Whamcloud - gitweb
LU-13460 lfs: make function print_failed_tgt() work correctly 59/38959/6
authorEmoly Liu <emoly@whamcloud.com>
Wed, 17 Jun 2020 07:43:00 +0000 (15:43 +0800)
committerOleg Drokin <green@whamcloud.com>
Fri, 10 Jul 2020 16:52:52 +0000 (16:52 +0000)
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 <emoly@whamcloud.com>
Change-Id: Idffdddac1b5b249aa903b97912c767826f3b146c
Reviewed-on: https://review.whamcloud.com/38959
Reviewed-by: Mike Pershin <mpershin@whamcloud.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
lustre/tests/sanity.sh
lustre/utils/lfs.c
lustre/utils/liblustreapi.c

index eff0c18..4be9bc0 100755 (executable)
@@ -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"
        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
        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"
                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"
                error "failed to find --size +100K --mdt $mdt_idx $dir"
 }
 run_test 56rb "check lfs find --size --ost/--mdt works"
index d776a67..3f7e129 100644 (file)
@@ -5948,7 +5948,7 @@ static int mntdf(char *mntdir, char *fsname, char *pool, enum mntdf_flags flags,
                                continue;
 
                        /*
                                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
                         * 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
index dbf46bb..5575b78 100644 (file)
@@ -4210,26 +4210,35 @@ static int check_mdt_match(struct find_param *param)
  * not active, just print the object affected by this
  * failed target
  **/
  * 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;
 {
        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)
 }
 
 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,
        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;
        }
 
                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,
        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;
        }
 
                return rc;
        }