Whamcloud - gitweb
LU-14507 mdt: handle default stripe_count=-1 properly
authorAndreas Dilger <adilger@whamcloud.com>
Wed, 10 Mar 2021 16:57:44 +0000 (09:57 -0700)
committerLi Xi <lixi@ddn.com>
Wed, 28 Apr 2021 13:42:46 +0000 (13:42 +0000)
If the default LMV stripe_count=-1 print it as a signed value
instead of unsigned, to better match how it is set with "-c -1".

Lustre-commit: d9753b5ba6ad29fd8958a47b462d2fa594ba1145
Lustre-change: https://review.whamcloud.com/41983

Signed-off-by: Andreas Dilger <adilger@whamcloud.com>
Change-Id: I106f266c33e2c2cf0f5bcc1491e4bc5ac93ebbe5
Reviewed-by: Jian Yu <yujian@whamcloud.com>
Reviewed-by: Lai Siyao <lai.siyao@whamcloud.com>
Reviewed-on: https://review.whamcloud.com/43147
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Li Xi <lixi@ddn.com>
lustre/include/lustre_lmv.h
lustre/mdt/mdt_lib.c
lustre/tests/sanity.sh
lustre/utils/liblustreapi.c

index 363dfb0..a3f8ed4 100644 (file)
@@ -150,6 +150,8 @@ static inline void lmv1_le_to_cpu(struct lmv_mds_md_v1 *lmv_dst,
                                le32_to_cpu(lmv_src->lmv_master_mdt_index);
        lmv_dst->lmv_hash_type = le32_to_cpu(lmv_src->lmv_hash_type);
        lmv_dst->lmv_layout_version = le32_to_cpu(lmv_src->lmv_layout_version);
+       if (lmv_src->lmv_stripe_count > LMV_MAX_STRIPE_COUNT)
+               return;
        for (i = 0; i < lmv_src->lmv_stripe_count; i++)
                fid_le_to_cpu(&lmv_dst->lmv_stripe_fids[i],
                              &lmv_src->lmv_stripe_fids[i]);
index be2531a..da82333 100644 (file)
@@ -681,7 +681,7 @@ void mdt_dump_lmv(unsigned int level, const union lmv_mds_md *lmv)
 
        lmm1 = &lmv->lmv_md_v1;
        CDEBUG(level,
-              "magic 0x%08X, master %#X stripe_count %#x hash_type %#x\n",
+              "magic 0x%08X, master %#X stripe_count %d hash_type %#x\n",
               le32_to_cpu(lmm1->lmv_magic),
               le32_to_cpu(lmm1->lmv_master_mdt_index),
               le32_to_cpu(lmm1->lmv_stripe_count),
@@ -690,6 +690,9 @@ void mdt_dump_lmv(unsigned int level, const union lmv_mds_md *lmv)
        if (le32_to_cpu(lmm1->lmv_magic) == LMV_MAGIC_STRIPE)
                return;
 
+       if (le32_to_cpu(lmm1->lmv_stripe_count) > LMV_MAX_STRIPE_COUNT)
+               return;
+
        for (i = 0; i < le32_to_cpu(lmm1->lmv_stripe_count); i++) {
                struct lu_fid fid;
 
index fe21cfe..6726900 100755 (executable)
@@ -21413,7 +21413,7 @@ test_300_check_default_striped_dir()
 
        echo "checking $dirname $default_count $default_index"
        $LFS setdirstripe -D -c $default_count -i $default_index \
-                               -t all_char $DIR/$tdir/$dirname ||
+                               -H all_char $DIR/$tdir/$dirname ||
                error "set default stripe on striped dir error"
        stripe_count=$($LFS getdirstripe -D -c $DIR/$tdir/$dirname)
        [ $stripe_count -eq $default_count ] ||
@@ -21430,8 +21430,9 @@ test_300_check_default_striped_dir()
        unlinkmany $DIR/$tdir/$dirname/f- 10    || error "unlink files failed"
        for dir in $(find $DIR/$tdir/$dirname/*); do
                stripe_count=$($LFS getdirstripe -c $dir)
-               [ $stripe_count -eq $default_count ] ||
-               [ $stripe_count -eq 0 ] || [ $default_count -eq 1 ] ||
+               (( $stripe_count == $default_count )) ||
+               (( $stripe_count == $MDSCOUNT && $default_count == -1 )) ||
+               (( $stripe_count == 0 )) || (( $default_count == 1 )) ||
                error "stripe count $default_count != $stripe_count for $dir"
 
                stripe_index=$($LFS getdirstripe -i $dir)
@@ -21483,7 +21484,7 @@ test_300g() {
        #check default stripe count/stripe index
        test_300_check_default_striped_dir normal_dir $MDSCOUNT 1
        test_300_check_default_striped_dir normal_dir 1 0
-       test_300_check_default_striped_dir normal_dir 2 1
+       test_300_check_default_striped_dir normal_dir -1 1
        test_300_check_default_striped_dir normal_dir 2 -1
 
        #delete default stripe information
@@ -21517,7 +21518,7 @@ test_300h() {
 
        test_300_check_default_striped_dir striped_dir $MDSCOUNT 1
        test_300_check_default_striped_dir striped_dir 1 0
-       test_300_check_default_striped_dir striped_dir 2 1
+       test_300_check_default_striped_dir striped_dir -1 1
        test_300_check_default_striped_dir striped_dir 2 -1
 
        #delete default stripe information
index bcf73fe..d03ea43 100644 (file)
@@ -3186,7 +3186,7 @@ void lmv_dump_user_lmm(struct lmv_user_md *lum, char *pool_name,
                llapi_printf(LLAPI_MSG_NORMAL, "%s", separator);
                if (verbose & ~VERBOSE_STRIPE_COUNT)
                        llapi_printf(LLAPI_MSG_NORMAL, "lmv_stripe_count: ");
-               llapi_printf(LLAPI_MSG_NORMAL, "%u",
+               llapi_printf(LLAPI_MSG_NORMAL, "%d",
                             (int)lum->lum_stripe_count);
                if ((verbose & VERBOSE_STRIPE_OFFSET) && !yaml)
                        separator = " ";