Skip to content

Commit

Permalink
fix truncate inode time modification breakage
Browse files Browse the repository at this point in the history
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 6e656be.

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 <[email protected]>
Signed-off-by: Al Viro <[email protected]>
  • Loading branch information
Nick Piggin authored and Al Viro committed Jun 4, 2010
1 parent 8718d36 commit af5a30d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion fs/ext2/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
5 changes: 3 additions & 2 deletions mm/shmem.c
Original file line number Diff line number Diff line change
Expand Up @@ -764,10 +764,11 @@ static void shmem_truncate_range(struct inode *inode, loff_t start, loff_t end)
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) {
Expand Down

0 comments on commit af5a30d

Please sign in to comment.