Unionfs: move a rename helper closer to rename code
authorErez Zadok <ezk@cs.sunysb.edu>
Mon, 28 Jul 2008 03:23:49 +0000 (23:23 -0400)
committerErez Zadok <ezk@cs.sunysb.edu>
Mon, 28 Jul 2008 03:23:49 +0000 (23:23 -0400)
Signed-off-by: Erez Zadok <ezk@cs.sunysb.edu>
fs/unionfs/rename.c
fs/unionfs/subr.c
fs/unionfs/union.h

index 3389dcfd2bb35f58c48b10dbcb47b4ba972439b2..0a2ac48ceefd71428c676a8565fdd07c54d88f6b 100644 (file)
 
 #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)
index f9508f2f28b54b5738484e766e596457a02201b8..c3234514fa34c1626e201e7965f2ae68a8774ed5 100644 (file)
@@ -109,48 +109,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;
index f6c4b963acd8c85d6834dcd1dd76029882e9c884..d5c85099327e45c07b1d7791d6e6fbabc533efb2 100644 (file)
@@ -360,9 +360,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);