More patch description fixups. Standardize case.
[ext4-patch-queue.git] / ext4_get_extent_length_fix.patch
blob8e9d25877c6bc3579940271f9d5d354966f9a65f
1 ext4: Use the ext4_ext_actual_len() helper function
3 From: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
5 ext4 uses the high bit of the extent length to encode whether the extent
6 is intialized or not. The helper function ext4_ext_get_actual_len should
7 be used to get the actual length of the extent.
9 This addresses the kernel bug documented here:
10 http://bugzilla.kernel.org/show_bug.cgi?id=9732
12 kernel BUG at fs/ext4/extents.c:1056!
13 ....
14 Call Trace:
15 [<ffffffff88366073>] :ext4dev:ext4_ext_get_blocks+0x5ba/0x8c1
16 [<ffffffff81053c91>] lock_release_holdtime+0x27/0x49
17 [<ffffffff812748f6>] _spin_unlock+0x17/0x20
18 [<ffffffff883400a6>] :jbd2:start_this_handle+0x4e0/0x4fe
19 [<ffffffff88366564>] :ext4dev:ext4_fallocate+0x175/0x39a
20 [<ffffffff81053c91>] lock_release_holdtime+0x27/0x49
21 [<ffffffff81056480>] __lock_acquire+0x4e7/0xc4d
22 [<ffffffff81053c91>] lock_release_holdtime+0x27/0x49
23 [<ffffffff810a8de7>] sys_fallocate+0xe4/0x10d
24 [<ffffffff8100c043>] tracesys+0xd5/0xda
26 Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
27 Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
29 ---
31 fs/ext4/extents.c | 24 +++++++++++++-----------
32 1 file changed, 13 insertions(+), 11 deletions(-)
35 Index: linux-2.6.24-rc7/fs/ext4/extents.c
36 ===================================================================
37 --- linux-2.6.24-rc7.orig/fs/ext4/extents.c 2008-01-16 13:52:34.000000000 -0800
38 +++ linux-2.6.24-rc7/fs/ext4/extents.c 2008-01-16 13:52:37.000000000 -0800
39 @@ -1029,7 +1029,7 @@ ext4_ext_search_left(struct inode *inode
41 struct ext4_extent_idx *ix;
42 struct ext4_extent *ex;
43 - int depth;
44 + int depth, ee_len;
46 BUG_ON(path == NULL);
47 depth = path->p_depth;
48 @@ -1043,6 +1043,7 @@ ext4_ext_search_left(struct inode *inode
49 * first one in the file */
51 ex = path[depth].p_ext;
52 + ee_len = ext4_ext_get_actual_len(ex);
53 if (*logical < le32_to_cpu(ex->ee_block)) {
54 BUG_ON(EXT_FIRST_EXTENT(path[depth].p_hdr) != ex);
55 while (--depth >= 0) {
56 @@ -1052,10 +1053,10 @@ ext4_ext_search_left(struct inode *inode
57 return 0;
60 - BUG_ON(*logical < le32_to_cpu(ex->ee_block) + le16_to_cpu(ex->ee_len));
61 + BUG_ON(*logical < (le32_to_cpu(ex->ee_block) + ee_len));
63 - *logical = le32_to_cpu(ex->ee_block) + le16_to_cpu(ex->ee_len) - 1;
64 - *phys = ext_pblock(ex) + le16_to_cpu(ex->ee_len) - 1;
65 + *logical = le32_to_cpu(ex->ee_block) + ee_len - 1;
66 + *phys = ext_pblock(ex) + ee_len - 1;
67 return 0;
70 @@ -1075,7 +1076,7 @@ ext4_ext_search_right(struct inode *inod
71 struct ext4_extent_idx *ix;
72 struct ext4_extent *ex;
73 ext4_fsblk_t block;
74 - int depth;
75 + int depth, ee_len;
77 BUG_ON(path == NULL);
78 depth = path->p_depth;
79 @@ -1089,6 +1090,7 @@ ext4_ext_search_right(struct inode *inod
80 * first one in the file */
82 ex = path[depth].p_ext;
83 + ee_len = ext4_ext_get_actual_len(ex);
84 if (*logical < le32_to_cpu(ex->ee_block)) {
85 BUG_ON(EXT_FIRST_EXTENT(path[depth].p_hdr) != ex);
86 while (--depth >= 0) {
87 @@ -1100,7 +1102,7 @@ ext4_ext_search_right(struct inode *inod
88 return 0;
91 - BUG_ON(*logical < le32_to_cpu(ex->ee_block) + le16_to_cpu(ex->ee_len));
92 + BUG_ON(*logical < (le32_to_cpu(ex->ee_block) + ee_len));
94 if (ex != EXT_LAST_EXTENT(path[depth].p_hdr)) {
95 /* next allocated block in this leaf */
96 @@ -1316,7 +1318,7 @@ ext4_can_extents_be_merged(struct inode
97 if (ext1_ee_len + ext2_ee_len > max_len)
98 return 0;
99 #ifdef AGGRESSIVE_TEST
100 - if (le16_to_cpu(ex1->ee_len) >= 4)
101 + if (ext1_ee_len >= 4)
102 return 0;
103 #endif
105 @@ -2313,7 +2315,7 @@ int ext4_ext_get_blocks(handle_t *handle
106 - le32_to_cpu(newex.ee_block)
107 + ext_pblock(&newex);
108 /* number of remaining blocks in the extent */
109 - allocated = le16_to_cpu(newex.ee_len) -
110 + allocated = ext4_ext_get_actual_len(&newex) -
111 (iblock - le32_to_cpu(newex.ee_block));
112 goto out;
113 } else {
114 @@ -2429,7 +2431,7 @@ int ext4_ext_get_blocks(handle_t *handle
115 newex.ee_len = cpu_to_le16(max_blocks);
116 err = ext4_ext_check_overlap(inode, &newex, path);
117 if (err)
118 - allocated = le16_to_cpu(newex.ee_len);
119 + allocated = ext4_ext_get_actual_len(&newex);
120 else
121 allocated = max_blocks;
123 @@ -2461,7 +2463,7 @@ int ext4_ext_get_blocks(handle_t *handle
124 * but otherwise we'd need to call it every free() */
125 ext4_mb_discard_inode_preallocations(inode);
126 ext4_free_blocks(handle, inode, ext_pblock(&newex),
127 - le16_to_cpu(newex.ee_len), 0);
128 + ext4_ext_get_actual_len(&newex), 0);
129 goto out2;
132 @@ -2470,7 +2472,7 @@ int ext4_ext_get_blocks(handle_t *handle
134 /* previous routine could use block we allocated */
135 newblock = ext_pblock(&newex);
136 - allocated = le16_to_cpu(newex.ee_len);
137 + allocated = ext4_ext_get_actual_len(&newex);
138 outnew:
139 __set_bit(BH_New, &bh_result->b_state);