aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDarrick J. Wong <darrick.wong@oracle.com>2014-09-11 11:38:21 -0400
committerTheodore Ts'o <tytso@mit.edu>2014-09-11 11:38:21 -0400
commitfeb8c6d3dd0f2cc0e1c3376d099cf298c5f2c2c8 (patch)
tree1f91bf01066b1a35414e4f6291fd4ff4ab47a45f
parentc7f725435adcf2ade4b9152ee33339d28f4cc330 (diff)
jbd2: fix journal checksum feature flag handling
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>
-rw-r--r--fs/ext4/super.c11
-rw-r--r--fs/jbd2/journal.c16
2 files changed, 14 insertions, 13 deletions
diff --git a/fs/ext4/super.c b/fs/ext4/super.c
index 2766b8eba121..fb219b95f8d2 100644
--- a/fs/ext4/super.c
+++ b/fs/ext4/super.c
@@ -3237,6 +3237,10 @@ static int set_journal_csum_feature_set(struct super_block *sb)
3237 incompat = 0; 3237 incompat = 0;
3238 } 3238 }
3239 3239
3240 jbd2_journal_clear_features(sbi->s_journal,
3241 JBD2_FEATURE_COMPAT_CHECKSUM, 0,
3242 JBD2_FEATURE_INCOMPAT_CSUM_V3 |
3243 JBD2_FEATURE_INCOMPAT_CSUM_V2);
3240 if (test_opt(sb, JOURNAL_ASYNC_COMMIT)) { 3244 if (test_opt(sb, JOURNAL_ASYNC_COMMIT)) {
3241 ret = jbd2_journal_set_features(sbi->s_journal, 3245 ret = jbd2_journal_set_features(sbi->s_journal,
3242 compat, 0, 3246 compat, 0,
@@ -3249,11 +3253,8 @@ static int set_journal_csum_feature_set(struct super_block *sb)
3249 jbd2_journal_clear_features(sbi->s_journal, 0, 0, 3253 jbd2_journal_clear_features(sbi->s_journal, 0, 0,
3250 JBD2_FEATURE_INCOMPAT_ASYNC_COMMIT); 3254 JBD2_FEATURE_INCOMPAT_ASYNC_COMMIT);
3251 } else { 3255 } else {
3252 jbd2_journal_clear_features(sbi->s_journal, 3256 jbd2_journal_clear_features(sbi->s_journal, 0, 0,
3253 JBD2_FEATURE_COMPAT_CHECKSUM, 0, 3257 JBD2_FEATURE_INCOMPAT_ASYNC_COMMIT);
3254 JBD2_FEATURE_INCOMPAT_ASYNC_COMMIT |
3255 JBD2_FEATURE_INCOMPAT_CSUM_V3 |
3256 JBD2_FEATURE_INCOMPAT_CSUM_V2);
3257 } 3258 }
3258 3259
3259 return ret; 3260 return ret;
diff --git a/fs/jbd2/journal.c b/fs/jbd2/journal.c
index 415041c4c40c..e4dc74713a43 100644
--- a/fs/jbd2/journal.c
+++ b/fs/jbd2/journal.c
@@ -1522,14 +1522,6 @@ static int journal_get_superblock(journal_t *journal)
1522 goto out; 1522 goto out;
1523 } 1523 }
1524 1524
1525 if (jbd2_journal_has_csum_v2or3(journal) &&
1526 JBD2_HAS_COMPAT_FEATURE(journal, JBD2_FEATURE_COMPAT_CHECKSUM)) {
1527 /* Can't have checksum v1 and v2 on at the same time! */
1528 printk(KERN_ERR "JBD2: Can't enable checksumming v1 and v2 "
1529 "at the same time!\n");
1530 goto out;
1531 }
1532
1533 if (JBD2_HAS_INCOMPAT_FEATURE(journal, JBD2_FEATURE_INCOMPAT_CSUM_V2) && 1525 if (JBD2_HAS_INCOMPAT_FEATURE(journal, JBD2_FEATURE_INCOMPAT_CSUM_V2) &&
1534 JBD2_HAS_INCOMPAT_FEATURE(journal, JBD2_FEATURE_INCOMPAT_CSUM_V3)) { 1526 JBD2_HAS_INCOMPAT_FEATURE(journal, JBD2_FEATURE_INCOMPAT_CSUM_V3)) {
1535 /* Can't have checksum v2 and v3 at the same time! */ 1527 /* Can't have checksum v2 and v3 at the same time! */
@@ -1538,6 +1530,14 @@ static int journal_get_superblock(journal_t *journal)
1538 goto out; 1530 goto out;
1539 } 1531 }
1540 1532
1533 if (jbd2_journal_has_csum_v2or3(journal) &&
1534 JBD2_HAS_COMPAT_FEATURE(journal, JBD2_FEATURE_COMPAT_CHECKSUM)) {
1535 /* Can't have checksum v1 and v2 on at the same time! */
1536 printk(KERN_ERR "JBD2: Can't enable checksumming v1 and v2/3 "
1537 "at the same time!\n");
1538 goto out;
1539 }
1540
1541 if (!jbd2_verify_csum_type(journal, sb)) { 1541 if (!jbd2_verify_csum_type(journal, sb)) {
1542 printk(KERN_ERR "JBD2: Unknown checksum type\n"); 1542 printk(KERN_ERR "JBD2: Unknown checksum type\n");
1543 goto out; 1543 goto out;