From 219cbfc7665a9260f3d5c8ceee823506a89df42f Mon Sep 17 00:00:00 2001 From: Emoly Liu Date: Wed, 17 Jun 2020 15:43:00 +0800 Subject: [PATCH] LU-13460 lfs: make function print_failed_tgt() work correctly param->fp_xxx_index is the number of the specified targets, not the specific index, so it can't be passed into llapi_obd_statfs() directly to get the statfs information. Instead, all the targets listed in param->fp_xxx_indexes should be passed one by one. Also, $mdt_idx in sanity.sh test_56rb should be initialized with the correct mdt index. Signed-off-by: Emoly Liu Change-Id: Idffdddac1b5b249aa903b97912c767826f3b146c Reviewed-on: https://review.whamcloud.com/38959 Reviewed-by: Mike Pershin Reviewed-by: Andreas Dilger Tested-by: jenkins Tested-by: Maloo Reviewed-by: Oleg Drokin --- lustre/tests/sanity.sh | 9 +++++---- lustre/utils/lfs.c | 2 +- lustre/utils/liblustreapi.c | 41 +++++++++++++++++++++++++---------------- 3 files changed, 31 insertions(+), 21 deletions(-) diff --git a/lustre/tests/sanity.sh b/lustre/tests/sanity.sh index eff0c18..4be9bc0 100755 --- a/lustre/tests/sanity.sh +++ b/lustre/tests/sanity.sh @@ -6268,14 +6268,15 @@ test_56rb() { test_mkdir -p $dir || error "failed to mkdir $dir" $LFS setstripe -c 1 -i 0 $dir/$tfile || error "failed to setstripe $dir/$tfile" + mdt_idx=$($LFS getdirstripe -i $dir) 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: ")" ] || + $LFS find --size +100K --ost 0 $dir |& tee $tmp + ! grep -q obd_uuid $tmp || 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: ")" ] || + $LFS find --size +100K --mdt $mdt_idx $dir |& tee $tmp + ! grep -q obd_uuid $tmp || error "failed to find --size +100K --mdt $mdt_idx $dir" } run_test 56rb "check lfs find --size --ost/--mdt works" diff --git a/lustre/utils/lfs.c b/lustre/utils/lfs.c index d776a67..3f7e129 100644 --- a/lustre/utils/lfs.c +++ b/lustre/utils/lfs.c @@ -5948,7 +5948,7 @@ static int mntdf(char *mntdir, char *fsname, char *pool, enum mntdf_flags flags, continue; /* - * the llapi_obd_statfs() call may have returned with + * the llapi_obd_fstatfs() call may have returned with * an error, but if it filled in uuid_buf we will at * lease use that to print out a message for that OBD. * If we didn't get anything in the uuid_buf, then fill diff --git a/lustre/utils/liblustreapi.c b/lustre/utils/liblustreapi.c index dbf46bb..5575b78 100644 --- a/lustre/utils/liblustreapi.c +++ b/lustre/utils/liblustreapi.c @@ -4210,26 +4210,35 @@ static int check_mdt_match(struct find_param *param) * not active, just print the object affected by this * failed target **/ -static int print_failed_tgt(struct find_param *param, char *path, int type) +static void print_failed_tgt(struct find_param *param, char *path, int type) { struct obd_statfs stat_buf; struct obd_uuid uuid_buf; - int ret; + int tgt_nr, i, *indexes; + int ret = 0; - if (type != LL_STATFS_LOV && type != LL_STATFS_LMV) - return -EINVAL; + if (type != LL_STATFS_LOV && type != LL_STATFS_LMV) { + llapi_error(LLAPI_MSG_NORMAL, ret, "%s: wrong statfs type(%d)", + __func__, type); + return; + } - memset(&stat_buf, 0, sizeof(struct obd_statfs)); - memset(&uuid_buf, 0, sizeof(struct obd_uuid)); - ret = llapi_obd_statfs(path, type, - 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", - param->fp_obd_uuid->uuid); + tgt_nr = (type == LL_STATFS_LOV) ? param->fp_obd_index : + param->fp_mdt_index; + indexes = (type == LL_STATFS_LOV) ? param->fp_obd_indexes : + param->fp_mdt_indexes; - return ret; + for (i = 0; i < tgt_nr; i++) { + memset(&stat_buf, 0, sizeof(struct obd_statfs)); + memset(&uuid_buf, 0, sizeof(struct obd_uuid)); + + ret = llapi_obd_statfs(path, type, indexes[i], &stat_buf, + &uuid_buf); + if (ret) + llapi_error(LLAPI_MSG_NORMAL, ret, + "%s: obd_uuid: %s failed", + __func__, param->fp_obd_uuid->uuid); + } } static int find_check_stripe_size(struct find_param *param) @@ -5147,7 +5156,7 @@ static int cb_migrate_mdt_init(char *path, DIR *parent, DIR **dirp, ret = llapi_ioctl_pack(&data, &rawbuf, sizeof(raw)); if (ret != 0) { llapi_error(LLAPI_MSG_ERROR, ret, - "llapi_obd_statfs: error packing ioctl data"); + "%s: error packing ioctl data", __func__); goto out; } @@ -5477,7 +5486,7 @@ int llapi_obd_fstatfs(int fd, __u32 type, __u32 index, rc = llapi_ioctl_pack(&data, &rawbuf, sizeof(raw)); if (rc != 0) { llapi_error(LLAPI_MSG_ERROR, rc, - "llapi_obd_statfs: error packing ioctl data"); + "%s: error packing ioctl data", __func__); return rc; } -- 1.8.3.1