From 3728c2825aa277dbd2523fd240fb04b8699932f8 Mon Sep 17 00:00:00 2001 From: Andreas Dilger Date: Tue, 7 Apr 2020 18:37:36 -0600 Subject: [PATCH] LU-13427 lmv: do not print MDTs that are inactive Have lmv return -EAGAIN instead of -ENODATA for unconfigured MDTs. That avoids "lfs df -v" from printing a long list of invalid MDTs when trying to get the target state for non-rotational devices. Add test for "lfs df -v" printing nonrotational state, as well as limiting the reported OST and MDT to configured devices. Fixes: 4c76eb64a9ff ("LU-8920 utils: don't print deactivated OSTs in 'lfs df') Signed-off-by: Andreas Dilger Change-Id: Ia3dcf85f4cf52caa39848f0f6ed8d47d42ce7057 Reviewed-on: https://review.whamcloud.com/38165 Tested-by: jenkins Reviewed-by: Jian Yu Tested-by: Maloo Reviewed-by: Ben Evans Reviewed-by: Mike Pershin Reviewed-by: Oleg Drokin --- lustre/lmv/lmv_obd.c | 5 ++++- lustre/tests/sanity.sh | 33 ++++++++++++++++++++++++++++++--- lustre/tests/test-framework.sh | 3 ++- 3 files changed, 36 insertions(+), 5 deletions(-) diff --git a/lustre/lmv/lmv_obd.c b/lustre/lmv/lmv_obd.c index 37d341d..062a44a 100644 --- a/lustre/lmv/lmv_obd.c +++ b/lustre/lmv/lmv_obd.c @@ -837,7 +837,10 @@ static int lmv_iocontrol(unsigned int cmd, struct obd_export *exp, RETURN(-ENODEV); tgt = lmv_tgt(lmv, index); - if (!tgt || !tgt->ltd_active) + if (!tgt) + RETURN(-EAGAIN); + + if (!tgt->ltd_active) RETURN(-ENODATA); mdc_obd = class_exp2obd(tgt->ltd_exp); diff --git a/lustre/tests/sanity.sh b/lustre/tests/sanity.sh index ddf1381..c6bbc40 100755 --- a/lustre/tests/sanity.sh +++ b/lustre/tests/sanity.sh @@ -5624,16 +5624,24 @@ test_56c() { local ost_idx=0 local ost_name=$(ostname_from_index $ost_idx) local old_status=$(ost_dev_status $ost_idx) + local p="$TMP/$TESTSUITE-$TESTNAME.parameters" [[ -z "$old_status" ]] || skip_env "OST $ost_name is in $old_status status" do_facet ost1 $LCTL set_param -n obdfilter.$ost_name.degraded=1 - [[ $OST1_VERSION -ge $(version_code 2.12.55) ]] && do_facet ost1 \ + [[ $OST1_VERSION -lt $(version_code 2.12.55) ]] || do_facet ost1 \ $LCTL set_param -n obdfilter.$ost_name.no_precreate=1 + if [[ $OST1_VERSION -ge $(version_code 2.12.57) ]]; then + save_lustre_params ost1 osd-*.$ost_name.nonrotational > $p + do_facet ost1 $LCTL set_param -n osd-*.$ost_name.nonrotational=1 + fi + + [[ $($LFS df -v $MOUNT |& grep -c "inactive device") -eq 0 ]] || + error "$LFS df -v showing inactive devices" sleep_maxage - local new_status=$(ost_dev_status $ost_idx) + local new_status=$(ost_dev_status $ost_idx $MOUNT -v) [[ "$new_status" =~ "D" ]] || error "$ost_name status is '$new_status', missing 'D'" @@ -5641,18 +5649,37 @@ test_56c() { [[ "$new_status" =~ "N" ]] || error "$ost_name status is '$new_status', missing 'N'" fi + if [[ $OST1_VERSION -ge $(version_code 2.12.57) ]]; then + [[ "$new_status" =~ "f" ]] || + error "$ost_name status is '$new_status', missing 'f'" + fi do_facet ost1 $LCTL set_param -n obdfilter.$ost_name.degraded=0 - [[ $OST1_VERSION -ge $(version_code 2.12.55) ]] && do_facet ost1 \ + [[ $OST1_VERSION -lt $(version_code 2.12.55) ]] || do_facet ost1 \ $LCTL set_param -n obdfilter.$ost_name.no_precreate=0 + [[ -z "$p" ]] && restore_lustre_params < $p || true sleep_maxage new_status=$(ost_dev_status $ost_idx) [[ ! "$new_status" =~ "D" && ! "$new_status" =~ "N" ]] || error "$ost_name status is '$new_status', has 'D' and/or 'N'" + # can't check 'f' as devices may actually be on flash } run_test 56c "check 'lfs df' showing device status" +test_56d() { + local mdts=$($LFS df -v $MOUNT | grep -c MDT) + local osts=$($LFS df -v $MOUNT | grep -c OST) + + $LFS df $MOUNT + + (( mdts == MDSCOUNT )) || + error "lfs df -v showed $mdts MDTs, not $MDSCOUNT" + (( osts == OSTCOUNT )) || + error "lfs df -v showed $osts OSTs, not $OSTCOUNT" +} +run_test 56d "'lfs df -v' prints only configured devices" + NUMFILES=3 NUMDIRS=3 setup_56() { diff --git a/lustre/tests/test-framework.sh b/lustre/tests/test-framework.sh index b18222c..5fe9a9d 100755 --- a/lustre/tests/test-framework.sh +++ b/lustre/tests/test-framework.sh @@ -2217,10 +2217,11 @@ mdt_free_inodes() { ost_dev_status() { local ost_idx=$1 local mnt_pnt=${2:-$MOUNT} + local opts=$3 local ost_uuid ost_uuid=$(ostuuid_from_index $ost_idx $mnt_pnt) - lfs_df $mnt_pnt | awk '/'$ost_uuid'/ { print $7 }' + lfs_df $opts $mnt_pnt | awk '/'$ost_uuid'/ { print $7 }' } setup_quota(){ -- 1.8.3.1