diff options
Diffstat (limited to 'fs/ext4/balloc.c')
-rw-r--r-- | fs/ext4/balloc.c | 25 |
1 files changed, 18 insertions, 7 deletions
diff --git a/fs/ext4/balloc.c b/fs/ext4/balloc.c index d6babf94907e..9e8d8ffb063f 100644 --- a/fs/ext4/balloc.c +++ b/fs/ext4/balloc.c @@ -30,6 +30,23 @@ static unsigned ext4_num_base_meta_clusters(struct super_block *sb, */ /* + * Calculate block group number for a given block number + */ +ext4_group_t ext4_get_group_number(struct super_block *sb, + ext4_fsblk_t block) +{ + ext4_group_t group; + + if (test_opt2(sb, STD_GROUP_SIZE)) + group = (le32_to_cpu(EXT4_SB(sb)->s_es->s_first_data_block) + + block) >> + (EXT4_BLOCK_SIZE_BITS(sb) + EXT4_CLUSTER_BITS(sb) + 3); + else + ext4_get_group_no_and_offset(sb, block, &group, NULL); + return group; +} + +/* * Calculate the block group number and offset into the block/cluster * allocation bitmap, given a block number */ @@ -59,13 +76,7 @@ static inline int ext4_block_in_group(struct super_block *sb, { ext4_group_t actual_group; - if (test_opt2(sb, STD_GROUP_SIZE)) - actual_group = - (le32_to_cpu(EXT4_SB(sb)->s_es->s_first_data_block) + - block) >> - (EXT4_BLOCK_SIZE_BITS(sb) + EXT4_CLUSTER_BITS(sb) + 3); - else - ext4_get_group_no_and_offset(sb, block, &actual_group, NULL); + actual_group = ext4_get_group_number(sb, block); return (actual_group == block_group) ? 1 : 0; } |