From 479f9585b0bf02bdc43346dfd037837b8340dde7 Mon Sep 17 00:00:00 2001 From: Li Dongyang Date: Thu, 17 Aug 2023 23:27:00 +1000 Subject: [PATCH] LU-17036 utils: make sure resize option is legit To align the metadata on 1MB boundaries we manually set the resize blocks to 16368G for 4K block size, however mke2fs expects the resize blocks is bigger than device size. For devices between 16368G and 16384G the mke2fs will fail with: The resize maximum must be greater than the filesystem size. Change-Id: I4567a79c1405e9527d7f0f9bec4c8a7aae0eba6c Test-Parameters: trivial Signed-off-by: Li Dongyang Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/51970 Tested-by: jenkins Tested-by: Maloo Reviewed-by: Andreas Dilger Reviewed-by: Emoly Liu Reviewed-by: Oleg Drokin --- lustre/utils/libmount_utils_ldiskfs.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/lustre/utils/libmount_utils_ldiskfs.c b/lustre/utils/libmount_utils_ldiskfs.c index a48cadb..32b19a1 100644 --- a/lustre/utils/libmount_utils_ldiskfs.c +++ b/lustre/utils/libmount_utils_ldiskfs.c @@ -867,12 +867,15 @@ int ldiskfs_make_lustre(struct mkfs_opts *mop) unsigned int group_blocks = mop->mo_blocksize_kb * 8192; unsigned int desc_per_block = mop->mo_blocksize_kb * 1024 / 32; unsigned int resize_blks; + __u64 block_count = mop->mo_device_kb / mop->mo_blocksize_kb; resize_blks = (1ULL<<32) - desc_per_block*group_blocks; - snprintf(buf, sizeof(buf), "%u", resize_blks); - append_unique(start, ext_opts ? "," : " -E ", - "resize", buf, maxbuflen); - ext_opts = 1; + if (resize_blks > block_count) { + snprintf(buf, sizeof(buf), "%u", resize_blks); + append_unique(start, ext_opts ? "," : " -E ", + "resize", buf, maxbuflen); + ext_opts = 1; + } } /* Avoid zeroing out the full journal - speeds up mkfs */ -- 1.8.3.1