From 725502de199031a379761fba338885d2c3bbfb25 Mon Sep 17 00:00:00 2001 From: Theodore Ts'o Date: Wed, 27 Aug 2014 09:27:54 -0400 Subject: [PATCH] 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 --- misc/mk_hugefiles.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/misc/mk_hugefiles.c b/misc/mk_hugefiles.c index c292ddc..8291f01 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); -- 1.8.3.1