fi
}
+#
+# clear quota limits for a user or a group
+# usage: resetquota -u username
+# resetquota -g groupname
+
+resetquota() {
+ [ "$#" != 2 ] && error "resetquota: wrong number of arguments: $#"
+ [ "$1" != "-u" -a "$1" != "-g" ] && error "resetquota: wrong specifier $1 passed"
+ $LFS setquota "$1" "$2" -b 0 -B 0 -i 0 -I 0 $MOUNT || error "resetquota failed"
+}
+
# set quota
test_0() {
$LFS quotaoff -ug $DIR
$LFS quotacheck -ug $DIR
- $LFS setquota -u $TSTUSR -b 0 -B 0 -i 0 -I 0 $DIR
- $LFS setquota -g $TSTUSR -b 0 -B 0 -i 0 -I 0 $DIR
+ resetquota -u $TSTUSR
+ resetquota -g $TSTUSR
lctl set_param debug="+quota"
do_facet $SINGLEMDS "lctl set_param debug=+quota"
[ $OST0_QUOTA_USED -ne 0 ] && \
($SHOW_QUOTA_USER; error "quota deleted isn't released")
$SHOW_QUOTA_USER
- $LFS setquota -u $TSTUSR -b 0 -B 0 -i 0 -I 0 $DIR
+ resetquota -u $TSTUSR
# test for group
log "--------------------------------------"
[ $OST0_QUOTA_USED -ne 0 ] && \
($SHOW_QUOTA_USER; error "quota deleted isn't released")
$SHOW_QUOTA_GROUP
- $LFS setquota -g $TSTUSR -b 0 -B 0 -i 0 -I 0 $DIR
+ resetquota -g $TSTUSR
}
# block hard limit (normal use and out of quota)
[ $MDS_QUOTA_USED -ne 0 ] && \
($SHOW_QUOTA_USER; error "quota deleted isn't released")
$SHOW_QUOTA_USER
- $LFS setquota -u $TSTUSR -b 0 -B 0 -i 0 -I 0 $DIR
+ resetquota -u $TSTUSR
# test for group
log "--------------------------------------"
[ $MDS_QUOTA_USED -ne 0 ] && \
($SHOW_QUOTA_USER; error "quota deleted isn't released")
$SHOW_QUOTA_GROUP
- $LFS setquota -g $TSTUSR -b 0 -B 0 -i 0 -I 0 $DIR
+ resetquota -g $TSTUSR
}
# file hard limit (normal use and out of quota)
$LFS setquota -u $TSTUSR -b $LIMIT -B 0 -i 0 -I 0 $DIR
test_block_soft $TESTFILE $GRACE
- $LFS setquota -u $TSTUSR -b 0 -B 0 -i 0 -I 0 $DIR
+ resetquota -u $TSTUSR
echo " Group quota (soft limit: $LIMIT kbytes grace: $GRACE seconds)"
TESTFILE=$DIR/$tdir/$tfile-1
$LFS setquota -g $TSTUSR -b $LIMIT -B 0 -i 0 -I 0 $DIR
test_block_soft $TESTFILE $GRACE
- $LFS setquota -g $TSTUSR -b 0 -B 0 -i 0 -I 0 $DIR
+ resetquota -g $TSTUSR
}
run_test_with_stat 3 "Block soft limit (start timer, timer goes off, stop timer) ==="
$SHOW_QUOTA_USER
test_file_soft $TESTFILE $LIMIT $GRACE
- $LFS setquota -u $TSTUSR -b 0 -B 0 -i 0 -I 0 $DIR
+ resetquota -u $TSTUSR
echo " Group quota (soft limit: $LIMIT files grace: $GRACE seconds)"
$LFS setquota -t -g --block-grace $MAX_DQ_TIME --inode-grace $GRACE $DIR
TESTFILE=$DIR/$tdir/$tfile-1
test_file_soft $TESTFILE $LIMIT $GRACE
- $LFS setquota -g $TSTUSR -b 0 -B 0 -i 0 -I 0 $DIR
+ resetquota -g $TSTUSR
# cleanup
$LFS setquota -t -u --block-grace $MAX_DQ_TIME --inode-grace $MAX_IQ_TIME $DIR
unlinkmany $DIR/$tdir/$tfile-0_ $((ILIMIT + 1))
sync; sleep 3; sync;
- $LFS setquota -u $TSTUSR -b 0 -B 0 -i 0 -I 0 $DIR
- $LFS setquota -g $TSTUSR -b 0 -B 0 -i 0 -I 0 $DIR
+ resetquota -u $TSTUSR
+ resetquota -g $TSTUSR
}
run_test_with_stat 5 "Chown & chgrp successfully even out of block/file quota ==="
rm -f $FILEA
sync; sleep 3; sync;
- $LFS setquota -u $TSTUSR -b 0 -B 0 -i 0 -I 0 $DIR
- $LFS setquota -g $TSTUSR -b 0 -B 0 -i 0 -I 0 $DIR
+ resetquota -u $TSTUSR
+ resetquota -g $TSTUSR
return 0
}
run_test_with_stat 6 "Block quota acquire & release ========="
echo " limits on $OST0_UUID = $OST0_LIMIT"
# cleanup
- $LFS setquota -u $TSTUSR -b 0 -B 0 -i 0 -I 0 $DIR
+ resetquota -u $TSTUSR
}
run_test_with_stat 7 "Quota recovery (only block limit) ======"
rm -f $TESTFILE $TESTFILE2
sync; sleep 3; sync;
- $LFS setquota -u $TSTUSR -b 0 -B 0 -i 0 -I 0 $DIR
+ resetquota -u $TSTUSR
}
run_test_with_stat 12 "test a deadlock between quota and journal ==="
rm -f $TESTFILE $TESTFILE.2
sync; sleep 3; sync;
- $LFS setquota -u $TSTUSR -b 0 -B 0 -i 0 -I 0 $DIR
+ resetquota -u $TSTUSR
}
run_test_with_stat 13 "test multiple clients write block quota ==="
# do the check
dmesg | tail | grep "\-122" |grep llog_obd_origin_add && error "err -122 not found in dmesg"
- $LFS setquota -u root -b 0 -B 0 -i 0 -I 0 $DIR
+ resetquota -u root
#check_if_quota_zero u root
# clean
TOTAL_LIMIT="`$LFS quota -v -u $TSTUSR $DIR | awk '/^.*'$PATTERN'.*[[:digit:]+][[:space:]+]/ { print $4 }'`"
[ $TOTAL_LIMIT -eq $LIMIT ] || error " (user)total limits = $TOTAL_LIMIT; limit = $LIMIT, failed!"
echo " (user)total limits = $TOTAL_LIMIT; limit = $LIMIT, successful!"
- $LFS setquota -u $TSTUSR -b 0 -B 0 -i 0 -I 0 $DIR
+ resetquota -u $TSTUSR
# test for group
$LFS setquota -g $TSTUSR -b 0 -B $LIMIT -i 0 -I 0 $DIR
TOTAL_LIMIT="`$LFS quota -v -g $TSTUSR $DIR | awk '/^.*'$PATTERN'.*[[:digit:]+][[:space:]+]/ { print $4 }'`"
[ $TOTAL_LIMIT -eq $LIMIT ] || error " (group)total limits = $TOTAL_LIMIT; limit = $LIMIT, failed!"
echo " (group)total limits = $TOTAL_LIMIT; limit = $LIMIT, successful!"
- $LFS setquota -g $TSTUSR -b 0 -B 0 -i 0 -I 0 $DIR
+ resetquota -g $TSTUSR
$LFS quotaoff -ug $DIR
do_facet $SINGLEMDS "lctl set_param lquota.mdd_obd-${FSNAME}-MDT*.quota_type=ug" | grep "error writing" && \
error "fail to set version for $SINGLEMDS"
rm -f $TESTFILE
sync; sleep 3; sync;
- $LFS setquota -$1 $TSTUSR -b 0 -B 0 -i 0 -I 0 $DIR
+ resetquota -$1 $TSTUSR
}
# test without adjusting qunit
set_blk_unitsz $((128 * 1024))
set_blk_tunesz $((128 * 1024 / 2))
- $LFS setquota -u $TSTUSR -b 0 -B 0 -i 0 -I 0 $MOUNT
- $LFS setquota -g $TSTUSR -b 0 -B 0 -i 0 -I 0 $MOUNT
+ resetquota -u $TSTUSR
+ resetquota -g $TSTUSR
return $RC
}
rm -f $TESTFILE
sync; sleep 3; sync;
- $LFS setquota -u $TSTUSR -b 0 -B 0 -i 0 -I 0 $MOUNT
+ resetquota -u $TSTUSR
set_blk_unitsz $((128 * 1024))
set_blk_tunesz $((128 * 1024 / 2))
rm -f $TESTFILE
sync; sleep 3; sync;
- $LFS setquota -u $TSTUSR -b 0 -B 0 -i 0 -I 0 $MOUNT
+ resetquota -u $TSTUSR
set_blk_unitsz $((128 * 1024))
set_blk_tunesz $((128 * 1024 / 2))
[ $testfile_size -ne $((BLK_SZ * 1024 * 100)) ] && \
error "expect $((BLK_SZ * 1024 * 100)), got ${testfile_size}. Verifying file failed!"
$SHOW_QUOTA_USER
- $LFS setquota -u $TSTUSR -b 0 -B 0 -i 0 -I 0 $MOUNT
+ resetquota -u $TSTUSR
rm -rf $TESTFILE
sync; sleep 1; sync
}
# cleanup
rm -f $TESTFILE
- $LFS setquota -u $TSTUSR -b 0 -B 0 -i 0 -I 0 $MOUNT
+ resetquota -u $TSTUSR
set_blk_unitsz $((128 * 1024))
set_blk_tunesz $((128 * 1024 / 2))
grep -E '^ *'$MOUNT' *[0-9]+\** *'${LVAL[0]}' *'${LVAL[1]}' *[0-9]+\** *'${LVAL[2]}' *'${LVAL[3]}) \
|| error "lfs quota output is unexpected"
- $LFS setquota -u $TSTUSR -b 0 -B 0 -i 0 -I 0 \
- $MOUNT || error "could not reset quota limits"
-
+ resetquota -u $TSTUSR
}
run_test_with_stat 20 "test if setquota specifiers work properly (15754)"
set_blk_unitsz $((128 * 1024))
set_blk_tunesz $((128 * 1024 / 2))
- $LFS setquota -u $TSTUSR -b 0 -B 0 -i 0 -I 0 $MOUNT
- $LFS setquota -g $TSTUSR -b 0 -B 0 -i 0 -I 0 $MOUNT
+ resetquota -u $TSTUSR
+ resetquota -g $TSTUSR
return $RC
}
[ $OST0_QUOTA_USED -ne 0 ] && \
($SHOW_QUOTA_USER; error "quota deleted isn't released")
$SHOW_QUOTA_USER
- $LFS setquota -u $TSTUSR -b 0 -B 0 -i 0 -I 0 $DIR
+ resetquota -u $TSTUSR
}
test_23() {
# cleanup
rm -f $TESTFILE
- $LFS setquota -u $TSTUSR -b 0 -B 0 -i 0 -I 0 $MOUNT
+ resetquota -u $TSTUSR
set_blk_unitsz $((128 * 1024))
set_blk_tunesz $((128 * 1024 / 2))