Unionfs ODF: properly update parent dir times after rmdir/unlink
authorErez Zadok <ezk@cs.sunysb.edu>
Sun, 2 Dec 2007 16:47:04 +0000 (11:47 -0500)
committerRachita Kothiyal <rachita@dewey.fsl.cs.sunysb.edu>
Thu, 1 May 2008 23:03:24 +0000 (19:03 -0400)
Comply with our time-based cache-coherency invariants: that the mtime of a
unionfs object is the max() of all lower ones.

fs/unionfs/unlink.c

index b1032a21659ce7286c7c2189544ea66067255250..461993096bf35f5137a721f38d43d8bc448bed83 100644 (file)
@@ -24,7 +24,6 @@ static int unionfs_do_unlink(struct inode *dir, struct dentry *dentry)
        struct dentry *lower_dir_dentry;
        int bstart, bend, bindex;
        int err = 0;
-       struct iattr attr;
        int opaque;
 
        opaque = odf_get_opaque(dentry->d_parent);
@@ -55,7 +54,6 @@ static int unionfs_do_unlink(struct inode *dir, struct dentry *dentry)
                if (!err)
                        unionfs_copy_attr_times(dentry->d_inode);
                dput(lower_dentry);
-               fsstack_copy_attr_times(dir, lower_dir_dentry->d_inode);
                unlock_dir(lower_dir_dentry);
 
                if (err)
@@ -72,15 +70,12 @@ static int unionfs_do_unlink(struct inode *dir, struct dentry *dentry)
        }
 
        /*
-        * we want to update mtime here, since if the file to
-        * be removed was only on a rd only branch, then since
-        * the mtime of that branch has not changed, so the
-        * mtime of the upper file is not updated
+        * XXX: do we want to update mtime here? (since if the file to be
+        * removed was only on a rd only branch, then since the mtime of
+        * that branch has not changed, so the mtime of the upper file is
+        * not updated?)
         */
        odf_purge_dir_cache(dentry->d_parent);
-       attr.ia_mtime = current_kernel_time();
-       attr.ia_valid = ATTR_MTIME | ATTR_MTIME_SET | ATTR_FORCE;
-       err = notify_change(dentry->d_parent, &attr);
 
        /*
         * XXX: ignore this error, for now, unionfs_setattr should
@@ -130,17 +125,14 @@ int unionfs_unlink(struct inode *dir, struct dentry *dentry)
                if (!S_ISDIR(dentry->d_inode->i_mode))
                        unionfs_postcopyup_release(dentry);
                d_drop(dentry);
-               /*
-                * if unlink/whiteout succeeded, parent dir mtime has
-                * changed
-                */
-               unionfs_copy_attr_times(dir);
        }
 
 out:
        if (!err) {
                unionfs_check_dentry(dentry);
                unionfs_check_inode(dir);
+               /* update parent dir times if unlink/whiteout succeeded */
+               unionfs_copy_attr_times(dir);
        }
        unionfs_unlock_dentry(dentry);
        unionfs_read_unlock(dentry->d_sb);
@@ -153,7 +145,6 @@ static int unionfs_do_rmdir(struct inode *dir, struct dentry *dentry)
        struct dentry *lower_dir_dentry = NULL;
        int bstart, bend, bindex;
        int err = 0;
-       struct iattr attr;
 
        err = unionfs_partial_lookup(dentry);
        if (err)
@@ -178,7 +169,6 @@ static int unionfs_do_rmdir(struct inode *dir, struct dentry *dentry)
                else
                        err = -EROFS;
                dput(lower_dentry);
-               fsstack_copy_attr_times(dir, lower_dir_dentry->d_inode);
 
                /* propagate number of hard-links */
                /* FIXME: does this belong in or out of the loop? */
@@ -202,15 +192,12 @@ static int unionfs_do_rmdir(struct inode *dir, struct dentry *dentry)
        }
 
        /*
-        * we want to update mtime here, since if the file to
-        * be removed was only on a rd only branch, then since
-        * the mtime of that branch has not changed, so the
-        * mtime of the upper file is not updated
+        * XXX: do we want to update mtime here? (since if the file to be
+        * removed was only on a rd only branch, then since the mtime of
+        * that branch has not changed, so the mtime of the upper file is
+        * not updated?)
         */
        odf_purge_dir_cache(dentry->d_parent);
-       attr.ia_mtime = current_kernel_time();
-       attr.ia_valid = ATTR_MTIME | ATTR_MTIME_SET | ATTR_FORCE;
-       err = notify_change(dentry->d_parent, &attr);
 
        /*
         * XXX: ignore this error, for now, unionfs_setattr should
@@ -250,6 +237,9 @@ int unionfs_rmdir(struct inode *dir, struct dentry *dentry)
        err = unionfs_do_rmdir(dir, dentry);
        if (err)
                goto out;
+       /* update parent dir times if if rmdir/whiteout succeeded above */
+       unionfs_copy_attr_times(dir);
+
        /* FIXME: what if this fails? */
        err = odf_remove(dentry, ODF_RMV_NOTWH);