From: Theodore Ts'o Date: Wed, 27 Aug 2014 13:27:54 +0000 (-0400) Subject: mke2fs: complain if bigalloc and hugefiles_align_disk is incompatible X-Git-Tag: v1.42.12~8 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=725502de199031a379761fba338885d2c3bbfb25;p=thirdparty%2Fe2fsprogs.git mke2fs: complain if bigalloc and hugefiles_align_disk is incompatible If the starting partition offset is incompatible with the bigalloc cluster size, complain and exit, instead of creating a file which would have a logical to physical block mapping which breaks the cluster alignment requirement. Signed-off-by: Theodore Ts'o --- diff --git a/misc/mk_hugefiles.c b/misc/mk_hugefiles.c index c292ddc13..8291f0199 100644 --- a/misc/mk_hugefiles.c +++ b/misc/mk_hugefiles.c @@ -490,9 +490,18 @@ errcode_t mk_hugefiles(ext2_filsys fs, const char *device_name) t = get_string_from_profile(fs_types, "hugefiles_align", "0"); align = parse_num_blocks2(t, fs->super->s_log_block_size); free(t); - if (get_bool_from_profile(fs_types, "hugefiles_align_disk", 0)) + if (get_bool_from_profile(fs_types, "hugefiles_align_disk", 0)) { part_offset = get_partition_start(device_name) / (fs->blocksize / 512); + if (part_offset % EXT2FS_CLUSTER_RATIO(fs)) { + fprintf(stderr, + _("Partition offset of %llu (%uk) blocks " + "not compatible with cluster size %u.\n"), + part_offset, fs->blocksize, + EXT2_CLUSTER_SIZE(fs->super)); + exit(1); + } + } num_blocks = round_up_align(num_blocks, align, 0); zero_hugefile = get_bool_from_profile(fs_types, "zero_hugefiles", zero_hugefile);