Skip to content

Commit eb9e47f

Browse files
cgxu519jankara
authored andcommitted
ext2: introduce new helper ext2_group_last_block_no()
Introduce new helper ext2_group_last_block_no() to calculate last block num for specific block group, we can replace open coded logic by calling this common helper. Link: https://lore.kernel.org/r/20191104114036.9893-1-cgxu519@mykernel.net Signed-off-by: Chengguang Xu <cgxu519@mykernel.net> Signed-off-by: Jan Kara <jack@suse.cz>
1 parent dae82c7 commit eb9e47f

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

‎fs/ext2/ext2.h‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -813,6 +813,18 @@ ext2_group_first_block_no(struct super_block *sb, unsigned long group_no)
813813
le32_to_cpu(EXT2_SB(sb)->s_es->s_first_data_block);
814814
}
815815

816+
static inline ext2_fsblk_t
817+
ext2_group_last_block_no(struct super_block *sb, unsigned long group_no)
818+
{
819+
struct ext2_sb_info *sbi = EXT2_SB(sb);
820+
821+
if (group_no == sbi->s_groups_count - 1)
822+
return le32_to_cpu(sbi->s_es->s_blocks_count) - 1;
823+
else
824+
return ext2_group_first_block_no(sb, group_no) +
825+
EXT2_BLOCKS_PER_GROUP(sb) - 1;
826+
}
827+
816828
#define ext2_set_bit __test_and_set_bit_le
817829
#define ext2_clear_bit __test_and_clear_bit_le
818830
#define ext2_test_bit test_bit_le

0 commit comments

Comments
 (0)