From: David Chinner <dgc@sgi.com>
To: xfs-dev@sgi.com
Cc: xfs@oss.sgi.com
Subject: Review: Fix sub-page zeroing for buffered writes into unwritten extents
Date: Wed, 24 Jan 2007 09:47:04 +1100 [thread overview]
Message-ID: <20070123224704.GH33919298@melbourne.sgi.com> (raw)
Simple test case:
prealloc large file
write 3000 bytes to the middle of the file
read back file
The data in the block where the 3000 bytes was written has
non-zero garbage around it both in memory and on disk.
The problem is a buffer mapping problem. When we copy data
into an unwritten buffer, we have the create flag set which
means we map the buffer. We then mark the buffer as unwritten,
and do some more checks. Because the buffer is mapped, we do
not set the buffer_new() flag on the buffer, which means when
we return to the generic code, it does not do sub-block zeroing
of the unwritten areas of the block.
The following patch fixes the problem. Comments?
Cheers,
Dave.
--
Dave Chinner
Principal Engineer
SGI Australian Software Group
---
fs/xfs/linux-2.6/xfs_aops.c | 13 +++++++++----
1 file changed, 9 insertions(+), 4 deletions(-)
Index: 2.6.x-xfs-new/fs/xfs/linux-2.6/xfs_aops.c
===================================================================
--- 2.6.x-xfs-new.orig/fs/xfs/linux-2.6/xfs_aops.c 2007-01-23 18:40:45.255241599 +1100
+++ 2.6.x-xfs-new/fs/xfs/linux-2.6/xfs_aops.c 2007-01-23 18:49:13.345681246 +1100
@@ -1282,13 +1282,18 @@ __xfs_get_blocks(
bh_result->b_bdev = iomap.iomap_target->bt_bdev;
/*
- * If we previously allocated a block out beyond eof and we are
- * now coming back to use it then we will need to flag it as new
- * even if it has a disk address.
+ * If we previously allocated a block out beyond eof and we are now
+ * coming back to use it then we will need to flag it as new even if it
+ * has a disk address.
+ *
+ * With sub-block writes into unwritten extents we also need to mark
+ * the buffer as new so that the unwritten parts of the buffer gets
+ * correctly zeroed.
*/
if (create &&
((!buffer_mapped(bh_result) && !buffer_uptodate(bh_result)) ||
- (offset >= i_size_read(inode)) || (iomap.iomap_flags & IOMAP_NEW)))
+ (offset >= i_size_read(inode)) ||
+ (iomap.iomap_flags & (IOMAP_NEW|IOMAP_UNWRITTEN))))
set_buffer_new(bh_result);
if (iomap.iomap_flags & IOMAP_DELAY) {
next reply other threads:[~2007-01-23 22:48 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-01-23 22:47 David Chinner [this message]
2007-01-24 16:44 ` Review: Fix sub-page zeroing for buffered writes into unwritten extents Lachlan McIlroy
2007-01-28 22:22 ` David Chinner
2007-01-29 12:55 ` Lachlan McIlroy
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=20070123224704.GH33919298@melbourne.sgi.com \
--to=dgc@sgi.com \
--cc=xfs-dev@sgi.com \
--cc=xfs@oss.sgi.com \
/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