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 34 35"
-# bug number: LU-2887
- # 21 9 (min)"
- ZFS_SLOW="12a 9"
-fi
+ # bug number for skipped test: LU-2836 LU-6836 LU-2836
+ ALWAYS_EXCEPT="$ALWAYS_EXCEPT 3 4a 6"
-[ "$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}
check_and_setup_lustre
+ENABLE_PROJECT_QUOTAS=${ENABLE_PROJECT_QUOTAS:-true}
is_project_quota_supported() {
+ $ENABLE_PROJECT_QUOTAS || return 1
[ "$(facet_fstype $SINGLEMDS)" == "ldiskfs" ] &&
- [ $(lustre_version_code $SINGLEMDS) -gt $(version_code 2.9.55) ] &&
- egrep -q "7." /etc/redhat-release &&
- man chattr | grep project >&/dev/null
+ [ $(lustre_version_code $SINGLEMDS) -gt \
+ $(version_code 2.9.55) ] &&
+ lfs --help | grep project >&/dev/null &&
+ egrep -q "7." /etc/redhat-release && return 0
+
+ if [ "$(facet_fstype $SINGLEMDS)" == "zfs" ]; then
+ [ $(lustre_version_code $SINGLEMDS) -le \
+ $(version_code 2.10.53) ] && return 1
+
+ $ZPOOL upgrade -v | grep project_quota && return 0
+ fi
+
+ return 1
}
SHOW_QUOTA_USER="$LFS quota -v -u $TSTUSR $DIR"
change_project()
{
- echo "chattr $*"
- chattr $* || error "chattr $* failed"
+ echo "lfs project $*"
+ lfs project $* || error "lfs project $* failed"
}
RUNAS="runas -u $TSTID -g $TSTID"
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
local spec
local uuid
+ sync_all_data > /dev/null 2>&1 || true
+
[ "$#" != 4 ] && error "getquota: wrong number of arguments: $#"
[ "$1" != "-u" -a "$1" != "-g" -a "$1" != "-p" ] &&
error "getquota: wrong u/g/p specifier $1 passed"
disable_project_quota() {
is_project_quota_supported || return 0
+ [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] && return 0
stopall || error "failed to stopall (1)"
for num in $(seq $MDSCOUNT); do
}
enable_project_quota() {
- is_project_quota_supported || return 0
+ is_project_quota_supported || return 0
+ [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] && return 0
stopall || error "failed to stopall (1)"
for num in $(seq $MDSCOUNT); do
}
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"
# test for Project
log "--------------------------------------"
- log "project quota (block hardlimit:$LIMIT mb)"
+ log "Project quota (block hardlimit:$LIMIT mb)"
$LFS setquota -p $TSTPRJID -b 0 -B ${LIMIT}M -i 0 -I 0 $DIR ||
error "set project quota failed"
cancel_lru_locks osc
sync; sync_all_data || true
$RUNAS $DD of=$TESTFILE count=10 seek=$LIMIT && quota_error p \
- $TSTPRJID "project write success, but expect edquot"
+ $TSTPRJID "project write success, but expect EDQUOT"
# cleanup
cleanup_quota_test
[ $USED -ne 0 ] &&
error "Used inodes($USED) for project $TSTPRJID isn't 0"
- change_project +P $DIR/$tdir/
- change_project -p $TSTPRJID -d $DIR/$tdir
+ change_project -sp $TSTPRJID $DIR/$tdir
log "Create $LIMIT files ..."
$RUNAS createmany -m ${TESTFILE} $((LIMIT-1)) || quota_error p \
$TSTPRJID "project create fail, but expect success"
log "Create out of file quota ..."
$RUNAS touch ${TESTFILE}_xxx && quota_error p $TSTPRJID \
"project create success, but expect EDQUOT"
- change_project -P $DIR/$tdir
- change_project -p 0 -d $DIR/$tdir
+ change_project -C $DIR/$tdir
cleanup_quota_test
USED=$(getquota -p $TSTPRJID global curinodes)
# make sure the system is clean
USED=$(getquota -p $TSTPRJID global curspace)
[ $USED -ne 0 ] && error \
- "Used space($USED) for project $TSTPROJID isn't 0."
+ "Used space($USED) for project $TSTPRJID isn't 0."
$LFS setquota -t -p --block-grace $GRACE --inode-grace \
$MAX_IQ_TIME $DIR ||
setup_quota_test
trap cleanup_quota_test EXIT
- is_project_quota_supported && change_project +P $DIR/$tdir/ &&
- change_project -p $TSTPRJID -d $DIR/$tdir
+ is_project_quota_supported && change_project -sp $TSTPRJID $DIR/$tdir
echo "Create files to exceed soft limit"
$RUNAS createmany -m ${TESTFILE}_ $((LIMIT + 1)) ||
USED=$(getquota -g $TSTUSR global curspace)
[ $USED -ne 0 ] && error "Used block($USED) for group $TSTUSR isn't 0."
if is_project_quota_supported; then
+ USED=$(getquota -p $TSTPRJID global curinodes)
+ [ $USED -ne 0 ] &&
+ error "Used inode($USED) for project $TSTPRJID isn't 0."
USED=$(getquota -p $TSTPRJID global curspace)
[ $USED -ne 0 ] &&
error "Used block($USED) for project $TSTPRJID isn't 0."
# hardlimit should be cleared on slave during reintegration
$RUNAS createmany -m $TESTFILE $((ilimit + 1)) ||
- quota_error -u $TSTUSR "create failed, expect success"
+ quota_error u $TSTUSR "create failed, expect success"
$RUNAS unlinkmany $TESTFILE $((ilimit + 1)) || error "unlink failed"
rmdir $DIR/${tdir}-1 || error "unlink remote dir failed"
$LFS setquota -g $TSTUSR -b 0 -B $BLK_LIMIT -i 0 -I $FILE_LIMIT $DIR ||
error "set group quota failed"
if is_project_quota_supported; then
- change_project +P $DIR/$tdir && change_project -p \
- $TSTPRJID -d $DIR/$tdir
+ change_project -sp $TSTPRJID $DIR/$tdir
echo "Set enough high limit for project: $TSTPRJID"
$LFS setquota -p $TSTPRJID -b 0 \
-B $BLK_LIMIT -i 0 -I $FILE_LIMIT $DIR ||
$RUNAS bash rundbench -D $DIR/$tdir 3 $duration ||
quota_error a $TSTUSR "dbench failed!"
- is_project_quota_supported && change_project -P $DIR/$tdir &&
- change_project -dp 0 $DIR/$tdir
+ is_project_quota_supported && change_project -C $DIR/$tdir
cleanup_quota_test
resetquota -u $TSTUSR
resetquota -g $TSTUSR
USED=$(getquota -g $TSTID global curinodes)
[ $USED -eq 0 ] || error "Used inodes for group $TSTID isn't 0. $USED"
if is_project_quota_supported; then
+ USED=$(getquota -p $TSTPRJID global curspace)
+ [ $USED -eq 0 ] ||
+ error "Used space for project $TSTPRJID isn't 0. $USED"
USED=$(getquota -p $TSTPRJID global curinodes)
[ $USED -eq 0 ] ||
error "Used inodes for project $TSTPRJID isn't 0. $USED"
fi
log "Restart..."
- local ORIG_REFORMAT=$REFORMAT
- REFORMAT=""
- cleanup_and_setup_lustre
- REFORMAT=$ORIG_REFORMAT
+ stopall
+ setupall
quota_init
echo "Verify disk usage after restart"
echo "Create $file_cnt files..."
for i in `seq $file_cnt`; do
touch $TESTFILE-$i
- chown $((file_cnt - i)):$((file_cnt - i)) $TESTFILE-$i
+ chown $((file_cnt - i)):$((file_cnt - i)) $TESTFILE-$i ||
+ error "failed to chown $TESTFILE-$i"
done
cancel_lru_locks osc
sync; sync_all_data || true
procf=${procf}.quota_slave.acct_user
local accnt_cnt
- acct_cnt=$(do_facet mds1 $LCTL get_param $procf | grep "id:" | wc -l)
+ acct_cnt=$(do_facet mds1 $LCTL get_param $procf | grep "id:" | \
+ awk '{if ($3 < 10000) {print $3}}' | wc -l)
echo "Found $acct_cnt id entries"
- [ $file_cnt -eq $acct_cnt ] || error "skipped id entries"
+ [ $file_cnt -eq $acct_cnt ] || {
+ do_facet mds1 $LCTL get_param $procf
+ error "skipped id entries"
+ }
cleanup_quota_test
}
setup_quota_test || error "setup quota failed with $?"
touch $TESTFILE
- projectid=$(lsattr -p $TESTFILE | awk '{print $1}')
+ projectid=$(lfs project $TESTFILE | awk '{print $1}')
[ $projectid -ne 0 ] &&
error "Project id should be 0 not $projectid"
change_project -p 1024 $TESTFILE
- projectid=$(lsattr -p $TESTFILE | awk '{print $1}')
+ projectid=$(lfs project $TESTFILE | awk '{print $1}')
[ $projectid -ne 1024 ] &&
error "Project id should be 1024 not $projectid"
stopall || error "failed to stopall (1)"
mount
setupall
- projectid=$(lsattr -p $TESTFILE | awk '{print $1}')
+ projectid=$(lfs project $TESTFILE | awk '{print $1}')
[ $projectid -ne 1024 ] &&
error "Project id should be 1024 not $projectid"
setup_quota_test || error "setup quota failed with $?"
mkdir -p $dir1 $dir2
- change_project +P $dir1 && change_project -p 1 -d $dir1 && touch $dir1/1
- change_project +P $dir2 && change_project -p 2 -d $dir2
+ change_project -sp 1 $dir1 && touch $dir1/1
+ change_project -sp 2 $dir2
ln $dir1/1 $dir2/1_link &&
error "Hard link across different project quota should fail"
setup_quota_test || error "setup quota failed with $?"
mkdir -p $dir1 $dir2
- change_project +P $dir1 && change_project -p 1 -d $dir1 && touch $dir1/1
- change_project +P $dir2 && change_project -p 2 -d $dir2
+ change_project -sp 1 $dir1 && touch $dir1/1
+ change_project -sp 2 $dir2
mv $dir1/1 $dir2/2 || error "mv failed $?"
- local projid=$(lsattr -p $dir2/2 | awk '{print $1}')
+ local projid=$(lfs project $dir2/2 | awk '{print $1}')
if [ "$projid" != "2" ]; then
error "project id expected 2 not $projid"
fi
setup_quota_test || error "setup quota failed with $?"
local dir="$DIR/$tdir/dir"
- mkdir -p $dir && change_project +P $dir && change_project -dp 1 $dir
+ mkdir -p $dir && change_project -sp 1 $dir
$LFS mkdir -i 1 $dir/remote_dir || error "create remote dir failed"
- local projid=$(lsattr -dp $dir/remote_dir | awk '{print $1}')
+ local projid=$(lfs project -d $dir/remote_dir | awk '{print $1}')
[ "$projid" != "1" ] && error "projid id expected 1 not $projid"
touch $dir/remote_dir/file
#verify inherit works file for remote dir.
- local projid=$(lsattr -dp $dir/remote_dir/file | awk '{print $1}')
+ local projid=$(lfs project -d $dir/remote_dir/file | awk '{print $1}')
[ "$projid" != "1" ] &&
error "file under remote dir expected 1 not $projid"
setup_quota_test || error "setup quota failed with $?"
local dir="$DIR/$tdir/dir"
- mkdir $dir && change_project -dp 1 $dir
+ mkdir $dir && change_project -p 1 $dir
count=$($LFS find --projid 1 $DIR | wc -l)
[ "$count" != 1 ] && error "expected 1 but got $count"
setup_quota_test || error "setup quota failed with $?"
local dir="$DIR/$tdir/dir"
- mkdir $dir && change_project -dp 1 $dir && change_project +P $dir
+ mkdir $dir && change_project -sp 1 $dir
local used=$(getquota -p 1 global curinodes)
- [ $used != "1" ] && error "expected 1 got $used"
+ [ $used != "1" ] && error "expected 1 got $used"
touch $dir/1
touch $dir/2
cp $dir/2 $dir/3
used=$(getquota -p 1 global curinodes)
- [ $used != "4" ] && error "expected 4 got $used"
+ [ $used != "4" ] && error "expected 4 got $used"
$DD if=/dev/zero of=$DIR/$tdir/6 bs=1M count=1
#try cp to dir
cp $DIR/$tdir/6 $dir/6
used=$(getquota -p 1 global curinodes)
- [ $used != "5" ] && error "expected 5 got $used"
+ [ $used != "5" ] && error "expected 5 got $used"
#try mv to dir
mv $DIR/$tdir/6 $dir/7
used=$(getquota -p 1 global curinodes)
- [ $used != "6" ] && error "expected 6 got $used"
+ [ $used != "6" ] && error "expected 6 got $used"
rm -rf $dir
cleanup_quota_test
skip "Project quota is not supported" && return 0
setup_quota_test || error "setup quota failed with $?"
local dir="$DIR/$tdir/dir"
- mkdir $dir && change_project -dp 1 $dir && change_project +P $dir
+ mkdir $dir && change_project -sp 1 $dir
touch $DIR/$tdir/file
#Try renaming a file into the project. This should fail.
skip "Project quota is not supported" && return 0
setup_quota_test || error "setup quota failed with $?"
local dir="$DIR/$tdir/dir"
- mkdir $dir && change_project +P $dir
- lsattr -pd $dir | grep P || error "inherit attribute should be set"
+ mkdir $dir && change_project -s $dir
+ lfs project -d $dir | grep P || error "inherit attribute should be set"
- change_project -Pd $dir
- lsattr -pd $dir | grep P && error "inherit attribute should be cleared"
+ change_project -C $dir
+ lfs project -d $dir | grep P &&
+ error "inherit attribute should be cleared"
rm -rf $dir
cleanup_quota_test
}
run_test 53 "Project inherit attribute could be cleared"
+test_54() {
+ ! is_project_quota_supported &&
+ skip "Project quota is not supported" && return 0
+ setup_quota_test || error "setup quota failed with $?"
+ trap cleanup_quota_test EXIT
+ local testfile="$DIR/$tdir/$tfile-0"
+
+ #set project ID/inherit attribute
+ change_project -sp $TSTPRJID $DIR/$tdir
+ $RUNAS createmany -m ${testfile} 100 ||
+ error "create many files failed"
+
+ local proj_count=$(lfs project -r $DIR/$tdir | wc -l)
+ # one more count for directory itself */
+ ((proj_count++))
+
+ #check project
+ local proj_count1=$(lfs project -rcp $TSTPRJID $DIR/$tdir | wc -l)
+ [ $proj_count1 -eq 0 ] || error "c1: expected 0 got $proj_count1"
+
+ proj_count1=$(lfs project -rcp $((TSTPRJID+1)) $DIR/$tdir | wc -l)
+ [ $proj_count1 -eq $proj_count ] ||
+ error "c2: expected $proj_count got $proj_count1"
+
+ #clear project but with kept projid
+ change_project -rCk $DIR/$tdir
+ proj_count1=$(lfs project -rcp $TSTPRJID $DIR/$tdir | wc -l)
+ [ $proj_count1 -eq $proj_count ] ||
+ error "c3: expected $proj_count got $proj_count1"
+
+ #verify projid untouched.
+ proj_count1=$(lfs project -r $DIR/$tdir | grep -c $TSTPRJID)
+ ((proj_count1++))
+ [ $proj_count1 -eq $proj_count ] ||
+ error "c4: expected $proj_count got $proj_count1"
+
+ # test -0 option
+ lfs project $DIR/$tdir -cr -0 | xargs -0 lfs project -s
+ proj_count1=$(lfs project -rcp $TSTPRJID $DIR/$tdir | wc -l)
+ [ $proj_count1 -eq 0 ] || error "c5: expected 0 got $proj_count1"
+
+ #this time clear all
+ change_project -rC $DIR/$tdir
+ proj_count1=$(lfs project -r $DIR/$tdir | grep -c $TSTPRJID)
+ [ $proj_count1 -eq 0 ] ||
+ error "c6: expected 0 got $proj_count1"
+ #cleanup
+ unlinkmany ${testfile} 100 ||
+ error "unlink many files failed"
+
+ cleanup_quota_test
+}
+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
+ setup_quota_test || error "setup quota failed with $?"
+
+ set_ost_qtype $QTYPE || error "enable ost quota failed"
+ quota_init
+
+ #add second group to TSTUSR
+ usermod -G $TSTUSR,$TSTUSR2 $TSTUSR
+
+ #prepare test file
+ $RUNAS dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1024 count=100000 ||
+ error "failed to dd"
+
+ cancel_lru_locks osc
+ sync; sync_all_data || true
+
+ $LFS setquota -g $TSTUSR2 -b 0 -B 50M $DIR ||
+ error "failed to setquota on group $TSTUSR2"
+
+ $LFS quota -v -g $TSTUSR2 $DIR
+
+ runas -u $TSTUSR -g $TSTUSR2 chgrp $TSTUSR2 $DIR/$tdir/$tfile &&
+ error "chgrp should failed with -EDQUOT"
+
+ USED=$(getquota -g $TSTUSR2 global curspace)
+ echo "$USED"
+
+ $LFS setquota -g $TSTUSR2 -b 0 -B 300M $DIR ||
+ error "failed to setquota on group $TSTUSR2"
+
+ $LFS quota -v -g $TSTUSR2 $DIR
+
+ runas -u $TSTUSR -g $TSTUSR2 chgrp $TSTUSR2 $DIR/$tdir/$tfile ||
+ error "chgrp should succeed"
+
+ $LFS quota -v -g $TSTUSR2 $DIR
+
+ resetquota -g $TSTUSR2
+ cleanup_quota_test
+}
+run_test 55 "Chgrp should be affected by group quota"
+
+test_56() {
+ setup_quota_test || error "setup quota failed with $?"
+
+ set_ost_qtype $QTYPE || error "enable ost quota failed"
+ quota_init
+
+ $LFS setquota -t -u -b 10 -i 10 $DIR ||
+ erro "failed to set grace time for usr quota"
+ grace_time=$($LFS quota -t -u $DIR | grep "Block grace time:" |
+ awk '{print $4 $8}')
+ if [ "x$grace_time" != "x10s;10s" ]; then
+ $LFS quota -t -u $DIR
+ error "expected grace time: 10s;10s, got:$grace_time"
+ fi
+
+ cleanup_quota_test
+}
+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
+ skip "ldiskfs only test"
+ return
+ fi
+ disable_project_quota
+ setup_quota_test || error "setup quota failed with $?"
+ quota_init
+
+ local testfile="$DIR/$tdir/$tfile-0"
+ #make sure it did not crash kernel
+ touch $testfile && lfs project -sp 1 $testfile
+
+ enable_project_quota
+ cleanup_quota_test
+}
+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." && return
+
+ 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"
+
quota_fini()
{
do_nodes $(comma_list $(nodes_list)) "lctl set_param debug=-quota"
disable_project_quota
}
+reset_quota_settings
quota_fini
cd $ORIG_PWD