Whamcloud - gitweb
LU-1999 tests: check LW client eviction in logs
[fs/lustre-release.git] / lustre / tests / recovery-small.sh
index b4cf00a..45cf76e 100755 (executable)
@@ -3,7 +3,7 @@
 set -e
 
 #         bug  5494 5493
-ALWAYS_EXCEPT="24   52 $RECOVERY_SMALL_EXCEPT"
+ALWAYS_EXCEPT="24   52    $RECOVERY_SMALL_EXCEPT"
 
 export MULTIOP=${MULTIOP:-multiop}
 PTLDEBUG=${PTLDEBUG:--1}
@@ -1059,7 +1059,10 @@ test_58() { # bug 11546
         lctl set_param fail_loc=0
         drop_bl_callback rm -f $DIR/$tfile
         wait $pid
-        do_facet client "df $DIR"
+        # the first 'df' could tigger the eviction caused by
+        # 'drop_bl_callback', and it's normal case.
+        # but the next 'df' should return successfully.
+        do_facet client "df $DIR" || do_facet client "df $DIR"
 }
 run_test 58 "Eviction in the middle of open RPC reply processing"
 
@@ -1175,8 +1178,8 @@ check_cli_ir_state()
         local st
         st=$(do_node $NODE "lctl get_param mgc.*.ir_state |
                             awk '/imperative_recovery:/ { print \\\$2}'")
-        [ $st != ON -o $st != OFF ] ||
-                error "Error state $st, must be ON or OFF"
+       [ $st != ON -o $st != OFF -o $st != ENABLED -o $st != DISABLED ] ||
+               error "Error state $st, must be ENABLED or DISABLED"
         echo -n $st
 }
 
@@ -1189,8 +1192,8 @@ check_target_ir_state()
 
         st=$(do_facet $target "lctl get_param -n $recovery_proc |
                                awk '/IR:/{ print \\\$2}'")
-        [ $st != ON -o $st != OFF ] ||
-                error "Error state $st, must be ON or OFF"
+       [ $st != ON -o $st != OFF -o $st != ENABLED -o $st != DISABLED ] ||
+               error "Error state $st, must be ENABLED or DISABLED"
         echo -n $st
 }
 
@@ -1276,19 +1279,30 @@ target_instance_match()
 
 test_100()
 {
-        do_facet mgs $LCTL list_param mgs.*.ir_timeout ||
-                { skip "MGS without IR support"; return 0; }
+       do_facet mgs $LCTL list_param mgs.*.ir_timeout ||
+               { skip "MGS without IR support"; return 0; }
+
+       # MDT was just restarted in the previous test, make sure everything
+       # is all set.
+       local cnt=30
+       while [ $cnt -gt 0 ]; do
+               nidtbl_versions_match && break
+               sleep 1
+               cnt=$((cnt - 1))
+       done
+
+       # disable IR
+       set_ir_status disabled
 
-        # disable IR
-        set_ir_status disabled
+       local prev_ver=$(nidtbl_version_client client)
 
         local saved_FAILURE_MODE=$FAILURE_MODE
         [ $(facet_host mgs) = $(facet_host ost1) ] && FAILURE_MODE="SOFT"
         fail ost1
 
         # valid check
-        nidtbl_versions_match &&
-                error "version must differ due to IR disabled"
+       [ $(nidtbl_version_client client) -eq $prev_ver ] ||
+               error "version must not change due to IR disabled"
         target_instance_match ost1 || error "instance mismatch"
 
         # restore env
@@ -1421,7 +1435,8 @@ test_104()
         clients_up
 
         local ir_state=$(check_target_ir_state ost1)
-        [ $ir_state = "OFF" ] || error "ir status on ost1 should be OFF"
+       [ $ir_state = "DISABLED" -o $ir_state = "OFF" ] ||
+               error "ir status on ost1 should be DISABLED"
 }
 run_test 104 "IR: ost can disable IR voluntarily"
 
@@ -1443,7 +1458,8 @@ test_105()
 
         # make sure lustre mount at $rcli disabling IR
         local ir_state=$(check_cli_ir_state $rcli)
-        [ $ir_state = OFF ] || error "IR state must be OFF at $rcli"
+       [ $ir_state = "DISABLED" -o $ir_state = "OFF" ] ||
+               error "IR state must be DISABLED at $rcli"
 
        # Since the client just mounted, its last_rcvd entry is not on disk.
        # Send an RPC so exp_need_sync forces last_rcvd to commit this export
@@ -1455,9 +1471,10 @@ test_105()
         [ $(get_ir_status) = "partial" ] || error "MGS IR state must be partial"
 
         fail ost1
-        # make sure IR on ost1 is OFF
+       # make sure IR on ost1 is DISABLED
         local ir_state=$(check_target_ir_state ost1)
-        [ $ir_state = "OFF" ] || error "IR status on ost1 should be OFF"
+       [ $ir_state = "DISABLED" -o $ir_state = "OFF" ] ||
+               error "IR status on ost1 should be DISABLED"
 
         # restore it
         MOUNTOPT=$old_MOUNTOPT
@@ -1468,14 +1485,57 @@ test_105()
         [ $(get_ir_status) = "full" ] || error "MGS IR status must be full"
 
         fail ost1
-        # make sure IR on ost1 is ON
+       # make sure IR on ost1 is ENABLED
         local ir_state=$(check_target_ir_state ost1)
-        [ $ir_state = "ON" ] || error "IR status on ost1 should be OFF"
+       [ $ir_state = "ENABLED" -o $ir_state = "ON" ] ||
+               error "IR status on ost1 should be ENABLED"
 
         return 0
 }
 run_test 105 "IR: NON IR clients support"
 
+cleanup_106() {
+       trap 0
+       umount_client $DIR2
+}
+
+test_106() { # LU-1789
+#define OBD_FAIL_MDC_LIGHTWEIGHT         0x805
+       $LCTL set_param fail_loc=0x805
+
+       trap cleanup_106 EXIT
+
+       # enable lightweight flag on mdc connection
+       mount_client $DIR2
+
+       local MDS_NEXP=$(do_facet $SINGLEMDS \
+                        lctl get_param -n mdt.${mds1_svc}.num_exports |
+                        cut -d' ' -f2)
+       $LCTL set_param fail_loc=0
+
+       touch $DIR2/$tfile || error "failed to create empty file"
+       replay_barrier $SINGLEMDS
+       facet_failover $SINGLEMDS
+
+       # lightweight connection must be evicted
+       touch -c $DIR2/$tfile || true
+       evicted=`dmesg | awk '/test 106/ {start = 1;}
+                             /This client was evicted by .*MDT0000/ {
+                                     if (start) {
+                                             print;
+                                     }
+                             }'`
+       [ -z "$evicted" ] && error "lightweight client not evicted by mds"
+
+       # and all operations performed by lightweight client should be
+       # synchronous, so the file created before mds restart should be there
+       $CHECKSTAT -t file $DIR/$tfile || error "file not present"
+       rm -f $DIR/$tfile
+
+       cleanup_106
+}
+run_test 106 "lightweight connection support"
+
 complete $(basename $0) $SECONDS
 check_and_cleanup_lustre
 exit_status