Skip to content

Commit e4adf8b

Browse files
zhangyi089tytso
authored andcommitted
jbd2: checking valid features early in journal_get_superblock()
journal_get_superblock() is used to check validity of the jounal supberblock, so move the features checks from jbd2_journal_load() to journal_get_superblock(). Signed-off-by: Zhang Yi <[email protected]> Reviewed-by: Jan Kara <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Theodore Ts'o <[email protected]>
1 parent 9600f3e commit e4adf8b

File tree

1 file changed

+15
-15
lines changed

1 file changed

+15
-15
lines changed

fs/jbd2/journal.c

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1398,6 +1398,21 @@ static int journal_get_superblock(journal_t *journal)
13981398
goto out;
13991399
}
14001400

1401+
/*
1402+
* If this is a V2 superblock, then we have to check the
1403+
* features flags on it.
1404+
*/
1405+
if (!jbd2_format_support_feature(journal))
1406+
return 0;
1407+
1408+
if ((sb->s_feature_ro_compat &
1409+
~cpu_to_be32(JBD2_KNOWN_ROCOMPAT_FEATURES)) ||
1410+
(sb->s_feature_incompat &
1411+
~cpu_to_be32(JBD2_KNOWN_INCOMPAT_FEATURES))) {
1412+
printk(KERN_WARNING "JBD2: Unrecognised features on journal\n");
1413+
goto out;
1414+
}
1415+
14011416
if (jbd2_has_feature_csum2(journal) &&
14021417
jbd2_has_feature_csum3(journal)) {
14031418
/* Can't have checksum v2 and v3 at the same time! */
@@ -2059,21 +2074,6 @@ int jbd2_journal_load(journal_t *journal)
20592074
int err;
20602075
journal_superblock_t *sb = journal->j_superblock;
20612076

2062-
/*
2063-
* If this is a V2 superblock, then we have to check the
2064-
* features flags on it.
2065-
*/
2066-
if (jbd2_format_support_feature(journal)) {
2067-
if ((sb->s_feature_ro_compat &
2068-
~cpu_to_be32(JBD2_KNOWN_ROCOMPAT_FEATURES)) ||
2069-
(sb->s_feature_incompat &
2070-
~cpu_to_be32(JBD2_KNOWN_INCOMPAT_FEATURES))) {
2071-
printk(KERN_WARNING
2072-
"JBD2: Unrecognised features on journal\n");
2073-
return -EINVAL;
2074-
}
2075-
}
2076-
20772077
/*
20782078
* Create a slab for this blocksize
20792079
*/

0 commit comments

Comments
 (0)