Whamcloud - gitweb
LU-5710 corrected some typos and grammar errors
[fs/lustre-release.git] / lustre / tests / replay-single.sh
index 87e73b9..f657ec4 100755 (executable)
@@ -21,19 +21,15 @@ GRANT_CHECK_LIST=${GRANT_CHECK_LIST:-""}
 require_dsh_mds || exit 0
 
 # Skip these tests
-# bug number:  17466 18857      LU-1867 LU-1473
-ALWAYS_EXCEPT="61d   33a 33b    89      62     $REPLAY_SINGLE_EXCEPT"
-
-[ $(facet_fstype $SINGLEMDS) = "zfs" ] &&
-# bug number for skipped test:        LU-951
-       ALWAYS_EXCEPT="$ALWAYS_EXCEPT 73a"
+# bug number:  17466 18857      LU-1473
+ALWAYS_EXCEPT="61d   33a 33b    62     $REPLAY_SINGLE_EXCEPT"
 
 #                                                  63 min  7 min  AT AT AT AT"
 [ "$SLOW" = "no" ] && EXCEPT_SLOW="1 2 3 4 6 12 16 44a      44b    65 66 67 68"
 
 [ $(facet_fstype $SINGLEMDS) = "zfs" ] &&
-# bug number for skipped test:        LU-3127
-        ALWAYS_EXCEPT="$ALWAYS_EXCEPT 73b"
+# bug number for skipped test:        LU-1867  LU-3127
+        ALWAYS_EXCEPT="$ALWAYS_EXCEPT 89       73b"
 
 build_test_filter
 
@@ -440,9 +436,12 @@ test_20b() { # bug 10480
        mds_evict_client
        client_up || client_up || true    # reconnect
 
+       do_facet $SINGLEMDS "lctl set_param -n osd*.*MDT*.force_sync 1"
+
        fail $SINGLEMDS                            # start orphan recovery
        wait_recovery_complete $SINGLEMDS || error "MDS recovery not done"
        wait_delete_completed_mds $wait_timeout || return 3
+
        AFTERUSED=$(df -P $DIR | tail -1 | awk '{ print $3 }')
        log "before $BEFOREUSED, after $AFTERUSED"
        (( $AFTERUSED > $BEFOREUSED + $(fs_log_size) )) &&
@@ -1070,17 +1069,28 @@ run_test 50 "Double OSC recovery, don't LASSERT (3812)"
 
 # b3764 timed out lock replay
 test_52() {
-    touch $DIR/$tfile
-    cancel_lru_locks mdc
+       [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.6.90) ] &&
+               skip "MDS prior to 2.6.90 handle LDLM_REPLY_NET incorrectly" &&
+               return 0
 
-    multiop $DIR/$tfile s || return 1
-    replay_barrier $SINGLEMDS
-#define OBD_FAIL_LDLM_REPLY              0x30c
-    do_facet $SINGLEMDS "lctl set_param fail_loc=0x8000030c"
-    fail $SINGLEMDS || return 2
-    do_facet $SINGLEMDS "lctl set_param fail_loc=0x0"
+       touch $DIR/$tfile
+       cancel_lru_locks mdc
+
+       multiop_bg_pause $DIR/$tfile s_s || return 1
+       mpid=$!
 
-    $CHECKSTAT -t file $DIR/$tfile-* && return 3 || true
+       #define OBD_FAIL_MDS_LDLM_REPLY_NET     0x157
+       lctl set_param -n ldlm.cancel_unused_locks_before_replay "0"
+       do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000157"
+
+       fail $SINGLEMDS || return 2
+       kill -USR1 $mpid
+       wait $mpid || return 3
+
+       do_facet $SINGLEMDS "lctl set_param fail_loc=0x0"
+       lctl set_param fail_loc=0x0
+       lctl set_param -n ldlm.cancel_unused_locks_before_replay "1"
+       rm -f $DIR/$tfile
 }
 run_test 52 "time out lock replay (3764)"
 
@@ -1556,9 +1566,10 @@ test_61d() { # bug 16002 # bug 17466 # bug 22137
 #   OBD_FAIL_OBD_LLOG_SETUP        0x605
     stop mgs
     do_facet mgs "lctl set_param fail_loc=0x80000605"
-    start mgs $MGSDEV $MGS_MOUNT_OPTS && error "mgs start should have failed"
+    start mgs $(mgsdevname) $MGS_MOUNT_OPTS &&
+       error "mgs start should have failed"
     do_facet mgs "lctl set_param fail_loc=0"
-    start mgs $MGSDEV $MGS_MOUNT_OPTS || error "cannot restart mgs"
+    start mgs $(mgsdevname) $MGS_MOUNT_OPTS || error "cannot restart mgs"
 }
 run_test 61d "error in llog_setup should cleanup the llog context correctly"
 
