GIT: unionfs2-2.6.27.y: Unionfs: branch-management bug-fix to lower mnt counts

Erez Zadok ezk at fsl.cs.sunysb.edu
Thu Aug 12 23:16:47 EDT 2010


commit c98f9d6afa974aac9440805006d478a651794bb8
Author: Erez_Zadok <ezk at cs.sunysb.edu>
Date:   Mon Jul 16 23:54:11 2007 -0400

    Unionfs: branch-management bug-fix to lower mnt counts
    
    When we revalidate opened files, the files may point to a different set of
    files on the lower branches: this could happen especially if we insert a new
    leftmost branch which happens to have duplicate file names of already-open
    files in lower-priority branches.  In this case, update the mnt counts of
    the old and new branches which hold the file accordingly.  Without this fix,
    the mntcnt of one branch is going to be one too high; and another will be
    one too low.
    
    Signed-off-by: Erez Zadok <ezk at cs.sunysb.edu>

diff --git a/fs/unionfs/commonfops.c b/fs/unionfs/commonfops.c
index 18ade2f..46e5008 100644
--- a/fs/unionfs/commonfops.c
+++ b/fs/unionfs/commonfops.c
@@ -334,6 +334,9 @@ int unionfs_file_revalidate(struct file *file, int willwrite)
 	 */
 	if (!d_deleted(dentry) &&
 	    (sbgen > fgen || dbstart(dentry) != fbstart(file))) {
+		int orig_brid =	/* save orig branch ID */
+			UNIONFS_F(file)->saved_branch_ids[fbstart(file)];
+
 		/* First we throw out the existing files. */
 		cleanup_file(file);
 
@@ -360,10 +363,23 @@ int unionfs_file_revalidate(struct file *file, int willwrite)
 			if (err)
 				goto out;
 		} else {
+			int new_brid;
 			/* We only open the highest priority branch. */
 			err = open_highest_file(file, willwrite);
 			if (err)
 				goto out;
+			new_brid = UNIONFS_F(file)->saved_branch_ids[fbstart(file)];
+			if (new_brid != orig_brid) {
+				/*
+				 * If we re-opened the file on a different
+				 * branch than the original one, then update
+				 * the mnt counts of the old and new
+				 * branches accordingly.
+				 */
+				unionfs_mntget(dentry, bstart);	/* new branch */
+				unionfs_mntput(sb->s_root, /* orig branch */
+					       branch_id_to_idx(sb, orig_brid));
+			}
 		}
 		atomic_set(&UNIONFS_F(file)->generation,
 			   atomic_read(&UNIONFS_I(dentry->d_inode)->


More information about the unionfs-cvs mailing list