7 # This test needs to be run on the client
10 export MULTIOP=${MULTIOP:-multiop}
11 LUSTRE=${LUSTRE:-$(cd $(dirname $0)/..; echo $PWD)}
14 . $LUSTRE/tests/test-framework.sh
16 . ${CONFIG:=$LUSTRE/tests/cfg/$NAME.sh}
18 CHECK_GRANT=${CHECK_GRANT:-"yes"}
19 GRANT_CHECK_LIST=${GRANT_CHECK_LIST:-""}
21 require_dsh_mds || exit 0
24 # bug number for skipped tests:
26 ALWAYS_EXCEPT="$REPLAY_SINGLE_EXCEPT 61d"
27 # UPDATE THE COMMENT ABOVE WITH BUG NUMBERS WHEN CHANGING ALWAYS_EXCEPT!
30 [ "$SLOW" = "no" ] && EXCEPT_SLOW="44b"
32 [ $(facet_fstype $SINGLEMDS) = "zfs" ] &&
33 # bug number for skipped test: LU-1867 LU-3127
34 ALWAYS_EXCEPT="$ALWAYS_EXCEPT 89 73b"
38 check_and_setup_lustre
43 rm -rf $DIR/[df][0-9]* $DIR/f.$TESTSUITE.*
45 # LU-482 Avert LVM and VM inability to flush caches in pre .33 kernels
46 if [ $LINUX_VERSION_CODE -lt $(version_code 2.6.33) ]; then
48 do_facet $SINGLEMDS sync
51 test_0a() { # was test_0
52 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
53 replay_barrier $SINGLEMDS
57 run_test 0a "empty replay"
60 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
62 # this test attempts to trigger a race in the precreation code,
63 # and must run before any other objects are created on the filesystem
65 createmany -o $DIR/$tfile 20 || error "createmany -o $DIR/$tfile failed"
66 unlinkmany $DIR/$tfile 20 || error "unlinkmany $DIR/$tfile failed"
68 run_test 0b "ensure object created after recover exists. (3284)"
71 replay_barrier $SINGLEMDS
74 facet_failover $SINGLEMDS
75 zconf_mount $(hostname) $MOUNT || error "mount fails"
76 client_up || error "post-failover df failed"
77 # file shouldn't exist if replay-barrier works as expected
78 rm $DIR/$tfile && error "File exists and it shouldn't"
81 run_test 0c "check replay-barrier"
84 replay_barrier $SINGLEMDS
86 facet_failover $SINGLEMDS
87 zconf_mount $(hostname) $MOUNT || error "mount fails"
88 client_up || error "post-failover df failed"
90 run_test 0d "expired recovery with no clients"
93 replay_barrier $SINGLEMDS
96 $CHECKSTAT -t file $DIR/$tfile ||
97 error "$CHECKSTAT $DIR/$tfile attribute check failed"
100 run_test 1 "simple create"
103 replay_barrier $SINGLEMDS
106 $CHECKSTAT -t file $DIR/$tfile ||
107 error "$CHECKSTAT $DIR/$tfile attribute check failed"
113 mcreate $DIR/$tfile || error "mcreate $DIR/$tfile failed"
114 replay_barrier $SINGLEMDS
117 $CHECKSTAT -t file $DIR/$tfile ||
118 error "$CHECKSTAT $DIR/$tfile attribute check failed"
124 local file=$DIR/$tfile
125 replay_barrier $SINGLEMDS
127 openfile -f O_DIRECTORY $file
129 $CHECKSTAT -t file $file ||
130 error "$CHECKSTAT $file attribute check failed"
133 run_test 3a "replay failed open(O_DIRECTORY)"
136 replay_barrier $SINGLEMDS
137 #define OBD_FAIL_MDS_OPEN_PACK | OBD_FAIL_ONCE
138 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000114"
140 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
142 $CHECKSTAT -t file $DIR/$tfile &&
143 error "$CHECKSTAT $DIR/$tfile attribute check should fail"
146 run_test 3b "replay failed open -ENOMEM"
149 replay_barrier $SINGLEMDS
150 #define OBD_FAIL_MDS_ALLOC_OBDO | OBD_FAIL_ONCE
151 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000128"
153 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
156 $CHECKSTAT -t file $DIR/$tfile &&
157 error "$CHECKSTAT $DIR/$tfile attribute check should fail"
160 run_test 3c "replay failed open -ENOMEM"
162 test_4a() { # was test_4
163 replay_barrier $SINGLEMDS
164 for i in $(seq 10); do
165 echo "tag-$i" > $DIR/$tfile-$i
168 for i in $(seq 10); do
169 grep -q "tag-$i" $DIR/$tfile-$i || error "$tfile-$i"
172 run_test 4a "|x| 10 open(O_CREAT)s"
175 for i in $(seq 10); do
176 echo "tag-$i" > $DIR/$tfile-$i
178 replay_barrier $SINGLEMDS
181 $CHECKSTAT -t file $DIR/$tfile-* &&
182 error "$CHECKSTAT $DIR/$tfile-* attribute check should fail" ||
185 run_test 4b "|x| rm 10 files"
187 # The idea is to get past the first block of precreated files on both
188 # osts, and then replay.
190 replay_barrier $SINGLEMDS
191 for i in $(seq 220); do
192 echo "tag-$i" > $DIR/$tfile-$i
195 for i in $(seq 220); do
196 grep -q "tag-$i" $DIR/$tfile-$i || error "$tfile-$i"
200 # waiting for commitment of removal
202 run_test 5 "|x| 220 open(O_CREAT)"
204 test_6a() { # was test_6
205 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
206 replay_barrier $SINGLEMDS
207 mcreate $DIR/$tdir/$tfile
209 $CHECKSTAT -t dir $DIR/$tdir ||
210 error "$CHECKSTAT $DIR/$tdir attribute check failed"
211 $CHECKSTAT -t file $DIR/$tdir/$tfile ||
212 error "$CHECKSTAT $DIR/$tdir/$tfile attribute check failed"
214 # waiting for log process thread
216 run_test 6a "mkdir + contained create"
219 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
220 replay_barrier $SINGLEMDS
223 $CHECKSTAT -t dir $DIR/$tdir &&
224 error "$CHECKSTAT $DIR/$tdir attribute check should fail" ||
227 run_test 6b "|X| rmdir"
230 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
231 replay_barrier $SINGLEMDS
232 mcreate $DIR/$tdir/$tfile
234 $CHECKSTAT -t dir $DIR/$tdir ||
235 error "$CHECKSTAT $DIR/$tdir attribute check failed"
236 $CHECKSTAT -t file $DIR/$tdir/$tfile ||
237 error "$CHECKSTAT $DIR/$tdir/$tfile attribute check failed"
240 run_test 7 "mkdir |X| contained create"
243 replay_barrier $SINGLEMDS
244 multiop_bg_pause $DIR/$tfile mo_c ||
245 error "multiop mknod $DIR/$tfile failed"
249 $CHECKSTAT -t file $DIR/$tfile ||
250 error "$CHECKSTAT $DIR/$tfile attribute check failed"
251 kill -USR1 $MULTIPID || error "multiop mknod $MULTIPID not running"
252 wait $MULTIPID || error "multiop mknod $MULTIPID failed"
255 run_test 8 "creat open |X| close"
258 replay_barrier $SINGLEMDS
260 local old_inum=$(ls -i $DIR/$tfile | awk '{print $1}')
262 local new_inum=$(ls -i $DIR/$tfile | awk '{print $1}')
264 echo " old_inum == $old_inum, new_inum == $new_inum"
265 if [ $old_inum -eq $new_inum ] ;
267 echo "old_inum and new_inum match"
269 echo " old_inum and new_inum do not match"
270 error "old index($old_inum) does not match new index($new_inum)"
274 run_test 9 "|X| create (same inum/gen)"
277 mcreate $DIR/$tfile || error "mcreate $DIR/$tfile failed"
278 replay_barrier $SINGLEMDS
279 mv $DIR/$tfile $DIR/$tfile-2
282 $CHECKSTAT $DIR/$tfile &&
283 error "$CHECKSTAT $DIR/$tfile attribute check should fail"
284 $CHECKSTAT $DIR/$tfile-2 ||
285 error "$CHECKSTAT $DIR/$tfile-2 attribute check failed"
289 run_test 10 "create |X| rename unlink"
292 mcreate $DIR/$tfile || error "mcreate $DIR/$tfile failed"
293 echo "old" > $DIR/$tfile
294 mv $DIR/$tfile $DIR/$tfile-2
295 replay_barrier $SINGLEMDS
296 echo "new" > $DIR/$tfile
298 grep old $DIR/$tfile-2
300 grep new $DIR/$tfile || error "grep $DIR/$tfile failed"
301 grep old $DIR/$tfile-2 || error "grep $DIR/$tfile-2 failed"
303 run_test 11 "create open write rename |X| create-old-name read"
306 mcreate $DIR/$tfile || error "mcreate $DIR/$tfile failed"
307 multiop_bg_pause $DIR/$tfile o_tSc ||
308 error "multiop_bg_pause $DIR/$tfile failed"
311 replay_barrier $SINGLEMDS
312 kill -USR1 $pid || error "multiop $pid not running"
313 wait $pid || error "multiop $pid failed"
316 [ -e $DIR/$tfile ] && error "file $DIR/$tfile should not exist"
319 run_test 12 "open, unlink |X| close"
321 # 1777 - replay open after committed chmod that would make
322 # a regular open a failure
324 mcreate $DIR/$tfile || error "mcreate $DIR/$tfile failed"
325 multiop_bg_pause $DIR/$tfile O_wc ||
326 error "multiop_bg_pause $DIR/$tfile failed"
329 $CHECKSTAT -p 0 $DIR/$tfile ||
330 error "$CHECKSTAT $DIR/$tfile attribute check failed"
331 replay_barrier $SINGLEMDS
333 kill -USR1 $pid || error "multiop $pid not running"
334 wait $pid || error "multiop $pid failed"
336 $CHECKSTAT -s 1 -p 0 $DIR/$tfile ||
337 error "second $CHECKSTAT $DIR/$tfile attribute check failed"
338 rm $DIR/$tfile || error "rm $DIR/$tfile failed"
341 run_test 13 "open chmod 0 |x| write close"
344 multiop_bg_pause $DIR/$tfile O_tSc ||
345 error "multiop_bg_pause $DIR/$tfile failed"
348 replay_barrier $SINGLEMDS
349 kill -USR1 $pid || error "multiop $pid not running"
350 wait $pid || error "multiop $pid failed"
353 [ -e $DIR/$tfile ] && error "file $DIR/$tfile should not exist"
356 run_test 14 "open(O_CREAT), unlink |X| close"
359 multiop_bg_pause $DIR/$tfile O_tSc ||
360 error "multiop_bg_pause $DIR/$tfile failed"
363 replay_barrier $SINGLEMDS
364 touch $DIR/$tfile-1 || error "touch $DIR/$tfile-1 failed"
365 kill -USR1 $pid || error "multiop $pid not running"
366 wait $pid || error "multiop $pid failed"
369 [ -e $DIR/$tfile ] && error "file $DIR/$tfile should not exist"
370 touch $DIR/$tfile-2 || error "touch $DIR/$tfile-2 failed"
373 run_test 15 "open(O_CREAT), unlink |X| touch new, close"
376 replay_barrier $SINGLEMDS
379 mcreate $DIR/$tfile-2
381 [ -e $DIR/$tfile ] && error "file $DIR/$tfile should not exist"
382 [ -e $DIR/$tfile-2 ] || error "file $DIR/$tfile-2 does not exist"
383 munlink $DIR/$tfile-2 || error "munlink $DIR/$tfile-2 failed"
385 run_test 16 "|X| open(O_CREAT), unlink, touch new, unlink new"
388 replay_barrier $SINGLEMDS
389 multiop_bg_pause $DIR/$tfile O_c ||
390 error "multiop_bg_pause $DIR/$tfile failed"
393 kill -USR1 $pid || error "multiop $pid not running"
394 wait $pid || error "multiop $pid failed"
395 $CHECKSTAT -t file $DIR/$tfile ||
396 error "$CHECKSTAT $DIR/$tfile attribute check failed"
399 run_test 17 "|X| open(O_CREAT), |replay| close"
402 replay_barrier $SINGLEMDS
403 multiop_bg_pause $DIR/$tfile O_tSc ||
404 error "multiop_bg_pause $DIR/$tfile failed"
407 touch $DIR/$tfile-2 || error "touch $DIR/$tfile-2 failed"
408 echo "pid: $pid will close"
409 kill -USR1 $pid || error "multiop $pid not running"
410 wait $pid || error "multiop $pid failed"
413 [ -e $DIR/$tfile ] && error "file $DIR/$tfile should not exist"
414 [ -e $DIR/$tfile-2 ] || error "file $DIR/$tfile-2 does not exist"
415 # this touch frequently fails
416 touch $DIR/$tfile-3 || error "touch $DIR/$tfile-3 failed"
417 munlink $DIR/$tfile-2 || error "munlink $DIR/$tfile-2 failed"
418 munlink $DIR/$tfile-3 || error "munlink $DIR/$tfile-3 failed"
421 run_test 18 "open(O_CREAT), unlink, touch new, close, touch, unlink"
423 # bug 1855 (a simpler form of test_11 above)
425 replay_barrier $SINGLEMDS
427 echo "old" > $DIR/$tfile
428 mv $DIR/$tfile $DIR/$tfile-2
429 grep old $DIR/$tfile-2
431 grep old $DIR/$tfile-2 || error "grep $DIR/$tfile-2 failed"
433 run_test 19 "mcreate, open, write, rename "
435 test_20a() { # was test_20
436 replay_barrier $SINGLEMDS
437 multiop_bg_pause $DIR/$tfile O_tSc ||
438 error "multiop_bg_pause $DIR/$tfile failed"
443 kill -USR1 $pid || error "multiop $pid not running"
444 wait $pid || error "multiop $pid failed"
445 [ -e $DIR/$tfile ] && error "file $DIR/$tfile should not exist"
448 run_test 20a "|X| open(O_CREAT), unlink, replay, close (test mds_cleanup_orphans)"
450 test_20b() { # bug 10480
451 local wait_timeout=$((TIMEOUT * 4))
455 BEFOREUSED=$(df -P $DIR | tail -1 | awk '{ print $3 }')
456 dd if=/dev/zero of=$DIR/$tfile bs=4k count=10000 &
457 while [ ! -e $DIR/$tfile ] ; do
458 usleep 60 # give dd a chance to start
461 $GETSTRIPE $DIR/$tfile || error "$GETSTRIPE $DIR/$tfile failed"
463 rm -f $DIR/$tfile || error "rm -f $DIR/$tfile failed"
465 client_up || client_up || true # reconnect
467 do_facet $SINGLEMDS "lctl set_param -n osd*.*MDT*.force_sync 1"
469 fail $SINGLEMDS # start orphan recovery
470 wait_recovery_complete $SINGLEMDS || error "MDS recovery not done"
471 wait_delete_completed_mds $wait_timeout ||
472 error "delete did not complete"
474 AFTERUSED=$(df -P $DIR | tail -1 | awk '{ print $3 }')
475 log "before $BEFOREUSED, after $AFTERUSED"
476 (( $AFTERUSED > $BEFOREUSED + $(fs_log_size) )) &&
477 error "after $AFTERUSED > before $BEFOREUSED"
480 run_test 20b "write, unlink, eviction, replay, (test mds_cleanup_orphans)"
482 test_20c() { # bug 10480
483 multiop_bg_pause $DIR/$tfile Ow_c ||
484 error "multiop_bg_pause $DIR/$tfile failed"
490 client_up || client_up || true # reconnect
492 kill -USR1 $pid || error "multiop $pid not running"
493 wait $pid || error "multiop $pid failed"
494 [ -s $DIR/$tfile ] || error "File was truncated"
498 run_test 20c "check that client eviction does not affect file content"
501 replay_barrier $SINGLEMDS
502 multiop_bg_pause $DIR/$tfile O_tSc ||
503 error "multiop_bg_pause $DIR/$tfile failed"
506 touch $DIR/$tfile-1 || error "touch $DIR/$tfile-1 failed"
509 kill -USR1 $pid || error "multiop $pid not running"
510 wait $pid || error "multiop $pid failed"
511 [ -e $DIR/$tfile ] && error "file $DIR/$tfile should not exist"
512 touch $DIR/$tfile-2 || error "touch $DIR/$tfile-2 failed"
515 run_test 21 "|X| open(O_CREAT), unlink touch new, replay, close (test mds_cleanup_orphans)"
518 multiop_bg_pause $DIR/$tfile O_tSc ||
519 error "multiop_bg_pause $DIR/$tfile failed"
522 replay_barrier $SINGLEMDS
526 kill -USR1 $pid || error "multiop $pid not running"
527 wait $pid || error "multiop $pid failed"
528 [ -e $DIR/$tfile ] && error "file $DIR/$tfile should not exist"
531 run_test 22 "open(O_CREAT), |X| unlink, replay, close (test mds_cleanup_orphans)"
534 multiop_bg_pause $DIR/$tfile O_tSc ||
535 error "multiop_bg_pause $DIR/$tfile failed"
538 replay_barrier $SINGLEMDS
540 touch $DIR/$tfile-1 || error "touch $DIR/$tfile-1 failed"
543 kill -USR1 $pid || error "multiop $pid not running"
544 wait $pid || error "multiop $pid failed"
545 [ -e $DIR/$tfile ] && error "file $DIR/$tfile should not exist"
546 touch $DIR/$tfile-2 || error "touch $DIR/$tfile-2 failed"
549 run_test 23 "open(O_CREAT), |X| unlink touch new, replay, close (test mds_cleanup_orphans)"
552 multiop_bg_pause $DIR/$tfile O_tSc ||
553 error "multiop_bg_pause $DIR/$tfile failed"
556 replay_barrier $SINGLEMDS
559 kill -USR1 $pid || error "multiop $pid not running"
560 wait $pid || error "multiop $pid failed"
561 [ -e $DIR/$tfile ] && error "file $DIR/$tfile should not exist"
564 run_test 24 "open(O_CREAT), replay, unlink, close (test mds_cleanup_orphans)"
567 multiop_bg_pause $DIR/$tfile O_tSc ||
568 error "multiop_bg_pause $DIR/$tfile failed"
572 replay_barrier $SINGLEMDS
574 kill -USR1 $pid || error "multiop $pid not running"
575 wait $pid || error "multiop $pid failed"
576 [ -e $DIR/$tfile ] && error "file $DIR/$tfile should not exist"
579 run_test 25 "open(O_CREAT), unlink, replay, close (test mds_cleanup_orphans)"
582 replay_barrier $SINGLEMDS
583 multiop_bg_pause $DIR/$tfile-1 O_tSc ||
584 error "multiop_bg_pause $DIR/$tfile-1 failed"
586 multiop_bg_pause $DIR/$tfile-2 O_tSc ||
587 error "multiop_bg_pause $DIR/$tfile-2 failed"
591 kill -USR1 $pid2 || error "second multiop $pid2 not running"
592 wait $pid2 || error "second multiop $pid2 failed"
595 kill -USR1 $pid1 || error "multiop $pid1 not running"
596 wait $pid1 || error "multiop $pid1 failed"
597 [ -e $DIR/$tfile-1 ] && error "file $DIR/$tfile-1 should not exist"
598 [ -e $DIR/$tfile-2 ] && error "file $DIR/$tfile-2 should not exist"
601 run_test 26 "|X| open(O_CREAT), unlink two, close one, replay, close one (test mds_cleanup_orphans)"
604 replay_barrier $SINGLEMDS
605 multiop_bg_pause $DIR/$tfile-1 O_tSc ||
606 error "multiop_bg_pause $DIR/$tfile-1 failed"
608 multiop_bg_pause $DIR/$tfile-2 O_tSc ||
609 error "multiop_bg_pause $DIR/$tfile-2 failed"
615 kill -USR1 $pid1 || error "multiop $pid1 not running"
616 wait $pid1 || error "multiop $pid1 failed"
617 kill -USR1 $pid2 || error "second multiop $pid2 not running"
618 wait $pid2 || error "second multiop $pid2 failed"
619 [ -e $DIR/$tfile-1 ] && error "file $DIR/$tfile-1 should not exist"
620 [ -e $DIR/$tfile-2 ] && error "file $DIR/$tfile-2 should not exist"
623 run_test 27 "|X| open(O_CREAT), unlink two, replay, close two (test mds_cleanup_orphans)"
626 multiop_bg_pause $DIR/$tfile-1 O_tSc ||
627 error "multiop_bg_pause $DIR/$tfile-1 failed"
629 multiop_bg_pause $DIR/$tfile-2 O_tSc ||
630 error "multiop_bg_pause $DIR/$tfile-2 failed"
632 replay_barrier $SINGLEMDS
635 kill -USR1 $pid2 || error "second multiop $pid2 not running"
636 wait $pid2 || error "second multiop $pid2 failed"
639 kill -USR1 $pid1 || error "multiop $pid1 not running"
640 wait $pid1 || error "multiop $pid1 failed"
641 [ -e $DIR/$tfile-1 ] && error "file $DIR/$tfile-1 should not exist"
642 [ -e $DIR/$tfile-2 ] && error "file $DIR/$tfile-2 should not exist"
645 run_test 28 "open(O_CREAT), |X| unlink two, close one, replay, close one (test mds_cleanup_orphans)"
648 multiop_bg_pause $DIR/$tfile-1 O_tSc ||
649 error "multiop_bg_pause $DIR/$tfile-1 failed"
651 multiop_bg_pause $DIR/$tfile-2 O_tSc ||
652 error "multiop_bg_pause $DIR/$tfile-2 failed"
654 replay_barrier $SINGLEMDS
659 kill -USR1 $pid1 || error "multiop $pid1 not running"
660 wait $pid1 || error "multiop $pid1 failed"
661 kill -USR1 $pid2 || error "second multiop $pid2 not running"
662 wait $pid2 || error "second multiop $pid2 failed"
663 [ -e $DIR/$tfile-1 ] && error "file $DIR/$tfile-1 should not exist"
664 [ -e $DIR/$tfile-2 ] && error "file $DIR/$tfile-2 should not exist"
667 run_test 29 "open(O_CREAT), |X| unlink two, replay, close two (test mds_cleanup_orphans)"
670 multiop_bg_pause $DIR/$tfile-1 O_tSc ||
671 error "multiop_bg_pause $DIR/$tfile-1 failed"
673 multiop_bg_pause $DIR/$tfile-2 O_tSc ||
674 error "multiop_bg_pause $DIR/$tfile-2 failed"
679 replay_barrier $SINGLEMDS
681 kill -USR1 $pid1 || error "multiop $pid1 not running"
682 wait $pid1 || error "multiop $pid1 failed"
683 kill -USR1 $pid2 || error "second multiop $pid2 not running"
684 wait $pid2 || error "second multiop $pid2 failed"
685 [ -e $DIR/$tfile-1 ] && error "file $DIR/$tfile-1 should not exist"
686 [ -e $DIR/$tfile-2 ] && error "file $DIR/$tfile-2 should not exist"
689 run_test 30 "open(O_CREAT) two, unlink two, replay, close two (test mds_cleanup_orphans)"
692 multiop_bg_pause $DIR/$tfile-1 O_tSc ||
693 error "multiop_bg_pause $DIR/$tfile-1 failed"
695 multiop_bg_pause $DIR/$tfile-2 O_tSc ||
696 error "multiop_bg_pause $DIR/$tfile-2 failed"
700 replay_barrier $SINGLEMDS
703 kill -USR1 $pid1 || error "multiop $pid1 not running"
704 wait $pid1 || error "multiop $pid1 failed"
705 kill -USR1 $pid2 || error "second multiop $pid2 not running"
706 wait $pid2 || error "second multiop $pid2 failed"
707 [ -e $DIR/$tfile-1 ] && error "file $DIR/$tfile-1 should not exist"
708 [ -e $DIR/$tfile-2 ] && error "file $DIR/$tfile-2 should not exist"
711 run_test 31 "open(O_CREAT) two, unlink one, |X| unlink one, close two (test mds_cleanup_orphans)"
713 # tests for bug 2104; completion without crashing is success. The close is
714 # stale, but we always return 0 for close, so the app never sees it.
716 multiop_bg_pause $DIR/$tfile O_c ||
717 error "multiop_bg_pause $DIR/$tfile failed"
719 multiop_bg_pause $DIR/$tfile O_c ||
720 error "second multiop_bg_pause $DIR/$tfile failed"
723 client_up || client_up || error "client_up failed"
724 kill -USR1 $pid1 || error "multiop $pid1 not running"
725 kill -USR1 $pid2 || error "second multiop $pid2 not running"
726 wait $pid1 || error "multiop $pid1 failed"
727 wait $pid2 || error "second multiop $pid2 failed"
730 run_test 32 "close() notices client eviction; close() after client eviction"
733 createmany -o $DIR/$tfile-%d 10 ||
734 error "createmany create $DIR/$tfile failed"
735 replay_barrier_nosync $SINGLEMDS
736 fail_abort $SINGLEMDS
737 # recreate shouldn't fail
738 createmany -o $DIR/$tfile--%d 10 ||
739 error "createmany recreate $DIR/$tfile failed"
743 run_test 33a "fid seq shouldn't be reused after abort recovery"
746 #define OBD_FAIL_SEQ_ALLOC 0x1311
747 do_facet $SINGLEMDS "lctl set_param fail_loc=0x1311"
749 createmany -o $DIR/$tfile-%d 10
750 replay_barrier_nosync $SINGLEMDS
751 fail_abort $SINGLEMDS
752 # recreate shouldn't fail
753 createmany -o $DIR/$tfile--%d 10 ||
754 error "createmany recreate $DIR/$tfile failed"
758 run_test 33b "test fid seq allocation"
761 multiop_bg_pause $DIR/$tfile O_c ||
762 error "multiop_bg_pause $DIR/$tfile failed"
766 replay_barrier $SINGLEMDS
767 fail_abort $SINGLEMDS
768 kill -USR1 $pid || error "multiop $pid not running"
769 wait $pid || error "multiop $pid failed"
770 [ -e $DIR/$tfile ] && error "file $DIR/$tfile should not exist"
774 run_test 34 "abort recovery before client does replay (test mds_cleanup_orphans)"
776 # bug 2278 - generate one orphan on OST, then destroy it during recovery from llog
778 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
780 #define OBD_FAIL_MDS_REINT_NET_REP 0x119
781 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000119"
786 # give a chance to remove from MDS
787 fail_abort $SINGLEMDS
788 $CHECKSTAT -t file $DIR/$tfile &&
789 error "$CHECKSTAT $DIR/$tfile attribute check should fail" ||
792 run_test 35 "test recovery from llog for unlink op"
794 # b=2432 resent cancel after replay uses wrong cookie,
795 # so don't resend cancels
797 replay_barrier $SINGLEMDS
799 checkstat $DIR/$tfile
800 facet_failover $SINGLEMDS
802 if dmesg | grep "unknown lock cookie"; then
803 error "cancel after replay failed"
806 run_test 36 "don't resend cancel"
809 # directory orphans can't be unlinked from PENDING directory
811 rmdir $DIR/$tfile 2>/dev/null
812 multiop_bg_pause $DIR/$tfile dD_c ||
813 error "multiop_bg_pause $DIR/$tfile failed"
817 replay_barrier $SINGLEMDS
818 # clear the dmesg buffer so we only see errors from this recovery
819 do_facet $SINGLEMDS dmesg -c >/dev/null
820 fail_abort $SINGLEMDS
821 kill -USR1 $pid || error "multiop $pid not running"
822 do_facet $SINGLEMDS dmesg | grep "error .* unlinking .* from PENDING" &&
823 error "error unlinking files"
824 wait $pid || error "multiop $pid failed"
828 run_test 37 "abort recovery before client does replay (test mds_cleanup_orphans for directories)"
831 createmany -o $DIR/$tfile-%d 800 ||
832 error "createmany -o $DIR/$tfile failed"
833 unlinkmany $DIR/$tfile-%d 0 400 || error "unlinkmany $DIR/$tfile failed"
834 replay_barrier $SINGLEMDS
836 unlinkmany $DIR/$tfile-%d 400 400 ||
837 error "unlinkmany $DIR/$tfile 400 failed"
839 $CHECKSTAT -t file $DIR/$tfile-* &&
840 error "$CHECKSTAT $DIR/$tfile-* attribute check should fail" ||
843 run_test 38 "test recovery from unlink llog (test llog_gen_rec) "
845 test_39() { # bug 4176
846 createmany -o $DIR/$tfile-%d 800 ||
847 error "createmany -o $DIR/$tfile failed"
848 replay_barrier $SINGLEMDS
849 unlinkmany $DIR/$tfile-%d 0 400
851 unlinkmany $DIR/$tfile-%d 400 400 ||
852 error "unlinkmany $DIR/$tfile 400 failed"
854 $CHECKSTAT -t file $DIR/$tfile-* &&
855 error "$CHECKSTAT $DIR/$tfile-* attribute check should fail" ||
858 run_test 39 "test recovery from unlink llog (test llog_gen_rec) "
861 lctl get_param -n osc.*.stats | awk -vwrites=0 '/ost_write/ { writes += $2 } END { print writes; }'
866 # always need connection to MDS to verify layout during IO. LU-2628.
867 lctl get_param mdc.*.connect_flags | grep -q layout_lock &&
868 skip "layout_lock needs MDS connection for IO" && return 0
870 $LCTL mark multiop $MOUNT/$tfile OS_c
871 multiop $MOUNT/$tfile OS_c &
873 writeme -s $MOUNT/${tfile}-2 &
876 facet_failover $SINGLEMDS
877 #define OBD_FAIL_MDS_CONNECT_NET 0x117
878 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000117"
880 stat1=$(count_ost_writes)
882 stat2=$(count_ost_writes)
883 echo "$stat1, $stat2"
884 if [ $stat1 -lt $stat2 ]; then
885 echo "writes continuing during recovery"
888 echo "writes not continuing during recovery, bug 2477"
891 echo "waiting for writeme $WRITE_PID"
895 echo "waiting for multiop $PID"
896 wait $PID || error "multiop $PID failed"
897 do_facet client munlink $MOUNT/$tfile ||
898 error "munlink $MOUNT/$tfile failed"
899 do_facet client munlink $MOUNT/${tfile}-2 ||
900 error "munlink $MOUNT/$tfile-2 failed"
903 run_test 40 "cause recovery in ptlrpc, ensure IO continues"
906 # make sure that a read to one osc doesn't try to double-unlock its page just
907 # because another osc is invalid. trigger_group_io used to mistakenly return
908 # an error if any oscs were invalid even after having successfully put rpcs
909 # on valid oscs. This was fatal if the caller was ll_readpage who unlocked
910 # the page, guarnateeing that the unlock from the RPC completion would
911 # assert on trying to unlock the unlocked page.
913 [ $OSTCOUNT -lt 2 ] &&
914 skip_env "skipping test 41: we don't have a second OST to test with" &&
917 local f=$MOUNT/$tfile
918 # make sure the start of the file is ost1
919 $SETSTRIPE -S $((128 * 1024)) -i 0 $f
920 do_facet client dd if=/dev/zero of=$f bs=4k count=1 ||
921 error "dd on client failed"
923 # fail ost2 and read from ost1
924 local mdtosc=$(get_mdtosc_proc_path $SINGLEMDS $ost2_svc)
925 local osc2dev=$(do_facet $SINGLEMDS "lctl get_param -n devices" |
926 grep $mdtosc | awk '{print $1}')
927 [ -z "$osc2dev" ] && echo "OST: $ost2_svc" &&
928 lctl get_param -n devices &&
929 error "OST 2 $osc2dev does not exist"
930 do_facet $SINGLEMDS $LCTL --device $osc2dev deactivate ||
931 error "deactive device on $SINGLEMDS failed"
932 do_facet client dd if=$f of=/dev/null bs=4k count=1 ||
933 error "second dd on client failed"
934 do_facet $SINGLEMDS $LCTL --device $osc2dev activate ||
935 error "active device on $SINGLEMDS failed"
938 run_test 41 "read from a valid osc while other oscs are invalid"
940 # test MDS recovery after ost failure
942 blocks=$(df -P $MOUNT | tail -n 1 | awk '{ print $2 }')
943 createmany -o $DIR/$tfile-%d 800 ||
944 error "createmany -o $DIR/$tfile failed"
946 unlinkmany $DIR/$tfile-%d 0 400
948 lctl set_param debug=-1
951 # osc is evicted, fs is smaller (but only with failout OSTs (bug 7287)
952 #blocks_after=`df -P $MOUNT | tail -n 1 | awk '{ print $2 }'`
953 #[ $blocks_after -lt $blocks ] || return 1
954 echo "wait for MDS to timeout and recover"
955 sleep $((TIMEOUT * 2))
957 unlinkmany $DIR/$tfile-%d 400 400 ||
958 error "unlinkmany $DIR/$tfile 400 failed"
959 $CHECKSTAT -t file $DIR/$tfile-* &&
960 error "$CHECKSTAT $DIR/$tfile-* attribute check should fail" ||
963 run_test 42 "recovery after ost failure"
965 # timeout in MDS/OST recovery RPC will LBUG MDS
966 test_43() { # bug 2530
967 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
969 replay_barrier $SINGLEMDS
971 # OBD_FAIL_OST_CREATE_NET 0x204
972 do_facet ost1 "lctl set_param fail_loc=0x80000204"
978 run_test 43 "mds osc import failure during recovery; don't LBUG"
980 test_44a() { # was test_44
983 local mdcdev=$($LCTL dl |
984 awk "/${FSNAME}-MDT0000-mdc-/ {if (\$2 == \"UP\") {print \$1}}")
985 [ "$mdcdev" ] || error "${FSNAME}-MDT0000-mdc- not UP"
986 [ $(echo $mdcdev | wc -w) -eq 1 ] ||
987 { $LCTL dl; error "looking for mdcdev=$mdcdev"; }
989 # adaptive timeouts slow this way down
990 if at_is_enabled; then
991 at_max_saved=$(at_max_get mds)
995 for i in $(seq 1 10); do
996 echo "$i of 10 ($(date +%s))"
997 do_facet $SINGLEMDS \
998 "lctl get_param -n md[ts].*.mdt.timeouts | grep service"
999 #define OBD_FAIL_TGT_CONN_RACE 0x701
1000 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000701"
1001 # lctl below may fail, it is valid case
1002 $LCTL --device $mdcdev recover
1005 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
1006 [ $at_max_saved -ne 0 ] && at_max_set $at_max_saved mds
1009 run_test 44a "race in target handle connect"
1012 local mdcdev=$($LCTL dl |
1013 awk "/${FSNAME}-MDT0000-mdc-/ {if (\$2 == \"UP\") {print \$1}}")
1014 [ "$mdcdev" ] || error "${FSNAME}-MDT0000-mdc not up"
1015 [ $(echo $mdcdev | wc -w) -eq 1 ] ||
1016 { echo mdcdev=$mdcdev; $LCTL dl;
1017 error "more than one ${FSNAME}-MDT0000-mdc"; }
1019 for i in $(seq 1 10); do
1020 echo "$i of 10 ($(date +%s))"
1021 do_facet $SINGLEMDS \
1022 "lctl get_param -n md[ts].*.mdt.timeouts | grep service"
1023 #define OBD_FAIL_TGT_DELAY_RECONNECT 0x704
1024 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000704"
1025 # lctl below may fail, it is valid case
1026 $LCTL --device $mdcdev recover
1031 run_test 44b "race in target handle connect"
1034 replay_barrier $SINGLEMDS
1035 createmany -m $DIR/$tfile-%d 100 || error "failed to create directories"
1036 #define OBD_FAIL_TGT_RCVG_FLAG 0x712
1037 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000712"
1038 fail_abort $SINGLEMDS
1039 unlinkmany $DIR/$tfile-%d 100 && error "unliked after fail abort"
1041 unlinkmany $DIR/$tfile-%d 100 && error "unliked after fail"
1044 run_test 44c "race in target handle connect"
1046 # Handle failed close
1048 local mdcdev=$($LCTL get_param -n devices |
1049 awk "/ ${FSNAME}-MDT0000-mdc-/ {print \$1}")
1050 [ "$mdcdev" ] || error "${FSNAME}-MDT0000-mdc not up"
1051 [ $(echo $mdcdev | wc -w) -eq 1 ] ||
1052 { echo mdcdev=$mdcdev; $LCTL dl;
1053 error "more than one ${FSNAME}-MDT0000-mdc"; }
1055 $LCTL --device $mdcdev recover ||
1056 error "$LCTL --device $mdcdev recover failed"
1058 multiop_bg_pause $DIR/$tfile O_c ||
1059 error "multiop_bg_pause $DIR/$tfile failed"
1062 # This will cause the CLOSE to fail before even
1063 # allocating a reply buffer
1064 $LCTL --device $mdcdev deactivate ||
1065 error "$LCTL --device $mdcdev deactivate failed"
1068 kill -USR1 $pid || error "multiop $pid not running"
1069 wait $pid || error "multiop $pid failed"
1071 $LCTL --device $mdcdev activate ||
1072 error "$LCTL --device $mdcdev activate failed"
1075 $CHECKSTAT -t file $DIR/$tfile ||
1076 error "$CHECKSTAT $DIR/$tfile attribute check failed"
1079 run_test 45 "Handle failed close"
1083 drop_reply "touch $DIR/$tfile"
1085 # ironically, the previous test, 45, will cause a real forced close,
1086 # so just look for one for this test
1087 dmesg | grep -i "force closing client file handle for $tfile" &&
1088 error "found force closing in dmesg"
1091 run_test 46 "Don't leak file handle after open resend (3325)"
1093 test_47() { # bug 2824
1094 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1096 # create some files to make sure precreate has been done on all
1097 # OSTs. (just in case this test is run independently)
1098 createmany -o $DIR/$tfile 20 ||
1099 error "createmany create $DIR/$tfile failed"
1101 # OBD_FAIL_OST_CREATE_NET 0x204
1103 do_facet ost1 "lctl set_param fail_loc=0x80000204"
1104 client_up || error "client_up failed"
1106 # let the MDS discover the OST failure, attempt to recover, fail
1107 # and recover again.
1108 sleep $((3 * TIMEOUT))
1110 # Without 2824, this createmany would hang
1111 createmany -o $DIR/$tfile 20 ||
1112 error "createmany recraete $DIR/$tfile failed"
1113 unlinkmany $DIR/$tfile 20 || error "unlinkmany $DIR/$tfile failed"
1117 run_test 47 "MDS->OSC failure during precreate cleanup (2824)"
1120 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1121 [ "$OSTCOUNT" -lt "2" ] &&
1122 skip_env "$OSTCOUNT < 2 OSTs -- skipping" && return
1124 replay_barrier $SINGLEMDS
1125 createmany -o $DIR/$tfile 20 ||
1126 error "createmany -o $DIR/$tfile failed"
1127 # OBD_FAIL_OST_EROFS 0x216
1128 facet_failover $SINGLEMDS
1129 do_facet ost1 "lctl set_param fail_loc=0x80000216"
1130 client_up || error "client_up failed"
1132 createmany -o $DIR/$tfile 20 20 ||
1133 error "createmany recraete $DIR/$tfile failed"
1134 unlinkmany $DIR/$tfile 40 || error "unlinkmany $DIR/$tfile failed"
1137 run_test 48 "MDS->OSC failure during precreate cleanup (2824)"
1140 local mdtosc=$(get_mdtosc_proc_path $SINGLEMDS $ost1_svc)
1141 local oscdev=$(do_facet $SINGLEMDS "lctl get_param -n devices" |
1142 grep $mdtosc | awk '{print $1}')
1143 [ "$oscdev" ] || error "could not find OSC device on MDS"
1144 do_facet $SINGLEMDS $LCTL --device $oscdev recover ||
1145 error "OSC device $oscdev recovery failed"
1146 do_facet $SINGLEMDS $LCTL --device $oscdev recover ||
1147 error "second OSC device $oscdev recovery failed"
1148 # give the mds_lov_sync threads a chance to run
1151 run_test 50 "Double OSC recovery, don't LASSERT (3812)"
1153 # b3764 timed out lock replay
1155 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.6.90) ] &&
1156 skip "MDS prior to 2.6.90 handle LDLM_REPLY_NET incorrectly" &&
1159 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
1160 cancel_lru_locks mdc
1162 multiop_bg_pause $DIR/$tfile s_s || error "multiop $DIR/$tfile failed"
1165 #define OBD_FAIL_MDS_LDLM_REPLY_NET 0x157
1166 lctl set_param -n ldlm.cancel_unused_locks_before_replay "0"
1167 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000157"
1169 fail $SINGLEMDS || error "fail $SINGLEMDS failed"
1171 wait $mpid || error "multiop_bg_pause pid failed"
1173 do_facet $SINGLEMDS "lctl set_param fail_loc=0x0"
1174 lctl set_param fail_loc=0x0
1175 lctl set_param -n ldlm.cancel_unused_locks_before_replay "1"
1178 run_test 52 "time out lock replay (3764)"
1180 # bug 3462 - simultaneous MDC requests
1182 [[ $(lctl get_param mdc.*.import |
1183 grep "connect_flags:.*multi_mod_rpc") ]] ||
1184 { skip "Need MDC with 'multi_mod_rpcs' feature"; return 0; }
1186 cancel_lru_locks mdc # cleanup locks from former test cases
1187 mkdir $DIR/${tdir}-1 || error "mkdir $DIR/${tdir}-1 failed"
1188 mkdir $DIR/${tdir}-2 || error "mkdir $DIR/${tdir}-2 failed"
1189 multiop $DIR/${tdir}-1/f O_c &
1191 # give multiop a change to open
1194 #define OBD_FAIL_MDS_CLOSE_NET 0x115
1195 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000115"
1196 kill -USR1 $close_pid
1197 cancel_lru_locks mdc # force the close
1198 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
1200 mcreate $DIR/${tdir}-2/f || error "mcreate $DIR/${tdir}-2/f failed"
1202 # close should still be here
1203 [ -d /proc/$close_pid ] || error "close_pid doesn't exist"
1205 replay_barrier_nodf $SINGLEMDS
1207 wait $close_pid || error "close_pid $close_pid failed"
1209 $CHECKSTAT -t file $DIR/${tdir}-1/f ||
1210 error "$CHECKSTAT $DIR/${tdir}-1/f attribute check failed"
1211 $CHECKSTAT -t file $DIR/${tdir}-2/f ||
1212 error "$CHECKSTAT $DIR/${tdir}-2/f attribute check failed"
1213 rm -rf $DIR/${tdir}-*
1215 run_test 53a "|X| close request while two MDC requests in flight"
1218 cancel_lru_locks mdc # cleanup locks from former test cases
1220 mkdir $DIR/${tdir}-1 || error "mkdir $DIR/${tdir}-1 failed"
1221 mkdir $DIR/${tdir}-2 || error "mkdir $DIR/${tdir}-2 failed"
1222 multiop_bg_pause $DIR/${tdir}-1/f O_c ||
1223 error "multiop_bg_pause $DIR/${tdir}-1/f failed"
1226 #define OBD_FAIL_MDS_REINT_NET 0x107
1227 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000107"
1228 mcreate $DIR/${tdir}-2/f &
1232 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
1233 kill -USR1 $close_pid
1234 cancel_lru_locks mdc # force the close
1235 wait $close_pid || error "close_pid $close_pid failed"
1236 # open should still be here
1237 [ -d /proc/$open_pid ] || error "open_pid doesn't exist"
1239 replay_barrier_nodf $SINGLEMDS
1241 wait $open_pid || error "open_pid failed"
1243 $CHECKSTAT -t file $DIR/${tdir}-1/f ||
1244 error "$CHECKSTAT $DIR/${tdir}-1/f attribute check failed"
1245 $CHECKSTAT -t file $DIR/${tdir}-2/f ||
1246 error "$CHECKSTAT $DIR/${tdir}-2/f attribute check failed"
1247 rm -rf $DIR/${tdir}-*
1249 run_test 53b "|X| open request while two MDC requests in flight"
1252 cancel_lru_locks mdc # cleanup locks from former test cases
1254 mkdir $DIR/${tdir}-1 || error "mkdir $DIR/${tdir}-1 failed"
1255 mkdir $DIR/${tdir}-2 || error "mkdir $DIR/${tdir}-2 failed"
1256 multiop $DIR/${tdir}-1/f O_c &
1259 #define OBD_FAIL_MDS_REINT_NET 0x107
1260 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000107"
1261 mcreate $DIR/${tdir}-2/f &
1265 #define OBD_FAIL_MDS_CLOSE_NET 0x115
1266 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000115"
1267 kill -USR1 $close_pid
1268 cancel_lru_locks mdc # force the close
1270 #bz20647: make sure all pids exist before failover
1271 [ -d /proc/$close_pid ] || error "close_pid doesn't exist"
1272 [ -d /proc/$open_pid ] || error "open_pid doesn't exists"
1273 replay_barrier_nodf $SINGLEMDS
1274 fail_nodf $SINGLEMDS
1275 wait $open_pid || error "open_pid failed"
1277 # close should be gone
1278 [ -d /proc/$close_pid ] && error "close_pid should not exist"
1279 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
1281 $CHECKSTAT -t file $DIR/${tdir}-1/f ||
1282 error "$CHECKSTAT $DIR/${tdir}-1/f attribute check failed"
1283 $CHECKSTAT -t file $DIR/${tdir}-2/f ||
1284 error "$CHECKSTAT $DIR/${tdir}-2/f attribute check failed"
1285 rm -rf $DIR/${tdir}-*
1287 run_test 53c "|X| open request and close request while two MDC requests in flight"
1290 [[ $(lctl get_param mdc.*.import |
1291 grep "connect_flags:.*multi_mod_rpc") ]] ||
1292 { skip "Need MDC with 'multi_mod_rpcs' feature"; return 0; }
1294 cancel_lru_locks mdc # cleanup locks from former test cases
1296 mkdir $DIR/${tdir}-1 || error "mkdir $DIR/${tdir}-1 failed"
1297 mkdir $DIR/${tdir}-2 || error "mkdir $DIR/${tdir}-2 failed"
1298 multiop $DIR/${tdir}-1/f O_c &
1300 # give multiop a chance to open
1303 #define OBD_FAIL_MDS_CLOSE_NET_REP 0x13b
1304 do_facet $SINGLEMDS "lctl set_param fail_loc=0x8000013b"
1305 kill -USR1 $close_pid
1306 cancel_lru_locks mdc # force the close
1307 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
1308 mcreate $DIR/${tdir}-2/f || error "mcreate $DIR/${tdir}-2/f failed"
1310 # close should still be here
1311 [ -d /proc/$close_pid ] || error "close_pid doesn't exist"
1313 wait $close_pid || error "close_pid failed"
1315 $CHECKSTAT -t file $DIR/${tdir}-1/f ||
1316 error "$CHECKSTAT $DIR/${tdir}-1/f attribute check failed"
1317 $CHECKSTAT -t file $DIR/${tdir}-2/f ||
1318 error "$CHECKSTAT $DIR/${tdir}-2/f attribute check failed"
1319 rm -rf $DIR/${tdir}-*
1321 run_test 53d "close reply while two MDC requests in flight"
1324 cancel_lru_locks mdc # cleanup locks from former test cases
1326 mkdir $DIR/${tdir}-1 || error "mkdir $DIR/${tdir}-1 failed"
1327 mkdir $DIR/${tdir}-2 || error "mkdir $DIR/${tdir}-2 failed"
1328 multiop $DIR/${tdir}-1/f O_c &
1331 #define OBD_FAIL_MDS_REINT_NET_REP 0x119
1332 do_facet $SINGLEMDS "lctl set_param fail_loc=0x119"
1333 mcreate $DIR/${tdir}-2/f &
1337 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
1338 kill -USR1 $close_pid
1339 cancel_lru_locks mdc # force the close
1340 wait $close_pid || error "close_pid failed"
1341 # open should still be here
1342 [ -d /proc/$open_pid ] || error "open_pid doesn't exists"
1344 replay_barrier_nodf $SINGLEMDS
1346 wait $open_pid || error "open_pid failed"
1348 $CHECKSTAT -t file $DIR/${tdir}-1/f ||
1349 error "$CHECKSTAT $DIR/${tdir}-1/f attribute check failed"
1350 $CHECKSTAT -t file $DIR/${tdir}-2/f ||
1351 error "$CHECKSTAT $DIR/${tdir}-2/f attribute check failed"
1352 rm -rf $DIR/${tdir}-*
1354 run_test 53e "|X| open reply while two MDC requests in flight"
1357 cancel_lru_locks mdc # cleanup locks from former test cases
1359 mkdir $DIR/${tdir}-1 || error "mkdir $DIR/${tdir}-1 failed"
1360 mkdir $DIR/${tdir}-2 || error "mkdir $DIR/${tdir}-2 failed"
1361 multiop $DIR/${tdir}-1/f O_c &
1364 #define OBD_FAIL_MDS_REINT_NET_REP 0x119
1365 do_facet $SINGLEMDS "lctl set_param fail_loc=0x119"
1366 mcreate $DIR/${tdir}-2/f &
1370 #define OBD_FAIL_MDS_CLOSE_NET_REP 0x13b
1371 do_facet $SINGLEMDS "lctl set_param fail_loc=0x8000013b"
1372 kill -USR1 $close_pid
1373 cancel_lru_locks mdc # force the close
1375 #bz20647: make sure all pids are exists before failover
1376 [ -d /proc/$close_pid ] || error "close_pid doesn't exist"
1377 [ -d /proc/$open_pid ] || error "open_pid doesn't exists"
1378 replay_barrier_nodf $SINGLEMDS
1379 fail_nodf $SINGLEMDS
1380 wait $open_pid || error "open_pid failed"
1382 # close should be gone
1383 [ -d /proc/$close_pid ] && error "close_pid should not exist"
1384 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
1386 $CHECKSTAT -t file $DIR/${tdir}-1/f ||
1387 error "$CHECKSTAT $DIR/${tdir}-1/f attribute check failed"
1388 $CHECKSTAT -t file $DIR/${tdir}-2/f ||
1389 error "$CHECKSTAT $DIR/${tdir}-2/f attribute check failed"
1390 rm -rf $DIR/${tdir}-*
1392 run_test 53f "|X| open reply and close reply while two MDC requests in flight"
1395 cancel_lru_locks mdc # cleanup locks from former test cases
1397 mkdir $DIR/${tdir}-1 || error "mkdir $DIR/${tdir}-1 failed"
1398 mkdir $DIR/${tdir}-2 || error "mkdir $DIR/${tdir}-2 failed"
1399 multiop $DIR/${tdir}-1/f O_c &
1402 #define OBD_FAIL_MDS_REINT_NET_REP 0x119
1403 do_facet $SINGLEMDS "lctl set_param fail_loc=0x119"
1404 mcreate $DIR/${tdir}-2/f &
1408 #define OBD_FAIL_MDS_CLOSE_NET 0x115
1409 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000115"
1410 kill -USR1 $close_pid
1411 cancel_lru_locks mdc # force the close
1412 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
1414 #bz20647: make sure all pids are exists before failover
1415 [ -d /proc/$close_pid ] || error "close_pid doesn't exist"
1416 [ -d /proc/$open_pid ] || error "open_pid doesn't exists"
1417 replay_barrier_nodf $SINGLEMDS
1418 fail_nodf $SINGLEMDS
1419 wait $open_pid || error "open_pid failed"
1421 # close should be gone
1422 [ -d /proc/$close_pid ] && error "close_pid should not exist"
1424 $CHECKSTAT -t file $DIR/${tdir}-1/f ||
1425 error "$CHECKSTAT $DIR/${tdir}-1/f attribute check failed"
1426 $CHECKSTAT -t file $DIR/${tdir}-2/f ||
1427 error "$CHECKSTAT $DIR/${tdir}-2/f attribute check failed"
1428 rm -rf $DIR/${tdir}-*
1430 run_test 53g "|X| drop open reply and close request while close and open are both in flight"
1433 cancel_lru_locks mdc # cleanup locks from former test cases
1435 mkdir $DIR/${tdir}-1 || error "mkdir $DIR/${tdir}-1 failed"
1436 mkdir $DIR/${tdir}-2 || error "mkdir $DIR/${tdir}-2 failed"
1437 multiop $DIR/${tdir}-1/f O_c &
1440 #define OBD_FAIL_MDS_REINT_NET 0x107
1441 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000107"
1442 mcreate $DIR/${tdir}-2/f &
1446 #define OBD_FAIL_MDS_CLOSE_NET_REP 0x13b
1447 do_facet $SINGLEMDS "lctl set_param fail_loc=0x8000013b"
1448 kill -USR1 $close_pid
1449 cancel_lru_locks mdc # force the close
1452 #bz20647: make sure all pids are exists before failover
1453 [ -d /proc/$close_pid ] || error "close_pid doesn't exist"
1454 [ -d /proc/$open_pid ] || error "open_pid doesn't exists"
1455 replay_barrier_nodf $SINGLEMDS
1456 fail_nodf $SINGLEMDS
1457 wait $open_pid || error "open_pid failed"
1459 # close should be gone
1460 [ -d /proc/$close_pid ] && error "close_pid should not exist"
1461 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
1463 $CHECKSTAT -t file $DIR/${tdir}-1/f ||
1464 error "$CHECKSTAT $DIR/${tdir}-1/f attribute check failed"
1465 $CHECKSTAT -t file $DIR/${tdir}-2/f ||
1466 error "$CHECKSTAT $DIR/${tdir}-2/f attribute check failed"
1467 rm -rf $DIR/${tdir}-*
1469 run_test 53h "open request and close reply while two MDC requests in flight"
1471 #b3761 ASSERTION(hash != 0) failed
1473 # OBD_FAIL_MDS_OPEN_CREATE | OBD_FAIL_ONCE
1474 do_facet $SINGLEMDS "lctl set_param fail_loc=0x8000012b"
1476 # give touch a chance to run
1478 do_facet $SINGLEMDS "lctl set_param fail_loc=0x0"
1482 run_test 55 "let MDS_CHECK_RESENT return the original return code instead of 0"
1484 #b3440 ASSERTION(rec->ur_fid2->id) failed
1486 ln -s foo $DIR/$tfile
1487 replay_barrier $SINGLEMDS
1488 #drop_reply "cat $DIR/$tfile"
1492 run_test 56 "don't replay a symlink open request (3440)"
1494 #recovery one mds-ost setattr from llog
1496 #define OBD_FAIL_MDS_OST_SETATTR 0x12c
1497 do_facet $SINGLEMDS "lctl set_param fail_loc=0x8000012c"
1498 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
1499 replay_barrier $SINGLEMDS
1502 $CHECKSTAT -t file $DIR/$tfile ||
1503 error "$CHECKSTAT $DIR/$tfile attribute check failed"
1504 do_facet $SINGLEMDS "lctl set_param fail_loc=0x0"
1507 run_test 57 "test recovery from llog for setattr op"
1510 zconf_umount $(hostname) $MOUNT2
1514 #recovery many mds-ost setattr from llog
1516 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
1517 #define OBD_FAIL_MDS_OST_SETATTR 0x12c
1518 do_facet $SINGLEMDS "lctl set_param fail_loc=0x8000012c"
1519 createmany -o $DIR/$tdir/$tfile-%d 2500
1520 replay_barrier $SINGLEMDS
1523 $CHECKSTAT -t file $DIR/$tdir/$tfile-* >/dev/null ||
1524 error "$CHECKSTAT $DIR/$tfile-* attribute check failed"
1525 do_facet $SINGLEMDS "lctl set_param fail_loc=0x0"
1526 unlinkmany $DIR/$tdir/$tfile-%d 2500 ||
1527 error "unlinkmany $DIR/$tfile failed"
1530 run_test 58a "test recovery from llog for setattr op (test llog_gen_rec)"
1536 trap cleanup_58 EXIT
1538 large_xattr_enabled &&
1539 orig="$(generate_string $(max_xattr_size))" || orig="bar"
1540 # Original extended attribute can be long. Print a small version of
1541 # attribute if an error occurs
1542 local sm_msg=$(printf "%.9s" $orig)
1544 mount_client $MOUNT2 || error "mount_client on $MOUNT2 failed"
1545 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
1546 touch $DIR/$tdir/$tfile || error "touch $DIR/$tdir/$tfile failed"
1547 replay_barrier $SINGLEMDS
1548 setfattr -n trusted.foo -v $orig $DIR/$tdir/$tfile
1550 new=$(get_xattr_value trusted.foo $MOUNT2/$tdir/$tfile)
1551 [[ "$new" = "$orig" ]] ||
1552 error "xattr set ($sm_msg...) differs from xattr get ($new)"
1553 rm -f $DIR/$tdir/$tfile
1556 wait_clients_import_state ${CLIENTS:-$HOSTNAME} "mgs" FULL
1558 run_test 58b "test replay of setxattr op"
1560 test_58c() { # bug 16570
1565 trap cleanup_58 EXIT
1567 if large_xattr_enabled; then
1568 local xattr_size=$(max_xattr_size)
1569 orig="$(generate_string $((xattr_size / 2)))"
1570 orig1="$(generate_string $xattr_size)"
1576 # PING_INTERVAL max(obd_timeout / 4, 1U)
1577 sleep $((TIMEOUT / 4))
1579 # Original extended attribute can be long. Print a small version of
1580 # attribute if an error occurs
1581 local sm_msg=$(printf "%.9s" $orig)
1582 local sm_msg1=$(printf "%.9s" $orig1)
1584 mount_client $MOUNT2 || error "mount_client on $MOUNT2 failed"
1585 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
1586 touch $DIR/$tdir/$tfile || error "touch $DIR/$tdir/$tfile failed"
1587 drop_request "setfattr -n trusted.foo -v $orig $DIR/$tdir/$tfile" ||
1588 error "drop_request for setfattr failed"
1589 new=$(get_xattr_value trusted.foo $MOUNT2/$tdir/$tfile)
1590 [[ "$new" = "$orig" ]] ||
1591 error "xattr set ($sm_msg...) differs from xattr get ($new)"
1592 drop_reint_reply "setfattr -n trusted.foo1 \
1593 -v $orig1 $DIR/$tdir/$tfile" ||
1594 error "drop_reint_reply for setfattr failed"
1595 new=$(get_xattr_value trusted.foo1 $MOUNT2/$tdir/$tfile)
1596 [[ "$new" = "$orig1" ]] ||
1597 error "second xattr set ($sm_msg1...) differs xattr get ($new)"
1598 rm -f $DIR/$tdir/$tfile
1602 run_test 58c "resend/reconstruct setxattr op"
1604 # log_commit_thread vs filter_destroy race used to lead to import use after free
1607 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1609 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
1610 createmany -o $DIR/$tdir/$tfile-%d 200 ||
1611 error "createmany create files failed"
1613 unlinkmany $DIR/$tdir/$tfile-%d 200 ||
1614 error "unlinkmany $DIR/$tdir/$tfile failed"
1615 #define OBD_FAIL_PTLRPC_DELAY_RECOV 0x507
1616 do_facet ost1 "lctl set_param fail_loc=0x507"
1619 do_facet ost1 "lctl set_param fail_loc=0x0"
1623 run_test 59 "test log_commit_thread vs filter_destroy race"
1625 # race between add unlink llog vs cat log init in post_recovery (only for b1_6)
1626 # bug 12086: should no oops and No ctxt error for this test
1628 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
1629 createmany -o $DIR/$tdir/$tfile-%d 200 ||
1630 error "createmany create files failed"
1631 replay_barrier $SINGLEMDS
1632 unlinkmany $DIR/$tdir/$tfile-%d 0 100
1634 unlinkmany $DIR/$tdir/$tfile-%d 100 100
1635 local no_ctxt=$(dmesg | grep "No ctxt")
1636 [ -z "$no_ctxt" ] || error "ctxt is not initialized in recovery"
1638 run_test 60 "test llog post recovery init vs llog unlink"
1640 #test race llog recovery thread vs llog cleanup
1641 test_61a() { # was test_61
1642 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1644 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
1645 createmany -o $DIR/$tdir/$tfile-%d 800 ||
1646 error "createmany create files failed"
1648 unlinkmany $DIR/$tdir/$tfile-%d 800
1649 # OBD_FAIL_OST_LLOG_RECOVERY_TIMEOUT 0x221
1650 set_nodes_failloc "$(osts_nodes)" 0x80000221
1655 set_nodes_failloc "$(osts_nodes)" 0x0
1657 $CHECKSTAT -t file $DIR/$tdir/$tfile-* &&
1658 error "$CHECKSTAT $DIR/$tdir/$tfile attribute check should fail"
1661 run_test 61a "test race llog recovery vs llog cleanup"
1663 #test race mds llog sync vs llog cleanup
1665 # OBD_FAIL_MDS_LLOG_SYNC_TIMEOUT 0x13a
1666 do_facet $SINGLEMDS "lctl set_param fail_loc=0x8000013a"
1667 facet_failover $SINGLEMDS
1670 do_facet client dd if=/dev/zero of=$DIR/$tfile bs=4k count=1 ||
1673 run_test 61b "test race mds llog sync vs llog cleanup"
1675 #test race cancel cookie cb vs llog cleanup
1677 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1679 # OBD_FAIL_OST_CANCEL_COOKIE_TIMEOUT 0x222
1680 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
1681 set_nodes_failloc "$(osts_nodes)" 0x80000222
1685 set_nodes_failloc "$(osts_nodes)" 0x0
1687 run_test 61c "test race mds llog sync vs llog cleanup"
1689 test_61d() { # bug 16002 # bug 17466 # bug 22137
1690 # OBD_FAIL_OBD_LLOG_SETUP 0x605
1692 do_facet mgs "lctl set_param fail_loc=0x80000605"
1693 start mgs $(mgsdevname) $MGS_MOUNT_OPTS &&
1694 error "mgs start should have failed"
1695 do_facet mgs "lctl set_param fail_loc=0"
1696 start mgs $(mgsdevname) $MGS_MOUNT_OPTS || error "cannot restart mgs"
1698 run_test 61d "error in llog_setup should cleanup the llog context correctly"
1700 test_62() { # Bug 15756 - don't mis-drop resent replay
1701 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
1702 replay_barrier $SINGLEMDS
1703 createmany -o $DIR/$tdir/$tfile- 25 ||
1704 error "createmany create files failed"
1705 #define OBD_FAIL_TGT_REPLAY_DROP 0x707
1706 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000707"
1708 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
1709 unlinkmany $DIR/$tdir/$tfile- 25 ||
1710 error "unlinkmany $DIR/$tdir/$tfile failed"
1713 run_test 62 "don't mis-drop resent replay"
1715 #Adaptive Timeouts (bug 3055)
1723 echo "Cleaning up AT ..."
1724 if [ -n "$ATOLDBASE" ]; then
1725 local at_history=$($LCTL get_param -n at_history)
1726 do_facet $SINGLEMDS "lctl set_param at_history=$at_history" || true
1727 do_facet ost1 "lctl set_param at_history=$at_history" || true
1730 if [ $AT_MAX_SET -ne 0 ]; then
1731 for facet in mds client ost; do
1732 var=AT_MAX_SAVE_${facet}
1733 echo restore AT on $facet to saved value ${!var}
1734 at_max_set ${!var} $facet
1735 at_new=$(at_max_get $facet)
1736 echo Restored AT value on $facet $at_new
1737 [ $at_new -eq ${!var} ] ||
1738 error "AT value not restored SAVED ${!var} NEW $at_new"
1745 local at_max_new=600
1747 # Save at_max original values
1749 if [ $AT_MAX_SET -eq 0 ]; then
1750 # Suppose that all osts have the same at_max
1751 for facet in mds client ost; do
1752 eval AT_MAX_SAVE_${facet}=$(at_max_get $facet)
1756 for facet in mds client ost; do
1757 at_max=$(at_max_get $facet)
1758 if [ $at_max -ne $at_max_new ]; then
1759 echo "AT value on $facet is $at_max, set it by force temporarily to $at_max_new"
1760 at_max_set $at_max_new $facet
1765 if [ -z "$ATOLDBASE" ]; then
1766 ATOLDBASE=$(do_facet $SINGLEMDS "lctl get_param -n at_history")
1767 # speed up the timebase so we can check decreasing AT
1768 do_facet $SINGLEMDS "lctl set_param at_history=8" || true
1769 do_facet ost1 "lctl set_param at_history=8" || true
1771 # sleep for a while to cool down, should be > 8s and also allow
1772 # at least one ping to be sent. simply use TIMEOUT to be safe.
1777 test_65a() #bug 3055
1779 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1781 at_start || return 0
1782 $LCTL dk > /dev/null
1784 $LCTL set_param debug="other"
1785 # Slow down a request to the current service time, this is critical
1786 # because previous tests may have caused this value to increase.
1787 REQ_DELAY=`lctl get_param -n mdc.${FSNAME}-MDT0000-mdc-*.timeouts |
1788 awk '/portal 12/ {print $5}'`
1789 REQ_DELAY=$((${REQ_DELAY} + ${REQ_DELAY} / 4 + 5))
1791 do_facet $SINGLEMDS lctl set_param fail_val=$((${REQ_DELAY} * 1000))
1792 #define OBD_FAIL_PTLRPC_PAUSE_REQ 0x50a
1793 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x8000050a
1794 createmany -o $DIR/$tfile 10 > /dev/null
1795 unlinkmany $DIR/$tfile 10 > /dev/null
1796 # check for log message
1797 $LCTL dk | grep "Early reply #" || error "No early reply"
1799 # client should show REQ_DELAY estimates
1800 lctl get_param -n mdc.${FSNAME}-MDT0000-mdc-*.timeouts | grep portal
1802 lctl get_param -n mdc.${FSNAME}-MDT0000-mdc-*.timeouts | grep portal
1804 run_test 65a "AT: verify early replies"
1806 test_65b() #bug 3055
1808 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1810 at_start || return 0
1813 $LCTL set_param debug="other trace"
1814 $LCTL dk > /dev/null
1815 # Slow down a request to the current service time, this is critical
1816 # because previous tests may have caused this value to increase.
1817 $SETSTRIPE --stripe-index=0 --count=1 $DIR/$tfile
1818 multiop $DIR/$tfile Ow1yc
1819 REQ_DELAY=`lctl get_param -n osc.${FSNAME}-OST0000-osc-*.timeouts |
1820 awk '/portal 6/ {print $5}'`
1821 REQ_DELAY=$((${REQ_DELAY} + ${REQ_DELAY} / 4 + 5))
1823 do_facet ost1 lctl set_param fail_val=${REQ_DELAY}
1824 #define OBD_FAIL_OST_BRW_PAUSE_PACK 0x224
1825 do_facet ost1 $LCTL set_param fail_loc=0x224
1828 $SETSTRIPE --stripe-index=0 --count=1 $DIR/$tfile
1829 # force some real bulk transfer
1830 multiop $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
1832 do_facet ost1 $LCTL set_param fail_loc=0
1833 # check for log message
1834 $LCTL dk | grep "Early reply #" || error "No early reply"
1836 # client should show REQ_DELAY estimates
1837 lctl get_param -n osc.${FSNAME}-OST0000-osc-*.timeouts | grep portal
1839 run_test 65b "AT: verify early replies on packed reply / bulk"
1841 test_66a() #bug 3055
1843 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1845 at_start || return 0
1846 lctl get_param -n mdc.${FSNAME}-MDT0000-mdc-*.timeouts | grep "portal 12"
1847 # adjust 5s at a time so no early reply is sent (within deadline)
1848 do_facet $SINGLEMDS "$LCTL set_param fail_val=5000"
1849 #define OBD_FAIL_PTLRPC_PAUSE_REQ 0x50a
1850 do_facet $SINGLEMDS "$LCTL set_param fail_loc=0x8000050a"
1851 createmany -o $DIR/$tfile 20 > /dev/null
1852 unlinkmany $DIR/$tfile 20 > /dev/null
1853 lctl get_param -n mdc.${FSNAME}-MDT0000-mdc-*.timeouts | grep "portal 12"
1854 do_facet $SINGLEMDS "$LCTL set_param fail_val=10000"
1855 do_facet $SINGLEMDS "$LCTL set_param fail_loc=0x8000050a"
1856 createmany -o $DIR/$tfile 20 > /dev/null
1857 unlinkmany $DIR/$tfile 20 > /dev/null
1858 lctl get_param -n mdc.${FSNAME}-MDT0000-mdc-*.timeouts | grep "portal 12"
1859 do_facet $SINGLEMDS "$LCTL set_param fail_loc=0"
1861 createmany -o $DIR/$tfile 20 > /dev/null
1862 unlinkmany $DIR/$tfile 20 > /dev/null
1863 lctl get_param -n mdc.${FSNAME}-MDT0000-mdc-*.timeouts | grep "portal 12"
1864 CUR=$(lctl get_param -n mdc.${FSNAME}-MDT0000-mdc-*.timeouts | awk '/portal 12/ {print $5}')
1865 WORST=$(lctl get_param -n mdc.${FSNAME}-MDT0000-mdc-*.timeouts | awk '/portal 12/ {print $7}')
1866 echo "Current MDT timeout $CUR, worst $WORST"
1867 [ $CUR -lt $WORST ] || error "Current $CUR should be less than worst $WORST"
1869 run_test 66a "AT: verify MDT service time adjusts with no early replies"
1871 test_66b() #bug 3055
1873 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1875 at_start || return 0
1876 ORIG=$(lctl get_param -n mdc.${FSNAME}-MDT0000*.timeouts |
1877 awk '/network/ {print $4}')
1878 $LCTL set_param fail_val=$(($ORIG + 5))
1879 #define OBD_FAIL_PTLRPC_PAUSE_REP 0x50c
1880 $LCTL set_param fail_loc=0x50c
1881 ls $DIR/$tfile > /dev/null 2>&1
1882 $LCTL set_param fail_loc=0
1883 CUR=$(lctl get_param -n mdc.${FSNAME}-MDT0000*.timeouts |
1884 awk '/network/ {print $4}')
1885 WORST=$(lctl get_param -n mdc.${FSNAME}-MDT0000*.timeouts |
1886 awk '/network/ {print $6}')
1887 echo "network timeout orig $ORIG, cur $CUR, worst $WORST"
1888 [ $WORST -gt $ORIG ] ||
1889 error "Worst $WORST should be worse than orig $ORIG"
1891 run_test 66b "AT: verify net latency adjusts"
1893 test_67a() #bug 3055
1895 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1897 at_start || return 0
1898 CONN1=$(lctl get_param -n osc.*.stats | awk '/_connect/ {total+=$2} END {print total}')
1899 # sleeping threads may drive values above this
1900 do_facet ost1 "$LCTL set_param fail_val=400"
1901 #define OBD_FAIL_PTLRPC_PAUSE_REQ 0x50a
1902 do_facet ost1 "$LCTL set_param fail_loc=0x50a"
1903 createmany -o $DIR/$tfile 20 > /dev/null
1904 unlinkmany $DIR/$tfile 20 > /dev/null
1905 do_facet ost1 "$LCTL set_param fail_loc=0"
1906 CONN2=$(lctl get_param -n osc.*.stats | awk '/_connect/ {total+=$2} END {print total}')
1907 ATTEMPTS=$(($CONN2 - $CONN1))
1908 echo "$ATTEMPTS osc reconnect attempts on gradual slow"
1909 [ $ATTEMPTS -gt 0 ] &&
1910 error_ignore bz13721 "AT should have prevented reconnect"
1913 run_test 67a "AT: verify slow request processing doesn't induce reconnects"
1915 test_67b() #bug 3055
1917 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1919 at_start || return 0
1920 CONN1=$(lctl get_param -n osc.*.stats | awk '/_connect/ {total+=$2} END {print total}')
1922 # exhaust precreations on ost1
1923 local OST=$(ostname_from_index 0)
1924 local mdtosc=$(get_mdtosc_proc_path mds $OST)
1925 local last_id=$(do_facet $SINGLEMDS lctl get_param -n \
1926 osc.$mdtosc.prealloc_last_id)
1927 local next_id=$(do_facet $SINGLEMDS lctl get_param -n \
1928 osc.$mdtosc.prealloc_next_id)
1930 mkdir -p $DIR/$tdir/${OST} || error "mkdir $DIR/$tdir/${OST} failed"
1931 $SETSTRIPE -i 0 -c 1 $DIR/$tdir/${OST} || error "$SETSTRIPE failed"
1932 echo "Creating to objid $last_id on ost $OST..."
1933 #define OBD_FAIL_OST_PAUSE_CREATE 0x223
1934 do_facet ost1 "$LCTL set_param fail_val=20000"
1935 do_facet ost1 "$LCTL set_param fail_loc=0x80000223"
1936 createmany -o $DIR/$tdir/${OST}/f $next_id $((last_id - next_id + 2))
1939 do_facet ost1 "lctl get_param -n ost.OSS.ost_create.timeouts"
1941 CONN2=$(lctl get_param -n osc.*.stats | awk '/_connect/ {total+=$2} END {print total}')
1942 ATTEMPTS=$(($CONN2 - $CONN1))
1943 echo "$ATTEMPTS osc reconnect attempts on instant slow"
1944 # do it again; should not timeout
1945 do_facet ost1 "$LCTL set_param fail_loc=0x80000223"
1946 cp /etc/profile $DIR/$tfile || error "cp failed"
1947 do_facet ost1 "$LCTL set_param fail_loc=0"
1949 do_facet ost1 "lctl get_param -n ost.OSS.ost_create.timeouts"
1950 CONN3=$(lctl get_param -n osc.*.stats | awk '/_connect/ {total+=$2} END {print total}')
1951 ATTEMPTS=$(($CONN3 - $CONN2))
1952 echo "$ATTEMPTS osc reconnect attempts on 2nd slow"
1953 [ $ATTEMPTS -gt 0 ] && error "AT should have prevented reconnect"
1956 run_test 67b "AT: verify instant slowdown doesn't induce reconnects"
1958 test_68 () #bug 13813
1960 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1962 at_start || return 0
1963 local ldlm_enqueue_min=$(find /sys -name ldlm_enqueue_min)
1964 [ -z "$ldlm_enqueue_min" ] && skip "missing /sys/.../ldlm_enqueue_min" && return 0
1965 local ldlm_enqueue_min_r=$(do_facet ost1 "find /sys -name ldlm_enqueue_min")
1966 [ -z "$ldlm_enqueue_min_r" ] && skip "missing /sys/.../ldlm_enqueue_min in the ost1" && return 0
1967 local ENQ_MIN=$(cat $ldlm_enqueue_min)
1968 local ENQ_MIN_R=$(do_facet ost1 "cat $ldlm_enqueue_min_r")
1969 echo $TIMEOUT >> $ldlm_enqueue_min
1970 do_facet ost1 "echo $TIMEOUT >> $ldlm_enqueue_min_r"
1972 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
1973 $SETSTRIPE --stripe-index=0 --count=1 $DIR/$tdir
1974 #define OBD_FAIL_LDLM_PAUSE_CANCEL 0x312
1975 $LCTL set_param fail_val=$(($TIMEOUT - 1))
1976 $LCTL set_param fail_loc=0x80000312
1977 cp /etc/profile $DIR/$tdir/${tfile}_1 || error "1st cp failed $?"
1978 $LCTL set_param fail_val=$((TIMEOUT * 5 / 4))
1979 $LCTL set_param fail_loc=0x80000312
1980 cp /etc/profile $DIR/$tdir/${tfile}_2 || error "2nd cp failed $?"
1981 $LCTL set_param fail_loc=0
1983 echo $ENQ_MIN >> $ldlm_enqueue_min
1984 do_facet ost1 "echo $ENQ_MIN_R >> $ldlm_enqueue_min_r"
1988 run_test 68 "AT: verify slowing locks"
1991 # end of AT tests includes above lines
1993 # start multi-client tests
1995 [ -z "$CLIENTS" ] &&
1996 { skip "Need two or more clients." && return; }
1997 [ $CLIENTCOUNT -lt 2 ] &&
1998 { skip "Need two or more clients, have $CLIENTCOUNT" && return; }
2000 echo "mount clients $CLIENTS ..."
2001 zconf_mount_clients $CLIENTS $MOUNT
2003 local clients=${CLIENTS//,/ }
2004 echo "Write/read files on $DIR ; clients $CLIENTS ... "
2005 for CLIENT in $clients; do
2006 do_node $CLIENT dd bs=1M count=10 if=/dev/zero \
2007 of=$DIR/${tfile}_${CLIENT} 2>/dev/null ||
2008 error "dd failed on $CLIENT"
2011 local prev_client=$(echo $clients | sed 's/^.* \(.\+\)$/\1/')
2012 for C in ${CLIENTS//,/ }; do
2013 do_node $prev_client dd if=$DIR/${tfile}_${C} \
2014 of=/dev/null 2>/dev/null ||
2015 error "dd if=$DIR/${tfile}_${C} failed on $prev_client"
2021 run_test 70a "check multi client t-f"
2023 check_for_process () {
2028 killall_process $clients "$prog" -0
2032 local clients=${CLIENTS:-$HOSTNAME}
2034 zconf_mount_clients $clients $MOUNT
2037 [ "$SLOW" = "no" ] && duration=120
2038 # set duration to 900 because it takes some time to boot node
2039 [ "$FAILURE_MODE" = HARD ] && duration=900
2042 local start_ts=$(date +%s)
2043 local cmd="rundbench 1 -t $duration"
2045 if [ $MDSCOUNT -ge 2 ]; then
2046 test_mkdir -p -c$MDSCOUNT $DIR/$tdir
2047 $LFS setdirstripe -D -c$MDSCOUNT $DIR/$tdir
2049 do_nodesv $clients "set -x; MISSING_DBENCH_OK=$MISSING_DBENCH_OK \
2050 PATH=\$PATH:$LUSTRE/utils:$LUSTRE/tests/:$DBENCH_LIB \
2051 DBENCH_LIB=$DBENCH_LIB TESTSUITE=$TESTSUITE TESTNAME=$TESTNAME \
2052 MOUNT=$MOUNT DIR=$DIR/$tdir/\\\$(hostname) LCTL=$LCTL $cmd" &
2055 #LU-1897 wait for all dbench copies to start
2056 while ! check_for_process $clients dbench; do
2057 elapsed=$(($(date +%s) - start_ts))
2058 if [ $elapsed -gt $duration ]; then
2059 killall_process $clients dbench
2060 error "dbench failed to start on $clients!"
2065 log "Started rundbench load pid=$pid ..."
2067 elapsed=$(($(date +%s) - start_ts))
2068 local num_failovers=0
2070 while [ $elapsed -lt $duration ]; do
2071 if ! check_for_process $clients dbench; then
2072 error_noexit "dbench stopped on some of $clients!"
2073 killall_process $clients dbench
2077 replay_barrier mds$fail_index
2078 sleep 1 # give clients a time to do operations
2079 # Increment the number of failovers
2080 num_failovers=$((num_failovers+1))
2081 log "$TESTNAME fail mds$fail_index $num_failovers times"
2083 elapsed=$(($(date +%s) - start_ts))
2084 if [ $fail_index -ge $MDSCOUNT ]; then
2087 fail_index=$((fail_index+1))
2091 wait $pid || error "rundbench load on $clients failed!"
2093 run_test 70b "dbench ${MDSCOUNT}mdts recovery; $CLIENTCOUNT clients"
2094 # end multi-client tests
2099 local monitor_pid=$3
2101 local start_ts=$(date +%s)
2102 local num_failovers=0
2105 elapsed=$(($(date +%s) - start_ts))
2106 while [ $elapsed -lt $duration ]; do
2107 fail_index=$((RANDOM%max_index+1))
2108 kill -0 $monitor_pid ||
2109 error "$monitor_pid stopped"
2111 replay_barrier mds$fail_index
2113 # Increment the number of failovers
2114 num_failovers=$((num_failovers+1))
2115 log "$TESTNAME fail mds$fail_index $num_failovers times"
2117 elapsed=$(($(date +%s) - start_ts))
2123 rm -f $DIR/replay-single.70c.lck
2128 local clients=${CLIENTS:-$HOSTNAME}
2131 zconf_mount_clients $clients $MOUNT
2134 [ "$SLOW" = "no" ] && duration=180
2135 # set duration to 900 because it takes some time to boot node
2136 [ "$FAILURE_MODE" = HARD ] && duration=600
2139 local start_ts=$(date +%s)
2141 trap cleanup_70c EXIT
2143 while [ ! -e $DIR/replay-single.70c.lck ]; do
2144 test_mkdir -p -c$MDSCOUNT $DIR/$tdir || break
2145 if [ $MDSCOUNT -ge 2 ]; then
2146 $LFS setdirstripe -D -c$MDSCOUNT $DIR/$tdir ||
2147 error "set default dirstripe failed"
2149 cd $DIR/$tdir || break
2150 tar cf - /etc | tar xf - || error "tar failed in loop"
2154 echo "Started tar $tar_70c_pid"
2156 random_fail_mdt $MDSCOUNT $duration $tar_70c_pid
2157 kill -0 $tar_70c_pid || error "tar $tar_70c_pid stopped"
2159 touch $DIR/replay-single.70c.lck
2160 wait $tar_70c_pid || error "$?: tar failed"
2165 run_test 70c "tar ${MDSCOUNT}mdts recovery"
2169 kill -9 $mkdir_70d_pid
2173 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2174 local clients=${CLIENTS:-$HOSTNAME}
2177 zconf_mount_clients $clients $MOUNT
2180 [ "$SLOW" = "no" ] && duration=180
2181 # set duration to 900 because it takes some time to boot node
2182 [ "$FAILURE_MODE" = HARD ] && duration=900
2187 local start_ts=$(date +%s)
2189 trap cleanup_70d EXIT
2192 $LFS mkdir -i0 -c2 $DIR/$tdir/test || {
2196 $LFS mkdir -i1 -c2 $DIR/$tdir/test1 || {
2201 touch $DIR/$tdir/test/a || {
2205 mkdir $DIR/$tdir/test/b || {
2209 rm -rf $DIR/$tdir/test || {
2214 touch $DIR/$tdir/test1/a || {
2218 mkdir $DIR/$tdir/test1/b || {
2223 rm -rf $DIR/$tdir/test1 || {
2230 echo "Started $mkdir_70d_pid"
2232 random_fail_mdt $MDSCOUNT $duration $mkdir_70d_pid
2233 kill -0 $mkdir_70d_pid || error "mkdir/rmdir $mkdir_70d_pid stopped"
2238 run_test 70d "mkdir/rmdir striped dir ${MDSCOUNT}mdts recovery"
2242 kill -9 $rename_70e_pid
2246 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2247 local clients=${CLIENTS:-$HOSTNAME}
2250 echo ha > /proc/sys/lnet/debug
2251 zconf_mount_clients $clients $MOUNT
2254 [ "$SLOW" = "no" ] && duration=180
2255 # set duration to 900 because it takes some time to boot node
2256 [ "$FAILURE_MODE" = HARD ] && duration=900
2259 $LFS mkdir -i0 $DIR/$tdir/test_0
2260 $LFS mkdir -i0 $DIR/$tdir/test_1
2261 touch $DIR/$tdir/test_0/a
2262 touch $DIR/$tdir/test_1/b
2263 trap cleanup_70e EXIT
2266 mrename $DIR/$tdir/test_0/a $DIR/$tdir/test_1/b > \
2272 checkstat $DIR/$tdir/test_0/a && {
2273 echo "a still exists"
2277 checkstat $DIR/$tdir/test_1/b || {
2278 echo "b still exists"
2282 touch $DIR/$tdir/test_0/a || {
2283 echo "touch a fails"
2287 mrename $DIR/$tdir/test_1/b $DIR/$tdir/test_0/a > \
2295 echo "Started $rename_70e_pid"
2297 random_fail_mdt 2 $duration $rename_70e_pid
2298 kill -0 $rename_70e_pid || error "rename $rename_70e_pid stopped"
2303 run_test 70e "rename cross-MDT with random fails"
2307 kill -9 $mkdir_71a_pid
2310 random_double_fail_mdt() {
2313 local monitor_pid=$3
2315 local start_ts=$(date +%s)
2316 local num_failovers=0
2320 elapsed=$(($(date +%s) - start_ts))
2321 while [ $elapsed -lt $duration ]; do
2322 fail_index=$((RANDOM%max_index + 1))
2323 if [ $fail_index -eq $max_index ]; then
2326 second_index=$((fail_index + 1))
2328 kill -0 $monitor_pid ||
2329 error "$monitor_pid stopped"
2331 replay_barrier mds$fail_index
2332 replay_barrier mds$second_index
2334 # Increment the number of failovers
2335 num_failovers=$((num_failovers+1))
2336 log "fail mds$fail_index mds$second_index $num_failovers times"
2337 fail mds${fail_index},mds${second_index}
2338 elapsed=$(($(date +%s) - start_ts))
2343 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2344 local clients=${CLIENTS:-$HOSTNAME}
2347 zconf_mount_clients $clients $MOUNT
2350 [ "$SLOW" = "no" ] && duration=180
2351 # set duration to 900 because it takes some time to boot node
2352 [ "$FAILURE_MODE" = HARD ] && duration=900
2357 local start_ts=$(date +%s)
2359 trap cleanup_71a EXIT
2362 $LFS mkdir -i0 -c2 $DIR/$tdir/test
2363 rmdir $DIR/$tdir/test
2367 echo "Started $mkdir_71a_pid"
2369 random_double_fail_mdt 2 $duration $mkdir_71a_pid
2370 kill -0 $mkdir_71a_pid || error "mkdir/rmdir $mkdir_71a_pid stopped"
2375 run_test 71a "mkdir/rmdir striped dir with 2 mdts recovery"
2378 multiop_bg_pause $DIR/$tfile O_tSc ||
2379 error "multiop_bg_pause $DIR/$tfile failed"
2383 replay_barrier $SINGLEMDS
2384 #define OBD_FAIL_LDLM_ENQUEUE_NET 0x302
2385 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000302"
2388 wait $pid || error "multiop pid failed"
2389 [ -e $DIR/$tfile ] && error "file $DIR/$tfile should not exist"
2392 run_test 73a "open(O_CREAT), unlink, replay, reconnect before open replay, close"
2395 multiop_bg_pause $DIR/$tfile O_tSc ||
2396 error "multiop_bg_pause $DIR/$tfile failed"
2400 replay_barrier $SINGLEMDS
2401 #define OBD_FAIL_LDLM_REPLY 0x30c
2402 do_facet $SINGLEMDS "lctl set_param fail_loc=0x8000030c"
2405 wait $pid || error "multiop pid failed"
2406 [ -e $DIR/$tfile ] && error "file $DIR/$tfile should not exist"
2409 run_test 73b "open(O_CREAT), unlink, replay, reconnect at open_replay reply, close"
2413 local clients=${CLIENTS:-$HOSTNAME}
2415 zconf_umount_clients $clients $MOUNT
2417 facet_failover $SINGLEMDS
2418 zconf_mount_clients $clients $MOUNT
2420 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
2421 rm $DIR/$tfile || error "rm $DIR/$tfile failed"
2422 clients_up || error "client evicted: $?"
2425 run_test 74 "Ensure applications don't fail waiting for OST recovery"
2427 remote_dir_check_80() {
2432 diridx=$($GETSTRIPE -M $remote_dir) ||
2433 error "$GETSTRIPE -M $remote_dir failed"
2434 [ $diridx -eq $MDTIDX ] || error "$diridx != $MDTIDX"
2436 createmany -o $remote_dir/f-%d 20 || error "creation failed"
2437 fileidx=$($GETSTRIPE -M $remote_dir/f-1) ||
2438 error "$GETSTRIPE -M $remote_dir/f-1 failed"
2439 [ $fileidx -eq $MDTIDX ] || error "$fileidx != $MDTIDX"
2445 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2446 ([ $FAILURE_MODE == "HARD" ] &&
2447 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
2448 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
2452 local remote_dir=$DIR/$tdir/remote_dir
2454 mkdir -p $DIR/$tdir || error "mkdir $DIR/$tdir failed"
2455 #define OBD_FAIL_OUT_UPDATE_NET_REP 0x1701
2456 do_facet mds${MDTIDX} lctl set_param fail_loc=0x1701
2457 $LFS mkdir -i $MDTIDX $remote_dir &
2463 wait $CLIENT_PID || error "remote creation failed"
2465 remote_dir_check_80 || error "remote dir check failed"
2466 rm -rf $DIR/$tdir || error "rmdir failed"
2470 run_test 80a "DNE: create remote dir, drop update rep from MDT0, fail MDT0"
2473 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2474 ([ $FAILURE_MODE == "HARD" ] &&
2475 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
2476 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
2480 local remote_dir=$DIR/$tdir/remote_dir
2482 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
2483 #define OBD_FAIL_UPDATE_OBJ_NET_REP 0x1701
2484 do_facet mds${MDTIDX} lctl set_param fail_loc=0x1701
2485 $LFS mkdir -i $MDTIDX $remote_dir &
2490 fail mds$((MDTIDX + 1))
2492 wait $CLIENT_PID || error "remote creation failed"
2494 remote_dir_check_80 || error "remote dir check failed"
2495 rm -rf $DIR/$tdir || error "rmdir failed"
2499 run_test 80b "DNE: create remote dir, drop update rep from MDT0, fail MDT1"
2502 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2503 ([ $FAILURE_MODE == "HARD" ] &&
2504 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
2505 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
2509 local remote_dir=$DIR/$tdir/remote_dir
2511 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
2512 #define OBD_FAIL_UPDATE_OBJ_NET_REP 0x1701
2513 do_facet mds${MDTIDX} lctl set_param fail_loc=0x1701
2514 $LFS mkdir -i $MDTIDX $remote_dir &
2520 fail mds$((MDTIDX + 1))
2522 wait $CLIENT_PID || error "remote creation failed"
2524 remote_dir_check_80 || error "remote dir check failed"
2525 rm -rf $DIR/$tdir || error "rmdir failed"
2529 run_test 80c "DNE: create remote dir, drop update rep from MDT1, fail MDT[0,1]"
2532 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2534 local remote_dir=$DIR/$tdir/remote_dir
2536 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
2537 #define OBD_FAIL_UPDATE_OBJ_NET_REP 0x1701
2538 do_facet mds${MDTIDX} lctl set_param fail_loc=0x1701
2539 $LFS mkdir -i $MDTIDX $remote_dir &
2542 # sleep 3 seconds to make sure MDTs are failed after
2543 # lfs mkdir -i has finished on all of MDTs.
2548 fail mds${MDTIDX},mds$((MDTIDX + 1))
2550 wait $CLIENT_PID || error "remote creation failed"
2552 remote_dir_check_80 || error "remote dir check failed"
2553 rm -rf $DIR/$tdir || error "rmdir failed"
2557 run_test 80d "DNE: create remote dir, drop update rep from MDT1, fail 2 MDTs"
2560 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2561 ([ $FAILURE_MODE == "HARD" ] &&
2562 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
2563 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
2567 local remote_dir=$DIR/$tdir/remote_dir
2569 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
2570 # OBD_FAIL_MDS_REINT_NET_REP 0x119
2571 do_facet mds$((MDTIDX + 1)) lctl set_param fail_loc=0x119
2572 $LFS mkdir -i $MDTIDX $remote_dir &
2575 # sleep 3 seconds to make sure MDTs are failed after
2576 # lfs mkdir -i has finished on all of MDTs.
2582 wait $CLIENT_PID || error "remote creation failed"
2584 remote_dir_check_80 || error "remote dir check failed"
2585 rm -rf $DIR/$tdir || error "rmdir failed"
2589 run_test 80e "DNE: create remote dir, drop MDT1 rep, fail MDT0"
2592 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2593 ([ $FAILURE_MODE == "HARD" ] &&
2594 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
2595 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
2598 local remote_dir=$DIR/$tdir/remote_dir
2600 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
2601 # OBD_FAIL_MDS_REINT_NET_REP 0x119
2602 do_facet mds$((MDTIDX + 1)) lctl set_param fail_loc=0x119
2603 $LFS mkdir -i $MDTIDX $remote_dir &
2607 fail mds$((MDTIDX + 1))
2609 wait $CLIENT_PID || error "remote creation failed"
2611 remote_dir_check_80 || error "remote dir check failed"
2612 rm -rf $DIR/$tdir || error "rmdir failed"
2616 run_test 80f "DNE: create remote dir, drop MDT1 rep, fail MDT1"
2619 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2620 ([ $FAILURE_MODE == "HARD" ] &&
2621 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
2622 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
2626 local remote_dir=$DIR/$tdir/remote_dir
2628 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
2629 # OBD_FAIL_MDS_REINT_NET_REP 0x119
2630 do_facet mds$((MDTIDX + 1)) lctl set_param fail_loc=0x119
2631 $LFS mkdir -i $MDTIDX $remote_dir &
2634 # sleep 3 seconds to make sure MDTs are failed after
2635 # lfs mkdir -i has finished on all of MDTs.
2641 fail mds$((MDTIDX + 1))
2643 wait $CLIENT_PID || error "remote creation failed"
2645 remote_dir_check_80 || error "remote dir check failed"
2646 rm -rf $DIR/$tdir || error "rmdir failed"
2650 run_test 80g "DNE: create remote dir, drop MDT1 rep, fail MDT0, then MDT1"
2653 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2655 local remote_dir=$DIR/$tdir/remote_dir
2657 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
2658 # OBD_FAIL_MDS_REINT_NET_REP 0x119
2659 do_facet mds$((MDTIDX + 1)) lctl set_param fail_loc=0x119
2660 $LFS mkdir -i $MDTIDX $remote_dir &
2663 # sleep 3 seconds to make sure MDTs are failed after
2664 # lfs mkdir -i has finished on all of MDTs.
2669 fail mds${MDTIDX},mds$((MDTIDX + 1))
2671 wait $CLIENT_PID || error "remote dir creation failed"
2673 remote_dir_check_80 || error "remote dir check failed"
2674 rm -rf $DIR/$tdir || error "rmdir failed"
2678 run_test 80h "DNE: create remote dir, drop MDT1 rep, fail 2 MDTs"
2681 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2682 ([ $FAILURE_MODE == "HARD" ] &&
2683 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
2684 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
2688 local remote_dir=$DIR/$tdir/remote_dir
2690 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
2691 $LFS mkdir -i $MDTIDX $remote_dir || error "lfs mkdir failed"
2693 touch $remote_dir || error "touch $remote_dir failed"
2694 # OBD_FAIL_OBJ_UPDATE_NET_REP 0x1701
2695 do_facet mds${MDTIDX} lctl set_param fail_loc=0x1701
2700 fail mds$((MDTIDX + 1))
2702 wait $CLIENT_PID || error "rm remote dir failed"
2704 stat $remote_dir 2&>/dev/null && error "$remote_dir still exist!"
2706 rm -rf $DIR/$tdir || error "rmdir failed"
2710 run_test 81a "DNE: unlink remote dir, drop MDT0 update rep, fail MDT1"
2713 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2714 ([ $FAILURE_MODE == "HARD" ] &&
2715 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
2716 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
2719 local remote_dir=$DIR/$tdir/remote_dir
2721 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
2722 $LFS mkdir -i $MDTIDX $remote_dir || error "lfs mkdir failed"
2724 # OBD_FAIL_OBJ_UPDATE_NET_REP 0x1701
2725 do_facet mds${MDTIDX} lctl set_param fail_loc=0x1701
2732 wait $CLIENT_PID || error "rm remote dir failed"
2734 stat $remote_dir 2&>/dev/null && error "$remote_dir still exist!"
2736 rm -rf $DIR/$tdir || error "rmdir failed"
2740 run_test 81b "DNE: unlink remote dir, drop MDT0 update reply, fail MDT0"
2743 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2744 ([ $FAILURE_MODE == "HARD" ] &&
2745 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
2746 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
2750 local remote_dir=$DIR/$tdir/remote_dir
2752 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
2753 $LFS mkdir -i $MDTIDX $remote_dir || error "lfs mkdir failed"
2755 # OBD_FAIL_OBJ_UPDATE_NET_REP 0x1701
2756 do_facet mds${MDTIDX} lctl set_param fail_loc=0x1701
2763 fail mds$((MDTIDX + 1))
2765 wait $CLIENT_PID || error "rm remote dir failed"
2767 stat $remote_dir 2&>/dev/null && error "$remote_dir still exist!"
2769 rm -rf $DIR/$tdir || error "rmdir failed"
2773 run_test 81c "DNE: unlink remote dir, drop MDT0 update reply, fail MDT0,MDT1"
2776 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2778 local remote_dir=$DIR/$tdir/remote_dir
2780 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
2781 $LFS mkdir -i $MDTIDX $remote_dir || error "lfs mkdir failed"
2783 # OBD_FAIL_OBJ_UPDATE_NET_REP 0x1701
2784 do_facet mds${MDTIDX} lctl set_param fail_loc=0x1701
2790 fail mds${MDTIDX},mds$((MDTIDX + 1))
2792 wait $CLIENT_PID || error "rm remote dir failed"
2794 stat $remote_dir 2&>/dev/null && error "$remote_dir still exist!"
2796 rm -rf $DIR/$tdir || error "rmdir failed"
2800 run_test 81d "DNE: unlink remote dir, drop MDT0 update reply, fail 2 MDTs"
2803 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2804 ([ $FAILURE_MODE == "HARD" ] &&
2805 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
2806 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
2810 local remote_dir=$DIR/$tdir/remote_dir
2812 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
2813 $LFS mkdir -i $MDTIDX $remote_dir || error "lfs mkdir failed"
2815 # OBD_FAIL_MDS_REINT_NET_REP 0x119
2816 do_facet mds$((MDTIDX + 1)) lctl set_param fail_loc=0x119
2819 do_facet mds$((MDTIDX + 1)) lctl set_param fail_loc=0
2824 wait $CLIENT_PID || error "rm remote dir failed"
2826 stat $remote_dir 2&>/dev/null && error "$remote_dir still exist!"
2828 rm -rf $DIR/$tdir || error "rmdir failed"
2832 run_test 81e "DNE: unlink remote dir, drop MDT1 req reply, fail MDT0"
2835 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2836 ([ $FAILURE_MODE == "HARD" ] &&
2837 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
2838 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
2842 local remote_dir=$DIR/$tdir/remote_dir
2844 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
2845 $LFS mkdir -i $MDTIDX $remote_dir || error "lfs mkdir failed"
2847 # OBD_FAIL_MDS_REINT_NET_REP 0x119
2848 do_facet mds$((MDTIDX + 1)) lctl set_param fail_loc=0x119
2853 fail mds$((MDTIDX + 1))
2855 wait $CLIENT_PID || error "rm remote dir failed"
2857 stat $remote_dir 2&>/dev/null && error "$remote_dir still exist!"
2859 rm -rf $DIR/$tdir || error "rmdir failed"
2863 run_test 81f "DNE: unlink remote dir, drop MDT1 req reply, fail MDT1"
2866 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2867 ([ $FAILURE_MODE == "HARD" ] &&
2868 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
2869 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
2873 local remote_dir=$DIR/$tdir/remote_dir
2875 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
2876 $LFS mkdir -i $MDTIDX $remote_dir || error "lfs mkdir failed"
2878 # OBD_FAIL_MDS_REINT_NET_REP 0x119
2879 do_facet mds$((MDTIDX + 1)) lctl set_param fail_loc=0x119
2886 fail mds$((MDTIDX + 1))
2888 wait $CLIENT_PID || error "rm remote dir failed"
2890 stat $remote_dir 2&>/dev/null && error "$remote_dir still exist!"
2892 rm -rf $DIR/$tdir || error "rmdir failed"
2896 run_test 81g "DNE: unlink remote dir, drop req reply, fail M0, then M1"
2899 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2901 local remote_dir=$DIR/$tdir/remote_dir
2903 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
2904 $LFS mkdir -i $MDTIDX $remote_dir || error "lfs mkdir failed"
2906 # OBD_FAIL_MDS_REINT_NET_REP 0x119
2907 do_facet mds$((MDTIDX + 1)) lctl set_param fail_loc=0x119
2913 fail mds${MDTIDX},mds$((MDTIDX + 1))
2915 wait $CLIENT_PID || error "rm remote dir failed"
2917 stat $remote_dir 2&>/dev/null && error "$remote_dir still exist!"
2919 rm -rf $DIR/$tdir || error "rmdir failed"
2923 run_test 81h "DNE: unlink remote dir, drop request reply, fail 2 MDTs"
2926 #define OBD_FAIL_MDS_OPEN_WAIT_CREATE 0x144
2927 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000144"
2928 createmany -o $DIR/$tfile- 1 &
2932 client_up || client_up || true # reconnect
2934 run_test 84a "stale open during export disconnect"
2936 test_85a() { #bug 16774
2937 lctl set_param -n ldlm.cancel_unused_locks_before_replay "1"
2939 for i in $(seq 100); do
2940 echo "tag-$i" > $DIR/$tfile-$i
2941 grep -q "tag-$i" $DIR/$tfile-$i || error "f2-$i"
2944 lov_id=$(lctl dl | grep "clilov")
2945 addr=$(echo $lov_id | awk '{print $4}' | awk -F '-' '{print $NF}')
2946 count=$(lctl get_param -n \
2947 ldlm.namespaces.*MDT0000*$addr.lock_unused_count)
2948 echo "before recovery: unused locks count = $count"
2952 count2=$(lctl get_param -n \
2953 ldlm.namespaces.*MDT0000*$addr.lock_unused_count)
2954 echo "after recovery: unused locks count = $count2"
2956 if [ $count2 -ge $count ]; then
2957 error "unused locks are not canceled"
2960 run_test 85a "check the cancellation of unused locks during recovery(IBITS)"
2962 test_85b() { #bug 16774
2963 lctl set_param -n ldlm.cancel_unused_locks_before_replay "1"
2965 do_facet mgs $LCTL pool_new $FSNAME.$TESTNAME ||
2966 error "unable to create pool $TESTNAME"
2967 do_facet mgs $LCTL pool_add $FSNAME.$TESTNAME $FSNAME-OST0000 ||
2968 error "unable to add pool $TESTNAME"
2970 $SETSTRIPE -c 1 -p $FSNAME.$TESTNAME $DIR
2972 for i in $(seq 100); do
2973 dd if=/dev/urandom of=$DIR/$tfile-$i bs=4096 \
2974 count=32 >/dev/null 2>&1
2977 cancel_lru_locks osc
2979 for i in $(seq 100); do
2980 dd if=$DIR/$tfile-$i of=/dev/null bs=4096 \
2981 count=32 >/dev/null 2>&1
2984 lov_id=$(lctl dl | grep "clilov")
2985 addr=$(echo $lov_id | awk '{print $4}' | awk -F '-' '{print $NF}')
2986 count=$(lctl get_param -n \
2987 ldlm.namespaces.*OST0000*$addr.lock_unused_count)
2988 echo "before recovery: unused locks count = $count"
2989 [ $count -ne 0 ] || error "unused locks ($count) should be zero"
2993 count2=$(lctl get_param \
2994 -n ldlm.namespaces.*OST0000*$addr.lock_unused_count)
2995 echo "after recovery: unused locks count = $count2"
2997 do_facet mgs $LCTL pool_remove $FSNAME.$TESTNAME $FSNAME-OST0000 ||
2998 error "unable to remove pool $TESTNAME"
2999 do_facet mgs $LCTL pool_destroy $FSNAME.$TESTNAME ||
3000 error "unable to destroy the pool $TESTNAME"
3002 if [ $count2 -ge $count ]; then
3003 error "unused locks are not canceled"
3006 run_test 85b "check the cancellation of unused locks during recovery(EXTENT)"
3009 local clients=${CLIENTS:-$HOSTNAME}
3011 zconf_umount_clients $clients $MOUNT
3012 do_facet $SINGLEMDS lctl set_param mdt.${FSNAME}-MDT*.exports.clear=0
3013 remount_facet $SINGLEMDS
3014 zconf_mount_clients $clients $MOUNT
3016 run_test 86 "umount server after clear nid_stats should not hit LBUG"
3019 do_facet ost1 "lctl set_param -n obdfilter.${ost1_svc}.sync_journal 0"
3022 $SETSTRIPE -i 0 -c 1 $DIR/$tfile
3023 dd if=/dev/urandom of=$DIR/$tfile bs=1024k count=8 ||
3024 error "dd to $DIR/$tfile failed"
3025 cksum=$(md5sum $DIR/$tfile | awk '{print $1}')
3026 cancel_lru_locks osc
3028 dd if=$DIR/$tfile of=/dev/null bs=1024k count=8 || error "Cannot read"
3029 cksum2=$(md5sum $DIR/$tfile | awk '{print $1}')
3030 if [ $cksum != $cksum2 ] ; then
3031 error "New checksum $cksum2 does not match original $cksum"
3034 run_test 87a "write replay"
3037 do_facet ost1 "lctl set_param -n obdfilter.${ost1_svc}.sync_journal 0"
3040 $SETSTRIPE -i 0 -c 1 $DIR/$tfile
3041 dd if=/dev/urandom of=$DIR/$tfile bs=1024k count=8 ||
3042 error "dd to $DIR/$tfile failed"
3043 sleep 1 # Give it a chance to flush dirty data
3044 echo TESTTEST | dd of=$DIR/$tfile bs=1 count=8 seek=64
3045 cksum=$(md5sum $DIR/$tfile | awk '{print $1}')
3046 cancel_lru_locks osc
3048 dd if=$DIR/$tfile of=/dev/null bs=1024k count=8 || error "Cannot read"
3049 cksum2=$(md5sum $DIR/$tfile | awk '{print $1}')
3050 if [ $cksum != $cksum2 ] ; then
3051 error "New checksum $cksum2 does not match original $cksum"
3054 run_test 87b "write replay with changed data (checksum resend)"
3056 test_88() { #bug 17485
3057 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
3058 mkdir -p $TMP/$tdir || error "mkdir $TMP/$tdir failed"
3060 $SETSTRIPE -i 0 -c 1 $DIR/$tdir || error "$SETSTRIPE"
3063 replay_barrier $SINGLEMDS
3065 # exhaust precreations on ost1
3066 local OST=$(ostname_from_index 0)
3067 local mdtosc=$(get_mdtosc_proc_path $SINGLEMDS $OST)
3068 local last_id=$(do_facet $SINGLEMDS lctl get_param -n osc.$mdtosc.prealloc_last_id)
3069 local next_id=$(do_facet $SINGLEMDS lctl get_param -n osc.$mdtosc.prealloc_next_id)
3070 echo "before test: last_id = $last_id, next_id = $next_id"
3072 echo "Creating to objid $last_id on ost $OST..."
3073 createmany -o $DIR/$tdir/f-%d $next_id $((last_id - next_id + 2)) ||
3074 error "createmany create files to last_id failed"
3076 #create some files to use some uncommitted objids
3077 last_id=$(($last_id + 1))
3078 createmany -o $DIR/$tdir/f-%d $last_id 8 ||
3079 error "createmany create files with uncommitted objids failed"
3081 last_id2=$(do_facet $SINGLEMDS lctl get_param -n osc.$mdtosc.prealloc_last_id)
3082 next_id2=$(do_facet $SINGLEMDS lctl get_param -n osc.$mdtosc.prealloc_next_id)
3083 echo "before recovery: last_id = $last_id2, next_id = $next_id2"
3085 # if test uses shutdown_facet && reboot_facet instead of facet_failover ()
3086 # it has to take care about the affected facets, bug20407
3087 local affected_mds1=$(affected_facets mds1)
3088 local affected_ost1=$(affected_facets ost1)
3090 shutdown_facet $SINGLEMDS
3093 reboot_facet $SINGLEMDS
3094 change_active $affected_mds1
3095 wait_for_facet $affected_mds1
3096 mount_facets $affected_mds1 || error "Restart of mds failed"
3099 change_active $affected_ost1
3100 wait_for_facet $affected_ost1
3101 mount_facets $affected_ost1 || error "Restart of ost1 failed"
3105 last_id2=$(do_facet $SINGLEMDS lctl get_param -n osc.$mdtosc.prealloc_last_id)
3106 next_id2=$(do_facet $SINGLEMDS lctl get_param -n osc.$mdtosc.prealloc_next_id)
3107 echo "after recovery: last_id = $last_id2, next_id = $next_id2"
3109 # create new files, which should use new objids, and ensure the orphan
3110 # cleanup phase for ost1 is completed at the same time
3111 for i in $(seq 8); do
3112 file_id=$(($last_id + 10 + $i))
3113 dd if=/dev/urandom of=$DIR/$tdir/f-$file_id bs=4096 count=128
3116 # if the objids were not recreated, then "ls" will fail with -ENOENT
3117 ls -l $DIR/$tdir/* || error "can't get the status of precreated files"
3120 # write into previously created files
3121 for i in $(seq 8); do
3122 file_id=$(($last_id + $i))
3123 dd if=/dev/urandom of=$DIR/$tdir/f-$file_id bs=4096 count=128
3124 cp -f $DIR/$tdir/f-$file_id $TMP/$tdir/
3127 # compare the content
3128 for i in $(seq 8); do
3129 file_id=$(($last_id + $i))
3130 cmp $TMP/$tdir/f-$file_id $DIR/$tdir/f-$file_id ||
3131 error "the content of file is modified!"
3136 run_test 88 "MDS should not assign same objid to different files "
3139 cancel_lru_locks osc
3140 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
3141 rm -f $DIR/$tdir/$tfile
3143 wait_delete_completed
3144 BLOCKS1=$(df -P $MOUNT | tail -n 1 | awk '{ print $3 }')
3145 $SETSTRIPE -i 0 -c 1 $DIR/$tdir/$tfile
3146 dd if=/dev/zero bs=1M count=10 of=$DIR/$tdir/$tfile
3149 facet_failover $SINGLEMDS
3150 rm $DIR/$tdir/$tfile
3153 zconf_mount $(hostname) $MOUNT || error "mount fails"
3154 client_up || error "client_up failed"
3156 wait_delete_completed
3157 BLOCKS2=$(df -P $MOUNT | tail -n 1 | awk '{ print $3 }')
3158 [ $((BLOCKS2 - BLOCKS1)) -le 4 ] ||
3159 error $((BLOCKS2 - BLOCKS1)) blocks leaked
3162 run_test 89 "no disk space leak on late ost connection"
3168 change_active $facet
3169 wait_for_facet $facet
3170 mount_facet $facet || error "Restart of $facet failed"
3174 test_90() { # bug 19494
3175 local dir=$DIR/$tdir
3176 local ostfail=$(get_random_entry $(get_facets OST))
3178 if [[ $FAILURE_MODE = HARD ]]; then
3179 local affected=$(affected_facets $ostfail);
3180 if [[ "$affected" != $ostfail ]]; then
3181 skip not functional with FAILURE_MODE=$FAILURE_MODE, affected: $affected
3185 # maybe effected by previous test
3186 wait_osc_import_state mds ost FULL
3188 mkdir $dir || error "mkdir $dir failed"
3190 echo "Create the files"
3192 # file "f${index}" striped over 1 OST
3193 # file "all" striped over all OSTs
3195 $SETSTRIPE -c $OSTCOUNT $dir/all ||
3196 error "setstripe failed to create $dir/all"
3198 for (( i=0; i<$OSTCOUNT; i++ )); do
3200 $SETSTRIPE -i $i -c 1 $f || error "$SETSTRIPE failed to create $f"
3202 # confirm setstripe actually created the stripe on the requested OST
3203 local uuid=$(ostuuid_from_index $i)
3204 for file in f$i all; do
3205 if [[ $dir/$file != $($LFS find --obd $uuid --name $file $dir) ]]; then
3206 $GETSTRIPE $dir/$file
3207 error wrong stripe: $file, uuid: $uuid
3212 # Before failing an OST, get its obd name and index
3213 local varsvc=${ostfail}_svc
3214 local obd=$(do_facet $ostfail lctl get_param \
3215 -n obdfilter.${!varsvc}.uuid)
3216 local index=$(($(facet_number $ostfail) - 1))
3218 echo "Fail $ostfail $obd, display the list of affected files"
3219 shutdown_facet $ostfail || error "shutdown_facet $ostfail failed"
3221 trap "cleanup_90 $ostfail" EXIT INT
3222 echo "General Query: lfs find $dir"
3223 local list=$($LFS find $dir)
3225 for (( i=0; i<$OSTCOUNT; i++ )); do
3226 list_member "$list" $dir/f$i ||
3227 error_noexit "lfs find $dir: no file f$i"
3229 list_member "$list" $dir/all ||
3230 error_noexit "lfs find $dir: no file all"
3232 # focus on the missing OST,
3233 # we expect to see only two files affected: "f$(index)" and "all"
3235 echo "Querying files on shutdown $ostfail: lfs find --obd $obd"
3236 list=$($LFS find --obd $obd $dir)
3238 for file in all f$index; do
3239 list_member "$list" $dir/$file ||
3240 error_noexit "lfs find does not report the affected $obd for $file"
3243 [[ $(echo $list | wc -w) -eq 2 ]] ||
3244 error_noexit "lfs find reports the wrong list of affected files ${#list[@]}"
3246 echo "Check getstripe: $GETSTRIPE -r --obd $obd"
3247 list=$($GETSTRIPE -r --obd $obd $dir)
3249 for file in all f$index; do
3250 echo "$list" | grep $dir/$file ||
3251 error_noexit "lfs getsripe does not report the affected $obd for $file"
3256 run_test 90 "lfs find identifies the missing striped file segments"
3259 local server_version=$(lustre_version_code $SINGLEMDS)
3260 [[ $server_version -ge $(version_code 2.6.90) ]] ||
3261 [[ $server_version -ge $(version_code 2.5.4) &&
3262 $server_version -lt $(version_code 2.5.50) ]] ||
3263 { skip "Need MDS version 2.5.4+ or 2.6.90+"; return; }
3265 cancel_lru_locks osc
3267 $SETSTRIPE -i 0 -c 1 $DIR/$tfile ||
3268 error "$SETSTRIPE $DIR/$tfile failed"
3269 dd if=/dev/zero of=$DIR/$tfile bs=1024 count=1 ||
3270 error "dd to $DIR/$tfile failed"
3271 #define OBD_FAIL_TGT_REPLAY_RECONNECT 0x715
3272 # We need to emulate a state that OST is waiting for other clients
3273 # not completing the recovery. Final ping is queued, but reply will be
3274 # sent on the recovery completion. It is done by sleep before
3275 # processing final pings
3276 do_facet ost1 "$LCTL set_param fail_val=40"
3277 do_facet ost1 "$LCTL set_param fail_loc=0x715"
3280 run_test 93a "replay + reconnect"
3283 local server_version=$(lustre_version_code $SINGLEMDS)
3284 [[ $server_version -ge $(version_code 2.7.90) ]] ||
3285 { skip "Need MDS version 2.7.90+"; return; }
3287 cancel_lru_locks mdc
3289 createmany -o $DIR/$tfile 20 ||
3290 error "createmany -o $DIR/$tfile failed"
3292 #define OBD_FAIL_TGT_REPLAY_RECONNECT 0x715
3293 # We need to emulate a state that MDT is waiting for other clients
3294 # not completing the recovery. Final ping is queued, but reply will be
3295 # sent on the recovery completion. It is done by sleep before
3296 # processing final pings
3297 do_facet mds1 "$LCTL set_param fail_val=80"
3298 do_facet mds1 "$LCTL set_param fail_loc=0x715"
3301 run_test 93b "replay + reconnect on mds"
3303 striped_dir_check_100() {
3304 local striped_dir=$DIR/$tdir/striped_dir
3305 local stripe_count=$($LFS getdirstripe -c $striped_dir)
3307 $LFS getdirstripe $striped_dir
3308 [ $stripe_count -eq 2 ] || error "$stripe_count != 2"
3310 createmany -o $striped_dir/f-%d 20 ||
3311 error "creation failed under striped dir"
3315 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
3316 ([ $FAILURE_MODE == "HARD" ] &&
3317 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
3318 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
3321 local striped_dir=$DIR/$tdir/striped_dir
3324 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
3326 #To make sure MDT1 and MDT0 are connected
3327 #otherwise it may create single stripe dir here
3328 $LFS setdirstripe -i1 $DIR/$tdir/remote_dir
3330 #define OBD_FAIL_OUT_UPDATE_NET_REP 0x1701
3331 do_facet mds$((MDTIDX+1)) lctl set_param fail_loc=0x1701
3332 $LFS setdirstripe -i0 -c2 $striped_dir &
3335 fail mds$((MDTIDX + 1))
3337 wait $CLIENT_PID || error "striped dir creation failed"
3339 striped_dir_check_100 || error "striped dir check failed"
3340 rm -rf $DIR/$tdir || error "rmdir failed"
3342 run_test 100a "DNE: create striped dir, drop update rep from MDT1, fail MDT1"
3345 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
3346 ([ $FAILURE_MODE == "HARD" ] &&
3347 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
3348 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
3351 local striped_dir=$DIR/$tdir/striped_dir
3354 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
3356 #To make sure MDT1 and MDT0 are connected
3357 #otherwise it may create single stripe dir here
3358 $LFS setdirstripe -i1 $DIR/$tdir/remote_dir
3360 # OBD_FAIL_MDS_REINT_NET_REP 0x119
3361 do_facet mds$MDTIDX lctl set_param fail_loc=0x119
3362 $LFS mkdir -i0 -c2 $striped_dir &
3367 wait $CLIENT_PID || error "striped dir creation failed"
3369 striped_dir_check_100 || error "striped dir check failed"
3370 rm -rf $DIR/$tdir || error "rmdir failed"
3372 run_test 100b "DNE: create striped dir, fail MDT0"
3374 test_101() { #LU-5648
3375 mkdir -p $DIR/$tdir/d1
3376 mkdir -p $DIR/$tdir/d2
3377 touch $DIR/$tdir/file0
3380 replay_barrier $SINGLEMDS
3381 for i in $(seq $num) ; do
3382 echo test$i > $DIR/$tdir/d1/file$i
3385 fail_abort $SINGLEMDS
3386 for i in $(seq $num) ; do
3387 touch $DIR/$tdir/d2/file$i
3388 test -s $DIR/$tdir/d2/file$i &&
3389 ls -al $DIR/$tdir/d2/file$i && error "file$i's size > 0"
3394 run_test 101 "Shouldn't reassign precreated objs to other files after recovery"
3403 [[ $(lctl get_param mdc.*.import |
3404 grep "connect_flags:.*multi_mod_rpc") ]] ||
3405 { skip "Need MDC with 'multi_mod_rpcs' feature"; return 0; }
3407 $LFS mkdir -c1 $DIR/$tdir || error "mkdir $DIR/$tdir failed"
3408 idx=$(printf "%04x" $($LFS getdirstripe -i $DIR/$tdir))
3409 facet="mds$((0x$idx + 1))"
3411 # get current value of max_mod_rcps_in_flight
3412 num=$($LCTL get_param -n \
3413 mdc.$FSNAME-MDT$idx-mdc-*.max_mod_rpcs_in_flight)
3414 # set default value if client does not support multi mod RPCs
3415 [ -z "$num" ] && num=1
3417 echo "creating $num files ..."
3419 for i in $(seq $num); do
3420 touch $DIR/$tdir/file-$i
3423 # drop request on MDT to force resend
3424 #define OBD_FAIL_MDS_REINT_MULTI_NET 0x159
3425 do_facet $facet "$LCTL set_param fail_loc=0x159"
3426 echo "launch $num chmod in parallel ($(date +%H:%M:%S)) ..."
3427 for i in $(seq $num); do
3428 chmod 0600 $DIR/$tdir/file-$i &
3432 do_facet $facet "$LCTL set_param fail_loc=0"
3433 for pid in $pids; do
3434 wait $pid || error "chmod failed"
3436 echo "done ($(date +%H:%M:%S))"
3438 # check chmod succeed
3439 for i in $(seq $num); do
3440 checkstat -vp 0600 $DIR/$tdir/file-$i
3445 run_test 102a "check resend (request lost) with multiple modify RPCs in flight"
3454 [[ $(lctl get_param mdc.*.import |
3455 grep "connect_flags:.*multi_mod_rpc") ]] ||
3456 { skip "Need MDC with 'multi_mod_rpcs' feature"; return 0; }
3458 $LFS mkdir -c1 $DIR/$tdir || error "mkdir $DIR/$tdir failed"
3459 idx=$(printf "%04x" $($LFS getdirstripe -i $DIR/$tdir))
3460 facet="mds$((0x$idx + 1))"
3462 # get current value of max_mod_rcps_in_flight
3463 num=$($LCTL get_param -n \
3464 mdc.$FSNAME-MDT$idx-mdc-*.max_mod_rpcs_in_flight)
3465 # set default value if client does not support multi mod RPCs
3466 [ -z "$num" ] && num=1
3468 echo "creating $num files ..."
3470 for i in $(seq $num); do
3471 touch $DIR/$tdir/file-$i
3474 # drop reply on MDT to force reconstruction
3475 #define OBD_FAIL_MDS_REINT_MULTI_NET_REP 0x15a
3476 do_facet $facet "$LCTL set_param fail_loc=0x15a"
3477 echo "launch $num chmod in parallel ($(date +%H:%M:%S)) ..."
3478 for i in $(seq $num); do
3479 chmod 0600 $DIR/$tdir/file-$i &
3483 do_facet $facet "$LCTL set_param fail_loc=0"
3484 for pid in $pids; do
3485 wait $pid || error "chmod failed"
3487 echo "done ($(date +%H:%M:%S))"
3489 # check chmod succeed
3490 for i in $(seq $num); do
3491 checkstat -vp 0600 $DIR/$tdir/file-$i
3496 run_test 102b "check resend (reply lost) with multiple modify RPCs in flight"
3505 [[ $(lctl get_param mdc.*.import |
3506 grep "connect_flags:.*multi_mod_rpc") ]] ||
3507 { skip "Need MDC with 'multi_mod_rpcs' feature"; return 0; }
3509 $LFS mkdir -c1 $DIR/$tdir || error "mkdir $DIR/$tdir failed"
3510 idx=$(printf "%04x" $($LFS getdirstripe -i $DIR/$tdir))
3511 facet="mds$((0x$idx + 1))"
3513 # get current value of max_mod_rcps_in_flight
3514 num=$($LCTL get_param -n \
3515 mdc.$FSNAME-MDT$idx-mdc-*.max_mod_rpcs_in_flight)
3516 # set default value if client does not support multi mod RPCs
3517 [ -z "$num" ] && num=1
3519 echo "creating $num files ..."
3521 for i in $(seq $num); do
3522 touch $DIR/$tdir/file-$i
3525 replay_barrier $facet
3528 #define OBD_FAIL_MDS_REINT_MULTI_NET_REP 0x15a
3529 do_facet $facet "$LCTL set_param fail_loc=0x15a"
3530 echo "launch $num chmod in parallel ($(date +%H:%M:%S)) ..."
3531 for i in $(seq $num); do
3532 chmod 0600 $DIR/$tdir/file-$i &
3536 do_facet $facet "$LCTL set_param fail_loc=0"
3541 for pid in $pids; do
3542 wait $pid || error "chmod failed"
3544 echo "done ($(date +%H:%M:%S))"
3546 # check chmod succeed
3547 for i in $(seq $num); do
3548 checkstat -vp 0600 $DIR/$tdir/file-$i
3553 run_test 102c "check replay w/o reconstruction with multiple mod RPCs in flight"
3562 [[ $(lctl get_param mdc.*.import |
3563 grep "connect_flags:.*multi_mod_rpc") ]] ||
3564 { skip "Need MDC with 'multi_mod_rpcs' feature"; return 0; }
3566 $LFS mkdir -c1 $DIR/$tdir || error "mkdir $DIR/$tdir failed"
3567 idx=$(printf "%04x" $($LFS getdirstripe -i $DIR/$tdir))
3568 facet="mds$((0x$idx + 1))"
3570 # get current value of max_mod_rcps_in_flight
3571 num=$($LCTL get_param -n \
3572 mdc.$FSNAME-MDT$idx-mdc-*.max_mod_rpcs_in_flight)
3573 # set default value if client does not support multi mod RPCs
3574 [ -z "$num" ] && num=1
3576 echo "creating $num files ..."
3578 for i in $(seq $num); do
3579 touch $DIR/$tdir/file-$i
3583 #define OBD_FAIL_MDS_REINT_MULTI_NET_REP 0x15a
3584 do_facet $facet "$LCTL set_param fail_loc=0x15a"
3585 echo "launch $num chmod in parallel ($(date +%H:%M:%S)) ..."
3586 for i in $(seq $num); do
3587 chmod 0600 $DIR/$tdir/file-$i &
3592 # write MDT transactions to disk
3593 do_facet $facet "sync; sync; sync"
3595 do_facet $facet "$LCTL set_param fail_loc=0"
3600 for pid in $pids; do
3601 wait $pid || error "chmod failed"
3603 echo "done ($(date +%H:%M:%S))"
3605 # check chmod succeed
3606 for i in $(seq $num); do
3607 checkstat -vp 0600 $DIR/$tdir/file-$i
3612 run_test 102d "check replay & reconstruction with multiple mod RPCs in flight"
3615 remote_mds_nodsh && skip "remote MDS with nodsh" && return
3616 #define OBD_FAIL_MDS_TRACK_OVERFLOW 0x162
3617 do_facet mds1 $LCTL set_param fail_loc=0x80000162
3620 createmany -o $DIR/$tdir/t- 30 ||
3621 error "create files on remote directory failed"
3623 rm -rf $DIR/$tdir/t-*
3625 #MDS should crash with tr->otr_next_id overflow
3628 run_test 103 "Check otr_next_id overflow"
3631 check_striped_dir_110()
3633 $CHECKSTAT -t dir $DIR/$tdir/striped_dir ||
3634 error "create striped dir failed"
3635 local stripe_count=$($LFS getdirstripe -c $DIR/$tdir/striped_dir)
3636 [ $stripe_count -eq $MDSCOUNT ] ||
3637 error "$stripe_count != 2 after recovery"
3641 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
3642 ([ $FAILURE_MODE == "HARD" ] &&
3643 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
3644 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
3649 $LFS mkdir -i1 -c$MDSCOUNT $DIR/$tdir/striped_dir
3652 check_striped_dir_110 || error "check striped_dir failed"
3653 rm -rf $DIR/$tdir || error "rmdir failed"
3657 run_test 110a "DNE: create striped dir, fail MDT1"
3660 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
3661 ([ $FAILURE_MODE == "HARD" ] &&
3662 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
3663 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
3668 $LFS mkdir -i1 -c$MDSCOUNT $DIR/$tdir/striped_dir
3671 zconf_mount $(hostname) $MOUNT
3672 client_up || return 1
3674 check_striped_dir_110 || error "check striped_dir failed"
3676 rm -rf $DIR/$tdir || error "rmdir failed"
3680 run_test 110b "DNE: create striped dir, fail MDT1 and client"
3683 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
3684 ([ $FAILURE_MODE == "HARD" ] &&
3685 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
3686 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
3691 $LFS mkdir -i1 -c$MDSCOUNT $DIR/$tdir/striped_dir
3694 check_striped_dir_110 || error "check striped_dir failed"
3696 rm -rf $DIR/$tdir || error "rmdir failed"
3700 run_test 110c "DNE: create striped dir, fail MDT2"
3703 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
3704 ([ $FAILURE_MODE == "HARD" ] &&
3705 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
3706 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
3711 $LFS mkdir -i1 -c$MDSCOUNT $DIR/$tdir/striped_dir
3714 zconf_mount $(hostname) $MOUNT
3715 client_up || return 1
3717 check_striped_dir_110 || error "check striped_dir failed"
3719 rm -rf $DIR/$tdir || error "rmdir failed"
3723 run_test 110d "DNE: create striped dir, fail MDT2 and client"
3726 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
3727 ([ $FAILURE_MODE == "HARD" ] &&
3728 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
3729 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
3734 $LFS mkdir -i1 -c$MDSCOUNT $DIR/$tdir/striped_dir
3738 zconf_mount $(hostname) $MOUNT
3739 client_up || return 1
3741 check_striped_dir_110 || error "check striped_dir failed"
3743 rm -rf $DIR/$tdir || error "rmdir failed"
3747 run_test 110e "DNE: create striped dir, uncommit on MDT2, fail client/MDT1/MDT2"
3750 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
3751 ([ $FAILURE_MODE == "HARD" ] &&
3752 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
3753 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
3759 $LFS mkdir -i1 -c$MDSCOUNT $DIR/$tdir/striped_dir
3762 check_striped_dir_110 || error "check striped_dir failed"
3764 rm -rf $DIR/$tdir || error "rmdir failed"
3768 run_test 110f "DNE: create striped dir, fail MDT1/MDT2"
3771 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
3772 ([ $FAILURE_MODE == "HARD" ] &&
3773 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
3774 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
3779 $LFS mkdir -i1 -c$MDSCOUNT $DIR/$tdir/striped_dir
3783 zconf_mount $(hostname) $MOUNT
3784 client_up || return 1
3786 check_striped_dir_110 || error "check striped_dir failed"
3788 rm -rf $DIR/$tdir || error "rmdir failed"
3792 run_test 110g "DNE: create striped dir, uncommit on MDT1, fail client/MDT1/MDT2"
3795 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
3796 ([ $FAILURE_MODE == "HARD" ] &&
3797 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
3798 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
3802 $LFS mkdir -i1 -c2 $DIR/$tdir/striped_dir
3804 rm -rf $DIR/$tdir/striped_dir
3807 $CHECKSTAT -t dir $DIR/$tdir/striped_dir &&
3808 error "striped dir still exists"
3811 run_test 111a "DNE: unlink striped dir, fail MDT1"
3814 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
3815 ([ $FAILURE_MODE == "HARD" ] &&
3816 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
3817 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
3821 $LFS mkdir -i1 -c2 $DIR/$tdir/striped_dir
3823 rm -rf $DIR/$tdir/striped_dir
3826 zconf_mount $(hostname) $MOUNT
3827 client_up || return 1
3829 $CHECKSTAT -t dir $DIR/$tdir/striped_dir &&
3830 error "striped dir still exists"
3833 run_test 111b "DNE: unlink striped dir, fail MDT2"
3836 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
3837 ([ $FAILURE_MODE == "HARD" ] &&
3838 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
3839 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
3843 $LFS mkdir -i1 -c2 $DIR/$tdir/striped_dir
3845 rm -rf $DIR/$tdir/striped_dir
3849 zconf_mount $(hostname) $MOUNT
3850 client_up || return 1
3851 $CHECKSTAT -t dir $DIR/$tdir/striped_dir &&
3852 error "striped dir still exists"
3855 run_test 111c "DNE: unlink striped dir, uncommit on MDT1, fail client/MDT1/MDT2"
3858 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
3859 ([ $FAILURE_MODE == "HARD" ] &&
3860 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
3861 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
3865 $LFS mkdir -i1 -c2 $DIR/$tdir/striped_dir
3867 rm -rf $DIR/$tdir/striped_dir
3871 zconf_mount $(hostname) $MOUNT
3872 client_up || return 1
3873 $CHECKSTAT -t dir $DIR/$tdir/striped_dir &&
3874 error "striped dir still exists"
3878 run_test 111d "DNE: unlink striped dir, uncommit on MDT2, fail client/MDT1/MDT2"
3881 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
3882 ([ $FAILURE_MODE == "HARD" ] &&
3883 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
3884 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
3888 $LFS mkdir -i1 -c2 $DIR/$tdir/striped_dir
3890 rm -rf $DIR/$tdir/striped_dir
3893 $CHECKSTAT -t dir $DIR/$tdir/striped_dir &&
3894 error "striped dir still exists"
3897 run_test 111e "DNE: unlink striped dir, uncommit on MDT2, fail MDT1/MDT2"
3900 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
3901 ([ $FAILURE_MODE == "HARD" ] &&
3902 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
3903 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
3907 $LFS mkdir -i1 -c2 $DIR/$tdir/striped_dir
3909 rm -rf $DIR/$tdir/striped_dir
3912 $CHECKSTAT -t dir $DIR/$tdir/striped_dir &&
3913 error "striped dir still exists"
3916 run_test 111f "DNE: unlink striped dir, uncommit on MDT1, fail MDT1/MDT2"
3919 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
3920 ([ $FAILURE_MODE == "HARD" ] &&
3921 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
3922 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
3926 $LFS mkdir -i1 -c2 $DIR/$tdir/striped_dir
3929 rm -rf $DIR/$tdir/striped_dir
3931 $CHECKSTAT -t dir $DIR/$tdir/striped_dir &&
3932 error "striped dir still exists"
3935 run_test 111g "DNE: unlink striped dir, fail MDT1/MDT2"
3937 test_112_rename_prepare() {
3938 mkdir -p $DIR/$tdir/src_dir
3939 $LFS mkdir -i 1 $DIR/$tdir/src_dir/src_child ||
3940 error "create remote source failed"
3942 touch $DIR/$tdir/src_dir/src_child/a
3944 $LFS mkdir -i 2 $DIR/$tdir/tgt_dir ||
3945 error "create remote target dir failed"
3947 $LFS mkdir -i 3 $DIR/$tdir/tgt_dir/tgt_child ||
3948 error "create remote target child failed"
3953 $CHECKSTAT -t dir $DIR/$tdir/src_dir/src_child &&
3954 error "src_child still exists after rename"
3956 $CHECKSTAT -t file $DIR/$tdir/tgt_dir/tgt_child/a ||
3957 error "missing file(a) after rename"
3961 [ $MDSCOUNT -lt 4 ] && skip "needs >= 4 MDTs" && return 0
3962 ([ $FAILURE_MODE == "HARD" ] &&
3963 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
3964 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
3967 test_112_rename_prepare
3970 mrename $DIR/$tdir/src_dir/src_child $DIR/$tdir/tgt_dir/tgt_child ||
3971 error "rename dir cross MDT failed!"
3975 rm -rf $DIR/$tdir || error "rmdir failed"
3977 run_test 112a "DNE: cross MDT rename, fail MDT1"
3980 [ $MDSCOUNT -lt 4 ] && skip "needs >= 4 MDTs" && return 0
3981 ([ $FAILURE_MODE == "HARD" ] &&
3982 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
3983 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
3986 test_112_rename_prepare
3989 mrename $DIR/$tdir/src_dir/src_child $DIR/$tdir/tgt_dir/tgt_child ||
3990 error "rename dir cross MDT failed!"
3995 rm -rf $DIR/$tdir || error "rmdir failed"
3997 run_test 112b "DNE: cross MDT rename, fail MDT2"
4000 [ $MDSCOUNT -lt 4 ] && skip "needs >= 4 MDTs" && return 0
4001 ([ $FAILURE_MODE == "HARD" ] &&
4002 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
4003 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
4006 test_112_rename_prepare
4009 mrename $DIR/$tdir/src_dir/src_child $DIR/$tdir/tgt_dir/tgt_child ||
4010 error "rename dir cross MDT failed!"
4015 rm -rf $DIR/$tdir || error "rmdir failed"
4017 run_test 112c "DNE: cross MDT rename, fail MDT3"
4020 [ $MDSCOUNT -lt 4 ] && skip "needs >= 4 MDTs" && return 0
4021 ([ $FAILURE_MODE == "HARD" ] &&
4022 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
4023 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
4026 test_112_rename_prepare
4029 mrename $DIR/$tdir/src_dir/src_child $DIR/$tdir/tgt_dir/tgt_child ||
4030 error "rename dir cross MDT failed!"
4035 rm -rf $DIR/$tdir || error "rmdir failed"
4037 run_test 112d "DNE: cross MDT rename, fail MDT4"
4040 [ $MDSCOUNT -lt 4 ] && skip "needs >= 4 MDTs" && return 0
4041 ([ $FAILURE_MODE == "HARD" ] &&
4042 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
4043 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
4046 test_112_rename_prepare
4050 mrename $DIR/$tdir/src_dir/src_child $DIR/$tdir/tgt_dir/tgt_child ||
4051 error "rename dir cross MDT failed!"
4056 rm -rf $DIR/$tdir || error "rmdir failed"
4058 run_test 112e "DNE: cross MDT rename, fail MDT1 and MDT2"
4061 [ $MDSCOUNT -lt 4 ] && skip "needs >= 4 MDTs" && return 0
4062 ([ $FAILURE_MODE == "HARD" ] &&
4063 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
4064 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
4067 test_112_rename_prepare
4071 mrename $DIR/$tdir/src_dir/src_child $DIR/$tdir/tgt_dir/tgt_child ||
4072 error "rename dir cross MDT failed!"
4077 rm -rf $DIR/$tdir || error "rmdir failed"
4079 run_test 112f "DNE: cross MDT rename, fail MDT1 and MDT3"
4082 [ $MDSCOUNT -lt 4 ] && skip "needs >= 4 MDTs" && return 0
4083 ([ $FAILURE_MODE == "HARD" ] &&
4084 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
4085 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
4088 test_112_rename_prepare
4092 mrename $DIR/$tdir/src_dir/src_child $DIR/$tdir/tgt_dir/tgt_child ||
4093 error "rename dir cross MDT failed!"
4098 rm -rf $DIR/$tdir || error "rmdir failed"
4100 run_test 112g "DNE: cross MDT rename, fail MDT1 and MDT4"
4103 [ $MDSCOUNT -lt 4 ] && skip "needs >= 4 MDTs" && return 0
4104 ([ $FAILURE_MODE == "HARD" ] &&
4105 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
4106 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
4109 test_112_rename_prepare
4113 mrename $DIR/$tdir/src_dir/src_child $DIR/$tdir/tgt_dir/tgt_child ||
4114 error "rename dir cross MDT failed!"
4119 rm -rf $DIR/$tdir || error "rmdir failed"
4121 run_test 112h "DNE: cross MDT rename, fail MDT2 and MDT3"
4124 [ $MDSCOUNT -lt 4 ] && skip "needs >= 4 MDTs" && return 0
4125 ([ $FAILURE_MODE == "HARD" ] &&
4126 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
4127 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
4130 test_112_rename_prepare
4134 mrename $DIR/$tdir/src_dir/src_child $DIR/$tdir/tgt_dir/tgt_child ||
4135 error "rename dir cross MDT failed!"
4140 rm -rf $DIR/$tdir || error "rmdir failed"
4142 run_test 112i "DNE: cross MDT rename, fail MDT2 and MDT4"
4145 [ $MDSCOUNT -lt 4 ] && skip "needs >= 4 MDTs" && return 0
4146 ([ $FAILURE_MODE == "HARD" ] &&
4147 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
4148 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
4151 test_112_rename_prepare
4155 mrename $DIR/$tdir/src_dir/src_child $DIR/$tdir/tgt_dir/tgt_child ||
4156 error "rename dir cross MDT failed!"
4161 rm -rf $DIR/$tdir || error "rmdir failed"
4163 run_test 112j "DNE: cross MDT rename, fail MDT3 and MDT4"
4166 [ $MDSCOUNT -lt 4 ] && skip "needs >= 4 MDTs" && return 0
4167 ([ $FAILURE_MODE == "HARD" ] &&
4168 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
4169 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
4172 test_112_rename_prepare
4177 mrename $DIR/$tdir/src_dir/src_child $DIR/$tdir/tgt_dir/tgt_child ||
4178 error "rename dir cross MDT failed!"
4183 rm -rf $DIR/$tdir || error "rmdir failed"
4185 run_test 112k "DNE: cross MDT rename, fail MDT1,MDT2,MDT3"
4188 [ $MDSCOUNT -lt 4 ] && skip "needs >= 4 MDTs" && return 0
4189 ([ $FAILURE_MODE == "HARD" ] &&
4190 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
4191 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
4194 test_112_rename_prepare
4199 mrename $DIR/$tdir/src_dir/src_child $DIR/$tdir/tgt_dir/tgt_child ||
4200 error "rename dir cross MDT failed!"
4205 rm -rf $DIR/$tdir || error "rmdir failed"
4207 run_test 112l "DNE: cross MDT rename, fail MDT1,MDT2,MDT4"
4210 [ $MDSCOUNT -lt 4 ] && skip "needs >= 4 MDTs" && return 0
4211 ([ $FAILURE_MODE == "HARD" ] &&
4212 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
4213 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
4216 test_112_rename_prepare
4221 mrename $DIR/$tdir/src_dir/src_child $DIR/$tdir/tgt_dir/tgt_child ||
4222 error "rename dir cross MDT failed!"
4227 rm -rf $DIR/$tdir || error "rmdir failed"
4229 run_test 112m "DNE: cross MDT rename, fail MDT1,MDT3,MDT4"
4232 [ $MDSCOUNT -lt 4 ] && skip "needs >= 4 MDTs" && return 0
4233 ([ $FAILURE_MODE == "HARD" ] &&
4234 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
4235 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
4238 test_112_rename_prepare
4243 mrename $DIR/$tdir/src_dir/src_child $DIR/$tdir/tgt_dir/tgt_child ||
4244 error "rename dir cross MDT failed!"
4249 rm -rf $DIR/$tdir || error "rmdir failed"
4251 run_test 112n "DNE: cross MDT rename, fail MDT2,MDT3,MDT4"
4254 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
4255 ([ $FAILURE_MODE == "HARD" ] &&
4256 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
4257 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
4265 for ((j=0;j<$((MDSCOUNT));j++)); do
4266 fail_index=$((fail_index+1))
4267 index=$((fail_index % MDSCOUNT))
4268 replay_barrier mds$((index + 1))
4269 for ((i=0;i<5;i++)); do
4270 test_mkdir -i$index -c$MDSCOUNT $DIR/$tdir/test_$i ||
4271 error "create striped dir $DIR/$tdir/test_$i"
4274 fail mds$((index + 1))
4275 for ((i=0;i<5;i++)); do
4276 checkstat -t dir $DIR/$tdir/test_$i ||
4277 error "$DIR/$tdir/test_$i does not exist!"
4279 rm -rf $DIR/$tdir/test_* ||
4283 run_test 115 "failover for create/unlink striped directory"
4286 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
4287 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.55) ] &&
4288 skip "Do not support large update log before 2.7.55" &&
4290 ([ $FAILURE_MODE == "HARD" ] &&
4291 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
4292 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
4299 # OBD_FAIL_SPLIT_UPDATE_REC 0x1702
4300 do_facet mds1 "lctl set_param fail_loc=0x80001702"
4301 $LFS setdirstripe -c$MDSCOUNT $DIR/$tdir/striped_dir
4304 $CHECKSTAT -t dir $DIR/$tdir/striped_dir ||
4305 error "stried_dir does not exists"
4307 run_test 116a "large update log master MDT recovery"
4310 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
4311 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.55) ] &&
4312 skip "Do not support large update log before 2.7.55" &&
4315 ([ $FAILURE_MODE == "HARD" ] &&
4316 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
4317 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
4324 # OBD_FAIL_SPLIT_UPDATE_REC 0x1702
4325 do_facet mds2 "lctl set_param fail_loc=0x80001702"
4326 $LFS setdirstripe -c$MDSCOUNT $DIR/$tdir/striped_dir
4329 $CHECKSTAT -t dir $DIR/$tdir/striped_dir ||
4330 error "stried_dir does not exists"
4332 run_test 116b "large update log slave MDT recovery"
4335 [ $MDSCOUNT -lt 4 ] && skip "needs >= 4 MDTs" && return 0
4336 ([ $FAILURE_MODE == "HARD" ] &&
4337 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
4338 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
4344 $LFS setdirstripe -i0 -c$MDSCOUNT $DIR/$tdir/remote_dir
4345 $LFS setdirstripe -i1 -c$MDSCOUNT $DIR/$tdir/remote_dir_1
4348 # Let's set rdonly on all MDTs, so client will send
4349 # replay requests on all MDTs and replay these requests
4350 # at the same time. This test will verify the recovery
4351 # will not be deadlock in this case, LU-7531.
4352 for ((index = 0; index < $((MDSCOUNT)); index++)); do
4353 replay_barrier mds$((index + 1))
4354 if [ -z $mds_indexs ]; then
4355 mds_indexs="${mds_indexs}mds$((index+1))"
4357 mds_indexs="${mds_indexs},mds$((index+1))"
4361 rm -rf $DIR/$tdir/remote_dir
4362 rm -rf $DIR/$tdir/remote_dir_1
4366 rm -rf $DIR/$tdir || error "rmdir failed"
4368 run_test 117 "DNE: cross MDT unlink, fail MDT1 and MDT2"
4371 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
4372 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.64) ] &&
4373 skip "Do not support large update log before 2.7.64" &&
4378 $LFS setdirstripe -c2 $DIR/$tdir/striped_dir ||
4379 error "setdirstripe fails"
4380 $LFS setdirstripe -c2 $DIR/$tdir/striped_dir1 ||
4381 error "setdirstripe fails 1"
4382 rm -rf $DIR/$tdir/striped_dir* || error "rmdir fails"
4384 # OBD_FAIL_INVALIDATE_UPDATE 0x1705
4385 do_facet mds1 "lctl set_param fail_loc=0x1705"
4386 $LFS setdirstripe -c2 $DIR/$tdir/striped_dir
4387 $LFS setdirstripe -c2 $DIR/$tdir/striped_dir1
4388 do_facet mds1 "lctl set_param fail_loc=0x0"
4391 $LFS setdirstripe -c2 $DIR/$tdir/striped_dir
4392 $LFS setdirstripe -c2 $DIR/$tdir/striped_dir1
4397 run_test 118 "invalidate osp update will not cause update log corruption"
4400 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
4401 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.64) ] &&
4402 skip "Do not support large update log before 2.7.64" &&
4405 local hard_timeout=$(do_facet mds1 \
4406 "lctl get_param -n mdt.$FSNAME-MDT0000.recovery_time_hard")
4408 local clients=${CLIENTS:-$HOSTNAME}
4409 local time_min=$(recovery_time_min)
4412 mkdir $DIR/$tdir/tmp
4413 rmdir $DIR/$tdir/tmp
4416 mkdir $DIR/$tdir/dir_1
4417 for ((i = 0; i < 20; i++)); do
4418 $LFS setdirstripe -c2 $DIR/$tdir/stripe_dir-$i
4425 #define OBD_FAIL_TGT_REPLAY_DELAY 0x714
4426 do_facet mds1 $LCTL set_param fail_loc=0x80000714
4427 #sleep (timeout + 5), so mds will evict the client exports,
4428 #but DNE update recovery will keep going.
4429 do_facet mds1 $LCTL set_param fail_val=$((time_min + 5))
4431 mount_facet mds1 "-o recovery_time_hard=$time_min"
4433 wait_clients_import_state "$clients" mds1 FULL
4435 clients_up || clients_up || error "failover df: $?"
4437 #revert back the hard timeout
4438 do_facet mds1 $LCTL set_param \
4439 mdt.$FSNAME-MDT0000.recovery_time_hard=$hard_timeout
4441 for ((i = 0; i < 20; i++)); do
4442 stripe_count=$($LFS getdirstripe -c $DIR/$tdir/stripe_dir-$i)
4443 [ $stripe_count == 2 ] || {
4444 error "stripe_dir-$i creation replay fails"
4449 run_test 119 "timeout of normal replay does not cause DNE replay fails "
4452 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
4453 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.64) ] &&
4454 skip "Do not support large update log before 2.7.64" &&
4458 replay_barrier_nosync mds1
4459 for ((i = 0; i < 20; i++)); do
4460 mkdir $DIR/$tdir/dir-$i || {
4461 error "create dir-$i fails"
4464 $LFS setdirstripe -c2 $DIR/$tdir/stripe_dir-$i || {
4465 error "create stripe_dir-$i fails"
4472 for ((i = 0; i < 20; i++)); do
4473 [ ! -e "$DIR/$tdir/dir-$i" ] || {
4474 error "dir-$i still exists"
4477 [ ! -e "$DIR/$tdir/stripe_dir-$i" ] || {
4478 error "stripe_dir-$i still exists"
4483 run_test 120 "DNE fail abort should stop both normal and DNE replay"
4486 check_and_cleanup_lustre