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