Add patch SR-ext4-resize-mark-new-group-EXT_BG_INODE_ZEROED.patch
[ext4-patch-queue/an.git] / Fix-EXT_MAX_BLOCK.patch
blobc0a319799f0601936ea2db4f56cbe3cb8003c15c
1 ext4: fix invalid block number magic for >16 TB fs
3 From: Girish Shilamkar <Girish.Shilamkar@Sun.COM>
5 The magic constant EXT_MAX_BLOCK = 0xffffffff in extents code is used
6 in some places to return "invalid block number", and to set the extent
7 length = "whole file" in other places.
9 So with >= 16 TB fs we would prefer to use it differently. We can have
10 EXT_UNSET_BLOCK = 1 to indicate "invalid block number" as it will never
11 be valid block for allocation. And for the "whole file" use case we can
12 continue using current EXT_MAX_BLOCK.
14 Signed-off-by: Girish Shilamkar <Girish.Shilamkar@Sun.COM>
15 Signed-off-by: Mingming Cao <cmm@us.ibm.com>
16 Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
17 ---
18 fs/ext4/ext4_extents.h | 1 +
19 fs/ext4/extents.c | 20 ++++++++++----------
20 2 files changed, 11 insertions(+), 10 deletions(-)
22 Index: linux-2.6.26-rc9/fs/ext4/ext4_extents.h
23 ===================================================================
24 --- linux-2.6.26-rc9.orig/fs/ext4/ext4_extents.h 2008-07-08 16:52:23.000000000 -0700
25 +++ linux-2.6.26-rc9/fs/ext4/ext4_extents.h 2008-07-08 16:59:41.000000000 -0700
26 @@ -126,6 +126,7 @@ struct ext4_ext_path {
29 #define EXT_MAX_BLOCK 0xffffffff
30 +#define EXT_UNSET_BLOCK 1
33 * EXT_INIT_MAX_LEN is the maximum number of blocks we can have in an
34 Index: linux-2.6.26-rc9/fs/ext4/extents.c
35 ===================================================================
36 --- linux-2.6.26-rc9.orig/fs/ext4/extents.c 2008-07-08 16:52:32.000000000 -0700
37 +++ linux-2.6.26-rc9/fs/ext4/extents.c 2008-07-08 16:59:41.000000000 -0700
38 @@ -1204,7 +1204,7 @@ ext4_ext_search_right(struct inode *inod
41 * ext4_ext_next_allocated_block:
42 - * returns allocated block in subsequent extent or EXT_MAX_BLOCK.
43 + * returns allocated block in subsequent extent or EXT_UNSET_BLOCK.
44 * NOTE: it considers block number from index entry as
45 * allocated block. Thus, index entries have to be consistent
46 * with leaves.
47 @@ -1218,7 +1218,7 @@ ext4_ext_next_allocated_block(struct ext
48 depth = path->p_depth;
50 if (depth == 0 && path->p_ext == NULL)
51 - return EXT_MAX_BLOCK;
52 + return EXT_UNSET_BLOCK;
54 while (depth >= 0) {
55 if (depth == path->p_depth) {
56 @@ -1235,12 +1235,12 @@ ext4_ext_next_allocated_block(struct ext
57 depth--;
60 - return EXT_MAX_BLOCK;
61 + return EXT_UNSET_BLOCK;
65 * ext4_ext_next_leaf_block:
66 - * returns first allocated block from next leaf or EXT_MAX_BLOCK
67 + * returns first allocated block from next leaf or EXT_UNSET_BLOCK
69 static ext4_lblk_t ext4_ext_next_leaf_block(struct inode *inode,
70 struct ext4_ext_path *path)
71 @@ -1252,7 +1252,7 @@ static ext4_lblk_t ext4_ext_next_leaf_bl
73 /* zero-tree has no leaf blocks at all */
74 if (depth == 0)
75 - return EXT_MAX_BLOCK;
76 + return EXT_UNSET_BLOCK;
78 /* go to index block */
79 depth--;
80 @@ -1265,7 +1265,7 @@ static ext4_lblk_t ext4_ext_next_leaf_bl
81 depth--;
84 - return EXT_MAX_BLOCK;
85 + return EXT_UNSET_BLOCK;
89 @@ -1445,7 +1445,7 @@ unsigned int ext4_ext_check_overlap(stru
91 if (b2 < b1) {
92 b2 = ext4_ext_next_allocated_block(path);
93 - if (b2 == EXT_MAX_BLOCK)
94 + if (b2 == EXT_UNSET_BLOCK)
95 goto out;
98 @@ -1524,7 +1524,7 @@ repeat:
99 fex = EXT_LAST_EXTENT(eh);
100 next = ext4_ext_next_leaf_block(inode, path);
101 if (le32_to_cpu(newext->ee_block) > le32_to_cpu(fex->ee_block)
102 - && next != EXT_MAX_BLOCK) {
103 + && next != EXT_UNSET_BLOCK) {
104 ext_debug("next leaf block - %d\n", next);
105 BUG_ON(npath != NULL);
106 npath = ext4_ext_find_extent(inode, next, NULL);
107 @@ -1883,8 +1883,8 @@ ext4_ext_rm_leaf(handle_t *handle, struc
108 path[depth].p_ext = ex;
110 a = ex_ee_block > start ? ex_ee_block : start;
111 - b = ex_ee_block + ex_ee_len - 1 < EXT_MAX_BLOCK ?
112 - ex_ee_block + ex_ee_len - 1 : EXT_MAX_BLOCK;
113 + b = (unsigned long long)ex_ee_block + ex_ee_len - 1 <
114 + EXT_MAX_BLOCK ? ex_ee_block + ex_ee_len - 1 : EXT_MAX_BLOCK;
116 ext_debug(" border %u:%u\n", a, b);