From: Namjae Jeon <namjae.jeon@samsung.com>
To: Theodore Ts'o <tytso@mit.edu>
Cc: linux-ext4 <linux-ext4@vger.kernel.org>,
"Lukáš Czerner" <lczerner@redhat.com>
Subject: [PATCH v2 1/2] ext4: fix COLLAPSE_RANGE failure issue on ext4 with 1KB block size
Date: Sat, 19 Apr 2014 13:50:37 +0900 [thread overview]
Message-ID: <000c01cf5b8a$e7dd2cc0$b7978640$@samsung.com> (raw)
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 | 13 ++++++++++---
1 file changed, 10 insertions(+), 3 deletions(-)
diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c
index 9b9251a..4cf8c5b 100644
--- a/fs/ext4/extents.c
+++ b/fs/ext4/extents.c
@@ -5395,7 +5395,7 @@ int ext4_collapse_range(struct inode *inode, loff_t offset, loff_t len)
ext4_lblk_t punch_start, punch_stop;
handle_t *handle;
unsigned int credits;
- loff_t new_size;
+ loff_t new_size, ioffset;
int ret;
/* Collapse range works only on fs block size aligned offsets. */
@@ -5418,8 +5418,15 @@ int ext4_collapse_range(struct inode *inode, loff_t offset, loff_t len)
return ret;
}
+ /*
+ * Need to round down offset to be aligned with page size boundary
+ * for page size > block size.
+ */
+ ioffset = round_down(offset, PAGE_SIZE);
+
/* Write out all dirty pages */
- ret = filemap_write_and_wait_range(inode->i_mapping, offset, LLONG_MAX);
+ ret = filemap_write_and_wait_range(inode->i_mapping, ioffset,
+ LLONG_MAX);
if (ret)
return ret;
@@ -5441,7 +5448,7 @@ int ext4_collapse_range(struct inode *inode, loff_t offset, loff_t len)
goto out_mutex;
}
- truncate_pagecache(inode, offset);
+ truncate_pagecache(inode, ioffset);
/* Wait for existing dio to complete */
ext4_inode_block_unlocked_dio(inode);
--
1.7.11-rc0
next reply other threads:[~2014-04-19 4:50 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-04-19 4:50 Namjae Jeon [this message]
2014-04-19 20:36 ` [PATCH v2 1/2] ext4: fix COLLAPSE_RANGE failure issue on ext4 with 1KB block size Theodore Ts'o
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='000c01cf5b8a$e7dd2cc0$b7978640$@samsung.com' \
--to=namjae.jeon@samsung.com \
--cc=lczerner@redhat.com \
--cc=linux-ext4@vger.kernel.org \
--cc=tytso@mit.edu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.