- for (j=0, blk = new_blk;
- j < fs->inode_blocks_per_group;
- j++, blk++) {
- ext2fs_mark_block_bitmap(bmap, blk);
- if (flexbg_size) {
- dgrp_t gr = ext2fs_group_of_blk(fs, blk);
- fs->group_desc[gr].bg_free_blocks_count--;
- fs->super->s_free_blocks_count--;
- fs->group_desc[gr].bg_flags &= ~EXT2_BG_BLOCK_UNINIT;
+
+ ext2fs_mark_block_bitmap_range2(bmap,
+ new_blk, fs->inode_blocks_per_group);
+ if (flexbg_size) {
+ blk64_t num, blk;
+ num = fs->inode_blocks_per_group;
+ blk = new_blk;
+ while (num) {
+ int gr = ext2fs_group_of_blk2(fs, blk);
+ last_blk = ext2fs_group_last_block2(fs, gr);
+ blk64_t n = num;
+
+ if (blk + num > last_blk)
+ n = last_blk - blk + 1;
+
+ ext2fs_bg_free_blocks_count_set(fs, gr,
+ ext2fs_bg_free_blocks_count(fs, gr) -
+ n/EXT2FS_CLUSTER_RATIO(fs));
+ ext2fs_bg_flags_clear(fs, gr,
+ EXT2_BG_BLOCK_UNINIT);