Whamcloud - gitweb
LU-5152 quota: disable sync chgrp to OSTs
[fs/lustre-release.git] / lustre / tests / sanity-quota.sh
index 0fe27bb..86c54fe 100755 (executable)
@@ -10,8 +10,8 @@ SRCDIR=$(dirname $0)
 export PATH=$PWD/$SRCDIR:$SRCDIR:$PWD/$SRCDIR/../utils:$PATH:/sbin
 
 ONLY=${ONLY:-"$*"}
-# Bug number for skipped test:
-ALWAYS_EXCEPT="$SANITY_QUOTA_EXCEPT"
+# Bug number for skipped test:      LU-5152
+ALWAYS_EXCEPT="$SANITY_QUOTA_EXCEPT 55"
 # UPDATE THE COMMENT ABOVE WITH BUG NUMBERS WHEN CHANGING ALWAYS_EXCEPT!
 
 [ "$ALWAYS_EXCEPT$EXCEPT" ] &&
@@ -47,17 +47,17 @@ if [ $(facet_fstype $SINGLEMDS) == ldiskfs ] &&
        skip_env "e2fsprogs doesn't support quota" && exit 0
 fi
 
+# Test duration:                   30 min
+[ "$SLOW" = "no" ] && EXCEPT_SLOW="61"
+
 if [ $(facet_fstype $SINGLEMDS) = "zfs" ]; then
-# bug number for skipped test:        LU-2836 LU-6836 LU-2836
-       ALWAYS_EXCEPT="$ALWAYS_EXCEPT 3       4a      6"
-# bug number for skipped test:        LU-5638
-       ALWAYS_EXCEPT="$ALWAYS_EXCEPT 11 33"
-# bug number:     LU-2887
-       #         21  9   (min)"
-       ZFS_SLOW="12a 9"
-fi
+       # bug number for skipped test: LU-6836
+       ALWAYS_EXCEPT="$ALWAYS_EXCEPT  4a"
 
-[ "$SLOW" = "no" ] && EXCEPT_SLOW="$ZFS_SLOW"
+       # bug number:                        LU-2887
+       # Test duration:                     21      9 min"
+       [ "$SLOW" = "no" ] && EXCEPT_SLOW+=" 12a     9"
+fi
 
 QUOTALOG=${TESTSUITELOG:-$TMP/$(basename $0 .sh).log}
 
@@ -128,11 +128,6 @@ DD="dd if=/dev/zero bs=1M"
 
 FAIL_ON_ERROR=false
 
-check_runas_id_ret $TSTUSR $TSTUSR $RUNAS ||
-       error "Please create user $TSTUSR($TSTID) and group $TSTUSR($TSTID)"
-check_runas_id_ret $TSTUSR2 $TSTUSR2 $RUNAS2 ||
-       error "Please create user $TSTUSR2($TSTID2) and group $TSTUSR2($TSTID2)"
-
 # clear quota limits for a user or a group
 # usage: resetquota -u username
 #        resetquota -g groupname
