6 ALWAYS_EXCEPT="52 60 $RECOVERY_SMALL_EXCEPT"
8 export MULTIOP=${MULTIOP:-multiop}
9 PTLDEBUG=${PTLDEBUG:--1}
10 LUSTRE=${LUSTRE:-`dirname $0`/..}
11 . $LUSTRE/tests/test-framework.sh
13 . ${CONFIG:=$LUSTRE/tests/cfg/$NAME.sh}
16 require_dsh_mds || exit 0
18 # also long tests: 19, 21a, 21e, 21f, 23, 27
19 # 1 2.5 2.5 4 4 (min)"
20 [ "$SLOW" = "no" ] && EXCEPT_SLOW="17 26a 26b 50 51 57"
22 [ $(facet_fstype $SINGLEMDS) = "zfs" ] &&
23 # bug number for skipped test: LU-2194 LU-2547
24 ALWAYS_EXCEPT="$ALWAYS_EXCEPT 19b 24a 24b"
28 # Allow us to override the setup if we already have a mounted system by
29 # setting SETUP=" " and CLEANUP=" "
31 CLEANUP=${CLEANUP:-""}
33 check_and_setup_lustre
36 rm -rf $DIR/d[0-9]* $DIR/f.${TESTSUITE}*
39 local f1="$DIR/$tfile"
40 local f2="$DIR/$tfile.2"
42 drop_request "mcreate $f1" ||
43 error_noexit "create '$f1': drop req"
45 drop_reint_reply "mcreate $f2" ||
46 error_noexit "create '$f2': drop rep"
48 drop_request "tchmod 111 $f2" ||
49 error_noexit "chmod '$f2': drop req"
51 drop_reint_reply "tchmod 666 $f2" ||
52 error_noexit "chmod '$f2': drop rep"
54 drop_request "statone $f2" ||
55 error_noexit "stat '$f2': drop req"
57 drop_reply "statone $f2" ||
58 error_noexit "stat '$f2': drop rep"
60 run_test 1 "create, chmod, stat: drop req, drop rep"
64 do_facet_create_file client $t 10K ||
65 error_noexit "Create file $t"
67 drop_request "cat $t > /dev/null" ||
68 error_noexit "Open request for $t file"
70 drop_reply "cat $t > /dev/null" ||
71 error_noexit "Open replay for $t file"
73 run_test 4 "open: drop req, drop rep"
78 local RR="$T-renamed-again"
79 do_facet_create_file client $T 10K ||
80 error_noexit "Create file $T"
82 drop_request "mv $T $R" ||
83 error_noexit "Rename $T"
85 drop_reint_reply "mv $R $RR" ||
86 error_noexit "Failed rename replay on $R"
88 do_facet client "checkstat -v $RR" ||
89 error_noexit "checkstat error on $RR"
91 do_facet client "rm $RR" ||
92 error_noexit "Can't remove file $RR"
94 run_test 5 "rename: drop req, drop rep"
98 local LINK1=$DIR/$tfile.link1
99 local LINK2=$DIR/$tfile.link2
101 do_facet_create_file client $T 10K ||
102 error_noexit "Create file $T"
104 drop_request "mlink $T $LINK1" ||
105 error_noexit "mlink request for $T"
107 drop_reint_reply "mlink $T $LINK2" ||
108 error_noexit "mlink reply for $T"
110 drop_request "munlink $LINK1" ||
111 error_noexit "munlink request for $T"
113 drop_reint_reply "munlink $LINK2" ||
114 error_noexit "munlink reply for $T"
116 do_facet client "rm $T" ||
117 error_noexit "Can't remove file $T"
119 run_test 6 "link, unlink: drop req, drop rep"
123 drop_reint_reply "touch $DIR/$tfile" || return 1
125 run_test 8 "touch: drop rep (bug 1423)"
129 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
133 do_facet_random_file client $TMP/$tfile 1K ||
134 error_noexit "Create random file $TMP/$tfile"
135 # make this big, else test 9 doesn't wait for bulk -- bz 5595
136 do_facet_create_file client $TMP/$t1 4M ||
137 error_noexit "Create file $TMP/$t1"
138 do_facet client "cp $TMP/$t1 $DIR/$t1" ||
139 error_noexit "Can't copy to $DIR/$t1 file"
140 pause_bulk "cp $TMP/$tfile $DIR/$tfile" ||
141 error_noexit "Can't pause_bulk copy"
142 do_facet client "cp $TMP/$t1 $DIR/$t2" ||
143 error_noexit "Can't copy file"
144 do_facet client "sync"
145 do_facet client "rm $DIR/$tfile $DIR/$t2 $DIR/$t1" ||
146 error_noexit "Can't remove files"
147 do_facet client "rm $TMP/$t1 $TMP/$tfile"
149 run_test 9 "pause bulk on OST (bug 1420)"
153 local before=$(date +%s)
156 do_facet client "stat $DIR > /dev/null" ||
157 error "failed to stat $DIR: $?"
158 drop_bl_callback "chmod 0777 $DIR" ||
159 error "failed to chmod $DIR: $?"
161 # let the client reconnect
163 evict=$(do_facet client $LCTL get_param mdc.$FSNAME-MDT*.state |
164 awk -F"[ [,]" '/EVICTED ]$/ { if (mx<$5) {mx=$5;} } END { print mx }')
165 [ ! -z "$evict" ] && [[ $evict -gt $before ]] ||
166 (do_facet client $LCTL get_param mdc.$FSNAME-MDT*.state;
167 error "no eviction: $evict before:$before")
169 do_facet client checkstat -v -p 0777 $DIR ||
170 error "client checkstat failed: $?"
172 run_test 10a "finish request on server after client eviction (bug 1521)"
175 local before=$(date +%s)
178 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.6.53) ]] &&
179 skip "Need MDS version at least 2.6.53" && return
180 do_facet client "stat $DIR > /dev/null" ||
181 error "failed to stat $DIR: $?"
182 drop_bl_callback_once "chmod 0777 $DIR" ||
183 error "failed to chmod $DIR: $?"
185 # let the client reconnect
187 evict=$(do_facet client $LCTL get_param mdc.$FSNAME-MDT*.state |
188 awk -F"[ [,]" '/EVICTED ]$/ { if (mx<$5) {mx=$5;} } END { print mx }')
190 [ -z "$evict" ] || [[ $evict -le $before ]] ||
191 (do_facet client $LCTL get_param mdc.$FSNAME-MDT*.state;
192 error "eviction happened: $evict before:$before")
194 do_facet client checkstat -v -p 0777 $DIR ||
195 error "client checkstat failed: $?"
197 run_test 10b "re-send BL AST"
200 local before=$(date +%s)
203 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.6.90) ]] &&
204 skip "Need MDS version at least 2.6.90" && return
206 # sleep 1 is to make sure that BEFORE is not equal to EVICTED below
209 echo -n ", world" | dd of=$TMP/$tfile bs=1c seek=5
213 $LFS setstripe -i 0 -c 1 $DIR1/$tfile
214 echo -n hello > $DIR1/$tfile
216 stat $DIR2/$tfile >& /dev/null
217 $LCTL set_param fail_err=71
218 drop_bl_callback_once "echo -n \\\", world\\\" >> $DIR2/$tfile"
222 cmp $DIR1/$tfile $DIR2/$tfile || error "file contents differ"
223 cmp $DIR1/$tfile $TMP/$tfile || error "wrong content found"
225 evict=$(do_facet client $LCTL get_param osc.$FSNAME-OST0000*.state | \
227 awk -F"[ [,]" '/EVICTED$/ { if (mx<$1) {mx=$1;} } END { print mx }')
229 [[ $evict -gt $before ]] ||
230 (do_facet client $LCTL get_param osc.$FSNAME-OST0000*.state;
231 error "no eviction: $evict before:$before")
234 umount_client $MOUNT2
236 run_test 10d "test failed blocking ast"
239 # wake up a thread waiting for completion after eviction
241 do_facet client $MULTIOP $DIR/$tfile Ow ||
242 { error "multiop write failed: $?"; return 1; }
243 do_facet client $MULTIOP $DIR/$tfile or ||
244 { error "multiop read failed: $?"; return 2; }
248 do_facet client $MULTIOP $DIR/$tfile or ||
249 { error "multiop read failed: $?"; return 3; }
250 drop_bl_callback_once $MULTIOP $DIR/$tfile Ow ||
251 echo "evicted as expected"
253 do_facet client munlink $DIR/$tfile ||
254 { error "munlink failed: $?"; return 4; }
255 # allow recovery to complete
256 client_up || client_up || sleep $TIMEOUT
258 run_test 11 "wake up a thread waiting for completion after eviction (b=2460)"
262 $LCTL mark $MULTIOP $DIR/$tfile OS_c
263 do_facet $SINGLEMDS "lctl set_param fail_loc=0x115"
264 clear_failloc $SINGLEMDS $((TIMEOUT * 2)) &
265 multiop_bg_pause $DIR/$tfile OS_c ||
266 { error "multiop failed: $?"; return 1; }
268 #define OBD_FAIL_MDS_CLOSE_NET 0x115
270 echo "waiting for multiop $PID"
271 wait $PID || { error "wait for multiop faile: $?"; return 2; }
272 do_facet client munlink $DIR/$tfile ||
273 { error "client munlink failed: $?"; return 3; }
274 # allow recovery to complete
275 client_up || client_up || sleep $TIMEOUT
277 run_test 12 "recover from timed out resend in ptlrpcd (b=2494)"
279 # Bug 113, check that readdir lost recv timeout works.
281 mkdir -p $DIR/$tdir || { error "mkdir failed: $?"; return 1; }
282 touch $DIR/$tdir/newentry || { error "touch failed: $?"; return 2; }
283 # OBD_FAIL_MDS_READPAGE_NET|OBD_FAIL_ONCE
284 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000104"
285 ls $DIR/$tdir || { error "ls failed: $?"; return 3; }
286 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
287 rm -rf $DIR/$tdir || { error "remove test dir failed: $?"; return 4; }
289 run_test 13 "mdc_readpage restart test (bug 1138)"
291 # Bug 113, check that readdir lost send timeout works.
294 touch $DIR/$tdir/newentry
295 # OBD_FAIL_MDS_SENDPAGE|OBD_FAIL_ONCE
296 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000106"
297 ls $DIR/$tdir || return 1
298 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
300 run_test 14 "mdc_readpage resend test (bug 1138)"
303 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000128"
304 touch $DIR/$tfile && return 1
307 run_test 15 "failed open (-ENOMEM)"
309 READ_AHEAD=`lctl get_param -n llite.*.max_read_ahead_mb | head -n 1`
311 lctl set_param -n llite.*.max_read_ahead_mb 0
315 lctl set_param -n llite.*.max_read_ahead_mb $READ_AHEAD
319 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
321 do_facet_random_file client $TMP/$tfile 100K ||
322 { error_noexit "Create random file $TMP/$T" ; return 0; }
323 do_facet client "cp $TMP/$tfile $DIR/$tfile" ||
324 { error_noexit "Copy to $DIR/$tfile file" ; return 0; }
328 #define OBD_FAIL_PTLRPC_BULK_PUT_NET 0x504 | OBD_FAIL_ONCE
329 do_facet ost1 "lctl set_param fail_loc=0x80000504"
331 # OST bulk will time out here, client resends
332 do_facet client "cmp $TMP/$tfile $DIR/$tfile" || return 1
333 do_facet ost1 lctl set_param fail_loc=0
334 # give recovery a chance to finish (shouldn't take long)
336 do_facet client "cmp $TMP/$tfile $DIR/$tfile" || return 2
340 run_test 16 "timeout bulk put, don't evict client (2732)"
345 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
347 local SAMPLE_FILE=$TMP/$tfile
348 do_facet_random_file client $SAMPLE_FILE 20K ||
349 { error_noexit "Create random file $SAMPLE_FILE" ; return 0; }
351 # With adaptive timeouts, bulk_get won't expire until adaptive_timeout_max
352 if at_is_enabled; then
353 at_max_saved=$(at_max_get ost1)
354 at_max_set $TIMEOUT ost1
357 # OBD_FAIL_PTLRPC_BULK_GET_NET 0x0503 | OBD_FAIL_ONCE
358 # OST bulk will time out here, client retries
359 do_facet ost1 lctl set_param fail_loc=0x80000503
360 # need to ensure we send an RPC
361 do_facet client cp $SAMPLE_FILE $DIR/$tfile
364 # with AT, client will wait adaptive_max*factor+net_latency before
365 # expiring the req, hopefully timeout*2 is enough
366 sleep $(($TIMEOUT*2))
368 do_facet ost1 lctl set_param fail_loc=0
369 do_facet client "df $DIR"
370 # expect cmp to succeed, client resent bulk
371 do_facet client "cmp $SAMPLE_FILE $DIR/$tfile" || return 3
372 do_facet client "rm $DIR/$tfile" || return 4
373 [ $at_max_saved -ne 0 ] && at_max_set $at_max_saved ost1
376 run_test 17 "timeout bulk get, don't evict client (2732)"
379 [ -z ${ost2_svc} ] && skip_env "needs 2 osts" && return 0
381 do_facet_create_file client $TMP/$tfile 20K ||
382 { error_noexit "Create file $TMP/$tfile" ; return 0; }
384 do_facet client mkdir -p $DIR/$tdir
388 pgcache_empty || return 1
391 $LFS setstripe -i 1 -c 1 $f
392 stripe_index=$($LFS getstripe -i $f)
393 if [ $stripe_index -ne 1 ]; then
395 error "$f: stripe_index $stripe_index != 1" && return
398 do_facet client cp $TMP/$tfile $f
400 local osc2dev=`lctl get_param -n devices | grep ${ost2_svc}-osc- | egrep -v 'MDT' | awk '{print $1}'`
401 $LCTL --device $osc2dev deactivate || return 3
402 # my understanding is that there should be nothing in the page
403 # cache after the client reconnects?
405 pgcache_empty || rc=2
406 $LCTL --device $osc2dev activate
410 run_test 18a "manual ost invalidate clears page cache immediately"
413 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
415 do_facet_create_file client $TMP/$tfile 20K ||
416 { error_noexit "Create file $TMP/$tfile" ; return 0; }
418 do_facet client mkdir -p $DIR/$tdir
422 pgcache_empty || return 1
424 $LFS setstripe -i 0 -c 1 $f
425 stripe_index=$($LFS getstripe -i $f)
426 if [ $stripe_index -ne 0 ]; then
428 error "$f: stripe_index $stripe_index != 0" && return
431 do_facet client cp $TMP/$tfile $f
434 # allow recovery to complete
435 sleep $((TIMEOUT + 2))
436 # my understanding is that there should be nothing in the page
437 # cache after the client reconnects?
439 pgcache_empty || rc=2
443 run_test 18b "eviction and reconnect clears page cache (2766)"
446 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
448 do_facet_create_file client $TMP/$tfile 20K ||
449 { error_noexit "Create file $TMP/$tfile" ; return 0; }
451 do_facet client mkdir -p $DIR/$tdir
455 pgcache_empty || return 1
457 $LFS setstripe -i 0 -c 1 $f
458 stripe_index=$($LFS getstripe -i $f)
459 if [ $stripe_index -ne 0 ]; then
461 error "$f: stripe_index $stripe_index != 0" && return
464 do_facet client cp $TMP/$tfile $f
468 # OBD_FAIL_OST_CONNECT_NET2
469 # lost reply to connect request
470 do_facet ost1 lctl set_param fail_loc=0x80000225
473 df $MOUNT > /dev/null 2>&1
475 # my understanding is that there should be nothing in the page
476 # cache after the client reconnects?
478 pgcache_empty || rc=2
482 run_test 18c "Dropped connect reply after eviction handing (14755)"
485 local BEFORE=`date +%s`
488 mount_client $DIR2 || error "failed to mount $DIR2"
490 # cancel cached locks from OST to avoid eviction from it
493 do_facet client "stat $DIR > /dev/null" ||
494 error "failed to stat $DIR: $?"
495 drop_ldlm_cancel "chmod 0777 $DIR2" ||
496 error "failed to chmod $DIR2"
500 # let the client reconnect
502 EVICT=$(do_facet client $LCTL get_param mdc.$FSNAME-MDT*.state |
503 awk -F"[ [,]" '/EVICTED ]$/ \
504 { if (mx<$5) {mx=$5;} } END { print mx }')
506 [ ! -z "$EVICT" ] && [[ $EVICT -gt $BEFORE ]] ||
507 (do_facet client $LCTL get_param mdc.$FSNAME-MDT*.state;
508 error "no eviction: $EVICT before:$BEFORE")
510 run_test 19a "test expired_lock_main on mds (2867)"
513 local BEFORE=`date +%s`
516 mount_client $DIR2 || error "failed to mount $DIR2: $?"
518 # cancel cached locks from MDT to avoid eviction from it
521 do_facet client $MULTIOP $DIR/$tfile Ow ||
522 error "failed to run multiop: $?"
523 drop_ldlm_cancel $MULTIOP $DIR2/$tfile Ow ||
524 error "failed to ldlm_cancel: $?"
526 umount_client $DIR2 || error "failed to unmount $DIR2: $?"
527 do_facet client munlink $DIR/$tfile ||
528 error "failed to unlink $DIR/$tfile: $?"
530 # let the client reconnect
532 EVICT=$(do_facet client $LCTL get_param osc.$FSNAME-OST*.state |
533 awk -F"[ [,]" '/EVICTED ]$/ \
534 { if (mx < $5) {mx = $5;} } END { print mx }')
536 [ ! -z "$EVICT" ] && [[ $EVICT -gt $BEFORE ]] ||
537 (do_facet client $LCTL get_param osc.$FSNAME-OST*.state;
538 error "no eviction: $EVICT before:$BEFORE")
540 run_test 19b "test expired_lock_main on ost (2867)"
543 local BEFORE=`date +%s`
546 $LCTL set_param ldlm.namespaces.*.early_lock_cancel=0
548 mkdir -p $DIR1/$tfile
551 #define OBD_FAIL_PTLRPC_CANCEL_RESEND 0x516
552 do_facet mds $LCTL set_param fail_loc=0x80000516
554 touch $DIR2/$tfile/file1 &
556 # let touch to get blocked on the server
560 $LCTL set_param ldlm.namespaces.*.early_lock_cancel=1
563 # let the client reconnect
565 EVICT=$(do_facet client $LCTL get_param mdc.$FSNAME-MDT*.state |
566 awk -F"[ [,]" '/EVICTED ]$/ { if (mx<$5) {mx=$5;} } END { print mx }')
568 [ -z "$EVICT" ] || [[ $EVICT -le $BEFORE ]] || error "eviction happened"
570 run_test 19c "check reconnect and lock resend do not trigger expired_lock_main"
572 test_20a() { # bug 2983 - ldlm_handle_enqueue cleanup
573 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
576 $LFS setstripe -i 0 -c 1 $DIR/$tdir/${tfile}
577 multiop_bg_pause $DIR/$tdir/${tfile} O_wc || return 1
580 #define OBD_FAIL_LDLM_ENQUEUE_EXTENT_ERR 0x308
581 do_facet ost1 lctl set_param fail_loc=0x80000308
582 kill -USR1 $MULTI_PID
585 [ $rc -eq 0 ] && error "multiop didn't fail enqueue: rc $rc" || true
587 run_test 20a "ldlm_handle_enqueue error (should return error)"
589 test_20b() { # bug 2986 - ldlm_handle_enqueue error during open
590 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
593 $LFS setstripe -i 0 -c 1 $DIR/$tdir/${tfile}
595 #define OBD_FAIL_LDLM_ENQUEUE_EXTENT_ERR 0x308
596 do_facet ost1 lctl set_param fail_loc=0x80000308
597 dd if=/etc/hosts of=$DIR/$tdir/$tfile && \
598 error "didn't fail open enqueue" || true
600 run_test 20b "ldlm_handle_enqueue error (should return error)"
603 mkdir -p $DIR/$tdir-1
604 mkdir -p $DIR/$tdir-2
605 multiop_bg_pause $DIR/$tdir-1/f O_c || return 1
608 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000129"
609 $MULTIOP $DIR/$tdir-2/f Oc &
612 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
614 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000115"
615 kill -USR1 $close_pid
617 wait $close_pid || return 1
618 wait $open_pid || return 2
619 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
621 $CHECKSTAT -t file $DIR/$tdir-1/f || return 3
622 $CHECKSTAT -t file $DIR/$tdir-2/f || return 4
626 run_test 21a "drop close request while close and open are both in flight"
629 mkdir -p $DIR/$tdir-1
630 mkdir -p $DIR/$tdir-2
631 multiop_bg_pause $DIR/$tdir-1/f O_c || return 1
634 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000107"
635 mcreate $DIR/$tdir-2/f &
638 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
640 kill -USR1 $close_pid
642 wait $close_pid || return 1
643 wait $open_pid || return 3
645 $CHECKSTAT -t file $DIR/$tdir-1/f || return 4
646 $CHECKSTAT -t file $DIR/$tdir-2/f || return 5
649 run_test 21b "drop open request while close and open are both in flight"
652 mkdir -p $DIR/$tdir-1
653 mkdir -p $DIR/$tdir-2
654 multiop_bg_pause $DIR/$tdir-1/f O_c || return 1
657 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000107"
658 mcreate $DIR/$tdir-2/f &
661 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
663 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000115"
664 kill -USR1 $close_pid
666 wait $close_pid || return 1
667 wait $open_pid || return 2
669 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
671 $CHECKSTAT -t file $DIR/$tdir-1/f || return 2
672 $CHECKSTAT -t file $DIR/$tdir-2/f || return 3
675 run_test 21c "drop both request while close and open are both in flight"
678 mkdir -p $DIR/$tdir-1
679 mkdir -p $DIR/$tdir-2
680 multiop_bg_pause $DIR/$tdir-1/f O_c || return 1
683 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000129"
684 $MULTIOP $DIR/$tdir-2/f Oc &
686 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
688 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000122"
691 wait $pid || return 1
692 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
694 $CHECKSTAT -t file $DIR/$tdir-1/f || return 2
695 $CHECKSTAT -t file $DIR/$tdir-2/f || return 3
699 run_test 21d "drop close reply while close and open are both in flight"
702 mkdir -p $DIR/$tdir-1
703 mkdir -p $DIR/$tdir-2
704 multiop_bg_pause $DIR/$tdir-1/f O_c || return 1
707 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000119"
708 touch $DIR/$tdir-2/f &
710 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
714 wait $pid || return 1
717 $CHECKSTAT -t file $DIR/$tdir-1/f || return 2
718 $CHECKSTAT -t file $DIR/$tdir-2/f || return 3
721 run_test 21e "drop open reply while close and open are both in flight"
724 mkdir -p $DIR/$tdir-1
725 mkdir -p $DIR/$tdir-2
726 multiop_bg_pause $DIR/$tdir-1/f O_c || return 1
729 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000119"
730 touch $DIR/$tdir-2/f &
732 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
734 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000122"
737 wait $pid || return 1
738 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
740 $CHECKSTAT -t file $DIR/$tdir-1/f || return 2
741 $CHECKSTAT -t file $DIR/$tdir-2/f || return 3
744 run_test 21f "drop both reply while close and open are both in flight"
747 mkdir -p $DIR/$tdir-1
748 mkdir -p $DIR/$tdir-2
749 multiop_bg_pause $DIR/$tdir-1/f O_c || return 1
752 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000119"
753 touch $DIR/$tdir-2/f &
755 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
757 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000115"
760 wait $pid || return 1
761 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
763 $CHECKSTAT -t file $DIR/$tdir-1/f || return 2
764 $CHECKSTAT -t file $DIR/$tdir-2/f || return 3
767 run_test 21g "drop open reply and close request while close and open are both in flight"
770 mkdir -p $DIR/$tdir-1
771 mkdir -p $DIR/$tdir-2
772 multiop_bg_pause $DIR/$tdir-1/f O_c || return 1
775 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000107"
776 touch $DIR/$tdir-2/f &
779 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
781 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000122"
784 wait $pid || return 1
785 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
787 wait $touch_pid || return 2
789 $CHECKSTAT -t file $DIR/$tdir-1/f || return 3
790 $CHECKSTAT -t file $DIR/$tdir-2/f || return 4
793 run_test 21h "drop open request and close reply while close and open are both in flight"
795 # bug 3462 - multiple MDC requests
800 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000115"
805 $MULTIOP $f1 msu || return 1
808 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
810 wait $close_pid || return 2
811 rm -rf $f2 || return 4
813 run_test 22 "drop close request and do mknod"
816 multiop_bg_pause $DIR/$tfile O_c || return 1
818 # give a chance for open
822 drop_request "kill -USR1 $pid"
825 wait $pid || return 1
828 run_test 23 "client hang when close a file after mds crash"
830 test_24a() { # bug 11710 details correct fsync() behavior
831 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
834 $LFS setstripe -i 0 -c 1 $DIR/$tdir
836 multiop_bg_pause $DIR/$tdir/$tfile Owy_wyc || return 1
839 kill -USR1 $MULTI_PID
842 lctl set_param fail_loc=0x0
845 error_ignore bz5494 "multiop didn't fail fsync: rc $rc" || true
847 run_test 24a "fsync error (should return error)"
849 wait_client_evicted () {
852 local varsvc=${facet}_svc
854 wait_update $(facet_active_host $facet) \
855 "lctl get_param -n *.${!varsvc}.num_exports | cut -d' ' -f2" \
860 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
864 lfs setstripe $DIR/$tdir -s 0 -i 0 -c 1
866 multiop_bg_pause $DIR/$tdir/$tfile-1 Ow8192_yc ||
867 error "mulitop Ow8192_yc failed"
870 multiop_bg_pause $DIR/$tdir/$tfile-2 Ow8192_c ||
871 error "mulitop Ow8192_c failed"
876 kill -USR1 $MULTI_PID1
879 kill -USR1 $MULTI_PID2
882 lctl set_param fail_loc=0x0
884 [ $rc1 -eq 0 -o $rc2 -eq 0 ] &&
885 error_ignore bz5494 "multiop didn't fail fsync: $rc1 or close: $rc2" ||
888 dmesg | grep "dirty page discard:" ||
889 error "no discarded dirty page found!"
891 run_test 24b "test dirty page discard due to client eviction"
893 test_26a() { # was test_26 bug 5921 - evict dead exports by pinger
894 # this test can only run from a client on a separate node.
895 remote_ost || { skip "local OST" && return 0; }
896 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
897 remote_mds || { skip "local MDS" && return 0; }
899 if [ $(facet_host mgs) = $(facet_host ost1) ]; then
900 skip "msg and ost1 are at the same node"
904 check_timeout || return 1
906 local OST_NEXP=$(do_facet ost1 lctl get_param -n obdfilter.${ost1_svc}.num_exports | cut -d' ' -f2)
908 echo starting with $OST_NEXP OST exports
909 # OBD_FAIL_PTLRPC_DROP_RPC 0x505
910 do_facet client lctl set_param fail_loc=0x505
911 # evictor takes PING_EVICT_TIMEOUT + 3 * PING_INTERVAL to evict.
912 # But if there's a race to start the evictor from various obds,
913 # the loser might have to wait for the next ping.
916 wait_client_evicted ost1 $OST_NEXP $((TIMEOUT * 2 + TIMEOUT * 3 / 4))
918 do_facet client lctl set_param fail_loc=0x0
919 [ $rc -eq 0 ] || error "client not evicted from OST"
921 run_test 26a "evict dead exports"
923 test_26b() { # bug 10140 - evict dead exports by pinger
924 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
926 if [ $(facet_host mgs) = $(facet_host ost1) ]; then
927 skip "msg and ost1 are at the same node"
931 check_timeout || return 1
933 zconf_mount `hostname` $MOUNT2 ||
934 { error "Failed to mount $MOUNT2"; return 2; }
935 sleep 1 # wait connections being established
937 local MDS_NEXP=$(do_facet $SINGLEMDS lctl get_param -n mdt.${mds1_svc}.num_exports | cut -d' ' -f2)
938 local OST_NEXP=$(do_facet ost1 lctl get_param -n obdfilter.${ost1_svc}.num_exports | cut -d' ' -f2)
940 echo starting with $OST_NEXP OST and $MDS_NEXP MDS exports
942 zconf_umount `hostname` $MOUNT2 -f
944 # PING_INTERVAL max(obd_timeout / 4, 1U)
945 # PING_EVICT_TIMEOUT (PING_INTERVAL * 6)
947 # evictor takes PING_EVICT_TIMEOUT + 3 * PING_INTERVAL to evict.
948 # But if there's a race to start the evictor from various obds,
949 # the loser might have to wait for the next ping.
950 # = 9 * PING_INTERVAL + PING_INTERVAL
951 # = 10 PING_INTERVAL = 10 obd_timeout / 4 = 2.5 obd_timeout
952 # let's wait $((TIMEOUT * 3)) # bug 19887
954 wait_client_evicted ost1 $OST_NEXP $((TIMEOUT * 3)) || \
955 error "Client was not evicted by ost" rc=1
956 wait_client_evicted $SINGLEMDS $MDS_NEXP $((TIMEOUT * 3)) || \
957 error "Client was not evicted by mds"
959 run_test 26b "evict dead exports"
963 writemany -q -a $DIR/$tdir/$tfile 0 5 &
966 local save_FAILURE_MODE=$FAILURE_MODE
968 facet_failover $SINGLEMDS
969 #define OBD_FAIL_OSC_SHUTDOWN 0x407
970 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000407
971 # need to wait for reconnect
972 echo waiting for fail_loc
973 wait_update_facet $SINGLEMDS "lctl get_param -n fail_loc" "-2147482617"
974 facet_failover $SINGLEMDS
976 kill -USR1 $CLIENT_PID
979 FAILURE_MODE=$save_FAILURE_MODE
981 run_test 27 "fail LOV while using OSC's"
983 test_28() { # bug 6086 - error adding new clients
984 do_facet client mcreate $DIR/$tfile || return 1
985 drop_bl_callback_once "chmod 0777 $DIR/$tfile" ||
986 echo "evicted as expected"
987 #define OBD_FAIL_MDS_CLIENT_ADD 0x12f
988 do_facet $SINGLEMDS "lctl set_param fail_loc=0x8000012f"
989 # fail once (evicted), reconnect fail (fail_loc), ok
990 client_up || (sleep 10; client_up) || (sleep 10; client_up) || error "reconnect failed"
992 fail $SINGLEMDS # verify MDS last_rcvd can be loaded
994 run_test 28 "handle error adding new clients (bug 6086)"
996 test_29a() { # bug 22273 - error adding new clients
997 #define OBD_FAIL_TGT_CLIENT_ADD 0x711
998 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000711"
999 # fail abort so client will be new again
1000 fail_abort $SINGLEMDS
1001 client_up || error "reconnect failed"
1002 wait_osc_import_state $SINGLEMDS ost FULL
1005 run_test 29a "error adding new clients doesn't cause LBUG (bug 22273)"
1007 test_29b() { # bug 22273 - error adding new clients
1008 #define OBD_FAIL_TGT_CLIENT_ADD 0x711
1009 do_facet ost1 "lctl set_param fail_loc=0x80000711"
1010 # fail abort so client will be new again
1012 client_up || error "reconnect failed"
1015 run_test 29b "error adding new clients doesn't cause LBUG (bug 22273)"
1019 # put a load of file creates/writes/deletes
1020 writemany -q $DIR/$tdir/$tfile 0 5 &
1022 echo writemany pid $CLIENT_PID
1026 # wait for client to reconnect to MDS
1031 # client process should see no problems even though MDS went down
1033 kill -USR1 $CLIENT_PID
1036 echo writemany returned $rc
1037 #these may fail because of eviction due to slow AST response.
1039 error_ignore bz13652 "writemany returned rc $rc" || true
1041 run_test 50 "failover MDS under load"
1044 #define OBD_FAIL_MDS_SYNC_CAPA_SL 0x1310
1045 do_facet ost1 lctl set_param fail_loc=0x00001310
1048 # put a load of file creates/writes/deletes
1049 writemany -q $DIR/$tdir/$tfile 0 5 &
1053 facet_failover $SINGLEMDS
1054 # failover at various points during recovery
1055 SEQ="1 5 10 $(seq $TIMEOUT 5 $(($TIMEOUT+10)))"
1056 echo will failover at $SEQ
1059 #echo failover in $i sec
1060 log "test_$testnum: failover in $i sec"
1062 facet_failover $SINGLEMDS
1064 # client process should see no problems even though MDS went down
1065 # and recovery was interrupted
1067 kill -USR1 $CLIENT_PID
1070 echo writemany returned $rc
1072 error_ignore bz13652 "writemany returned rc $rc" || true
1074 run_test 51 "failover MDS during recovery"
1077 do_facet client "mkdir -p $DIR/$tdir"
1078 do_facet client "writemany -q -a $DIR/$tdir/$tfile 300 5" &
1080 echo writemany pid $CLIENT_PID
1085 wait $CLIENT_PID || rc=$?
1086 # active client process should see an EIO for down OST
1087 [ $rc -eq 5 ] && { echo "writemany correctly failed $rc" && return 0; }
1088 # but timing or failover setup may allow success
1089 [ $rc -eq 0 ] && { echo "writemany succeeded" && return 0; }
1090 echo "writemany returned $rc"
1095 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1100 [ $rc -ne 0 ] && { return $rc; }
1101 # wait for client to reconnect to OST
1105 [ $rc -ne 0 ] && { return $rc; }
1112 run_test 52 "failover OST under load"
1114 # test of open reconstruct
1117 drop_ldlm_reply "openfile -f O_RDWR:O_CREAT -m 0755 $DIR/$tfile" ||\
1120 run_test 53 "touch: drop rep"
1123 zconf_mount `hostname` $MOUNT2
1125 touch $DIR2/$tfile.1
1127 cat $DIR2/$tfile.missing # save transno = 0, rc != 0 into last_rcvd
1130 ERROR=`dmesg | egrep "(test 54|went back in time)" | tail -n1 | grep "went back in time"`
1131 [ x"$ERROR" == x ] || error "back in time occured"
1133 run_test 54 "back in time"
1135 # bug 11330 - liblustre application death during I/O locks up OST
1137 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1141 # Minimum pass speed is 2MBps
1143 # LU-2887/LU-3089 - set min pass speed to 500KBps
1144 [ "$(facet_fstype ost1)" = "zfs" ] && ddtimeout=256
1146 # first dd should be finished quickly
1147 $LFS setstripe -c 1 -i 0 $DIR/$tdir/$tfile-1
1148 dd if=/dev/zero of=$DIR/$tdir/$tfile-1 bs=32M count=4 &
1151 echo "step1: testing ......"
1152 while kill -0 $DDPID 2> /dev/null; do
1154 if [ $count -gt $ddtimeout ]; then
1155 error "dd should be finished!"
1159 echo "(dd_pid=$DDPID, time=$count)successful"
1161 $LFS setstripe -c 1 -i 0 $DIR/$tdir/$tfile-2
1162 #define OBD_FAIL_OST_DROP_REQ 0x21d
1163 do_facet ost1 lctl set_param fail_loc=0x0000021d
1164 # second dd will be never finished
1165 dd if=/dev/zero of=$DIR/$tdir/$tfile-2 bs=32M count=4 &
1168 echo "step2: testing ......"
1169 while [ $count -le $ddtimeout ]; do
1170 if ! kill -0 $DDPID 2> /dev/null; then
1172 error "dd shouldn't be finished! (time=$count)"
1177 echo "(dd_pid=$DDPID, time=$count)successful"
1179 #Recover fail_loc and dd will finish soon
1180 do_facet ost1 lctl set_param fail_loc=0
1182 echo "step3: testing ......"
1183 while kill -0 $DDPID 2> /dev/null; do
1185 if [ $count -gt $((ddtimeout + 440)) ]; then
1186 error "dd should be finished!"
1190 echo "(dd_pid=$DDPID, time=$count)successful"
1194 run_test 55 "ost_brw_read/write drops timed-out read/write request"
1196 test_56() { # b=11277
1197 #define OBD_FAIL_MDS_RESEND 0x136
1199 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000136"
1200 stat $DIR/$tfile || error "stat failed"
1201 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
1204 run_test 56 "do not fail on getattr resend"
1207 # no oscs means no client or mdt
1208 while lctl get_param osc.*.* > /dev/null 2>&1; do
1209 : # loop until proc file is removed
1213 test_57() { # bug 10866
1217 #define OBD_FAIL_LPROC_REMOVE 0xB00
1218 lctl set_param fail_loc=0x80000B00
1219 zconf_umount `hostname` $DIR
1220 lctl set_param fail_loc=0x80000B00
1221 fail_abort $SINGLEMDS
1223 lctl set_param fail_loc=0
1225 do_facet client "df $DIR"
1227 run_test 57 "read procfs entries causes kernel crash"
1229 test_58() { # bug 11546
1230 #define OBD_FAIL_MDC_ENQUEUE_PAUSE 0x801
1233 lctl set_param fail_loc=0x80000801
1234 cp $DIR/$tfile /dev/null &
1237 lctl set_param fail_loc=0
1238 drop_bl_callback_once rm -f $DIR/$tfile
1240 # the first 'df' could tigger the eviction caused by
1241 # 'drop_bl_callback_once', and it's normal case.
1242 # but the next 'df' should return successfully.
1243 do_facet client "df $DIR" || do_facet client "df $DIR"
1245 run_test 58 "Eviction in the middle of open RPC reply processing"
1247 test_59() { # bug 10589
1248 zconf_mount `hostname` $MOUNT2 || error "Failed to mount $MOUNT2"
1249 echo $DIR2 | grep -q $MOUNT2 || error "DIR2 is not set properly: $DIR2"
1250 #define OBD_FAIL_LDLM_CANCEL_EVICT_RACE 0x311
1251 lctl set_param fail_loc=0x311
1252 writes=$(LANG=C dd if=/dev/zero of=$DIR2/$tfile count=1 2>&1)
1253 [ $? = 0 ] || error "dd write failed"
1254 writes=$(echo $writes | awk -F '+' '/out/ {print $1}')
1255 lctl set_param fail_loc=0
1257 zconf_umount `hostname` $MOUNT2 -f
1258 reads=$(LANG=C dd if=$DIR/$tfile of=/dev/null 2>&1)
1259 [ $? = 0 ] || error "dd read failed"
1260 reads=$(echo $reads | awk -F '+' '/in/ {print $1}')
1261 [ "$reads" -eq "$writes" ] || error "read" $reads "blocks, must be" $writes
1263 run_test 59 "Read cancel race on client eviction"
1266 # we assume that all md changes are in the MDT0 changelog
1267 if [ $MDSCOUNT -gt 1 ]; then
1268 error_ignore bz17935 $*
1275 MDT0=$($LCTL get_param -n mdc.*.mds_server_uuid |
1276 awk '{ gsub(/_UUID/,""); print $1 }' | head -n1)
1281 # Register (and start) changelog
1282 USER=$(do_facet $SINGLEMDS lctl --device $MDT0 changelog_register -n)
1283 echo "Registered as $MDT0 changelog user $USER"
1285 # Generate a large number of changelog entries
1286 createmany -o $DIR/$tdir/$tfile $NUM_FILES
1290 # Unlink files in the background
1291 unlinkmany $DIR/$tdir/$tfile $NUM_FILES &
1295 # Failover the MDS while unlinks are happening
1296 facet_failover $SINGLEMDS
1298 # Wait for unlinkmany to finish
1301 # Check if all the create/unlink events were recorded
1303 $LFS changelog $MDT0 >> $DIR/$tdir/changelog
1304 local cl_count=$(grep UNLNK $DIR/$tdir/changelog | wc -l)
1305 echo "$cl_count unlinks in $MDT0 changelog"
1307 do_facet $SINGLEMDS lctl --device $MDT0 changelog_deregister $USER
1308 USERS=$(( $(do_facet $SINGLEMDS lctl get_param -n \
1309 mdd.$MDT0.changelog_users | wc -l) - 2 ))
1310 if [ $USERS -eq 0 ]; then
1311 [ $cl_count -eq $NUM_FILES ] || \
1312 err17935 "Recorded ${cl_count} unlinks out of $NUM_FILES"
1313 # Also make sure we can clear large changelogs
1314 cl_count=$($LFS changelog $FSNAME | wc -l)
1315 [ $cl_count -le 2 ] || \
1316 error "Changelog not empty: $cl_count entries"
1318 # If there are other users, there may be other unlinks in the log
1319 [ $cl_count -ge $NUM_FILES ] || \
1320 err17935 "Recorded ${cl_count} unlinks out of $NUM_FILES"
1321 echo "$USERS other changelog users; can't verify clear"
1324 run_test 60 "Add Changelog entries during MDS failover"
1328 local mdtosc=$(get_mdtosc_proc_path $SINGLEMDS $FSNAME-OST0000)
1329 mdtosc=${mdtosc/-MDT*/-MDT\*}
1330 local cflags="osc.$mdtosc.connect_flags"
1331 do_facet $SINGLEMDS "lctl get_param -n $cflags" |grep -q skip_orphan
1332 [ $? -ne 0 ] && skip "don't have skip orphan feature" && return
1334 mkdir -p $DIR/$tdir || error "mkdir dir $DIR/$tdir failed"
1335 # Set the default stripe of $DIR/$tdir to put the files to ost1
1336 $LFS setstripe -c 1 -i 0 $DIR/$tdir
1338 replay_barrier $SINGLEMDS
1339 createmany -o $DIR/$tdir/$tfile-%d 10
1340 local oid=`do_facet ost1 "lctl get_param -n obdfilter.${ost1_svc}.last_id"`
1342 fail_abort $SINGLEMDS
1344 touch $DIR/$tdir/$tfile
1345 local id=`$LFS getstripe $DIR/$tdir/$tfile | awk '$1 == 0 { print $2 }'`
1346 [ $id -le $oid ] && error "the orphan objid was reused, failed"
1351 run_test 61 "Verify to not reuse orphan objects - bug 17025"
1353 # test_62 as seen it b2_1 please do not reuse test_62
1356 # zconf_umount `hostname` $DIR
1357 # #define OBD_FAIL_PTLRPC_DELAY_IMP_FULL 0x516
1358 # lctl set_param fail_loc=0x516
1361 #run_test 62 "Verify connection flags race - bug LU-1716"
1363 check_cli_ir_state()
1365 local NODE=${1:-$HOSTNAME}
1367 st=$(do_node $NODE "lctl get_param mgc.*.ir_state |
1368 awk '/imperative_recovery:/ { print \\\$2}'")
1369 [ $st != ON -o $st != OFF -o $st != ENABLED -o $st != DISABLED ] ||
1370 error "Error state $st, must be ENABLED or DISABLED"
1374 check_target_ir_state()
1377 local name=${target}_svc
1378 local recovery_proc=obdfilter.${!name}.recovery_status
1381 st=$(do_facet $target "lctl get_param -n $recovery_proc |
1382 awk '/IR:/{ print \\\$2}'")
1383 [ $st != ON -o $st != OFF -o $st != ENABLED -o $st != DISABLED ] ||
1384 error "Error state $st, must be ENABLED or DISABLED"
1390 do_facet mgs lctl set_param -n mgs.MGS.live.$FSNAME="state=$1"
1395 local state=$(do_facet mgs "lctl get_param -n mgs.MGS.live.$FSNAME |
1396 awk '/state:/{ print \\\$2 }'")
1400 nidtbl_version_mgs()
1402 local ver=$(do_facet mgs "lctl get_param -n mgs.MGS.live.$FSNAME |
1403 awk '/nidtbl_version:/{ print \\\$2 }'")
1407 # nidtbl_version_client <mds1|client> [node]
1408 nidtbl_version_client()
1411 local node=${2:-$HOSTNAME}
1413 if [ X$cli = Xclient ]; then
1416 local obdtype=${cli/%[0-9]*/}
1417 [ $obdtype != mds ] && error "wrong parameters $cli"
1419 node=$(facet_active_host $cli)
1424 local vers=$(do_node $node "lctl get_param -n mgc.*.ir_state" |
1425 awk "/$cli/{print \$6}" |sort -u)
1427 # in case there are multiple mounts on the client node
1429 [ ${#arr[@]} -ne 1 ] && error "versions on client node mismatch"
1433 nidtbl_versions_match()
1435 [ $(nidtbl_version_mgs) -eq $(nidtbl_version_client ${1:-client}) ]
1438 target_instance_match()
1444 obdtype=${srv/%[0-9]*/}
1455 error "invalid target type" $srv
1460 local target=${srv}_svc
1461 local si=$(do_facet $srv lctl get_param -n $obdname.${!target}.instance)
1462 local ci=$(lctl get_param -n $cliname.${!target}-${cliname}-*.import |
1463 awk '/instance/{ print $2 }' | head -n1)
1465 return $([ $si -eq $ci ])
1470 do_facet mgs $LCTL list_param mgs.*.ir_timeout ||
1471 { skip "MGS without IR support"; return 0; }
1473 # MDT was just restarted in the previous test, make sure everything
1476 while [ $cnt -gt 0 ]; do
1477 nidtbl_versions_match && break
1483 set_ir_status disabled
1485 local prev_ver=$(nidtbl_version_client client)
1487 local saved_FAILURE_MODE=$FAILURE_MODE
1488 [ $(facet_host mgs) = $(facet_host ost1) ] && FAILURE_MODE="SOFT"
1492 [ $(nidtbl_version_client client) -eq $prev_ver ] ||
1493 error "version must not change due to IR disabled"
1494 target_instance_match ost1 || error "instance mismatch"
1498 FAILURE_MODE=$saved_FAILURE_MODE
1500 run_test 100 "IR: Make sure normal recovery still works w/o IR"
1504 do_facet mgs $LCTL list_param mgs.*.ir_timeout ||
1505 { skip "MGS without IR support"; return 0; }
1509 local OST1_IMP=$(get_osc_import_name client ost1)
1511 # disable pinger recovery
1512 lctl set_param -n osc.$OST1_IMP.pinger_recov=0
1516 target_instance_match ost1 || error "instance mismatch"
1517 nidtbl_versions_match || error "version must match"
1519 lctl set_param -n osc.$OST1_IMP.pinger_recov=1
1521 run_test 101 "IR: Make sure IR works w/o normal recovery"
1525 do_facet mgs $LCTL list_param mgs.*.ir_timeout ||
1526 { skip "MGS without IR support"; return 0; }
1528 local clients=${CLIENTS:-$HOSTNAME}
1535 # let's have a new nidtbl version
1538 # sleep for a while so that clients can see the failure of ost
1539 # it must be MGC_TIMEOUT_MIN_SECONDS + MGC_TIMEOUT_RAND_CENTISEC.
1540 # int mgc_request.c:
1541 # define MGC_TIMEOUT_MIN_SECONDS 5
1542 # define MGC_TIMEOUT_RAND_CENTISEC 0x1ff /* ~500 *
1543 local count=30 # 20 seconds at most
1544 while [ $count -gt 0 ]; do
1545 nidtbl_versions_match && break
1550 nidtbl_versions_match || error "nidtbl mismatch"
1553 old_version=$(nidtbl_version_client client)
1555 zconf_umount_clients $clients $MOUNT || error "Cannot umount client"
1558 combined_mgs_mds && mgsdev=mds1
1559 remount_facet $mgsdev
1562 zconf_mount_clients $clients $MOUNT || error "Cannot mount client"
1565 new_version=$(nidtbl_version_client client)
1566 [ $new_version -lt $old_version ] &&
1567 error "nidtbl version wrong after mgs restarts"
1570 run_test 102 "IR: New client gets updated nidtbl after MGS restart"
1574 do_facet mgs $LCTL list_param mgs.*.ir_timeout ||
1575 { skip "MGS without IR support"; return 0; }
1577 combined_mgs_mds && skip "mgs and mds on the same target" && return 0
1579 # workaround solution to generate config log on the mds
1585 # We need this test because mds is like a client in IR context.
1586 start mds1 $(mdsdevname 1) $MDS_MOUNT_OPTS ||
1587 error "MDS should start w/o mgs"
1589 # start mgs and remount mds w/ ir
1590 start mgs $(mgsdevname) $MGS_MOUNT_OPTS
1593 # remount client so that fsdb will be created on the MGS
1594 umount_client $MOUNT || error "umount failed"
1595 mount_client $MOUNT || error "mount failed"
1597 # sleep 30 seconds so the MDS has a chance to detect MGS restarting
1599 while [ $count -gt 0 ]; do
1600 [ $(nidtbl_version_client mds1) -ne 0 ] && break
1605 # after a while, mds should be able to reconnect to mgs and fetch
1606 # up-to-date nidtbl version
1607 nidtbl_versions_match mds1 || error "mds nidtbl mismatch"
1612 run_test 103 "IR: MDS can start w/o MGS and get updated nidtbl later"
1616 do_facet mgs $LCTL list_param mgs.*.ir_timeout ||
1617 { skip "MGS without IR support"; return 0; }
1622 start ost1 $(ostdevname 1) "$OST_MOUNT_OPTS -onoir" ||
1623 error "OST1 cannot start"
1626 local ir_state=$(check_target_ir_state ost1)
1627 [ $ir_state = "DISABLED" -o $ir_state = "OFF" ] ||
1628 error "ir status on ost1 should be DISABLED"
1630 run_test 104 "IR: ost can disable IR voluntarily"
1634 [ -z "$RCLIENTS" ] && skip "Needs multiple clients" && return 0
1635 do_facet mgs $LCTL list_param mgs.*.ir_timeout ||
1636 { skip "MGS without IR support"; return 0; }
1640 # get one of the clients from client list
1641 local rcli=$(echo $RCLIENTS |cut -d' ' -f 1)
1643 local mount_opts=${MOUNT_OPTS:+$MOUNT_OPTS,}noir
1644 zconf_umount $rcli $MOUNT || error "umount failed"
1645 zconf_mount $rcli $MOUNT $mount_opts || error "mount failed"
1647 # make sure lustre mount at $rcli disabling IR
1648 local ir_state=$(check_cli_ir_state $rcli)
1649 [ $ir_state = "DISABLED" -o $ir_state = "OFF" ] ||
1650 error "IR state must be DISABLED at $rcli"
1652 # Since the client just mounted, its last_rcvd entry is not on disk.
1653 # Send an RPC so exp_need_sync forces last_rcvd to commit this export
1654 # so the client can reconnect during OST recovery (LU-924, LU-1582)
1655 $SETSTRIPE -i 0 $DIR/$tfile
1656 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 conv=sync
1658 # make sure MGS's state is Partial
1659 [ $(get_ir_status) = "partial" ] || error "MGS IR state must be partial"
1662 # make sure IR on ost1 is DISABLED
1663 local ir_state=$(check_target_ir_state ost1)
1664 [ $ir_state = "DISABLED" -o $ir_state = "OFF" ] ||
1665 error "IR status on ost1 should be DISABLED"
1667 # remount with the default MOUNT_OPTS
1668 zconf_umount $rcli $MOUNT || error "umount failed"
1669 zconf_mount $rcli $MOUNT || error "mount failed"
1671 # make sure MGS's state is full
1672 [ $(get_ir_status) = "full" ] || error "MGS IR status must be full"
1675 # make sure IR on ost1 is ENABLED
1676 local ir_state=$(check_target_ir_state ost1)
1677 [ $ir_state = "ENABLED" -o $ir_state = "ON" ] ||
1678 error "IR status on ost1 should be ENABLED"
1682 run_test 105 "IR: NON IR clients support"
1690 test_106() { # LU-1789
1691 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.3.50) ]] ||
1692 { skip "Need MDS version at least 2.3.50"; return 0; }
1694 #define OBD_FAIL_MDC_LIGHTWEIGHT 0x805
1695 $LCTL set_param fail_loc=0x805
1698 trap cleanup_106 EXIT
1700 # enable lightweight flag on mdc connection
1703 local MDS_NEXP=$(do_facet $SINGLEMDS \
1704 lctl get_param -n mdt.${mds1_svc}.num_exports |
1706 $LCTL set_param fail_loc=0
1708 touch $DIR2/$tfile || error "failed to create empty file"
1709 replay_barrier $SINGLEMDS
1711 $LCTL set_param debug=console
1713 facet_failover $SINGLEMDS
1715 # lightweight connection must be evicted
1716 touch -c $DIR2/$tfile || true
1717 $LCTL dk $TMP/lustre-log-$TESTNAME.log
1718 evicted=`awk '/This client was evicted by .*MDT0000/ {
1720 }' $TMP/lustre-log-$TESTNAME.log`
1721 [ -z "$evicted" ] && error "lightweight client not evicted by mds"
1723 # and all operations performed by lightweight client should be
1724 # synchronous, so the file created before mds restart should be there
1725 $CHECKSTAT -t file $DIR/$tfile || error "file not present"
1730 run_test 106 "lightweight connection support"
1737 # OBD_FAIL_MDS_REINT_NET_REP 0x119
1738 do_facet $SINGLEMDS lctl set_param fail_loc=0x119
1739 multiop $DIR/$tdir D_c &
1741 mkdir $DIR/$tdir/dir_106 &
1743 do_facet $SINGLEMDS lctl set_param fail_loc=0
1746 wait $CLIENT_PID || rc=$?
1747 checkstat -t dir $DIR/$tdir/dir_106 || return 1
1749 kill -USR1 $close_pid
1750 wait $close_pid || return 2
1754 run_test 107 "drop reint reply, then restart MDT"
1757 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
1758 local remote_dir=$DIR/$tdir/remote_dir
1762 #prepare for 110 test, which need set striped dir on remote MDT.
1763 for num in $(seq $MDSCOUNT); do
1765 lctl set_param -n mdt.${FSNAME}*.enable_remote_dir=1 \
1770 drop_request "$LFS mkdir -i $MDTIDX -c2 $remote_dir" ||
1771 error "lfs mkdir failed"
1772 local diridx=$($GETSTRIPE -M $remote_dir)
1773 [ $diridx -eq $MDTIDX ] || error "$diridx != $MDTIDX"
1775 rm -rf $DIR/$tdir || error "rmdir failed"
1777 run_test 110a "create remote directory: drop client req"
1780 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
1781 local remote_dir=$DIR/$tdir/remote_dir
1785 drop_reint_reply "$LFS mkdir -i $MDTIDX -c2 $remote_dir" ||
1786 error "lfs mkdir failed"
1788 diridx=$($GETSTRIPE -M $remote_dir)
1789 [ $diridx -eq $MDTIDX ] || error "$diridx != $MDTIDX"
1791 rm -rf $DIR/$tdir || error "rmdir failed"
1793 run_test 110b "create remote directory: drop Master rep"
1796 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
1797 local remote_dir=$DIR/$tdir/remote_dir
1801 drop_update_reply $MDTIDX "$LFS mkdir -i $MDTIDX -c2 $remote_dir" ||
1802 error "lfs mkdir failed"
1804 diridx=$($GETSTRIPE -M $remote_dir)
1805 [ $diridx -eq $MDTIDX ] || error "$diridx != $MDTIDX"
1807 rm -rf $DIR/$tdir || error "rmdir failed"
1809 run_test 110c "create remote directory: drop update rep on slave MDT"
1812 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
1813 local remote_dir=$DIR/$tdir/remote_dir
1817 $LFS mkdir -i $MDTIDX -c2 $remote_dir || error "lfs mkdir failed"
1819 drop_request "rm -rf $remote_dir" || error "rm remote dir failed"
1821 rm -rf $DIR/$tdir || error "rmdir failed"
1825 run_test 110d "remove remote directory: drop client req"
1828 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
1829 local remote_dir=$DIR/$tdir/remote_dir
1833 $LFS mkdir -i $MDTIDX -c2 $remote_dir || error "lfs mkdir failed"
1834 drop_reint_reply "rm -rf $remote_dir" || error "rm remote dir failed"
1836 rm -rf $DIR/$tdir || error "rmdir failed"
1840 run_test 110e "remove remote directory: drop master rep"
1843 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
1844 local remote_dir=$DIR/$tdir/remote_dir
1848 $LFS mkdir -i $MDTIDX -c2 $remote_dir || error "lfs mkdir failed"
1849 drop_update_reply $MDTIDX "rm -rf $remote_dir" ||
1850 error "rm remote dir failed"
1852 rm -rf $DIR/$tdir || error "rmdir failed"
1854 run_test 110f "remove remote directory: drop slave rep"
1857 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
1858 local remote_dir=$DIR/$tdir/remote_dir
1861 mkdir -p $remote_dir
1863 createmany -o $remote_dir/f 100
1865 #define OBD_FAIL_MIGRATE_NET_REP 0x1702
1866 do_facet mds$MDTIDX lctl set_param fail_loc=0x1702
1867 $LFS mv -M $MDTIDX $remote_dir || error "migrate failed"
1868 do_facet mds$MDTIDX lctl set_param fail_loc=0x0
1870 for file in $(find $remote_dir); do
1871 mdt_index=$($LFS getstripe -M $file)
1872 [ $mdt_index == $MDTIDX ] ||
1873 error "$file is not on MDT${MDTIDX}"
1876 rm -rf $DIR/$tdir || error "rmdir failed"
1878 run_test 110g "drop reply during migration"
1880 # LU-2844 mdt prepare fail should not cause umount oops
1883 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.3.62) ]] ||
1884 { skip "Need MDS version at least 2.3.62"; return 0; }
1886 local mdsdev=$(mdsdevname ${SINGLEMDS//mds/})
1887 #define OBD_FAIL_MDS_CHANGELOG_INIT 0x151
1888 do_facet $SINGLEMDS lctl set_param fail_loc=0x151
1889 stop $SINGLEMDS || error "stop MDS failed"
1890 start $SINGLEMDS $mdsdev && error "start MDS should fail"
1891 do_facet $SINGLEMDS lctl set_param fail_loc=0
1892 start $SINGLEMDS $mdsdev || error "start MDS failed"
1894 run_test 111 "mdd setup fail should not cause umount oops"
1898 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1900 do_facet_random_file client $TMP/$tfile 100K ||
1901 error_noexit "Create random file $TMP/$tfile"
1903 pause_bulk "cp $TMP/$tfile $DIR/$tfile" $TIMEOUT ||
1904 error_noexit "Can't pause_bulk copy"
1907 # expect cmp to succeed, client resent bulk
1908 cmp $TMP/$tfile $DIR/$tfile ||
1909 error_noexit "Wrong data has been written"
1911 error_noexit "Can't remove file"
1914 run_test 112a "bulk resend while orignal request is in progress"
1916 # parameters: fail_loc CMD RC
1923 #define OBD_FAIL_LDLM_CP_CB_WAIT2 0x320
1924 #define OBD_FAIL_LDLM_CP_CB_WAIT3 0x321
1925 #define OBD_FAIL_LDLM_CP_CB_WAIT4 0x322
1926 #define OBD_FAIL_LDLM_CP_CB_WAIT5 0x323
1929 echo -n "** FLOCK REPLY vs. EVICTION race, lock $2"
1930 [ "$1" = "CLEANUP" ] &&
1931 fail=0x80000320 && echo ", $1 cp first"
1932 [ "$1" = "REPLY" ] &&
1933 fail=0x80000321 && echo ", $1 cp first"
1934 [ "$1" = "DEADLOCK CLEANUP" ] &&
1935 fail=0x80000322 && echo " DEADLOCK, CLEANUP cp first"
1936 [ "$1" = "DEADLOCK REPLY" ] &&
1937 fail=0x80000323 && echo " DEADLOCK, REPLY cp first"
1939 if [ x"$2" = x"get" ]; then
1940 #for TEST lock, take a conflict in advance
1941 # sleep longer than evictor to not confuse fail_loc: 2+2+4
1942 echo "** Taking conflict **"
1943 flocks_test 5 set read sleep 10 $DIR/$tfile &
1949 $LCTL set_param fail_loc=$fail
1951 flocks_test 5 $2 write $DIR/$tfile &
1955 echo "** Evicting and re-connecting client **"
1960 if [ x"$2" = x"get" ]; then
1967 # check if the return value is allowed
1968 [ $rc -eq $3 ] && rc=0
1970 $LCTL set_param fail_loc=0
1974 # a lock is taken, unlock vs. cleanup_resource() race for destroying
1975 # the ORIGINAL lock.
1980 flocks_test 5 set write sleep 4 $DIR/$tfile &
1984 # let unlock to sleep in CP CB
1985 $LCTL set_param fail_loc=$1
1988 # let cleanup to cleep in CP CB
1996 $LCTL set_param fail_loc=0
2001 flock_is_enabled || { skip "mount w/o flock enabled" && return; }
2004 test_120_reply "CLEANUP" set 5 || error "SET race failed"
2005 test_120_reply "CLEANUP" get 5 || error "GET race failed"
2006 test_120_reply "CLEANUP" unlock 5 || error "UNLOCK race failed"
2008 test_120_reply "REPLY" set 5 || error "SET race failed"
2009 test_120_reply "REPLY" get 5 || error "GET race failed"
2010 test_120_reply "REPLY" unlock 5 || error "UNLOCK race failed"
2013 test_120_reply "DEADLOCK CLEANUP" set 5 || error "DEADLOCK race failed"
2014 test_120_reply "DEADLOCK REPLY" set 35 || error "DEADLOCK race failed"
2016 test_120_destroy 0x320 || error "unlock-cleanup race failed"
2018 run_test 120 "flock race: completion vs. evict"
2021 local BEFORE=$(date +%s)
2024 # modify dir so that next revalidate would not obtain UPDATE lock
2027 # drop 1 reply with UPDATE lock,
2028 # resend should not create 2nd lock on server
2029 mcreate $DIR/$tfile || error "mcreate failed: $?"
2030 drop_ldlm_reply_once "stat $DIR/$tfile" || error "stat failed: $?"
2032 # 2 BL AST will be sent to client, both must find the same lock,
2033 # race them to not get EINVAL for 2nd BL AST
2034 #define OBD_FAIL_LDLM_PAUSE_CANCEL2 0x31f
2035 $LCTL set_param fail_loc=0x8000031f
2037 $LCTL set_param ldlm.namespaces.*.early_lock_cancel=0 > /dev/null
2038 chmod 0777 $DIR/$tfile || error "chmod failed: $?"
2039 $LCTL set_param ldlm.namespaces.*.early_lock_cancel=1 > /dev/null
2041 # let the client reconnect
2043 EVICT=$($LCTL get_param mdc.$FSNAME-MDT*.state |
2044 awk -F"[ [,]" '/EVICTED ]$/ { if (mx<$5) {mx=$5;} } END { print mx }')
2046 [ -z "$EVICT" ] || [[ $EVICT -le $BEFORE ]] || error "eviction happened"
2048 run_test 113 "ldlm enqueue dropped reply should not cause deadlocks"
2051 check_and_cleanup_lustre