Fix superblock field s_blocks_count for bigalloc file systems

Treat the s_blocks_count field in the superblock as a free block count
(instead of the number of free clusters) for bigalloc file systems.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
bitmap-optimize
Theodore Ts'o 2011-06-16 01:38:43 -04:00
parent a3efe48420
commit fe75afbf33
5 changed files with 10 additions and 7 deletions

View File

@ -401,6 +401,7 @@ redo_counts:
ext2fs_unmark_valid(fs);
}
}
free_blocks = EXT2FS_C2B(fs, free_blocks);
if (free_blocks != ext2fs_free_blocks_count(fs->super)) {
pctx.group = 0;
pctx.blk = ext2fs_free_blocks_count(fs->super);

View File

@ -690,7 +690,7 @@ void check_super_block(e2fsck_t ctx)
return;
}
ctx->free_blocks = free_blocks;
ctx->free_blocks = EXT2FS_C2B(fs, free_blocks);
ctx->free_inodes = free_inodes;
if ((ext2fs_free_blocks_count(sb) > ext2fs_blocks_count(sb)) ||

View File

@ -91,6 +91,7 @@ errcode_t ext2fs_initialize(const char *name, int flags,
unsigned int overhead = 0;
unsigned int ipg;
dgrp_t i;
blk64_t free_blocks;
blk_t numblocks;
int rsv_gdt;
int csum_flag;
@ -431,7 +432,7 @@ ipg_retry:
* superblock and group descriptors (the inode tables and
* bitmaps will be accounted for when allocated).
*/
ext2fs_free_blocks_count_set(super, 0);
free_blocks = 0;
csum_flag = EXT2_HAS_RO_COMPAT_FEATURE(fs->super,
EXT4_FEATURE_RO_COMPAT_GDT_CSUM);
for (i = 0; i < fs->group_desc_count; i++) {
@ -453,14 +454,14 @@ ipg_retry:
if (fs->super->s_log_groups_per_flex)
numblocks += 2 + fs->inode_blocks_per_group;
ext2fs_free_blocks_count_set(super,
ext2fs_free_blocks_count(super) +
numblocks);
free_blocks += numblocks;
ext2fs_bg_free_blocks_count_set(fs, i, numblocks);
ext2fs_bg_free_inodes_count_set(fs, i, fs->super->s_inodes_per_group);
ext2fs_bg_used_dirs_count_set(fs, i, 0);
ext2fs_group_desc_csum_set(fs, i);
}
free_blocks &= ~EXT2FS_CLUSTER_MASK(fs);
ext2fs_free_blocks_count_set(super, free_blocks);
c = (char) 255;
if (((int) c) == -1) {

View File

@ -2134,7 +2134,7 @@ static void fix_cluster_bg_counts(ext2_filsys fs)
group++;
}
}
ext2fs_free_blocks_count_set(fs->super, tot_free);
ext2fs_free_blocks_count_set(fs->super, EXT2FS_C2B(fs, tot_free));
}
int main (int argc, char *argv[])

View File

@ -265,7 +265,7 @@ static int release_blocks_proc(ext2_filsys fs, blk64_t *blocknr,
group = ext2fs_group_of_blk2(fs, block);
ext2fs_bg_free_blocks_count_set(fs, group, ext2fs_bg_free_blocks_count(fs, group) + 1);
ext2fs_group_desc_csum_set(fs, group);
ext2fs_free_blocks_count_add(fs->super, 1);
ext2fs_free_blocks_count_add(fs->super, EXT2FS_CLUSTER_RATIO(fs));
return 0;
}
@ -1402,6 +1402,7 @@ static errcode_t ext2fs_calculate_summary_stats(ext2_filsys fs)
group_free = 0;
}
}
total_free = EXT2FS_C2B(fs, total_free);
ext2fs_free_blocks_count_set(fs->super, total_free);
/*