Unionfs: maintain one-open-file invariant for non-directories
authorErez Zadok <ezk@cs.sunysb.edu>
Wed, 23 Apr 2008 23:05:40 +0000 (19:05 -0400)
committerErez Zadok <ezk@cs.sunysb.edu>
Wed, 30 Mar 2011 23:31:35 +0000 (19:31 -0400)
Signed-off-by: Erez Zadok <ezk@cs.sunysb.edu>
fs/unionfs/commonfops.c

index 2706194feae2bb38fea83a5a7d13ddc91888d410..82b0eea47347b16eabee42739692bed481e4ad3a 100644 (file)
@@ -320,7 +320,9 @@ static int __unionfs_file_revalidate(struct file *file, struct dentry *dentry,
         * to refresh things.
         */
        if (d_deleted(dentry) ||
-           (sbgen <= fgen && dbstart(dentry) == fbstart(file)))
+           (sbgen <= fgen &&
+            dbstart(dentry) == fbstart(file) &&
+            unionfs_lower_file(file)))
                goto out_may_copyup;
 
        /* save orig branch ID */
@@ -369,6 +371,8 @@ static int __unionfs_file_revalidate(struct file *file, struct dentry *dentry,
                        unionfs_mntput(sb->s_root,
                                       branch_id_to_idx(sb, orig_brid));
                }
+               /* regular files have only one open lower file */
+               fbend(file) = fbstart(file);
        }
        atomic_set(&UNIONFS_F(file)->generation,
                   atomic_read(&UNIONFS_I(dentry->d_inode)->generation));
@@ -381,6 +385,9 @@ out_may_copyup:
                pr_debug("unionfs: do delay copyup of \"%s\"\n",
                         dentry->d_name.name);
                err = do_delayed_copyup(file);
+               /* regular files have only one open lower file */
+               if (!err && !S_ISDIR(dentry->d_inode->i_mode))
+                       fbend(file) = fbstart(file);
        }
 
 out: