]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - releases/2.6.32.17/0012-ext4-Drop-EXT4_GET_BLOCKS_UPDATE_RESERVE_SPACE-flag.patch
4.9-stable patches
[thirdparty/kernel/stable-queue.git] / releases / 2.6.32.17 / 0012-ext4-Drop-EXT4_GET_BLOCKS_UPDATE_RESERVE_SPACE-flag.patch
1 From 3a1a12ca4219f564fe4f86cae1bfb563422a2d15 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:26 -0400
4 Subject: ext4: Drop EXT4_GET_BLOCKS_UPDATE_RESERVE_SPACE flag
5
6 commit 1296cc85c26e94eb865d03f82140f27d598de467 upstream (as of v2.6.33-rc6)
7
8 We should update reserve space if it is delalloc buffer
9 and that is indicated by EXT4_GET_BLOCKS_DELALLOC_RESERVE flag.
10 So use EXT4_GET_BLOCKS_DELALLOC_RESERVE in place of
11 EXT4_GET_BLOCKS_UPDATE_RESERVE_SPACE
12
13 [ Stable note: This fixes a corruption cuased by the following
14 reproduction case:
15
16 rm -f $TEST_FN
17 touch $TEST_FN
18 fallocate -n -o 656712 -l 858907 $TEST_FN
19 dd if=/dev/zero of=$TEST_FN conv=notrunc bs=1 seek=1011020 count=36983
20 sync
21 dd if=/dev/zero of=$TEST_FN conv=notrunc bs=1 seek=332121 count=24005
22 dd if=/dev/zero of=$TEST_FN conv=notrunc bs=1 seek=1040179 count=93319
23
24 If the filesystem is then unmounted and e2fsck run forced, the
25 i_blocks field for the file $TEST_FN will be found to be incorrect. ]
26
27 Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
28 Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
29 Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
30 ---
31 fs/ext4/ext4.h | 7 ++-----
32 fs/ext4/extents.c | 4 ++--
33 fs/ext4/inode.c | 8 ++++----
34 3 files changed, 8 insertions(+), 11 deletions(-)
35
36 --- a/fs/ext4/ext4.h
37 +++ b/fs/ext4/ext4.h
38 @@ -361,14 +361,11 @@ struct ext4_new_group_data {
39 so set the magic i_delalloc_reserve_flag after taking the
40 inode allocation semaphore for */
41 #define EXT4_GET_BLOCKS_DELALLOC_RESERVE 0x0004
42 - /* Call ext4_da_update_reserve_space() after successfully
43 - allocating the blocks */
44 -#define EXT4_GET_BLOCKS_UPDATE_RESERVE_SPACE 0x0008
45 /* caller is from the direct IO path, request to creation of an
46 unitialized extents if not allocated, split the uninitialized
47 extent if blocks has been preallocated already*/
48 -#define EXT4_GET_BLOCKS_DIO 0x0010
49 -#define EXT4_GET_BLOCKS_CONVERT 0x0020
50 +#define EXT4_GET_BLOCKS_DIO 0x0008
51 +#define EXT4_GET_BLOCKS_CONVERT 0x0010
52 #define EXT4_GET_BLOCKS_DIO_CREATE_EXT (EXT4_GET_BLOCKS_DIO|\
53 EXT4_GET_BLOCKS_CREATE_UNINIT_EXT)
54 /* Convert extent to initialized after direct IO complete */
55 --- a/fs/ext4/extents.c
56 +++ b/fs/ext4/extents.c
57 @@ -3148,7 +3148,7 @@ out:
58 * But fallocate would have already updated quota and block
59 * count for this offset. So cancel these reservation
60 */
61 - if (flags & EXT4_GET_BLOCKS_UPDATE_RESERVE_SPACE)
62 + if (flags & EXT4_GET_BLOCKS_DELALLOC_RESERVE)
63 ext4_da_update_reserve_space(inode, allocated, 0);
64
65 map_out:
66 @@ -3394,7 +3394,7 @@ int ext4_ext_get_blocks(handle_t *handle
67 * Update reserved blocks/metadata blocks after successful
68 * block allocation which had been deferred till now.
69 */
70 - if (flags & EXT4_GET_BLOCKS_UPDATE_RESERVE_SPACE)
71 + if (flags & EXT4_GET_BLOCKS_DELALLOC_RESERVE)
72 ext4_da_update_reserve_space(inode, allocated, 1);
73
74 /*
75 --- a/fs/ext4/inode.c
76 +++ b/fs/ext4/inode.c
77 @@ -1358,7 +1358,7 @@ int ext4_get_blocks(handle_t *handle, st
78 * reserve space here.
79 */
80 if ((retval > 0) &&
81 - (flags & EXT4_GET_BLOCKS_UPDATE_RESERVE_SPACE))
82 + (flags & EXT4_GET_BLOCKS_DELALLOC_RESERVE))
83 ext4_da_update_reserve_space(inode, retval, 1);
84 }
85 if (flags & EXT4_GET_BLOCKS_DELALLOC_RESERVE)
86 @@ -2261,10 +2261,10 @@ static int mpage_da_map_blocks(struct mp
87 * variables are updated after the blocks have been allocated.
88 */
89 new.b_state = 0;
90 - get_blocks_flags = (EXT4_GET_BLOCKS_CREATE |
91 - EXT4_GET_BLOCKS_DELALLOC_RESERVE);
92 + get_blocks_flags = EXT4_GET_BLOCKS_CREATE;
93 if (mpd->b_state & (1 << BH_Delay))
94 - get_blocks_flags |= EXT4_GET_BLOCKS_UPDATE_RESERVE_SPACE;
95 + get_blocks_flags |= EXT4_GET_BLOCKS_DELALLOC_RESERVE;
96 +
97 blks = ext4_get_blocks(handle, mpd->inode, next, max_blocks,
98 &new, get_blocks_flags);
99 if (blks < 0) {