Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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 <yanaijie@huawei.com>
Link: https://lore.kernel.org/r/20230323140517.1070239-9-yanaijie@huawei.com
Signed-off-by: Theodore Ts'o <tytso@mit.edu>

authored by

Jason Yan and committed by
Theodore Ts'o
54902099 107d2be9

+28 -26
+28 -26
fs/ext4/super.c
··· 4641 4641 struct ext4_super_block *es, 4642 4642 int silent) 4643 4643 { 4644 + struct ext4_sb_info *sbi = EXT4_SB(sb); 4645 + 4644 4646 if (le32_to_cpu(es->s_rev_level) == EXT4_GOOD_OLD_REV && 4645 4647 (ext4_has_compat_features(sb) || 4646 4648 ext4_has_ro_compat_features(sb) || ··· 4711 4709 */ 4712 4710 if (!ext4_feature_set_ok(sb, (sb_rdonly(sb)))) 4713 4711 return -EINVAL; 4712 + 4713 + if (sbi->s_daxdev) { 4714 + if (sb->s_blocksize == PAGE_SIZE) 4715 + set_bit(EXT4_FLAGS_BDEV_IS_DAX, &sbi->s_ext4_flags); 4716 + else 4717 + ext4_msg(sb, KERN_ERR, "unsupported blocksize for DAX\n"); 4718 + } 4719 + 4720 + if (sbi->s_mount_opt & EXT4_MOUNT_DAX_ALWAYS) { 4721 + if (ext4_has_feature_inline_data(sb)) { 4722 + ext4_msg(sb, KERN_ERR, "Cannot use DAX on a filesystem" 4723 + " that may contain inline data"); 4724 + return -EINVAL; 4725 + } 4726 + if (!test_bit(EXT4_FLAGS_BDEV_IS_DAX, &sbi->s_ext4_flags)) { 4727 + ext4_msg(sb, KERN_ERR, 4728 + "DAX unsupported by block device."); 4729 + return -EINVAL; 4730 + } 4731 + } 4732 + 4733 + if (ext4_has_feature_encrypt(sb) && es->s_encryption_level) { 4734 + ext4_msg(sb, KERN_ERR, "Unsupported encryption level %d", 4735 + es->s_encryption_level); 4736 + return -EINVAL; 4737 + } 4714 4738 4715 4739 return 0; 4716 4740 } ··· 5269 5241 5270 5242 if (ext4_check_feature_compatibility(sb, es, silent)) 5271 5243 goto failed_mount; 5272 - 5273 - if (sbi->s_daxdev) { 5274 - if (sb->s_blocksize == PAGE_SIZE) 5275 - set_bit(EXT4_FLAGS_BDEV_IS_DAX, &sbi->s_ext4_flags); 5276 - else 5277 - ext4_msg(sb, KERN_ERR, "unsupported blocksize for DAX\n"); 5278 - } 5279 - 5280 - if (sbi->s_mount_opt & EXT4_MOUNT_DAX_ALWAYS) { 5281 - if (ext4_has_feature_inline_data(sb)) { 5282 - ext4_msg(sb, KERN_ERR, "Cannot use DAX on a filesystem" 5283 - " that may contain inline data"); 5284 - goto failed_mount; 5285 - } 5286 - if (!test_bit(EXT4_FLAGS_BDEV_IS_DAX, &sbi->s_ext4_flags)) { 5287 - ext4_msg(sb, KERN_ERR, 5288 - "DAX unsupported by block device."); 5289 - goto failed_mount; 5290 - } 5291 - } 5292 - 5293 - if (ext4_has_feature_encrypt(sb) && es->s_encryption_level) { 5294 - ext4_msg(sb, KERN_ERR, "Unsupported encryption level %d", 5295 - es->s_encryption_level); 5296 - goto failed_mount; 5297 - } 5298 5244 5299 5245 if (ext4_block_group_meta_init(sb, silent)) 5300 5246 goto failed_mount;