@@ -235,7 +230,13 @@ set_mdt_qtype() {
        local cmd
        [[ "$qtype" =~ "p" ]] && ! is_project_quota_supported &&
                qtype=$(tr -d 'p' <<<$qtype)
-       do_facet mgs $LCTL conf_param $FSNAME.quota.mdt=$qtype
+
+       if [[ $PERM_CMD = *"set_param -P"* ]]; then
+               do_facet mgs $PERM_CMD \
+                       osd-*.$FSNAME-MDT*.quota_slave.enable=$qtype
+       else
+               do_facet mgs $PERM_CMD $FSNAME.quota.mdt=$qtype
+       fi
        # we have to make sure each MDT received config changes
        for mdt in ${mdts//,/ }; do
                varsvc=${mdt}_svc
@@ -259,7 +260,13 @@ set_ost_qtype() {
        local cmd
        [[ "$qtype" =~ "p" ]] && ! is_project_quota_supported &&
                qtype=$(tr -d 'p' <<<$qtype)
-       do_facet mgs $LCTL conf_param $FSNAME.quota.ost=$qtype
+
+       if [[ $PERM_CMD = *"set_param -P"* ]]; then
+               do_facet mgs $PERM_CMD \
+                       osd-*.$FSNAME-OST*.quota_slave.enable=$qtype
+       else
+               do_facet mgs $PERM_CMD $FSNAME.quota.ost=$qtype
+       fi
        # we have to make sure each OST received config changes
        for ost in ${osts//,/ }; do
                varsvc=${ost}_svc
@@ -431,17 +438,25 @@ enable_project_quota() {
 }
 enable_project_quota
 
+reset_quota_settings() {
+       resetquota -u $TSTUSR
+       resetquota -g $TSTUSR
+       resetquota -u $TSTUSR2
+       resetquota -g $TSTUSR2
+       resetquota -p $TSTPRJID
+}
+
 # enable quota debug
 quota_init() {
        do_nodes $(comma_list $(nodes_list)) "lctl set_param debug=+quota"
 }
 quota_init
+reset_quota_settings
 
-resetquota -u $TSTUSR
-resetquota -g $TSTUSR
-resetquota -u $TSTUSR2
-resetquota -g $TSTUSR2
-resetquota -p $TSTPRJID
+check_runas_id_ret $TSTUSR $TSTUSR $RUNAS ||
+       error "Please create user $TSTUSR($TSTID) and group $TSTUSR($TSTID)"
+check_runas_id_ret $TSTUSR2 $TSTUSR2 $RUNAS2 ||
+       error "Please create user $TSTUSR2($TSTID2) and group $TSTUSR2($TSTID2)"
 
 test_quota_performance() {
        local TESTFILE="$DIR/$tdir/$tfile-0"
@@ -473,7 +488,7 @@ test_0() {
        local free_space=$(lfs_df | grep "summary" | awk '{print $4}')
        [ $free_space -le $((MB * 1024)) ] &&
                skip "not enough space ${free_space} KB, " \
-                       "required $((MB * 1024)) KB" && return
+                       "required $((MB * 1024)) KB"
        setup_quota_test || error "setup quota failed with $?"
        trap cleanup_quota_test EXIT
 
@@ -619,8 +634,7 @@ test_2() {
        local FREE_INODES=$(mdt_free_inodes 0)
        echo "$FREE_INODES free inodes on master MDT"
        [ $FREE_INODES -lt $LIMIT ] &&
-               skip "not enough free inodes $FREE_INODES required $LIMIT" &&
-               return
+               skip "not enough free inodes $FREE_INODES required $LIMIT"
 
        setup_quota_test || error "setup quota failed with $?"
        trap cleanup_quota_test EXIT
@@ -1422,7 +1436,7 @@ run_test 7d "Quota reintegration (Transfer index in multiple bulks)"
 
 # quota reintegration (inode limits)
 test_7e() {
-       [ "$MDSCOUNT" -lt "2" ] && skip "needs >= 2 MDTs" && return
+       [ "$MDSCOUNT" -lt "2" ] && skip "needs >= 2 MDTs"
 
        # LU-2435: skip this quota test if underlying zfs version has not
        # supported native dnode accounting
@@ -1432,8 +1446,7 @@ test_7e() {
                local feature=$(do_facet mds1 $ZPOOL get -H $F $pool)
 
                [[ "$feature" != *" active "* ]] &&
-                       skip "requires zpool with active userobj_accounting" &&
-                       return
+                       skip "requires zpool with active userobj_accounting"
        }
 
        local ilimit=$((1024 * 2)) # 2k inodes
@@ -1667,7 +1680,7 @@ test_11() {
 run_test 11 "Chown/chgrp ignores quota"
 
 test_12a() {
-       [ "$OSTCOUNT" -lt "2" ] && skip "needs >= 2 OSTs" && return
+       [ "$OSTCOUNT" -lt "2" ] && skip "needs >= 2 OSTs"
 
        local blimit=22 # 22M
        local blk_cnt=$((blimit - 5))
@@ -1711,7 +1724,7 @@ test_12a() {
 run_test 12a "Block quota rebalancing"
 
 test_12b() {
-       [ "$MDSCOUNT" -lt "2" ] && skip "needs >= 2 MDTs" && return
+       [ "$MDSCOUNT" -lt "2" ] && skip "needs >= 2 MDTs"
 
        local ilimit=$((1024 * 2)) # 2k inodes
        local TESTFILE0=$DIR/$tdir/$tfile
@@ -2156,7 +2169,7 @@ test_22() {
 
        echo "Verify if quota is enabled"
        local qtype1=$(mdt_quota_type)
-       [ $qtype1 != $qtype] && error "mdt quota setting is lost"
+       [ $qtype1 != $qtype ] && error "mdt quota setting is lost"
        qtype=$(ost_quota_type)
        [ $qtype1 != $qtype ] && error "ost quota setting is lost"
 
@@ -2178,7 +2191,7 @@ test_22() {
 
        return 0
 }
-run_test 22 "enable/disable quota by 'lctl conf_param'"
+run_test 22 "enable/disable quota by 'lctl conf_param/set_param -P'"
 
 test_23_sub() {
        local TESTFILE="$DIR/$tdir/$tfile"
@@ -2230,7 +2243,7 @@ test_23_sub() {
 test_23() {
        [ $(facet_fstype ost1) == "zfs" ] &&
                skip "Overwrite in place is not guaranteed to be " \
-               "space neutral on ZFS" && return
+               "space neutral on ZFS"
 
        local OST0_MIN=$((6 * 1024)) # 6MB, extra space for meta blocks.
        check_whether_skip && return 0
@@ -2672,7 +2685,7 @@ run_test 35 "Usage is still accessible across reboot"
 # LU-5006
 test_37() {
        [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.6.93) ] &&
-               skip "Old server doesn't have LU-5006 fix." && return
+               skip "Old server doesn't have LU-5006 fix."
 
        setup_quota_test || error "setup quota failed with $?"
        trap cleanup_quota_test EXIT
@@ -2704,7 +2717,7 @@ run_test 37 "Quota accounted properly for file created by 'lfs setstripe'"
 # LU-8801
 test_38() {
        [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.8.60) ] &&
-               skip "Old server doesn't have LU-8801 fix." && return
+               skip "Old server doesn't have LU-8801 fix."
 
        [ "$UID" != 0 ] && skip_env "must run as root" && return
 
@@ -2752,7 +2765,7 @@ run_test 38 "Quota accounting iterator doesn't skip id entries"
 test_39() {
        local TESTFILE="$DIR/$tdir/project"
        ! is_project_quota_supported &&
-               skip "Project quota is not supported" && return 0
+               skip "Project quota is not supported"
 
        setup_quota_test || error "setup quota failed with $?"
 
@@ -2778,7 +2791,7 @@ run_test 39 "Project ID interface works correctly"
 
 test_40a() {
        ! is_project_quota_supported &&
-               skip "Project quota is not supported" && return 0
+               skip "Project quota is not supported"
        local dir1="$DIR/$tdir/dir1"
        local dir2="$DIR/$tdir/dir2"
 
@@ -2798,7 +2811,7 @@ run_test 40a "Hard link across different project ID"
 
 test_40b() {
        ! is_project_quota_supported &&
-               skip "Project quota is not supported" && return 0
+               skip "Project quota is not supported"
        local dir1="$DIR/$tdir/dir1"
        local dir2="$DIR/$tdir/dir2"
 
@@ -2818,9 +2831,9 @@ test_40b() {
 run_test 40b "Mv across different project ID"
 
 test_40c() {
-       [ "$MDSCOUNT" -lt "2" ] && skip "needs >= 2 MDTs" && return
+       [ "$MDSCOUNT" -lt "2" ] && skip "needs >= 2 MDTs"
                ! is_project_quota_supported &&
-                       skip "Project quota is not supported" && return 0
+                       skip "Project quota is not supported"
 
        setup_quota_test || error "setup quota failed with $?"
        local dir="$DIR/$tdir/dir"
@@ -2848,7 +2861,7 @@ run_test 40c "Remote child Dir inherit project quota properly"
 
 test_50() {
        ! is_project_quota_supported &&
-               skip "Project quota is not supported" && return 0
+               skip "Project quota is not supported"
 
        setup_quota_test || error "setup quota failed with $?"
        local dir="$DIR/$tdir/dir"
@@ -2864,7 +2877,7 @@ run_test 50 "Test if lfs find --projid works"
 
 test_51() {
        ! is_project_quota_supported &&
-               skip "Project quota is not supported" && return 0
+               skip "Project quota is not supported"
        setup_quota_test || error "setup quota failed with $?"
        local dir="$DIR/$tdir/dir"
 
@@ -2896,7 +2909,7 @@ run_test 51 "Test project accounting with mv/cp"
 
 test_52() {
        ! is_project_quota_supported &&
-               skip "Project quota is not supported" && return 0
+               skip "Project quota is not supported"
        setup_quota_test || error "setup quota failed with $?"
        local dir="$DIR/$tdir/dir"
        mkdir $dir && change_project -sp 1 $dir
@@ -2914,7 +2927,7 @@ run_test 52 "Rename across different project ID"
 
 test_53() {
        ! is_project_quota_supported &&
-               skip "Project quota is not supported" && return 0
+               skip "Project quota is not supported"
        setup_quota_test || error "setup quota failed with $?"
        local dir="$DIR/$tdir/dir"
        mkdir $dir && change_project -s $dir
@@ -2931,7 +2944,7 @@ run_test 53 "Project inherit attribute could be cleared"
 
 test_54() {
        ! is_project_quota_supported &&
-               skip "Project quota is not supported" && return 0
+               skip "Project quota is not supported"
        setup_quota_test || error "setup quota failed with $?"
        trap cleanup_quota_test EXIT
        local testfile="$DIR/$tdir/$tfile-0"
@@ -2985,7 +2998,7 @@ run_test 54 "basic lfs project interface test"
 
 test_55() {
        [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.10.58) ] &&
-               skip "Not supported before 2.10.58." && return
+               skip "Not supported before 2.10.58."
        setup_quota_test || error "setup quota failed with $?"
 
        set_ost_qtype $QTYPE || error "enable ost quota failed"
@@ -3022,11 +3035,12 @@ test_55() {
 
        $LFS quota -v -g $TSTUSR2 $DIR
 
+       resetquota -g $TSTUSR2
        cleanup_quota_test
 }
 run_test 55 "Chgrp should be affected by group quota"
 
-test_56 () {
+test_56() {
        setup_quota_test || error "setup quota failed with $?"
 
        set_ost_qtype $QTYPE || error "enable ost quota failed"
@@ -3045,11 +3059,30 @@ test_56 () {
 }
 run_test 56 "lfs quota -t should work well"
 
+test_57() {
+       setup_quota_test || error "setup quota failed with $?"
+
+       local dir="$DIR/$tdir/dir"
+       mkdir -p $dir
+       mkfifo $dir/pipe
+       #try to change pipe file should not hang and return failure
+       wait_update_facet client "$LFS project -sp 1 $dir/pipe 2>&1 |
+               awk -F ':' '{ print \\\$2 }'" \
+                       " failed to get xattr for '$dir/pipe'" || return 1
+       #command can process further if it hit some errors
+       touch $dir/aaa $dir/bbb
+       #create one invalid link file
+       ln -s $dir/not_exist_file $dir/ccc
+       local cnt=$(lfs project -r $dir 2>/dev/null | wc -l)
+       [ $cnt -eq 2 ] || error "expected 2 got $cnt"
+
+       cleanup_quota_test
+}
+run_test 57 "lfs project could tolerate errors"
+
 test_59() {
-       if [ $(facet_fstype $SINGLEMDS) != ldiskfs ]; then
+       [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
                skip "ldiskfs only test"
-               return
-       fi
        disable_project_quota
        setup_quota_test || error "setup quota failed with $?"
        quota_init
@@ -3063,11 +3096,348 @@ test_59() {
 }
 run_test 59 "lfs project dosen't crash kernel with project disabled"
 
+test_60() {
+       setup_quota_test || error "setup quota failed with $?"
+       trap cleanup_quota_test EXIT
+       local testfile=$DIR/$tdir/$tfile
+       local limit=100
+
+       set_mdt_qtype "ug" || error "enable mdt quota failed"
+
+       $LFS setquota -g $TSTUSR -b 0 -B 0 -i 0 -I $limit $DIR ||
+               error "set quota failed"
+       quota_show_check a g $TSTUSR
+
+       chown $TSTUSR.$TSTUSR $DIR/$tdir || error "chown $DIR/$tdir failed"
+       chmod g+s $DIR/$tdir || error "chmod g+s failed"
+       $RUNAS createmany -m ${testfile} $((limit-1)) ||
+               error "create many files failed"
+
+       $RUNAS touch $DIR/$tdir/foo && error "regular user should fail"
+
+       # root user can overrun quota
+       runas -u 0 -g 0 touch $DIR/$tdir/foo ||
+               error "root user should succeed"
+
+       cleanup_quota_test
+       resetquota -g $TSTUSR
+}
+run_test 60 "Test quota for root with setgid"
+
+# test default quota
+test_default_quota() {
+       [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.11.51) ] &&
+               skip "Not supported before 2.11.51."
+
+       local qtype=$1
+       local qpool=$2
+       local qid=$TSTUSR
+       local qprjid=$TSTPRJID
+       local qdtype="-U"
+       local qs="-b"
+       local qh="-B"
+       local LIMIT=20480 #20M disk space
+       local TESTFILE="$DIR/$tdir/$tfile-0"
+
+       [ $qtype == "-p" ] && ! is_project_quota_supported &&
+               echo "Project quota is not supported" && return 0
+
+       [ $qtype == "-u" ] && qdtype="-U"
+       [ $qtype == "-g" ] && qdtype="-G"
+       [ $qtype == "-p" ] && {
+               qdtype="-P"
+               qid=$qprjid
+       }
+
+       [ $qpool == "meta" ] && {
+               LIMIT=10240 #10K inodes
+               qs="-i"
+               qh="-I"
+       }
+
+       setup_quota_test || error "setup quota failed with $?"
+       trap cleanup_quota_test EXIT
+
+       quota_init
+
+       # enable mdt/ost quota
+       set_mdt_qtype $QTYPE || error "enable mdt quota failed"
+       set_ost_qtype $QTYPE || error "enable ost quota failed"
+
+       log "set to use default quota"
+       $LFS setquota $qtype $qid -d $DIR ||
+               error "set $qid to use default quota failed"
+
+       log "set default quota"
+       $LFS setquota $qdtype $qs ${LIMIT} $qh ${LIMIT} $DIR ||
+               error "set $qid default quota failed"
+
+       log "get default quota"
+       $LFS quota $qdtype $DIR || error "get default quota failed"
+
+       if [ $qpool == "data" ]; then
+               local SLIMIT=$($LFS quota $qdtype $DIR | grep "$MOUNT" | \
+                                                       awk '{print $2}')
+               [ $SLIMIT -eq $LIMIT ] ||
+                       error "the returned default quota is wrong"
+       else
+               local SLIMIT=$($LFS quota $qdtype $DIR | grep "$MOUNT" | \
+                                                       awk '{print $5}')
+               [ $SLIMIT -eq $LIMIT ] ||
+                       error "the returned default quota is wrong"
+       fi
+
+       # make sure the system is clean
+       local USED=$(getquota $qtype $qid global curspace)
+       [ $USED -ne 0 ] && error "Used space for $qid isn't 0."
+
+       $SETSTRIPE $TESTFILE -c 1 || error "setstripe $TESTFILE failed"
+       chown $TSTUSR.$TSTUSR $TESTFILE || error "chown $TESTFILE failed"
+
+       [ $qtype == "-p" ] && change_project -sp $TSTPRJID $DIR/$tdir
+
+       log "Test not out of quota"
+       if [ $qpool == "data" ]; then
+               $RUNAS $DD of=$TESTFILE count=$((LIMIT/2 >> 10)) oflag=sync ||
+                       quota_error $qtype $qid "write failed, expect succeed"
+       else
+               $RUNAS createmany -m $TESTFILE $((LIMIT/2)) ||
+                       quota_error $qtype $qid "create failed, expect succeed"
+
+               unlinkmany $TESTFILE $((LIMIT/2))
+       fi
+
+       log "Test out of quota"
+       # flush cache, ensure noquota flag is set on client
+       cancel_lru_locks osc
+       cancel_lru_locks mdc
+       sync; sync_all_data || true
+       if [ $qpool == "data" ]; then
+               $RUNAS $DD of=$TESTFILE count=$((LIMIT*2 >> 10)) oflag=sync &&
+                       quota_error $qtype $qid "write succeed, expect EDQUOT"
+       else
+               $RUNAS createmany -m $TESTFILE $((LIMIT*2)) &&
+                       quota_error $qtype $qid "create succeed, expect EDQUOT"
+
+               unlinkmany $TESTFILE $((LIMIT*2))
+       fi
+
+       log "Increase default quota"
+       # increase default quota
+       $LFS setquota $qdtype $qs $((LIMIT*3)) $qh $((LIMIT*3)) $DIR ||
+               error "set default quota failed"
+
+       cancel_lru_locks osc
+       cancel_lru_locks mdc
+       sync; sync_all_data || true
+       if [ $qpool == "data" ]; then
+               $RUNAS $DD of=$TESTFILE count=$((LIMIT*2 >> 10)) oflag=sync ||
+                       quota_error $qtype $qid "write failed, expect succeed"
+       else
+               $RUNAS createmany -m $TESTFILE $((LIMIT*2)) ||
+                       quota_error $qtype $qid "create failed, expect succeed"
+
+               unlinkmany $TESTFILE $((LIMIT*2))
+       fi
+
+       log "Set quota to override default quota"
+       $LFS setquota $qtype $qid $qs ${LIMIT} $qh ${LIMIT} $DIR ||
+               error "set $qid quota failed"
+
+       cancel_lru_locks osc
+       cancel_lru_locks mdc
+       sync; sync_all_data || true
+       if [ $qpool == "data" ]; then
+               $RUNAS $DD of=$TESTFILE count=$((LIMIT*2 >> 10)) oflag=sync &&
+                       quota_error $qtype $qid "write succeed, expect EQUOT"
+       else
+               $RUNAS createmany -m $TESTFILE $((LIMIT*2)) &&
+                       quota_error $qtype $qid "create succeed, expect EQUOT"
+
+               unlinkmany $TESTFILE $((LIMIT*2))
+       fi
+
+       log "Set to use default quota again"
+       $LFS setquota $qtype $qid -d $DIR ||
+               error "set $qid to use default quota failed"
+
+       cancel_lru_locks osc
+       cancel_lru_locks mdc
+       sync; sync_all_data || true
+       if [ $qpool == "data" ]; then
+               $RUNAS $DD of=$TESTFILE count=$((LIMIT*2 >> 10)) oflag=sync ||
+                       quota_error $qtype $qid "write failed, expect succeed"
+       else
+               $RUNAS createmany -m $TESTFILE $((LIMIT*2)) ||
+                       quota_error $qtype $qid "create failed, expect succeed"
+
+               unlinkmany $TESTFILE $((LIMIT*2))
+       fi
+
+       log "Cleanup"
+       rm -f $TESTFILE
+       wait_delete_completed || error "wait_delete_completed failed"
+       sync_all_data || true
+       $LFS setquota $qdtype -b 0 -B 0 -i 0 -I 0 $DIR ||
+               error "reset default quota failed"
+       $LFS setquota $qtype $qid -b 0 -B 0 -i 0 -I 0 $DIR ||
+               error "reset quota failed"
+
+       cleanup_quota_test
+}
+
+test_61() {
+       test_default_quota "-u" "data"
+       test_default_quota "-u" "meta"
+       test_default_quota "-g" "data"
+       test_default_quota "-g" "meta"
+       test_default_quota "-p" "data"
+       test_default_quota "-p" "meta"
+}
+run_test 61 "default quota tests"
+
+test_62() {
+       ! is_project_quota_supported &&
+               skip "Project quota is not supported"
+        [[ "$(chattr -h 2>&1)" =~ "project" ]] ||
+               skip "chattr did not support project quota"
+       setup_quota_test || error "setup quota failed with $?"
+       local testdir=$DIR/$tdir/
+
+       $RUNAS mkdir -p $testdir || error "failed to mkdir"
+       change_project -s $testdir
+       [[ $($LFS project -d $testdir) =~ "P" ]] ||
+               error "inherit attribute should be set"
+       # chattr used FS_IOC_SETFLAGS ioctl
+       $RUNAS chattr -P $testdir &&
+               error "regular user clear inherit should fail"
+       [[ $($LFS project -d $testdir) =~ "P" ]] ||
+               error "inherit attribute should still be set"
+       chattr -P $testdir || error "root failed to clear inherit"
+       [[ $($LFS project -d $testdir) =~ "P" ]] &&
+               error "inherit attribute should be cleared"
+       cleanup_quota_test
+}
+run_test 62 "Project inherit should be only changed by root"
+
+test_dom() {
+       [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.11.55) ] &&
+               skip "Not supported before 2.11.55" && return
+
+       local qtype=$1
+       local qid=$TSTUSR
+       local dd_failed=false
+       local tdir_dom=${tdir}_dom
+       local LIMIT=20480 #20M
+
+       [ $qtype == "p" ] && ! is_project_quota_supported &&
+               echo "Project quota is not supported" && return 0
+
+       [ $qtype == "p" ] && qid=$TSTPRJID
+
+       setup_quota_test || error "setup quota failed with $?"
+       trap cleanup_quota_test EXIT
+
+       quota_init
+
+       # enable mdt/ost quota
+       set_mdt_qtype $QTYPE || error "enable mdt quota failed"
+       set_ost_qtype $QTYPE || error "enable ost quota failed"
+
+       # make sure the system is clean
+       local USED=$(getquota -$qtype $qid global curspace)
+       [ $USED -ne 0 ] && error "Used space for $qid isn't 0."
+
+       chown $TSTUSR.$TSTUSR $DIR/$tdir || error "chown $tdir failed"
+
+       mkdir $DIR/$tdir_dom || error "mkdir $tdir_dom failed"
+       $SETSTRIPE -E 1M -L mdt $DIR/$tdir_dom ||
+               error "setstripe $tdir_dom failed"
+       chown $TSTUSR.$TSTUSR $DIR/$tdir_dom || error "chown $tdir_dom failed"
+
+       [ $qtype == "p" ] && {
+               change_project -sp $TSTPRJID $DIR/$tdir
+               change_project -sp $TSTPRJID $DIR/$tdir_dom
+       }
+
+       $LFS setquota -$qtype $qid -b $LIMIT -B $LIMIT $DIR ||
+               error "set $qid quota failed"
+
+       for ((i = 0; i < $((LIMIT/2048)); i++)); do
+               $RUNAS $DD of=$DIR/$tdir_dom/$tfile-$i count=1 oflag=sync ||
+                                                               dd_failed=true
+       done
+
+       $dd_failed && quota_error $qtype $qid "write failed, expect succeed"
+
+       for ((i = $((LIMIT/2048)); i < $((LIMIT/1024 + 10)); i++)); do
+               $RUNAS $DD of=$DIR/$tdir_dom/$tfile-$i count=1 oflag=sync ||
+                                                               dd_failed=true
+       done
+
+       $dd_failed || quota_error $qtype $qid "write succeed, expect EDQUOT"
+
+       rm -f $DIR/$tdir_dom/*
+
+       # flush cache, ensure noquota flag is set on client
+       cancel_lru_locks osc
+       cancel_lru_locks mdc
+       sync; sync_all_data || true
+
+       dd_failed=false
+
+       $RUNAS $DD of=$DIR/$tdir/file count=$((LIMIT/2048)) oflag=sync ||
+               quota_error $qtype $qid "write failed, expect succeed"
+
+       for ((i = 0; i < $((LIMIT/2048 + 10)); i++)); do
+               $RUNAS $DD of=$DIR/$tdir_dom/$tfile-$i count=1 oflag=sync ||
+                                                               dd_failed=true
+       done
+
+       $dd_failed || quota_error $qtype $TSTID "write succeed, expect EDQUOT"
+
+       rm -f $DIR/$tdir/*
+       rm -f $DIR/$tdir_dom/*
+
+       # flush cache, ensure noquota flag is set on client
+       cancel_lru_locks osc
+       cancel_lru_locks mdc
+       sync; sync_all_data || true
+
+       dd_failed=false
+
+       for ((i = 0; i < $((LIMIT/2048)); i++)); do
+               $RUNAS $DD of=$DIR/$tdir_dom/$tfile-$i count=1 oflag=sync ||
+                                                               dd_failed=true
+       done
+
+       $dd_failed && quota_error $qtype $qid "write failed, expect succeed"
+
+       $RUNAS $DD of=$DIR/$tdir/file count=$((LIMIT/2048 + 10)) oflag=sync &&
+               quota_error $qtype $qid "write succeed, expect EDQUOT"
+
+       rm -f $DIR/$tdir/*
+       rm -fr $DIR/$tdir_dom
+
+       $LFS setquota -u $TSTUSR -b 0 -B 0 -i 0 -I 0 $DIR ||
+               error "reset usr quota failed"
+
+       cleanup_quota_test
+}
+
+test_63() {
+       test_dom "u"
+       test_dom "g"
+       test_dom "p"
+}
+run_test 63 "quota on DoM tests"
+
 quota_fini()
 {
        do_nodes $(comma_list $(nodes_list)) "lctl set_param debug=-quota"
        disable_project_quota
 }
+reset_quota_settings
 quota_fini
 
 cd $ORIG_PWD