Unionfs: simplify stale-inode detection code
authorErez Zadok <ezk@cs.sunysb.edu>
Mon, 28 Jul 2008 04:25:46 +0000 (00:25 -0400)
committerErez Zadok <ezk@cs.sunysb.edu>
Fri, 12 Aug 2011 02:38:16 +0000 (22:38 -0400)
Signed-off-by: Erez Zadok <ezk@cs.sunysb.edu>
fs/unionfs/dentry.c
fs/unionfs/lookup.c
fs/unionfs/main.c
fs/unionfs/union.h

index 51c0baf47810512e48b4aaee8939843065bcfd89..cd4611bebd993db9818c21228f66aab5dd407354 100644 (file)
 
 #include "union.h"
 
+bool is_negative_lower(const struct dentry *dentry)
+{
+       int bindex;
+       struct dentry *lower_dentry;
+
+       BUG_ON(!dentry || dbstart(dentry) < 0);
+       for (bindex = dbstart(dentry); bindex <= dbend(dentry); bindex++) {
+               lower_dentry = unionfs_lower_dentry_idx(dentry, bindex);
+               /* XXX: what if lower_dentry is NULL? */
+               if (lower_dentry && lower_dentry->d_inode)
+                       return false;
+       }
+       return true;
+}
 
 static inline void __dput_lowers(struct dentry *dentry, int start, int end)
 {
@@ -113,7 +127,7 @@ static bool __unionfs_d_revalidate_one(struct dentry *dentry,
                        dentry = result;
                }
 
-               if (unlikely(positive && UNIONFS_I(dentry->d_inode)->stale)) {
+               if (unlikely(positive && is_negative_lower(dentry))) {
                        make_bad_inode(dentry->d_inode);
                        d_drop(dentry);
                        valid = false;
index f6bb7481eedcbed3776559c9d913c0418d70f7d1..1ba7103d7b7ceea2dd544a1d97f6c5e6137f3639 100644 (file)
@@ -320,11 +320,9 @@ out_negative:
                goto out;
 
        /* If we've only got negative dentries, then use the leftmost one. */
-       if (lookupmode == INTERPOSE_REVAL) {
-               if (dentry->d_inode)
-                       UNIONFS_I(dentry->d_inode)->stale = 1;
+       if (lookupmode == INTERPOSE_REVAL)
                goto out;
-       }
+
        if (!lower_dir_dentry) {
                err = -ENOENT;
                goto out;
@@ -424,7 +422,6 @@ out:
                     !UNIONFS_I(dentry->d_inode)->lower_inodes)) {
                        unionfs_mntput(dentry->d_sb->s_root, bstart);
                        dput(first_lower_dentry);
-                       UNIONFS_I(dentry->d_inode)->stale = 1;
                }
        }
        kfree(whname);
@@ -433,9 +430,6 @@ out:
                unionfs_unlock_dentry(dentry);
        if (!err && d_interposed)
                return d_interposed;
-       if (dentry->d_inode && UNIONFS_I(dentry->d_inode)->stale &&
-           first_dentry_offset >= 0)
-               unionfs_mntput(dentry->d_sb->s_root, first_dentry_offset);
        return ERR_PTR(err);
 }
 
index b8f84bbd5b70cd83a9cbcf07bd8497ad4df03f8c..a9d2cb660218755ca5c0fcc2c862cb2e32e95a10 100644 (file)
@@ -83,25 +83,13 @@ struct dentry *unionfs_interpose(struct dentry *dentry, struct super_block *sb,
 {
        int err = 0;
        struct inode *inode;
-       int is_negative_dentry = 1;
-       int bindex, bstart, bend;
        int need_fill_inode = 1;
        struct dentry *spliced = NULL;
 
        verify_locked(dentry);
 
-       bstart = dbstart(dentry);
-       bend = dbend(dentry);
-
        /* Make sure that we didn't get a negative dentry. */
-       for (bindex = bstart; bindex <= bend; bindex++) {
-               if (unionfs_lower_dentry_idx(dentry, bindex) &&
-                   unionfs_lower_dentry_idx(dentry, bindex)->d_inode) {
-                       is_negative_dentry = 0;
-                       break;
-               }
-       }
-       BUG_ON(is_negative_dentry);
+       BUG_ON(is_negative_lower(dentry));
 
        /*
         * We allocate our new inode below by calling unionfs_iget,
index 9520a00e9a3604cca76bd97d8153a03805cbfdd6..640605927a7f89a8a413c060ec1145d6459fb98c 100644 (file)
@@ -106,7 +106,6 @@ struct unionfs_inode_info {
        int bstart;
        int bend;
        atomic_t generation;
-       int stale;
        /* Stuff for readdir over NFS. */
        spinlock_t rdlock;
        struct list_head readdircache;
@@ -384,6 +383,7 @@ extern bool __unionfs_d_revalidate_one_locked(struct dentry *dentry,
                                              bool willwrite);
 extern bool __unionfs_d_revalidate_chain(struct dentry *dentry,
                                         struct nameidata *nd, bool willwrite);
+extern bool is_negative_lower(const struct dentry *dentry);
 extern bool is_newer_lower(const struct dentry *dentry);
 extern void purge_sb_data(struct super_block *sb);