]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - releases/2.6.32.17/0006-ext4-Ensure-zeroout-blocks-have-no-dirty-metadata.patch
4.9-stable patches
[thirdparty/kernel/stable-queue.git] / releases / 2.6.32.17 / 0006-ext4-Ensure-zeroout-blocks-have-no-dirty-metadata.patch
1 From 436e2704a8b589fb1217add4f9e5be480773ca6c Mon Sep 17 00:00:00 2001
2 From: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
3 Date: Sun, 30 May 2010 22:49:20 -0400
4 Subject: ext4: Ensure zeroout blocks have no dirty metadata
5
6 commit 515f41c33a9d44a964264c9511ad2c869af1fac3 upstream (as of v2.6.33-rc3)
7
8 This fixes a bug (found by Curt Wohlgemuth) in which new blocks
9 returned from an extent created with ext4_ext_zeroout() can have dirty
10 metadata still associated with them.
11
12 Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
13 Signed-off-by: Curt Wohlgemuth <curtw@google.com>
14 Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
15 Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
16 ---
17 fs/ext4/extents.c | 20 ++++++++++++++++++++
18 1 file changed, 20 insertions(+)
19
20 --- a/fs/ext4/extents.c
21 +++ b/fs/ext4/extents.c
22 @@ -3029,6 +3029,14 @@ out:
23 return err;
24 }
25
26 +static void unmap_underlying_metadata_blocks(struct block_device *bdev,
27 + sector_t block, int count)
28 +{
29 + int i;
30 + for (i = 0; i < count; i++)
31 + unmap_underlying_metadata(bdev, block + i);
32 +}
33 +
34 static int
35 ext4_ext_handle_uninitialized_extents(handle_t *handle, struct inode *inode,
36 ext4_lblk_t iblock, unsigned int max_blocks,
37 @@ -3104,6 +3112,18 @@ out:
38 } else
39 allocated = ret;
40 set_buffer_new(bh_result);
41 + /*
42 + * if we allocated more blocks than requested
43 + * we need to make sure we unmap the extra block
44 + * allocated. The actual needed block will get
45 + * unmapped later when we find the buffer_head marked
46 + * new.
47 + */
48 + if (allocated > max_blocks) {
49 + unmap_underlying_metadata_blocks(inode->i_sb->s_bdev,
50 + newblock + max_blocks,
51 + allocated - max_blocks);
52 + }
53 map_out:
54 set_buffer_mapped(bh_result);
55 out1: