Whamcloud - gitweb
LU-6455 tests: Re-enable replay-vbr and replay-single tests
[fs/lustre-release.git] / lustre / tests / replay-vbr.sh
old mode 100644 (file)
new mode 100755 (executable)
index a5a71ec..7da4f8a
@@ -1,4 +1,6 @@
 #!/bin/bash
+# -*- mode: Bash; tab-width: 4; indent-tabs-mode: t; -*-
+# vim:shiftwidth=4:softtabstop=4:tabstop=4:
 
 set -e
 
@@ -10,6 +12,7 @@ LUSTRE=${LUSTRE:-$(cd $(dirname $0)/..; echo $PWD)}
 SETUP=${SETUP:-}
 CLEANUP=${CLEANUP:-}
 MOUNT_2=${MOUNT_2:-"yes"}
+export MULTIOP=${MULTIOP:-multiop}
 . $LUSTRE/tests/test-framework.sh
 init_test_env $@
 . ${CONFIG:=$LUSTRE/tests/cfg/$NAME.sh}
@@ -17,6 +20,7 @@ init_logging
 
 remote_mds_nodsh && log "SKIP: remote MDS with nodsh" && exit 0
 
+#                                  ~6  (min)"
 [ "$SLOW" = "no" ] && EXCEPT_SLOW="7"
 
 build_test_filter
