All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH -V4 1/2] Fix sub-block zeroing for buffered writes into unwritten extents
@ 2009-04-29  4:47 Aneesh Kumar K.V
  2009-04-29  4:47 ` [PATCH -V4 2/2] ext4: Use -1 as the fake block number for delayed new buffer_head Aneesh Kumar K.V
                   ` (2 more replies)
  0 siblings, 3 replies; 15+ messages in thread
From: Aneesh Kumar K.V @ 2009-04-29  4:47 UTC (permalink / raw)
  To: cmm, tytso, sandeen; +Cc: linux-ext4, Aneesh Kumar K.V

We need to mark the  buffer_head mapping prealloc space
as new during write_begin. Otherwise we don't zero out the
page cache content properly for a partial write. This will
cause file corruption with preallocation.

Also use block number -1 as the fake block number so that
unmap_underlying_metadata doesn't drop wrong buffer_head

Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>

---
 fs/ext4/inode.c |   10 ++++++++++
 1 files changed, 10 insertions(+), 0 deletions(-)

diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
index e91f978..12dcfab 100644
--- a/fs/ext4/inode.c
+++ b/fs/ext4/inode.c
@@ -2323,6 +2323,16 @@ static int ext4_da_get_block_prep(struct inode *inode, sector_t iblock,
 		set_buffer_delay(bh_result);
 	} else if (ret > 0) {
 		bh_result->b_size = (ret << inode->i_blkbits);
+		/*
+		 * 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 (buffer_unwritten(bh_result)) {
+			bh_result->b_bdev = inode->i_sb->s_bdev;
+			set_buffer_new(bh_result);
+			bh_result->b_blocknr = -1;
+		}
 		ret = 0;
 	}
 
-- 
tg: (56a50ad..) preallocate_corruption_quickfix (depends on: master)

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

end of thread, other threads:[~2009-05-12 15:18 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-04-29  4:47 [PATCH -V4 1/2] Fix sub-block zeroing for buffered writes into unwritten extents Aneesh Kumar K.V
2009-04-29  4:47 ` [PATCH -V4 2/2] ext4: Use -1 as the fake block number for delayed new buffer_head Aneesh Kumar K.V
2009-04-29 13:59   ` Eric Sandeen
2009-04-29 15:35   ` Theodore Tso
2009-04-29 15:37     ` Eric Sandeen
2009-04-29 16:52       ` Theodore Tso
2009-04-29 17:01         ` Eric Sandeen
2009-05-04  8:54     ` Aneesh Kumar K.V
2009-05-04 15:06       ` Eric Sandeen
2009-05-12 15:17   ` [PATCH -V5] " Aneesh Kumar K.V
2009-04-29 13:59 ` [PATCH -V4 1/2] Fix sub-block zeroing for buffered writes into unwritten extents Eric Sandeen
2009-04-29 17:28   ` Mingming
2009-05-12  2:42 ` Theodore Tso
2009-05-12  3:37   ` Eric Sandeen
2009-05-12 15:16   ` [PATCH -V5] Fix sub-block zeroing for buffered writes intounwritten extents Aneesh Kumar K.V

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.