Whamcloud - gitweb
bz-13725
[fs/lustre-release.git] / lustre / tests / sanity.sh
index 537f3b3..626e23e 100644 (file)
@@ -7,8 +7,8 @@
 set -e
 
 ONLY=${ONLY:-"$*"}
-# bug number for skipped test: 4900 4900 2108 9789 3637 9789 3561 5188/5749 13310 10764
-ALWAYS_EXCEPT=${ALWAYS_EXCEPT:-"27o 27q  42a  42b  42c  42d  45   68        74b   75"}
+# bug number for skipped test: 4900 4900 2108 9789 3637 9789 3561 13310 10764
+ALWAYS_EXCEPT="                 27o 27q  42a  42b  42c  42d  45   74b   75 $SANITY_EXCEPT"
 # bug number for skipped test: 2108 9789 3637 9789 3561 5188/5749 1443
 #ALWAYS_EXCEPT=${ALWAYS_EXCEPT:-"27m 42a 42b 42c 42d 45 68 76"}
 # UPDATE THE COMMENT ABOVE WITH BUG NUMBERS WHEN CHANGING ALWAYS_EXCEPT!
@@ -90,7 +90,7 @@ LUSTRE=${LUSTRE:-`dirname $0`/..}
 init_test_env $@
 . ${CONFIG:=$LUSTRE/tests/cfg/local.sh}
 
-if [ ! -z "$USING_KRB5" ]; then
+if $GSS_KRB5; then
     $RUNAS krb5_login.sh || exit 1
     $RUNAS -u $(($RUNAS_ID + 1)) krb5_login.sh || exit 1
 fi
