add patch revert-remove-block_device_ejected
[ext4-patch-queue.git] / update-cmtime-on-truncate-up
blob0c5df85e92f695d12786bfee1c39958b33efb5b6
1 ext4: update c/mtime on truncate up
3 From: Eryu Guan <guaneryu@gmail.com>
5 Commit 3da40c7b0898 ("ext4: only call ext4_truncate when size <= isize")
6 introduced a bug that c/mtime is not updated on truncate up.
8 Fix the issue by setting c/mtime explicitly in the truncate up case.
10 Note that ftruncate(2) is not affected, so you won't see this bug using
11 truncate(1) and xfs_io(1).
13 Signed-off-by: Zirong Lang <zorro.lang@gmail.com>
14 Signed-off-by: Eryu Guan <guaneryu@gmail.com>
15 Signed-off-by: Theodore Ts'o <tytso@mit.edu>
16 ---
17  fs/ext4/inode.c | 8 ++++++++
18  1 file changed, 8 insertions(+)
20 diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
21 index cecf9aa..2442eb0 100644
22 --- a/fs/ext4/inode.c
23 +++ b/fs/ext4/inode.c
24 @@ -4725,6 +4725,14 @@ int ext4_setattr(struct dentry *dentry, struct iattr *attr)
25                                 error = ext4_orphan_add(handle, inode);
26                                 orphan = 1;
27                         }
28 +                       /*
29 +                        * Update c/mtime on truncate up, ext4_truncate() will
30 +                        * update c/mtime in shrink case below
31 +                        */
32 +                       if (!shrink) {
33 +                               inode->i_mtime = ext4_current_time(inode);
34 +                               inode->i_ctime = inode->i_mtime;
35 +                       }
36                         down_write(&EXT4_I(inode)->i_data_sem);
37                         EXT4_I(inode)->i_disksize = attr->ia_size;
38                         rc = ext4_mark_inode_dirty(handle, inode);
39 -- 
40 1.8.3.1
43 To unsubscribe from this list: send the line "unsubscribe linux-ext4" in
44 the body of a message to majordomo@vger.kernel.org
45 More majordomo info at  http://vger.kernel.org/majordomo-info.html