Skip to content

Commit 6cbab5f

Browse files
ebiggerstytso
authored andcommitted
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>
1 parent 7ac6730 commit 6cbab5f

12 files changed

Lines changed: 45 additions & 55 deletions

File tree

fs/ext4/bitmap.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ int ext4_inode_bitmap_csum_verify(struct super_block *sb,
3030

3131
sz = EXT4_INODES_PER_GROUP(sb) >> 3;
3232
provided = le16_to_cpu(gdp->bg_inode_bitmap_csum_lo);
33-
calculated = ext4_chksum(sbi, sbi->s_csum_seed, (__u8 *)bh->b_data, sz);
33+
calculated = ext4_chksum(sbi->s_csum_seed, (__u8 *)bh->b_data, sz);
3434
if (sbi->s_desc_size >= EXT4_BG_INODE_BITMAP_CSUM_HI_END) {
3535
hi = le16_to_cpu(gdp->bg_inode_bitmap_csum_hi);
3636
provided |= (hi << 16);
@@ -52,7 +52,7 @@ void ext4_inode_bitmap_csum_set(struct super_block *sb,
5252
return;
5353

5454
sz = EXT4_INODES_PER_GROUP(sb) >> 3;
55-
csum = ext4_chksum(sbi, sbi->s_csum_seed, (__u8 *)bh->b_data, sz);
55+
csum = ext4_chksum(sbi->s_csum_seed, (__u8 *)bh->b_data, sz);
5656
gdp->bg_inode_bitmap_csum_lo = cpu_to_le16(csum & 0xFFFF);
5757
if (sbi->s_desc_size >= EXT4_BG_INODE_BITMAP_CSUM_HI_END)
5858
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,
7171
return 1;
7272

7373
provided = le16_to_cpu(gdp->bg_block_bitmap_csum_lo);
74-
calculated = ext4_chksum(sbi, sbi->s_csum_seed, (__u8 *)bh->b_data, sz);
74+
calculated = ext4_chksum(sbi->s_csum_seed, (__u8 *)bh->b_data, sz);
7575
if (sbi->s_desc_size >= EXT4_BG_BLOCK_BITMAP_CSUM_HI_END) {
7676
hi = le16_to_cpu(gdp->bg_block_bitmap_csum_hi);
7777
provided |= (hi << 16);
@@ -92,7 +92,7 @@ void ext4_block_bitmap_csum_set(struct super_block *sb,
9292
if (!ext4_has_feature_metadata_csum(sb))
9393
return;
9494

95-
csum = ext4_chksum(sbi, sbi->s_csum_seed, (__u8 *)bh->b_data, sz);
95+
csum = ext4_chksum(sbi->s_csum_seed, (__u8 *)bh->b_data, sz);
9696
gdp->bg_block_bitmap_csum_lo = cpu_to_le16(csum & 0xFFFF);
9797
if (sbi->s_desc_size >= EXT4_BG_BLOCK_BITMAP_CSUM_HI_END)
9898
gdp->bg_block_bitmap_csum_hi = cpu_to_le16(csum >> 16);

fs/ext4/ext4.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2494,8 +2494,7 @@ static inline __le16 ext4_rec_len_to_disk(unsigned len, unsigned blocksize)
24942494
#define DX_HASH_SIPHASH 6
24952495
#define DX_HASH_LAST DX_HASH_SIPHASH
24962496

2497-
static inline u32 ext4_chksum(struct ext4_sb_info *sbi, u32 crc,
2498-
const void *address, unsigned int length)
2497+
static inline u32 ext4_chksum(u32 crc, const void *address, unsigned int length)
24992498
{
25002499
return crc32c(crc, address, length);
25012500
}

fs/ext4/extents.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,9 @@ static __le32 ext4_extent_block_csum(struct inode *inode,
5050
struct ext4_extent_header *eh)
5151
{
5252
struct ext4_inode_info *ei = EXT4_I(inode);
53-
struct ext4_sb_info *sbi = EXT4_SB(inode->i_sb);
5453
__u32 csum;
5554

56-
csum = ext4_chksum(sbi, ei->i_csum_seed, (__u8 *)eh,
55+
csum = ext4_chksum(ei->i_csum_seed, (__u8 *)eh,
5756
EXT4_EXTENT_TAIL_OFFSET(eh));
5857
return cpu_to_le32(csum);
5958
}

fs/ext4/fast_commit.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -734,7 +734,7 @@ static u8 *ext4_fc_reserve_space(struct super_block *sb, int len, u32 *crc)
734734
tl.fc_len = cpu_to_le16(remaining);
735735
memcpy(dst, &tl, EXT4_FC_TAG_BASE_LEN);
736736
memset(dst + EXT4_FC_TAG_BASE_LEN, 0, remaining);
737-
*crc = ext4_chksum(sbi, *crc, sbi->s_fc_bh->b_data, bsize);
737+
*crc = ext4_chksum(*crc, sbi->s_fc_bh->b_data, bsize);
738738

739739
ext4_fc_submit_bh(sb, false);
740740

@@ -781,7 +781,7 @@ static int ext4_fc_write_tail(struct super_block *sb, u32 crc)
781781
tail.fc_tid = cpu_to_le32(sbi->s_journal->j_running_transaction->t_tid);
782782
memcpy(dst, &tail.fc_tid, sizeof(tail.fc_tid));
783783
dst += sizeof(tail.fc_tid);
784-
crc = ext4_chksum(sbi, crc, sbi->s_fc_bh->b_data,
784+
crc = ext4_chksum(crc, sbi->s_fc_bh->b_data,
785785
dst - (u8 *)sbi->s_fc_bh->b_data);
786786
tail.fc_crc = cpu_to_le32(crc);
787787
memcpy(dst, &tail.fc_crc, sizeof(tail.fc_crc));
@@ -2133,13 +2133,13 @@ static int ext4_fc_replay_scan(journal_t *journal,
21332133
case EXT4_FC_TAG_INODE:
21342134
case EXT4_FC_TAG_PAD:
21352135
state->fc_cur_tag++;
2136-
state->fc_crc = ext4_chksum(sbi, state->fc_crc, cur,
2136+
state->fc_crc = ext4_chksum(state->fc_crc, cur,
21372137
EXT4_FC_TAG_BASE_LEN + tl.fc_len);
21382138
break;
21392139
case EXT4_FC_TAG_TAIL:
21402140
state->fc_cur_tag++;
21412141
memcpy(&tail, val, sizeof(tail));
2142-
state->fc_crc = ext4_chksum(sbi, state->fc_crc, cur,
2142+
state->fc_crc = ext4_chksum(state->fc_crc, cur,
21432143
EXT4_FC_TAG_BASE_LEN +
21442144
offsetof(struct ext4_fc_tail,
21452145
fc_crc));
@@ -2166,7 +2166,7 @@ static int ext4_fc_replay_scan(journal_t *journal,
21662166
break;
21672167
}
21682168
state->fc_cur_tag++;
2169-
state->fc_crc = ext4_chksum(sbi, state->fc_crc, cur,
2169+
state->fc_crc = ext4_chksum(state->fc_crc, cur,
21702170
EXT4_FC_TAG_BASE_LEN + tl.fc_len);
21712171
break;
21722172
default:

fs/ext4/ialloc.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1288,10 +1288,9 @@ struct inode *__ext4_new_inode(struct mnt_idmap *idmap,
12881288
__u32 csum;
12891289
__le32 inum = cpu_to_le32(inode->i_ino);
12901290
__le32 gen = cpu_to_le32(inode->i_generation);
1291-
csum = ext4_chksum(sbi, sbi->s_csum_seed, (__u8 *)&inum,
1291+
csum = ext4_chksum(sbi->s_csum_seed, (__u8 *)&inum,
12921292
sizeof(inum));
1293-
ei->i_csum_seed = ext4_chksum(sbi, csum, (__u8 *)&gen,
1294-
sizeof(gen));
1293+
ei->i_csum_seed = ext4_chksum(csum, (__u8 *)&gen, sizeof(gen));
12951294
}
12961295

12971296
ext4_clear_state_flags(ei); /* Only relevant on 32-bit archs */

fs/ext4/inode.c

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -58,29 +58,27 @@ static void ext4_journalled_zero_new_buffers(handle_t *handle,
5858
static __u32 ext4_inode_csum(struct inode *inode, struct ext4_inode *raw,
5959
struct ext4_inode_info *ei)
6060
{
61-
struct ext4_sb_info *sbi = EXT4_SB(inode->i_sb);
6261
__u32 csum;
6362
__u16 dummy_csum = 0;
6463
int offset = offsetof(struct ext4_inode, i_checksum_lo);
6564
unsigned int csum_size = sizeof(dummy_csum);
6665

67-
csum = ext4_chksum(sbi, ei->i_csum_seed, (__u8 *)raw, offset);
68-
csum = ext4_chksum(sbi, csum, (__u8 *)&dummy_csum, csum_size);
66+
csum = ext4_chksum(ei->i_csum_seed, (__u8 *)raw, offset);
67+
csum = ext4_chksum(csum, (__u8 *)&dummy_csum, csum_size);
6968
offset += csum_size;
70-
csum = ext4_chksum(sbi, csum, (__u8 *)raw + offset,
69+
csum = ext4_chksum(csum, (__u8 *)raw + offset,
7170
EXT4_GOOD_OLD_INODE_SIZE - offset);
7271

7372
if (EXT4_INODE_SIZE(inode->i_sb) > EXT4_GOOD_OLD_INODE_SIZE) {
7473
offset = offsetof(struct ext4_inode, i_checksum_hi);
75-
csum = ext4_chksum(sbi, csum, (__u8 *)raw +
76-
EXT4_GOOD_OLD_INODE_SIZE,
74+
csum = ext4_chksum(csum, (__u8 *)raw + EXT4_GOOD_OLD_INODE_SIZE,
7775
offset - EXT4_GOOD_OLD_INODE_SIZE);
7876
if (EXT4_FITS_IN_INODE(raw, ei, i_checksum_hi)) {
79-
csum = ext4_chksum(sbi, csum, (__u8 *)&dummy_csum,
77+
csum = ext4_chksum(csum, (__u8 *)&dummy_csum,
8078
csum_size);
8179
offset += csum_size;
8280
}
83-
csum = ext4_chksum(sbi, csum, (__u8 *)raw + offset,
81+
csum = ext4_chksum(csum, (__u8 *)raw + offset,
8482
EXT4_INODE_SIZE(inode->i_sb) - offset);
8583
}
8684

@@ -4922,10 +4920,9 @@ struct inode *__ext4_iget(struct super_block *sb, unsigned long ino,
49224920
__u32 csum;
49234921
__le32 inum = cpu_to_le32(inode->i_ino);
49244922
__le32 gen = raw_inode->i_generation;
4925-
csum = ext4_chksum(sbi, sbi->s_csum_seed, (__u8 *)&inum,
4923+
csum = ext4_chksum(sbi->s_csum_seed, (__u8 *)&inum,
49264924
sizeof(inum));
4927-
ei->i_csum_seed = ext4_chksum(sbi, csum, (__u8 *)&gen,
4928-
sizeof(gen));
4925+
ei->i_csum_seed = ext4_chksum(csum, (__u8 *)&gen, sizeof(gen));
49294926
}
49304927

49314928
if ((!ext4_inode_csum_verify(inode, raw_inode, ei) ||

fs/ext4/ioctl.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -354,8 +354,8 @@ void ext4_reset_inode_seed(struct inode *inode)
354354
if (!ext4_has_feature_metadata_csum(inode->i_sb))
355355
return;
356356

357-
csum = ext4_chksum(sbi, sbi->s_csum_seed, (__u8 *)&inum, sizeof(inum));
358-
ei->i_csum_seed = ext4_chksum(sbi, csum, (__u8 *)&gen, sizeof(gen));
357+
csum = ext4_chksum(sbi->s_csum_seed, (__u8 *)&inum, sizeof(inum));
358+
ei->i_csum_seed = ext4_chksum(csum, (__u8 *)&gen, sizeof(gen));
359359
}
360360

361361
/*

fs/ext4/mmp.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ static __le32 ext4_mmp_csum(struct super_block *sb, struct mmp_struct *mmp)
1414
int offset = offsetof(struct mmp_struct, mmp_checksum);
1515
__u32 csum;
1616

17-
csum = ext4_chksum(sbi, sbi->s_csum_seed, (char *)mmp, offset);
17+
csum = ext4_chksum(sbi->s_csum_seed, (char *)mmp, offset);
1818

1919
return cpu_to_le32(csum);
2020
}

fs/ext4/namei.c

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -346,11 +346,10 @@ static struct ext4_dir_entry_tail *get_dirent_tail(struct inode *inode,
346346

347347
static __le32 ext4_dirblock_csum(struct inode *inode, void *dirent, int size)
348348
{
349-
struct ext4_sb_info *sbi = EXT4_SB(inode->i_sb);
350349
struct ext4_inode_info *ei = EXT4_I(inode);
351350
__u32 csum;
352351

353-
csum = ext4_chksum(sbi, ei->i_csum_seed, (__u8 *)dirent, size);
352+
csum = ext4_chksum(ei->i_csum_seed, (__u8 *)dirent, size);
354353
return cpu_to_le32(csum);
355354
}
356355

@@ -442,17 +441,16 @@ static struct dx_countlimit *get_dx_countlimit(struct inode *inode,
442441
static __le32 ext4_dx_csum(struct inode *inode, struct ext4_dir_entry *dirent,
443442
int count_offset, int count, struct dx_tail *t)
444443
{
445-
struct ext4_sb_info *sbi = EXT4_SB(inode->i_sb);
446444
struct ext4_inode_info *ei = EXT4_I(inode);
447445
__u32 csum;
448446
int size;
449447
__u32 dummy_csum = 0;
450448
int offset = offsetof(struct dx_tail, dt_checksum);
451449

452450
size = count_offset + (count * sizeof(struct dx_entry));
453-
csum = ext4_chksum(sbi, ei->i_csum_seed, (__u8 *)dirent, size);
454-
csum = ext4_chksum(sbi, csum, (__u8 *)t, offset);
455-
csum = ext4_chksum(sbi, csum, (__u8 *)&dummy_csum, sizeof(dummy_csum));
451+
csum = ext4_chksum(ei->i_csum_seed, (__u8 *)dirent, size);
452+
csum = ext4_chksum(csum, (__u8 *)t, offset);
453+
csum = ext4_chksum(csum, (__u8 *)&dummy_csum, sizeof(dummy_csum));
456454

457455
return cpu_to_le32(csum);
458456
}

fs/ext4/orphan.c

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -541,9 +541,9 @@ static int ext4_orphan_file_block_csum_verify(struct super_block *sb,
541541
return 1;
542542

543543
ot = ext4_orphan_block_tail(sb, bh);
544-
calculated = ext4_chksum(EXT4_SB(sb), oi->of_csum_seed,
545-
(__u8 *)&dsk_block_nr, sizeof(dsk_block_nr));
546-
calculated = ext4_chksum(EXT4_SB(sb), calculated, (__u8 *)bh->b_data,
544+
calculated = ext4_chksum(oi->of_csum_seed, (__u8 *)&dsk_block_nr,
545+
sizeof(dsk_block_nr));
546+
calculated = ext4_chksum(calculated, (__u8 *)bh->b_data,
547547
inodes_per_ob * sizeof(__u32));
548548
return le32_to_cpu(ot->ob_checksum) == calculated;
549549
}
@@ -560,10 +560,9 @@ void ext4_orphan_file_block_trigger(struct jbd2_buffer_trigger_type *triggers,
560560
struct ext4_orphan_block_tail *ot;
561561
__le64 dsk_block_nr = cpu_to_le64(bh->b_blocknr);
562562

563-
csum = ext4_chksum(EXT4_SB(sb), oi->of_csum_seed,
564-
(__u8 *)&dsk_block_nr, sizeof(dsk_block_nr));
565-
csum = ext4_chksum(EXT4_SB(sb), csum, (__u8 *)data,
566-
inodes_per_ob * sizeof(__u32));
563+
csum = ext4_chksum(oi->of_csum_seed, (__u8 *)&dsk_block_nr,
564+
sizeof(dsk_block_nr));
565+
csum = ext4_chksum(csum, (__u8 *)data, inodes_per_ob * sizeof(__u32));
567566
ot = ext4_orphan_block_tail(sb, bh);
568567
ot->ob_checksum = cpu_to_le32(csum);
569568
}

0 commit comments

Comments
 (0)