Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit eee597ac authored by Lukas Czerner's avatar Lukas Czerner Committed by Theodore Ts'o
Browse files

ext4: update mtime in ext4_punch_hole even if no blocks are released



Currently in ext4_punch_hole we're going to skip the mtime update if
there are no actual blocks to release. However we've actually modified
the file by zeroing the partial block so the mtime should be updated.

Moreover the sync and datasync handling is skipped as well, which is
also wrong. Fix it.

Signed-off-by: default avatarLukas Czerner <lczerner@redhat.com>
Signed-off-by: default avatarTheodore Ts'o <tytso@mit.edu>
Reported-by: default avatarJoe Habermann <joe.habermann@quantum.com>
Cc: <stable@vger.kernel.org>
parent 6390d33b
Loading
Loading
Loading
Loading
+18 −18
Original line number Original line Diff line number Diff line
@@ -4298,9 +4298,8 @@ int ext4_punch_hole(struct inode *inode, loff_t offset, loff_t length)
		EXT4_BLOCK_SIZE_BITS(sb);
		EXT4_BLOCK_SIZE_BITS(sb);
	stop_block = (offset + length) >> EXT4_BLOCK_SIZE_BITS(sb);
	stop_block = (offset + length) >> EXT4_BLOCK_SIZE_BITS(sb);


	/* If there are no blocks to remove, return now */
	/* If there are blocks to remove, do it */
	if (first_block >= stop_block)
	if (stop_block > first_block) {
		goto out_stop;


		down_write(&EXT4_I(inode)->i_data_sem);
		down_write(&EXT4_I(inode)->i_data_sem);
		ext4_discard_preallocations(inode);
		ext4_discard_preallocations(inode);
@@ -4320,6 +4319,7 @@ int ext4_punch_hole(struct inode *inode, loff_t offset, loff_t length)
						    stop_block);
						    stop_block);


		up_write(&EXT4_I(inode)->i_data_sem);
		up_write(&EXT4_I(inode)->i_data_sem);
	}
	if (IS_SYNC(inode))
	if (IS_SYNC(inode))
		ext4_handle_sync(handle);
		ext4_handle_sync(handle);