@@ -1988,22 +1999,6 @@ test_73b() {
 }
 run_test 73b "open(O_CREAT), unlink, replay, reconnect at open_replay reply, close"
 
-test_73c() {
-    multiop_bg_pause $DIR/$tfile O_tSc || return 3
-    pid=$!
-    rm -f $DIR/$tfile
-
-    replay_barrier $SINGLEMDS
-#define OBD_FAIL_TGT_LAST_REPLAY       0x710
-    do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000710"
-    fail $SINGLEMDS
-    kill -USR1 $pid
-    wait $pid || return 1
-    [ -e $DIR/$tfile ] && return 2
-    return 0
-}
-run_test 73c "open(O_CREAT), unlink, replay, reconnect at last_replay, close"
-
 # bug 18554
 test_74() {
     local clients=${CLIENTS:-$HOSTNAME}
@@ -2043,12 +2038,12 @@ test_80a() {
        local remote_dir=$DIR/$tdir/remote_dir
 
        mkdir -p $DIR/$tdir
-       #define OBD_FAIL_UPDATE_OBJ_NET_REP     0x1701
-       do_facet mds$((MDTIDX + 1)) lctl set_param fail_loc=0x1701
+       #define OBD_FAIL_OUT_UPDATE_NET_REP     0x1701
+       do_facet mds${MDTIDX} lctl set_param fail_loc=0x1701
        $LFS mkdir -i $MDTIDX $remote_dir &
        local CLIENT_PID=$!
 
-       fail mds$((MDTIDX + 1))
+       fail mds${MDTIDX}
 
        wait $CLIENT_PID || error "remote creation failed"
 
@@ -2057,7 +2052,7 @@ test_80a() {
 
        return 0
 }
-run_test 80a "DNE: create remote dir, drop update rep from MDT1, fail MDT1"
+run_test 80a "DNE: create remote dir, drop update rep from MDT0, fail MDT0"
 
 test_80b() {
        [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
@@ -2071,11 +2066,11 @@ test_80b() {
 
        mkdir -p $DIR/$tdir
        #define OBD_FAIL_UPDATE_OBJ_NET_REP     0x1701
-       do_facet mds$((MDTIDX + 1)) lctl set_param fail_loc=0x1701
+       do_facet mds${MDTIDX} lctl set_param fail_loc=0x1701
        $LFS mkdir -i $MDTIDX $remote_dir &
        local CLIENT_PID=$!
 
-       fail mds${MDTIDX}
+       fail mds$((MDTIDX + 1))
 
        wait $CLIENT_PID || error "remote creation failed"
 
@@ -2084,7 +2079,7 @@ test_80b() {
 
        return 0
 }
-run_test 80b "DNE: create remote dir, drop update rep from MDT1, fail MDT0"
+run_test 80b "DNE: create remote dir, drop update rep from MDT0, fail MDT1"
 
 test_80c() {
        [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
@@ -2098,7 +2093,7 @@ test_80c() {
 
        mkdir -p $DIR/$tdir
        #define OBD_FAIL_UPDATE_OBJ_NET_REP     0x1701
-       do_facet mds$((MDTIDX + 1)) lctl set_param fail_loc=0x1701
+       do_facet mds${MDTIDX} lctl set_param fail_loc=0x1701
        $LFS mkdir -i $MDTIDX $remote_dir &
        local CLIENT_PID=$!
 
@@ -2121,10 +2116,13 @@ test_80d() {
 
        mkdir -p $DIR/$tdir
        #define OBD_FAIL_UPDATE_OBJ_NET_REP     0x1701
-       do_facet mds$((MDTIDX + 1)) lctl set_param fail_loc=0x1701
+       do_facet mds${MDTIDX} lctl set_param fail_loc=0x1701
        $LFS mkdir -i $MDTIDX $remote_dir &
        local CLIENT_PID=$!
 
+       # sleep 3 seconds to make sure MDTs are failed after
+       # lfs mkdir -i has finished on all of MDTs.
+       sleep 3
        fail mds${MDTIDX},mds$((MDTIDX + 1))
 
        wait $CLIENT_PID || error "remote creation failed"
@@ -2148,10 +2146,14 @@ test_80e() {
 
        mkdir -p $DIR/$tdir
        # OBD_FAIL_MDS_REINT_NET_REP       0x119
-       do_facet mds${MDTIDX} lctl set_param fail_loc=0x119
+       do_facet mds$((MDTIDX + 1)) lctl set_param fail_loc=0x119
        $LFS mkdir -i $MDTIDX $remote_dir &
        local CLIENT_PID=$!
 
+       # sleep 3 seconds to make sure MDTs are failed after
+       # lfs mkdir -i has finished on all of MDTs.
+       sleep 3
+
        fail mds${MDTIDX}
 
        wait $CLIENT_PID || error "remote creation failed"
@@ -2161,7 +2163,7 @@ test_80e() {
 
        return 0
 }
-run_test 80e "DNE: create remote dir, drop MDT0 rep, fail MDT0"
+run_test 80e "DNE: create remote dir, drop MDT1 rep, fail MDT0"
 
 test_80f() {
        [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
@@ -2174,7 +2176,7 @@ test_80f() {
 
        mkdir -p $DIR/$tdir
        # OBD_FAIL_MDS_REINT_NET_REP       0x119
-       do_facet mds${MDTIDX} lctl set_param fail_loc=0x119
+       do_facet mds$((MDTIDX + 1)) lctl set_param fail_loc=0x119
        $LFS mkdir -i $MDTIDX $remote_dir &
        local CLIENT_PID=$!
 
@@ -2187,7 +2189,7 @@ test_80f() {
 
        return 0
 }
-run_test 80f "DNE: create remote dir, drop MDT0 rep, fail MDT1"
+run_test 80f "DNE: create remote dir, drop MDT1 rep, fail MDT1"
 
 test_80g() {
        [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
@@ -2201,10 +2203,14 @@ test_80g() {
 
        mkdir -p $DIR/$tdir
        # OBD_FAIL_MDS_REINT_NET_REP       0x119
-       do_facet mds${MDTIDX} lctl set_param fail_loc=0x119
+       do_facet mds$((MDTIDX + 1)) lctl set_param fail_loc=0x119
        $LFS mkdir -i $MDTIDX $remote_dir &
        local CLIENT_PID=$!
 
+       # sleep 3 seconds to make sure MDTs are failed after
+       # lfs mkdir -i has finished on all of MDTs.
+       sleep 3
+
        fail mds${MDTIDX}
        fail mds$((MDTIDX + 1))
 
@@ -2215,7 +2221,7 @@ test_80g() {
 
        return 0
 }
-run_test 80g "DNE: create remote dir, drop MDT0 rep, fail MDT0, then MDT1"
+run_test 80g "DNE: create remote dir, drop MDT1 rep, fail MDT0, then MDT1"
 
 test_80h() {
        [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
@@ -2224,10 +2230,14 @@ test_80h() {
 
        mkdir -p $DIR/$tdir
        # OBD_FAIL_MDS_REINT_NET_REP       0x119
-       do_facet mds${MDTIDX} lctl set_param fail_loc=0x119
+       do_facet mds$((MDTIDX + 1)) lctl set_param fail_loc=0x119
        $LFS mkdir -i $MDTIDX $remote_dir &
        local CLIENT_PID=$!
 
+       # sleep 3 seconds to make sure MDTs are failed after
+       # lfs mkdir -i has finished on all of MDTs.
+       sleep 3
+
        fail mds${MDTIDX},mds$((MDTIDX + 1))
 
        wait $CLIENT_PID || return 1
@@ -2237,7 +2247,7 @@ test_80h() {
 
        return 0
 }
-run_test 80h "DNE: create remote dir, drop MDT0 rep, fail 2 MDTs"
+run_test 80h "DNE: create remote dir, drop MDT1 rep, fail 2 MDTs"
 
 test_81a() {
        [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
@@ -2472,26 +2482,6 @@ test_81h() {
 }
 run_test 81h "DNE: unlink remote dir, drop request reply, fail 2 MDTs"
 
-test_83a() {
-    mkdir -p $DIR/$tdir
-    createmany -o $DIR/$tdir/$tfile- 10 || return 1
-#define OBD_FAIL_MDS_FAIL_LOV_LOG_ADD       0x140
-    do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000140"
-    unlinkmany $DIR/$tdir/$tfile- 10 || return 2
-}
-run_test 83a "fail log_add during unlink recovery"
-
-test_83b() {
-    mkdir -p $DIR/$tdir
-    createmany -o $DIR/$tdir/$tfile- 10 || return 1
-    replay_barrier $SINGLEMDS
-    unlinkmany $DIR/$tdir/$tfile- 10 || return 2
-#define OBD_FAIL_MDS_FAIL_LOV_LOG_ADD       0x140
-    do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000140"
-    fail $SINGLEMDS
-}
-run_test 83b "fail log_add during unlink recovery"
-
 test_84a() {
 #define OBD_FAIL_MDS_OPEN_WAIT_CREATE  0x144
     do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000144"
@@ -2669,7 +2659,7 @@ test_88() { #bug 17485
         dd if=/dev/urandom of=$DIR/$tdir/f-$file_id bs=4096 count=128
     done
 
-    # if the objids were not recreated, then "ls" will failed for -ENOENT
+    # if the objids were not recreated, then "ls" will fail with -ENOENT
     ls -l $DIR/$tdir/* || error "can't get the status of precreated files"
 
     local file_id
@@ -2806,6 +2796,121 @@ test_90() { # bug 19494
 }
 run_test 90 "lfs find identifies the missing striped file segments"
 
+test_93() {
+    local server_version=$(lustre_version_code $SINGLEMDS)
+       [[ $server_version -ge $(version_code 2.6.90) ]] ||
+       [[ $server_version -ge $(version_code 2.5.4) &&
+          $server_version -lt $(version_code 2.5.50) ]] ||
+               { skip "Need MDS version 2.5.4+ or 2.6.90+"; return; }
+
+    cancel_lru_locks osc
+
+    $SETSTRIPE -i 0 -c 1 $DIR/$tfile
+    dd if=/dev/zero of=$DIR/$tfile bs=1024 count=1
+#define OBD_FAIL_TGT_REPLAY_RECONNECT     0x715
+    # We need to emulate a state that OST is waiting for other clients
+    # not completing the recovery. Final ping is queued, but reply will be sent
+    # on the recovery completion. It is done by sleep before processing final
+    # pings
+    do_facet ost1 "$LCTL set_param fail_val=40"
+    do_facet ost1 "$LCTL set_param fail_loc=0x715"
+    fail ost1
+}
+run_test 93 "replay + reconnect"
+
+striped_dir_check_100() {
+       local striped_dir=$DIR/$tdir/striped_dir
+       local stripe_count=$($LFS getdirstripe -c $striped_dir)
+
+       $LFS getdirstripe $striped_dir
+       [ $stripe_count -eq 2 ] || error "$stripe_count != 2"
+
+       createmany -o $striped_dir/f-%d 20 ||
+               error "creation failed under striped dir"
+}
+
+test_100a() {
+       [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
+       ([ $FAILURE_MODE == "HARD" ] &&
+               [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
+               skip "MDTs needs to be on diff hosts for HARD fail mode" &&
+               return 0
+
+       local striped_dir=$DIR/$tdir/striped_dir
+       local MDTIDX=1
+
+       mkdir $DIR/$tdir
+
+       #To make sure MDT1 and MDT0 are connected
+       #otherwise it may create single stripe dir here
+       $LFS setdirstripe -i1 $DIR/$tdir/remote_dir
+
+       #define OBD_FAIL_OUT_UPDATE_NET_REP     0x1701
+       do_facet mds$((MDTIDX+1)) lctl set_param fail_loc=0x1701
+       $LFS setdirstripe -i0 -c2 $striped_dir &
+       local CLIENT_PID=$!
+
+       fail mds$((MDTIDX + 1))
+
+       wait $CLIENT_PID || error "striped dir creation failed"
+
+       striped_dir_check_100 || error "striped dir check failed"
+       rm -rf $DIR/$tdir || error "rmdir failed"
+}
+run_test 100a "DNE: create striped dir, drop update rep from MDT1, fail MDT1"
+
+test_100b() {
+       [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
+       ([ $FAILURE_MODE == "HARD" ] &&
+               [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
+               skip "MDTs needs to be on diff hosts for HARD fail mode" &&
+               return 0
+
+       local striped_dir=$DIR/$tdir/striped_dir
+       local MDTIDX=1
+
+       mkdir $DIR/$tdir
+
+       #To make sure MDT1 and MDT0 are connected
+       #otherwise it may create single stripe dir here
+       $LFS setdirstripe -i1 $DIR/$tdir/remote_dir
+
+       # OBD_FAIL_MDS_REINT_NET_REP       0x119
+       do_facet mds$MDTIDX lctl set_param fail_loc=0x119
+       $LFS mkdir -i0 -c2 $striped_dir &
+
+       local CLIENT_PID=$!
+       fail mds$MDTIDX
+
+       wait $CLIENT_PID || error "striped dir creation failed"
+
+       striped_dir_check_100 || error "striped dir check failed"
+       rm -rf $DIR/$tdir || error "rmdir failed"
+}
+run_test 100b "DNE: create striped dir, fail MDT0"
+
+test_101() { #LU-5648
+       mkdir -p $DIR/$tdir/d1
+       mkdir -p $DIR/$tdir/d2
+       touch $DIR/$tdir/file0
+       num=1000
+
+       replay_barrier $SINGLEMDS
+       for i in $(seq $num) ; do
+               echo test$i > $DIR/$tdir/d1/file$i
+       done
+
+       fail_abort $SINGLEMDS
+       for i in $(seq $num) ; do
+               touch $DIR/$tdir/d2/file$i
+               test -s $DIR/$tdir/d2/file$i &&
+                       ls -al $DIR/$tdir/d2/file$i && error "file$i's size > 0"
+       done
+
+       rm -rf $DIR/$tdir
+}
+run_test 101 "Shouldn't reassign precreated objs to other files after recovery"
+
 complete $SECONDS
 check_and_cleanup_lustre
 exit_status