All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] ext4: update mtime in ext4_punch_hole even if no blocks are released
@ 2018-04-24 13:07 Lukas Czerner
  2018-05-13 23:39 ` Theodore Y. Ts'o
  0 siblings, 1 reply; 2+ messages in thread
From: Lukas Czerner @ 2018-04-24 13:07 UTC (permalink / raw)
  To: linux-ext4; +Cc: Lukas Czerner, stable

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: Lukas Czerner <lczerner@redhat.com>
Reported-by: Joe Habermann <joe.habermann@quantum.com>
Cc: <stable@vger.kernel.org>
---
 fs/ext4/inode.c | 36 ++++++++++++++++++------------------
 1 file changed, 18 insertions(+), 18 deletions(-)

diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
index 1e50c5e..6b4c5c0 100644
--- a/fs/ext4/inode.c
+++ b/fs/ext4/inode.c
@@ -4298,28 +4298,28 @@ int ext4_punch_hole(struct inode *inode, loff_t offset, loff_t 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 (first_block >= stop_block)
-		goto out_stop;
+	/* If there are blocks to remove, do it */
+	if (stop_block > first_block) {
 
-	down_write(&EXT4_I(inode)->i_data_sem);
-	ext4_discard_preallocations(inode);
+		down_write(&EXT4_I(inode)->i_data_sem);
+		ext4_discard_preallocations(inode);
 
-	ret = ext4_es_remove_extent(inode, first_block,
-				    stop_block - first_block);
-	if (ret) {
-		up_write(&EXT4_I(inode)->i_data_sem);
-		goto out_stop;
-	}
+		ret = ext4_es_remove_extent(inode, first_block,
+					    stop_block - first_block);
+		if (ret) {
+			up_write(&EXT4_I(inode)->i_data_sem);
+			goto out_stop;
+		}
 
-	if (ext4_test_inode_flag(inode, EXT4_INODE_EXTENTS))
-		ret = ext4_ext_remove_space(inode, first_block,
-					    stop_block - 1);
-	else
-		ret = ext4_ind_remove_space(handle, inode, first_block,
-					    stop_block);
+		if (ext4_test_inode_flag(inode, EXT4_INODE_EXTENTS))
+			ret = ext4_ext_remove_space(inode, first_block,
+						    stop_block - 1);
+		else
+			ret = ext4_ind_remove_space(handle, inode, first_block,
+						    stop_block);
 
-	up_write(&EXT4_I(inode)->i_data_sem);
+		up_write(&EXT4_I(inode)->i_data_sem);
+	}
 	if (IS_SYNC(inode))
 		ext4_handle_sync(handle);
 
-- 
2.7.5

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] ext4: update mtime in ext4_punch_hole even if no blocks are released
  2018-04-24 13:07 [PATCH] ext4: update mtime in ext4_punch_hole even if no blocks are released Lukas Czerner
@ 2018-05-13 23:39 ` Theodore Y. Ts'o
  0 siblings, 0 replies; 2+ messages in thread
From: Theodore Y. Ts'o @ 2018-05-13 23:39 UTC (permalink / raw)
  To: Lukas Czerner; +Cc: linux-ext4, stable

On Tue, Apr 24, 2018 at 03:07:51PM +0200, Lukas Czerner wrote:
> 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: Lukas Czerner <lczerner@redhat.com>
> Reported-by: Joe Habermann <joe.habermann@quantum.com>
> Cc: <stable@vger.kernel.org>

Thanks, applied.

						- Ted

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2018-05-13 23:39 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-04-24 13:07 [PATCH] ext4: update mtime in ext4_punch_hole even if no blocks are released Lukas Czerner
2018-05-13 23:39 ` Theodore Y. Ts'o

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.