From cc623e9ff1a0b6e3ffcdfac086a7630f93e70b93 Mon Sep 17 00:00:00 2001 From: James Nunez Date: Tue, 5 May 2015 11:53:30 -0600 Subject: [PATCH] LU-2524 test: Clean up sanity-quota MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Conduct miscellaneous cleanup to sanity-quota including: Removing the `-p` (parents) option from many calls to mkdir Replace `lfs setstripe` with $SETSTRIPE Added check for and call to `error` with error messages for a variety of common routines ,like mkdir, or for functions that return a value. Replace `…` with $(...) Removed linefeed escape after |, ||, & and && operators. Modified parameters in test 4b so that the --inode-grace value exceeds the valid range. Removed unused variables Removed $ from variables inside $(()) Signed-off-by: James Nunez Change-Id: Iadedea0bd0a0f85235e0bb908ee0a6ed36503eb3 Reviewed-on: http://review.whamcloud.com/14680 Tested-by: Jenkins Tested-by: Maloo Reviewed-by: Jian Yu Reviewed-by: Wei Liu Reviewed-by: Saurabh Tandan Reviewed-by: Oleg Drokin --- lustre/tests/sanity-quota.sh | 215 ++++++++++++++++++++++--------------------- 1 file changed, 108 insertions(+), 107 deletions(-) diff --git a/lustre/tests/sanity-quota.sh b/lustre/tests/sanity-quota.sh index f8d7413..bd66215 100644 --- a/lustre/tests/sanity-quota.sh +++ b/lustre/tests/sanity-quota.sh @@ -6,15 +6,16 @@ # Run test by setting NOSETUP=true when ltest has setup env for us set -e -SRCDIR=`dirname $0` +SRCDIR=$(dirname $0) export PATH=$PWD/$SRCDIR:$SRCDIR:$PWD/$SRCDIR/../utils:$PATH:/sbin ONLY=${ONLY:-"$*"} +# Bug number for skipped test: ALWAYS_EXCEPT="$SANITY_QUOTA_EXCEPT" # UPDATE THE COMMENT ABOVE WITH BUG NUMBERS WHEN CHANGING ALWAYS_EXCEPT! [ "$ALWAYS_EXCEPT$EXCEPT" ] && - echo "Skipping tests: `echo $ALWAYS_EXCEPT $EXCEPT`" + echo "Skipping tests: $ALWAYS_EXCEPT $EXCEPT" TMP=${TMP:-/tmp} @@ -73,15 +74,13 @@ export QUOTA_AUTO=0 check_and_setup_lustre -LOVNAME=`lctl get_param -n llite.*.lov.common_name | tail -n 1` -OSTCOUNT=`lctl get_param -n lov.$LOVNAME.numobd` +LOVNAME=$(lctl get_param -n llite.*.lov.common_name | tail -n 1) +OSTCOUNT=$(lctl get_param -n lov.$LOVNAME.numobd) SHOW_QUOTA_USER="$LFS quota -v -u $TSTUSR $DIR" SHOW_QUOTA_USERID="$LFS quota -v -u $TSTID $DIR" -SHOW_QUOTA_USER2="$LFS quota -v -u $TSTUSR2 $DIR" SHOW_QUOTA_GROUP="$LFS quota -v -g $TSTUSR $DIR" SHOW_QUOTA_GROUPID="$LFS quota -v -g $TSTID $DIR" -SHOW_QUOTA_GROUP2="$LFS quota -v -g $TSTUSR2 $DIR" SHOW_QUOTA_INFO_USER="$LFS quota -t -u $DIR" SHOW_QUOTA_INFO_GROUP="$LFS quota -t -g $DIR" @@ -162,7 +161,6 @@ quota_log() { # get quota for a user or a group # usage: getquota -u|-g | global| \ # bhardlimit|bsoftlimit|bgrace|ihardlimit|isoftlimit|igrace -# getquota() { local spec local uuid @@ -296,11 +294,10 @@ wait_ost_reint() { } setup_quota_test() { - rm -rf $DIR/$tdir wait_delete_completed echo "Creating test directory" - mkdir -p $DIR/$tdir - chmod 0777 $DIR/$tdir + mkdir $DIR/$tdir || return 1 + chmod 0777 $DIR/$tdir || return 2 # always clear fail_loc in case of fail_loc isn't cleared # properly when previous test failed lustre_fail mds_ost 0 @@ -388,7 +385,7 @@ test_0() { [ $free_space -le $((MB * 1024)) ] && skip "not enough space ${free_space} KB, " \ "required $((MB * 1024)) KB" && return - setup_quota_test + setup_quota_test || error "setup quota failed with $?" trap cleanup_quota_test EXIT set_ost_qtype "none" || error "disable ost quota failed" @@ -409,7 +406,7 @@ test_1() { local LIMIT=10 # 10M local TESTFILE="$DIR/$tdir/$tfile-0" - setup_quota_test + setup_quota_test || error "setup quota failed with $?" trap cleanup_quota_test EXIT # enable ost quota @@ -424,8 +421,8 @@ test_1() { 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 - chown $TSTUSR.$TSTUSR $TESTFILE + $SETSTRIPE $TESTFILE -c 1 || error "setstripe $TESTFILE failed" + chown $TSTUSR.$TSTUSR $TESTFILE || error "chown $TESTFILE failed" log "Write..." $RUNAS $DD of=$TESTFILE count=$((LIMIT/2)) || @@ -439,7 +436,7 @@ test_1() { quota_error u $TSTUSR "user write success, but expect EDQUOT" rm -f $TESTFILE - wait_delete_completed + 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 \ @@ -457,8 +454,8 @@ test_1() { USED=$(getquota -g $TSTUSR global curspace) [ $USED -ne 0 ] && error "Used space($USED) for group $TSTUSR isn't 0" - $LFS setstripe $TESTFILE -c 1 - chown $TSTUSR.$TSTUSR $TESTFILE + $SETSTRIPE $TESTFILE -c 1 || error "setstripe $TESTFILE failed" + chown $TSTUSR.$TSTUSR $TESTFILE || error "chown $TESTFILE failed" log "Write ..." $RUNAS $DD of=$TESTFILE count=$((LIMIT/2)) || @@ -494,7 +491,7 @@ test_2() { skip "not enough free inodes $FREE_INODES required $LIMIT" && return - setup_quota_test + setup_quota_test || error "setup quota failed with $?" trap cleanup_quota_test EXIT # enable mdt quota @@ -510,14 +507,14 @@ test_2() { [ $USED -ne 0 ] && error "Used inodes($USED) for user $TSTUSR isn't 0." log "Create $LIMIT files ..." - $RUNAS createmany -m ${TESTFILE} $LIMIT || \ + $RUNAS createmany -m ${TESTFILE} $LIMIT || quota_error u $TSTUSR "user create failure, but expect success" log "Create out of file quota ..." - $RUNAS touch ${TESTFILE}_xxx && \ + $RUNAS touch ${TESTFILE}_xxx && quota_error u $TSTUSR "user create success, but expect EDQUOT" # cleanup - unlinkmany ${TESTFILE} $LIMIT + unlinkmany ${TESTFILE} $LIMIT || error "unlinkmany $TESTFILE failed" rm -f ${TESTFILE}_xxx wait_delete_completed @@ -532,7 +529,7 @@ test_2() { $LFS setquota -g $TSTUSR -b 0 -B 0 -i 0 -I $LIMIT $DIR || error "set group quota failed" - TESTFILE=$DIR/$tdir/$tfile-1 + TESTFILE=$DIR/$tdir/$tfile-1 # make sure the system is clean USED=$(getquota -g $TSTUSR global curinodes) [ $USED -ne 0 ] && error "Used inodes($USED) for group $TSTUSR isn't 0." @@ -541,11 +538,11 @@ test_2() { $RUNAS createmany -m ${TESTFILE} $LIMIT || quota_error g $TSTUSR "group create failure, but expect success" log "Create out of file quota ..." - $RUNAS touch ${TESTFILE}_xxx && \ + $RUNAS touch ${TESTFILE}_xxx && quota_error g $TSTUSR "group create success, but expect EDQUOT" # cleanup - unlinkmany ${TESTFILE} $LIMIT + unlinkmany ${TESTFILE} $LIMIT || error "unlinkmany $TESTFILE failed" rm -f ${TESTFILE}_xxx wait_delete_completed @@ -567,7 +564,7 @@ test_block_soft() { setup_quota_test trap cleanup_quota_test EXIT - $LFS setstripe $TESTFILE -c 1 -i 0 + $SETSTRIPE $TESTFILE -c 1 -i 0 chown $TSTUSR.$TSTUSR $TESTFILE echo "Write up to soft limit" @@ -624,7 +621,7 @@ test_block_soft() { $SHOW_QUOTA_INFO_USER $SHOW_QUOTA_INFO_GROUP - $LFS setstripe $TESTFILE -c 1 -i 0 + $SETSTRIPE $TESTFILE -c 1 -i 0 chown $TSTUSR.$TSTUSR $TESTFILE echo "Write ..." @@ -790,7 +787,8 @@ test_4b() { local GR_STR3="5s" local GR_STR4="1w2d3h4m5s" local GR_STR5="5c" - local GR_STR6="1111111111111111" + local GR_STR6="18446744073709551615" + local GR_STR7="-1" wait_delete_completed @@ -807,6 +805,8 @@ test_4b() { echo " Invalid grace strings test" ! $LFS setquota -t -u --block-grace $GR_STR4 --inode-grace $GR_STR5 $DIR ! $LFS setquota -t -g --block-grace $GR_STR4 --inode-grace $GR_STR6 $DIR + ! $LFS setquota -t -g --block-grace $GR_STR4 --inode-grace \ + $GR_STR7 $DIR # cleanup $LFS setquota -t -u --block-grace $MAX_DQ_TIME --inode-grace \ @@ -821,7 +821,7 @@ test_5() { local BLIMIT=10 # 10M local ILIMIT=10 # 10 inodes - setup_quota_test + setup_quota_test || error "setup quota failed with $?" trap cleanup_quota_test EXIT set_mdt_qtype "ug" || error "enable mdt quota failed" @@ -850,13 +850,14 @@ test_5() { error "write failure, expect success" echo "Chown files to $TSTUSR.$TSTUSR ..." - for i in `seq 0 $ILIMIT`; do + for i in $(seq 0 $ILIMIT); do chown $TSTUSR.$TSTUSR $DIR/$tdir/$tfile-0_$i || quota_error a $TSTUSR "chown failure, expect success" done # cleanup - unlinkmany $DIR/$tdir/$tfile-0_ $((ILIMIT + 1)) + unlinkmany $DIR/$tdir/$tfile-0_ $((ILIMIT + 1)) || + error "unlinkmany $DIR/$tdir/$tfile-0_ failed" cleanup_quota_test resetquota -u $TSTUSR @@ -872,7 +873,7 @@ test_6() { # test output do_facet ost1 dmesg -c > /dev/null - setup_quota_test + setup_quota_test || error "setup quota failed with $?" trap cleanup_quota_test EXIT # make sure the system is clean @@ -885,13 +886,13 @@ test_6() { # create file for $TSTUSR local TESTFILE=$DIR/$tdir/$tfile-$TSTUSR - $LFS setstripe $TESTFILE -c 1 -i 0 - chown $TSTUSR.$TSTUSR $TESTFILE + $SETSTRIPE $TESTFILE -c 1 -i 0 || error "setstripe $TESTFILE failed" + chown $TSTUSR.$TSTUSR $TESTFILE || error "chown $TESTFILE failed" # create file for $TSTUSR2 local TESTFILE2=$DIR/$tdir/$tfile-$TSTUSR2 - $LFS setstripe $TESTFILE2 -c 1 -i 0 - chown $TSTUSR2.$TSTUSR2 $TESTFILE2 + $SETSTRIPE $TESTFILE2 -c 1 -i 0 || error "setstripe $TESTFILE2 failed" + chown $TSTUSR2.$TSTUSR2 $TESTFILE2 || error "chown $TESTFILE2 failed" # cache per-ID lock for $TSTUSR on slave $LFS setquota -u $TSTUSR -b 0 -B ${LIMIT}M -i 0 -I 0 $DIR || @@ -965,7 +966,7 @@ test_7a() { [ "$SLOW" = "no" ] && LIMIT=5 - setup_quota_test + setup_quota_test || error "setup quota failed with $?" trap cleanup_quota_test EXIT # make sure the system is clean @@ -979,12 +980,12 @@ test_7a() { local OSTUUID=$(ostuuid_from_index 0) USED=$(getquota -u $TSTUSR $OSTUUID bhardlimit) - [ $USED -ne 0 ] && error "limit($USED) on $OSTUUID for user" \ - "$TSTUSR isn't 0." + [ $USED -ne 0 ] && + error "limit($USED) on $OSTUUID for user $TSTUSR isn't 0" # create test file - $LFS setstripe $TESTFILE -c 1 -i 0 - chown $TSTUSR.$TSTUSR $TESTFILE + $SETSTRIPE $TESTFILE -c 1 -i 0 || error "setstripe $TESTFILE failed" + chown $TSTUSR.$TSTUSR $TESTFILE || error "chown $TESTFILE failed" echo "Stop ost1..." stop ost1 @@ -995,7 +996,7 @@ test_7a() { error "set quota failed" echo "Start ost1..." - start ost1 $(ostdevname 1) $OST_MOUNT_OPTS + start ost1 $(ostdevname 1) $OST_MOUNT_OPTS || error "start ost1 failed" quota_init wait_ost_reint "ug" || error "reintegration failed" @@ -1017,7 +1018,7 @@ test_7a() { error "clear quota failed" echo "Start ost1..." - start ost1 $(ostdevname 1) $OST_MOUNT_OPTS + start ost1 $(ostdevname 1) $OST_MOUNT_OPTS || error "start ost1 failed" quota_init wait_ost_reint "ug" || error "reintegration failed" @@ -1036,7 +1037,7 @@ test_7b() { local LIMIT="100G" local TESTFILE=$DIR/$tdir/$tfile - setup_quota_test + setup_quota_test || error "setup quota failed with $?" trap cleanup_quota_test EXIT # make sure the system is clean @@ -1050,12 +1051,12 @@ test_7b() { local OSTUUID=$(ostuuid_from_index 0) USED=$(getquota -u $TSTUSR $OSTUUID bhardlimit) - [ $USED -ne 0 ] && error "limit($USED) on $OSTUUID for user" \ - "$TSTUSR isn't 0." + [ $USED -ne 0 ] && + error "limit($USED) on $OSTUUID for user $TSTUSR isn't 0" # create test file - $LFS setstripe $TESTFILE -c 1 -i 0 - chown $TSTUSR.$TSTUSR $TESTFILE + $SETSTRIPE $TESTFILE -c 1 -i 0 || error "setstripe $TESTFILE failed" + chown $TSTUSR.$TSTUSR $TESTFILE || error "chown $TESTFILE failed" # consume some space to make sure the granted space will not # be released during reconciliation @@ -1078,7 +1079,7 @@ test_7b() { echo "Restart ost to trigger reintegration..." stop ost1 - start ost1 $(ostdevname 1) $OST_MOUNT_OPTS + start ost1 $(ostdevname 1) $OST_MOUNT_OPTS || error "start ost1 failed" quota_init wait_ost_reint "ug" || error "reintegration failed" @@ -1099,7 +1100,7 @@ test_7c() { [ "$SLOW" = "no" ] && LIMIT=5 - setup_quota_test + setup_quota_test || error "setup quota failed with $?" trap cleanup_quota_test EXIT # make sure the system is clean @@ -1150,7 +1151,7 @@ test_7d(){ local TESTFILE1="$DIR/$tdir/$tfile"-1 local limit=20 #20M - setup_quota_test + setup_quota_test || error "setup quota failed with $?" trap cleanup_quota_test EXIT set_ost_qtype "none" || error "disable ost quota failed" @@ -1189,7 +1190,7 @@ test_7e() { local ilimit=$((1024 * 2)) # 2k inodes local TESTFILE=$DIR/${tdir}-1/$tfile - setup_quota_test + setup_quota_test || error "setup quota failed with $?" trap cleanup_quota_test EXIT # make sure the system is clean @@ -1211,7 +1212,7 @@ test_7e() { echo "Enable quota & set quota limit for $TSTUSR" set_mdt_qtype "ug" || error "enable mdt quota failed" - $LFS setquota -u $TSTUSR -b 0 -B 0 -i 0 -I $ilimit $DIR || + $LFS setquota -u $TSTUSR -b 0 -B 0 -i 0 -I $ilimit $DIR || error "set quota failed" echo "Start mds${MDSCOUNT}..." @@ -1263,7 +1264,7 @@ test_8() { local BLK_LIMIT="100g" #100G local FILE_LIMIT=1000000 - setup_quota_test + setup_quota_test || error "setup quota failed with $?" trap cleanup_quota_test EXIT set_mdt_qtype "ug" || error "enable mdt quota failed" @@ -1307,7 +1308,7 @@ test_9() { check_whether_skip && return 0 - setup_quota_test + setup_quota_test || error "setup quota failed with $?" trap cleanup_quota_test EXIT set_ost_qtype "ug" || error "enable ost quota failed" @@ -1332,8 +1333,8 @@ test_9() { quota_show_check a g $TSTUSR echo "Create test file" - $LFS setstripe $TESTFILE -c 1 -i 0 - chown $TSTUSR.$TSTUSR $TESTFILE + $SETSTRIPE $TESTFILE -c 1 -i 0 || error "setstripe $TESTFILE failed" + chown $TSTUSR.$TSTUSR $TESTFILE || error "chown $TESTFILE failed" log "Write the big file of 4.5G ..." $RUNAS $DD of=$TESTFILE count=$filesize || @@ -1354,7 +1355,7 @@ run_test 9 "Block limit larger than 4GB (b10707)" test_10() { local TESTFILE=$DIR/$tdir/$tfile - setup_quota_test + setup_quota_test || error "setup quota failed with $?" trap cleanup_quota_test EXIT # set limit to root user should fail @@ -1370,8 +1371,8 @@ test_10() { error "set quota failed" quota_show_check b u $TSTUSR - $LFS setstripe $TESTFILE -c 1 - chown $TSTUSR.$TSTUSR $TESTFILE + $SETSTRIPE $TESTFILE -c 1 || error "setstripe $TESTFILE failed" + chown $TSTUSR.$TSTUSR $TESTFILE || error "chown $TESTFILE failed" runas -u 0 -g 0 $DD of=$TESTFILE count=3 oflag=sync || error "write failure, expect success" @@ -1383,18 +1384,18 @@ run_test 10 "Test quota for root user" test_11() { local TESTFILE=$DIR/$tdir/$tfile - setup_quota_test + setup_quota_test || error "setup quota failed with $?" trap cleanup_quota_test EXIT set_mdt_qtype "ug" || "enable mdt quota failed" $LFS setquota -u $TSTUSR -b 0 -B 0 -i 0 -I 1 $DIR || error "set quota failed" - touch "$TESTFILE"-0 - touch "$TESTFILE"-1 + touch "$TESTFILE"-0 || error "touch $TESTFILE-0 failed" + touch "$TESTFILE"-1 || error "touch $TESTFILE-0 failed" - chown $TSTUSR.$TSTUSR "$TESTFILE"-0 - chown $TSTUSR.$TSTUSR "$TESTFILE"-1 + chown $TSTUSR.$TSTUSR "$TESTFILE"-0 || error "chown $TESTFILE-0 failed" + chown $TSTUSR.$TSTUSR "$TESTFILE"-1 || error "chown $TESTFILE-1 failed" $SHOW_QUOTA_USER local USED=$(getquota -u $TSTUSR global curinodes) @@ -1413,7 +1414,7 @@ test_12a() { local TESTFILE0="$DIR/$tdir/$tfile"-0 local TESTFILE1="$DIR/$tdir/$tfile"-1 - setup_quota_test + setup_quota_test || error "setup quota failed with $?" trap cleanup_quota_test EXIT set_ost_qtype "u" || "enable ost quota failed" @@ -1422,10 +1423,10 @@ test_12a() { $LFS setquota -u $TSTUSR -b 0 -B "$blimit"M -i 0 -I 0 $DIR || error "set quota failed" - $LFS setstripe $TESTFILE0 -c 1 -i 0 - $LFS setstripe $TESTFILE1 -c 1 -i 1 - chown $TSTUSR.$TSTUSR $TESTFILE0 - chown $TSTUSR.$TSTUSR $TESTFILE1 + $SETSTRIPE $TESTFILE0 -c 1 -i 0 || error "setstripe $TESTFILE0 failed" + $SETSTRIPE $TESTFILE1 -c 1 -i 1 || error "setstripe $TESTFILE1 failed" + chown $TSTUSR.$TSTUSR $TESTFILE0 || error "chown $TESTFILE0 failed" + chown $TSTUSR.$TSTUSR $TESTFILE1 || error "chown $TESTFILE1 failed" echo "Write to ost0..." $RUNAS $DD of=$TESTFILE0 count=$blk_cnt oflag=sync || @@ -1456,7 +1457,7 @@ test_12b() { local TESTFILE0=$DIR/$tdir/$tfile local TESTFILE1=$DIR/${tdir}-1/$tfile - setup_quota_test + setup_quota_test || error "setup quota failed with $?" trap cleanup_quota_test EXIT $LFS mkdir -i 1 $DIR/${tdir}-1 || error "create remote dir failed" @@ -1499,7 +1500,7 @@ test_13(){ # the name of lwp on ost1 name is MDT0000-lwp-OST0000 local procf="ldlm.namespaces.*MDT0000-lwp-OST0000.lru_size" - setup_quota_test + setup_quota_test || error "setup quota failed with $?" trap cleanup_quota_test EXIT set_ost_qtype "u" || "enable ost quota failed" @@ -1507,8 +1508,8 @@ test_13(){ $LFS setquota -u $TSTUSR -b 0 -B 10M -i 0 -I 0 $DIR || error "set quota failed" - $LFS setstripe $TESTFILE -c 1 -i 0 - chown $TSTUSR.$TSTUSR $TESTFILE + $SETSTRIPE $TESTFILE -c 1 -i 0 || error "setstripe $TESTFILE failed" + chown $TSTUSR.$TSTUSR $TESTFILE || error "chown $TESTFILE failed" # clear the locks in cache first do_facet ost1 $LCTL set_param -n $procf=clear @@ -1549,7 +1550,7 @@ test_15(){ wait_delete_completed sync_all_data || true - # test for user + # test for user $LFS setquota -u $TSTUSR -b 0 -B $LIMIT -i 0 -I 0 $DIR || error "set user quota failed" local TOTAL_LIMIT=$(getquota -u $TSTUSR global bhardlimit) @@ -1572,7 +1573,7 @@ test_17sub() { local BLKS=1 # 1M less than limit local TESTFILE=$DIR/$tdir/$tfile - setup_quota_test + setup_quota_test || error "setup quota failed with $?" trap cleanup_quota_test EXIT # make sure the system is clean @@ -1617,7 +1618,7 @@ test_17sub() { sync; sync_all_data || true USED=$(getquota -u $TSTUSR global curspace) - [ $USED -ge $(($BLKS * 1024)) ] || quota_error u $TSTUSR \ + [ $USED -ge $((BLKS * 1024)) ] || quota_error u $TSTUSR \ "Used space(${USED}K) is less than ${BLKS}M" cleanup_quota_test @@ -1650,7 +1651,7 @@ test_18_sub () { local blimit="200m" # 200M local TESTFILE="$DIR/$tdir/$tfile" - setup_quota_test + setup_quota_test || error "setup quota failed with $?" trap cleanup_quota_test EXIT set_ost_qtype "u" || error "enable ost quota failed" @@ -1659,8 +1660,8 @@ test_18_sub () { error "set quota failed" quota_show_check b u $TSTUSR - $LFS setstripe $TESTFILE -i 0 -c 1 - chown $TSTUSR.$TSTUSR $TESTFILE + $SETSTRIPE $TESTFILE -i 0 -c 1 || error "setstripe $TESTFILE failed" + chown $TSTUSR.$TSTUSR $TESTFILE || error "chown $TESTFILE failed" local timeout=$(sysctl -n lustre.timeout) @@ -1730,16 +1731,16 @@ test_19() { local blimit=5 # 5M local TESTFILE=$DIR/$tdir/$tfile - setup_quota_test + setup_quota_test || error "setup quota failed with $?" trap cleanup_quota_test EXIT set_ost_qtype "ug" || error "enable ost quota failed" # bind file to a single OST - $LFS setstripe -c 1 $TESTFILE - chown $TSTUSR.$TSTUSR $TESTFILE + $SETSTRIPE -c 1 $TESTFILE || error "setstripe $TESTFILE failed" + chown $TSTUSR.$TSTUSR $TESTFILE || error "chown $TESTFILE failed" - echo "Set user quota (limit: "$blimit"M)" + echo "Set user quota (limit: ${blimit}M)" $LFS setquota -u $TSTUSR -b 0 -B "$blimit"M -i 0 -I 0 $MOUNT || error "set user quota failed" quota_show_check b u $TSTUSR @@ -1764,7 +1765,8 @@ run_test 19 "Updating admin limits doesn't zero operational limits(b14790)" test_20() { # b15754 local LSTR=(2g 1t 4k 3m) # limits strings # limits values - local LVAL=($[2*1024*1024] $[1*1024*1024*1024] $[4*1024] $[3*1024*1024]) + local LVAL=($((2*1024*1024)) $((1*1024*1024*1024)) $((4*1024)) \ + $((3*1024*1024))) resetquota -u $TSTUSR @@ -1806,7 +1808,7 @@ test_21() { local BLIMIT=10 # 10G local ILIMIT=1000000 - setup_quota_test + setup_quota_test || error "setup quota failed with $?" trap cleanup_quota_test EXIT set_ost_qtype "ug" || error "Enable ost quota failed" @@ -1874,7 +1876,7 @@ test_22() { set_ost_qtype "ug" || error "enable ost quota failed" echo "Restart..." - stopall + stopall || error "failed to stopall (1)" mount setupall @@ -1889,7 +1891,7 @@ test_22() { set_ost_qtype "none" || error "disable ost quota failed" echo "Restart..." - stopall + stopall || error "failed to stopall (2)" mount setupall quota_init @@ -1908,7 +1910,7 @@ test_23_sub() { local TESTFILE="$DIR/$tdir/$tfile" local LIMIT=$1 - setup_quota_test + setup_quota_test || error "setup quota failed with $?" trap cleanup_quota_test EXIT set_ost_qtype "ug" || error "Enable ost quota failed" @@ -1919,8 +1921,8 @@ test_23_sub() { error "set quota failed" quota_show_check b u $TSTUSR - $LFS setstripe $TESTFILE -c 1 -i 0 - chown $TSTUSR.$TSTUSR $TESTFILE + $SETSTRIPE $TESTFILE -c 1 -i 0 || error "setstripe $TESTFILE failed" + chown $TSTUSR.$TSTUSR $TESTFILE || error "chown $TESTFILE failed" log "Step1: trigger EDQUOT with O_DIRECT" log "Write half of file" @@ -1972,16 +1974,16 @@ test_24() { local blimit=5 # 5M local TESTFILE="$DIR/$tdir/$tfile" - setup_quota_test + setup_quota_test || error "setup quota failed with $?" trap cleanup_quota_test EXIT set_ost_qtype "ug" || error "enable ost quota failed" # bind file to a single OST - $LFS setstripe -c 1 $TESTFILE - chown $TSTUSR.$TSTUSR $TESTFILE + $SETSTRIPE -c 1 $TESTFILE || error "setstripe $TESTFILE failed" + chown $TSTUSR.$TSTUSR $TESTFILE || error "chown $TESTFILE failed" - echo "Set user quota (limit: "$blimit"M)" + echo "Set user quota (limit: ${blimit}M)" $LFS setquota -u $TSTUSR -b 0 -B "$blimit"M -i 0 -I 0 $MOUNT || error "set quota failed" @@ -2047,18 +2049,17 @@ test_27c() { run_test 27c "lfs quota should support human-readable output" test_30() { - local output local LIMIT=4 # 4MB local TESTFILE="$DIR/$tdir/$tfile" local GRACE=10 - setup_quota_test + setup_quota_test || error "setup quota failed with $?" trap cleanup_quota_test EXIT set_ost_qtype "u" || error "enable ost quota failed" - $LFS setstripe $TESTFILE -i 0 -c 1 - chown $TSTUSR.$TSTUSR $TESTFILE + $SETSTRIPE $TESTFILE -i 0 -c 1 || error "setstripe $TESTFILE failed" + chown $TSTUSR.$TSTUSR $TESTFILE || error "chown $TESTFILE failed" $LFS setquota -t -u --block-grace $GRACE --inode-grace \ $MAX_IQ_TIME $DIR || error "set grace time failed" @@ -2091,7 +2092,7 @@ test_33() { local BLK_CNT=2 # of 2M each local TOTAL_BLKS=$((INODES * BLK_CNT * 1024)) - setup_quota_test + setup_quota_test || error "setup quota failed with $?" trap cleanup_quota_test EXIT # make sure the system is clean @@ -2103,7 +2104,7 @@ test_33() { error "Used space ($USED) for group $TSTID isn't 0." echo "Write files..." - for i in `seq 0 $INODES`; do + for i in $(seq 0 $INODES); do $RUNAS $DD of=$DIR/$tdir/$tfile-$i count=$BLK_CNT 2>/dev/null || error "write failed" echo "Iteration $i/$INODES completed" @@ -2143,10 +2144,10 @@ run_test 33 "Basic usage tracking for user & group" # usage transfer test for user & group test_34() { - local BLK_CNT=2 # 2MB + local BLK_CNT=2 # 2MB - setup_quota_test - trap cleanup_quota_test EXIT + setup_quota_test || error "setup quota failed with $?" + trap cleanup_quota_test EXIT # make sure the system is clean local USED=$(getquota -u $TSTID global curspace) @@ -2219,7 +2220,7 @@ run_test 34 "Usage transfer for user & group" test_35() { local BLK_CNT=2 # 2 MB - setup_quota_test + setup_quota_test || error "setup quota failed with $?" trap cleanup_quota_test EXIT echo "Write file..." @@ -2293,7 +2294,7 @@ run_test 35 "Usage is still accessible across reboot" # chown/chgrp to the file created with MDS_OPEN_DELAY_CREATE # LU-5006 test_37() { - setup_quota_test + setup_quota_test || error "setup quota failed with $?" trap cleanup_quota_test EXIT # make sure the system is clean @@ -2302,7 +2303,7 @@ test_37() { error "Used space ($USED) for user $TSTID isn't 0." # create file with MDS_OPEN_DELAY_CREATE flag - $LFS setstripe -c 1 -i 0 $DIR/$tdir/$tfile || + $SETSTRIPE -c 1 -i 0 $DIR/$tdir/$tfile || error "Create file failed" # write to file dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=1 conv=notrunc \ @@ -2322,7 +2323,7 @@ run_test 37 "Quota accounted properly for file created by 'lfs setstripe'" quota_fini() { - do_nodes $(comma_list $(nodes_list)) "lctl set_param debug=-quota" + do_nodes $(comma_list $(nodes_list)) "lctl set_param debug=-quota" } quota_fini -- 1.8.3.1