Unionfs: simplify the macros used to get/set the dentry start/end branches
authorErez Zadok <ezk@cs.sunysb.edu>
Mon, 28 Jul 2008 04:25:46 +0000 (00:25 -0400)
committerErez Zadok <ezk@cs.sunysb.edu>
Wed, 30 Mar 2011 23:31:37 +0000 (19:31 -0400)
Signed-off-by: Erez Zadok <ezk@cs.sunysb.edu>
fs/unionfs/commonfops.c
fs/unionfs/copyup.c
fs/unionfs/dentry.c
fs/unionfs/fanout.h
fs/unionfs/inode.c
fs/unionfs/lookup.c
fs/unionfs/main.c
fs/unionfs/rename.c
fs/unionfs/subr.c
fs/unionfs/super.c

index 631e081e792b1ea325c4e74737bebf30a2d63276..6f61fb0f52eac71c3fa6b5ebc88cef99f12caa4a 100644 (file)
@@ -290,7 +290,7 @@ static int do_delayed_copyup(struct file *file)
        }
        /* for reg file, we only open it "once" */
        fbend(file) = fbstart(file);
-       set_dbend(dentry, dbstart(dentry));
+       dbend(dentry) = dbstart(dentry);
        ibend(dentry->d_inode) = ibstart(dentry->d_inode);
 
 out:
@@ -823,8 +823,8 @@ static int unionfs_ioctl_queryfile(struct file *file, unsigned int cmd,
                }
        }
        /* restore original dentry's offsets */
-       set_dbstart(dentry, orig_bstart);
-       set_dbend(dentry, orig_bend);
+       dbstart(dentry) = orig_bstart;
+       dbend(dentry) = orig_bend;
        ibstart(dentry->d_inode) = orig_bstart;
        ibend(dentry->d_inode) = orig_bend;
 
