5 LUSTRE=${LUSTRE:-$(dirname $0)/..}
6 . $LUSTRE/tests/test-framework.sh
10 ALWAYS_EXCEPT="$REPLAY_SINGLE_EXCEPT "
11 if [ "$mds1_FSTYPE" = zfs ]; then
15 always_except LU-13614 59
16 always_except LU-12805 36
18 always_except LU-9795 121
23 CHECK_GRANT=${CHECK_GRANT:-"yes"}
24 GRANT_CHECK_LIST=${GRANT_CHECK_LIST:-""}
26 require_dsh_mds || exit 0
27 check_and_setup_lustre
32 rm -rf $DIR/[df][0-9]* $DIR/f.$TESTSUITE.*
34 test_0a() { # was test_0
35 mkdir_on_mdt0 $DIR/$tdir || error "mkdir $DIR/$tdir failed"
36 replay_barrier $SINGLEMDS
40 run_test 0a "empty replay"
43 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
45 # this test attempts to trigger a race in the precreation code,
46 # and must run before any other objects are created on the filesystem
48 createmany -o $DIR/$tfile 20 || error "createmany -o $DIR/$tfile failed"
49 unlinkmany $DIR/$tfile 20 || error "unlinkmany $DIR/$tfile failed"
51 run_test 0b "ensure object created after recover exists. (3284)"
54 replay_barrier $SINGLEMDS
57 facet_failover $SINGLEMDS
58 zconf_mount $(hostname) $MOUNT || error "mount fails"
59 client_up || error "post-failover df failed"
60 # file shouldn't exist if replay-barrier works as expected
61 rm $DIR/$tfile && error "File exists and it shouldn't"
64 run_test 0c "check replay-barrier"
67 replay_barrier $SINGLEMDS
69 facet_failover $SINGLEMDS
70 zconf_mount $(hostname) $MOUNT || error "mount fails"
71 client_up || error "post-failover df failed"
73 run_test 0d "expired recovery with no clients"
76 replay_barrier $SINGLEMDS
79 $CHECKSTAT -t file $DIR/$tfile ||
80 error "$CHECKSTAT $DIR/$tfile attribute check failed"
83 run_test 1 "simple create"
86 replay_barrier $SINGLEMDS
89 $CHECKSTAT -t file $DIR/$tfile ||
90 error "$CHECKSTAT $DIR/$tfile attribute check failed"
96 mcreate $DIR/$tfile || error "mcreate $DIR/$tfile failed"
97 replay_barrier $SINGLEMDS
100 $CHECKSTAT -t file $DIR/$tfile ||
101 error "$CHECKSTAT $DIR/$tfile attribute check failed"
107 replay_barrier $SINGLEMDS
108 $LFS setstripe -c $OSTCOUNT $DIR/$tfile
110 $CHECKSTAT -t file $DIR/$tfile ||
111 error "$CHECKSTAT $DIR/$tfile check failed"
113 run_test 2c "setstripe replay"
116 [[ "$mds1_FSTYPE" = zfs ]] &&
117 [[ "$MDS1_VERSION" -lt $(version_code 2.12.51) ]] &&
118 skip "requires LU-10143 fix on MDS"
119 replay_barrier $SINGLEMDS
120 $LFS setdirstripe -i 0 -c $MDSCOUNT $DIR/$tdir
122 $CHECKSTAT -t dir $DIR/$tdir ||
123 error "$CHECKSTAT $DIR/$tdir check failed"
125 run_test 2d "setdirstripe replay"
128 testid=$(echo $TESTNAME | tr '_' ' ')
129 #define OBD_FAIL_MDS_CLOSE_NET_REP 0x13b
130 do_facet $SINGLEMDS "$LCTL set_param fail_loc=0x8000013b"
131 openfile -f O_CREAT:O_EXCL $DIR/$tfile &
133 replay_barrier $SINGLEMDS
136 $CHECKSTAT -t file $DIR/$tfile ||
137 error "$CHECKSTAT $DIR/$tfile attribute check failed"
138 dmesg | tac | sed "/$testid/,$ d" | \
139 grep "Open request replay failed with -17" &&
140 error "open replay failed" || true
142 run_test 2e "O_CREAT|O_EXCL create replay"
145 local file=$DIR/$tfile
146 replay_barrier $SINGLEMDS
148 openfile -f O_DIRECTORY $file
150 $CHECKSTAT -t file $file ||
151 error "$CHECKSTAT $file attribute check failed"
154 run_test 3a "replay failed open(O_DIRECTORY)"
157 replay_barrier $SINGLEMDS
158 #define OBD_FAIL_MDS_OPEN_PACK | CFS_FAIL_ONCE
159 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000114"
161 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
163 $CHECKSTAT -t file $DIR/$tfile &&
164 error "$CHECKSTAT $DIR/$tfile attribute check should fail"
167 run_test 3b "replay failed open -ENOMEM"
170 replay_barrier $SINGLEMDS
171 #define OBD_FAIL_MDS_ALLOC_OBDO | CFS_FAIL_ONCE
172 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000128"
174 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
177 $CHECKSTAT -t file $DIR/$tfile &&
178 error "$CHECKSTAT $DIR/$tfile attribute check should fail"
181 run_test 3c "replay failed open -ENOMEM"
183 test_4a() { # was test_4
184 replay_barrier $SINGLEMDS
185 for i in $(seq 10); do
186 echo "tag-$i" > $DIR/$tfile-$i
189 for i in $(seq 10); do
190 grep -q "tag-$i" $DIR/$tfile-$i || error "$tfile-$i"
193 run_test 4a "|x| 10 open(O_CREAT)s"
196 for i in $(seq 10); do
197 echo "tag-$i" > $DIR/$tfile-$i
199 replay_barrier $SINGLEMDS
202 $CHECKSTAT -t file $DIR/$tfile-* &&
203 error "$CHECKSTAT $DIR/$tfile-* attribute check should fail" ||
206 run_test 4b "|x| rm 10 files"
208 # The idea is to get past the first block of precreated files on both
209 # osts, and then replay.
211 replay_barrier $SINGLEMDS
212 for i in $(seq 220); do
213 echo "tag-$i" > $DIR/$tfile-$i
216 for i in $(seq 220); do
217 grep -q "tag-$i" $DIR/$tfile-$i || error "$tfile-$i"
221 # waiting for commitment of removal
223 run_test 5 "|x| 220 open(O_CREAT)"
225 test_6a() { # was test_6
226 mkdir_on_mdt0 $DIR/$tdir || error "mkdir $DIR/$tdir failed"
227 replay_barrier $SINGLEMDS
228 mcreate $DIR/$tdir/$tfile
230 $CHECKSTAT -t dir $DIR/$tdir ||
231 error "$CHECKSTAT $DIR/$tdir attribute check failed"
232 $CHECKSTAT -t file $DIR/$tdir/$tfile ||
233 error "$CHECKSTAT $DIR/$tdir/$tfile attribute check failed"
235 # waiting for log process thread
237 run_test 6a "mkdir + contained create"
240 mkdir_on_mdt0 $DIR/$tdir || error "mkdir $DIR/$tdir failed"
241 replay_barrier $SINGLEMDS
244 $CHECKSTAT -t dir $DIR/$tdir &&
245 error "$CHECKSTAT $DIR/$tdir attribute check should fail" ||
248 run_test 6b "|X| rmdir"
251 mkdir_on_mdt0 $DIR/$tdir || error "mkdir $DIR/$tdir failed"
252 replay_barrier $SINGLEMDS
253 mcreate $DIR/$tdir/$tfile
255 $CHECKSTAT -t dir $DIR/$tdir ||
256 error "$CHECKSTAT $DIR/$tdir attribute check failed"
257 $CHECKSTAT -t file $DIR/$tdir/$tfile ||
258 error "$CHECKSTAT $DIR/$tdir/$tfile attribute check failed"
261 run_test 7 "mkdir |X| contained create"
264 replay_barrier $SINGLEMDS
265 multiop_bg_pause $DIR/$tfile mo_c ||
266 error "multiop mknod $DIR/$tfile failed"
270 $CHECKSTAT -t file $DIR/$tfile ||
271 error "$CHECKSTAT $DIR/$tfile attribute check failed"
272 kill -USR1 $MULTIPID || error "multiop mknod $MULTIPID not running"
273 wait $MULTIPID || error "multiop mknod $MULTIPID failed"
276 run_test 8 "creat open |X| close"
279 replay_barrier $SINGLEMDS
281 local old_inum=$(ls -i $DIR/$tfile | awk '{print $1}')
283 local new_inum=$(ls -i $DIR/$tfile | awk '{print $1}')
285 echo " old_inum == $old_inum, new_inum == $new_inum"
286 if [ $old_inum -eq $new_inum ] ;
288 echo "old_inum and new_inum match"
290 echo " old_inum and new_inum do not match"
291 error "old index($old_inum) does not match new index($new_inum)"
295 run_test 9 "|X| create (same inum/gen)"
298 mcreate $DIR/$tfile || error "mcreate $DIR/$tfile failed"
299 replay_barrier $SINGLEMDS
300 mv $DIR/$tfile $DIR/$tfile-2
303 $CHECKSTAT $DIR/$tfile &&
304 error "$CHECKSTAT $DIR/$tfile attribute check should fail"
305 $CHECKSTAT $DIR/$tfile-2 ||
306 error "$CHECKSTAT $DIR/$tfile-2 attribute check failed"
310 run_test 10 "create |X| rename unlink"
313 mcreate $DIR/$tfile || error "mcreate $DIR/$tfile failed"
314 echo "old" > $DIR/$tfile
315 mv $DIR/$tfile $DIR/$tfile-2
316 replay_barrier $SINGLEMDS
317 echo "new" > $DIR/$tfile
319 grep old $DIR/$tfile-2
321 grep new $DIR/$tfile || error "grep $DIR/$tfile failed"
322 grep old $DIR/$tfile-2 || error "grep $DIR/$tfile-2 failed"
324 run_test 11 "create open write rename |X| create-old-name read"
327 mcreate $DIR/$tfile || error "mcreate $DIR/$tfile failed"
328 multiop_bg_pause $DIR/$tfile o_tSc ||
329 error "multiop_bg_pause $DIR/$tfile failed"
332 replay_barrier $SINGLEMDS
333 kill -USR1 $pid || error "multiop $pid not running"
334 wait $pid || error "multiop $pid failed"
337 [ -e $DIR/$tfile ] && error "file $DIR/$tfile should not exist"
340 run_test 12 "open, unlink |X| close"
342 # 1777 - replay open after committed chmod that would make
343 # a regular open a failure
345 mcreate $DIR/$tfile || error "mcreate $DIR/$tfile failed"
346 multiop_bg_pause $DIR/$tfile O_wc ||
347 error "multiop_bg_pause $DIR/$tfile failed"
350 $CHECKSTAT -p 0 $DIR/$tfile ||
351 error "$CHECKSTAT $DIR/$tfile attribute check failed"
352 replay_barrier $SINGLEMDS
354 kill -USR1 $pid || error "multiop $pid not running"
355 wait $pid || error "multiop $pid failed"
357 $CHECKSTAT -s 1 -p 0 $DIR/$tfile ||
358 error "second $CHECKSTAT $DIR/$tfile attribute check failed"
359 rm $DIR/$tfile || error "rm $DIR/$tfile failed"
362 run_test 13 "open chmod 0 |x| write close"
365 multiop_bg_pause $DIR/$tfile O_tSc ||
366 error "multiop_bg_pause $DIR/$tfile failed"
369 replay_barrier $SINGLEMDS
370 kill -USR1 $pid || error "multiop $pid not running"
371 wait $pid || error "multiop $pid failed"
374 [ -e $DIR/$tfile ] && error "file $DIR/$tfile should not exist"
377 run_test 14 "open(O_CREAT), unlink |X| close"
380 multiop_bg_pause $DIR/$tfile O_tSc ||
381 error "multiop_bg_pause $DIR/$tfile failed"
384 replay_barrier $SINGLEMDS
385 touch $DIR/$tfile-1 || error "touch $DIR/$tfile-1 failed"
386 kill -USR1 $pid || error "multiop $pid not running"
387 wait $pid || error "multiop $pid failed"
390 [ -e $DIR/$tfile ] && error "file $DIR/$tfile should not exist"
391 touch $DIR/$tfile-2 || error "touch $DIR/$tfile-2 failed"
394 run_test 15 "open(O_CREAT), unlink |X| touch new, close"
397 replay_barrier $SINGLEMDS
400 mcreate $DIR/$tfile-2
402 [ -e $DIR/$tfile ] && error "file $DIR/$tfile should not exist"
403 [ -e $DIR/$tfile-2 ] || error "file $DIR/$tfile-2 does not exist"
404 unlink $DIR/$tfile-2 || error "unlink $DIR/$tfile-2 failed"
406 run_test 16 "|X| open(O_CREAT), unlink, touch new, unlink new"
409 replay_barrier $SINGLEMDS
410 multiop_bg_pause $DIR/$tfile O_c ||
411 error "multiop_bg_pause $DIR/$tfile failed"
414 kill -USR1 $pid || error "multiop $pid not running"
415 wait $pid || error "multiop $pid failed"
416 $CHECKSTAT -t file $DIR/$tfile ||
417 error "$CHECKSTAT $DIR/$tfile attribute check failed"
420 run_test 17 "|X| open(O_CREAT), |replay| close"
423 replay_barrier $SINGLEMDS
424 multiop_bg_pause $DIR/$tfile O_tSc ||
425 error "multiop_bg_pause $DIR/$tfile failed"
428 touch $DIR/$tfile-2 || error "touch $DIR/$tfile-2 failed"
429 echo "pid: $pid will close"
430 kill -USR1 $pid || error "multiop $pid not running"
431 wait $pid || error "multiop $pid failed"
434 [ -e $DIR/$tfile ] && error "file $DIR/$tfile should not exist"
435 [ -e $DIR/$tfile-2 ] || error "file $DIR/$tfile-2 does not exist"
436 # this touch frequently fails
437 touch $DIR/$tfile-3 || error "touch $DIR/$tfile-3 failed"
438 unlink $DIR/$tfile-2 || error "unlink $DIR/$tfile-2 failed"
439 unlink $DIR/$tfile-3 || error "unlink $DIR/$tfile-3 failed"
442 run_test 18 "open(O_CREAT), unlink, touch new, close, touch, unlink"
444 # bug 1855 (a simpler form of test_11 above)
446 replay_barrier $SINGLEMDS
448 echo "old" > $DIR/$tfile
449 mv $DIR/$tfile $DIR/$tfile-2
450 grep old $DIR/$tfile-2
452 grep old $DIR/$tfile-2 || error "grep $DIR/$tfile-2 failed"
454 run_test 19 "mcreate, open, write, rename "
456 test_20a() { # was test_20
457 replay_barrier $SINGLEMDS
458 multiop_bg_pause $DIR/$tfile O_tSc ||
459 error "multiop_bg_pause $DIR/$tfile failed"
464 kill -USR1 $pid || error "multiop $pid not running"
465 wait $pid || error "multiop $pid failed"
466 [ -e $DIR/$tfile ] && error "file $DIR/$tfile should not exist"
469 run_test 20a "|X| open(O_CREAT), unlink, replay, close (test mds_cleanup_orphans)"
471 test_20b() { # bug 10480
472 local wait_timeout=$((TIMEOUT * 4))
473 local extra=$(fs_log_size)
477 save_layout_restore_at_exit $MOUNT
478 $LFS setstripe -i 0 -c 1 $DIR
480 local beforeused=$(df -P $DIR | tail -1 | awk '{ print $3 }')
482 dd if=/dev/zero of=$DIR/$tfile bs=4k count=10000 &
483 while [ ! -e $DIR/$tfile ] ; do
484 sleep 0.01 # give dd a chance to start
487 $LFS getstripe $DIR/$tfile || error "$LFS getstripe $DIR/$tfile failed"
489 rm -f $DIR/$tfile || error "rm -f $DIR/$tfile failed"
491 client_up || client_up || true # reconnect
493 do_facet $SINGLEMDS "lctl set_param -n osd*.*MDT*.force_sync=1"
495 fail $SINGLEMDS # start orphan recovery
496 wait_recovery_complete $SINGLEMDS || error "MDS recovery not done"
497 wait_delete_completed $wait_timeout || error "delete did not finish"
501 local afterused=$(df -P $DIR | tail -1 | awk '{ print $3 }')
502 log "before $beforeused, after $afterused"
504 (( $beforeused + $extra >= $afterused )) && break
505 n_attempts=$((n_attempts + 1))
506 [ $n_attempts -gt 3 ] &&
507 error "after $afterused > before $beforeused + $extra"
509 wait_zfs_commit $SINGLEMDS 5
514 run_test 20b "write, unlink, eviction, replay (test mds_cleanup_orphans)"
516 test_20c() { # bug 10480
517 multiop_bg_pause $DIR/$tfile Ow_c ||
518 error "multiop_bg_pause $DIR/$tfile failed"
524 client_up || client_up || true # reconnect
526 kill -USR1 $pid || error "multiop $pid not running"
527 wait $pid || error "multiop $pid failed"
528 [ -s $DIR/$tfile ] || error "File was truncated"
532 run_test 20c "check that client eviction does not affect file content"
535 replay_barrier $SINGLEMDS
536 multiop_bg_pause $DIR/$tfile O_tSc ||
537 error "multiop_bg_pause $DIR/$tfile failed"
540 touch $DIR/$tfile-1 || error "touch $DIR/$tfile-1 failed"
543 kill -USR1 $pid || error "multiop $pid not running"
544 wait $pid || error "multiop $pid failed"
545 [ -e $DIR/$tfile ] && error "file $DIR/$tfile should not exist"
546 touch $DIR/$tfile-2 || error "touch $DIR/$tfile-2 failed"
549 run_test 21 "|X| open(O_CREAT), unlink touch new, replay, close (test mds_cleanup_orphans)"
552 multiop_bg_pause $DIR/$tfile O_tSc ||
553 error "multiop_bg_pause $DIR/$tfile failed"
556 replay_barrier $SINGLEMDS
560 kill -USR1 $pid || error "multiop $pid not running"
561 wait $pid || error "multiop $pid failed"
562 [ -e $DIR/$tfile ] && error "file $DIR/$tfile should not exist"
565 run_test 22 "open(O_CREAT), |X| unlink, replay, close (test mds_cleanup_orphans)"
568 multiop_bg_pause $DIR/$tfile O_tSc ||
569 error "multiop_bg_pause $DIR/$tfile failed"
572 replay_barrier $SINGLEMDS
574 touch $DIR/$tfile-1 || error "touch $DIR/$tfile-1 failed"
577 kill -USR1 $pid || error "multiop $pid not running"
578 wait $pid || error "multiop $pid failed"
579 [ -e $DIR/$tfile ] && error "file $DIR/$tfile should not exist"
580 touch $DIR/$tfile-2 || error "touch $DIR/$tfile-2 failed"
583 run_test 23 "open(O_CREAT), |X| unlink touch new, replay, close (test mds_cleanup_orphans)"
586 multiop_bg_pause $DIR/$tfile O_tSc ||
587 error "multiop_bg_pause $DIR/$tfile failed"
590 replay_barrier $SINGLEMDS
593 kill -USR1 $pid || error "multiop $pid not running"
594 wait $pid || error "multiop $pid failed"
595 [ -e $DIR/$tfile ] && error "file $DIR/$tfile should not exist"
598 run_test 24 "open(O_CREAT), replay, unlink, close (test mds_cleanup_orphans)"
601 multiop_bg_pause $DIR/$tfile O_tSc ||
602 error "multiop_bg_pause $DIR/$tfile failed"
606 replay_barrier $SINGLEMDS
608 kill -USR1 $pid || error "multiop $pid not running"
609 wait $pid || error "multiop $pid failed"
610 [ -e $DIR/$tfile ] && error "file $DIR/$tfile should not exist"
613 run_test 25 "open(O_CREAT), unlink, replay, close (test mds_cleanup_orphans)"
616 replay_barrier $SINGLEMDS
617 multiop_bg_pause $DIR/$tfile-1 O_tSc ||
618 error "multiop_bg_pause $DIR/$tfile-1 failed"
620 multiop_bg_pause $DIR/$tfile-2 O_tSc ||
621 error "multiop_bg_pause $DIR/$tfile-2 failed"
625 kill -USR1 $pid2 || error "second multiop $pid2 not running"
626 wait $pid2 || error "second multiop $pid2 failed"
629 kill -USR1 $pid1 || error "multiop $pid1 not running"
630 wait $pid1 || error "multiop $pid1 failed"
631 [ -e $DIR/$tfile-1 ] && error "file $DIR/$tfile-1 should not exist"
632 [ -e $DIR/$tfile-2 ] && error "file $DIR/$tfile-2 should not exist"
635 run_test 26 "|X| open(O_CREAT), unlink two, close one, replay, close one (test mds_cleanup_orphans)"
638 replay_barrier $SINGLEMDS
639 multiop_bg_pause $DIR/$tfile-1 O_tSc ||
640 error "multiop_bg_pause $DIR/$tfile-1 failed"
642 multiop_bg_pause $DIR/$tfile-2 O_tSc ||
643 error "multiop_bg_pause $DIR/$tfile-2 failed"
649 kill -USR1 $pid1 || error "multiop $pid1 not running"
650 wait $pid1 || error "multiop $pid1 failed"
651 kill -USR1 $pid2 || error "second multiop $pid2 not running"
652 wait $pid2 || error "second multiop $pid2 failed"
653 [ -e $DIR/$tfile-1 ] && error "file $DIR/$tfile-1 should not exist"
654 [ -e $DIR/$tfile-2 ] && error "file $DIR/$tfile-2 should not exist"
657 run_test 27 "|X| open(O_CREAT), unlink two, replay, close two (test mds_cleanup_orphans)"
660 multiop_bg_pause $DIR/$tfile-1 O_tSc ||
661 error "multiop_bg_pause $DIR/$tfile-1 failed"
663 multiop_bg_pause $DIR/$tfile-2 O_tSc ||
664 error "multiop_bg_pause $DIR/$tfile-2 failed"
666 replay_barrier $SINGLEMDS
669 kill -USR1 $pid2 || error "second multiop $pid2 not running"
670 wait $pid2 || error "second multiop $pid2 failed"
673 kill -USR1 $pid1 || error "multiop $pid1 not running"
674 wait $pid1 || error "multiop $pid1 failed"
675 [ -e $DIR/$tfile-1 ] && error "file $DIR/$tfile-1 should not exist"
676 [ -e $DIR/$tfile-2 ] && error "file $DIR/$tfile-2 should not exist"
679 run_test 28 "open(O_CREAT), |X| unlink two, close one, replay, close one (test mds_cleanup_orphans)"
682 multiop_bg_pause $DIR/$tfile-1 O_tSc ||
683 error "multiop_bg_pause $DIR/$tfile-1 failed"
685 multiop_bg_pause $DIR/$tfile-2 O_tSc ||
686 error "multiop_bg_pause $DIR/$tfile-2 failed"
688 replay_barrier $SINGLEMDS
693 kill -USR1 $pid1 || error "multiop $pid1 not running"
694 wait $pid1 || error "multiop $pid1 failed"
695 kill -USR1 $pid2 || error "second multiop $pid2 not running"
696 wait $pid2 || error "second multiop $pid2 failed"
697 [ -e $DIR/$tfile-1 ] && error "file $DIR/$tfile-1 should not exist"
698 [ -e $DIR/$tfile-2 ] && error "file $DIR/$tfile-2 should not exist"
701 run_test 29 "open(O_CREAT), |X| unlink two, replay, close two (test mds_cleanup_orphans)"
704 multiop_bg_pause $DIR/$tfile-1 O_tSc ||
705 error "multiop_bg_pause $DIR/$tfile-1 failed"
707 multiop_bg_pause $DIR/$tfile-2 O_tSc ||
708 error "multiop_bg_pause $DIR/$tfile-2 failed"
713 replay_barrier $SINGLEMDS
715 kill -USR1 $pid1 || error "multiop $pid1 not running"
716 wait $pid1 || error "multiop $pid1 failed"
717 kill -USR1 $pid2 || error "second multiop $pid2 not running"
718 wait $pid2 || error "second multiop $pid2 failed"
719 [ -e $DIR/$tfile-1 ] && error "file $DIR/$tfile-1 should not exist"
720 [ -e $DIR/$tfile-2 ] && error "file $DIR/$tfile-2 should not exist"
723 run_test 30 "open(O_CREAT) two, unlink two, replay, close two (test mds_cleanup_orphans)"
726 multiop_bg_pause $DIR/$tfile-1 O_tSc ||
727 error "multiop_bg_pause $DIR/$tfile-1 failed"
729 multiop_bg_pause $DIR/$tfile-2 O_tSc ||
730 error "multiop_bg_pause $DIR/$tfile-2 failed"
734 replay_barrier $SINGLEMDS
737 kill -USR1 $pid1 || error "multiop $pid1 not running"
738 wait $pid1 || error "multiop $pid1 failed"
739 kill -USR1 $pid2 || error "second multiop $pid2 not running"
740 wait $pid2 || error "second multiop $pid2 failed"
741 [ -e $DIR/$tfile-1 ] && error "file $DIR/$tfile-1 should not exist"
742 [ -e $DIR/$tfile-2 ] && error "file $DIR/$tfile-2 should not exist"
745 run_test 31 "open(O_CREAT) two, unlink one, |X| unlink one, close two (test mds_cleanup_orphans)"
747 # tests for bug 2104; completion without crashing is success. The close is
748 # stale, but we always return 0 for close, so the app never sees it.
750 multiop_bg_pause $DIR/$tfile O_c ||
751 error "multiop_bg_pause $DIR/$tfile failed"
753 multiop_bg_pause $DIR/$tfile O_c ||
754 error "second multiop_bg_pause $DIR/$tfile failed"
757 client_up || client_up || error "client_up failed"
758 kill -USR1 $pid1 || error "multiop $pid1 not running"
759 kill -USR1 $pid2 || error "second multiop $pid2 not running"
760 wait $pid1 || error "multiop $pid1 failed"
761 wait $pid2 || error "second multiop $pid2 failed"
764 run_test 32 "close() notices client eviction; close() after client eviction"
767 createmany -o $DIR/$tfile-%d 10 ||
768 error "createmany create $DIR/$tfile failed"
769 replay_barrier_nosync $SINGLEMDS
770 fail_abort $SINGLEMDS
771 # recreate shouldn't fail
772 createmany -o $DIR/$tfile--%d 10 ||
773 error "createmany recreate $DIR/$tfile failed"
777 run_test 33a "fid seq shouldn't be reused after abort recovery"
780 #define OBD_FAIL_SEQ_ALLOC 0x1311
781 do_facet $SINGLEMDS "lctl set_param fail_loc=0x1311"
783 createmany -o $DIR/$tfile-%d 10
784 replay_barrier_nosync $SINGLEMDS
785 fail_abort $SINGLEMDS
786 # recreate shouldn't fail
787 createmany -o $DIR/$tfile--%d 10 ||
788 error "createmany recreate $DIR/$tfile failed"
792 run_test 33b "test fid seq allocation"
795 multiop_bg_pause $DIR/$tfile O_c ||
796 error "multiop_bg_pause $DIR/$tfile failed"
800 replay_barrier $SINGLEMDS
801 fail_abort $SINGLEMDS
802 kill -USR1 $pid || error "multiop $pid not running"
803 wait $pid || error "multiop $pid failed"
804 [ -e $DIR/$tfile ] && error "file $DIR/$tfile should not exist"
808 run_test 34 "abort recovery before client does replay (test mds_cleanup_orphans)"
810 # bug 2278 - generate one orphan on OST, then destroy it during recovery from llog
812 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
814 #define OBD_FAIL_MDS_REINT_NET_REP 0x119
815 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000119"
820 # give a chance to remove from MDS
821 fail_abort $SINGLEMDS
822 $CHECKSTAT -t file $DIR/$tfile &&
823 error "$CHECKSTAT $DIR/$tfile attribute check should fail" ||
826 run_test 35 "test recovery from llog for unlink op"
828 # b=2432 resent cancel after replay uses wrong cookie,
829 # so don't resend cancels
831 replay_barrier $SINGLEMDS
833 checkstat $DIR/$tfile
834 facet_failover $SINGLEMDS
836 if do_facet $SINGLEMDS $LCTL dk | grep "stale lock .*cookie"; then
837 error "cancel after replay failed"
840 run_test 36 "don't resend cancel"
843 # directory orphans can't be unlinked from PENDING directory
845 mkdir_on_mdt0 $DIR/$tdir || error "mkdir $tdir failed"
846 rmdir $DIR/$tdir/$tfile 2>/dev/null
847 multiop_bg_pause $DIR/$tdir/$tfile dD_c ||
848 error "multiop_bg_pause $tfile failed"
850 rmdir $DIR/$tdir/$tfile
852 replay_barrier $SINGLEMDS
853 # clear the dmesg buffer so we only see errors from this recovery
854 do_facet $SINGLEMDS dmesg -c >/dev/null
855 fail_abort $SINGLEMDS
856 kill -USR1 $pid || error "multiop $pid not running"
857 do_facet $SINGLEMDS dmesg | grep "error unlinking orphan" &&
858 error "error unlinking files"
859 wait $pid || error "multiop $pid failed"
863 run_test 37 "abort recovery before client does replay (test mds_cleanup_orphans for directories)"
866 createmany -o $DIR/$tfile-%d 800 ||
867 error "createmany -o $DIR/$tfile failed"
868 unlinkmany $DIR/$tfile-%d 0 400 || error "unlinkmany $DIR/$tfile failed"
869 replay_barrier $SINGLEMDS
871 unlinkmany $DIR/$tfile-%d 400 400 ||
872 error "unlinkmany $DIR/$tfile 400 failed"
874 $CHECKSTAT -t file $DIR/$tfile-* &&
875 error "$CHECKSTAT $DIR/$tfile-* attribute check should fail" ||
878 run_test 38 "test recovery from unlink llog (test llog_gen_rec) "
880 test_39() { # bug 4176
881 createmany -o $DIR/$tfile-%d 800 ||
882 error "createmany -o $DIR/$tfile failed"
883 replay_barrier $SINGLEMDS
884 unlinkmany $DIR/$tfile-%d 0 400
886 unlinkmany $DIR/$tfile-%d 400 400 ||
887 error "unlinkmany $DIR/$tfile 400 failed"
889 $CHECKSTAT -t file $DIR/$tfile-* &&
890 error "$CHECKSTAT $DIR/$tfile-* attribute check should fail" ||
893 run_test 39 "test recovery from unlink llog (test llog_gen_rec) "
896 lctl get_param -n osc.*.stats | awk -vwrites=0 '/ost_write/ { writes += $2 } END { print writes; }'
900 # make sure that a read to one osc doesn't try to double-unlock its page just
901 # because another osc is invalid. trigger_group_io used to mistakenly return
902 # an error if any oscs were invalid even after having successfully put rpcs
903 # on valid oscs. This was fatal if the caller was ll_readpage who unlocked
904 # the page, guarnateeing that the unlock from the RPC completion would
905 # assert on trying to unlock the unlocked page.
907 [ $OSTCOUNT -lt 2 ] && skip_env "needs >= 2 OSTs" && return
909 local f=$MOUNT/$tfile
910 # make sure the start of the file is ost1
911 $LFS setstripe -S $((128 * 1024)) -i 0 $f
912 do_facet client dd if=/dev/zero of=$f bs=4k count=1 ||
913 error "dd on client failed"
915 # fail ost2 and read from ost1
916 local mdtosc=$(get_mdtosc_proc_path $SINGLEMDS $ost2_svc)
917 local osc2dev=$(do_facet $SINGLEMDS "lctl get_param -n devices" |
918 grep $mdtosc | awk '{print $1}')
919 [ -z "$osc2dev" ] && echo "OST: $ost2_svc" &&
920 lctl get_param -n devices &&
921 error "OST 2 $osc2dev does not exist"
922 do_facet $SINGLEMDS $LCTL --device $osc2dev deactivate ||
923 error "deactive device on $SINGLEMDS failed"
924 do_facet client dd if=$f of=/dev/null bs=4k count=1 ||
925 error "second dd on client failed"
926 do_facet $SINGLEMDS $LCTL --device $osc2dev activate ||
927 error "active device on $SINGLEMDS failed"
930 run_test 41 "read from a valid osc while other oscs are invalid"
932 # test MDS recovery after ost failure
934 blocks=$(df -P $MOUNT | tail -n 1 | awk '{ print $2 }')
935 createmany -o $DIR/$tfile-%d 800 ||
936 error "createmany -o $DIR/$tfile failed"
938 unlinkmany $DIR/$tfile-%d 0 400
940 lctl set_param debug=-1
943 # osc is evicted, fs is smaller (but only with failout OSTs (bug 7287)
944 #blocks_after=`df -P $MOUNT | tail -n 1 | awk '{ print $2 }'`
945 #[ $blocks_after -lt $blocks ] || return 1
946 echo "wait for MDS to timeout and recover"
947 sleep $((TIMEOUT * 2))
949 unlinkmany $DIR/$tfile-%d 400 400 ||
950 error "unlinkmany $DIR/$tfile 400 failed"
951 $CHECKSTAT -t file $DIR/$tfile-* &&
952 error "$CHECKSTAT $DIR/$tfile-* attribute check should fail" ||
955 run_test 42 "recovery after ost failure"
957 # timeout in MDS/OST recovery RPC will LBUG MDS
958 test_43() { # bug 2530
959 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
961 replay_barrier $SINGLEMDS
963 # OBD_FAIL_OST_CREATE_NET 0x204
964 do_facet ost1 "lctl set_param fail_loc=0x80000204"
970 run_test 43 "mds osc import failure during recovery; don't LBUG"
972 test_44a() { # was test_44
975 local mdcdev=$($LCTL dl |
976 awk "/${FSNAME}-MDT0000-mdc-/ {if (\$2 == \"UP\") {print \$1}}")
977 [ "$mdcdev" ] || error "${FSNAME}-MDT0000-mdc- not UP"
978 [ $(echo $mdcdev | wc -w) -eq 1 ] ||
979 { $LCTL dl; error "looking for mdcdev=$mdcdev"; }
981 # adaptive timeouts slow this way down
982 if at_is_enabled; then
983 at_max_saved=$(at_max_get mds)
987 for i in $(seq 1 10); do
988 echo "$i of 10 ($(date +%s))"
989 do_facet $SINGLEMDS \
990 "lctl get_param -n md[ts].*.mdt.timeouts | grep service"
991 #define OBD_FAIL_TGT_CONN_RACE 0x701
992 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000701"
993 # lctl below may fail, it is valid case
994 $LCTL --device $mdcdev recover
997 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
998 [ $at_max_saved -ne 0 ] && at_max_set $at_max_saved mds
1001 run_test 44a "race in target handle connect"
1004 local mdcdev=$($LCTL dl |
1005 awk "/${FSNAME}-MDT0000-mdc-/ {if (\$2 == \"UP\") {print \$1}}")
1006 [ "$mdcdev" ] || error "${FSNAME}-MDT0000-mdc not up"
1007 [ $(echo $mdcdev | wc -w) -eq 1 ] ||
1008 { echo mdcdev=$mdcdev; $LCTL dl;
1009 error "more than one ${FSNAME}-MDT0000-mdc"; }
1011 for i in $(seq 1 10); do
1012 echo "$i of 10 ($(date +%s))"
1013 do_facet $SINGLEMDS \
1014 "lctl get_param -n md[ts].*.mdt.timeouts | grep service"
1015 #define OBD_FAIL_TGT_DELAY_RECONNECT 0x704
1016 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000704"
1017 # lctl below may fail, it is valid case
1018 $LCTL --device $mdcdev recover
1023 run_test 44b "race in target handle connect"
1026 replay_barrier $SINGLEMDS
1027 createmany -m $DIR/$tfile-%d 100 || error "failed to create directories"
1028 #define OBD_FAIL_TGT_RCVG_FLAG 0x712
1029 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000712"
1030 fail_abort $SINGLEMDS
1031 unlinkmany $DIR/$tfile-%d 100 && error "unliked after fail abort"
1033 unlinkmany $DIR/$tfile-%d 100 && error "unliked after fail"
1036 run_test 44c "race in target handle connect"
1038 # Handle failed close
1040 local mdcdev=$($LCTL get_param -n devices |
1041 awk "/ ${FSNAME}-MDT0000-mdc-/ {print \$1}")
1042 [ "$mdcdev" ] || error "${FSNAME}-MDT0000-mdc not up"
1043 [ $(echo $mdcdev | wc -w) -eq 1 ] ||
1044 { echo mdcdev=$mdcdev; $LCTL dl;
1045 error "more than one ${FSNAME}-MDT0000-mdc"; }
1047 $LCTL --device $mdcdev recover ||
1048 error "$LCTL --device $mdcdev recover failed"
1050 multiop_bg_pause $DIR/$tfile O_c ||
1051 error "multiop_bg_pause $DIR/$tfile failed"
1054 # This will cause the CLOSE to fail before even
1055 # allocating a reply buffer
1056 $LCTL --device $mdcdev deactivate ||
1057 error "$LCTL --device $mdcdev deactivate failed"
1060 kill -USR1 $pid || error "multiop $pid not running"
1061 wait $pid || error "multiop $pid failed"
1063 $LCTL --device $mdcdev activate ||
1064 error "$LCTL --device $mdcdev activate failed"
1067 $CHECKSTAT -t file $DIR/$tfile ||
1068 error "$CHECKSTAT $DIR/$tfile attribute check failed"
1071 run_test 45 "Handle failed close"
1074 drop_reply "touch $DIR/$tfile"
1076 # ironically, the previous test, 45, will cause a real forced close,
1077 # so just look for one for this test
1078 local FID=$($LFS path2fid $tfile)
1079 $LCTL dk | grep -i "force closing file handle $FID" &&
1080 error "found force closing in dmesg"
1083 run_test 46 "Don't leak file handle after open resend (3325)"
1085 test_47() { # bug 2824
1086 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1088 # create some files to make sure precreate has been done on all
1089 # OSTs. (just in case this test is run independently)
1090 createmany -o $DIR/$tfile 20 ||
1091 error "createmany create $DIR/$tfile failed"
1093 # OBD_FAIL_OST_CREATE_NET 0x204
1095 do_facet ost1 "lctl set_param fail_loc=0x80000204"
1096 client_up || error "client_up failed"
1098 # let the MDS discover the OST failure, attempt to recover, fail
1099 # and recover again.
1100 sleep $((3 * TIMEOUT))
1102 # Without 2824, this createmany would hang
1103 createmany -o $DIR/$tfile 20 ||
1104 error "createmany recraete $DIR/$tfile failed"
1105 unlinkmany $DIR/$tfile 20 || error "unlinkmany $DIR/$tfile failed"
1109 run_test 47 "MDS->OSC failure during precreate cleanup (2824)"
1112 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1113 [ "$OSTCOUNT" -lt "2" ] && skip_env "needs >= 2 OSTs" && return
1115 replay_barrier $SINGLEMDS
1116 createmany -o $DIR/$tfile 20 ||
1117 error "createmany -o $DIR/$tfile failed"
1118 # OBD_FAIL_OST_EROFS 0x216
1119 facet_failover $SINGLEMDS
1120 do_facet ost1 "lctl set_param fail_loc=0x80000216"
1121 client_up || error "client_up failed"
1123 # let the MDS discover the OST failure, attempt to recover, fail
1124 # and recover again.
1125 sleep $((3 * TIMEOUT))
1127 createmany -o $DIR/$tfile 20 20 ||
1128 error "createmany recraete $DIR/$tfile failed"
1129 unlinkmany $DIR/$tfile 40 || error "unlinkmany $DIR/$tfile failed"
1132 run_test 48 "MDS->OSC failure during precreate cleanup (2824)"
1135 local mdtosc=$(get_mdtosc_proc_path $SINGLEMDS $ost1_svc)
1136 local oscdev=$(do_facet $SINGLEMDS "lctl get_param -n devices" |
1137 grep $mdtosc | awk '{print $1}')
1138 [ "$oscdev" ] || error "could not find OSC device on MDS"
1139 do_facet $SINGLEMDS $LCTL --device $oscdev recover ||
1140 error "OSC device $oscdev recovery failed"
1141 do_facet $SINGLEMDS $LCTL --device $oscdev recover ||
1142 error "second OSC device $oscdev recovery failed"
1143 # give the mds_lov_sync threads a chance to run
1146 run_test 50 "Double OSC recovery, don't LASSERT (3812)"
1148 # b3764 timed out lock replay
1150 [ "$MDS1_VERSION" -lt $(version_code 2.6.90) ] &&
1151 skip "MDS prior to 2.6.90 handle LDLM_REPLY_NET incorrectly"
1153 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
1154 cancel_lru_locks mdc
1156 multiop_bg_pause $DIR/$tfile s_s || error "multiop $DIR/$tfile failed"
1159 #define OBD_FAIL_MDS_LDLM_REPLY_NET 0x157
1160 lctl set_param -n ldlm.cancel_unused_locks_before_replay "0"
1161 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000157"
1163 fail $SINGLEMDS || error "fail $SINGLEMDS failed"
1165 wait $mpid || error "multiop_bg_pause pid failed"
1167 do_facet $SINGLEMDS "lctl set_param fail_loc=0x0"
1168 lctl set_param fail_loc=0x0
1169 lctl set_param -n ldlm.cancel_unused_locks_before_replay "1"
1172 run_test 52 "time out lock replay (3764)"
1174 # bug 3462 - simultaneous MDC requests
1176 [[ $(lctl get_param mdc.*.import |
1177 grep "connect_flags:.*multi_mod_rpc") ]] ||
1178 { skip "Need MDC with 'multi_mod_rpcs' feature"; return 0; }
1180 cancel_lru_locks mdc # cleanup locks from former test cases
1181 mkdir_on_mdt0 $DIR/${tdir}-1 || error "mkdir $DIR/${tdir}-1 failed"
1182 mkdir_on_mdt0 $DIR/${tdir}-2 || error "mkdir $DIR/${tdir}-2 failed"
1183 multiop $DIR/${tdir}-1/f O_c &
1185 # give multiop a change to open
1188 #define OBD_FAIL_MDS_CLOSE_NET 0x115
1189 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000115"
1190 kill -USR1 $close_pid
1191 cancel_lru_locks mdc # force the close
1192 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
1194 mcreate $DIR/${tdir}-2/f || error "mcreate $DIR/${tdir}-2/f failed"
1196 # close should still be here
1197 [ -d /proc/$close_pid ] || error "close_pid doesn't exist"
1199 replay_barrier_nodf $SINGLEMDS
1201 wait $close_pid || error "close_pid $close_pid failed"
1203 $CHECKSTAT -t file $DIR/${tdir}-1/f ||
1204 error "$CHECKSTAT $DIR/${tdir}-1/f attribute check failed"
1205 $CHECKSTAT -t file $DIR/${tdir}-2/f ||
1206 error "$CHECKSTAT $DIR/${tdir}-2/f attribute check failed"
1207 rm -rf $DIR/${tdir}-*
1209 run_test 53a "|X| close request while two MDC requests in flight"
1212 cancel_lru_locks mdc # cleanup locks from former test cases
1214 mkdir_on_mdt0 $DIR/${tdir}-1 || error "mkdir $DIR/${tdir}-1 failed"
1215 mkdir_on_mdt0 $DIR/${tdir}-2 || error "mkdir $DIR/${tdir}-2 failed"
1216 multiop_bg_pause $DIR/${tdir}-1/f O_c ||
1217 error "multiop_bg_pause $DIR/${tdir}-1/f failed"
1220 #define OBD_FAIL_MDS_REINT_NET 0x107
1221 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000107"
1222 mcreate $DIR/${tdir}-2/f &
1226 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
1227 kill -USR1 $close_pid
1228 cancel_lru_locks mdc # force the close
1229 wait $close_pid || error "close_pid $close_pid failed"
1230 # open should still be here
1231 [ -d /proc/$open_pid ] || error "open_pid doesn't exist"
1233 replay_barrier_nodf $SINGLEMDS
1235 wait $open_pid || error "open_pid failed"
1237 $CHECKSTAT -t file $DIR/${tdir}-1/f ||
1238 error "$CHECKSTAT $DIR/${tdir}-1/f attribute check failed"
1239 $CHECKSTAT -t file $DIR/${tdir}-2/f ||
1240 error "$CHECKSTAT $DIR/${tdir}-2/f attribute check failed"
1241 rm -rf $DIR/${tdir}-*
1243 run_test 53b "|X| open request while two MDC requests in flight"
1246 cancel_lru_locks mdc # cleanup locks from former test cases
1248 mkdir_on_mdt0 $DIR/${tdir}-1 || error "mkdir $DIR/${tdir}-1 failed"
1249 mkdir_on_mdt0 $DIR/${tdir}-2 || error "mkdir $DIR/${tdir}-2 failed"
1250 multiop $DIR/${tdir}-1/f O_c &
1253 #define OBD_FAIL_MDS_REINT_NET 0x107
1254 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000107"
1255 mcreate $DIR/${tdir}-2/f &
1259 #define OBD_FAIL_MDS_CLOSE_NET 0x115
1260 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000115"
1261 kill -USR1 $close_pid
1262 cancel_lru_locks mdc # force the close
1264 #bz20647: make sure all pids exist before failover
1265 [ -d /proc/$close_pid ] || error "close_pid doesn't exist"
1266 [ -d /proc/$open_pid ] || error "open_pid doesn't exists"
1267 replay_barrier_nodf $SINGLEMDS
1268 fail_nodf $SINGLEMDS
1269 wait $open_pid || error "open_pid failed"
1271 # close should be gone
1272 [ -d /proc/$close_pid ] && error "close_pid should not exist"
1273 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
1275 $CHECKSTAT -t file $DIR/${tdir}-1/f ||
1276 error "$CHECKSTAT $DIR/${tdir}-1/f attribute check failed"
1277 $CHECKSTAT -t file $DIR/${tdir}-2/f ||
1278 error "$CHECKSTAT $DIR/${tdir}-2/f attribute check failed"
1279 rm -rf $DIR/${tdir}-*
1281 run_test 53c "|X| open request and close request while two MDC requests in flight"
1284 [[ $(lctl get_param mdc.*.import |
1285 grep "connect_flags:.*multi_mod_rpc") ]] ||
1286 { skip "Need MDC with 'multi_mod_rpcs' feature"; return 0; }
1288 cancel_lru_locks mdc # cleanup locks from former test cases
1290 mkdir_on_mdt0 $DIR/${tdir}-1 || error "mkdir $DIR/${tdir}-1 failed"
1291 mkdir_on_mdt0 $DIR/${tdir}-2 || error "mkdir $DIR/${tdir}-2 failed"
1292 multiop $DIR/${tdir}-1/f O_c &
1294 # give multiop a chance to open
1297 #define OBD_FAIL_MDS_CLOSE_NET_REP 0x13b
1298 do_facet $SINGLEMDS "lctl set_param fail_loc=0x8000013b"
1299 kill -USR1 $close_pid
1300 cancel_lru_locks mdc # force the close
1301 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
1302 mcreate $DIR/${tdir}-2/f || error "mcreate $DIR/${tdir}-2/f failed"
1304 # close should still be here
1305 [ -d /proc/$close_pid ] || error "close_pid doesn't exist"
1307 wait $close_pid || error "close_pid failed"
1309 $CHECKSTAT -t file $DIR/${tdir}-1/f ||
1310 error "$CHECKSTAT $DIR/${tdir}-1/f attribute check failed"
1311 $CHECKSTAT -t file $DIR/${tdir}-2/f ||
1312 error "$CHECKSTAT $DIR/${tdir}-2/f attribute check failed"
1313 rm -rf $DIR/${tdir}-*
1315 run_test 53d "close reply while two MDC requests in flight"
1318 cancel_lru_locks mdc # cleanup locks from former test cases
1320 mkdir_on_mdt0 $DIR/${tdir}-1 || error "mkdir $DIR/${tdir}-1 failed"
1321 mkdir_on_mdt0 $DIR/${tdir}-2 || error "mkdir $DIR/${tdir}-2 failed"
1322 multiop $DIR/${tdir}-1/f O_c &
1325 #define OBD_FAIL_MDS_REINT_NET_REP 0x119
1326 do_facet $SINGLEMDS "lctl set_param fail_loc=0x119"
1327 mcreate $DIR/${tdir}-2/f &
1331 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
1332 kill -USR1 $close_pid
1333 cancel_lru_locks mdc # force the close
1334 wait $close_pid || error "close_pid failed"
1335 # open should still be here
1336 [ -d /proc/$open_pid ] || error "open_pid doesn't exists"
1338 replay_barrier_nodf $SINGLEMDS
1340 wait $open_pid || error "open_pid failed"
1342 $CHECKSTAT -t file $DIR/${tdir}-1/f ||
1343 error "$CHECKSTAT $DIR/${tdir}-1/f attribute check failed"
1344 $CHECKSTAT -t file $DIR/${tdir}-2/f ||
1345 error "$CHECKSTAT $DIR/${tdir}-2/f attribute check failed"
1346 rm -rf $DIR/${tdir}-*
1348 run_test 53e "|X| open reply while two MDC requests in flight"
1351 cancel_lru_locks mdc # cleanup locks from former test cases
1353 mkdir_on_mdt0 $DIR/${tdir}-1 || error "mkdir $DIR/${tdir}-1 failed"
1354 mkdir_on_mdt0 $DIR/${tdir}-2 || error "mkdir $DIR/${tdir}-2 failed"
1355 multiop $DIR/${tdir}-1/f O_c &
1358 #define OBD_FAIL_MDS_REINT_NET_REP 0x119
1359 do_facet $SINGLEMDS "lctl set_param fail_loc=0x119"
1360 mcreate $DIR/${tdir}-2/f &
1364 #define OBD_FAIL_MDS_CLOSE_NET_REP 0x13b
1365 do_facet $SINGLEMDS "lctl set_param fail_loc=0x8000013b"
1366 kill -USR1 $close_pid
1367 cancel_lru_locks mdc # force the close
1369 #bz20647: make sure all pids are exists before failover
1370 [ -d /proc/$close_pid ] || error "close_pid doesn't exist"
1371 [ -d /proc/$open_pid ] || error "open_pid doesn't exists"
1372 replay_barrier_nodf $SINGLEMDS
1373 fail_nodf $SINGLEMDS
1374 wait $open_pid || error "open_pid failed"
1376 # close should be gone
1377 [ -d /proc/$close_pid ] && error "close_pid should not exist"
1378 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
1380 $CHECKSTAT -t file $DIR/${tdir}-1/f ||
1381 error "$CHECKSTAT $DIR/${tdir}-1/f attribute check failed"
1382 $CHECKSTAT -t file $DIR/${tdir}-2/f ||
1383 error "$CHECKSTAT $DIR/${tdir}-2/f attribute check failed"
1384 rm -rf $DIR/${tdir}-*
1386 run_test 53f "|X| open reply and close reply while two MDC requests in flight"
1389 cancel_lru_locks mdc # cleanup locks from former test cases
1391 mkdir_on_mdt0 $DIR/${tdir}-1 || error "mkdir $DIR/${tdir}-1 failed"
1392 mkdir_on_mdt0 $DIR/${tdir}-2 || error "mkdir $DIR/${tdir}-2 failed"
1393 multiop $DIR/${tdir}-1/f O_c &
1396 #define OBD_FAIL_MDS_REINT_NET_REP 0x119
1397 do_facet $SINGLEMDS "lctl set_param fail_loc=0x119"
1398 mcreate $DIR/${tdir}-2/f &
1402 #define OBD_FAIL_MDS_CLOSE_NET 0x115
1403 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000115"
1404 kill -USR1 $close_pid
1405 cancel_lru_locks mdc # force the close
1406 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
1408 #bz20647: make sure all pids are exists before failover
1409 [ -d /proc/$close_pid ] || error "close_pid doesn't exist"
1410 [ -d /proc/$open_pid ] || error "open_pid doesn't exists"
1411 replay_barrier_nodf $SINGLEMDS
1412 fail_nodf $SINGLEMDS
1413 wait $open_pid || error "open_pid failed"
1415 # close should be gone
1416 [ -d /proc/$close_pid ] && error "close_pid should not exist"
1418 $CHECKSTAT -t file $DIR/${tdir}-1/f ||
1419 error "$CHECKSTAT $DIR/${tdir}-1/f attribute check failed"
1420 $CHECKSTAT -t file $DIR/${tdir}-2/f ||
1421 error "$CHECKSTAT $DIR/${tdir}-2/f attribute check failed"
1422 rm -rf $DIR/${tdir}-*
1424 run_test 53g "|X| drop open reply and close request while close and open are both in flight"
1427 cancel_lru_locks mdc # cleanup locks from former test cases
1429 mkdir_on_mdt0 $DIR/${tdir}-1 || error "mkdir $DIR/${tdir}-1 failed"
1430 mkdir_on_mdt0 $DIR/${tdir}-2 || error "mkdir $DIR/${tdir}-2 failed"
1431 multiop $DIR/${tdir}-1/f O_c &
1434 #define OBD_FAIL_MDS_REINT_NET 0x107
1435 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000107"
1436 mcreate $DIR/${tdir}-2/f &
1440 #define OBD_FAIL_MDS_CLOSE_NET_REP 0x13b
1441 do_facet $SINGLEMDS "lctl set_param fail_loc=0x8000013b"
1442 kill -USR1 $close_pid
1443 cancel_lru_locks mdc # force the close
1446 #bz20647: make sure all pids are exists before failover
1447 [ -d /proc/$close_pid ] || error "close_pid doesn't exist"
1448 [ -d /proc/$open_pid ] || error "open_pid doesn't exists"
1449 replay_barrier_nodf $SINGLEMDS
1450 fail_nodf $SINGLEMDS
1451 wait $open_pid || error "open_pid failed"
1453 # close should be gone
1454 [ -d /proc/$close_pid ] && error "close_pid should not exist"
1455 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
1457 $CHECKSTAT -t file $DIR/${tdir}-1/f ||
1458 error "$CHECKSTAT $DIR/${tdir}-1/f attribute check failed"
1459 $CHECKSTAT -t file $DIR/${tdir}-2/f ||
1460 error "$CHECKSTAT $DIR/${tdir}-2/f attribute check failed"
1461 rm -rf $DIR/${tdir}-*
1463 run_test 53h "open request and close reply while two MDC requests in flight"
1465 #b3761 ASSERTION(hash != 0) failed
1467 # OBD_FAIL_MDS_OPEN_CREATE | CFS_FAIL_ONCE
1468 do_facet $SINGLEMDS "lctl set_param fail_loc=0x8000012b"
1470 # give touch a chance to run
1472 do_facet $SINGLEMDS "lctl set_param fail_loc=0x0"
1476 run_test 55 "let MDS_CHECK_RESENT return the original return code instead of 0"
1478 #b3440 ASSERTION(rec->ur_fid2->id) failed
1480 ln -s foo $DIR/$tfile
1481 replay_barrier $SINGLEMDS
1482 #drop_reply "cat $DIR/$tfile"
1486 run_test 56 "don't replay a symlink open request (3440)"
1488 #recovery one mds-ost setattr from llog
1490 #define OBD_FAIL_MDS_OST_SETATTR 0x12c
1491 do_facet $SINGLEMDS "lctl set_param fail_loc=0x8000012c"
1492 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
1493 replay_barrier $SINGLEMDS
1495 wait_recovery_complete $SINGLEMDS || error "MDS recovery is not done"
1496 wait_mds_ost_sync || error "wait_mds_ost_sync failed"
1497 $CHECKSTAT -t file $DIR/$tfile ||
1498 error "$CHECKSTAT $DIR/$tfile attribute check failed"
1499 do_facet $SINGLEMDS "lctl set_param fail_loc=0x0"
1502 run_test 57 "test recovery from llog for setattr op"
1505 zconf_umount $(hostname) $MOUNT2
1509 #recovery many mds-ost setattr from llog
1511 mkdir_on_mdt0 $DIR/$tdir || error "mkdir $DIR/$tdir failed"
1512 #define OBD_FAIL_MDS_OST_SETATTR 0x12c
1513 do_facet $SINGLEMDS "lctl set_param fail_loc=0x8000012c"
1514 createmany -o $DIR/$tdir/$tfile-%d 2500
1515 replay_barrier $SINGLEMDS
1518 $CHECKSTAT -t file $DIR/$tdir/$tfile-* >/dev/null ||
1519 error "$CHECKSTAT $DIR/$tfile-* attribute check failed"
1520 do_facet $SINGLEMDS "lctl set_param fail_loc=0x0"
1521 unlinkmany $DIR/$tdir/$tfile-%d 2500 ||
1522 error "unlinkmany $DIR/$tfile failed"
1525 run_test 58a "test recovery from llog for setattr op (test llog_gen_rec)"
1531 trap cleanup_58 EXIT
1533 large_xattr_enabled &&
1534 orig="$(generate_string $(max_xattr_size))" || orig="bar"
1535 # Original extended attribute can be long. Print a small version of
1536 # attribute if an error occurs
1537 local sm_msg=$(printf "%.9s" $orig)
1539 mount_client $MOUNT2 || error "mount_client on $MOUNT2 failed"
1540 mkdir_on_mdt0 $DIR/$tdir || error "mkdir $DIR/$tdir failed"
1541 touch $DIR/$tdir/$tfile || error "touch $DIR/$tdir/$tfile failed"
1542 replay_barrier $SINGLEMDS
1543 setfattr -n trusted.foo -v $orig $DIR/$tdir/$tfile
1545 new=$(get_xattr_value trusted.foo $MOUNT2/$tdir/$tfile)
1546 [[ "$new" = "$orig" ]] ||
1547 error "xattr set ($sm_msg...) differs from xattr get ($new)"
1548 rm -f $DIR/$tdir/$tfile
1551 wait_clients_import_state ${CLIENTS:-$HOSTNAME} "mgs" FULL
1553 run_test 58b "test replay of setxattr op"
1555 test_58c() { # bug 16570
1560 trap cleanup_58 EXIT
1562 if large_xattr_enabled; then
1563 local xattr_size=$(max_xattr_size)
1564 orig="$(generate_string $((xattr_size / 2)))"
1565 orig1="$(generate_string $xattr_size)"
1571 # PING_INTERVAL max(obd_timeout / 4, 1U)
1572 sleep $((TIMEOUT / 4))
1574 # Original extended attribute can be long. Print a small version of
1575 # attribute if an error occurs
1576 local sm_msg=$(printf "%.9s" $orig)
1577 local sm_msg1=$(printf "%.9s" $orig1)
1579 mount_client $MOUNT2 || error "mount_client on $MOUNT2 failed"
1580 mkdir_on_mdt0 $DIR/$tdir || error "mkdir $DIR/$tdir failed"
1581 touch $DIR/$tdir/$tfile || error "touch $DIR/$tdir/$tfile failed"
1582 drop_request "setfattr -n trusted.foo -v $orig $DIR/$tdir/$tfile" ||
1583 error "drop_request for setfattr failed"
1584 new=$(get_xattr_value trusted.foo $MOUNT2/$tdir/$tfile)
1585 [[ "$new" = "$orig" ]] ||
1586 error "xattr set ($sm_msg...) differs from xattr get ($new)"
1587 drop_reint_reply "setfattr -n trusted.foo1 \
1588 -v $orig1 $DIR/$tdir/$tfile" ||
1589 error "drop_reint_reply for setfattr failed"
1590 new=$(get_xattr_value trusted.foo1 $MOUNT2/$tdir/$tfile)
1591 [[ "$new" = "$orig1" ]] ||
1592 error "second xattr set ($sm_msg1...) differs xattr get ($new)"
1593 rm -f $DIR/$tdir/$tfile
1597 run_test 58c "resend/reconstruct setxattr op"
1599 # log_commit_thread vs filter_destroy race used to lead to import use after free
1602 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1604 mkdir_on_mdt0 $DIR/$tdir || error "mkdir $DIR/$tdir failed"
1605 createmany -o $DIR/$tdir/$tfile-%d 200 ||
1606 error "createmany create files failed"
1608 unlinkmany $DIR/$tdir/$tfile-%d 200 ||
1609 error "unlinkmany $DIR/$tdir/$tfile failed"
1610 #define OBD_FAIL_PTLRPC_DELAY_RECOV 0x507
1611 do_facet ost1 "lctl set_param fail_loc=0x507"
1614 do_facet ost1 "lctl set_param fail_loc=0x0"
1618 run_test 59 "test log_commit_thread vs filter_destroy race"
1620 # race between add unlink llog vs cat log init in post_recovery (only for b1_6)
1621 # bug 12086: should no oops and No ctxt error for this test
1623 mkdir_on_mdt0 $DIR/$tdir || error "mkdir $DIR/$tdir failed"
1624 createmany -o $DIR/$tdir/$tfile-%d 200 ||
1625 error "createmany create files failed"
1626 replay_barrier $SINGLEMDS
1627 unlinkmany $DIR/$tdir/$tfile-%d 0 100
1629 unlinkmany $DIR/$tdir/$tfile-%d 100 100
1630 local no_ctxt=$(dmesg | grep "No ctxt")
1631 [ -z "$no_ctxt" ] || error "ctxt is not initialized in recovery"
1633 run_test 60 "test llog post recovery init vs llog unlink"
1635 #test race llog recovery thread vs llog cleanup
1636 test_61a() { # was test_61
1637 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1639 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
1640 createmany -o $DIR/$tdir/$tfile-%d 800 ||
1641 error "createmany create files failed"
1643 unlinkmany $DIR/$tdir/$tfile-%d 800
1644 # OBD_FAIL_OST_LLOG_RECOVERY_TIMEOUT 0x221
1645 set_nodes_failloc "$(osts_nodes)" 0x80000221
1650 set_nodes_failloc "$(osts_nodes)" 0x0
1652 $CHECKSTAT -t file $DIR/$tdir/$tfile-* &&
1653 error "$CHECKSTAT $DIR/$tdir/$tfile attribute check should fail"
1656 run_test 61a "test race llog recovery vs llog cleanup"
1658 #test race mds llog sync vs llog cleanup
1660 # OBD_FAIL_MDS_LLOG_SYNC_TIMEOUT 0x13a
1661 do_facet $SINGLEMDS "lctl set_param fail_loc=0x8000013a"
1662 facet_failover $SINGLEMDS
1665 do_facet client dd if=/dev/zero of=$DIR/$tfile bs=4k count=1 ||
1668 run_test 61b "test race mds llog sync vs llog cleanup"
1670 #test race cancel cookie cb vs llog cleanup
1672 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1674 # OBD_FAIL_OST_CANCEL_COOKIE_TIMEOUT 0x222
1675 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
1676 set_nodes_failloc "$(osts_nodes)" 0x80000222
1680 set_nodes_failloc "$(osts_nodes)" 0x0
1682 run_test 61c "test race mds llog sync vs llog cleanup"
1684 test_61d() { # bug 16002 # bug 17466 # bug 22137
1685 # OBD_FAIL_OBD_LLOG_SETUP 0x605
1687 do_facet mgs "lctl set_param fail_loc=0x80000605"
1688 start mgs $(mgsdevname) $MGS_MOUNT_OPTS &&
1689 error "mgs start should have failed"
1690 do_facet mgs "lctl set_param fail_loc=0"
1691 start mgs $(mgsdevname) $MGS_MOUNT_OPTS || error "cannot restart mgs"
1693 run_test 61d "error in llog_setup should cleanup the llog context correctly"
1695 test_62() { # Bug 15756 - don't mis-drop resent replay
1696 mkdir_on_mdt0 $DIR/$tdir || error "mkdir $DIR/$tdir failed"
1697 replay_barrier $SINGLEMDS
1698 createmany -o $DIR/$tdir/$tfile- 25 ||
1699 error "createmany create files failed"
1700 #define OBD_FAIL_TGT_REPLAY_DROP 0x707
1701 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000707"
1703 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
1704 unlinkmany $DIR/$tdir/$tfile- 25 ||
1705 error "unlinkmany $DIR/$tdir/$tfile failed"
1708 run_test 62 "don't mis-drop resent replay"
1710 #Adaptive Timeouts (bug 3055)
1718 echo "Cleaning up AT ..."
1719 if [ -n "$ATOLDBASE" ]; then
1720 local at_history=$($LCTL get_param -n at_history)
1721 do_facet $SINGLEMDS "lctl set_param at_history=$at_history" || true
1722 do_facet ost1 "lctl set_param at_history=$at_history" || true
1725 if [ $AT_MAX_SET -ne 0 ]; then
1726 for facet in mds client ost; do
1727 var=AT_MAX_SAVE_${facet}
1728 echo restore AT on $facet to saved value ${!var}
1729 at_max_set ${!var} $facet
1730 at_new=$(at_max_get $facet)
1731 echo Restored AT value on $facet $at_new
1732 [ $at_new -eq ${!var} ] ||
1733 error "AT value not restored SAVED ${!var} NEW $at_new"
1740 local at_max_new=600
1742 # Save at_max original values
1744 if [ $AT_MAX_SET -eq 0 ]; then
1745 # Suppose that all osts have the same at_max
1746 for facet in mds client ost; do
1747 eval AT_MAX_SAVE_${facet}=$(at_max_get $facet)
1751 for facet in mds client ost; do
1752 at_max=$(at_max_get $facet)
1753 if [ $at_max -ne $at_max_new ]; then
1754 echo "AT value on $facet is $at_max, set it by force temporarily to $at_max_new"
1755 at_max_set $at_max_new $facet
1760 if [ -z "$ATOLDBASE" ]; then
1761 ATOLDBASE=$(do_facet $SINGLEMDS "lctl get_param -n at_history")
1762 # speed up the timebase so we can check decreasing AT
1763 do_facet $SINGLEMDS "lctl set_param at_history=8" || true
1764 do_facet ost1 "lctl set_param at_history=8" || true
1766 # sleep for a while to cool down, should be > 8s and also allow
1767 # at least one ping to be sent. simply use TIMEOUT to be safe.
1772 test_65a() #bug 3055
1774 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1776 at_start || return 0
1777 $LCTL dk > /dev/null
1779 $LCTL set_param debug="other"
1780 # Slow down a request to the current service time, this is critical
1781 # because previous tests may have caused this value to increase.
1782 REQ_DELAY=`lctl get_param -n mdc.${FSNAME}-MDT0000-mdc-*.timeouts |
1783 awk '/portal 12/ {print $5}'`
1784 REQ_DELAY=$((${REQ_DELAY} + ${REQ_DELAY} / 4 + 5))
1786 do_facet $SINGLEMDS lctl set_param fail_val=$((${REQ_DELAY} * 1000))
1787 #define OBD_FAIL_PTLRPC_PAUSE_REQ 0x50a
1788 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x8000050a
1789 createmany -o $DIR/$tfile 10 > /dev/null
1790 unlinkmany $DIR/$tfile 10 > /dev/null
1791 # check for log message
1792 $LCTL dk | grep -i "Early reply #" || error "No early reply"
1794 # client should show REQ_DELAY estimates
1795 lctl get_param -n mdc.${FSNAME}-MDT0000-mdc-*.timeouts | grep portal
1797 lctl get_param -n mdc.${FSNAME}-MDT0000-mdc-*.timeouts | grep portal
1799 run_test 65a "AT: verify early replies"
1801 test_65b() #bug 3055
1803 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1805 at_start || return 0
1808 $LCTL set_param debug="other trace"
1809 $LCTL dk > /dev/null
1810 # Slow down a request to the current service time, this is critical
1811 # because previous tests may have caused this value to increase.
1812 $LFS setstripe --stripe-index=0 --stripe-count=1 $DIR/$tfile ||
1813 error "$LFS setstripe failed for $DIR/$tfile"
1815 multiop $DIR/$tfile Ow1yc
1816 REQ_DELAY=`lctl get_param -n osc.${FSNAME}-OST0000-osc-*.timeouts |
1817 awk '/portal 6/ {print $5}'`
1818 REQ_DELAY=$((${REQ_DELAY} + ${REQ_DELAY} / 4 + 5))
1820 do_facet ost1 lctl set_param fail_val=${REQ_DELAY}
1821 #define OBD_FAIL_OST_BRW_PAUSE_PACK 0x224
1822 do_facet ost1 $LCTL set_param fail_loc=0x224
1825 $LFS setstripe --stripe-index=0 --stripe-count=1 $DIR/$tfile ||
1826 error "$LFS setstripe failed"
1827 # force some real bulk transfer
1828 multiop $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
1830 do_facet ost1 $LCTL set_param fail_loc=0
1831 # check for log message
1832 $LCTL dk | grep -i "Early reply #" || error "No early reply"
1834 # client should show REQ_DELAY estimates
1835 lctl get_param -n osc.${FSNAME}-OST0000-osc-*.timeouts | grep portal
1837 run_test 65b "AT: verify early replies on packed reply / bulk"
1839 test_66a() #bug 3055
1841 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1843 at_start || return 0
1844 lctl get_param -n mdc.${FSNAME}-MDT0000-mdc-*.timeouts | grep "portal 12"
1845 # adjust 5s at a time so no early reply is sent (within deadline)
1846 do_facet $SINGLEMDS "$LCTL set_param fail_val=5000"
1847 #define OBD_FAIL_PTLRPC_PAUSE_REQ 0x50a
1848 do_facet $SINGLEMDS "$LCTL set_param fail_loc=0x8000050a"
1849 createmany -o $DIR/$tfile 20 > /dev/null
1850 unlinkmany $DIR/$tfile 20 > /dev/null
1851 lctl get_param -n mdc.${FSNAME}-MDT0000-mdc-*.timeouts | grep "portal 12"
1852 do_facet $SINGLEMDS "$LCTL set_param fail_val=10000"
1853 do_facet $SINGLEMDS "$LCTL set_param fail_loc=0x8000050a"
1854 createmany -o $DIR/$tfile 20 > /dev/null
1855 unlinkmany $DIR/$tfile 20 > /dev/null
1856 lctl get_param -n mdc.${FSNAME}-MDT0000-mdc-*.timeouts | grep "portal 12"
1857 do_facet $SINGLEMDS "$LCTL set_param fail_loc=0"
1859 createmany -o $DIR/$tfile 20 > /dev/null
1860 unlinkmany $DIR/$tfile 20 > /dev/null
1861 lctl get_param -n mdc.${FSNAME}-MDT0000-mdc-*.timeouts | grep "portal 12"
1862 CUR=$(lctl get_param -n mdc.${FSNAME}-MDT0000-mdc-*.timeouts | awk '/portal 12/ {print $5}')
1863 WORST=$(lctl get_param -n mdc.${FSNAME}-MDT0000-mdc-*.timeouts | awk '/portal 12/ {print $7}')
1864 echo "Current MDT timeout $CUR, worst $WORST"
1865 [ $CUR -lt $WORST ] || error "Current $CUR should be less than worst $WORST"
1867 run_test 66a "AT: verify MDT service time adjusts with no early replies"
1869 test_66b() #bug 3055
1871 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1873 at_start || return 0
1874 ORIG=$(lctl get_param -n mdc.${FSNAME}-MDT0000*.timeouts |
1875 awk '/network/ {print $4}')
1876 $LCTL set_param fail_val=$(($ORIG + 5))
1877 #define OBD_FAIL_PTLRPC_PAUSE_REP 0x50c
1878 $LCTL set_param fail_loc=0x50c
1879 touch $DIR/$tfile > /dev/null 2>&1
1880 $LCTL set_param fail_loc=0
1881 CUR=$(lctl get_param -n mdc.${FSNAME}-MDT0000*.timeouts |
1882 awk '/network/ {print $4}')
1883 WORST=$(lctl get_param -n mdc.${FSNAME}-MDT0000*.timeouts |
1884 awk '/network/ {print $6}')
1885 echo "network timeout orig $ORIG, cur $CUR, worst $WORST"
1886 [ $WORST -gt $ORIG ] ||
1887 error "Worst $WORST should be worse than orig $ORIG"
1889 run_test 66b "AT: verify net latency adjusts"
1891 test_67a() #bug 3055
1893 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1895 at_start || return 0
1896 CONN1=$(lctl get_param -n osc.*.stats | awk '/_connect/ {total+=$2} END {print total}')
1897 # sleeping threads may drive values above this
1898 do_facet ost1 "$LCTL set_param fail_val=400"
1899 #define OBD_FAIL_PTLRPC_PAUSE_REQ 0x50a
1900 do_facet ost1 "$LCTL set_param fail_loc=0x50a"
1901 createmany -o $DIR/$tfile 20 > /dev/null
1902 unlinkmany $DIR/$tfile 20 > /dev/null
1903 do_facet ost1 "$LCTL set_param fail_loc=0"
1904 CONN2=$(lctl get_param -n osc.*.stats | awk '/_connect/ {total+=$2} END {print total}')
1905 ATTEMPTS=$(($CONN2 - $CONN1))
1906 echo "$ATTEMPTS osc reconnect attempts on gradual slow"
1907 [ $ATTEMPTS -gt 0 ] &&
1908 error_ignore bz13721 "AT should have prevented reconnect"
1911 run_test 67a "AT: verify slow request processing doesn't induce reconnects"
1913 test_67b() #bug 3055
1915 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1917 at_start || return 0
1918 CONN1=$(lctl get_param -n osc.*.stats | awk '/_connect/ {total+=$2} END {print total}')
1920 # exhaust precreations on ost1
1921 local OST=$(ostname_from_index 0)
1922 local mdtosc=$(get_mdtosc_proc_path mds $OST)
1923 local last_id=$(do_facet $SINGLEMDS lctl get_param -n \
1924 osp.$mdtosc.prealloc_last_id)
1925 local next_id=$(do_facet $SINGLEMDS lctl get_param -n \
1926 osp.$mdtosc.prealloc_next_id)
1928 mkdir -p $DIR/$tdir/${OST} || error "mkdir $DIR/$tdir/${OST} failed"
1929 $LFS setstripe -i 0 -c 1 $DIR/$tdir/${OST} ||
1930 error "$LFS setstripe failed"
1931 echo "Creating to objid $last_id on ost $OST..."
1932 #define OBD_FAIL_OST_PAUSE_CREATE 0x223
1933 do_facet ost1 "$LCTL set_param fail_val=20000"
1934 do_facet ost1 "$LCTL set_param fail_loc=0x80000223"
1935 createmany -o $DIR/$tdir/${OST}/f $next_id $((last_id - next_id + 2))
1938 do_facet ost1 "lctl get_param -n ost.OSS.ost_create.timeouts"
1940 CONN2=$(lctl get_param -n osc.*.stats | awk '/_connect/ {total+=$2} END {print total}')
1941 ATTEMPTS=$(($CONN2 - $CONN1))
1942 echo "$ATTEMPTS osc reconnect attempts on instant slow"
1943 # do it again; should not timeout
1944 do_facet ost1 "$LCTL set_param fail_loc=0x80000223"
1945 cp /etc/profile $DIR/$tfile || error "cp failed"
1946 do_facet ost1 "$LCTL set_param fail_loc=0"
1948 do_facet ost1 "lctl get_param -n ost.OSS.ost_create.timeouts"
1949 CONN3=$(lctl get_param -n osc.*.stats | awk '/_connect/ {total+=$2} END {print total}')
1950 ATTEMPTS=$(($CONN3 - $CONN2))
1951 echo "$ATTEMPTS osc reconnect attempts on 2nd slow"
1952 [ $ATTEMPTS -gt 0 ] && error "AT should have prevented reconnect"
1955 run_test 67b "AT: verify instant slowdown doesn't induce reconnects"
1957 test_68 () #bug 13813
1959 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1961 at_start || return 0
1962 local ldlm_enqueue_min=$(find /sys -name ldlm_enqueue_min)
1963 [ -z "$ldlm_enqueue_min" ] && skip "missing /sys/.../ldlm_enqueue_min" && return 0
1964 local ldlm_enqueue_min_r=$(do_facet ost1 "find /sys -name ldlm_enqueue_min")
1965 [ -z "$ldlm_enqueue_min_r" ] && skip "missing /sys/.../ldlm_enqueue_min in the ost1" && return 0
1966 local ENQ_MIN=$(cat $ldlm_enqueue_min)
1967 local ENQ_MIN_R=$(do_facet ost1 "cat $ldlm_enqueue_min_r")
1968 echo $TIMEOUT >> $ldlm_enqueue_min
1969 do_facet ost1 "echo $TIMEOUT >> $ldlm_enqueue_min_r"
1971 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
1972 $LFS setstripe --stripe-index=0 -c 1 $DIR/$tdir ||
1973 error "$LFS setstripe failed for $DIR/$tdir"
1974 #define OBD_FAIL_LDLM_PAUSE_CANCEL 0x312
1975 $LCTL set_param fail_val=$(($TIMEOUT - 1))
1976 $LCTL set_param fail_loc=0x80000312
1977 cp /etc/profile $DIR/$tdir/${tfile}_1 || error "1st cp failed $?"
1978 $LCTL set_param fail_val=$((TIMEOUT * 5 / 4))
1979 $LCTL set_param fail_loc=0x80000312
1980 cp /etc/profile $DIR/$tdir/${tfile}_2 || error "2nd cp failed $?"
1981 $LCTL set_param fail_loc=0
1983 echo $ENQ_MIN >> $ldlm_enqueue_min
1984 do_facet ost1 "echo $ENQ_MIN_R >> $ldlm_enqueue_min_r"
1988 run_test 68 "AT: verify slowing locks"
1991 # end of AT tests includes above lines
1993 # start multi-client tests
1995 [ $CLIENTCOUNT -lt 2 ] &&
1996 { skip "Need two or more clients, have $CLIENTCOUNT" && return; }
1998 echo "mount clients $CLIENTS ..."
1999 zconf_mount_clients $CLIENTS $MOUNT
2001 local clients=${CLIENTS//,/ }
2002 echo "Write/read files on $DIR ; clients $CLIENTS ... "
2003 for CLIENT in $clients; do
2004 do_node $CLIENT dd bs=1M count=10 if=/dev/zero \
2005 of=$DIR/${tfile}_${CLIENT} 2>/dev/null ||
2006 error "dd failed on $CLIENT"
2009 local prev_client=$(echo $clients | sed 's/^.* \(.\+\)$/\1/')
2010 for C in ${CLIENTS//,/ }; do
2011 do_node $prev_client dd if=$DIR/${tfile}_${C} \
2012 of=/dev/null 2>/dev/null ||
2013 error "dd if=$DIR/${tfile}_${C} failed on $prev_client"
2019 run_test 70a "check multi client t-f"
2021 check_for_process () {
2026 killall_process $clients "$prog" -0
2030 local clients=${CLIENTS:-$HOSTNAME}
2032 zconf_mount_clients $clients $MOUNT
2035 [ "$SLOW" = "no" ] && duration=120
2036 # set duration to 900 because it takes some time to boot node
2037 [ "$FAILURE_MODE" = HARD ] && duration=900
2040 local start_ts=$(date +%s)
2041 local cmd="rundbench 1 -t $duration"
2043 if [ $MDSCOUNT -ge 2 ]; then
2044 test_mkdir -p -c$MDSCOUNT $DIR/$tdir
2045 $LFS setdirstripe -D -c$MDSCOUNT $DIR/$tdir
2047 do_nodesv $clients "set -x; MISSING_DBENCH_OK=$MISSING_DBENCH_OK \
2048 PATH=\$PATH:$LUSTRE/utils:$LUSTRE/tests/:$DBENCH_LIB \
2049 DBENCH_LIB=$DBENCH_LIB TESTSUITE=$TESTSUITE TESTNAME=$TESTNAME \
2050 MOUNT=$MOUNT DIR=$DIR/$tdir/\\\$(hostname) LCTL=$LCTL $cmd" &
2053 #LU-1897 wait for all dbench copies to start
2054 while ! check_for_process $clients dbench; do
2055 elapsed=$(($(date +%s) - start_ts))
2056 if [ $elapsed -gt $duration ]; then
2057 killall_process $clients dbench
2058 error "dbench failed to start on $clients!"
2063 log "Started rundbench load pid=$pid ..."
2065 elapsed=$(($(date +%s) - start_ts))
2066 local num_failovers=0
2068 while [ $elapsed -lt $duration ]; do
2069 if ! check_for_process $clients dbench; then
2070 error_noexit "dbench stopped on some of $clients!"
2071 killall_process $clients dbench
2075 replay_barrier mds$fail_index
2076 sleep 1 # give clients a time to do operations
2077 # Increment the number of failovers
2078 num_failovers=$((num_failovers+1))
2079 log "$TESTNAME fail mds$fail_index $num_failovers times"
2081 elapsed=$(($(date +%s) - start_ts))
2082 if [ $fail_index -ge $MDSCOUNT ]; then
2085 fail_index=$((fail_index+1))
2089 wait $pid || error "rundbench load on $clients failed!"
2091 run_test 70b "dbench ${MDSCOUNT}mdts recovery; $CLIENTCOUNT clients"
2092 # end multi-client tests
2097 local monitor_pid=$3
2099 local start_ts=$(date +%s)
2100 local num_failovers=0
2103 elapsed=$(($(date +%s) - start_ts))
2104 while [ $elapsed -lt $duration ]; do
2105 fail_index=$((RANDOM%max_index+1))
2106 kill -0 $monitor_pid ||
2107 error "$monitor_pid stopped"
2109 replay_barrier mds$fail_index
2111 # Increment the number of failovers
2112 num_failovers=$((num_failovers+1))
2113 log "$TESTNAME fail mds$fail_index $num_failovers times"
2115 elapsed=$(($(date +%s) - start_ts))
2121 rm -f $DIR/replay-single.70c.lck
2126 local clients=${CLIENTS:-$HOSTNAME}
2129 zconf_mount_clients $clients $MOUNT
2132 [ "$SLOW" = "no" ] && duration=180
2133 # set duration to 900 because it takes some time to boot node
2134 [ "$FAILURE_MODE" = HARD ] && duration=600
2137 local start_ts=$(date +%s)
2139 stack_trap cleanup_70c EXIT
2141 while [ ! -e $DIR/replay-single.70c.lck ]; do
2142 test_mkdir -p -c$MDSCOUNT $DIR/$tdir || break
2143 if [ $MDSCOUNT -ge 2 ]; then
2144 $LFS setdirstripe -D -c$MDSCOUNT $DIR/$tdir ||
2145 error "set default dirstripe failed"
2147 cd $DIR/$tdir || break
2148 tar cf - /etc | tar xf - || error "tar failed in loop"
2152 echo "Started tar $tar_70c_pid"
2154 random_fail_mdt $MDSCOUNT $duration $tar_70c_pid
2155 kill -0 $tar_70c_pid || error "tar $tar_70c_pid stopped"
2157 touch $DIR/replay-single.70c.lck
2158 wait $tar_70c_pid || error "$?: tar failed"
2163 run_test 70c "tar ${MDSCOUNT}mdts recovery"
2167 kill -9 $mkdir_70d_pid
2171 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2172 local clients=${CLIENTS:-$HOSTNAME}
2175 zconf_mount_clients $clients $MOUNT
2178 [ "$SLOW" = "no" ] && duration=180
2179 # set duration to 900 because it takes some time to boot node
2180 [ "$FAILURE_MODE" = HARD ] && duration=900
2185 local start_ts=$(date +%s)
2187 trap cleanup_70d EXIT
2190 $LFS mkdir -i0 -c2 $DIR/$tdir/test || {
2194 $LFS mkdir -i1 -c2 $DIR/$tdir/test1 || {
2199 touch $DIR/$tdir/test/a || {
2203 mkdir $DIR/$tdir/test/b || {
2207 rm -rf $DIR/$tdir/test || {
2213 touch $DIR/$tdir/test1/a || {
2217 mkdir $DIR/$tdir/test1/b || {
2222 rm -rf $DIR/$tdir/test1 || {
2224 ls -lR $DIR/$tdir/test1
2230 echo "Started $mkdir_70d_pid"
2232 random_fail_mdt $MDSCOUNT $duration $mkdir_70d_pid
2233 kill -0 $mkdir_70d_pid || error "mkdir/rmdir $mkdir_70d_pid stopped"
2238 run_test 70d "mkdir/rmdir striped dir ${MDSCOUNT}mdts recovery"
2241 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2242 local clients=${CLIENTS:-$HOSTNAME}
2245 lctl set_param debug=+ha
2246 zconf_mount_clients $clients $MOUNT
2249 [ "$SLOW" = "no" ] && duration=180
2250 # set duration to 900 because it takes some time to boot node
2251 [ "$FAILURE_MODE" = HARD ] && duration=900
2254 $LFS mkdir -i0 $DIR/$tdir/test_0
2255 $LFS mkdir -i0 $DIR/$tdir/test_1
2256 touch $DIR/$tdir/test_0/a
2257 touch $DIR/$tdir/test_1/b
2260 mrename $DIR/$tdir/test_0/a $DIR/$tdir/test_1/b > /dev/null || {
2265 checkstat $DIR/$tdir/test_0/a && {
2266 echo "a still exists"
2270 checkstat $DIR/$tdir/test_1/b || {
2271 echo "b still exists"
2275 touch $DIR/$tdir/test_0/a || {
2276 echo "touch a fails"
2280 mrename $DIR/$tdir/test_1/b $DIR/$tdir/test_0/a > /dev/null || {
2287 stack_trap "kill -9 $rename_70e_pid" EXIT
2288 echo "Started PID=$rename_70e_pid"
2290 random_fail_mdt 2 $duration $rename_70e_pid
2291 kill -0 $rename_70e_pid || error "rename $rename_70e_pid stopped"
2293 run_test 70e "rename cross-MDT with random fails"
2295 test_70f_write_and_read(){
2300 echo "Write/read files in: '$DIR/$tdir', clients: '$CLIENTS' ..."
2301 for client in ${CLIENTS//,/ }; do
2302 [ -f $stopflag ] || return
2304 local tgtfile=$DIR/$tdir/$tfile.$client
2305 do_node $client dd $DD_OPTS bs=1M count=10 if=$srcfile \
2306 of=$tgtfile 2>/dev/null ||
2307 error "dd $DD_OPTS bs=1M count=10 if=$srcfile " \
2308 "of=$tgtfile failed on $client, rc=$?"
2311 local prev_client=$(echo ${CLIENTS//,/ } | awk '{ print $NF }')
2314 for client in ${CLIENTS//,/ }; do
2315 [ -f $stopflag ] || return
2317 # flush client cache in case test is running on only one client
2318 # do_node $client cancel_lru_locks osc
2319 do_node $client $LCTL set_param ldlm.namespaces.*.lru_size=clear
2321 tgtfile=$DIR/$tdir/$tfile.$client
2322 local md5=$(do_node $prev_client "md5sum $tgtfile")
2323 [ ${checksum[$index]// */} = ${md5// */} ] ||
2324 error "$tgtfile: checksum doesn't match on $prev_client"
2325 index=$((index + 1))
2335 mkdir -p $DIR/$tdir || error "cannot create $DIR/$tdir directory"
2336 $LFS setstripe -c -1 $DIR/$tdir ||
2337 error "cannot $LFS setstripe $DIR/$tdir"
2340 while [ -f $stopflag ]; do
2341 test_70f_write_and_read $srcfile $stopflag
2342 # use direct IO and buffer cache in turns if loop
2343 [ -n "$DD_OPTS" ] && DD_OPTS="" || DD_OPTS="oflag=direct"
2347 test_70f_cleanup() {
2349 rm -f $TMP/$tfile.stop
2350 do_nodes $CLIENTS rm -f $TMP/$tfile
2351 rm -f $DIR/$tdir/$tfile.*
2355 # [ x$ost1failover_HOST = x$ost_HOST ] &&
2356 # { skip "Failover host not defined" && return; }
2357 # [ $CLIENTCOUNT -lt 2 ] &&
2358 # { skip "Need 2 or more clients, have $CLIENTCOUNT" && return; }
2360 [[ "$OST1_VERSION" -lt $(version_code 2.9.53) ]] &&
2361 skip "Need server version at least 2.9.53"
2363 echo "mount clients $CLIENTS ..."
2364 zconf_mount_clients $CLIENTS $MOUNT
2366 local srcfile=$TMP/$tfile
2370 trap test_70f_cleanup EXIT
2371 # create a different source file local to each client node so we can
2372 # detect if the file wasn't written out properly after failover
2373 do_nodes $CLIENTS dd bs=1M count=10 if=/dev/urandom of=$srcfile \
2374 2>/dev/null || error "can't create $srcfile on $CLIENTS"
2375 for client in ${CLIENTS//,/ }; do
2376 checksum[$index]=$(do_node $client "md5sum $srcfile")
2377 index=$((index + 1))
2381 [ "$SLOW" = "no" ] && duration=60
2382 # set duration to 900 because it takes some time to boot node
2383 [ "$FAILURE_MODE" = HARD ] && duration=900
2385 local stopflag=$TMP/$tfile.stop
2386 test_70f_loop $srcfile $stopflag &
2390 local num_failovers=0
2391 local start_ts=$SECONDS
2392 while [ $elapsed -lt $duration ]; do
2396 num_failovers=$((num_failovers + 1))
2397 log "$TESTNAME failing OST $num_failovers times"
2400 elapsed=$((SECONDS - start_ts))
2407 run_test 70f "OSS O_DIRECT recovery with $CLIENTCOUNT clients"
2411 kill -9 $mkdir_71a_pid
2414 random_double_fail_mdt() {
2417 local monitor_pid=$3
2419 local start_ts=$(date +%s)
2420 local num_failovers=0
2424 elapsed=$(($(date +%s) - start_ts))
2425 while [ $elapsed -lt $duration ]; do
2426 fail_index=$((RANDOM%max_index + 1))
2427 if [ $fail_index -eq $max_index ]; then
2430 second_index=$((fail_index + 1))
2432 kill -0 $monitor_pid ||
2433 error "$monitor_pid stopped"
2435 replay_barrier mds$fail_index
2436 replay_barrier mds$second_index
2438 # Increment the number of failovers
2439 num_failovers=$((num_failovers+1))
2440 log "fail mds$fail_index mds$second_index $num_failovers times"
2441 fail mds${fail_index},mds${second_index}
2442 elapsed=$(($(date +%s) - start_ts))
2447 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2448 local clients=${CLIENTS:-$HOSTNAME}
2451 zconf_mount_clients $clients $MOUNT
2454 [ "$SLOW" = "no" ] && duration=180
2455 # set duration to 900 because it takes some time to boot node
2456 [ "$FAILURE_MODE" = HARD ] && duration=900
2458 mkdir_on_mdt0 $DIR/$tdir
2461 local start_ts=$(date +%s)
2463 trap cleanup_71a EXIT
2466 $LFS mkdir -i0 -c2 $DIR/$tdir/test
2467 rmdir $DIR/$tdir/test
2471 echo "Started $mkdir_71a_pid"
2473 random_double_fail_mdt 2 $duration $mkdir_71a_pid
2474 kill -0 $mkdir_71a_pid || error "mkdir/rmdir $mkdir_71a_pid stopped"
2479 run_test 71a "mkdir/rmdir striped dir with 2 mdts recovery"
2482 multiop_bg_pause $DIR/$tfile O_tSc ||
2483 error "multiop_bg_pause $DIR/$tfile failed"
2487 replay_barrier $SINGLEMDS
2488 #define OBD_FAIL_LDLM_ENQUEUE_NET 0x302
2489 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000302"
2492 wait $pid || error "multiop pid failed"
2493 [ -e $DIR/$tfile ] && error "file $DIR/$tfile should not exist"
2496 run_test 73a "open(O_CREAT), unlink, replay, reconnect before open replay, close"
2499 multiop_bg_pause $DIR/$tfile O_tSc ||
2500 error "multiop_bg_pause $DIR/$tfile failed"
2504 replay_barrier $SINGLEMDS
2505 #define OBD_FAIL_MDS_LDLM_REPLY_NET 0x157
2506 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000157"
2509 wait $pid || error "multiop pid failed"
2510 [ -e $DIR/$tfile ] && error "file $DIR/$tfile should not exist"
2513 run_test 73b "open(O_CREAT), unlink, replay, reconnect at open_replay reply, close"
2517 local clients=${CLIENTS:-$HOSTNAME}
2519 zconf_umount_clients $clients $MOUNT
2521 facet_failover $SINGLEMDS
2522 zconf_mount_clients $clients $MOUNT
2524 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
2525 rm $DIR/$tfile || error "rm $DIR/$tfile failed"
2526 clients_up || error "client evicted: $?"
2529 run_test 74 "Ensure applications don't fail waiting for OST recovery"
2531 remote_dir_check_80() {
2536 diridx=$($LFS getstripe -m $remote_dir) ||
2537 error "$LFS getstripe -m $remote_dir failed"
2538 [ $diridx -eq $mdtidx ] || error "$diridx != $mdtidx"
2540 createmany -o $remote_dir/f-%d 20 || error "creation failed"
2541 fileidx=$($LFS getstripe -m $remote_dir/f-1) ||
2542 error "$LFS getstripe -m $remote_dir/f-1 failed"
2543 [ $fileidx -eq $mdtidx ] || error "$fileidx != $mdtidx"
2549 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2550 ([ $FAILURE_MODE == "HARD" ] &&
2551 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
2552 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
2556 local remote_dir=$DIR/$tdir/remote_dir
2558 mkdir_on_mdt0 $DIR/$tdir || error "mkdir $DIR/$tdir failed"
2559 #define OBD_FAIL_OUT_UPDATE_NET_REP 0x1701
2560 do_facet mds${MDTIDX} lctl set_param fail_loc=0x1701
2561 $LFS mkdir -i $MDTIDX $remote_dir &
2567 wait $CLIENT_PID || error "remote creation failed"
2569 remote_dir_check_80 || error "remote dir check failed"
2570 rm -rf $DIR/$tdir || error "rmdir failed"
2574 run_test 80a "DNE: create remote dir, drop update rep from MDT0, fail MDT0"
2577 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2578 ([ $FAILURE_MODE == "HARD" ] &&
2579 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
2580 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
2584 local remote_dir=$DIR/$tdir/remote_dir
2586 mkdir_on_mdt0 $DIR/$tdir || error "mkdir $DIR/$tdir failed"
2587 #define OBD_FAIL_OUT_UPDATE_NET_REP 0x1701
2588 do_facet mds${MDTIDX} lctl set_param fail_loc=0x1701
2589 $LFS mkdir -i $MDTIDX $remote_dir &
2594 fail mds$((MDTIDX + 1))
2596 wait $CLIENT_PID || error "remote creation failed"
2598 remote_dir_check_80 || error "remote dir check failed"
2599 rm -rf $DIR/$tdir || error "rmdir failed"
2603 run_test 80b "DNE: create remote dir, drop update rep from MDT0, fail MDT1"
2606 [[ "$mds1_FSTYPE" = zfs ]] &&
2607 [[ $MDS1_VERSION -lt $(version_code 2.12.51) ]] &&
2608 skip "requires LU-10143 fix on MDS"
2609 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
2610 ([ $FAILURE_MODE == "HARD" ] &&
2611 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
2612 skip "MDTs needs to be on diff hosts for HARD fail mode"
2615 local remote_dir=$DIR/$tdir/remote_dir
2617 mkdir_on_mdt0 $DIR/$tdir || error "mkdir $DIR/$tdir failed"
2618 #define OBD_FAIL_OUT_UPDATE_NET_REP 0x1701
2619 do_facet mds${MDTIDX} lctl set_param fail_loc=0x1701
2620 $LFS mkdir -i $MDTIDX $remote_dir &
2626 fail mds$((MDTIDX + 1))
2628 wait $CLIENT_PID || error "remote creation failed"
2630 remote_dir_check_80 || error "remote dir check failed"
2631 rm -rf $DIR/$tdir || error "rmdir failed"
2635 run_test 80c "DNE: create remote dir, drop update rep from MDT1, fail MDT[0,1]"
2638 [[ "$mds1_FSTYPE" = zfs ]] &&
2639 [[ $MDS1_VERSION -lt $(version_code 2.12.51) ]] &&
2640 skip "requires LU-10143 fix on MDS"
2641 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
2643 local remote_dir=$DIR/$tdir/remote_dir
2645 mkdir_on_mdt0 $DIR/$tdir || error "mkdir $DIR/$tdir failed"
2646 #define OBD_FAIL_OUT_UPDATE_NET_REP 0x1701
2647 do_facet mds${MDTIDX} lctl set_param fail_loc=0x1701
2648 $LFS mkdir -i $MDTIDX $remote_dir &
2651 # sleep 3 seconds to make sure MDTs are failed after
2652 # lfs mkdir -i has finished on all of MDTs.
2657 fail mds${MDTIDX},mds$((MDTIDX + 1))
2659 wait $CLIENT_PID || error "remote creation failed"
2661 remote_dir_check_80 || error "remote dir check failed"
2662 rm -rf $DIR/$tdir || error "rmdir failed"
2666 run_test 80d "DNE: create remote dir, drop update rep from MDT1, fail 2 MDTs"
2669 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2670 ([ $FAILURE_MODE == "HARD" ] &&
2671 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
2672 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
2676 local remote_dir=$DIR/$tdir/remote_dir
2678 mkdir_on_mdt0 $DIR/$tdir || error "mkdir $DIR/$tdir failed"
2679 # OBD_FAIL_MDS_REINT_NET_REP 0x119
2680 do_facet mds$((MDTIDX + 1)) lctl set_param fail_loc=0x119
2681 $LFS mkdir -i $MDTIDX $remote_dir &
2684 # sleep 3 seconds to make sure MDTs are failed after
2685 # lfs mkdir -i has finished on all of MDTs.
2691 wait $CLIENT_PID || error "remote creation failed"
2693 remote_dir_check_80 || error "remote dir check failed"
2694 rm -rf $DIR/$tdir || error "rmdir failed"
2698 run_test 80e "DNE: create remote dir, drop MDT1 rep, fail MDT0"
2701 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2702 ([ $FAILURE_MODE == "HARD" ] &&
2703 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
2704 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
2707 local remote_dir=$DIR/$tdir/remote_dir
2709 mkdir_on_mdt0 $DIR/$tdir || error "mkdir $DIR/$tdir failed"
2710 # OBD_FAIL_MDS_REINT_NET_REP 0x119
2711 do_facet mds$((MDTIDX + 1)) lctl set_param fail_loc=0x119
2712 $LFS mkdir -i $MDTIDX $remote_dir &
2716 fail mds$((MDTIDX + 1))
2718 wait $CLIENT_PID || error "remote creation failed"
2720 remote_dir_check_80 || error "remote dir check failed"
2721 rm -rf $DIR/$tdir || error "rmdir failed"
2725 run_test 80f "DNE: create remote dir, drop MDT1 rep, fail MDT1"
2728 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2729 ([ $FAILURE_MODE == "HARD" ] &&
2730 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
2731 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
2735 local remote_dir=$DIR/$tdir/remote_dir
2737 mkdir_on_mdt0 $DIR/$tdir || error "mkdir $DIR/$tdir failed"
2738 # OBD_FAIL_MDS_REINT_NET_REP 0x119
2739 do_facet mds$((MDTIDX + 1)) lctl set_param fail_loc=0x119
2740 $LFS mkdir -i $MDTIDX $remote_dir &
2743 # sleep 3 seconds to make sure MDTs are failed after
2744 # lfs mkdir -i has finished on all of MDTs.
2750 fail mds$((MDTIDX + 1))
2752 wait $CLIENT_PID || error "remote creation failed"
2754 remote_dir_check_80 || error "remote dir check failed"
2755 rm -rf $DIR/$tdir || error "rmdir failed"
2759 run_test 80g "DNE: create remote dir, drop MDT1 rep, fail MDT0, then MDT1"
2762 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2764 local remote_dir=$DIR/$tdir/remote_dir
2766 mkdir_on_mdt0 $DIR/$tdir || error "mkdir $DIR/$tdir failed"
2767 # OBD_FAIL_MDS_REINT_NET_REP 0x119
2768 do_facet mds$((MDTIDX + 1)) lctl set_param fail_loc=0x119
2769 $LFS mkdir -i $MDTIDX $remote_dir &
2772 # sleep 3 seconds to make sure MDTs are failed after
2773 # lfs mkdir -i has finished on all of MDTs.
2778 fail mds${MDTIDX},mds$((MDTIDX + 1))
2780 wait $CLIENT_PID || error "remote dir creation failed"
2782 remote_dir_check_80 || error "remote dir check failed"
2783 rm -rf $DIR/$tdir || error "rmdir failed"
2787 run_test 80h "DNE: create remote dir, drop MDT1 rep, fail 2 MDTs"
2790 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2791 ([ $FAILURE_MODE == "HARD" ] &&
2792 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
2793 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
2797 local remote_dir=$DIR/$tdir/remote_dir
2799 mkdir_on_mdt0 $DIR/$tdir || error "mkdir $DIR/$tdir failed"
2800 $LFS mkdir -i $MDTIDX $remote_dir || error "lfs mkdir failed"
2802 touch $remote_dir || error "touch $remote_dir failed"
2803 # OBD_FAIL_OUT_UPDATE_NET_REP 0x1701
2804 do_facet mds${MDTIDX} lctl set_param fail_loc=0x1701
2809 fail mds$((MDTIDX + 1))
2811 wait $CLIENT_PID || error "rm remote dir failed"
2813 stat $remote_dir &>/dev/null && error "$remote_dir still exist!"
2815 rm -rf $DIR/$tdir || error "rmdir failed"
2819 run_test 81a "DNE: unlink remote dir, drop MDT0 update rep, fail MDT1"
2822 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2823 ([ $FAILURE_MODE == "HARD" ] &&
2824 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
2825 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
2828 local remote_dir=$DIR/$tdir/remote_dir
2830 mkdir_on_mdt0 $DIR/$tdir || error "mkdir $DIR/$tdir failed"
2831 $LFS mkdir -i $MDTIDX $remote_dir || error "lfs mkdir failed"
2833 # OBD_FAIL_OUT_UPDATE_NET_REP 0x1701
2834 do_facet mds${MDTIDX} lctl set_param fail_loc=0x1701
2841 wait $CLIENT_PID || error "rm remote dir failed"
2843 stat $remote_dir &>/dev/null && error "$remote_dir still exist!"
2845 rm -rf $DIR/$tdir || error "rmdir failed"
2849 run_test 81b "DNE: unlink remote dir, drop MDT0 update reply, fail MDT0"
2852 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2853 ([ $FAILURE_MODE == "HARD" ] &&
2854 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
2855 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
2859 local remote_dir=$DIR/$tdir/remote_dir
2861 mkdir_on_mdt0 $DIR/$tdir || error "mkdir $DIR/$tdir failed"
2862 $LFS mkdir -i $MDTIDX $remote_dir || error "lfs mkdir failed"
2864 # OBD_FAIL_OUT_UPDATE_NET_REP 0x1701
2865 do_facet mds${MDTIDX} lctl set_param fail_loc=0x1701
2872 fail mds$((MDTIDX + 1))
2874 wait $CLIENT_PID || error "rm remote dir failed"
2876 stat $remote_dir &>/dev/null && error "$remote_dir still exist!"
2878 rm -rf $DIR/$tdir || error "rmdir failed"
2882 run_test 81c "DNE: unlink remote dir, drop MDT0 update reply, fail MDT0,MDT1"
2885 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2887 local remote_dir=$DIR/$tdir/remote_dir
2889 mkdir_on_mdt0 $DIR/$tdir || error "mkdir $DIR/$tdir failed"
2890 $LFS mkdir -i $MDTIDX $remote_dir || error "lfs mkdir failed"
2892 # OBD_FAIL_OUT_UPDATE_NET_REP 0x1701
2893 do_facet mds${MDTIDX} lctl set_param fail_loc=0x1701
2899 fail mds${MDTIDX},mds$((MDTIDX + 1))
2901 wait $CLIENT_PID || error "rm remote dir failed"
2903 stat $remote_dir &>/dev/null && error "$remote_dir still exist!"
2905 rm -rf $DIR/$tdir || error "rmdir failed"
2909 run_test 81d "DNE: unlink remote dir, drop MDT0 update reply, fail 2 MDTs"
2912 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2913 ([ $FAILURE_MODE == "HARD" ] &&
2914 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
2915 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
2919 local remote_dir=$DIR/$tdir/remote_dir
2921 mkdir_on_mdt0 $DIR/$tdir || error "mkdir $DIR/$tdir failed"
2922 $LFS mkdir -i $MDTIDX $remote_dir || error "lfs mkdir failed"
2924 # OBD_FAIL_MDS_REINT_NET_REP 0x119
2925 do_facet mds$((MDTIDX + 1)) lctl set_param fail_loc=0x119
2928 do_facet mds$((MDTIDX + 1)) lctl set_param fail_loc=0
2933 wait $CLIENT_PID || error "rm remote dir failed"
2935 stat $remote_dir &>/dev/null && error "$remote_dir still exist!"
2937 rm -rf $DIR/$tdir || error "rmdir failed"
2941 run_test 81e "DNE: unlink remote dir, drop MDT1 req reply, fail MDT0"
2944 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2945 ([ $FAILURE_MODE == "HARD" ] &&
2946 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
2947 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
2951 local remote_dir=$DIR/$tdir/remote_dir
2953 mkdir_on_mdt0 $DIR/$tdir || error "mkdir $DIR/$tdir failed"
2954 $LFS mkdir -i $MDTIDX $remote_dir || error "lfs mkdir failed"
2956 # OBD_FAIL_MDS_REINT_NET_REP 0x119
2957 do_facet mds$((MDTIDX + 1)) lctl set_param fail_loc=0x119
2962 fail mds$((MDTIDX + 1))
2964 wait $CLIENT_PID || error "rm remote dir failed"
2966 stat $remote_dir &>/dev/null && error "$remote_dir still exist!"
2968 rm -rf $DIR/$tdir || error "rmdir failed"
2972 run_test 81f "DNE: unlink remote dir, drop MDT1 req reply, fail MDT1"
2975 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2976 ([ $FAILURE_MODE == "HARD" ] &&
2977 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
2978 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
2982 local remote_dir=$DIR/$tdir/remote_dir
2984 mkdir_on_mdt0 $DIR/$tdir || error "mkdir $DIR/$tdir failed"
2985 $LFS mkdir -i $MDTIDX $remote_dir || error "lfs mkdir failed"
2987 # OBD_FAIL_MDS_REINT_NET_REP 0x119
2988 do_facet mds$((MDTIDX + 1)) lctl set_param fail_loc=0x119
2995 fail mds$((MDTIDX + 1))
2997 wait $CLIENT_PID || error "rm remote dir failed"
2999 stat $remote_dir &>/dev/null && error "$remote_dir still exist!"
3001 rm -rf $DIR/$tdir || error "rmdir failed"
3005 run_test 81g "DNE: unlink remote dir, drop req reply, fail M0, then M1"
3008 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
3010 local remote_dir=$DIR/$tdir/remote_dir
3012 mkdir_on_mdt0 $DIR/$tdir || error "mkdir $DIR/$tdir failed"
3013 $LFS mkdir -i $MDTIDX $remote_dir || error "lfs mkdir failed"
3015 # OBD_FAIL_MDS_REINT_NET_REP 0x119
3016 do_facet mds$((MDTIDX + 1)) lctl set_param fail_loc=0x119
3022 fail mds${MDTIDX},mds$((MDTIDX + 1))
3024 wait $CLIENT_PID || error "rm remote dir failed"
3026 stat $remote_dir &>/dev/null && error "$remote_dir still exist!"
3028 rm -rf $DIR/$tdir || error "rmdir failed"
3032 run_test 81h "DNE: unlink remote dir, drop request reply, fail 2 MDTs"
3035 #define OBD_FAIL_MDS_OPEN_WAIT_CREATE 0x144
3036 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000144"
3037 createmany -o $DIR/$tfile- 1 &
3041 client_up || client_up || true # reconnect
3043 run_test 84a "stale open during export disconnect"
3045 test_85a() { #bug 16774
3046 lctl set_param -n ldlm.cancel_unused_locks_before_replay "1"
3048 for i in $(seq 100); do
3049 echo "tag-$i" > $DIR/$tfile-$i
3050 grep -q "tag-$i" $DIR/$tfile-$i || error "f2-$i"
3053 lov_id=$(lctl dl | grep "clilov")
3054 addr=$(echo $lov_id | awk '{print $4}' | awk -F '-' '{print $NF}')
3055 count=$(lctl get_param -n \
3056 ldlm.namespaces.*MDT0000*$addr.lock_unused_count)
3057 echo "before recovery: unused locks count = $count"
3061 count2=$(lctl get_param -n \
3062 ldlm.namespaces.*MDT0000*$addr.lock_unused_count)
3063 echo "after recovery: unused locks count = $count2"
3065 if [ $count2 -ge $count ]; then
3066 error "unused locks are not canceled"
3069 run_test 85a "check the cancellation of unused locks during recovery(IBITS)"
3071 test_85b() { #bug 16774
3075 lctl set_param -n ldlm.cancel_unused_locks_before_replay "1"
3077 $LFS setstripe -c 1 -i 0 $DIR/$tdir
3079 for i in $(seq 100); do
3080 dd if=/dev/urandom of=$DIR/$tdir/$tfile-$i bs=4096 \
3081 count=32 >/dev/null 2>&1
3084 cancel_lru_locks osc
3086 for i in $(seq 100); do
3087 dd if=$DIR/$tdir/$tfile-$i of=/dev/null bs=4096 \
3088 count=32 >/dev/null 2>&1
3091 lov_id=$(lctl dl | grep "clilov")
3092 addr=$(echo $lov_id | awk '{print $4}' | awk -F '-' '{print $NF}')
3093 count=$(lctl get_param -n \
3094 ldlm.namespaces.*OST0000*$addr.lock_unused_count)
3095 echo "before recovery: unused locks count = $count"
3096 [ $count -ne 0 ] || error "unused locks ($count) should be zero"
3100 count2=$(lctl get_param \
3101 -n ldlm.namespaces.*OST0000*$addr.lock_unused_count)
3102 echo "after recovery: unused locks count = $count2"
3104 if [ $count2 -ge $count ]; then
3105 error "unused locks are not canceled"
3110 run_test 85b "check the cancellation of unused locks during recovery(EXTENT)"
3113 local clients=${CLIENTS:-$HOSTNAME}
3115 zconf_umount_clients $clients $MOUNT
3116 do_facet $SINGLEMDS lctl set_param mdt.${FSNAME}-MDT*.exports.clear=0
3117 remount_facet $SINGLEMDS
3118 zconf_mount_clients $clients $MOUNT
3120 run_test 86 "umount server after clear nid_stats should not hit LBUG"
3123 do_facet ost1 "lctl set_param -n obdfilter.${ost1_svc}.sync_journal 0"
3126 $LFS setstripe -i 0 -c 1 $DIR/$tfile
3127 dd if=/dev/urandom of=$DIR/$tfile bs=1024k count=8 ||
3128 error "dd to $DIR/$tfile failed"
3129 cksum=$(md5sum $DIR/$tfile | awk '{print $1}')
3130 cancel_lru_locks osc
3132 dd if=$DIR/$tfile of=/dev/null bs=1024k count=8 || error "Cannot read"
3133 cksum2=$(md5sum $DIR/$tfile | awk '{print $1}')
3134 if [ $cksum != $cksum2 ] ; then
3135 error "New checksum $cksum2 does not match original $cksum"
3138 run_test 87a "write replay"
3141 do_facet ost1 "lctl set_param -n obdfilter.${ost1_svc}.sync_journal 0"
3144 $LFS setstripe -i 0 -c 1 $DIR/$tfile
3145 dd if=/dev/urandom of=$DIR/$tfile bs=1024k count=8 ||
3146 error "dd to $DIR/$tfile failed"
3147 sleep 1 # Give it a chance to flush dirty data
3148 echo TESTTEST | dd of=$DIR/$tfile bs=1 count=8 seek=64
3149 cksum=$(md5sum $DIR/$tfile | awk '{print $1}')
3150 cancel_lru_locks osc
3152 dd if=$DIR/$tfile of=/dev/null bs=1024k count=8 || error "Cannot read"
3153 cksum2=$(md5sum $DIR/$tfile | awk '{print $1}')
3154 if [ $cksum != $cksum2 ] ; then
3155 error "New checksum $cksum2 does not match original $cksum"
3158 run_test 87b "write replay with changed data (checksum resend)"
3160 test_88() { #bug 17485
3161 mkdir_on_mdt0 $DIR/$tdir || error "mkdir $DIR/$tdir failed"
3162 mkdir -p $TMP/$tdir || error "mkdir $TMP/$tdir failed"
3164 $LFS setstripe -i 0 -c 1 $DIR/$tdir || error "$LFS setstripe failed"
3167 replay_barrier $SINGLEMDS
3169 # exhaust precreations on ost1
3170 local OST=$(ostname_from_index 0)
3171 local mdtosc=$(get_mdtosc_proc_path $SINGLEMDS $OST)
3172 local last_id=$(do_facet $SINGLEMDS lctl get_param -n osp.$mdtosc.prealloc_last_id)
3173 local next_id=$(do_facet $SINGLEMDS lctl get_param -n osp.$mdtosc.prealloc_next_id)
3174 echo "before test: last_id = $last_id, next_id = $next_id"
3176 echo "Creating to objid $last_id on ost $OST..."
3177 createmany -o $DIR/$tdir/f-%d $next_id $((last_id - next_id + 2)) ||
3178 error "createmany create files to last_id failed"
3180 #create some files to use some uncommitted objids
3181 last_id=$(($last_id + 1))
3182 createmany -o $DIR/$tdir/f-%d $last_id 8 ||
3183 error "createmany create files with uncommitted objids failed"
3185 last_id2=$(do_facet $SINGLEMDS lctl get_param -n osp.$mdtosc.prealloc_last_id)
3186 next_id2=$(do_facet $SINGLEMDS lctl get_param -n osp.$mdtosc.prealloc_next_id)
3187 echo "before recovery: last_id = $last_id2, next_id = $next_id2"
3189 # if test uses shutdown_facet && reboot_facet instead of facet_failover ()
3190 # it has to take care about the affected facets, bug20407
3191 local affected_mds1=$(affected_facets mds1)
3192 local affected_ost1=$(affected_facets ost1)
3194 shutdown_facet $SINGLEMDS
3197 reboot_facet $SINGLEMDS
3198 change_active $affected_mds1
3199 wait_for_facet $affected_mds1
3200 mount_facets $affected_mds1 || error "Restart of mds failed"
3203 change_active $affected_ost1
3204 wait_for_facet $affected_ost1
3205 mount_facets $affected_ost1 || error "Restart of ost1 failed"
3209 last_id2=$(do_facet $SINGLEMDS lctl get_param -n osp.$mdtosc.prealloc_last_id)
3210 next_id2=$(do_facet $SINGLEMDS lctl get_param -n osp.$mdtosc.prealloc_next_id)
3211 echo "after recovery: last_id = $last_id2, next_id = $next_id2"
3213 # create new files, which should use new objids, and ensure the orphan
3214 # cleanup phase for ost1 is completed at the same time
3215 for i in $(seq 8); do
3216 file_id=$(($last_id + 10 + $i))
3217 dd if=/dev/urandom of=$DIR/$tdir/f-$file_id bs=4096 count=128
3220 # if the objids were not recreated, then "ls" will fail with -ENOENT
3221 ls -l $DIR/$tdir/* || error "can't get the status of precreated files"
3224 # write into previously created files
3225 for i in $(seq 8); do
3226 file_id=$(($last_id + $i))
3227 dd if=/dev/urandom of=$DIR/$tdir/f-$file_id bs=4096 count=128
3228 cp -f $DIR/$tdir/f-$file_id $TMP/$tdir/
3231 # compare the content
3232 for i in $(seq 8); do
3233 file_id=$(($last_id + $i))
3234 cmp $TMP/$tdir/f-$file_id $DIR/$tdir/f-$file_id ||
3235 error "the content of file is modified!"
3240 run_test 88 "MDS should not assign same objid to different files "
3243 cancel_lru_locks osc
3244 mkdir_on_mdt0 $DIR/$tdir || error "mkdir $DIR/$tdir failed"
3245 rm -f $DIR/$tdir/$tfile
3246 wait_mds_ost_sync || error "initial MDS-OST sync timed out"
3247 wait_delete_completed || error "initial wait delete timed out"
3248 local before=$(calc_osc_kbytes kbytesfree)
3249 local write_size=$(fs_log_size)
3251 $LFS setstripe -i 0 -c 1 $DIR/$tdir/$tfile
3252 (( $write_size >= 1024 )) || write_size=1024
3253 dd if=/dev/zero bs=${write_size}k count=10 of=$DIR/$tdir/$tfile
3256 facet_failover $SINGLEMDS
3257 rm $DIR/$tdir/$tfile
3260 zconf_mount $(hostname) $MOUNT || error "mount fails"
3261 client_up || error "client_up failed"
3263 # wait for the remounted client to connect to ost1
3264 local target=$(get_osc_import_name client ost1)
3265 wait_import_state "FULL" "osc.${target}.ost_server_uuid" \
3266 $(max_recovery_time)
3268 wait_mds_ost_sync || error "MDS-OST sync timed out"
3269 wait_delete_completed || error "wait delete timed out"
3270 local after=$(calc_osc_kbytes kbytesfree)
3272 log "free_before: $before free_after: $after"
3273 (( $before <= $after + $(fs_log_size) )) ||
3274 error "kbytesfree $before > $after + margin $(fs_log_size)"
3276 run_test 89 "no disk space leak on late ost connection"
3283 change_active $facet
3284 wait_for_facet $facet
3285 mount_facet $facet || error "Restart of $facet failed"
3289 test_90() { # bug 19494
3290 local dir=$DIR/$tdir
3291 local ostfail=$(get_random_entry $(get_facets OST))
3293 if [[ $FAILURE_MODE = HARD ]]; then
3294 local affected=$(affected_facets $ostfail);
3296 [[ "$affected" == $ostfail ]] ||
3297 skip "cannot use FAILURE_MODE=$FAILURE_MODE, affected: $affected"
3299 # ensure all OSTs are active to allow allocations
3302 mkdir $dir || error "mkdir $dir failed"
3304 echo "Create the files"
3306 # file "f${index}" striped over 1 OST
3307 # file "all" striped over all OSTs
3309 $LFS setstripe -c $OSTCOUNT $dir/all ||
3310 error "setstripe failed to create $dir/all"
3312 for ((i = 0; i < $OSTCOUNT; i++)); do
3315 $LFS setstripe -i $i -c 1 $f ||
3316 error "$LFS setstripe failed to create $f"
3318 # confirm setstripe actually created stripe on requested OST
3319 local uuid=$(ostuuid_from_index $i)
3321 for file in f$i all; do
3322 local found=$($LFS find --obd $uuid --name $file $dir)
3324 if [[ $dir/$file != $found ]]; then
3325 $LFS getstripe $dir/$file
3326 error "wrong stripe: $file, uuid: $uuid"
3331 # Before failing an OST, get its obd name and index
3332 local varsvc=${ostfail}_svc
3333 local obd=$(do_facet $ostfail lctl get_param \
3334 -n obdfilter.${!varsvc}.uuid)
3335 local index=$(($(facet_number $ostfail) - 1))
3337 echo "Fail $ostfail $obd, display the list of affected files"
3338 shutdown_facet $ostfail || error "shutdown_facet $ostfail failed"
3340 trap "cleanup_90 $ostfail" EXIT INT
3341 echo "General Query: lfs find $dir"
3342 local list=$($LFS find $dir)
3344 for (( i=0; i<$OSTCOUNT; i++ )); do
3345 list_member "$list" $dir/f$i ||
3346 error_noexit "lfs find $dir: no file f$i"
3348 list_member "$list" $dir/all ||
3349 error_noexit "lfs find $dir: no file all"
3351 # focus on the missing OST,
3352 # we expect to see only two files affected: "f$(index)" and "all"
3354 echo "Querying files on shutdown $ostfail: lfs find --obd $obd"
3355 list=$($LFS find --obd $obd $dir)
3357 for file in all f$index; do
3358 list_member "$list" $dir/$file ||
3359 error_noexit "lfs find does not report the affected $obd for $file"
3362 [[ $(echo $list | wc -w) -eq 2 ]] ||
3363 error_noexit "lfs find reports the wrong list of affected files ${#list[@]}"
3365 echo "Check getstripe: $LFS getstripe -r --obd $obd"
3366 list=$($LFS getstripe -r --obd $obd $dir)
3368 for file in all f$index; do
3369 echo "$list" | grep $dir/$file ||
3370 error_noexit "lfs getsripe does not report the affected $obd for $file"
3375 run_test 90 "lfs find identifies the missing striped file segments"
3378 [[ "$MDS1_VERSION" -ge $(version_code 2.6.90) ]] ||
3379 [[ "$MDS1_VERSION" -ge $(version_code 2.5.4) &&
3380 "$MDS1_VERSION" -lt $(version_code 2.5.50) ]] ||
3381 skip "Need MDS version 2.5.4+ or 2.6.90+"
3383 cancel_lru_locks osc
3385 $LFS setstripe -i 0 -c 1 $DIR/$tfile ||
3386 error "$LFS setstripe $DIR/$tfile failed"
3387 dd if=/dev/zero of=$DIR/$tfile bs=1024 count=1 ||
3388 error "dd to $DIR/$tfile failed"
3389 #define OBD_FAIL_TGT_REPLAY_RECONNECT 0x715
3390 # We need to emulate a state that OST is waiting for other clients
3391 # not completing the recovery. Final ping is queued, but reply will be
3392 # sent on the recovery completion. It is done by sleep before
3393 # processing final pings
3394 do_facet ost1 "$LCTL set_param fail_val=40"
3395 do_facet ost1 "$LCTL set_param fail_loc=0x715"
3398 run_test 93a "replay + reconnect"
3401 [[ "$MDS1_VERSION" -ge $(version_code 2.7.90) ]] ||
3402 skip "Need MDS version 2.7.90+"
3404 cancel_lru_locks mdc
3406 createmany -o $DIR/$tfile 20 ||
3407 error "createmany -o $DIR/$tfile failed"
3409 #define OBD_FAIL_TGT_REPLAY_RECONNECT 0x715
3410 # We need to emulate a state that MDT is waiting for other clients
3411 # not completing the recovery. Final ping is queued, but reply will be
3412 # sent on the recovery completion. It is done by sleep before
3413 # processing final pings
3414 do_facet mds1 "$LCTL set_param fail_val=80"
3415 do_facet mds1 "$LCTL set_param fail_loc=0x715"
3418 run_test 93b "replay + reconnect on mds"
3420 striped_dir_check_100() {
3421 local striped_dir=$DIR/$tdir/striped_dir
3422 local stripe_count=$($LFS getdirstripe -c $striped_dir)
3424 $LFS getdirstripe $striped_dir
3425 [ $stripe_count -eq 2 ] || error "$stripe_count != 2"
3427 createmany -o $striped_dir/f-%d 20 ||
3428 error "creation failed under striped dir"
3432 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
3433 ([ $FAILURE_MODE == "HARD" ] &&
3434 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
3435 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
3438 local striped_dir=$DIR/$tdir/striped_dir
3441 mkdir_on_mdt0 $DIR/$tdir || error "mkdir $DIR/$tdir failed"
3443 #To make sure MDT1 and MDT0 are connected
3444 #otherwise it may create single stripe dir here
3445 $LFS setdirstripe -i1 $DIR/$tdir/remote_dir
3447 #define OBD_FAIL_OUT_UPDATE_NET_REP 0x1701
3448 do_facet mds$((MDTIDX+1)) lctl set_param fail_loc=0x1701
3449 $LFS setdirstripe -i0 -c2 $striped_dir &
3452 fail mds$((MDTIDX + 1))
3454 wait $CLIENT_PID || error "striped dir creation failed"
3456 striped_dir_check_100 || error "striped dir check failed"
3457 rm -rf $DIR/$tdir || error "rmdir failed"
3459 run_test 100a "DNE: create striped dir, drop update rep from MDT1, fail MDT1"
3462 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
3463 ([ $FAILURE_MODE == "HARD" ] &&
3464 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
3465 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
3468 local striped_dir=$DIR/$tdir/striped_dir
3471 mkdir_on_mdt0 $DIR/$tdir || error "mkdir $DIR/$tdir failed"
3473 #To make sure MDT1 and MDT0 are connected
3474 #otherwise it may create single stripe dir here
3475 $LFS setdirstripe -i1 $DIR/$tdir/remote_dir
3477 # OBD_FAIL_MDS_REINT_NET_REP 0x119
3478 do_facet mds$MDTIDX lctl set_param fail_loc=0x119
3479 $LFS mkdir -i0 -c2 $striped_dir &
3484 wait $CLIENT_PID || error "striped dir creation failed"
3486 striped_dir_check_100 || error "striped dir check failed"
3487 rm -rf $DIR/$tdir || error "rmdir failed"
3489 run_test 100b "DNE: create striped dir, fail MDT0"
3492 (( $MDSCOUNT >= 2 )) || skip "needs >= 2 MDTs"
3493 [[ "$FAILURE_MODE" != "HARD" ||
3494 "$(facet_host mds1)" != "$(facet_host mds2)" ]] ||
3495 skip "MDTs needs to be on diff hosts for HARD fail mode"
3497 local striped_dir=$DIR/$tdir/striped_dir
3499 mkdir_on_mdt0 $DIR/$tdir || error "mkdir $DIR/$tdir failed"
3501 #To make sure MDT1 and MDT0 are connected
3502 #otherwise it may create single stripe dir here
3503 $LFS setdirstripe -i1 $DIR/$tdir/remote_dir
3506 $LFS mkdir -i1 -c2 $striped_dir
3508 fail_abort mds2 abort_recov_mdt
3510 if (( $MDS1_VERSION >= $(version_code 2.15.54.138) )); then
3511 # after 2.15.54.138 striped mkdir can replay by client request
3512 createmany -o $striped_dir/f-%d 20 ||
3513 error "createmany -o $DIR/$tfile failed"
3518 # LU-16159 abort_recovery will cancel update logs, the second recovery
3519 # won't replay $striped_dir creation
3520 (( $MDS1_VERSION >= $(version_code 2.15.52) &&
3521 $MDS1_VERSION < $(version_code 2.15.54.138) )) &&
3522 fail_abort_cleanup && return 0
3524 striped_dir_check_100 || error "striped dir check failed"
3526 run_test 100c "DNE: create striped dir, abort_recov_mdt mds2"
3529 (( $MDSCOUNT > 1 )) || skip "needs > 1 MDTs"
3530 (( $MDS1_VERSION >= $(version_code 2.15.52.144) )) ||
3531 skip "Need MDS version 2.15.52.144+"
3533 test_mkdir -c $MDSCOUNT $DIR/$tdir || error "mkdir $tdir failed"
3534 $LFS setdirstripe -D -i -1 -c $MDSCOUNT $DIR/$tdir ||
3535 error "set $tdir default LMV failed"
3536 createmany -d $DIR/$tdir/s 100 || error "create subdir failed"
3538 local index=$((RANDOM % MDSCOUNT))
3539 local devname=$(mdtname_from_index $index)
3540 local mdt=mds$((index + 1))
3545 # cancel update llog upon recovery abort
3546 do_facet $mdt $LCTL --device $devname llog_print update_log
3547 log=$(do_facet $mdt "$LCTL --device $devname llog_print update_log |
3548 awk '/index/ { print \\\$4; exit }'")
3550 count=$(do_facet $mdt "$LCTL --device $devname llog_print update_log |
3552 (( count > 0 )) || error "no update logs found"
3553 stack_trap fail_abort_cleanup RETURN
3554 fail_abort $mdt || error "fail_abort $mdt failed"
3555 wait_update_facet $mdt "$LCTL --device $devname llog_print update_log |
3556 grep -c index" 0 60 || error "update logs not canceled"
3558 run_test 100d "DNE: cancel update logs upon recovery abort"
3561 (( MDSCOUNT > 1 )) || skip "needs >= 2 MDTs"
3562 (( MDS1_VERSION >= $(version_code 2.15.54.79) )) ||
3563 skip "Need MDS version 2.15.54.79+"
3564 [[ $FAILURE_MODE != "HARD" ||
3565 "$(facet_host mds1)" != "$(facet_host mds2)" ]] ||
3566 skip "MDTs needs to be on diff hosts for HARD fail mode"
3570 local striped_dir=$DIR/$tdir/striped_dir
3572 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
3577 $LFS mkdir -i 0,1 $striped_dir
3578 old=$($LFS getdirstripe $striped_dir)
3583 new=$($LFS getdirstripe $striped_dir)
3585 [ "$old" == "$new" ] ||
3586 error "$striped_dir layout mismatch"
3587 rm -rf $DIR/$tdir || error "rmdir failed"
3589 run_test 100e "DNE: create striped dir on MDT0 and MDT1, fail MDT0, MDT1"
3591 test_101() { #LU-5648
3592 mkdir -p $DIR/$tdir/d1
3593 mkdir -p $DIR/$tdir/d2
3594 touch $DIR/$tdir/file0
3597 replay_barrier $SINGLEMDS
3598 for i in $(seq $num) ; do
3599 echo test$i > $DIR/$tdir/d1/file$i
3602 fail_abort $SINGLEMDS
3603 for i in $(seq $num) ; do
3604 touch $DIR/$tdir/d2/file$i
3605 test -s $DIR/$tdir/d2/file$i &&
3606 ls -al $DIR/$tdir/d2/file$i && error "file$i's size > 0"
3611 run_test 101 "Shouldn't reassign precreated objs to other files after recovery"
3620 [[ $(lctl get_param mdc.*.import |
3621 grep "connect_flags:.*multi_mod_rpc") ]] ||
3622 { skip "Need MDC with 'multi_mod_rpcs' feature"; return 0; }
3624 $LFS mkdir -c1 $DIR/$tdir || error "mkdir $DIR/$tdir failed"
3625 idx=$(printf "%04x" $($LFS getdirstripe -i $DIR/$tdir))
3626 facet="mds$((0x$idx + 1))"
3628 # get current value of max_mod_rcps_in_flight
3629 num=$($LCTL get_param -n \
3630 mdc.$FSNAME-MDT$idx-mdc-*.max_mod_rpcs_in_flight)
3631 # set default value if client does not support multi mod RPCs
3632 [ -z "$num" ] && num=1
3634 echo "creating $num files ..."
3636 for i in $(seq $num); do
3637 touch $DIR/$tdir/file-$i
3640 # drop request on MDT to force resend
3641 #define OBD_FAIL_MDS_REINT_MULTI_NET 0x159
3642 do_facet $facet "$LCTL set_param fail_loc=0x159"
3643 echo "launch $num chmod in parallel ($(date +%H:%M:%S)) ..."
3644 for i in $(seq $num); do
3645 chmod 0600 $DIR/$tdir/file-$i &
3649 do_facet $facet "$LCTL set_param fail_loc=0"
3650 for pid in $pids; do
3651 wait $pid || error "chmod failed"
3653 echo "done ($(date +%H:%M:%S))"
3655 # check chmod succeed
3656 for i in $(seq $num); do
3657 checkstat -vp 0600 $DIR/$tdir/file-$i
3662 run_test 102a "check resend (request lost) with multiple modify RPCs in flight"
3671 [[ $(lctl get_param mdc.*.import |
3672 grep "connect_flags:.*multi_mod_rpc") ]] ||
3673 { skip "Need MDC with 'multi_mod_rpcs' feature"; return 0; }
3675 $LFS mkdir -c1 $DIR/$tdir || error "mkdir $DIR/$tdir failed"
3676 idx=$(printf "%04x" $($LFS getdirstripe -i $DIR/$tdir))
3677 facet="mds$((0x$idx + 1))"
3679 # get current value of max_mod_rcps_in_flight
3680 num=$($LCTL get_param -n \
3681 mdc.$FSNAME-MDT$idx-mdc-*.max_mod_rpcs_in_flight)
3682 # set default value if client does not support multi mod RPCs
3683 [ -z "$num" ] && num=1
3685 echo "creating $num files ..."
3687 for i in $(seq $num); do
3688 touch $DIR/$tdir/file-$i
3691 # drop reply on MDT to force reconstruction
3692 #define OBD_FAIL_MDS_REINT_MULTI_NET_REP 0x15a
3693 do_facet $facet "$LCTL set_param fail_loc=0x15a"
3694 echo "launch $num chmod in parallel ($(date +%H:%M:%S)) ..."
3695 for i in $(seq $num); do
3696 chmod 0600 $DIR/$tdir/file-$i &
3700 do_facet $facet "$LCTL set_param fail_loc=0"
3701 for pid in $pids; do
3702 wait $pid || error "chmod failed"
3704 echo "done ($(date +%H:%M:%S))"
3706 # check chmod succeed
3707 for i in $(seq $num); do
3708 checkstat -vp 0600 $DIR/$tdir/file-$i
3713 run_test 102b "check resend (reply lost) with multiple modify RPCs in flight"
3722 [[ $(lctl get_param mdc.*.import |
3723 grep "connect_flags:.*multi_mod_rpc") ]] ||
3724 { skip "Need MDC with 'multi_mod_rpcs' feature"; return 0; }
3726 $LFS mkdir -c1 $DIR/$tdir || error "mkdir $DIR/$tdir failed"
3727 idx=$(printf "%04x" $($LFS getdirstripe -i $DIR/$tdir))
3728 facet="mds$((0x$idx + 1))"
3730 # get current value of max_mod_rcps_in_flight
3731 num=$($LCTL get_param -n \
3732 mdc.$FSNAME-MDT$idx-mdc-*.max_mod_rpcs_in_flight)
3733 # set default value if client does not support multi mod RPCs
3734 [ -z "$num" ] && num=1
3736 echo "creating $num files ..."
3738 for i in $(seq $num); do
3739 touch $DIR/$tdir/file-$i
3742 replay_barrier $facet
3745 #define OBD_FAIL_MDS_REINT_MULTI_NET_REP 0x15a
3746 do_facet $facet "$LCTL set_param fail_loc=0x15a"
3747 echo "launch $num chmod in parallel ($(date +%H:%M:%S)) ..."
3748 for i in $(seq $num); do
3749 chmod 0600 $DIR/$tdir/file-$i &
3753 do_facet $facet "$LCTL set_param fail_loc=0"
3758 for pid in $pids; do
3759 wait $pid || error "chmod failed"
3761 echo "done ($(date +%H:%M:%S))"
3763 # check chmod succeed
3764 for i in $(seq $num); do
3765 checkstat -vp 0600 $DIR/$tdir/file-$i
3770 run_test 102c "check replay w/o reconstruction with multiple mod RPCs in flight"
3779 [[ $(lctl get_param mdc.*.import |
3780 grep "connect_flags:.*multi_mod_rpc") ]] ||
3781 { skip "Need MDC with 'multi_mod_rpcs' feature"; return 0; }
3783 $LFS mkdir -c1 $DIR/$tdir || error "mkdir $DIR/$tdir failed"
3784 idx=$(printf "%04x" $($LFS getdirstripe -i $DIR/$tdir))
3785 facet="mds$((0x$idx + 1))"
3787 # get current value of max_mod_rcps_in_flight
3788 num=$($LCTL get_param -n \
3789 mdc.$FSNAME-MDT$idx-mdc-*.max_mod_rpcs_in_flight)
3790 # set default value if client does not support multi mod RPCs
3791 [ -z "$num" ] && num=1
3793 echo "creating $num files ..."
3795 for i in $(seq $num); do
3796 touch $DIR/$tdir/file-$i
3800 #define OBD_FAIL_MDS_REINT_MULTI_NET_REP 0x15a
3801 do_facet $facet "$LCTL set_param fail_loc=0x15a"
3802 echo "launch $num chmod in parallel ($(date +%H:%M:%S)) ..."
3803 for i in $(seq $num); do
3804 chmod 0600 $DIR/$tdir/file-$i &
3809 # write MDT transactions to disk
3810 do_facet $facet "sync; sync; sync"
3812 do_facet $facet "$LCTL set_param fail_loc=0"
3817 for pid in $pids; do
3818 wait $pid || error "chmod failed"
3820 echo "done ($(date +%H:%M:%S))"
3822 # check chmod succeed
3823 for i in $(seq $num); do
3824 checkstat -vp 0600 $DIR/$tdir/file-$i
3829 run_test 102d "check replay & reconstruction with multiple mod RPCs in flight"
3832 remote_mds_nodsh && skip "remote MDS with nodsh"
3833 [[ "$MDS1_VERSION" -gt $(version_code 2.8.54) ]] ||
3834 skip "Need MDS version 2.8.54+"
3836 #define OBD_FAIL_MDS_TRACK_OVERFLOW 0x162
3837 do_facet mds1 $LCTL set_param fail_loc=0x80000162
3840 createmany -o $DIR/$tdir/t- 30 ||
3841 error "create files on remote directory failed"
3843 rm -rf $DIR/$tdir/t-*
3845 #MDS should crash with tr->otr_next_id overflow
3848 run_test 103 "Check otr_next_id overflow"
3851 check_striped_dir_110()
3853 $CHECKSTAT -t dir $DIR/$tdir/striped_dir ||
3854 error "create striped dir failed"
3855 local stripe_count=$($LFS getdirstripe -c $DIR/$tdir/striped_dir)
3856 [ $stripe_count -eq $MDSCOUNT ] ||
3857 error "$stripe_count != 2 after recovery"
3861 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
3862 [[ "$MDS1_VERSION" -ge $(version_code 2.7.56) ]] ||
3863 skip "Need MDS version at least 2.7.56"
3865 ([ $FAILURE_MODE == "HARD" ] &&
3866 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
3867 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
3872 $LFS mkdir -i1 -c$MDSCOUNT $DIR/$tdir/striped_dir
3875 check_striped_dir_110 || error "check striped_dir failed"
3876 rm -rf $DIR/$tdir || error "rmdir failed"
3880 run_test 110a "DNE: create striped dir, fail MDT1"
3883 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
3884 [[ "$MDS1_VERSION" -ge $(version_code 2.7.56) ]] ||
3885 skip "Need MDS version at least 2.7.56"
3887 ([ $FAILURE_MODE == "HARD" ] &&
3888 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
3889 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
3894 $LFS mkdir -i1 -c$MDSCOUNT $DIR/$tdir/striped_dir
3897 zconf_mount $(hostname) $MOUNT
3898 client_up || return 1
3900 check_striped_dir_110 || error "check striped_dir failed"
3902 rm -rf $DIR/$tdir || error "rmdir failed"
3906 run_test 110b "DNE: create striped dir, fail MDT1 and client"
3909 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
3910 [[ "$MDS1_VERSION" -ge $(version_code 2.7.56) ]] ||
3911 skip "Need MDS version at least 2.7.56"
3913 ([ $FAILURE_MODE == "HARD" ] &&
3914 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
3915 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
3920 $LFS mkdir -i1 -c$MDSCOUNT $DIR/$tdir/striped_dir
3923 check_striped_dir_110 || error "check striped_dir failed"
3925 rm -rf $DIR/$tdir || error "rmdir failed"
3929 run_test 110c "DNE: create striped dir, fail MDT2"
3932 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
3933 [[ "$MDS1_VERSION" -ge $(version_code 2.7.56) ]] ||
3934 skip "Need MDS version at least 2.7.56"
3936 ([ $FAILURE_MODE == "HARD" ] &&
3937 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
3938 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
3943 $LFS mkdir -i1 -c$MDSCOUNT $DIR/$tdir/striped_dir
3946 zconf_mount $(hostname) $MOUNT
3947 client_up || return 1
3949 check_striped_dir_110 || error "check striped_dir failed"
3951 rm -rf $DIR/$tdir || error "rmdir failed"
3955 run_test 110d "DNE: create striped dir, fail MDT2 and client"
3958 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
3959 [[ "$MDS1_VERSION" -ge $(version_code 2.7.56) ]] ||
3960 skip "Need MDS version at least 2.7.56"
3962 ([ $FAILURE_MODE == "HARD" ] &&
3963 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
3964 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
3969 $LFS mkdir -i1 -c$MDSCOUNT $DIR/$tdir/striped_dir
3973 zconf_mount $(hostname) $MOUNT
3974 client_up || return 1
3976 check_striped_dir_110 || error "check striped_dir failed"
3978 rm -rf $DIR/$tdir || error "rmdir failed"
3982 run_test 110e "DNE: create striped dir, uncommit on MDT2, fail client/MDT1/MDT2"
3985 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
3986 [[ "$MDS1_VERSION" -ge $(version_code 2.7.56) ]] ||
3987 skip "Need MDS version at least 2.7.56"
3989 ([ $FAILURE_MODE == "HARD" ] &&
3990 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
3991 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
3997 $LFS mkdir -i1 -c$MDSCOUNT $DIR/$tdir/striped_dir
4000 check_striped_dir_110 || error "check striped_dir failed"
4002 rm -rf $DIR/$tdir || error "rmdir failed"
4006 run_test 110f "DNE: create striped dir, fail MDT1/MDT2"
4009 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
4010 [[ "$MDS1_VERSION" -ge $(version_code 2.7.56) ]] ||
4011 skip "Need MDS version at least 2.7.56"
4013 ([ $FAILURE_MODE == "HARD" ] &&
4014 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
4015 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
4020 $LFS mkdir -i1 -c$MDSCOUNT $DIR/$tdir/striped_dir
4024 zconf_mount $(hostname) $MOUNT
4025 client_up || return 1
4027 check_striped_dir_110 || error "check striped_dir failed"
4029 rm -rf $DIR/$tdir || error "rmdir failed"
4033 run_test 110g "DNE: create striped dir, uncommit on MDT1, fail client/MDT1/MDT2"
4036 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
4037 [[ "$MDS1_VERSION" -ge $(version_code 2.7.56) ]] ||
4038 skip "Need MDS version at least 2.7.56"
4040 ([ $FAILURE_MODE == "HARD" ] &&
4041 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
4042 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
4046 $LFS mkdir -i1 -c2 $DIR/$tdir/striped_dir
4048 rm -rf $DIR/$tdir/striped_dir
4051 $CHECKSTAT -t dir $DIR/$tdir/striped_dir &&
4052 error "striped dir still exists"
4055 run_test 111a "DNE: unlink striped dir, fail MDT1"
4058 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
4059 [[ "$MDS1_VERSION" -ge $(version_code 2.7.56) ]] ||
4060 skip "Need MDS version at least 2.7.56"
4062 ([ $FAILURE_MODE == "HARD" ] &&
4063 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
4064 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
4068 $LFS mkdir -i1 -c2 $DIR/$tdir/striped_dir
4070 rm -rf $DIR/$tdir/striped_dir
4073 zconf_mount $(hostname) $MOUNT
4074 client_up || return 1
4076 $CHECKSTAT -t dir $DIR/$tdir/striped_dir &&
4077 error "striped dir still exists"
4080 run_test 111b "DNE: unlink striped dir, fail MDT2"
4083 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
4084 [[ "$MDS1_VERSION" -ge $(version_code 2.7.56) ]] ||
4085 skip "Need MDS version at least 2.7.56"
4087 ([ $FAILURE_MODE == "HARD" ] &&
4088 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
4089 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
4093 $LFS mkdir -i1 -c2 $DIR/$tdir/striped_dir
4095 rm -rf $DIR/$tdir/striped_dir
4099 zconf_mount $(hostname) $MOUNT
4100 client_up || return 1
4101 $CHECKSTAT -t dir $DIR/$tdir/striped_dir &&
4102 error "striped dir still exists"
4105 run_test 111c "DNE: unlink striped dir, uncommit on MDT1, fail client/MDT1/MDT2"
4108 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
4109 [[ "$MDS1_VERSION" -ge $(version_code 2.7.56) ]] ||
4110 skip "Need MDS version at least 2.7.56"
4112 ([ $FAILURE_MODE == "HARD" ] &&
4113 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
4114 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
4118 $LFS mkdir -i1 -c2 $DIR/$tdir/striped_dir
4120 rm -rf $DIR/$tdir/striped_dir
4124 zconf_mount $(hostname) $MOUNT
4125 client_up || return 1
4126 $CHECKSTAT -t dir $DIR/$tdir/striped_dir &&
4127 error "striped dir still exists"
4131 run_test 111d "DNE: unlink striped dir, uncommit on MDT2, fail client/MDT1/MDT2"
4134 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
4135 [[ "$MDS1_VERSION" -ge $(version_code 2.7.56) ]] ||
4136 skip "Need MDS version at least 2.7.56"
4138 ([ $FAILURE_MODE == "HARD" ] &&
4139 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
4140 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
4144 $LFS mkdir -i1 -c2 $DIR/$tdir/striped_dir
4146 rm -rf $DIR/$tdir/striped_dir
4149 $CHECKSTAT -t dir $DIR/$tdir/striped_dir &&
4150 error "striped dir still exists"
4153 run_test 111e "DNE: unlink striped dir, uncommit on MDT2, fail MDT1/MDT2"
4156 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
4157 [[ "$MDS1_VERSION" -ge $(version_code 2.7.56) ]] ||
4158 skip "Need MDS version at least 2.7.56"
4160 ([ $FAILURE_MODE == "HARD" ] &&
4161 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
4162 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
4166 $LFS mkdir -i1 -c2 $DIR/$tdir/striped_dir
4168 rm -rf $DIR/$tdir/striped_dir
4171 $CHECKSTAT -t dir $DIR/$tdir/striped_dir &&
4172 error "striped dir still exists"
4175 run_test 111f "DNE: unlink striped dir, uncommit on MDT1, fail MDT1/MDT2"
4178 (( $MDSCOUNT >= 2 )) || skip "needs >= 2 MDTs"
4179 (( $MDS1_VERSION >= $(version_code 2.7.56) )) ||
4180 skip "Need MDS version at least 2.7.56"
4182 ([ $FAILURE_MODE != "HARD" ] ||
4183 [ "$(facet_host mds1)" != "$(facet_host mds2)" ]) ||
4184 skip "MDTs needs to be on diff hosts for HARD fail mode"
4187 $LFS mkdir -i1 -c2 $DIR/$tdir/striped_dir
4191 rm -rf $DIR/$tdir/striped_dir
4193 $CHECKSTAT -t dir $DIR/$tdir/striped_dir &&
4194 error "striped dir still exists"
4197 run_test 111g "DNE: unlink striped dir, fail MDT1/MDT2"
4199 test_112_rename_prepare() {
4200 mkdir_on_mdt0 $DIR/$tdir
4201 mkdir -p $DIR/$tdir/src_dir
4202 $LFS mkdir -i 1 $DIR/$tdir/src_dir/src_child ||
4203 error "create remote source failed"
4205 touch $DIR/$tdir/src_dir/src_child/a
4207 $LFS mkdir -i 2 $DIR/$tdir/tgt_dir ||
4208 error "create remote target dir failed"
4210 $LFS mkdir -i 3 $DIR/$tdir/tgt_dir/tgt_child ||
4211 error "create remote target child failed"
4216 $CHECKSTAT -t dir $DIR/$tdir/src_dir/src_child &&
4217 error "src_child still exists after rename"
4219 $CHECKSTAT -t file $DIR/$tdir/tgt_dir/tgt_child/a ||
4220 error "missing file(a) after rename"
4224 [ $MDSCOUNT -lt 4 ] && skip "needs >= 4 MDTs" && return 0
4225 [[ "$MDS1_VERSION" -ge $(version_code 2.7.56) ]] ||
4226 skip "Need MDS version at least 2.7.56"
4228 ([ $FAILURE_MODE == "HARD" ] &&
4229 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
4230 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
4233 test_112_rename_prepare
4236 mrename $DIR/$tdir/src_dir/src_child $DIR/$tdir/tgt_dir/tgt_child ||
4237 error "rename dir cross MDT failed!"
4241 rm -rf $DIR/$tdir || error "rmdir failed"
4243 run_test 112a "DNE: cross MDT rename, fail MDT1"
4246 [ $MDSCOUNT -lt 4 ] && skip "needs >= 4 MDTs" && return 0
4247 [[ "$MDS1_VERSION" -ge $(version_code 2.7.56) ]] ||
4248 skip "Need MDS version at least 2.7.56"
4250 ([ $FAILURE_MODE == "HARD" ] &&
4251 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
4252 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
4255 test_112_rename_prepare
4258 mrename $DIR/$tdir/src_dir/src_child $DIR/$tdir/tgt_dir/tgt_child ||
4259 error "rename dir cross MDT failed!"
4264 rm -rf $DIR/$tdir || error "rmdir failed"
4266 run_test 112b "DNE: cross MDT rename, fail MDT2"
4269 [ $MDSCOUNT -lt 4 ] && skip "needs >= 4 MDTs" && return 0
4270 [[ "$MDS1_VERSION" -ge $(version_code 2.7.56) ]] ||
4271 skip "Need MDS version at least 2.7.56"
4273 ([ $FAILURE_MODE == "HARD" ] &&
4274 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
4275 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
4278 test_112_rename_prepare
4281 mrename $DIR/$tdir/src_dir/src_child $DIR/$tdir/tgt_dir/tgt_child ||
4282 error "rename dir cross MDT failed!"
4287 rm -rf $DIR/$tdir || error "rmdir failed"
4289 run_test 112c "DNE: cross MDT rename, fail MDT3"
4292 [ $MDSCOUNT -lt 4 ] && skip "needs >= 4 MDTs" && return 0
4293 [[ "$MDS1_VERSION" -ge $(version_code 2.7.56) ]] ||
4294 skip "Need MDS version at least 2.7.56"
4296 ([ $FAILURE_MODE == "HARD" ] &&
4297 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
4298 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
4301 test_112_rename_prepare
4304 mrename $DIR/$tdir/src_dir/src_child $DIR/$tdir/tgt_dir/tgt_child ||
4305 error "rename dir cross MDT failed!"
4310 rm -rf $DIR/$tdir || error "rmdir failed"
4312 run_test 112d "DNE: cross MDT rename, fail MDT4"
4315 [ $MDSCOUNT -lt 4 ] && skip "needs >= 4 MDTs" && return 0
4316 [[ "$MDS1_VERSION" -ge $(version_code 2.7.56) ]] ||
4317 skip "Need MDS version at least 2.7.56"
4319 ([ $FAILURE_MODE == "HARD" ] &&
4320 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
4321 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
4324 test_112_rename_prepare
4328 mrename $DIR/$tdir/src_dir/src_child $DIR/$tdir/tgt_dir/tgt_child ||
4329 error "rename dir cross MDT failed!"
4334 rm -rf $DIR/$tdir || error "rmdir failed"
4336 run_test 112e "DNE: cross MDT rename, fail MDT1 and MDT2"
4339 [ $MDSCOUNT -lt 4 ] && skip "needs >= 4 MDTs" && return 0
4340 [[ "$MDS1_VERSION" -ge $(version_code 2.7.56) ]] ||
4341 skip "Need MDS version at least 2.7.56"
4343 ([ $FAILURE_MODE == "HARD" ] &&
4344 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
4345 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
4348 test_112_rename_prepare
4352 mrename $DIR/$tdir/src_dir/src_child $DIR/$tdir/tgt_dir/tgt_child ||
4353 error "rename dir cross MDT failed!"
4358 rm -rf $DIR/$tdir || error "rmdir failed"
4360 run_test 112f "DNE: cross MDT rename, fail MDT1 and MDT3"
4363 [ $MDSCOUNT -lt 4 ] && skip "needs >= 4 MDTs" && return 0
4364 [[ "$MDS1_VERSION" -ge $(version_code 2.7.56) ]] ||
4365 skip "Need MDS version at least 2.7.56"
4367 ([ $FAILURE_MODE == "HARD" ] &&
4368 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
4369 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
4372 test_112_rename_prepare
4376 mrename $DIR/$tdir/src_dir/src_child $DIR/$tdir/tgt_dir/tgt_child ||
4377 error "rename dir cross MDT failed!"
4382 rm -rf $DIR/$tdir || error "rmdir failed"
4384 run_test 112g "DNE: cross MDT rename, fail MDT1 and MDT4"
4387 [ $MDSCOUNT -lt 4 ] && skip "needs >= 4 MDTs" && return 0
4388 [[ "$MDS1_VERSION" -ge $(version_code 2.7.56) ]] ||
4389 skip "Need MDS version at least 2.7.56"
4391 ([ $FAILURE_MODE == "HARD" ] &&
4392 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
4393 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
4396 test_112_rename_prepare
4400 mrename $DIR/$tdir/src_dir/src_child $DIR/$tdir/tgt_dir/tgt_child ||
4401 error "rename dir cross MDT failed!"
4406 rm -rf $DIR/$tdir || error "rmdir failed"
4408 run_test 112h "DNE: cross MDT rename, fail MDT2 and MDT3"
4411 [ $MDSCOUNT -lt 4 ] && skip "needs >= 4 MDTs" && return 0
4412 [[ "$MDS1_VERSION" -ge $(version_code 2.7.56) ]] ||
4413 skip "Need MDS version at least 2.7.56"
4415 ([ $FAILURE_MODE == "HARD" ] &&
4416 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
4417 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
4420 test_112_rename_prepare
4424 mrename $DIR/$tdir/src_dir/src_child $DIR/$tdir/tgt_dir/tgt_child ||
4425 error "rename dir cross MDT failed!"
4430 rm -rf $DIR/$tdir || error "rmdir failed"
4432 run_test 112i "DNE: cross MDT rename, fail MDT2 and MDT4"
4435 [ $MDSCOUNT -lt 4 ] && skip "needs >= 4 MDTs" && return 0
4436 [[ "$MDS1_VERSION" -ge $(version_code 2.7.56) ]] ||
4437 skip "Need MDS version at least 2.7.56"
4439 ([ $FAILURE_MODE == "HARD" ] &&
4440 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
4441 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
4444 test_112_rename_prepare
4448 mrename $DIR/$tdir/src_dir/src_child $DIR/$tdir/tgt_dir/tgt_child ||
4449 error "rename dir cross MDT failed!"
4454 rm -rf $DIR/$tdir || error "rmdir failed"
4456 run_test 112j "DNE: cross MDT rename, fail MDT3 and MDT4"
4459 [ $MDSCOUNT -lt 4 ] && skip "needs >= 4 MDTs" && return 0
4460 [[ "$MDS1_VERSION" -ge $(version_code 2.7.56) ]] ||
4461 skip "Need MDS version at least 2.7.56"
4463 ([ $FAILURE_MODE == "HARD" ] &&
4464 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
4465 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
4468 test_112_rename_prepare
4473 mrename $DIR/$tdir/src_dir/src_child $DIR/$tdir/tgt_dir/tgt_child ||
4474 error "rename dir cross MDT failed!"
4479 rm -rf $DIR/$tdir || error "rmdir failed"
4481 run_test 112k "DNE: cross MDT rename, fail MDT1,MDT2,MDT3"
4484 [ $MDSCOUNT -lt 4 ] && skip "needs >= 4 MDTs" && return 0
4485 [[ "$MDS1_VERSION" -ge $(version_code 2.7.56) ]] ||
4486 skip "Need MDS version at least 2.7.56"
4488 ([ $FAILURE_MODE == "HARD" ] &&
4489 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
4490 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
4493 test_112_rename_prepare
4498 mrename $DIR/$tdir/src_dir/src_child $DIR/$tdir/tgt_dir/tgt_child ||
4499 error "rename dir cross MDT failed!"
4504 rm -rf $DIR/$tdir || error "rmdir failed"
4506 run_test 112l "DNE: cross MDT rename, fail MDT1,MDT2,MDT4"
4509 [ $MDSCOUNT -lt 4 ] && skip "needs >= 4 MDTs" && return 0
4510 [[ "$MDS1_VERSION" -ge $(version_code 2.7.56) ]] ||
4511 skip "Need MDS version at least 2.7.56"
4513 ([ $FAILURE_MODE == "HARD" ] &&
4514 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
4515 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
4518 test_112_rename_prepare
4523 mrename $DIR/$tdir/src_dir/src_child $DIR/$tdir/tgt_dir/tgt_child ||
4524 error "rename dir cross MDT failed!"
4529 rm -rf $DIR/$tdir || error "rmdir failed"
4531 run_test 112m "DNE: cross MDT rename, fail MDT1,MDT3,MDT4"
4534 [ $MDSCOUNT -lt 4 ] && skip "needs >= 4 MDTs" && return 0
4535 [[ "$MDS1_VERSION" -ge $(version_code 2.7.56) ]] ||
4536 skip "Need MDS version at least 2.7.56"
4538 ([ $FAILURE_MODE == "HARD" ] &&
4539 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
4540 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
4543 test_112_rename_prepare
4548 mrename $DIR/$tdir/src_dir/src_child $DIR/$tdir/tgt_dir/tgt_child ||
4549 error "rename dir cross MDT failed!"
4554 rm -rf $DIR/$tdir || error "rmdir failed"
4556 run_test 112n "DNE: cross MDT rename, fail MDT2,MDT3,MDT4"
4559 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
4560 [[ "$MDS1_VERSION" -ge $(version_code 2.7.56) ]] ||
4561 skip "Need MDS version at least 2.7.56"
4563 ([ $FAILURE_MODE == "HARD" ] &&
4564 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
4565 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
4573 for ((j=0;j<$((MDSCOUNT));j++)); do
4574 fail_index=$((fail_index+1))
4575 index=$((fail_index % MDSCOUNT))
4576 replay_barrier mds$((index + 1))
4577 for ((i=0;i<5;i++)); do
4578 test_mkdir -i$index -c$MDSCOUNT $DIR/$tdir/test_$i ||
4579 error "create striped dir $DIR/$tdir/test_$i"
4582 fail mds$((index + 1))
4583 for ((i=0;i<5;i++)); do
4584 checkstat -t dir $DIR/$tdir/test_$i ||
4585 error "$DIR/$tdir/test_$i does not exist!"
4587 rm -rf $DIR/$tdir/test_* ||
4591 run_test 115 "failover for create/unlink striped directory"
4594 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
4595 [ "$MDS1_VERSION" -lt $(version_code 2.7.55) ] &&
4596 skip "Do not support large update log before 2.7.55" &&
4598 ([ $FAILURE_MODE == "HARD" ] &&
4599 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
4600 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
4604 mkdir_on_mdt0 $DIR/$tdir
4607 # OBD_FAIL_SPLIT_UPDATE_REC 0x1702
4608 do_facet mds1 "lctl set_param fail_loc=0x80001702"
4609 $LFS setdirstripe -i0 -c$MDSCOUNT $DIR/$tdir/striped_dir
4612 $CHECKSTAT -t dir $DIR/$tdir/striped_dir ||
4613 error "stried_dir does not exists"
4615 run_test 116a "large update log master MDT recovery"
4618 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
4619 [ "$MDS1_VERSION" -lt $(version_code 2.7.55) ] &&
4620 skip "Do not support large update log before 2.7.55" &&
4623 ([ $FAILURE_MODE == "HARD" ] &&
4624 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
4625 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
4629 mkdir_on_mdt0 $DIR/$tdir
4632 # OBD_FAIL_SPLIT_UPDATE_REC 0x1702
4633 do_facet mds2 "lctl set_param fail_loc=0x80001702"
4634 $LFS setdirstripe -i0 -c$MDSCOUNT $DIR/$tdir/striped_dir
4637 $CHECKSTAT -t dir $DIR/$tdir/striped_dir ||
4638 error "stried_dir does not exists"
4640 run_test 116b "large update log slave MDT recovery"
4643 [ $MDSCOUNT -lt 4 ] && skip "needs >= 4 MDTs" && return 0
4644 ([ $FAILURE_MODE == "HARD" ] &&
4645 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
4646 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
4652 $LFS setdirstripe -i0 -c$MDSCOUNT $DIR/$tdir/remote_dir
4653 $LFS setdirstripe -i1 -c$MDSCOUNT $DIR/$tdir/remote_dir_1
4656 # Let's set rdonly on all MDTs, so client will send
4657 # replay requests on all MDTs and replay these requests
4658 # at the same time. This test will verify the recovery
4659 # will not be deadlock in this case, LU-7531.
4660 for ((index = 0; index < $((MDSCOUNT)); index++)); do
4661 replay_barrier mds$((index + 1))
4662 if [ -z $mds_indexs ]; then
4663 mds_indexs="${mds_indexs}mds$((index+1))"
4665 mds_indexs="${mds_indexs},mds$((index+1))"
4669 rm -rf $DIR/$tdir/remote_dir
4670 rm -rf $DIR/$tdir/remote_dir_1
4674 rm -rf $DIR/$tdir || error "rmdir failed"
4676 run_test 117 "DNE: cross MDT unlink, fail MDT1 and MDT2"
4679 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
4680 [ "$MDS1_VERSION" -lt $(version_code 2.7.64) ] &&
4681 skip "Do not support large update log before 2.7.64" &&
4686 $LFS setdirstripe -c2 $DIR/$tdir/striped_dir ||
4687 error "setdirstripe fails"
4688 $LFS setdirstripe -c2 $DIR/$tdir/striped_dir1 ||
4689 error "setdirstripe fails 1"
4690 rm -rf $DIR/$tdir/striped_dir* || error "rmdir fails"
4692 # OBD_FAIL_INVALIDATE_UPDATE 0x1705
4693 do_facet mds1 "lctl set_param fail_loc=0x1705"
4694 $LFS setdirstripe -c2 $DIR/$tdir/striped_dir
4695 $LFS setdirstripe -c2 $DIR/$tdir/striped_dir1
4696 do_facet mds1 "lctl set_param fail_loc=0x0"
4699 $LFS setdirstripe -c2 $DIR/$tdir/striped_dir
4700 $LFS setdirstripe -c2 $DIR/$tdir/striped_dir1
4705 run_test 118 "invalidate osp update will not cause update log corruption"
4708 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
4709 [ "$MDS1_VERSION" -lt $(version_code 2.7.64) ] &&
4710 skip "Do not support large update log before 2.7.64" &&
4713 local hard_timeout=$(do_facet mds1 \
4714 "lctl get_param -n mdt.$FSNAME-MDT0000.recovery_time_hard")
4716 local clients=${CLIENTS:-$HOSTNAME}
4717 local time_min=$(recovery_time_min)
4719 mkdir_on_mdt0 $DIR/$tdir
4720 mkdir $DIR/$tdir/tmp
4721 rmdir $DIR/$tdir/tmp
4724 mkdir $DIR/$tdir/dir_1
4725 for ((i = 0; i < 20; i++)); do
4726 $LFS setdirstripe -i0 -c2 $DIR/$tdir/stripe_dir-$i
4733 #define OBD_FAIL_TGT_REPLAY_DELAY 0x714
4734 do_facet mds1 $LCTL set_param fail_loc=0x80000714
4735 #sleep (timeout + 5), so mds will evict the client exports,
4736 #but DNE update recovery will keep going.
4737 do_facet mds1 $LCTL set_param fail_val=$((time_min + 5))
4739 mount_facet mds1 "-o recovery_time_hard=$time_min"
4741 wait_clients_import_state "$clients" mds1 FULL
4743 clients_up || clients_up || error "failover df: $?"
4745 #revert back the hard timeout
4746 do_facet mds1 $LCTL set_param \
4747 mdt.$FSNAME-MDT0000.recovery_time_hard=$hard_timeout
4749 for ((i = 0; i < 20; i++)); do
4750 stripe_count=$($LFS getdirstripe -c $DIR/$tdir/stripe_dir-$i)
4751 [ $stripe_count == 2 ] || {
4752 error "stripe_dir-$i creation replay fails"
4757 run_test 119 "timeout of normal replay does not cause DNE replay fails "
4760 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
4761 [ "$MDS1_VERSION" -lt $(version_code 2.7.64) ] &&
4762 skip "Do not support large update log before 2.7.64" &&
4765 mkdir_on_mdt0 $DIR/$tdir
4766 replay_barrier_nosync mds1
4767 for ((i = 0; i < 20; i++)); do
4768 mkdir $DIR/$tdir/dir-$i || {
4769 error "create dir-$i fails"
4772 $LFS setdirstripe -i0 -c2 $DIR/$tdir/stripe_dir-$i || {
4773 error "create stripe_dir-$i fails"
4778 stack_trap fail_abort_cleanup RETURN
4781 for ((i = 0; i < 20; i++)); do
4782 [ ! -e "$DIR/$tdir/dir-$i" ] || {
4783 error "dir-$i still exists"
4786 [ ! -e "$DIR/$tdir/stripe_dir-$i" ] || {
4787 error "stripe_dir-$i still exists"
4792 run_test 120 "DNE fail abort should stop both normal and DNE replay"
4795 [ "$MDS1_VERSION" -lt $(version_code 2.10.90) ] &&
4796 skip "Don't support it before 2.11" &&
4799 local at_max_saved=$(at_max_get mds)
4801 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
4802 cancel_lru_locks mdc
4804 multiop_bg_pause $DIR/$tfile s_s || error "multiop $DIR/$tfile failed"
4807 lctl set_param -n ldlm.cancel_unused_locks_before_replay "0"
4813 #define OBD_FAIL_TGT_RECOVERY_REQ_RACE 0x721
4814 do_facet $SINGLEMDS "lctl set_param fail_loc=0x721 fail_val=0"
4818 wait_clients_import_state "$clients" mds1 FULL
4819 clients_up || clients_up || error "failover df: $?"
4822 wait $mpid || error "multiop_bg_pause pid failed"
4824 do_facet $SINGLEMDS "lctl set_param fail_loc=0x0"
4825 lctl set_param -n ldlm.cancel_unused_locks_before_replay "1"
4826 at_max_set $at_max_saved mds
4829 run_test 121 "lock replay timed out and race"
4832 [ "$MDS1_VERSION" -lt $(version_code 2.10.90) ] &&
4833 skip "Do not support Data-on-MDT before 2.11"
4835 replay_barrier $SINGLEMDS
4836 $LFS setstripe -E 1M -L mdt -E EOF -c 2 $DIR/$tfile
4839 [ $($LFS getstripe -L $DIR/$tfile) == "mdt" ] ||
4840 error "Fail to replay DoM file creation"
4842 run_test 130a "DoM file create (setstripe) replay"
4845 [ "$MDS1_VERSION" -lt $(version_code 2.10.90) ] &&
4846 skip "Do not support Data-on-MDT before 2.11"
4848 mkdir_on_mdt0 $DIR/$tdir
4849 $LFS setstripe -E 1M -L mdt -E EOF -c 2 $DIR/$tdir
4850 replay_barrier $SINGLEMDS
4851 touch $DIR/$tdir/$tfile
4854 [ $($LFS getstripe -L $DIR/$tdir/$tfile) == "mdt" ] ||
4855 error "Fail to replay DoM file creation"
4857 run_test 130b "DoM file create (inherited) replay"
4860 [ "$MDS1_VERSION" -lt $(version_code 2.10.90) ] &&
4861 skip "Do not support Data-on-MDT before 2.11"
4863 $LFS setstripe -E 1M -L mdt -E EOF -c 2 $DIR/$tfile
4864 replay_barrier $SINGLEMDS
4865 echo "dom_data" | dd of=$DIR/$tfile bs=8 count=1
4866 # lock is not canceled and will be replayed
4869 [ $(cat $DIR/$tfile) == "dom_data" ] ||
4870 error "Wrong file content after failover"
4872 run_test 131a "DoM file write lock replay"
4875 [ "$MDS1_VERSION" -lt $(version_code 2.10.90) ] &&
4876 skip "Do not support Data-on-MDT before 2.11"
4878 # refresh grants so write after replay_barrier doesn't
4880 $LFS setstripe -E 1M -L mdt -E EOF -c 2 $DIR/$tfile-2
4881 stack_trap "rm -f $DIR/$tfile-2"
4882 dd if=/dev/zero of=$DIR/$tfile-2 bs=64k count=2 ||
4884 $LFS setstripe -E 1M -L mdt -E EOF -c 2 $DIR/$tfile
4885 replay_barrier $SINGLEMDS
4886 echo "dom_data" | dd of=$DIR/$tfile bs=8 count=1
4887 cancel_lru_locks mdc
4891 [ $(cat $DIR/$tfile) == "dom_data" ] ||
4892 error "Wrong file content after failover"
4894 run_test 131b "DoM file write replay"
4897 [ "$MDS1_VERSION" -lt $(version_code 2.12.0) ] &&
4898 skip "Need MDS version 2.12.0 or later"
4900 $LFS setstripe -E 1M -c 1 -E EOF -c 2 $DIR/$tfile
4901 replay_barrier $SINGLEMDS
4902 # write over the first component size cause next component instantiation
4903 dd if=/dev/urandom of=$DIR/$tfile bs=1M count=1 seek=1 ||
4904 error "dd to $DIR/$tfile failed"
4905 lfs getstripe $DIR/$tfile
4907 cksum=$(md5sum $DIR/$tfile | awk '{print $1}')
4908 $LFS getstripe -I2 $DIR/$tfile | grep -q lmm_objects ||
4909 error "Component #1 was not instantiated"
4913 lfs getstripe $DIR/$tfile
4914 $LFS getstripe -I2 $DIR/$tfile | grep -q lmm_objects ||
4915 error "Component #1 instantiation was not replayed"
4916 cksum2=$(md5sum $DIR/$tfile | awk '{print $1}')
4917 if [ $cksum != $cksum2 ] ; then
4918 error_noexit "New cksum $cksum2 does not match original $cksum"
4921 run_test 132a "PFL new component instantiate replay"
4924 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
4925 ([ $FAILURE_MODE == "HARD" ] &&
4926 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
4927 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
4930 local remote_dir=$DIR/$tdir/remote_dir
4932 mkdir -p $DIR/$tdir || error "mkdir $DIR/$tdir failed"
4933 $LFS mkdir -i 1 $remote_dir
4936 do_facet mds2 $LCTL set_param seq.srv*MDT0001.space=clear
4938 zconf_mount $(hostname) $MOUNT
4939 client_up || return 1
4941 #define OBD_FAIL_MDS_ALL_REQUEST_NET 0x123
4943 do_facet mds1 $LCTL set_param fail_val=700 fail_loc=0x80000123
4944 cp /etc/hosts $remote_dir/file &
4950 wait $pid || error "cp failed"
4951 rm -rf $DIR/$tdir || error "rmdir failed"
4955 run_test 133 "check resend of ongoing requests for lwp during failover"
4958 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs" && return 0
4959 (( $MDS1_VERSION >= $(version_code 2.13.56) )) ||
4960 skip "need MDS version >= 2.13.56"
4963 pool_add_targets pool_134 1 1
4965 mkdir -p $DIR/$tdir/{A,B}
4966 $LFS setstripe -p pool_134 $DIR/$tdir/A
4967 $LFS setstripe -E EOF -p pool_134 $DIR/$tdir/B
4971 touch $DIR/$tdir/A/$tfile || error "touch non-pfl file failed"
4972 touch $DIR/$tdir/B/$tfile || error "touch pfl failed"
4976 [ -f $DIR/$tdir/A/$tfile ] || error "non-pfl file does not exist"
4977 [ -f $DIR/$tdir/B/$tfile ] || error "pfl file does not exist"
4979 run_test 134 "replay creation of a file created in a pool"
4986 # make sure we are using the primary server
4987 [[ $(facet_active ost1) == "ost1" ]] || fail ost1
4989 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
4992 $LFS setstripe -S $((128 * 1024)) -i 0 $DIR/$tdir
4994 # Init all the clients connections (write lastrcv on the OST)
4998 old_replay=$($LCTL get_param ldlm.cancel_unused_locks_before_replay)
4999 $LCTL set_param ldlm.cancel_unused_locks_before_replay=0
5000 stack_trap "$LCTL set_param $old_replay" EXIT
5002 # Create 20 files so we have 20 ost locks
5003 for i in $(seq 20) ; do
5004 echo blah > $DIR/$tdir/file.${i} & PID+="$! "
5012 #define OBD_FAIL_LDLM_LOCK_REPLAY 0x32d
5013 # Make sure lock replay server side never completes and errors out.
5014 do_rpc_nodes $(facet_active_host ost1) \
5015 load_module ../libcfs/libcfs/libcfs
5016 do_facet ost1 "$LCTL set_param fail_loc=0x32d fail_val=20"
5019 # Now make sure we notice
5020 (sync;sync;sync;echo "End of sync") & PID=$!
5021 wait_clients_import_state ${HOSTNAME} ost1 REPLAY_LOCKS
5022 kill -0 $PID || error "Unexpected sync success"
5029 do_rpc_nodes $(facet_active_host ost1) \
5030 load_module ../libcfs/libcfs/libcfs
5031 do_facet ost1 "$LCTL set_param fail_loc=0"
5035 clients_up || clients_up || error "$LFS df $MOUNT failed"
5037 wait $PID || error "Fail to sync"
5038 echo blah > $DIR/$tdir/file.test2
5042 run_test 135 "Server failure in lock replay phase"
5045 (( $MDSCOUNT >= 3 )) || skip "needs > 2 MDTs"
5046 (( MDS1_VERSION >= $(version_code 2.15.53) )) ||
5047 skip "need MDS version >= 2.15.53 for LU-16536 fix"
5049 $LFS mkdir -i0 -c3 $DIR/$tdir || error "can't mkdir"
5050 $LFS getdirstripe $DIR/$tdir
5053 #define OBD_FAIL_OUT_DROP_DESTROY 0x170b
5054 local mdts=$(comma_list $(mdts_nodes))
5055 do_nodes $mdts $LCTL set_param fail_loc=0x170b
5061 start mds1 $(mdsdevname 1) $MDS_MOUNT_OPTS || error "MDT1 start failed"
5062 start mds2 $(mdsdevname 2) $MDS_MOUNT_OPTS || error "MDT2 start failed"
5063 start mds3 $(mdsdevname 3) $MDS_MOUNT_OPTS || error "MDT3 star"
5065 run_test 136 "MDS to disconnect all OSPs first, then cleanup ldlm"
5068 [[ -z $RCLIENTS ]] && skip "Need remote client"
5072 rcli=$(echo $RCLIENTS | cut -d ' ' -f 1)
5074 echo "Selected \"$rcli\" from \"$RCLIENTS\""
5076 # We want idle disconnect enabled on all targets except OST0000. Test
5077 # assumes all nodes are configured the same.
5078 old=$(do_node $rcli "$LCTL get_param -n *.*.idle_timeout 2>/dev/null |
5080 [[ -n $old ]] || error "Cannot determine current idle_timeout"
5082 if ((old == 0)); then
5083 do_node "$rcli" "$LCTL set_param *.*.idle_timeout=10"
5084 do_node "$rcli" "$LCTL set_param osc.*OST0000*.idle_timeout=0"
5085 stack_trap "do_node $rcli $LCTL set_param *.*.idle_timeout=$old"
5087 do_node "$rcli" "$LCTL set_param osc.*OST0000*.idle_timeout=0"
5088 stack_trap "do_node $rcli $LCTL set_param osc.*OST0000*.idle_timeout=$old"
5091 # Ensure OST0 import is idle
5092 wait_update "$rcli" \
5093 "$LCTL get_param osc.*OST0000*.import | \
5094 awk 'BEGIN{ count=0 } /idle: 0/ { count+=1 } \
5095 END { print count }'" \
5098 (( $? != 0 )) && error "OST0000 not idle after 30s"
5100 # Send ping to ensure import is FULL
5101 do_node "$rcli" "lctl set_param osc.*OST0000*.ping=1" ||
5102 error "OBD ping failed"
5106 conns=( $(do_node "$rcli" "$LCTL get_param *.*.import" |
5107 awk '/connection_attempts:/{print $NF}' | xargs echo) )
5111 saved_debug=$(do_node "$rcli" \
5112 "cat /sys/module/libcfs/parameters/libcfs_debug" \
5114 [[ -z $saved_debug ]] && error "Failed to get existing debug"
5115 stack_trap "do_node $rcli $LCTL set_param debug=$saved_debug"
5116 do_node "$rcli" "$LCTL set_param debug=+info+rpctrace"
5118 # From lustre/obdclass/class_obd.c
5119 # unsigned int ping_interval = (OBD_TIMEOUT_DEFAULT > 4) ?
5120 # (OBD_TIMEOUT_DEFAULT / 4) : 1;
5121 # Delay a ping for 3 intervals
5124 timeout=$(do_node "$rcli" "$LCTL get_param -n timeout")
5125 (( timeout > 4 )) && delay=$((3 * timeout / 4)) || delay=3
5127 do_node "$rcli" "$LCTL clear"
5128 log "delay ping ${delay}s"
5130 #define OBD_FAIL_PTLRPC_DELAY_SEND_FAIL 0x535
5131 do_node "$rcli" "$LCTL set_param fail_loc=0x80000535 fail_val=${delay}"
5132 # Send ping that will be delayed for ${delay} seconds
5133 # This races with the pinger, but it is okay if a ping sent by pinger
5134 # thread is delayed instead
5135 do_node "$rcli" "lctl set_param osc.*OST0000*.ping=1"
5137 local logfile="$TMP/lustre-log-${TESTNAME}.log"
5141 local begin=$SECONDS
5142 local max_wait=$((delay + 1))
5145 while (( $waited <= $max_wait )); do
5146 [[ -z $sleep ]] || sleep $sleep
5148 waited=$((SECONDS - begin))
5149 do_node "$rcli" "$LCTL dk" >> ${logfile}
5151 if ! grep -q 'fail_timeout id 535 sleeping for' $logfile; then
5152 reason="Did not hit fail_loc"
5156 if ! grep -q 'cfs_fail_timeout id 535 awake' $logfile; then
5157 reason="Delayed send did not wake"
5161 nsent=$(grep -c "ptl_send_rpc.*o400->.*OST0000" $logfile)
5162 if (( nsent <= 1 )); then
5163 reason="Did not send more than 1 obd ping"
5167 expired=$(grep "Request sent has timed out .* o400->" $logfile)
5168 if [[ -z $expired ]]; then
5169 reason="RPC did not time out"
5176 if [[ -n $reason ]]; then
5187 conns2=( $(do_node "$rcli" "$LCTL get_param *.*.import" |
5188 awk '/connection_attempts:/{print $NF}' | xargs echo) )
5190 echo "conns: ${conns[*]}"
5192 echo "conns2: ${conns2[*]}"
5194 (( ${#conns[@]} != ${#conns2[@]} )) &&
5195 error "Expected ${#conns[@]} imports found ${#conns2[@]}"
5199 for ((i = 0; i < ${#conns[@]}; i++)); do
5200 if (( conns[i] != conns2[i] )); then
5201 error "New connection attempt ${conns[i]} -> ${conns2[i]}"
5207 run_test 200 "Dropping one OBD_PING should not cause disconnect"
5209 complete_test $SECONDS
5210 check_and_cleanup_lustre