Whamcloud - gitweb
b=19053
[fs/lustre-release.git] / lustre / tests / sanity.sh
index a482ad5..493ee2c 100644 (file)
@@ -1,4 +1,6 @@
 #!/bin/bash
+# -*- mode: Bash; tab-width: 4; indent-tabs-mode: t; -*-
+# vim:autoindent:shiftwidth=4:tabstop=4:
 #
 # Run select tests by setting ONLY, or as arguments to the script.
 # Skip specific tests by setting EXCEPT.
@@ -482,6 +484,17 @@ test_17h() { #bug 17378
 }
 run_test 17h "create objects: lov_free_memmd() doesn't lbug"
 
+test_17i() { #bug 20018
+        mkdir -p $DIR/$tdir
+       local foo=$DIR/$tdir/$tfile
+       ln -s $foo $foo || error "create symlink failed"
+#define OBD_FAIL_MDS_READLINK_EPROTO     0x143
+       do_facet mds lctl set_param fail_loc=0x80000144
+       ls -l $foo && error "error not detected"
+       return 0
+}
+run_test 17i "don't panic on short symlink"
+
 test_18() {
        touch $DIR/f
        ls $DIR || error
@@ -1194,6 +1207,65 @@ test_27w() { # bug 10997
 }
 run_test 27w "check lfs setstripe -c -s -i options ============="
 
+test_27x() {
+       [ "$OSTCOUNT" -lt "2" ] && skip "$OSTCOUNT < 2 OSTs" && return
+       DELAY=$(do_facet mds lctl get_param -n lov.*.qos_maxage | awk '{print $1 + 2}')
+       OFFSET=$(($OSTCOUNTi - 1))
+       OSTIDX=0
+       local OST=$(lfs osts | awk '/'${OSTIDX}': / { print $2 }' | sed -e 's/_UUID$//')
+       
+       mkdir -p $DIR/$tdir
+       $SETSTRIPE $DIR/$tdir -c 1      # 1 stripe per file
+       do_facet ost$OSTIDX lctl set_param -n obdfilter.$OST.degraded 1
+       sleep $DELAY
+       createmany -o $DIR/$tdir/$tfile $OSTCOUNT
+       for i in `seq 0 $OFFSET`; do
+               [ `$GETSTRIPE $DIR/$tdir/$tfile$i | grep -A 10 obdidx | awk '{print $1}' | grep -w "$OSTIDX"` ] && 
+               error "OST0 was degraded but new created file still use it"
+       done
+       do_facet ost$OSTIDX lctl set_param -n obdfilter.$OST.degraded 0
+}
+run_test 27x "create files while OST0 is degraded"
+
+test_27y() {
+        [ "$OSTCOUNT" -lt "2" ] && skip "$OSTCOUNT < 2 OSTs -- skipping" && return
+        remote_mds_nodsh && skip "remote MDS with nodsh" && return
+
+        MDS_OSCS=`do_facet mds lctl dl | awk '/[oO][sS][cC].*md[ts]/ { print $4 }'`
+        DELAY=$(do_facet mds lctl get_param -n lov.*.qos_maxage | awk '{print $1 + 2}')
+        OFFSET=$(($OSTCOUNT-1))
+        OST=-1
+        for OSC in $MDS_OSCS; do
+                if [ $OST == -1 ]; then {
+                        OST=`osc_to_ost $OSC`
+                } else {
+                        echo $OSC "is Deactivate:"
+                        do_facet mds lctl --device  %$OSC deactivate
+                } fi
+        done
+
+        OSTIDX=$(lfs osts | grep ${OST} | awk '{print $1}' | sed -e 's/://')
+        mkdir -p $DIR/$tdir
+        $SETSTRIPE $DIR/$tdir -c 1      # 1 stripe / file
+
+        do_facet ost$OSTIDX lctl set_param -n obdfilter.$OST.degraded 1 
+        sleep $DELAY 
+        createmany -o $DIR/$tdir/$tfile $OSTCOUNT
+        do_facet ost$OSTIDX lctl set_param -n obdfilter.$OST.degraded 0 
+
+        for i in `seq 0 $OFFSET`; do
+                [ `$GETSTRIPE $DIR/$tdir/$tfile$i | grep -A 10 obdidx | awk '{print $1}'| grep -w "$OSTIDX"` ] || \
+                      error "files created on deactivated OSTs instead of degraded OST"
+        done
+        for OSC in $MDS_OSCS; do
+                [ `osc_to_ost $OSC` != $OST  ] && {
+                        echo $OSC "is activate"
+                        do_facet mds lctl --device %$OSC activate
+                }
+        done
+}
+run_test 27y "create files while OST0 is degraded and the rest inactive"
+
 # createtest also checks that device nodes are created and
 # then visible correctly (#2091)
 test_28() { # bug 2091
@@ -2375,16 +2447,16 @@ test_52a() {
        [ -f $DIR/d52a/foo ] && chattr -a $DIR/d52a/foo
        mkdir -p $DIR/d52a
        touch $DIR/d52a/foo
-       chattr =a $DIR/d52a/foo || error "chattr =a failed"
+       chattr +a $DIR/d52a/foo || error "chattr +a failed"
        echo bar >> $DIR/d52a/foo || error "append bar failed"
        cp /etc/hosts $DIR/d52a/foo && error "cp worked"
        rm -f $DIR/d52a/foo 2>/dev/null && error "rm worked"
        link $DIR/d52a/foo $DIR/d52a/foo_link 2>/dev/null && error "link worked"
        echo foo >> $DIR/d52a/foo || error "append foo failed"
        mrename $DIR/d52a/foo $DIR/d52a/foo_ren && error "rename worked"
-       lsattr $DIR/d52a/foo | egrep -q "^-+a-+ $DIR/d52a/foo" || error "lsattr"
+       lsattr $DIR/d52a/foo | egrep -q "^-+[ae]-+ $DIR/d52a/foo" || error "lsattr"
        chattr -a $DIR/d52a/foo || error "chattr -a failed"
-
+        cp -r $DIR/d52a /tmp/
        rm -fr $DIR/d52a || error "cleanup rm failed"
 }
 run_test 52a "append-only flag test (should return errors) ====="
@@ -2393,17 +2465,17 @@ test_52b() {
        [ -f $DIR/d52b/foo ] && chattr -i $DIR/d52b/foo
        mkdir -p $DIR/d52b
        touch $DIR/d52b/foo
-       chattr =i $DIR/d52b/foo || error
-       cat test > $DIR/d52b/foo && error
-       cp /etc/hosts $DIR/d52b/foo && error
-       rm -f $DIR/d52b/foo 2>/dev/null && error
-       link $DIR/d52b/foo $DIR/d52b/foo_link 2>/dev/null && error
-       echo foo >> $DIR/d52b/foo && error
-       mrename $DIR/d52b/foo $DIR/d52b/foo_ren && error
+       chattr +i $DIR/d52b/foo || error "chattr +i failed"
+       cat test > $DIR/d52b/foo && error "cat test worked"
+       cp /etc/hosts $DIR/d52b/foo && error "cp worked"
+       rm -f $DIR/d52b/foo 2>/dev/null && error "rm worked"
+       link $DIR/d52b/foo $DIR/d52b/foo_link 2>/dev/null && error  "link worked"
+       echo foo >> $DIR/d52b/foo && error "echo worked"
+       mrename $DIR/d52b/foo $DIR/d52b/foo_ren && error "rename worked"
        [ -f $DIR/d52b/foo ] || error
        [ -f $DIR/d52b/foo_ren ] && error
-       lsattr $DIR/d52b/foo | egrep -q "^-+i-+ $DIR/d52b/foo" || error
-       chattr -i $DIR/d52b/foo || error
+       lsattr $DIR/d52b/foo | egrep -q "^-+[ie]-+ $DIR/d52b/foo" || error "lsattr"
+       chattr -i $DIR/d52b/foo || error "chattr failed"
 
        rm -fr $DIR/d52b || error
 }
@@ -5207,11 +5279,11 @@ run_test 120g "Early Lock Cancel: performance test"
 
 test_121() { #bug #10589
        rm -rf $DIR/$tfile
-       writes=$(LANG=C dd if=/dev/zero of=$DIR/$tfile count=1 2>&1 | awk -F '+' '/out/ {print $1}')
+       writes=$(LANG=C dd if=/dev/zero of=$DIR/$tfile count=1 2>&1 | awk -F '+' '/out$/ {print $1}')
 #define OBD_FAIL_LDLM_CANCEL_RACE        0x310
        lctl set_param fail_loc=0x310
        cancel_lru_locks osc > /dev/null
-       reads=$(LANG=C dd if=$DIR/$tfile of=/dev/null 2>&1 | awk -F '+' '/in/ {print $1}')
+       reads=$(LANG=C dd if=$DIR/$tfile of=/dev/null 2>&1 | awk -F '+' '/in$/ {print $1}')
        lctl set_param fail_loc=0
        [ "$reads" -eq "$writes" ] || error "read" $reads "blocks, must be" $writes
 }
@@ -5826,16 +5898,16 @@ test_130e() {
        trap cleanup_130 EXIT RETURN
 
        local fm_file=$DIR/$tfile
-       lfs setstripe -s 65536 -c 2 $fm_file || error "setstripe failed on $fm_file"
+       lfs setstripe -s 131072 -c 2 $fm_file || error "setstripe failed on $fm_file"
        NUM_BLKS=512
-       EXPECTED_LEN=$(( (NUM_BLKS / 2) * 4 ))
+       EXPECTED_LEN=$(( (NUM_BLKS / 2) * 64 ))
        for ((i = 0; i < $NUM_BLKS; i++))
        do
-               dd if=/dev/zero of=$fm_file count=1 bs=4096 seek=$((2*$i)) conv=notrunc > /dev/null 2>&1
+               dd if=/dev/zero of=$fm_file count=1 bs=64k seek=$((2*$i)) conv=notrunc > /dev/null 2>&1
        done
 
        filefrag -ves $fm_file || error "filefrag $fm_file failed"
-       filefrag_op=`filefrag -ve $fm_file | grep -A 750 "ext:" | grep -v "ext:" | grep -v "found"`
+       filefrag_op=`filefrag -ve $fm_file | grep -A 12000 "ext:" | grep -v "ext:" | grep -v "found"`
 
        last_lun=`echo $filefrag_op | cut -d: -f5`
 
@@ -5962,7 +6034,14 @@ test_132() { #1028, SOM
         som_mode_switch $som1 $gl1 $gl2
 
         som2=$(do_facet $mymds "$LCTL get_param mdt.*.som" |  awk -F= ' {print $2}' | head -n 1)
-        [ $som1 != $som2 ] || error "som is still "$som2
+        if [ $som1 == $som2 ]; then
+            error "som is still "$som2
+            if [ x$som2 = x"enabled" ]; then
+                som2="disabled"
+            else
+                som2="enabled"
+            fi
+        fi
 
         gl1=$(get_ost_param "ldlm_glimpse_enqueue")
         stat $DIR/$tfile >/dev/null
@@ -6032,19 +6111,13 @@ test_150() {
 }
 run_test 150 "truncate/append tests"
 
-function roc_access() {
-        local list=$(comma_list $(osts_nodes))
-        ACCNUM=`do_nodes $list $LCTL get_param -n obdfilter.*.stats | \
-                grep 'cache_access'| awk '{print $2}' | \
-                awk '{sum=sum+$3} END{print sum}'`
-        echo $ACCNUM
-}
-
 function roc_hit() {
         local list=$(comma_list $(osts_nodes))
-        ACCNUM=`do_nodes $list $LCTL get_param -n obdfilter.*.stats | \
-                grep 'cache_hit'|awk '{print $2}' | \
-                awk '{sum=sum+$1} END{print sum}'`
+        local log=$TMP/${TESTSUITE}-$TESTNAME.param
+        do_nodes $list "$LCTL get_param -n obdfilter.*.stats" >$log
+
+        local ACCNUM=`awk '/^cache_hit/ {sum=sum+$2} END{print sum}' $log`
+        rm -f $log 
         echo $ACCNUM
 }
 
@@ -6290,25 +6363,48 @@ test_162() {
     touch $DIR/$tdir/d2/x2
     mkdir -p $DIR/$tdir/d2/a/b/c
     mkdir -p $DIR/$tdir/d2/p/q/r
+       # regular file
     FID=$($LFS path2fid $DIR/$tdir/d2/$tfile | tr -d '[')
     check_path "/$tdir/d2/$tfile" $DIR $FID --link 0
+
+       # softlink
+    ln -s $DIR/$tdir/d2/$tfile $DIR/$tdir/d2/p/q/r/slink
+    FID=$($LFS path2fid $DIR/$tdir/d2/p/q/r/slink | tr -d '[')
+    check_path "/$tdir/d2/p/q/r/slink" $DIR $FID --link 0
+
+       # hardlink
     ln $DIR/$tdir/d2/$tfile $DIR/$tdir/d2/p/q/r/hlink
     mv $DIR/$tdir/d2/$tfile $DIR/$tdir/d2/a/b/c/new_file
     FID=$($LFS path2fid $DIR/$tdir/d2/a/b/c/new_file | tr -d '[')
     # fid2path dir/fsname should both work
     check_path "/$tdir/d2/a/b/c/new_file" $FSNAME $FID --link 1
     check_path "/$tdir/d2/p/q/r/hlink" $DIR $FID --link 0
-    # check that there are 2 links
-    ${LFS} fid2path $DIR $FID | wc -l | grep -q 2 || \
-       err17935 "expected 2 links"
 
+    # hardlink count: check that there are 2 links
+    # Doesnt work with CMD yet: 17935
+       ${LFS} fid2path $DIR $FID | wc -l | grep -q 2 || \
+               err17935 "expected 2 links"
+
+       # hardlink indexing: remove the first link
     rm $DIR/$tdir/d2/p/q/r/hlink
     check_path "/$tdir/d2/a/b/c/new_file" $DIR $FID --link 0
-    # Doesnt work with CMD yet: 17935
-    return 0
+
+       return 0
 }
 run_test 162 "path lookup sanity"
 
+test_163() {
+       remote_mds_nodsh && skip "remote MDS with nodsh" && return
+       copytool --test || { skip "copytool not runnable: $?" && return; }
+       copytool &
+       sleep 1
+       local uuid=$($LCTL get_param -n mdc.lustre-MDT0000-mdc-*.uuid)
+       # this proc file is temporary and linux-only
+       do_facet mds lctl set_param mdt.lustre-MDT0000.mdccomm=$uuid || error "lnl send failed"
+       kill $!
+}
+run_test 163 "LustreNetLink kernelcomms"
+
 test_169() {
        # do directio so as not to populate the page cache
        log "creating a 10 Mb file"
@@ -6324,7 +6420,7 @@ test_169() {
        log "removing the temporary file"
        rm -rf $DIR/$tfile || error "tmp file removal failed"
 }
-run_test 169 "parallel read and truncate should not deadlock ==="
+run_test 169 "parallel read and truncate should not deadlock"
 
 test_170() {
         $LCTL clear    # bug 18514
@@ -6411,6 +6507,7 @@ test_200a() {
        do_facet mgs $LCTL pool_new $FSNAME.$POOL
         # get param should return err until pool is created
         wait_update $HOSTNAME "lctl get_param -n lov.$FSNAME-*.pools.$POOL 2>/dev/null || echo foo" "" || error "Pool creation of $POOL failed"
+       [ $($LFS pool_list $FSNAME | grep -c $POOL) -eq 1 ] || error "$POOL not in lfs pool_list"
 }
 run_test 200a "Create new pool =========================================="
 
@@ -6420,6 +6517,9 @@ test_200b() {
        do_facet mgs $LCTL pool_add $FSNAME.$POOL \
                $FSNAME-OST[$TGTPOOL_FIRST-$TGTPOOL_MAX/$TGTPOOL_STEP]
        wait_update $HOSTNAME "lctl get_param -n lov.$FSNAME-*.pools.$POOL | sort -u | tr '\n' ' ' " "$TGT" || error "Add to pool failed"
+       local lfscount=$($LFS pool_list $FSNAME.$POOL | grep -c "\-OST")
+       local addcount=$((($TGTPOOL_MAX - $TGTPOOL_FIRST) / $TGTPOOL_STEP + 1))
+       [ $lfscount -eq $addcount ] || error "lfs pool_list bad ost count $lfscount != $addcount"
 }
 run_test 200b "Add targets to a pool ===================================="
 
@@ -6433,8 +6533,8 @@ run_test 200c "Set pool on a directory ================================="
 
 test_200d() {
        remote_mgs_nodsh && skip "remote MGS with nodsh" && return
-       res=$($GETSTRIPE $POOL_DIR | grep pool: | cut -f8 -d " ")
-       [ "$res" = $POOL ] || error "Pool on $POOL_DIR is not $POOL"
+       res=$($GETSTRIPE --pool $POOL_DIR | awk '/^pool:/ {print $2}')
+       [ "$res" = $POOL ] || error "Pool on $POOL_DIR is $res, not $POOL"
 }
 run_test 200d "Check pool on a directory ==============================="
 
@@ -6523,6 +6623,19 @@ test_213() {
 }
 run_test 213 "OSC lock completion and cancel race don't crash - bug 18829"
 
+test_214() { # for bug 20133
+       mkdir -p $DIR/d214p/d214c
+       for (( i=0; i < 340; i++ )) ; do
+               touch $DIR/d214p/d214c/a$i
+       done
+
+       ls -l $DIR/d214p || error "ls -l $DIR/d214p failed"
+       mv $DIR/d214p/d214c $DIR/ || error "mv $DIR/d214p/d214c $DIR/ failed"
+       ls $DIR/d214c || error "ls $DIR/d214c failed"
+       rm -rf $DIR/d214* || error "rm -rf $DIR/d214* failed"
+}
+run_test 214 "hash-indexed directory test - bug 20133"
+
 #
 # tests that do cleanup/setup should be run at the end
 #