check_and_setup_lustre
is_project_quota_supported() {
+ lsattr -dp > /dev/null 2>&1 || 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) ] &&
+ 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"
fi
if [ "$local_ugp" == "a" -o "$local_ugp" == "p" ]; then
- $LFS quota -v -p $local_id $DIR
- log "Files for project ($local_id):"
- ($LFS find --projid $local_id $DIR | head -n 4 |
+ $LFS quota -v -p $TSTPRJID $DIR
+ log "Files for project ($TSTPRJID):"
+ ($LFS find --projid $TSTPRJID $DIR | head -n 4 |
xargs stat 2>/dev/null)
fi
}
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
# 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=$(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."
# LU-2435: skip this quota test if underlying zfs version has not
# supported native dnode accounting
[ "$(facet_fstype mds1)" == "zfs" ] && {
- local zfs_version=$(do_facet mds1 cat /sys/module/zfs/version)
+ local F="feature@userobj_accounting"
+ local pool=$(zpool_name mds1)
+ local feature=$(do_facet mds1 $ZPOOL get -H $F $pool)
- [ $(version_code $zfs_version) -lt $(version_code 0.7.0) ] &&
- skip "requires zfs version at least 0.7.0" && return
+ [[ "$feature" != *" active "* ]] &&
+ skip "requires zpool with active userobj_accounting" &&
+ return
}
local ilimit=$((1024 * 2)) # 2k inodes
# 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"
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"
mkdir $dir && change_project -dp 1 $dir && change_project +P $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
}
run_test 52 "Rename across different project ID"
+test_53() {
+ ! is_project_quota_supported &&
+ 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"
+
+ change_project -Pd $dir
+ lsattr -pd $dir | grep P && error "inherit attribute should be cleared"
+
+ rm -rf $dir
+ cleanup_quota_test
+}
+run_test 53 "Project inherit attribute could be cleared"
+
quota_fini()
{
do_nodes $(comma_list $(nodes_list)) "lctl set_param debug=-quota"