int csum_flag;
int bigalloc_flag;
int io_flags;
+ int has_bg;
unsigned reserved_inos;
char *buf = 0;
char c;
* backup.
*/
overhead = (int) (2 + fs->inode_blocks_per_group);
- if (ext2fs_bg_has_super(fs, fs->group_desc_count - 1))
+ has_bg = 0;
+ if (ext2fs_has_feature_sparse_super2(super)) {
+ /*
+ * We have to do this manually since
+ * super->s_backup_bgs hasn't been set up yet.
+ */
+ if (fs->group_desc_count == 2)
+ has_bg = param->s_backup_bgs[0] != 0;
+ else
+ has_bg = param->s_backup_bgs[1] != 0;
+ } else
+ has_bg = ext2fs_bg_has_super(fs, fs->group_desc_count - 1);
+ if (has_bg)
overhead += 1 + fs->desc_blocks + super->s_reserved_gdt_blocks;
rem = ((ext2fs_blocks_count(super) - super->s_first_data_block) %
super->s_blocks_per_group);
goto errout;
print_resource_track(rfs, &rtrack, fs->io);
+ retval = clear_sparse_super2_last_group(rfs);
+ if (retval)
+ goto errout;
+
init_resource_track(&rtrack, "calculate_summary_stats", fs->io);
retval = ext2fs_calculate_summary_stats(rfs->new_fs);
if (retval)
goto errout;
print_resource_track(rfs, &rtrack, fs->io);
- retval = clear_sparse_super2_last_group(rfs);
- if (retval)
- goto errout;
-
retval = ext2fs_set_gdt_csum(rfs->new_fs);
if (retval)
goto errout;
blk64_t old_numblocks, numblocks, adjblocks;
unsigned long i, j, old_desc_blocks;
unsigned int meta_bg, meta_bg_size;
- int has_super, csum_flag;
+ int has_super, csum_flag, has_bg;
unsigned long long new_inodes; /* u64 to check for overflow */
double percent;
*/
overhead = (int) (2 + fs->inode_blocks_per_group);
- if (ext2fs_bg_has_super(fs, fs->group_desc_count - 1))
+ has_bg = 0;
+ if (ext2fs_has_feature_sparse_super2(fs->super)) {
+ /*
+ * We have to do this manually since
+ * super->s_backup_bgs hasn't been set up yet.
+ */
+ if (fs->group_desc_count == 2)
+ has_bg = fs->super->s_backup_bgs[0] != 0;
+ else
+ has_bg = fs->super->s_backup_bgs[1] != 0;
+ } else
+ has_bg = ext2fs_bg_has_super(fs, fs->group_desc_count - 1);
+ if (has_bg)
overhead += 1 + fs->desc_blocks +
fs->super->s_reserved_gdt_blocks;
if (last_bg > old_last_bg) {
if (old_fs->group_desc_count == 1)
fs->super->s_backup_bgs[0] = 1;
- if (old_fs->group_desc_count == 1 &&
- fs->super->s_backup_bgs[0])
- fs->super->s_backup_bgs[0] = last_bg;
- else if (fs->super->s_backup_bgs[1])
+ if ((old_fs->group_desc_count < 3 &&
+ fs->group_desc_count > 2) ||
+ fs->super->s_backup_bgs[1])
fs->super->s_backup_bgs[1] = last_bg;
} else if (last_bg < old_last_bg) {
if (fs->super->s_backup_bgs[0] > last_bg)
fs->super->s_backup_bgs[1] == old_last_bg)
return 0;
+ if (old_last_bg == 0)
+ return 0;
+
retval = ext2fs_super_and_bgd_loc2(rfs->old_fs, old_last_bg,
&sb, &old_desc, NULL, &num);
if (retval)