Skip to content

Commit 18dad50

Browse files
zhangyi089tytso
authored andcommitted
jbd2: open code jbd2_verify_csum_type() helper
jbd2_verify_csum_type() helper check checksum type in the superblock for v2 or v3 checksum feature, it always return true if these features are not enabled, and it has only one user, so open code it is more clear. Signed-off-by: Zhang Yi <[email protected]> Reviewed-by: Jan Kara <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Theodore Ts'o <[email protected]>
1 parent e4adf8b commit 18dad50

File tree

1 file changed

+5
-13
lines changed

1 file changed

+5
-13
lines changed

fs/jbd2/journal.c

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -115,14 +115,6 @@ void __jbd2_debug(int level, const char *file, const char *func,
115115
#endif
116116

117117
/* Checksumming functions */
118-
static int jbd2_verify_csum_type(journal_t *j, journal_superblock_t *sb)
119-
{
120-
if (!jbd2_journal_has_csum_v2or3_feature(j))
121-
return 1;
122-
123-
return sb->s_checksum_type == JBD2_CRC32C_CHKSUM;
124-
}
125-
126118
static __be32 jbd2_superblock_csum(journal_t *j, journal_superblock_t *sb)
127119
{
128120
__u32 csum;
@@ -1429,13 +1421,13 @@ static int journal_get_superblock(journal_t *journal)
14291421
goto out;
14301422
}
14311423

1432-
if (!jbd2_verify_csum_type(journal, sb)) {
1433-
printk(KERN_ERR "JBD2: Unknown checksum type\n");
1434-
goto out;
1435-
}
1436-
14371424
/* Load the checksum driver */
14381425
if (jbd2_journal_has_csum_v2or3_feature(journal)) {
1426+
if (sb->s_checksum_type != JBD2_CRC32C_CHKSUM) {
1427+
printk(KERN_ERR "JBD2: Unknown checksum type\n");
1428+
goto out;
1429+
}
1430+
14391431
journal->j_chksum_driver = crypto_alloc_shash("crc32c", 0, 0);
14401432
if (IS_ERR(journal->j_chksum_driver)) {
14411433
printk(KERN_ERR "JBD2: Cannot load crc32c driver.\n");

0 commit comments

Comments
 (0)