From e542ab2a0b40f4f53d4b8cbd1013ea1d46e9574f Mon Sep 17 00:00:00 2001 From: Emoly Liu Date: Mon, 9 Jun 2014 19:20:37 +0800 Subject: [PATCH] LU-4227 utils: mgs option is required to format a MDT/OST When running mkfs.lustre to format a MDT, --mgs or --mgsnode option is required; while to format a OST, --mgsnode option is required. conf-sanity.sh test_79 is added to verify the fix. Signed-off-by: Emoly Liu Change-Id: Ia65b382aad2bc31496f3da62f15349ec38990ea0 Reviewed-on: http://review.whamcloud.com/8387 Tested-by: Jenkins Tested-by: Maloo Reviewed-by: Andreas Dilger Reviewed-by: Niu Yawei Reviewed-by: Faccini Bruno --- lustre/tests/conf-sanity.sh | 46 +++++++++++++++++++++++++++++++++++++++++++++ lustre/utils/mkfs_lustre.c | 30 +++++++++-------------------- 2 files changed, 55 insertions(+), 21 deletions(-) diff --git a/lustre/tests/conf-sanity.sh b/lustre/tests/conf-sanity.sh index 8b34529..3862b8f 100644 --- a/lustre/tests/conf-sanity.sh +++ b/lustre/tests/conf-sanity.sh @@ -4682,6 +4682,52 @@ test_78() { } run_test 78 "run resize2fs on MDT and OST filesystems" +test_79() { # LU-4227 + [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.5.59) ]] || + { skip "Need MDS version at least 2.5.59"; return 0; } + + local mdsdev1=$(mdsdevname 1) + local mdsvdev1=$(mdsvdevname 1) + local mdsdev2=$(mdsdevname 2) + local mdsvdev2=$(mdsvdevname 2) + local ostdev1=$(ostdevname 1) + local ostvdev1=$(ostvdevname 1) + local opts_mds1="$(mkfs_opts mds1 $mdsdev1) --reformat" + local opts_mds2="$(mkfs_opts mds2 $mdsdev2) --reformat" + local opts_ost1="$(mkfs_opts ost1 $ostdev1) --reformat" + local mgsnode_opt + + # remove --mgs/--mgsnode from mkfs.lustre options + opts_mds1=$(echo $opts_mds1 | sed -e "s/--mgs//") + + mgsnode_opt=$(echo $opts_mds2 | + awk '{ for ( i = 1; i < NF; i++ ) + if ( $i ~ "--mgsnode" ) { print $i; break } }') + [ -n $mgsnode_opt ] && + opts_mds2=$(echo $opts_mds2 | sed -e "s/$mgsnode_opt//") + + mgsnode_opt=$(echo $opts_ost1 | + awk '{ for ( i = 1; i < NF; i++ ) + if ( $i ~ "--mgsnode" ) { print $i; break } }') + [ -n $mgsnode_opt ] && + opts_ost1=$(echo $opts_ost1 | sed -e "s/$mgsnode_opt//") + + # -MGS, format a mdt without --mgs option + add mds1 $opts_mds1 $mdsdev1 $mdsvdev1 && + error "Must specify --mgs when formatting mdt combined with mgs" + + # +MGS, format a mdt/ost without --mgsnode option + add mds1 $(mkfs_opts mds1 $mdsdev1) --reformat $mdsdev1 $mdsvdev1 \ + > /dev/null || error "start mds1 failed" + add mds2 $opts_mds2 $mdsdev2 $mdsvdev2 && + error "Must specify --mgsnode when formatting a mdt" + add ost1 $opts_ost1 $ostdev1 $ostvdev2 && + error "Must specify --mgsnode when formatting an ost" + + return 0 +} +run_test 79 "format MDT/OST without mgs option (should return errors)" + test_80() { start_mds start_ost diff --git a/lustre/utils/mkfs_lustre.c b/lustre/utils/mkfs_lustre.c index 001a051..ceed41d 100644 --- a/lustre/utils/mkfs_lustre.c +++ b/lustre/utils/mkfs_lustre.c @@ -661,27 +661,15 @@ int main(int argc, char *const argv[]) mop.mo_ldd.ldd_flags &= ~LDD_F_NEED_INDEX; mop.mo_ldd.ldd_svindex = 0; } - -#if 0 - /* - * Comment out these 2 checks temporarily, since for multi-MDSes - * in single node only 1 mds node could have mgs service - */ - if (IS_MDT(ldd) && !IS_MGS(ldd) && (mop.mo_mgs_failnodes == 0)) { - verrprint("No management node specified, adding MGS to this " - "MDT\n"); - ldd->ldd_flags |= LDD_F_SV_TYPE_MGS; - } - if (!IS_MGS(ldd) && (mop.mo_mgs_failnodes == 0)) { - fatal(); - if (IS_MDT(ldd)) - fprintf(stderr, "Must specify --mgs or --mgsnode=\n"); - else - fprintf(stderr, "Must specify --mgsnode=\n"); - ret = EINVAL; - goto out; - } -#endif + if (!IS_MGS(ldd) && (mop.mo_mgs_failnodes == 0)) { + fatal(); + if (IS_MDT(ldd)) + fprintf(stderr, "Must specify --mgs or --mgsnode\n"); + else + fprintf(stderr, "Must specify --mgsnode\n"); + ret = EINVAL; + goto out; + } if ((IS_MDT(ldd) || IS_OST(ldd)) && mop.mo_ldd.ldd_fsname[0] == '\0') { fatal(); fprintf(stderr, "Must specify --fsname for MDT/OST device\n"); -- 1.8.3.1