Whamcloud - gitweb
LU-14659 test: improve generate_uneven_mdts() in sanity.sh
authorLai Siyao <lai.siyao@whamcloud.com>
Wed, 4 Aug 2021 04:37:29 +0000 (00:37 -0400)
committerAndreas Dilger <adilger@whamcloud.com>
Sat, 21 Oct 2023 17:41:09 +0000 (17:41 +0000)
Improve generate_uneven_mdts() in several places:
1. set qos maxage to 1, so the result is up to date, and avoid filling
   up MDT.
2. fill MDT with files of size 64K other than 1M, so MDT imbalance is
   quicker to achieve.
3. when checking minimum imbalance after test, lookup max value from
   the result, other than by index stored before directory creation,
   because the result is dynamic if several MDTs have almost the same
   free space and inodes.

Lustre-change: https://review.whamcloud.com/44649
Lustre-commit: d45be79a069f527657c1ce91630183031ea42b27

Test-Parameter: trivial mdscount=2 mdtcount=4 testlist=sanity
Fixes: 233344d451e ("LU-13417 test: generate uneven MDTs early for sanity 413")
Signed-off-by: Lai Siyao <lai.siyao@whamcloud.com>
Change-Id: I2807101ff632404e25fdb640840d83d1991c88d9
Reviewed-on: https://review.whamcloud.com/c/ex/lustre-release/+/52751
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
lustre/lod/lproc_lod.c
lustre/tests/sanity.sh

index 5c85c7e..de3d34c 100644 (file)
@@ -735,8 +735,8 @@ static ssize_t __qos_maxage_show(struct kobject *kobj, struct attribute *attr,
        struct lu_tgt_descs *ltd = is_mdt ? &lod->lod_mdt_descs :
                                            &lod->lod_ost_descs;
 
-       return snprintf(buf, PAGE_SIZE, "%u Sec\n",
-                      ltd->ltd_lov_desc.ld_qos_maxage);
+       return scnprintf(buf, PAGE_SIZE, "%u\n",
+                        ltd->ltd_lov_desc.ld_qos_maxage);
 }
 
 static ssize_t mdt_qos_maxage_show(struct kobject *kobj, struct attribute *attr,
index 9061581..1b7ce6c 100755 (executable)
@@ -26098,6 +26098,8 @@ run_test 412 "mkdir on specific MDTs"
 TEST413_COUNT=${TEST413_COUNT:-200}
 generate_uneven_mdts() {
        local threshold=$1
+       local lmv_qos_maxage
+       local lod_qos_maxage
        local ffree
        local bavail
        local max
@@ -26107,6 +26109,17 @@ generate_uneven_mdts() {
        local tmp
        local i
 
+       lmv_qos_maxage=$($LCTL get_param -n lmv.*.qos_maxage)
+       $LCTL set_param lmv.*.qos_maxage=1
+       stack_trap "$LCTL set_param \
+               lmv.*.qos_maxage=$lmv_qos_maxage > /dev/null" RETURN
+       lod_qos_maxage=$(do_facet mds1 $LCTL get_param -n \
+               lod.$FSNAME-MDT0000-mdtlov.qos_maxage | awk '{ print $1 }')
+       do_nodes $(comma_list $(mdts_nodes)) $LCTL set_param \
+               lod.*.mdt_qos_maxage=1
+       stack_trap "do_nodes $(comma_list $(mdts_nodes)) $LCTL set_param \
+               lod.*.mdt_qos_maxage=$lod_qos_maxage > /dev/null" RETURN
+
        echo
        echo "Check for uneven MDTs: "
 
@@ -26130,9 +26143,15 @@ generate_uneven_mdts() {
                fi
        done
 
+       (( ${ffree[min_index]} > 0 )) ||
+               skip "no free files in MDT$min_index"
+       (( ${ffree[min_index]} < 10000000 )) ||
+               skip "too many free files in MDT$min_index"
+
        # Check if we need to generate uneven MDTs
        local diff=$(((max - min) * 100 / min))
        local testdir=$DIR/$tdir-fillmdt
+       local start
 
        i=0
        while (( diff < threshold )); do
@@ -26153,6 +26172,9 @@ generate_uneven_mdts() {
                done
                sync; sleep 1; sync
 
+               # wait for QOS to update
+               (( SECONDS < start + 1 )) && sleep $((start + 1 - SECONDS))
+
                ffree=($(lctl get_param -n mdc.*[mM][dD][cC]-*.filesfree))
                bavail=($(lctl get_param -n mdc.*[mM][dD][cC]-*.kbytesavail))
                max=$(((${ffree[max_index]} >> 8) * \
@@ -26219,7 +26241,6 @@ test_qos_mkdir() {
        local stripe_index=$($LFS getstripe -m $testdir)
        local test_mkdir_rr=true
 
-       echo "dirstripe: '$($LFS getdirstripe $testdir)'"
        getfattr -d -m dmv -e hex $testdir | grep dmv
        if (( $? == 0 && $MDS1_VERSION >= $(version_code 2.14.0) )); then
                echo "defstripe: '$($LFS getdirstripe -D $testdir)'"
@@ -26296,7 +26317,7 @@ test_qos_mkdir() {
 
        (( ${ffree[min_index]} > 0 )) ||
                skip "no free files in MDT$min_index"
-       (( ${ffree[min_index]} < 100000000 )) ||
+       (( ${ffree[min_index]} < 10000000 )) ||
                skip "too many free files in MDT$min_index"
 
        echo "MDT filesfree available: ${ffree[@]}"
@@ -26324,32 +26345,33 @@ test_qos_mkdir() {
                        error "$mkdir_cmd subdir$i failed"
        done
 
+       max=0
        for (( i = 0; i < $MDSCOUNT; i++ )); do
                count=$($LFS getdirstripe -i $testdir/* | grep -c "^$i$")
+               (( count > max )) && max=$count
                echo "$count directories created on MDT$i"
-
-               if [ $stripe_count -gt 1 ]; then
-                       count=$($LFS getdirstripe $testdir/* |
-                               grep -c -P "^\s+$i\t")
-                       echo "$count stripes created on MDT$i"
-               fi
        done
 
-       max=$($LFS getdirstripe -i $testdir/* | grep -c "^$max_index$")
        min=$($LFS getdirstripe -i $testdir/* | grep -c "^$min_index$")
 
        # D-value should > 10% of averge
-       (( max - min >= num / 10 )) ||
+       (( max - min > num / 10 )) ||
                error "subdirs shouldn't be evenly distributed: $max - $min < $((num / 10))"
 
-       # 5% for stripes
+       # ditto for stripes
        if (( stripe_count > 1 )); then
-               max=$($LFS getdirstripe $testdir/* |
-                       grep -c -P "^\s+$max_index\t")
+               max=0
+               for (( i = 0; i < $MDSCOUNT; i++ )); do
+                       count=$($LFS getdirstripe $testdir/* |
+                               grep -c -P "^\s+$i\t")
+                       (( count > max )) && max=$count
+                       echo "$count stripes created on MDT$i"
+               done
+
                min=$($LFS getdirstripe $testdir/* |
                        grep -c -P "^\s+$min_index\t")
-               (( max - min >= num * stripe_count / 20 )) ||
-                       error "stripes shouldn't be evenly distributed: $max - $min < $((num / 20)) * $stripe_count"
+               (( max - min > num * stripe_count / 10 )) ||
+                       error "stripes shouldn't be evenly distributed: $max - $min < $((num / 10)) * $stripe_count"
        fi
 }