. $LUSTRE/tests/test-framework.sh
init_test_env $@
. ${CONFIG:=$LUSTRE/tests/cfg/$NAME.sh}
+init_logging
DIRECTIO=${DIRECTIO:-$LUSTRE/tests/directio}
[ $MDSCOUNT -gt 1 ] && skip "CMD case" && exit 0
-unset ENABLE_QUOTA
-
-remote_mds_nodsh && skip "remote MDS with nodsh" && exit 0
-remote_ost_nodsh && skip "remote OST with nodsh" && exit 0
+require_dsh_mds || exit 0
+require_dsh_ost || exit 0
[ "$SLOW" = "no" ] && EXCEPT_SLOW="9 10 11 18b 21"
DIR=${DIR:-$MOUNT}
DIR2=${DIR2:-$MOUNT2}
-check_and_setup_lustre
+QUOTA_AUTO_OLD=$QUOTA_AUTO
+export QUOTA_AUTO=0
-if [ x"$(som_check)" = x"enabled" ]; then
- echo "Som is enabled, Quota is temporary conflicts with it"
- check_and_cleanup_lustre
- exit 0
-fi
+check_and_setup_lustre
LOVNAME=`lctl get_param -n llite.*.lov.common_name | tail -n 1`
OSTCOUNT=`lctl get_param -n lov.$LOVNAME.numobd`
$RUNAS dd if=/dev/zero of=$TESTFILE bs=$BLK_SZ count=$(($LIMIT/2)) || quota_error g $TSTUSR "(grp) write failure, but expect success"
etime=`date +%s`
delta=$((etime - stime))
- rate=$((BLK_SZ * LIMIT / 2 / delta / 1024))
- [ $rate -gt 1024 ] || error "SLOW IO for $TSTUSR (group): $rate KB/sec"
+ if [ $delta -gt 0 ]; then
+ rate=$((BLK_SZ * LIMIT / 2 / delta / 1024))
+ [ $rate -gt 1024 ] || error "SLOW IO for $TSTUSR (group): $rate KB/sec"
+ fi
log " Done"
log " Write out of block quota ..."
# this time maybe cache write, ignore it's failure
# block quota acquire & release
test_6() {
if [ $OSTCOUNT -lt 2 ]; then
- skip "$OSTCOUNT < 2, too few osts"
+ skip_env "$OSTCOUNT < 2, too few osts"
return 0;
fi
chmod 0777 $DIR/$tdir
[ "$(grep $DIR2 /proc/mounts)" ] || mount_client $DIR2 || \
- { skip "Need lustre mounted on $MOUNT2 " && retutn 0; }
+ { skip_env "Need lustre mounted on $MOUNT2 " && retutn 0; }
LIMIT=$(( $BUNIT_SZ * $(($OSTCOUNT + 1)) * 10)) # 10 bunits each sever
TESTFILE="$DIR/$tdir/$tfile-0"
DDPID=$!
echo " step2: testing ......"
- count=0
- while [ true ]; do
- if ! ps -p ${DDPID1} > /dev/null 2>&1; then break; fi
- count=$[count+1]
- if [ $count -gt 64 ]; then
+ local last_size=$(stat -c %s $TESTFILE2)
+ local stall_secs=0
+ local start_secs=$SECONDS
+ while [ -d /proc/${DDPID1} ]; do
+ local size=$(stat -c %s $TESTFILE2)
+ if [ $size -eq $last_size ]; then
+ stall_secs=$[stall_secs+1]
+ else
+ stall_secs=0
+ fi
+ if [ $stall_secs -gt 30 ]; then
lustre_fail ost 0
- quota_error u $TSTUSR2 "dd should be finished!"
+ quota_error u $TSTUSR2 "giving up: dd stalled (i.e. made no progress) for 30 seconds!"
fi
+ last_size=$size
sleep 1
done
- echo "(dd_pid=$DDPID1, time=$count)successful"
+ echo "(dd_pid=$DDPID1, time=$((SECONDS-start_secs)))successful"
#Recover fail_loc and dd will finish soon
lustre_fail ost 0
# check if watchdog is triggered
do_facet ost1 dmesg > $TMP/lustre-log-${TESTNAME}.log
watchdog=`awk '/test 18b/ {start = 1;}
- /Watchdog triggered/ {
+ /Service thread pid/ && /was inactive/ {
if (start) {
print;
}
}
run_test_with_stat 28 "test for consistency for qunit when setquota (18574) ==========="
+test_29()
+{
+ local BLK_LIMIT=$((100 * 1024 * 1024)) # 100G
+ local timeout
+ local pid
+
+ if at_is_enabled; then
+ timeout=$(at_max_get client)
+ at_max_set 10 client
+ else
+ timeout=$(lctl get_param -n timeout)
+ lctl set_param timeout=10
+ fi
+
+ #define OBD_FAIL_MDS_QUOTACTL_NET 0x12e
+ lustre_fail mds 0x12e
+
+ $LFS setquota -u $TSTUSR -b 0 -B $BLK_LIMIT -i 0 -I 0 $DIR & pid=$!
+
+ echo "sleeping for $((10 * 2)) seconds"
+ sleep $((10 * 2))
+ ps -p $pid && error "lfs hadn't finished by timeout"
+ wait $pid && error "succeeded, but should have failed"
+
+ lustre_fail mds 0
+
+ if at_is_enabled; then
+ at_max_set $timeout client
+ else
+ lctl set_param timeout=$timeout
+ fi
+
+ resetquota -u $TSTUSR
+}
+run_test_with_stat 29 "unhandled quotactls must not hang lustre client (19778) ========"
+
test_30()
{
local output
local TESTFILE="$DIR/$tdir/$tfile"
local GRACE=10
+ set_blk_tunesz 512
+ set_blk_unitsz 1024
+
mkdir -p $DIR/$tdir
chmod 0777 $DIR/$tdir
+ $LFS setstripe $TESTFILE -i 0 -c 1
+ chown $TSTUSR.$TSTUSR $TESTFILE
+
$LFS setquota -t -u --block-grace $GRACE --inode-grace $MAX_IQ_TIME $DIR
$LFS setquota -u $TSTUSR -b $LIMIT -B 0 -i 0 -I 0 $DIR
$RUNAS dd if=/dev/zero of=$TESTFILE bs=1024 count=$((LIMIT * 2)) || true
cancel_lru_locks osc
- sleep 5
+ sleep $GRACE
$LFS setquota -u $TSTUSR -B 0 $DIR
- output=`$SHOW_QUOTA_USER | grep $MOUNT | awk '{ print $5 }' | tr -d s`
- [ "$output" -le "$((GRACE - 5))" ] || error "grace times were reset or unexpectedly high latency"
+ # over-quota flag has not yet settled since we do not trigger async events
+ # based on grace time period expiration
+ $SHOW_QUOTA_USER
+ $RUNAS dd if=/dev/zero of=$TESTFILE conv=notrunc oflag=append bs=1048576 count=1 || true
+ cancel_lru_locks osc
+ # now over-quota flag should be settled and further writes should fail
+ $SHOW_QUOTA_USER
+ $RUNAS dd if=/dev/zero of=$TESTFILE conv=notrunc oflag=append bs=1048576 count=1 && error "grace times were reset"
rm -f $TESTFILE
resetquota -u $TSTUSR
$LFS setquota -t -u --block-grace $MAX_DQ_TIME --inode-grace $MAX_IQ_TIME $DIR
+
+ set_blk_unitsz $((128 * 1024))
+ set_blk_tunesz $((128 * 1024 / 2))
}
run_test_with_stat 30 "hard limit updates should not reset grace times ================"
+# test duplicate quota releases b=18630
+test_31() {
+ mkdir -p $DIR/$tdir
+ chmod 0777 $DIR/$tdir
+
+ LIMIT=$(( $BUNIT_SZ * $(($OSTCOUNT + 1)) * 10)) # 10 bunits each sever
+ TESTFILE="$DIR/$tdir/$tfile-0"
+ TESTFILE2="$DIR/$tdir/$tfile-1"
+
+ wait_delete_completed
+
+ log " User quota (limit: $LIMIT kbytes)"
+ $LFS setquota -u $TSTUSR -b 0 -B $LIMIT -i 0 -I 0 $DIR
+
+ $LFS setstripe $TESTFILE -i 0 -c 1
+ chown $TSTUSR.$TSTUSR $TESTFILE
+ $LFS setstripe $TESTFILE2 -i 0 -c 1
+ chown $TSTUSR.$TSTUSR $TESTFILE2
+
+ log " step1: write out of block quota ..."
+ $RUNAS dd if=/dev/zero of=$TESTFILE bs=$BLK_SZ count=5120
+ $RUNAS dd if=/dev/zero of=$TESTFILE2 bs=$BLK_SZ count=5120
+
+ #define OBD_FAIL_QUOTA_DELAY_SD 0xA04
+ #define OBD_FAIL_SOME 0x10000000 /* fail N times */
+ lustre_fail ost $((0x00000A04 | 0x10000000)) 1
+
+ log " step2: delete two files so that triggering duplicate quota release ..."
+ rm -f $TESTFILE $TESTFILE2
+ sync; sleep 5; sync # OBD_FAIL_QUOTA_DELAY_SD will delay for 5 seconds
+ wait_delete_completed
+
+ log " step3: verify if the ost failed"
+ do_facet ost1 dmesg > $TMP/lustre-log-${TESTNAME}.log
+ watchdog=`awk '/test 31/ {start = 1;}
+ /release quota error/ {
+ if (start) {
+ print;
+ }
+ }' $TMP/lustre-log-${TESTNAME}.log`
+ [ "$watchdog" ] && error "$watchdog"
+ rm -f $TMP/lustre-log-${TESTNAME}.log
+
+ lustre_fail ost 0
+ resetquota -u $TSTUSR
+}
+run_test_with_stat 31 "test duplicate quota releases ==="
+
# turn off quota
quota_fini()
{
cd $ORIG_PWD
check_and_cleanup_lustre
echo '=========================== finished ==============================='
+export QUOTA_AUTO=$QUOTA_AUTO_OLD
[ -f "$QUOTALOG" ] && cat $QUOTALOG && grep -q FAIL $QUOTALOG && exit 1 || true
echo "$0: completed"