+. $LUSTRE/tests/test-framework.sh
+init_test_env $@
+. ${CONFIG:=$LUSTRE/tests/cfg/$NAME.sh}
+init_logging
+
+require_dsh_mds || exit 0
+
+# also long tests: 19, 21a, 21e, 21f, 23, 27
+# 1 2.5 2.5 4 4 (min)"
+[ "$SLOW" = "no" ] && EXCEPT_SLOW="17 26a 26b 50 51 57"
+
+[ $(facet_fstype $SINGLEMDS) = "zfs" ] &&
+# bug number for skipped test: LU-2547
+ ALWAYS_EXCEPT="$ALWAYS_EXCEPT 24a 24b"
+
+build_test_filter
+
+# Allow us to override the setup if we already have a mounted system by
+# setting SETUP=" " and CLEANUP=" "
+SETUP=${SETUP:-""}
+CLEANUP=${CLEANUP:-""}
+
+check_and_setup_lustre
+
+assert_DIR
+rm -rf $DIR/d[0-9]* $DIR/f.${TESTSUITE}*
+
+test_1() {
+ local f1="$DIR/$tfile"
+ local f2="$DIR/$tfile.2"
+
+ drop_request "mcreate $f1" ||
+ error_noexit "create '$f1': drop req"
+
+ drop_reint_reply "mcreate $f2" ||
+ error_noexit "create '$f2': drop rep"
+
+ drop_request "tchmod 111 $f2" ||
+ error_noexit "chmod '$f2': drop req"
+
+ drop_reint_reply "tchmod 666 $f2" ||
+ error_noexit "chmod '$f2': drop rep"
+
+ drop_request "statone $f2" ||
+ error_noexit "stat '$f2': drop req"
+
+ drop_reply "statone $f2" ||
+ error_noexit "stat '$f2': drop rep"
+}
+run_test 1 "create, chmod, stat: drop req, drop rep"
+
+test_4() {
+ local t=$DIR/$tfile
+ do_facet_create_file client $t 10K ||
+ error_noexit "Create file $t"
+
+ drop_request "cat $t > /dev/null" ||
+ error_noexit "Open request for $t file"
+
+ drop_reply "cat $t > /dev/null" ||
+ error_noexit "Open replay for $t file"
+}
+run_test 4 "open: drop req, drop rep"
+
+test_5() {
+ local T=$DIR/$tfile
+ local R="$T-renamed"
+ local RR="$T-renamed-again"
+ do_facet_create_file client $T 10K ||
+ error_noexit "Create file $T"
+
+ drop_request "mv $T $R" ||
+ error_noexit "Rename $T"
+
+ drop_reint_reply "mv $R $RR" ||
+ error_noexit "Failed rename replay on $R"
+
+ do_facet client "checkstat -v $RR" ||
+ error_noexit "checkstat error on $RR"
+
+ do_facet client "rm $RR" ||
+ error_noexit "Can't remove file $RR"
+}
+run_test 5 "rename: drop req, drop rep"
+
+test_6() {
+ local T=$DIR/$tfile
+ local LINK1=$DIR/$tfile.link1
+ local LINK2=$DIR/$tfile.link2
+
+ do_facet_create_file client $T 10K ||
+ error_noexit "Create file $T"
+
+ drop_request "mlink $T $LINK1" ||
+ error_noexit "mlink request for $T"
+
+ drop_reint_reply "mlink $T $LINK2" ||
+ error_noexit "mlink reply for $T"
+
+ drop_request "munlink $LINK1" ||
+ error_noexit "munlink request for $T"
+
+ drop_reint_reply "munlink $LINK2" ||
+ error_noexit "munlink reply for $T"
+
+ do_facet client "rm $T" ||
+ error_noexit "Can't remove file $T"
+}
+run_test 6 "link, unlink: drop req, drop rep"
+
+#bug 1423
+test_8() {
+ drop_reint_reply "touch $DIR/$tfile" || return 1
+}
+run_test 8 "touch: drop rep (bug 1423)"
+
+#bug 1420
+test_9() {
+ remote_ost_nodsh && skip "remote OST with nodsh" && return 0
+
+ local t1=${tfile}.1
+ local t2=${tfile}.2
+ do_facet_random_file client $TMP/$tfile 1K ||
+ error_noexit "Create random file $TMP/$tfile"
+ # make this big, else test 9 doesn't wait for bulk -- bz 5595
+ do_facet_create_file client $TMP/$t1 4M ||
+ error_noexit "Create file $TMP/$t1"
+ do_facet client "cp $TMP/$t1 $DIR/$t1" ||
+ error_noexit "Can't copy to $DIR/$t1 file"
+ pause_bulk "cp $TMP/$tfile $DIR/$tfile" ||
+ error_noexit "Can't pause_bulk copy"
+ do_facet client "cp $TMP/$t1 $DIR/$t2" ||
+ error_noexit "Can't copy file"
+ do_facet client "sync"
+ do_facet client "rm $DIR/$tfile $DIR/$t2 $DIR/$t1" ||
+ error_noexit "Can't remove files"
+ do_facet client "rm $TMP/$t1 $TMP/$tfile"
+}
+run_test 9 "pause bulk on OST (bug 1420)"
+
+#bug 1521
+test_10a() {
+ local before=$(date +%s)
+ local evict
+
+ do_facet client "stat $DIR > /dev/null" ||
+ error "failed to stat $DIR: $?"
+ drop_bl_callback "chmod 0777 $DIR" ||
+ error "failed to chmod $DIR: $?"
+
+ # let the client reconnect
+ client_reconnect
+ evict=$(do_facet client $LCTL get_param mdc.$FSNAME-MDT*.state |
+ awk -F"[ [,]" '/EVICTED ]$/ { if (mx<$5) {mx=$5;} } END { print mx }')
+ [ ! -z "$evict" ] && [[ $evict -gt $before ]] ||
+ (do_facet client $LCTL get_param mdc.$FSNAME-MDT*.state;
+ error "no eviction: $evict before:$before")
+
+ do_facet client checkstat -v -p 0777 $DIR ||
+ error "client checkstat failed: $?"
+}
+run_test 10a "finish request on server after client eviction (bug 1521)"
+
+test_10b() {
+ local before=$(date +%s)
+ local evict
+
+ [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.6.53) ]] &&
+ skip "Need MDS version at least 2.6.53" && return
+ do_facet client "stat $DIR > /dev/null" ||
+ error "failed to stat $DIR: $?"
+ drop_bl_callback_once "chmod 0777 $DIR" ||
+ error "failed to chmod $DIR: $?"
+
+ # let the client reconnect
+ client_reconnect
+ evict=$(do_facet client $LCTL get_param mdc.$FSNAME-MDT*.state |
+ awk -F"[ [,]" '/EVICTED ]$/ { if (mx<$5) {mx=$5;} } END { print mx }')
+
+ [ -z "$evict" ] || [[ $evict -le $before ]] ||
+ (do_facet client $LCTL get_param mdc.$FSNAME-MDT*.state;
+ error "eviction happened: $evict before:$before")
+
+ do_facet client checkstat -v -p 0777 $DIR ||
+ error "client checkstat failed: $?"
+}
+run_test 10b "re-send BL AST"
+
+test_10d() {
+ local before=$(date +%s)
+ local evict
+
+ [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.6.90) ]] &&
+ skip "Need MDS version at least 2.6.90" && return
+
+ # sleep 1 is to make sure that BEFORE is not equal to EVICTED below
+ sleep 1
+ rm -f $TMP/$tfile
+ echo -n ", world" | dd of=$TMP/$tfile bs=1c seek=5
+
+ mount_client $MOUNT2
+
+ cancel_lru_locks osc
+ $LFS setstripe -i 0 -c 1 $DIR1/$tfile
+ echo -n hello > $DIR1/$tfile
+
+ stat $DIR2/$tfile >& /dev/null
+ $LCTL set_param fail_err=71
+ drop_bl_callback "echo -n \\\", world\\\" >> $DIR2/$tfile"
+
+ client_reconnect
+
+ cmp $DIR1/$tfile $DIR2/$tfile || error "file contents differ"
+ cmp $DIR1/$tfile $TMP/$tfile || error "wrong content found"
+
+ evict=$(do_facet client $LCTL get_param osc.$FSNAME-OST0000*.state | \
+ tr -d '\-\[\] ' | \
+ awk -F"[ [,]" '/EVICTED$/ { if (mx<$1) {mx=$1;} } END { print mx }')
+
+ [[ $evict -gt $before ]] ||
+ (do_facet client $LCTL get_param osc.$FSNAME-OST0000*.state;
+ error "no eviction: $evict before:$before")
+
+ rm $TMP/$tfile
+ umount_client $MOUNT2
+}
+run_test 10d "test failed blocking ast"
+
+#bug 2460
+# wake up a thread waiting for completion after eviction
+test_11(){
+ do_facet client $MULTIOP $DIR/$tfile Ow ||
+ { error "multiop write failed: $?"; return 1; }
+ do_facet client $MULTIOP $DIR/$tfile or ||
+ { error "multiop read failed: $?"; return 2; }
+
+ cancel_lru_locks osc
+
+ do_facet client $MULTIOP $DIR/$tfile or ||
+ { error "multiop read failed: $?"; return 3; }
+ drop_bl_callback_once $MULTIOP $DIR/$tfile Ow ||
+ echo "evicted as expected"
+
+ do_facet client munlink $DIR/$tfile ||
+ { error "munlink failed: $?"; return 4; }
+ # allow recovery to complete
+ client_up || client_up || sleep $TIMEOUT
+}
+run_test 11 "wake up a thread waiting for completion after eviction (b=2460)"
+
+#b=2494
+test_12(){
+ $LCTL mark $MULTIOP $DIR/$tfile OS_c
+ do_facet $SINGLEMDS "lctl set_param fail_loc=0x115"
+ clear_failloc $SINGLEMDS $((TIMEOUT * 2)) &
+ multiop_bg_pause $DIR/$tfile OS_c ||
+ { error "multiop failed: $?"; return 1; }
+ PID=$!
+#define OBD_FAIL_MDS_CLOSE_NET 0x115
+ kill -USR1 $PID
+ echo "waiting for multiop $PID"
+ wait $PID || { error "wait for multiop faile: $?"; return 2; }
+ do_facet client munlink $DIR/$tfile ||
+ { error "client munlink failed: $?"; return 3; }
+ # allow recovery to complete
+ client_up || client_up || sleep $TIMEOUT
+}
+run_test 12 "recover from timed out resend in ptlrpcd (b=2494)"
+
+# Bug 113, check that readdir lost recv timeout works.
+test_13() {
+ mkdir -p $DIR/$tdir || { error "mkdir failed: $?"; return 1; }
+ touch $DIR/$tdir/newentry || { error "touch failed: $?"; return 2; }
+# OBD_FAIL_MDS_READPAGE_NET|OBD_FAIL_ONCE
+ do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000104"
+ ls $DIR/$tdir || { error "ls failed: $?"; return 3; }
+ do_facet $SINGLEMDS "lctl set_param fail_loc=0"
+ rm -rf $DIR/$tdir || { error "remove test dir failed: $?"; return 4; }
+}
+run_test 13 "mdc_readpage restart test (bug 1138)"
+
+# Bug 113, check that readdir lost send timeout works.
+test_14() {
+ mkdir -p $DIR/$tdir
+ touch $DIR/$tdir/newentry
+# OBD_FAIL_MDS_SENDPAGE|OBD_FAIL_ONCE
+ do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000106"
+ ls $DIR/$tdir || return 1
+ do_facet $SINGLEMDS "lctl set_param fail_loc=0"
+}
+run_test 14 "mdc_readpage resend test (bug 1138)"
+
+test_15() {
+ do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000128"
+ touch $DIR/$tfile && return 1
+ return 0
+}
+run_test 15 "failed open (-ENOMEM)"
+
+READ_AHEAD=`lctl get_param -n llite.*.max_read_ahead_mb | head -n 1`
+stop_read_ahead() {
+ lctl set_param -n llite.*.max_read_ahead_mb 0
+}
+
+start_read_ahead() {
+ lctl set_param -n llite.*.max_read_ahead_mb $READ_AHEAD
+}
+
+test_16() {
+ remote_ost_nodsh && skip "remote OST with nodsh" && return 0
+
+ do_facet_random_file client $TMP/$tfile 100K ||
+ { error_noexit "Create random file $TMP/$T" ; return 0; }
+ do_facet client "cp $TMP/$tfile $DIR/$tfile" ||
+ { error_noexit "Copy to $DIR/$tfile file" ; return 0; }
+ sync
+ stop_read_ahead
+
+#define OBD_FAIL_PTLRPC_BULK_PUT_NET 0x504 | OBD_FAIL_ONCE
+ do_facet ost1 "lctl set_param fail_loc=0x80000504"
+ cancel_lru_locks osc
+ # OST bulk will time out here, client resends
+ do_facet client "cmp $TMP/$tfile $DIR/$tfile" || return 1
+ do_facet ost1 lctl set_param fail_loc=0
+ # give recovery a chance to finish (shouldn't take long)
+ sleep $TIMEOUT
+ do_facet client "cmp $TMP/$tfile $DIR/$tfile" || return 2
+ start_read_ahead
+ rm -f $TMP/$tfile
+}
+run_test 16 "timeout bulk put, don't evict client (2732)"
+
+test_17() {
+ local at_max_saved=0
+
+ remote_ost_nodsh && skip "remote OST with nodsh" && return 0
+
+ local SAMPLE_FILE=$TMP/$tfile
+ do_facet_random_file client $SAMPLE_FILE 20K ||
+ { error_noexit "Create random file $SAMPLE_FILE" ; return 0; }
+
+ # With adaptive timeouts, bulk_get won't expire until adaptive_timeout_max
+ if at_is_enabled; then
+ at_max_saved=$(at_max_get ost1)
+ at_max_set $TIMEOUT ost1
+ fi
+
+ # OBD_FAIL_PTLRPC_BULK_GET_NET 0x0503 | OBD_FAIL_ONCE
+ # OST bulk will time out here, client retries
+ do_facet ost1 lctl set_param fail_loc=0x80000503
+ # need to ensure we send an RPC
+ do_facet client cp $SAMPLE_FILE $DIR/$tfile
+ sync
+
+ # with AT, client will wait adaptive_max*factor+net_latency before
+ # expiring the req, hopefully timeout*2 is enough
+ sleep $(($TIMEOUT*2))
+
+ do_facet ost1 lctl set_param fail_loc=0
+ do_facet client "df $DIR"
+ # expect cmp to succeed, client resent bulk
+ do_facet client "cmp $SAMPLE_FILE $DIR/$tfile" || return 3
+ do_facet client "rm $DIR/$tfile" || return 4
+ [ $at_max_saved -ne 0 ] && at_max_set $at_max_saved ost1
+ return 0
+}
+run_test 17 "timeout bulk get, don't evict client (2732)"
+
+test_18a() {
+ [ -z ${ost2_svc} ] && skip_env "needs 2 osts" && return 0
+
+ do_facet_create_file client $TMP/$tfile 20K ||
+ { error_noexit "Create file $TMP/$tfile" ; return 0; }
+
+ do_facet client mkdir -p $DIR/$tdir
+ f=$DIR/$tdir/$tfile
+
+ cancel_lru_locks osc
+ pgcache_empty || return 1
+
+ # 1 stripe on ost2
+ $LFS setstripe -i 1 -c 1 $f
+ stripe_index=$($LFS getstripe -i $f)
+ if [ $stripe_index -ne 1 ]; then
+ $LFS getstripe $f
+ error "$f: stripe_index $stripe_index != 1" && return
+ fi
+
+ do_facet client cp $TMP/$tfile $f
+ sync
+ local osc2dev=`lctl get_param -n devices | grep ${ost2_svc}-osc- | egrep -v 'MDT' | awk '{print $1}'`
+ $LCTL --device $osc2dev deactivate || return 3
+ # my understanding is that there should be nothing in the page
+ # cache after the client reconnects?
+ rc=0
+ pgcache_empty || rc=2
+ $LCTL --device $osc2dev activate
+ rm -f $f $TMP/$tfile
+ return $rc
+}
+run_test 18a "manual ost invalidate clears page cache immediately"
+
+test_18b() {
+ remote_ost_nodsh && skip "remote OST with nodsh" && return 0
+
+ do_facet_create_file client $TMP/$tfile 20K ||
+ { error_noexit "Create file $TMP/$tfile" ; return 0; }
+
+ do_facet client mkdir -p $DIR/$tdir
+ f=$DIR/$tdir/$tfile
+
+ cancel_lru_locks osc
+ pgcache_empty || return 1
+
+ $LFS setstripe -i 0 -c 1 $f
+ stripe_index=$($LFS getstripe -i $f)
+ if [ $stripe_index -ne 0 ]; then
+ $LFS getstripe $f
+ error "$f: stripe_index $stripe_index != 0" && return
+ fi
+
+ do_facet client cp $TMP/$tfile $f
+ sync
+ ost_evict_client
+ # allow recovery to complete
+ sleep $((TIMEOUT + 2))
+ # my understanding is that there should be nothing in the page
+ # cache after the client reconnects?
+ rc=0
+ pgcache_empty || rc=2
+ rm -f $f $TMP/$tfile
+ return $rc
+}
+run_test 18b "eviction and reconnect clears page cache (2766)"
+
+test_18c() {
+ remote_ost_nodsh && skip "remote OST with nodsh" && return 0
+
+ do_facet_create_file client $TMP/$tfile 20K ||
+ { error_noexit "Create file $TMP/$tfile" ; return 0; }
+
+ do_facet client mkdir -p $DIR/$tdir
+ f=$DIR/$tdir/$tfile
+
+ cancel_lru_locks osc
+ pgcache_empty || return 1
+
+ $LFS setstripe -i 0 -c 1 $f
+ stripe_index=$($LFS getstripe -i $f)
+ if [ $stripe_index -ne 0 ]; then
+ $LFS getstripe $f
+ error "$f: stripe_index $stripe_index != 0" && return
+ fi
+
+ do_facet client cp $TMP/$tfile $f
+ sync
+ ost_evict_client
+
+ # OBD_FAIL_OST_CONNECT_NET2
+ # lost reply to connect request
+ do_facet ost1 lctl set_param fail_loc=0x80000225
+ # force reconnect
+ sleep 1
+ df $MOUNT > /dev/null 2>&1
+ sleep 2
+ # my understanding is that there should be nothing in the page
+ # cache after the client reconnects?
+ rc=0
+ pgcache_empty || rc=2
+ rm -f $f $TMP/$tfile
+ return $rc
+}
+run_test 18c "Dropped connect reply after eviction handing (14755)"
+
+test_19a() {
+ local BEFORE=`date +%s`
+ local EVICT
+
+ mount_client $DIR2 || error "failed to mount $DIR2"
+
+ # cancel cached locks from OST to avoid eviction from it
+ cancel_lru_locks osc
+
+ do_facet client "stat $DIR > /dev/null" ||
+ error "failed to stat $DIR: $?"
+ drop_ldlm_cancel "chmod 0777 $DIR2" ||
+ error "failed to chmod $DIR2"
+
+ umount_client $DIR2
+
+ # let the client reconnect
+ client_reconnect
+ EVICT=$(do_facet client $LCTL get_param mdc.$FSNAME-MDT*.state |
+ awk -F"[ [,]" '/EVICTED ]$/ \
+ { if (mx<$5) {mx=$5;} } END { print mx }')
+
+ [ ! -z "$EVICT" ] && [[ $EVICT -gt $BEFORE ]] ||
+ (do_facet client $LCTL get_param mdc.$FSNAME-MDT*.state;
+ error "no eviction: $EVICT before:$BEFORE")
+}
+run_test 19a "test expired_lock_main on mds (2867)"
+
+test_19b() {
+ local BEFORE=`date +%s`
+ local EVICT
+
+ mount_client $DIR2 || error "failed to mount $DIR2: $?"
+
+ # cancel cached locks from MDT to avoid eviction from it
+ cancel_lru_locks mdc
+
+ do_facet client $MULTIOP $DIR/$tfile Ow ||
+ error "failed to run multiop: $?"
+ drop_ldlm_cancel $MULTIOP $DIR2/$tfile Ow ||
+ error "failed to ldlm_cancel: $?"
+
+ umount_client $DIR2 || error "failed to unmount $DIR2: $?"
+ do_facet client munlink $DIR/$tfile ||
+ error "failed to unlink $DIR/$tfile: $?"
+
+ # let the client reconnect
+ client_reconnect
+ EVICT=$(do_facet client $LCTL get_param osc.$FSNAME-OST*.state |
+ awk -F"[ [,]" '/EVICTED ]$/ \
+ { if (mx < $5) {mx = $5;} } END { print mx }')
+
+ [ ! -z "$EVICT" ] && [[ $EVICT -gt $BEFORE ]] ||
+ (do_facet client $LCTL get_param osc.$FSNAME-OST*.state;
+ error "no eviction: $EVICT before:$BEFORE")
+}
+run_test 19b "test expired_lock_main on ost (2867)"
+
+test_19c() {
+ local BEFORE=`date +%s`
+
+ mount_client $DIR2
+ $LCTL set_param ldlm.namespaces.*.early_lock_cancel=0
+
+ mkdir -p $DIR1/$tfile
+ stat $DIR1/$tfile
+
+#define OBD_FAIL_PTLRPC_CANCEL_RESEND 0x516
+ do_facet mds $LCTL set_param fail_loc=0x80000516
+
+ touch $DIR2/$tfile/file1 &
+ PID1=$!
+ # let touch to get blocked on the server
+ sleep 2
+
+ wait $PID1
+ $LCTL set_param ldlm.namespaces.*.early_lock_cancel=1
+ umount_client $DIR2
+
+ # let the client reconnect
+ sleep 5
+ EVICT=$(do_facet client $LCTL get_param mdc.$FSNAME-MDT*.state |
+ awk -F"[ [,]" '/EVICTED ]$/ { if (mx<$5) {mx=$5;} } END { print mx }')
+
+ [ -z "$EVICT" ] || [[ $EVICT -le $BEFORE ]] || error "eviction happened"
+}
+run_test 19c "check reconnect and lock resend do not trigger expired_lock_main"
+
+test_20a() { # bug 2983 - ldlm_handle_enqueue cleanup
+ remote_ost_nodsh && skip "remote OST with nodsh" && return 0
+
+ mkdir -p $DIR/$tdir
+ $LFS setstripe -i 0 -c 1 $DIR/$tdir/${tfile}
+ multiop_bg_pause $DIR/$tdir/${tfile} O_wc || return 1
+ MULTI_PID=$!
+ cancel_lru_locks osc
+#define OBD_FAIL_LDLM_ENQUEUE_EXTENT_ERR 0x308
+ do_facet ost1 lctl set_param fail_loc=0x80000308
+ kill -USR1 $MULTI_PID
+ wait $MULTI_PID
+ rc=$?
+ [ $rc -eq 0 ] && error "multiop didn't fail enqueue: rc $rc" || true
+}
+run_test 20a "ldlm_handle_enqueue error (should return error)"
+
+test_20b() { # bug 2986 - ldlm_handle_enqueue error during open
+ remote_ost_nodsh && skip "remote OST with nodsh" && return 0
+
+ mkdir -p $DIR/$tdir
+ $LFS setstripe -i 0 -c 1 $DIR/$tdir/${tfile}
+ cancel_lru_locks osc
+#define OBD_FAIL_LDLM_ENQUEUE_EXTENT_ERR 0x308
+ do_facet ost1 lctl set_param fail_loc=0x80000308
+ dd if=/etc/hosts of=$DIR/$tdir/$tfile && \
+ error "didn't fail open enqueue" || true
+}
+run_test 20b "ldlm_handle_enqueue error (should return error)"
+
+test_21a() {
+ mkdir -p $DIR/$tdir-1
+ mkdir -p $DIR/$tdir-2
+ multiop_bg_pause $DIR/$tdir-1/f O_c || return 1
+ close_pid=$!
+
+ do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000129"
+ $MULTIOP $DIR/$tdir-2/f Oc &
+ open_pid=$!
+ sleep 1
+ do_facet $SINGLEMDS "lctl set_param fail_loc=0"
+
+ do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000115"
+ kill -USR1 $close_pid
+ cancel_lru_locks mdc
+ wait $close_pid || return 1
+ wait $open_pid || return 2
+ do_facet $SINGLEMDS "lctl set_param 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_bg_pause $DIR/$tdir-1/f O_c || return 1
+ close_pid=$!
+
+ do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000107"
+ mcreate $DIR/$tdir-2/f &
+ open_pid=$!
+ sleep 1
+ do_facet $SINGLEMDS "lctl set_param fail_loc=0"
+
+ kill -USR1 $close_pid
+ cancel_lru_locks mdc
+ 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_bg_pause $DIR/$tdir-1/f O_c || return 1
+ close_pid=$!
+
+ do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000107"
+ mcreate $DIR/$tdir-2/f &
+ open_pid=$!
+ sleep 3
+ do_facet $SINGLEMDS "lctl set_param fail_loc=0"
+
+ do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000115"
+ kill -USR1 $close_pid
+ cancel_lru_locks mdc
+ wait $close_pid || return 1
+ wait $open_pid || return 2
+
+ do_facet $SINGLEMDS "lctl set_param 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_bg_pause $DIR/$tdir-1/f O_c || return 1
+ pid=$!
+
+ do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000129"
+ $MULTIOP $DIR/$tdir-2/f Oc &
+ sleep 1
+ do_facet $SINGLEMDS "lctl set_param fail_loc=0"
+
+ do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000122"
+ kill -USR1 $pid
+ cancel_lru_locks mdc
+ wait $pid || return 1
+ do_facet $SINGLEMDS "lctl set_param 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_bg_pause $DIR/$tdir-1/f O_c || return 1
+ pid=$!
+
+ do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000119"
+ touch $DIR/$tdir-2/f &
+ sleep 1
+ do_facet $SINGLEMDS "lctl set_param fail_loc=0"
+
+ kill -USR1 $pid
+ cancel_lru_locks mdc
+ 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_bg_pause $DIR/$tdir-1/f O_c || return 1
+ pid=$!
+
+ do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000119"
+ touch $DIR/$tdir-2/f &
+ sleep 1
+ do_facet $SINGLEMDS "lctl set_param fail_loc=0"
+
+ do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000122"
+ kill -USR1 $pid
+ cancel_lru_locks mdc
+ wait $pid || return 1
+ do_facet $SINGLEMDS "lctl set_param 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_bg_pause $DIR/$tdir-1/f O_c || return 1
+ pid=$!
+
+ do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000119"
+ touch $DIR/$tdir-2/f &
+ sleep 1
+ do_facet $SINGLEMDS "lctl set_param fail_loc=0"
+
+ do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000115"
+ kill -USR1 $pid
+ cancel_lru_locks mdc
+ wait $pid || return 1
+ do_facet $SINGLEMDS "lctl set_param 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_bg_pause $DIR/$tdir-1/f O_c || return 1
+ pid=$!
+
+ do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000107"
+ touch $DIR/$tdir-2/f &
+ touch_pid=$!
+ sleep 1
+ do_facet $SINGLEMDS "lctl set_param fail_loc=0"
+
+ do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000122"
+ cancel_lru_locks mdc
+ kill -USR1 $pid
+ wait $pid || return 1
+ do_facet $SINGLEMDS "lctl set_param 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 $SINGLEMDS "lctl set_param fail_loc=0x80000115"
+ $MULTIOP $f2 Oc &
+ close_pid=$!
+
+ sleep 1
+ $MULTIOP $f1 msu || return 1
+
+ cancel_lru_locks mdc
+ do_facet $SINGLEMDS "lctl set_param 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_bg_pause $DIR/$tfile O_c || return 1
+ pid=$!
+ # give a chance for open
+ sleep 5
+
+ # try the close
+ drop_request "kill -USR1 $pid"
+
+ fail $SINGLEMDS
+ wait $pid || return 1
+ return 0
+}
+run_test 23 "client hang when close a file after mds crash"
+
+test_24a() { # bug 11710 details correct fsync() behavior
+ remote_ost_nodsh && skip "remote OST with nodsh" && return 0
+
+ mkdir -p $DIR/$tdir
+ $LFS setstripe -i 0 -c 1 $DIR/$tdir
+ cancel_lru_locks osc
+ multiop_bg_pause $DIR/$tdir/$tfile Owy_wyc || return 1
+ MULTI_PID=$!
+ ost_evict_client
+ kill -USR1 $MULTI_PID
+ wait $MULTI_PID
+ rc=$?
+ lctl set_param fail_loc=0x0
+ client_reconnect
+ [ $rc -eq 0 ] &&
+ error_ignore bz5494 "multiop didn't fail fsync: rc $rc" || true
+}
+run_test 24a "fsync error (should return error)"
+
+wait_client_evicted () {
+ local facet=$1
+ local exports=$2
+ local varsvc=${facet}_svc
+
+ wait_update $(facet_active_host $facet) \
+ "lctl get_param -n *.${!varsvc}.num_exports | cut -d' ' -f2" \
+ $((exports - 1)) $3
+}
+
+test_24b() {
+ remote_ost_nodsh && skip "remote OST with nodsh" && return 0
+
+ dmesg -c > /dev/null
+ mkdir -p $DIR/$tdir
+ lfs setstripe $DIR/$tdir -s 0 -i 0 -c 1
+ cancel_lru_locks osc
+ multiop_bg_pause $DIR/$tdir/$tfile-1 Ow8192_yc ||
+ error "mulitop Ow8192_yc failed"
+
+ MULTI_PID1=$!
+ multiop_bg_pause $DIR/$tdir/$tfile-2 Ow8192_c ||
+ error "mulitop Ow8192_c failed"
+
+ MULTI_PID2=$!
+ ost_evict_client
+
+ kill -USR1 $MULTI_PID1
+ wait $MULTI_PID1
+ rc1=$?
+ kill -USR1 $MULTI_PID2
+ wait $MULTI_PID2
+ rc2=$?
+ lctl set_param fail_loc=0x0
+ client_reconnect
+ [ $rc1 -eq 0 -o $rc2 -eq 0 ] &&
+ error_ignore bz5494 "multiop didn't fail fsync: $rc1 or close: $rc2" ||
+ true
+
+ dmesg | grep "dirty page discard:" ||
+ error "no discarded dirty page found!"
+}
+run_test 24b "test dirty page discard due to client eviction"
+
+test_26a() { # was test_26 bug 5921 - evict dead exports by pinger
+# this test can only run from a client on a separate node.
+ remote_ost || { skip "local OST" && return 0; }
+ remote_ost_nodsh && skip "remote OST with nodsh" && return 0
+ remote_mds || { skip "local MDS" && return 0; }
+
+ if [ $(facet_host mgs) = $(facet_host ost1) ]; then
+ skip "msg and ost1 are at the same node"
+ return 0
+ fi
+
+ check_timeout || return 1
+
+ local OST_NEXP=$(do_facet ost1 lctl get_param -n obdfilter.${ost1_svc}.num_exports | cut -d' ' -f2)
+
+ echo starting with $OST_NEXP OST exports
+# OBD_FAIL_PTLRPC_DROP_RPC 0x505
+ do_facet client lctl set_param fail_loc=0x505
+ # evictor takes PING_EVICT_TIMEOUT + 3 * PING_INTERVAL to evict.
+ # But if there's a race to start the evictor from various obds,
+ # the loser might have to wait for the next ping.
+
+ local rc=0
+ wait_client_evicted ost1 $OST_NEXP $((TIMEOUT * 2 + TIMEOUT * 3 / 4))
+ rc=$?
+ do_facet client lctl set_param fail_loc=0x0
+ [ $rc -eq 0 ] || error "client not evicted from OST"
+}
+run_test 26a "evict dead exports"
+
+test_26b() { # bug 10140 - evict dead exports by pinger
+ remote_ost_nodsh && skip "remote OST with nodsh" && return 0
+
+ if [ $(facet_host mgs) = $(facet_host ost1) ]; then
+ skip "msg and ost1 are at the same node"
+ return 0
+ fi
+
+ check_timeout || return 1
+ clients_up
+ zconf_mount `hostname` $MOUNT2 ||
+ { error "Failed to mount $MOUNT2"; return 2; }
+ sleep 1 # wait connections being established
+
+ local MDS_NEXP=$(do_facet $SINGLEMDS lctl get_param -n mdt.${mds1_svc}.num_exports | cut -d' ' -f2)
+ local OST_NEXP=$(do_facet ost1 lctl get_param -n obdfilter.${ost1_svc}.num_exports | cut -d' ' -f2)
+
+ echo starting with $OST_NEXP OST and $MDS_NEXP MDS exports
+
+ zconf_umount `hostname` $MOUNT2 -f
+
+ # PING_INTERVAL max(obd_timeout / 4, 1U)
+ # PING_EVICT_TIMEOUT (PING_INTERVAL * 6)
+
+ # evictor takes PING_EVICT_TIMEOUT + 3 * PING_INTERVAL to evict.
+ # But if there's a race to start the evictor from various obds,
+ # the loser might have to wait for the next ping.
+ # = 9 * PING_INTERVAL + PING_INTERVAL
+ # = 10 PING_INTERVAL = 10 obd_timeout / 4 = 2.5 obd_timeout
+ # let's wait $((TIMEOUT * 3)) # bug 19887
+ local rc=0
+ wait_client_evicted ost1 $OST_NEXP $((TIMEOUT * 3)) || \
+ error "Client was not evicted by ost" rc=1
+ wait_client_evicted $SINGLEMDS $MDS_NEXP $((TIMEOUT * 3)) || \
+ error "Client was not evicted by mds"
+}
+run_test 26b "evict dead exports"
+
+test_27() {
+ mkdir -p $DIR/$tdir
+ writemany -q -a $DIR/$tdir/$tfile 0 5 &
+ CLIENT_PID=$!
+ sleep 1
+ local save_FAILURE_MODE=$FAILURE_MODE
+ FAILURE_MODE="SOFT"
+ facet_failover $SINGLEMDS
+#define OBD_FAIL_OSC_SHUTDOWN 0x407
+ do_facet $SINGLEMDS lctl set_param fail_loc=0x80000407
+ # need to wait for reconnect
+ echo waiting for fail_loc
+ wait_update_facet $SINGLEMDS "lctl get_param -n fail_loc" "-2147482617"
+ facet_failover $SINGLEMDS
+ #no crashes allowed!
+ kill -USR1 $CLIENT_PID
+ wait $CLIENT_PID
+ true
+ FAILURE_MODE=$save_FAILURE_MODE
+}
+run_test 27 "fail LOV while using OSC's"
+
+test_28() { # bug 6086 - error adding new clients
+ do_facet client mcreate $DIR/$tfile || return 1
+ drop_bl_callback_once "chmod 0777 $DIR/$tfile" ||
+ echo "evicted as expected"
+ #define OBD_FAIL_MDS_CLIENT_ADD 0x12f
+ do_facet $SINGLEMDS "lctl set_param fail_loc=0x8000012f"
+ # fail once (evicted), reconnect fail (fail_loc), ok
+ client_up || (sleep 10; client_up) || (sleep 10; client_up) || error "reconnect failed"
+ rm -f $DIR/$tfile
+ fail $SINGLEMDS # verify MDS last_rcvd can be loaded
+}
+run_test 28 "handle error adding new clients (bug 6086)"
+
+test_29a() { # bug 22273 - error adding new clients
+ #define OBD_FAIL_TGT_CLIENT_ADD 0x711
+ do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000711"
+ # fail abort so client will be new again
+ fail_abort $SINGLEMDS
+ client_up || error "reconnect failed"
+ wait_osc_import_state $SINGLEMDS ost FULL
+ return 0
+}
+run_test 29a "error adding new clients doesn't cause LBUG (bug 22273)"
+
+test_29b() { # bug 22273 - error adding new clients
+ #define OBD_FAIL_TGT_CLIENT_ADD 0x711
+ do_facet ost1 "lctl set_param fail_loc=0x80000711"
+ # fail abort so client will be new again
+ fail_abort ost1
+ client_up || error "reconnect failed"
+ return 0
+}
+run_test 29b "error adding new clients doesn't cause LBUG (bug 22273)"