ref: 381472b60a9ff25f0e0cbf535af7d0b786810210
parent: 79fb06860bb52d73e6f69fbb2c79d05eaba37a5c
author: gkostka <[email protected]>
date: Mon Nov 16 17:28:06 EST 2015
Introduce init_bgs in mkfs module
--- a/lwext4/ext4_mkfs.c
+++ b/lwext4/ext4_mkfs.c
@@ -310,6 +310,10 @@
ext4_bg_set_used_dirs_count(&aux_info->bg_desc[i], aux_info->sb,
0);
+ ext4_bg_set_flag(&aux_info->bg_desc[i],
+ EXT4_BLOCK_GROUP_BLOCK_UNINIT |
+ EXT4_BLOCK_GROUP_INODE_UNINIT);
+
sb_free_blk += bg_free_blk;
}
@@ -328,10 +332,10 @@
aux_info->first_data_block + i * info->blocks_per_group;
uint32_t blk_off = 0;
+ blk_off += aux_info->bg_desc_blocks;
if (has_superblock(info, i)) {
bg_start_block++;
- blk_off = info->bg_desc_reserve_blocks +
- aux_info->bg_desc_blocks;
+ blk_off += info->bg_desc_reserve_blocks;
}
uint32_t block_size = ext4_sb_get_block_size(aux_info->sb);
@@ -379,6 +383,7 @@
return r;
}
+
return r;
}
@@ -463,6 +468,24 @@
return r;
}
+static int init_bgs(struct ext4_fs *fs)
+{
+ int r = EOK;
+ struct ext4_block_group_ref ref;
+ uint32_t i;
+ uint32_t bg_count = ext4_block_group_cnt(&fs->sb);
+ for (i = 0; i < bg_count; ++i) {
+ r = ext4_fs_get_block_group_ref(fs, i, &ref);
+ if (r != EOK)
+ break;
+
+ r = ext4_fs_put_block_group_ref(&ref);
+ if (r != EOK)
+ break;
+ }
+ return r;
+}
+
static int alloc_inodes(struct ext4_fs *fs)
{
int r = EOK;
@@ -572,10 +595,12 @@
info->inodes_per_group = compute_inodes_per_group(info);
- info->feat_compat = EXT2_SUPPORTED_FCOM;
- info->feat_ro_compat = EXT2_SUPPORTED_FRO_COM;
- info->feat_incompat = EXT2_SUPPORTED_FINCOM;
+ info->feat_compat = EXT3_SUPPORTED_FCOM;
+ info->feat_ro_compat = EXT3_SUPPORTED_FRO_COM;
+ info->feat_incompat = EXT3_SUPPORTED_FINCOM;
+ info->feat_incompat &= ~EXT4_FINCOM_META_BG;
+
if (info->no_journal == 0)
info->feat_compat |= 0;
@@ -630,6 +655,10 @@
r = ext4_fs_init(fs, bd);
if (r != EOK)
goto cache_fini;
+
+ r = init_bgs(fs);
+ if (r != EOK)
+ goto fs_fini;
r = alloc_inodes(fs);
if (r != EOK)