From: Yongqiang Yang <xiaoqiangnk@gmail.com>
To: linux-ext4@vger.kernel.org
Cc: achender@linux.vnet.ibm.com, hughd@google.com, tytso@mit.edu,
Yongqiang Yang <xiaoqiangnk@gmail.com>
Subject: [PATCH 2/2] ext4: let ext4_bio_write_page handle EOF correctly
Date: Wed, 7 Dec 2011 13:21:27 +0800 [thread overview]
Message-ID: <1323235287-29806-2-git-send-email-xiaoqiangnk@gmail.com> (raw)
In-Reply-To: <1323235287-29806-1-git-send-email-xiaoqiangnk@gmail.com>
We need to zero out part of a page which beyond EOF before setting uptodate,
otherwise, mapread or write will see non-zero data beyond EOF.
Signed-off-by: Yongqiang Yang <xiaoqiangnk@gmail.com>
---
fs/ext4/page-io.c | 12 ++++++++++++
1 files changed, 12 insertions(+), 0 deletions(-)
diff --git a/fs/ext4/page-io.c b/fs/ext4/page-io.c
index 235b79d..9e145b8 100644
--- a/fs/ext4/page-io.c
+++ b/fs/ext4/page-io.c
@@ -385,6 +385,18 @@ int ext4_bio_write_page(struct ext4_io_submit *io,
block_end = block_start + blocksize;
if (block_start >= len) {
+ /*
+ * Comments copied from block_write_full_page_endio:
+ *
+ * The page straddles i_size. It must be zeroed out on
+ * each and every writepage invocation because it may
+ * be mmapped. "A file is mapped in multiples of the
+ * page size. For a file that is not a multiple of
+ * the page size, the remaining memory is zeroed when
+ * mapped, and writes to that region are not written
+ * out to the file."
+ */
+ zero_user_segment(page, block_start, block_end);
clear_buffer_dirty(bh);
set_buffer_uptodate(bh);
continue;
--
1.7.5.1
next prev parent reply other threads:[~2011-12-07 8:23 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-12-07 5:21 [PATCH 1/2] ext4: remove a wrong BUG_ON in ext4_ext_convert_to_initialized Yongqiang Yang
2011-12-07 5:21 ` Yongqiang Yang [this message]
2011-12-14 3:33 ` [PATCH 2/2] ext4: let ext4_bio_write_page handle EOF correctly Ted Ts'o
2011-12-09 22:41 ` [PATCH 1/2] ext4: remove a wrong BUG_ON in ext4_ext_convert_to_initialized Eric Gouriou
[not found] ` <CAGBYx2boc0OtAOq7BNurQkCZG0Oeyf2LLd+F-9EvwL31CNccmw@mail.gmail.com>
2011-12-13 0:01 ` Eric Gouriou
2011-12-14 3:33 ` Ted 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=1323235287-29806-2-git-send-email-xiaoqiangnk@gmail.com \
--to=xiaoqiangnk@gmail.com \
--cc=achender@linux.vnet.ibm.com \
--cc=hughd@google.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 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).