Commit b3aea4ed authored by Christoph Hellwig's avatar Christoph Hellwig Committed by Tim Shimmin

[XFS] kill the v_flag member in struct bhv_vnode

All flags previously handled at the vnode level are not in the xfs_inode
where we already have a flags mechanisms and free bits for flags
previously in the vnode.

SGI-PV: 969608
SGI-Modid: xfs-linux-melb:xfs-kern:29495a
Signed-off-by: default avatarChristoph Hellwig <hch@infradead.org>
Signed-off-by: default avatarDavid Chinner <dgc@sgi.com>
Signed-off-by: default avatarTim Shimmin <tes@sgi.com>
parent 2f6f7b3d
...@@ -304,13 +304,13 @@ xfs_map_blocks( ...@@ -304,13 +304,13 @@ xfs_map_blocks(
xfs_iomap_t *mapp, xfs_iomap_t *mapp,
int flags) int flags)
{ {
bhv_vnode_t *vp = vn_from_inode(inode); xfs_inode_t *ip = XFS_I(inode);
int error, nmaps = 1; int error, nmaps = 1;
error = xfs_bmap(xfs_vtoi(vp), offset, count, error = xfs_bmap(ip, offset, count,
flags, mapp, &nmaps); flags, mapp, &nmaps);
if (!error && (flags & (BMAPI_WRITE|BMAPI_ALLOCATE))) if (!error && (flags & (BMAPI_WRITE|BMAPI_ALLOCATE)))
VMODIFY(vp); xfs_iflags_set(ip, XFS_IMODIFIED);
return -error; return -error;
} }
...@@ -1246,10 +1246,7 @@ xfs_vm_writepages( ...@@ -1246,10 +1246,7 @@ xfs_vm_writepages(
struct address_space *mapping, struct address_space *mapping,
struct writeback_control *wbc) struct writeback_control *wbc)
{ {
struct bhv_vnode *vp = vn_from_inode(mapping->host); xfs_iflags_clear(XFS_I(mapping->host), XFS_ITRUNCATED);
if (VN_TRUNC(vp))
VUNTRUNCATE(vp);
return generic_writepages(mapping, wbc); return generic_writepages(mapping, wbc);
} }
......
...@@ -193,13 +193,11 @@ xfs_file_fsync( ...@@ -193,13 +193,11 @@ xfs_file_fsync(
struct dentry *dentry, struct dentry *dentry,
int datasync) int datasync)
{ {
bhv_vnode_t *vp = vn_from_inode(dentry->d_inode);
int flags = FSYNC_WAIT; int flags = FSYNC_WAIT;
if (datasync) if (datasync)
flags |= FSYNC_DATA; flags |= FSYNC_DATA;
if (VN_TRUNC(vp)) xfs_iflags_clear(XFS_I(dentry->d_inode), XFS_ITRUNCATED);
VUNTRUNCATE(vp);
return -xfs_fsync(XFS_I(dentry->d_inode), flags, return -xfs_fsync(XFS_I(dentry->d_inode), flags,
(xfs_off_t)0, (xfs_off_t)-1); (xfs_off_t)0, (xfs_off_t)-1);
} }
...@@ -277,10 +275,9 @@ xfs_file_ioctl( ...@@ -277,10 +275,9 @@ xfs_file_ioctl(
{ {
int error; int error;
struct inode *inode = filp->f_path.dentry->d_inode; struct inode *inode = filp->f_path.dentry->d_inode;
bhv_vnode_t *vp = vn_from_inode(inode);
error = xfs_ioctl(XFS_I(inode), filp, 0, cmd, (void __user *)p); error = xfs_ioctl(XFS_I(inode), filp, 0, cmd, (void __user *)p);
VMODIFY(vp); xfs_iflags_set(XFS_I(inode), XFS_IMODIFIED);
/* NOTE: some of the ioctl's return positive #'s as a /* NOTE: some of the ioctl's return positive #'s as a
* byte count indicating success, such as * byte count indicating success, such as
...@@ -299,10 +296,9 @@ xfs_file_ioctl_invis( ...@@ -299,10 +296,9 @@ xfs_file_ioctl_invis(
{ {
int error; int error;
struct inode *inode = filp->f_path.dentry->d_inode; struct inode *inode = filp->f_path.dentry->d_inode;
bhv_vnode_t *vp = vn_from_inode(inode);
error = xfs_ioctl(XFS_I(inode), filp, IO_INVIS, cmd, (void __user *)p); error = xfs_ioctl(XFS_I(inode), filp, IO_INVIS, cmd, (void __user *)p);
VMODIFY(vp); xfs_iflags_set(XFS_I(inode), XFS_IMODIFIED);
/* NOTE: some of the ioctl's return positive #'s as a /* NOTE: some of the ioctl's return positive #'s as a
* byte count indicating success, such as * byte count indicating success, such as
......
...@@ -61,8 +61,7 @@ xfs_flushinval_pages( ...@@ -61,8 +61,7 @@ xfs_flushinval_pages(
int ret = 0; int ret = 0;
if (VN_CACHED(vp)) { if (VN_CACHED(vp)) {
if (VN_TRUNC(vp)) xfs_iflags_clear(ip, XFS_ITRUNCATED);
VUNTRUNCATE(vp);
ret = filemap_write_and_wait(inode->i_mapping); ret = filemap_write_and_wait(inode->i_mapping);
if (!ret) if (!ret)
truncate_inode_pages(inode->i_mapping, first); truncate_inode_pages(inode->i_mapping, first);
...@@ -84,8 +83,7 @@ xfs_flush_pages( ...@@ -84,8 +83,7 @@ xfs_flush_pages(
int ret2; int ret2;
if (VN_DIRTY(vp)) { if (VN_DIRTY(vp)) {
if (VN_TRUNC(vp)) xfs_iflags_clear(ip, XFS_ITRUNCATED);
VUNTRUNCATE(vp);
ret = filemap_fdatawrite(inode->i_mapping); ret = filemap_fdatawrite(inode->i_mapping);
if (flags & XFS_B_ASYNC) if (flags & XFS_B_ASYNC)
return ret; return ret;
......
...@@ -371,7 +371,6 @@ xfs_compat_ioctl( ...@@ -371,7 +371,6 @@ xfs_compat_ioctl(
unsigned long arg) unsigned long arg)
{ {
struct inode *inode = file->f_path.dentry->d_inode; struct inode *inode = file->f_path.dentry->d_inode;
bhv_vnode_t *vp = vn_from_inode(inode);
int error; int error;
switch (cmd) { switch (cmd) {
...@@ -459,7 +458,7 @@ xfs_compat_ioctl( ...@@ -459,7 +458,7 @@ xfs_compat_ioctl(
} }
error = xfs_ioctl(XFS_I(inode), file, mode, cmd, (void __user *)arg); error = xfs_ioctl(XFS_I(inode), file, mode, cmd, (void __user *)arg);
VMODIFY(vp); xfs_iflags_set(XFS_I(inode), XFS_IMODIFIED);
return error; return error;
} }
......
...@@ -221,7 +221,7 @@ xfs_init_security( ...@@ -221,7 +221,7 @@ xfs_init_security(
error = xfs_attr_set(XFS_I(ip), name, value, error = xfs_attr_set(XFS_I(ip), name, value,
length, ATTR_SECURE); length, ATTR_SECURE);
if (!error) if (!error)
VMODIFY(vp); xfs_iflags_set(XFS_I(ip), XFS_IMODIFIED);
kfree(name); kfree(name);
kfree(value); kfree(value);
...@@ -327,7 +327,7 @@ xfs_vn_mknod( ...@@ -327,7 +327,7 @@ xfs_vn_mknod(
if (!error) { if (!error) {
error = _ACL_INHERIT(vp, &vattr, default_acl); error = _ACL_INHERIT(vp, &vattr, default_acl);
if (!error) if (!error)
VMODIFY(vp); xfs_iflags_set(XFS_I(&vp->v_inode), XFS_IMODIFIED);
else else
xfs_cleanup_inode(dir, vp, dentry, mode); xfs_cleanup_inode(dir, vp, dentry, mode);
} }
...@@ -409,7 +409,7 @@ xfs_vn_link( ...@@ -409,7 +409,7 @@ xfs_vn_link(
if (unlikely(error)) { if (unlikely(error)) {
VN_RELE(vp); VN_RELE(vp);
} else { } else {
VMODIFY(vn_from_inode(dir)); xfs_iflags_set(XFS_I(dir), XFS_IMODIFIED);
xfs_validate_fields(ip, &vattr); xfs_validate_fields(ip, &vattr);
d_instantiate(dentry, ip); d_instantiate(dentry, ip);
} }
......
...@@ -197,7 +197,7 @@ xfs_revalidate_inode( ...@@ -197,7 +197,7 @@ xfs_revalidate_inode(
inode->i_flags |= S_NOATIME; inode->i_flags |= S_NOATIME;
else else
inode->i_flags &= ~S_NOATIME; inode->i_flags &= ~S_NOATIME;
vp->v_flag &= ~VMODIFIED; xfs_iflags_clear(ip, XFS_IMODIFIED);
} }
void void
...@@ -441,13 +441,12 @@ xfs_fs_clear_inode( ...@@ -441,13 +441,12 @@ xfs_fs_clear_inode(
if (XFS_I(inode)) if (XFS_I(inode))
xfs_inactive(XFS_I(inode)); xfs_inactive(XFS_I(inode));
VN_LOCK(vp);
vp->v_flag &= ~VMODIFIED;
VN_UNLOCK(vp, 0);
if (XFS_I(inode)) if (XFS_I(inode)) {
xfs_iflags_clear(XFS_I(inode), XFS_IMODIFIED);
if (xfs_reclaim(XFS_I(inode))) if (xfs_reclaim(XFS_I(inode)))
panic("%s: cannot reclaim 0x%p\n", __FUNCTION__, vp); panic("%s: cannot reclaim 0x%p\n", __FUNCTION__, vp);
}
ASSERT(XFS_I(inode) == NULL); ASSERT(XFS_I(inode) == NULL);
......
...@@ -84,9 +84,6 @@ vn_initialize( ...@@ -84,9 +84,6 @@ vn_initialize(
XFS_STATS_INC(vn_active); XFS_STATS_INC(vn_active);
XFS_STATS_INC(vn_alloc); XFS_STATS_INC(vn_alloc);
vp->v_flag = VMODIFIED;
spinlock_init(&vp->v_lock, "v_lock");
spin_lock(&vnumber_lock); spin_lock(&vnumber_lock);
if (!++vn_generation) /* v_number shouldn't be zero */ if (!++vn_generation) /* v_number shouldn't be zero */
vn_generation++; vn_generation++;
...@@ -157,7 +154,7 @@ __vn_revalidate( ...@@ -157,7 +154,7 @@ __vn_revalidate(
error = xfs_getattr(xfs_vtoi(vp), vattr, 0); error = xfs_getattr(xfs_vtoi(vp), vattr, 0);
if (likely(!error)) { if (likely(!error)) {
vn_revalidate_core(vp, vattr); vn_revalidate_core(vp, vattr);
VUNMODIFY(vp); xfs_iflags_clear(xfs_vtoi(vp), XFS_IMODIFIED);
} }
return -error; return -error;
} }
...@@ -182,10 +179,8 @@ vn_hold( ...@@ -182,10 +179,8 @@ vn_hold(
XFS_STATS_INC(vn_hold); XFS_STATS_INC(vn_hold);
VN_LOCK(vp);
inode = igrab(vn_to_inode(vp)); inode = igrab(vn_to_inode(vp));
ASSERT(inode); ASSERT(inode);
VN_UNLOCK(vp, 0);
return vp; return vp;
} }
...@@ -199,7 +194,7 @@ vn_hold( ...@@ -199,7 +194,7 @@ vn_hold(
/* 2 */ (void *)(__psint_t) line, \ /* 2 */ (void *)(__psint_t) line, \
/* 3 */ (void *)(__psint_t)(vn_count(vp)), \ /* 3 */ (void *)(__psint_t)(vn_count(vp)), \
/* 4 */ (void *)(ra), \ /* 4 */ (void *)(ra), \
/* 5 */ (void *)(__psunsigned_t)(vp)->v_flag, \ /* 5 */ NULL, \
/* 6 */ (void *)(__psint_t)current_cpu(), \ /* 6 */ (void *)(__psint_t)current_cpu(), \
/* 7 */ (void *)(__psint_t)current_pid(), \ /* 7 */ (void *)(__psint_t)current_pid(), \
/* 8 */ (void *)__return_address, \ /* 8 */ (void *)__return_address, \
......
...@@ -27,20 +27,8 @@ struct attrlist_cursor_kern; ...@@ -27,20 +27,8 @@ struct attrlist_cursor_kern;
typedef struct dentry bhv_vname_t; typedef struct dentry bhv_vname_t;
typedef __u64 bhv_vnumber_t; typedef __u64 bhv_vnumber_t;
typedef enum bhv_vflags {
VMODIFIED = 0x08, /* XFS inode state possibly differs */
/* to the Linux inode state. */
VTRUNCATED = 0x40, /* truncated down so flush-on-close */
} bhv_vflags_t;
/*
* MP locking protocols:
* v_flag, VN_LOCK/VN_UNLOCK
*/
typedef struct bhv_vnode { typedef struct bhv_vnode {
bhv_vflags_t v_flag; /* vnode flags (see above) */
bhv_vnumber_t v_number; /* in-core vnode number */ bhv_vnumber_t v_number; /* in-core vnode number */
spinlock_t v_lock; /* VN_LOCK/VN_UNLOCK */
atomic_t v_iocount; /* outstanding I/O count */ atomic_t v_iocount; /* outstanding I/O count */
#ifdef XFS_VNODE_TRACE #ifdef XFS_VNODE_TRACE
struct ktrace *v_trace; /* trace header structure */ struct ktrace *v_trace; /* trace header structure */
...@@ -254,35 +242,6 @@ static inline struct bhv_vnode *vn_grab(struct bhv_vnode *vp) ...@@ -254,35 +242,6 @@ static inline struct bhv_vnode *vn_grab(struct bhv_vnode *vp)
#define VNAMELEN(dentry) ((dentry)->d_name.len) #define VNAMELEN(dentry) ((dentry)->d_name.len)
#define VNAME_TO_VNODE(dentry) (vn_from_inode((dentry)->d_inode)) #define VNAME_TO_VNODE(dentry) (vn_from_inode((dentry)->d_inode))
/*
* Vnode spinlock manipulation.
*/
#define VN_LOCK(vp) mutex_spinlock(&(vp)->v_lock)
#define VN_UNLOCK(vp, s) mutex_spinunlock(&(vp)->v_lock, s)
STATIC_INLINE void vn_flagset(struct bhv_vnode *vp, uint flag)
{
spin_lock(&vp->v_lock);
vp->v_flag |= flag;
spin_unlock(&vp->v_lock);
}
STATIC_INLINE uint vn_flagclr(struct bhv_vnode *vp, uint flag)
{
uint cleared;
spin_lock(&vp->v_lock);
cleared = (vp->v_flag & flag);
vp->v_flag &= ~flag;
spin_unlock(&vp->v_lock);
return cleared;
}
#define VMODIFY(vp) vn_flagset(vp, VMODIFIED)
#define VUNMODIFY(vp) vn_flagclr(vp, VMODIFIED)
#define VTRUNCATE(vp) vn_flagset(vp, VTRUNCATED)
#define VUNTRUNCATE(vp) vn_flagclr(vp, VTRUNCATED)
/* /*
* Dealing with bad inodes * Dealing with bad inodes
*/ */
...@@ -322,7 +281,6 @@ static inline void vn_atime_to_time_t(bhv_vnode_t *vp, time_t *tt) ...@@ -322,7 +281,6 @@ static inline void vn_atime_to_time_t(bhv_vnode_t *vp, time_t *tt)
#define VN_CACHED(vp) (vn_to_inode(vp)->i_mapping->nrpages) #define VN_CACHED(vp) (vn_to_inode(vp)->i_mapping->nrpages)
#define VN_DIRTY(vp) mapping_tagged(vn_to_inode(vp)->i_mapping, \ #define VN_DIRTY(vp) mapping_tagged(vn_to_inode(vp)->i_mapping, \
PAGECACHE_TAG_DIRTY) PAGECACHE_TAG_DIRTY)
#define VN_TRUNC(vp) ((vp)->v_flag & VTRUNCATED)
/* /*
* Flags to vop_setattr/getattr. * Flags to vop_setattr/getattr.
......
...@@ -336,6 +336,7 @@ xfs_iget_core( ...@@ -336,6 +336,7 @@ xfs_iget_core(
ASSERT(((ip->i_d.di_flags & XFS_DIFLAG_REALTIME) != 0) == ASSERT(((ip->i_d.di_flags & XFS_DIFLAG_REALTIME) != 0) ==
((ip->i_iocore.io_flags & XFS_IOCORE_RT) != 0)); ((ip->i_iocore.io_flags & XFS_IOCORE_RT) != 0));
xfs_iflags_set(ip, XFS_IMODIFIED);
*ipp = ip; *ipp = ip;
/* /*
......
...@@ -391,6 +391,9 @@ xfs_iflags_test(xfs_inode_t *ip, unsigned short flags) ...@@ -391,6 +391,9 @@ xfs_iflags_test(xfs_inode_t *ip, unsigned short flags)
#define XFS_IRECLAIMABLE 0x0020 /* inode can be reclaimed */ #define XFS_IRECLAIMABLE 0x0020 /* inode can be reclaimed */
#define XFS_INEW 0x0040 #define XFS_INEW 0x0040
#define XFS_IFILESTREAM 0x0080 /* inode is in a filestream directory */ #define XFS_IFILESTREAM 0x0080 /* inode is in a filestream directory */
#define XFS_IMODIFIED 0x0100 /* XFS inode state possibly differs */
/* to the Linux inode state. */
#define XFS_ITRUNCATED 0x0200 /* truncated down so flush-on-close */
/* /*
* Flags for inode locking. * Flags for inode locking.
......
...@@ -660,7 +660,7 @@ xfs_setattr( ...@@ -660,7 +660,7 @@ xfs_setattr(
* vnode and flush it when the file is closed, and * vnode and flush it when the file is closed, and
* do not wait the usual (long) time for writeout. * do not wait the usual (long) time for writeout.
*/ */
VTRUNCATE(vp); xfs_iflags_set(ip, XFS_ITRUNCATED);
} }
/* /*
* Have to do this even if the file's size doesn't change. * Have to do this even if the file's size doesn't change.
...@@ -1519,6 +1519,8 @@ xfs_release( ...@@ -1519,6 +1519,8 @@ xfs_release(
return 0; return 0;
if (!XFS_FORCED_SHUTDOWN(mp)) { if (!XFS_FORCED_SHUTDOWN(mp)) {
int truncated;
/* /*
* If we are using filestreams, and we have an unlinked * If we are using filestreams, and we have an unlinked
* file that we are processing the last close on, then nothing * file that we are processing the last close on, then nothing
...@@ -1539,7 +1541,13 @@ xfs_release( ...@@ -1539,7 +1541,13 @@ xfs_release(
* significantly reducing the time window where we'd otherwise * significantly reducing the time window where we'd otherwise
* be exposed to that problem. * be exposed to that problem.
*/ */
if (VUNTRUNCATE(vp) && VN_DIRTY(vp) && ip->i_delayed_blks > 0) spin_lock(&ip->i_flags_lock);
truncated = __xfs_iflags_test(ip, XFS_ITRUNCATED);
if (truncated)
ip->i_flags &= ~XFS_ITRUNCATED;
spin_unlock(&ip->i_flags_lock);
if (truncated && VN_DIRTY(vp) && ip->i_delayed_blks > 0)
xfs_flush_pages(ip, 0, -1, XFS_B_ASYNC, FI_NONE); xfs_flush_pages(ip, 0, -1, XFS_B_ASYNC, FI_NONE);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment