Skip to content

Commit d005af3

Browse files
ebiggersJaegeuk Kim
authored andcommitted
f2fs: remove unused sbi argument from checksum functions
Since __f2fs_crc32() now calls crc32() directly, it no longer uses its sbi argument. Remove that, and simplify its callers accordingly. Signed-off-by: Eric Biggers <ebiggers@google.com> Reviewed-by: Chao Yu <chao@kernel.org> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
1 parent 13be879 commit d005af3

File tree

5 files changed

+24
-35
lines changed

5 files changed

+24
-35
lines changed

fs/f2fs/checkpoint.c

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -826,17 +826,16 @@ static void write_orphan_inodes(struct f2fs_sb_info *sbi, block_t start_blk)
826826
}
827827
}
828828

829-
static __u32 f2fs_checkpoint_chksum(struct f2fs_sb_info *sbi,
830-
struct f2fs_checkpoint *ckpt)
829+
static __u32 f2fs_checkpoint_chksum(struct f2fs_checkpoint *ckpt)
831830
{
832831
unsigned int chksum_ofs = le32_to_cpu(ckpt->checksum_offset);
833832
__u32 chksum;
834833

835-
chksum = f2fs_crc32(sbi, ckpt, chksum_ofs);
834+
chksum = f2fs_crc32(ckpt, chksum_ofs);
836835
if (chksum_ofs < CP_CHKSUM_OFFSET) {
837836
chksum_ofs += sizeof(chksum);
838-
chksum = f2fs_chksum(sbi, chksum, (__u8 *)ckpt + chksum_ofs,
839-
F2FS_BLKSIZE - chksum_ofs);
837+
chksum = f2fs_chksum(chksum, (__u8 *)ckpt + chksum_ofs,
838+
F2FS_BLKSIZE - chksum_ofs);
840839
}
841840
return chksum;
842841
}
@@ -862,7 +861,7 @@ static int get_checkpoint_version(struct f2fs_sb_info *sbi, block_t cp_addr,
862861
return -EINVAL;
863862
}
864863

