]> git.ipfire.org Git - people/pmueller/ipfire-2.x.git/blame - src/patches/suse-2.6.27.39/patches.fixes/ext4-fix-sub-block-zeroing-for-preallocated-writes
Fix oinkmaster patch.
[people/pmueller/ipfire-2.x.git] / src / patches / suse-2.6.27.39 / patches.fixes / ext4-fix-sub-block-zeroing-for-preallocated-writes
CommitLineData
2cb7cef9
BS
1From: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
2Date: Wed, 13 May 2009 22:36:58 +0000 (-0400)
3Subject: ext4: Fix sub-block zeroing for writes into preallocated extents
4Patch-mainline: 2.6.30
5Git-commit: 9c1ee184a30394e54165fa4c15923cabd952c106
6References: bnc#503161
7
8ext4: Fix sub-block zeroing for writes into preallocated extents
9
10We need to mark the buffer_head mapping preallocated space as new
11during write_begin. Otherwise we don't zero out the page cache content
12properly for a partial write. This will cause file corruption with
13preallocation.
14
15Now that we mark the buffer_head new we also need to have a valid
16buffer_head blocknr so that unmap_underlying_metadata() unmaps the
17correct block.
18
19Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
20Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
21Acked-by: Jeff Mahoney <jeffm@suse.com>
22---
23
24 fs/ext4/extents.c | 2 ++
25 fs/ext4/inode.c | 7 +++++++
26 2 files changed, 9 insertions(+)
27
28--- a/fs/ext4/extents.c
29+++ b/fs/ext4/extents.c
30@@ -2664,6 +2664,8 @@ int ext4_ext_get_blocks(handle_t *handle
31 if (allocated > max_blocks)
32 allocated = max_blocks;
33 set_buffer_unwritten(bh_result);
34+ bh_result->b_bdev = inode->i_sb->s_bdev;
35+ bh_result->b_blocknr = newblock;
36 goto out2;
37 }
38
39--- a/fs/ext4/inode.c
40+++ b/fs/ext4/inode.c
41@@ -2220,6 +2220,13 @@ static int ext4_da_get_block_prep(struct
42 set_buffer_delay(bh_result);
43 } else if (ret > 0) {
44 bh_result->b_size = (ret << inode->i_blkbits);
45+ /*
46+ * With sub-block writes into unwritten extents
47+ * we also need to mark the buffer as new so that
48+ * the unwritten parts of the buffer gets correctly zeroed.
49+ */
50+ if (buffer_unwritten(bh_result))
51+ set_buffer_new(bh_result);
52 ret = 0;
53 }
54