From 26870a369ffb4e8fde49fcf283f588f7bf3fa3b4 Mon Sep 17 00:00:00 2001 From: Artem Blagodarenko Date: Wed, 8 Apr 2015 15:52:53 +0300 Subject: [PATCH] LU-6442 utils: "-G " can be passed through mkfs options mkfs.lustre util checks if parametrs already contain "flex_bg" option (number of block groups that will be packed together to create a larger virtual block group) and adds this option if it doesn't exists. But second parameter "-G" (number of block groups that will be packed together to create a larger virtual block group) can be added twice: one passed through mkfs options and another one - default value. In this case this parameter is not changed actually and default value is applied. This patch adds extra check. Default option "-G" is added only if no "-G" option passed through mkfs options. Xyratex-bug-id: MRP-2046 Signed-off-by: Artem Blagodarenko Reviewed-by: Sergey Cheremencev Tested-by: Elena Gryaznova Reviewed-by: Vitaly Fertman Change-Id: I14fb5f8d10fa369428efcbbcb4f638f388979818 Reviewed-on: http://review.whamcloud.com/14400 Tested-by: Jenkins Tested-by: Maloo Reviewed-by: Emoly Liu Reviewed-by: Andreas Dilger Reviewed-by: Oleg Drokin --- lustre/tests/conf-sanity.sh | 36 +++++++++++++++++++++++++++++++++++- lustre/utils/mount_utils_ldiskfs.c | 3 ++- 2 files changed, 37 insertions(+), 2 deletions(-) diff --git a/lustre/tests/conf-sanity.sh b/lustre/tests/conf-sanity.sh index d106839..09b4884 100644 --- a/lustre/tests/conf-sanity.sh +++ b/lustre/tests/conf-sanity.sh @@ -4956,7 +4956,7 @@ test_80() { } run_test 80 "mgc import reconnect race" -# Save the original values of $OSTCOUNT and $OSTINDEX$i. +#Save the original values of $OSTCOUNT and $OSTINDEX$i. save_ostindex() { local new_ostcount=$1 saved_ostcount=$OSTCOUNT @@ -5407,6 +5407,40 @@ test_85() { } run_test 85 "osd_ost init: fail ea_fid_set" +test_86() { + [ "$(facet_fstype ost1)" = "zfs" ] && + skip "LU-6442: no such mkfs params for ZFS OSTs" && return + + local OST_OPTS="$(mkfs_opts ost1 $(ostdevname 1)) \ + --reformat $(ostdevname 1) $(ostvdevname 1)" + + local NEWSIZE=1024 + local OLDSIZE=$(do_facet ost1 "$DEBUGFS -c -R stats $(ostdevname 1)" | + awk '/Flex block group size: / { print $NF; exit; }') + + local opts=OST_OPTS + if [[ ${!opts} != *mkfsoptions* ]]; then + eval opts=\"${!opts} \ + --mkfsoptions='\\\"-O flex_bg -G $NEWSIZE\\\"'\" + else + val=${!opts//--mkfsoptions=\\\"/ \ + --mkfsoptions=\\\"-O flex_bg -G $NEWSIZE } + eval opts='${val}' + fi + + echo "params: $opts" + + add ost1 $opts || error "add ost1 failed with new params" + + local FOUNDSIZE=$(do_facet ost1 "$DEBUGFS -c -R stats $(ostdevname 1)" | + awk '/Flex block group size: / { print $NF; exit; }') + + [[ $FOUNDSIZE == $NEWSIZE ]] || + error "Flex block group size: $FOUNDSIZE, expected: $NEWSIZE" + return 0 +} +run_test 86 "Replacing mkfs.lustre -G option" + if ! combined_mgs_mds ; then stop mgs fi diff --git a/lustre/utils/mount_utils_ldiskfs.c b/lustre/utils/mount_utils_ldiskfs.c index 4f662fa..e7e39a5 100644 --- a/lustre/utils/mount_utils_ldiskfs.c +++ b/lustre/utils/mount_utils_ldiskfs.c @@ -615,7 +615,8 @@ static int enable_default_ext4_features(struct mkfs_opts *mop, char *anchor, append_unique(anchor, ",", "flex_bg", NULL, maxbuflen); - if (IS_OST(&mop->mo_ldd)) { + if (IS_OST(&mop->mo_ldd) && + strstr(mop->mo_mkfsopts, "-G") == NULL) { snprintf(tmp_buf, sizeof(tmp_buf), " -G %u", (1 << 20) / L_BLOCK_SIZE); strscat(anchor, tmp_buf, maxbuflen); -- 1.8.3.1