From: Andreas Dilger Date: Sat, 3 Nov 2018 09:10:22 +0000 (-0600) Subject: LU-11609 mke2fs: allow 64bit feature without extents X-Git-Tag: v1.47.1-wc1~15 X-Git-Url: https://git.whamcloud.com/?a=commitdiff_plain;h=1d7afea72b16ad44a0f7aa319008b494a9715017;p=tools%2Fe2fsprogs.git LU-11609 mke2fs: allow 64bit feature without extents The 64bit feature should be allowed without extents to for 32-bit metadata_csum checksums to be stored in the group descriptor. Change the extents check to check for more than 2^32 blocks instead of the 64bit feature flag. This also avoids warnings later if the metadata_csum feature is enabled on a filesystem without 64bit. Consolidate repeated 64bit feature checks into one check. The fs_blocks_count value is always set when parse_fs_type() is called, so no need to check if it is zero. Signed-off-by: Andreas Dilger Change-Id: Ie73ff0ed50cfed5d6a9596260c6b6dc32d3ebbe5 Reviewed-on: https://review.whamcloud.com/33897 Tested-by: Jenkins Tested-by: Maloo Reviewed-by: Li Dongyang --- diff --git a/misc/mke2fs.c b/misc/mke2fs.c index d354e3b..51c71c1 100644 --- a/misc/mke2fs.c +++ b/misc/mke2fs.c @@ -2077,8 +2077,7 @@ profile_error: * be appropriately configured. */ fs_types = parse_fs_type(fs_type, usage_types, &fs_param, - fs_blocks_count ? fs_blocks_count : dev_size, - argv[0]); + fs_blocks_count, argv[0]); if (!fs_types) { fprintf(stderr, "%s", _("Failed to parse fs types list\n")); exit(1); @@ -2228,24 +2227,25 @@ profile_error: * We now need to do a sanity check of fs_blocks_count for * 32-bit vs 64-bit block number support. */ - if ((fs_blocks_count > MAX_32_NUM) && - ext2fs_has_feature_64bit(&fs_param)) - ext2fs_clear_feature_resize_inode(&fs_param); - if ((fs_blocks_count > MAX_32_NUM) && - !ext2fs_has_feature_64bit(&fs_param) && - get_bool_from_profile(fs_types, "auto_64-bit_support", 0)) { - ext2fs_set_feature_64bit(&fs_param); - ext2fs_clear_feature_resize_inode(&fs_param); - } - if ((fs_blocks_count > MAX_32_NUM) && - !ext2fs_has_feature_64bit(&fs_param)) { - fprintf(stderr, _("%s: Size of device (0x%llx blocks) %s " + if (fs_blocks_count > MAX_32_NUM) { + if (!ext2fs_has_feature_64bit(&fs_param) && + get_bool_from_profile(fs_types, "auto_64-bit_support", 0)) + ext2fs_set_feature_64bit(&fs_param); + + if (ext2fs_has_feature_64bit(&fs_param)) { + ext2fs_clear_feature_resize_inode(&fs_param); + } else { + fprintf(stderr, + _("%s: Size of device (0x%llx blocks) %s " "too big to be expressed\n\t" "in 32 bits using a blocksize of %d.\n"), - program_name, (unsigned long long) fs_blocks_count, - device_name, EXT2_BLOCK_SIZE(&fs_param)); - exit(1); + program_name, + (unsigned long long) fs_blocks_count, + device_name, EXT2_BLOCK_SIZE(&fs_param)); + exit(1); + } } + /* * Guard against group descriptor count overflowing... Mostly to avoid * strange results for absurdly large devices. This is in log2: @@ -2325,13 +2325,13 @@ profile_error: fs_param.s_feature_compat = 0; fs_param.s_feature_ro_compat &= EXT4_FEATURE_RO_COMPAT_METADATA_CSUM; - } + } /* Check the user's mkfs options for 64bit */ - if (ext2fs_has_feature_64bit(&fs_param) && + if (fs_blocks_count > MAX_32_NUM && !ext2fs_has_feature_extents(&fs_param)) { - printf("%s", _("Extents MUST be enabled for a 64-bit " - "filesystem. Pass -O extents to rectify.\n")); + printf("%s", _("Extents MUST be enabled for filesystems with " + "over 2^32 blocks. Use '-O extents' to fix.\n")); exit(1); }