Whamcloud - gitweb
LU-14299 test: sleep to enable quota acquire again
[fs/lustre-release.git] / lustre / tests / sanity-quota.sh
index 43eafd8..365a424 100755 (executable)
@@ -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
@@ -671,7 +693,7 @@ test_1b() {
        pool_add_targets $qpool 0 $(($OSTCOUNT - 1)) ||
                error "pool_add_targets failed"
 
-       $LFS setquota -u $TSTUSR -B ${limit}M -o $qpool $DIR ||
+       $LFS setquota -u $TSTUSR -B ${limit}M --pool $qpool $DIR ||
                error "set user quota failed"
 
        # make sure the system is clean
@@ -700,7 +722,7 @@ test_1b() {
        $LFS setquota -g $TSTUSR -b 0 -B ${global_limit}M -i 0 -I 0 $DIR ||
                error "set group quota failed"
 
-       $LFS setquota -g $TSTUSR -b 0 -B ${limit}M -o $qpool $DIR ||
+       $LFS setquota -g $TSTUSR -b 0 -B ${limit}M --pool $qpool $DIR ||
                error "set group quota failed"
 
        testfile="$DIR/$tdir/$tfile-1"
@@ -739,7 +761,7 @@ test_1b() {
        $LFS setquota -p $TSTPRJID -b 0 -B ${global_limit}M -i 0 -I 0 $DIR ||
                error "set project quota failed"
 
-       $LFS setquota -p $TSTPRJID -b 0 -B ${limit}M -o $qpool $DIR ||
+       $LFS setquota -p $TSTPRJID -b 0 -B ${limit}M --pool $qpool $DIR ||
                error "set project quota failed"
 
 
@@ -786,10 +808,10 @@ test_1c() {
 
        # create pools without hard limit
        # initially such case raised several bugs
-       $LFS setquota -u $TSTUSR -B 0M -o $qpool1 $DIR ||
+       $LFS setquota -u $TSTUSR -B 0M --pool $qpool1 $DIR ||
                error "set user quota failed"
 
-       $LFS setquota -u $TSTUSR -B 0M -o $qpool2 $DIR ||
+       $LFS setquota -u $TSTUSR -B 0M --pool $qpool2 $DIR ||
                error "set user quota failed"
 
        # make sure the system is clean
@@ -848,10 +870,10 @@ test_1d() {
        pool_add_targets $qpool2 0 $(($OSTCOUNT - 1)) ||
                error "pool_add_targets failed"
 
-       $LFS setquota -u $TSTUSR -B ${limit1}M -o $qpool1 $DIR ||
+       $LFS setquota -u $TSTUSR -B ${limit1}M --pool $qpool1 $DIR ||
                error "set user quota failed"
 
-       $LFS setquota -u $TSTUSR -B ${limit2}M -o $qpool2 $DIR ||
+       $LFS setquota -u $TSTUSR -B ${limit2}M --pool $qpool2 $DIR ||
        error "set user quota failed"
 
        # make sure the system is clean
@@ -908,7 +930,7 @@ test_1e() {
        pool_add_targets $qpool1 1 1 ||
                error "pool_add_targets failed"
 
-       $LFS setquota -u $TSTUSR -B ${limit1}M -o $qpool1 $DIR ||
+       $LFS setquota -u $TSTUSR -B ${limit1}M --pool $qpool1 $DIR ||
                error "set user quota failed"
 
        # make sure the system is clean
@@ -926,7 +948,7 @@ test_1e() {
        # Now write to file with a stripe on OST0, that doesn't belong to qpool1
        log "Write..."
        $RUNAS $DD of=$testfile2 count=20 ||
-               quota_error $short_qtype $TSTUSR \
+               quota_error u $TSTUSR \
                        "$qtype write failure, but expect success"
 
        rm -f $testfile
@@ -966,7 +988,7 @@ test_1f() {
        pool_add_targets $qpool1 0 0 ||
                error "pool_add_targets failed"
 
-       $LFS setquota -u $TSTUSR -B ${limit1}M -o $qpool1 $DIR ||
+       $LFS setquota -u $TSTUSR -B ${limit1}M --pool $qpool1 $DIR ||
                error "set user quota failed"
 
        # make sure the system is clean
@@ -999,6 +1021,105 @@ 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 testfile="$DIR/$tdir/$tfile-0"
+       local qpool="qpool1"
+       local mdmb_param="osc.*.max_dirty_mb"
+       local max_dirty_mb=$($LCTL get_param -n $mdmb_param | head -1)
+
+       mds_supports_qp
+       setup_quota_test || error "setup quota failed with $?"
+       stack_trap cleanup_quota_test EXIT
+       $LCTL set_param $mdmb_param=1
+       stack_trap "$LCTL set_param $mdmb_param=$max_dirty_mb" EXIT
+
+       # enable ost quota
+       set_ost_qtype $QTYPE || error "enable ost quota failed"
+
+       # test for user
+       log "User quota (block hardlimit:$global_limit MB)"
+       $LFS setquota -u $TSTUSR -b 0 -B ${global_limit}M -i 0 -I 0 $DIR ||
+               error "set user quota failed"
+
+       pool_add $qpool || error "pool_add failed"
+       pool_add_targets $qpool 0 $(($OSTCOUNT - 1)) ||
+               error "pool_add_targets failed"
+
+       $LFS setquota -u $TSTUSR -B ${limit}M --pool $qpool $DIR ||
+               error "set user quota failed"
+
+       # make sure the system is clean
+       local used=$(getquota -u $TSTUSR global curspace)
+       echo "used $used"
+       [ $used -ne 0 ] && error "Used space($used) for user $TSTUSR isn't 0."
+
+       $LFS setstripe $testfile -C 200 || error "setstripe $testfile failed"
+       chown $TSTUSR.$TSTUSR $testfile || error "chown $testfile failed"
+
+       log "Write..."
+       $RUNAS $DD of=$testfile count=$((limit/2)) ||
+               quota_error u $TSTUSR \
+                       "$qtype write failure, but expect success"
+       log "Write out of block quota ..."
+       # this time maybe cache write,  ignore it's failure
+       $RUNAS $DD of=$testfile count=$((limit/2)) seek=$((limit/2)) || true
+       # flush cache, ensure noquota flag is set on client
+       cancel_lru_locks osc
+       sync; sync_all_data || true
+       sleep 5
+       $RUNAS $DD of=$testfile count=$OSTCOUNT seek=$limit &&
+               quota_error u $TSTUSR \
+                       "user write success, but expect EDQUOT"
+
+       rm -f $testfile
+       wait_delete_completed || error "wait_delete_completed failed"
+       sync_all_data || true
+
+       used=$(getquota -u $TSTUSR global curspace $qpool)
+       [ $used -ne 0 ] && quota_error u $TSTUSR \
+               "user quota isn't released after deletion"
+       return 0
+}
+run_test 1g "Quota pools: Block hard limit with wide striping"
+
+test_1h() {
+       local limit=10  # 10M
+       local testfile="$DIR/$tdir/$tfile-0"
+
+       check_set_fallocate_or_skip
+
+       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"
@@ -1302,11 +1423,11 @@ test_3b() {
        $LFS setquota -t -u --block-grace $glbl_grace --inode-grace \
                $MAX_IQ_TIME $DIR || error "set user grace time failed"
        $LFS setquota -t -u --block-grace $grace \
-               -o $qpool $DIR || error "set user grace time failed"
+               --pool $qpool $DIR || error "set user grace time failed"
 
        $LFS setquota -u $TSTUSR -b ${glbl_limit}M -B 0 -i 0 -I 0 $DIR ||
                error "set user quota failed"
-       $LFS setquota -u $TSTUSR -b ${limit}M -B 0 -o $qpool $DIR ||
+       $LFS setquota -u $TSTUSR -b ${limit}M -B 0 --pool $qpool $DIR ||
                error "set user quota failed"
 
        test_block_soft $testfile $grace $limit "u" $qpool
@@ -1320,11 +1441,11 @@ test_3b() {
        $LFS setquota -t -g --block-grace $glbl_grace --inode-grace \
                $MAX_IQ_TIME $DIR || error "set group grace time failed"
        $LFS setquota -t -g --block-grace $grace \
-               -o $qpool $DIR || error "set group grace time failed"
+               --pool $qpool $DIR || error "set group grace time failed"
 
        $LFS setquota -g $TSTUSR -b ${glbl_limit}M -B 0 -i 0 -I 0 $DIR ||
                error "set group quota failed"
-       $LFS setquota -g $TSTUSR -b ${limit}M -B 0 -o $qpool $DIR ||
+       $LFS setquota -g $TSTUSR -b ${limit}M -B 0 --pool $qpool $DIR ||
                error "set group quota failed"
 
        test_block_soft $testfile $grace $limit "g" $qpool
@@ -1341,31 +1462,32 @@ test_3b() {
                        $MAX_IQ_TIME $DIR ||
                                error "set project grace time failed"
                $LFS setquota -t -p --block-grace $grace \
-                       -o $qpool $DIR || error "set project grace time failed"
+                       --pool $qpool $DIR ||
+                               error "set project grace time failed"
 
                $LFS setquota -p $TSTPRJID -b ${glbl_limit}M -B 0 -i 0 -I 0 \
                        $DIR || error "set project quota failed"
-               $LFS setquota -p $TSTPRJID -b ${limit}M -B 0 -o $qpool $DIR ||
-                       error "set project quota failed"
+               $LFS setquota -p $TSTPRJID -b ${limit}M -B 0 \
+                       --pool $qpool $DIR || error "set project quota failed"
 
                test_block_soft $testfile $grace $limit "p" $qpool
                resetquota -p $TSTPRJID
                $LFS setquota -t -p --block-grace $MAX_DQ_TIME --inode-grace \
                        $MAX_IQ_TIME $DIR ||
                                error "restore project grace time failed"
-               $LFS setquota -t -p --block-grace $MAX_DQ_TIME -o $qpool $DIR ||
-                       error "set project grace time failed"
+               $LFS setquota -t -p --block-grace $MAX_DQ_TIME --pool $qpool \
+                       $DIR || error "set project grace time failed"
        fi
 
        # cleanup
        $LFS setquota -t -u --block-grace $MAX_DQ_TIME --inode-grace \
                $MAX_IQ_TIME $DIR || error "restore user grace time failed"
        $LFS setquota -t -u --block-grace $MAX_DQ_TIME \
-               -o $qpool $DIR || error "restore user grace time failed"
+               --pool $qpool $DIR || error "restore user grace time failed"
        $LFS setquota -t -g --block-grace $MAX_DQ_TIME --inode-grace \
                $MAX_IQ_TIME $DIR || error "restore group grace time failed"
        $LFS setquota -t -g --block-grace $MAX_DQ_TIME \
-               -o $qpool $DIR || error "restore group grace time failed"
+               --pool $qpool $DIR || error "restore group grace time failed"
 }
 run_test 3b "Quota pools: Block soft limit (start timer, expires, stop timer)"
 
@@ -1409,19 +1531,19 @@ test_3c() {
        $LFS setquota -t -u --block-grace $glbl_grace --inode-grace \
                $MAX_IQ_TIME $DIR || error "set user grace time failed"
        $LFS setquota -t -u --block-grace $grace1 \
-               -o $qpool $DIR || error "set user grace time failed"
+               --pool $qpool $DIR || error "set user grace time failed"
        $LFS setquota -t -u --block-grace $grace2 \
-               -o $qpool2 $DIR || error "set user grace time failed"
+               --pool $qpool2 $DIR || error "set user grace time failed"
 
        $LFS setquota -u $TSTUSR -b ${glbl_limit}M -B 0 -i 0 -I 0 $DIR ||
                error "set user quota failed"
-       $LFS setquota -u $TSTUSR -b ${limit}M -B 0 -o $qpool $DIR ||
+       $LFS setquota -u $TSTUSR -b ${limit}M -B 0 --pool $qpool $DIR ||
                error "set user quota failed"
        # qpool has minimum soft limit, but it's grace is grater than
        # grace period of qpool2. Thus write shouldn't fail when
        # hit qpool soft limit - only when reaches up qpool2 limit
        # after grace2 seconds.
-       $LFS setquota -u $TSTUSR -b ${limit2}M -B 0 -o $qpool2 $DIR ||
+       $LFS setquota -u $TSTUSR -b ${limit2}M -B 0 --pool $qpool2 $DIR ||
                error "set user quota failed"
 
        test_block_soft $testfile $grace2 $limit2 "u" $qpool2
@@ -1430,9 +1552,9 @@ test_3c() {
        $LFS setquota -t -u --block-grace $MAX_DQ_TIME --inode-grace \
                $MAX_IQ_TIME $DIR || error "restore user grace time failed"
        $LFS setquota -t -u --block-grace $MAX_DQ_TIME \
-               -o $qpool $DIR || error "restore user grace time failed"
+               --pool $qpool $DIR || error "restore user grace time failed"
        $LFS setquota -t -u --block-grace $MAX_DQ_TIME \
-               -o $qpool2 $DIR || error "restore user grace time failed"
+               --pool $qpool2 $DIR || error "restore user grace time failed"
 }
 run_test 3c "Quota pools: check block soft limit on different pools"
 
@@ -1441,6 +1563,8 @@ test_file_soft() {
        local LIMIT=$2
        local grace=$3
        local qtype=$4
+       local SOFT_LIMIT=$(do_facet $SINGLEMDS $LCTL get_param -n \
+               qmt.$FSNAME-QMT0000.md-0x0.soft_least_qunit)
 
        setup_quota_test
        trap cleanup_quota_test EXIT
@@ -1473,12 +1597,8 @@ test_file_soft() {
        $SHOW_QUOTA_INFO_PROJID
 
        echo "Create file after timer goes off"
-       # There is a window that space is accounted in the quota usage but
-       # hasn't been decreased from the pending write, if we acquire quota
-       # in this window, we'll acquire more than we needed.
-       $RUNAS touch ${TESTFILE}_after_1 ${TESTFILE}_after_2 || true
-       sync_all_data || true
-       $RUNAS touch ${TESTFILE}_after_3 &&
+       # exceed least soft limit is possible
+       $RUNAS createmany -m ${TESTFILE}_after_3 $((SOFT_LIMIT + 1)) &&
                quota_error a $TSTUSR "create after timer expired," \
                        "but expect EDQUOT"
        sync_all_data || true
@@ -3402,6 +3522,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"
@@ -3781,6 +3980,10 @@ test_default_quota() {
        fi
 
        log "Increase default quota"
+
+       # LU-4505: sleep 5 seconds to enable quota acquire
+       sleep 5
+
        # increase default quota
        $LFS setquota $qdtype $qs $((LIMIT*3)) $qh $((LIMIT*3)) $DIR ||
                error "set default quota failed"
@@ -3816,6 +4019,10 @@ test_default_quota() {
        fi
 
        log "Set to use default quota again"
+
+       # LU-4505: sleep 5 seconds to enable quota acquire
+       sleep 5
+
        $LFS setquota $qtype $qid -d $DIR ||
                error "set $qid to use default quota failed"
 
@@ -4337,7 +4544,7 @@ test_69()
                error "set user quota failed"
 
        log "User quota (block hardlimit:$limit MB)"
-       $LFS setquota -u $TSTUSR -B ${limit}M -o $qpool $DIR ||
+       $LFS setquota -u $TSTUSR -B ${limit}M --pool $qpool $DIR ||
                error "set user quota failed"
 
        $RUNAS dd if=/dev/zero of="$dom0/f1" bs=1K count=512 oflag=sync ||
@@ -4389,7 +4596,7 @@ test_70()
        pool_add $qpool || error "pool_add failed"
        pool_add_targets $qpool 0 0 || error "pool_add_targets failed"
 
-       $LFS setquota -u $TSTUSR -B ${limit}M -o $qpool $DIR
+       $LFS setquota -u $TSTUSR -B ${limit}M --pool $qpool $DIR
        rc=$?
        [ $rc -eq $err ] || error "setquota res $rc != $err"
 
@@ -4409,6 +4616,204 @@ test_70()
 }
 run_test 70 "check lfs setquota/quota with a pool option"
 
+test_71a()
+{
+       local limit=10  # 10M
+       local global_limit=100  # 100M
+       local testfile="$DIR/$tdir/$tfile-0"
+       local qpool="qpool1"
+       local qpool2="qpool2"
+
+       [ "$ost1_FSTYPE" == zfs ] &&
+               skip "ZFS grants some block space together with inode"
+       [[ $OSTCOUNT -lt 2 ]] && skip "need >= 2 OSTs"
+       mds_supports_qp
+       setup_quota_test || error "setup quota failed with $?"
+       stack_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:$global_limit MB)"
+       $LFS setquota -u $TSTUSR -b 0 -B ${global_limit}M -i 0 -I 0 $DIR ||
+               error "set user quota failed"
+
+       pool_add $qpool || error "pool_add failed"
+       pool_add_targets $qpool 0 1 ||
+               error "pool_add_targets failed"
+
+       $LFS setquota -u $TSTUSR -B ${limit}M --pool $qpool $DIR ||
+               error "set user quota failed"
+
+       pool_add $qpool2 || error "pool_add failed"
+       pool_add_targets $qpool2 1 1 ||
+               error "pool_add_targets failed"
+
+       $LFS setquota -u $TSTUSR -B ${limit}M --pool $qpool2 $DIR ||
+               error "set user quota failed"
+
+       # make sure the system is clean
+       local used=$(getquota -u $TSTUSR global curspace)
+
+       echo "used $used"
+       [ $used -ne 0 ] && error "Used space($used) for user $TSTUSR isn't 0."
+
+       # create 1st component 1-10M
+       $LFS setstripe -E 10M -S 1M -c 1 -i 0 $testfile
+       #create 2nd component 10-30M
+       $LFS setstripe --component-add -E 30M -c 1 -i 1 $testfile
+       chown $TSTUSR.$TSTUSR $testfile || error "chown $testfile failed"
+
+       # сheck normal use and out of quota with PFL
+       # 1st element is in qppol1(OST0), 2nd in qpool2(OST2).
+       test_1_check_write $testfile "user" $((limit*2))
+       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"
+
+       # create 1st component 1-10M
+       $LFS setstripe -E 10M -S 1M -c 1 -i 0 $testfile
+       # create 2nd component 10-30M
+       $LFS setstripe --component-add -E 30M -c 1 -i 1 $testfile
+       chown $TSTUSR.$TSTUSR $testfile || error "chown $testfile failed"
+
+       # write to the 2nd component
+       $RUNAS $DD of=$testfile count=$limit seek=10 ||
+               quota_error u $TSTUSR \
+                       "write failure, but expect success"
+       # this time maybe cache write,  ignore it's failure
+       $RUNAS $DD of=$testfile count=$((2*limit)) seek=10 || true
+       cancel_lru_locks osc
+       sync; sync_all_data || true
+       # write over limit in qpool2(2nd component 10-30M)
+       $RUNAS $DD of=$testfile count=1 seek=$((10 + 2*limit)) &&
+               quota_error u $TSTUSR "user write success, but expect EDQUOT"
+       # write to the 1st component - OST0 is empty
+       $RUNAS $DD of=$testfile count=$limit seek=0 ||
+               quota_error u $TSTUSR "write failed"
+
+       cleanup_quota_test
+}
+run_test 71a "Check PFL with quota pools"
+
+test_71b()
+{
+       local global_limit=1000 # 1G
+       local limit1=160 # 160M
+       local limit2=10 # 10M
+       local testfile="$DIR/$tdir/$tfile-0"
+       local qpool="qpool1"
+       local qpool2="qpool2"
+
+       [ "$ost1_FSTYPE" == zfs ] &&
+               skip "ZFS grants some block space together with inode"
+       [[ $OSTCOUNT -lt 2 ]] && skip "need >= 2 OSTs" && return
+       mds_supports_qp
+       setup_quota_test || error "setup quota failed with $?"
+       stack_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:$global_limit MB)"
+       $LFS setquota -u $TSTUSR -b 0 -B ${global_limit}M -i 0 -I 0 $DIR ||
+               error "set user quota failed"
+
+       pool_add $qpool || error "pool_add failed"
+       pool_add_targets $qpool 0 1 ||
+               error "pool_add_targets failed"
+
+       $LFS setquota -u $TSTUSR -B ${limit1}M --pool $qpool $DIR ||
+               error "set user quota failed"
+
+       pool_add $qpool2 || error "pool_add failed"
+       pool_add_targets $qpool2 1 1 ||
+               error "pool_add_targets failed"
+
+       $LFS setquota -u $TSTUSR -B ${limit2}M --pool $qpool2 $DIR ||
+               error "set user quota failed"
+
+       # make sure the system is clean
+       local used=$(getquota -u $TSTUSR global curspace)
+
+       echo "used $used"
+       [ $used -ne 0 ] && error "Used space($used) for user $TSTUSR isn't 0."
+
+       # First component is on OST0, 2nd on OST1
+       $LFS setstripe -E 128M -i 0 -z 64M -E -1 -i 1 -z 64M $testfile
+       chown $TSTUSR.$TSTUSR $testfile || error "chown $testfile failed"
+
+       # fill the 1st component on OST0
+       $RUNAS $DD of=$testfile count=128 ||
+               quota_error u $TSTUSR "write failed"
+       # write to the 2nd cmpnt on OST1
+       $RUNAS $DD of=$testfile count=$((limit2/2)) seek=128 ||
+               quota_error u $TSTUSR "write failed"
+       # this time maybe cache write,  ignore it's failure
+       $RUNAS $DD of=$testfile count=$((limit2/2)) seek=$((128 + limit2/2)) ||
+               true
+       cancel_lru_locks osc
+       sync; sync_all_data || true
+       # write over limit in qpool2
+       $RUNAS $DD of=$testfile count=2 seek=$((128 + limit2)) &&
+               quota_error u $TSTUSR "user write success, but expect EDQUOT"
+
+       cleanup_quota_test
+}
+run_test 71b "Check SEL with quota pools"
+
+test_72()
+{
+       local limit=10  # 10M
+       local global_limit=50  # 50M
+       local testfile="$DIR/$tdir/$tfile-0"
+       local qpool="qpool1"
+
+       mds_supports_qp
+       setup_quota_test || error "setup quota failed with $?"
+       stack_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:$global_limit MB)"
+       $LFS setquota -u $TSTUSR -b 0 -B ${global_limit}M -i 0 -I 0 $DIR ||
+               error "set user quota failed"
+
+       pool_add $qpool || error "pool_add failed"
+       pool_add_targets $qpool 1 1 || error "pool_add_targets failed"
+
+       $LFS setquota -u $TSTUSR -B ${limit}M --pool $qpool $DIR ||
+               error "set user quota failed"
+
+       # make sure the system is clean
+       local used=$(getquota -u $TSTUSR global curspace)
+       echo "used $used"
+       [ $used -ne 0 ] && error "Used space($used) for user $TSTUSR isn't 0."
+
+       used=$(getquota -u $TSTUSR global bhardlimit $qpool)
+
+       $LFS setstripe $testfile -c 1 -i 1 || error "setstripe $testfile failed"
+       chown $TSTUSR.$TSTUSR $testfile || error "chown $testfile failed"
+       test_1_check_write $testfile "user" $limit
+       used=$(getquota -u $TSTUSR global bhardlimit $qpool)
+       echo "used $used"
+       [ $used -ge $limit ] || error "used($used) is less than limit($limit)"
+       # check that lfs quota -uv --pool prints only OST that
+       # was added in a pool
+       lfs quota -v -u quota_usr --pool $qpool $DIR | grep -v "OST0001" |
+               grep "OST\|MDT" && error "$qpool consists wrong targets"
+
+       cleanup_quota_test
+}
+run_test 72 "lfs quota --pool prints only pool's OSTs"
+
 quota_fini()
 {
        do_nodes $(comma_list $(nodes_list)) "lctl set_param debug=-quota"