From: Nathaniel Clark Date: Thu, 1 Aug 2019 15:36:59 +0000 (-0400) Subject: LU-12100 tests: Use minimum soft qunit limits X-Git-Tag: 2.12.58~61 X-Git-Url: https://git.whamcloud.com/?p=fs%2Flustre-release.git;a=commitdiff_plain;h=37e28b7e05a5b1f77fe663f9407436aea312b3b2 LU-12100 tests: Use minimum soft qunit limits Ensure that we don't create limits that are too small, which would cause all writes to fail. Wait for grace period to timeout. Test-Parameters: trivial Test-Parameters: testlist=sanity-quota Test-Parameters: testlist=sanity-quota fstype=zfs Signed-off-by: Nathaniel Clark Change-Id: I9342272615ca9c252fcc7f77ed8a61030fc9672a Reviewed-on: https://review.whamcloud.com/35667 Tested-by: jenkins Tested-by: Maloo Reviewed-by: Jian Yu Reviewed-by: Wang Shilong Reviewed-by: Oleg Drokin --- diff --git a/lustre/tests/sanity-quota.sh b/lustre/tests/sanity-quota.sh index c0ac7c3..3ac7b51 100755 --- a/lustre/tests/sanity-quota.sh +++ b/lustre/tests/sanity-quota.sh @@ -321,6 +321,44 @@ wait_ost_reint() { return 0 } +wait_grace_time() { + local qtype=$1 + local flavour=$2 + local extrasleep=${3:-5} + local qarg + + case $qtype in + u|g) qarg=$TSTUSR ;; + p) qarg=$TSTPRJID ;; + *) error "get_grace_time: Invalid quota type: $qtype" + esac + + case $flavour in + block) + time=$(lfs quota -$qtype $qarg $DIR| + awk 'NR == 3{ print $5 }'| sed 's/s$//') + ;; + file) + time=$(lfs quota -$qtype $qarg $DIR| + awk 'NR == 3{ print $9 }'| sed 's/s$//') + ;; + *) + error "Unknown quota type: $flavour" + ;; + esac + + echo "Sleep through grace ..." + [ "$time" == "-" ] && + error "Grace timeout was not set or quota not exceeded" + if [ "$time" == "none" ]; then + echo "...Grace timeout already expired" + else + let time+=$extrasleep + echo "...sleep $time seconds" + sleep $time + fi +} + setup_quota_test() { wait_delete_completed echo "Creating test directory" @@ -677,7 +715,7 @@ run_test 2 "File hard limit (normal use and out of quota)" test_block_soft() { local TESTFILE=$1 - local TIMER=$(($2 * 3 / 2)) + local GRACE=$2 local LIMIT=$3 local OFFSET=0 local qtype=$4 @@ -715,8 +753,7 @@ test_block_soft() { OFFSET=$((OFFSET + 1024)) cancel_lru_locks osc - echo "Sleep $TIMER seconds ..." - sleep $TIMER + wait_grace_time $qtype "block" $SHOW_QUOTA_USER $SHOW_QUOTA_GROUP @@ -765,10 +802,16 @@ test_block_soft() { # block soft limit test_3() { - local LIMIT=1 # 1MB local GRACE=20 # 20s + if [ $(facet_fstype $SINGLEMDS) = "zfs" ]; then + GRACE=60 + fi local TESTFILE=$DIR/$tdir/$tfile-0 + # get minimum soft qunit size + local LIMIT=$(( $(do_facet $SINGLEMDS $LCTL get_param -n \ + qmt.$FSNAME-QMT0000.dt-0x0.soft_least_qunit) / 1024 )) + set_ost_qtype $QTYPE || error "enable ost quota failed" echo "User quota (soft limit:$LIMIT MB grace:$GRACE seconds)" @@ -829,7 +872,7 @@ test_file_soft() { local TESTFILE=$1 local LIMIT=$2 local grace=$3 - local TIMER=$(($grace * 3 / 2)) + local qtype=$4 setup_quota_test trap cleanup_quota_test EXIT @@ -852,8 +895,7 @@ test_file_soft() { "but expect success. $trigger_time, $cur_time" sync_all_data || true - echo "Sleep $TIMER seconds ..." - sleep $TIMER + wait_grace_time $qtype "file" $SHOW_QUOTA_USER $SHOW_QUOTA_GROUP @@ -896,7 +938,8 @@ test_file_soft() { # file soft limit test_4a() { - local LIMIT=10 # inodes + local LIMIT=$(do_facet $SINGLEMDS $LCTL get_param -n \ + qmt.$FSNAME-QMT0000.md-0x0.soft_least_qunit) local TESTFILE=$DIR/$tdir/$tfile-0 local GRACE=12 @@ -914,7 +957,7 @@ test_4a() { [ $(facet_fstype $SINGLEMDS) = "zfs" ] && GRACE=20 - test_file_soft $TESTFILE $LIMIT $GRACE + test_file_soft $TESTFILE $LIMIT $GRACE "u" echo "Group quota (soft limit:$LIMIT files grace:$GRACE seconds)" # make sure the system is clean @@ -927,7 +970,7 @@ test_4a() { error "set group quota failed" TESTFILE=$DIR/$tdir/$tfile-1 - test_file_soft $TESTFILE $LIMIT $GRACE + test_file_soft $TESTFILE $LIMIT $GRACE "g" if is_project_quota_supported; then echo "Project quota (soft limit:$LIMIT files grace:$GRACE sec)" @@ -943,7 +986,7 @@ test_4a() { TESTFILE=$DIR/$tdir/$tfile-1 # one less than limit, because of parent directory included. - test_file_soft $TESTFILE $((LIMIT-1)) $GRACE + test_file_soft $TESTFILE $((LIMIT-1)) $GRACE "p" resetquota -p $TSTPRJID $LFS setquota -t -p --block-grace $MAX_DQ_TIME --inode-grace \ $MAX_IQ_TIME $DIR ||