1 jbd2: fix journal checksum feature flag handling
3 From: "Darrick J. Wong" <darrick.wong@oracle.com>
5 Clear all three journal checksum feature flags before turning on
6 whichever journal checksum options we want. Rearrange the error
7 checking so that newer flags get complained about first.
9 Reported-by: TR Reardon <thomas_reardon@hotmail.com>
10 Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
11 Signed-off-by: Theodore Ts'o <tytso@mit.edu>
13 fs/ext4/super.c | 11 ++++++-----
14 fs/jbd2/journal.c | 16 ++++++++--------
15 2 files changed, 14 insertions(+), 13 deletions(-)
18 diff --git a/fs/ext4/super.c b/fs/ext4/super.c
19 index bbf515c..7045f1d 100644
22 @@ -3190,6 +3190,10 @@ static int set_journal_csum_feature_set(struct super_block *sb)
26 + jbd2_journal_clear_features(sbi->s_journal,
27 + JBD2_FEATURE_COMPAT_CHECKSUM, 0,
28 + JBD2_FEATURE_INCOMPAT_CSUM_V3 |
29 + JBD2_FEATURE_INCOMPAT_CSUM_V2);
30 if (test_opt(sb, JOURNAL_ASYNC_COMMIT)) {
31 ret = jbd2_journal_set_features(sbi->s_journal,
33 @@ -3202,11 +3206,8 @@ static int set_journal_csum_feature_set(struct super_block *sb)
34 jbd2_journal_clear_features(sbi->s_journal, 0, 0,
35 JBD2_FEATURE_INCOMPAT_ASYNC_COMMIT);
37 - jbd2_journal_clear_features(sbi->s_journal,
38 - JBD2_FEATURE_COMPAT_CHECKSUM, 0,
39 - JBD2_FEATURE_INCOMPAT_ASYNC_COMMIT |
40 - JBD2_FEATURE_INCOMPAT_CSUM_V3 |
41 - JBD2_FEATURE_INCOMPAT_CSUM_V2);
42 + jbd2_journal_clear_features(sbi->s_journal, 0, 0,
43 + JBD2_FEATURE_INCOMPAT_ASYNC_COMMIT);
47 diff --git a/fs/jbd2/journal.c b/fs/jbd2/journal.c
48 index 19d74d8..7e70cd5 100644
49 --- a/fs/jbd2/journal.c
50 +++ b/fs/jbd2/journal.c
51 @@ -1522,14 +1522,6 @@ static int journal_get_superblock(journal_t *journal)
55 - if (jbd2_journal_has_csum_v2or3(journal) &&
56 - JBD2_HAS_COMPAT_FEATURE(journal, JBD2_FEATURE_COMPAT_CHECKSUM)) {
57 - /* Can't have checksum v1 and v2 on at the same time! */
58 - printk(KERN_ERR "JBD2: Can't enable checksumming v1 and v2 "
59 - "at the same time!\n");
63 if (JBD2_HAS_INCOMPAT_FEATURE(journal, JBD2_FEATURE_INCOMPAT_CSUM_V2) &&
64 JBD2_HAS_INCOMPAT_FEATURE(journal, JBD2_FEATURE_INCOMPAT_CSUM_V3)) {
65 /* Can't have checksum v2 and v3 at the same time! */
66 @@ -1538,6 +1530,14 @@ static int journal_get_superblock(journal_t *journal)
70 + if (jbd2_journal_has_csum_v2or3(journal) &&
71 + JBD2_HAS_COMPAT_FEATURE(journal, JBD2_FEATURE_COMPAT_CHECKSUM)) {
72 + /* Can't have checksum v1 and v2 on at the same time! */
73 + printk(KERN_ERR "JBD2: Can't enable checksumming v1 and v2/3 "
74 + "at the same time!\n");
78 if (!jbd2_verify_csum_type(journal, sb)) {
79 printk(KERN_ERR "JBD2: Unknown checksum type\n");