From: Allison Henderson <achender@linux.vnet.ibm.com>
To: linux-ext4@vger.kernel.org
Cc: Allison Henderson <achender@linux.vnet.ibm.com>
Subject: [PATCH 6/6 v5] ext4: fix partial page writes
Date: Sat, 20 Aug 2011 19:29:47 -0700 [thread overview]
Message-ID: <1313893787-25460-7-git-send-email-achender@linux.vnet.ibm.com> (raw)
In-Reply-To: <1313893787-25460-1-git-send-email-achender@linux.vnet.ibm.com>
These bugs were also found during extended fsx testing
for blocksize = 1k.
When ever a write operation begins or ends in a hole,
or extends EOF, the partial page contained in the hole
or beyond EOF needs to be zeroed out.
To correct this the new ext4_discard_partial_page_buffers_no_lock
routine is used to zero out the partial page, but only for buffer
heads that are already unmapped.
Signed-off-by: Allison Henderson <achender@linux.vnet.ibm.com>
---
:100644 100644 c1b42cb... 78c723b... M fs/ext4/inode.c
fs/ext4/inode.c | 15 +++++++++++++++
1 files changed, 15 insertions(+), 0 deletions(-)
diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
index c1b42cb..78c723b 100644
--- a/fs/ext4/inode.c
+++ b/fs/ext4/inode.c
@@ -2214,6 +2214,7 @@ static int ext4_da_write_begin(struct file *file, struct address_space *mapping,
pgoff_t index;
struct inode *inode = mapping->host;
handle_t *handle;
+ loff_t page_len;
index = pos >> PAGE_CACHE_SHIFT;
@@ -2260,6 +2261,11 @@ retry:
*/
if (pos + len > inode->i_size)
ext4_truncate_failed_write(inode);
+ } else {
+ page_len = pos & (PAGE_CACHE_SIZE - 1);
+ ext4_discard_partial_page_buffers_no_lock(handle,
+ inode, page, pos - page_len, page_len,
+ EXT4_DSCRD_PARTIAL_PG_ZERO_UNMAPED);
}
if (ret == -ENOSPC && ext4_should_retry_alloc(inode->i_sb, &retries))
@@ -2302,6 +2308,7 @@ static int ext4_da_write_end(struct file *file,
loff_t new_i_size;
unsigned long start, end;
int write_mode = (int)(unsigned long)fsdata;
+ loff_t page_len;
if (write_mode == FALL_BACK_TO_NONDELALLOC) {
if (ext4_should_order_data(inode)) {
@@ -2350,6 +2357,14 @@ static int ext4_da_write_end(struct file *file,
}
ret2 = generic_write_end(file, mapping, pos, len, copied,
page, fsdata);
+
+ page_len = PAGE_CACHE_SIZE -
+ ((pos + copied) & (PAGE_CACHE_SIZE - 1));
+
+ ext4_discard_partial_page_buffers_no_lock(handle,
+ inode, page, pos + copied, page_len,
+ EXT4_DSCRD_PARTIAL_PG_ZERO_UNMAPED);
+
copied = ret2;
if (ret2 < 0)
ret = ret2;
--
1.7.1
prev parent reply other threads:[~2011-08-21 2:26 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-08-21 2:29 [PATCH 0/6 v5] ext4: fix 1k block bugs Allison Henderson
2011-08-21 2:29 ` [PATCH 1/6 v5] ext4: Add new ext4_discard_partial_page_buffers routines Allison Henderson
2011-08-22 2:38 ` Ted Ts'o
2011-08-22 14:33 ` Allison Henderson
2011-08-21 2:29 ` [PATCH 2/6 v5] ext4: fix xfstests 75, 112, 127 punch hole failure Allison Henderson
2011-08-21 2:29 ` [PATCH 3/6 v5] ext4: fix 2nd xfstests " Allison Henderson
2011-08-21 2:29 ` [PATCH 4/6 v5] ext4: Correct large hole offset calcuation Allison Henderson
2011-08-22 15:50 ` Eric Sandeen
2011-08-22 17:19 ` Allison Henderson
2011-08-21 2:29 ` [PATCH 5/6 v5] ext4: fix fsx truncate failure Allison Henderson
2011-08-23 2:36 ` Ted Ts'o
2011-08-23 2:51 ` Allison Henderson
2011-08-21 2:29 ` Allison Henderson [this message]
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=1313893787-25460-7-git-send-email-achender@linux.vnet.ibm.com \
--to=achender@linux.vnet.ibm.com \
--cc=linux-ext4@vger.kernel.org \
/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 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).