Whamcloud - gitweb
LU-13460 lfs: use correct obd index in print_failed_tgt() 64/38264/3
authorEmoly Liu <emoly@whamcloud.com>
Fri, 17 Apr 2020 10:52:07 +0000 (18:52 +0800)
committerOleg Drokin <green@whamcloud.com>
Fri, 1 May 2020 04:27:21 +0000 (04:27 +0000)
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 <emoly@whamcloud.com>
Change-Id: I443a5b388ee1c3efc8fc589c09aeec6f9b71600b
Reviewed-on: https://review.whamcloud.com/38264
Tested-by: jenkins <devops@whamcloud.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Jian Yu <yujian@whamcloud.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
lustre/tests/sanity.sh
lustre/utils/liblustreapi.c

index 950fad3..7659f92 100755 (executable)
@@ -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"
 
index 1f1494f..5c0e16b 100644 (file)
@@ -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",