Whamcloud - gitweb
LU-14507 mdt: handle default stripe_count=-1 properly 83/41983/6
authorAndreas Dilger <adilger@whamcloud.com>
Wed, 10 Mar 2021 16:57:44 +0000 (09:57 -0700)
committerOleg Drokin <green@whamcloud.com>
Tue, 30 Mar 2021 04:16:44 +0000 (04:16 +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".

Signed-off-by: Andreas Dilger <adilger@whamcloud.com>
Change-Id: I106f266c33e2c2cf0f5bcc1491e4bc5ac93ebbe5
Reviewed-on: https://review.whamcloud.com/41983
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Jian Yu <yujian@whamcloud.com>
Reviewed-by: Lai Siyao <lai.siyao@whamcloud.com>
Reviewed-by: Oleg Drokin <green@whamcloud.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 0c6ddb2..b29dc02 100644 (file)
@@ -690,7 +690,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),
@@ -699,6 +699,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 33d2696..f223200 100755 (executable)
@@ -21788,7 +21788,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 ] ||
@@ -21805,8 +21805,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)
@@ -21858,7 +21859,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
@@ -21892,7 +21893,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 60fd7ea..0278d4c 100644 (file)
@@ -3173,7 +3173,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 = " ";