jbd2: open code jbd2_verify_csum_type() helper
authorZhang Yi <yi.zhang@huawei.com>
Fri, 11 Aug 2023 06:36:03 +0000 (14:36 +0800)
committerTheodore Ts'o <tytso@mit.edu>
Tue, 15 Aug 2023 13:00:33 +0000 (09:00 -0400)
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 <yi.zhang@huawei.com>
Reviewed-by: Jan Kara <jack@suse.cz>
Link: https://lore.kernel.org/r/20230811063610.2980059-6-yi.zhang@huaweicloud.com
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
fs/jbd2/journal.c

index 4d4494b42b39f715544cc33004f060fbb7b6c6d2..5d4744203e39193eeffeae6c543edd8bb95ccaab 100644 (file)
@@ -115,14 +115,6 @@ void __jbd2_debug(int level, const char *file, const char *func,
 #endif
 
 /* Checksumming functions */
-static int jbd2_verify_csum_type(journal_t *j, journal_superblock_t *sb)
-{
-       if (!jbd2_journal_has_csum_v2or3_feature(j))
-               return 1;
-
-       return sb->s_checksum_type == JBD2_CRC32C_CHKSUM;
-}
-
 static __be32 jbd2_superblock_csum(journal_t *j, journal_superblock_t *sb)
 {
        __u32 csum;
@@ -1429,13 +1421,13 @@ static int journal_get_superblock(journal_t *journal)
                goto out;
        }
 
-       if (!jbd2_verify_csum_type(journal, sb)) {
-               printk(KERN_ERR "JBD2: Unknown checksum type\n");
-               goto out;
-       }
-
        /* Load the checksum driver */
        if (jbd2_journal_has_csum_v2or3_feature(journal)) {
+               if (sb->s_checksum_type != JBD2_CRC32C_CHKSUM) {
+                       printk(KERN_ERR "JBD2: Unknown checksum type\n");
+                       goto out;
+               }
+
                journal->j_chksum_driver = crypto_alloc_shash("crc32c", 0, 0);
                if (IS_ERR(journal->j_chksum_driver)) {
                        printk(KERN_ERR "JBD2: Cannot load crc32c driver.\n");