All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/3] ext4: fix COLLAPSE_RANGE failure issue on ext4 with 1KB block size
@ 2014-04-16 22:27 Namjae Jeon
  2014-04-17  8:25 ` Lukáš Czerner
  0 siblings, 1 reply; 3+ messages in thread
From: Namjae Jeon @ 2014-04-16 22:27 UTC (permalink / raw)
  To: Theodore Ts'o; +Cc: linux-ext4, 'Lukáš Czerner'

From: Namjae Jeon <namjae.jeon@samsung.com>

When formatting with 1KB or 2KB(not aligned with PAGE SIZE) block size,
xfstests generic/075 and 091 are failing. The offset supplied to function
truncate_pagecache_range is block size aligned. In this function start offset
is re-aligned to PAGE_SIZE by rounding_up to the next page boundary.
Due to this rounding up, old data remains in the page cache when blocksize is
less than page size and start offset is not aligned with page size.
In case of collapse range, we need to align start offset to page size boundary
by doing a round down operation instead of round up.

Signed-off-by: Namjae Jeon <namjae.jeon@samsung.com>
Signed-off-by: Ashish Sangwan <a.sangwan@samsung.com>
---
 fs/ext4/extents.c | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c
index 1bb3e4b..f386dd6 100644
--- a/fs/ext4/extents.c
+++ b/fs/ext4/extents.c
@@ -5404,8 +5404,8 @@ int ext4_collapse_range(struct inode *inode, loff_t offset, loff_t len)
 	struct super_block *sb = inode->i_sb;
 	ext4_lblk_t punch_start, punch_stop;
 	handle_t *handle;
-	unsigned int credits;
-	loff_t new_size;
+	unsigned int credits, rounding;
+	loff_t new_size, ioffset;
 	int ret;
 
 	/* Collapse range works only on fs block size aligned offsets. */
@@ -5428,8 +5428,11 @@ int ext4_collapse_range(struct inode *inode, loff_t offset, loff_t len)
 			return ret;
 	}
 
+	rounding = max_t(uint, 1 << EXT4_BLOCK_SIZE_BITS(sb), PAGE_CACHE_SIZE);
+	ioffset = offset & ~(rounding - 1);
+
 	/* Write out all dirty pages */
-	ret = filemap_write_and_wait_range(inode->i_mapping, offset, -1);
+	ret = filemap_write_and_wait_range(inode->i_mapping, ioffset, -1);
 	if (ret)
 		return ret;
 
@@ -5451,7 +5454,7 @@ int ext4_collapse_range(struct inode *inode, loff_t offset, loff_t len)
 		goto out_mutex;
 	}
 
-	truncate_pagecache_range(inode, offset, -1);
+	truncate_pagecache_range(inode, ioffset, -1);
 
 	/* Wait for existing dio to complete */
 	ext4_inode_block_unlocked_dio(inode);
-- 
1.7.11-rc0


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

end of thread, other threads:[~2014-04-17  9:23 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-04-16 22:27 [PATCH 1/3] ext4: fix COLLAPSE_RANGE failure issue on ext4 with 1KB block size Namjae Jeon
2014-04-17  8:25 ` Lukáš Czerner
2014-04-17  9:23   ` Namjae Jeon

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.