More patch description fixups. Standardize case.
[ext4-patch-queue.git] / ext4_grp_t.patch
blobcbd1f534d507d5d85d84871e845c121ddb829651
1 ext4: add ext4_group_t, and change all group variables to this type.
3 From: Avantika Mathur <mathur@us.ibm.com>
5 In many places variables for block group are of type int, which limits the
6 maximum number of block groups to 2^31. Each block group can have up to
7 2^15 blocks, with a 4K block size, and the max filesystem size is limited to
8 2^31 * (2^15 * 2^12) = 2^58 -- or 256 PB
10 This patch introduces a new type ext4_group_t, of type unsigned long, to
11 represent block group numbers in ext4.
12 All occurrences of block group variables are converted to type ext4_group_t.
14 Signed-off-by: Avantika Mathur <mathur@us.ibm.com>
15 ---
17 fs/ext4/balloc.c | 69 +++++++++++++++++++++-----------------------
18 fs/ext4/group.h | 8 +++--
19 fs/ext4/ialloc.c | 46 +++++++++++++++--------------
20 fs/ext4/inode.c | 5 ++-
21 fs/ext4/resize.c | 12 ++++----
22 fs/ext4/super.c | 20 ++++++-------
23 include/linux/ext4_fs.h | 11 ++++---
24 include/linux/ext4_fs_i.h | 5 +++
25 include/linux/ext4_fs_sb.h | 2 +
26 9 files changed, 91 insertions(+), 87 deletions(-)
29 diff --git a/fs/ext4/balloc.c b/fs/ext4/balloc.c
30 index 71ee95e..9568a57 100644
31 --- a/fs/ext4/balloc.c
32 +++ b/fs/ext4/balloc.c
33 @@ -29,7 +29,7 @@
34 * Calculate the block group number and offset, given a block number
36 void ext4_get_group_no_and_offset(struct super_block *sb, ext4_fsblk_t blocknr,
37 - unsigned long *blockgrpp, ext4_grpblk_t *offsetp)
38 + ext4_group_t *blockgrpp, ext4_grpblk_t *offsetp)
40 struct ext4_super_block *es = EXT4_SB(sb)->s_es;
41 ext4_grpblk_t offset;
42 @@ -46,7 +46,7 @@ void ext4_get_group_no_and_offset(struct super_block *sb, ext4_fsblk_t blocknr,
43 /* Initializes an uninitialized block bitmap if given, and returns the
44 * number of blocks free in the group. */
45 unsigned ext4_init_block_bitmap(struct super_block *sb, struct buffer_head *bh,
46 - int block_group, struct ext4_group_desc *gdp)
47 + ext4_group_t block_group, struct ext4_group_desc *gdp)
49 unsigned long start;
50 int bit, bit_max;
51 @@ -60,7 +60,7 @@ unsigned ext4_init_block_bitmap(struct super_block *sb, struct buffer_head *bh,
52 * essentially implementing a per-group read-only flag. */
53 if (!ext4_group_desc_csum_verify(sbi, block_group, gdp)) {
54 ext4_error(sb, __FUNCTION__,
55 - "Checksum bad for group %u\n", block_group);
56 + "Checksum bad for group %lu\n", block_group);
57 gdp->bg_free_blocks_count = 0;
58 gdp->bg_free_inodes_count = 0;
59 gdp->bg_itable_unused = 0;
60 @@ -153,7 +153,7 @@ unsigned ext4_init_block_bitmap(struct super_block *sb, struct buffer_head *bh,
61 * group descriptor
63 struct ext4_group_desc * ext4_get_group_desc(struct super_block * sb,
64 - unsigned int block_group,
65 + ext4_group_t block_group,
66 struct buffer_head ** bh)
68 unsigned long group_desc;
69 @@ -164,7 +164,7 @@ struct ext4_group_desc * ext4_get_group_desc(struct super_block * sb,
70 if (block_group >= sbi->s_groups_count) {
71 ext4_error (sb, "ext4_get_group_desc",
72 "block_group >= groups_count - "
73 - "block_group = %d, groups_count = %lu",
74 + "block_group = %lu, groups_count = %lu",
75 block_group, sbi->s_groups_count);
77 return NULL;
78 @@ -176,7 +176,7 @@ struct ext4_group_desc * ext4_get_group_desc(struct super_block * sb,
79 if (!sbi->s_group_desc[group_desc]) {
80 ext4_error (sb, "ext4_get_group_desc",
81 "Group descriptor not loaded - "
82 - "block_group = %d, group_desc = %lu, desc = %lu",
83 + "block_group = %lu, group_desc = %lu, desc = %lu",
84 block_group, group_desc, offset);
85 return NULL;
87 @@ -200,7 +200,7 @@ struct ext4_group_desc * ext4_get_group_desc(struct super_block * sb,
88 * Return buffer_head on success or NULL in case of failure.
90 struct buffer_head *
91 -read_block_bitmap(struct super_block *sb, unsigned int block_group)
92 +read_block_bitmap(struct super_block *sb, ext4_group_t block_group)
94 struct ext4_group_desc * desc;
95 struct buffer_head * bh = NULL;
96 @@ -227,7 +227,7 @@ read_block_bitmap(struct super_block *sb, unsigned int block_group)
97 if (!bh)
98 ext4_error (sb, __FUNCTION__,
99 "Cannot read block bitmap - "
100 - "block_group = %d, block_bitmap = %llu",
101 + "block_group = %lu, block_bitmap = %llu",
102 block_group, bitmap_blk);
103 return bh;
105 @@ -320,7 +320,7 @@ restart:
107 static int
108 goal_in_my_reservation(struct ext4_reserve_window *rsv, ext4_grpblk_t grp_goal,
109 - unsigned int group, struct super_block * sb)
110 + ext4_group_t group, struct super_block *sb)
112 ext4_fsblk_t group_first_block, group_last_block;
114 @@ -540,7 +540,7 @@ void ext4_free_blocks_sb(handle_t *handle, struct super_block *sb,
116 struct buffer_head *bitmap_bh = NULL;
117 struct buffer_head *gd_bh;
118 - unsigned long block_group;
119 + ext4_group_t block_group;
120 ext4_grpblk_t bit;
121 unsigned long i;
122 unsigned long overflow;
123 @@ -920,9 +920,10 @@ claim_block(spinlock_t *lock, ext4_grpblk_t block, struct buffer_head *bh)
124 * ext4_journal_release_buffer(), else we'll run out of credits.
126 static ext4_grpblk_t
127 -ext4_try_to_allocate(struct super_block *sb, handle_t *handle, int group,
128 - struct buffer_head *bitmap_bh, ext4_grpblk_t grp_goal,
129 - unsigned long *count, struct ext4_reserve_window *my_rsv)
130 +ext4_try_to_allocate(struct super_block *sb, handle_t *handle,
131 + ext4_group_t group, struct buffer_head *bitmap_bh,
132 + ext4_grpblk_t grp_goal, unsigned long *count,
133 + struct ext4_reserve_window *my_rsv)
135 ext4_fsblk_t group_first_block;
136 ext4_grpblk_t start, end;
137 @@ -1156,7 +1157,7 @@ static int find_next_reservable_window(
139 static int alloc_new_reservation(struct ext4_reserve_window_node *my_rsv,
140 ext4_grpblk_t grp_goal, struct super_block *sb,
141 - unsigned int group, struct buffer_head *bitmap_bh)
142 + ext4_group_t group, struct buffer_head *bitmap_bh)
144 struct ext4_reserve_window_node *search_head;
145 ext4_fsblk_t group_first_block, group_end_block, start_block;
146 @@ -1354,7 +1355,7 @@ static void try_to_extend_reservation(struct ext4_reserve_window_node *my_rsv,
148 static ext4_grpblk_t
149 ext4_try_to_allocate_with_rsv(struct super_block *sb, handle_t *handle,
150 - unsigned int group, struct buffer_head *bitmap_bh,
151 + ext4_group_t group, struct buffer_head *bitmap_bh,
152 ext4_grpblk_t grp_goal,
153 struct ext4_reserve_window_node * my_rsv,
154 unsigned long *count, int *errp)
155 @@ -1528,12 +1529,12 @@ ext4_fsblk_t ext4_new_blocks(handle_t *handle, struct inode *inode,
157 struct buffer_head *bitmap_bh = NULL;
158 struct buffer_head *gdp_bh;
159 - unsigned long group_no;
160 - int goal_group;
161 + ext4_group_t group_no;
162 + ext4_group_t goal_group;
163 ext4_grpblk_t grp_target_blk; /* blockgroup relative goal block */
164 ext4_grpblk_t grp_alloc_blk; /* blockgroup-relative allocated block*/
165 ext4_fsblk_t ret_block; /* filesyetem-wide allocated block */
166 - int bgi; /* blockgroup iteration index */
167 + ext4_group_t bgi; /* blockgroup iteration index */
168 int fatal = 0, err;
169 int performed_allocation = 0;
170 ext4_grpblk_t free_blocks; /* number of free blocks in a group */
171 @@ -1544,10 +1545,7 @@ ext4_fsblk_t ext4_new_blocks(handle_t *handle, struct inode *inode,
172 struct ext4_reserve_window_node *my_rsv = NULL;
173 struct ext4_block_alloc_info *block_i;
174 unsigned short windowsz = 0;
175 -#ifdef EXT4FS_DEBUG
176 - static int goal_hits, goal_attempts;
177 -#endif
178 - unsigned long ngroups;
179 + ext4_group_t ngroups;
180 unsigned long num = *count;
182 *errp = -ENOSPC;
183 @@ -1743,9 +1741,6 @@ allocated:
184 * list of some description. We don't know in advance whether
185 * the caller wants to use it as metadata or data.
187 - ext4_debug("allocating block %lu. Goal hits %d of %d.\n",
188 - ret_block, goal_hits, goal_attempts);
190 spin_lock(sb_bgl_lock(sbi, group_no));
191 if (gdp->bg_flags & cpu_to_le16(EXT4_BG_BLOCK_UNINIT))
192 gdp->bg_flags &= cpu_to_le16(~EXT4_BG_BLOCK_UNINIT);
193 @@ -1804,8 +1799,8 @@ ext4_fsblk_t ext4_count_free_blocks(struct super_block *sb)
195 ext4_fsblk_t desc_count;
196 struct ext4_group_desc *gdp;
197 - int i;
198 - unsigned long ngroups = EXT4_SB(sb)->s_groups_count;
199 + ext4_group_t i;
200 + ext4_group_t ngroups = EXT4_SB(sb)->s_groups_count;
201 #ifdef EXT4FS_DEBUG
202 struct ext4_super_block *es;
203 ext4_fsblk_t bitmap_count;
204 @@ -1829,7 +1824,7 @@ ext4_fsblk_t ext4_count_free_blocks(struct super_block *sb)
205 continue;
207 x = ext4_count_free(bitmap_bh, sb->s_blocksize);
208 - printk("group %d: stored = %d, counted = %lu\n",
209 + printk(KERN_DEBUG "group %lu: stored = %d, counted = %lu\n",
210 i, le16_to_cpu(gdp->bg_free_blocks_count), x);
211 bitmap_count += x;
213 @@ -1853,7 +1848,7 @@ ext4_fsblk_t ext4_count_free_blocks(struct super_block *sb)
214 #endif
217 -static inline int test_root(int a, int b)
218 +static inline int test_root(ext4_group_t a, int b)
220 int num = b;
222 @@ -1862,7 +1857,7 @@ static inline int test_root(int a, int b)
223 return num == a;
226 -static int ext4_group_sparse(int group)
227 +static int ext4_group_sparse(ext4_group_t group)
229 if (group <= 1)
230 return 1;
231 @@ -1880,7 +1875,7 @@ static int ext4_group_sparse(int group)
232 * Return the number of blocks used by the superblock (primary or backup)
233 * in this group. Currently this will be only 0 or 1.
235 -int ext4_bg_has_super(struct super_block *sb, int group)
236 +int ext4_bg_has_super(struct super_block *sb, ext4_group_t group)
238 if (EXT4_HAS_RO_COMPAT_FEATURE(sb,
239 EXT4_FEATURE_RO_COMPAT_SPARSE_SUPER) &&
240 @@ -1889,18 +1884,20 @@ int ext4_bg_has_super(struct super_block *sb, int group)
241 return 1;
244 -static unsigned long ext4_bg_num_gdb_meta(struct super_block *sb, int group)
245 +static unsigned long ext4_bg_num_gdb_meta(struct super_block *sb,
246 + ext4_group_t group)
248 unsigned long metagroup = group / EXT4_DESC_PER_BLOCK(sb);
249 - unsigned long first = metagroup * EXT4_DESC_PER_BLOCK(sb);
250 - unsigned long last = first + EXT4_DESC_PER_BLOCK(sb) - 1;
251 + ext4_group_t first = metagroup * EXT4_DESC_PER_BLOCK(sb);
252 + ext4_group_t last = first + EXT4_DESC_PER_BLOCK(sb) - 1;
254 if (group == first || group == first + 1 || group == last)
255 return 1;
256 return 0;
259 -static unsigned long ext4_bg_num_gdb_nometa(struct super_block *sb, int group)
260 +static unsigned long ext4_bg_num_gdb_nometa(struct super_block *sb,
261 + ext4_group_t group)
263 if (EXT4_HAS_RO_COMPAT_FEATURE(sb,
264 EXT4_FEATURE_RO_COMPAT_SPARSE_SUPER) &&
265 @@ -1918,7 +1915,7 @@ static unsigned long ext4_bg_num_gdb_nometa(struct super_block *sb, int group)
266 * (primary or backup) in this group. In the future there may be a
267 * different number of descriptor blocks in each group.
269 -unsigned long ext4_bg_num_gdb(struct super_block *sb, int group)
270 +unsigned long ext4_bg_num_gdb(struct super_block *sb, ext4_group_t group)
272 unsigned long first_meta_bg =
273 le32_to_cpu(EXT4_SB(sb)->s_es->s_first_meta_bg);
274 diff --git a/fs/ext4/group.h b/fs/ext4/group.h
275 index 1577910..7eb0604 100644
276 --- a/fs/ext4/group.h
277 +++ b/fs/ext4/group.h
278 @@ -14,14 +14,16 @@ extern __le16 ext4_group_desc_csum(struct ext4_sb_info *sbi, __u32 group,
279 extern int ext4_group_desc_csum_verify(struct ext4_sb_info *sbi, __u32 group,
280 struct ext4_group_desc *gdp);
281 struct buffer_head *read_block_bitmap(struct super_block *sb,
282 - unsigned int block_group);
283 + ext4_group_t block_group);
284 extern unsigned ext4_init_block_bitmap(struct super_block *sb,
285 - struct buffer_head *bh, int group,
286 + struct buffer_head *bh,
287 + ext4_group_t group,
288 struct ext4_group_desc *desc);
289 #define ext4_free_blocks_after_init(sb, group, desc) \
290 ext4_init_block_bitmap(sb, NULL, group, desc)
291 extern unsigned ext4_init_inode_bitmap(struct super_block *sb,
292 - struct buffer_head *bh, int group,
293 + struct buffer_head *bh,
294 + ext4_group_t group,
295 struct ext4_group_desc *desc);
296 extern void mark_bitmap_end(int start_bit, int end_bit, char *bitmap);
297 #endif /* _LINUX_EXT4_GROUP_H */
298 diff --git a/fs/ext4/ialloc.c b/fs/ext4/ialloc.c
299 index c61f37f..64dea86 100644
300 --- a/fs/ext4/ialloc.c
301 +++ b/fs/ext4/ialloc.c
302 @@ -64,8 +64,8 @@ void mark_bitmap_end(int start_bit, int end_bit, char *bitmap)
305 /* Initializes an uninitialized inode bitmap */
306 -unsigned ext4_init_inode_bitmap(struct super_block *sb,
307 - struct buffer_head *bh, int block_group,
308 +unsigned ext4_init_inode_bitmap(struct super_block *sb, struct buffer_head *bh,
309 + ext4_group_t block_group,
310 struct ext4_group_desc *gdp)
312 struct ext4_sb_info *sbi = EXT4_SB(sb);
313 @@ -75,7 +75,7 @@ unsigned ext4_init_inode_bitmap(struct super_block *sb,
314 /* If checksum is bad mark all blocks and inodes use to prevent
315 * allocation, essentially implementing a per-group read-only flag. */
316 if (!ext4_group_desc_csum_verify(sbi, block_group, gdp)) {
317 - ext4_error(sb, __FUNCTION__, "Checksum bad for group %u\n",
318 + ext4_error(sb, __FUNCTION__, "Checksum bad for group %lu\n",
319 block_group);
320 gdp->bg_free_blocks_count = 0;
321 gdp->bg_free_inodes_count = 0;
322 @@ -98,7 +98,7 @@ unsigned ext4_init_inode_bitmap(struct super_block *sb,
323 * Return buffer_head of bitmap on success or NULL.
325 static struct buffer_head *
326 -read_inode_bitmap(struct super_block * sb, unsigned long block_group)
327 +read_inode_bitmap(struct super_block *sb, ext4_group_t block_group)
329 struct ext4_group_desc *desc;
330 struct buffer_head *bh = NULL;
331 @@ -152,7 +152,7 @@ void ext4_free_inode (handle_t *handle, struct inode * inode)
332 unsigned long ino;
333 struct buffer_head *bitmap_bh = NULL;
334 struct buffer_head *bh2;
335 - unsigned long block_group;
336 + ext4_group_t block_group;
337 unsigned long bit;
338 struct ext4_group_desc * gdp;
339 struct ext4_super_block * es;
340 @@ -260,12 +260,12 @@ error_return:
341 * For other inodes, search forward from the parent directory\'s block
342 * group to find a free inode.
344 -static int find_group_dir(struct super_block *sb, struct inode *parent)
345 +static ext4_group_t find_group_dir(struct super_block *sb, struct inode *parent)
347 - int ngroups = EXT4_SB(sb)->s_groups_count;
348 + ext4_group_t ngroups = EXT4_SB(sb)->s_groups_count;
349 unsigned int freei, avefreei;
350 struct ext4_group_desc *desc, *best_desc = NULL;
351 - int group, best_group = -1;
352 + ext4_group_t group, best_group = -1;
354 freei = percpu_counter_read_positive(&EXT4_SB(sb)->s_freeinodes_counter);
355 avefreei = freei / ngroups;
356 @@ -314,12 +314,13 @@ static int find_group_dir(struct super_block *sb, struct inode *parent)
357 #define INODE_COST 64
358 #define BLOCK_COST 256
360 -static int find_group_orlov(struct super_block *sb, struct inode *parent)
361 +static ext4_group_t find_group_orlov(struct super_block *sb,
362 + struct inode *parent)
364 - int parent_group = EXT4_I(parent)->i_block_group;
365 + ext4_group_t parent_group = EXT4_I(parent)->i_block_group;
366 struct ext4_sb_info *sbi = EXT4_SB(sb);
367 struct ext4_super_block *es = sbi->s_es;
368 - int ngroups = sbi->s_groups_count;
369 + ext4_group_t ngroups = sbi->s_groups_count;
370 int inodes_per_group = EXT4_INODES_PER_GROUP(sb);
371 unsigned int freei, avefreei;
372 ext4_fsblk_t freeb, avefreeb;
373 @@ -327,7 +328,7 @@ static int find_group_orlov(struct super_block *sb, struct inode *parent)
374 unsigned int ndirs;
375 int max_debt, max_dirs, min_inodes;
376 ext4_grpblk_t min_blocks;
377 - int group = -1, i;
378 + ext4_group_t group = -1, i;
379 struct ext4_group_desc *desc;
381 freei = percpu_counter_read_positive(&sbi->s_freeinodes_counter);
382 @@ -340,7 +341,7 @@ static int find_group_orlov(struct super_block *sb, struct inode *parent)
383 if ((parent == sb->s_root->d_inode) ||
384 (EXT4_I(parent)->i_flags & EXT4_TOPDIR_FL)) {
385 int best_ndir = inodes_per_group;
386 - int best_group = -1;
387 + ext4_group_t best_group = -1;
389 get_random_bytes(&group, sizeof(group));
390 parent_group = (unsigned)group % ngroups;
391 @@ -415,12 +416,13 @@ fallback:
392 return -1;
395 -static int find_group_other(struct super_block *sb, struct inode *parent)
396 +static ext4_group_t find_group_other(struct super_block *sb,
397 + struct inode *parent)
399 - int parent_group = EXT4_I(parent)->i_block_group;
400 - int ngroups = EXT4_SB(sb)->s_groups_count;
401 + ext4_group_t parent_group = EXT4_I(parent)->i_block_group;
402 + ext4_group_t ngroups = EXT4_SB(sb)->s_groups_count;
403 struct ext4_group_desc *desc;
404 - int group, i;
405 + ext4_group_t group, i;
408 * Try to place the inode in its parent directory
409 @@ -487,7 +489,7 @@ struct inode *ext4_new_inode(handle_t *handle, struct inode * dir, int mode)
410 struct super_block *sb;
411 struct buffer_head *bitmap_bh = NULL;
412 struct buffer_head *bh2;
413 - int group;
414 + ext4_group_t group;
415 unsigned long ino = 0;
416 struct inode * inode;
417 struct ext4_group_desc * gdp = NULL;
418 @@ -583,7 +585,7 @@ got:
419 ino > EXT4_INODES_PER_GROUP(sb)) {
420 ext4_error(sb, __FUNCTION__,
421 "reserved inode or inode > inodes count - "
422 - "block_group = %d, inode=%lu", group,
423 + "block_group = %lu, inode=%lu", group,
424 ino + group * EXT4_INODES_PER_GROUP(sb));
425 err = -EIO;
426 goto fail;
427 @@ -777,7 +779,7 @@ fail_drop:
428 struct inode *ext4_orphan_get(struct super_block *sb, unsigned long ino)
430 unsigned long max_ino = le32_to_cpu(EXT4_SB(sb)->s_es->s_inodes_count);
431 - unsigned long block_group;
432 + ext4_group_t block_group;
433 int bit;
434 struct buffer_head *bitmap_bh = NULL;
435 struct inode *inode = NULL;
436 @@ -833,7 +835,7 @@ unsigned long ext4_count_free_inodes (struct super_block * sb)
438 unsigned long desc_count;
439 struct ext4_group_desc *gdp;
440 - int i;
441 + ext4_group_t i;
442 #ifdef EXT4FS_DEBUG
443 struct ext4_super_block *es;
444 unsigned long bitmap_count, x;
445 @@ -879,7 +881,7 @@ unsigned long ext4_count_free_inodes (struct super_block * sb)
446 unsigned long ext4_count_dirs (struct super_block * sb)
448 unsigned long count = 0;
449 - int i;
450 + ext4_group_t i;
452 for (i = 0; i < EXT4_SB(sb)->s_groups_count; i++) {
453 struct ext4_group_desc *gdp = ext4_get_group_desc (sb, i, NULL);
454 diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
455 index 488f829..1ee19c9 100644
456 --- a/fs/ext4/inode.c
457 +++ b/fs/ext4/inode.c
458 @@ -2464,7 +2464,8 @@ out_stop:
459 static ext4_fsblk_t ext4_get_inode_block(struct super_block *sb,
460 unsigned long ino, struct ext4_iloc *iloc)
462 - unsigned long desc, group_desc, block_group;
463 + unsigned long desc, group_desc;
464 + ext4_group_t block_group;
465 unsigned long offset;
466 ext4_fsblk_t block;
467 struct buffer_head *bh;
468 @@ -2551,7 +2552,7 @@ static int __ext4_get_inode_loc(struct inode *inode,
469 struct ext4_group_desc *desc;
470 int inodes_per_buffer;
471 int inode_offset, i;
472 - int block_group;
473 + ext4_group_t block_group;
474 int start;
476 block_group = (inode->i_ino - 1) /
477 diff --git a/fs/ext4/resize.c b/fs/ext4/resize.c
478 index bd8a52b..7090c2d 100644
479 --- a/fs/ext4/resize.c
480 +++ b/fs/ext4/resize.c
481 @@ -28,7 +28,7 @@ static int verify_group_input(struct super_block *sb,
482 struct ext4_super_block *es = sbi->s_es;
483 ext4_fsblk_t start = ext4_blocks_count(es);
484 ext4_fsblk_t end = start + input->blocks_count;
485 - unsigned group = input->group;
486 + ext4_group_t group = input->group;
487 ext4_fsblk_t itend = input->inode_table + sbi->s_itb_per_group;
488 unsigned overhead = ext4_bg_has_super(sb, group) ?
489 (1 + ext4_bg_num_gdb(sb, group) +
490 @@ -357,7 +357,7 @@ static int verify_reserved_gdb(struct super_block *sb,
491 struct buffer_head *primary)
493 const ext4_fsblk_t blk = primary->b_blocknr;
494 - const unsigned long end = EXT4_SB(sb)->s_groups_count;
495 + const ext4_group_t end = EXT4_SB(sb)->s_groups_count;
496 unsigned three = 1;
497 unsigned five = 5;
498 unsigned seven = 7;
499 @@ -656,12 +656,12 @@ static void update_backups(struct super_block *sb,
500 int blk_off, char *data, int size)
502 struct ext4_sb_info *sbi = EXT4_SB(sb);
503 - const unsigned long last = sbi->s_groups_count;
504 + const ext4_group_t last = sbi->s_groups_count;
505 const int bpg = EXT4_BLOCKS_PER_GROUP(sb);
506 unsigned three = 1;
507 unsigned five = 5;
508 unsigned seven = 7;
509 - unsigned group;
510 + ext4_group_t group;
511 int rest = sb->s_blocksize - size;
512 handle_t *handle;
513 int err = 0, err2;
514 @@ -716,7 +716,7 @@ static void update_backups(struct super_block *sb,
515 exit_err:
516 if (err) {
517 ext4_warning(sb, __FUNCTION__,
518 - "can't update backup for group %d (err %d), "
519 + "can't update backup for group %lu (err %d), "
520 "forcing fsck on next reboot", group, err);
521 sbi->s_mount_state &= ~EXT4_VALID_FS;
522 sbi->s_es->s_state &= cpu_to_le16(~EXT4_VALID_FS);
523 @@ -952,7 +952,7 @@ int ext4_group_extend(struct super_block *sb, struct ext4_super_block *es,
524 ext4_fsblk_t n_blocks_count)
526 ext4_fsblk_t o_blocks_count;
527 - unsigned long o_groups_count;
528 + ext4_group_t o_groups_count;
529 ext4_grpblk_t last;
530 ext4_grpblk_t add;
531 struct buffer_head * bh;
532 diff --git a/fs/ext4/super.c b/fs/ext4/super.c
533 index 6302b03..df8842b 100644
534 --- a/fs/ext4/super.c
535 +++ b/fs/ext4/super.c
536 @@ -1364,7 +1364,7 @@ static int ext4_check_descriptors (struct super_block * sb)
537 struct ext4_group_desc * gdp = NULL;
538 int desc_block = 0;
539 int flexbg_flag = 0;
540 - int i;
541 + ext4_group_t i;
543 if (EXT4_HAS_INCOMPAT_FEATURE(sb, EXT4_FEATURE_INCOMPAT_FLEX_BG))
544 flexbg_flag = 1;
545 @@ -1386,7 +1386,7 @@ static int ext4_check_descriptors (struct super_block * sb)
546 if (block_bitmap < first_block || block_bitmap > last_block)
548 ext4_error (sb, "ext4_check_descriptors",
549 - "Block bitmap for group %d"
550 + "Block bitmap for group %lu"
551 " not in group (block %llu)!",
552 i, block_bitmap);
553 return 0;
554 @@ -1395,7 +1395,7 @@ static int ext4_check_descriptors (struct super_block * sb)
555 if (inode_bitmap < first_block || inode_bitmap > last_block)
557 ext4_error (sb, "ext4_check_descriptors",
558 - "Inode bitmap for group %d"
559 + "Inode bitmap for group %lu"
560 " not in group (block %llu)!",
561 i, inode_bitmap);
562 return 0;
563 @@ -1405,17 +1405,16 @@ static int ext4_check_descriptors (struct super_block * sb)
564 inode_table + sbi->s_itb_per_group - 1 > last_block)
566 ext4_error (sb, "ext4_check_descriptors",
567 - "Inode table for group %d"
568 + "Inode table for group %lu"
569 " not in group (block %llu)!",
570 i, inode_table);
571 return 0;
573 if (!ext4_group_desc_csum_verify(sbi, i, gdp)) {
574 ext4_error(sb, __FUNCTION__,
575 - "Checksum for group %d failed (%u!=%u)\n", i,
576 - le16_to_cpu(ext4_group_desc_csum(sbi, i,
577 - gdp)),
578 - le16_to_cpu(gdp->bg_checksum));
579 + "Checksum for group %lu failed (%u!=%u)\n",
580 + i, le16_to_cpu(ext4_group_desc_csum(sbi, i,
581 + gdp)), le16_to_cpu(gdp->bg_checksum));
582 return 0;
584 if (!flexbg_flag)
585 @@ -1429,7 +1428,6 @@ static int ext4_check_descriptors (struct super_block * sb)
586 return 1;
590 /* ext4_orphan_cleanup() walks a singly-linked list of inodes (starting at
591 * the superblock) which were deleted from all directories, but held open by
592 * a process at the time of a crash. We walk the list and try to delete these
593 @@ -1570,7 +1568,7 @@ static ext4_fsblk_t descriptor_loc(struct super_block *sb,
594 ext4_fsblk_t logical_sb_block, int nr)
596 struct ext4_sb_info *sbi = EXT4_SB(sb);
597 - unsigned long bg, first_meta_bg;
598 + ext4_group_t bg, first_meta_bg;
599 int has_super = 0;
601 first_meta_bg = le32_to_cpu(sbi->s_es->s_first_meta_bg);
602 @@ -2678,7 +2676,7 @@ static int ext4_statfs (struct dentry * dentry, struct kstatfs * buf)
603 if (test_opt(sb, MINIX_DF)) {
604 sbi->s_overhead_last = 0;
605 } else if (sbi->s_blocks_last != ext4_blocks_count(es)) {
606 - unsigned long ngroups = sbi->s_groups_count, i;
607 + ext4_group_t ngroups = sbi->s_groups_count, i;
608 ext4_fsblk_t overhead = 0;
609 smp_rmb();
611 diff --git a/include/linux/ext4_fs.h b/include/linux/ext4_fs.h
612 index 5e2da09..e1103c2 100644
613 --- a/include/linux/ext4_fs.h
614 +++ b/include/linux/ext4_fs.h
615 @@ -830,7 +830,7 @@ struct ext4_iloc
617 struct buffer_head *bh;
618 unsigned long offset;
619 - unsigned long block_group;
620 + ext4_group_t block_group;
623 static inline struct ext4_inode *ext4_raw_inode(struct ext4_iloc *iloc)
624 @@ -855,7 +855,7 @@ struct dir_private_info {
626 /* calculate the first block number of the group */
627 static inline ext4_fsblk_t
628 -ext4_group_first_block_no(struct super_block *sb, unsigned long group_no)
629 +ext4_group_first_block_no(struct super_block *sb, ext4_group_t group_no)
631 return group_no * (ext4_fsblk_t)EXT4_BLOCKS_PER_GROUP(sb) +
632 le32_to_cpu(EXT4_SB(sb)->s_es->s_first_data_block);
633 @@ -886,8 +886,9 @@ extern unsigned int ext4_block_group(struct super_block *sb,
634 ext4_fsblk_t blocknr);
635 extern ext4_grpblk_t ext4_block_group_offset(struct super_block *sb,
636 ext4_fsblk_t blocknr);
637 -extern int ext4_bg_has_super(struct super_block *sb, int group);
638 -extern unsigned long ext4_bg_num_gdb(struct super_block *sb, int group);
639 +extern int ext4_bg_has_super(struct super_block *sb, ext4_group_t group);
640 +extern unsigned long ext4_bg_num_gdb(struct super_block *sb,
641 + ext4_group_t group);
642 extern ext4_fsblk_t ext4_new_block (handle_t *handle, struct inode *inode,
643 ext4_fsblk_t goal, int *errp);
644 extern ext4_fsblk_t ext4_new_blocks (handle_t *handle, struct inode *inode,
645 @@ -900,7 +901,7 @@ extern void ext4_free_blocks_sb (handle_t *handle, struct super_block *sb,
646 extern ext4_fsblk_t ext4_count_free_blocks (struct super_block *);
647 extern void ext4_check_blocks_bitmap (struct super_block *);
648 extern struct ext4_group_desc * ext4_get_group_desc(struct super_block * sb,
649 - unsigned int block_group,
650 + ext4_group_t block_group,
651 struct buffer_head ** bh);
652 extern int ext4_should_retry_alloc(struct super_block *sb, int *retries);
653 extern void ext4_init_block_alloc_info(struct inode *);
654 diff --git a/include/linux/ext4_fs_i.h b/include/linux/ext4_fs_i.h
655 index 6c610b6..2b4e370 100644
656 --- a/include/linux/ext4_fs_i.h
657 +++ b/include/linux/ext4_fs_i.h
658 @@ -30,6 +30,9 @@ typedef unsigned long long ext4_fsblk_t;
659 /* data type for file logical block number */
660 typedef __u32 ext4_lblk_t;
662 +/* data type for block group number */
663 +typedef unsigned long ext4_group_t;
665 struct ext4_reserve_window {
666 ext4_fsblk_t _rsv_start; /* First byte reserved */
667 ext4_fsblk_t _rsv_end; /* Last byte reserved or 0 */
668 @@ -92,7 +95,7 @@ struct ext4_inode_info {
669 * place a file's data blocks near its inode block, and new inodes
670 * near to their parent directory's inode.
672 - __u32 i_block_group;
673 + ext4_group_t i_block_group;
674 __u32 i_state; /* Dynamic state flags for ext4 */
676 /* block reservation info */
677 diff --git a/include/linux/ext4_fs_sb.h b/include/linux/ext4_fs_sb.h
678 index b40e827..f15821c 100644
679 --- a/include/linux/ext4_fs_sb.h
680 +++ b/include/linux/ext4_fs_sb.h
681 @@ -35,7 +35,7 @@ struct ext4_sb_info {
682 unsigned long s_itb_per_group; /* Number of inode table blocks per group */
683 unsigned long s_gdb_count; /* Number of group descriptor blocks */
684 unsigned long s_desc_per_block; /* Number of group descriptors per block */
685 - unsigned long s_groups_count; /* Number of groups in the fs */
686 + ext4_group_t s_groups_count; /* Number of groups in the fs */
687 unsigned long s_overhead_last; /* Last calculated overhead */
688 unsigned long s_blocks_last; /* Last seen block count */
689 struct buffer_head * s_sbh; /* Buffer containing the super block */