@@ -55,7 +59,7 @@ rmultiop_start() {
     # /tmp/multiop_bg.pid file
 
     local pid_file=$TMP/multiop_bg.pid.$$
-    do_node $client "MULTIOP_PID_FILE=$pid_file LUSTRE= sh runmultiop_bg_pause $file $cmds" &
+    do_node $client "MULTIOP_PID_FILE=$pid_file LUSTRE= runmultiop_bg_pause $file $cmds" &
     local pid=$!
     sleep 3
     local multiop_pid
@@ -86,12 +90,30 @@ get_version() {
     local fid
 
     fid=$(do_node $client $LFS path2fid $file)
-    do_facet $SINGLEMDS $LCTL --device ${!var} getobjversion $fid
+    do_facet $SINGLEMDS $LCTL --device ${!var} getobjversion \\\"$fid\\\"
 }
 
 #save COS setting
 cos_param_file=$TMP/rvbr-cos-params
-save_lustre_params $(comma_list $(mdts_nodes)) "mdt.*.commit_on_sharing" > $cos_param_file
+save_lustre_params $(get_facets MDS) "mdt.*.commit_on_sharing" > $cos_param_file
+
+test_0a() {
+        get_version $CLIENT1 $DIR/$tdir/1a || true
+}
+run_test 0a "getversion for non existent file shouldn't cause kernel panic"
+
+test_0b() {
+        local var=${SINGLEMDS}_svc
+        local fid
+        local file=$DIR/$tdir/f
+
+        do_node $CLIENT1 mkdir -p $DIR/$tdir/
+        do_node $CLIENT1 touch $file
+        fid=$(do_node $CLIENT1 $LFS path2fid $file)
+        do_node $CLIENT1 rm -rf $file
+        do_facet $SINGLEMDS $LCTL --device ${!var} getobjversion \\\"$fid\\\" || true
+}
+run_test 0b "getversion for non existent fid shouldn't cause kernel panic"
 
 # test set #1: OPEN
 test_1a() { # former test_0a
@@ -125,7 +147,7 @@ test_1b() { # former test_0b
 
     client_evicted $CLIENT1 || error "$CLIENT1 not evicted"
     if ! do_node $CLIENT1 $CHECKSTAT -a $DIR/$tdir/$tfile; then
-        error "open succeeded unexpectedly"
+               error_and_remount "open succeeded unexpectedly"
     fi
 }
 run_test 1b "open (O_CREAT) checks version of parent"
@@ -190,7 +212,18 @@ test_2a() {  # extended former test_0d
     if (($pre != $post)); then
         error "version was changed: pre $pre, post $post"
     fi
-    do_node $CLIENT1 rm $DIR/$tfile-*
+       # remote directory
+       if [ $MDSCOUNT -ge 2 ]; then
+               #create remote dir
+               local MDT_IDX=1
+               pre=$(get_version $CLIENT1 $DIR)
+               do_node $CLIENT1 $LFS mkdir -i $MDT_IDX $DIR/$tfile-remote_dir
+               post=$(get_version $CLIENT1 $DIR)
+               if (($pre != $post)); then
+                       error "version was changed: pre $pre, post $post"
+               fi
+       fi
+       do_node $CLIENT1 rm -rf $DIR/$tfile-*
 
 }
 run_test 2a "create operations doesn't change version of parent"
@@ -212,7 +245,7 @@ test_2b() { # former test_0e
 
     client_evicted $CLIENT1 || error "$CLIENT1 not evicted"
     if ! do_node $CLIENT1 $CHECKSTAT -a $DIR/$tdir/$tfile; then
-        error "create succeeded unexpectedly"
+               error_and_remount "create succeeded unexpectedly"
     fi
 }
 run_test 2b "create checks version of parent"
@@ -228,6 +261,18 @@ test_3a() { # former test_0f
     if (($pre != $post)); then
         error "version was changed: pre $pre, post $post"
     fi
+
+       if [ $MDSCOUNT -ge 2 ]; then
+               #create remote dir
+               local MDT_IDX=1
+               do_node $CLIENT1 $LFS mkdir -i $MDT_IDX $DIR/$tfile-remote_dir
+               pre=$(get_version $CLIENT1 $DIR)
+               do_node $CLIENT1 rmdir $DIR/$tfile-remote_dir
+               post=$(get_version $CLIENT1 $DIR)
+               if (($pre != $post)); then
+                       error "version was changed: pre $pre, post $post"
+               fi
+       fi
 }
 run_test 3a "unlink doesn't change version of parent"
 
@@ -249,7 +294,7 @@ test_3b() { # former test_0g
 
     client_evicted $CLIENT1 || error "$CLIENT1 not evicted"
     if do_node $CLIENT1 $CHECKSTAT -a $DIR/$tdir/$tfile; then
-        error "unlink succeeded unexpectedly"
+               error_and_remount "unlink succeeded unexpectedly"
     fi
 }
 run_test 3b "unlink checks version of parent"
@@ -302,7 +347,7 @@ test_4c() { # former test_0j
 
     client_evicted $CLIENT1 || error "$CLIENT1 not evicted"
     if ! do_node $CLIENT1 $CHECKSTAT -u \\\#$UID $file; then
-        error "setattr of UID succeeded unexpectedly"
+               error_and_remount "setattr of UID succeeded unexpectedly"
     fi
 }
 run_test 4c "setattr of UID checks versions"
@@ -325,7 +370,7 @@ test_4d() { # former test_0k
 
     client_evicted $CLIENT1 || error "$CLIENT1 not evicted"
     if ! do_node $CLIENT1 $CHECKSTAT -g \\\#$UID $file; then
-        error "setattr of GID succeeded unexpectedly"
+               error_and_remount "setattr of GID succeeded unexpectedly"
     fi
 }
 run_test 4d "setattr of GID checks versions"
@@ -363,7 +408,7 @@ test_4f() { # former test_0m
 
     client_evicted $CLIENT1 || error "$CLIENT1 not evicted"
     if ! do_node $CLIENT1 $CHECKSTAT -p 0644 $file; then
-        error "setattr of permission succeeded unexpectedly"
+               error_and_remount "setattr of permission succeeded unexpectedly"
     fi
 }
 run_test 4f "setattr of permission checks versions"
@@ -492,7 +537,7 @@ test_4k() { # former test_0r
         error "time not changed: pre $mtime_pre, post $mtime_post"
     fi
     if ! do_node $CLIENT1 $CHECKSTAT -s 1 $file; then
-        error "setattr of size failed"
+               error_and_remount "setattr of size failed"
     fi
     mtime=$(do_node $CLIENT1 stat --format=%Y $file)
     if (($mtime != $mtime_post)); then
@@ -541,7 +586,7 @@ test_5b() { # former test_0t
 
     client_evicted $CLIENT1 || error "$CLIENT1 not evicted"
     if ! do_node $CLIENT1 $CHECKSTAT -a $DIR/$tdir/$tfile; then
-        error "link should fail"
+               error_and_remount "link should fail"
     fi
 }
 run_test 5b "link checks version of target parent"
@@ -564,7 +609,7 @@ test_5c() { # former test_0u
 
     client_evicted $CLIENT1 || error "$CLIENT1 not evicted"
     if ! do_node $CLIENT1 $CHECKSTAT -a $DIR/$tdir/$tfile; then
-        error "link should fail"
+               error_and_remount "link should fail"
     fi
 }
 run_test 5c "link checks version of source"
@@ -623,7 +668,7 @@ test_6c() { # former test_0x
 
     client_evicted $CLIENT1 || error "$CLIENT1 not evicted"
     if do_node $CLIENT1 $CHECKSTAT -a $DIR/$tfile; then
-        error "rename should fail"
+               error_and_remount "rename should fail"
     fi
 }
 run_test 6c "rename checks version of source parent"
@@ -646,7 +691,7 @@ test_6d() { # former test_0y
 
     client_evicted $CLIENT1 || error "$CLIENT1 not evicted"
     if do_node $CLIENT1 $CHECKSTAT -a $DIR/$tfile; then
-        error "rename should fail"
+               error_and_remount "rename should fail"
     fi
 }
 run_test 6d "rename checks version of target parent"
@@ -683,11 +728,11 @@ test_7_cycle() {
     # should fail as conflict expected
     client_evicted $CLIENT1 || rc=1
 
-    wait_recovery_complete $SINGLEMDS
-    wait_mds_ost_sync $SINGLEMDS
+       wait_recovery_complete $SINGLEMDS
+       wait_mds_ost_sync || error "wait_mds_ost_sync failed"
 
-    rm -rf $DIR/$tdir
-    return $rc
+       rm -rf $DIR/$tdir
+       return $rc
 }
 
 test_7a() {
@@ -843,7 +888,14 @@ test_7g() {
     first="createmany -o $DIR/$tdir/$tfile- 1; mv $DIR/$tdir/$tfile-0 $DIR/$tdir/$tfile"
     lost="createmany -o $MOUNT2/$tdir/$tfile- 1"
     last="link $DIR/$tdir/$tfile-0 $DIR/$tdir/$tfile-1"
-    test_7_cycle "$first" "$lost" "$last" || error "Test 7g.3 failed"
+       if [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.5.1) ]
+       then
+               test_7_cycle "$first" "$lost" "$last" ||
+                       error "Test 7g.3 failed"
+       else #LU-4442 LU-3528
+               test_7_cycle "$first" "$lost" "$last" &&
+                       error "Test 7g.3 failed"
+       fi
     return 0
 }
 run_test 7g "rename, {lost}, create"
@@ -1126,12 +1178,54 @@ test_12a() { # former test_2a
 }
 run_test 12a "lost data due to missed REMOTE client during replay"
 
+test_13() { # LU-8826
+       local var=${SINGLEMDS}_svc
+
+       if combined_mgs_mds ; then
+               skip "Needs separate MGS to enable IR"
+               return 0
+       fi
+
+       do_facet $SINGLEMDS "$LCTL set_param mdd.${!var}.sync_permission=0"
+       do_facet $SINGLEMDS "$LCTL set_param mdt.${!var}.commit_on_sharing=0"
+
+       zconf_mount $CLIENT2 $MOUNT2
+       do_node $CLIENT1 openfile -f O_RDWR:O_CREAT -m 0644 $DIR/$tfile
+
+       # set ir_timeout to a reasonable small value
+       local ir_timeout=$(do_facet mgs $LCTL get_param -n mgs.*.ir_timeout)
+       do_facet mgs $LCTL set_param mgs.*.ir_timeout=5
+       # make sure IR functional
+       sleep 5
+
+       replay_barrier $SINGLEMDS
+       do_node $CLIENT1 chmod 666 $DIR/$tfile
+       do_node $CLIENT2 chmod 777 $DIR2/$tfile
+
+       # make sure client data of $CLIENT2:$MOUNT2 is remained
+       # define OBD_FAIL_TGT_CLIENT_DEL        0x718
+       do_facet $SINGLEMDS $LCTL set_param fail_loc=0x718
+       zconf_umount $CLIENT2 $MOUNT2
+       # define OBD_FAIL_TGT_SLUGGISH_NET      0x719
+       do_facet $SINGLEMDS $LCTL set_param fail_loc=0x719
+       facet_failover $SINGLEMDS
+
+       client_up $CLIENT1 || error "$CLIENT1 evicted"
+
+       do_facet $SINGLEMDS $LCTL set_param fail_loc=0
+       do_facet mgs $LCTL set_param mgs.*.ir_timeout=$ir_timeout
+
+       do_node $CLIENT1 $CHECKSTAT -p 0666 $DIR/$tfile ||
+               error "$DIR/$tfile-a: unexpected state"
+}
+run_test 13 "Shouldn't give up VBR easily on sluggish network"
+
 #restore COS setting
 restore_lustre_params < $cos_param_file
 rm -f $cos_param_file
 
 [ "$CLIENTS" ] && zconf_mount_clients $CLIENTS $DIR
 
-complete $(basename $0) $SECONDS
+complete $SECONDS
 check_and_cleanup_lustre
 exit_status