index 6d1e461186fc969c046a837753b3753e541657e6..b91889722ba90fbf6315f1d6aeecfca04bcac493 100644 (file)
@@ -354,8 +354,8 @@ static void __clear(struct dentry *dentry, struct dentry *old_lower_dentry,
 {
        /* get rid of the lower dentry and all its traces */
        unionfs_set_lower_dentry_idx(dentry, new_bindex, NULL);
-       set_dbstart(dentry, old_bstart);
-       set_dbend(dentry, old_bend);
+       dbstart(dentry) = old_bstart;
+       dbend(dentry) = old_bend;
 
        dput(new_lower_dentry);
        dput(old_lower_dentry);
@@ -633,8 +633,8 @@ static void __cleanup_dentry(struct dentry *dentry, int bindex,
                new_bstart = bindex;
        if (new_bend < 0)
                new_bend = bindex;
-       set_dbstart(dentry, new_bstart);
-       set_dbend(dentry, new_bend);
+       dbstart(dentry) = new_bstart;
+       dbend(dentry) = new_bend;
 
 }
 
@@ -657,9 +657,9 @@ static void __set_dentry(struct dentry *upper, struct dentry *lower,
 {
        unionfs_set_lower_dentry_idx(upper, bindex, lower);
        if (likely(dbstart(upper) > bindex))
-               set_dbstart(upper, bindex);
+               dbstart(upper) = bindex;
        if (likely(dbend(upper) < bindex))
-               set_dbend(upper, bindex);
+               dbend(upper) = bindex;
 }
 
 /*
@@ -883,6 +883,6 @@ void unionfs_postcopyup_release(struct dentry *dentry)
                }
        }
        bindex = dbstart(dentry);
-       set_dbend(dentry, bindex);
+       dbend(dentry) = bindex;
        ibend(dentry->d_inode) = ibstart(dentry->d_inode) = bindex;
 }
index e5f894cd93763c5f0b3566a64006693934e28231..44b17ceb1b4dd4bb94d6c016deac4583f1484862 100644 (file)
@@ -106,8 +106,7 @@ static bool __unionfs_d_revalidate_one(struct dentry *dentry,
                bstart = dbstart(dentry);
                bend = dbend(dentry);
                __dput_lowers(dentry, bstart, bend);
-               set_dbstart(dentry, -1);
-               set_dbend(dentry, -1);
+               dbstart(dentry) = dbend(dentry) = -1;
 
                interpose_flag = INTERPOSE_REVAL_NEG;
                if (positive) {
@@ -542,8 +541,7 @@ static void unionfs_d_iput(struct dentry *dentry, struct inode *inode)
                        unionfs_set_lower_dentry_idx(dentry, bindex, NULL);
                }
        }
-       set_dbstart(dentry, -1);
-       set_dbend(dentry, -1);
+       dbstart(dentry) = dbend(dentry) = -1;
 
 drop_lower_inodes:
        rc = atomic_read(&inode->i_count);
index 29d42fbca223294fad48f2fc8e7e2457b81c34fd..69a8e8fa16264ea17f87e327bdefcf865cc58c2a 100644 (file)
@@ -33,6 +33,12 @@ static inline struct unionfs_inode_info *UNIONFS_I(const struct inode *inode)
 #define ibstart(ino) (UNIONFS_I(ino)->bstart)
 #define ibend(ino) (UNIONFS_I(ino)->bend)
 
+/* Dentry to private data */
+#define UNIONFS_D(dent) ((struct unionfs_dentry_info *)(dent)->d_fsdata)
+#define dbstart(dent) (UNIONFS_D(dent)->bstart)
+#define dbend(dent) (UNIONFS_D(dent)->bend)
+#define dbopaque(dent) (UNIONFS_D(dent)->bopaque)
+
 /* Superblock to private data */
 #define UNIONFS_SB(super) ((struct unionfs_sb_info *)(super)->s_fs_info)
 #define sbstart(sb) 0
@@ -199,48 +205,6 @@ static inline void branchput(struct super_block *sb, int index)
 }
 
 /* Dentry macros */
-static inline struct unionfs_dentry_info *UNIONFS_D(const struct dentry *dent)
-{
-       BUG_ON(!dent);
-       return dent->d_fsdata;
-}
-
-static inline int dbstart(const struct dentry *dent)
-{
-       BUG_ON(!dent);
-       return UNIONFS_D(dent)->bstart;
-}
-
-static inline void set_dbstart(struct dentry *dent, int val)
-{
-       BUG_ON(!dent);
-       UNIONFS_D(dent)->bstart = val;
-}
-
-static inline int dbend(const struct dentry *dent)
-{
-       BUG_ON(!dent);
-       return UNIONFS_D(dent)->bend;
-}
-
-static inline void set_dbend(struct dentry *dent, int val)
-{
-       BUG_ON(!dent);
-       UNIONFS_D(dent)->bend = val;
-}
-
-static inline int dbopaque(const struct dentry *dent)
-{
-       BUG_ON(!dent);
-       return UNIONFS_D(dent)->bopaque;
-}
-
-static inline void set_dbopaque(struct dentry *dent, int val)
-{
-       BUG_ON(!dent);
-       UNIONFS_D(dent)->bopaque = val;
-}
-
 static inline void unionfs_set_lower_dentry_idx(struct dentry *dent, int index,
                                                struct dentry *val)
 {
index a1d7aafe43a9725d6482a8ecb4e75fa61e71dda8..8b4da549e628224d72856a89b2e8846e090a808c 100644 (file)
@@ -644,7 +644,7 @@ static int unionfs_mkdir(struct inode *parent, struct dentry *dentry, int mode)
                                unionfs_set_lower_dentry_idx(dentry, i, NULL);
                        }
                }
-               set_dbend(dentry, bindex);
+               dbend(dentry) = bindex;
 
                /*
                 * Only INTERPOSE_LOOKUP can return a value other than 0 on
index 7f512c2a56408015539bb5b0ec40f436711a41f6..33be53c5e7b8d900ca5174fdc86e115631cdd096 100644 (file)
@@ -206,8 +206,7 @@ struct dentry *unionfs_lookup_backend(struct dentry *dentry,
                if (wh_lower_dentry->d_inode) {
                        /* We found a whiteout so let's give up. */
                        if (S_ISREG(wh_lower_dentry->d_inode->i_mode)) {
-                               set_dbend(dentry, bindex);
-                               set_dbopaque(dentry, bindex);
+                               dbend(dentry) = dbopaque(dentry) = bindex;
                                dput(wh_lower_dentry);
                                break;
                        }
@@ -276,7 +275,7 @@ struct dentry *unionfs_lookup_backend(struct dentry *dentry,
 
                /* store underlying dentry */
                if (dbstart(dentry) == -1)
-                       set_dbstart(dentry, bindex);
+                       dbstart(dentry) = bindex;
                unionfs_set_lower_dentry_idx(dentry, bindex, lower_dentry);
                /*
                 * FIXME: the following line needs to get fixed to allow
@@ -285,7 +284,7 @@ struct dentry *unionfs_lookup_backend(struct dentry *dentry,
                unionfs_set_lower_mnt_idx(dentry, bindex,
                                          unionfs_mntget(parent_dentry,
                                                         bindex));
-               set_dbend(dentry, bindex);
+               dbend(dentry) = bindex;
 
                /* update parent directory's atime with the bindex */
                fsstack_copy_attr_atime(parent_dentry->d_inode,
@@ -306,8 +305,7 @@ struct dentry *unionfs_lookup_backend(struct dentry *dentry,
                        err = opaque;
                        goto out_free;
                } else if (opaque) {
-                       set_dbend(dentry, bindex);
-                       set_dbopaque(dentry, bindex);
+                       dbend(dentry) = dbopaque(dentry) = bindex;
                        break;
                }
        }
@@ -353,8 +351,7 @@ out_negative:
                                     first_lower_dentry);
        unionfs_set_lower_mnt_idx(dentry, first_dentry_offset,
                                  first_lower_mnt);
-       set_dbstart(dentry, first_dentry_offset);
-       set_dbend(dentry, first_dentry_offset);
+       dbstart(dentry) = dbend(dentry) = first_dentry_offset;
 
        if (lookupmode == INTERPOSE_REVAL_NEG)
                BUG_ON(dentry->d_inode != NULL);
@@ -421,8 +418,7 @@ out_free:
        }
        kfree(UNIONFS_D(dentry)->lower_paths);
        UNIONFS_D(dentry)->lower_paths = NULL;
