case $flavour in
block)
time=$(lfs quota -$qtype $qarg $parg $DIR|
- awk 'NR == 3{ print $5 }'| sed 's/s$//')
+ awk 'NR == 3{ print $5 }')
;;
file)
time=$(lfs quota -$qtype $qarg $DIR|
- awk 'NR == 3{ print $9 }'| sed 's/s$//')
+ awk 'NR == 3{ print $9 }')
;;
*)
error "Unknown quota type: $flavour"
;;
esac
+ local sleep_seconds=0
+ local orig_time=$time
+
+ echo "Grace time is $time"
# from lfs.c:__sec2str()
# const char spec[] = "smhdw";
# {1, 60, 60*60, 24*60*60, 7*24*60*60};
- [[ $time == *m* ]] && time=${time//m/} && time=$((time*60));
- [[ $time == *h* ]] && time=${time//h/} && time=$((time*60*60));
- [[ $time == *d* ]] && time=${time//d/} && time=$((time*24*60*60));
- [[ $time == *w* ]] && time=${time//w/} && time=$((time*7*24*60*60));
+ [[ $time == *w* ]] && w_time=${time%w*} &&
+ let sleep_seconds+=$((w_time*7*24*60*60));
+ time=${time#*w}
+ [[ $time == *d* ]] && d_time=${time%d*} &&
+ let sleep_seconds+=$((d_time*24*60*60));
+ time=${time#*d}
+ [[ $time == *h* ]] && h_time=${time%h*} &&
+ let sleep_seconds+=$((h_time*60*60));
+ time=${time#*h}
+ [[ $time == *m* ]] && m_time=${time%m*} &&
+ let sleep_seconds+=$((m_time*60));
+ time=${time#*m}
+ [[ $time == *s* ]] && s_time=${time%s*} &&
+ let sleep_seconds+=$s_time
echo "Sleep through grace ..."
- [ "$time" == "-" ] &&
+ [ "$orig_time" == "-" ] &&
error "Grace timeout was not set or quota not exceeded"
- if [ "$time" == "none" ]; then
+ if [ "$orig_time" == "none" ]; then
echo "...Grace timeout already expired"
else
- let time+=$extrasleep
- echo "...sleep $time seconds"
- sleep $time
+ let sleep_seconds+=$extrasleep
+ echo "...sleep $sleep_seconds seconds"
+ sleep $sleep_seconds
fi
}
"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
}
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"
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
$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
}
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"
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"
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"