Whamcloud - gitweb
b=16551 (att 19784)
[fs/lustre-release.git] / lustre / tests / sanityN.sh
index 0f6b129..3341f43 100644 (file)
@@ -3,8 +3,8 @@
 set -e
 
 ONLY=${ONLY:-"$*"}
-# bug number for skipped test:  3192 9977
-ALWAYS_EXCEPT="14b 28 $SANITYN_EXCEPT"
+# bug number for skipped test: 3192 15528/3811 16929 9977 15528/11549
+ALWAYS_EXCEPT="                14b  19         22    28   29          $SANITYN_EXCEPT"
 # UPDATE THE COMMENT ABOVE WITH BUG NUMBERS WHEN CHANGING ALWAYS_EXCEPT!
 
 # bug number for skipped test:                                                    12652 12652
@@ -51,23 +51,17 @@ init_test_env $@
 SANITYLOG=${TESTSUITELOG:-$TMP/$(basename $0 .sh).log}
 FAIL_ON_ERROR=false
 
-if $GSS_KRB5; then
-    $RUNAS krb5_login.sh || exit 1
-fi
-
 SETUP=${SETUP:-:}
 TRACE=${TRACE:-""}
 
-LPROC=/proc/fs/lustre
-
 [ "$SANITYLOG" ] && rm -f $SANITYLOG || true
 
 check_and_setup_lustre
 
-LPROC=/proc/fs/lustre
 LOVNAME=`lctl get_param -n llite.*.lov.common_name | tail -n 1`
 OSTCOUNT=`lctl get_param -n lov.$LOVNAME.numobd`
 
+assert_DIR
 rm -rf $DIR1/[df][0-9]* $DIR1/lnk
 
 # $RUNAS_ID may get set incorrectly somewhere else
