1 ext4: update mtime in ext4_punch_hole even if no blocks are released
3 From: Lukas Czerner <lczerner@redhat.com>
5 Currently in ext4_punch_hole we're going to skip the mtime update if
6 there are no actual blocks to release. However we've actually modified
7 the file by zeroing the partial block so the mtime should be updated.
9 Moreover the sync and datasync handling is skipped as well, which is
12 Signed-off-by: Lukas Czerner <lczerner@redhat.com>
13 Signed-off-by: Theodore Ts'o <tytso@mit.edu>
14 Reported-by: Joe Habermann <joe.habermann@quantum.com>
15 Cc: <stable@vger.kernel.org>
17 fs/ext4/inode.c | 36 ++++++++++++++++++------------------
18 1 file changed, 18 insertions(+), 18 deletions(-)
20 diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
21 index 1e50c5e..6b4c5c0 100644
24 @@ -4298,28 +4298,28 @@ int ext4_punch_hole(struct inode *inode, loff_t offset, loff_t length)
25 EXT4_BLOCK_SIZE_BITS(sb);
26 stop_block = (offset + length) >> EXT4_BLOCK_SIZE_BITS(sb);
28 - /* If there are no blocks to remove, return now */
29 - if (first_block >= stop_block)
31 + /* If there are blocks to remove, do it */
32 + if (stop_block > first_block) {
34 - down_write(&EXT4_I(inode)->i_data_sem);
35 - ext4_discard_preallocations(inode);
36 + down_write(&EXT4_I(inode)->i_data_sem);
37 + ext4_discard_preallocations(inode);
39 - ret = ext4_es_remove_extent(inode, first_block,
40 - stop_block - first_block);
42 - up_write(&EXT4_I(inode)->i_data_sem);
45 + ret = ext4_es_remove_extent(inode, first_block,
46 + stop_block - first_block);
48 + up_write(&EXT4_I(inode)->i_data_sem);
52 - if (ext4_test_inode_flag(inode, EXT4_INODE_EXTENTS))
53 - ret = ext4_ext_remove_space(inode, first_block,
56 - ret = ext4_ind_remove_space(handle, inode, first_block,
58 + if (ext4_test_inode_flag(inode, EXT4_INODE_EXTENTS))
59 + ret = ext4_ext_remove_space(inode, first_block,
62 + ret = ext4_ind_remove_space(handle, inode, first_block,
65 - up_write(&EXT4_I(inode)->i_data_sem);
66 + up_write(&EXT4_I(inode)->i_data_sem);
69 ext4_handle_sync(handle);