Whamcloud - gitweb
Revert my use of the configure_flags macro in the lustre.spec file and just
[fs/lustre-release.git] / lustre / tests / recovery-small.sh
index d0dd6f0..d996a0f 100755 (executable)
@@ -2,61 +2,75 @@
 
 set -e
 
-#         bug 2732 2986
-ALWAYS_EXCEPT="17   20b"
+# 20b: bug  2986
+ALWAYS_EXCEPT=" 20b"
 
 
 LUSTRE=${LUSTRE:-`dirname $0`/..}
-UPCALL=${UPCALL:-$PWD/recovery-small-upcall.sh}
+
 . $LUSTRE/tests/test-framework.sh
 
 init_test_env $@
 
-. ${CONFIG:=$LUSTRE/tests/cfg/local.sh}
+. ${CONFIG:=$LUSTRE/tests/cfg/lmv.sh}
 
 build_test_filter
 
+assert_env MDSCOUNT
 
 # Allow us to override the setup if we already have a mounted system by
 # setting SETUP=" " and CLEANUP=" "
 SETUP=${SETUP:-"setup"}
 CLEANUP=${CLEANUP:-"cleanup"}
 
-
-make_config() {
+gen_config() {
     rm -f $XMLCONFIG
-    add_mds mds --dev $MDSDEV --size $MDSSIZE
-    add_lov lov1 mds --stripe_sz $STRIPE_BYTES\
-       --stripe_cnt $STRIPES_PER_OBJ --stripe_pattern 0
+
+    if [ "$MDSCOUNT" -gt 1 ]; then
+        add_lmv lmv1_svc
+        for mds in `mds_list`; do
+            MDSDEV=$TMP/${mds}-`hostname`
+            add_mds $mds --dev $MDSDEV --size $MDSSIZE  --lmv lmv1_svc
+        done
+        add_lov_to_lmv lov1 lmv1_svc --stripe_sz $STRIPE_BYTES \
+           --stripe_cnt $STRIPES_PER_OBJ --stripe_pattern 0
+       MDS=lmv1
+    else
+        add_mds mds1 --dev $MDSDEV --size $MDSSIZE
+        add_lov lov1 mds1 --stripe_sz $STRIPE_BYTES \
+           --stripe_cnt $STRIPES_PER_OBJ --stripe_pattern 0
+       MDS=mds1
+
+    fi
+
     add_ost ost --lov lov1 --dev $OSTDEV --size $OSTSIZE
     add_ost ost2 --lov lov1 --dev ${OSTDEV}-2 --size $OSTSIZE
-    add_client client mds --lov lov1 --path $MOUNT
+    add_client client ${MDS} --lov lov1 --path $MOUNT
 }
 
 setup() {
-    make_config
+    gen_config
+    start_krb5_kdc || exit 1
+    start_lsvcgssd || exit 2
+    start_lgssd || exit 3
     start ost --reformat $OSTLCONFARGS 
     start ost2 --reformat $OSTLCONFARGS 
     [ "$DAEMONFILE" ] && $LCTL debug_daemon start $DAEMONFILE $DAEMONSIZE
-    start mds $MDSLCONFARGS --reformat
-    zconf_mount `hostname`  $MOUNT
+    for mds in `mds_list`; do
+       start $mds --reformat $MDSLCONFARGS
+    done
+    grep " $MOUNT " /proc/mounts || zconf_mount `hostname`  $MOUNT
 }
 
 cleanup() {
     zconf_umount `hostname` $MOUNT
-    stop mds ${FORCE} $MDSLCONFARGS
+    for mds in `mds_list`; do
+       stop $mds ${FORCE} $MDSLCONFARGS
+    done
     stop ost2 ${FORCE} --dump cleanup.log
     stop ost ${FORCE} --dump cleanup.log
-}
-
-replay() {
-    do_mds "sync"
-    do_mds 'echo -e "device \$mds1\\nprobe\\nnotransno\\nreadonly" | lctl'
-    do_client "$1" &
-    shutdown_mds -f
-    start_mds
-    wait
-    do_client "df -h $MOUNT" # trigger failover, if we haven't already
+    stop_lgssd
+    stop_lsvcgssd
 }
 
 if [ ! -z "$EVAL" ]; then
@@ -64,6 +78,11 @@ if [ ! -z "$EVAL" ]; then
     exit $?
 fi
 
+if [ "$ONLY" == "setup" ]; then
+    setup
+    exit
+fi
+
 if [ "$ONLY" == "cleanup" ]; then
     sysctl -w portals.debug=0 || true
     cleanup
@@ -73,6 +92,8 @@ fi
 REFORMAT=--reformat $SETUP
 unset REFORMAT
 
+[ "$ONLY" == "setup" ] && exit
+
 test_1() {
     drop_request "mcreate $MOUNT/1"  || return 1
     drop_reint_reply "mcreate $MOUNT/2"    || return 2
@@ -171,6 +192,7 @@ test_12(){
 #define OBD_FAIL_MDS_CLOSE_NET           0x115
     sleep 2
     kill -USR1 $PID
+    cancel_lru_locks MDC  # force the close
     echo "waiting for multiop $PID"
     wait $PID || return 2
     do_facet client munlink $MOUNT/$tfile  || return 3
@@ -179,13 +201,13 @@ run_test 12 "recover from timed out resend in ptlrpcd (b=2494)"
 
 # Bug 113, check that readdir lost recv timeout works.
 test_13() {
-    mkdir /mnt/lustre/readdir
-    touch /mnt/lustre/readdir/newentry
+    mkdir /mnt/lustre/readdir || return 1
+    touch /mnt/lustre/readdir/newentry  || return 
 # OBD_FAIL_MDS_READPAGE_NET|OBD_FAIL_ONCE
     do_facet mds "sysctl -w lustre.fail_loc=0x80000104"
-    ls /mnt/lustre/readdir || return 1
+    ls /mnt/lustre/readdir || return 3
     do_facet mds "sysctl -w lustre.fail_loc=0"
-    rm -rf /mnt/lustre/readdir
+    rm -rf /mnt/lustre/readdir  || return 4
 }
 run_test 13 "mdc_readpage restart test (bug 1138)"
 
@@ -207,9 +229,26 @@ test_15() {
 }
 run_test 15 "failed open (-ENOMEM)"
 
+stop_read_ahead() {
+   for f in /proc/fs/lustre/llite/*/read_ahead; do 
+      echo 0 > $f
+   done
+}
+
+start_read_ahead() {
+   for f in /proc/fs/lustre/llite/*/read_ahead; do 
+      echo 1 > $f
+   done
+}
+
+# recovery timeout. This actually should be taken from 
+# obd_timeout
+RECOV_TIMEOUT=30
+
 test_16() {
     do_facet client cp /etc/termcap $MOUNT
     sync
+    stop_read_ahead
 
 #define OBD_FAIL_PTLRPC_BULK_PUT_NET 0x504 | OBD_FAIL_ONCE
     sysctl -w lustre.fail_loc=0x80000504
@@ -218,20 +257,25 @@ test_16() {
     do_facet client "cmp /etc/termcap $MOUNT/termcap"  && return 1
     sysctl -w lustre.fail_loc=0
     # give recovery a chance to finish (shouldn't take long)
-    sleep 
+    sleep $RECOV_TIMEOUT
     do_facet client "cmp /etc/termcap $MOUNT/termcap"  || return 2
+    start_read_ahead
 }
 run_test 16 "timeout bulk put, evict client (2732)"
 
 test_17() {
-#define OBD_FAIL_PTLRPC_BULK_GET_NET 0x0503 | OBD_FAIL_ONCE
-    # will get evicted here
+    # OBD_FAIL_PTLRPC_BULK_GET_NET 0x0503 | OBD_FAIL_ONCE
+    # client will get evicted here
     sysctl -w lustre.fail_loc=0x80000503
-    do_facet client cp /etc/termcap $MOUNT && return 1
+    do_facet client cp /etc/termcap $DIR/$tfile
 
-    do_facet client "cmp /etc/termcap $MOUNT/termcap"  && return 1
+    sleep $RECOV_TIMEOUT
     sysctl -w lustre.fail_loc=0
-    do_facet client "cmp /etc/termcap $MOUNT/termcap"  || return 2
+    do_facet client "df $DIR"
+    # expect cmp to fail
+    do_facet client "cmp /etc/termcap $DIR/$tfile"  && return 1
+    do_facet client "rm $DIR/$tfile" || return 2
+    return 0
 }
 run_test 17 "timeout bulk get, evict client (2732)"
 
@@ -297,6 +341,8 @@ test_19a() {
     drop_ldlm_cancel "chmod 0777 $f"  || echo evicted
 
     do_facet client checkstat -v -p 0777 $f  || echo evicted
+    # let the client reconnect
+    sleep 5
     do_facet client "munlink $f"
 }
 run_test 19a "test expired_lock_main on mds (2867)"
@@ -319,7 +365,7 @@ test_20a() {        # bug 2983 - ldlm_handle_enqueue cleanup
        mkdir -p $DIR/$tdir
        multiop $DIR/$tdir/${tfile} O_wc &
        MULTI_PID=$!
-       usleep 500
+       sleep 1
        cancel_lru_locks OSC
 #define OBD_FAIL_LDLM_ENQUEUE_EXTENT_ERR 0x308
        do_facet ost sysctl -w lustre.fail_loc=0x80000308
@@ -341,4 +387,233 @@ test_20b() {      # bug 2986 - ldlm_handle_enqueue error during open
 }
 run_test 20b "ldlm_handle_enqueue error (should return error)"
 
+test_21a() {
+       mkdir -p $DIR/$tdir-1
+       mkdir -p $DIR/$tdir-2
+       multiop $DIR/$tdir-1/f O_c &
+       close_pid=$!
+
+       do_facet mds "sysctl -w lustre.fail_loc=0x80000129"
+       multiop $DIR/$tdir-2/f Oc &
+       open_pid=$!
+       sleep 1
+       do_facet mds "sysctl -w lustre.fail_loc=0"
+
+       do_facet mds "sysctl -w lustre.fail_loc=0x80000115"
+       kill -USR1 $close_pid
+       cancel_lru_locks MDC  # force the close
+       wait $close_pid || return 1
+       wait $open_pid || return 2
+       do_facet mds "sysctl -w lustre.fail_loc=0"
+
+       $CHECKSTAT -t file $DIR/$tdir-1/f || return 3
+       $CHECKSTAT -t file $DIR/$tdir-2/f || return 4
+
+       rm -rf $DIR/$tdir-*
+}
+run_test 21a "drop close request while close and open are both in flight"
+
+test_21b() {
+       mkdir -p $DIR/$tdir-1
+       mkdir -p $DIR/$tdir-2
+       multiop $DIR/$tdir-1/f O_c &
+       close_pid=$!
+
+       do_facet mds "sysctl -w lustre.fail_loc=0x80000107"
+       mcreate $DIR/$tdir-2/f &
+       open_pid=$!
+       sleep 1
+       do_facet mds "sysctl -w lustre.fail_loc=0"
+
+       kill -USR1 $close_pid
+       cancel_lru_locks MDC  # force the close
+       wait $close_pid || return 1
+       wait $open_pid || return 3
+
+       $CHECKSTAT -t file $DIR/$tdir-1/f || return 4
+       $CHECKSTAT -t file $DIR/$tdir-2/f || return 5
+       rm -rf $DIR/$tdir-*
+}
+run_test 21b "drop open request while close and open are both in flight"
+
+test_21c() {
+       mkdir -p $DIR/$tdir-1
+       mkdir -p $DIR/$tdir-2
+       multiop $DIR/$tdir-1/f O_c &
+       close_pid=$!
+
+       do_facet mds "sysctl -w lustre.fail_loc=0x80000107"
+       mcreate $DIR/$tdir-2/f &
+       open_pid=$!
+       sleep 3
+       do_facet mds "sysctl -w lustre.fail_loc=0"
+
+       do_facet mds "sysctl -w lustre.fail_loc=0x80000115"
+       kill -USR1 $close_pid
+       cancel_lru_locks MDC  # force the close
+       wait $close_pid || return 1
+       wait $open_pid || return 2
+
+       do_facet mds "sysctl -w lustre.fail_loc=0"
+
+       $CHECKSTAT -t file $DIR/$tdir-1/f || return 2
+       $CHECKSTAT -t file $DIR/$tdir-2/f || return 3
+       rm -rf $DIR/$tdir-*
+}
+run_test 21c "drop both request while close and open are both in flight"
+
+test_21d() {
+       mkdir -p $DIR/$tdir-1
+       mkdir -p $DIR/$tdir-2
+       multiop $DIR/$tdir-1/f O_c &
+       pid=$!
+
+       do_facet mds "sysctl -w lustre.fail_loc=0x80000129"
+       multiop $DIR/$tdir-2/f Oc &
+       sleep 1
+       do_facet mds "sysctl -w lustre.fail_loc=0"
+
+       do_facet mds "sysctl -w lustre.fail_loc=0x80000122"
+       kill -USR1 $pid
+       cancel_lru_locks MDC  # force the close
+       wait $pid || return 1
+       do_facet mds "sysctl -w lustre.fail_loc=0"
+
+       $CHECKSTAT -t file $DIR/$tdir-1/f || return 2
+       $CHECKSTAT -t file $DIR/$tdir-2/f || return 3
+
+       rm -rf $DIR/$tdir-*
+}
+run_test 21d "drop close reply while close and open are both in flight"
+
+test_21e() {
+       mkdir -p $DIR/$tdir-1
+       mkdir -p $DIR/$tdir-2
+       multiop $DIR/$tdir-1/f O_c &
+       pid=$!
+
+       do_facet mds "sysctl -w lustre.fail_loc=0x80000119"
+       touch $DIR/$tdir-2/f &
+       sleep 1
+       do_facet mds "sysctl -w lustre.fail_loc=0"
+
+       kill -USR1 $pid
+       cancel_lru_locks MDC  # force the close
+       wait $pid || return 1
+
+       sleep $TIMEOUT
+       $CHECKSTAT -t file $DIR/$tdir-1/f || return 2
+       $CHECKSTAT -t file $DIR/$tdir-2/f || return 3
+       rm -rf $DIR/$tdir-*
+}
+run_test 21e "drop open reply while close and open are both in flight"
+
+test_21f() {
+       mkdir -p $DIR/$tdir-1
+       mkdir -p $DIR/$tdir-2
+       multiop $DIR/$tdir-1/f O_c &
+       pid=$!
+
+       do_facet mds "sysctl -w lustre.fail_loc=0x80000119"
+       touch $DIR/$tdir-2/f &
+       sleep 1
+       do_facet mds "sysctl -w lustre.fail_loc=0"
+
+       do_facet mds "sysctl -w lustre.fail_loc=0x80000122"
+       kill -USR1 $pid
+       cancel_lru_locks MDC  # force the close
+       wait $pid || return 1
+       do_facet mds "sysctl -w lustre.fail_loc=0"
+
+       $CHECKSTAT -t file $DIR/$tdir-1/f || return 2
+       $CHECKSTAT -t file $DIR/$tdir-2/f || return 3
+       rm -rf $DIR/$tdir-*
+}
+run_test 21f "drop both reply while close and open are both in flight"
+
+test_21g() {
+       mkdir -p $DIR/$tdir-1
+       mkdir -p $DIR/$tdir-2
+       multiop $DIR/$tdir-1/f O_c &
+       pid=$!
+
+       do_facet mds "sysctl -w lustre.fail_loc=0x80000119"
+       touch $DIR/$tdir-2/f &
+       sleep 1
+       do_facet mds "sysctl -w lustre.fail_loc=0"
+
+       do_facet mds "sysctl -w lustre.fail_loc=0x80000115"
+       kill -USR1 $pid
+       cancel_lru_locks MDC  # force the close
+       wait $pid || return 1
+       do_facet mds "sysctl -w lustre.fail_loc=0"
+
+       $CHECKSTAT -t file $DIR/$tdir-1/f || return 2
+       $CHECKSTAT -t file $DIR/$tdir-2/f || return 3
+       rm -rf $DIR/$tdir-*
+}
+run_test 21g "drop open reply and close request while close and open are both in flight"
+
+test_21h() {
+       mkdir -p $DIR/$tdir-1
+       mkdir -p $DIR/$tdir-2
+       multiop $DIR/$tdir-1/f O_c &
+       pid=$!
+
+       do_facet mds "sysctl -w lustre.fail_loc=0x80000107"
+       touch $DIR/$tdir-2/f &
+       touch_pid=$!
+       sleep 1
+       do_facet mds "sysctl -w lustre.fail_loc=0"
+
+       do_facet mds "sysctl -w lustre.fail_loc=0x80000122"
+       cancel_lru_locks MDC  # force the close
+       kill -USR1 $pid
+       wait $pid || return 1
+       do_facet mds "sysctl -w lustre.fail_loc=0"
+
+       wait $touch_pid || return 2
+
+       $CHECKSTAT -t file $DIR/$tdir-1/f || return 3
+       $CHECKSTAT -t file $DIR/$tdir-2/f || return 4
+       rm -rf $DIR/$tdir-*
+}
+run_test 21h "drop open request and close reply while close and open are both in flight"
+
+# bug 3462 - multiple MDC requests
+test_22() {
+    f1=$DIR/${tfile}-1
+    f2=$DIR/${tfile}-2
+    
+    do_facet mds "sysctl -w lustre.fail_loc=0x80000115"
+    multiop $f2 Oc &
+    close_pid=$!
+
+    sleep 1
+    multiop $f1 msu || return 1
+
+     cancel_lru_locks MDC  # force the close
+    do_facet mds "sysctl -w lustre.fail_loc=0"
+
+    wait $close_pid || return 2
+    rm -rf $f2 || return 4
+}
+run_test 22 "drop close request and do mknod"
+
+test_23() { #b=4561
+    multiop $DIR/$tfile O_c &
+    pid=$!
+    # give a chance for open
+    sleep 5
+
+    # try the close
+    drop_request "kill -USR1 $pid"
+
+    fail mds
+    wait $pid || return 1
+    return 0
+}
+#run_test 23 "client hang when close a file after mds crash"
+
+
 $CLEANUP