Unionfs: update times in setattr
authorErez Zadok <ezk@cs.sunysb.edu>
Sat, 24 Nov 2007 21:03:14 +0000 (16:03 -0500)
committerErez Zadok <ezk@cs.sunysb.edu>
Fri, 22 Nov 2013 23:54:51 +0000 (18:54 -0500)
Needed to maintain Unix semantics via utimes(2).

Signed-off-by: Erez Zadok <ezk@cs.sunysb.edu>
fs/unionfs/inode.c

index ef61d9c533dac0af7f5f3290276eb6e74b6cbc63..63ff3d3ebebe3ed86c8dfd515b282b6a93c48ffc 100644 (file)
@@ -1090,6 +1090,18 @@ static int unionfs_setattr(struct dentry *dentry, struct iattr *ia)
        /* get the size from the first lower inode */
        lower_inode = unionfs_lower_inode(inode);
        unionfs_copy_attr_all(inode, lower_inode);
+       /*
+        * unionfs_copy_attr_all will copy the lower times to our inode if
+        * the lower ones are newer (useful for cache coherency).  However,
+        * ->setattr is the only place in which we may have to copy the
+        * lower inode times absolutely, to support utimes(2).
+        */
+       if (ia->ia_valid & ATTR_MTIME_SET)
+               inode->i_mtime = lower_inode->i_mtime;
+       if (ia->ia_valid & ATTR_CTIME)
+               inode->i_ctime = lower_inode->i_ctime;
+       if (ia->ia_valid & ATTR_ATIME_SET)
+               inode->i_atime = lower_inode->i_atime;
        fsstack_copy_inode_size(inode, lower_inode);
        /* if setattr succeeded, then parent dir may have changed */
        unionfs_copy_attr_times(dentry->d_parent->d_inode);