提交 21a62542 编写于 作者: C Christoph Hellwig 提交者: Lachlan McIlroy

[XFS] simplify vn_revalidate

No need to allocate a bhv_vattr_t on stack and call xfs_getattr to update
a few fields in the Linux inode from the XFS inode, just do it directly.

And yes, this function is in dire need of a better name and prototype,
I'll do in a separate patch, though.

SGI-PV: 970705
SGI-Modid: xfs-linux-melb:xfs-kern:29713a
Signed-off-by: NChristoph Hellwig <hch@infradead.org>
Signed-off-by: NLachlan McIlroy <lachlan@sgi.com>
Signed-off-by: NTim Shimmin <tes@sgi.com>
上级 15947f2d
...@@ -1236,7 +1236,7 @@ xfs_ioc_xattr( ...@@ -1236,7 +1236,7 @@ xfs_ioc_xattr(
error = xfs_setattr(ip, vattr, attr_flags, NULL); error = xfs_setattr(ip, vattr, attr_flags, NULL);
if (likely(!error)) if (likely(!error))
__vn_revalidate(vp, vattr); /* update flags */ vn_revalidate(vp); /* update flags */
error = -error; error = -error;
break; break;
} }
...@@ -1271,7 +1271,7 @@ xfs_ioc_xattr( ...@@ -1271,7 +1271,7 @@ xfs_ioc_xattr(
error = xfs_setattr(ip, vattr, attr_flags, NULL); error = xfs_setattr(ip, vattr, attr_flags, NULL);
if (likely(!error)) if (likely(!error))
__vn_revalidate(vp, vattr); /* update flags */ vn_revalidate(vp); /* update flags */
error = -error; error = -error;
break; break;
} }
......
...@@ -636,7 +636,7 @@ xfs_vn_setattr( ...@@ -636,7 +636,7 @@ xfs_vn_setattr(
error = xfs_setattr(XFS_I(inode), &vattr, flags, NULL); error = xfs_setattr(XFS_I(inode), &vattr, flags, NULL);
if (likely(!error)) if (likely(!error))
__vn_revalidate(vn_from_inode(inode), &vattr); vn_revalidate(vn_from_inode(inode));
return -error; return -error;
} }
......
...@@ -97,69 +97,57 @@ vn_initialize( ...@@ -97,69 +97,57 @@ vn_initialize(
} }
/* /*
* Revalidate the Linux inode from the vattr. * Revalidate the Linux inode from the XFS inode.
* Note: i_size _not_ updated; we must hold the inode * Note: i_size _not_ updated; we must hold the inode
* semaphore when doing that - callers responsibility. * semaphore when doing that - callers responsibility.
*/ */
void int
vn_revalidate_core( vn_revalidate(
bhv_vnode_t *vp, bhv_vnode_t *vp)
bhv_vattr_t *vap)
{ {
struct inode *inode = vn_to_inode(vp); struct inode *inode = vn_to_inode(vp);
struct xfs_inode *ip = XFS_I(inode);
inode->i_mode = vap->va_mode; struct xfs_mount *mp = ip->i_mount;
inode->i_nlink = vap->va_nlink; unsigned long xflags;
inode->i_uid = vap->va_uid;
inode->i_gid = vap->va_gid; xfs_itrace_entry(ip);
inode->i_blocks = vap->va_nblocks;
inode->i_mtime = vap->va_mtime; if (XFS_FORCED_SHUTDOWN(mp))
inode->i_ctime = vap->va_ctime; return -EIO;
if (vap->va_xflags & XFS_XFLAG_IMMUTABLE)
xfs_ilock(ip, XFS_ILOCK_SHARED);
inode->i_mode = ip->i_d.di_mode;
inode->i_nlink = ip->i_d.di_nlink;
inode->i_uid = ip->i_d.di_uid;
inode->i_gid = ip->i_d.di_gid;
inode->i_blocks =
XFS_FSB_TO_BB(mp, ip->i_d.di_nblocks + ip->i_delayed_blks);
inode->i_mtime.tv_sec = ip->i_d.di_mtime.t_sec;
inode->i_mtime.tv_nsec = ip->i_d.di_mtime.t_nsec;
inode->i_ctime.tv_sec = ip->i_d.di_ctime.t_sec;
inode->i_ctime.tv_nsec = ip->i_d.di_ctime.t_nsec;
xflags = xfs_ip2xflags(ip);
if (xflags & XFS_XFLAG_IMMUTABLE)
inode->i_flags |= S_IMMUTABLE; inode->i_flags |= S_IMMUTABLE;
else else
inode->i_flags &= ~S_IMMUTABLE; inode->i_flags &= ~S_IMMUTABLE;
if (vap->va_xflags & XFS_XFLAG_APPEND) if (xflags & XFS_XFLAG_APPEND)
inode->i_flags |= S_APPEND; inode->i_flags |= S_APPEND;
else else
inode->i_flags &= ~S_APPEND; inode->i_flags &= ~S_APPEND;
if (vap->va_xflags & XFS_XFLAG_SYNC) if (xflags & XFS_XFLAG_SYNC)
inode->i_flags |= S_SYNC; inode->i_flags |= S_SYNC;
else else
inode->i_flags &= ~S_SYNC; inode->i_flags &= ~S_SYNC;
if (vap->va_xflags & XFS_XFLAG_NOATIME) if (xflags & XFS_XFLAG_NOATIME)
inode->i_flags |= S_NOATIME; inode->i_flags |= S_NOATIME;
else else
inode->i_flags &= ~S_NOATIME; inode->i_flags &= ~S_NOATIME;
} xfs_iunlock(ip, XFS_ILOCK_SHARED);
/*
* Revalidate the Linux inode from the vnode.
*/
int
__vn_revalidate(
bhv_vnode_t *vp,
bhv_vattr_t *vattr)
{
int error;
xfs_itrace_entry(xfs_vtoi(vp));
vattr->va_mask = XFS_AT_STAT | XFS_AT_XFLAGS;
error = xfs_getattr(xfs_vtoi(vp), vattr, 0);
if (likely(!error)) {
vn_revalidate_core(vp, vattr);
xfs_iflags_clear(xfs_vtoi(vp), XFS_IMODIFIED);
}
return -error;
}
int
vn_revalidate(
bhv_vnode_t *vp)
{
bhv_vattr_t vattr;
return __vn_revalidate(vp, &vattr); xfs_iflags_clear(ip, XFS_IMODIFIED);
return 0;
} }
/* /*
......
...@@ -189,8 +189,6 @@ typedef struct bhv_vattr { ...@@ -189,8 +189,6 @@ typedef struct bhv_vattr {
extern void vn_init(void); extern void vn_init(void);
extern bhv_vnode_t *vn_initialize(struct inode *); extern bhv_vnode_t *vn_initialize(struct inode *);
extern int vn_revalidate(bhv_vnode_t *); extern int vn_revalidate(bhv_vnode_t *);
extern int __vn_revalidate(bhv_vnode_t *, bhv_vattr_t *);
extern void vn_revalidate_core(bhv_vnode_t *, bhv_vattr_t *);
/* /*
* Yeah, these don't take vnode anymore at all, all this should be * Yeah, these don't take vnode anymore at all, all this should be
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册