提交 e5700704 编写于 作者: C Christoph Hellwig 提交者: Niv Sardi

[XFS] Don't update i_size for directories and special files

The core kernel uses vfs_getattr to look at the inode size and similar
attributes, so there is no need to keep i_size uptodate for directories or
special files. This means we can remove xfs_validate_fields because the
I/O path already keeps i_size uptodate for regular files.

SGI-PV: 981498

SGI-Modid: xfs-linux-melb:xfs-kern:31336a
Signed-off-by: NChristoph Hellwig <hch@infradead.org>
Signed-off-by: NBarry Naujok <bnaujok@sgi.com>
Signed-off-by: NLachlan McIlroy <lachlan@sgi.com>
上级 8f112e3b
...@@ -181,23 +181,6 @@ xfs_ichgtime_fast( ...@@ -181,23 +181,6 @@ xfs_ichgtime_fast(
mark_inode_dirty_sync(inode); mark_inode_dirty_sync(inode);
} }
/*
* Pull the link count and size up from the xfs inode to the linux inode
*/
STATIC void
xfs_validate_fields(
struct inode *inode)
{
struct xfs_inode *ip = XFS_I(inode);
loff_t size;
/* we're under i_sem so i_size can't change under us */
size = XFS_ISIZE(ip);
if (i_size_read(inode) != size)
i_size_write(inode, size);
}
/* /*
* Hook in SELinux. This is not quite correct yet, what we really need * Hook in SELinux. This is not quite correct yet, what we really need
* here (as we do for default ACLs) is a mechanism by which creation of * here (as we do for default ACLs) is a mechanism by which creation of
...@@ -331,10 +314,7 @@ xfs_vn_mknod( ...@@ -331,10 +314,7 @@ xfs_vn_mknod(
} }
if (S_ISDIR(mode))
xfs_validate_fields(inode);
d_instantiate(dentry, inode); d_instantiate(dentry, inode);
xfs_validate_fields(dir);
return -error; return -error;
out_cleanup_inode: out_cleanup_inode:
...@@ -450,7 +430,6 @@ xfs_vn_link( ...@@ -450,7 +430,6 @@ xfs_vn_link(
} }
xfs_iflags_set(XFS_I(dir), XFS_IMODIFIED); xfs_iflags_set(XFS_I(dir), XFS_IMODIFIED);
xfs_validate_fields(inode);
d_instantiate(dentry, inode); d_instantiate(dentry, inode);
return 0; return 0;
} }
...@@ -460,17 +439,15 @@ xfs_vn_unlink( ...@@ -460,17 +439,15 @@ xfs_vn_unlink(
struct inode *dir, struct inode *dir,
struct dentry *dentry) struct dentry *dentry)
{ {
struct inode *inode;
struct xfs_name name; struct xfs_name name;
int error; int error;
inode = dentry->d_inode;
xfs_dentry_to_name(&name, dentry); xfs_dentry_to_name(&name, dentry);
error = xfs_remove(XFS_I(dir), &name, XFS_I(inode)); error = -xfs_remove(XFS_I(dir), &name, XFS_I(dentry->d_inode));
if (likely(!error)) { if (error)
xfs_validate_fields(dir); /* size needs update */ return error;
xfs_validate_fields(inode);
/* /*
* With unlink, the VFS makes the dentry "negative": no inode, * With unlink, the VFS makes the dentry "negative": no inode,
* but still hashed. This is incompatible with case-insensitive * but still hashed. This is incompatible with case-insensitive
...@@ -478,8 +455,7 @@ xfs_vn_unlink( ...@@ -478,8 +455,7 @@ xfs_vn_unlink(
*/ */
if (xfs_sb_version_hasasciici(&XFS_M(dir->i_sb)->m_sb)) if (xfs_sb_version_hasasciici(&XFS_M(dir->i_sb)->m_sb))
d_invalidate(dentry); d_invalidate(dentry);
} return 0;
return -error;
} }
STATIC int STATIC int
...@@ -509,8 +485,6 @@ xfs_vn_symlink( ...@@ -509,8 +485,6 @@ xfs_vn_symlink(
goto out_cleanup_inode; goto out_cleanup_inode;
d_instantiate(dentry, inode); d_instantiate(dentry, inode);
xfs_validate_fields(dir);
xfs_validate_fields(inode);
return 0; return 0;
out_cleanup_inode: out_cleanup_inode:
...@@ -529,22 +503,13 @@ xfs_vn_rename( ...@@ -529,22 +503,13 @@ xfs_vn_rename(
struct inode *new_inode = ndentry->d_inode; struct inode *new_inode = ndentry->d_inode;
struct xfs_name oname; struct xfs_name oname;
struct xfs_name nname; struct xfs_name nname;
int error;
xfs_dentry_to_name(&oname, odentry); xfs_dentry_to_name(&oname, odentry);
xfs_dentry_to_name(&nname, ndentry); xfs_dentry_to_name(&nname, ndentry);
error = xfs_rename(XFS_I(odir), &oname, XFS_I(odentry->d_inode), return -xfs_rename(XFS_I(odir), &oname, XFS_I(odentry->d_inode),
XFS_I(ndir), &nname, new_inode ? XFS_I(ndir), &nname, new_inode ?
XFS_I(new_inode) : NULL); XFS_I(new_inode) : NULL);
if (likely(!error)) {
if (new_inode)
xfs_validate_fields(new_inode);
xfs_validate_fields(odir);
if (ndir != odir)
xfs_validate_fields(ndir);
}
return -error;
} }
/* /*
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册