From 47092d87b2460288186c05ccdede24b24aeeb52c Mon Sep 17 00:00:00 2001 From: Erez Zadok Date: Sun, 2 Dec 2007 11:47:04 -0500 Subject: [PATCH] Unionfs ODF: properly update parent dir times after rmdir/unlink 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 | 36 +++++++++++++----------------------- 1 file changed, 13 insertions(+), 23 deletions(-) diff --git a/fs/unionfs/unlink.c b/fs/unionfs/unlink.c index b1032a2165..461993096b 100644 --- a/fs/unionfs/unlink.c +++ b/fs/unionfs/unlink.c @@ -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); -- 2.43.0