@@ -140,9 +134,9 @@ test_2e() {
 run_test 2e "check chmod on root is propagated to others"
 
 test_3() {
-       ( cd $DIR1 ; ln -s this/is/good lnk )
-       [ "this/is/good" = "`perl -e 'print readlink("'$DIR2/lnk'");'`" ] || \
-               error
+       ( cd $DIR1 ; ln -s this/is/good $tfile )
+       [ "this/is/good" = "`perl -e 'print readlink("'$DIR2/$tfile'");'`" ] ||
+               error "link $DIR2/$tfile not as expected"
 }
 run_test 3 "symlink on one mtpt, readlink on another ==========="
 
@@ -166,11 +160,9 @@ test_6() {
 run_test 6 "remove of open file on other node =================="
 
 test_7() {
-       # run_one creates uniq $tdir (bug 13798)
-       # opendirunlink failes if it exists
-       rmdir $DIR1/$tdir || true
-       opendirunlink $DIR1/$tdir $DIR2/$tdir || \
-               error "opendirunlink $DIR1/$tdir $DIR2/$tdir"
+       local dir=d7
+       opendirunlink $DIR1/$dir $DIR2/$dir || \
+               error "opendirunlink $DIR1/$dir $DIR2/$dir"
 }
 run_test 7 "remove of open directory on other node ============="
 
@@ -182,10 +174,11 @@ run_test 8 "remove of open special file on other node =========="
 
 test_9() {
        MTPT=1
+       local dir
        > $DIR2/f9
        for C in a b c d e f g h i j k l; do
-               DIR=`eval echo \\$DIR$MTPT`
-               echo -n $C >> $DIR/f9
+               dir=`eval echo \\$DIR$MTPT`
+               echo -n $C >> $dir/f9
                [ "$MTPT" -eq 1 ] && MTPT=2 || MTPT=1
        done
        [ "`cat $DIR1/f9`" = "abcdefghijkl" ] || \
@@ -195,11 +188,12 @@ run_test 9 "append of file with sub-page size on multiple mounts"
 
 test_10a() {
        MTPT=1
+       local dir
        OFFSET=0
        > $DIR2/f10
        for C in a b c d e f g h i j k l; do
-               DIR=`eval echo \\$DIR$MTPT`
-               echo -n $C | dd of=$DIR/f10 bs=1 seek=$OFFSET count=1
+               dir=`eval echo \\$DIR$MTPT`
+               echo -n $C | dd of=$dir/f10 bs=1 seek=$OFFSET count=1
                [ "$MTPT" -eq 1 ] && MTPT=2 || MTPT=1
                OFFSET=`expr $OFFSET + 1`
        done
@@ -209,25 +203,26 @@ test_10a() {
 run_test 10a "write of file with sub-page size on multiple mounts "
 
 test_10b() {
-       yes "R" | dd of=$DIR1/f10b bs=3k count=1 || error "dd $DIR1"
+       # create a seed file
+       yes "R" | head -c 4000 >$TMP/f10b-seed
+       dd if=$TMP/f10b-seed of=$DIR1/f10b bs=3k count=1 || error "dd $DIR1"
 
        truncate $DIR1/f10b 4096 || error "truncate 4096"
 
        dd if=$DIR2/f10b of=$TMP/f10b-lustre bs=4k count=1 || error "dd $DIR2"
 
        # create a test file locally to compare
-       yes "R" | dd of=$TMP/f10b bs=3k count=1 || error "dd random"
+       dd if=$TMP/f10b-seed of=$TMP/f10b bs=3k count=1 || error "dd random"
        truncate $TMP/f10b 4096 || error "truncate 4096"
        cmp $TMP/f10b $TMP/f10b-lustre || error "file miscompare"
-       rm $TMP/f10b $TMP/f10b-lustre
+       rm $TMP/f10b $TMP/f10b-lustre $TMP/f10b-seed
 }
 run_test 10b "write of file with sub-page size on multiple mounts "
 
 test_11() {
        mkdir $DIR1/d11
-       multiop $DIR1/d11/f O_c &
+       multiop_bg_pause $DIR1/d11/f O_c || return 1
        MULTIPID=$!
-       usleep 200
        cp -p /bin/ls $DIR1/d11/f
        $DIR2/d11/f
        RC=$?
@@ -260,23 +255,25 @@ test_13() {       # bug 2451 - directory coherency
 run_test 13 "test directory page revocation ===================="
 
 test_14() {
-       mkdir $DIR1/d14
-       cp -p /bin/ls $DIR1/d14/ls
-       exec 100>> $DIR1/d14/ls
-       $DIR2/d14/ls && error || true
-       exec 100<&-
+       mkdir -p $DIR1/$tdir
+       cp -p /bin/ls $DIR1/$tdir/$tfile
+       multiop_bg_pause $DIR1/$tdir/$tfile Ow_c || return 1
+       MULTIPID=$!
+
+       $DIR2/$tdir/$tfile && error || true
+       kill -USR1 $MULTIPID
+       wait $MULTIPID || return 2
 }
 run_test 14 "execution of file open for write returns -ETXTBSY ="
 
 test_14a() {
         mkdir -p $DIR1/d14
        cp -p `which multiop` $DIR1/d14/multiop || error "cp failed"
-        $DIR1/d14/multiop $TMP/test14.junk O_c &
-        MULTIPID=$!
-        sleep 1
+        MULTIOP_PROG=$DIR1/d14/multiop multiop_bg_pause $TMP/test14.junk O_c || return 1
+        MULTIOP_PID=$!
         multiop $DIR2/d14/multiop Oc && error "expected error, got success"
-        kill -USR1 $MULTIPID || return 2
-        wait $MULTIPID || return 3
+        kill -USR1 $MULTIOP_PID || return 2
+        wait $MULTIOP_PID || return 3
         rm $TMP/test14.junk $DIR1/d14/multiop || error "removing multiop"
 }
 run_test 14a "open(RDWR) of executing file returns -ETXTBSY ===="
@@ -284,13 +281,12 @@ run_test 14a "open(RDWR) of executing file returns -ETXTBSY ===="
 test_14b() { # bug 3192, 7040
         mkdir -p $DIR1/d14
        cp -p `which multiop` $DIR1/d14/multiop || error "cp failed"
-        $DIR1/d14/multiop $TMP/test14.junk O_c &
-        MULTIPID=$!
-        sleep 1
-        truncate $DIR2/d14/multiop 0 && kill -9 $MULTIPID && \
+        MULTIOP_PROG=$DIR1/d14/multiop multiop_bg_pause $TMP/test14.junk O_c || return 1
+        MULTIOP_PID=$!
+        truncate $DIR2/d14/multiop 0 && kill -9 $MULTIOP_PID && \
                error "expected truncate error, got success"
-        kill -USR1 $MULTIPID || return 2
-        wait $MULTIPID || return 3
+        kill -USR1 $MULTIOP_PID || return 2
+        wait $MULTIOP_PID || return 3
        cmp `which multiop` $DIR1/d14/multiop || error "binary changed"
        rm $TMP/test14.junk $DIR1/d14/multiop || error "removing multiop"
 }
@@ -299,12 +295,11 @@ run_test 14b "truncate of executing file returns -ETXTBSY ======"
 test_14c() { # bug 3430, 7040
        mkdir -p $DIR1/d14
        cp -p `which multiop` $DIR1/d14/multiop || error "cp failed"
-       $DIR1/d14/multiop $TMP/test14.junk O_c &
-       MULTIPID=$!
-       sleep 1
+       MULTIOP_PROG=$DIR1/d14/multiop multiop_bg_pause $TMP/test14.junk O_c || return 1
+        MULTIOP_PID=$!
        cp /etc/hosts $DIR2/d14/multiop && error "expected error, got success"
-       kill -USR1 $MULTIPID || return 2
-       wait $MULTIPID || return 3
+       kill -USR1 $MULTIOP_PID || return 2
+       wait $MULTIOP_PID || return 3
        cmp `which multiop` $DIR1/d14/multiop || error "binary changed"
        rm $TMP/test14.junk $DIR1/d14/multiop || error "removing multiop"
 }
@@ -313,13 +308,12 @@ run_test 14c "open(O_TRUNC) of executing file return -ETXTBSY =="
 test_14d() { # bug 10921
        mkdir -p $DIR1/d14
        cp -p `which multiop` $DIR1/d14/multiop || error "cp failed"
-       $DIR1/d14/multiop $TMP/test14.junk O_c &
-       MULTIPID=$!
-       sleep 1
+       MULTIOP_PROG=$DIR1/d14/multiop multiop_bg_pause $TMP/test14.junk O_c || return 1
+        MULTIOP_PID=$!
        log chmod
        chmod 600 $DIR1/d14/multiop || error "chmod failed"
-       kill -USR1 $MULTIPID || return 2
-       wait $MULTIPID || return 3
+       kill -USR1 $MULTIOP_PID || return 2
+       wait $MULTIOP_PID || return 3
        cmp `which multiop` $DIR1/d14/multiop || error "binary changed"
        rm $TMP/test14.junk $DIR1/d14/multiop || error "removing multiop"
 }
@@ -341,16 +335,17 @@ test_16() {
 run_test 16 "2500 iterations of dual-mount fsx ================="
 
 test_17() { # bug 3513, 3667
-       [ ! -d /proc/fs/lustre/ost ] && skip "remote OST, skipping OST-only test" && return
+       remote_ost_nodsh && skip "remote OST with nodsh" && return
 
-       cp /etc/termcap $DIR1/f17
+       lfs setstripe $DIR1/$tfile -i 0 -c 1
+       cp /etc/termcap $DIR1/$tfile
        cancel_lru_locks osc > /dev/null
        #define OBD_FAIL_ONCE|OBD_FAIL_LDLM_CREATE_RESOURCE    0x30a
-       sysctl -w lustre.fail_loc=0x8000030a
-       ls -ls $DIR1/f17 | awk '{ print $1,$6 }' > $DIR1/f17-1 & \
-       ls -ls $DIR2/f17 | awk '{ print $1,$6 }' > $DIR2/f17-2
+       do_facet ost1 lctl set_param fail_loc=0x8000030a
+       ls -ls $DIR1/$tfile | awk '{ print $1,$6 }' > $DIR1/$tfile-1 & \
+       ls -ls $DIR2/$tfile | awk '{ print $1,$6 }' > $DIR2/$tfile-2
        wait
-       diff -u $DIR1/f17-1 $DIR2/f17-2 || error "files are different"
+       diff -u $DIR1/$tfile-1 $DIR2/$tfile-2 || error "files are different"
 }
 run_test 17 "resource creation/LVB creation race ==============="
 
@@ -363,10 +358,8 @@ run_test 18 "mmap sanity check ================================="
 test_19() { # bug3811
        [ -d /proc/fs/lustre/obdfilter ] || return 0
 
-       MAX=`cat /proc/fs/lustre/obdfilter/*/readcache_max_filesize | head -n 1`
-       for O in /proc/fs/lustre/obdfilter/*OST*; do
-               echo 4096 > $O/readcache_max_filesize
-       done
+       MAX=`lctl get_param -n obdfilter.*.readcache_max_filesize | head -n 1`
+       lctl set_param -n obdfilter.*OST*.readcache_max_filesize=4096
        dd if=/dev/urandom of=$TMP/f19b bs=512k count=32
        SUM=`cksum $TMP/f19b | cut -d" " -f 1,2`
        cp $TMP/f19b $DIR1/f19b
@@ -381,22 +374,20 @@ test_19() { # bug3811
                [ "`cat $TMP/sum2`" = "$SUM" ] || \
                        error "$DIR2/f19b `cat $TMP/sum2` != $SUM"
        done
-       for O in /proc/fs/lustre/obdfilter/*OST*; do
-               echo $MAX > $O/readcache_max_filesize
-       done
+       lctl set_param -n obdfilter.*OST*.readcache_max_filesize=$MAX
        rm $DIR1/f19b
 }
-#run_test 19 "test concurrent uncached read races ==============="
+run_test 19 "test concurrent uncached read races ==============="
 
 test_20() {
        mkdir $DIR1/d20
        cancel_lru_locks osc
-       CNT=$((`cat /proc/fs/lustre/llite/*/dump_page_cache | wc -l`))
+       CNT=$((`lctl get_param -n llite.*.dump_page_cache | wc -l`))
        multiop $DIR1/f20 Ow8190c
        multiop $DIR2/f20 Oz8194w8190c
        multiop $DIR1/f20 Oz0r8190c
        cancel_lru_locks osc
-       CNTD=$((`cat /proc/fs/lustre/llite/*/dump_page_cache | wc -l` - $CNT))
+       CNTD=$((`lctl get_param -n llite.*.dump_page_cache | wc -l` - $CNT))
        [ $CNTD -gt 0 ] && \
            error $CNTD" page left in cache after lock cancel" || true
 }
@@ -449,10 +440,9 @@ test_23() { # Bug 5972
        time1=`date +%s`        
        sleep 2
        
-       multiop $DIR1/f23 or20_c &
+       multiop_bg_pause $DIR1/f23 or20_c || return 1
        MULTIPID=$!
 
-       sleep 2
        time2=`stat -c "%X" $DIR2/f23`
 
        if (( $time2 <= $time1 )); then
@@ -488,6 +478,7 @@ test_25() {
        [ `lctl get_param -n mdc.*-mdc-*.connect_flags | grep -c acl` -lt 2 ] && \
            skip "must have acl, skipping" && return
 
+       mkdir -p $DIR1/$tdir
        touch $DIR1/$tdir/f1 || error "touch $DIR1/$tdir/f1"
        chmod 0755 $DIR1/$tdir/f1 || error "chmod 0755 $DIR1/$tdir/f1"
 
@@ -586,16 +577,17 @@ run_test 28 "read/write/truncate file with lost stripes"
 test_29() { # bug 10999
        touch $DIR1/$tfile
        #define OBD_FAIL_LDLM_GLIMPSE  0x30f
-       sysctl -w lustre.fail_loc=0x8000030f
+       lctl set_param fail_loc=0x8000030f
        ls -l $DIR2/$tfile &
        usleep 500
        dd if=/dev/zero of=$DIR1/$tfile bs=4k count=1
        wait
 }
 #bug 11549 - permanently turn test off in b1_5
-#run_test 29 "lock put race between glimpse and enqueue ========="
+run_test 29 "lock put race between glimpse and enqueue ========="
 
 test_30() { #bug #11110
+    mkdir -p $DIR1/$tdir
     cp -f /bin/bash $DIR1/$tdir/bash
     /bin/sh -c 'sleep 1; rm -f $DIR2/$tdir/bash; cp /bin/bash $DIR2/$tdir' &
     err=$($DIR1/$tdir/bash -c 'sleep 2; openfile -f O_RDONLY /proc/$$/exe >& /dev/null; echo $?')
@@ -611,13 +603,94 @@ test_31() {
         writes=`LANG=C dd if=/dev/zero of=$DIR/$tdir/$tfile count=1 2>&1 |
                 awk 'BEGIN { FS="+" } /out/ {print $1}'`
         #define OBD_FAIL_LDLM_CANCEL_BL_CB_RACE   0x314
-        sysctl -w lustre.fail_loc=0x314
+        lctl set_param fail_loc=0x314
         reads=`LANG=C dd if=$DIR2/$tdir/$tfile of=/dev/null 2>&1 |
                awk 'BEGIN { FS="+" } /in/ {print $1}'`
         [ $reads -eq $writes ] || error "read" $reads "blocks, must be" $writes
 }
 run_test 31 "voluntary cancel / blocking ast race=============="
 
+# enable/disable lockless truncate feature, depending on the arg 0/1
+enable_lockless_truncate() {
+        lctl set_param -n llite.*.lockless_truncate $1
+}
+
+test_32a() { # bug 11270
+        local p="$TMP/sanityN-$TESTNAME.parameters"
+        save_lustre_params $HOSTNAME llite.*.lockless_truncate > $p
+        cancel_lru_locks osc
+        clear_llite_stats
+        enable_lockless_truncate 1
+        dd if=/dev/zero of=$DIR1/$tfile count=10 bs=1M > /dev/null 2>&1
+
+        log "checking cached lockless truncate"
+        $TRUNCATE $DIR1/$tfile 8000000
+        $CHECKSTAT -s 8000000 $DIR2/$tfile || error "wrong file size"
+        [ $(calc_llite_stats lockless_truncate) -eq 0 ] ||
+                error "lockless truncate doesn't use cached locks"
+
+        log "checking not cached lockless truncate"
+        $TRUNCATE $DIR2/$tfile 5000000
+        $CHECKSTAT -s 5000000 $DIR1/$tfile || error "wrong file size"
+        [ $(calc_llite_stats lockless_truncate) -ne 0 ] ||
+                error "not cached trancate isn't lockless"
+
+        log "disabled lockless truncate"
+        enable_lockless_truncate 0
+        clear_llite_stats
+        $TRUNCATE $DIR2/$tfile 3000000
+        $CHECKSTAT -s 3000000 $DIR1/$tfile || error "wrong file size"
+        [ $(calc_llite_stats lockless_truncate) -eq 0 ] ||
+                error "lockless truncate disabling failed"
+        rm $DIR1/$tfile
+        # restore lockless_truncate default values
+        restore_lustre_params < $p
+        rm -f $p
+}
+run_test 32a "lockless truncate"
+
+test_32b() { # bug 11270
+        remote_ost_nodsh && skip "remote OST with nodsh" && return
+
+        local node
+        local p="$TMP/sanityN-$TESTNAME.parameters"
+        save_lustre_params $HOSTNAME "llite.*.contention_seconds" > $p
+        for node in $(osts_nodes); do
+                save_lustre_params $node "ldlm.namespaces.filter-*.max_nolock_bytes" >> $p
+                save_lustre_params $node "ldlm.namespaces.filter-*.contended_locks" >> $p
+                save_lustre_params $node "ldlm.namespaces.filter-*.contention_seconds" >> $p
+        done
+        clear_llite_stats
+        # agressive lockless i/o settings 
+        for node in $(osts_nodes); do
+                do_node $node 'lctl set_param -n ldlm.namespaces.filter-*.max_nolock_bytes 2000000; lctl set_param -n ldlm.namespaces.filter-*.contended_locks 0; lctl set_param -n ldlm.namespaces.filter-*.contention_seconds 60'
+        done
+        lctl set_param -n llite.*.contention_seconds 60
+        for i in $(seq 5); do
+                dd if=/dev/zero of=$DIR1/$tfile bs=4k count=1 conv=notrunc > /dev/null 2>&1
+                dd if=/dev/zero of=$DIR2/$tfile bs=4k count=1 conv=notrunc > /dev/null 2>&1
+        done
+        [ $(calc_llite_stats lockless_write_bytes) -ne 0 ] || error "lockless i/o was not triggered" 
+        # disable lockless i/o (it is disabled by default)
+        for node in $(osts_nodes); do
+                do_node $node 'lctl set_param -n ldlm.namespaces.filter-*.max_nolock_bytes 0; lctl set_param -n ldlm.namespaces.filter-*.contended_locks 32; lctl set_param -n ldlm.namespaces.filter-*.contention_seconds 0'
+        done
+        # set contention_seconds to 0 at client too, otherwise Lustre still
+        # remembers lock contention
+        lctl set_param -n llite.*.contention_seconds 0
+        clear_llite_stats
+        for i in $(seq 5); do
+                dd if=/dev/zero of=$DIR1/$tfile bs=4k count=1 conv=notrunc > /dev/null 2>&1
+                dd if=/dev/zero of=$DIR2/$tfile bs=4k count=1 conv=notrunc > /dev/null 2>&1
+        done
+        [ $(calc_llite_stats lockless_write_bytes) -eq 0 ] ||
+                error "lockless i/o works when disabled" 
+        rm -f $DIR1/$tfile
+        restore_lustre_params <$p
+        rm -f $p
+}
+run_test 32b "lockless i/o"
+
 log "cleanup: ======================================================"
 
 check_and_cleanup_lustre