mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-12-27 11:06:41 -05:00
ext4: remove sbi argument from ext4_chksum()
Since ext4_chksum() no longer uses its sbi argument, remove it. Signed-off-by: Eric Biggers <ebiggers@google.com> Reviewed-by: Baokun Li <libaokun1@huawei.com> Link: https://patch.msgid.link/20250513053809.699974-2-ebiggers@kernel.org Signed-off-by: Theodore Ts'o <tytso@mit.edu>
This commit is contained in:
committed by
Theodore Ts'o
parent
7ac67301e8
commit
6cbab5f95e
@@ -30,7 +30,7 @@ int ext4_inode_bitmap_csum_verify(struct super_block *sb,
|
||||
|
||||
sz = EXT4_INODES_PER_GROUP(sb) >> 3;
|
||||
provided = le16_to_cpu(gdp->bg_inode_bitmap_csum_lo);
|
||||
calculated = ext4_chksum(sbi, sbi->s_csum_seed, (__u8 *)bh->b_data, sz);
|
||||
calculated = ext4_chksum(sbi->s_csum_seed, (__u8 *)bh->b_data, sz);
|
||||
if (sbi->s_desc_size >= EXT4_BG_INODE_BITMAP_CSUM_HI_END) {
|
||||
hi = le16_to_cpu(gdp->bg_inode_bitmap_csum_hi);
|
||||
provided |= (hi << 16);
|
||||
@@ -52,7 +52,7 @@ void ext4_inode_bitmap_csum_set(struct super_block *sb,
|
||||
return;
|
||||
|
||||
sz = EXT4_INODES_PER_GROUP(sb) >> 3;
|
||||
csum = ext4_chksum(sbi, sbi->s_csum_seed, (__u8 *)bh->b_data, sz);
|
||||
csum = ext4_chksum(sbi->s_csum_seed, (__u8 *)bh->b_data, sz);
|
||||
gdp->bg_inode_bitmap_csum_lo = cpu_to_le16(csum & 0xFFFF);
|
||||
if (sbi->s_desc_size >= EXT4_BG_INODE_BITMAP_CSUM_HI_END)
|
||||
gdp->bg_inode_bitmap_csum_hi = cpu_to_le16(csum >> 16);
|
||||
@@ -71,7 +71,7 @@ int ext4_block_bitmap_csum_verify(struct super_block *sb,
|
||||
return 1;
|
||||
|
||||
provided = le16_to_cpu(gdp->bg_block_bitmap_csum_lo);
|
||||
calculated = ext4_chksum(sbi, sbi->s_csum_seed, (__u8 *)bh->b_data, sz);
|
||||
calculated = ext4_chksum(sbi->s_csum_seed, (__u8 *)bh->b_data, sz);
|
||||
if (sbi->s_desc_size >= EXT4_BG_BLOCK_BITMAP_CSUM_HI_END) {
|
||||
hi = le16_to_cpu(gdp->bg_block_bitmap_csum_hi);
|
||||
provided |= (hi << 16);
|
||||
@@ -92,7 +92,7 @@ void ext4_block_bitmap_csum_set(struct super_block *sb,
|
||||
if (!ext4_has_feature_metadata_csum(sb))
|
||||
return;
|
||||
|
||||
csum = ext4_chksum(sbi, sbi->s_csum_seed, (__u8 *)bh->b_data, sz);
|
||||
csum = ext4_chksum(sbi->s_csum_seed, (__u8 *)bh->b_data, sz);
|
||||
gdp->bg_block_bitmap_csum_lo = cpu_to_le16(csum & 0xFFFF);
|
||||
if (sbi->s_desc_size >= EXT4_BG_BLOCK_BITMAP_CSUM_HI_END)
|
||||
gdp->bg_block_bitmap_csum_hi = cpu_to_le16(csum >> 16);
|
||||
|
||||
@@ -2494,8 +2494,7 @@ static inline __le16 ext4_rec_len_to_disk(unsigned len, unsigned blocksize)
|
||||
#define DX_HASH_SIPHASH 6
|
||||
#define DX_HASH_LAST DX_HASH_SIPHASH
|
||||
|
||||
static inline u32 ext4_chksum(struct ext4_sb_info *sbi, u32 crc,
|
||||
const void *address, unsigned int length)
|
||||
static inline u32 ext4_chksum(u32 crc, const void *address, unsigned int length)
|
||||
{
|
||||
return crc32c(crc, address, length);
|
||||
}
|
||||
|
||||
@@ -50,10 +50,9 @@ static __le32 ext4_extent_block_csum(struct inode *inode,
|
||||
struct ext4_extent_header *eh)
|
||||
{
|
||||
struct ext4_inode_info *ei = EXT4_I(inode);
|
||||
struct ext4_sb_info *sbi = EXT4_SB(inode->i_sb);
|
||||
__u32 csum;
|
||||
|
||||
csum = ext4_chksum(sbi, ei->i_csum_seed, (__u8 *)eh,
|
||||
csum = ext4_chksum(ei->i_csum_seed, (__u8 *)eh,
|
||||
EXT4_EXTENT_TAIL_OFFSET(eh));
|
||||
return cpu_to_le32(csum);
|
||||
}
|
||||
|
||||
@@ -734,7 +734,7 @@ static u8 *ext4_fc_reserve_space(struct super_block *sb, int len, u32 *crc)
|
||||
tl.fc_len = cpu_to_le16(remaining);
|
||||
memcpy(dst, &tl, EXT4_FC_TAG_BASE_LEN);
|
||||
memset(dst + EXT4_FC_TAG_BASE_LEN, 0, remaining);
|
||||
*crc = ext4_chksum(sbi, *crc, sbi->s_fc_bh->b_data, bsize);
|
||||
*crc = ext4_chksum(*crc, sbi->s_fc_bh->b_data, bsize);
|
||||
|
||||
ext4_fc_submit_bh(sb, false);
|
||||
|
||||
@@ -781,7 +781,7 @@ static int ext4_fc_write_tail(struct super_block *sb, u32 crc)
|
||||
tail.fc_tid = cpu_to_le32(sbi->s_journal->j_running_transaction->t_tid);
|
||||
memcpy(dst, &tail.fc_tid, sizeof(tail.fc_tid));
|
||||
dst += sizeof(tail.fc_tid);
|
||||
crc = ext4_chksum(sbi, crc, sbi->s_fc_bh->b_data,
|
||||
crc = ext4_chksum(crc, sbi->s_fc_bh->b_data,
|
||||
dst - (u8 *)sbi->s_fc_bh->b_data);
|
||||
tail.fc_crc = cpu_to_le32(crc);
|
||||
memcpy(dst, &tail.fc_crc, sizeof(tail.fc_crc));
|
||||
@@ -2133,13 +2133,13 @@ static int ext4_fc_replay_scan(journal_t *journal,
|
||||
case EXT4_FC_TAG_INODE:
|
||||
case EXT4_FC_TAG_PAD:
|
||||
state->fc_cur_tag++;
|
||||
state->fc_crc = ext4_chksum(sbi, state->fc_crc, cur,
|
||||
state->fc_crc = ext4_chksum(state->fc_crc, cur,
|
||||
EXT4_FC_TAG_BASE_LEN + tl.fc_len);
|
||||
break;
|
||||
case EXT4_FC_TAG_TAIL:
|
||||
state->fc_cur_tag++;
|
||||
memcpy(&tail, val, sizeof(tail));
|
||||
state->fc_crc = ext4_chksum(sbi, state->fc_crc, cur,
|
||||
state->fc_crc = ext4_chksum(state->fc_crc, cur,
|
||||
EXT4_FC_TAG_BASE_LEN +
|
||||
offsetof(struct ext4_fc_tail,
|
||||
fc_crc));
|
||||
@@ -2166,7 +2166,7 @@ static int ext4_fc_replay_scan(journal_t *journal,
|
||||
break;
|
||||
}
|
||||
state->fc_cur_tag++;
|
||||
state->fc_crc = ext4_chksum(sbi, state->fc_crc, cur,
|
||||
state->fc_crc = ext4_chksum(state->fc_crc, cur,
|
||||
EXT4_FC_TAG_BASE_LEN + tl.fc_len);
|
||||
break;
|
||||
default:
|
||||
|
||||
@@ -1288,10 +1288,9 @@ struct inode *__ext4_new_inode(struct mnt_idmap *idmap,
|
||||
__u32 csum;
|
||||
__le32 inum = cpu_to_le32(inode->i_ino);
|
||||
__le32 gen = cpu_to_le32(inode->i_generation);
|
||||
csum = ext4_chksum(sbi, sbi->s_csum_seed, (__u8 *)&inum,
|
||||
csum = ext4_chksum(sbi->s_csum_seed, (__u8 *)&inum,
|
||||
sizeof(inum));
|
||||
ei->i_csum_seed = ext4_chksum(sbi, csum, (__u8 *)&gen,
|
||||
sizeof(gen));
|
||||
ei->i_csum_seed = ext4_chksum(csum, (__u8 *)&gen, sizeof(gen));
|
||||
}
|
||||
|
||||
ext4_clear_state_flags(ei); /* Only relevant on 32-bit archs */
|
||||
|
||||
@@ -58,29 +58,27 @@ static void ext4_journalled_zero_new_buffers(handle_t *handle,
|
||||
static __u32 ext4_inode_csum(struct inode *inode, struct ext4_inode *raw,
|
||||
struct ext4_inode_info *ei)
|
||||
{
|
||||
struct ext4_sb_info *sbi = EXT4_SB(inode->i_sb);
|
||||
__u32 csum;
|
||||
__u16 dummy_csum = 0;
|
||||
int offset = offsetof(struct ext4_inode, i_checksum_lo);
|
||||
unsigned int csum_size = sizeof(dummy_csum);
|
||||
|
||||
csum = ext4_chksum(sbi, ei->i_csum_seed, (__u8 *)raw, offset);
|
||||
csum = ext4_chksum(sbi, csum, (__u8 *)&dummy_csum, csum_size);
|
||||
csum = ext4_chksum(ei->i_csum_seed, (__u8 *)raw, offset);
|
||||
csum = ext4_chksum(csum, (__u8 *)&dummy_csum, csum_size);
|
||||
offset += csum_size;
|
||||
csum = ext4_chksum(sbi, csum, (__u8 *)raw + offset,
|
||||
csum = ext4_chksum(csum, (__u8 *)raw + offset,
|
||||
EXT4_GOOD_OLD_INODE_SIZE - offset);
|
||||
|
||||
if (EXT4_INODE_SIZE(inode->i_sb) > EXT4_GOOD_OLD_INODE_SIZE) {
|
||||
offset = offsetof(struct ext4_inode, i_checksum_hi);
|
||||
csum = ext4_chksum(sbi, csum, (__u8 *)raw +
|
||||
EXT4_GOOD_OLD_INODE_SIZE,
|
||||
csum = ext4_chksum(csum, (__u8 *)raw + EXT4_GOOD_OLD_INODE_SIZE,
|
||||
offset - EXT4_GOOD_OLD_INODE_SIZE);
|
||||
if (EXT4_FITS_IN_INODE(raw, ei, i_checksum_hi)) {
|
||||
csum = ext4_chksum(sbi, csum, (__u8 *)&dummy_csum,
|
||||
csum = ext4_chksum(csum, (__u8 *)&dummy_csum,
|
||||
csum_size);
|
||||
offset += csum_size;
|
||||
}
|
||||
csum = ext4_chksum(sbi, csum, (__u8 *)raw + offset,
|
||||
csum = ext4_chksum(csum, (__u8 *)raw + offset,
|
||||
EXT4_INODE_SIZE(inode->i_sb) - offset);
|
||||
}
|
||||
|
||||
@@ -4922,10 +4920,9 @@ struct inode *__ext4_iget(struct super_block *sb, unsigned long ino,
|
||||
__u32 csum;
|
||||
__le32 inum = cpu_to_le32(inode->i_ino);
|
||||
__le32 gen = raw_inode->i_generation;
|
||||
csum = ext4_chksum(sbi, sbi->s_csum_seed, (__u8 *)&inum,
|
||||
csum = ext4_chksum(sbi->s_csum_seed, (__u8 *)&inum,
|
||||
sizeof(inum));
|
||||
ei->i_csum_seed = ext4_chksum(sbi, csum, (__u8 *)&gen,
|
||||
sizeof(gen));
|
||||
ei->i_csum_seed = ext4_chksum(csum, (__u8 *)&gen, sizeof(gen));
|
||||
}
|
||||
|
||||
if ((!ext4_inode_csum_verify(inode, raw_inode, ei) ||
|
||||
|
||||
@@ -354,8 +354,8 @@ void ext4_reset_inode_seed(struct inode *inode)
|
||||
if (!ext4_has_feature_metadata_csum(inode->i_sb))
|
||||
return;
|
||||
|
||||
csum = ext4_chksum(sbi, sbi->s_csum_seed, (__u8 *)&inum, sizeof(inum));
|
||||
ei->i_csum_seed = ext4_chksum(sbi, csum, (__u8 *)&gen, sizeof(gen));
|
||||
csum = ext4_chksum(sbi->s_csum_seed, (__u8 *)&inum, sizeof(inum));
|
||||
ei->i_csum_seed = ext4_chksum(csum, (__u8 *)&gen, sizeof(gen));
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -14,7 +14,7 @@ static __le32 ext4_mmp_csum(struct super_block *sb, struct mmp_struct *mmp)
|
||||
int offset = offsetof(struct mmp_struct, mmp_checksum);
|
||||
__u32 csum;
|
||||
|
||||
csum = ext4_chksum(sbi, sbi->s_csum_seed, (char *)mmp, offset);
|
||||
csum = ext4_chksum(sbi->s_csum_seed, (char *)mmp, offset);
|
||||
|
||||
return cpu_to_le32(csum);
|
||||
}
|
||||
|
||||
@@ -346,11 +346,10 @@ static struct ext4_dir_entry_tail *get_dirent_tail(struct inode *inode,
|
||||
|
||||
static __le32 ext4_dirblock_csum(struct inode *inode, void *dirent, int size)
|
||||
{
|
||||
struct ext4_sb_info *sbi = EXT4_SB(inode->i_sb);
|
||||
struct ext4_inode_info *ei = EXT4_I(inode);
|
||||
__u32 csum;
|
||||
|
||||
csum = ext4_chksum(sbi, ei->i_csum_seed, (__u8 *)dirent, size);
|
||||
csum = ext4_chksum(ei->i_csum_seed, (__u8 *)dirent, size);
|
||||
return cpu_to_le32(csum);
|
||||
}
|
||||
|
||||
@@ -442,7 +441,6 @@ static struct dx_countlimit *get_dx_countlimit(struct inode *inode,
|
||||
static __le32 ext4_dx_csum(struct inode *inode, struct ext4_dir_entry *dirent,
|
||||
int count_offset, int count, struct dx_tail *t)
|
||||
{
|
||||
struct ext4_sb_info *sbi = EXT4_SB(inode->i_sb);
|
||||
struct ext4_inode_info *ei = EXT4_I(inode);
|
||||
__u32 csum;
|
||||
int size;
|
||||
@@ -450,9 +448,9 @@ static __le32 ext4_dx_csum(struct inode *inode, struct ext4_dir_entry *dirent,
|
||||
int offset = offsetof(struct dx_tail, dt_checksum);
|
||||
|
||||
size = count_offset + (count * sizeof(struct dx_entry));
|
||||
csum = ext4_chksum(sbi, ei->i_csum_seed, (__u8 *)dirent, size);
|
||||
csum = ext4_chksum(sbi, csum, (__u8 *)t, offset);
|
||||
csum = ext4_chksum(sbi, csum, (__u8 *)&dummy_csum, sizeof(dummy_csum));
|
||||
csum = ext4_chksum(ei->i_csum_seed, (__u8 *)dirent, size);
|
||||
csum = ext4_chksum(csum, (__u8 *)t, offset);
|
||||
csum = ext4_chksum(csum, (__u8 *)&dummy_csum, sizeof(dummy_csum));
|
||||
|
||||
return cpu_to_le32(csum);
|
||||
}
|
||||
|
||||
@@ -541,9 +541,9 @@ static int ext4_orphan_file_block_csum_verify(struct super_block *sb,
|
||||
return 1;
|
||||
|
||||
ot = ext4_orphan_block_tail(sb, bh);
|
||||
calculated = ext4_chksum(EXT4_SB(sb), oi->of_csum_seed,
|
||||
(__u8 *)&dsk_block_nr, sizeof(dsk_block_nr));
|
||||
calculated = ext4_chksum(EXT4_SB(sb), calculated, (__u8 *)bh->b_data,
|
||||
calculated = ext4_chksum(oi->of_csum_seed, (__u8 *)&dsk_block_nr,
|
||||
sizeof(dsk_block_nr));
|
||||
calculated = ext4_chksum(calculated, (__u8 *)bh->b_data,
|
||||
inodes_per_ob * sizeof(__u32));
|
||||
return le32_to_cpu(ot->ob_checksum) == calculated;
|
||||
}
|
||||
@@ -560,10 +560,9 @@ void ext4_orphan_file_block_trigger(struct jbd2_buffer_trigger_type *triggers,
|
||||
struct ext4_orphan_block_tail *ot;
|
||||
__le64 dsk_block_nr = cpu_to_le64(bh->b_blocknr);
|
||||
|
||||
csum = ext4_chksum(EXT4_SB(sb), oi->of_csum_seed,
|
||||
(__u8 *)&dsk_block_nr, sizeof(dsk_block_nr));
|
||||
csum = ext4_chksum(EXT4_SB(sb), csum, (__u8 *)data,
|
||||
inodes_per_ob * sizeof(__u32));
|
||||
csum = ext4_chksum(oi->of_csum_seed, (__u8 *)&dsk_block_nr,
|
||||
sizeof(dsk_block_nr));
|
||||
csum = ext4_chksum(csum, (__u8 *)data, inodes_per_ob * sizeof(__u32));
|
||||
ot = ext4_orphan_block_tail(sb, bh);
|
||||
ot->ob_checksum = cpu_to_le32(csum);
|
||||
}
|
||||
|
||||
@@ -289,11 +289,10 @@ static int ext4_verify_csum_type(struct super_block *sb,
|
||||
__le32 ext4_superblock_csum(struct super_block *sb,
|
||||
struct ext4_super_block *es)
|
||||
{
|
||||
struct ext4_sb_info *sbi = EXT4_SB(sb);
|
||||
int offset = offsetof(struct ext4_super_block, s_checksum);
|
||||
__u32 csum;
|
||||
|
||||
csum = ext4_chksum(sbi, ~0, (char *)es, offset);
|
||||
csum = ext4_chksum(~0, (char *)es, offset);
|
||||
|
||||
return cpu_to_le32(csum);
|
||||
}
|
||||
@@ -3206,14 +3205,14 @@ static __le16 ext4_group_desc_csum(struct super_block *sb, __u32 block_group,
|
||||
__u32 csum32;
|
||||
__u16 dummy_csum = 0;
|
||||
|
||||
csum32 = ext4_chksum(sbi, sbi->s_csum_seed, (__u8 *)&le_group,
|
||||
csum32 = ext4_chksum(sbi->s_csum_seed, (__u8 *)&le_group,
|
||||
sizeof(le_group));
|
||||
csum32 = ext4_chksum(sbi, csum32, (__u8 *)gdp, offset);
|
||||
csum32 = ext4_chksum(sbi, csum32, (__u8 *)&dummy_csum,
|
||||
csum32 = ext4_chksum(csum32, (__u8 *)gdp, offset);
|
||||
csum32 = ext4_chksum(csum32, (__u8 *)&dummy_csum,
|
||||
sizeof(dummy_csum));
|
||||
offset += sizeof(dummy_csum);
|
||||
if (offset < sbi->s_desc_size)
|
||||
csum32 = ext4_chksum(sbi, csum32, (__u8 *)gdp + offset,
|
||||
csum32 = ext4_chksum(csum32, (__u8 *)gdp + offset,
|
||||
sbi->s_desc_size - offset);
|
||||
|
||||
crc = csum32 & 0xFFFF;
|
||||
@@ -4641,7 +4640,7 @@ static int ext4_init_metadata_csum(struct super_block *sb, struct ext4_super_blo
|
||||
sbi->s_csum_seed = le32_to_cpu(es->s_checksum_seed);
|
||||
else if (ext4_has_feature_metadata_csum(sb) ||
|
||||
ext4_has_feature_ea_inode(sb))
|
||||
sbi->s_csum_seed = ext4_chksum(sbi, ~0, es->s_uuid,
|
||||
sbi->s_csum_seed = ext4_chksum(~0, es->s_uuid,
|
||||
sizeof(es->s_uuid));
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -139,12 +139,12 @@ static __le32 ext4_xattr_block_csum(struct inode *inode,
|
||||
__u32 dummy_csum = 0;
|
||||
int offset = offsetof(struct ext4_xattr_header, h_checksum);
|
||||
|
||||
csum = ext4_chksum(sbi, sbi->s_csum_seed, (__u8 *)&dsk_block_nr,
|
||||
csum = ext4_chksum(sbi->s_csum_seed, (__u8 *)&dsk_block_nr,
|
||||
sizeof(dsk_block_nr));
|
||||
csum = ext4_chksum(sbi, csum, (__u8 *)hdr, offset);
|
||||
csum = ext4_chksum(sbi, csum, (__u8 *)&dummy_csum, sizeof(dummy_csum));
|
||||
csum = ext4_chksum(csum, (__u8 *)hdr, offset);
|
||||
csum = ext4_chksum(csum, (__u8 *)&dummy_csum, sizeof(dummy_csum));
|
||||
offset += sizeof(dummy_csum);
|
||||
csum = ext4_chksum(sbi, csum, (__u8 *)hdr + offset,
|
||||
csum = ext4_chksum(csum, (__u8 *)hdr + offset,
|
||||
EXT4_BLOCK_SIZE(inode->i_sb) - offset);
|
||||
|
||||
return cpu_to_le32(csum);
|
||||
@@ -348,7 +348,7 @@ xattr_find_entry(struct inode *inode, struct ext4_xattr_entry **pentry,
|
||||
static u32
|
||||
ext4_xattr_inode_hash(struct ext4_sb_info *sbi, const void *buffer, size_t size)
|
||||
{
|
||||
return ext4_chksum(sbi, sbi->s_csum_seed, buffer, size);
|
||||
return ext4_chksum(sbi->s_csum_seed, buffer, size);
|
||||
}
|
||||
|
||||
static u64 ext4_xattr_inode_get_ref(struct inode *ea_inode)
|
||||
|
||||
Reference in New Issue
Block a user