From: Sergey Cheremencev Date: Mon, 5 Apr 2021 12:27:34 +0000 (+0300) Subject: LU-14631 quota: fix qunit sort X-Git-Tag: 2.14.52~55 X-Git-Url: https://git.whamcloud.com/?a=commitdiff_plain;h=9d3ce2985efc315529bf5faf6f3b970cd9949107;p=fs%2Flustre-release.git LU-14631 quota: fix qunit sort Fix lqes_cmp that is used to sort lqes by qunit. As lqes_cmp returns integer, it returns incorrects values if difference between qunits is grater than 4GB causing write to hang instead of fail with -EDQUOT: [] cl_sync_io_wait+0x295/0x3c0 [obdclass] [] cl_io_submit_sync+0x1c8/0x360 [obdclass] [] vvp_io_commit_sync+0x12a/0x460 [lustre] [] vvp_io_write_commit+0x4de/0x620 [lustre] [] vvp_io_write_start+0x309/0x990 [lustre] [] cl_io_start+0x68/0x130 [obdclass] [] cl_io_loop+0xcc/0x1c0 [obdclass] [] ll_file_io_generic+0x5c4/0xdc0 [lustre] [] ll_file_aio_write+0x289/0x730 [lustre] [] ll_file_write+0x100/0x1c0 [lustre] [] vfs_write+0xc0/0x1f0 [] SyS_write+0x7f/0xf0 The issue is occurred if a user hits block hard limit in a pool (pools limit 6GB), while global limit is set to some huge value(53T in my case) Change global limit in sanity-quota_1e to check that system doesn't hung anymore. HPE-bug-id: LUS-9891 Change-Id: I5a16fd3a40172187bbf35d9a9c9bfeef2ef3a108 Signed-off-by: Sergey Cheremencev Reviewed-by: Shaun Tancheff Tested-by: Jenkins Build User Reviewed-by: Alexander Boyko Reviewed-on: https://review.whamcloud.com/43410 Reviewed-by: Andreas Dilger Tested-by: jenkins Reviewed-by: Alexander Boyko Tested-by: Maloo Reviewed-by: Oleg Drokin --- diff --git a/lustre/quota/qmt_pool.c b/lustre/quota/qmt_pool.c index af0709c..87207c2 100644 --- a/lustre/quota/qmt_pool.c +++ b/lustre/quota/qmt_pool.c @@ -845,9 +845,14 @@ out: static int lqes_cmp(const void *arg1, const void *arg2) { const struct lquota_entry *lqe1, *lqe2; + lqe1 = *(const struct lquota_entry **)arg1; lqe2 = *(const struct lquota_entry **)arg2; - return lqe1->lqe_qunit - lqe2->lqe_qunit; + if (lqe1->lqe_qunit > lqe2->lqe_qunit) + return 1; + if (lqe1->lqe_qunit < lqe2->lqe_qunit) + return -1; + return 0; } void qmt_lqes_sort(const struct lu_env *env) diff --git a/lustre/tests/sanity-quota.sh b/lustre/tests/sanity-quota.sh index f876f20..773c04c 100755 --- a/lustre/tests/sanity-quota.sh +++ b/lustre/tests/sanity-quota.sh @@ -524,7 +524,7 @@ test_quota_performance() { # test basic quota performance b=21696 test_0() { - local MB=100 # 100M + local MB=100 # MB [ "$SLOW" = "no" ] && MB=10 local free_space=$(lfs_df | grep "summary" | awk '{print $4}') @@ -596,7 +596,7 @@ check_write_fallocate() { # test block hardlimit test_1a() { - local limit=10 # 10M + local limit=10 # MB local testfile="$DIR/$tdir/$tfile-0" setup_quota_test || error "setup quota failed with $?" @@ -686,8 +686,8 @@ test_1a() { run_test 1a "Block hard limit (normal use and out of quota)" test_1b() { - local limit=10 # 10M - local global_limit=20 # 100M + local limit=10 # MB + local global_limit=20 # MB local testfile="$DIR/$tdir/$tfile-0" local qpool="qpool1" @@ -795,7 +795,7 @@ test_1b() { run_test 1b "Quota pools: Block hard limit (normal use and out of quota)" test_1c() { - local global_limit=20 # 100M + local global_limit=20 # MB local testfile="$DIR/$tdir/$tfile-0" local qpool1="qpool1" local qpool2="qpool2" @@ -857,9 +857,9 @@ test_1c() { run_test 1c "Quota pools: check 3 pools with hardlimit only for global" test_1d() { - local limit1=10 # 10M - local limit2=12 # 12M - local global_limit=20 # 100M + local limit1=10 # MB + local limit2=12 # MB + local global_limit=20 # MB local testfile="$DIR/$tdir/$tfile-0" local qpool1="qpool1" local qpool2="qpool2" @@ -919,8 +919,8 @@ test_1d() { run_test 1d "Quota pools: check block hardlimit on different pools" test_1e() { - local limit1=10 # 10M - local global_limit=200 # 200M + local limit1=10 # MB + local global_limit=53000000 # MB local testfile="$DIR/$tdir/$tfile-0" local testfile2="$DIR/$tdir/$tfile-1" local qpool1="qpool1" @@ -981,8 +981,8 @@ test_1e() { run_test 1e "Quota pools: global pool high block limit vs quota pool with small" test_1f() { - local global_limit=200 # 200M - local limit1=10 # 10M + local global_limit=200 # MB + local limit1=10 # MB local TESTDIR="$DIR/$tdir/" local testfile="$TESTDIR/$tfile-0" local qpool1="qpool1" @@ -1036,8 +1036,8 @@ test_1f() { run_test 1f "Quota pools: correct qunit after removing/adding OST" test_1g() { - local limit=20 # 20M - local global_limit=40 # 40M + local limit=20 # MB + local global_limit=40 # MB local testfile="$DIR/$tdir/$tfile-0" local qpool="qpool1" local mdmb_param="osc.*.max_dirty_mb" @@ -1099,7 +1099,7 @@ test_1g() { run_test 1g "Quota pools: Block hard limit with wide striping" test_1h() { - local limit=10 # 10M + local limit=10 # MB local testfile="$DIR/$tdir/$tfile-0" check_set_fallocate_or_skip @@ -1345,7 +1345,7 @@ test_block_soft() { # block soft limit test_3a() { - local grace=20 # 20s + local grace=20 # seconds if [ $(facet_fstype $SINGLEMDS) = "zfs" ]; then grace=60 fi @@ -1412,7 +1412,7 @@ test_3a() { run_test 3a "Block soft limit (start timer, timer goes off, stop timer)" test_3b() { - local grace=20 # 20s + local grace=20 # seconds local qpool="qpool1" if [ $(facet_fstype $SINGLEMDS) = "zfs" ]; then grace=60 @@ -1511,7 +1511,7 @@ test_3b() { run_test 3b "Quota pools: Block soft limit (start timer, expires, stop timer)" test_3c() { - local grace=20 # 20s + local grace=20 # seconds local qpool="qpool1" local qpool2="qpool2" if [ $(facet_fstype $SINGLEMDS) = "zfs" ]; then @@ -1745,8 +1745,8 @@ run_test 4b "Grace time strings handling" # chown & chgrp (chown & chgrp successfully even out of block/file quota) test_5() { - local BLIMIT=10 # 10M - local ILIMIT=10 # 10 inodes + local BLIMIT=10 # MB + local ILIMIT=10 # inodes setup_quota_test || error "setup quota failed with $?" trap cleanup_quota_test EXIT @@ -1807,7 +1807,7 @@ run_test 5 "Chown & chgrp successfully even out of block/file quota" # test dropping acquire request on master test_6() { - local LIMIT=3 # 3M + local LIMIT=3 # MB # Clear dmesg so watchdog is not triggered by previous # test output @@ -1919,7 +1919,7 @@ run_test 6 "Test dropping acquire request on master" # quota reintegration (global index) test_7a() { local TESTFILE=$DIR/$tdir/$tfile - local LIMIT=20 # 20M + local LIMIT=20 # MB [ "$SLOW" = "no" ] && LIMIT=5 @@ -1990,7 +1990,7 @@ run_test 7a "Quota reintegration (global index)" # quota reintegration (slave index) test_7b() { - local LIMIT="100G" + local limit=100000 # MB local TESTFILE=$DIR/$tdir/$tfile setup_quota_test || error "setup quota failed with $?" @@ -2023,7 +2023,7 @@ test_7b() { lustre_fail mds 0xa02 set_ost_qtype $QTYPE || error "enable ost quota failed" - $LFS setquota -u $TSTUSR -b 0 -B $LIMIT -i 0 -I 0 $DIR || + $LFS setquota -u $TSTUSR -b 0 -B ${limit}M -i 0 -I 0 $DIR || error "set quota failed" # ignore the write error @@ -2050,7 +2050,7 @@ run_test 7b "Quota reintegration (slave index)" # quota reintegration (restart mds during reintegration) test_7c() { - local LIMIT=20 # 20M + local LIMIT=20 # MB local TESTFILE=$DIR/$tdir/$tfile [ "$SLOW" = "no" ] && LIMIT=5 @@ -2103,7 +2103,7 @@ run_test 7c "Quota reintegration (restart mds during reintegration)" test_7d(){ local TESTFILE=$DIR/$tdir/$tfile local TESTFILE1="$DIR/$tdir/$tfile"-1 - local limit=20 #20M + local limit=20 # MB setup_quota_test || error "setup quota failed with $?" trap cleanup_quota_test EXIT @@ -2150,7 +2150,7 @@ test_7e() { skip "requires zpool with active userobj_accounting" } - local ilimit=$((1024 * 2)) # 2k inodes + local ilimit=$((1024 * 2)) # inodes local TESTFILE=$DIR/${tdir}-1/$tfile setup_quota_test || error "setup quota failed with $?" @@ -2375,7 +2375,7 @@ run_test 11 "Chown/chgrp ignores quota" test_12a() { [ "$OSTCOUNT" -lt "2" ] && skip "needs >= 2 OSTs" - local blimit=22 # 22M + local blimit=22 # MB local blk_cnt=$((blimit - 5)) local TESTFILE0="$DIR/$tdir/$tfile"-0 local TESTFILE1="$DIR/$tdir/$tfile"-1 @@ -2386,7 +2386,7 @@ test_12a() { set_ost_qtype "u" || error "enable ost quota failed" quota_show_check b u $TSTUSR - $LFS setquota -u $TSTUSR -b 0 -B "$blimit"M -i 0 -I 0 $DIR || + $LFS setquota -u $TSTUSR -b 0 -B ${blimit}M -i 0 -I 0 $DIR || error "set quota failed" $LFS setstripe $TESTFILE0 -c 1 -i 0 || error "setstripe $TESTFILE0 failed" @@ -2418,7 +2418,7 @@ run_test 12a "Block quota rebalancing" test_12b() { [ "$MDSCOUNT" -lt "2" ] && skip "needs >= 2 MDTs" - local ilimit=$((1024 * 2)) # 2k inodes + local ilimit=$((1024 * 2)) # inodes local TESTFILE0=$DIR/$tdir/$tfile local TESTFILE1=$DIR/${tdir}-1/$tfile @@ -2611,7 +2611,7 @@ run_test 17 "DQACQ return recoverable error" test_18_sub () { local io_type=$1 - local blimit="200m" # 200M + local blimit=200 # MB local TESTFILE="$DIR/$tdir/$tfile" setup_quota_test || error "setup quota failed with $?" @@ -2619,7 +2619,7 @@ test_18_sub () { set_ost_qtype "u" || error "enable ost quota failed" log "User quota (limit: $blimit)" - $LFS setquota -u $TSTUSR -b 0 -B $blimit -i 0 -I 0 $MOUNT || + $LFS setquota -u $TSTUSR -b 0 -B ${blimit}M -i 0 -I 0 $MOUNT || error "set quota failed" quota_show_check b u $TSTUSR @@ -2690,7 +2690,7 @@ test_18() { run_test 18 "MDS failover while writing, no watchdog triggered (b14840)" test_19() { - local blimit=5 # 5M + local blimit=5 # MB local TESTFILE=$DIR/$tdir/$tfile setup_quota_test || error "setup quota failed with $?" @@ -2703,11 +2703,11 @@ test_19() { chown $TSTUSR.$TSTUSR $TESTFILE || error "chown $TESTFILE failed" echo "Set user quota (limit: ${blimit}M)" - $LFS setquota -u $TSTUSR -b 0 -B "$blimit"M -i 0 -I 0 $MOUNT || + $LFS setquota -u $TSTUSR -b 0 -B ${blimit}M -i 0 -I 0 $MOUNT || error "set user quota failed" quota_show_check b u $TSTUSR echo "Update quota limits" - $LFS setquota -u $TSTUSR -b 0 -B "$blimit"M -i 0 -I 0 $MOUNT || + $LFS setquota -u $TSTUSR -b 0 -B ${blimit}M -i 0 -I 0 $MOUNT || error "set group quota failed" quota_show_check b u $TSTUSR @@ -2942,7 +2942,7 @@ test_23() { run_test 23 "Quota should be honored with directIO (b16125)" test_24() { - local blimit=5 # 5M + local blimit=5 # MB local TESTFILE="$DIR/$tdir/$tfile" setup_quota_test || error "setup quota failed with $?" @@ -3045,7 +3045,7 @@ test_27d() { run_test 27d "lfs setquota should support fraction block limit" test_30() { - local LIMIT=4 # 4MB + local LIMIT=4 # MB local TESTFILE="$DIR/$tdir/$tfile" local GRACE=10 @@ -3083,8 +3083,8 @@ run_test 30 "Hard limit updates should not reset grace times" # basic usage tracking for user & group test_33() { - local INODES=10 # 10 files - local BLK_CNT=2 # of 2M each + local INODES=10 # files + local BLK_CNT=2 # MB each local TOTAL_BLKS=$((INODES * BLK_CNT * 1024)) setup_quota_test || error "setup quota failed with $?" @@ -3168,7 +3168,7 @@ run_test 33 "Basic usage tracking for user & group & project" # usage transfer test for user & group & project test_34() { - local BLK_CNT=2 # 2MB + local BLK_CNT=2 # MB local project_supported="no" is_project_quota_supported && project_supported="yes" @@ -3260,7 +3260,7 @@ run_test 34 "Usage transfer for user & group & project" # usage is still accessible across restart test_35() { - local BLK_CNT=2 # 2 MB + local BLK_CNT=2 # MB setup_quota_test || error "setup quota failed with $?" trap cleanup_quota_test EXIT @@ -4236,7 +4236,7 @@ test_64() { run_test 64 "lfs project on symlink files should fail" test_65() { - local SIZE=10 #10M + local SIZE=10 # MB local TESTFILE="$DIR/$tdir/$tfile-0" setup_quota_test || error "setup quota failed with $?" @@ -4350,7 +4350,7 @@ getgranted() { } test_67() { - local limit=20 # 20M + local limit=20 # MB local testfile="$DIR/$tdir/$tfile-0" local testfile2="$DIR/$tdir/$tfile-1" local testfile3="$DIR/$tdir/$tfile-2" @@ -4534,8 +4534,8 @@ run_test 68 "slave number in quota pool changed after each add/remove OST" test_69() { - local global_limit=200 # 200M - local limit=10 # 10M + local global_limit=200 # MB + local limit=10 # MB local testfile="$DIR/$tdir/$tfile-0" local dom0="$DIR/$tdir/dom0" local qpool="qpool1" @@ -4598,7 +4598,7 @@ run_test 69 "EDQUOT at one of pools shouldn't affect DOM" test_70() { local qpool="qpool1" - local limit=20 + local limit=20 # MB local err=0 local bhard @@ -4637,8 +4637,8 @@ run_test 70 "check lfs setquota/quota with a pool option" test_71a() { - local limit=10 # 10M - local global_limit=100 # 100M + local limit=10 # MB + local global_limit=100 # MB local testfile="$DIR/$tdir/$tfile-0" local qpool="qpool1" local qpool2="qpool2" @@ -4721,9 +4721,9 @@ run_test 71a "Check PFL with quota pools" test_71b() { - local global_limit=1000 # 1G - local limit1=160 # 160M - local limit2=10 # 10M + local global_limit=1000 # MB + local limit1=160 # MB + local limit2=10 # MB local testfile="$DIR/$tdir/$tfile-0" local qpool="qpool1" local qpool2="qpool2" @@ -4788,8 +4788,8 @@ run_test 71b "Check SEL with quota pools" test_72() { - local limit=10 # 10M - local global_limit=50 # 50M + local limit=10 # MB + local global_limit=50 # MB local testfile="$DIR/$tdir/$tfile-0" local qpool="qpool1"