cleanup: eliminate wrapper function copyup_dentry
authorErez Zadok <ezk@bigvaio.(none)>
Fri, 18 May 2007 07:27:02 +0000 (03:27 -0400)
committerErez_Zadok <ezk@cs.sunysb.edu>
Tue, 21 Aug 2007 22:39:02 +0000 (18:39 -0400)
Eliminate simple wrapper function copyup_dentry which trivially called
copyup_named_dentry with 2 more args derived from the caller.  Instead,
remove the wrapper, rename copyup_named_dentry to copyup_dentry, and make
everyone call copyup_dentry directly.  This clarifies the code a bit more
and saves a bit on stack space.

fs/unionfs/copyup.c
fs/unionfs/inode.c
fs/unionfs/rename.c
fs/unionfs/union.h

index 3a303d135981b3c073809826c53327d4d52ac755..fcdc124736a316e3f55887756038f6decb5e0116 100644 (file)
  */
 
 /* forward definitions */
-static int copyup_named_dentry(struct inode *dir, struct dentry *dentry,
-                              int bstart, int new_bindex, const char *name,
-                              int namelen, struct file **copyup_file,
-                              loff_t len);
 static struct dentry *create_parents_named(struct inode *dir,
                                           struct dentry *dentry,
                                           const char *name, int bindex);
@@ -128,15 +124,6 @@ static int copyup_permissions(struct super_block *sb,
        return err;
 }
 
-int copyup_dentry(struct inode *dir, struct dentry *dentry,
-                 int bstart, int new_bindex,
-                 struct file **copyup_file, loff_t len)
-{
-       return copyup_named_dentry(dir, dentry, bstart, new_bindex,
-                                  dentry->d_name.name,
-                                  dentry->d_name.len, copyup_file, len);
-}
-
 /*
  * create the new device/file/directory - use copyup_permission to copyup
  * times, and mode
@@ -347,10 +334,9 @@ static void __clear(struct dentry *dentry, struct dentry *old_hidden_dentry,
  * @copyup_file: the "struct file" to return (optional)
  * @len: how many bytes to copy-up?
  */
-static int copyup_named_dentry(struct inode *dir, struct dentry *dentry,
-                              int bstart, int new_bindex, const char *name,
-                              int namelen, struct file **copyup_file,
-                              loff_t len)
+int copyup_dentry(struct inode *dir, struct dentry *dentry, int bstart,
+                 int new_bindex, const char *name, int namelen,
+                 struct file **copyup_file, loff_t len)
 {
        struct dentry *new_hidden_dentry;
        struct dentry *old_hidden_dentry = NULL;
@@ -529,9 +515,8 @@ int copyup_named_file(struct inode *dir, struct file *file, char *name,
        int err = 0;
        struct file *output_file = NULL;
 
-       err = copyup_named_dentry(dir, file->f_dentry, bstart,
-                                 new_bindex, name, strlen(name), &output_file,
-                                 len);
+       err = copyup_dentry(dir, file->f_dentry, bstart, new_bindex,
+                           name, strlen(name), &output_file, len);
        if (!err) {
                fbstart(file) = new_bindex;
                unionfs_set_lower_file_idx(file, new_bindex, output_file);
@@ -549,8 +534,10 @@ int copyup_file(struct inode *dir, struct file *file, int bstart,
 {
        int err = 0;
        struct file *output_file = NULL;
+       struct dentry *dentry = file->f_dentry;
 
-       err = copyup_dentry(dir, file->f_dentry, bstart, new_bindex,
+       err = copyup_dentry(dir, dentry, bstart, new_bindex,
+                           dentry->d_name.name, dentry->d_name.len,
                            &output_file, len);
        if (!err) {
                fbstart(file) = new_bindex;
index 02bea8f31a508887302c7e04a94f281e9a5be982..8a41999927368f23feb2529e883e1fc17d2b0794 100644 (file)
@@ -344,7 +344,8 @@ docopyup:
                for (bindex = old_bstart - 1; bindex >= 0; bindex--) {
                        err = copyup_dentry(old_dentry->d_parent->d_inode,
                                            old_dentry, old_bstart,
-                                           bindex, NULL,
+                                           bindex, old_dentry->d_name.name,
+                                           old_dentry->d_name.len, NULL,
                                            old_dentry->d_inode->i_size);
                        if (!err) {
                                hidden_new_dentry =
@@ -1024,8 +1025,10 @@ static int unionfs_setattr(struct dentry *dentry, struct iattr *ia)
                                if (ia->ia_valid & ATTR_SIZE)
                                        size = ia->ia_size;
                                err = copyup_dentry(dentry->d_parent->d_inode,
-                                                   dentry, bstart, i, NULL,
-                                                   size);
+                                                   dentry, bstart, i,
+                                                   dentry->d_name.name,
+                                                   dentry->d_name.len,
+                                                   NULL, size);
 
                                if (!err) {
                                        copyup = 1;
index a19957fa7889b9637b21ce14c32e9dd48ab9051c..d4963e431699d72f94ca92fdd4819de5caa664f6 100644 (file)
@@ -226,6 +226,8 @@ static int do_unionfs_rename(struct inode *old_dir,
                         */
                        err = copyup_dentry(old_dentry->d_parent->d_inode,
                                            old_dentry, old_bstart, bindex,
+                                           old_dentry->d_name.name,
+                                           old_dentry->d_name.len,
                                            NULL, old_dentry->d_inode->i_size);
                        if (!err) {
                                dput(wh_old);
index be5e61b683668b3e2997aa47e90152aecea7a6ff..7c54ef7a77a00d840de1309027af5e2b57f7fdc0 100644 (file)
@@ -262,9 +262,9 @@ extern int copyup_named_file(struct inode *dir, struct file *file,
                             char *name, int bstart, int new_bindex,
                             loff_t len);
 /* copies a dentry from dbstart to newbindex branch */
-extern int copyup_dentry(struct inode *dir, struct dentry *dentry, int bstart,
-                        int new_bindex, struct file **copyup_file,
-                        loff_t len);
+extern int copyup_dentry(struct inode *dir, struct dentry *dentry,
+                        int bstart, int new_bindex, const char *name,
+                        int namelen, struct file **copyup_file, loff_t len);
 /* helper functions for post-copyup cleanup */
 extern void unionfs_inherit_mnt(struct dentry *dentry);
 extern void unionfs_purge_extras(struct dentry *dentry);