* [PATCH 0/4] ext4,jbd2: clean up unused arguments to checksum functions
@ 2025-05-13 5:38 Eric Biggers
2025-05-13 5:38 ` [PATCH 1/4] ext4: remove sbi argument from ext4_chksum() Eric Biggers
` (4 more replies)
0 siblings, 5 replies; 10+ messages in thread
From: Eric Biggers @ 2025-05-13 5:38 UTC (permalink / raw)
To: linux-ext4
Since ext4_chksum() and jbd2_chksum() now call crc32c() directly, they
no longer use their ext4_sb_info and journal_t arguments. Remove these
unnecessary arguments. No functional changes.
Eric Biggers (4):
ext4: remove sbi argument from ext4_chksum()
ext4: remove sb argument from ext4_superblock_csum()
jbd2: remove journal_t argument from jbd2_chksum()
jbd2: remove journal_t argument from jbd2_superblock_csum()
fs/ext4/bitmap.c | 8 ++++----
fs/ext4/ext4.h | 6 ++----
fs/ext4/extents.c | 3 +--
fs/ext4/fast_commit.c | 10 +++++-----
fs/ext4/ialloc.c | 5 ++---
fs/ext4/inode.c | 19 ++++++++-----------
fs/ext4/ioctl.c | 8 ++++----
fs/ext4/mmp.c | 2 +-
fs/ext4/namei.c | 10 ++++------
fs/ext4/orphan.c | 13 ++++++-------
fs/ext4/resize.c | 2 +-
fs/ext4/super.c | 22 ++++++++++------------
fs/ext4/xattr.c | 10 +++++-----
fs/jbd2/commit.c | 6 +++---
fs/jbd2/journal.c | 14 +++++++-------
fs/jbd2/recovery.c | 10 +++++-----
include/linux/jbd2.h | 3 +--
17 files changed, 69 insertions(+), 82 deletions(-)
base-commit: 94824ac9a8aaf2fb3c54b4bdde842db80ffa555d
--
2.49.0
^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH 1/4] ext4: remove sbi argument from ext4_chksum()
2025-05-13 5:38 [PATCH 0/4] ext4,jbd2: clean up unused arguments to checksum functions Eric Biggers
@ 2025-05-13 5:38 ` Eric Biggers
2025-05-13 6:13 ` Baokun Li
2025-05-13 5:38 ` [PATCH 2/4] ext4: remove sb argument from ext4_superblock_csum() Eric Biggers
` (3 subsequent siblings)
4 siblings, 1 reply; 10+ messages in thread
From: Eric Biggers @ 2025-05-13 5:38 UTC (permalink / raw)
To: linux-ext4
From: Eric Biggers <ebiggers@google.com>
Since ext4_chksum() no longer uses its sbi argument, remove it.
Signed-off-by: Eric Biggers <ebiggers@google.com>
---
fs/ext4/bitmap.c | 8 ++++----
fs/ext4/ext4.h | 3 +--
fs/ext4/extents.c | 3 +--
fs/ext4/fast_commit.c | 10 +++++-----
fs/ext4/ialloc.c | 5 ++---
fs/ext4/inode.c | 19 ++++++++-----------
fs/ext4/ioctl.c | 4 ++--
fs/ext4/mmp.c | 2 +-
fs/ext4/namei.c | 10 ++++------
fs/ext4/orphan.c | 13 ++++++-------
fs/ext4/super.c | 13 ++++++-------
fs/ext4/xattr.c | 10 +++++-----
12 files changed, 45 insertions(+), 55 deletions(-)
diff --git a/fs/ext4/bitmap.c b/fs/ext4/bitmap.c
index a4dbaccee6e7..87760fabdd2e 100644
--- a/fs/ext4/bitmap.c
+++ b/fs/ext4/bitmap.c
@@ -28,11 +28,11 @@ int ext4_inode_bitmap_csum_verify(struct super_block *sb,
if (!ext4_has_feature_metadata_csum(sb))
return 1;
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);
} else
calculated &= 0xFFFF;
@@ -50,11 +50,11 @@ void ext4_inode_bitmap_csum_set(struct super_block *sb,
if (!ext4_has_feature_metadata_csum(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);
}
@@ -69,11 +69,11 @@ int ext4_block_bitmap_csum_verify(struct super_block *sb,
if (!ext4_has_feature_metadata_csum(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);
} else
calculated &= 0xFFFF;
@@ -90,10 +90,10 @@ void ext4_block_bitmap_csum_set(struct super_block *sb,
struct ext4_sb_info *sbi = EXT4_SB(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);
}
diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h
index 5a20e9cd7184..5c7a86acbf79 100644
--- a/fs/ext4/ext4.h
+++ b/fs/ext4/ext4.h
@@ -2485,12 +2485,11 @@ static inline __le16 ext4_rec_len_to_disk(unsigned len, unsigned blocksize)
#define DX_HASH_HALF_MD4_UNSIGNED 4
#define DX_HASH_TEA_UNSIGNED 5
#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);
}
#ifdef __KERNEL__
diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c
index c616a16a9f36..016ace18f2d1 100644
--- a/fs/ext4/extents.c
+++ b/fs/ext4/extents.c
@@ -48,14 +48,13 @@
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);
}
static int ext4_extent_block_csum_verify(struct inode *inode,
diff --git a/fs/ext4/fast_commit.c b/fs/ext4/fast_commit.c
index da4263a14a20..7d045e630203 100644
--- a/fs/ext4/fast_commit.c
+++ b/fs/ext4/fast_commit.c
@@ -725,11 +725,11 @@ static u8 *ext4_fc_reserve_space(struct super_block *sb, int len, u32 *crc)
tl.fc_tag = cpu_to_le16(EXT4_FC_TAG_PAD);
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);
ret = jbd2_fc_get_buf(EXT4_SB(sb)->s_journal, &bh);
if (ret)
@@ -772,11 +772,11 @@ static int ext4_fc_write_tail(struct super_block *sb, u32 crc)
memcpy(dst, &tl, EXT4_FC_TAG_BASE_LEN);
dst += EXT4_FC_TAG_BASE_LEN;
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));
dst += sizeof(tail.fc_crc);
memset(dst, 0, bsize - off); /* Don't leak uninitialized memory. */
@@ -2103,17 +2103,17 @@ static int ext4_fc_replay_scan(journal_t *journal,
case EXT4_FC_TAG_UNLINK:
case EXT4_FC_TAG_CREAT:
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));
if (le32_to_cpu(tail.fc_tid) == expected_tid &&
le32_to_cpu(tail.fc_crc) == state->fc_crc) {
@@ -2136,11 +2136,11 @@ static int ext4_fc_replay_scan(journal_t *journal,
if (le32_to_cpu(head.fc_tid) != expected_tid) {
ret = JBD2_FC_REPLAY_STOP;
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:
ret = state->fc_replay_num_tags ?
JBD2_FC_REPLAY_STOP : -ECANCELED;
diff --git a/fs/ext4/ialloc.c b/fs/ext4/ialloc.c
index 38bc8d74f4cc..cfc5e2132996 100644
--- a/fs/ext4/ialloc.c
+++ b/fs/ext4/ialloc.c
@@ -1285,14 +1285,13 @@ struct inode *__ext4_new_inode(struct mnt_idmap *idmap,
/* Precompute checksum seed for inode metadata */
if (ext4_has_feature_metadata_csum(sb)) {
__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 */
ext4_set_inode_state(inode, EXT4_STATE_NEW);
diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
index f386de8c12f6..48c7f8a2d8ed 100644
--- a/fs/ext4/inode.c
+++ b/fs/ext4/inode.c
@@ -56,33 +56,31 @@ static void ext4_journalled_zero_new_buffers(handle_t *handle,
unsigned from, unsigned to);
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);
}
return csum;
}
@@ -4851,14 +4849,13 @@ struct inode *__ext4_iget(struct super_block *sb, unsigned long ino,
if (ext4_has_feature_metadata_csum(sb)) {
struct ext4_sb_info *sbi = EXT4_SB(inode->i_sb);
__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) ||
ext4_simulate_fail(sb, EXT4_SIM_INODE_CRC)) &&
(!(EXT4_SB(sb)->s_mount_state & EXT4_FC_REPLAY))) {
diff --git a/fs/ext4/ioctl.c b/fs/ext4/ioctl.c
index d17207386ead..6b99284095bf 100644
--- a/fs/ext4/ioctl.c
+++ b/fs/ext4/ioctl.c
@@ -352,12 +352,12 @@ void ext4_reset_inode_seed(struct inode *inode)
__u32 csum;
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));
}
/*
* Swap the information from the given @inode and the inode
* EXT4_BOOT_LOADER_INO. It will basically swap i_data and all other
diff --git a/fs/ext4/mmp.c b/fs/ext4/mmp.c
index 3e26464b1425..51661570cf3b 100644
--- a/fs/ext4/mmp.c
+++ b/fs/ext4/mmp.c
@@ -12,11 +12,11 @@ static __le32 ext4_mmp_csum(struct super_block *sb, struct mmp_struct *mmp)
{
struct ext4_sb_info *sbi = EXT4_SB(sb);
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);
}
static int ext4_mmp_csum_verify(struct super_block *sb, struct mmp_struct *mmp)
diff --git a/fs/ext4/namei.c b/fs/ext4/namei.c
index dda1791e9e1a..5546189c918b 100644
--- a/fs/ext4/namei.c
+++ b/fs/ext4/namei.c
@@ -344,15 +344,14 @@ static struct ext4_dir_entry_tail *get_dirent_tail(struct inode *inode,
return t;
}
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);
}
#define warn_no_space_for_csum(inode) \
__warn_no_space_for_csum((inode), __func__, __LINE__)
@@ -440,21 +439,20 @@ 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;
__u32 dummy_csum = 0;
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);
}
static int ext4_dx_csum_verify(struct inode *inode,
diff --git a/fs/ext4/orphan.c b/fs/ext4/orphan.c
index c66e0cb29bd4..7c7f792ad6ab 100644
--- a/fs/ext4/orphan.c
+++ b/fs/ext4/orphan.c
@@ -539,13 +539,13 @@ static int ext4_orphan_file_block_csum_verify(struct super_block *sb,
if (!ext4_has_feature_metadata_csum(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;
}
/* This gets called only when checksumming is enabled */
@@ -558,14 +558,13 @@ void ext4_orphan_file_block_trigger(struct jbd2_buffer_trigger_type *triggers,
int inodes_per_ob = ext4_inodes_per_orphan_block(sb);
struct ext4_orphan_info *oi = &EXT4_SB(sb)->s_orphan_info;
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);
}
int ext4_init_orphan_info(struct super_block *sb)
diff --git a/fs/ext4/super.c b/fs/ext4/super.c
index 8122d4ffb3b5..d7780269b455 100644
--- a/fs/ext4/super.c
+++ b/fs/ext4/super.c
@@ -287,15 +287,14 @@ 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);
}
static int ext4_superblock_csum_verify(struct super_block *sb,
@@ -3207,18 +3206,18 @@ static __le16 ext4_group_desc_csum(struct super_block *sb, __u32 block_group,
if (ext4_has_feature_metadata_csum(sbi->s_sb)) {
/* Use new metadata_csum algorithm */
__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;
goto out;
}
@@ -4642,11 +4641,11 @@ static int ext4_init_metadata_csum(struct super_block *sb, struct ext4_super_blo
/* Precompute checksum seed for all metadata */
if (ext4_has_feature_csum_seed(sb))
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;
}
static int ext4_check_feature_compatibility(struct super_block *sb,
diff --git a/fs/ext4/xattr.c b/fs/ext4/xattr.c
index 7ab8f2e8e815..8d15acbacc20 100644
--- a/fs/ext4/xattr.c
+++ b/fs/ext4/xattr.c
@@ -137,16 +137,16 @@ static __le32 ext4_xattr_block_csum(struct inode *inode,
__u32 csum;
__le64 dsk_block_nr = cpu_to_le64(block_nr);
__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);
}
@@ -346,11 +346,11 @@ 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)
{
return ((u64) inode_get_ctime_sec(ea_inode) << 32) |
--
2.49.0
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH 2/4] ext4: remove sb argument from ext4_superblock_csum()
2025-05-13 5:38 [PATCH 0/4] ext4,jbd2: clean up unused arguments to checksum functions Eric Biggers
2025-05-13 5:38 ` [PATCH 1/4] ext4: remove sbi argument from ext4_chksum() Eric Biggers
@ 2025-05-13 5:38 ` Eric Biggers
2025-05-13 6:17 ` Baokun Li
2025-05-13 5:38 ` [PATCH 3/4] jbd2: remove journal_t argument from jbd2_chksum() Eric Biggers
` (2 subsequent siblings)
4 siblings, 1 reply; 10+ messages in thread
From: Eric Biggers @ 2025-05-13 5:38 UTC (permalink / raw)
To: linux-ext4
From: Eric Biggers <ebiggers@google.com>
Since ext4_superblock_csum() no longer uses its sb argument, remove it.
Signed-off-by: Eric Biggers <ebiggers@google.com>
---
fs/ext4/ext4.h | 3 +--
fs/ext4/ioctl.c | 4 ++--
fs/ext4/resize.c | 2 +-
fs/ext4/super.c | 9 ++++-----
4 files changed, 8 insertions(+), 10 deletions(-)
diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h
index 5c7a86acbf79..25221c6693b0 100644
--- a/fs/ext4/ext4.h
+++ b/fs/ext4/ext4.h
@@ -3116,12 +3116,11 @@ extern int ext4_read_bh(struct buffer_head *bh, blk_opf_t op_flags,
bh_end_io_t *end_io, bool simu_fail);
extern int ext4_read_bh_lock(struct buffer_head *bh, blk_opf_t op_flags, bool wait);
extern void ext4_sb_breadahead_unmovable(struct super_block *sb, sector_t block);
extern int ext4_seq_options_show(struct seq_file *seq, void *offset);
extern int ext4_calculate_overhead(struct super_block *sb);
-extern __le32 ext4_superblock_csum(struct super_block *sb,
- struct ext4_super_block *es);
+extern __le32 ext4_superblock_csum(struct ext4_super_block *es);
extern void ext4_superblock_csum_set(struct super_block *sb);
extern int ext4_alloc_flex_bg_array(struct super_block *sb,
ext4_group_t ngroup);
extern const char *ext4_decode_error(struct super_block *sb, int errno,
char nbuf[16]);
diff --git a/fs/ext4/ioctl.c b/fs/ext4/ioctl.c
index 6b99284095bf..c05eb0efbb95 100644
--- a/fs/ext4/ioctl.c
+++ b/fs/ext4/ioctl.c
@@ -141,19 +141,19 @@ static int ext4_update_backup_sb(struct super_block *sb,
}
es = (struct ext4_super_block *) (bh->b_data + offset);
lock_buffer(bh);
if (ext4_has_feature_metadata_csum(sb) &&
- es->s_checksum != ext4_superblock_csum(sb, es)) {
+ es->s_checksum != ext4_superblock_csum(es)) {
ext4_msg(sb, KERN_ERR, "Invalid checksum for backup "
"superblock %llu", sb_block);
unlock_buffer(bh);
goto out_bh;
}
func(es, arg);
if (ext4_has_feature_metadata_csum(sb))
- es->s_checksum = ext4_superblock_csum(sb, es);
+ es->s_checksum = ext4_superblock_csum(es);
set_buffer_uptodate(bh);
unlock_buffer(bh);
if (handle) {
err = ext4_handle_dirty_metadata(handle, NULL, bh);
diff --git a/fs/ext4/resize.c b/fs/ext4/resize.c
index b7ff0d955f0d..050f26168d97 100644
--- a/fs/ext4/resize.c
+++ b/fs/ext4/resize.c
@@ -1117,11 +1117,11 @@ static inline void ext4_set_block_group_nr(struct super_block *sb, char *data,
{
struct ext4_super_block *es = (struct ext4_super_block *) data;
es->s_block_group_nr = cpu_to_le16(group);
if (ext4_has_feature_metadata_csum(sb))
- es->s_checksum = ext4_superblock_csum(sb, es);
+ es->s_checksum = ext4_superblock_csum(es);
}
/*
* Update the backup copies of the ext4 metadata. These don't need to be part
* of the main resize transaction, because e2fsck will re-write them if there
diff --git a/fs/ext4/super.c b/fs/ext4/super.c
index d7780269b455..14e47cc2a5a3 100644
--- a/fs/ext4/super.c
+++ b/fs/ext4/super.c
@@ -284,12 +284,11 @@ static int ext4_verify_csum_type(struct super_block *sb,
return 1;
return es->s_checksum_type == EXT4_CRC32C_CHKSUM;
}
-__le32 ext4_superblock_csum(struct super_block *sb,
- struct ext4_super_block *es)
+__le32 ext4_superblock_csum(struct ext4_super_block *es)
{
int offset = offsetof(struct ext4_super_block, s_checksum);
__u32 csum;
csum = ext4_chksum(~0, (char *)es, offset);
@@ -301,21 +300,21 @@ static int ext4_superblock_csum_verify(struct super_block *sb,
struct ext4_super_block *es)
{
if (!ext4_has_feature_metadata_csum(sb))
return 1;
- return es->s_checksum == ext4_superblock_csum(sb, es);
+ return es->s_checksum == ext4_superblock_csum(es);
}
void ext4_superblock_csum_set(struct super_block *sb)
{
struct ext4_super_block *es = EXT4_SB(sb)->s_es;
if (!ext4_has_feature_metadata_csum(sb))
return;
- es->s_checksum = ext4_superblock_csum(sb, es);
+ es->s_checksum = ext4_superblock_csum(es);
}
ext4_fsblk_t ext4_block_bitmap(struct super_block *sb,
struct ext4_group_desc *bg)
{
@@ -5913,11 +5912,11 @@ static struct file *ext4_get_journal_blkdev(struct super_block *sb,
goto out_bh;
}
if ((le32_to_cpu(es->s_feature_ro_compat) &
EXT4_FEATURE_RO_COMPAT_METADATA_CSUM) &&
- es->s_checksum != ext4_superblock_csum(sb, es)) {
+ es->s_checksum != ext4_superblock_csum(es)) {
ext4_msg(sb, KERN_ERR, "external journal has corrupt superblock");
errno = -EFSCORRUPTED;
goto out_bh;
}
--
2.49.0
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH 3/4] jbd2: remove journal_t argument from jbd2_chksum()
2025-05-13 5:38 [PATCH 0/4] ext4,jbd2: clean up unused arguments to checksum functions Eric Biggers
2025-05-13 5:38 ` [PATCH 1/4] ext4: remove sbi argument from ext4_chksum() Eric Biggers
2025-05-13 5:38 ` [PATCH 2/4] ext4: remove sb argument from ext4_superblock_csum() Eric Biggers
@ 2025-05-13 5:38 ` Eric Biggers
2025-05-13 6:19 ` Baokun Li
2025-05-13 5:38 ` [PATCH 4/4] jbd2: remove journal_t argument from jbd2_superblock_csum() Eric Biggers
2025-05-20 14:40 ` [PATCH 0/4] ext4,jbd2: clean up unused arguments to checksum functions Theodore Ts'o
4 siblings, 1 reply; 10+ messages in thread
From: Eric Biggers @ 2025-05-13 5:38 UTC (permalink / raw)
To: linux-ext4
From: Eric Biggers <ebiggers@google.com>
Since jbd2_chksum() no longer uses its journal_t argument, remove it.
Signed-off-by: Eric Biggers <ebiggers@google.com>
---
fs/jbd2/commit.c | 6 +++---
fs/jbd2/journal.c | 8 ++++----
fs/jbd2/recovery.c | 10 +++++-----
include/linux/jbd2.h | 3 +--
4 files changed, 13 insertions(+), 14 deletions(-)
diff --git a/fs/jbd2/commit.c b/fs/jbd2/commit.c
index 1c7c49356878..7203d2d2624d 100644
--- a/fs/jbd2/commit.c
+++ b/fs/jbd2/commit.c
@@ -97,11 +97,11 @@ static void jbd2_commit_block_csum_set(journal_t *j, struct buffer_head *bh)
h = (struct commit_header *)(bh->b_data);
h->h_chksum_type = 0;
h->h_chksum_size = 0;
h->h_chksum[0] = 0;
- csum = jbd2_chksum(j, j->j_csum_seed, bh->b_data, j->j_blocksize);
+ csum = jbd2_chksum(j->j_csum_seed, bh->b_data, j->j_blocksize);
h->h_chksum[0] = cpu_to_be32(csum);
}
/*
* Done it all: now submit the commit record. We should have
@@ -328,12 +328,12 @@ static void jbd2_block_tag_csum_set(journal_t *j, journal_block_tag_t *tag,
if (!jbd2_journal_has_csum_v2or3(j))
return;
seq = cpu_to_be32(sequence);
addr = kmap_local_folio(bh->b_folio, bh_offset(bh));
- csum32 = jbd2_chksum(j, j->j_csum_seed, (__u8 *)&seq, sizeof(seq));
- csum32 = jbd2_chksum(j, csum32, addr, bh->b_size);
+ csum32 = jbd2_chksum(j->j_csum_seed, (__u8 *)&seq, sizeof(seq));
+ csum32 = jbd2_chksum(csum32, addr, bh->b_size);
kunmap_local(addr);
if (jbd2_has_feature_csum3(j))
tag3->t_checksum = cpu_to_be32(csum32);
else
diff --git a/fs/jbd2/journal.c b/fs/jbd2/journal.c
index a5ccba25ff47..255fa03031d8 100644
--- a/fs/jbd2/journal.c
+++ b/fs/jbd2/journal.c
@@ -120,11 +120,11 @@ static __be32 jbd2_superblock_csum(journal_t *j, journal_superblock_t *sb)
__u32 csum;
__be32 old_csum;
old_csum = sb->s_checksum;
sb->s_checksum = 0;
- csum = jbd2_chksum(j, ~0, (char *)sb, sizeof(journal_superblock_t));
+ csum = jbd2_chksum(~0, (char *)sb, sizeof(journal_superblock_t));
sb->s_checksum = old_csum;
return cpu_to_be32(csum);
}
@@ -1000,11 +1000,11 @@ void jbd2_descriptor_block_csum_set(journal_t *j, struct buffer_head *bh)
return;
tail = (struct jbd2_journal_block_tail *)(bh->b_data + j->j_blocksize -
sizeof(struct jbd2_journal_block_tail));
tail->t_checksum = 0;
- csum = jbd2_chksum(j, j->j_csum_seed, bh->b_data, j->j_blocksize);
+ csum = jbd2_chksum(j->j_csum_seed, bh->b_data, j->j_blocksize);
tail->t_checksum = cpu_to_be32(csum);
}
/*
* Return tid of the oldest transaction in the journal and block in the journal
@@ -1490,11 +1490,11 @@ static int journal_load_superblock(journal_t *journal)
if (be32_to_cpu(sb->s_maxlen) < journal->j_total_len)
journal->j_total_len = be32_to_cpu(sb->s_maxlen);
/* Precompute checksum seed for all metadata */
if (jbd2_journal_has_csum_v2or3(journal))
- journal->j_csum_seed = jbd2_chksum(journal, ~0, sb->s_uuid,
+ journal->j_csum_seed = jbd2_chksum(~0, sb->s_uuid,
sizeof(sb->s_uuid));
/* After journal features are set, we can compute transaction limits */
jbd2_journal_init_transaction_limits(journal);
if (jbd2_has_feature_fast_commit(journal)) {
@@ -2336,11 +2336,11 @@ int jbd2_journal_set_features(journal_t *journal, unsigned long compat,
/* If enabling v3 checksums, update superblock and precompute seed */
if (INCOMPAT_FEATURE_ON(JBD2_FEATURE_INCOMPAT_CSUM_V3)) {
sb->s_checksum_type = JBD2_CRC32C_CHKSUM;
sb->s_feature_compat &=
~cpu_to_be32(JBD2_FEATURE_COMPAT_CHECKSUM);
- journal->j_csum_seed = jbd2_chksum(journal, ~0, sb->s_uuid,
+ journal->j_csum_seed = jbd2_chksum(~0, sb->s_uuid,
sizeof(sb->s_uuid));
}
/* If enabling v1 checksums, downgrade superblock */
if (COMPAT_FEATURE_ON(JBD2_FEATURE_COMPAT_CHECKSUM))
diff --git a/fs/jbd2/recovery.c b/fs/jbd2/recovery.c
index c271a050b7e6..cac8c2cd4a92 100644
--- a/fs/jbd2/recovery.c
+++ b/fs/jbd2/recovery.c
@@ -183,11 +183,11 @@ static int jbd2_descriptor_block_csum_verify(journal_t *j, void *buf)
tail = (struct jbd2_journal_block_tail *)((char *)buf +
j->j_blocksize - sizeof(struct jbd2_journal_block_tail));
provided = tail->t_checksum;
tail->t_checksum = 0;
- calculated = jbd2_chksum(j, j->j_csum_seed, buf, j->j_blocksize);
+ calculated = jbd2_chksum(j->j_csum_seed, buf, j->j_blocksize);
tail->t_checksum = provided;
return provided == cpu_to_be32(calculated);
}
@@ -438,11 +438,11 @@ static int jbd2_commit_block_csum_verify(journal_t *j, void *buf)
return 1;
h = buf;
provided = h->h_chksum[0];
h->h_chksum[0] = 0;
- calculated = jbd2_chksum(j, j->j_csum_seed, buf, j->j_blocksize);
+ calculated = jbd2_chksum(j->j_csum_seed, buf, j->j_blocksize);
h->h_chksum[0] = provided;
return provided == cpu_to_be32(calculated);
}
@@ -459,11 +459,11 @@ static bool jbd2_commit_block_csum_verify_partial(journal_t *j, void *buf)
memcpy(tmpbuf, buf, sizeof(struct commit_header));
h = tmpbuf;
provided = h->h_chksum[0];
h->h_chksum[0] = 0;
- calculated = jbd2_chksum(j, j->j_csum_seed, tmpbuf, j->j_blocksize);
+ calculated = jbd2_chksum(j->j_csum_seed, tmpbuf, j->j_blocksize);
kfree(tmpbuf);
return provided == cpu_to_be32(calculated);
}
@@ -476,12 +476,12 @@ static int jbd2_block_tag_csum_verify(journal_t *j, journal_block_tag_t *tag,
if (!jbd2_journal_has_csum_v2or3(j))
return 1;
seq = cpu_to_be32(sequence);
- csum32 = jbd2_chksum(j, j->j_csum_seed, (__u8 *)&seq, sizeof(seq));
- csum32 = jbd2_chksum(j, csum32, buf, j->j_blocksize);
+ csum32 = jbd2_chksum(j->j_csum_seed, (__u8 *)&seq, sizeof(seq));
+ csum32 = jbd2_chksum(csum32, buf, j->j_blocksize);
if (jbd2_has_feature_csum3(j))
return tag3->t_checksum == cpu_to_be32(csum32);
else
return tag->t_checksum == cpu_to_be16(csum32);
diff --git a/include/linux/jbd2.h b/include/linux/jbd2.h
index 023e8abdb99a..b04d554e0992 100644
--- a/include/linux/jbd2.h
+++ b/include/linux/jbd2.h
@@ -1764,12 +1764,11 @@ static inline unsigned long jbd2_log_space_left(journal_t *journal)
#define BJ_Forget 2 /* Buffer superseded by this transaction */
#define BJ_Shadow 3 /* Buffer contents being shadowed to the log */
#define BJ_Reserved 4 /* Buffer is reserved for access by journal */
#define BJ_Types 5
-static inline u32 jbd2_chksum(journal_t *journal, u32 crc,
- const void *address, unsigned int length)
+static inline u32 jbd2_chksum(u32 crc, const void *address, unsigned int length)
{
return crc32c(crc, address, length);
}
/* Return most recent uncommitted transaction */
--
2.49.0
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH 4/4] jbd2: remove journal_t argument from jbd2_superblock_csum()
2025-05-13 5:38 [PATCH 0/4] ext4,jbd2: clean up unused arguments to checksum functions Eric Biggers
` (2 preceding siblings ...)
2025-05-13 5:38 ` [PATCH 3/4] jbd2: remove journal_t argument from jbd2_chksum() Eric Biggers
@ 2025-05-13 5:38 ` Eric Biggers
2025-05-13 6:21 ` Baokun Li
2025-05-20 14:40 ` [PATCH 0/4] ext4,jbd2: clean up unused arguments to checksum functions Theodore Ts'o
4 siblings, 1 reply; 10+ messages in thread
From: Eric Biggers @ 2025-05-13 5:38 UTC (permalink / raw)
To: linux-ext4
From: Eric Biggers <ebiggers@google.com>
Since jbd2_superblock_csum() no longer uses its journal_t argument,
remove it.
Signed-off-by: Eric Biggers <ebiggers@google.com>
---
fs/jbd2/journal.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/fs/jbd2/journal.c b/fs/jbd2/journal.c
index 255fa03031d8..46a09744e27a 100644
--- a/fs/jbd2/journal.c
+++ b/fs/jbd2/journal.c
@@ -113,11 +113,11 @@ void __jbd2_debug(int level, const char *file, const char *func,
va_end(args);
}
#endif
/* Checksumming functions */
-static __be32 jbd2_superblock_csum(journal_t *j, journal_superblock_t *sb)
+static __be32 jbd2_superblock_csum(journal_superblock_t *sb)
{
__u32 csum;
__be32 old_csum;
old_csum = sb->s_checksum;
@@ -1384,11 +1384,11 @@ static int journal_check_superblock(journal_t *journal)
printk(KERN_ERR "JBD2: Unknown checksum type\n");
return err;
}
/* Check superblock checksum */
- if (sb->s_checksum != jbd2_superblock_csum(journal, sb)) {
+ if (sb->s_checksum != jbd2_superblock_csum(sb)) {
printk(KERN_ERR "JBD2: journal checksum error\n");
err = -EFSBADCRC;
return err;
}
}
@@ -1819,11 +1819,11 @@ static int jbd2_write_superblock(journal_t *journal, blk_opf_t write_flags)
journal->j_devname);
clear_buffer_write_io_error(bh);
set_buffer_uptodate(bh);
}
if (jbd2_journal_has_csum_v2or3(journal))
- sb->s_checksum = jbd2_superblock_csum(journal, sb);
+ sb->s_checksum = jbd2_superblock_csum(sb);
get_bh(bh);
bh->b_end_io = end_buffer_write_sync;
submit_bh(REQ_OP_WRITE | write_flags, bh);
wait_on_buffer(bh);
if (buffer_write_io_error(bh)) {
--
2.49.0
^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [PATCH 1/4] ext4: remove sbi argument from ext4_chksum()
2025-05-13 5:38 ` [PATCH 1/4] ext4: remove sbi argument from ext4_chksum() Eric Biggers
@ 2025-05-13 6:13 ` Baokun Li
0 siblings, 0 replies; 10+ messages in thread
From: Baokun Li @ 2025-05-13 6:13 UTC (permalink / raw)
To: Eric Biggers; +Cc: linux-ext4
On 2025/5/13 13:38, Eric Biggers wrote:
> From: Eric Biggers <ebiggers@google.com>
>
> Since ext4_chksum() no longer uses its sbi argument, remove it.
>
> Signed-off-by: Eric Biggers <ebiggers@google.com>
Nice cleanup! Looks good to me.
Reviewed-by: Baokun Li <libaokun1@huawei.com>
> ---
> fs/ext4/bitmap.c | 8 ++++----
> fs/ext4/ext4.h | 3 +--
> fs/ext4/extents.c | 3 +--
> fs/ext4/fast_commit.c | 10 +++++-----
> fs/ext4/ialloc.c | 5 ++---
> fs/ext4/inode.c | 19 ++++++++-----------
> fs/ext4/ioctl.c | 4 ++--
> fs/ext4/mmp.c | 2 +-
> fs/ext4/namei.c | 10 ++++------
> fs/ext4/orphan.c | 13 ++++++-------
> fs/ext4/super.c | 13 ++++++-------
> fs/ext4/xattr.c | 10 +++++-----
> 12 files changed, 45 insertions(+), 55 deletions(-)
>
> diff --git a/fs/ext4/bitmap.c b/fs/ext4/bitmap.c
> index a4dbaccee6e7..87760fabdd2e 100644
> --- a/fs/ext4/bitmap.c
> +++ b/fs/ext4/bitmap.c
> @@ -28,11 +28,11 @@ int ext4_inode_bitmap_csum_verify(struct super_block *sb,
> if (!ext4_has_feature_metadata_csum(sb))
> return 1;
>
> 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);
> } else
> calculated &= 0xFFFF;
> @@ -50,11 +50,11 @@ void ext4_inode_bitmap_csum_set(struct super_block *sb,
>
> if (!ext4_has_feature_metadata_csum(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);
> }
>
> @@ -69,11 +69,11 @@ int ext4_block_bitmap_csum_verify(struct super_block *sb,
>
> if (!ext4_has_feature_metadata_csum(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);
> } else
> calculated &= 0xFFFF;
> @@ -90,10 +90,10 @@ void ext4_block_bitmap_csum_set(struct super_block *sb,
> struct ext4_sb_info *sbi = EXT4_SB(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);
> }
> diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h
> index 5a20e9cd7184..5c7a86acbf79 100644
> --- a/fs/ext4/ext4.h
> +++ b/fs/ext4/ext4.h
> @@ -2485,12 +2485,11 @@ static inline __le16 ext4_rec_len_to_disk(unsigned len, unsigned blocksize)
> #define DX_HASH_HALF_MD4_UNSIGNED 4
> #define DX_HASH_TEA_UNSIGNED 5
> #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);
> }
>
> #ifdef __KERNEL__
> diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c
> index c616a16a9f36..016ace18f2d1 100644
> --- a/fs/ext4/extents.c
> +++ b/fs/ext4/extents.c
> @@ -48,14 +48,13 @@
>
> 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);
> }
>
> static int ext4_extent_block_csum_verify(struct inode *inode,
> diff --git a/fs/ext4/fast_commit.c b/fs/ext4/fast_commit.c
> index da4263a14a20..7d045e630203 100644
> --- a/fs/ext4/fast_commit.c
> +++ b/fs/ext4/fast_commit.c
> @@ -725,11 +725,11 @@ static u8 *ext4_fc_reserve_space(struct super_block *sb, int len, u32 *crc)
>
> tl.fc_tag = cpu_to_le16(EXT4_FC_TAG_PAD);
> 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);
>
> ret = jbd2_fc_get_buf(EXT4_SB(sb)->s_journal, &bh);
> if (ret)
> @@ -772,11 +772,11 @@ static int ext4_fc_write_tail(struct super_block *sb, u32 crc)
> memcpy(dst, &tl, EXT4_FC_TAG_BASE_LEN);
> dst += EXT4_FC_TAG_BASE_LEN;
> 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));
> dst += sizeof(tail.fc_crc);
> memset(dst, 0, bsize - off); /* Don't leak uninitialized memory. */
> @@ -2103,17 +2103,17 @@ static int ext4_fc_replay_scan(journal_t *journal,
> case EXT4_FC_TAG_UNLINK:
> case EXT4_FC_TAG_CREAT:
> 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));
> if (le32_to_cpu(tail.fc_tid) == expected_tid &&
> le32_to_cpu(tail.fc_crc) == state->fc_crc) {
> @@ -2136,11 +2136,11 @@ static int ext4_fc_replay_scan(journal_t *journal,
> if (le32_to_cpu(head.fc_tid) != expected_tid) {
> ret = JBD2_FC_REPLAY_STOP;
> 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:
> ret = state->fc_replay_num_tags ?
> JBD2_FC_REPLAY_STOP : -ECANCELED;
> diff --git a/fs/ext4/ialloc.c b/fs/ext4/ialloc.c
> index 38bc8d74f4cc..cfc5e2132996 100644
> --- a/fs/ext4/ialloc.c
> +++ b/fs/ext4/ialloc.c
> @@ -1285,14 +1285,13 @@ struct inode *__ext4_new_inode(struct mnt_idmap *idmap,
> /* Precompute checksum seed for inode metadata */
> if (ext4_has_feature_metadata_csum(sb)) {
> __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 */
> ext4_set_inode_state(inode, EXT4_STATE_NEW);
>
> diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
> index f386de8c12f6..48c7f8a2d8ed 100644
> --- a/fs/ext4/inode.c
> +++ b/fs/ext4/inode.c
> @@ -56,33 +56,31 @@ static void ext4_journalled_zero_new_buffers(handle_t *handle,
> unsigned from, unsigned to);
>
> 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);
> }
>
> return csum;
> }
> @@ -4851,14 +4849,13 @@ struct inode *__ext4_iget(struct super_block *sb, unsigned long ino,
> if (ext4_has_feature_metadata_csum(sb)) {
> struct ext4_sb_info *sbi = EXT4_SB(inode->i_sb);
> __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) ||
> ext4_simulate_fail(sb, EXT4_SIM_INODE_CRC)) &&
> (!(EXT4_SB(sb)->s_mount_state & EXT4_FC_REPLAY))) {
> diff --git a/fs/ext4/ioctl.c b/fs/ext4/ioctl.c
> index d17207386ead..6b99284095bf 100644
> --- a/fs/ext4/ioctl.c
> +++ b/fs/ext4/ioctl.c
> @@ -352,12 +352,12 @@ void ext4_reset_inode_seed(struct inode *inode)
> __u32 csum;
>
> 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));
> }
>
> /*
> * Swap the information from the given @inode and the inode
> * EXT4_BOOT_LOADER_INO. It will basically swap i_data and all other
> diff --git a/fs/ext4/mmp.c b/fs/ext4/mmp.c
> index 3e26464b1425..51661570cf3b 100644
> --- a/fs/ext4/mmp.c
> +++ b/fs/ext4/mmp.c
> @@ -12,11 +12,11 @@ static __le32 ext4_mmp_csum(struct super_block *sb, struct mmp_struct *mmp)
> {
> struct ext4_sb_info *sbi = EXT4_SB(sb);
> 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);
> }
>
> static int ext4_mmp_csum_verify(struct super_block *sb, struct mmp_struct *mmp)
> diff --git a/fs/ext4/namei.c b/fs/ext4/namei.c
> index dda1791e9e1a..5546189c918b 100644
> --- a/fs/ext4/namei.c
> +++ b/fs/ext4/namei.c
> @@ -344,15 +344,14 @@ static struct ext4_dir_entry_tail *get_dirent_tail(struct inode *inode,
> return t;
> }
>
> 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);
> }
>
> #define warn_no_space_for_csum(inode) \
> __warn_no_space_for_csum((inode), __func__, __LINE__)
> @@ -440,21 +439,20 @@ 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;
> __u32 dummy_csum = 0;
> 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);
> }
>
> static int ext4_dx_csum_verify(struct inode *inode,
> diff --git a/fs/ext4/orphan.c b/fs/ext4/orphan.c
> index c66e0cb29bd4..7c7f792ad6ab 100644
> --- a/fs/ext4/orphan.c
> +++ b/fs/ext4/orphan.c
> @@ -539,13 +539,13 @@ static int ext4_orphan_file_block_csum_verify(struct super_block *sb,
>
> if (!ext4_has_feature_metadata_csum(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;
> }
>
> /* This gets called only when checksumming is enabled */
> @@ -558,14 +558,13 @@ void ext4_orphan_file_block_trigger(struct jbd2_buffer_trigger_type *triggers,
> int inodes_per_ob = ext4_inodes_per_orphan_block(sb);
> struct ext4_orphan_info *oi = &EXT4_SB(sb)->s_orphan_info;
> 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);
> }
>
> int ext4_init_orphan_info(struct super_block *sb)
> diff --git a/fs/ext4/super.c b/fs/ext4/super.c
> index 8122d4ffb3b5..d7780269b455 100644
> --- a/fs/ext4/super.c
> +++ b/fs/ext4/super.c
> @@ -287,15 +287,14 @@ 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);
> }
>
> static int ext4_superblock_csum_verify(struct super_block *sb,
> @@ -3207,18 +3206,18 @@ static __le16 ext4_group_desc_csum(struct super_block *sb, __u32 block_group,
> if (ext4_has_feature_metadata_csum(sbi->s_sb)) {
> /* Use new metadata_csum algorithm */
> __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;
> goto out;
> }
> @@ -4642,11 +4641,11 @@ static int ext4_init_metadata_csum(struct super_block *sb, struct ext4_super_blo
> /* Precompute checksum seed for all metadata */
> if (ext4_has_feature_csum_seed(sb))
> 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;
> }
>
> static int ext4_check_feature_compatibility(struct super_block *sb,
> diff --git a/fs/ext4/xattr.c b/fs/ext4/xattr.c
> index 7ab8f2e8e815..8d15acbacc20 100644
> --- a/fs/ext4/xattr.c
> +++ b/fs/ext4/xattr.c
> @@ -137,16 +137,16 @@ static __le32 ext4_xattr_block_csum(struct inode *inode,
> __u32 csum;
> __le64 dsk_block_nr = cpu_to_le64(block_nr);
> __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);
> }
>
> @@ -346,11 +346,11 @@ 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)
> {
> return ((u64) inode_get_ctime_sec(ea_inode) << 32) |
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH 2/4] ext4: remove sb argument from ext4_superblock_csum()
2025-05-13 5:38 ` [PATCH 2/4] ext4: remove sb argument from ext4_superblock_csum() Eric Biggers
@ 2025-05-13 6:17 ` Baokun Li
0 siblings, 0 replies; 10+ messages in thread
From: Baokun Li @ 2025-05-13 6:17 UTC (permalink / raw)
To: Eric Biggers; +Cc: linux-ext4
On 2025/5/13 13:38, Eric Biggers wrote:
> From: Eric Biggers <ebiggers@google.com>
>
> Since ext4_superblock_csum() no longer uses its sb argument, remove it.
>
> Signed-off-by: Eric Biggers <ebiggers@google.com>
Good spotting!
Reviewed-by: Baokun Li <libaokun1@huawei.com>
> ---
> fs/ext4/ext4.h | 3 +--
> fs/ext4/ioctl.c | 4 ++--
> fs/ext4/resize.c | 2 +-
> fs/ext4/super.c | 9 ++++-----
> 4 files changed, 8 insertions(+), 10 deletions(-)
>
> diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h
> index 5c7a86acbf79..25221c6693b0 100644
> --- a/fs/ext4/ext4.h
> +++ b/fs/ext4/ext4.h
> @@ -3116,12 +3116,11 @@ extern int ext4_read_bh(struct buffer_head *bh, blk_opf_t op_flags,
> bh_end_io_t *end_io, bool simu_fail);
> extern int ext4_read_bh_lock(struct buffer_head *bh, blk_opf_t op_flags, bool wait);
> extern void ext4_sb_breadahead_unmovable(struct super_block *sb, sector_t block);
> extern int ext4_seq_options_show(struct seq_file *seq, void *offset);
> extern int ext4_calculate_overhead(struct super_block *sb);
> -extern __le32 ext4_superblock_csum(struct super_block *sb,
> - struct ext4_super_block *es);
> +extern __le32 ext4_superblock_csum(struct ext4_super_block *es);
> extern void ext4_superblock_csum_set(struct super_block *sb);
> extern int ext4_alloc_flex_bg_array(struct super_block *sb,
> ext4_group_t ngroup);
> extern const char *ext4_decode_error(struct super_block *sb, int errno,
> char nbuf[16]);
> diff --git a/fs/ext4/ioctl.c b/fs/ext4/ioctl.c
> index 6b99284095bf..c05eb0efbb95 100644
> --- a/fs/ext4/ioctl.c
> +++ b/fs/ext4/ioctl.c
> @@ -141,19 +141,19 @@ static int ext4_update_backup_sb(struct super_block *sb,
> }
>
> es = (struct ext4_super_block *) (bh->b_data + offset);
> lock_buffer(bh);
> if (ext4_has_feature_metadata_csum(sb) &&
> - es->s_checksum != ext4_superblock_csum(sb, es)) {
> + es->s_checksum != ext4_superblock_csum(es)) {
> ext4_msg(sb, KERN_ERR, "Invalid checksum for backup "
> "superblock %llu", sb_block);
> unlock_buffer(bh);
> goto out_bh;
> }
> func(es, arg);
> if (ext4_has_feature_metadata_csum(sb))
> - es->s_checksum = ext4_superblock_csum(sb, es);
> + es->s_checksum = ext4_superblock_csum(es);
> set_buffer_uptodate(bh);
> unlock_buffer(bh);
>
> if (handle) {
> err = ext4_handle_dirty_metadata(handle, NULL, bh);
> diff --git a/fs/ext4/resize.c b/fs/ext4/resize.c
> index b7ff0d955f0d..050f26168d97 100644
> --- a/fs/ext4/resize.c
> +++ b/fs/ext4/resize.c
> @@ -1117,11 +1117,11 @@ static inline void ext4_set_block_group_nr(struct super_block *sb, char *data,
> {
> struct ext4_super_block *es = (struct ext4_super_block *) data;
>
> es->s_block_group_nr = cpu_to_le16(group);
> if (ext4_has_feature_metadata_csum(sb))
> - es->s_checksum = ext4_superblock_csum(sb, es);
> + es->s_checksum = ext4_superblock_csum(es);
> }
>
> /*
> * Update the backup copies of the ext4 metadata. These don't need to be part
> * of the main resize transaction, because e2fsck will re-write them if there
> diff --git a/fs/ext4/super.c b/fs/ext4/super.c
> index d7780269b455..14e47cc2a5a3 100644
> --- a/fs/ext4/super.c
> +++ b/fs/ext4/super.c
> @@ -284,12 +284,11 @@ static int ext4_verify_csum_type(struct super_block *sb,
> return 1;
>
> return es->s_checksum_type == EXT4_CRC32C_CHKSUM;
> }
>
> -__le32 ext4_superblock_csum(struct super_block *sb,
> - struct ext4_super_block *es)
> +__le32 ext4_superblock_csum(struct ext4_super_block *es)
> {
> int offset = offsetof(struct ext4_super_block, s_checksum);
> __u32 csum;
>
> csum = ext4_chksum(~0, (char *)es, offset);
> @@ -301,21 +300,21 @@ static int ext4_superblock_csum_verify(struct super_block *sb,
> struct ext4_super_block *es)
> {
> if (!ext4_has_feature_metadata_csum(sb))
> return 1;
>
> - return es->s_checksum == ext4_superblock_csum(sb, es);
> + return es->s_checksum == ext4_superblock_csum(es);
> }
>
> void ext4_superblock_csum_set(struct super_block *sb)
> {
> struct ext4_super_block *es = EXT4_SB(sb)->s_es;
>
> if (!ext4_has_feature_metadata_csum(sb))
> return;
>
> - es->s_checksum = ext4_superblock_csum(sb, es);
> + es->s_checksum = ext4_superblock_csum(es);
> }
>
> ext4_fsblk_t ext4_block_bitmap(struct super_block *sb,
> struct ext4_group_desc *bg)
> {
> @@ -5913,11 +5912,11 @@ static struct file *ext4_get_journal_blkdev(struct super_block *sb,
> goto out_bh;
> }
>
> if ((le32_to_cpu(es->s_feature_ro_compat) &
> EXT4_FEATURE_RO_COMPAT_METADATA_CSUM) &&
> - es->s_checksum != ext4_superblock_csum(sb, es)) {
> + es->s_checksum != ext4_superblock_csum(es)) {
> ext4_msg(sb, KERN_ERR, "external journal has corrupt superblock");
> errno = -EFSCORRUPTED;
> goto out_bh;
> }
>
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH 3/4] jbd2: remove journal_t argument from jbd2_chksum()
2025-05-13 5:38 ` [PATCH 3/4] jbd2: remove journal_t argument from jbd2_chksum() Eric Biggers
@ 2025-05-13 6:19 ` Baokun Li
0 siblings, 0 replies; 10+ messages in thread
From: Baokun Li @ 2025-05-13 6:19 UTC (permalink / raw)
To: Eric Biggers; +Cc: linux-ext4
On 2025/5/13 13:38, Eric Biggers wrote:
> From: Eric Biggers <ebiggers@google.com>
>
> Since jbd2_chksum() no longer uses its journal_t argument, remove it.
>
> Signed-off-by: Eric Biggers <ebiggers@google.com>
Looks good, thanks for the patch!
Reviewed-by: Baokun Li <libaokun1@huawei.com>
> ---
> fs/jbd2/commit.c | 6 +++---
> fs/jbd2/journal.c | 8 ++++----
> fs/jbd2/recovery.c | 10 +++++-----
> include/linux/jbd2.h | 3 +--
> 4 files changed, 13 insertions(+), 14 deletions(-)
>
> diff --git a/fs/jbd2/commit.c b/fs/jbd2/commit.c
> index 1c7c49356878..7203d2d2624d 100644
> --- a/fs/jbd2/commit.c
> +++ b/fs/jbd2/commit.c
> @@ -97,11 +97,11 @@ static void jbd2_commit_block_csum_set(journal_t *j, struct buffer_head *bh)
>
> h = (struct commit_header *)(bh->b_data);
> h->h_chksum_type = 0;
> h->h_chksum_size = 0;
> h->h_chksum[0] = 0;
> - csum = jbd2_chksum(j, j->j_csum_seed, bh->b_data, j->j_blocksize);
> + csum = jbd2_chksum(j->j_csum_seed, bh->b_data, j->j_blocksize);
> h->h_chksum[0] = cpu_to_be32(csum);
> }
>
> /*
> * Done it all: now submit the commit record. We should have
> @@ -328,12 +328,12 @@ static void jbd2_block_tag_csum_set(journal_t *j, journal_block_tag_t *tag,
> if (!jbd2_journal_has_csum_v2or3(j))
> return;
>
> seq = cpu_to_be32(sequence);
> addr = kmap_local_folio(bh->b_folio, bh_offset(bh));
> - csum32 = jbd2_chksum(j, j->j_csum_seed, (__u8 *)&seq, sizeof(seq));
> - csum32 = jbd2_chksum(j, csum32, addr, bh->b_size);
> + csum32 = jbd2_chksum(j->j_csum_seed, (__u8 *)&seq, sizeof(seq));
> + csum32 = jbd2_chksum(csum32, addr, bh->b_size);
> kunmap_local(addr);
>
> if (jbd2_has_feature_csum3(j))
> tag3->t_checksum = cpu_to_be32(csum32);
> else
> diff --git a/fs/jbd2/journal.c b/fs/jbd2/journal.c
> index a5ccba25ff47..255fa03031d8 100644
> --- a/fs/jbd2/journal.c
> +++ b/fs/jbd2/journal.c
> @@ -120,11 +120,11 @@ static __be32 jbd2_superblock_csum(journal_t *j, journal_superblock_t *sb)
> __u32 csum;
> __be32 old_csum;
>
> old_csum = sb->s_checksum;
> sb->s_checksum = 0;
> - csum = jbd2_chksum(j, ~0, (char *)sb, sizeof(journal_superblock_t));
> + csum = jbd2_chksum(~0, (char *)sb, sizeof(journal_superblock_t));
> sb->s_checksum = old_csum;
>
> return cpu_to_be32(csum);
> }
>
> @@ -1000,11 +1000,11 @@ void jbd2_descriptor_block_csum_set(journal_t *j, struct buffer_head *bh)
> return;
>
> tail = (struct jbd2_journal_block_tail *)(bh->b_data + j->j_blocksize -
> sizeof(struct jbd2_journal_block_tail));
> tail->t_checksum = 0;
> - csum = jbd2_chksum(j, j->j_csum_seed, bh->b_data, j->j_blocksize);
> + csum = jbd2_chksum(j->j_csum_seed, bh->b_data, j->j_blocksize);
> tail->t_checksum = cpu_to_be32(csum);
> }
>
> /*
> * Return tid of the oldest transaction in the journal and block in the journal
> @@ -1490,11 +1490,11 @@ static int journal_load_superblock(journal_t *journal)
>
> if (be32_to_cpu(sb->s_maxlen) < journal->j_total_len)
> journal->j_total_len = be32_to_cpu(sb->s_maxlen);
> /* Precompute checksum seed for all metadata */
> if (jbd2_journal_has_csum_v2or3(journal))
> - journal->j_csum_seed = jbd2_chksum(journal, ~0, sb->s_uuid,
> + journal->j_csum_seed = jbd2_chksum(~0, sb->s_uuid,
> sizeof(sb->s_uuid));
> /* After journal features are set, we can compute transaction limits */
> jbd2_journal_init_transaction_limits(journal);
>
> if (jbd2_has_feature_fast_commit(journal)) {
> @@ -2336,11 +2336,11 @@ int jbd2_journal_set_features(journal_t *journal, unsigned long compat,
> /* If enabling v3 checksums, update superblock and precompute seed */
> if (INCOMPAT_FEATURE_ON(JBD2_FEATURE_INCOMPAT_CSUM_V3)) {
> sb->s_checksum_type = JBD2_CRC32C_CHKSUM;
> sb->s_feature_compat &=
> ~cpu_to_be32(JBD2_FEATURE_COMPAT_CHECKSUM);
> - journal->j_csum_seed = jbd2_chksum(journal, ~0, sb->s_uuid,
> + journal->j_csum_seed = jbd2_chksum(~0, sb->s_uuid,
> sizeof(sb->s_uuid));
> }
>
> /* If enabling v1 checksums, downgrade superblock */
> if (COMPAT_FEATURE_ON(JBD2_FEATURE_COMPAT_CHECKSUM))
> diff --git a/fs/jbd2/recovery.c b/fs/jbd2/recovery.c
> index c271a050b7e6..cac8c2cd4a92 100644
> --- a/fs/jbd2/recovery.c
> +++ b/fs/jbd2/recovery.c
> @@ -183,11 +183,11 @@ static int jbd2_descriptor_block_csum_verify(journal_t *j, void *buf)
>
> tail = (struct jbd2_journal_block_tail *)((char *)buf +
> j->j_blocksize - sizeof(struct jbd2_journal_block_tail));
> provided = tail->t_checksum;
> tail->t_checksum = 0;
> - calculated = jbd2_chksum(j, j->j_csum_seed, buf, j->j_blocksize);
> + calculated = jbd2_chksum(j->j_csum_seed, buf, j->j_blocksize);
> tail->t_checksum = provided;
>
> return provided == cpu_to_be32(calculated);
> }
>
> @@ -438,11 +438,11 @@ static int jbd2_commit_block_csum_verify(journal_t *j, void *buf)
> return 1;
>
> h = buf;
> provided = h->h_chksum[0];
> h->h_chksum[0] = 0;
> - calculated = jbd2_chksum(j, j->j_csum_seed, buf, j->j_blocksize);
> + calculated = jbd2_chksum(j->j_csum_seed, buf, j->j_blocksize);
> h->h_chksum[0] = provided;
>
> return provided == cpu_to_be32(calculated);
> }
>
> @@ -459,11 +459,11 @@ static bool jbd2_commit_block_csum_verify_partial(journal_t *j, void *buf)
>
> memcpy(tmpbuf, buf, sizeof(struct commit_header));
> h = tmpbuf;
> provided = h->h_chksum[0];
> h->h_chksum[0] = 0;
> - calculated = jbd2_chksum(j, j->j_csum_seed, tmpbuf, j->j_blocksize);
> + calculated = jbd2_chksum(j->j_csum_seed, tmpbuf, j->j_blocksize);
> kfree(tmpbuf);
>
> return provided == cpu_to_be32(calculated);
> }
>
> @@ -476,12 +476,12 @@ static int jbd2_block_tag_csum_verify(journal_t *j, journal_block_tag_t *tag,
>
> if (!jbd2_journal_has_csum_v2or3(j))
> return 1;
>
> seq = cpu_to_be32(sequence);
> - csum32 = jbd2_chksum(j, j->j_csum_seed, (__u8 *)&seq, sizeof(seq));
> - csum32 = jbd2_chksum(j, csum32, buf, j->j_blocksize);
> + csum32 = jbd2_chksum(j->j_csum_seed, (__u8 *)&seq, sizeof(seq));
> + csum32 = jbd2_chksum(csum32, buf, j->j_blocksize);
>
> if (jbd2_has_feature_csum3(j))
> return tag3->t_checksum == cpu_to_be32(csum32);
> else
> return tag->t_checksum == cpu_to_be16(csum32);
> diff --git a/include/linux/jbd2.h b/include/linux/jbd2.h
> index 023e8abdb99a..b04d554e0992 100644
> --- a/include/linux/jbd2.h
> +++ b/include/linux/jbd2.h
> @@ -1764,12 +1764,11 @@ static inline unsigned long jbd2_log_space_left(journal_t *journal)
> #define BJ_Forget 2 /* Buffer superseded by this transaction */
> #define BJ_Shadow 3 /* Buffer contents being shadowed to the log */
> #define BJ_Reserved 4 /* Buffer is reserved for access by journal */
> #define BJ_Types 5
>
> -static inline u32 jbd2_chksum(journal_t *journal, u32 crc,
> - const void *address, unsigned int length)
> +static inline u32 jbd2_chksum(u32 crc, const void *address, unsigned int length)
> {
> return crc32c(crc, address, length);
> }
>
> /* Return most recent uncommitted transaction */
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH 4/4] jbd2: remove journal_t argument from jbd2_superblock_csum()
2025-05-13 5:38 ` [PATCH 4/4] jbd2: remove journal_t argument from jbd2_superblock_csum() Eric Biggers
@ 2025-05-13 6:21 ` Baokun Li
0 siblings, 0 replies; 10+ messages in thread
From: Baokun Li @ 2025-05-13 6:21 UTC (permalink / raw)
To: Eric Biggers; +Cc: linux-ext4
On 2025/5/13 13:38, Eric Biggers wrote:
> From: Eric Biggers <ebiggers@google.com>
>
> Since jbd2_superblock_csum() no longer uses its journal_t argument,
> remove it.
>
> Signed-off-by: Eric Biggers <ebiggers@google.com>
Looks good. Feel free to add:
Reviewed-by: Baokun Li <libaokun1@huawei.com>
> ---
> fs/jbd2/journal.c | 6 +++---
> 1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/fs/jbd2/journal.c b/fs/jbd2/journal.c
> index 255fa03031d8..46a09744e27a 100644
> --- a/fs/jbd2/journal.c
> +++ b/fs/jbd2/journal.c
> @@ -113,11 +113,11 @@ void __jbd2_debug(int level, const char *file, const char *func,
> va_end(args);
> }
> #endif
>
> /* Checksumming functions */
> -static __be32 jbd2_superblock_csum(journal_t *j, journal_superblock_t *sb)
> +static __be32 jbd2_superblock_csum(journal_superblock_t *sb)
> {
> __u32 csum;
> __be32 old_csum;
>
> old_csum = sb->s_checksum;
> @@ -1384,11 +1384,11 @@ static int journal_check_superblock(journal_t *journal)
> printk(KERN_ERR "JBD2: Unknown checksum type\n");
> return err;
> }
>
> /* Check superblock checksum */
> - if (sb->s_checksum != jbd2_superblock_csum(journal, sb)) {
> + if (sb->s_checksum != jbd2_superblock_csum(sb)) {
> printk(KERN_ERR "JBD2: journal checksum error\n");
> err = -EFSBADCRC;
> return err;
> }
> }
> @@ -1819,11 +1819,11 @@ static int jbd2_write_superblock(journal_t *journal, blk_opf_t write_flags)
> journal->j_devname);
> clear_buffer_write_io_error(bh);
> set_buffer_uptodate(bh);
> }
> if (jbd2_journal_has_csum_v2or3(journal))
> - sb->s_checksum = jbd2_superblock_csum(journal, sb);
> + sb->s_checksum = jbd2_superblock_csum(sb);
> get_bh(bh);
> bh->b_end_io = end_buffer_write_sync;
> submit_bh(REQ_OP_WRITE | write_flags, bh);
> wait_on_buffer(bh);
> if (buffer_write_io_error(bh)) {
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH 0/4] ext4,jbd2: clean up unused arguments to checksum functions
2025-05-13 5:38 [PATCH 0/4] ext4,jbd2: clean up unused arguments to checksum functions Eric Biggers
` (3 preceding siblings ...)
2025-05-13 5:38 ` [PATCH 4/4] jbd2: remove journal_t argument from jbd2_superblock_csum() Eric Biggers
@ 2025-05-20 14:40 ` Theodore Ts'o
4 siblings, 0 replies; 10+ messages in thread
From: Theodore Ts'o @ 2025-05-20 14:40 UTC (permalink / raw)
To: linux-ext4, Eric Biggers; +Cc: Theodore Ts'o
On Mon, 12 May 2025 22:38:05 -0700, Eric Biggers wrote:
> Since ext4_chksum() and jbd2_chksum() now call crc32c() directly, they
> no longer use their ext4_sb_info and journal_t arguments. Remove these
> unnecessary arguments. No functional changes.
>
> Eric Biggers (4):
> ext4: remove sbi argument from ext4_chksum()
> ext4: remove sb argument from ext4_superblock_csum()
> jbd2: remove journal_t argument from jbd2_chksum()
> jbd2: remove journal_t argument from jbd2_superblock_csum()
>
> [...]
Applied, thanks!
[1/4] ext4: remove sbi argument from ext4_chksum()
commit: 6cbab5f95e49ec8a9f21784fae3ff0ee09b2dfbc
[2/4] ext4: remove sb argument from ext4_superblock_csum()
commit: 6017dbb7b67a3ca90d339ca32fe6dde425686435
[3/4] jbd2: remove journal_t argument from jbd2_chksum()
commit: 76005718cf8bfdb6b0f818ea75ca6a4b3bee34cd
[4/4] jbd2: remove journal_t argument from jbd2_superblock_csum()
commit: fff6f35b9b2f0c79c9eb6106311530864d8f1394
Best regards,
--
Theodore Ts'o <tytso@mit.edu>
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2025-05-20 14:40 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-05-13 5:38 [PATCH 0/4] ext4,jbd2: clean up unused arguments to checksum functions Eric Biggers
2025-05-13 5:38 ` [PATCH 1/4] ext4: remove sbi argument from ext4_chksum() Eric Biggers
2025-05-13 6:13 ` Baokun Li
2025-05-13 5:38 ` [PATCH 2/4] ext4: remove sb argument from ext4_superblock_csum() Eric Biggers
2025-05-13 6:17 ` Baokun Li
2025-05-13 5:38 ` [PATCH 3/4] jbd2: remove journal_t argument from jbd2_chksum() Eric Biggers
2025-05-13 6:19 ` Baokun Li
2025-05-13 5:38 ` [PATCH 4/4] jbd2: remove journal_t argument from jbd2_superblock_csum() Eric Biggers
2025-05-13 6:21 ` Baokun Li
2025-05-20 14:40 ` [PATCH 0/4] ext4,jbd2: clean up unused arguments to checksum functions Theodore Ts'o
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox