68
68
struct ext2_super_block *sb = fs->super;
69
69
unsigned long bpg = sb->s_blocks_per_group;
70
unsigned int gdpb = fs->blocksize / sizeof(struct ext2_group_desc);
70
unsigned int gdpb = EXT2_DESC_PER_BLOCK(sb);
71
71
unsigned long max_blocks = 0xffffffff;
72
72
unsigned long rsv_groups;
73
73
unsigned int rsv_gdb;
158
159
set_field(s_first_meta_bg, 0);
159
160
set_field(s_raid_stride, 0); /* default stride size: 0 */
160
161
set_field(s_raid_stripe_width, 0); /* default stripe width: 0 */
162
set_field(s_log_groups_per_flex, 0);
161
163
set_field(s_flags, 0);
162
164
if (super->s_feature_incompat & ~EXT2_LIB_FEATURE_INCOMPAT_SUPP) {
163
165
retval = EXT2_ET_UNSUPP_FEATURE;
172
174
if (super->s_rev_level >= EXT2_DYNAMIC_REV) {
173
175
set_field(s_first_ino, EXT2_GOOD_OLD_FIRST_INO);
174
176
set_field(s_inode_size, EXT2_GOOD_OLD_INODE_SIZE);
177
if (super->s_inode_size >= sizeof(struct ext2_inode_large)) {
178
int extra_isize = sizeof(struct ext2_inode_large) -
179
EXT2_GOOD_OLD_INODE_SIZE;
180
set_field(s_min_extra_isize, extra_isize);
181
set_field(s_want_extra_isize, extra_isize);
184
super->s_first_ino = EXT2_GOOD_OLD_FIRST_INO;
185
super->s_inode_size = EXT2_GOOD_OLD_INODE_SIZE;
177
188
set_field(s_checkinterval, EXT2_DFL_CHECKINTERVAL);
367
378
* Note that although the block bitmap, inode bitmap, and
368
379
* inode table have not been allocated (and in fact won't be
369
380
* by this routine), they are accounted for nevertheless.
382
* If FLEX_BG meta-data grouping is used, only account for the
383
* superblock and group descriptors (the inode tables and
384
* bitmaps will be accounted for when allocated).
371
386
super->s_free_blocks_count = 0;
387
csum_flag = EXT2_HAS_RO_COMPAT_FEATURE(fs->super,
388
EXT4_FEATURE_RO_COMPAT_GDT_CSUM);
372
389
for (i = 0; i < fs->group_desc_count; i++) {
391
* Don't set the BLOCK_UNINIT group for the last group
392
* because the block bitmap needs to be padded.
395
if (i != fs->group_desc_count - 1)
396
fs->group_desc[i].bg_flags |=
397
EXT2_BG_BLOCK_UNINIT;
398
fs->group_desc[i].bg_flags |= EXT2_BG_INODE_UNINIT;
399
numblocks = super->s_inodes_per_group;
401
numblocks -= super->s_first_ino;
402
fs->group_desc[i].bg_itable_unused = numblocks;
373
404
numblocks = ext2fs_reserve_super_and_bgd(fs, i, fs->block_map);
405
if (fs->super->s_log_groups_per_flex)
406
numblocks += 2 + fs->inode_blocks_per_group;
375
408
super->s_free_blocks_count += numblocks;
376
409
fs->group_desc[i].bg_free_blocks_count = numblocks;
377
410
fs->group_desc[i].bg_free_inodes_count =
378
411
fs->super->s_inodes_per_group;
379
412
fs->group_desc[i].bg_used_dirs_count = 0;
413
ext2fs_group_desc_csum_set(fs, i);