From 25e58c4755609f74bbcd046fd3cea17a7a6dd063 Mon Sep 17 00:00:00 2001 From: Emoly Liu Date: Fri, 17 Apr 2020 18:52:07 +0800 Subject: [PATCH] LU-13460 lfs: use correct obd index in print_failed_tgt() In function print_failed_tgt(), when calling llapi_obd_statfs(), the correct obd index should be used according to obd type. sanity.sh test_56rb is added to verify this patch. Signed-off-by: Emoly Liu Change-Id: I443a5b388ee1c3efc8fc589c09aeec6f9b71600b Reviewed-on: https://review.whamcloud.com/38264 Tested-by: jenkins Reviewed-by: Andreas Dilger Tested-by: Maloo Reviewed-by: Jian Yu Reviewed-by: Oleg Drokin --- lustre/tests/sanity.sh | 20 ++++++++++++++++++++ lustre/utils/liblustreapi.c | 3 ++- 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/lustre/tests/sanity.sh b/lustre/tests/sanity.sh index 950fad3..7659f92 100755 --- a/lustre/tests/sanity.sh +++ b/lustre/tests/sanity.sh @@ -6194,6 +6194,26 @@ test_56ra() { } run_test 56ra "check lfs find -size -lazy works for data on OSTs" +test_56rb() { + local dir=$DIR/$tdir + local tmp=$TMP/$tfile.log + local mdt_idx; + + test_mkdir -p $dir || error "failed to mkdir $dir" + $LFS setstripe -c 1 -i 0 $dir/$tfile || + error "failed to setstripe $dir/$tfile" + dd if=/dev/zero of=$dir/$tfile bs=1M count=1 + + stack_trap "rm -f $tmp" EXIT + $LFS find --size +100K --ost 0 $dir 2>&1 | tee $tmp + [ -z "$(cat $tmp | grep "obd_uuid: ")" ] || + error "failed to find --size +100K --ost 0 $dir" + $LFS find --size +100K --mdt $mdt_idx $dir 2>&1 | tee $tmp + [ -z "$(cat $tmp | grep "obd_uuid: ")" ] || + error "failed to find --size +100K --mdt $mdt_idx $dir" +} +run_test 56rb "check lfs find --size --ost/--mdt works" + test_56s() { # LU-611 #LU-9369 [[ $OSTCOUNT -lt 2 ]] && skip_env "need at least 2 OSTs" diff --git a/lustre/utils/liblustreapi.c b/lustre/utils/liblustreapi.c index 1f1494f..5c0e16b 100644 --- a/lustre/utils/liblustreapi.c +++ b/lustre/utils/liblustreapi.c @@ -4158,7 +4158,8 @@ static int print_failed_tgt(struct find_param *param, char *path, int type) memset(&stat_buf, 0, sizeof(struct obd_statfs)); memset(&uuid_buf, 0, sizeof(struct obd_uuid)); ret = llapi_obd_statfs(path, type, - param->fp_obd_index, &stat_buf, + type == LL_STATFS_LOV ? param->fp_obd_index : + param->fp_mdt_index, &stat_buf, &uuid_buf); if (ret) llapi_error(LLAPI_MSG_NORMAL, ret, "obd_uuid: %s failed", -- 1.8.3.1