Unionfs: minor code rearrangement in rename
authorErez Zadok <ezk@cs.sunysb.edu>
Thu, 10 Jan 2008 12:11:04 +0000 (07:11 -0500)
committerRachita Kothiyal <rachita@dewey.fsl.cs.sunysb.edu>
Thu, 1 May 2008 23:03:32 +0000 (19:03 -0400)
To avoid too much code nesting.

Signed-off-by: Erez Zadok <ezk@cs.sunysb.edu>
fs/unionfs/rename.c

index 0b3d94df4b450c343e278c2e715045660c5c7b63..05867f4beaaab20ffcf1bfe483f245431e1a6d17 100644 (file)
@@ -415,57 +415,54 @@ int unionfs_rename(struct inode *old_dir, struct dentry *old_dentry,
                                goto out;
                }
        }
+
        err = do_unionfs_rename(old_dir, old_dentry, new_dir, new_dentry);
-out:
-       if (err) {
-               /* clear the new_dentry stuff created */
-               d_drop(new_dentry);
-       } else {
-               /*
-                * force re-lookup since the dir on ro branch is not renamed,
-                * and lower dentries still indicate the un-renamed ones.
-                */
-               if (S_ISDIR(old_dentry->d_inode->i_mode))
-                       atomic_dec(&UNIONFS_D(old_dentry)->generation);
-               else
-                       unionfs_postcopyup_release(old_dentry);
-
-               /*
-                * If the dentry already existed before the rename and is
-                * not used by anyone else, we must purge its lower
-                * pointers, since it might remain in the cache for a while
-                * and the odf might give the same inode number to a new
-                * inode, so we don't want the new inode to have the old
-                * inode's pointers.
-                *
-                * If its i_count >= 2 we must not modify its lower
-                * pointers.  The odf will silly rename this inode so it
-                * doesn't give it to another inode
-                */
-               if (new_dentry->d_inode &&
-                   atomic_read(&new_dentry->d_inode->i_count) < 2) {
-                       int bindex;
-                       struct inode *i = new_dentry->d_inode;
-                       for (bindex = ibstart(i);
-                            bindex <= ibend(i);
-                            bindex++) {
-                               if (unionfs_lower_inode_idx(i, bindex))
-                                       iput(unionfs_lower_inode_idx(i,
-                                                                    bindex));
-                               unionfs_set_lower_inode_idx(i, bindex, NULL);
-                       }
-               }
+       if (err)
+               goto out;
+       /*
+        * force re-lookup since the dir on ro branch is not renamed, and
+        * lower dentries still indicate the un-renamed ones.
+        */
+       if (S_ISDIR(old_dentry->d_inode->i_mode))
+               atomic_dec(&UNIONFS_D(old_dentry)->generation);
+       else
+               unionfs_postcopyup_release(old_dentry);
 
-               /* if all of this renaming succeeded, update our times */
-               unionfs_copy_attr_times(old_dir);
-               unionfs_copy_attr_times(new_dir);
-               unionfs_copy_attr_times(old_dentry->d_inode);
-               unionfs_copy_attr_times(new_dentry->d_inode);
-               unionfs_check_inode(old_dir);
-               unionfs_check_inode(new_dir);
-               unionfs_check_dentry(old_dentry);
+       /*
+        * If the dentry already existed before the rename and is not used
+        * by anyone else, we must purge its lower pointers, since it might
+        * remain in the cache for a while and the odf might give the same
+        * inode number to a new inode, so we don't want the new inode to
+        * have the old inode's pointers.
+        *
+        * If its i_count >= 2 we must not modify its lower pointers.
+        * The odf will silly rename this inode so it doesn't give it to
+        * another inode
+        */
+       if (new_dentry->d_inode &&
+           atomic_read(&new_dentry->d_inode->i_count) < 2) {
+               int bindex;
+               struct inode *i = new_dentry->d_inode;
+               for (bindex = ibstart(i); bindex <= ibend(i); bindex++) {
+                       if (unionfs_lower_inode_idx(i, bindex))
+                               iput(unionfs_lower_inode_idx(i, bindex));
+                       unionfs_set_lower_inode_idx(i, bindex, NULL);
+               }
        }
 
+       /* if all of this renaming succeeded, update our times */
+       unionfs_copy_attr_times(old_dir);
+       unionfs_copy_attr_times(new_dir);
+       unionfs_copy_attr_times(old_dentry->d_inode);
+       unionfs_copy_attr_times(new_dentry->d_inode);
+       unionfs_check_inode(old_dir);
+       unionfs_check_inode(new_dir);
+       unionfs_check_dentry(old_dentry);
+       unionfs_check_dentry(new_dentry);
+
+out:
+       if (err)                /* clear the new_dentry stuff created */
+               d_drop(new_dentry);
        unionfs_unlock_dentry(new_dentry);
        unionfs_unlock_dentry(old_dentry);
        unionfs_read_unlock(old_dentry->d_sb);