[PATCH] vfs: shrink_dcache_parent on rmdir, dir rename only on success

From: Sage Weil
Date: Tue May 31 2011 - 12:26:13 EST


Only prune the dentries of the rmdir or dir rename succeeds. Doing so on
failure makes no sense (though it's mostly harmless).

Signed-off-by: Sage Weil <sage@xxxxxxxxxxxx>
---
fs/namei.c | 5 ++---
1 files changed, 2 insertions(+), 3 deletions(-)

diff --git a/fs/namei.c b/fs/namei.c
index e2e4e8d..72b0370 100644
--- a/fs/namei.c
+++ b/fs/namei.c
@@ -2579,11 +2579,11 @@ int vfs_rmdir(struct inode *dir, struct dentry *dentry)
if (error)
goto out;

- shrink_dcache_parent(dentry);
error = dir->i_op->rmdir(dir, dentry);
if (error)
goto out;

+ shrink_dcache_parent(dentry);
dentry->d_inode->i_flags |= S_DEAD;
dont_mount(dentry);

@@ -2994,13 +2994,12 @@ static int vfs_rename_dir(struct inode *old_dir, struct dentry *old_dentry,
if (d_mountpoint(old_dentry) || d_mountpoint(new_dentry))
goto out;

- if (target)
- shrink_dcache_parent(new_dentry);
error = old_dir->i_op->rename(old_dir, old_dentry, new_dir, new_dentry);
if (error)
goto out;

if (target) {
+ shrink_dcache_parent(new_dentry);
target->i_flags |= S_DEAD;
dont_mount(new_dentry);
}
--
1.7.0

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/