865-
crc = f2fs_checkpoint_chksum(sbi, *cp_block);
864+
crc = f2fs_checkpoint_chksum(*cp_block);
866865
if (crc != cur_cp_crc(*cp_block)) {
867866
f2fs_folio_put(*cp_folio, true);
868867
f2fs_warn(sbi, "invalid crc value");
@@ -1505,7 +1504,7 @@ static int do_checkpoint(struct f2fs_sb_info *sbi, struct cp_control *cpc)
15051504
get_sit_bitmap(sbi, __bitmap_ptr(sbi, SIT_BITMAP));
15061505
get_nat_bitmap(sbi, __bitmap_ptr(sbi, NAT_BITMAP));
15071506

1508-
crc32 = f2fs_checkpoint_chksum(sbi, ckpt);
1507+
crc32 = f2fs_checkpoint_chksum(ckpt);
15091508
*((__le32 *)((unsigned char *)ckpt +
15101509
le32_to_cpu(ckpt->checksum_offset)))
15111510
= cpu_to_le32(crc32);

fs/f2fs/compress.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -679,8 +679,7 @@ static int f2fs_compress_pages(struct compress_ctx *cc)
679679
cc->cbuf->clen = cpu_to_le32(cc->clen);
680680

681681
if (fi->i_compress_flag & BIT(COMPRESS_CHKSUM))
682-
chksum = f2fs_crc32(F2FS_I_SB(cc->inode),
683-
cc->cbuf->cdata, cc->clen);
682+
chksum = f2fs_crc32(cc->cbuf->cdata, cc->clen);
684683
cc->cbuf->chksum = cpu_to_le32(chksum);
685684

686685
for (i = 0; i < COMPRESS_DATA_RESERVED_SIZE; i++)
@@ -776,7 +775,7 @@ void f2fs_decompress_cluster(struct decompress_io_ctx *dic, bool in_task)
776775

777776
if (!ret && (fi->i_compress_flag & BIT(COMPRESS_CHKSUM))) {
778777
u32 provided = le32_to_cpu(dic->cbuf->chksum);
779-
u32 calculated = f2fs_crc32(sbi, dic->cbuf->cdata, dic->clen);
778+
u32 calculated = f2fs_crc32(dic->cbuf->cdata, dic->clen);
780779

781780
if (provided != calculated) {
782781
if (!is_inode_flag_set(dic->inode, FI_COMPRESS_CORRUPT)) {

fs/f2fs/f2fs.h

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1976,28 +1976,20 @@ static inline unsigned int f2fs_time_to_wait(struct f2fs_sb_info *sbi,
19761976
/*
19771977
* Inline functions
19781978
*/
1979-
static inline u32 __f2fs_crc32(struct f2fs_sb_info *sbi, u32 crc,
1980-
const void *address, unsigned int length)
1979+
static inline u32 __f2fs_crc32(u32 crc, const void *address,
1980+
unsigned int length)
19811981
{
19821982
return crc32(crc, address, length);
19831983
}
19841984

1985-
static inline u32 f2fs_crc32(struct f2fs_sb_info *sbi, const void *address,
1986-
unsigned int length)
1985+
static inline u32 f2fs_crc32(const void *address, unsigned int length)
19871986
{
1988-
return __f2fs_crc32(sbi, F2FS_SUPER_MAGIC, address, length);
1987+
return __f2fs_crc32(F2FS_SUPER_MAGIC, address, length);
19891988
}
19901989

1991-
static inline bool f2fs_crc_valid(struct f2fs_sb_info *sbi, __u32 blk_crc,
1992-
void *buf, size_t buf_size)
1990+
static inline u32 f2fs_chksum(u32 crc, const void *address, unsigned int length)
19931991
{
1994-
return f2fs_crc32(sbi, buf, buf_size) == blk_crc;
1995-
}
1996-
1997-
static inline u32 f2fs_chksum(struct f2fs_sb_info *sbi, u32 crc,
1998-
const void *address, unsigned int length)
1999-
{
2000-
return __f2fs_crc32(sbi, crc, address, length);
1992+
return __f2fs_crc32(crc, address, length);
20011993
}
20021994

20031995
static inline struct f2fs_inode_info *F2FS_I(struct inode *inode)

fs/f2fs/inode.c

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -144,15 +144,14 @@ static __u32 f2fs_inode_chksum(struct f2fs_sb_info *sbi, struct page *page)
144144
unsigned int offset = offsetof(struct f2fs_inode, i_inode_checksum);
145145
unsigned int cs_size = sizeof(dummy_cs);
146146

147-
chksum = f2fs_chksum(sbi, sbi->s_chksum_seed, (__u8 *)&ino,
148-
sizeof(ino));
149-
chksum_seed = f2fs_chksum(sbi, chksum, (__u8 *)&gen, sizeof(gen));
147+
chksum = f2fs_chksum(sbi->s_chksum_seed, (__u8 *)&ino, sizeof(ino));
148+
chksum_seed = f2fs_chksum(chksum, (__u8 *)&gen, sizeof(gen));
150149

151-
chksum = f2fs_chksum(sbi, chksum_seed, (__u8 *)ri, offset);
152-
chksum = f2fs_chksum(sbi, chksum, (__u8 *)&dummy_cs, cs_size);
150+
chksum = f2fs_chksum(chksum_seed, (__u8 *)ri, offset);
151+
chksum = f2fs_chksum(chksum, (__u8 *)&dummy_cs, cs_size);
153152
offset += cs_size;
154-
chksum = f2fs_chksum(sbi, chksum, (__u8 *)ri + offset,
155-
F2FS_BLKSIZE - offset);
153+
chksum = f2fs_chksum(chksum, (__u8 *)ri + offset,
154+
F2FS_BLKSIZE - offset);
156155
return chksum;
157156
}
158157

fs/f2fs/super.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3564,7 +3564,7 @@ static int sanity_check_raw_super(struct f2fs_sb_info *sbi,
35643564
return -EFSCORRUPTED;
35653565
}
35663566
crc = le32_to_cpu(raw_super->crc);
3567-
if (!f2fs_crc_valid(sbi, crc, raw_super, crc_offset)) {
3567+
if (crc != f2fs_crc32(raw_super, crc_offset)) {
35683568
f2fs_info(sbi, "Invalid SB checksum value: %u", crc);
35693569
return -EFSCORRUPTED;
35703570
}
@@ -4120,7 +4120,7 @@ int f2fs_commit_super(struct f2fs_sb_info *sbi, bool recover)
41204120

41214121
/* we should update superblock crc here */
41224122
if (!recover && f2fs_sb_has_sb_chksum(sbi)) {
4123-
crc = f2fs_crc32(sbi, F2FS_RAW_SUPER(sbi),
4123+
crc = f2fs_crc32(F2FS_RAW_SUPER(sbi),
41244124
offsetof(struct f2fs_super_block, crc));
41254125
F2FS_RAW_SUPER(sbi)->crc = cpu_to_le32(crc);
41264126
}
@@ -4581,8 +4581,8 @@ static int f2fs_fill_super(struct super_block *sb, void *data, int silent)
45814581

45824582
/* precompute checksum seed for metadata */
45834583
if (f2fs_sb_has_inode_chksum(sbi))
4584-
sbi->s_chksum_seed = f2fs_chksum(sbi, ~0, raw_super->uuid,
4585-
sizeof(raw_super->uuid));
4584+
sbi->s_chksum_seed = f2fs_chksum(~0, raw_super->uuid,
4585+
sizeof(raw_super->uuid));
45864586

45874587
default_options(sbi, false);
45884588
/* parse mount options */

0 commit comments

Comments
 (0)