X-Git-Url: https://git.whamcloud.com/?a=blobdiff_plain;f=lustre%2Ftests%2Fsanity-quota.sh;h=210a5796332511ecc2c6186b1438b2b2c0c0aca2;hb=e5c8f6670fbeea9ec8c6092dfa4369508da54485;hp=9a360a0879b0209ab71bcaec212cb34331e7481a;hpb=e7d7cd40f7c371cf7d7e9b95bf58fbc14f5dae0e;p=fs%2Flustre-release.git diff --git a/lustre/tests/sanity-quota.sh b/lustre/tests/sanity-quota.sh index 9a360a08..210a579 100755 --- a/lustre/tests/sanity-quota.sh +++ b/lustre/tests/sanity-quota.sh @@ -558,6 +558,28 @@ test_1_check_write() { "user write success, but expect EDQUOT" } +check_write_fallocate() { + local testfile="$1" + local qtype="$2" + local limit=$3 + local short_qtype=${qtype:0:1} + + count=$((limit/2)) + log "Write ${count}MiB Using Fallocate" + $RUNAS fallocate -l${count}MiB $testfile || + quota_error $short_qtype $TSTUSR "Write ${count}MiB fail" + + cancel_lru_locks osc + sync; sync_all_data || true + sleep 2 + + count=$((limit + 1)) + log "Write ${count}MiB Using Fallocate" + $RUNAS fallocate -l${count}MiB $testfile && + quota_error $short_qtype $TSTUSR \ + "Write success, expect EDQUOT" || true +} + # test block hardlimit test_1a() { local limit=10 # 10M @@ -1000,8 +1022,8 @@ test_1f() { run_test 1f "Quota pools: correct qunit after removing/adding OST" test_1g() { - local limit=10 # 10M - local global_limit=20 # 20M + local limit=20 # 20M + local global_limit=40 # 40M local testfile="$DIR/$tdir/$tfile-0" local qpool="qpool1" local mdmb_param="osc.*.max_dirty_mb" @@ -1062,6 +1084,44 @@ test_1g() { } run_test 1g "Quota pools: Block hard limit with wide striping" +test_1h() { + local limit=10 # 10M + local testfile="$DIR/$tdir/$tfile-0" + + [ "$ost1_FSTYPE" != ldiskfs ] && skip "non-ldiskfs backend" + [ $OST1_VERSION -lt $(version_code 2.13.50) ] && + skip "Need OST version at least 2.13.53" + + setup_quota_test || error "setup quota failed with $?" + trap cleanup_quota_test EXIT + + # enable ost quota + set_ost_qtype $QTYPE || error "enable ost quota failed" + + # test for user + log "User quota (block hardlimit:$limit MB)" + $LFS setquota -u $TSTUSR -b 0 -B ${limit}M -i 0 -I 0 $DIR || + error "set user quota failed" + + # make sure the system is clean + local used=$(getquota -u $TSTUSR global curspace) + [ $used -ne 0 ] && error "Used space($used) for user $TSTUSR isn't 0." + + $LFS setstripe $testfile -c 1 || error "setstripe $testfile failed" + chown $TSTUSR.$TSTUSR $testfile || error "chown $testfile failed" + + check_write_fallocate $testfile "user" $limit + + rm -f $testfile + wait_delete_completed || error "wait_delete_completed failed" + sync_all_data || true + used=$(getquota -u $TSTUSR global curspace) + [ $used -ne 0 ] && quota_error u $TSTUSR \ + "user quota isn't released after deletion" + resetquota -u $TSTUSR +} +run_test 1h "Block hard limit test using fallocate" + # test inode hardlimit test_2() { local TESTFILE="$DIR/$tdir/$tfile-0" @@ -3466,6 +3526,85 @@ test_40c() { } run_test 40c "Remote child Dir inherit project quota properly" +test_40d() { + [ "$MDSCOUNT" -lt "2" ] && skip_env "needs >= 2 MDTs" + is_project_quota_supported || skip "Project quota is not supported" + + setup_quota_test || error "setup quota failed with $?" + local dir="$DIR/$tdir/dir" + + mkdir -p $dir + $LFS setdirstripe -D -c 2 -i -1 $dir || error "setdirstripe failed" + change_project -sp $TSTPRJID $dir || + error "change project on $dir failed" + for i in $(seq 5); do + mkdir -p $dir/d$i/d$i || + error "mkdir $dir/d$i/d$i failed" + local projid=$($LFS project -d $dir/d$i/d$i | + awk '{print $1}') + [ "$projid" == "$TSTPRJID" ] || + error "projid id expected $TSTPRJID not $projid" + touch $dir/d$i/d$i/file + #verify inherit works file for stripe dir. + local projid=$($LFS project -d $dir/d$i/d$i/file | awk '{print $1}') + [ "$projid" == "$TSTPRJID" ] || + error "file under remote dir expected 1 not $projid" + done + + # account should be 1 + (2 + 1) *10 + 1 * 5 + USED=$(getquota -p $TSTPRJID global curinodes) + [ "$USED" == "36" ] || + error "file count expected 36 got $USED" + + rm -rf $dir + cleanup_quota_test +} +run_test 40d "Stripe Directory inherit project quota properly" + +test_41() { + is_project_quota_supported || + skip "Project quota is not supported" + setup_quota_test || error "setup quota failed with $?" + trap cleanup_quota_test EXIT + local dir="$DIR/$tdir/dir" + local blimit=102400 + local ilimit=4096 + local projid=$((testnum * 1000)) + + quota_init + + # enable mdt/ost quota + set_mdt_qtype ugp || error "enable mdt quota failed" + set_ost_qtype ugp || error "enable ost quota failed" + + test_mkdir -p $dir && change_project -sp $projid $dir + $LFS setquota -p $projid -b 0 -B ${blimit}K -i 0 -I $ilimit $dir || + error "set project quota failed" + + sync; sync_all_data + sleep_maxage + + # check if df output works as expected + echo "== global statfs: $MOUNT ==" + df -kP $MOUNT; df -iP $MOUNT; $LFS quota -p $projid $dir + echo + echo "== project statfs (prjid=$projid): $dir ==" + df -kP $dir; df -iP $dir + local bused=$(getquota -p $projid global curspace) + local iused=$(getquota -p $projid global curinodes) + # note trailing space to match double printf from awk + local expected="$blimit $bused $ilimit $iused " + + wait_update $HOSTNAME \ + "{ df -kP $dir; df -iP $dir; } | + awk '/$FSNAME/ { printf \\\"%d %d \\\", \\\$2,\\\$3 }'" \ + "$expected" || + error "failed to get correct statfs for project quota" + + cleanup_quota_test +} +run_test 41 "df should return projid-specific values" + test_50() { ! is_project_quota_supported && skip "Project quota is not supported"