@@ -2062,7 +2062,7 @@ test_48b() { # bug 2399
        fi
        ls . > /dev/null && error "'ls .' worked after removing cwd"
        ls .. > /dev/null || error "'ls ..' failed after removing cwd"
-       cd . && error "'cd .' worked after removing cwd"
+       is_patchless || ( cd . && error "'cd .' worked after removing cwd" )
        mkdir . && error "'mkdir .' worked after removing cwd"
        rmdir . && error "'rmdir .' worked after removing cwd"
        ln -s . foo && error "'ln -s .' worked after removing cwd"
@@ -2085,7 +2085,7 @@ test_48c() { # bug 2350
        fi
        $TRACE ls . && error "'ls .' worked after removing cwd"
        $TRACE ls .. || error "'ls ..' failed after removing cwd"
-       $TRACE cd . && error "'cd .' worked after removing cwd"
+       is_patchless || ( $TRACE cd . && error "'cd .' worked after removing cwd" )
        $TRACE mkdir . && error "'mkdir .' worked after removing cwd"
        $TRACE rmdir . && error "'rmdir .' worked after removing cwd"
        $TRACE ln -s . foo && error "'ln -s .' worked after removing cwd"
@@ -2109,11 +2109,11 @@ test_48d() { # bug 2350
        fi
        $TRACE ls . && error "'ls .' worked after removing parent"
        $TRACE ls .. && error "'ls ..' worked after removing parent"
-       $TRACE cd . && error "'cd .' worked after recreate parent"
+       is_patchless || ( $TRACE cd . && error "'cd .' worked after recreate parent" )
        $TRACE mkdir . && error "'mkdir .' worked after removing parent"
        $TRACE rmdir . && error "'rmdir .' worked after removing parent"
        $TRACE ln -s . foo && error "'ln -s .' worked after removing parent"
-       $TRACE cd .. && error "'cd ..' worked after removing parent" || true
+       is_patchless || ( $TRACE cd .. && error "'cd ..' worked after removing parent" || true )
 }
 run_test 48d "Access removed parent subdir (should return errors)"
 
@@ -2467,6 +2467,7 @@ test_56h() {
 run_test 56h "check lfs find ! -name ============================="
 
 test_56i() {
+       tdir=${tdir}i
        mkdir -p $DIR/$tdir
        UUID=`$GETSTRIPE $DIR/$tdir | awk '/0: / { print $2 }'`
        OUT="`$LFIND -ost $UUID $DIR/$tdir`"
@@ -2669,22 +2670,21 @@ test_65c() {
 }
 run_test 65c "directory setstripe $(($STRIPESIZE * 4)) 1 $(($OSTCOUNT - 1))"
 
-if [ $STRIPECOUNT -eq 0 ]; then
-       sc=1
-elif [ $STRIPECOUNT -gt 160 ]; then
-#LOV_MAX_STRIPE_COUNT is 160, 4294967295(-1) is included.
-       [ $OSTCOUNT -gt 160 ] && sc=160 || sc=$(($OSTCOUNT - 1))
-else
-       sc=$(($STRIPECOUNT - 1))
-fi
-
 test_65d() {
        mkdir -p $DIR/d65
+       if [ $STRIPECOUNT -le 0 ]; then
+               sc=1
+       elif [ $STRIPECOUNT -gt 160 ]; then
+#LOV_MAX_STRIPE_COUNT is 160
+               [ $OSTCOUNT -gt 160 ] && sc=160 || sc=$(($OSTCOUNT - 1))
+       else
+               sc=$(($STRIPECOUNT - 1))
+       fi
        $SETSTRIPE $DIR/d65 $STRIPESIZE -1 $sc || error "setstripe"
        touch $DIR/d65/f4 $DIR/d65/f5
        $LVERIFY $DIR/d65 $DIR/d65/f4 $DIR/d65/f5 || error "lverify failed"
 }
-run_test 65d "directory setstripe $STRIPESIZE -1 $sc =============="
+run_test 65d "directory setstripe $STRIPESIZE -1 stripe_count =============="
 
 test_65e() {
        mkdir -p $DIR/d65
@@ -2787,12 +2787,14 @@ test_67() {
 }
 run_test 67 "security test ====================================="
 
+LLOOP=
 cleanup_68() {
        trap 0
-       if [ "$LOOPDEV" ]; then
-               swapoff $LOOPDEV || error "swapoff failed"
-               losetup -d $LOOPDEV || error "losetup -d failed"
-               unset LOOPDEV LOOPNUM
+       if [ ! -z "$LLOOP" ]; then
+               swapoff $LLOOP || error "swapoff failed"
+               $LCTL blockdev_detach $LLOOP || error "detach failed"
+               rm -f $LLOOP
+               unset LLOOP
        fi
        rm -f $DIR/f68
 }
@@ -2805,6 +2807,7 @@ swap_used() {
        swapon -s | awk '($1 == "'$1'") { print $4 }'
 }
 
+
 # excercise swapping to lustre by adding a high priority swapfile entry
 # and then consuming memory until it is used.
 test_68() {
@@ -2812,20 +2815,24 @@ test_68() {
        grep -q obdfilter $LPROC/devices && \
                skip "local OST" && return
 
-       find_loop_dev
-       dd if=/dev/zero of=$DIR/f68 bs=64k count=1024
+       grep -q llite_lloop /proc/modules
+       [ $? -ne 0 ] && skip "can't find module llite_lloop" && return
+
+       LLOOP=$TMP/lloop.`date +%s`.`date +%N`
+       dd if=/dev/zero of=$DIR/f68 bs=64k seek=2047 count=1
+       mkswap $DIR/f68
+
+       $LCTL blockdev_attach $DIR/f68 $LLOOP || error "attach failed"
 
        trap cleanup_68 EXIT
 
-       losetup $LOOPDEV $DIR/f68 || error "losetup $LOOPDEV failed"
-       mkswap $LOOPDEV
-       swapon -p 32767 $LOOPDEV || error "swapon $LOOPDEV failed"
+       swapon -p 32767 $LLOOP || error "swapon $LLOOP failed"
 
-       echo "before: `swapon -s | grep $LOOPDEV`"
-       KBFREE=`meminfo MemTotal`
-       $MEMHOG $KBFREE || error "error allocating $KBFREE kB"
-       echo "after: `swapon -s | grep $LOOPDEV`"
-       SWAPUSED=`swap_used $LOOPDEV`
+       echo "before: `swapon -s | grep $LLOOP`"
+       MEMTOTAL=`meminfo MemTotal`
+       $MEMHOG $MEMTOTAL || error "error allocating $MEMTOTAL kB"
+       echo "after: `swapon -s | grep $LLOOP`"
+       SWAPUSED=`swap_used $LLOOP`
 
        cleanup_68
 
@@ -2838,8 +2845,7 @@ run_test 68 "support swapping to Lustre ========================"
 test_69() {
        [ $(grep -c obdfilter $LPROC/devices) -eq 0 ] && \
                skip "skipping test for remote OST" && return
-       [ ! -z "$USING_KRB5" ] && \
-               skip "gss with bulk security will triger oops. re-enable this after b10091 get fixed" && return
+       $GSS && skip "gss with bulk security will triger oops. re-enable this after b10091 get fixed" && return
 
        f="$DIR/$tfile"
        touch $f
@@ -3541,22 +3547,22 @@ test_102b() {
 run_test 102b "getfattr/setfattr for trusted.lov EAs ============"
 
 test_102c() {
-       # b10930: get/set/list trusted.lov xattr
-       echo "get/set/list trusted.lov xattr ..."
+       # b10930: get/set/list lustre.lov xattr
+       echo "get/set/list lustre.lov xattr ..."
        [ "$OSTCOUNT" -lt "2" ] && skip "skipping 2-stripe test" && return
        mkdir -p $DIR/$tdir
        chown $RUNAS_ID $DIR/$tdir
        local testfile=$DIR/$tdir/$tfile
        $RUNAS $SETSTRIPE $testfile 65536 1 2
-       $RUNAS getfattr -d -m "^trusted" $testfile 2> /dev/null | \
-       grep "trusted.lov" || error "can't get trusted.lov from $testfile"
+       $RUNAS getfattr -d -m "^lustre" $testfile 2> /dev/null | \
+       grep "lustre.lov" || error "can't get lustre.lov from $testfile"
 
        local testfile2=${testfile}2
-       local value=`getfattr -n trusted.lov $testfile 2> /dev/null | \
-                    grep "trusted.lov" |sed -e 's/[^=]\+=//'  `
+       local value=`getfattr -n lustre.lov $testfile 2> /dev/null | \
+                    grep "lustre.lov" |sed -e 's/[^=]\+=//'  `
        
        $RUNAS $MCREATE $testfile2
-       $RUNAS setfattr -n trusted.lov -v $value $testfile2     
+       $RUNAS setfattr -n lustre.lov -v $value $testfile2      
        local tmp_file=${testfile}3
        $RUNAS $GETSTRIPE -v $testfile2 > $tmp_file
        local stripe_size=`grep "size"  $tmp_file| awk '{print $2}'`
@@ -3564,7 +3570,7 @@ test_102c() {
        [ $stripe_size -eq 65536 ] || error "stripe size $stripe_size != 65536"
        [ $stripe_count -eq 2 ] || error "stripe count $stripe_count != 2"
 }
-run_test 102c "non-root getfattr/setfattr for trusted.lov EAs ==========="
+run_test 102c "non-root getfattr/setfattr for lustre.lov EAs ==========="
 
 get_stripe_info() {
        stripe_size=0
@@ -3715,7 +3721,7 @@ test_103 () {
     [ "$UID" != 0 ] && skip "must run as root" && return
     [ -z "$(grep acl $LPROC/mdc/*-mdc-*/connect_flags)" ] && skip "must have acl enabled" && return
     [ -z "$(which setfacl 2>/dev/null)" ] && skip "could not find setfacl" && return
-    [ ! -z "$USING_KRB5" ] && skip "could not run under gss" && return
+    $GSS && skip "could not run under gss" && return
 
     SAVE_UMASK=`umask`
     umask 0022
@@ -4018,7 +4024,79 @@ test_119b() # bug 11737
 }
 run_test 119b "Sparse directIO read must return actual read amount"
 
-test_119a() {
+LDLM_POOL_CTL_RECALC=1
+LDLM_POOL_CTL_SHRINK=2
+
+disable_pool_recalc() {
+        for NSD in $LPROC/ldlm/namespaces/*$1*; do
+                if test -f $NSD/pool/control; then
+                        CONTROL=`cat $NSD/pool/control`
+                        CONTROL=$((CONTROL & ~LDLM_POOL_CTL_RECALC))
+                        echo "$CONTROL" > $NSD/pool/control
+                fi
+        done
+}
+
+enable_pool_recalc() {
+        for NSD in $LPROC/ldlm/namespaces/*$1*; do
+                if test -f $NSD/pool/control; then
+                        CONTROL=`cat $NSD/pool/control`
+                        CONTROL=$((CONTROL | LDLM_POOL_CTL_RECALC))
+                        echo "$CONTROL" > $NSD/pool/control
+                fi
+        done
+}
+
+disable_pool_shrink() {
+        for NSD in $LPROC/ldlm/namespaces/*$1*; do
+                if test -f $NSD/pool/control; then
+                        CONTROL=`cat $NSD/pool/control`
+                        CONTROL=$((CONTROL & ~LDLM_POOL_CTL_SHRINK))
+                        echo "$CONTROL" > $NSD/pool/control
+                fi
+        done
+}
+
+enable_pool_shrink() {
+        for NSD in $LPROC/ldlm/namespaces/*$1*; do
+                if test -f $NSD/pool/control; then
+                        CONTROL=`cat $NSD/pool/control`
+                        CONTROL=$((CONTROL | LDLM_POOL_CTL_SHRINK))
+                        echo "$CONTROL" > $NSD/pool/control
+                fi
+        done
+}
+
+disable_pool() {
+        disable_pool_shrink $1
+        disable_pool_recalc $1
+}
+
+enable_pool() {
+        enable_pool_shrink $1
+        enable_pool_recalc $1
+}
+
+lru_resize_enable()
+{
+        enable_pool osc
+        enable_pool "filter-$FSNAME"
+        enable_pool mdc
+        enable_pool "mds-$FSNAME"
+}
+
+lru_resize_disable()
+{
+        disable_pool osc
+        disable_pool "filter-$FSNAME"
+        disable_pool mdc
+        disable_pool "mds-$FSNAME"
+}
+
+test_120a() {
+        [ -z "`grep early_lock_cancel $LPROC/mdc/*/connect_flags`" ] && \
+               skip "no early lock cancel on server" && return 0
+        lru_resize_disable
         mkdir $DIR/$tdir
         cancel_lru_locks mdc
         stat $DIR/$tdir > /dev/null
@@ -4029,10 +4107,14 @@ test_119a() {
         blk2=`awk '/ldlm_bl_callback/ {print $2}' $LPROC/ldlm/services/ldlm_cbd/stats`
         [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
         [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
+        lru_resize_enable
 }
-run_test 119a "Early Lock Cancel: mkdir test"
+run_test 120a "Early Lock Cancel: mkdir test"
 
-test_119b() {
+test_120b() {
+        [ -z "`grep early_lock_cancel $LPROC/mdc/*/connect_flags`" ] && \
+               skip "no early lock cancel on server" && return 0
+        lru_resize_disable
         mkdir $DIR/$tdir
         cancel_lru_locks mdc
         stat $DIR/$tdir > /dev/null
@@ -4043,10 +4125,14 @@ test_119b() {
         can2=`awk '/ldlm_cancel/ {print $2}' $LPROC/ldlm/services/ldlm_canceld/stats`
         [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
         [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
+        lru_resize_enable
 }
-run_test 119b "Early Lock Cancel: create test"
+run_test 120b "Early Lock Cancel: create test"
 
-test_119c() {
+test_120c() {
+        [ -z "`grep early_lock_cancel $LPROC/mdc/*/connect_flags`" ] && \
+               skip "no early lock cancel on server" && return 0
+        lru_resize_disable
         mkdir -p $DIR/$tdir/d1 $DIR/$tdir/d2
         touch $DIR/$tdir/d1/f1
         cancel_lru_locks mdc
@@ -4058,10 +4144,14 @@ test_119c() {
         blk2=`awk '/ldlm_bl_callback/ {print $2}' $LPROC/ldlm/services/ldlm_cbd/stats`
         [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
         [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
+        lru_resize_enable
 }
-run_test 119c "Early Lock Cancel: link test"
+run_test 120c "Early Lock Cancel: link test"
 
-test_119d() {
+test_120d() {
+        [ -z "`grep early_lock_cancel $LPROC/mdc/*/connect_flags`" ] && \
+               skip "no early lock cancel on server" && return 0
+        lru_resize_disable
         touch $DIR/$tdir
         cancel_lru_locks mdc
         stat $DIR/$tdir > /dev/null
@@ -4072,10 +4162,14 @@ test_119d() {
         blk2=`awk '/ldlm_bl_callback/ {print $2}' $LPROC/ldlm/services/ldlm_cbd/stats`
         [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
         [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
+        lru_resize_enable
 }
-run_test 119d "Early Lock Cancel: setattr test"
+run_test 120d "Early Lock Cancel: setattr test"
 
-test_119e() {
+test_120e() {
+        [ -z "`grep early_lock_cancel $LPROC/mdc/*/connect_flags`" ] && \
+               skip "no early lock cancel on server" && return 0
+        lru_resize_disable
         mkdir $DIR/$tdir
         dd if=/dev/zero of=$DIR/$tdir/f1 count=1
         cancel_lru_locks mdc
@@ -4089,10 +4183,14 @@ test_119e() {
         blk2=`awk '/ldlm_bl_callback/ {print $2}' $LPROC/ldlm/services/ldlm_cbd/stats`
         [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
         [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
+        lru_resize_enable
 }
-run_test 119e "Early Lock Cancel: unlink test"
+run_test 120e "Early Lock Cancel: unlink test"
 
-test_119f() {
+test_120f() {
+        [ -z "`grep early_lock_cancel $LPROC/mdc/*/connect_flags`" ] && \
+               skip "no early lock cancel on server" && return 0
+        lru_resize_disable
         mkdir -p $DIR/$tdir/d1 $DIR/$tdir/d2
         dd if=/dev/zero of=$DIR/$tdir/d1/f1 count=1
         dd if=/dev/zero of=$DIR/$tdir/d2/f2 count=1
@@ -4108,13 +4206,17 @@ test_119f() {
         blk2=`awk '/ldlm_bl_callback/ {print $2}' $LPROC/ldlm/services/ldlm_cbd/stats`
         [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
         [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
+        lru_resize_enable
 }
-run_test 119f "Early Lock Cancel: rename test"
+run_test 120f "Early Lock Cancel: rename test"
 
-test_119g() {
+test_120g() {
+        [ -z "`grep early_lock_cancel $LPROC/mdc/*/connect_flags`" ] && \
+               skip "no early lock cancel on server" && return 0
+        lru_resize_disable
         count=10000
         echo create $count files
-        mkdir  $DIR/$tdir
+        mkdir -p $DIR/$tdir
         cancel_lru_locks mdc
         cancel_lru_locks osc
         t0=`date +%s`
@@ -4137,8 +4239,96 @@ test_119g() {
         echo total: $((can2-can1)) cancels, $((blk2-blk1)) blockings
         sleep 2
         # wait for commitment of removal
+        lru_resize_enable
+}
+run_test 120g "Early Lock Cancel: performance test"
+
+test_121() { #bug #10589
+       rm -rf $DIR/$tfile
+       writes=`dd if=/dev/zero of=$DIR/$tfile count=1 2>&1 | awk 'BEGIN { FS="+" } /out/ {print $1}'`
+#define OBD_FAIL_LDLM_CANCEL_RACE        0x310
+       sysctl -w lustre.fail_loc=0x310
+       cancel_lru_locks osc > /dev/null
+       reads=`dd if=$DIR/$tfile of=/dev/null 2>&1 | awk 'BEGIN { FS="+" } /in/ {print $1}'`
+       sysctl -w lustre.fail_loc=0
+       [ $reads -eq $writes ] || error "read" $reads "blocks, must be" $writes
 }
-run_test 119g "Early Lock Cancel: performance test"
+run_test 121 "read cancel race ========="
+
+test_124() {
+       [ -z "`grep lru_resize $LPROC/mdc/*/connect_flags`" ] && \
+               skip "no lru resize on server" && return 0
+        cancel_lru_locks mdc
+        lru_resize_enable
+        NSDIR=`find $LPROC/ldlm/namespaces | grep mdc | head -1`
+
+        # we want to test main pool functionality, that is cancel based on SLV
+        # this is why shrinkers are disabled
+        disable_pool_shrink "mds-$FSNAME"
+        disable_pool_shrink mdc
+
+        NR=2000
+        mkdir -p $DIR/$tdir || error "failed to create $DIR/$tdir"
+
+        LRU_SIZE=`cat $NSDIR/lru_size`
+
+        # use touch to produce $NR new locks
+        log "create $NR files at $DIR/$tdir"
+        for ((i=0;i<$NR;i++)); do touch $DIR/$tdir/f$i; done
+
+        LRU_SIZE_B=`cat $NSDIR/lru_size`
+        if test $LRU_SIZE -ge $LRU_SIZE_B; then
+                skip "No cached locks created!"
+                cat $NSDIR/pool/state
+                return 0
+        fi
+        LRU_SIZE_B=$((LRU_SIZE_B-LRU_SIZE))
+        log "created $LRU_SIZE_B lock(s)"
+
+        # we want to sleep 30s to not make test too long
+        SLEEP=30
+        SLEEP_ADD=10
+
+        # we know that lru resize allows one client to hold $LIMIT locks for 10h
+        MAX_HRS=10
+
+        # get the pool limit
+        LIMIT=`cat $NSDIR/pool/limit`
+
+        # calculate lock volume factor taking into account sleep and data set
+        # use $LRU_SIZE_B here to take into account real number of locks created
+        # in the case of CMD, LRU_SIZE_B != $NR in most of cases
+        LVF=$(($LIMIT * $MAX_HRS * 60 * 60 / $LRU_SIZE_B / $SLEEP))
+
+        log "make client drop locks $LVF times faster so that ${SLEEP}s is enough to cancel $LRU_SIZE_B lock(s)"
+        OLD_LVF=`cat $NSDIR/pool/lock_volume_factor`
+        echo "$LVF" > $NSDIR/pool/lock_volume_factor
+        log "sleep for "$((SLEEP+SLEEP_ADD))"s"
+        sleep $((SLEEP+SLEEP_ADD))
+        echo "$OLD_LVF" > $NSDIR/pool/lock_volume_factor
+        LRU_SIZE_A=`cat $NSDIR/lru_size`
+
+        [ $LRU_SIZE_B -ge $LRU_SIZE_A ] || {
+                error "No locks dropped in "$((SLEEP+SLEEP_ADD))"s. LRU size: $LRU_SIZE_A"
+                lru_resize_enable
+                unlinkmany $DIR/$tdir/f $NR
+                return
+        }
+
+        log "Dropped "$((LRU_SIZE_B-LRU_SIZE_A))" locks in "$((SLEEP+SLEEP_ADD))"s"
+        lru_resize_enable
+        log "unlink $NR files at $DIR/$tdir"
+        unlinkmany $DIR/$tdir/f $NR
+}
+run_test 124 "lru resize ======================================="
+
+test_125() { # 13358
+       mkdir -p $DIR/d125 || error "mkdir failed"
+       $SETSTRIPE $DIR/d125 65536 -1 -1 || error "setstripe failed"
+       setfacl -R -m u:bin:rwx $DIR/d125 || error "setfacl $DIR/d125 failed"
+       ls -ld $DIR/d125 || error "cannot access $DIR/d125"
+}
+run_test 125 "don't return EPROTO when a dir has a non-default striping and ACLs"
 
 TMPDIR=$OLDTMPDIR
 TMP=$OLDTMP