From dfd6fb3fcc0416825c019b9de35b662c95d3f2c7 Mon Sep 17 00:00:00 2001 From: Erez Zadok Date: Mon, 28 Jul 2008 00:25:46 -0400 Subject: [PATCH] Unionfs: move a rename helper closer to rename code Signed-off-by: Erez Zadok --- fs/unionfs/rename.c | 42 ++++++++++++++++++++++++++++++++++++++++++ fs/unionfs/subr.c | 42 ------------------------------------------ fs/unionfs/union.h | 3 --- 3 files changed, 42 insertions(+), 45 deletions(-) diff --git a/fs/unionfs/rename.c b/fs/unionfs/rename.c index fe8d877104e..5b3f1a3a972 100644 --- a/fs/unionfs/rename.c +++ b/fs/unionfs/rename.c @@ -18,6 +18,48 @@ #include "union.h" +/* + * This is a helper function for rename, used when rename ends up with hosed + * over dentries and we need to revert. + */ +static int unionfs_refresh_lower_dentry(struct dentry *dentry, int bindex) +{ + struct dentry *lower_dentry; + struct dentry *lower_parent; + int err = 0; + + verify_locked(dentry); + + unionfs_lock_dentry(dentry->d_parent, UNIONFS_DMUTEX_CHILD); + lower_parent = unionfs_lower_dentry_idx(dentry->d_parent, bindex); + unionfs_unlock_dentry(dentry->d_parent); + + BUG_ON(!S_ISDIR(lower_parent->d_inode->i_mode)); + + lower_dentry = lookup_one_len(dentry->d_name.name, lower_parent, + dentry->d_name.len); + if (IS_ERR(lower_dentry)) { + err = PTR_ERR(lower_dentry); + goto out; + } + + dput(unionfs_lower_dentry_idx(dentry, bindex)); + iput(unionfs_lower_inode_idx(dentry->d_inode, bindex)); + unionfs_set_lower_inode_idx(dentry->d_inode, bindex, NULL); + + if (!lower_dentry->d_inode) { + dput(lower_dentry); + unionfs_set_lower_dentry_idx(dentry, bindex, NULL); + } else { + unionfs_set_lower_dentry_idx(dentry, bindex, lower_dentry); + unionfs_set_lower_inode_idx(dentry->d_inode, bindex, + igrab(lower_dentry->d_inode)); + } + +out: + return err; +} + static int __unionfs_rename(struct inode *old_dir, struct dentry *old_dentry, struct inode *new_dir, struct dentry *new_dentry, int bindex, struct dentry **wh_old) diff --git a/fs/unionfs/subr.c b/fs/unionfs/subr.c index b76fa7aa00c..1f1db3d0500 100644 --- a/fs/unionfs/subr.c +++ b/fs/unionfs/subr.c @@ -114,48 +114,6 @@ out: return err; } -/* - * This is a helper function for rename, which ends up with hosed over - * dentries when it needs to revert. - */ -int unionfs_refresh_lower_dentry(struct dentry *dentry, int bindex) -{ - struct dentry *lower_dentry; - struct dentry *lower_parent; - int err = 0; - - verify_locked(dentry); - - unionfs_lock_dentry(dentry->d_parent, UNIONFS_DMUTEX_CHILD); - lower_parent = unionfs_lower_dentry_idx(dentry->d_parent, bindex); - unionfs_unlock_dentry(dentry->d_parent); - - BUG_ON(!S_ISDIR(lower_parent->d_inode->i_mode)); - - lower_dentry = lookup_one_len(dentry->d_name.name, lower_parent, - dentry->d_name.len); - if (IS_ERR(lower_dentry)) { - err = PTR_ERR(lower_dentry); - goto out; - } - - dput(unionfs_lower_dentry_idx(dentry, bindex)); - iput(unionfs_lower_inode_idx(dentry->d_inode, bindex)); - unionfs_set_lower_inode_idx(dentry->d_inode, bindex, NULL); - - if (!lower_dentry->d_inode) { - dput(lower_dentry); - unionfs_set_lower_dentry_idx(dentry, bindex, NULL); - } else { - unionfs_set_lower_dentry_idx(dentry, bindex, lower_dentry); - unionfs_set_lower_inode_idx(dentry->d_inode, bindex, - igrab(lower_dentry->d_inode)); - } - -out: - return err; -} - int make_dir_opaque(struct dentry *dentry, int bindex) { int err = 0; diff --git a/fs/unionfs/union.h b/fs/unionfs/union.h index 7420cb07d41..9520a00e9a3 100644 --- a/fs/unionfs/union.h +++ b/fs/unionfs/union.h @@ -353,9 +353,6 @@ extern int check_empty(struct dentry *dentry, extern int delete_whiteouts(struct dentry *dentry, int bindex, struct unionfs_dir_state *namelist); -/* Re-lookup a lower dentry. */ -extern int unionfs_refresh_lower_dentry(struct dentry *dentry, int bindex); - extern void unionfs_reinterpose(struct dentry *this_dentry); extern struct super_block *unionfs_duplicate_super(struct super_block *sb); -- 2.34.1