jbd2: fix journal checksum feature flag handling
authorDarrick J. Wong <darrick.wong@oracle.com>
Thu, 11 Sep 2014 15:38:21 +0000 (11:38 -0400)
committerTheodore Ts'o <tytso@mit.edu>
Thu, 11 Sep 2014 15:38:21 +0000 (11:38 -0400)
Clear all three journal checksum feature flags before turning on
whichever journal checksum options we want.  Rearrange the error
checking so that newer flags get complained about first.

Reported-by: TR Reardon <thomas_reardon@hotmail.com>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
fs/ext4/super.c
fs/jbd2/journal.c

index 2766b8eba12124bbcb7ba571b012221087172ef5..fb219b95f8d2ab7d527ef115e80578ec6792f10c 100644 (file)
@@ -3237,6 +3237,10 @@ static int set_journal_csum_feature_set(struct super_block *sb)
                incompat = 0;
        }
 
+       jbd2_journal_clear_features(sbi->s_journal,
+                       JBD2_FEATURE_COMPAT_CHECKSUM, 0,
+                       JBD2_FEATURE_INCOMPAT_CSUM_V3 |
+                       JBD2_FEATURE_INCOMPAT_CSUM_V2);
        if (test_opt(sb, JOURNAL_ASYNC_COMMIT)) {
                ret = jbd2_journal_set_features(sbi->s_journal,
                                compat, 0,
@@ -3249,11 +3253,8 @@ static int set_journal_csum_feature_set(struct super_block *sb)
                jbd2_journal_clear_features(sbi->s_journal, 0, 0,
                                JBD2_FEATURE_INCOMPAT_ASYNC_COMMIT);
        } else {
-               jbd2_journal_clear_features(sbi->s_journal,
-                               JBD2_FEATURE_COMPAT_CHECKSUM, 0,
-                               JBD2_FEATURE_INCOMPAT_ASYNC_COMMIT |
-                               JBD2_FEATURE_INCOMPAT_CSUM_V3 |
-                               JBD2_FEATURE_INCOMPAT_CSUM_V2);
+               jbd2_journal_clear_features(sbi->s_journal, 0, 0,
+                               JBD2_FEATURE_INCOMPAT_ASYNC_COMMIT);
        }
 
        return ret;
index 415041c4c40c8f6571732616b520702e5f01c39b..e4dc74713a4328eda4738823f51e0c6070937e0a 100644 (file)
@@ -1522,14 +1522,6 @@ static int journal_get_superblock(journal_t *journal)
                goto out;
        }
 
-       if (jbd2_journal_has_csum_v2or3(journal) &&
-           JBD2_HAS_COMPAT_FEATURE(journal, JBD2_FEATURE_COMPAT_CHECKSUM)) {
-               /* Can't have checksum v1 and v2 on at the same time! */
-               printk(KERN_ERR "JBD2: Can't enable checksumming v1 and v2 "
-                      "at the same time!\n");
-               goto out;
-       }
-
        if (JBD2_HAS_INCOMPAT_FEATURE(journal, JBD2_FEATURE_INCOMPAT_CSUM_V2) &&
            JBD2_HAS_INCOMPAT_FEATURE(journal, JBD2_FEATURE_INCOMPAT_CSUM_V3)) {
                /* Can't have checksum v2 and v3 at the same time! */
@@ -1538,6 +1530,14 @@ static int journal_get_superblock(journal_t *journal)
                goto out;
        }
 
+       if (jbd2_journal_has_csum_v2or3(journal) &&
+           JBD2_HAS_COMPAT_FEATURE(journal, JBD2_FEATURE_COMPAT_CHECKSUM)) {
+               /* Can't have checksum v1 and v2 on at the same time! */
+               printk(KERN_ERR "JBD2: Can't enable checksumming v1 and v2/3 "
+                      "at the same time!\n");
+               goto out;
+       }
+
        if (!jbd2_verify_csum_type(journal, sb)) {
                printk(KERN_ERR "JBD2: Unknown checksum type\n");
                goto out;