linux-ext4.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] ext4: avoid exposure of stale data in ext4_punch_hole()
@ 2013-09-26 17:32 Maxim Patlasov
  2013-09-26 18:53 ` Jan Kara
  2013-09-27 15:54 ` [PATCH] ext4: avoid exposure of stale data in ext4_punch_hole() -v2 Maxim Patlasov
  0 siblings, 2 replies; 9+ messages in thread
From: Maxim Patlasov @ 2013-09-26 17:32 UTC (permalink / raw)
  To: tytso; +Cc: linux-ext4, adilger.kernel, linux-kernel

While handling punch-hole fallocate, it's useless to truncate page cache
before removing the range from extent tree (or block map in indirect case)
because page cache can be re-populated (by read-ahead or read(2) or mmap-ed
read) immediately after truncating page cache, but before updating extent
tree (or block map). In that case the user will see stale data even after
fallocate is completed.

Signed-off-by: Maxim Patlasov <mpatlasov@parallels.com>
---
 fs/ext4/inode.c |   17 +++++++++--------
 1 file changed, 9 insertions(+), 8 deletions(-)

diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
index 0d424d7..6b71116 100644
--- a/fs/ext4/inode.c
+++ b/fs/ext4/inode.c
@@ -3564,14 +3564,6 @@ int ext4_punch_hole(struct inode *inode, loff_t offset, loff_t length)
 
 	}
 
-	first_block_offset = round_up(offset, sb->s_blocksize);
-	last_block_offset = round_down((offset + length), sb->s_blocksize) - 1;
-
-	/* Now release the pages and zero block aligned part of pages*/
-	if (last_block_offset > first_block_offset)
-		truncate_pagecache_range(inode, first_block_offset,
-					 last_block_offset);

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

end of thread, other threads:[~2014-02-21  9:45 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-09-26 17:32 [PATCH] ext4: avoid exposure of stale data in ext4_punch_hole() Maxim Patlasov
2013-09-26 18:53 ` Jan Kara
2013-09-27 13:05   ` Maxim Patlasov
2013-09-27 14:43     ` Jan Kara
2013-09-27 15:16       ` Maxim Patlasov
2013-09-27 15:54 ` [PATCH] ext4: avoid exposure of stale data in ext4_punch_hole() -v2 Maxim Patlasov
2013-09-27 16:05   ` Jan Kara
2014-02-21  0:21     ` Theodore Ts'o
2014-02-21  9:45       ` Jan Kara

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).