Whamcloud - gitweb
Call test_foo() functions directly instead of via run_one() so they do setup
[fs/lustre-release.git] / lustre / tests / sanity.sh
index 7c91dd5..538d819 100644 (file)
@@ -648,9 +648,7 @@ test_25a() {
 run_test 25a "create file in symlinked directory ==============="
 
 test_25b() {
-       if [ ! -d $DIR/d25 ]; then
-               run_one 25a
-       fi
+       [ ! -d $DIR/d25 ] && test_25a
        $CHECKSTAT -t file $DIR/s25/foo || error
 }
 run_test 25b "lookup file in symlinked directory ==============="
@@ -687,9 +685,7 @@ test_26d() {
 run_test 26d "create multiple component recursive symlink ======"
 
 test_26e() {
-       if [ ! -h $DIR/d26-3 ]; then
-               run_one 26d
-       fi
+       [ ! -h $DIR/d26-3 ] && test_26d
        rm $DIR/d26-3
 }
 run_test 26e "unlink multiple component recursive symlink ======"
@@ -697,7 +693,7 @@ run_test 26e "unlink multiple component recursive symlink ======"
 test_27a() {
        echo '== stripe sanity =============================================='
        mkdir $DIR/d27
-       $LSTRIPE $DIR/d27/f0 8192 0 1 || error
+       $LSTRIPE $DIR/d27/f0 65536 0 1 || error
        $CHECKSTAT -t file $DIR/d27/f0 || error
        pass
        log "== test_27b: write to one stripe file ========================="
@@ -710,7 +706,7 @@ test_27c() {
        if [ ! -d $DIR/d27 ]; then
                mkdir $DIR/d27
        fi
-       $LSTRIPE $DIR/d27/f01 8192 0 2 || error
+       $LSTRIPE $DIR/d27/f01 65536 0 2 || error
        [ `$LFIND $DIR/d27/f01 | grep -A 10 obdidx | wc -l` -eq 4 ] ||
                error "two-stripe file doesn't have two stripes"
        pass
@@ -733,8 +729,8 @@ test_27e() {
        if [ ! -d $DIR/d27 ]; then
                mkdir $DIR/d27
        fi
-       $LSTRIPE $DIR/d27/f12 8192 0 2 || error
-       $LSTRIPE $DIR/d27/f12 8192 0 2 && error
+       $LSTRIPE $DIR/d27/f12 65536 0 2 || error
+       $LSTRIPE $DIR/d27/f12 65536 0 2 && error
        $CHECKSTAT -t file $DIR/d27/f12 || error
 }
 run_test 27e "lstripe existing file (should return error) ======"
@@ -768,10 +764,23 @@ test_27j() {
         if [ ! -d $DIR/d27 ]; then
                 mkdir $DIR/d27
         fi
-        $LSTRIPE $DIR/d27/f27j 8192 $STRIPECOUNT 1 && error || true
+        $LSTRIPE $DIR/d27/f27j 65536 $STRIPECOUNT 1 && error || true
 }
 run_test 27j "lstripe with bad stripe offset (should return error)"
 
+test_27k() { # bug 2844
+       FILE=$DIR/d27/f27k
+       LL_MAX_BLKSIZE=$((4 * 1024 * 1024))
+       [ ! -d $DIR/d27 ] && mkdir -p $DIR/d27
+       $LSTRIPE $FILE 67108864 -1 0 || error "lstripe failed"
+       BLKSIZE=`stat $FILE | awk '/IO Block:/ { print $7 }'`
+       [ $BLKSIZE -le $LL_MAX_BLKSIZE ] || error "$BLKSIZE > $LL_MAX_BLKSIZE"
+       dd if=/dev/zero of=$FILE bs=4k count=1
+       BLKSIZE=`stat $FILE | awk '/IO Block:/ { print $7 }'`
+       [ $BLKSIZE -le $LL_MAX_BLKSIZE ] || error "$BLKSIZE > $LL_MAX_BLKSIZE"
+}
+run_test 27k "limit i_blksize for broken user apps ============="
+
 test_28() {
        mkdir $DIR/d28
        $CREATETEST $DIR/d28/ct || error
@@ -1085,92 +1094,91 @@ run_test 33a "test open file(mode=0444) with O_RDWR (should return error)"
 
 TEST_34_SIZE=${TEST_34_SIZE:-2000000000000}
 test_34a() {
-       rm -f $DIR/test_34_file
-       $MCREATE $DIR/test_34_file || error
-       $LFIND $DIR/test_34_file 2>&1 | grep -q "no stripe info" || error
-       $TRUNCATE $DIR/test_34_file $TEST_34_SIZE || error
-       $LFIND $DIR/test_34_file 2>&1 | grep -q "no stripe info" || error
-       $CHECKSTAT -s $TEST_34_SIZE $DIR/test_34_file || error
+       rm -f $DIR/f34
+       $MCREATE $DIR/f34 || error
+       $LFIND $DIR/f34 2>&1 | grep -q "no stripe info" || error
+       $TRUNCATE $DIR/f34 $TEST_34_SIZE || error
+       $LFIND $DIR/f34 2>&1 | grep -q "no stripe info" || error
+       $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
 }
 run_test 34a "truncate file that has not been opened ==========="
 
 test_34b() {
-       [ ! -f $DIR/test_34_file ] && run_one 34a
-       $CHECKSTAT -s $TEST_34_SIZE $DIR/test_34_file || error
-       $OPENFILE -f O_RDONLY $DIR/test_34_file
-       $LFIND $DIR/test_34_file 2>&1 | grep -q "no stripe info" || error
-       $CHECKSTAT -s $TEST_34_SIZE $DIR/test_34_file || error
+       [ ! -f $DIR/f34 ] && test_34a
+       $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
+       $OPENFILE -f O_RDONLY $DIR/f34
+       $LFIND $DIR/f34 2>&1 | grep -q "no stripe info" || error
+       $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
 }
 run_test 34b "O_RDONLY opening file doesn't create objects ====="
 
 test_34c() {
-       [ ! -f $DIR/test_34_file ] && run_one 34a 
-       $CHECKSTAT -s $TEST_34_SIZE $DIR/test_34_file || error
-       $OPENFILE -f O_RDWR $DIR/test_34_file
-       $LFIND $DIR/test_34_file 2>&1 | grep -q "no stripe info" && error
-       $CHECKSTAT -s $TEST_34_SIZE $DIR/test_34_file || error
+       [ ! -f $DIR/f34 ] && test_34a 
+       $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
+       $OPENFILE -f O_RDWR $DIR/f34
+       $LFIND $DIR/f34 2>&1 | grep -q "no stripe info" && error
+       $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
 }
 run_test 34c "O_RDWR opening file-with-size works =============="
 
 test_34d() {
-       dd if=/dev/zero of=$DIR/test_34_file conv=notrunc bs=4k count=1 || error
-       $CHECKSTAT -s $TEST_34_SIZE $DIR/test_34_file || error
-       rm $DIR/test_34_file
+       dd if=/dev/zero of=$DIR/f34 conv=notrunc bs=4k count=1 || error
+       $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
+       rm $DIR/f34
 }
 run_test 34d "write to sparse file ============================="
 
 test_34e() {
-       rm -f $DIR/test_34_file
-       $MCREATE $DIR/test_34_file || error
-       $TRUNCATE $DIR/test_34_file 1000 || error
-       $CHECKSTAT -s 1000 $DIR/test_34_file || error
-       $OPENFILE -f O_RDWR $DIR/test_34_file
-       $CHECKSTAT -s 1000 $DIR/test_34_file || error
+       rm -f $DIR/f34e
+       $MCREATE $DIR/f34e || error
+       $TRUNCATE $DIR/f34e 1000 || error
+       $CHECKSTAT -s 1000 $DIR/f34e || error
+       $OPENFILE -f O_RDWR $DIR/f34e
+       $CHECKSTAT -s 1000 $DIR/f34e || error
 }
 run_test 34e "create objects, some with size and some without =="
 
 test_35a() {
-       cp /bin/sh $DIR/test_35a_file
-       chmod 444 $DIR/test_35a_file
-       chown $RUNAS_ID $DIR/test_35a_file
-       $RUNAS $DIR/test_35a_file && error || true
-       rm $DIR/test_35a_file
+       cp /bin/sh $DIR/f35a
+       chmod 444 $DIR/f35a
+       chown $RUNAS_ID $DIR/f35a
+       $RUNAS $DIR/f35a && error || true
+       rm $DIR/f35a
 }
 run_test 35a "exec file with mode 444 (should return and not leak) ====="
 
-
 test_36a() {
-       rm -f $DIR/test_36_file
-       utime $DIR/test_36_file || error
+       rm -f $DIR/f36
+       utime $DIR/f36 || error
 }
 run_test 36a "MDS utime check (mknod, utime) ==================="
 
 test_36b() {
-       echo "" > $DIR/test_36_file
-       utime $DIR/test_36_file || error
+       echo "" > $DIR/f36
+       utime $DIR/f36 || error
 }
 run_test 36b "OST utime check (open, utime) ===================="
 
 test_36c() {
-       rm -f $DIR/d36/test_36_file
+       rm -f $DIR/d36/f36
        mkdir $DIR/d36
        chown $RUNAS_ID $DIR/d36
-       $RUNAS utime $DIR/d36/test_36_file || error
+       $RUNAS utime $DIR/d36/f36 || error
 }
 run_test 36c "non-root MDS utime check (mknod, utime) =========="
 
 test_36d() {
-       [ ! -d $DIR/d36 ] && run_one 36c
-       echo "" > $DIR/d36/test_36_file
-       $RUNAS utime $DIR/d36/test_36_file || error
+       [ ! -d $DIR/d36 ] && test_36c
+       echo "" > $DIR/d36/f36
+       $RUNAS utime $DIR/d36/f36 || error
 }
 run_test 36d "non-root OST utime check (open, utime) ==========="
 
 test_36e() {
        [ $RUNAS_ID -eq $UID ] && return
        [ ! -d $DIR/d36 ] && mkdir $DIR/d36
-       touch $DIR/d36/test_36_file2
-       $RUNAS utime $DIR/d36/test_36_file2 && error || true
+       touch $DIR/d36/f36e
+       $RUNAS utime $DIR/d36/f36e && error "utime worked, want failure" || true
 }
 run_test 36e "utime on non-owned file (should return error) ===="
 
@@ -1231,16 +1239,23 @@ stop_kupdated() {
        trap start_kupdated EXIT
 }
 
+# ensure that all stripes have some grant before we test client-side cache
+for i in `seq -f $DIR/f42-%g 1 $STRIPECOUNT`; do
+       dd if=/dev/zero of=$i bs=4k count=1
+       rm $i
+done
+
 # Tests 42* verify that our behaviour is correct WRT caching, file closure,
 # file truncation, and file removal.
 test_42a() {
        cancel_lru_locks OSC
        stop_kupdated
-        sync # just to be safe
-        BEFOREWRITES=`count_ost_writes`
-        dd if=/dev/zero of=$DIR/f42a bs=1024 count=100
-        AFTERWRITES=`count_ost_writes`
-        [ $BEFOREWRITES -eq $AFTERWRITES ] || \
+       sync; sleep 1; sync # just to be safe
+       BEFOREWRITES=`count_ost_writes`
+       grep [0-9] /proc/fs/lustre/osc/OSC*MNT*/cur_grant_bytes
+       dd if=/dev/zero of=$DIR/f42a bs=1024 count=100
+       AFTERWRITES=`count_ost_writes`
+       [ $BEFOREWRITES -eq $AFTERWRITES ] || \
                error "$BEFOREWRITES < $AFTERWRITES"
        start_kupdated
 }
@@ -1277,7 +1292,7 @@ run_test 42b "test destroy of file with cached dirty data ======"
 # any number of fixes (don't get {0,EOF} on open, match
 # composite locks, do smarter file size management) fix
 # this, but for now we want these tests to verify that
-# the cancelation with truncate intent works, so we
+# the cancellation with truncate intent works, so we
 # start the file with a full-file pw lock to match against
 # until the truncate.
 trunc_test() {
@@ -1318,7 +1333,7 @@ run_test 42d "test complete truncate of file with cached dirty data"
 test_43() {
        mkdir $DIR/d43
        cp -p /bin/ls $DIR/d43/f
-       exec 100>> $DIR/d43/f   
+       exec 100>> $DIR/d43/f
        $DIR/d43/f && error || true
        exec 100<&-
 }
@@ -1327,8 +1342,7 @@ run_test 43 "execution of file opened for write should return -ETXTBSY"
 test_43a() {
         mkdir -p $DIR/d43
        cp -p `which multiop` $DIR/d43/multiop
-        touch $DIR/d43/g
-        $DIR/d43/multiop $DIR/d43/g o_c &
+        $DIR/d43/multiop $TMP/test43.junk O_c &
         MULTIPID=$!
         sleep 1
         multiop $DIR/d43/multiop Oc && error "expected error, got success"
@@ -1340,8 +1354,7 @@ run_test 43a "open(RDWR) of file being executed should return -ETXTBSY"
 test_43b() {
         mkdir -p $DIR/d43
        cp -p `which multiop` $DIR/d43/multiop
-        touch $DIR/d43/g
-        $DIR/d43/multiop $DIR/d43/g o_c &
+        $DIR/d43/multiop $TMP/test43.junk O_c &
         MULTIPID=$!
         sleep 1
         truncate $DIR/d43/multiop 0 && error "expected error, got success"
@@ -1414,6 +1427,8 @@ do_dirty_record() {
 }
 test_45() {
        f="$DIR/f45"
+       # Obtain grants from OST if it supports it
+       echo blah > ${f}_grant
        stop_kupdated
        sync
        do_dirty_record "echo blah > $f"
@@ -1427,7 +1442,7 @@ test_45() {
        do_dirty_record "echo blah > $f"
        [ $before -eq $after ] && error "write wasn't cached"
        do_dirty_record "cancel_lru_locks OSC"
-       [ $before -gt $after ] || error "lock cancelation didn't lower dirty count"
+       [ $before -gt $after ] || error "lock cancellation didn't lower dirty count"
        start_kupdated
 }
 run_test 45 "osc io page accounting ============================"
@@ -1709,12 +1724,11 @@ test_62() {
         cancel_lru_locks OSC
         echo 0x405 > /proc/sys/lustre/fail_loc
         cat $f && error "cat succeeded, expect -EIO"
-        multiop $f Owc && error "multiop succeeded, expect -EIO"
         echo 0 > /proc/sys/lustre/fail_loc
 }
 run_test 62 "verify obd_match failure doesn't LBUG (should -EIO)"
 
-# bug 2319 - osic_wait() interrupted causes crash because of invalid waitq.
+# bug 2319 - oig_wait() interrupted causes crash because of invalid waitq.
 test_63() {
        MAX_DIRTY_MB=`cat /proc/fs/lustre/osc/*/max_dirty_mb | head -1`
        for i in /proc/fs/lustre/osc/*/max_dirty_mb ; do
@@ -1732,7 +1746,18 @@ test_63() {
        done
        true
 }
-run_test 63 "Verify osic_wait interruption does not crash ======"
+run_test 63 "Verify oig_wait interruption does not crash ======"
+
+test_64a () {
+       df $DIR
+       grep "[0-9]" /proc/fs/lustre/osc/OSC*MNT*/cur*
+}
+run_test 64a "verify filter grant calculations (in kernel) ======"
+
+test_64b () {
+       sh oos.sh $MOUNT
+}
+run_test 64b "check out-of-space detection on client ============"
 
 # on the LLNL clusters, runas will still pick up root's $TMP settings,
 # which will not be writable for the runas user, and then you get a CVS
@@ -1753,14 +1778,14 @@ test_99a() {
 run_test 99a "cvs init ========================================="
 
 test_99b() {
-       [ ! -d $DIR/d99cvsroot ] && run_one 99a
+       [ ! -d $DIR/d99cvsroot ] && test_99a
        cd /etc/init.d
        $RUNAS cvs -d $DIR/d99cvsroot import -m "nomesg" d99reposname vtag rtag
 }
 run_test 99b "cvs import ======================================="
 
 test_99c() {
-       [ ! -d $DIR/d99cvsroot ] && run_one 99b
+       [ ! -d $DIR/d99cvsroot ] && test_99b
        cd $DIR
        mkdir -p $DIR/d99reposname
        chown $RUNAS_ID $DIR/d99reposname
@@ -1769,7 +1794,7 @@ test_99c() {
 run_test 99c "cvs checkout ====================================="
 
 test_99d() {
-       [ ! -d $DIR/d99cvsroot ] && run_one 99c
+       [ ! -d $DIR/d99cvsroot ] && test_99c
        cd $DIR/d99reposname
        $RUNAS touch foo99
        $RUNAS cvs add -m 'addmsg' foo99
@@ -1777,14 +1802,14 @@ test_99d() {
 run_test 99d "cvs add =========================================="
 
 test_99e() {
-       [ ! -d $DIR/d99cvsroot ] && run_one 99c
+       [ ! -d $DIR/d99cvsroot ] && test_99c
        cd $DIR/d99reposname
        $RUNAS cvs update
 }
 run_test 99e "cvs update ======================================="
 
 test_99f() {
-       [ ! -d $DIR/d99cvsroot ] && run_one 99d
+       [ ! -d $DIR/d99cvsroot ] && test_99d
        cd $DIR/d99reposname
        $RUNAS cvs commit -m 'nomsg' foo99
 }