]> git.ipfire.org Git - people/teissler/ipfire-2.x.git/blob - src/patches/suse-2.6.27.31/patches.fixes/ext4-clear-unwritten-flag-after-extent-initialization
Merge branch 'master' of git://git.ipfire.org/ipfire-2.x
[people/teissler/ipfire-2.x.git] / src / patches / suse-2.6.27.31 / patches.fixes / ext4-clear-unwritten-flag-after-extent-initialization
1 From: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
2 Date: Thu, 14 May 2009 21:05:39 +0000 (-0400)
3 Subject: ext4: Clear the unwritten buffer_head flag after the extent is initialized
4 Patch-mainline: 2.6.30-rc6
5 Git-commit: 2a8964d63d50dd2d65d71d342bc7fb6ef4117614
6 References: bnc#503161
7
8 ext4: Clear the unwritten buffer_head flag after the extent is initialized
9
10 The BH_Unwritten flag indicates that the buffer is allocated on disk
11 but has not been written; that is, the disk was part of a persistent
12 preallocation area. That flag should only be set when a get_blocks()
13 function is looking up a inode's logical to physical block mapping.
14
15 When ext4_get_blocks_wrap() is called with create=1, the uninitialized
16 extent is converted into an initialized one, so the BH_Unwritten flag
17 is no longer appropriate. Hence, we need to make sure the
18 BH_Unwritten is not left set, since the combination of BH_Mapped and
19 BH_Unwritten is not allowed; among other things, it will result ext4's
20 get_block() to be called over and over again during the write_begin
21 phase of write(2).
22
23 Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
24 Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
25 Acked-by: Jeff Mahoney <jeffm@suse.com>
26 ---
27
28 fs/ext4/inode.c | 13 +++++++++++++
29 1 file changed, 13 insertions(+)
30
31 --- a/fs/ext4/inode.c
32 +++ b/fs/ext4/inode.c
33 @@ -1058,6 +1058,7 @@ int ext4_get_blocks_wrap(handle_t *handl
34 int retval;
35
36 clear_buffer_mapped(bh);
37 + clear_buffer_unwritten(bh);
38
39 /*
40 * Try to see if we can get the block without requesting
41 @@ -1088,6 +1089,18 @@ int ext4_get_blocks_wrap(handle_t *handl
42 return retval;
43
44 /*
45 + * When we call get_blocks without the create flag, the
46 + * BH_Unwritten flag could have gotten set if the blocks
47 + * requested were part of a uninitialized extent. We need to
48 + * clear this flag now that we are committed to convert all or
49 + * part of the uninitialized extent to be an initialized
50 + * extent. This is because we need to avoid the combination
51 + * of BH_Unwritten and BH_Mapped flags being simultaneously
52 + * set on the buffer_head.
53 + */
54 + clear_buffer_unwritten(bh);
55 +
56 + /*
57 * New blocks allocate and/or writing to uninitialized extent
58 * will possibly result in updating i_data, so we take
59 * the write lock of i_data_sem, and call get_blocks()