-       set_dbstart(dentry, -1);
-       set_dbend(dentry, -1);
+       dbstart(dentry) = dbend(dentry) = -1;
 
 out:
        if (!err && UNIONFS_D(dentry)) {
@@ -582,7 +578,7 @@ void update_bstart(struct dentry *dentry)
                if (!lower_dentry)
                        continue;
                if (lower_dentry->d_inode) {
-                       set_dbstart(dentry, bindex);
+                       dbstart(dentry) = bindex;
                        break;
                }
                dput(lower_dentry);
index b76264a5203124c2d7827b778d73bbad821aeb77..b8f84bbd5b70cd83a9cbcf07bd8497ad4df03f8c 100644 (file)
@@ -675,8 +675,8 @@ static int unionfs_read_super(struct super_block *sb, void *raw_data,
                unionfs_set_lower_dentry_idx(sb->s_root, bindex, d);
                unionfs_set_lower_mnt_idx(sb->s_root, bindex, m);
        }
-       set_dbstart(sb->s_root, bstart);
-       set_dbend(sb->s_root, bend);
+       dbstart(sb->s_root) = bstart;
+       dbend(sb->s_root) = bend;
 
        /* Set the generation number to one, since this is for the mount. */
        atomic_set(&UNIONFS_D(sb->s_root)->generation, 1);
index cc16eb2989d82daf289d1054e605901438fa956d..fe8d877104e892b78662e570e564bfbebd06b8a9 100644 (file)
@@ -156,9 +156,9 @@ out:
        if (!err) {
                /* Fixup the new_dentry. */
                if (bindex < dbstart(new_dentry))
-                       set_dbstart(new_dentry, bindex);
+                       dbstart(new_dentry) = bindex;
                else if (bindex > dbend(new_dentry))
-                       set_dbend(new_dentry, bindex);
+                       dbend(new_dentry) = bindex;
        }
 
        kfree(wh_name);
@@ -298,7 +298,7 @@ static int do_unionfs_rename(struct inode *old_dir,
                                       &nd);
                unlock_dir(lower_parent);
                if (!local_err) {
-                       set_dbopaque(old_dentry, bwh_old);
+                       dbopaque(old_dentry) = bwh_old;
                } else {
                        /*
                         * we can't fix anything now, so we cop-out and use
@@ -426,9 +426,9 @@ static int may_rename_dir(struct dentry *dentry)
        if (dbend(dentry) == bstart || dbopaque(dentry) == bstart)
                return 0;
 
-       set_dbstart(dentry, bstart + 1);
+       dbstart(dentry) = bstart + 1;
        err = check_empty(dentry, NULL);
-       set_dbstart(dentry, bstart);
+       dbstart(dentry) = bstart;
        if (err == -ENOTEMPTY)
                err = -EXDEV;
        return err;
index 1a40f63ffbbdd4b2b1e4ff30dd2bd6ceb3d3d630..b76fa7aa00c2e13ffee5d79b286f620a3e5c6753 100644 (file)
@@ -107,7 +107,7 @@ int create_whiteout(struct dentry *dentry, int start)
 
        /* set dbopaque so that lookup will not proceed after this branch */
        if (!err)
-               set_dbopaque(dentry, bindex);
+               dbopaque(dentry) = bindex;
 
 out:
        kfree(name);
@@ -195,7 +195,7 @@ int make_dir_opaque(struct dentry *dentry, int bindex)
        if (!diropq->d_inode)
                err = vfs_create(lower_dir, diropq, S_IRUGO, &nd);
        if (!err)
-               set_dbopaque(dentry, bindex);
+               dbopaque(dentry) = bindex;
        release_lower_nd(&nd, err);
 
        dput(diropq);
index b110760fc4bee01c8f61cc437d67e2c36e3496aa..1a172af9623453625fbc5fc989016b5c03ad04bb 100644 (file)
@@ -771,7 +771,7 @@ out_no_change:
        /* update our unionfs_sb_info and root dentry index of last branch */
        i = sbmax(sb);          /* save no. of branches to release at end */
        sbend(sb) = new_branches - 1;
-       set_dbend(sb->s_root, new_branches - 1);
+       dbend(sb->s_root) = new_branches - 1;
        old_ibstart = ibstart(sb->s_root->d_inode);
        old_ibend = ibend(sb->s_root->d_inode);
        ibend(sb->s_root->d_inode) = new_branches - 1;