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 <tytso@mit.edu>
This commit is contained in:
Theodore Ts'o 2014-08-27 09:27:54 -04:00
parent 3ff57555f6
commit 725502de19

View File

@ -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);