diff options
author | Darrick J. Wong <darrick.wong@oracle.com> | 2015-10-15 10:30:36 -0400 |
---|---|---|
committer | Theodore Ts'o <tytso@mit.edu> | 2015-10-15 10:30:36 -0400 |
commit | 8595798ca34d186d39abcb277591e541776c0ef5 (patch) | |
tree | 2a88574a18479f688e837cf4169b58d438e9d5bf /include/linux/jbd2.h | |
parent | b90197b655185a11640cce3a0a0bc5d8291b8ad2 (diff) | |
download | linux-8595798ca34d186d39abcb277591e541776c0ef5.tar.gz linux-8595798ca34d186d39abcb277591e541776c0ef5.tar.bz2 linux-8595798ca34d186d39abcb277591e541776c0ef5.zip |
jbd2: gate checksum calculations on crc driver presence, not sb flags
Change the journal's checksum functions to gate on whether or not the
crc32c driver is loaded, and gate the loading on the superblock bits.
This prevents a journal crash if someone loads a journal in no-csum
mode and then randomizes the superblock, thus flipping on the feature
bits.
Tested-By: Nikolay Borisov <kernel@kyup.com>
Reported-by: Nikolay Borisov <kernel@kyup.com>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Diffstat (limited to 'include/linux/jbd2.h')
-rw-r--r-- | include/linux/jbd2.h | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/include/linux/jbd2.h b/include/linux/jbd2.h index df07e78487d5..6da6f89722e1 100644 --- a/include/linux/jbd2.h +++ b/include/linux/jbd2.h @@ -1338,13 +1338,18 @@ static inline int tid_geq(tid_t x, tid_t y) extern int jbd2_journal_blocks_per_page(struct inode *inode); extern size_t journal_tag_bytes(journal_t *journal); +static inline bool jbd2_journal_has_csum_v2or3_feature(journal_t *j) +{ + return JBD2_HAS_INCOMPAT_FEATURE(j, JBD2_FEATURE_INCOMPAT_CSUM_V2) || + JBD2_HAS_INCOMPAT_FEATURE(j, JBD2_FEATURE_INCOMPAT_CSUM_V3); +} + static inline int jbd2_journal_has_csum_v2or3(journal_t *journal) { - if (JBD2_HAS_INCOMPAT_FEATURE(journal, JBD2_FEATURE_INCOMPAT_CSUM_V2) || - JBD2_HAS_INCOMPAT_FEATURE(journal, JBD2_FEATURE_INCOMPAT_CSUM_V3)) - return 1; + WARN_ON_ONCE(jbd2_journal_has_csum_v2or3_feature(journal) && + journal->j_chksum_driver == NULL); - return 0; + return journal->j_chksum_driver != NULL; } /* |