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:
25 ALWAYS_EXCEPT="$REPLAY_SINGLE_EXCEPT "
26 # UPDATE THE COMMENT ABOVE WITH BUG NUMBERS WHEN CHANGING ALWAYS_EXCEPT!
28 # time in minutes: 7.5"
29 [ "$SLOW" = "no" ] && EXCEPT_SLOW="44b"
31 if [ $(facet_fstype $SINGLEMDS) = "zfs" ]; then
32 # bug number for skipped test: LU-11388
34 if [ $MDSCOUNT -gt 1 ]; then
35 # bug number for skipped test: LU-10740 LU-11330 LU-9157 LU-11336
36 ALWAYS_EXCEPT+=" 2d 70d 80c 80d"
40 # bug number for skipped tests: LU-9795 (all below)
41 ALWAYS_EXCEPT="$ALWAYS_EXCEPT 0b 0c 0d 34 45"
42 ALWAYS_EXCEPT="$ALWAYS_EXCEPT 47 58b 58c 71a 85a"
43 ALWAYS_EXCEPT="$ALWAYS_EXCEPT 85b 86 88 89 90"
44 ALWAYS_EXCEPT="$ALWAYS_EXCEPT 93a 100a 100b 120"
49 check_and_setup_lustre
54 rm -rf $DIR/[df][0-9]* $DIR/f.$TESTSUITE.*
56 # LU-482 Avert LVM and VM inability to flush caches in pre .33 kernels
57 if [ $LINUX_VERSION_CODE -lt $(version_code 2.6.33) ]; then
59 do_facet $SINGLEMDS sync
62 test_0a() { # was test_0
63 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
64 replay_barrier $SINGLEMDS
68 run_test 0a "empty replay"
71 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
73 # this test attempts to trigger a race in the precreation code,
74 # and must run before any other objects are created on the filesystem
76 createmany -o $DIR/$tfile 20 || error "createmany -o $DIR/$tfile failed"
77 unlinkmany $DIR/$tfile 20 || error "unlinkmany $DIR/$tfile failed"
79 run_test 0b "ensure object created after recover exists. (3284)"
82 replay_barrier $SINGLEMDS
85 facet_failover $SINGLEMDS
86 zconf_mount $(hostname) $MOUNT || error "mount fails"
87 client_up || error "post-failover df failed"
88 # file shouldn't exist if replay-barrier works as expected
89 rm $DIR/$tfile && error "File exists and it shouldn't"
92 run_test 0c "check replay-barrier"
95 replay_barrier $SINGLEMDS
97 facet_failover $SINGLEMDS
98 zconf_mount $(hostname) $MOUNT || error "mount fails"
99 client_up || error "post-failover df failed"
101 run_test 0d "expired recovery with no clients"
104 replay_barrier $SINGLEMDS
107 $CHECKSTAT -t file $DIR/$tfile ||
108 error "$CHECKSTAT $DIR/$tfile attribute check failed"
111 run_test 1 "simple create"
114 replay_barrier $SINGLEMDS
117 $CHECKSTAT -t file $DIR/$tfile ||
118 error "$CHECKSTAT $DIR/$tfile attribute check failed"
124 mcreate $DIR/$tfile || error "mcreate $DIR/$tfile failed"
125 replay_barrier $SINGLEMDS
128 $CHECKSTAT -t file $DIR/$tfile ||
129 error "$CHECKSTAT $DIR/$tfile attribute check failed"
135 replay_barrier $SINGLEMDS
136 $LFS setstripe -c $OSTCOUNT $DIR/$tfile
138 $CHECKSTAT -t file $DIR/$tfile ||
139 error "$CHECKSTAT $DIR/$tfile check failed"
141 run_test 2c "setstripe replay"
144 replay_barrier $SINGLEMDS
145 $LFS setdirstripe -i 0 -c $MDSCOUNT $DIR/$tdir
147 $CHECKSTAT -t dir $DIR/$tdir ||
148 error "$CHECKSTAT $DIR/$tdir check failed"
150 run_test 2d "setdirstripe replay"
153 local file=$DIR/$tfile
154 replay_barrier $SINGLEMDS
156 openfile -f O_DIRECTORY $file
158 $CHECKSTAT -t file $file ||
159 error "$CHECKSTAT $file attribute check failed"
162 run_test 3a "replay failed open(O_DIRECTORY)"
165 replay_barrier $SINGLEMDS
166 #define OBD_FAIL_MDS_OPEN_PACK | OBD_FAIL_ONCE
167 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000114"
169 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
171 $CHECKSTAT -t file $DIR/$tfile &&
172 error "$CHECKSTAT $DIR/$tfile attribute check should fail"
175 run_test 3b "replay failed open -ENOMEM"
178 replay_barrier $SINGLEMDS
179 #define OBD_FAIL_MDS_ALLOC_OBDO | OBD_FAIL_ONCE
180 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000128"
182 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
185 $CHECKSTAT -t file $DIR/$tfile &&
186 error "$CHECKSTAT $DIR/$tfile attribute check should fail"
189 run_test 3c "replay failed open -ENOMEM"
191 test_4a() { # was test_4
192 replay_barrier $SINGLEMDS
193 for i in $(seq 10); do
194 echo "tag-$i" > $DIR/$tfile-$i
197 for i in $(seq 10); do
198 grep -q "tag-$i" $DIR/$tfile-$i || error "$tfile-$i"
201 run_test 4a "|x| 10 open(O_CREAT)s"
204 for i in $(seq 10); do
205 echo "tag-$i" > $DIR/$tfile-$i
207 replay_barrier $SINGLEMDS
210 $CHECKSTAT -t file $DIR/$tfile-* &&
211 error "$CHECKSTAT $DIR/$tfile-* attribute check should fail" ||
214 run_test 4b "|x| rm 10 files"
216 # The idea is to get past the first block of precreated files on both
217 # osts, and then replay.
219 replay_barrier $SINGLEMDS
220 for i in $(seq 220); do
221 echo "tag-$i" > $DIR/$tfile-$i
224 for i in $(seq 220); do
225 grep -q "tag-$i" $DIR/$tfile-$i || error "$tfile-$i"
229 # waiting for commitment of removal
231 run_test 5 "|x| 220 open(O_CREAT)"
233 test_6a() { # was test_6
234 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
235 replay_barrier $SINGLEMDS
236 mcreate $DIR/$tdir/$tfile
238 $CHECKSTAT -t dir $DIR/$tdir ||
239 error "$CHECKSTAT $DIR/$tdir attribute check failed"
240 $CHECKSTAT -t file $DIR/$tdir/$tfile ||
241 error "$CHECKSTAT $DIR/$tdir/$tfile attribute check failed"
243 # waiting for log process thread
245 run_test 6a "mkdir + contained create"
248 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
249 replay_barrier $SINGLEMDS
252 $CHECKSTAT -t dir $DIR/$tdir &&
253 error "$CHECKSTAT $DIR/$tdir attribute check should fail" ||
256 run_test 6b "|X| rmdir"
259 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
260 replay_barrier $SINGLEMDS
261 mcreate $DIR/$tdir/$tfile
263 $CHECKSTAT -t dir $DIR/$tdir ||
264 error "$CHECKSTAT $DIR/$tdir attribute check failed"
265 $CHECKSTAT -t file $DIR/$tdir/$tfile ||
266 error "$CHECKSTAT $DIR/$tdir/$tfile attribute check failed"
269 run_test 7 "mkdir |X| contained create"
272 replay_barrier $SINGLEMDS
273 multiop_bg_pause $DIR/$tfile mo_c ||
274 error "multiop mknod $DIR/$tfile failed"
278 $CHECKSTAT -t file $DIR/$tfile ||
279 error "$CHECKSTAT $DIR/$tfile attribute check failed"
280 kill -USR1 $MULTIPID || error "multiop mknod $MULTIPID not running"
281 wait $MULTIPID || error "multiop mknod $MULTIPID failed"
284 run_test 8 "creat open |X| close"
287 replay_barrier $SINGLEMDS
289 local old_inum=$(ls -i $DIR/$tfile | awk '{print $1}')
291 local new_inum=$(ls -i $DIR/$tfile | awk '{print $1}')
293 echo " old_inum == $old_inum, new_inum == $new_inum"
294 if [ $old_inum -eq $new_inum ] ;
296 echo "old_inum and new_inum match"
298 echo " old_inum and new_inum do not match"
299 error "old index($old_inum) does not match new index($new_inum)"
303 run_test 9 "|X| create (same inum/gen)"
306 mcreate $DIR/$tfile || error "mcreate $DIR/$tfile failed"
307 replay_barrier $SINGLEMDS
308 mv $DIR/$tfile $DIR/$tfile-2
311 $CHECKSTAT $DIR/$tfile &&
312 error "$CHECKSTAT $DIR/$tfile attribute check should fail"
313 $CHECKSTAT $DIR/$tfile-2 ||
314 error "$CHECKSTAT $DIR/$tfile-2 attribute check failed"
318 run_test 10 "create |X| rename unlink"
321 mcreate $DIR/$tfile || error "mcreate $DIR/$tfile failed"
322 echo "old" > $DIR/$tfile
323 mv $DIR/$tfile $DIR/$tfile-2
324 replay_barrier $SINGLEMDS
325 echo "new" > $DIR/$tfile
327 grep old $DIR/$tfile-2
329 grep new $DIR/$tfile || error "grep $DIR/$tfile failed"
330 grep old $DIR/$tfile-2 || error "grep $DIR/$tfile-2 failed"
332 run_test 11 "create open write rename |X| create-old-name read"
335 mcreate $DIR/$tfile || error "mcreate $DIR/$tfile failed"
336 multiop_bg_pause $DIR/$tfile o_tSc ||
337 error "multiop_bg_pause $DIR/$tfile failed"
340 replay_barrier $SINGLEMDS
341 kill -USR1 $pid || error "multiop $pid not running"
342 wait $pid || error "multiop $pid failed"
345 [ -e $DIR/$tfile ] && error "file $DIR/$tfile should not exist"
348 run_test 12 "open, unlink |X| close"
350 # 1777 - replay open after committed chmod that would make
351 # a regular open a failure
353 mcreate $DIR/$tfile || error "mcreate $DIR/$tfile failed"
354 multiop_bg_pause $DIR/$tfile O_wc ||
355 error "multiop_bg_pause $DIR/$tfile failed"
358 $CHECKSTAT -p 0 $DIR/$tfile ||
359 error "$CHECKSTAT $DIR/$tfile attribute check failed"
360 replay_barrier $SINGLEMDS
362 kill -USR1 $pid || error "multiop $pid not running"
363 wait $pid || error "multiop $pid failed"
365 $CHECKSTAT -s 1 -p 0 $DIR/$tfile ||
366 error "second $CHECKSTAT $DIR/$tfile attribute check failed"
367 rm $DIR/$tfile || error "rm $DIR/$tfile failed"
370 run_test 13 "open chmod 0 |x| write close"
373 multiop_bg_pause $DIR/$tfile O_tSc ||
374 error "multiop_bg_pause $DIR/$tfile failed"
377 replay_barrier $SINGLEMDS
378 kill -USR1 $pid || error "multiop $pid not running"
379 wait $pid || error "multiop $pid failed"
382 [ -e $DIR/$tfile ] && error "file $DIR/$tfile should not exist"
385 run_test 14 "open(O_CREAT), unlink |X| close"
388 multiop_bg_pause $DIR/$tfile O_tSc ||
389 error "multiop_bg_pause $DIR/$tfile failed"
392 replay_barrier $SINGLEMDS
393 touch $DIR/$tfile-1 || error "touch $DIR/$tfile-1 failed"
394 kill -USR1 $pid || error "multiop $pid not running"
395 wait $pid || error "multiop $pid failed"
398 [ -e $DIR/$tfile ] && error "file $DIR/$tfile should not exist"
399 touch $DIR/$tfile-2 || error "touch $DIR/$tfile-2 failed"
402 run_test 15 "open(O_CREAT), unlink |X| touch new, close"
405 replay_barrier $SINGLEMDS
408 mcreate $DIR/$tfile-2
410 [ -e $DIR/$tfile ] && error "file $DIR/$tfile should not exist"
411 [ -e $DIR/$tfile-2 ] || error "file $DIR/$tfile-2 does not exist"
412 munlink $DIR/$tfile-2 || error "munlink $DIR/$tfile-2 failed"
414 run_test 16 "|X| open(O_CREAT), unlink, touch new, unlink new"
417 replay_barrier $SINGLEMDS
418 multiop_bg_pause $DIR/$tfile O_c ||
419 error "multiop_bg_pause $DIR/$tfile failed"
422 kill -USR1 $pid || error "multiop $pid not running"
423 wait $pid || error "multiop $pid failed"
424 $CHECKSTAT -t file $DIR/$tfile ||
425 error "$CHECKSTAT $DIR/$tfile attribute check failed"
428 run_test 17 "|X| open(O_CREAT), |replay| close"
431 replay_barrier $SINGLEMDS
432 multiop_bg_pause $DIR/$tfile O_tSc ||
433 error "multiop_bg_pause $DIR/$tfile failed"
436 touch $DIR/$tfile-2 || error "touch $DIR/$tfile-2 failed"
437 echo "pid: $pid will close"
438 kill -USR1 $pid || error "multiop $pid not running"
439 wait $pid || error "multiop $pid failed"
442 [ -e $DIR/$tfile ] && error "file $DIR/$tfile should not exist"
443 [ -e $DIR/$tfile-2 ] || error "file $DIR/$tfile-2 does not exist"
444 # this touch frequently fails
445 touch $DIR/$tfile-3 || error "touch $DIR/$tfile-3 failed"
446 munlink $DIR/$tfile-2 || error "munlink $DIR/$tfile-2 failed"
447 munlink $DIR/$tfile-3 || error "munlink $DIR/$tfile-3 failed"
450 run_test 18 "open(O_CREAT), unlink, touch new, close, touch, unlink"
452 # bug 1855 (a simpler form of test_11 above)
454 replay_barrier $SINGLEMDS
456 echo "old" > $DIR/$tfile
457 mv $DIR/$tfile $DIR/$tfile-2
458 grep old $DIR/$tfile-2
460 grep old $DIR/$tfile-2 || error "grep $DIR/$tfile-2 failed"
462 run_test 19 "mcreate, open, write, rename "
464 test_20a() { # was test_20
465 replay_barrier $SINGLEMDS
466 multiop_bg_pause $DIR/$tfile O_tSc ||
467 error "multiop_bg_pause $DIR/$tfile failed"
472 kill -USR1 $pid || error "multiop $pid not running"
473 wait $pid || error "multiop $pid failed"
474 [ -e $DIR/$tfile ] && error "file $DIR/$tfile should not exist"
477 run_test 20a "|X| open(O_CREAT), unlink, replay, close (test mds_cleanup_orphans)"
479 test_20b() { # bug 10480
480 local wait_timeout=$((TIMEOUT * 4))
481 local extra=$(fs_log_size)
485 $LFS setstripe -i 0 -c 1 $DIR
487 local beforeused=$(df -P $DIR | tail -1 | awk '{ print $3 }')
489 dd if=/dev/zero of=$DIR/$tfile bs=4k count=10000 &
490 while [ ! -e $DIR/$tfile ] ; do
491 usleep 60 # give dd a chance to start
494 $LFS getstripe $DIR/$tfile || error "$LFS getstripe $DIR/$tfile failed"
496 rm -f $DIR/$tfile || error "rm -f $DIR/$tfile failed"
498 client_up || client_up || true # reconnect
500 do_facet $SINGLEMDS "lctl set_param -n osd*.*MDT*.force_sync=1"
502 fail $SINGLEMDS # start orphan recovery
503 wait_recovery_complete $SINGLEMDS || error "MDS recovery not done"
504 wait_delete_completed $wait_timeout || error "delete did not finish"
508 local afterused=$(df -P $DIR | tail -1 | awk '{ print $3 }')
509 log "before $beforeused, after $afterused"
511 (( $beforeused + $extra >= $afterused )) && break
512 n_attempts=$((n_attempts + 1))
513 [ $n_attempts -gt 3 ] &&
514 error "after $afterused > before $beforeused + $extra"
516 wait_zfs_commit $SINGLEMDS 5
521 run_test 20b "write, unlink, eviction, replay (test mds_cleanup_orphans)"
523 test_20c() { # bug 10480
524 multiop_bg_pause $DIR/$tfile Ow_c ||
525 error "multiop_bg_pause $DIR/$tfile failed"
531 client_up || client_up || true # reconnect
533 kill -USR1 $pid || error "multiop $pid not running"
534 wait $pid || error "multiop $pid failed"
535 [ -s $DIR/$tfile ] || error "File was truncated"
539 run_test 20c "check that client eviction does not affect file content"
542 replay_barrier $SINGLEMDS
543 multiop_bg_pause $DIR/$tfile O_tSc ||
544 error "multiop_bg_pause $DIR/$tfile failed"
547 touch $DIR/$tfile-1 || error "touch $DIR/$tfile-1 failed"
550 kill -USR1 $pid || error "multiop $pid not running"
551 wait $pid || error "multiop $pid failed"
552 [ -e $DIR/$tfile ] && error "file $DIR/$tfile should not exist"
553 touch $DIR/$tfile-2 || error "touch $DIR/$tfile-2 failed"
556 run_test 21 "|X| open(O_CREAT), unlink touch new, replay, close (test mds_cleanup_orphans)"
559 multiop_bg_pause $DIR/$tfile O_tSc ||
560 error "multiop_bg_pause $DIR/$tfile failed"
563 replay_barrier $SINGLEMDS
567 kill -USR1 $pid || error "multiop $pid not running"
568 wait $pid || error "multiop $pid failed"
569 [ -e $DIR/$tfile ] && error "file $DIR/$tfile should not exist"
572 run_test 22 "open(O_CREAT), |X| unlink, replay, close (test mds_cleanup_orphans)"
575 multiop_bg_pause $DIR/$tfile O_tSc ||
576 error "multiop_bg_pause $DIR/$tfile failed"
579 replay_barrier $SINGLEMDS
581 touch $DIR/$tfile-1 || error "touch $DIR/$tfile-1 failed"
584 kill -USR1 $pid || error "multiop $pid not running"
585 wait $pid || error "multiop $pid failed"
586 [ -e $DIR/$tfile ] && error "file $DIR/$tfile should not exist"
587 touch $DIR/$tfile-2 || error "touch $DIR/$tfile-2 failed"
590 run_test 23 "open(O_CREAT), |X| unlink touch new, replay, close (test mds_cleanup_orphans)"
593 multiop_bg_pause $DIR/$tfile O_tSc ||
594 error "multiop_bg_pause $DIR/$tfile failed"
597 replay_barrier $SINGLEMDS
600 kill -USR1 $pid || error "multiop $pid not running"
601 wait $pid || error "multiop $pid failed"
602 [ -e $DIR/$tfile ] && error "file $DIR/$tfile should not exist"
605 run_test 24 "open(O_CREAT), replay, unlink, close (test mds_cleanup_orphans)"
608 multiop_bg_pause $DIR/$tfile O_tSc ||
609 error "multiop_bg_pause $DIR/$tfile failed"
613 replay_barrier $SINGLEMDS
615 kill -USR1 $pid || error "multiop $pid not running"
616 wait $pid || error "multiop $pid failed"
617 [ -e $DIR/$tfile ] && error "file $DIR/$tfile should not exist"
620 run_test 25 "open(O_CREAT), unlink, replay, close (test mds_cleanup_orphans)"
623 replay_barrier $SINGLEMDS
624 multiop_bg_pause $DIR/$tfile-1 O_tSc ||
625 error "multiop_bg_pause $DIR/$tfile-1 failed"
627 multiop_bg_pause $DIR/$tfile-2 O_tSc ||
628 error "multiop_bg_pause $DIR/$tfile-2 failed"
632 kill -USR1 $pid2 || error "second multiop $pid2 not running"
633 wait $pid2 || error "second multiop $pid2 failed"
636 kill -USR1 $pid1 || error "multiop $pid1 not running"
637 wait $pid1 || error "multiop $pid1 failed"
638 [ -e $DIR/$tfile-1 ] && error "file $DIR/$tfile-1 should not exist"
639 [ -e $DIR/$tfile-2 ] && error "file $DIR/$tfile-2 should not exist"
642 run_test 26 "|X| open(O_CREAT), unlink two, close one, replay, close one (test mds_cleanup_orphans)"
645 replay_barrier $SINGLEMDS
646 multiop_bg_pause $DIR/$tfile-1 O_tSc ||
647 error "multiop_bg_pause $DIR/$tfile-1 failed"
649 multiop_bg_pause $DIR/$tfile-2 O_tSc ||
650 error "multiop_bg_pause $DIR/$tfile-2 failed"
656 kill -USR1 $pid1 || error "multiop $pid1 not running"
657 wait $pid1 || error "multiop $pid1 failed"
658 kill -USR1 $pid2 || error "second multiop $pid2 not running"
659 wait $pid2 || error "second multiop $pid2 failed"
660 [ -e $DIR/$tfile-1 ] && error "file $DIR/$tfile-1 should not exist"
661 [ -e $DIR/$tfile-2 ] && error "file $DIR/$tfile-2 should not exist"
664 run_test 27 "|X| open(O_CREAT), unlink two, replay, close two (test mds_cleanup_orphans)"
667 multiop_bg_pause $DIR/$tfile-1 O_tSc ||
668 error "multiop_bg_pause $DIR/$tfile-1 failed"
670 multiop_bg_pause $DIR/$tfile-2 O_tSc ||
671 error "multiop_bg_pause $DIR/$tfile-2 failed"
673 replay_barrier $SINGLEMDS
676 kill -USR1 $pid2 || error "second multiop $pid2 not running"
677 wait $pid2 || error "second multiop $pid2 failed"
680 kill -USR1 $pid1 || error "multiop $pid1 not running"
681 wait $pid1 || error "multiop $pid1 failed"
682 [ -e $DIR/$tfile-1 ] && error "file $DIR/$tfile-1 should not exist"
683 [ -e $DIR/$tfile-2 ] && error "file $DIR/$tfile-2 should not exist"
686 run_test 28 "open(O_CREAT), |X| unlink two, close one, replay, close one (test mds_cleanup_orphans)"
689 multiop_bg_pause $DIR/$tfile-1 O_tSc ||
690 error "multiop_bg_pause $DIR/$tfile-1 failed"
692 multiop_bg_pause $DIR/$tfile-2 O_tSc ||
693 error "multiop_bg_pause $DIR/$tfile-2 failed"
695 replay_barrier $SINGLEMDS
700 kill -USR1 $pid1 || error "multiop $pid1 not running"
701 wait $pid1 || error "multiop $pid1 failed"
702 kill -USR1 $pid2 || error "second multiop $pid2 not running"
703 wait $pid2 || error "second multiop $pid2 failed"
704 [ -e $DIR/$tfile-1 ] && error "file $DIR/$tfile-1 should not exist"
705 [ -e $DIR/$tfile-2 ] && error "file $DIR/$tfile-2 should not exist"
708 run_test 29 "open(O_CREAT), |X| unlink two, replay, close two (test mds_cleanup_orphans)"
711 multiop_bg_pause $DIR/$tfile-1 O_tSc ||
712 error "multiop_bg_pause $DIR/$tfile-1 failed"
714 multiop_bg_pause $DIR/$tfile-2 O_tSc ||
715 error "multiop_bg_pause $DIR/$tfile-2 failed"
720 replay_barrier $SINGLEMDS
722 kill -USR1 $pid1 || error "multiop $pid1 not running"
723 wait $pid1 || error "multiop $pid1 failed"
724 kill -USR1 $pid2 || error "second multiop $pid2 not running"
725 wait $pid2 || error "second multiop $pid2 failed"
726 [ -e $DIR/$tfile-1 ] && error "file $DIR/$tfile-1 should not exist"
727 [ -e $DIR/$tfile-2 ] && error "file $DIR/$tfile-2 should not exist"
730 run_test 30 "open(O_CREAT) two, unlink two, replay, close two (test mds_cleanup_orphans)"
733 multiop_bg_pause $DIR/$tfile-1 O_tSc ||
734 error "multiop_bg_pause $DIR/$tfile-1 failed"
736 multiop_bg_pause $DIR/$tfile-2 O_tSc ||
737 error "multiop_bg_pause $DIR/$tfile-2 failed"
741 replay_barrier $SINGLEMDS
744 kill -USR1 $pid1 || error "multiop $pid1 not running"
745 wait $pid1 || error "multiop $pid1 failed"
746 kill -USR1 $pid2 || error "second multiop $pid2 not running"
747 wait $pid2 || error "second multiop $pid2 failed"
748 [ -e $DIR/$tfile-1 ] && error "file $DIR/$tfile-1 should not exist"
749 [ -e $DIR/$tfile-2 ] && error "file $DIR/$tfile-2 should not exist"
752 run_test 31 "open(O_CREAT) two, unlink one, |X| unlink one, close two (test mds_cleanup_orphans)"
754 # tests for bug 2104; completion without crashing is success. The close is
755 # stale, but we always return 0 for close, so the app never sees it.
757 multiop_bg_pause $DIR/$tfile O_c ||
758 error "multiop_bg_pause $DIR/$tfile failed"
760 multiop_bg_pause $DIR/$tfile O_c ||
761 error "second multiop_bg_pause $DIR/$tfile failed"
764 client_up || client_up || error "client_up failed"
765 kill -USR1 $pid1 || error "multiop $pid1 not running"
766 kill -USR1 $pid2 || error "second multiop $pid2 not running"
767 wait $pid1 || error "multiop $pid1 failed"
768 wait $pid2 || error "second multiop $pid2 failed"
771 run_test 32 "close() notices client eviction; close() after client eviction"
774 createmany -o $DIR/$tfile-%d 10 ||
775 error "createmany create $DIR/$tfile failed"
776 replay_barrier_nosync $SINGLEMDS
777 fail_abort $SINGLEMDS
778 # recreate shouldn't fail
779 createmany -o $DIR/$tfile--%d 10 ||
780 error "createmany recreate $DIR/$tfile failed"
784 run_test 33a "fid seq shouldn't be reused after abort recovery"
787 #define OBD_FAIL_SEQ_ALLOC 0x1311
788 do_facet $SINGLEMDS "lctl set_param fail_loc=0x1311"
790 createmany -o $DIR/$tfile-%d 10
791 replay_barrier_nosync $SINGLEMDS
792 fail_abort $SINGLEMDS
793 # recreate shouldn't fail
794 createmany -o $DIR/$tfile--%d 10 ||
795 error "createmany recreate $DIR/$tfile failed"
799 run_test 33b "test fid seq allocation"
802 multiop_bg_pause $DIR/$tfile O_c ||
803 error "multiop_bg_pause $DIR/$tfile failed"
807 replay_barrier $SINGLEMDS
808 fail_abort $SINGLEMDS
809 kill -USR1 $pid || error "multiop $pid not running"
810 wait $pid || error "multiop $pid failed"
811 [ -e $DIR/$tfile ] && error "file $DIR/$tfile should not exist"
815 run_test 34 "abort recovery before client does replay (test mds_cleanup_orphans)"
817 # bug 2278 - generate one orphan on OST, then destroy it during recovery from llog
819 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
821 #define OBD_FAIL_MDS_REINT_NET_REP 0x119
822 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000119"
827 # give a chance to remove from MDS
828 fail_abort $SINGLEMDS
829 $CHECKSTAT -t file $DIR/$tfile &&
830 error "$CHECKSTAT $DIR/$tfile attribute check should fail" ||
833 run_test 35 "test recovery from llog for unlink op"
835 # b=2432 resent cancel after replay uses wrong cookie,
836 # so don't resend cancels
838 replay_barrier $SINGLEMDS
840 checkstat $DIR/$tfile
841 facet_failover $SINGLEMDS
843 if dmesg | grep "unknown lock cookie"; then
844 error "cancel after replay failed"
847 run_test 36 "don't resend cancel"
850 # directory orphans can't be unlinked from PENDING directory
852 rmdir $DIR/$tfile 2>/dev/null
853 multiop_bg_pause $DIR/$tfile dD_c ||
854 error "multiop_bg_pause $DIR/$tfile failed"
858 replay_barrier $SINGLEMDS
859 # clear the dmesg buffer so we only see errors from this recovery
860 do_facet $SINGLEMDS dmesg -c >/dev/null
861 fail_abort $SINGLEMDS
862 kill -USR1 $pid || error "multiop $pid not running"
863 do_facet $SINGLEMDS dmesg | grep "error .* unlinking .* from PENDING" &&
864 error "error unlinking files"
865 wait $pid || error "multiop $pid failed"
869 run_test 37 "abort recovery before client does replay (test mds_cleanup_orphans for directories)"
872 createmany -o $DIR/$tfile-%d 800 ||
873 error "createmany -o $DIR/$tfile failed"
874 unlinkmany $DIR/$tfile-%d 0 400 || error "unlinkmany $DIR/$tfile failed"
875 replay_barrier $SINGLEMDS
877 unlinkmany $DIR/$tfile-%d 400 400 ||
878 error "unlinkmany $DIR/$tfile 400 failed"
880 $CHECKSTAT -t file $DIR/$tfile-* &&
881 error "$CHECKSTAT $DIR/$tfile-* attribute check should fail" ||
884 run_test 38 "test recovery from unlink llog (test llog_gen_rec) "
886 test_39() { # bug 4176
887 createmany -o $DIR/$tfile-%d 800 ||
888 error "createmany -o $DIR/$tfile failed"
889 replay_barrier $SINGLEMDS
890 unlinkmany $DIR/$tfile-%d 0 400
892 unlinkmany $DIR/$tfile-%d 400 400 ||
893 error "unlinkmany $DIR/$tfile 400 failed"
895 $CHECKSTAT -t file $DIR/$tfile-* &&
896 error "$CHECKSTAT $DIR/$tfile-* attribute check should fail" ||
899 run_test 39 "test recovery from unlink llog (test llog_gen_rec) "
902 lctl get_param -n osc.*.stats | awk -vwrites=0 '/ost_write/ { writes += $2 } END { print writes; }'
907 # always need connection to MDS to verify layout during IO. LU-2628.
908 lctl get_param mdc.*.connect_flags | grep -q layout_lock &&
909 skip "layout_lock needs MDS connection for IO" && return 0
911 $LCTL mark multiop $MOUNT/$tfile OS_c
912 multiop $MOUNT/$tfile OS_c &
914 writeme -s $MOUNT/${tfile}-2 &
917 facet_failover $SINGLEMDS
918 #define OBD_FAIL_MDS_CONNECT_NET 0x117
919 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000117"
921 stat1=$(count_ost_writes)
923 stat2=$(count_ost_writes)
924 echo "$stat1, $stat2"
925 if [ $stat1 -lt $stat2 ]; then
926 echo "writes continuing during recovery"
929 echo "writes not continuing during recovery, bug 2477"
932 echo "waiting for writeme $WRITE_PID"
936 echo "waiting for multiop $PID"
937 wait $PID || error "multiop $PID failed"
938 do_facet client munlink $MOUNT/$tfile ||
939 error "munlink $MOUNT/$tfile failed"
940 do_facet client munlink $MOUNT/${tfile}-2 ||
941 error "munlink $MOUNT/$tfile-2 failed"
944 run_test 40 "cause recovery in ptlrpc, ensure IO continues"
947 # make sure that a read to one osc doesn't try to double-unlock its page just
948 # because another osc is invalid. trigger_group_io used to mistakenly return
949 # an error if any oscs were invalid even after having successfully put rpcs
950 # on valid oscs. This was fatal if the caller was ll_readpage who unlocked
951 # the page, guarnateeing that the unlock from the RPC completion would
952 # assert on trying to unlock the unlocked page.
954 [ $OSTCOUNT -lt 2 ] && skip_env "needs >= 2 OSTs" && return
956 local f=$MOUNT/$tfile
957 # make sure the start of the file is ost1
958 $SETSTRIPE -S $((128 * 1024)) -i 0 $f
959 do_facet client dd if=/dev/zero of=$f bs=4k count=1 ||
960 error "dd on client failed"
962 # fail ost2 and read from ost1
963 local mdtosc=$(get_mdtosc_proc_path $SINGLEMDS $ost2_svc)
964 local osc2dev=$(do_facet $SINGLEMDS "lctl get_param -n devices" |
965 grep $mdtosc | awk '{print $1}')
966 [ -z "$osc2dev" ] && echo "OST: $ost2_svc" &&
967 lctl get_param -n devices &&
968 error "OST 2 $osc2dev does not exist"
969 do_facet $SINGLEMDS $LCTL --device $osc2dev deactivate ||
970 error "deactive device on $SINGLEMDS failed"
971 do_facet client dd if=$f of=/dev/null bs=4k count=1 ||
972 error "second dd on client failed"
973 do_facet $SINGLEMDS $LCTL --device $osc2dev activate ||
974 error "active device on $SINGLEMDS failed"
977 run_test 41 "read from a valid osc while other oscs are invalid"
979 # test MDS recovery after ost failure
981 blocks=$(df -P $MOUNT | tail -n 1 | awk '{ print $2 }')
982 createmany -o $DIR/$tfile-%d 800 ||
983 error "createmany -o $DIR/$tfile failed"
985 unlinkmany $DIR/$tfile-%d 0 400
987 lctl set_param debug=-1
990 # osc is evicted, fs is smaller (but only with failout OSTs (bug 7287)
991 #blocks_after=`df -P $MOUNT | tail -n 1 | awk '{ print $2 }'`
992 #[ $blocks_after -lt $blocks ] || return 1
993 echo "wait for MDS to timeout and recover"
994 sleep $((TIMEOUT * 2))
996 unlinkmany $DIR/$tfile-%d 400 400 ||
997 error "unlinkmany $DIR/$tfile 400 failed"
998 $CHECKSTAT -t file $DIR/$tfile-* &&
999 error "$CHECKSTAT $DIR/$tfile-* attribute check should fail" ||
1002 run_test 42 "recovery after ost failure"
1004 # timeout in MDS/OST recovery RPC will LBUG MDS
1005 test_43() { # bug 2530
1006 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1008 replay_barrier $SINGLEMDS
1010 # OBD_FAIL_OST_CREATE_NET 0x204
1011 do_facet ost1 "lctl set_param fail_loc=0x80000204"
1017 run_test 43 "mds osc import failure during recovery; don't LBUG"
1019 test_44a() { # was test_44
1020 local at_max_saved=0
1022 local mdcdev=$($LCTL dl |
1023 awk "/${FSNAME}-MDT0000-mdc-/ {if (\$2 == \"UP\") {print \$1}}")
1024 [ "$mdcdev" ] || error "${FSNAME}-MDT0000-mdc- not UP"
1025 [ $(echo $mdcdev | wc -w) -eq 1 ] ||
1026 { $LCTL dl; error "looking for mdcdev=$mdcdev"; }
1028 # adaptive timeouts slow this way down
1029 if at_is_enabled; then
1030 at_max_saved=$(at_max_get mds)
1034 for i in $(seq 1 10); do
1035 echo "$i of 10 ($(date +%s))"
1036 do_facet $SINGLEMDS \
1037 "lctl get_param -n md[ts].*.mdt.timeouts | grep service"
1038 #define OBD_FAIL_TGT_CONN_RACE 0x701
1039 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000701"
1040 # lctl below may fail, it is valid case
1041 $LCTL --device $mdcdev recover
1044 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
1045 [ $at_max_saved -ne 0 ] && at_max_set $at_max_saved mds
1048 run_test 44a "race in target handle connect"
1051 local mdcdev=$($LCTL dl |
1052 awk "/${FSNAME}-MDT0000-mdc-/ {if (\$2 == \"UP\") {print \$1}}")
1053 [ "$mdcdev" ] || error "${FSNAME}-MDT0000-mdc not up"
1054 [ $(echo $mdcdev | wc -w) -eq 1 ] ||
1055 { echo mdcdev=$mdcdev; $LCTL dl;
1056 error "more than one ${FSNAME}-MDT0000-mdc"; }
1058 for i in $(seq 1 10); do
1059 echo "$i of 10 ($(date +%s))"
1060 do_facet $SINGLEMDS \
1061 "lctl get_param -n md[ts].*.mdt.timeouts | grep service"
1062 #define OBD_FAIL_TGT_DELAY_RECONNECT 0x704
1063 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000704"
1064 # lctl below may fail, it is valid case
1065 $LCTL --device $mdcdev recover
1070 run_test 44b "race in target handle connect"
1073 replay_barrier $SINGLEMDS
1074 createmany -m $DIR/$tfile-%d 100 || error "failed to create directories"
1075 #define OBD_FAIL_TGT_RCVG_FLAG 0x712
1076 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000712"
1077 fail_abort $SINGLEMDS
1078 unlinkmany $DIR/$tfile-%d 100 && error "unliked after fail abort"
1080 unlinkmany $DIR/$tfile-%d 100 && error "unliked after fail"
1083 run_test 44c "race in target handle connect"
1085 # Handle failed close
1087 local mdcdev=$($LCTL get_param -n devices |
1088 awk "/ ${FSNAME}-MDT0000-mdc-/ {print \$1}")
1089 [ "$mdcdev" ] || error "${FSNAME}-MDT0000-mdc not up"
1090 [ $(echo $mdcdev | wc -w) -eq 1 ] ||
1091 { echo mdcdev=$mdcdev; $LCTL dl;
1092 error "more than one ${FSNAME}-MDT0000-mdc"; }
1094 $LCTL --device $mdcdev recover ||
1095 error "$LCTL --device $mdcdev recover failed"
1097 multiop_bg_pause $DIR/$tfile O_c ||
1098 error "multiop_bg_pause $DIR/$tfile failed"
1101 # This will cause the CLOSE to fail before even
1102 # allocating a reply buffer
1103 $LCTL --device $mdcdev deactivate ||
1104 error "$LCTL --device $mdcdev deactivate failed"
1107 kill -USR1 $pid || error "multiop $pid not running"
1108 wait $pid || error "multiop $pid failed"
1110 $LCTL --device $mdcdev activate ||
1111 error "$LCTL --device $mdcdev activate failed"
1114 $CHECKSTAT -t file $DIR/$tfile ||
1115 error "$CHECKSTAT $DIR/$tfile attribute check failed"
1118 run_test 45 "Handle failed close"
1122 drop_reply "touch $DIR/$tfile"
1124 # ironically, the previous test, 45, will cause a real forced close,
1125 # so just look for one for this test
1126 dmesg | grep -i "force closing client file handle for $tfile" &&
1127 error "found force closing in dmesg"
1130 run_test 46 "Don't leak file handle after open resend (3325)"
1132 test_47() { # bug 2824
1133 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1135 # create some files to make sure precreate has been done on all
1136 # OSTs. (just in case this test is run independently)
1137 createmany -o $DIR/$tfile 20 ||
1138 error "createmany create $DIR/$tfile failed"
1140 # OBD_FAIL_OST_CREATE_NET 0x204
1142 do_facet ost1 "lctl set_param fail_loc=0x80000204"
1143 client_up || error "client_up failed"
1145 # let the MDS discover the OST failure, attempt to recover, fail
1146 # and recover again.
1147 sleep $((3 * TIMEOUT))
1149 # Without 2824, this createmany would hang
1150 createmany -o $DIR/$tfile 20 ||
1151 error "createmany recraete $DIR/$tfile failed"
1152 unlinkmany $DIR/$tfile 20 || error "unlinkmany $DIR/$tfile failed"
1156 run_test 47 "MDS->OSC failure during precreate cleanup (2824)"
1159 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1160 [ "$OSTCOUNT" -lt "2" ] && skip_env "needs >= 2 OSTs" && return
1162 replay_barrier $SINGLEMDS
1163 createmany -o $DIR/$tfile 20 ||
1164 error "createmany -o $DIR/$tfile failed"
1165 # OBD_FAIL_OST_EROFS 0x216
1166 facet_failover $SINGLEMDS
1167 do_facet ost1 "lctl set_param fail_loc=0x80000216"
1168 client_up || error "client_up failed"
1170 # let the MDS discover the OST failure, attempt to recover, fail
1171 # and recover again.
1172 sleep $((3 * TIMEOUT))
1174 createmany -o $DIR/$tfile 20 20 ||
1175 error "createmany recraete $DIR/$tfile failed"
1176 unlinkmany $DIR/$tfile 40 || error "unlinkmany $DIR/$tfile failed"
1179 run_test 48 "MDS->OSC failure during precreate cleanup (2824)"
1182 local mdtosc=$(get_mdtosc_proc_path $SINGLEMDS $ost1_svc)
1183 local oscdev=$(do_facet $SINGLEMDS "lctl get_param -n devices" |
1184 grep $mdtosc | awk '{print $1}')
1185 [ "$oscdev" ] || error "could not find OSC device on MDS"
1186 do_facet $SINGLEMDS $LCTL --device $oscdev recover ||
1187 error "OSC device $oscdev recovery failed"
1188 do_facet $SINGLEMDS $LCTL --device $oscdev recover ||
1189 error "second OSC device $oscdev recovery failed"
1190 # give the mds_lov_sync threads a chance to run
1193 run_test 50 "Double OSC recovery, don't LASSERT (3812)"
1195 # b3764 timed out lock replay
1197 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.6.90) ] &&
1198 skip "MDS prior to 2.6.90 handle LDLM_REPLY_NET incorrectly" &&
1201 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
1202 cancel_lru_locks mdc
1204 multiop_bg_pause $DIR/$tfile s_s || error "multiop $DIR/$tfile failed"
1207 #define OBD_FAIL_MDS_LDLM_REPLY_NET 0x157
1208 lctl set_param -n ldlm.cancel_unused_locks_before_replay "0"
1209 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000157"
1211 fail $SINGLEMDS || error "fail $SINGLEMDS failed"
1213 wait $mpid || error "multiop_bg_pause pid failed"
1215 do_facet $SINGLEMDS "lctl set_param fail_loc=0x0"
1216 lctl set_param fail_loc=0x0
1217 lctl set_param -n ldlm.cancel_unused_locks_before_replay "1"
1220 run_test 52 "time out lock replay (3764)"
1222 # bug 3462 - simultaneous MDC requests
1224 [[ $(lctl get_param mdc.*.import |
1225 grep "connect_flags:.*multi_mod_rpc") ]] ||
1226 { skip "Need MDC with 'multi_mod_rpcs' feature"; return 0; }
1228 cancel_lru_locks mdc # cleanup locks from former test cases
1229 mkdir $DIR/${tdir}-1 || error "mkdir $DIR/${tdir}-1 failed"
1230 mkdir $DIR/${tdir}-2 || error "mkdir $DIR/${tdir}-2 failed"
1231 multiop $DIR/${tdir}-1/f O_c &
1233 # give multiop a change to open
1236 #define OBD_FAIL_MDS_CLOSE_NET 0x115
1237 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000115"
1238 kill -USR1 $close_pid
1239 cancel_lru_locks mdc # force the close
1240 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
1242 mcreate $DIR/${tdir}-2/f || error "mcreate $DIR/${tdir}-2/f failed"
1244 # close should still be here
1245 [ -d /proc/$close_pid ] || error "close_pid doesn't exist"
1247 replay_barrier_nodf $SINGLEMDS
1249 wait $close_pid || error "close_pid $close_pid failed"
1251 $CHECKSTAT -t file $DIR/${tdir}-1/f ||
1252 error "$CHECKSTAT $DIR/${tdir}-1/f attribute check failed"
1253 $CHECKSTAT -t file $DIR/${tdir}-2/f ||
1254 error "$CHECKSTAT $DIR/${tdir}-2/f attribute check failed"
1255 rm -rf $DIR/${tdir}-*
1257 run_test 53a "|X| close request while two MDC requests in flight"
1260 cancel_lru_locks mdc # cleanup locks from former test cases
1262 mkdir $DIR/${tdir}-1 || error "mkdir $DIR/${tdir}-1 failed"
1263 mkdir $DIR/${tdir}-2 || error "mkdir $DIR/${tdir}-2 failed"
1264 multiop_bg_pause $DIR/${tdir}-1/f O_c ||
1265 error "multiop_bg_pause $DIR/${tdir}-1/f failed"
1268 #define OBD_FAIL_MDS_REINT_NET 0x107
1269 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000107"
1270 mcreate $DIR/${tdir}-2/f &
1274 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
1275 kill -USR1 $close_pid
1276 cancel_lru_locks mdc # force the close
1277 wait $close_pid || error "close_pid $close_pid failed"
1278 # open should still be here
1279 [ -d /proc/$open_pid ] || error "open_pid doesn't exist"
1281 replay_barrier_nodf $SINGLEMDS
1283 wait $open_pid || error "open_pid failed"
1285 $CHECKSTAT -t file $DIR/${tdir}-1/f ||
1286 error "$CHECKSTAT $DIR/${tdir}-1/f attribute check failed"
1287 $CHECKSTAT -t file $DIR/${tdir}-2/f ||
1288 error "$CHECKSTAT $DIR/${tdir}-2/f attribute check failed"
1289 rm -rf $DIR/${tdir}-*
1291 run_test 53b "|X| open request while two MDC requests in flight"
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 &
1301 #define OBD_FAIL_MDS_REINT_NET 0x107
1302 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000107"
1303 mcreate $DIR/${tdir}-2/f &
1307 #define OBD_FAIL_MDS_CLOSE_NET 0x115
1308 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000115"
1309 kill -USR1 $close_pid
1310 cancel_lru_locks mdc # force the close
1312 #bz20647: make sure all pids exist before failover
1313 [ -d /proc/$close_pid ] || error "close_pid doesn't exist"
1314 [ -d /proc/$open_pid ] || error "open_pid doesn't exists"
1315 replay_barrier_nodf $SINGLEMDS
1316 fail_nodf $SINGLEMDS
1317 wait $open_pid || error "open_pid failed"
1319 # close should be gone
1320 [ -d /proc/$close_pid ] && error "close_pid should not exist"
1321 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
1323 $CHECKSTAT -t file $DIR/${tdir}-1/f ||
1324 error "$CHECKSTAT $DIR/${tdir}-1/f attribute check failed"
1325 $CHECKSTAT -t file $DIR/${tdir}-2/f ||
1326 error "$CHECKSTAT $DIR/${tdir}-2/f attribute check failed"
1327 rm -rf $DIR/${tdir}-*
1329 run_test 53c "|X| open request and close request while two MDC requests in flight"
1332 [[ $(lctl get_param mdc.*.import |
1333 grep "connect_flags:.*multi_mod_rpc") ]] ||
1334 { skip "Need MDC with 'multi_mod_rpcs' feature"; return 0; }
1336 cancel_lru_locks mdc # cleanup locks from former test cases
1338 mkdir $DIR/${tdir}-1 || error "mkdir $DIR/${tdir}-1 failed"
1339 mkdir $DIR/${tdir}-2 || error "mkdir $DIR/${tdir}-2 failed"
1340 multiop $DIR/${tdir}-1/f O_c &
1342 # give multiop a chance to open
1345 #define OBD_FAIL_MDS_CLOSE_NET_REP 0x13b
1346 do_facet $SINGLEMDS "lctl set_param fail_loc=0x8000013b"
1347 kill -USR1 $close_pid
1348 cancel_lru_locks mdc # force the close
1349 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
1350 mcreate $DIR/${tdir}-2/f || error "mcreate $DIR/${tdir}-2/f failed"
1352 # close should still be here
1353 [ -d /proc/$close_pid ] || error "close_pid doesn't exist"
1355 wait $close_pid || error "close_pid failed"
1357 $CHECKSTAT -t file $DIR/${tdir}-1/f ||
1358 error "$CHECKSTAT $DIR/${tdir}-1/f attribute check failed"
1359 $CHECKSTAT -t file $DIR/${tdir}-2/f ||
1360 error "$CHECKSTAT $DIR/${tdir}-2/f attribute check failed"
1361 rm -rf $DIR/${tdir}-*
1363 run_test 53d "close reply while two MDC requests in flight"
1366 cancel_lru_locks mdc # cleanup locks from former test cases
1368 mkdir $DIR/${tdir}-1 || error "mkdir $DIR/${tdir}-1 failed"
1369 mkdir $DIR/${tdir}-2 || error "mkdir $DIR/${tdir}-2 failed"
1370 multiop $DIR/${tdir}-1/f O_c &
1373 #define OBD_FAIL_MDS_REINT_NET_REP 0x119
1374 do_facet $SINGLEMDS "lctl set_param fail_loc=0x119"
1375 mcreate $DIR/${tdir}-2/f &
1379 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
1380 kill -USR1 $close_pid
1381 cancel_lru_locks mdc # force the close
1382 wait $close_pid || error "close_pid failed"
1383 # open should still be here
1384 [ -d /proc/$open_pid ] || error "open_pid doesn't exists"
1386 replay_barrier_nodf $SINGLEMDS
1388 wait $open_pid || error "open_pid failed"
1390 $CHECKSTAT -t file $DIR/${tdir}-1/f ||
1391 error "$CHECKSTAT $DIR/${tdir}-1/f attribute check failed"
1392 $CHECKSTAT -t file $DIR/${tdir}-2/f ||
1393 error "$CHECKSTAT $DIR/${tdir}-2/f attribute check failed"
1394 rm -rf $DIR/${tdir}-*
1396 run_test 53e "|X| open reply while two MDC requests in flight"
1399 cancel_lru_locks mdc # cleanup locks from former test cases
1401 mkdir $DIR/${tdir}-1 || error "mkdir $DIR/${tdir}-1 failed"
1402 mkdir $DIR/${tdir}-2 || error "mkdir $DIR/${tdir}-2 failed"
1403 multiop $DIR/${tdir}-1/f O_c &
1406 #define OBD_FAIL_MDS_REINT_NET_REP 0x119
1407 do_facet $SINGLEMDS "lctl set_param fail_loc=0x119"
1408 mcreate $DIR/${tdir}-2/f &
1412 #define OBD_FAIL_MDS_CLOSE_NET_REP 0x13b
1413 do_facet $SINGLEMDS "lctl set_param fail_loc=0x8000013b"
1414 kill -USR1 $close_pid
1415 cancel_lru_locks mdc # force the close
1417 #bz20647: make sure all pids are exists before failover
1418 [ -d /proc/$close_pid ] || error "close_pid doesn't exist"
1419 [ -d /proc/$open_pid ] || error "open_pid doesn't exists"
1420 replay_barrier_nodf $SINGLEMDS
1421 fail_nodf $SINGLEMDS
1422 wait $open_pid || error "open_pid failed"
1424 # close should be gone
1425 [ -d /proc/$close_pid ] && error "close_pid should not exist"
1426 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
1428 $CHECKSTAT -t file $DIR/${tdir}-1/f ||
1429 error "$CHECKSTAT $DIR/${tdir}-1/f attribute check failed"
1430 $CHECKSTAT -t file $DIR/${tdir}-2/f ||
1431 error "$CHECKSTAT $DIR/${tdir}-2/f attribute check failed"
1432 rm -rf $DIR/${tdir}-*
1434 run_test 53f "|X| open reply and close reply while two MDC requests in flight"
1437 cancel_lru_locks mdc # cleanup locks from former test cases
1439 mkdir $DIR/${tdir}-1 || error "mkdir $DIR/${tdir}-1 failed"
1440 mkdir $DIR/${tdir}-2 || error "mkdir $DIR/${tdir}-2 failed"
1441 multiop $DIR/${tdir}-1/f O_c &
1444 #define OBD_FAIL_MDS_REINT_NET_REP 0x119
1445 do_facet $SINGLEMDS "lctl set_param fail_loc=0x119"
1446 mcreate $DIR/${tdir}-2/f &
1450 #define OBD_FAIL_MDS_CLOSE_NET 0x115
1451 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000115"
1452 kill -USR1 $close_pid
1453 cancel_lru_locks mdc # force the close
1454 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
1456 #bz20647: make sure all pids are exists before failover
1457 [ -d /proc/$close_pid ] || error "close_pid doesn't exist"
1458 [ -d /proc/$open_pid ] || error "open_pid doesn't exists"
1459 replay_barrier_nodf $SINGLEMDS
1460 fail_nodf $SINGLEMDS
1461 wait $open_pid || error "open_pid failed"
1463 # close should be gone
1464 [ -d /proc/$close_pid ] && error "close_pid should not exist"
1466 $CHECKSTAT -t file $DIR/${tdir}-1/f ||
1467 error "$CHECKSTAT $DIR/${tdir}-1/f attribute check failed"
1468 $CHECKSTAT -t file $DIR/${tdir}-2/f ||
1469 error "$CHECKSTAT $DIR/${tdir}-2/f attribute check failed"
1470 rm -rf $DIR/${tdir}-*
1472 run_test 53g "|X| drop open reply and close request while close and open are both in flight"
1475 cancel_lru_locks mdc # cleanup locks from former test cases
1477 mkdir $DIR/${tdir}-1 || error "mkdir $DIR/${tdir}-1 failed"
1478 mkdir $DIR/${tdir}-2 || error "mkdir $DIR/${tdir}-2 failed"
1479 multiop $DIR/${tdir}-1/f O_c &
1482 #define OBD_FAIL_MDS_REINT_NET 0x107
1483 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000107"
1484 mcreate $DIR/${tdir}-2/f &
1488 #define OBD_FAIL_MDS_CLOSE_NET_REP 0x13b
1489 do_facet $SINGLEMDS "lctl set_param fail_loc=0x8000013b"
1490 kill -USR1 $close_pid
1491 cancel_lru_locks mdc # force the close
1494 #bz20647: make sure all pids are exists before failover
1495 [ -d /proc/$close_pid ] || error "close_pid doesn't exist"
1496 [ -d /proc/$open_pid ] || error "open_pid doesn't exists"
1497 replay_barrier_nodf $SINGLEMDS
1498 fail_nodf $SINGLEMDS
1499 wait $open_pid || error "open_pid failed"
1501 # close should be gone
1502 [ -d /proc/$close_pid ] && error "close_pid should not exist"
1503 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
1505 $CHECKSTAT -t file $DIR/${tdir}-1/f ||
1506 error "$CHECKSTAT $DIR/${tdir}-1/f attribute check failed"
1507 $CHECKSTAT -t file $DIR/${tdir}-2/f ||
1508 error "$CHECKSTAT $DIR/${tdir}-2/f attribute check failed"
1509 rm -rf $DIR/${tdir}-*
1511 run_test 53h "open request and close reply while two MDC requests in flight"
1513 #b3761 ASSERTION(hash != 0) failed
1515 # OBD_FAIL_MDS_OPEN_CREATE | OBD_FAIL_ONCE
1516 do_facet $SINGLEMDS "lctl set_param fail_loc=0x8000012b"
1518 # give touch a chance to run
1520 do_facet $SINGLEMDS "lctl set_param fail_loc=0x0"
1524 run_test 55 "let MDS_CHECK_RESENT return the original return code instead of 0"
1526 #b3440 ASSERTION(rec->ur_fid2->id) failed
1528 ln -s foo $DIR/$tfile
1529 replay_barrier $SINGLEMDS
1530 #drop_reply "cat $DIR/$tfile"
1534 run_test 56 "don't replay a symlink open request (3440)"
1536 #recovery one mds-ost setattr from llog
1538 #define OBD_FAIL_MDS_OST_SETATTR 0x12c
1539 do_facet $SINGLEMDS "lctl set_param fail_loc=0x8000012c"
1540 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
1541 replay_barrier $SINGLEMDS
1543 wait_recovery_complete $SINGLEMDS || error "MDS recovery is not done"
1544 wait_mds_ost_sync || error "wait_mds_ost_sync failed"
1545 $CHECKSTAT -t file $DIR/$tfile ||
1546 error "$CHECKSTAT $DIR/$tfile attribute check failed"
1547 do_facet $SINGLEMDS "lctl set_param fail_loc=0x0"
1550 run_test 57 "test recovery from llog for setattr op"
1553 zconf_umount $(hostname) $MOUNT2
1557 #recovery many mds-ost setattr from llog
1559 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
1560 #define OBD_FAIL_MDS_OST_SETATTR 0x12c
1561 do_facet $SINGLEMDS "lctl set_param fail_loc=0x8000012c"
1562 createmany -o $DIR/$tdir/$tfile-%d 2500
1563 replay_barrier $SINGLEMDS
1566 $CHECKSTAT -t file $DIR/$tdir/$tfile-* >/dev/null ||
1567 error "$CHECKSTAT $DIR/$tfile-* attribute check failed"
1568 do_facet $SINGLEMDS "lctl set_param fail_loc=0x0"
1569 unlinkmany $DIR/$tdir/$tfile-%d 2500 ||
1570 error "unlinkmany $DIR/$tfile failed"
1573 run_test 58a "test recovery from llog for setattr op (test llog_gen_rec)"
1579 trap cleanup_58 EXIT
1581 large_xattr_enabled &&
1582 orig="$(generate_string $(max_xattr_size))" || orig="bar"
1583 # Original extended attribute can be long. Print a small version of
1584 # attribute if an error occurs
1585 local sm_msg=$(printf "%.9s" $orig)
1587 mount_client $MOUNT2 || error "mount_client on $MOUNT2 failed"
1588 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
1589 touch $DIR/$tdir/$tfile || error "touch $DIR/$tdir/$tfile failed"
1590 replay_barrier $SINGLEMDS
1591 setfattr -n trusted.foo -v $orig $DIR/$tdir/$tfile
1593 new=$(get_xattr_value trusted.foo $MOUNT2/$tdir/$tfile)
1594 [[ "$new" = "$orig" ]] ||
1595 error "xattr set ($sm_msg...) differs from xattr get ($new)"
1596 rm -f $DIR/$tdir/$tfile
1599 wait_clients_import_state ${CLIENTS:-$HOSTNAME} "mgs" FULL
1601 run_test 58b "test replay of setxattr op"
1603 test_58c() { # bug 16570
1608 trap cleanup_58 EXIT
1610 if large_xattr_enabled; then
1611 local xattr_size=$(max_xattr_size)
1612 orig="$(generate_string $((xattr_size / 2)))"
1613 orig1="$(generate_string $xattr_size)"
1619 # PING_INTERVAL max(obd_timeout / 4, 1U)
1620 sleep $((TIMEOUT / 4))
1622 # Original extended attribute can be long. Print a small version of
1623 # attribute if an error occurs
1624 local sm_msg=$(printf "%.9s" $orig)
1625 local sm_msg1=$(printf "%.9s" $orig1)
1627 mount_client $MOUNT2 || error "mount_client on $MOUNT2 failed"
1628 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
1629 touch $DIR/$tdir/$tfile || error "touch $DIR/$tdir/$tfile failed"
1630 drop_request "setfattr -n trusted.foo -v $orig $DIR/$tdir/$tfile" ||
1631 error "drop_request for setfattr failed"
1632 new=$(get_xattr_value trusted.foo $MOUNT2/$tdir/$tfile)
1633 [[ "$new" = "$orig" ]] ||
1634 error "xattr set ($sm_msg...) differs from xattr get ($new)"
1635 drop_reint_reply "setfattr -n trusted.foo1 \
1636 -v $orig1 $DIR/$tdir/$tfile" ||
1637 error "drop_reint_reply for setfattr failed"
1638 new=$(get_xattr_value trusted.foo1 $MOUNT2/$tdir/$tfile)
1639 [[ "$new" = "$orig1" ]] ||
1640 error "second xattr set ($sm_msg1...) differs xattr get ($new)"
1641 rm -f $DIR/$tdir/$tfile
1645 run_test 58c "resend/reconstruct setxattr op"
1647 # log_commit_thread vs filter_destroy race used to lead to import use after free
1650 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1652 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
1653 createmany -o $DIR/$tdir/$tfile-%d 200 ||
1654 error "createmany create files failed"
1656 unlinkmany $DIR/$tdir/$tfile-%d 200 ||
1657 error "unlinkmany $DIR/$tdir/$tfile failed"
1658 #define OBD_FAIL_PTLRPC_DELAY_RECOV 0x507
1659 do_facet ost1 "lctl set_param fail_loc=0x507"
1662 do_facet ost1 "lctl set_param fail_loc=0x0"
1666 run_test 59 "test log_commit_thread vs filter_destroy race"
1668 # race between add unlink llog vs cat log init in post_recovery (only for b1_6)
1669 # bug 12086: should no oops and No ctxt error for this test
1671 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
1672 createmany -o $DIR/$tdir/$tfile-%d 200 ||
1673 error "createmany create files failed"
1674 replay_barrier $SINGLEMDS
1675 unlinkmany $DIR/$tdir/$tfile-%d 0 100
1677 unlinkmany $DIR/$tdir/$tfile-%d 100 100
1678 local no_ctxt=$(dmesg | grep "No ctxt")
1679 [ -z "$no_ctxt" ] || error "ctxt is not initialized in recovery"
1681 run_test 60 "test llog post recovery init vs llog unlink"
1683 #test race llog recovery thread vs llog cleanup
1684 test_61a() { # was test_61
1685 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1687 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
1688 createmany -o $DIR/$tdir/$tfile-%d 800 ||
1689 error "createmany create files failed"
1691 unlinkmany $DIR/$tdir/$tfile-%d 800
1692 # OBD_FAIL_OST_LLOG_RECOVERY_TIMEOUT 0x221
1693 set_nodes_failloc "$(osts_nodes)" 0x80000221
1698 set_nodes_failloc "$(osts_nodes)" 0x0
1700 $CHECKSTAT -t file $DIR/$tdir/$tfile-* &&
1701 error "$CHECKSTAT $DIR/$tdir/$tfile attribute check should fail"
1704 run_test 61a "test race llog recovery vs llog cleanup"
1706 #test race mds llog sync vs llog cleanup
1708 # OBD_FAIL_MDS_LLOG_SYNC_TIMEOUT 0x13a
1709 do_facet $SINGLEMDS "lctl set_param fail_loc=0x8000013a"
1710 facet_failover $SINGLEMDS
1713 do_facet client dd if=/dev/zero of=$DIR/$tfile bs=4k count=1 ||
1716 run_test 61b "test race mds llog sync vs llog cleanup"
1718 #test race cancel cookie cb vs llog cleanup
1720 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1722 # OBD_FAIL_OST_CANCEL_COOKIE_TIMEOUT 0x222
1723 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
1724 set_nodes_failloc "$(osts_nodes)" 0x80000222
1728 set_nodes_failloc "$(osts_nodes)" 0x0
1730 run_test 61c "test race mds llog sync vs llog cleanup"
1732 test_61d() { # bug 16002 # bug 17466 # bug 22137
1733 # OBD_FAIL_OBD_LLOG_SETUP 0x605
1735 do_facet mgs "lctl set_param fail_loc=0x80000605"
1736 start mgs $(mgsdevname) $MGS_MOUNT_OPTS &&
1737 error "mgs start should have failed"
1738 do_facet mgs "lctl set_param fail_loc=0"
1739 start mgs $(mgsdevname) $MGS_MOUNT_OPTS || error "cannot restart mgs"
1741 run_test 61d "error in llog_setup should cleanup the llog context correctly"
1743 test_62() { # Bug 15756 - don't mis-drop resent replay
1744 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
1745 replay_barrier $SINGLEMDS
1746 createmany -o $DIR/$tdir/$tfile- 25 ||
1747 error "createmany create files failed"
1748 #define OBD_FAIL_TGT_REPLAY_DROP 0x707
1749 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000707"
1751 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
1752 unlinkmany $DIR/$tdir/$tfile- 25 ||
1753 error "unlinkmany $DIR/$tdir/$tfile failed"
1756 run_test 62 "don't mis-drop resent replay"
1758 #Adaptive Timeouts (bug 3055)
1766 echo "Cleaning up AT ..."
1767 if [ -n "$ATOLDBASE" ]; then
1768 local at_history=$($LCTL get_param -n at_history)
1769 do_facet $SINGLEMDS "lctl set_param at_history=$at_history" || true
1770 do_facet ost1 "lctl set_param at_history=$at_history" || true
1773 if [ $AT_MAX_SET -ne 0 ]; then
1774 for facet in mds client ost; do
1775 var=AT_MAX_SAVE_${facet}
1776 echo restore AT on $facet to saved value ${!var}
1777 at_max_set ${!var} $facet
1778 at_new=$(at_max_get $facet)
1779 echo Restored AT value on $facet $at_new
1780 [ $at_new -eq ${!var} ] ||
1781 error "AT value not restored SAVED ${!var} NEW $at_new"
1788 local at_max_new=600
1790 # Save at_max original values
1792 if [ $AT_MAX_SET -eq 0 ]; then
1793 # Suppose that all osts have the same at_max
1794 for facet in mds client ost; do
1795 eval AT_MAX_SAVE_${facet}=$(at_max_get $facet)
1799 for facet in mds client ost; do
1800 at_max=$(at_max_get $facet)
1801 if [ $at_max -ne $at_max_new ]; then
1802 echo "AT value on $facet is $at_max, set it by force temporarily to $at_max_new"
1803 at_max_set $at_max_new $facet
1808 if [ -z "$ATOLDBASE" ]; then
1809 ATOLDBASE=$(do_facet $SINGLEMDS "lctl get_param -n at_history")
1810 # speed up the timebase so we can check decreasing AT
1811 do_facet $SINGLEMDS "lctl set_param at_history=8" || true
1812 do_facet ost1 "lctl set_param at_history=8" || true
1814 # sleep for a while to cool down, should be > 8s and also allow
1815 # at least one ping to be sent. simply use TIMEOUT to be safe.
1820 test_65a() #bug 3055
1822 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1824 at_start || return 0
1825 $LCTL dk > /dev/null
1827 $LCTL set_param debug="other"
1828 # Slow down a request to the current service time, this is critical
1829 # because previous tests may have caused this value to increase.
1830 REQ_DELAY=`lctl get_param -n mdc.${FSNAME}-MDT0000-mdc-*.timeouts |
1831 awk '/portal 12/ {print $5}'`
1832 REQ_DELAY=$((${REQ_DELAY} + ${REQ_DELAY} / 4 + 5))
1834 do_facet $SINGLEMDS lctl set_param fail_val=$((${REQ_DELAY} * 1000))
1835 #define OBD_FAIL_PTLRPC_PAUSE_REQ 0x50a
1836 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x8000050a
1837 createmany -o $DIR/$tfile 10 > /dev/null
1838 unlinkmany $DIR/$tfile 10 > /dev/null
1839 # check for log message
1840 $LCTL dk | grep "Early reply #" || error "No early reply"
1842 # client should show REQ_DELAY estimates
1843 lctl get_param -n mdc.${FSNAME}-MDT0000-mdc-*.timeouts | grep portal
1845 lctl get_param -n mdc.${FSNAME}-MDT0000-mdc-*.timeouts | grep portal
1847 run_test 65a "AT: verify early replies"
1849 test_65b() #bug 3055
1851 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1853 at_start || return 0
1856 $LCTL set_param debug="other trace"
1857 $LCTL dk > /dev/null
1858 # Slow down a request to the current service time, this is critical
1859 # because previous tests may have caused this value to increase.
1860 $SETSTRIPE --stripe-index=0 --stripe-count=1 $DIR/$tfile ||
1861 error "$SETSTRIPE failed for $DIR/$tfile"
1863 multiop $DIR/$tfile Ow1yc
1864 REQ_DELAY=`lctl get_param -n osc.${FSNAME}-OST0000-osc-*.timeouts |
1865 awk '/portal 6/ {print $5}'`
1866 REQ_DELAY=$((${REQ_DELAY} + ${REQ_DELAY} / 4 + 5))
1868 do_facet ost1 lctl set_param fail_val=${REQ_DELAY}
1869 #define OBD_FAIL_OST_BRW_PAUSE_PACK 0x224
1870 do_facet ost1 $LCTL set_param fail_loc=0x224
1873 $SETSTRIPE --stripe-index=0 --stripe-count=1 $DIR/$tfile ||
1874 error "$SETSTRIPE failed"
1875 # force some real bulk transfer
1876 multiop $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
1878 do_facet ost1 $LCTL set_param fail_loc=0
1879 # check for log message
1880 $LCTL dk | grep "Early reply #" || error "No early reply"
1882 # client should show REQ_DELAY estimates
1883 lctl get_param -n osc.${FSNAME}-OST0000-osc-*.timeouts | grep portal
1885 run_test 65b "AT: verify early replies on packed reply / bulk"
1887 test_66a() #bug 3055
1889 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1891 at_start || return 0
1892 lctl get_param -n mdc.${FSNAME}-MDT0000-mdc-*.timeouts | grep "portal 12"
1893 # adjust 5s at a time so no early reply is sent (within deadline)
1894 do_facet $SINGLEMDS "$LCTL set_param fail_val=5000"
1895 #define OBD_FAIL_PTLRPC_PAUSE_REQ 0x50a
1896 do_facet $SINGLEMDS "$LCTL set_param fail_loc=0x8000050a"
1897 createmany -o $DIR/$tfile 20 > /dev/null
1898 unlinkmany $DIR/$tfile 20 > /dev/null
1899 lctl get_param -n mdc.${FSNAME}-MDT0000-mdc-*.timeouts | grep "portal 12"
1900 do_facet $SINGLEMDS "$LCTL set_param fail_val=10000"
1901 do_facet $SINGLEMDS "$LCTL set_param fail_loc=0x8000050a"
1902 createmany -o $DIR/$tfile 20 > /dev/null
1903 unlinkmany $DIR/$tfile 20 > /dev/null
1904 lctl get_param -n mdc.${FSNAME}-MDT0000-mdc-*.timeouts | grep "portal 12"
1905 do_facet $SINGLEMDS "$LCTL set_param fail_loc=0"
1907 createmany -o $DIR/$tfile 20 > /dev/null
1908 unlinkmany $DIR/$tfile 20 > /dev/null
1909 lctl get_param -n mdc.${FSNAME}-MDT0000-mdc-*.timeouts | grep "portal 12"
1910 CUR=$(lctl get_param -n mdc.${FSNAME}-MDT0000-mdc-*.timeouts | awk '/portal 12/ {print $5}')
1911 WORST=$(lctl get_param -n mdc.${FSNAME}-MDT0000-mdc-*.timeouts | awk '/portal 12/ {print $7}')
1912 echo "Current MDT timeout $CUR, worst $WORST"
1913 [ $CUR -lt $WORST ] || error "Current $CUR should be less than worst $WORST"
1915 run_test 66a "AT: verify MDT service time adjusts with no early replies"
1917 test_66b() #bug 3055
1919 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1921 at_start || return 0
1922 ORIG=$(lctl get_param -n mdc.${FSNAME}-MDT0000*.timeouts |
1923 awk '/network/ {print $4}')
1924 $LCTL set_param fail_val=$(($ORIG + 5))
1925 #define OBD_FAIL_PTLRPC_PAUSE_REP 0x50c
1926 $LCTL set_param fail_loc=0x50c
1927 touch $DIR/$tfile > /dev/null 2>&1
1928 $LCTL set_param fail_loc=0
1929 CUR=$(lctl get_param -n mdc.${FSNAME}-MDT0000*.timeouts |
1930 awk '/network/ {print $4}')
1931 WORST=$(lctl get_param -n mdc.${FSNAME}-MDT0000*.timeouts |
1932 awk '/network/ {print $6}')
1933 echo "network timeout orig $ORIG, cur $CUR, worst $WORST"
1934 [ $WORST -gt $ORIG ] ||
1935 error "Worst $WORST should be worse than orig $ORIG"
1937 run_test 66b "AT: verify net latency adjusts"
1939 test_67a() #bug 3055
1941 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1943 at_start || return 0
1944 CONN1=$(lctl get_param -n osc.*.stats | awk '/_connect/ {total+=$2} END {print total}')
1945 # sleeping threads may drive values above this
1946 do_facet ost1 "$LCTL set_param fail_val=400"
1947 #define OBD_FAIL_PTLRPC_PAUSE_REQ 0x50a
1948 do_facet ost1 "$LCTL set_param fail_loc=0x50a"
1949 createmany -o $DIR/$tfile 20 > /dev/null
1950 unlinkmany $DIR/$tfile 20 > /dev/null
1951 do_facet ost1 "$LCTL set_param fail_loc=0"
1952 CONN2=$(lctl get_param -n osc.*.stats | awk '/_connect/ {total+=$2} END {print total}')
1953 ATTEMPTS=$(($CONN2 - $CONN1))
1954 echo "$ATTEMPTS osc reconnect attempts on gradual slow"
1955 [ $ATTEMPTS -gt 0 ] &&
1956 error_ignore bz13721 "AT should have prevented reconnect"
1959 run_test 67a "AT: verify slow request processing doesn't induce reconnects"
1961 test_67b() #bug 3055
1963 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1965 at_start || return 0
1966 CONN1=$(lctl get_param -n osc.*.stats | awk '/_connect/ {total+=$2} END {print total}')
1968 # exhaust precreations on ost1
1969 local OST=$(ostname_from_index 0)
1970 local mdtosc=$(get_mdtosc_proc_path mds $OST)
1971 local last_id=$(do_facet $SINGLEMDS lctl get_param -n \
1972 osc.$mdtosc.prealloc_last_id)
1973 local next_id=$(do_facet $SINGLEMDS lctl get_param -n \
1974 osc.$mdtosc.prealloc_next_id)
1976 mkdir -p $DIR/$tdir/${OST} || error "mkdir $DIR/$tdir/${OST} failed"
1977 $SETSTRIPE -i 0 -c 1 $DIR/$tdir/${OST} || error "$SETSTRIPE failed"
1978 echo "Creating to objid $last_id on ost $OST..."
1979 #define OBD_FAIL_OST_PAUSE_CREATE 0x223
1980 do_facet ost1 "$LCTL set_param fail_val=20000"
1981 do_facet ost1 "$LCTL set_param fail_loc=0x80000223"
1982 createmany -o $DIR/$tdir/${OST}/f $next_id $((last_id - next_id + 2))
1985 do_facet ost1 "lctl get_param -n ost.OSS.ost_create.timeouts"
1987 CONN2=$(lctl get_param -n osc.*.stats | awk '/_connect/ {total+=$2} END {print total}')
1988 ATTEMPTS=$(($CONN2 - $CONN1))
1989 echo "$ATTEMPTS osc reconnect attempts on instant slow"
1990 # do it again; should not timeout
1991 do_facet ost1 "$LCTL set_param fail_loc=0x80000223"
1992 cp /etc/profile $DIR/$tfile || error "cp failed"
1993 do_facet ost1 "$LCTL set_param fail_loc=0"
1995 do_facet ost1 "lctl get_param -n ost.OSS.ost_create.timeouts"
1996 CONN3=$(lctl get_param -n osc.*.stats | awk '/_connect/ {total+=$2} END {print total}')
1997 ATTEMPTS=$(($CONN3 - $CONN2))
1998 echo "$ATTEMPTS osc reconnect attempts on 2nd slow"
1999 [ $ATTEMPTS -gt 0 ] && error "AT should have prevented reconnect"
2002 run_test 67b "AT: verify instant slowdown doesn't induce reconnects"
2004 test_68 () #bug 13813
2006 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
2008 at_start || return 0
2009 local ldlm_enqueue_min=$(find /sys -name ldlm_enqueue_min)
2010 [ -z "$ldlm_enqueue_min" ] && skip "missing /sys/.../ldlm_enqueue_min" && return 0
2011 local ldlm_enqueue_min_r=$(do_facet ost1 "find /sys -name ldlm_enqueue_min")
2012 [ -z "$ldlm_enqueue_min_r" ] && skip "missing /sys/.../ldlm_enqueue_min in the ost1" && return 0
2013 local ENQ_MIN=$(cat $ldlm_enqueue_min)
2014 local ENQ_MIN_R=$(do_facet ost1 "cat $ldlm_enqueue_min_r")
2015 echo $TIMEOUT >> $ldlm_enqueue_min
2016 do_facet ost1 "echo $TIMEOUT >> $ldlm_enqueue_min_r"
2018 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
2019 $SETSTRIPE --stripe-index=0 -c 1 $DIR/$tdir ||
2020 error "$SETSTRIPE failed for $DIR/$tdir"
2021 #define OBD_FAIL_LDLM_PAUSE_CANCEL 0x312
2022 $LCTL set_param fail_val=$(($TIMEOUT - 1))
2023 $LCTL set_param fail_loc=0x80000312
2024 cp /etc/profile $DIR/$tdir/${tfile}_1 || error "1st cp failed $?"
2025 $LCTL set_param fail_val=$((TIMEOUT * 5 / 4))
2026 $LCTL set_param fail_loc=0x80000312
2027 cp /etc/profile $DIR/$tdir/${tfile}_2 || error "2nd cp failed $?"
2028 $LCTL set_param fail_loc=0
2030 echo $ENQ_MIN >> $ldlm_enqueue_min
2031 do_facet ost1 "echo $ENQ_MIN_R >> $ldlm_enqueue_min_r"
2035 run_test 68 "AT: verify slowing locks"
2038 # end of AT tests includes above lines
2040 # start multi-client tests
2042 [ -z "$CLIENTS" ] &&
2043 { skip "Need two or more clients." && return; }
2044 [ $CLIENTCOUNT -lt 2 ] &&
2045 { skip "Need two or more clients, have $CLIENTCOUNT" && return; }
2047 echo "mount clients $CLIENTS ..."
2048 zconf_mount_clients $CLIENTS $MOUNT
2050 local clients=${CLIENTS//,/ }
2051 echo "Write/read files on $DIR ; clients $CLIENTS ... "
2052 for CLIENT in $clients; do
2053 do_node $CLIENT dd bs=1M count=10 if=/dev/zero \
2054 of=$DIR/${tfile}_${CLIENT} 2>/dev/null ||
2055 error "dd failed on $CLIENT"
2058 local prev_client=$(echo $clients | sed 's/^.* \(.\+\)$/\1/')
2059 for C in ${CLIENTS//,/ }; do
2060 do_node $prev_client dd if=$DIR/${tfile}_${C} \
2061 of=/dev/null 2>/dev/null ||
2062 error "dd if=$DIR/${tfile}_${C} failed on $prev_client"
2068 run_test 70a "check multi client t-f"
2070 check_for_process () {
2075 killall_process $clients "$prog" -0
2079 local clients=${CLIENTS:-$HOSTNAME}
2081 zconf_mount_clients $clients $MOUNT
2084 [ "$SLOW" = "no" ] && duration=120
2085 # set duration to 900 because it takes some time to boot node
2086 [ "$FAILURE_MODE" = HARD ] && duration=900
2089 local start_ts=$(date +%s)
2090 local cmd="rundbench 1 -t $duration"
2092 if [ $MDSCOUNT -ge 2 ]; then
2093 test_mkdir -p -c$MDSCOUNT $DIR/$tdir
2094 $LFS setdirstripe -D -c$MDSCOUNT $DIR/$tdir
2096 do_nodesv $clients "set -x; MISSING_DBENCH_OK=$MISSING_DBENCH_OK \
2097 PATH=\$PATH:$LUSTRE/utils:$LUSTRE/tests/:$DBENCH_LIB \
2098 DBENCH_LIB=$DBENCH_LIB TESTSUITE=$TESTSUITE TESTNAME=$TESTNAME \
2099 MOUNT=$MOUNT DIR=$DIR/$tdir/\\\$(hostname) LCTL=$LCTL $cmd" &
2102 #LU-1897 wait for all dbench copies to start
2103 while ! check_for_process $clients dbench; do
2104 elapsed=$(($(date +%s) - start_ts))
2105 if [ $elapsed -gt $duration ]; then
2106 killall_process $clients dbench
2107 error "dbench failed to start on $clients!"
2112 log "Started rundbench load pid=$pid ..."
2114 elapsed=$(($(date +%s) - start_ts))
2115 local num_failovers=0
2117 while [ $elapsed -lt $duration ]; do
2118 if ! check_for_process $clients dbench; then
2119 error_noexit "dbench stopped on some of $clients!"
2120 killall_process $clients dbench
2124 replay_barrier mds$fail_index
2125 sleep 1 # give clients a time to do operations
2126 # Increment the number of failovers
2127 num_failovers=$((num_failovers+1))
2128 log "$TESTNAME fail mds$fail_index $num_failovers times"
2130 elapsed=$(($(date +%s) - start_ts))
2131 if [ $fail_index -ge $MDSCOUNT ]; then
2134 fail_index=$((fail_index+1))
2138 wait $pid || error "rundbench load on $clients failed!"
2140 run_test 70b "dbench ${MDSCOUNT}mdts recovery; $CLIENTCOUNT clients"
2141 # end multi-client tests
2146 local monitor_pid=$3
2148 local start_ts=$(date +%s)
2149 local num_failovers=0
2152 elapsed=$(($(date +%s) - start_ts))
2153 while [ $elapsed -lt $duration ]; do
2154 fail_index=$((RANDOM%max_index+1))
2155 kill -0 $monitor_pid ||
2156 error "$monitor_pid stopped"
2158 replay_barrier mds$fail_index
2160 # Increment the number of failovers
2161 num_failovers=$((num_failovers+1))
2162 log "$TESTNAME fail mds$fail_index $num_failovers times"
2164 elapsed=$(($(date +%s) - start_ts))
2170 rm -f $DIR/replay-single.70c.lck
2175 local clients=${CLIENTS:-$HOSTNAME}
2178 zconf_mount_clients $clients $MOUNT
2181 [ "$SLOW" = "no" ] && duration=180
2182 # set duration to 900 because it takes some time to boot node
2183 [ "$FAILURE_MODE" = HARD ] && duration=600
2186 local start_ts=$(date +%s)
2188 trap cleanup_70c EXIT
2190 while [ ! -e $DIR/replay-single.70c.lck ]; do
2191 test_mkdir -p -c$MDSCOUNT $DIR/$tdir || break
2192 if [ $MDSCOUNT -ge 2 ]; then
2193 $LFS setdirstripe -D -c$MDSCOUNT $DIR/$tdir ||
2194 error "set default dirstripe failed"
2196 cd $DIR/$tdir || break
2197 tar cf - /etc | tar xf - || error "tar failed in loop"
2201 echo "Started tar $tar_70c_pid"
2203 random_fail_mdt $MDSCOUNT $duration $tar_70c_pid
2204 kill -0 $tar_70c_pid || error "tar $tar_70c_pid stopped"
2206 touch $DIR/replay-single.70c.lck
2207 wait $tar_70c_pid || error "$?: tar failed"
2212 run_test 70c "tar ${MDSCOUNT}mdts recovery"
2216 kill -9 $mkdir_70d_pid
2220 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2221 local clients=${CLIENTS:-$HOSTNAME}
2224 zconf_mount_clients $clients $MOUNT
2227 [ "$SLOW" = "no" ] && duration=180
2228 # set duration to 900 because it takes some time to boot node
2229 [ "$FAILURE_MODE" = HARD ] && duration=900
2234 local start_ts=$(date +%s)
2236 trap cleanup_70d EXIT
2239 $LFS mkdir -i0 -c2 $DIR/$tdir/test || {
2243 $LFS mkdir -i1 -c2 $DIR/$tdir/test1 || {
2248 touch $DIR/$tdir/test/a || {
2252 mkdir $DIR/$tdir/test/b || {
2256 rm -rf $DIR/$tdir/test || {
2262 touch $DIR/$tdir/test1/a || {
2266 mkdir $DIR/$tdir/test1/b || {
2271 rm -rf $DIR/$tdir/test1 || {
2273 ls -lR $DIR/$tdir/test1
2279 echo "Started $mkdir_70d_pid"
2281 random_fail_mdt $MDSCOUNT $duration $mkdir_70d_pid
2282 kill -0 $mkdir_70d_pid || error "mkdir/rmdir $mkdir_70d_pid stopped"
2287 run_test 70d "mkdir/rmdir striped dir ${MDSCOUNT}mdts recovery"
2290 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2291 local clients=${CLIENTS:-$HOSTNAME}
2294 lctl set_param debug=+ha
2295 zconf_mount_clients $clients $MOUNT
2298 [ "$SLOW" = "no" ] && duration=180
2299 # set duration to 900 because it takes some time to boot node
2300 [ "$FAILURE_MODE" = HARD ] && duration=900
2303 $LFS mkdir -i0 $DIR/$tdir/test_0
2304 $LFS mkdir -i0 $DIR/$tdir/test_1
2305 touch $DIR/$tdir/test_0/a
2306 touch $DIR/$tdir/test_1/b
2309 mrename $DIR/$tdir/test_0/a $DIR/$tdir/test_1/b > /dev/null || {
2314 checkstat $DIR/$tdir/test_0/a && {
2315 echo "a still exists"
2319 checkstat $DIR/$tdir/test_1/b || {
2320 echo "b still exists"
2324 touch $DIR/$tdir/test_0/a || {
2325 echo "touch a fails"
2329 mrename $DIR/$tdir/test_1/b $DIR/$tdir/test_0/a > /dev/null || {
2336 stack_trap "kill -9 $rename_70e_pid" EXIT
2337 echo "Started PID=$rename_70e_pid"
2339 random_fail_mdt 2 $duration $rename_70e_pid
2340 kill -0 $rename_70e_pid || error "rename $rename_70e_pid stopped"
2342 run_test 70e "rename cross-MDT with random fails"
2344 test_70f_write_and_read(){
2349 echo "Write/read files in: '$DIR/$tdir', clients: '$CLIENTS' ..."
2350 for client in ${CLIENTS//,/ }; do
2351 [ -f $stopflag ] || return
2353 local tgtfile=$DIR/$tdir/$tfile.$client
2354 do_node $client dd $DD_OPTS bs=1M count=10 if=$srcfile \
2355 of=$tgtfile 2>/dev/null ||
2356 error "dd $DD_OPTS bs=1M count=10 if=$srcfile " \
2357 "of=$tgtfile failed on $client, rc=$?"
2360 local prev_client=$(echo ${CLIENTS//,/ } | awk '{ print $NF }')
2363 for client in ${CLIENTS//,/ }; do
2364 [ -f $stopflag ] || return
2366 # flush client cache in case test is running on only one client
2367 # do_node $client cancel_lru_locks osc
2368 do_node $client $LCTL set_param ldlm.namespaces.*.lru_size=clear
2370 tgtfile=$DIR/$tdir/$tfile.$client
2371 local md5=$(do_node $prev_client "md5sum $tgtfile")
2372 [ ${checksum[$index]// */} = ${md5// */} ] ||
2373 error "$tgtfile: checksum doesn't match on $prev_client"
2374 index=$((index + 1))
2384 mkdir -p $DIR/$tdir || error "cannot create $DIR/$tdir directory"
2385 $SETSTRIPE -c -1 $DIR/$tdir || error "cannot $SETSTRIPE $DIR/$tdir"
2388 while [ -f $stopflag ]; do
2389 test_70f_write_and_read $srcfile $stopflag
2390 # use direct IO and buffer cache in turns if loop
2391 [ -n "$DD_OPTS" ] && DD_OPTS="" || DD_OPTS="oflag=direct"
2395 test_70f_cleanup() {
2397 rm -f $TMP/$tfile.stop
2398 do_nodes $CLIENTS rm -f $TMP/$tfile
2399 rm -f $DIR/$tdir/$tfile.*
2403 # [ x$ost1failover_HOST = x$ost_HOST ] &&
2404 # { skip "Failover host not defined" && return; }
2405 # [ -z "$CLIENTS" ] &&
2406 # { skip "CLIENTS are not specified." && return; }
2407 # [ $CLIENTCOUNT -lt 2 ] &&
2408 # { skip "Need 2 or more clients, have $CLIENTCOUNT" && return; }
2410 [[ $(lustre_version_code ost1) -lt $(version_code 2.9.53) ]] &&
2411 skip "Need server version at least 2.9.53" && return
2413 echo "mount clients $CLIENTS ..."
2414 zconf_mount_clients $CLIENTS $MOUNT
2416 local srcfile=$TMP/$tfile
2420 trap test_70f_cleanup EXIT
2421 # create a different source file local to each client node so we can
2422 # detect if the file wasn't written out properly after failover
2423 do_nodes $CLIENTS dd bs=1M count=10 if=/dev/urandom of=$srcfile \
2424 2>/dev/null || error "can't create $srcfile on $CLIENTS"
2425 for client in ${CLIENTS//,/ }; do
2426 checksum[$index]=$(do_node $client "md5sum $srcfile")
2427 index=$((index + 1))
2431 [ "$SLOW" = "no" ] && duration=60
2432 # set duration to 900 because it takes some time to boot node
2433 [ "$FAILURE_MODE" = HARD ] && duration=900
2435 local stopflag=$TMP/$tfile.stop
2436 test_70f_loop $srcfile $stopflag &
2440 local num_failovers=0
2441 local start_ts=$SECONDS
2442 while [ $elapsed -lt $duration ]; do
2446 num_failovers=$((num_failovers + 1))
2447 log "$TESTNAME failing OST $num_failovers times"
2450 elapsed=$((SECONDS - start_ts))
2457 run_test 70f "OSS O_DIRECT recovery with $CLIENTCOUNT clients"
2461 kill -9 $mkdir_71a_pid
2464 random_double_fail_mdt() {
2467 local monitor_pid=$3
2469 local start_ts=$(date +%s)
2470 local num_failovers=0
2474 elapsed=$(($(date +%s) - start_ts))
2475 while [ $elapsed -lt $duration ]; do
2476 fail_index=$((RANDOM%max_index + 1))
2477 if [ $fail_index -eq $max_index ]; then
2480 second_index=$((fail_index + 1))
2482 kill -0 $monitor_pid ||
2483 error "$monitor_pid stopped"
2485 replay_barrier mds$fail_index
2486 replay_barrier mds$second_index
2488 # Increment the number of failovers
2489 num_failovers=$((num_failovers+1))
2490 log "fail mds$fail_index mds$second_index $num_failovers times"
2491 fail mds${fail_index},mds${second_index}
2492 elapsed=$(($(date +%s) - start_ts))
2497 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2498 local clients=${CLIENTS:-$HOSTNAME}
2501 zconf_mount_clients $clients $MOUNT
2504 [ "$SLOW" = "no" ] && duration=180
2505 # set duration to 900 because it takes some time to boot node
2506 [ "$FAILURE_MODE" = HARD ] && duration=900
2511 local start_ts=$(date +%s)
2513 trap cleanup_71a EXIT
2516 $LFS mkdir -i0 -c2 $DIR/$tdir/test
2517 rmdir $DIR/$tdir/test
2521 echo "Started $mkdir_71a_pid"
2523 random_double_fail_mdt 2 $duration $mkdir_71a_pid
2524 kill -0 $mkdir_71a_pid || error "mkdir/rmdir $mkdir_71a_pid stopped"
2529 run_test 71a "mkdir/rmdir striped dir with 2 mdts recovery"
2532 multiop_bg_pause $DIR/$tfile O_tSc ||
2533 error "multiop_bg_pause $DIR/$tfile failed"
2537 replay_barrier $SINGLEMDS
2538 #define OBD_FAIL_LDLM_ENQUEUE_NET 0x302
2539 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000302"
2542 wait $pid || error "multiop pid failed"
2543 [ -e $DIR/$tfile ] && error "file $DIR/$tfile should not exist"
2546 run_test 73a "open(O_CREAT), unlink, replay, reconnect before open replay, close"
2549 multiop_bg_pause $DIR/$tfile O_tSc ||
2550 error "multiop_bg_pause $DIR/$tfile failed"
2554 replay_barrier $SINGLEMDS
2555 #define OBD_FAIL_LDLM_REPLY 0x30c
2556 do_facet $SINGLEMDS "lctl set_param fail_loc=0x8000030c"
2559 wait $pid || error "multiop pid failed"
2560 [ -e $DIR/$tfile ] && error "file $DIR/$tfile should not exist"
2563 run_test 73b "open(O_CREAT), unlink, replay, reconnect at open_replay reply, close"
2567 local clients=${CLIENTS:-$HOSTNAME}
2569 zconf_umount_clients $clients $MOUNT
2571 facet_failover $SINGLEMDS
2572 zconf_mount_clients $clients $MOUNT
2574 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
2575 rm $DIR/$tfile || error "rm $DIR/$tfile failed"
2576 clients_up || error "client evicted: $?"
2579 run_test 74 "Ensure applications don't fail waiting for OST recovery"
2581 remote_dir_check_80() {
2586 diridx=$($LFS getstripe -m $remote_dir) ||
2587 error "$LFS getstripe -m $remote_dir failed"
2588 [ $diridx -eq $mdtidx ] || error "$diridx != $mdtidx"
2590 createmany -o $remote_dir/f-%d 20 || error "creation failed"
2591 fileidx=$($LFS getstripe -m $remote_dir/f-1) ||
2592 error "$LFS getstripe -m $remote_dir/f-1 failed"
2593 [ $fileidx -eq $mdtidx ] || error "$fileidx != $mdtidx"
2599 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2600 ([ $FAILURE_MODE == "HARD" ] &&
2601 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
2602 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
2606 local remote_dir=$DIR/$tdir/remote_dir
2608 mkdir -p $DIR/$tdir || error "mkdir $DIR/$tdir failed"
2609 #define OBD_FAIL_OUT_UPDATE_NET_REP 0x1701
2610 do_facet mds${MDTIDX} lctl set_param fail_loc=0x1701
2611 $LFS mkdir -i $MDTIDX $remote_dir &
2617 wait $CLIENT_PID || error "remote creation failed"
2619 remote_dir_check_80 || error "remote dir check failed"
2620 rm -rf $DIR/$tdir || error "rmdir failed"
2624 run_test 80a "DNE: create remote dir, drop update rep from MDT0, fail MDT0"
2627 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2628 ([ $FAILURE_MODE == "HARD" ] &&
2629 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
2630 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
2634 local remote_dir=$DIR/$tdir/remote_dir
2636 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
2637 #define OBD_FAIL_OUT_UPDATE_NET_REP 0x1701
2638 do_facet mds${MDTIDX} lctl set_param fail_loc=0x1701
2639 $LFS mkdir -i $MDTIDX $remote_dir &
2644 fail mds$((MDTIDX + 1))
2646 wait $CLIENT_PID || error "remote creation failed"
2648 remote_dir_check_80 || error "remote dir check failed"
2649 rm -rf $DIR/$tdir || error "rmdir failed"
2653 run_test 80b "DNE: create remote dir, drop update rep from MDT0, fail MDT1"
2656 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2657 ([ $FAILURE_MODE == "HARD" ] &&
2658 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
2659 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
2663 local remote_dir=$DIR/$tdir/remote_dir
2665 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
2666 #define OBD_FAIL_OUT_UPDATE_NET_REP 0x1701
2667 do_facet mds${MDTIDX} lctl set_param fail_loc=0x1701
2668 $LFS mkdir -i $MDTIDX $remote_dir &
2674 fail mds$((MDTIDX + 1))
2676 wait $CLIENT_PID || error "remote creation failed"
2678 remote_dir_check_80 || error "remote dir check failed"
2679 rm -rf $DIR/$tdir || error "rmdir failed"
2683 run_test 80c "DNE: create remote dir, drop update rep from MDT1, fail MDT[0,1]"
2686 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2688 local remote_dir=$DIR/$tdir/remote_dir
2690 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
2691 #define OBD_FAIL_OUT_UPDATE_NET_REP 0x1701
2692 do_facet mds${MDTIDX} lctl set_param fail_loc=0x1701
2693 $LFS mkdir -i $MDTIDX $remote_dir &
2696 # sleep 3 seconds to make sure MDTs are failed after
2697 # lfs mkdir -i has finished on all of MDTs.
2702 fail mds${MDTIDX},mds$((MDTIDX + 1))
2704 wait $CLIENT_PID || error "remote creation failed"
2706 remote_dir_check_80 || error "remote dir check failed"
2707 rm -rf $DIR/$tdir || error "rmdir failed"
2711 run_test 80d "DNE: create remote dir, drop update rep from MDT1, fail 2 MDTs"
2714 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2715 ([ $FAILURE_MODE == "HARD" ] &&
2716 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
2717 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
2721 local remote_dir=$DIR/$tdir/remote_dir
2723 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
2724 # OBD_FAIL_MDS_REINT_NET_REP 0x119
2725 do_facet mds$((MDTIDX + 1)) lctl set_param fail_loc=0x119
2726 $LFS mkdir -i $MDTIDX $remote_dir &
2729 # sleep 3 seconds to make sure MDTs are failed after
2730 # lfs mkdir -i has finished on all of MDTs.
2736 wait $CLIENT_PID || error "remote creation failed"
2738 remote_dir_check_80 || error "remote dir check failed"
2739 rm -rf $DIR/$tdir || error "rmdir failed"
2743 run_test 80e "DNE: create remote dir, drop MDT1 rep, fail MDT0"
2746 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2747 ([ $FAILURE_MODE == "HARD" ] &&
2748 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
2749 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
2752 local remote_dir=$DIR/$tdir/remote_dir
2754 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
2755 # OBD_FAIL_MDS_REINT_NET_REP 0x119
2756 do_facet mds$((MDTIDX + 1)) lctl set_param fail_loc=0x119
2757 $LFS mkdir -i $MDTIDX $remote_dir &
2761 fail mds$((MDTIDX + 1))
2763 wait $CLIENT_PID || error "remote creation failed"
2765 remote_dir_check_80 || error "remote dir check failed"
2766 rm -rf $DIR/$tdir || error "rmdir failed"
2770 run_test 80f "DNE: create remote dir, drop MDT1 rep, fail MDT1"
2773 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2774 ([ $FAILURE_MODE == "HARD" ] &&
2775 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
2776 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
2780 local remote_dir=$DIR/$tdir/remote_dir
2782 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
2783 # OBD_FAIL_MDS_REINT_NET_REP 0x119
2784 do_facet mds$((MDTIDX + 1)) lctl set_param fail_loc=0x119
2785 $LFS mkdir -i $MDTIDX $remote_dir &
2788 # sleep 3 seconds to make sure MDTs are failed after
2789 # lfs mkdir -i has finished on all of MDTs.
2795 fail mds$((MDTIDX + 1))
2797 wait $CLIENT_PID || error "remote creation failed"
2799 remote_dir_check_80 || error "remote dir check failed"
2800 rm -rf $DIR/$tdir || error "rmdir failed"
2804 run_test 80g "DNE: create remote dir, drop MDT1 rep, fail MDT0, then MDT1"
2807 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2809 local remote_dir=$DIR/$tdir/remote_dir
2811 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
2812 # OBD_FAIL_MDS_REINT_NET_REP 0x119
2813 do_facet mds$((MDTIDX + 1)) lctl set_param fail_loc=0x119
2814 $LFS mkdir -i $MDTIDX $remote_dir &
2817 # sleep 3 seconds to make sure MDTs are failed after
2818 # lfs mkdir -i has finished on all of MDTs.
2823 fail mds${MDTIDX},mds$((MDTIDX + 1))
2825 wait $CLIENT_PID || error "remote dir creation failed"
2827 remote_dir_check_80 || error "remote dir check failed"
2828 rm -rf $DIR/$tdir || error "rmdir failed"
2832 run_test 80h "DNE: create remote dir, drop MDT1 rep, fail 2 MDTs"
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 touch $remote_dir || error "touch $remote_dir failed"
2848 # OBD_FAIL_OUT_UPDATE_NET_REP 0x1701
2849 do_facet mds${MDTIDX} lctl set_param fail_loc=0x1701
2854 fail mds$((MDTIDX + 1))
2856 wait $CLIENT_PID || error "rm remote dir failed"
2858 stat $remote_dir &>/dev/null && error "$remote_dir still exist!"
2860 rm -rf $DIR/$tdir || error "rmdir failed"
2864 run_test 81a "DNE: unlink remote dir, drop MDT0 update rep, fail MDT1"
2867 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2868 ([ $FAILURE_MODE == "HARD" ] &&
2869 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
2870 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_OUT_UPDATE_NET_REP 0x1701
2879 do_facet mds${MDTIDX} lctl set_param fail_loc=0x1701
2886 wait $CLIENT_PID || error "rm remote dir failed"
2888 stat $remote_dir &>/dev/null && error "$remote_dir still exist!"
2890 rm -rf $DIR/$tdir || error "rmdir failed"
2894 run_test 81b "DNE: unlink remote dir, drop MDT0 update reply, fail MDT0"
2897 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2898 ([ $FAILURE_MODE == "HARD" ] &&
2899 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
2900 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
2904 local remote_dir=$DIR/$tdir/remote_dir
2906 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
2907 $LFS mkdir -i $MDTIDX $remote_dir || error "lfs mkdir failed"
2909 # OBD_FAIL_OUT_UPDATE_NET_REP 0x1701
2910 do_facet mds${MDTIDX} lctl set_param fail_loc=0x1701
2917 fail mds$((MDTIDX + 1))
2919 wait $CLIENT_PID || error "rm remote dir failed"
2921 stat $remote_dir &>/dev/null && error "$remote_dir still exist!"
2923 rm -rf $DIR/$tdir || error "rmdir failed"
2927 run_test 81c "DNE: unlink remote dir, drop MDT0 update reply, fail MDT0,MDT1"
2930 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2932 local remote_dir=$DIR/$tdir/remote_dir
2934 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
2935 $LFS mkdir -i $MDTIDX $remote_dir || error "lfs mkdir failed"
2937 # OBD_FAIL_OUT_UPDATE_NET_REP 0x1701
2938 do_facet mds${MDTIDX} lctl set_param fail_loc=0x1701
2944 fail mds${MDTIDX},mds$((MDTIDX + 1))
2946 wait $CLIENT_PID || error "rm remote dir failed"
2948 stat $remote_dir &>/dev/null && error "$remote_dir still exist!"
2950 rm -rf $DIR/$tdir || error "rmdir failed"
2954 run_test 81d "DNE: unlink remote dir, drop MDT0 update reply, fail 2 MDTs"
2957 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2958 ([ $FAILURE_MODE == "HARD" ] &&
2959 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
2960 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
2964 local remote_dir=$DIR/$tdir/remote_dir
2966 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
2967 $LFS mkdir -i $MDTIDX $remote_dir || error "lfs mkdir failed"
2969 # OBD_FAIL_MDS_REINT_NET_REP 0x119
2970 do_facet mds$((MDTIDX + 1)) lctl set_param fail_loc=0x119
2973 do_facet mds$((MDTIDX + 1)) lctl set_param fail_loc=0
2978 wait $CLIENT_PID || error "rm remote dir failed"
2980 stat $remote_dir &>/dev/null && error "$remote_dir still exist!"
2982 rm -rf $DIR/$tdir || error "rmdir failed"
2986 run_test 81e "DNE: unlink remote dir, drop MDT1 req reply, fail MDT0"
2989 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2990 ([ $FAILURE_MODE == "HARD" ] &&
2991 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
2992 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
2996 local remote_dir=$DIR/$tdir/remote_dir
2998 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
2999 $LFS mkdir -i $MDTIDX $remote_dir || error "lfs mkdir failed"
3001 # OBD_FAIL_MDS_REINT_NET_REP 0x119
3002 do_facet mds$((MDTIDX + 1)) lctl set_param fail_loc=0x119
3007 fail mds$((MDTIDX + 1))
3009 wait $CLIENT_PID || error "rm remote dir failed"
3011 stat $remote_dir &>/dev/null && error "$remote_dir still exist!"
3013 rm -rf $DIR/$tdir || error "rmdir failed"
3017 run_test 81f "DNE: unlink remote dir, drop MDT1 req reply, fail MDT1"
3020 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
3021 ([ $FAILURE_MODE == "HARD" ] &&
3022 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
3023 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
3027 local remote_dir=$DIR/$tdir/remote_dir
3029 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
3030 $LFS mkdir -i $MDTIDX $remote_dir || error "lfs mkdir failed"
3032 # OBD_FAIL_MDS_REINT_NET_REP 0x119
3033 do_facet mds$((MDTIDX + 1)) lctl set_param fail_loc=0x119
3040 fail mds$((MDTIDX + 1))
3042 wait $CLIENT_PID || error "rm remote dir failed"
3044 stat $remote_dir &>/dev/null && error "$remote_dir still exist!"
3046 rm -rf $DIR/$tdir || error "rmdir failed"
3050 run_test 81g "DNE: unlink remote dir, drop req reply, fail M0, then M1"
3053 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
3055 local remote_dir=$DIR/$tdir/remote_dir
3057 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
3058 $LFS mkdir -i $MDTIDX $remote_dir || error "lfs mkdir failed"
3060 # OBD_FAIL_MDS_REINT_NET_REP 0x119
3061 do_facet mds$((MDTIDX + 1)) lctl set_param fail_loc=0x119
3067 fail mds${MDTIDX},mds$((MDTIDX + 1))
3069 wait $CLIENT_PID || error "rm remote dir failed"
3071 stat $remote_dir &>/dev/null && error "$remote_dir still exist!"
3073 rm -rf $DIR/$tdir || error "rmdir failed"
3077 run_test 81h "DNE: unlink remote dir, drop request reply, fail 2 MDTs"
3080 #define OBD_FAIL_MDS_OPEN_WAIT_CREATE 0x144
3081 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000144"
3082 createmany -o $DIR/$tfile- 1 &
3086 client_up || client_up || true # reconnect
3088 run_test 84a "stale open during export disconnect"
3090 test_85a() { #bug 16774
3091 lctl set_param -n ldlm.cancel_unused_locks_before_replay "1"
3093 for i in $(seq 100); do
3094 echo "tag-$i" > $DIR/$tfile-$i
3095 grep -q "tag-$i" $DIR/$tfile-$i || error "f2-$i"
3098 lov_id=$(lctl dl | grep "clilov")
3099 addr=$(echo $lov_id | awk '{print $4}' | awk -F '-' '{print $NF}')
3100 count=$(lctl get_param -n \
3101 ldlm.namespaces.*MDT0000*$addr.lock_unused_count)
3102 echo "before recovery: unused locks count = $count"
3106 count2=$(lctl get_param -n \
3107 ldlm.namespaces.*MDT0000*$addr.lock_unused_count)
3108 echo "after recovery: unused locks count = $count2"
3110 if [ $count2 -ge $count ]; then
3111 error "unused locks are not canceled"
3114 run_test 85a "check the cancellation of unused locks during recovery(IBITS)"
3116 test_85b() { #bug 16774
3117 lctl set_param -n ldlm.cancel_unused_locks_before_replay "1"
3119 if ! combined_mgs_mds ; then
3123 create_pool $FSNAME.$TESTNAME ||
3124 error "unable to create pool $TESTNAME"
3125 do_facet mgs $LCTL pool_add $FSNAME.$TESTNAME $FSNAME-OST0000 ||
3126 error "unable to add pool $TESTNAME"
3128 $SETSTRIPE -c 1 -p $FSNAME.$TESTNAME $DIR
3130 for i in $(seq 100); do
3131 dd if=/dev/urandom of=$DIR/$tfile-$i bs=4096 \
3132 count=32 >/dev/null 2>&1
3135 cancel_lru_locks osc
3137 for i in $(seq 100); do
3138 dd if=$DIR/$tfile-$i of=/dev/null bs=4096 \
3139 count=32 >/dev/null 2>&1
3142 lov_id=$(lctl dl | grep "clilov")
3143 addr=$(echo $lov_id | awk '{print $4}' | awk -F '-' '{print $NF}')
3144 count=$(lctl get_param -n \
3145 ldlm.namespaces.*OST0000*$addr.lock_unused_count)
3146 echo "before recovery: unused locks count = $count"
3147 [ $count -ne 0 ] || error "unused locks ($count) should be zero"
3151 count2=$(lctl get_param \
3152 -n ldlm.namespaces.*OST0000*$addr.lock_unused_count)
3153 echo "after recovery: unused locks count = $count2"
3155 do_facet mgs $LCTL pool_remove $FSNAME.$TESTNAME $FSNAME-OST0000 ||
3156 error "unable to remove pool $TESTNAME"
3157 do_facet mgs $LCTL pool_destroy $FSNAME.$TESTNAME ||
3158 error "unable to destroy the pool $TESTNAME"
3160 if ! combined_mgs_mds ; then
3164 if [ $count2 -ge $count ]; then
3165 error "unused locks are not canceled"
3168 run_test 85b "check the cancellation of unused locks during recovery(EXTENT)"
3171 local clients=${CLIENTS:-$HOSTNAME}
3173 zconf_umount_clients $clients $MOUNT
3174 do_facet $SINGLEMDS lctl set_param mdt.${FSNAME}-MDT*.exports.clear=0
3175 remount_facet $SINGLEMDS
3176 zconf_mount_clients $clients $MOUNT
3178 run_test 86 "umount server after clear nid_stats should not hit LBUG"
3181 do_facet ost1 "lctl set_param -n obdfilter.${ost1_svc}.sync_journal 0"
3184 $SETSTRIPE -i 0 -c 1 $DIR/$tfile
3185 dd if=/dev/urandom of=$DIR/$tfile bs=1024k count=8 ||
3186 error "dd to $DIR/$tfile failed"
3187 cksum=$(md5sum $DIR/$tfile | awk '{print $1}')
3188 cancel_lru_locks osc
3190 dd if=$DIR/$tfile of=/dev/null bs=1024k count=8 || error "Cannot read"
3191 cksum2=$(md5sum $DIR/$tfile | awk '{print $1}')
3192 if [ $cksum != $cksum2 ] ; then
3193 error "New checksum $cksum2 does not match original $cksum"
3196 run_test 87a "write replay"
3199 do_facet ost1 "lctl set_param -n obdfilter.${ost1_svc}.sync_journal 0"
3202 $SETSTRIPE -i 0 -c 1 $DIR/$tfile
3203 dd if=/dev/urandom of=$DIR/$tfile bs=1024k count=8 ||
3204 error "dd to $DIR/$tfile failed"
3205 sleep 1 # Give it a chance to flush dirty data
3206 echo TESTTEST | dd of=$DIR/$tfile bs=1 count=8 seek=64
3207 cksum=$(md5sum $DIR/$tfile | awk '{print $1}')
3208 cancel_lru_locks osc
3210 dd if=$DIR/$tfile of=/dev/null bs=1024k count=8 || error "Cannot read"
3211 cksum2=$(md5sum $DIR/$tfile | awk '{print $1}')
3212 if [ $cksum != $cksum2 ] ; then
3213 error "New checksum $cksum2 does not match original $cksum"
3216 run_test 87b "write replay with changed data (checksum resend)"
3218 test_88() { #bug 17485
3219 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
3220 mkdir -p $TMP/$tdir || error "mkdir $TMP/$tdir failed"
3222 $SETSTRIPE -i 0 -c 1 $DIR/$tdir || error "$SETSTRIPE"
3225 replay_barrier $SINGLEMDS
3227 # exhaust precreations on ost1
3228 local OST=$(ostname_from_index 0)
3229 local mdtosc=$(get_mdtosc_proc_path $SINGLEMDS $OST)
3230 local last_id=$(do_facet $SINGLEMDS lctl get_param -n osc.$mdtosc.prealloc_last_id)
3231 local next_id=$(do_facet $SINGLEMDS lctl get_param -n osc.$mdtosc.prealloc_next_id)
3232 echo "before test: last_id = $last_id, next_id = $next_id"
3234 echo "Creating to objid $last_id on ost $OST..."
3235 createmany -o $DIR/$tdir/f-%d $next_id $((last_id - next_id + 2)) ||
3236 error "createmany create files to last_id failed"
3238 #create some files to use some uncommitted objids
3239 last_id=$(($last_id + 1))
3240 createmany -o $DIR/$tdir/f-%d $last_id 8 ||
3241 error "createmany create files with uncommitted objids failed"
3243 last_id2=$(do_facet $SINGLEMDS lctl get_param -n osc.$mdtosc.prealloc_last_id)
3244 next_id2=$(do_facet $SINGLEMDS lctl get_param -n osc.$mdtosc.prealloc_next_id)
3245 echo "before recovery: last_id = $last_id2, next_id = $next_id2"
3247 # if test uses shutdown_facet && reboot_facet instead of facet_failover ()
3248 # it has to take care about the affected facets, bug20407
3249 local affected_mds1=$(affected_facets mds1)
3250 local affected_ost1=$(affected_facets ost1)
3252 shutdown_facet $SINGLEMDS
3255 reboot_facet $SINGLEMDS
3256 change_active $affected_mds1
3257 wait_for_facet $affected_mds1
3258 mount_facets $affected_mds1 || error "Restart of mds failed"
3261 change_active $affected_ost1
3262 wait_for_facet $affected_ost1
3263 mount_facets $affected_ost1 || error "Restart of ost1 failed"
3267 last_id2=$(do_facet $SINGLEMDS lctl get_param -n osc.$mdtosc.prealloc_last_id)
3268 next_id2=$(do_facet $SINGLEMDS lctl get_param -n osc.$mdtosc.prealloc_next_id)
3269 echo "after recovery: last_id = $last_id2, next_id = $next_id2"
3271 # create new files, which should use new objids, and ensure the orphan
3272 # cleanup phase for ost1 is completed at the same time
3273 for i in $(seq 8); do
3274 file_id=$(($last_id + 10 + $i))
3275 dd if=/dev/urandom of=$DIR/$tdir/f-$file_id bs=4096 count=128
3278 # if the objids were not recreated, then "ls" will fail with -ENOENT
3279 ls -l $DIR/$tdir/* || error "can't get the status of precreated files"
3282 # write into previously created files
3283 for i in $(seq 8); do
3284 file_id=$(($last_id + $i))
3285 dd if=/dev/urandom of=$DIR/$tdir/f-$file_id bs=4096 count=128
3286 cp -f $DIR/$tdir/f-$file_id $TMP/$tdir/
3289 # compare the content
3290 for i in $(seq 8); do
3291 file_id=$(($last_id + $i))
3292 cmp $TMP/$tdir/f-$file_id $DIR/$tdir/f-$file_id ||
3293 error "the content of file is modified!"
3298 run_test 88 "MDS should not assign same objid to different files "
3300 function calc_osc_kbytes_used() {
3301 local kbtotal=$(calc_osc_kbytes kbytestotal)
3302 local kbfree=$(calc_osc_kbytes kbytesfree)
3303 echo $((kbtotal-kbfree))
3307 cancel_lru_locks osc
3308 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
3309 rm -f $DIR/$tdir/$tfile
3310 wait_mds_ost_sync || error "initial MDS-OST sync timed out"
3311 wait_delete_completed || error "initial wait delete timed out"
3312 local blocks1=$(calc_osc_kbytes_used)
3313 local write_size=$(fs_log_size)
3315 $SETSTRIPE -i 0 -c 1 $DIR/$tdir/$tfile
3316 [ $write_size -lt 1024 ] && write_size=1024
3317 dd if=/dev/zero bs=${write_size}k count=10 of=$DIR/$tdir/$tfile
3320 facet_failover $SINGLEMDS
3321 rm $DIR/$tdir/$tfile
3324 zconf_mount $(hostname) $MOUNT || error "mount fails"
3325 client_up || error "client_up failed"
3327 # wait for the remounted client to connect to ost1
3328 local target=$(get_osc_import_name client ost1)
3329 wait_import_state "FULL" "osc.${target}.ost_server_uuid" \
3330 $(max_recovery_time)
3332 wait_mds_ost_sync || error "MDS-OST sync timed out"
3333 wait_delete_completed || error "wait delete timed out"
3334 local blocks2=$(calc_osc_kbytes_used)
3336 [ $((blocks2 - blocks1)) -le $(fs_log_size) ] ||
3337 error $((blocks2 - blocks1)) blocks leaked
3339 run_test 89 "no disk space leak on late ost connection"
3346 change_active $facet
3347 wait_for_facet $facet
3348 mount_facet $facet || error "Restart of $facet failed"
3352 test_90() { # bug 19494
3353 local dir=$DIR/$tdir
3354 local ostfail=$(get_random_entry $(get_facets OST))
3356 if [[ $FAILURE_MODE = HARD ]]; then
3357 local affected=$(affected_facets $ostfail);
3358 if [[ "$affected" != $ostfail ]]; then
3359 skip not functional with FAILURE_MODE=$FAILURE_MODE, affected: $affected
3363 # ensure all OSTs are active to allow allocations
3366 mkdir $dir || error "mkdir $dir failed"
3368 echo "Create the files"
3370 # file "f${index}" striped over 1 OST
3371 # file "all" striped over all OSTs
3373 $LFS setstripe -c $OSTCOUNT $dir/all ||
3374 error "setstripe failed to create $dir/all"
3376 for ((i = 0; i < $OSTCOUNT; i++)); do
3379 $LFS setstripe -i $i -c 1 $f ||
3380 error "$LFS setstripe failed to create $f"
3382 # confirm setstripe actually created stripe on requested OST
3383 local uuid=$(ostuuid_from_index $i)
3385 for file in f$i all; do
3386 local found=$($LFS find --obd $uuid --name $file $dir)
3388 if [[ $dir/$file != $found ]]; then
3389 $LFS getstripe $dir/$file
3390 error "wrong stripe: $file, uuid: $uuid"
3395 # Before failing an OST, get its obd name and index
3396 local varsvc=${ostfail}_svc
3397 local obd=$(do_facet $ostfail lctl get_param \
3398 -n obdfilter.${!varsvc}.uuid)
3399 local index=$(($(facet_number $ostfail) - 1))
3401 echo "Fail $ostfail $obd, display the list of affected files"
3402 shutdown_facet $ostfail || error "shutdown_facet $ostfail failed"
3404 trap "cleanup_90 $ostfail" EXIT INT
3405 echo "General Query: lfs find $dir"
3406 local list=$($LFS find $dir)
3408 for (( i=0; i<$OSTCOUNT; i++ )); do
3409 list_member "$list" $dir/f$i ||
3410 error_noexit "lfs find $dir: no file f$i"
3412 list_member "$list" $dir/all ||
3413 error_noexit "lfs find $dir: no file all"
3415 # focus on the missing OST,
3416 # we expect to see only two files affected: "f$(index)" and "all"
3418 echo "Querying files on shutdown $ostfail: lfs find --obd $obd"
3419 list=$($LFS find --obd $obd $dir)
3421 for file in all f$index; do
3422 list_member "$list" $dir/$file ||
3423 error_noexit "lfs find does not report the affected $obd for $file"
3426 [[ $(echo $list | wc -w) -eq 2 ]] ||
3427 error_noexit "lfs find reports the wrong list of affected files ${#list[@]}"
3429 echo "Check getstripe: $GETSTRIPE -r --obd $obd"
3430 list=$($GETSTRIPE -r --obd $obd $dir)
3432 for file in all f$index; do
3433 echo "$list" | grep $dir/$file ||
3434 error_noexit "lfs getsripe does not report the affected $obd for $file"
3439 run_test 90 "lfs find identifies the missing striped file segments"
3442 local server_version=$(lustre_version_code $SINGLEMDS)
3443 [[ $server_version -ge $(version_code 2.6.90) ]] ||
3444 [[ $server_version -ge $(version_code 2.5.4) &&
3445 $server_version -lt $(version_code 2.5.50) ]] ||
3446 { skip "Need MDS version 2.5.4+ or 2.6.90+"; return; }
3448 cancel_lru_locks osc
3450 $SETSTRIPE -i 0 -c 1 $DIR/$tfile ||
3451 error "$SETSTRIPE $DIR/$tfile failed"
3452 dd if=/dev/zero of=$DIR/$tfile bs=1024 count=1 ||
3453 error "dd to $DIR/$tfile failed"
3454 #define OBD_FAIL_TGT_REPLAY_RECONNECT 0x715
3455 # We need to emulate a state that OST is waiting for other clients
3456 # not completing the recovery. Final ping is queued, but reply will be
3457 # sent on the recovery completion. It is done by sleep before
3458 # processing final pings
3459 do_facet ost1 "$LCTL set_param fail_val=40"
3460 do_facet ost1 "$LCTL set_param fail_loc=0x715"
3463 run_test 93a "replay + reconnect"
3466 local server_version=$(lustre_version_code $SINGLEMDS)
3467 [[ $server_version -ge $(version_code 2.7.90) ]] ||
3468 { skip "Need MDS version 2.7.90+"; return; }
3470 cancel_lru_locks mdc
3472 createmany -o $DIR/$tfile 20 ||
3473 error "createmany -o $DIR/$tfile failed"
3475 #define OBD_FAIL_TGT_REPLAY_RECONNECT 0x715
3476 # We need to emulate a state that MDT is waiting for other clients
3477 # not completing the recovery. Final ping is queued, but reply will be
3478 # sent on the recovery completion. It is done by sleep before
3479 # processing final pings
3480 do_facet mds1 "$LCTL set_param fail_val=80"
3481 do_facet mds1 "$LCTL set_param fail_loc=0x715"
3484 run_test 93b "replay + reconnect on mds"
3486 striped_dir_check_100() {
3487 local striped_dir=$DIR/$tdir/striped_dir
3488 local stripe_count=$($LFS getdirstripe -c $striped_dir)
3490 $LFS getdirstripe $striped_dir
3491 [ $stripe_count -eq 2 ] || error "$stripe_count != 2"
3493 createmany -o $striped_dir/f-%d 20 ||
3494 error "creation failed under striped dir"
3498 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
3499 ([ $FAILURE_MODE == "HARD" ] &&
3500 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
3501 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
3504 local striped_dir=$DIR/$tdir/striped_dir
3507 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
3509 #To make sure MDT1 and MDT0 are connected
3510 #otherwise it may create single stripe dir here
3511 $LFS setdirstripe -i1 $DIR/$tdir/remote_dir
3513 #define OBD_FAIL_OUT_UPDATE_NET_REP 0x1701
3514 do_facet mds$((MDTIDX+1)) lctl set_param fail_loc=0x1701
3515 $LFS setdirstripe -i0 -c2 $striped_dir &
3518 fail mds$((MDTIDX + 1))
3520 wait $CLIENT_PID || error "striped dir creation failed"
3522 striped_dir_check_100 || error "striped dir check failed"
3523 rm -rf $DIR/$tdir || error "rmdir failed"
3525 run_test 100a "DNE: create striped dir, drop update rep from MDT1, fail MDT1"
3528 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
3529 ([ $FAILURE_MODE == "HARD" ] &&
3530 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
3531 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
3534 local striped_dir=$DIR/$tdir/striped_dir
3537 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
3539 #To make sure MDT1 and MDT0 are connected
3540 #otherwise it may create single stripe dir here
3541 $LFS setdirstripe -i1 $DIR/$tdir/remote_dir
3543 # OBD_FAIL_MDS_REINT_NET_REP 0x119
3544 do_facet mds$MDTIDX lctl set_param fail_loc=0x119
3545 $LFS mkdir -i0 -c2 $striped_dir &
3550 wait $CLIENT_PID || error "striped dir creation failed"
3552 striped_dir_check_100 || error "striped dir check failed"
3553 rm -rf $DIR/$tdir || error "rmdir failed"
3555 run_test 100b "DNE: create striped dir, fail MDT0"
3557 test_101() { #LU-5648
3558 mkdir -p $DIR/$tdir/d1
3559 mkdir -p $DIR/$tdir/d2
3560 touch $DIR/$tdir/file0
3563 replay_barrier $SINGLEMDS
3564 for i in $(seq $num) ; do
3565 echo test$i > $DIR/$tdir/d1/file$i
3568 fail_abort $SINGLEMDS
3569 for i in $(seq $num) ; do
3570 touch $DIR/$tdir/d2/file$i
3571 test -s $DIR/$tdir/d2/file$i &&
3572 ls -al $DIR/$tdir/d2/file$i && error "file$i's size > 0"
3577 run_test 101 "Shouldn't reassign precreated objs to other files after recovery"
3586 [[ $(lctl get_param mdc.*.import |
3587 grep "connect_flags:.*multi_mod_rpc") ]] ||
3588 { skip "Need MDC with 'multi_mod_rpcs' feature"; return 0; }
3590 $LFS mkdir -c1 $DIR/$tdir || error "mkdir $DIR/$tdir failed"
3591 idx=$(printf "%04x" $($LFS getdirstripe -i $DIR/$tdir))
3592 facet="mds$((0x$idx + 1))"
3594 # get current value of max_mod_rcps_in_flight
3595 num=$($LCTL get_param -n \
3596 mdc.$FSNAME-MDT$idx-mdc-*.max_mod_rpcs_in_flight)
3597 # set default value if client does not support multi mod RPCs
3598 [ -z "$num" ] && num=1
3600 echo "creating $num files ..."
3602 for i in $(seq $num); do
3603 touch $DIR/$tdir/file-$i
3606 # drop request on MDT to force resend
3607 #define OBD_FAIL_MDS_REINT_MULTI_NET 0x159
3608 do_facet $facet "$LCTL set_param fail_loc=0x159"
3609 echo "launch $num chmod in parallel ($(date +%H:%M:%S)) ..."
3610 for i in $(seq $num); do
3611 chmod 0600 $DIR/$tdir/file-$i &
3615 do_facet $facet "$LCTL set_param fail_loc=0"
3616 for pid in $pids; do
3617 wait $pid || error "chmod failed"
3619 echo "done ($(date +%H:%M:%S))"
3621 # check chmod succeed
3622 for i in $(seq $num); do
3623 checkstat -vp 0600 $DIR/$tdir/file-$i
3628 run_test 102a "check resend (request lost) with multiple modify RPCs in flight"
3637 [[ $(lctl get_param mdc.*.import |
3638 grep "connect_flags:.*multi_mod_rpc") ]] ||
3639 { skip "Need MDC with 'multi_mod_rpcs' feature"; return 0; }
3641 $LFS mkdir -c1 $DIR/$tdir || error "mkdir $DIR/$tdir failed"
3642 idx=$(printf "%04x" $($LFS getdirstripe -i $DIR/$tdir))
3643 facet="mds$((0x$idx + 1))"
3645 # get current value of max_mod_rcps_in_flight
3646 num=$($LCTL get_param -n \
3647 mdc.$FSNAME-MDT$idx-mdc-*.max_mod_rpcs_in_flight)
3648 # set default value if client does not support multi mod RPCs
3649 [ -z "$num" ] && num=1
3651 echo "creating $num files ..."
3653 for i in $(seq $num); do
3654 touch $DIR/$tdir/file-$i
3657 # drop reply on MDT to force reconstruction
3658 #define OBD_FAIL_MDS_REINT_MULTI_NET_REP 0x15a
3659 do_facet $facet "$LCTL set_param fail_loc=0x15a"
3660 echo "launch $num chmod in parallel ($(date +%H:%M:%S)) ..."
3661 for i in $(seq $num); do
3662 chmod 0600 $DIR/$tdir/file-$i &
3666 do_facet $facet "$LCTL set_param fail_loc=0"
3667 for pid in $pids; do
3668 wait $pid || error "chmod failed"
3670 echo "done ($(date +%H:%M:%S))"
3672 # check chmod succeed
3673 for i in $(seq $num); do
3674 checkstat -vp 0600 $DIR/$tdir/file-$i
3679 run_test 102b "check resend (reply lost) with multiple modify RPCs in flight"
3688 [[ $(lctl get_param mdc.*.import |
3689 grep "connect_flags:.*multi_mod_rpc") ]] ||
3690 { skip "Need MDC with 'multi_mod_rpcs' feature"; return 0; }
3692 $LFS mkdir -c1 $DIR/$tdir || error "mkdir $DIR/$tdir failed"
3693 idx=$(printf "%04x" $($LFS getdirstripe -i $DIR/$tdir))
3694 facet="mds$((0x$idx + 1))"
3696 # get current value of max_mod_rcps_in_flight
3697 num=$($LCTL get_param -n \
3698 mdc.$FSNAME-MDT$idx-mdc-*.max_mod_rpcs_in_flight)
3699 # set default value if client does not support multi mod RPCs
3700 [ -z "$num" ] && num=1
3702 echo "creating $num files ..."
3704 for i in $(seq $num); do
3705 touch $DIR/$tdir/file-$i
3708 replay_barrier $facet
3711 #define OBD_FAIL_MDS_REINT_MULTI_NET_REP 0x15a
3712 do_facet $facet "$LCTL set_param fail_loc=0x15a"
3713 echo "launch $num chmod in parallel ($(date +%H:%M:%S)) ..."
3714 for i in $(seq $num); do
3715 chmod 0600 $DIR/$tdir/file-$i &
3719 do_facet $facet "$LCTL set_param fail_loc=0"
3724 for pid in $pids; do
3725 wait $pid || error "chmod failed"
3727 echo "done ($(date +%H:%M:%S))"
3729 # check chmod succeed
3730 for i in $(seq $num); do
3731 checkstat -vp 0600 $DIR/$tdir/file-$i
3736 run_test 102c "check replay w/o reconstruction with multiple mod RPCs in flight"
3745 [[ $(lctl get_param mdc.*.import |
3746 grep "connect_flags:.*multi_mod_rpc") ]] ||
3747 { skip "Need MDC with 'multi_mod_rpcs' feature"; return 0; }
3749 $LFS mkdir -c1 $DIR/$tdir || error "mkdir $DIR/$tdir failed"
3750 idx=$(printf "%04x" $($LFS getdirstripe -i $DIR/$tdir))
3751 facet="mds$((0x$idx + 1))"
3753 # get current value of max_mod_rcps_in_flight
3754 num=$($LCTL get_param -n \
3755 mdc.$FSNAME-MDT$idx-mdc-*.max_mod_rpcs_in_flight)
3756 # set default value if client does not support multi mod RPCs
3757 [ -z "$num" ] && num=1
3759 echo "creating $num files ..."
3761 for i in $(seq $num); do
3762 touch $DIR/$tdir/file-$i
3766 #define OBD_FAIL_MDS_REINT_MULTI_NET_REP 0x15a
3767 do_facet $facet "$LCTL set_param fail_loc=0x15a"
3768 echo "launch $num chmod in parallel ($(date +%H:%M:%S)) ..."
3769 for i in $(seq $num); do
3770 chmod 0600 $DIR/$tdir/file-$i &
3775 # write MDT transactions to disk
3776 do_facet $facet "sync; sync; sync"
3778 do_facet $facet "$LCTL set_param fail_loc=0"
3783 for pid in $pids; do
3784 wait $pid || error "chmod failed"
3786 echo "done ($(date +%H:%M:%S))"
3788 # check chmod succeed
3789 for i in $(seq $num); do
3790 checkstat -vp 0600 $DIR/$tdir/file-$i
3795 run_test 102d "check replay & reconstruction with multiple mod RPCs in flight"
3798 remote_mds_nodsh && skip "remote MDS with nodsh" && return
3799 local mds_version=$(lustre_version_code $SINGLEMDS)
3800 [[ $mds_version -gt $(version_code 2.8.54) ]] ||
3801 { skip "Need MDS version 2.8.54+"; return; }
3803 #define OBD_FAIL_MDS_TRACK_OVERFLOW 0x162
3804 do_facet mds1 $LCTL set_param fail_loc=0x80000162
3807 createmany -o $DIR/$tdir/t- 30 ||
3808 error "create files on remote directory failed"
3810 rm -rf $DIR/$tdir/t-*
3812 #MDS should crash with tr->otr_next_id overflow
3815 run_test 103 "Check otr_next_id overflow"
3818 check_striped_dir_110()
3820 $CHECKSTAT -t dir $DIR/$tdir/striped_dir ||
3821 error "create striped dir failed"
3822 local stripe_count=$($LFS getdirstripe -c $DIR/$tdir/striped_dir)
3823 [ $stripe_count -eq $MDSCOUNT ] ||
3824 error "$stripe_count != 2 after recovery"
3828 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
3829 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.7.56) ]] ||
3830 skip "Need MDS version at least 2.7.56"
3832 ([ $FAILURE_MODE == "HARD" ] &&
3833 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
3834 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
3839 $LFS mkdir -i1 -c$MDSCOUNT $DIR/$tdir/striped_dir
3842 check_striped_dir_110 || error "check striped_dir failed"
3843 rm -rf $DIR/$tdir || error "rmdir failed"
3847 run_test 110a "DNE: create striped dir, fail MDT1"
3850 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
3851 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.7.56) ]] ||
3852 skip "Need MDS version at least 2.7.56"
3854 ([ $FAILURE_MODE == "HARD" ] &&
3855 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
3856 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
3861 $LFS mkdir -i1 -c$MDSCOUNT $DIR/$tdir/striped_dir
3864 zconf_mount $(hostname) $MOUNT
3865 client_up || return 1
3867 check_striped_dir_110 || error "check striped_dir failed"
3869 rm -rf $DIR/$tdir || error "rmdir failed"
3873 run_test 110b "DNE: create striped dir, fail MDT1 and client"
3876 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
3877 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.7.56) ]] ||
3878 skip "Need MDS version at least 2.7.56"
3880 ([ $FAILURE_MODE == "HARD" ] &&
3881 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
3882 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
3887 $LFS mkdir -i1 -c$MDSCOUNT $DIR/$tdir/striped_dir
3890 check_striped_dir_110 || error "check striped_dir failed"
3892 rm -rf $DIR/$tdir || error "rmdir failed"
3896 run_test 110c "DNE: create striped dir, fail MDT2"
3899 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
3900 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.7.56) ]] ||
3901 skip "Need MDS version at least 2.7.56"
3903 ([ $FAILURE_MODE == "HARD" ] &&
3904 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
3905 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
3910 $LFS mkdir -i1 -c$MDSCOUNT $DIR/$tdir/striped_dir
3913 zconf_mount $(hostname) $MOUNT
3914 client_up || return 1
3916 check_striped_dir_110 || error "check striped_dir failed"
3918 rm -rf $DIR/$tdir || error "rmdir failed"
3922 run_test 110d "DNE: create striped dir, fail MDT2 and client"
3925 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
3926 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.7.56) ]] ||
3927 skip "Need MDS version at least 2.7.56"
3929 ([ $FAILURE_MODE == "HARD" ] &&
3930 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
3931 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
3936 $LFS mkdir -i1 -c$MDSCOUNT $DIR/$tdir/striped_dir
3940 zconf_mount $(hostname) $MOUNT
3941 client_up || return 1
3943 check_striped_dir_110 || error "check striped_dir failed"
3945 rm -rf $DIR/$tdir || error "rmdir failed"
3949 run_test 110e "DNE: create striped dir, uncommit on MDT2, fail client/MDT1/MDT2"
3952 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
3953 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.7.56) ]] ||
3954 skip "Need MDS version at least 2.7.56"
3956 ([ $FAILURE_MODE == "HARD" ] &&
3957 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
3958 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
3964 $LFS mkdir -i1 -c$MDSCOUNT $DIR/$tdir/striped_dir
3967 check_striped_dir_110 || error "check striped_dir failed"
3969 rm -rf $DIR/$tdir || error "rmdir failed"
3973 run_test 110f "DNE: create striped dir, fail MDT1/MDT2"
3976 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
3977 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.7.56) ]] ||
3978 skip "Need MDS version at least 2.7.56"
3980 ([ $FAILURE_MODE == "HARD" ] &&
3981 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
3982 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
3987 $LFS mkdir -i1 -c$MDSCOUNT $DIR/$tdir/striped_dir
3991 zconf_mount $(hostname) $MOUNT
3992 client_up || return 1
3994 check_striped_dir_110 || error "check striped_dir failed"
3996 rm -rf $DIR/$tdir || error "rmdir failed"
4000 run_test 110g "DNE: create striped dir, uncommit on MDT1, fail client/MDT1/MDT2"
4003 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
4004 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.7.56) ]] ||
4005 skip "Need MDS version at least 2.7.56"
4007 ([ $FAILURE_MODE == "HARD" ] &&
4008 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
4009 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
4013 $LFS mkdir -i1 -c2 $DIR/$tdir/striped_dir
4015 rm -rf $DIR/$tdir/striped_dir
4018 $CHECKSTAT -t dir $DIR/$tdir/striped_dir &&
4019 error "striped dir still exists"
4022 run_test 111a "DNE: unlink striped dir, fail MDT1"
4025 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
4026 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.7.56) ]] ||
4027 skip "Need MDS version at least 2.7.56"
4029 ([ $FAILURE_MODE == "HARD" ] &&
4030 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
4031 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
4035 $LFS mkdir -i1 -c2 $DIR/$tdir/striped_dir
4037 rm -rf $DIR/$tdir/striped_dir
4040 zconf_mount $(hostname) $MOUNT
4041 client_up || return 1
4043 $CHECKSTAT -t dir $DIR/$tdir/striped_dir &&
4044 error "striped dir still exists"
4047 run_test 111b "DNE: unlink striped dir, fail MDT2"
4050 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
4051 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.7.56) ]] ||
4052 skip "Need MDS version at least 2.7.56"
4054 ([ $FAILURE_MODE == "HARD" ] &&
4055 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
4056 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
4060 $LFS mkdir -i1 -c2 $DIR/$tdir/striped_dir
4062 rm -rf $DIR/$tdir/striped_dir
4066 zconf_mount $(hostname) $MOUNT
4067 client_up || return 1
4068 $CHECKSTAT -t dir $DIR/$tdir/striped_dir &&
4069 error "striped dir still exists"
4072 run_test 111c "DNE: unlink striped dir, uncommit on MDT1, fail client/MDT1/MDT2"
4075 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
4076 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.7.56) ]] ||
4077 skip "Need MDS version at least 2.7.56"
4079 ([ $FAILURE_MODE == "HARD" ] &&
4080 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
4081 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
4085 $LFS mkdir -i1 -c2 $DIR/$tdir/striped_dir
4087 rm -rf $DIR/$tdir/striped_dir
4091 zconf_mount $(hostname) $MOUNT
4092 client_up || return 1
4093 $CHECKSTAT -t dir $DIR/$tdir/striped_dir &&
4094 error "striped dir still exists"
4098 run_test 111d "DNE: unlink striped dir, uncommit on MDT2, fail client/MDT1/MDT2"
4101 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
4102 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.7.56) ]] ||
4103 skip "Need MDS version at least 2.7.56"
4105 ([ $FAILURE_MODE == "HARD" ] &&
4106 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
4107 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
4111 $LFS mkdir -i1 -c2 $DIR/$tdir/striped_dir
4113 rm -rf $DIR/$tdir/striped_dir
4116 $CHECKSTAT -t dir $DIR/$tdir/striped_dir &&
4117 error "striped dir still exists"
4120 run_test 111e "DNE: unlink striped dir, uncommit on MDT2, fail MDT1/MDT2"
4123 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
4124 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.7.56) ]] ||
4125 skip "Need MDS version at least 2.7.56"
4127 ([ $FAILURE_MODE == "HARD" ] &&
4128 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
4129 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
4133 $LFS mkdir -i1 -c2 $DIR/$tdir/striped_dir
4135 rm -rf $DIR/$tdir/striped_dir
4138 $CHECKSTAT -t dir $DIR/$tdir/striped_dir &&
4139 error "striped dir still exists"
4142 run_test 111f "DNE: unlink striped dir, uncommit on MDT1, fail MDT1/MDT2"
4145 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
4146 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.7.56) ]] ||
4147 skip "Need MDS version at least 2.7.56"
4149 ([ $FAILURE_MODE == "HARD" ] &&
4150 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
4151 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
4155 $LFS mkdir -i1 -c2 $DIR/$tdir/striped_dir
4158 rm -rf $DIR/$tdir/striped_dir
4160 $CHECKSTAT -t dir $DIR/$tdir/striped_dir &&
4161 error "striped dir still exists"
4164 run_test 111g "DNE: unlink striped dir, fail MDT1/MDT2"
4166 test_112_rename_prepare() {
4167 mkdir -p $DIR/$tdir/src_dir
4168 $LFS mkdir -i 1 $DIR/$tdir/src_dir/src_child ||
4169 error "create remote source failed"
4171 touch $DIR/$tdir/src_dir/src_child/a
4173 $LFS mkdir -i 2 $DIR/$tdir/tgt_dir ||
4174 error "create remote target dir failed"
4176 $LFS mkdir -i 3 $DIR/$tdir/tgt_dir/tgt_child ||
4177 error "create remote target child failed"
4182 $CHECKSTAT -t dir $DIR/$tdir/src_dir/src_child &&
4183 error "src_child still exists after rename"
4185 $CHECKSTAT -t file $DIR/$tdir/tgt_dir/tgt_child/a ||
4186 error "missing file(a) after rename"
4190 [ $MDSCOUNT -lt 4 ] && skip "needs >= 4 MDTs" && return 0
4191 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.7.56) ]] ||
4192 skip "Need MDS version at least 2.7.56"
4194 ([ $FAILURE_MODE == "HARD" ] &&
4195 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
4196 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
4199 test_112_rename_prepare
4202 mrename $DIR/$tdir/src_dir/src_child $DIR/$tdir/tgt_dir/tgt_child ||
4203 error "rename dir cross MDT failed!"
4207 rm -rf $DIR/$tdir || error "rmdir failed"
4209 run_test 112a "DNE: cross MDT rename, fail MDT1"
4212 [ $MDSCOUNT -lt 4 ] && skip "needs >= 4 MDTs" && return 0
4213 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.7.56) ]] ||
4214 skip "Need MDS version at least 2.7.56"
4216 ([ $FAILURE_MODE == "HARD" ] &&
4217 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
4218 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
4221 test_112_rename_prepare
4224 mrename $DIR/$tdir/src_dir/src_child $DIR/$tdir/tgt_dir/tgt_child ||
4225 error "rename dir cross MDT failed!"
4230 rm -rf $DIR/$tdir || error "rmdir failed"
4232 run_test 112b "DNE: cross MDT rename, fail MDT2"
4235 [ $MDSCOUNT -lt 4 ] && skip "needs >= 4 MDTs" && return 0
4236 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.7.56) ]] ||
4237 skip "Need MDS version at least 2.7.56"
4239 ([ $FAILURE_MODE == "HARD" ] &&
4240 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
4241 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
4244 test_112_rename_prepare
4247 mrename $DIR/$tdir/src_dir/src_child $DIR/$tdir/tgt_dir/tgt_child ||
4248 error "rename dir cross MDT failed!"
4253 rm -rf $DIR/$tdir || error "rmdir failed"
4255 run_test 112c "DNE: cross MDT rename, fail MDT3"
4258 [ $MDSCOUNT -lt 4 ] && skip "needs >= 4 MDTs" && return 0
4259 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.7.56) ]] ||
4260 skip "Need MDS version at least 2.7.56"
4262 ([ $FAILURE_MODE == "HARD" ] &&
4263 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
4264 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
4267 test_112_rename_prepare
4270 mrename $DIR/$tdir/src_dir/src_child $DIR/$tdir/tgt_dir/tgt_child ||
4271 error "rename dir cross MDT failed!"
4276 rm -rf $DIR/$tdir || error "rmdir failed"
4278 run_test 112d "DNE: cross MDT rename, fail MDT4"
4281 [ $MDSCOUNT -lt 4 ] && skip "needs >= 4 MDTs" && return 0
4282 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.7.56) ]] ||
4283 skip "Need MDS version at least 2.7.56"
4285 ([ $FAILURE_MODE == "HARD" ] &&
4286 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
4287 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
4290 test_112_rename_prepare
4294 mrename $DIR/$tdir/src_dir/src_child $DIR/$tdir/tgt_dir/tgt_child ||
4295 error "rename dir cross MDT failed!"
4300 rm -rf $DIR/$tdir || error "rmdir failed"
4302 run_test 112e "DNE: cross MDT rename, fail MDT1 and MDT2"
4305 [ $MDSCOUNT -lt 4 ] && skip "needs >= 4 MDTs" && return 0
4306 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.7.56) ]] ||
4307 skip "Need MDS version at least 2.7.56"
4309 ([ $FAILURE_MODE == "HARD" ] &&
4310 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
4311 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
4314 test_112_rename_prepare
4318 mrename $DIR/$tdir/src_dir/src_child $DIR/$tdir/tgt_dir/tgt_child ||
4319 error "rename dir cross MDT failed!"
4324 rm -rf $DIR/$tdir || error "rmdir failed"
4326 run_test 112f "DNE: cross MDT rename, fail MDT1 and MDT3"
4329 [ $MDSCOUNT -lt 4 ] && skip "needs >= 4 MDTs" && return 0
4330 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.7.56) ]] ||
4331 skip "Need MDS version at least 2.7.56"
4333 ([ $FAILURE_MODE == "HARD" ] &&
4334 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
4335 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
4338 test_112_rename_prepare
4342 mrename $DIR/$tdir/src_dir/src_child $DIR/$tdir/tgt_dir/tgt_child ||
4343 error "rename dir cross MDT failed!"
4348 rm -rf $DIR/$tdir || error "rmdir failed"
4350 run_test 112g "DNE: cross MDT rename, fail MDT1 and MDT4"
4353 [ $MDSCOUNT -lt 4 ] && skip "needs >= 4 MDTs" && return 0
4354 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.7.56) ]] ||
4355 skip "Need MDS version at least 2.7.56"
4357 ([ $FAILURE_MODE == "HARD" ] &&
4358 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
4359 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
4362 test_112_rename_prepare
4366 mrename $DIR/$tdir/src_dir/src_child $DIR/$tdir/tgt_dir/tgt_child ||
4367 error "rename dir cross MDT failed!"
4372 rm -rf $DIR/$tdir || error "rmdir failed"
4374 run_test 112h "DNE: cross MDT rename, fail MDT2 and MDT3"
4377 [ $MDSCOUNT -lt 4 ] && skip "needs >= 4 MDTs" && return 0
4378 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.7.56) ]] ||
4379 skip "Need MDS version at least 2.7.56"
4381 ([ $FAILURE_MODE == "HARD" ] &&
4382 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
4383 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
4386 test_112_rename_prepare
4390 mrename $DIR/$tdir/src_dir/src_child $DIR/$tdir/tgt_dir/tgt_child ||
4391 error "rename dir cross MDT failed!"
4396 rm -rf $DIR/$tdir || error "rmdir failed"
4398 run_test 112i "DNE: cross MDT rename, fail MDT2 and MDT4"
4401 [ $MDSCOUNT -lt 4 ] && skip "needs >= 4 MDTs" && return 0
4402 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.7.56) ]] ||
4403 skip "Need MDS version at least 2.7.56"
4405 ([ $FAILURE_MODE == "HARD" ] &&
4406 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
4407 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
4410 test_112_rename_prepare
4414 mrename $DIR/$tdir/src_dir/src_child $DIR/$tdir/tgt_dir/tgt_child ||
4415 error "rename dir cross MDT failed!"
4420 rm -rf $DIR/$tdir || error "rmdir failed"
4422 run_test 112j "DNE: cross MDT rename, fail MDT3 and MDT4"
4425 [ $MDSCOUNT -lt 4 ] && skip "needs >= 4 MDTs" && return 0
4426 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.7.56) ]] ||
4427 skip "Need MDS version at least 2.7.56"
4429 ([ $FAILURE_MODE == "HARD" ] &&
4430 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
4431 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
4434 test_112_rename_prepare
4439 mrename $DIR/$tdir/src_dir/src_child $DIR/$tdir/tgt_dir/tgt_child ||
4440 error "rename dir cross MDT failed!"
4445 rm -rf $DIR/$tdir || error "rmdir failed"
4447 run_test 112k "DNE: cross MDT rename, fail MDT1,MDT2,MDT3"
4450 [ $MDSCOUNT -lt 4 ] && skip "needs >= 4 MDTs" && return 0
4451 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.7.56) ]] ||
4452 skip "Need MDS version at least 2.7.56"
4454 ([ $FAILURE_MODE == "HARD" ] &&
4455 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
4456 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
4459 test_112_rename_prepare
4464 mrename $DIR/$tdir/src_dir/src_child $DIR/$tdir/tgt_dir/tgt_child ||
4465 error "rename dir cross MDT failed!"
4470 rm -rf $DIR/$tdir || error "rmdir failed"
4472 run_test 112l "DNE: cross MDT rename, fail MDT1,MDT2,MDT4"
4475 [ $MDSCOUNT -lt 4 ] && skip "needs >= 4 MDTs" && return 0
4476 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.7.56) ]] ||
4477 skip "Need MDS version at least 2.7.56"
4479 ([ $FAILURE_MODE == "HARD" ] &&
4480 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
4481 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
4484 test_112_rename_prepare
4489 mrename $DIR/$tdir/src_dir/src_child $DIR/$tdir/tgt_dir/tgt_child ||
4490 error "rename dir cross MDT failed!"
4495 rm -rf $DIR/$tdir || error "rmdir failed"
4497 run_test 112m "DNE: cross MDT rename, fail MDT1,MDT3,MDT4"
4500 [ $MDSCOUNT -lt 4 ] && skip "needs >= 4 MDTs" && return 0
4501 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.7.56) ]] ||
4502 skip "Need MDS version at least 2.7.56"
4504 ([ $FAILURE_MODE == "HARD" ] &&
4505 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
4506 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
4509 test_112_rename_prepare
4514 mrename $DIR/$tdir/src_dir/src_child $DIR/$tdir/tgt_dir/tgt_child ||
4515 error "rename dir cross MDT failed!"
4520 rm -rf $DIR/$tdir || error "rmdir failed"
4522 run_test 112n "DNE: cross MDT rename, fail MDT2,MDT3,MDT4"
4525 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
4526 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.7.56) ]] ||
4527 skip "Need MDS version at least 2.7.56"
4529 ([ $FAILURE_MODE == "HARD" ] &&
4530 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
4531 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
4539 for ((j=0;j<$((MDSCOUNT));j++)); do
4540 fail_index=$((fail_index+1))
4541 index=$((fail_index % MDSCOUNT))
4542 replay_barrier mds$((index + 1))
4543 for ((i=0;i<5;i++)); do
4544 test_mkdir -i$index -c$MDSCOUNT $DIR/$tdir/test_$i ||
4545 error "create striped dir $DIR/$tdir/test_$i"
4548 fail mds$((index + 1))
4549 for ((i=0;i<5;i++)); do
4550 checkstat -t dir $DIR/$tdir/test_$i ||
4551 error "$DIR/$tdir/test_$i does not exist!"
4553 rm -rf $DIR/$tdir/test_* ||
4557 run_test 115 "failover for create/unlink striped directory"
4560 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
4561 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.55) ] &&
4562 skip "Do not support large update log before 2.7.55" &&
4564 ([ $FAILURE_MODE == "HARD" ] &&
4565 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
4566 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
4573 # OBD_FAIL_SPLIT_UPDATE_REC 0x1702
4574 do_facet mds1 "lctl set_param fail_loc=0x80001702"
4575 $LFS setdirstripe -i0 -c$MDSCOUNT $DIR/$tdir/striped_dir
4578 $CHECKSTAT -t dir $DIR/$tdir/striped_dir ||
4579 error "stried_dir does not exists"
4581 run_test 116a "large update log master MDT recovery"
4584 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
4585 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.55) ] &&
4586 skip "Do not support large update log before 2.7.55" &&
4589 ([ $FAILURE_MODE == "HARD" ] &&
4590 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
4591 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
4598 # OBD_FAIL_SPLIT_UPDATE_REC 0x1702
4599 do_facet mds2 "lctl set_param fail_loc=0x80001702"
4600 $LFS setdirstripe -i0 -c$MDSCOUNT $DIR/$tdir/striped_dir
4603 $CHECKSTAT -t dir $DIR/$tdir/striped_dir ||
4604 error "stried_dir does not exists"
4606 run_test 116b "large update log slave MDT recovery"
4609 [ $MDSCOUNT -lt 4 ] && skip "needs >= 4 MDTs" && return 0
4610 ([ $FAILURE_MODE == "HARD" ] &&
4611 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
4612 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
4618 $LFS setdirstripe -i0 -c$MDSCOUNT $DIR/$tdir/remote_dir
4619 $LFS setdirstripe -i1 -c$MDSCOUNT $DIR/$tdir/remote_dir_1
4622 # Let's set rdonly on all MDTs, so client will send
4623 # replay requests on all MDTs and replay these requests
4624 # at the same time. This test will verify the recovery
4625 # will not be deadlock in this case, LU-7531.
4626 for ((index = 0; index < $((MDSCOUNT)); index++)); do
4627 replay_barrier mds$((index + 1))
4628 if [ -z $mds_indexs ]; then
4629 mds_indexs="${mds_indexs}mds$((index+1))"
4631 mds_indexs="${mds_indexs},mds$((index+1))"
4635 rm -rf $DIR/$tdir/remote_dir
4636 rm -rf $DIR/$tdir/remote_dir_1
4640 rm -rf $DIR/$tdir || error "rmdir failed"
4642 run_test 117 "DNE: cross MDT unlink, fail MDT1 and MDT2"
4645 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
4646 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.64) ] &&
4647 skip "Do not support large update log before 2.7.64" &&
4652 $LFS setdirstripe -c2 $DIR/$tdir/striped_dir ||
4653 error "setdirstripe fails"
4654 $LFS setdirstripe -c2 $DIR/$tdir/striped_dir1 ||
4655 error "setdirstripe fails 1"
4656 rm -rf $DIR/$tdir/striped_dir* || error "rmdir fails"
4658 # OBD_FAIL_INVALIDATE_UPDATE 0x1705
4659 do_facet mds1 "lctl set_param fail_loc=0x1705"
4660 $LFS setdirstripe -c2 $DIR/$tdir/striped_dir
4661 $LFS setdirstripe -c2 $DIR/$tdir/striped_dir1
4662 do_facet mds1 "lctl set_param fail_loc=0x0"
4665 $LFS setdirstripe -c2 $DIR/$tdir/striped_dir
4666 $LFS setdirstripe -c2 $DIR/$tdir/striped_dir1
4671 run_test 118 "invalidate osp update will not cause update log corruption"
4674 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
4675 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.64) ] &&
4676 skip "Do not support large update log before 2.7.64" &&
4679 local hard_timeout=$(do_facet mds1 \
4680 "lctl get_param -n mdt.$FSNAME-MDT0000.recovery_time_hard")
4682 local clients=${CLIENTS:-$HOSTNAME}
4683 local time_min=$(recovery_time_min)
4686 mkdir $DIR/$tdir/tmp
4687 rmdir $DIR/$tdir/tmp
4690 mkdir $DIR/$tdir/dir_1
4691 for ((i = 0; i < 20; i++)); do
4692 $LFS setdirstripe -i0 -c2 $DIR/$tdir/stripe_dir-$i
4699 #define OBD_FAIL_TGT_REPLAY_DELAY 0x714
4700 do_facet mds1 $LCTL set_param fail_loc=0x80000714
4701 #sleep (timeout + 5), so mds will evict the client exports,
4702 #but DNE update recovery will keep going.
4703 do_facet mds1 $LCTL set_param fail_val=$((time_min + 5))
4705 mount_facet mds1 "-o recovery_time_hard=$time_min"
4707 wait_clients_import_state "$clients" mds1 FULL
4709 clients_up || clients_up || error "failover df: $?"
4711 #revert back the hard timeout
4712 do_facet mds1 $LCTL set_param \
4713 mdt.$FSNAME-MDT0000.recovery_time_hard=$hard_timeout
4715 for ((i = 0; i < 20; i++)); do
4716 stripe_count=$($LFS getdirstripe -c $DIR/$tdir/stripe_dir-$i)
4717 [ $stripe_count == 2 ] || {
4718 error "stripe_dir-$i creation replay fails"
4723 run_test 119 "timeout of normal replay does not cause DNE replay fails "
4726 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
4727 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.64) ] &&
4728 skip "Do not support large update log before 2.7.64" &&
4732 replay_barrier_nosync mds1
4733 for ((i = 0; i < 20; i++)); do
4734 mkdir $DIR/$tdir/dir-$i || {
4735 error "create dir-$i fails"
4738 $LFS setdirstripe -i0 -c2 $DIR/$tdir/stripe_dir-$i || {
4739 error "create stripe_dir-$i fails"
4746 for ((i = 0; i < 20; i++)); do
4747 [ ! -e "$DIR/$tdir/dir-$i" ] || {
4748 error "dir-$i still exists"
4751 [ ! -e "$DIR/$tdir/stripe_dir-$i" ] || {
4752 error "stripe_dir-$i still exists"
4757 run_test 120 "DNE fail abort should stop both normal and DNE replay"
4760 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.10.90) ] &&
4761 skip "Don't support it before 2.11" &&
4764 local at_max_saved=$(at_max_get mds)
4766 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
4767 cancel_lru_locks mdc
4769 multiop_bg_pause $DIR/$tfile s_s || error "multiop $DIR/$tfile failed"
4772 lctl set_param -n ldlm.cancel_unused_locks_before_replay "0"
4778 #define OBD_FAIL_TGT_RECOVERY_REQ_RACE 0x721
4779 do_facet $SINGLEMDS "lctl set_param fail_loc=0x721 fail_val=0"
4783 wait_clients_import_state "$clients" mds1 FULL
4784 clients_up || clients_up || error "failover df: $?"
4787 wait $mpid || error "multiop_bg_pause pid failed"
4789 do_facet $SINGLEMDS "lctl set_param fail_loc=0x0"
4790 lctl set_param -n ldlm.cancel_unused_locks_before_replay "1"
4791 at_max_set $at_max_saved mds
4794 run_test 121 "lock replay timed out and race"
4797 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.10.90) ] &&
4798 skip "Do not support Data-on-MDT before 2.11"
4800 replay_barrier $SINGLEMDS
4801 $LFS setstripe -E 1M -L mdt -E EOF -c 2 $DIR/$tfile
4804 [ $($LFS getstripe -L $DIR/$tfile) == "mdt" ] ||
4805 error "Fail to replay DoM file creation"
4807 run_test 130a "DoM file create (setstripe) replay"
4810 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.10.90) ] &&
4811 skip "Do not support Data-on-MDT before 2.11"
4814 $LFS setstripe -E 1M -L mdt -E EOF -c 2 $DIR/$tdir
4815 replay_barrier $SINGLEMDS
4816 touch $DIR/$tdir/$tfile
4819 [ $($LFS getstripe -L $DIR/$tdir/$tfile) == "mdt" ] ||
4820 error "Fail to replay DoM file creation"
4822 run_test 130b "DoM file create (inherited) replay"
4825 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.10.90) ] &&
4826 skip "Do not support Data-on-MDT before 2.11"
4828 $LFS setstripe -E 1M -L mdt -E EOF -c 2 $DIR/$tfile
4829 replay_barrier $SINGLEMDS
4830 echo "dom_data" | dd of=$DIR/$tfile bs=8 count=1
4831 # lock is not canceled and will be replayed
4834 [ $(cat $DIR/$tfile) == "dom_data" ] ||
4835 error "Wrong file content after failover"
4837 run_test 131a "DoM file write lock replay"
4840 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.10.90) ] &&
4841 skip "Do not support Data-on-MDT before 2.11"
4843 $LFS setstripe -E 1M -L mdt -E EOF -c 2 $DIR/$tfile
4844 replay_barrier $SINGLEMDS
4845 echo "dom_data" | dd of=$DIR/$tfile bs=8 count=1
4846 cancel_lru_locks mdc
4850 [ $(cat $DIR/$tfile) == "dom_data" ] ||
4851 error "Wrong file content after failover"
4853 run_test 131b "DoM file write replay"
4856 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.9.90) ] &&
4857 skip "Do not support PFL files before 2.10"
4859 $LFS setstripe -E 1M -c 1 -E EOF -c 2 $DIR/$tfile
4860 replay_barrier $SINGLEMDS
4861 # write over the first component size cause next component instantiation
4862 dd if=/dev/urandom of=$DIR/$tfile bs=1M count=1 seek=1 ||
4863 error "dd to $DIR/$tfile failed"
4864 lfs getstripe $DIR/$tfile
4866 cksum=$(md5sum $DIR/$tfile | awk '{print $1}')
4867 $LFS getstripe -I2 $DIR/$tfile | grep -q lmm_objects ||
4868 error "Component #1 was not instantiated"
4872 lfs getstripe $DIR/$tfile
4873 $LFS getstripe -I2 $DIR/$tfile | grep -q lmm_objects ||
4874 error "Component #1 instantiation was not replayed"
4875 cksum2=$(md5sum $DIR/$tfile | awk '{print $1}')
4876 if [ $cksum != $cksum2 ] ; then
4877 error_noexit "New cksum $cksum2 does not match original $cksum"
4880 run_test 132a "PFL new component instantiate replay"
4883 check_and_cleanup_lustre