diff options
author | Eric Sandeen <sandeen@redhat.com> | 2011-09-16 09:21:53 -0400 |
---|---|---|
committer | Theodore Ts'o <tytso@mit.edu> | 2011-09-16 09:28:43 -0400 |
commit | 98f4547198b369bef7e41eb7ce4a16855726c393 (patch) | |
tree | bcc3905013eb56a8698060ca1c1d375286912e54 /resize | |
parent | 65b7a463da3b8f7ce0892be579f34ba4cf66456e (diff) | |
download | e2fsprogs-98f4547198b369bef7e41eb7ce4a16855726c393.tar.gz |
e2fsprogs: add ext2fs_group_blocks_count helper
Code to count the number of blocks in the last partial
group is cut and pasted around the e2fsprogs codebase
a few times.
Making this a helper function should improve matters.
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Diffstat (limited to 'resize')
-rw-r--r-- | resize/online.c | 7 | ||||
-rw-r--r-- | resize/resize2fs.c | 16 |
2 files changed, 5 insertions, 18 deletions
diff --git a/resize/online.c b/resize/online.c index 1b3589bc..8bb7e9e4 100644 --- a/resize/online.c +++ b/resize/online.c @@ -152,12 +152,7 @@ errcode_t online_resize_fs(ext2_filsys fs, const char *mtpt, input.block_bitmap = ext2fs_block_bitmap_loc(new_fs, i); input.inode_bitmap = ext2fs_inode_bitmap_loc(new_fs, i); input.inode_table = ext2fs_inode_table_loc(new_fs, i); - input.blocks_count = sb->s_blocks_per_group; - if (i == new_fs->group_desc_count-1) { - input.blocks_count = ext2fs_blocks_count(new_fs->super) - - sb->s_first_data_block - - (i * sb->s_blocks_per_group); - } + input.blocks_count = ext2fs_group_blocks_count(new_fs, i); input.reserved_blocks = (blk_t) (percent * input.blocks_count / 100.0); diff --git a/resize/resize2fs.c b/resize/resize2fs.c index 45ea5f42..59beb357 100644 --- a/resize/resize2fs.c +++ b/resize/resize2fs.c @@ -499,18 +499,10 @@ retry: ext2fs_bg_flags_zap(fs, i); if (csum_flag) ext2fs_bg_flags_set(fs, i, EXT2_BG_INODE_UNINIT | EXT2_BG_INODE_ZEROED); - if (i == fs->group_desc_count-1) { - numblocks = (ext2fs_blocks_count(fs->super) - - fs->super->s_first_data_block) % - fs->super->s_blocks_per_group; - if (!numblocks) - numblocks = fs->super->s_blocks_per_group; - } else { - numblocks = fs->super->s_blocks_per_group; - if (csum_flag) - ext2fs_bg_flags_set(fs, i, - EXT2_BG_BLOCK_UNINIT); - } + + numblocks = ext2fs_group_blocks_count(fs, i); + if ((i < fs->group_desc_count - 1) && csum_flag) + ext2fs_bg_flags_set(fs, i, EXT2_BG_BLOCK_UNINIT); has_super = ext2fs_bg_has_super(fs, i); if (has_super) { |