Skip to content

Commit 5490209

Browse files
JasonYanHwtytso
authored andcommitted
ext4: move dax and encrypt checking into ext4_check_feature_compatibility()
These checkings are also related with feature compatibility checkings. So move them into ext4_check_feature_compatibility(). No functional change. Signed-off-by: Jason Yan <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Theodore Ts'o <[email protected]>
1 parent 107d2be commit 5490209

File tree

1 file changed

+28
-26
lines changed

1 file changed

+28
-26
lines changed

fs/ext4/super.c

Lines changed: 28 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -4641,6 +4641,8 @@ static int ext4_check_feature_compatibility(struct super_block *sb,
46414641
struct ext4_super_block *es,
46424642
int silent)
46434643
{
4644+
struct ext4_sb_info *sbi = EXT4_SB(sb);
4645+
46444646
if (le32_to_cpu(es->s_rev_level) == EXT4_GOOD_OLD_REV &&
46454647
(ext4_has_compat_features(sb) ||
46464648
ext4_has_ro_compat_features(sb) ||
@@ -4710,6 +4712,32 @@ static int ext4_check_feature_compatibility(struct super_block *sb,
47104712
if (!ext4_feature_set_ok(sb, (sb_rdonly(sb))))
47114713
return -EINVAL;
47124714

4715+
if (sbi->s_daxdev) {
4716+
if (sb->s_blocksize == PAGE_SIZE)
4717+
set_bit(EXT4_FLAGS_BDEV_IS_DAX, &sbi->s_ext4_flags);
4718+
else
4719+
ext4_msg(sb, KERN_ERR, "unsupported blocksize for DAX\n");
4720+
}
4721+
4722+
if (sbi->s_mount_opt & EXT4_MOUNT_DAX_ALWAYS) {
4723+
if (ext4_has_feature_inline_data(sb)) {
4724+
ext4_msg(sb, KERN_ERR, "Cannot use DAX on a filesystem"
4725+
" that may contain inline data");
4726+
return -EINVAL;
4727+
}
4728+
if (!test_bit(EXT4_FLAGS_BDEV_IS_DAX, &sbi->s_ext4_flags)) {
4729+
ext4_msg(sb, KERN_ERR,
4730+
"DAX unsupported by block device.");
4731+
return -EINVAL;
4732+
}
4733+
}
4734+
4735+
if (ext4_has_feature_encrypt(sb) && es->s_encryption_level) {
4736+
ext4_msg(sb, KERN_ERR, "Unsupported encryption level %d",
4737+
es->s_encryption_level);
4738+
return -EINVAL;
4739+
}
4740+
47134741
return 0;
47144742
}
47154743

@@ -5242,32 +5270,6 @@ static int __ext4_fill_super(struct fs_context *fc, struct super_block *sb)
52425270
if (ext4_check_feature_compatibility(sb, es, silent))
52435271
goto failed_mount;
52445272

5245-
if (sbi->s_daxdev) {
5246-
if (sb->s_blocksize == PAGE_SIZE)
5247-
set_bit(EXT4_FLAGS_BDEV_IS_DAX, &sbi->s_ext4_flags);
5248-
else
5249-
ext4_msg(sb, KERN_ERR, "unsupported blocksize for DAX\n");
5250-
}
5251-
5252-
if (sbi->s_mount_opt & EXT4_MOUNT_DAX_ALWAYS) {
5253-
if (ext4_has_feature_inline_data(sb)) {
5254-
ext4_msg(sb, KERN_ERR, "Cannot use DAX on a filesystem"
5255-
" that may contain inline data");
5256-
goto failed_mount;
5257-
}
5258-
if (!test_bit(EXT4_FLAGS_BDEV_IS_DAX, &sbi->s_ext4_flags)) {
5259-
ext4_msg(sb, KERN_ERR,
5260-
"DAX unsupported by block device.");
5261-
goto failed_mount;
5262-
}
5263-
}
5264-
5265-
if (ext4_has_feature_encrypt(sb) && es->s_encryption_level) {
5266-
ext4_msg(sb, KERN_ERR, "Unsupported encryption level %d",
5267-
es->s_encryption_level);
5268-
goto failed_mount;
5269-
}
5270-
52715273
if (ext4_block_group_meta_init(sb, silent))
52725274
goto failed_mount;
52735275

0 commit comments

Comments
 (0)