Skip to content
Permalink
Browse files
ext4: use do_div() to calculate block offset
Use do_div() to calculate the block offset and the offset
within the block, make the code more concise.

Signed-off-by: Chunguang Xu <brookxu@tencent.com>
  • Loading branch information
brookxu-tx authored and intel-lab-lkp committed Oct 16, 2020
1 parent f00c1a2 commit 1bcce45cce439ec86a89aa8cfc895b5e9ad5046b
Showing 1 changed file with 2 additions and 3 deletions.
@@ -265,7 +265,7 @@ struct ext4_group_desc * ext4_get_group_desc(struct super_block *sb,
ext4_group_t block_group,
struct buffer_head **bh)
{
unsigned int group_desc;
unsigned int group_desc = block_group;
unsigned int offset;
ext4_group_t ngroups = ext4_get_groups_count(sb);
struct ext4_group_desc *desc;
@@ -279,8 +279,7 @@ struct ext4_group_desc * ext4_get_group_desc(struct super_block *sb,
return NULL;
}

group_desc = block_group >> EXT4_DESC_PER_BLOCK_BITS(sb);
offset = block_group & (EXT4_DESC_PER_BLOCK(sb) - 1);
offset = do_div(group_desc, EXT4_DESC_PER_BLOCK(sb));
bh_p = sbi_array_rcu_deref(sbi, s_group_desc, group_desc);
/*
* sbi_array_rcu_deref returns with rcu unlocked, this is ok since

0 comments on commit 1bcce45

Please sign in to comment.