mirror of
https://github.com/raspberrypi/linux.git
synced 2025-12-25 19:42:19 +00:00
ext4: move checksum length calculation of inode bitmap into ext4_inode_bitmap_csum_[verify/set]() functions
There are some little improve: 1. remove repeat code to calculate checksum length of inode bitmap 2. remove unnecessary checksum length calculation if checksum is not enabled. 3. use more efficient bit shift operation instead of div opreation. Signed-off-by: Kemeng Shi <shikemeng@huaweicloud.com> Link: https://patch.msgid.link/20240820132234.2759926-6-shikemeng@huaweicloud.com Signed-off-by: Theodore Ts'o <tytso@mit.edu>
This commit is contained in:
committed by
Theodore Ts'o
parent
f7c69be505
commit
66eafbde7d
@@ -98,8 +98,7 @@ static int ext4_validate_inode_bitmap(struct super_block *sb,
|
||||
if (buffer_verified(bh))
|
||||
goto verified;
|
||||
blk = ext4_inode_bitmap(sb, desc);
|
||||
if (!ext4_inode_bitmap_csum_verify(sb, desc, bh,
|
||||
EXT4_INODES_PER_GROUP(sb) / 8) ||
|
||||
if (!ext4_inode_bitmap_csum_verify(sb, desc, bh) ||
|
||||
ext4_simulate_fail(sb, EXT4_SIM_IBITMAP_CRC)) {
|
||||
ext4_unlock_group(sb, block_group);
|
||||
ext4_error(sb, "Corrupt inode bitmap - block_group = %u, "
|
||||
@@ -327,8 +326,7 @@ void ext4_free_inode(handle_t *handle, struct inode *inode)
|
||||
if (percpu_counter_initialized(&sbi->s_dirs_counter))
|
||||
percpu_counter_dec(&sbi->s_dirs_counter);
|
||||
}
|
||||
ext4_inode_bitmap_csum_set(sb, gdp, bitmap_bh,
|
||||
EXT4_INODES_PER_GROUP(sb) / 8);
|
||||
ext4_inode_bitmap_csum_set(sb, gdp, bitmap_bh);
|
||||
ext4_group_desc_csum_set(sb, block_group, gdp);
|
||||
ext4_unlock_group(sb, block_group);
|
||||
|
||||
@@ -853,8 +851,7 @@ int ext4_mark_inode_used(struct super_block *sb, int ino)
|
||||
|
||||
ext4_free_inodes_set(sb, gdp, ext4_free_inodes_count(sb, gdp) - 1);
|
||||
if (ext4_has_group_desc_csum(sb)) {
|
||||
ext4_inode_bitmap_csum_set(sb, gdp, inode_bitmap_bh,
|
||||
EXT4_INODES_PER_GROUP(sb) / 8);
|
||||
ext4_inode_bitmap_csum_set(sb, gdp, inode_bitmap_bh);
|
||||
ext4_group_desc_csum_set(sb, group, gdp);
|
||||
}
|
||||
|
||||
@@ -1225,8 +1222,7 @@ got:
|
||||
}
|
||||
}
|
||||
if (ext4_has_group_desc_csum(sb)) {
|
||||
ext4_inode_bitmap_csum_set(sb, gdp, inode_bitmap_bh,
|
||||
EXT4_INODES_PER_GROUP(sb) / 8);
|
||||
ext4_inode_bitmap_csum_set(sb, gdp, inode_bitmap_bh);
|
||||
ext4_group_desc_csum_set(sb, group, gdp);
|
||||
}
|
||||
ext4_unlock_group(sb, group);
|
||||
|
||||
Reference in New Issue
Block a user