# Test duration: 30 min
[ "$SLOW" = "no" ] && EXCEPT_SLOW="61"
-if [ $(facet_fstype $SINGLEMDS) = "zfs" ]; then
+if [ "$mds1_FSTYPE" = zfs ]; then
# bug number: LU-2887
# Test duration: 21 9 min"
[ "$SLOW" = "no" ] && EXCEPT_SLOW+=" 12a 9"
require_dsh_ost || exit 0
# Does e2fsprogs support quota feature?
-if [ $(facet_fstype $SINGLEMDS) == ldiskfs ] &&
+if [ "$mds1_FSTYPE" == ldiskfs ] &&
do_facet $SINGLEMDS "! $DEBUGFS -c -R supported_features |
grep -q 'quota'"; then
- skip_env "e2fsprogs doesn't support quota" && exit 0
+ skip_env "e2fsprogs doesn't support quota"
fi
QUOTALOG=${TESTSUITELOG:-$TMP/$(basename $0 .sh).log}
xargs stat 2>/dev/null)
fi
+ is_project_quota_supported || return 0
if [ "$local_ugp" == "a" -o "$local_ugp" == "p" ]; then
$LFS quota -v -p $TSTPRJID $DIR
log "Files for project ($TSTPRJID):"
project_quota_enabled () {
local rc=0
- for num in $(seq $MDSCOUNT); do
- do_facet mds$num $DEBUGFS -R features $(mdsdevname $num) |
- grep -q project || rc=1
- done
- for num in $(seq $OSTCOUNT); do
- do_facet ost$num $DEBUGFS -R features $(ostdevname $num) |
- grep -q project || rc=1
+ local zfeat="feature@project_quota"
+
+ for facet in $(seq -f mds%g $MDSCOUNT) $(seq -f ost%g $OSTCOUNT); do
+ local facet_fstype=${facet:0:3}1_FSTYPE
+ local devname
+
+ if [ "${!facet_fstype}" = "zfs" ]; then
+ devname=$(zpool_name ${facet})
+ do_facet ${facet} $ZPOOL get -H "$zfeat" $devname |
+ grep -wq active || rc=1
+ else
+ [ ${facet:0:3} == "mds" ] &&
+ devname=$(mdsdevname ${facet:3}) ||
+ devname=$(ostdevname ${facet:3})
+ do_facet ${facet} $DEBUGFS -R features $devname |
+ grep -q project || rc=1
+ fi
done
[ $rc -eq 0 ] && PQ_CLEANUP=false || PQ_CLEANUP=true
return $rc
reset_quota_settings() {
resetquota -u $TSTUSR
+ resetquota -u $TSTID
resetquota -g $TSTUSR
+ resetquota -g $TSTID
resetquota -u $TSTUSR2
+ resetquota -u $TSTID2
resetquota -g $TSTUSR2
+ resetquota -g $TSTID2
resetquota -p $TSTPRJID
}
local etime=$(date +%s)
delta=$((etime - stime))
if [ $delta -gt 0 ]; then
- rate=$((size * 1024 / delta))
- if [ $(facet_fstype $SINGLEMDS) = "zfs" ]; then
- # LU-2872 - see LU-2887 for fix
- [ $rate -gt 64 ] ||
- error "SLOW IO for $TSTUSR (user): $rate KB/sec"
- else
- [ $rate -gt 1024 ] ||
- error "SLOW IO for $TSTUSR (user): $rate KB/sec"
- fi
+ rate=$((size * 1024 / delta))
+ if [ "$mds1_FSTYPE" = zfs ]; then
+ # LU-2872 - see LU-2887 for fix
+ [ $rate -gt 64 ] ||
+ error "SLOW IO for $TSTUSR (user): $rate KB/sec"
+ else
+ [ $rate -gt 1024 ] ||
+ error "SLOW IO for $TSTUSR (user): $rate KB/sec"
+ fi
fi
rm -f $TESTFILE
}
$LFS setquota -u $TSTUSR -b 0 -B 0 -i $LIMIT -I 0 $DIR ||
error "set user quota failed"
- [ $(facet_fstype $SINGLEMDS) = "zfs" ] && GRACE=20
+ [ "$mds1_FSTYPE" = zfs ] && GRACE=20
test_file_soft $TESTFILE $LIMIT $GRACE "u"
error "write $TESTFILE failure, expect success"
$RUNAS2 $DD of=$TESTFILE2 count=1 ||
error "write $TESTFILE2 failure, expect success"
+
+ if at_is_enabled; then
+ at_max_saved=$(at_max_get ost1)
+ at_max_set $TIMEOUT ost1
+
+ # write to enforced ID ($TSTUSR) to exceed limit to make sure
+ # DQACQ is sent, which makes at_max to take effect
+ $RUNAS $DD of=$TESTFILE count=$LIMIT seek=1 oflag=sync \
+ conv=notrunc
+ rm -f $TESTFILE
+ wait_delete_completed
+ fi
+
sync; sync
sync_all_data || true
#define OBD_FAIL_PTLRPC_DROP_REQ_OPC 0x513
lustre_fail mds 0x513 601
- if at_is_enabled; then
- at_max_saved=$(at_max_get ost1)
- at_max_set $TIMEOUT ost1
- fi
-
do_facet ost1 $LCTL set_param \
osd-*.$FSNAME-OST*.quota_slave.timeout=$((TIMEOUT / 2))
# no watchdog is triggered
do_facet ost1 dmesg > $TMP/lustre-log-${TESTNAME}.log
- watchdog=$(awk '/Service thread pid/ && /was inactive/ \
+ watchdog=$(awk '/[Ss]ervice thread pid/ && /was inactive/ \
{ print; }' $TMP/lustre-log-${TESTNAME}.log)
[ -z "$watchdog" ] || error "$watchdog"
# enable ost quota
set_ost_qtype $QTYPE || error "enable ost quota failed"
# trigger reintegration
- local procf="osd-$(facet_fstype ost1).$FSNAME-OST*."
+ local procf="osd-$ost1_FSTYPE.$FSNAME-OST*."
procf=${procf}quota_slave.force_reint
do_facet ost1 $LCTL set_param $procf=1 ||
error "force reintegration failed"
# LU-2435: skip this quota test if underlying zfs version has not
# supported native dnode accounting
- [ "$(facet_fstype mds1)" == "zfs" ] && {
+ [ "$mds1_FSTYPE" == zfs ] && {
local F="feature@userobj_accounting"
local pool=$(zpool_name mds1)
local feature=$(do_facet mds1 $ZPOOL get -H $F $pool)
# check if watchdog is triggered
do_facet ost1 dmesg > $TMP/lustre-log-${TESTNAME}.log
- local watchdog=$(awk '/Service thread pid/ && /was inactive/ \
+ local watchdog=$(awk '/[Ss]ervice thread pid/ && /was inactive/ \
{ print; }' $TMP/lustre-log-${TESTNAME}.log)
[ -z "$watchdog" ] || error "$watchdog"
rm -f $TMP/lustre-log-${TESTNAME}.log
}
test_23() {
- [ $(facet_fstype ost1) == "zfs" ] &&
+ [ "$ost1_FSTYPE" == zfs ] &&
skip "Overwrite in place is not guaranteed to be " \
"space neutral on ZFS"
$SHOW_QUOTA_PROJID ||
error "lfs quota failed with projid argument"
fi
- resetquota -u $TSTUSR
- resetquota -g $TSTUSR
+ resetquota -u $TSTID
+ resetquota -g $TSTID
resetquota -p $TSTPRJID
return 0
}
# chown/chgrp to the file created with MDS_OPEN_DELAY_CREATE
# LU-5006
test_37() {
- [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.6.93) ] &&
+ [ "$MDS1_VERSION" -lt $(version_code 2.6.93) ] &&
skip "Old server doesn't have LU-5006 fix."
setup_quota_test || error "setup quota failed with $?"
# LU-8801
test_38() {
- [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.8.60) ] &&
+ [ "$MDS1_VERSION" -lt $(version_code 2.8.60) ] &&
skip "Old server doesn't have LU-8801 fix."
[ "$UID" != 0 ] && skip_env "must run as root" && return
cancel_lru_locks osc
sync; sync_all_data || true
- local procf="osd-$(facet_fstype $SINGLEMDS).$FSNAME-MDT0000"
+ local procf="osd-$mds1_FSTYPE.$FSNAME-MDT0000"
procf=${procf}.quota_slave.acct_user
local accnt_cnt
run_test 54 "basic lfs project interface test"
test_55() {
- [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.10.58) ] &&
+ [ "$MDS1_VERSION" -lt $(version_code 2.10.58) ] &&
skip "Not supported before 2.10.58."
setup_quota_test || error "setup quota failed with $?"
run_test 57 "lfs project could tolerate errors"
test_59() {
- [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
+ [ "$mds1_FSTYPE" != ldiskfs ] &&
skip "ldiskfs only test"
disable_project_quota
setup_quota_test || error "setup quota failed with $?"
# test default quota
test_default_quota() {
- [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.11.51) ] &&
+ [ "$MDS1_VERSION" -lt $(version_code 2.11.51) ] &&
skip "Not supported before 2.11.51."
local qtype=$1
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
+ [ "$MDS1_VERSION" -lt $(version_code 2.11.55) ] &&
+ skip "Not supported before 2.11.55"
local qtype=$1
local qid=$TSTUSR
}
run_test 64 "lfs project on symlink files should fail"
+test_65() {
+ local SIZE=10 #10M
+ local TESTFILE="$DIR/$tdir/$tfile-0"
+
+ setup_quota_test || error "setup quota failed with $?"
+ set_ost_qtype $QTYPE || error "enable ost quota failed"
+ quota_init
+
+ echo "Write..."
+ $RUNAS $DD of=$TESTFILE count=$SIZE ||
+ error "failed to write"
+ # flush cache, ensure noquota flag is set on client
+ cancel_lru_locks osc
+ sync; sync_all_data || true
+
+ local quota_u=$($LFS quota -u $TSTUSR $DIR)
+ local quota_g=$($LFS quota -g $TSTUSR $DIR)
+ local quota_all=$($RUNAS $LFS quota $DIR)
+
+ [ "$(echo "$quota_all" | head -n3)" != "$quota_u" ] &&
+ error "usr quota not match"
+ [ "$(echo "$quota_all" | tail -n3)" != "$quota_g" ] &&
+ error "grp quota not match"
+
+ rm -f $TESTFILE
+ # cleanup
+ cleanup_quota_test
+}
+run_test 65 "Check lfs quota result"
+
+test_66() {
+ ! is_project_quota_supported &&
+ skip "Project quota is not supported"
+ setup_quota_test || error "setup quota failed with $?"
+ stack_trap cleanup_quota_test EXIT
+ local old=$(do_facet mds1 $LCTL get_param -n \
+ mdt.*.enable_chprojid_gid | head -1)
+ local testdir=$DIR/$tdir/foo
+
+ do_facet mds1 $LCTL set_param mdt.*.enable_chprojid_gid=0
+ stack_trap "do_facet mds1 $LCTL set_param mdt.*.enable_chprojid_gid=0" \
+ EXIT
+
+ test_mkdir -i 0 -c 1 $testdir || error "failed to mkdir"
+ chown -R $TSTID:$TSTID $testdir
+ change_project -sp $TSTPRJID $testdir
+ $RUNAS mkdir $testdir/foo || error "failed to mkdir foo"
+
+ $RUNAS lfs project -p 0 $testdir/foo &&
+ error "nonroot user should fail to set projid"
+
+ $RUNAS lfs project -C $testdir/foo &&
+ error "nonroot user should fail to clear projid"
+
+ change_project -C $testdir/foo || error "failed to clear project"
+
+ do_facet mds1 $LCTL set_param mdt.*.enable_chprojid_gid=-1
+ $RUNAS lfs project -p $TSTPRJID $testdir/foo || error \
+ "failed to set projid with normal user when enable_chprojid_gid=-1"
+
+ $RUNAS lfs project -rC $testdir/ || error \
+"failed to clear project state with normal user when enable_chprojid_gid=-1"
+
+ touch $testdir/bar || error "failed touch $testdir/bar"
+ $RUNAS lfs project -p $TSTPRJID $testdir/bar && error \
+ "normal user should not be able to set projid on root owned file"
+
+ change_project -p $TSTPRJID $testdir/bar || error \
+ "root should be able to change its own file's projid"
+
+ cleanup_quota_test
+}
+run_test 66 "nonroot user can not change project state in default"
+
quota_fini()
{
do_nodes $(comma_list $(nodes_list)) "lctl set_param debug=-quota"