]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
fix truncate inode time modification breakage
authorNick Piggin <npiggin@suse.de>
Thu, 3 Jun 2010 12:01:46 +0000 (22:01 +1000)
committerAl Viro <viro@zeniv.linux.org.uk>
Fri, 4 Jun 2010 21:16:30 +0000 (17:16 -0400)
mtime and ctime should be changed only if the file size has actually
changed. Patches changing ext2 and tmpfs from vmtruncate to new truncate
sequence has caused regressions where they always update timestamps.

There is some strange cases in POSIX where truncate(2) must not update
times unless the size has acutally changed, see 6e656be89.

This area is all still rather buggy in different ways in a lot of
filesystems and needs a cleanup and audit (ideally the vfs will provide
a simple attribute or call to direct all filesystems exactly which
attributes to change). But coming up with the best solution will take a
while and is not appropriate for rc anyway.

So fix recent regression for now.

Signed-off-by: Nick Piggin <npiggin@suse.de>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
fs/ext2/inode.c
mm/shmem.c

index 19214435b75213cbbd6b4ba557194476e30654bd..3675088cb88c53c9f23c01369652d9630f5ced11 100644 (file)
@@ -1552,7 +1552,7 @@ int ext2_setattr(struct dentry *dentry, struct iattr *iattr)
                if (error)
                        return error;
        }
-       if (iattr->ia_valid & ATTR_SIZE) {
+       if (iattr->ia_valid & ATTR_SIZE && iattr->ia_size != inode->i_size) {
                error = ext2_setsize(inode, iattr->ia_size);
                if (error)
                        return error;
index 7e5030ae18ffd07ab19f070939f357fff3816ab9..f65f84062db554ed2b3e9452cc787f8ab4f1b0d3 100644 (file)
@@ -764,10 +764,11 @@ done2:
 static int shmem_notify_change(struct dentry *dentry, struct iattr *attr)
 {
        struct inode *inode = dentry->d_inode;
+       loff_t newsize = attr->ia_size;
        int error;
 
-       if (S_ISREG(inode->i_mode) && (attr->ia_valid & ATTR_SIZE)) {
-               loff_t newsize = attr->ia_size;
+       if (S_ISREG(inode->i_mode) && (attr->ia_valid & ATTR_SIZE)
+                                       && newsize != inode->i_size) {
                struct page *page = NULL;
 
                if (newsize < inode->i_size) {