5 LUSTRE=${LUSTRE:-$(dirname $0)/..}
6 . $LUSTRE/tests/test-framework.sh
10 ALWAYS_EXCEPT="$REPLAY_SINGLE_EXCEPT "
11 # bug number for skipped test: LU-13614
14 if [ "$mds1_FSTYPE" = zfs ]; then
19 # bug number for skipped tests: LU-9795
20 ALWAYS_EXCEPT="$ALWAYS_EXCEPT 121"
22 # UPDATE THE COMMENT ABOVE WITH BUG NUMBERS WHEN CHANGING ALWAYS_EXCEPT!
24 # bug number: LU-12805
29 CHECK_GRANT=${CHECK_GRANT:-"yes"}
30 GRANT_CHECK_LIST=${GRANT_CHECK_LIST:-""}
32 require_dsh_mds || exit 0
33 check_and_setup_lustre
38 rm -rf $DIR/[df][0-9]* $DIR/f.$TESTSUITE.*
40 # LU-482 Avert LVM and VM inability to flush caches in pre .33 kernels
41 if [ $LINUX_VERSION_CODE -lt $(version_code 2.6.33) ]; then
43 do_facet $SINGLEMDS sync
48 test_0a() { # was test_0
49 mkdir_on_mdt0 $DIR/$tdir || error "mkdir $DIR/$tdir failed"
50 replay_barrier $SINGLEMDS
54 run_test 0a "empty replay"
57 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
59 # this test attempts to trigger a race in the precreation code,
60 # and must run before any other objects are created on the filesystem
62 createmany -o $DIR/$tfile 20 || error "createmany -o $DIR/$tfile failed"
63 unlinkmany $DIR/$tfile 20 || error "unlinkmany $DIR/$tfile failed"
65 run_test 0b "ensure object created after recover exists. (3284)"
68 replay_barrier $SINGLEMDS
71 facet_failover $SINGLEMDS
72 zconf_mount $(hostname) $MOUNT || error "mount fails"
73 client_up || error "post-failover df failed"
74 # file shouldn't exist if replay-barrier works as expected
75 rm $DIR/$tfile && error "File exists and it shouldn't"
78 run_test 0c "check replay-barrier"
81 replay_barrier $SINGLEMDS
83 facet_failover $SINGLEMDS
84 zconf_mount $(hostname) $MOUNT || error "mount fails"
85 client_up || error "post-failover df failed"
87 run_test 0d "expired recovery with no clients"
90 replay_barrier $SINGLEMDS
93 $CHECKSTAT -t file $DIR/$tfile ||
94 error "$CHECKSTAT $DIR/$tfile attribute check failed"
97 run_test 1 "simple create"
100 replay_barrier $SINGLEMDS
103 $CHECKSTAT -t file $DIR/$tfile ||
104 error "$CHECKSTAT $DIR/$tfile attribute check failed"
110 mcreate $DIR/$tfile || error "mcreate $DIR/$tfile failed"
111 replay_barrier $SINGLEMDS
114 $CHECKSTAT -t file $DIR/$tfile ||
115 error "$CHECKSTAT $DIR/$tfile attribute check failed"
121 replay_barrier $SINGLEMDS
122 $LFS setstripe -c $OSTCOUNT $DIR/$tfile
124 $CHECKSTAT -t file $DIR/$tfile ||
125 error "$CHECKSTAT $DIR/$tfile check failed"
127 run_test 2c "setstripe replay"
130 [[ "$mds1_FSTYPE" = zfs ]] &&
131 [[ "$MDS1_VERSION" -lt $(version_code 2.12.51) ]] &&
132 skip "requires LU-10143 fix on MDS"
133 replay_barrier $SINGLEMDS
134 $LFS setdirstripe -i 0 -c $MDSCOUNT $DIR/$tdir
136 $CHECKSTAT -t dir $DIR/$tdir ||
137 error "$CHECKSTAT $DIR/$tdir check failed"
139 run_test 2d "setdirstripe replay"
142 testid=$(echo $TESTNAME | tr '_' ' ')
143 #define OBD_FAIL_MDS_CLOSE_NET_REP 0x13b
144 do_facet $SINGLEMDS "$LCTL set_param fail_loc=0x8000013b"
145 openfile -f O_CREAT:O_EXCL $DIR/$tfile &
147 replay_barrier $SINGLEMDS
150 $CHECKSTAT -t file $DIR/$tfile ||
151 error "$CHECKSTAT $DIR/$tfile attribute check failed"
152 dmesg | tac | sed "/$testid/,$ d" | \
153 grep "Open request replay failed with -17" &&
154 error "open replay failed" || true
156 run_test 2e "O_CREAT|O_EXCL create replay"
159 local file=$DIR/$tfile
160 replay_barrier $SINGLEMDS
162 openfile -f O_DIRECTORY $file
164 $CHECKSTAT -t file $file ||
165 error "$CHECKSTAT $file attribute check failed"
168 run_test 3a "replay failed open(O_DIRECTORY)"
171 replay_barrier $SINGLEMDS
172 #define OBD_FAIL_MDS_OPEN_PACK | OBD_FAIL_ONCE
173 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000114"
175 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 3b "replay failed open -ENOMEM"
184 replay_barrier $SINGLEMDS
185 #define OBD_FAIL_MDS_ALLOC_OBDO | OBD_FAIL_ONCE
186 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000128"
188 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
191 $CHECKSTAT -t file $DIR/$tfile &&
192 error "$CHECKSTAT $DIR/$tfile attribute check should fail"
195 run_test 3c "replay failed open -ENOMEM"
197 test_4a() { # was test_4
198 replay_barrier $SINGLEMDS
199 for i in $(seq 10); do
200 echo "tag-$i" > $DIR/$tfile-$i
203 for i in $(seq 10); do
204 grep -q "tag-$i" $DIR/$tfile-$i || error "$tfile-$i"
207 run_test 4a "|x| 10 open(O_CREAT)s"
210 for i in $(seq 10); do
211 echo "tag-$i" > $DIR/$tfile-$i
213 replay_barrier $SINGLEMDS
216 $CHECKSTAT -t file $DIR/$tfile-* &&
217 error "$CHECKSTAT $DIR/$tfile-* attribute check should fail" ||
220 run_test 4b "|x| rm 10 files"
222 # The idea is to get past the first block of precreated files on both
223 # osts, and then replay.
225 replay_barrier $SINGLEMDS
226 for i in $(seq 220); do
227 echo "tag-$i" > $DIR/$tfile-$i
230 for i in $(seq 220); do
231 grep -q "tag-$i" $DIR/$tfile-$i || error "$tfile-$i"
235 # waiting for commitment of removal
237 run_test 5 "|x| 220 open(O_CREAT)"
239 test_6a() { # was test_6
240 mkdir_on_mdt0 $DIR/$tdir || error "mkdir $DIR/$tdir failed"
241 replay_barrier $SINGLEMDS
242 mcreate $DIR/$tdir/$tfile
244 $CHECKSTAT -t dir $DIR/$tdir ||
245 error "$CHECKSTAT $DIR/$tdir attribute check failed"
246 $CHECKSTAT -t file $DIR/$tdir/$tfile ||
247 error "$CHECKSTAT $DIR/$tdir/$tfile attribute check failed"
249 # waiting for log process thread
251 run_test 6a "mkdir + contained create"
254 mkdir_on_mdt0 $DIR/$tdir || error "mkdir $DIR/$tdir failed"
255 replay_barrier $SINGLEMDS
258 $CHECKSTAT -t dir $DIR/$tdir &&
259 error "$CHECKSTAT $DIR/$tdir attribute check should fail" ||
262 run_test 6b "|X| rmdir"
265 mkdir_on_mdt0 $DIR/$tdir || error "mkdir $DIR/$tdir failed"
266 replay_barrier $SINGLEMDS
267 mcreate $DIR/$tdir/$tfile
269 $CHECKSTAT -t dir $DIR/$tdir ||
270 error "$CHECKSTAT $DIR/$tdir attribute check failed"
271 $CHECKSTAT -t file $DIR/$tdir/$tfile ||
272 error "$CHECKSTAT $DIR/$tdir/$tfile attribute check failed"
275 run_test 7 "mkdir |X| contained create"
278 replay_barrier $SINGLEMDS
279 multiop_bg_pause $DIR/$tfile mo_c ||
280 error "multiop mknod $DIR/$tfile failed"
284 $CHECKSTAT -t file $DIR/$tfile ||
285 error "$CHECKSTAT $DIR/$tfile attribute check failed"
286 kill -USR1 $MULTIPID || error "multiop mknod $MULTIPID not running"
287 wait $MULTIPID || error "multiop mknod $MULTIPID failed"
290 run_test 8 "creat open |X| close"
293 replay_barrier $SINGLEMDS
295 local old_inum=$(ls -i $DIR/$tfile | awk '{print $1}')
297 local new_inum=$(ls -i $DIR/$tfile | awk '{print $1}')
299 echo " old_inum == $old_inum, new_inum == $new_inum"
300 if [ $old_inum -eq $new_inum ] ;
302 echo "old_inum and new_inum match"
304 echo " old_inum and new_inum do not match"
305 error "old index($old_inum) does not match new index($new_inum)"
309 run_test 9 "|X| create (same inum/gen)"
312 mcreate $DIR/$tfile || error "mcreate $DIR/$tfile failed"
313 replay_barrier $SINGLEMDS
314 mv $DIR/$tfile $DIR/$tfile-2
317 $CHECKSTAT $DIR/$tfile &&
318 error "$CHECKSTAT $DIR/$tfile attribute check should fail"
319 $CHECKSTAT $DIR/$tfile-2 ||
320 error "$CHECKSTAT $DIR/$tfile-2 attribute check failed"
324 run_test 10 "create |X| rename unlink"
327 mcreate $DIR/$tfile || error "mcreate $DIR/$tfile failed"
328 echo "old" > $DIR/$tfile
329 mv $DIR/$tfile $DIR/$tfile-2
330 replay_barrier $SINGLEMDS
331 echo "new" > $DIR/$tfile
333 grep old $DIR/$tfile-2
335 grep new $DIR/$tfile || error "grep $DIR/$tfile failed"
336 grep old $DIR/$tfile-2 || error "grep $DIR/$tfile-2 failed"
338 run_test 11 "create open write rename |X| create-old-name read"
341 mcreate $DIR/$tfile || error "mcreate $DIR/$tfile failed"
342 multiop_bg_pause $DIR/$tfile o_tSc ||
343 error "multiop_bg_pause $DIR/$tfile failed"
346 replay_barrier $SINGLEMDS
347 kill -USR1 $pid || error "multiop $pid not running"
348 wait $pid || error "multiop $pid failed"
351 [ -e $DIR/$tfile ] && error "file $DIR/$tfile should not exist"
354 run_test 12 "open, unlink |X| close"
356 # 1777 - replay open after committed chmod that would make
357 # a regular open a failure
359 mcreate $DIR/$tfile || error "mcreate $DIR/$tfile failed"
360 multiop_bg_pause $DIR/$tfile O_wc ||
361 error "multiop_bg_pause $DIR/$tfile failed"
364 $CHECKSTAT -p 0 $DIR/$tfile ||
365 error "$CHECKSTAT $DIR/$tfile attribute check failed"
366 replay_barrier $SINGLEMDS
368 kill -USR1 $pid || error "multiop $pid not running"
369 wait $pid || error "multiop $pid failed"
371 $CHECKSTAT -s 1 -p 0 $DIR/$tfile ||
372 error "second $CHECKSTAT $DIR/$tfile attribute check failed"
373 rm $DIR/$tfile || error "rm $DIR/$tfile failed"
376 run_test 13 "open chmod 0 |x| write close"
379 multiop_bg_pause $DIR/$tfile O_tSc ||
380 error "multiop_bg_pause $DIR/$tfile failed"
383 replay_barrier $SINGLEMDS
384 kill -USR1 $pid || error "multiop $pid not running"
385 wait $pid || error "multiop $pid failed"
388 [ -e $DIR/$tfile ] && error "file $DIR/$tfile should not exist"
391 run_test 14 "open(O_CREAT), unlink |X| close"
394 multiop_bg_pause $DIR/$tfile O_tSc ||
395 error "multiop_bg_pause $DIR/$tfile failed"
398 replay_barrier $SINGLEMDS
399 touch $DIR/$tfile-1 || error "touch $DIR/$tfile-1 failed"
400 kill -USR1 $pid || error "multiop $pid not running"
401 wait $pid || error "multiop $pid failed"
404 [ -e $DIR/$tfile ] && error "file $DIR/$tfile should not exist"
405 touch $DIR/$tfile-2 || error "touch $DIR/$tfile-2 failed"
408 run_test 15 "open(O_CREAT), unlink |X| touch new, close"
411 replay_barrier $SINGLEMDS
414 mcreate $DIR/$tfile-2
416 [ -e $DIR/$tfile ] && error "file $DIR/$tfile should not exist"
417 [ -e $DIR/$tfile-2 ] || error "file $DIR/$tfile-2 does not exist"
418 munlink $DIR/$tfile-2 || error "munlink $DIR/$tfile-2 failed"
420 run_test 16 "|X| open(O_CREAT), unlink, touch new, unlink new"
423 replay_barrier $SINGLEMDS
424 multiop_bg_pause $DIR/$tfile O_c ||
425 error "multiop_bg_pause $DIR/$tfile failed"
428 kill -USR1 $pid || error "multiop $pid not running"
429 wait $pid || error "multiop $pid failed"
430 $CHECKSTAT -t file $DIR/$tfile ||
431 error "$CHECKSTAT $DIR/$tfile attribute check failed"
434 run_test 17 "|X| open(O_CREAT), |replay| close"
437 replay_barrier $SINGLEMDS
438 multiop_bg_pause $DIR/$tfile O_tSc ||
439 error "multiop_bg_pause $DIR/$tfile failed"
442 touch $DIR/$tfile-2 || error "touch $DIR/$tfile-2 failed"
443 echo "pid: $pid will close"
444 kill -USR1 $pid || error "multiop $pid not running"
445 wait $pid || error "multiop $pid failed"
448 [ -e $DIR/$tfile ] && error "file $DIR/$tfile should not exist"
449 [ -e $DIR/$tfile-2 ] || error "file $DIR/$tfile-2 does not exist"
450 # this touch frequently fails
451 touch $DIR/$tfile-3 || error "touch $DIR/$tfile-3 failed"
452 munlink $DIR/$tfile-2 || error "munlink $DIR/$tfile-2 failed"
453 munlink $DIR/$tfile-3 || error "munlink $DIR/$tfile-3 failed"
456 run_test 18 "open(O_CREAT), unlink, touch new, close, touch, unlink"
458 # bug 1855 (a simpler form of test_11 above)
460 replay_barrier $SINGLEMDS
462 echo "old" > $DIR/$tfile
463 mv $DIR/$tfile $DIR/$tfile-2
464 grep old $DIR/$tfile-2
466 grep old $DIR/$tfile-2 || error "grep $DIR/$tfile-2 failed"
468 run_test 19 "mcreate, open, write, rename "
470 test_20a() { # was test_20
471 replay_barrier $SINGLEMDS
472 multiop_bg_pause $DIR/$tfile O_tSc ||
473 error "multiop_bg_pause $DIR/$tfile failed"
478 kill -USR1 $pid || error "multiop $pid not running"
479 wait $pid || error "multiop $pid failed"
480 [ -e $DIR/$tfile ] && error "file $DIR/$tfile should not exist"
483 run_test 20a "|X| open(O_CREAT), unlink, replay, close (test mds_cleanup_orphans)"
485 test_20b() { # bug 10480
486 local wait_timeout=$((TIMEOUT * 4))
487 local extra=$(fs_log_size)
491 save_layout_restore_at_exit $MOUNT
492 $LFS setstripe -i 0 -c 1 $DIR
494 local beforeused=$(df -P $DIR | tail -1 | awk '{ print $3 }')
496 dd if=/dev/zero of=$DIR/$tfile bs=4k count=10000 &
497 while [ ! -e $DIR/$tfile ] ; do
498 sleep 0.01 # give dd a chance to start
501 $LFS getstripe $DIR/$tfile || error "$LFS getstripe $DIR/$tfile failed"
503 rm -f $DIR/$tfile || error "rm -f $DIR/$tfile failed"
505 client_up || client_up || true # reconnect
507 do_facet $SINGLEMDS "lctl set_param -n osd*.*MDT*.force_sync=1"
509 fail $SINGLEMDS # start orphan recovery
510 wait_recovery_complete $SINGLEMDS || error "MDS recovery not done"
511 wait_delete_completed $wait_timeout || error "delete did not finish"
515 local afterused=$(df -P $DIR | tail -1 | awk '{ print $3 }')
516 log "before $beforeused, after $afterused"
518 (( $beforeused + $extra >= $afterused )) && break
519 n_attempts=$((n_attempts + 1))
520 [ $n_attempts -gt 3 ] &&
521 error "after $afterused > before $beforeused + $extra"
523 wait_zfs_commit $SINGLEMDS 5
528 run_test 20b "write, unlink, eviction, replay (test mds_cleanup_orphans)"
530 test_20c() { # bug 10480
531 multiop_bg_pause $DIR/$tfile Ow_c ||
532 error "multiop_bg_pause $DIR/$tfile failed"
538 client_up || client_up || true # reconnect
540 kill -USR1 $pid || error "multiop $pid not running"
541 wait $pid || error "multiop $pid failed"
542 [ -s $DIR/$tfile ] || error "File was truncated"
546 run_test 20c "check that client eviction does not affect file content"
549 replay_barrier $SINGLEMDS
550 multiop_bg_pause $DIR/$tfile O_tSc ||
551 error "multiop_bg_pause $DIR/$tfile failed"
554 touch $DIR/$tfile-1 || error "touch $DIR/$tfile-1 failed"
557 kill -USR1 $pid || error "multiop $pid not running"
558 wait $pid || error "multiop $pid failed"
559 [ -e $DIR/$tfile ] && error "file $DIR/$tfile should not exist"
560 touch $DIR/$tfile-2 || error "touch $DIR/$tfile-2 failed"
563 run_test 21 "|X| open(O_CREAT), unlink touch new, replay, close (test mds_cleanup_orphans)"
566 multiop_bg_pause $DIR/$tfile O_tSc ||
567 error "multiop_bg_pause $DIR/$tfile failed"
570 replay_barrier $SINGLEMDS
574 kill -USR1 $pid || error "multiop $pid not running"
575 wait $pid || error "multiop $pid failed"
576 [ -e $DIR/$tfile ] && error "file $DIR/$tfile should not exist"
579 run_test 22 "open(O_CREAT), |X| unlink, replay, close (test mds_cleanup_orphans)"
582 multiop_bg_pause $DIR/$tfile O_tSc ||
583 error "multiop_bg_pause $DIR/$tfile failed"
586 replay_barrier $SINGLEMDS
588 touch $DIR/$tfile-1 || error "touch $DIR/$tfile-1 failed"
591 kill -USR1 $pid || error "multiop $pid not running"
592 wait $pid || error "multiop $pid failed"
593 [ -e $DIR/$tfile ] && error "file $DIR/$tfile should not exist"
594 touch $DIR/$tfile-2 || error "touch $DIR/$tfile-2 failed"
597 run_test 23 "open(O_CREAT), |X| unlink touch new, replay, close (test mds_cleanup_orphans)"
600 multiop_bg_pause $DIR/$tfile O_tSc ||
601 error "multiop_bg_pause $DIR/$tfile failed"
604 replay_barrier $SINGLEMDS
607 kill -USR1 $pid || error "multiop $pid not running"
608 wait $pid || error "multiop $pid failed"
609 [ -e $DIR/$tfile ] && error "file $DIR/$tfile should not exist"
612 run_test 24 "open(O_CREAT), replay, unlink, close (test mds_cleanup_orphans)"
615 multiop_bg_pause $DIR/$tfile O_tSc ||
616 error "multiop_bg_pause $DIR/$tfile failed"
620 replay_barrier $SINGLEMDS
622 kill -USR1 $pid || error "multiop $pid not running"
623 wait $pid || error "multiop $pid failed"
624 [ -e $DIR/$tfile ] && error "file $DIR/$tfile should not exist"
627 run_test 25 "open(O_CREAT), unlink, replay, close (test mds_cleanup_orphans)"
630 replay_barrier $SINGLEMDS
631 multiop_bg_pause $DIR/$tfile-1 O_tSc ||
632 error "multiop_bg_pause $DIR/$tfile-1 failed"
634 multiop_bg_pause $DIR/$tfile-2 O_tSc ||
635 error "multiop_bg_pause $DIR/$tfile-2 failed"
639 kill -USR1 $pid2 || error "second multiop $pid2 not running"
640 wait $pid2 || error "second multiop $pid2 failed"
643 kill -USR1 $pid1 || error "multiop $pid1 not running"
644 wait $pid1 || error "multiop $pid1 failed"
645 [ -e $DIR/$tfile-1 ] && error "file $DIR/$tfile-1 should not exist"
646 [ -e $DIR/$tfile-2 ] && error "file $DIR/$tfile-2 should not exist"
649 run_test 26 "|X| open(O_CREAT), unlink two, close one, replay, close one (test mds_cleanup_orphans)"
652 replay_barrier $SINGLEMDS
653 multiop_bg_pause $DIR/$tfile-1 O_tSc ||
654 error "multiop_bg_pause $DIR/$tfile-1 failed"
656 multiop_bg_pause $DIR/$tfile-2 O_tSc ||
657 error "multiop_bg_pause $DIR/$tfile-2 failed"
663 kill -USR1 $pid1 || error "multiop $pid1 not running"
664 wait $pid1 || error "multiop $pid1 failed"
665 kill -USR1 $pid2 || error "second multiop $pid2 not running"
666 wait $pid2 || error "second multiop $pid2 failed"
667 [ -e $DIR/$tfile-1 ] && error "file $DIR/$tfile-1 should not exist"
668 [ -e $DIR/$tfile-2 ] && error "file $DIR/$tfile-2 should not exist"
671 run_test 27 "|X| open(O_CREAT), unlink two, replay, close two (test mds_cleanup_orphans)"
674 multiop_bg_pause $DIR/$tfile-1 O_tSc ||
675 error "multiop_bg_pause $DIR/$tfile-1 failed"
677 multiop_bg_pause $DIR/$tfile-2 O_tSc ||
678 error "multiop_bg_pause $DIR/$tfile-2 failed"
680 replay_barrier $SINGLEMDS
683 kill -USR1 $pid2 || error "second multiop $pid2 not running"
684 wait $pid2 || error "second multiop $pid2 failed"
687 kill -USR1 $pid1 || error "multiop $pid1 not running"
688 wait $pid1 || error "multiop $pid1 failed"
689 [ -e $DIR/$tfile-1 ] && error "file $DIR/$tfile-1 should not exist"
690 [ -e $DIR/$tfile-2 ] && error "file $DIR/$tfile-2 should not exist"
693 run_test 28 "open(O_CREAT), |X| unlink two, close one, replay, close one (test mds_cleanup_orphans)"
696 multiop_bg_pause $DIR/$tfile-1 O_tSc ||
697 error "multiop_bg_pause $DIR/$tfile-1 failed"
699 multiop_bg_pause $DIR/$tfile-2 O_tSc ||
700 error "multiop_bg_pause $DIR/$tfile-2 failed"
702 replay_barrier $SINGLEMDS
707 kill -USR1 $pid1 || error "multiop $pid1 not running"
708 wait $pid1 || error "multiop $pid1 failed"
709 kill -USR1 $pid2 || error "second multiop $pid2 not running"
710 wait $pid2 || error "second multiop $pid2 failed"
711 [ -e $DIR/$tfile-1 ] && error "file $DIR/$tfile-1 should not exist"
712 [ -e $DIR/$tfile-2 ] && error "file $DIR/$tfile-2 should not exist"
715 run_test 29 "open(O_CREAT), |X| unlink two, replay, close two (test mds_cleanup_orphans)"
718 multiop_bg_pause $DIR/$tfile-1 O_tSc ||
719 error "multiop_bg_pause $DIR/$tfile-1 failed"
721 multiop_bg_pause $DIR/$tfile-2 O_tSc ||
722 error "multiop_bg_pause $DIR/$tfile-2 failed"
727 replay_barrier $SINGLEMDS
729 kill -USR1 $pid1 || error "multiop $pid1 not running"
730 wait $pid1 || error "multiop $pid1 failed"
731 kill -USR1 $pid2 || error "second multiop $pid2 not running"
732 wait $pid2 || error "second multiop $pid2 failed"
733 [ -e $DIR/$tfile-1 ] && error "file $DIR/$tfile-1 should not exist"
734 [ -e $DIR/$tfile-2 ] && error "file $DIR/$tfile-2 should not exist"
737 run_test 30 "open(O_CREAT) two, unlink two, replay, close two (test mds_cleanup_orphans)"
740 multiop_bg_pause $DIR/$tfile-1 O_tSc ||
741 error "multiop_bg_pause $DIR/$tfile-1 failed"
743 multiop_bg_pause $DIR/$tfile-2 O_tSc ||
744 error "multiop_bg_pause $DIR/$tfile-2 failed"
748 replay_barrier $SINGLEMDS
751 kill -USR1 $pid1 || error "multiop $pid1 not running"
752 wait $pid1 || error "multiop $pid1 failed"
753 kill -USR1 $pid2 || error "second multiop $pid2 not running"
754 wait $pid2 || error "second multiop $pid2 failed"
755 [ -e $DIR/$tfile-1 ] && error "file $DIR/$tfile-1 should not exist"
756 [ -e $DIR/$tfile-2 ] && error "file $DIR/$tfile-2 should not exist"
759 run_test 31 "open(O_CREAT) two, unlink one, |X| unlink one, close two (test mds_cleanup_orphans)"
761 # tests for bug 2104; completion without crashing is success. The close is
762 # stale, but we always return 0 for close, so the app never sees it.
764 multiop_bg_pause $DIR/$tfile O_c ||
765 error "multiop_bg_pause $DIR/$tfile failed"
767 multiop_bg_pause $DIR/$tfile O_c ||
768 error "second multiop_bg_pause $DIR/$tfile failed"
771 client_up || client_up || error "client_up failed"
772 kill -USR1 $pid1 || error "multiop $pid1 not running"
773 kill -USR1 $pid2 || error "second multiop $pid2 not running"
774 wait $pid1 || error "multiop $pid1 failed"
775 wait $pid2 || error "second multiop $pid2 failed"
778 run_test 32 "close() notices client eviction; close() after client eviction"
781 createmany -o $DIR/$tfile-%d 10 ||
782 error "createmany create $DIR/$tfile failed"
783 replay_barrier_nosync $SINGLEMDS
784 fail_abort $SINGLEMDS
785 # recreate shouldn't fail
786 createmany -o $DIR/$tfile--%d 10 ||
787 error "createmany recreate $DIR/$tfile failed"
791 run_test 33a "fid seq shouldn't be reused after abort recovery"
794 #define OBD_FAIL_SEQ_ALLOC 0x1311
795 do_facet $SINGLEMDS "lctl set_param fail_loc=0x1311"
797 createmany -o $DIR/$tfile-%d 10
798 replay_barrier_nosync $SINGLEMDS
799 fail_abort $SINGLEMDS
800 # recreate shouldn't fail
801 createmany -o $DIR/$tfile--%d 10 ||
802 error "createmany recreate $DIR/$tfile failed"
806 run_test 33b "test fid seq allocation"
809 multiop_bg_pause $DIR/$tfile O_c ||
810 error "multiop_bg_pause $DIR/$tfile failed"
814 replay_barrier $SINGLEMDS
815 fail_abort $SINGLEMDS
816 kill -USR1 $pid || error "multiop $pid not running"
817 wait $pid || error "multiop $pid failed"
818 [ -e $DIR/$tfile ] && error "file $DIR/$tfile should not exist"
822 run_test 34 "abort recovery before client does replay (test mds_cleanup_orphans)"
824 # bug 2278 - generate one orphan on OST, then destroy it during recovery from llog
826 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
828 #define OBD_FAIL_MDS_REINT_NET_REP 0x119
829 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000119"
834 # give a chance to remove from MDS
835 fail_abort $SINGLEMDS
836 $CHECKSTAT -t file $DIR/$tfile &&
837 error "$CHECKSTAT $DIR/$tfile attribute check should fail" ||
840 run_test 35 "test recovery from llog for unlink op"
842 # b=2432 resent cancel after replay uses wrong cookie,
843 # so don't resend cancels
845 replay_barrier $SINGLEMDS
847 checkstat $DIR/$tfile
848 facet_failover $SINGLEMDS
850 if do_facet $SINGLEMDS $LCTL dk | grep "stale lock .*cookie"; then
851 error "cancel after replay failed"
854 run_test 36 "don't resend cancel"
857 # directory orphans can't be unlinked from PENDING directory
859 mkdir_on_mdt0 $DIR/$tdir || error "mkdir $tdir failed"
860 rmdir $DIR/$tdir/$tfile 2>/dev/null
861 multiop_bg_pause $DIR/$tdir/$tfile dD_c ||
862 error "multiop_bg_pause $tfile failed"
864 rmdir $DIR/$tdir/$tfile
866 replay_barrier $SINGLEMDS
867 # clear the dmesg buffer so we only see errors from this recovery
868 do_facet $SINGLEMDS dmesg -c >/dev/null
869 fail_abort $SINGLEMDS
870 kill -USR1 $pid || error "multiop $pid not running"
871 do_facet $SINGLEMDS dmesg | grep "error unlinking orphan" &&
872 error "error unlinking files"
873 wait $pid || error "multiop $pid failed"
877 run_test 37 "abort recovery before client does replay (test mds_cleanup_orphans for directories)"
880 createmany -o $DIR/$tfile-%d 800 ||
881 error "createmany -o $DIR/$tfile failed"
882 unlinkmany $DIR/$tfile-%d 0 400 || error "unlinkmany $DIR/$tfile failed"
883 replay_barrier $SINGLEMDS
885 unlinkmany $DIR/$tfile-%d 400 400 ||
886 error "unlinkmany $DIR/$tfile 400 failed"
888 $CHECKSTAT -t file $DIR/$tfile-* &&
889 error "$CHECKSTAT $DIR/$tfile-* attribute check should fail" ||
892 run_test 38 "test recovery from unlink llog (test llog_gen_rec) "
894 test_39() { # bug 4176
895 createmany -o $DIR/$tfile-%d 800 ||
896 error "createmany -o $DIR/$tfile failed"
897 replay_barrier $SINGLEMDS
898 unlinkmany $DIR/$tfile-%d 0 400
900 unlinkmany $DIR/$tfile-%d 400 400 ||
901 error "unlinkmany $DIR/$tfile 400 failed"
903 $CHECKSTAT -t file $DIR/$tfile-* &&
904 error "$CHECKSTAT $DIR/$tfile-* attribute check should fail" ||
907 run_test 39 "test recovery from unlink llog (test llog_gen_rec) "
910 lctl get_param -n osc.*.stats | awk -vwrites=0 '/ost_write/ { writes += $2 } END { print writes; }'
914 # make sure that a read to one osc doesn't try to double-unlock its page just
915 # because another osc is invalid. trigger_group_io used to mistakenly return
916 # an error if any oscs were invalid even after having successfully put rpcs
917 # on valid oscs. This was fatal if the caller was ll_readpage who unlocked
918 # the page, guarnateeing that the unlock from the RPC completion would
919 # assert on trying to unlock the unlocked page.
921 [ $OSTCOUNT -lt 2 ] && skip_env "needs >= 2 OSTs" && return
923 local f=$MOUNT/$tfile
924 # make sure the start of the file is ost1
925 $LFS setstripe -S $((128 * 1024)) -i 0 $f
926 do_facet client dd if=/dev/zero of=$f bs=4k count=1 ||
927 error "dd on client failed"
929 # fail ost2 and read from ost1
930 local mdtosc=$(get_mdtosc_proc_path $SINGLEMDS $ost2_svc)
931 local osc2dev=$(do_facet $SINGLEMDS "lctl get_param -n devices" |
932 grep $mdtosc | awk '{print $1}')
933 [ -z "$osc2dev" ] && echo "OST: $ost2_svc" &&
934 lctl get_param -n devices &&
935 error "OST 2 $osc2dev does not exist"
936 do_facet $SINGLEMDS $LCTL --device $osc2dev deactivate ||
937 error "deactive device on $SINGLEMDS failed"
938 do_facet client dd if=$f of=/dev/null bs=4k count=1 ||
939 error "second dd on client failed"
940 do_facet $SINGLEMDS $LCTL --device $osc2dev activate ||
941 error "active device on $SINGLEMDS failed"
944 run_test 41 "read from a valid osc while other oscs are invalid"
946 # test MDS recovery after ost failure
948 blocks=$(df -P $MOUNT | tail -n 1 | awk '{ print $2 }')
949 createmany -o $DIR/$tfile-%d 800 ||
950 error "createmany -o $DIR/$tfile failed"
952 unlinkmany $DIR/$tfile-%d 0 400
954 lctl set_param debug=-1
957 # osc is evicted, fs is smaller (but only with failout OSTs (bug 7287)
958 #blocks_after=`df -P $MOUNT | tail -n 1 | awk '{ print $2 }'`
959 #[ $blocks_after -lt $blocks ] || return 1
960 echo "wait for MDS to timeout and recover"
961 sleep $((TIMEOUT * 2))
963 unlinkmany $DIR/$tfile-%d 400 400 ||
964 error "unlinkmany $DIR/$tfile 400 failed"
965 $CHECKSTAT -t file $DIR/$tfile-* &&
966 error "$CHECKSTAT $DIR/$tfile-* attribute check should fail" ||
969 run_test 42 "recovery after ost failure"
971 # timeout in MDS/OST recovery RPC will LBUG MDS
972 test_43() { # bug 2530
973 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
975 replay_barrier $SINGLEMDS
977 # OBD_FAIL_OST_CREATE_NET 0x204
978 do_facet ost1 "lctl set_param fail_loc=0x80000204"
984 run_test 43 "mds osc import failure during recovery; don't LBUG"
986 test_44a() { # was test_44
989 local mdcdev=$($LCTL dl |
990 awk "/${FSNAME}-MDT0000-mdc-/ {if (\$2 == \"UP\") {print \$1}}")
991 [ "$mdcdev" ] || error "${FSNAME}-MDT0000-mdc- not UP"
992 [ $(echo $mdcdev | wc -w) -eq 1 ] ||
993 { $LCTL dl; error "looking for mdcdev=$mdcdev"; }
995 # adaptive timeouts slow this way down
996 if at_is_enabled; then
997 at_max_saved=$(at_max_get mds)
1001 for i in $(seq 1 10); do
1002 echo "$i of 10 ($(date +%s))"
1003 do_facet $SINGLEMDS \
1004 "lctl get_param -n md[ts].*.mdt.timeouts | grep service"
1005 #define OBD_FAIL_TGT_CONN_RACE 0x701
1006 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000701"
1007 # lctl below may fail, it is valid case
1008 $LCTL --device $mdcdev recover
1011 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
1012 [ $at_max_saved -ne 0 ] && at_max_set $at_max_saved mds
1015 run_test 44a "race in target handle connect"
1018 local mdcdev=$($LCTL dl |
1019 awk "/${FSNAME}-MDT0000-mdc-/ {if (\$2 == \"UP\") {print \$1}}")
1020 [ "$mdcdev" ] || error "${FSNAME}-MDT0000-mdc not up"
1021 [ $(echo $mdcdev | wc -w) -eq 1 ] ||
1022 { echo mdcdev=$mdcdev; $LCTL dl;
1023 error "more than one ${FSNAME}-MDT0000-mdc"; }
1025 for i in $(seq 1 10); do
1026 echo "$i of 10 ($(date +%s))"
1027 do_facet $SINGLEMDS \
1028 "lctl get_param -n md[ts].*.mdt.timeouts | grep service"
1029 #define OBD_FAIL_TGT_DELAY_RECONNECT 0x704
1030 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000704"
1031 # lctl below may fail, it is valid case
1032 $LCTL --device $mdcdev recover
1037 run_test 44b "race in target handle connect"
1040 replay_barrier $SINGLEMDS
1041 createmany -m $DIR/$tfile-%d 100 || error "failed to create directories"
1042 #define OBD_FAIL_TGT_RCVG_FLAG 0x712
1043 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000712"
1044 fail_abort $SINGLEMDS
1045 unlinkmany $DIR/$tfile-%d 100 && error "unliked after fail abort"
1047 unlinkmany $DIR/$tfile-%d 100 && error "unliked after fail"
1050 run_test 44c "race in target handle connect"
1052 # Handle failed close
1054 local mdcdev=$($LCTL get_param -n devices |
1055 awk "/ ${FSNAME}-MDT0000-mdc-/ {print \$1}")
1056 [ "$mdcdev" ] || error "${FSNAME}-MDT0000-mdc not up"
1057 [ $(echo $mdcdev | wc -w) -eq 1 ] ||
1058 { echo mdcdev=$mdcdev; $LCTL dl;
1059 error "more than one ${FSNAME}-MDT0000-mdc"; }
1061 $LCTL --device $mdcdev recover ||
1062 error "$LCTL --device $mdcdev recover failed"
1064 multiop_bg_pause $DIR/$tfile O_c ||
1065 error "multiop_bg_pause $DIR/$tfile failed"
1068 # This will cause the CLOSE to fail before even
1069 # allocating a reply buffer
1070 $LCTL --device $mdcdev deactivate ||
1071 error "$LCTL --device $mdcdev deactivate failed"
1074 kill -USR1 $pid || error "multiop $pid not running"
1075 wait $pid || error "multiop $pid failed"
1077 $LCTL --device $mdcdev activate ||
1078 error "$LCTL --device $mdcdev activate failed"
1081 $CHECKSTAT -t file $DIR/$tfile ||
1082 error "$CHECKSTAT $DIR/$tfile attribute check failed"
1085 run_test 45 "Handle failed close"
1088 drop_reply "touch $DIR/$tfile"
1090 # ironically, the previous test, 45, will cause a real forced close,
1091 # so just look for one for this test
1092 local FID=$($LFS path2fid $tfile)
1093 $LCTL dk | grep -i "force closing file handle $FID" &&
1094 error "found force closing in dmesg"
1097 run_test 46 "Don't leak file handle after open resend (3325)"
1099 test_47() { # bug 2824
1100 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1102 # create some files to make sure precreate has been done on all
1103 # OSTs. (just in case this test is run independently)
1104 createmany -o $DIR/$tfile 20 ||
1105 error "createmany create $DIR/$tfile failed"
1107 # OBD_FAIL_OST_CREATE_NET 0x204
1109 do_facet ost1 "lctl set_param fail_loc=0x80000204"
1110 client_up || error "client_up failed"
1112 # let the MDS discover the OST failure, attempt to recover, fail
1113 # and recover again.
1114 sleep $((3 * TIMEOUT))
1116 # Without 2824, this createmany would hang
1117 createmany -o $DIR/$tfile 20 ||
1118 error "createmany recraete $DIR/$tfile failed"
1119 unlinkmany $DIR/$tfile 20 || error "unlinkmany $DIR/$tfile failed"
1123 run_test 47 "MDS->OSC failure during precreate cleanup (2824)"
1126 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1127 [ "$OSTCOUNT" -lt "2" ] && skip_env "needs >= 2 OSTs" && return
1129 replay_barrier $SINGLEMDS
1130 createmany -o $DIR/$tfile 20 ||
1131 error "createmany -o $DIR/$tfile failed"
1132 # OBD_FAIL_OST_EROFS 0x216
1133 facet_failover $SINGLEMDS
1134 do_facet ost1 "lctl set_param fail_loc=0x80000216"
1135 client_up || error "client_up failed"
1137 # let the MDS discover the OST failure, attempt to recover, fail
1138 # and recover again.
1139 sleep $((3 * TIMEOUT))
1141 createmany -o $DIR/$tfile 20 20 ||
1142 error "createmany recraete $DIR/$tfile failed"
1143 unlinkmany $DIR/$tfile 40 || error "unlinkmany $DIR/$tfile failed"
1146 run_test 48 "MDS->OSC failure during precreate cleanup (2824)"
1149 local mdtosc=$(get_mdtosc_proc_path $SINGLEMDS $ost1_svc)
1150 local oscdev=$(do_facet $SINGLEMDS "lctl get_param -n devices" |
1151 grep $mdtosc | awk '{print $1}')
1152 [ "$oscdev" ] || error "could not find OSC device on MDS"
1153 do_facet $SINGLEMDS $LCTL --device $oscdev recover ||
1154 error "OSC device $oscdev recovery failed"
1155 do_facet $SINGLEMDS $LCTL --device $oscdev recover ||
1156 error "second OSC device $oscdev recovery failed"
1157 # give the mds_lov_sync threads a chance to run
1160 run_test 50 "Double OSC recovery, don't LASSERT (3812)"
1162 # b3764 timed out lock replay
1164 [ "$MDS1_VERSION" -lt $(version_code 2.6.90) ] &&
1165 skip "MDS prior to 2.6.90 handle LDLM_REPLY_NET incorrectly"
1167 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
1168 cancel_lru_locks mdc
1170 multiop_bg_pause $DIR/$tfile s_s || error "multiop $DIR/$tfile failed"
1173 #define OBD_FAIL_MDS_LDLM_REPLY_NET 0x157
1174 lctl set_param -n ldlm.cancel_unused_locks_before_replay "0"
1175 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000157"
1177 fail $SINGLEMDS || error "fail $SINGLEMDS failed"
1179 wait $mpid || error "multiop_bg_pause pid failed"
1181 do_facet $SINGLEMDS "lctl set_param fail_loc=0x0"
1182 lctl set_param fail_loc=0x0
1183 lctl set_param -n ldlm.cancel_unused_locks_before_replay "1"
1186 run_test 52 "time out lock replay (3764)"
1188 # bug 3462 - simultaneous MDC requests
1190 [[ $(lctl get_param mdc.*.import |
1191 grep "connect_flags:.*multi_mod_rpc") ]] ||
1192 { skip "Need MDC with 'multi_mod_rpcs' feature"; return 0; }
1194 cancel_lru_locks mdc # cleanup locks from former test cases
1195 mkdir_on_mdt0 $DIR/${tdir}-1 || error "mkdir $DIR/${tdir}-1 failed"
1196 mkdir_on_mdt0 $DIR/${tdir}-2 || error "mkdir $DIR/${tdir}-2 failed"
1197 multiop $DIR/${tdir}-1/f O_c &
1199 # give multiop a change to open
1202 #define OBD_FAIL_MDS_CLOSE_NET 0x115
1203 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000115"
1204 kill -USR1 $close_pid
1205 cancel_lru_locks mdc # force the close
1206 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
1208 mcreate $DIR/${tdir}-2/f || error "mcreate $DIR/${tdir}-2/f failed"
1210 # close should still be here
1211 [ -d /proc/$close_pid ] || error "close_pid doesn't exist"
1213 replay_barrier_nodf $SINGLEMDS
1215 wait $close_pid || error "close_pid $close_pid failed"
1217 $CHECKSTAT -t file $DIR/${tdir}-1/f ||
1218 error "$CHECKSTAT $DIR/${tdir}-1/f attribute check failed"
1219 $CHECKSTAT -t file $DIR/${tdir}-2/f ||
1220 error "$CHECKSTAT $DIR/${tdir}-2/f attribute check failed"
1221 rm -rf $DIR/${tdir}-*
1223 run_test 53a "|X| close request while two MDC requests in flight"
1226 cancel_lru_locks mdc # cleanup locks from former test cases
1228 mkdir_on_mdt0 $DIR/${tdir}-1 || error "mkdir $DIR/${tdir}-1 failed"
1229 mkdir_on_mdt0 $DIR/${tdir}-2 || error "mkdir $DIR/${tdir}-2 failed"
1230 multiop_bg_pause $DIR/${tdir}-1/f O_c ||
1231 error "multiop_bg_pause $DIR/${tdir}-1/f failed"
1234 #define OBD_FAIL_MDS_REINT_NET 0x107
1235 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000107"
1236 mcreate $DIR/${tdir}-2/f &
1240 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
1241 kill -USR1 $close_pid
1242 cancel_lru_locks mdc # force the close
1243 wait $close_pid || error "close_pid $close_pid failed"
1244 # open should still be here
1245 [ -d /proc/$open_pid ] || error "open_pid doesn't exist"
1247 replay_barrier_nodf $SINGLEMDS
1249 wait $open_pid || error "open_pid failed"
1251 $CHECKSTAT -t file $DIR/${tdir}-1/f ||
1252 error "$CHECKSTAT $DIR/${tdir}-1/f attribute check failed"
1253 $CHECKSTAT -t file $DIR/${tdir}-2/f ||
1254 error "$CHECKSTAT $DIR/${tdir}-2/f attribute check failed"
1255 rm -rf $DIR/${tdir}-*
1257 run_test 53b "|X| open request while two MDC requests in flight"
1260 cancel_lru_locks mdc # cleanup locks from former test cases
1262 mkdir_on_mdt0 $DIR/${tdir}-1 || error "mkdir $DIR/${tdir}-1 failed"
1263 mkdir_on_mdt0 $DIR/${tdir}-2 || error "mkdir $DIR/${tdir}-2 failed"
1264 multiop $DIR/${tdir}-1/f O_c &
1267 #define OBD_FAIL_MDS_REINT_NET 0x107
1268 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000107"
1269 mcreate $DIR/${tdir}-2/f &
1273 #define OBD_FAIL_MDS_CLOSE_NET 0x115
1274 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000115"
1275 kill -USR1 $close_pid
1276 cancel_lru_locks mdc # force the close
1278 #bz20647: make sure all pids exist before failover
1279 [ -d /proc/$close_pid ] || error "close_pid doesn't exist"
1280 [ -d /proc/$open_pid ] || error "open_pid doesn't exists"
1281 replay_barrier_nodf $SINGLEMDS
1282 fail_nodf $SINGLEMDS
1283 wait $open_pid || error "open_pid failed"
1285 # close should be gone
1286 [ -d /proc/$close_pid ] && error "close_pid should not exist"
1287 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
1289 $CHECKSTAT -t file $DIR/${tdir}-1/f ||
1290 error "$CHECKSTAT $DIR/${tdir}-1/f attribute check failed"
1291 $CHECKSTAT -t file $DIR/${tdir}-2/f ||
1292 error "$CHECKSTAT $DIR/${tdir}-2/f attribute check failed"
1293 rm -rf $DIR/${tdir}-*
1295 run_test 53c "|X| open request and close request while two MDC requests in flight"
1298 [[ $(lctl get_param mdc.*.import |
1299 grep "connect_flags:.*multi_mod_rpc") ]] ||
1300 { skip "Need MDC with 'multi_mod_rpcs' feature"; return 0; }
1302 cancel_lru_locks mdc # cleanup locks from former test cases
1304 mkdir_on_mdt0 $DIR/${tdir}-1 || error "mkdir $DIR/${tdir}-1 failed"
1305 mkdir_on_mdt0 $DIR/${tdir}-2 || error "mkdir $DIR/${tdir}-2 failed"
1306 multiop $DIR/${tdir}-1/f O_c &
1308 # give multiop a chance to open
1311 #define OBD_FAIL_MDS_CLOSE_NET_REP 0x13b
1312 do_facet $SINGLEMDS "lctl set_param fail_loc=0x8000013b"
1313 kill -USR1 $close_pid
1314 cancel_lru_locks mdc # force the close
1315 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
1316 mcreate $DIR/${tdir}-2/f || error "mcreate $DIR/${tdir}-2/f failed"
1318 # close should still be here
1319 [ -d /proc/$close_pid ] || error "close_pid doesn't exist"
1321 wait $close_pid || error "close_pid failed"
1323 $CHECKSTAT -t file $DIR/${tdir}-1/f ||
1324 error "$CHECKSTAT $DIR/${tdir}-1/f attribute check failed"
1325 $CHECKSTAT -t file $DIR/${tdir}-2/f ||
1326 error "$CHECKSTAT $DIR/${tdir}-2/f attribute check failed"
1327 rm -rf $DIR/${tdir}-*
1329 run_test 53d "close reply while two MDC requests in flight"
1332 cancel_lru_locks mdc # cleanup locks from former test cases
1334 mkdir_on_mdt0 $DIR/${tdir}-1 || error "mkdir $DIR/${tdir}-1 failed"
1335 mkdir_on_mdt0 $DIR/${tdir}-2 || error "mkdir $DIR/${tdir}-2 failed"
1336 multiop $DIR/${tdir}-1/f O_c &
1339 #define OBD_FAIL_MDS_REINT_NET_REP 0x119
1340 do_facet $SINGLEMDS "lctl set_param fail_loc=0x119"
1341 mcreate $DIR/${tdir}-2/f &
1345 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
1346 kill -USR1 $close_pid
1347 cancel_lru_locks mdc # force the close
1348 wait $close_pid || error "close_pid failed"
1349 # open should still be here
1350 [ -d /proc/$open_pid ] || error "open_pid doesn't exists"
1352 replay_barrier_nodf $SINGLEMDS
1354 wait $open_pid || error "open_pid failed"
1356 $CHECKSTAT -t file $DIR/${tdir}-1/f ||
1357 error "$CHECKSTAT $DIR/${tdir}-1/f attribute check failed"
1358 $CHECKSTAT -t file $DIR/${tdir}-2/f ||
1359 error "$CHECKSTAT $DIR/${tdir}-2/f attribute check failed"
1360 rm -rf $DIR/${tdir}-*
1362 run_test 53e "|X| open reply while two MDC requests in flight"
1365 cancel_lru_locks mdc # cleanup locks from former test cases
1367 mkdir_on_mdt0 $DIR/${tdir}-1 || error "mkdir $DIR/${tdir}-1 failed"
1368 mkdir_on_mdt0 $DIR/${tdir}-2 || error "mkdir $DIR/${tdir}-2 failed"
1369 multiop $DIR/${tdir}-1/f O_c &
1372 #define OBD_FAIL_MDS_REINT_NET_REP 0x119
1373 do_facet $SINGLEMDS "lctl set_param fail_loc=0x119"
1374 mcreate $DIR/${tdir}-2/f &
1378 #define OBD_FAIL_MDS_CLOSE_NET_REP 0x13b
1379 do_facet $SINGLEMDS "lctl set_param fail_loc=0x8000013b"
1380 kill -USR1 $close_pid
1381 cancel_lru_locks mdc # force the close
1383 #bz20647: make sure all pids are exists before failover
1384 [ -d /proc/$close_pid ] || error "close_pid doesn't exist"
1385 [ -d /proc/$open_pid ] || error "open_pid doesn't exists"
1386 replay_barrier_nodf $SINGLEMDS
1387 fail_nodf $SINGLEMDS
1388 wait $open_pid || error "open_pid failed"
1390 # close should be gone
1391 [ -d /proc/$close_pid ] && error "close_pid should not exist"
1392 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
1394 $CHECKSTAT -t file $DIR/${tdir}-1/f ||
1395 error "$CHECKSTAT $DIR/${tdir}-1/f attribute check failed"
1396 $CHECKSTAT -t file $DIR/${tdir}-2/f ||
1397 error "$CHECKSTAT $DIR/${tdir}-2/f attribute check failed"
1398 rm -rf $DIR/${tdir}-*
1400 run_test 53f "|X| open reply and close reply while two MDC requests in flight"
1403 cancel_lru_locks mdc # cleanup locks from former test cases
1405 mkdir_on_mdt0 $DIR/${tdir}-1 || error "mkdir $DIR/${tdir}-1 failed"
1406 mkdir_on_mdt0 $DIR/${tdir}-2 || error "mkdir $DIR/${tdir}-2 failed"
1407 multiop $DIR/${tdir}-1/f O_c &
1410 #define OBD_FAIL_MDS_REINT_NET_REP 0x119
1411 do_facet $SINGLEMDS "lctl set_param fail_loc=0x119"
1412 mcreate $DIR/${tdir}-2/f &
1416 #define OBD_FAIL_MDS_CLOSE_NET 0x115
1417 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000115"
1418 kill -USR1 $close_pid
1419 cancel_lru_locks mdc # force the close
1420 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
1422 #bz20647: make sure all pids are exists before failover
1423 [ -d /proc/$close_pid ] || error "close_pid doesn't exist"
1424 [ -d /proc/$open_pid ] || error "open_pid doesn't exists"
1425 replay_barrier_nodf $SINGLEMDS
1426 fail_nodf $SINGLEMDS
1427 wait $open_pid || error "open_pid failed"
1429 # close should be gone
1430 [ -d /proc/$close_pid ] && error "close_pid should not exist"
1432 $CHECKSTAT -t file $DIR/${tdir}-1/f ||
1433 error "$CHECKSTAT $DIR/${tdir}-1/f attribute check failed"
1434 $CHECKSTAT -t file $DIR/${tdir}-2/f ||
1435 error "$CHECKSTAT $DIR/${tdir}-2/f attribute check failed"
1436 rm -rf $DIR/${tdir}-*
1438 run_test 53g "|X| drop open reply and close request while close and open are both in flight"
1441 cancel_lru_locks mdc # cleanup locks from former test cases
1443 mkdir_on_mdt0 $DIR/${tdir}-1 || error "mkdir $DIR/${tdir}-1 failed"
1444 mkdir_on_mdt0 $DIR/${tdir}-2 || error "mkdir $DIR/${tdir}-2 failed"
1445 multiop $DIR/${tdir}-1/f O_c &
1448 #define OBD_FAIL_MDS_REINT_NET 0x107
1449 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000107"
1450 mcreate $DIR/${tdir}-2/f &
1454 #define OBD_FAIL_MDS_CLOSE_NET_REP 0x13b
1455 do_facet $SINGLEMDS "lctl set_param fail_loc=0x8000013b"
1456 kill -USR1 $close_pid
1457 cancel_lru_locks mdc # force the close
1460 #bz20647: make sure all pids are exists before failover
1461 [ -d /proc/$close_pid ] || error "close_pid doesn't exist"
1462 [ -d /proc/$open_pid ] || error "open_pid doesn't exists"
1463 replay_barrier_nodf $SINGLEMDS
1464 fail_nodf $SINGLEMDS
1465 wait $open_pid || error "open_pid failed"
1467 # close should be gone
1468 [ -d /proc/$close_pid ] && error "close_pid should not exist"
1469 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
1471 $CHECKSTAT -t file $DIR/${tdir}-1/f ||
1472 error "$CHECKSTAT $DIR/${tdir}-1/f attribute check failed"
1473 $CHECKSTAT -t file $DIR/${tdir}-2/f ||
1474 error "$CHECKSTAT $DIR/${tdir}-2/f attribute check failed"
1475 rm -rf $DIR/${tdir}-*
1477 run_test 53h "open request and close reply while two MDC requests in flight"
1479 #b3761 ASSERTION(hash != 0) failed
1481 # OBD_FAIL_MDS_OPEN_CREATE | OBD_FAIL_ONCE
1482 do_facet $SINGLEMDS "lctl set_param fail_loc=0x8000012b"
1484 # give touch a chance to run
1486 do_facet $SINGLEMDS "lctl set_param fail_loc=0x0"
1490 run_test 55 "let MDS_CHECK_RESENT return the original return code instead of 0"
1492 #b3440 ASSERTION(rec->ur_fid2->id) failed
1494 ln -s foo $DIR/$tfile
1495 replay_barrier $SINGLEMDS
1496 #drop_reply "cat $DIR/$tfile"
1500 run_test 56 "don't replay a symlink open request (3440)"
1502 #recovery one mds-ost setattr from llog
1504 #define OBD_FAIL_MDS_OST_SETATTR 0x12c
1505 do_facet $SINGLEMDS "lctl set_param fail_loc=0x8000012c"
1506 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
1507 replay_barrier $SINGLEMDS
1509 wait_recovery_complete $SINGLEMDS || error "MDS recovery is not done"
1510 wait_mds_ost_sync || error "wait_mds_ost_sync failed"
1511 $CHECKSTAT -t file $DIR/$tfile ||
1512 error "$CHECKSTAT $DIR/$tfile attribute check failed"
1513 do_facet $SINGLEMDS "lctl set_param fail_loc=0x0"
1516 run_test 57 "test recovery from llog for setattr op"
1519 zconf_umount $(hostname) $MOUNT2
1523 #recovery many mds-ost setattr from llog
1525 mkdir_on_mdt0 $DIR/$tdir || error "mkdir $DIR/$tdir failed"
1526 #define OBD_FAIL_MDS_OST_SETATTR 0x12c
1527 do_facet $SINGLEMDS "lctl set_param fail_loc=0x8000012c"
1528 createmany -o $DIR/$tdir/$tfile-%d 2500
1529 replay_barrier $SINGLEMDS
1532 $CHECKSTAT -t file $DIR/$tdir/$tfile-* >/dev/null ||
1533 error "$CHECKSTAT $DIR/$tfile-* attribute check failed"
1534 do_facet $SINGLEMDS "lctl set_param fail_loc=0x0"
1535 unlinkmany $DIR/$tdir/$tfile-%d 2500 ||
1536 error "unlinkmany $DIR/$tfile failed"
1539 run_test 58a "test recovery from llog for setattr op (test llog_gen_rec)"
1545 trap cleanup_58 EXIT
1547 large_xattr_enabled &&
1548 orig="$(generate_string $(max_xattr_size))" || orig="bar"
1549 # Original extended attribute can be long. Print a small version of
1550 # attribute if an error occurs
1551 local sm_msg=$(printf "%.9s" $orig)
1553 mount_client $MOUNT2 || error "mount_client on $MOUNT2 failed"
1554 mkdir_on_mdt0 $DIR/$tdir || error "mkdir $DIR/$tdir failed"
1555 touch $DIR/$tdir/$tfile || error "touch $DIR/$tdir/$tfile failed"
1556 replay_barrier $SINGLEMDS
1557 setfattr -n trusted.foo -v $orig $DIR/$tdir/$tfile
1559 new=$(get_xattr_value trusted.foo $MOUNT2/$tdir/$tfile)
1560 [[ "$new" = "$orig" ]] ||
1561 error "xattr set ($sm_msg...) differs from xattr get ($new)"
1562 rm -f $DIR/$tdir/$tfile
1565 wait_clients_import_state ${CLIENTS:-$HOSTNAME} "mgs" FULL
1567 run_test 58b "test replay of setxattr op"
1569 test_58c() { # bug 16570
1574 trap cleanup_58 EXIT
1576 if large_xattr_enabled; then
1577 local xattr_size=$(max_xattr_size)
1578 orig="$(generate_string $((xattr_size / 2)))"
1579 orig1="$(generate_string $xattr_size)"
1585 # PING_INTERVAL max(obd_timeout / 4, 1U)
1586 sleep $((TIMEOUT / 4))
1588 # Original extended attribute can be long. Print a small version of
1589 # attribute if an error occurs
1590 local sm_msg=$(printf "%.9s" $orig)
1591 local sm_msg1=$(printf "%.9s" $orig1)
1593 mount_client $MOUNT2 || error "mount_client on $MOUNT2 failed"
1594 mkdir_on_mdt0 $DIR/$tdir || error "mkdir $DIR/$tdir failed"
1595 touch $DIR/$tdir/$tfile || error "touch $DIR/$tdir/$tfile failed"
1596 drop_request "setfattr -n trusted.foo -v $orig $DIR/$tdir/$tfile" ||
1597 error "drop_request for setfattr failed"
1598 new=$(get_xattr_value trusted.foo $MOUNT2/$tdir/$tfile)
1599 [[ "$new" = "$orig" ]] ||
1600 error "xattr set ($sm_msg...) differs from xattr get ($new)"
1601 drop_reint_reply "setfattr -n trusted.foo1 \
1602 -v $orig1 $DIR/$tdir/$tfile" ||
1603 error "drop_reint_reply for setfattr failed"
1604 new=$(get_xattr_value trusted.foo1 $MOUNT2/$tdir/$tfile)
1605 [[ "$new" = "$orig1" ]] ||
1606 error "second xattr set ($sm_msg1...) differs xattr get ($new)"
1607 rm -f $DIR/$tdir/$tfile
1611 run_test 58c "resend/reconstruct setxattr op"
1613 # log_commit_thread vs filter_destroy race used to lead to import use after free
1616 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1618 mkdir_on_mdt0 $DIR/$tdir || error "mkdir $DIR/$tdir failed"
1619 createmany -o $DIR/$tdir/$tfile-%d 200 ||
1620 error "createmany create files failed"
1622 unlinkmany $DIR/$tdir/$tfile-%d 200 ||
1623 error "unlinkmany $DIR/$tdir/$tfile failed"
1624 #define OBD_FAIL_PTLRPC_DELAY_RECOV 0x507
1625 do_facet ost1 "lctl set_param fail_loc=0x507"
1628 do_facet ost1 "lctl set_param fail_loc=0x0"
1632 run_test 59 "test log_commit_thread vs filter_destroy race"
1634 # race between add unlink llog vs cat log init in post_recovery (only for b1_6)
1635 # bug 12086: should no oops and No ctxt error for this test
1637 mkdir_on_mdt0 $DIR/$tdir || error "mkdir $DIR/$tdir failed"
1638 createmany -o $DIR/$tdir/$tfile-%d 200 ||
1639 error "createmany create files failed"
1640 replay_barrier $SINGLEMDS
1641 unlinkmany $DIR/$tdir/$tfile-%d 0 100
1643 unlinkmany $DIR/$tdir/$tfile-%d 100 100
1644 local no_ctxt=$(dmesg | grep "No ctxt")
1645 [ -z "$no_ctxt" ] || error "ctxt is not initialized in recovery"
1647 run_test 60 "test llog post recovery init vs llog unlink"
1649 #test race llog recovery thread vs llog cleanup
1650 test_61a() { # was test_61
1651 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1653 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
1654 createmany -o $DIR/$tdir/$tfile-%d 800 ||
1655 error "createmany create files failed"
1657 unlinkmany $DIR/$tdir/$tfile-%d 800
1658 # OBD_FAIL_OST_LLOG_RECOVERY_TIMEOUT 0x221
1659 set_nodes_failloc "$(osts_nodes)" 0x80000221
1664 set_nodes_failloc "$(osts_nodes)" 0x0
1666 $CHECKSTAT -t file $DIR/$tdir/$tfile-* &&
1667 error "$CHECKSTAT $DIR/$tdir/$tfile attribute check should fail"
1670 run_test 61a "test race llog recovery vs llog cleanup"
1672 #test race mds llog sync vs llog cleanup
1674 # OBD_FAIL_MDS_LLOG_SYNC_TIMEOUT 0x13a
1675 do_facet $SINGLEMDS "lctl set_param fail_loc=0x8000013a"
1676 facet_failover $SINGLEMDS
1679 do_facet client dd if=/dev/zero of=$DIR/$tfile bs=4k count=1 ||
1682 run_test 61b "test race mds llog sync vs llog cleanup"
1684 #test race cancel cookie cb vs llog cleanup
1686 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1688 # OBD_FAIL_OST_CANCEL_COOKIE_TIMEOUT 0x222
1689 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
1690 set_nodes_failloc "$(osts_nodes)" 0x80000222
1694 set_nodes_failloc "$(osts_nodes)" 0x0
1696 run_test 61c "test race mds llog sync vs llog cleanup"
1698 test_61d() { # bug 16002 # bug 17466 # bug 22137
1699 # OBD_FAIL_OBD_LLOG_SETUP 0x605
1701 do_facet mgs "lctl set_param fail_loc=0x80000605"
1702 start mgs $(mgsdevname) $MGS_MOUNT_OPTS &&
1703 error "mgs start should have failed"
1704 do_facet mgs "lctl set_param fail_loc=0"
1705 start mgs $(mgsdevname) $MGS_MOUNT_OPTS || error "cannot restart mgs"
1707 run_test 61d "error in llog_setup should cleanup the llog context correctly"
1709 test_62() { # Bug 15756 - don't mis-drop resent replay
1710 mkdir_on_mdt0 $DIR/$tdir || error "mkdir $DIR/$tdir failed"
1711 replay_barrier $SINGLEMDS
1712 createmany -o $DIR/$tdir/$tfile- 25 ||
1713 error "createmany create files failed"
1714 #define OBD_FAIL_TGT_REPLAY_DROP 0x707
1715 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000707"
1717 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
1718 unlinkmany $DIR/$tdir/$tfile- 25 ||
1719 error "unlinkmany $DIR/$tdir/$tfile failed"
1722 run_test 62 "don't mis-drop resent replay"
1724 #Adaptive Timeouts (bug 3055)
1732 echo "Cleaning up AT ..."
1733 if [ -n "$ATOLDBASE" ]; then
1734 local at_history=$($LCTL get_param -n at_history)
1735 do_facet $SINGLEMDS "lctl set_param at_history=$at_history" || true
1736 do_facet ost1 "lctl set_param at_history=$at_history" || true
1739 if [ $AT_MAX_SET -ne 0 ]; then
1740 for facet in mds client ost; do
1741 var=AT_MAX_SAVE_${facet}
1742 echo restore AT on $facet to saved value ${!var}
1743 at_max_set ${!var} $facet
1744 at_new=$(at_max_get $facet)
1745 echo Restored AT value on $facet $at_new
1746 [ $at_new -eq ${!var} ] ||
1747 error "AT value not restored SAVED ${!var} NEW $at_new"
1754 local at_max_new=600
1756 # Save at_max original values
1758 if [ $AT_MAX_SET -eq 0 ]; then
1759 # Suppose that all osts have the same at_max
1760 for facet in mds client ost; do
1761 eval AT_MAX_SAVE_${facet}=$(at_max_get $facet)
1765 for facet in mds client ost; do
1766 at_max=$(at_max_get $facet)
1767 if [ $at_max -ne $at_max_new ]; then
1768 echo "AT value on $facet is $at_max, set it by force temporarily to $at_max_new"
1769 at_max_set $at_max_new $facet
1774 if [ -z "$ATOLDBASE" ]; then
1775 ATOLDBASE=$(do_facet $SINGLEMDS "lctl get_param -n at_history")
1776 # speed up the timebase so we can check decreasing AT
1777 do_facet $SINGLEMDS "lctl set_param at_history=8" || true
1778 do_facet ost1 "lctl set_param at_history=8" || true
1780 # sleep for a while to cool down, should be > 8s and also allow
1781 # at least one ping to be sent. simply use TIMEOUT to be safe.
1786 test_65a() #bug 3055
1788 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1790 at_start || return 0
1791 $LCTL dk > /dev/null
1793 $LCTL set_param debug="other"
1794 # Slow down a request to the current service time, this is critical
1795 # because previous tests may have caused this value to increase.
1796 REQ_DELAY=`lctl get_param -n mdc.${FSNAME}-MDT0000-mdc-*.timeouts |
1797 awk '/portal 12/ {print $5}'`
1798 REQ_DELAY=$((${REQ_DELAY} + ${REQ_DELAY} / 4 + 5))
1800 do_facet $SINGLEMDS lctl set_param fail_val=$((${REQ_DELAY} * 1000))
1801 #define OBD_FAIL_PTLRPC_PAUSE_REQ 0x50a
1802 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x8000050a
1803 createmany -o $DIR/$tfile 10 > /dev/null
1804 unlinkmany $DIR/$tfile 10 > /dev/null
1805 # check for log message
1806 $LCTL dk | grep -i "Early reply #" || error "No early reply"
1808 # client should show REQ_DELAY estimates
1809 lctl get_param -n mdc.${FSNAME}-MDT0000-mdc-*.timeouts | grep portal
1811 lctl get_param -n mdc.${FSNAME}-MDT0000-mdc-*.timeouts | grep portal
1813 run_test 65a "AT: verify early replies"
1815 test_65b() #bug 3055
1817 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1819 at_start || return 0
1822 $LCTL set_param debug="other trace"
1823 $LCTL dk > /dev/null
1824 # Slow down a request to the current service time, this is critical
1825 # because previous tests may have caused this value to increase.
1826 $LFS setstripe --stripe-index=0 --stripe-count=1 $DIR/$tfile ||
1827 error "$LFS setstripe failed for $DIR/$tfile"
1829 multiop $DIR/$tfile Ow1yc
1830 REQ_DELAY=`lctl get_param -n osc.${FSNAME}-OST0000-osc-*.timeouts |
1831 awk '/portal 6/ {print $5}'`
1832 REQ_DELAY=$((${REQ_DELAY} + ${REQ_DELAY} / 4 + 5))
1834 do_facet ost1 lctl set_param fail_val=${REQ_DELAY}
1835 #define OBD_FAIL_OST_BRW_PAUSE_PACK 0x224
1836 do_facet ost1 $LCTL set_param fail_loc=0x224
1839 $LFS setstripe --stripe-index=0 --stripe-count=1 $DIR/$tfile ||
1840 error "$LFS setstripe failed"
1841 # force some real bulk transfer
1842 multiop $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
1844 do_facet ost1 $LCTL set_param fail_loc=0
1845 # check for log message
1846 $LCTL dk | grep -i "Early reply #" || error "No early reply"
1848 # client should show REQ_DELAY estimates
1849 lctl get_param -n osc.${FSNAME}-OST0000-osc-*.timeouts | grep portal
1851 run_test 65b "AT: verify early replies on packed reply / bulk"
1853 test_66a() #bug 3055
1855 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1857 at_start || return 0
1858 lctl get_param -n mdc.${FSNAME}-MDT0000-mdc-*.timeouts | grep "portal 12"
1859 # adjust 5s at a time so no early reply is sent (within deadline)
1860 do_facet $SINGLEMDS "$LCTL set_param fail_val=5000"
1861 #define OBD_FAIL_PTLRPC_PAUSE_REQ 0x50a
1862 do_facet $SINGLEMDS "$LCTL set_param fail_loc=0x8000050a"
1863 createmany -o $DIR/$tfile 20 > /dev/null
1864 unlinkmany $DIR/$tfile 20 > /dev/null
1865 lctl get_param -n mdc.${FSNAME}-MDT0000-mdc-*.timeouts | grep "portal 12"
1866 do_facet $SINGLEMDS "$LCTL set_param fail_val=10000"
1867 do_facet $SINGLEMDS "$LCTL set_param fail_loc=0x8000050a"
1868 createmany -o $DIR/$tfile 20 > /dev/null
1869 unlinkmany $DIR/$tfile 20 > /dev/null
1870 lctl get_param -n mdc.${FSNAME}-MDT0000-mdc-*.timeouts | grep "portal 12"
1871 do_facet $SINGLEMDS "$LCTL set_param fail_loc=0"
1873 createmany -o $DIR/$tfile 20 > /dev/null
1874 unlinkmany $DIR/$tfile 20 > /dev/null
1875 lctl get_param -n mdc.${FSNAME}-MDT0000-mdc-*.timeouts | grep "portal 12"
1876 CUR=$(lctl get_param -n mdc.${FSNAME}-MDT0000-mdc-*.timeouts | awk '/portal 12/ {print $5}')
1877 WORST=$(lctl get_param -n mdc.${FSNAME}-MDT0000-mdc-*.timeouts | awk '/portal 12/ {print $7}')
1878 echo "Current MDT timeout $CUR, worst $WORST"
1879 [ $CUR -lt $WORST ] || error "Current $CUR should be less than worst $WORST"
1881 run_test 66a "AT: verify MDT service time adjusts with no early replies"
1883 test_66b() #bug 3055
1885 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1887 at_start || return 0
1888 ORIG=$(lctl get_param -n mdc.${FSNAME}-MDT0000*.timeouts |
1889 awk '/network/ {print $4}')
1890 $LCTL set_param fail_val=$(($ORIG + 5))
1891 #define OBD_FAIL_PTLRPC_PAUSE_REP 0x50c
1892 $LCTL set_param fail_loc=0x50c
1893 touch $DIR/$tfile > /dev/null 2>&1
1894 $LCTL set_param fail_loc=0
1895 CUR=$(lctl get_param -n mdc.${FSNAME}-MDT0000*.timeouts |
1896 awk '/network/ {print $4}')
1897 WORST=$(lctl get_param -n mdc.${FSNAME}-MDT0000*.timeouts |
1898 awk '/network/ {print $6}')
1899 echo "network timeout orig $ORIG, cur $CUR, worst $WORST"
1900 [ $WORST -gt $ORIG ] ||
1901 error "Worst $WORST should be worse than orig $ORIG"
1903 run_test 66b "AT: verify net latency adjusts"
1905 test_67a() #bug 3055
1907 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1909 at_start || return 0
1910 CONN1=$(lctl get_param -n osc.*.stats | awk '/_connect/ {total+=$2} END {print total}')
1911 # sleeping threads may drive values above this
1912 do_facet ost1 "$LCTL set_param fail_val=400"
1913 #define OBD_FAIL_PTLRPC_PAUSE_REQ 0x50a
1914 do_facet ost1 "$LCTL set_param fail_loc=0x50a"
1915 createmany -o $DIR/$tfile 20 > /dev/null
1916 unlinkmany $DIR/$tfile 20 > /dev/null
1917 do_facet ost1 "$LCTL set_param fail_loc=0"
1918 CONN2=$(lctl get_param -n osc.*.stats | awk '/_connect/ {total+=$2} END {print total}')
1919 ATTEMPTS=$(($CONN2 - $CONN1))
1920 echo "$ATTEMPTS osc reconnect attempts on gradual slow"
1921 [ $ATTEMPTS -gt 0 ] &&
1922 error_ignore bz13721 "AT should have prevented reconnect"
1925 run_test 67a "AT: verify slow request processing doesn't induce reconnects"
1927 test_67b() #bug 3055
1929 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1931 at_start || return 0
1932 CONN1=$(lctl get_param -n osc.*.stats | awk '/_connect/ {total+=$2} END {print total}')
1934 # exhaust precreations on ost1
1935 local OST=$(ostname_from_index 0)
1936 local mdtosc=$(get_mdtosc_proc_path mds $OST)
1937 local last_id=$(do_facet $SINGLEMDS lctl get_param -n \
1938 osp.$mdtosc.prealloc_last_id)
1939 local next_id=$(do_facet $SINGLEMDS lctl get_param -n \
1940 osp.$mdtosc.prealloc_next_id)
1942 mkdir -p $DIR/$tdir/${OST} || error "mkdir $DIR/$tdir/${OST} failed"
1943 $LFS setstripe -i 0 -c 1 $DIR/$tdir/${OST} ||
1944 error "$LFS setstripe failed"
1945 echo "Creating to objid $last_id on ost $OST..."
1946 #define OBD_FAIL_OST_PAUSE_CREATE 0x223
1947 do_facet ost1 "$LCTL set_param fail_val=20000"
1948 do_facet ost1 "$LCTL set_param fail_loc=0x80000223"
1949 createmany -o $DIR/$tdir/${OST}/f $next_id $((last_id - next_id + 2))
1952 do_facet ost1 "lctl get_param -n ost.OSS.ost_create.timeouts"
1954 CONN2=$(lctl get_param -n osc.*.stats | awk '/_connect/ {total+=$2} END {print total}')
1955 ATTEMPTS=$(($CONN2 - $CONN1))
1956 echo "$ATTEMPTS osc reconnect attempts on instant slow"
1957 # do it again; should not timeout
1958 do_facet ost1 "$LCTL set_param fail_loc=0x80000223"
1959 cp /etc/profile $DIR/$tfile || error "cp failed"
1960 do_facet ost1 "$LCTL set_param fail_loc=0"
1962 do_facet ost1 "lctl get_param -n ost.OSS.ost_create.timeouts"
1963 CONN3=$(lctl get_param -n osc.*.stats | awk '/_connect/ {total+=$2} END {print total}')
1964 ATTEMPTS=$(($CONN3 - $CONN2))
1965 echo "$ATTEMPTS osc reconnect attempts on 2nd slow"
1966 [ $ATTEMPTS -gt 0 ] && error "AT should have prevented reconnect"
1969 run_test 67b "AT: verify instant slowdown doesn't induce reconnects"
1971 test_68 () #bug 13813
1973 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1975 at_start || return 0
1976 local ldlm_enqueue_min=$(find /sys -name ldlm_enqueue_min)
1977 [ -z "$ldlm_enqueue_min" ] && skip "missing /sys/.../ldlm_enqueue_min" && return 0
1978 local ldlm_enqueue_min_r=$(do_facet ost1 "find /sys -name ldlm_enqueue_min")
1979 [ -z "$ldlm_enqueue_min_r" ] && skip "missing /sys/.../ldlm_enqueue_min in the ost1" && return 0
1980 local ENQ_MIN=$(cat $ldlm_enqueue_min)
1981 local ENQ_MIN_R=$(do_facet ost1 "cat $ldlm_enqueue_min_r")
1982 echo $TIMEOUT >> $ldlm_enqueue_min
1983 do_facet ost1 "echo $TIMEOUT >> $ldlm_enqueue_min_r"
1985 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
1986 $LFS setstripe --stripe-index=0 -c 1 $DIR/$tdir ||
1987 error "$LFS setstripe failed for $DIR/$tdir"
1988 #define OBD_FAIL_LDLM_PAUSE_CANCEL 0x312
1989 $LCTL set_param fail_val=$(($TIMEOUT - 1))
1990 $LCTL set_param fail_loc=0x80000312
1991 cp /etc/profile $DIR/$tdir/${tfile}_1 || error "1st cp failed $?"
1992 $LCTL set_param fail_val=$((TIMEOUT * 5 / 4))
1993 $LCTL set_param fail_loc=0x80000312
1994 cp /etc/profile $DIR/$tdir/${tfile}_2 || error "2nd cp failed $?"
1995 $LCTL set_param fail_loc=0
1997 echo $ENQ_MIN >> $ldlm_enqueue_min
1998 do_facet ost1 "echo $ENQ_MIN_R >> $ldlm_enqueue_min_r"
2002 run_test 68 "AT: verify slowing locks"
2005 # end of AT tests includes above lines
2007 # start multi-client tests
2009 [ $CLIENTCOUNT -lt 2 ] &&
2010 { skip "Need two or more clients, have $CLIENTCOUNT" && return; }
2012 echo "mount clients $CLIENTS ..."
2013 zconf_mount_clients $CLIENTS $MOUNT
2015 local clients=${CLIENTS//,/ }
2016 echo "Write/read files on $DIR ; clients $CLIENTS ... "
2017 for CLIENT in $clients; do
2018 do_node $CLIENT dd bs=1M count=10 if=/dev/zero \
2019 of=$DIR/${tfile}_${CLIENT} 2>/dev/null ||
2020 error "dd failed on $CLIENT"
2023 local prev_client=$(echo $clients | sed 's/^.* \(.\+\)$/\1/')
2024 for C in ${CLIENTS//,/ }; do
2025 do_node $prev_client dd if=$DIR/${tfile}_${C} \
2026 of=/dev/null 2>/dev/null ||
2027 error "dd if=$DIR/${tfile}_${C} failed on $prev_client"
2033 run_test 70a "check multi client t-f"
2035 check_for_process () {
2040 killall_process $clients "$prog" -0
2044 local clients=${CLIENTS:-$HOSTNAME}
2046 zconf_mount_clients $clients $MOUNT
2049 [ "$SLOW" = "no" ] && duration=120
2050 # set duration to 900 because it takes some time to boot node
2051 [ "$FAILURE_MODE" = HARD ] && duration=900
2054 local start_ts=$(date +%s)
2055 local cmd="rundbench 1 -t $duration"
2057 if [ $MDSCOUNT -ge 2 ]; then
2058 test_mkdir -p -c$MDSCOUNT $DIR/$tdir
2059 $LFS setdirstripe -D -c$MDSCOUNT $DIR/$tdir
2061 do_nodesv $clients "set -x; MISSING_DBENCH_OK=$MISSING_DBENCH_OK \
2062 PATH=\$PATH:$LUSTRE/utils:$LUSTRE/tests/:$DBENCH_LIB \
2063 DBENCH_LIB=$DBENCH_LIB TESTSUITE=$TESTSUITE TESTNAME=$TESTNAME \
2064 MOUNT=$MOUNT DIR=$DIR/$tdir/\\\$(hostname) LCTL=$LCTL $cmd" &
2067 #LU-1897 wait for all dbench copies to start
2068 while ! check_for_process $clients dbench; do
2069 elapsed=$(($(date +%s) - start_ts))
2070 if [ $elapsed -gt $duration ]; then
2071 killall_process $clients dbench
2072 error "dbench failed to start on $clients!"
2077 log "Started rundbench load pid=$pid ..."
2079 elapsed=$(($(date +%s) - start_ts))
2080 local num_failovers=0
2082 while [ $elapsed -lt $duration ]; do
2083 if ! check_for_process $clients dbench; then
2084 error_noexit "dbench stopped on some of $clients!"
2085 killall_process $clients dbench
2089 replay_barrier mds$fail_index
2090 sleep 1 # give clients a time to do operations
2091 # Increment the number of failovers
2092 num_failovers=$((num_failovers+1))
2093 log "$TESTNAME fail mds$fail_index $num_failovers times"
2095 elapsed=$(($(date +%s) - start_ts))
2096 if [ $fail_index -ge $MDSCOUNT ]; then
2099 fail_index=$((fail_index+1))
2103 wait $pid || error "rundbench load on $clients failed!"
2105 run_test 70b "dbench ${MDSCOUNT}mdts recovery; $CLIENTCOUNT clients"
2106 # end multi-client tests
2111 local monitor_pid=$3
2113 local start_ts=$(date +%s)
2114 local num_failovers=0
2117 elapsed=$(($(date +%s) - start_ts))
2118 while [ $elapsed -lt $duration ]; do
2119 fail_index=$((RANDOM%max_index+1))
2120 kill -0 $monitor_pid ||
2121 error "$monitor_pid stopped"
2123 replay_barrier mds$fail_index
2125 # Increment the number of failovers
2126 num_failovers=$((num_failovers+1))
2127 log "$TESTNAME fail mds$fail_index $num_failovers times"
2129 elapsed=$(($(date +%s) - start_ts))
2135 rm -f $DIR/replay-single.70c.lck
2140 local clients=${CLIENTS:-$HOSTNAME}
2143 zconf_mount_clients $clients $MOUNT
2146 [ "$SLOW" = "no" ] && duration=180
2147 # set duration to 900 because it takes some time to boot node
2148 [ "$FAILURE_MODE" = HARD ] && duration=600
2151 local start_ts=$(date +%s)
2153 trap cleanup_70c EXIT
2155 while [ ! -e $DIR/replay-single.70c.lck ]; do
2156 test_mkdir -p -c$MDSCOUNT $DIR/$tdir || break
2157 if [ $MDSCOUNT -ge 2 ]; then
2158 $LFS setdirstripe -D -c$MDSCOUNT $DIR/$tdir ||
2159 error "set default dirstripe failed"
2161 cd $DIR/$tdir || break
2162 tar cf - /etc | tar xf - || error "tar failed in loop"
2166 echo "Started tar $tar_70c_pid"
2168 random_fail_mdt $MDSCOUNT $duration $tar_70c_pid
2169 kill -0 $tar_70c_pid || error "tar $tar_70c_pid stopped"
2171 touch $DIR/replay-single.70c.lck
2172 wait $tar_70c_pid || error "$?: tar failed"
2177 run_test 70c "tar ${MDSCOUNT}mdts recovery"
2181 kill -9 $mkdir_70d_pid
2185 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2186 local clients=${CLIENTS:-$HOSTNAME}
2189 zconf_mount_clients $clients $MOUNT
2192 [ "$SLOW" = "no" ] && duration=180
2193 # set duration to 900 because it takes some time to boot node
2194 [ "$FAILURE_MODE" = HARD ] && duration=900
2199 local start_ts=$(date +%s)
2201 trap cleanup_70d EXIT
2204 $LFS mkdir -i0 -c2 $DIR/$tdir/test || {
2208 $LFS mkdir -i1 -c2 $DIR/$tdir/test1 || {
2213 touch $DIR/$tdir/test/a || {
2217 mkdir $DIR/$tdir/test/b || {
2221 rm -rf $DIR/$tdir/test || {
2227 touch $DIR/$tdir/test1/a || {
2231 mkdir $DIR/$tdir/test1/b || {
2236 rm -rf $DIR/$tdir/test1 || {
2238 ls -lR $DIR/$tdir/test1
2244 echo "Started $mkdir_70d_pid"
2246 random_fail_mdt $MDSCOUNT $duration $mkdir_70d_pid
2247 kill -0 $mkdir_70d_pid || error "mkdir/rmdir $mkdir_70d_pid stopped"
2252 run_test 70d "mkdir/rmdir striped dir ${MDSCOUNT}mdts recovery"
2255 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2256 local clients=${CLIENTS:-$HOSTNAME}
2259 lctl set_param debug=+ha
2260 zconf_mount_clients $clients $MOUNT
2263 [ "$SLOW" = "no" ] && duration=180
2264 # set duration to 900 because it takes some time to boot node
2265 [ "$FAILURE_MODE" = HARD ] && duration=900
2268 $LFS mkdir -i0 $DIR/$tdir/test_0
2269 $LFS mkdir -i0 $DIR/$tdir/test_1
2270 touch $DIR/$tdir/test_0/a
2271 touch $DIR/$tdir/test_1/b
2274 mrename $DIR/$tdir/test_0/a $DIR/$tdir/test_1/b > /dev/null || {
2279 checkstat $DIR/$tdir/test_0/a && {
2280 echo "a still exists"
2284 checkstat $DIR/$tdir/test_1/b || {
2285 echo "b still exists"
2289 touch $DIR/$tdir/test_0/a || {
2290 echo "touch a fails"
2294 mrename $DIR/$tdir/test_1/b $DIR/$tdir/test_0/a > /dev/null || {
2301 stack_trap "kill -9 $rename_70e_pid" EXIT
2302 echo "Started PID=$rename_70e_pid"
2304 random_fail_mdt 2 $duration $rename_70e_pid
2305 kill -0 $rename_70e_pid || error "rename $rename_70e_pid stopped"
2307 run_test 70e "rename cross-MDT with random fails"
2309 test_70f_write_and_read(){
2314 echo "Write/read files in: '$DIR/$tdir', clients: '$CLIENTS' ..."
2315 for client in ${CLIENTS//,/ }; do
2316 [ -f $stopflag ] || return
2318 local tgtfile=$DIR/$tdir/$tfile.$client
2319 do_node $client dd $DD_OPTS bs=1M count=10 if=$srcfile \
2320 of=$tgtfile 2>/dev/null ||
2321 error "dd $DD_OPTS bs=1M count=10 if=$srcfile " \
2322 "of=$tgtfile failed on $client, rc=$?"
2325 local prev_client=$(echo ${CLIENTS//,/ } | awk '{ print $NF }')
2328 for client in ${CLIENTS//,/ }; do
2329 [ -f $stopflag ] || return
2331 # flush client cache in case test is running on only one client
2332 # do_node $client cancel_lru_locks osc
2333 do_node $client $LCTL set_param ldlm.namespaces.*.lru_size=clear
2335 tgtfile=$DIR/$tdir/$tfile.$client
2336 local md5=$(do_node $prev_client "md5sum $tgtfile")
2337 [ ${checksum[$index]// */} = ${md5// */} ] ||
2338 error "$tgtfile: checksum doesn't match on $prev_client"
2339 index=$((index + 1))
2349 mkdir -p $DIR/$tdir || error "cannot create $DIR/$tdir directory"
2350 $LFS setstripe -c -1 $DIR/$tdir ||
2351 error "cannot $LFS setstripe $DIR/$tdir"
2354 while [ -f $stopflag ]; do
2355 test_70f_write_and_read $srcfile $stopflag
2356 # use direct IO and buffer cache in turns if loop
2357 [ -n "$DD_OPTS" ] && DD_OPTS="" || DD_OPTS="oflag=direct"
2361 test_70f_cleanup() {
2363 rm -f $TMP/$tfile.stop
2364 do_nodes $CLIENTS rm -f $TMP/$tfile
2365 rm -f $DIR/$tdir/$tfile.*
2369 # [ x$ost1failover_HOST = x$ost_HOST ] &&
2370 # { skip "Failover host not defined" && return; }
2371 # [ $CLIENTCOUNT -lt 2 ] &&
2372 # { skip "Need 2 or more clients, have $CLIENTCOUNT" && return; }
2374 [[ "$OST1_VERSION" -lt $(version_code 2.9.53) ]] &&
2375 skip "Need server version at least 2.9.53"
2377 echo "mount clients $CLIENTS ..."
2378 zconf_mount_clients $CLIENTS $MOUNT
2380 local srcfile=$TMP/$tfile
2384 trap test_70f_cleanup EXIT
2385 # create a different source file local to each client node so we can
2386 # detect if the file wasn't written out properly after failover
2387 do_nodes $CLIENTS dd bs=1M count=10 if=/dev/urandom of=$srcfile \
2388 2>/dev/null || error "can't create $srcfile on $CLIENTS"
2389 for client in ${CLIENTS//,/ }; do
2390 checksum[$index]=$(do_node $client "md5sum $srcfile")
2391 index=$((index + 1))
2395 [ "$SLOW" = "no" ] && duration=60
2396 # set duration to 900 because it takes some time to boot node
2397 [ "$FAILURE_MODE" = HARD ] && duration=900
2399 local stopflag=$TMP/$tfile.stop
2400 test_70f_loop $srcfile $stopflag &
2404 local num_failovers=0
2405 local start_ts=$SECONDS
2406 while [ $elapsed -lt $duration ]; do
2410 num_failovers=$((num_failovers + 1))
2411 log "$TESTNAME failing OST $num_failovers times"
2414 elapsed=$((SECONDS - start_ts))
2421 run_test 70f "OSS O_DIRECT recovery with $CLIENTCOUNT clients"
2425 kill -9 $mkdir_71a_pid
2428 random_double_fail_mdt() {
2431 local monitor_pid=$3
2433 local start_ts=$(date +%s)
2434 local num_failovers=0
2438 elapsed=$(($(date +%s) - start_ts))
2439 while [ $elapsed -lt $duration ]; do
2440 fail_index=$((RANDOM%max_index + 1))
2441 if [ $fail_index -eq $max_index ]; then
2444 second_index=$((fail_index + 1))
2446 kill -0 $monitor_pid ||
2447 error "$monitor_pid stopped"
2449 replay_barrier mds$fail_index
2450 replay_barrier mds$second_index
2452 # Increment the number of failovers
2453 num_failovers=$((num_failovers+1))
2454 log "fail mds$fail_index mds$second_index $num_failovers times"
2455 fail mds${fail_index},mds${second_index}
2456 elapsed=$(($(date +%s) - start_ts))
2461 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2462 local clients=${CLIENTS:-$HOSTNAME}
2465 zconf_mount_clients $clients $MOUNT
2468 [ "$SLOW" = "no" ] && duration=180
2469 # set duration to 900 because it takes some time to boot node
2470 [ "$FAILURE_MODE" = HARD ] && duration=900
2472 mkdir_on_mdt0 $DIR/$tdir
2475 local start_ts=$(date +%s)
2477 trap cleanup_71a EXIT
2480 $LFS mkdir -i0 -c2 $DIR/$tdir/test
2481 rmdir $DIR/$tdir/test
2485 echo "Started $mkdir_71a_pid"
2487 random_double_fail_mdt 2 $duration $mkdir_71a_pid
2488 kill -0 $mkdir_71a_pid || error "mkdir/rmdir $mkdir_71a_pid stopped"
2493 run_test 71a "mkdir/rmdir striped dir with 2 mdts recovery"
2496 multiop_bg_pause $DIR/$tfile O_tSc ||
2497 error "multiop_bg_pause $DIR/$tfile failed"
2501 replay_barrier $SINGLEMDS
2502 #define OBD_FAIL_LDLM_ENQUEUE_NET 0x302
2503 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000302"
2506 wait $pid || error "multiop pid failed"
2507 [ -e $DIR/$tfile ] && error "file $DIR/$tfile should not exist"
2510 run_test 73a "open(O_CREAT), unlink, replay, reconnect before open replay, close"
2513 multiop_bg_pause $DIR/$tfile O_tSc ||
2514 error "multiop_bg_pause $DIR/$tfile failed"
2518 replay_barrier $SINGLEMDS
2519 #define OBD_FAIL_MDS_LDLM_REPLY_NET 0x157
2520 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000157"
2523 wait $pid || error "multiop pid failed"
2524 [ -e $DIR/$tfile ] && error "file $DIR/$tfile should not exist"
2527 run_test 73b "open(O_CREAT), unlink, replay, reconnect at open_replay reply, close"
2531 local clients=${CLIENTS:-$HOSTNAME}
2533 zconf_umount_clients $clients $MOUNT
2535 facet_failover $SINGLEMDS
2536 zconf_mount_clients $clients $MOUNT
2538 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
2539 rm $DIR/$tfile || error "rm $DIR/$tfile failed"
2540 clients_up || error "client evicted: $?"
2543 run_test 74 "Ensure applications don't fail waiting for OST recovery"
2545 remote_dir_check_80() {
2550 diridx=$($LFS getstripe -m $remote_dir) ||
2551 error "$LFS getstripe -m $remote_dir failed"
2552 [ $diridx -eq $mdtidx ] || error "$diridx != $mdtidx"
2554 createmany -o $remote_dir/f-%d 20 || error "creation failed"
2555 fileidx=$($LFS getstripe -m $remote_dir/f-1) ||
2556 error "$LFS getstripe -m $remote_dir/f-1 failed"
2557 [ $fileidx -eq $mdtidx ] || error "$fileidx != $mdtidx"
2563 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2564 ([ $FAILURE_MODE == "HARD" ] &&
2565 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
2566 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
2570 local remote_dir=$DIR/$tdir/remote_dir
2572 mkdir_on_mdt0 $DIR/$tdir || error "mkdir $DIR/$tdir failed"
2573 #define OBD_FAIL_OUT_UPDATE_NET_REP 0x1701
2574 do_facet mds${MDTIDX} lctl set_param fail_loc=0x1701
2575 $LFS mkdir -i $MDTIDX $remote_dir &
2581 wait $CLIENT_PID || error "remote creation failed"
2583 remote_dir_check_80 || error "remote dir check failed"
2584 rm -rf $DIR/$tdir || error "rmdir failed"
2588 run_test 80a "DNE: create remote dir, drop update rep from MDT0, fail MDT0"
2591 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2592 ([ $FAILURE_MODE == "HARD" ] &&
2593 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
2594 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
2598 local remote_dir=$DIR/$tdir/remote_dir
2600 mkdir_on_mdt0 $DIR/$tdir || error "mkdir $DIR/$tdir failed"
2601 #define OBD_FAIL_OUT_UPDATE_NET_REP 0x1701
2602 do_facet mds${MDTIDX} lctl set_param fail_loc=0x1701
2603 $LFS mkdir -i $MDTIDX $remote_dir &
2608 fail mds$((MDTIDX + 1))
2610 wait $CLIENT_PID || error "remote creation failed"
2612 remote_dir_check_80 || error "remote dir check failed"
2613 rm -rf $DIR/$tdir || error "rmdir failed"
2617 run_test 80b "DNE: create remote dir, drop update rep from MDT0, fail MDT1"
2620 [[ "$mds1_FSTYPE" = zfs ]] &&
2621 [[ $MDS1_VERSION -lt $(version_code 2.12.51) ]] &&
2622 skip "requires LU-10143 fix on MDS"
2623 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
2624 ([ $FAILURE_MODE == "HARD" ] &&
2625 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
2626 skip "MDTs needs to be on diff hosts for HARD fail mode"
2629 local remote_dir=$DIR/$tdir/remote_dir
2631 mkdir_on_mdt0 $DIR/$tdir || error "mkdir $DIR/$tdir failed"
2632 #define OBD_FAIL_OUT_UPDATE_NET_REP 0x1701
2633 do_facet mds${MDTIDX} lctl set_param fail_loc=0x1701
2634 $LFS mkdir -i $MDTIDX $remote_dir &
2640 fail mds$((MDTIDX + 1))
2642 wait $CLIENT_PID || error "remote creation failed"
2644 remote_dir_check_80 || error "remote dir check failed"
2645 rm -rf $DIR/$tdir || error "rmdir failed"
2649 run_test 80c "DNE: create remote dir, drop update rep from MDT1, fail MDT[0,1]"
2652 [[ "$mds1_FSTYPE" = zfs ]] &&
2653 [[ $MDS1_VERSION -lt $(version_code 2.12.51) ]] &&
2654 skip "requires LU-10143 fix on MDS"
2655 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
2657 local remote_dir=$DIR/$tdir/remote_dir
2659 mkdir_on_mdt0 $DIR/$tdir || error "mkdir $DIR/$tdir failed"
2660 #define OBD_FAIL_OUT_UPDATE_NET_REP 0x1701
2661 do_facet mds${MDTIDX} lctl set_param fail_loc=0x1701
2662 $LFS mkdir -i $MDTIDX $remote_dir &
2665 # sleep 3 seconds to make sure MDTs are failed after
2666 # lfs mkdir -i has finished on all of MDTs.
2671 fail mds${MDTIDX},mds$((MDTIDX + 1))
2673 wait $CLIENT_PID || error "remote creation failed"
2675 remote_dir_check_80 || error "remote dir check failed"
2676 rm -rf $DIR/$tdir || error "rmdir failed"
2680 run_test 80d "DNE: create remote dir, drop update rep from MDT1, fail 2 MDTs"
2683 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2684 ([ $FAILURE_MODE == "HARD" ] &&
2685 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
2686 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
2690 local remote_dir=$DIR/$tdir/remote_dir
2692 mkdir_on_mdt0 $DIR/$tdir || error "mkdir $DIR/$tdir failed"
2693 # OBD_FAIL_MDS_REINT_NET_REP 0x119
2694 do_facet mds$((MDTIDX + 1)) lctl set_param fail_loc=0x119
2695 $LFS mkdir -i $MDTIDX $remote_dir &
2698 # sleep 3 seconds to make sure MDTs are failed after
2699 # lfs mkdir -i has finished on all of MDTs.
2705 wait $CLIENT_PID || error "remote creation failed"
2707 remote_dir_check_80 || error "remote dir check failed"
2708 rm -rf $DIR/$tdir || error "rmdir failed"
2712 run_test 80e "DNE: create remote dir, drop MDT1 rep, fail MDT0"
2715 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2716 ([ $FAILURE_MODE == "HARD" ] &&
2717 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
2718 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
2721 local remote_dir=$DIR/$tdir/remote_dir
2723 mkdir_on_mdt0 $DIR/$tdir || error "mkdir $DIR/$tdir failed"
2724 # OBD_FAIL_MDS_REINT_NET_REP 0x119
2725 do_facet mds$((MDTIDX + 1)) lctl set_param fail_loc=0x119
2726 $LFS mkdir -i $MDTIDX $remote_dir &
2730 fail mds$((MDTIDX + 1))
2732 wait $CLIENT_PID || error "remote creation failed"
2734 remote_dir_check_80 || error "remote dir check failed"
2735 rm -rf $DIR/$tdir || error "rmdir failed"
2739 run_test 80f "DNE: create remote dir, drop MDT1 rep, fail MDT1"
2742 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2743 ([ $FAILURE_MODE == "HARD" ] &&
2744 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
2745 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
2749 local remote_dir=$DIR/$tdir/remote_dir
2751 mkdir_on_mdt0 $DIR/$tdir || error "mkdir $DIR/$tdir failed"
2752 # OBD_FAIL_MDS_REINT_NET_REP 0x119
2753 do_facet mds$((MDTIDX + 1)) lctl set_param fail_loc=0x119
2754 $LFS mkdir -i $MDTIDX $remote_dir &
2757 # sleep 3 seconds to make sure MDTs are failed after
2758 # lfs mkdir -i has finished on all of MDTs.
2764 fail mds$((MDTIDX + 1))
2766 wait $CLIENT_PID || error "remote creation failed"
2768 remote_dir_check_80 || error "remote dir check failed"
2769 rm -rf $DIR/$tdir || error "rmdir failed"
2773 run_test 80g "DNE: create remote dir, drop MDT1 rep, fail MDT0, then MDT1"
2776 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2778 local remote_dir=$DIR/$tdir/remote_dir
2780 mkdir_on_mdt0 $DIR/$tdir || error "mkdir $DIR/$tdir failed"
2781 # OBD_FAIL_MDS_REINT_NET_REP 0x119
2782 do_facet mds$((MDTIDX + 1)) lctl set_param fail_loc=0x119
2783 $LFS mkdir -i $MDTIDX $remote_dir &
2786 # sleep 3 seconds to make sure MDTs are failed after
2787 # lfs mkdir -i has finished on all of MDTs.
2792 fail mds${MDTIDX},mds$((MDTIDX + 1))
2794 wait $CLIENT_PID || error "remote dir creation failed"
2796 remote_dir_check_80 || error "remote dir check failed"
2797 rm -rf $DIR/$tdir || error "rmdir failed"
2801 run_test 80h "DNE: create remote dir, drop MDT1 rep, fail 2 MDTs"
2804 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2805 ([ $FAILURE_MODE == "HARD" ] &&
2806 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
2807 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
2811 local remote_dir=$DIR/$tdir/remote_dir
2813 mkdir_on_mdt0 $DIR/$tdir || error "mkdir $DIR/$tdir failed"
2814 $LFS mkdir -i $MDTIDX $remote_dir || error "lfs mkdir failed"
2816 touch $remote_dir || error "touch $remote_dir failed"
2817 # OBD_FAIL_OUT_UPDATE_NET_REP 0x1701
2818 do_facet mds${MDTIDX} lctl set_param fail_loc=0x1701
2823 fail mds$((MDTIDX + 1))
2825 wait $CLIENT_PID || error "rm remote dir failed"
2827 stat $remote_dir &>/dev/null && error "$remote_dir still exist!"
2829 rm -rf $DIR/$tdir || error "rmdir failed"
2833 run_test 81a "DNE: unlink remote dir, drop MDT0 update rep, fail MDT1"
2836 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2837 ([ $FAILURE_MODE == "HARD" ] &&
2838 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
2839 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
2842 local remote_dir=$DIR/$tdir/remote_dir
2844 mkdir_on_mdt0 $DIR/$tdir || error "mkdir $DIR/$tdir failed"
2845 $LFS mkdir -i $MDTIDX $remote_dir || error "lfs mkdir failed"
2847 # OBD_FAIL_OUT_UPDATE_NET_REP 0x1701
2848 do_facet mds${MDTIDX} lctl set_param fail_loc=0x1701
2855 wait $CLIENT_PID || error "rm remote dir failed"
2857 stat $remote_dir &>/dev/null && error "$remote_dir still exist!"
2859 rm -rf $DIR/$tdir || error "rmdir failed"
2863 run_test 81b "DNE: unlink remote dir, drop MDT0 update reply, fail MDT0"
2866 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2867 ([ $FAILURE_MODE == "HARD" ] &&
2868 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
2869 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
2873 local remote_dir=$DIR/$tdir/remote_dir
2875 mkdir_on_mdt0 $DIR/$tdir || error "mkdir $DIR/$tdir failed"
2876 $LFS mkdir -i $MDTIDX $remote_dir || error "lfs mkdir failed"
2878 # OBD_FAIL_OUT_UPDATE_NET_REP 0x1701
2879 do_facet mds${MDTIDX} lctl set_param fail_loc=0x1701
2886 fail mds$((MDTIDX + 1))
2888 wait $CLIENT_PID || error "rm remote dir failed"
2890 stat $remote_dir &>/dev/null && error "$remote_dir still exist!"
2892 rm -rf $DIR/$tdir || error "rmdir failed"
2896 run_test 81c "DNE: unlink remote dir, drop MDT0 update reply, fail MDT0,MDT1"
2899 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2901 local remote_dir=$DIR/$tdir/remote_dir
2903 mkdir_on_mdt0 $DIR/$tdir || error "mkdir $DIR/$tdir failed"
2904 $LFS mkdir -i $MDTIDX $remote_dir || error "lfs mkdir failed"
2906 # OBD_FAIL_OUT_UPDATE_NET_REP 0x1701
2907 do_facet mds${MDTIDX} lctl set_param fail_loc=0x1701
2913 fail mds${MDTIDX},mds$((MDTIDX + 1))
2915 wait $CLIENT_PID || error "rm remote dir failed"
2917 stat $remote_dir &>/dev/null && error "$remote_dir still exist!"
2919 rm -rf $DIR/$tdir || error "rmdir failed"
2923 run_test 81d "DNE: unlink remote dir, drop MDT0 update reply, fail 2 MDTs"
2926 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2927 ([ $FAILURE_MODE == "HARD" ] &&
2928 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
2929 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
2933 local remote_dir=$DIR/$tdir/remote_dir
2935 mkdir_on_mdt0 $DIR/$tdir || error "mkdir $DIR/$tdir failed"
2936 $LFS mkdir -i $MDTIDX $remote_dir || error "lfs mkdir failed"
2938 # OBD_FAIL_MDS_REINT_NET_REP 0x119
2939 do_facet mds$((MDTIDX + 1)) lctl set_param fail_loc=0x119
2942 do_facet mds$((MDTIDX + 1)) lctl set_param fail_loc=0
2947 wait $CLIENT_PID || error "rm remote dir failed"
2949 stat $remote_dir &>/dev/null && error "$remote_dir still exist!"
2951 rm -rf $DIR/$tdir || error "rmdir failed"
2955 run_test 81e "DNE: unlink remote dir, drop MDT1 req reply, fail MDT0"
2958 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2959 ([ $FAILURE_MODE == "HARD" ] &&
2960 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
2961 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
2965 local remote_dir=$DIR/$tdir/remote_dir
2967 mkdir_on_mdt0 $DIR/$tdir || error "mkdir $DIR/$tdir failed"
2968 $LFS mkdir -i $MDTIDX $remote_dir || error "lfs mkdir failed"
2970 # OBD_FAIL_MDS_REINT_NET_REP 0x119
2971 do_facet mds$((MDTIDX + 1)) lctl set_param fail_loc=0x119
2976 fail mds$((MDTIDX + 1))
2978 wait $CLIENT_PID || error "rm remote dir failed"
2980 stat $remote_dir &>/dev/null && error "$remote_dir still exist!"
2982 rm -rf $DIR/$tdir || error "rmdir failed"
2986 run_test 81f "DNE: unlink remote dir, drop MDT1 req reply, fail MDT1"
2989 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2990 ([ $FAILURE_MODE == "HARD" ] &&
2991 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
2992 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
2996 local remote_dir=$DIR/$tdir/remote_dir
2998 mkdir_on_mdt0 $DIR/$tdir || error "mkdir $DIR/$tdir failed"
2999 $LFS mkdir -i $MDTIDX $remote_dir || error "lfs mkdir failed"
3001 # OBD_FAIL_MDS_REINT_NET_REP 0x119
3002 do_facet mds$((MDTIDX + 1)) lctl set_param fail_loc=0x119
3009 fail mds$((MDTIDX + 1))
3011 wait $CLIENT_PID || error "rm remote dir failed"
3013 stat $remote_dir &>/dev/null && error "$remote_dir still exist!"
3015 rm -rf $DIR/$tdir || error "rmdir failed"
3019 run_test 81g "DNE: unlink remote dir, drop req reply, fail M0, then M1"
3022 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
3024 local remote_dir=$DIR/$tdir/remote_dir
3026 mkdir_on_mdt0 $DIR/$tdir || error "mkdir $DIR/$tdir failed"
3027 $LFS mkdir -i $MDTIDX $remote_dir || error "lfs mkdir failed"
3029 # OBD_FAIL_MDS_REINT_NET_REP 0x119
3030 do_facet mds$((MDTIDX + 1)) lctl set_param fail_loc=0x119
3036 fail mds${MDTIDX},mds$((MDTIDX + 1))
3038 wait $CLIENT_PID || error "rm remote dir failed"
3040 stat $remote_dir &>/dev/null && error "$remote_dir still exist!"
3042 rm -rf $DIR/$tdir || error "rmdir failed"
3046 run_test 81h "DNE: unlink remote dir, drop request reply, fail 2 MDTs"
3049 #define OBD_FAIL_MDS_OPEN_WAIT_CREATE 0x144
3050 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000144"
3051 createmany -o $DIR/$tfile- 1 &
3055 client_up || client_up || true # reconnect
3057 run_test 84a "stale open during export disconnect"
3059 test_85a() { #bug 16774
3060 lctl set_param -n ldlm.cancel_unused_locks_before_replay "1"
3062 for i in $(seq 100); do
3063 echo "tag-$i" > $DIR/$tfile-$i
3064 grep -q "tag-$i" $DIR/$tfile-$i || error "f2-$i"
3067 lov_id=$(lctl dl | grep "clilov")
3068 addr=$(echo $lov_id | awk '{print $4}' | awk -F '-' '{print $NF}')
3069 count=$(lctl get_param -n \
3070 ldlm.namespaces.*MDT0000*$addr.lock_unused_count)
3071 echo "before recovery: unused locks count = $count"
3075 count2=$(lctl get_param -n \
3076 ldlm.namespaces.*MDT0000*$addr.lock_unused_count)
3077 echo "after recovery: unused locks count = $count2"
3079 if [ $count2 -ge $count ]; then
3080 error "unused locks are not canceled"
3083 run_test 85a "check the cancellation of unused locks during recovery(IBITS)"
3085 test_85b() { #bug 16774
3089 lctl set_param -n ldlm.cancel_unused_locks_before_replay "1"
3091 $LFS setstripe -c 1 -i 0 $DIR/$tdir
3093 for i in $(seq 100); do
3094 dd if=/dev/urandom of=$DIR/$tdir/$tfile-$i bs=4096 \
3095 count=32 >/dev/null 2>&1
3098 cancel_lru_locks osc
3100 for i in $(seq 100); do
3101 dd if=$DIR/$tdir/$tfile-$i of=/dev/null bs=4096 \
3102 count=32 >/dev/null 2>&1
3105 lov_id=$(lctl dl | grep "clilov")
3106 addr=$(echo $lov_id | awk '{print $4}' | awk -F '-' '{print $NF}')
3107 count=$(lctl get_param -n \
3108 ldlm.namespaces.*OST0000*$addr.lock_unused_count)
3109 echo "before recovery: unused locks count = $count"
3110 [ $count -ne 0 ] || error "unused locks ($count) should be zero"
3114 count2=$(lctl get_param \
3115 -n ldlm.namespaces.*OST0000*$addr.lock_unused_count)
3116 echo "after recovery: unused locks count = $count2"
3118 if [ $count2 -ge $count ]; then
3119 error "unused locks are not canceled"
3124 run_test 85b "check the cancellation of unused locks during recovery(EXTENT)"
3127 local clients=${CLIENTS:-$HOSTNAME}
3129 zconf_umount_clients $clients $MOUNT
3130 do_facet $SINGLEMDS lctl set_param mdt.${FSNAME}-MDT*.exports.clear=0
3131 remount_facet $SINGLEMDS
3132 zconf_mount_clients $clients $MOUNT
3134 run_test 86 "umount server after clear nid_stats should not hit LBUG"
3137 do_facet ost1 "lctl set_param -n obdfilter.${ost1_svc}.sync_journal 0"
3140 $LFS setstripe -i 0 -c 1 $DIR/$tfile
3141 dd if=/dev/urandom of=$DIR/$tfile bs=1024k count=8 ||
3142 error "dd to $DIR/$tfile failed"
3143 cksum=$(md5sum $DIR/$tfile | awk '{print $1}')
3144 cancel_lru_locks osc
3146 dd if=$DIR/$tfile of=/dev/null bs=1024k count=8 || error "Cannot read"
3147 cksum2=$(md5sum $DIR/$tfile | awk '{print $1}')
3148 if [ $cksum != $cksum2 ] ; then
3149 error "New checksum $cksum2 does not match original $cksum"
3152 run_test 87a "write replay"
3155 do_facet ost1 "lctl set_param -n obdfilter.${ost1_svc}.sync_journal 0"
3158 $LFS setstripe -i 0 -c 1 $DIR/$tfile
3159 dd if=/dev/urandom of=$DIR/$tfile bs=1024k count=8 ||
3160 error "dd to $DIR/$tfile failed"
3161 sleep 1 # Give it a chance to flush dirty data
3162 echo TESTTEST | dd of=$DIR/$tfile bs=1 count=8 seek=64
3163 cksum=$(md5sum $DIR/$tfile | awk '{print $1}')
3164 cancel_lru_locks osc
3166 dd if=$DIR/$tfile of=/dev/null bs=1024k count=8 || error "Cannot read"
3167 cksum2=$(md5sum $DIR/$tfile | awk '{print $1}')
3168 if [ $cksum != $cksum2 ] ; then
3169 error "New checksum $cksum2 does not match original $cksum"
3172 run_test 87b "write replay with changed data (checksum resend)"
3174 test_88() { #bug 17485
3175 mkdir_on_mdt0 $DIR/$tdir || error "mkdir $DIR/$tdir failed"
3176 mkdir -p $TMP/$tdir || error "mkdir $TMP/$tdir failed"
3178 $LFS setstripe -i 0 -c 1 $DIR/$tdir || error "$LFS setstripe failed"
3181 replay_barrier $SINGLEMDS
3183 # exhaust precreations on ost1
3184 local OST=$(ostname_from_index 0)
3185 local mdtosc=$(get_mdtosc_proc_path $SINGLEMDS $OST)
3186 local last_id=$(do_facet $SINGLEMDS lctl get_param -n osp.$mdtosc.prealloc_last_id)
3187 local next_id=$(do_facet $SINGLEMDS lctl get_param -n osp.$mdtosc.prealloc_next_id)
3188 echo "before test: last_id = $last_id, next_id = $next_id"
3190 echo "Creating to objid $last_id on ost $OST..."
3191 createmany -o $DIR/$tdir/f-%d $next_id $((last_id - next_id + 2)) ||
3192 error "createmany create files to last_id failed"
3194 #create some files to use some uncommitted objids
3195 last_id=$(($last_id + 1))
3196 createmany -o $DIR/$tdir/f-%d $last_id 8 ||
3197 error "createmany create files with uncommitted objids failed"
3199 last_id2=$(do_facet $SINGLEMDS lctl get_param -n osp.$mdtosc.prealloc_last_id)
3200 next_id2=$(do_facet $SINGLEMDS lctl get_param -n osp.$mdtosc.prealloc_next_id)
3201 echo "before recovery: last_id = $last_id2, next_id = $next_id2"
3203 # if test uses shutdown_facet && reboot_facet instead of facet_failover ()
3204 # it has to take care about the affected facets, bug20407
3205 local affected_mds1=$(affected_facets mds1)
3206 local affected_ost1=$(affected_facets ost1)
3208 shutdown_facet $SINGLEMDS
3211 reboot_facet $SINGLEMDS
3212 change_active $affected_mds1
3213 wait_for_facet $affected_mds1
3214 mount_facets $affected_mds1 || error "Restart of mds failed"
3217 change_active $affected_ost1
3218 wait_for_facet $affected_ost1
3219 mount_facets $affected_ost1 || error "Restart of ost1 failed"
3223 last_id2=$(do_facet $SINGLEMDS lctl get_param -n osp.$mdtosc.prealloc_last_id)
3224 next_id2=$(do_facet $SINGLEMDS lctl get_param -n osp.$mdtosc.prealloc_next_id)
3225 echo "after recovery: last_id = $last_id2, next_id = $next_id2"
3227 # create new files, which should use new objids, and ensure the orphan
3228 # cleanup phase for ost1 is completed at the same time
3229 for i in $(seq 8); do
3230 file_id=$(($last_id + 10 + $i))
3231 dd if=/dev/urandom of=$DIR/$tdir/f-$file_id bs=4096 count=128
3234 # if the objids were not recreated, then "ls" will fail with -ENOENT
3235 ls -l $DIR/$tdir/* || error "can't get the status of precreated files"
3238 # write into previously created files
3239 for i in $(seq 8); do
3240 file_id=$(($last_id + $i))
3241 dd if=/dev/urandom of=$DIR/$tdir/f-$file_id bs=4096 count=128
3242 cp -f $DIR/$tdir/f-$file_id $TMP/$tdir/
3245 # compare the content
3246 for i in $(seq 8); do
3247 file_id=$(($last_id + $i))
3248 cmp $TMP/$tdir/f-$file_id $DIR/$tdir/f-$file_id ||
3249 error "the content of file is modified!"
3254 run_test 88 "MDS should not assign same objid to different files "
3257 cancel_lru_locks osc
3258 mkdir_on_mdt0 $DIR/$tdir || error "mkdir $DIR/$tdir failed"
3259 rm -f $DIR/$tdir/$tfile
3260 wait_mds_ost_sync || error "initial MDS-OST sync timed out"
3261 wait_delete_completed || error "initial wait delete timed out"
3262 local before=$(calc_osc_kbytes kbytesfree)
3263 local write_size=$(fs_log_size)
3265 $LFS setstripe -i 0 -c 1 $DIR/$tdir/$tfile
3266 (( $write_size >= 1024 )) || write_size=1024
3267 dd if=/dev/zero bs=${write_size}k count=10 of=$DIR/$tdir/$tfile
3270 facet_failover $SINGLEMDS
3271 rm $DIR/$tdir/$tfile
3274 zconf_mount $(hostname) $MOUNT || error "mount fails"
3275 client_up || error "client_up failed"
3277 # wait for the remounted client to connect to ost1
3278 local target=$(get_osc_import_name client ost1)
3279 wait_import_state "FULL" "osc.${target}.ost_server_uuid" \
3280 $(max_recovery_time)
3282 wait_mds_ost_sync || error "MDS-OST sync timed out"
3283 wait_delete_completed || error "wait delete timed out"
3284 local after=$(calc_osc_kbytes kbytesfree)
3286 log "free_before: $before free_after: $after"
3287 (( $before <= $after + $(fs_log_size) )) ||
3288 error "kbytesfree $before > $after + margin $(fs_log_size)"
3290 run_test 89 "no disk space leak on late ost connection"
3297 change_active $facet
3298 wait_for_facet $facet
3299 mount_facet $facet || error "Restart of $facet failed"
3303 test_90() { # bug 19494
3304 local dir=$DIR/$tdir
3305 local ostfail=$(get_random_entry $(get_facets OST))
3307 if [[ $FAILURE_MODE = HARD ]]; then
3308 local affected=$(affected_facets $ostfail);
3310 [[ "$affected" == $ostfail ]] ||
3311 skip "cannot use FAILURE_MODE=$FAILURE_MODE, affected: $affected"
3313 # ensure all OSTs are active to allow allocations
3316 mkdir $dir || error "mkdir $dir failed"
3318 echo "Create the files"
3320 # file "f${index}" striped over 1 OST
3321 # file "all" striped over all OSTs
3323 $LFS setstripe -c $OSTCOUNT $dir/all ||
3324 error "setstripe failed to create $dir/all"
3326 for ((i = 0; i < $OSTCOUNT; i++)); do
3329 $LFS setstripe -i $i -c 1 $f ||
3330 error "$LFS setstripe failed to create $f"
3332 # confirm setstripe actually created stripe on requested OST
3333 local uuid=$(ostuuid_from_index $i)
3335 for file in f$i all; do
3336 local found=$($LFS find --obd $uuid --name $file $dir)
3338 if [[ $dir/$file != $found ]]; then
3339 $LFS getstripe $dir/$file
3340 error "wrong stripe: $file, uuid: $uuid"
3345 # Before failing an OST, get its obd name and index
3346 local varsvc=${ostfail}_svc
3347 local obd=$(do_facet $ostfail lctl get_param \
3348 -n obdfilter.${!varsvc}.uuid)
3349 local index=$(($(facet_number $ostfail) - 1))
3351 echo "Fail $ostfail $obd, display the list of affected files"
3352 shutdown_facet $ostfail || error "shutdown_facet $ostfail failed"
3354 trap "cleanup_90 $ostfail" EXIT INT
3355 echo "General Query: lfs find $dir"
3356 local list=$($LFS find $dir)
3358 for (( i=0; i<$OSTCOUNT; i++ )); do
3359 list_member "$list" $dir/f$i ||
3360 error_noexit "lfs find $dir: no file f$i"
3362 list_member "$list" $dir/all ||
3363 error_noexit "lfs find $dir: no file all"
3365 # focus on the missing OST,
3366 # we expect to see only two files affected: "f$(index)" and "all"
3368 echo "Querying files on shutdown $ostfail: lfs find --obd $obd"
3369 list=$($LFS find --obd $obd $dir)
3371 for file in all f$index; do
3372 list_member "$list" $dir/$file ||
3373 error_noexit "lfs find does not report the affected $obd for $file"
3376 [[ $(echo $list | wc -w) -eq 2 ]] ||
3377 error_noexit "lfs find reports the wrong list of affected files ${#list[@]}"
3379 echo "Check getstripe: $LFS getstripe -r --obd $obd"
3380 list=$($LFS getstripe -r --obd $obd $dir)
3382 for file in all f$index; do
3383 echo "$list" | grep $dir/$file ||
3384 error_noexit "lfs getsripe does not report the affected $obd for $file"
3389 run_test 90 "lfs find identifies the missing striped file segments"
3392 [[ "$MDS1_VERSION" -ge $(version_code 2.6.90) ]] ||
3393 [[ "$MDS1_VERSION" -ge $(version_code 2.5.4) &&
3394 "$MDS1_VERSION" -lt $(version_code 2.5.50) ]] ||
3395 skip "Need MDS version 2.5.4+ or 2.6.90+"
3397 cancel_lru_locks osc
3399 $LFS setstripe -i 0 -c 1 $DIR/$tfile ||
3400 error "$LFS setstripe $DIR/$tfile failed"
3401 dd if=/dev/zero of=$DIR/$tfile bs=1024 count=1 ||
3402 error "dd to $DIR/$tfile failed"
3403 #define OBD_FAIL_TGT_REPLAY_RECONNECT 0x715
3404 # We need to emulate a state that OST is waiting for other clients
3405 # not completing the recovery. Final ping is queued, but reply will be
3406 # sent on the recovery completion. It is done by sleep before
3407 # processing final pings
3408 do_facet ost1 "$LCTL set_param fail_val=40"
3409 do_facet ost1 "$LCTL set_param fail_loc=0x715"
3412 run_test 93a "replay + reconnect"
3415 [[ "$MDS1_VERSION" -ge $(version_code 2.7.90) ]] ||
3416 skip "Need MDS version 2.7.90+"
3418 cancel_lru_locks mdc
3420 createmany -o $DIR/$tfile 20 ||
3421 error "createmany -o $DIR/$tfile failed"
3423 #define OBD_FAIL_TGT_REPLAY_RECONNECT 0x715
3424 # We need to emulate a state that MDT is waiting for other clients
3425 # not completing the recovery. Final ping is queued, but reply will be
3426 # sent on the recovery completion. It is done by sleep before
3427 # processing final pings
3428 do_facet mds1 "$LCTL set_param fail_val=80"
3429 do_facet mds1 "$LCTL set_param fail_loc=0x715"
3432 run_test 93b "replay + reconnect on mds"
3434 striped_dir_check_100() {
3435 local striped_dir=$DIR/$tdir/striped_dir
3436 local stripe_count=$($LFS getdirstripe -c $striped_dir)
3438 $LFS getdirstripe $striped_dir
3439 [ $stripe_count -eq 2 ] || error "$stripe_count != 2"
3441 createmany -o $striped_dir/f-%d 20 ||
3442 error "creation failed under striped dir"
3446 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
3447 ([ $FAILURE_MODE == "HARD" ] &&
3448 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
3449 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
3452 local striped_dir=$DIR/$tdir/striped_dir
3455 mkdir_on_mdt0 $DIR/$tdir || error "mkdir $DIR/$tdir failed"
3457 #To make sure MDT1 and MDT0 are connected
3458 #otherwise it may create single stripe dir here
3459 $LFS setdirstripe -i1 $DIR/$tdir/remote_dir
3461 #define OBD_FAIL_OUT_UPDATE_NET_REP 0x1701
3462 do_facet mds$((MDTIDX+1)) lctl set_param fail_loc=0x1701
3463 $LFS setdirstripe -i0 -c2 $striped_dir &
3466 fail mds$((MDTIDX + 1))
3468 wait $CLIENT_PID || error "striped dir creation failed"
3470 striped_dir_check_100 || error "striped dir check failed"
3471 rm -rf $DIR/$tdir || error "rmdir failed"
3473 run_test 100a "DNE: create striped dir, drop update rep from MDT1, fail MDT1"
3476 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
3477 ([ $FAILURE_MODE == "HARD" ] &&
3478 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
3479 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
3482 local striped_dir=$DIR/$tdir/striped_dir
3485 mkdir_on_mdt0 $DIR/$tdir || error "mkdir $DIR/$tdir failed"
3487 #To make sure MDT1 and MDT0 are connected
3488 #otherwise it may create single stripe dir here
3489 $LFS setdirstripe -i1 $DIR/$tdir/remote_dir
3491 # OBD_FAIL_MDS_REINT_NET_REP 0x119
3492 do_facet mds$MDTIDX lctl set_param fail_loc=0x119
3493 $LFS mkdir -i0 -c2 $striped_dir &
3498 wait $CLIENT_PID || error "striped dir creation failed"
3500 striped_dir_check_100 || error "striped dir check failed"
3501 rm -rf $DIR/$tdir || error "rmdir failed"
3503 run_test 100b "DNE: create striped dir, fail MDT0"
3506 (( $MDSCOUNT >= 2 )) || skip "needs >= 2 MDTs"
3507 [[ "$FAILURE_MODE" != "HARD" ||
3508 "$(facet_host mds1)" != "$(facet_host mds2)" ]] ||
3509 skip "MDTs needs to be on diff hosts for HARD fail mode"
3511 local striped_dir=$DIR/$tdir/striped_dir
3513 mkdir_on_mdt0 $DIR/$tdir || error "mkdir $DIR/$tdir failed"
3515 #To make sure MDT1 and MDT0 are connected
3516 #otherwise it may create single stripe dir here
3517 $LFS setdirstripe -i1 $DIR/$tdir/remote_dir
3520 $LFS mkdir -i1 -c2 $striped_dir
3522 stack_trap fail_abort_cleanup RETURN
3523 fail_abort mds2 abort_recov_mdt
3525 createmany -o $striped_dir/f-%d 20 &&
3526 error "createmany -o $DIR/$tfile should fail"
3530 # LU-16159 abort_recovery will cancel update logs, the second recovery
3531 # won't replay $striped_dir creation
3532 (( $MDS1_VERSION >= $(version_code 2.15.52) )) ||
3533 striped_dir_check_100 || error "striped dir check failed"
3535 run_test 100c "DNE: create striped dir, abort_recov_mdt mds2"
3538 (( $MDSCOUNT > 1 )) || skip "needs > 1 MDTs"
3539 (( $MDS1_VERSION >= $(version_code 2.15.52.144) )) ||
3540 skip "Need MDS version 2.15.52.144+"
3542 test_mkdir -c $MDSCOUNT $DIR/$tdir || error "mkdir $tdir failed"
3543 $LFS setdirstripe -D -i -1 -c $MDSCOUNT $DIR/$tdir ||
3544 error "set $tdir default LMV failed"
3545 createmany -d $DIR/$tdir/s 100 || error "create subdir failed"
3547 local index=$((RANDOM % MDSCOUNT))
3548 local devname=$(mdtname_from_index $index)
3549 local mdt=mds$((index + 1))
3554 # cancel update llog upon recovery abort
3555 do_facet $mdt $LCTL --device $devname llog_print update_log
3556 log=$(do_facet $mdt "$LCTL --device $devname llog_print update_log |
3557 awk '/index/ { print \\\$4; exit }'")
3559 count=$(do_facet $mdt "$LCTL --device $devname llog_print update_log |
3561 (( count > 0 )) || error "no update logs found"
3562 stack_trap fail_abort_cleanup RETURN
3563 fail_abort $mdt || error "fail_abort $mdt failed"
3564 wait_update_facet $mdt "$LCTL --device $devname llog_print update_log |
3565 grep -c index" 0 60 || error "update logs not canceled"
3567 run_test 100d "DNE: cancel update logs upon recovery abort"
3569 test_101() { #LU-5648
3570 mkdir -p $DIR/$tdir/d1
3571 mkdir -p $DIR/$tdir/d2
3572 touch $DIR/$tdir/file0
3575 replay_barrier $SINGLEMDS
3576 for i in $(seq $num) ; do
3577 echo test$i > $DIR/$tdir/d1/file$i
3580 fail_abort $SINGLEMDS
3581 for i in $(seq $num) ; do
3582 touch $DIR/$tdir/d2/file$i
3583 test -s $DIR/$tdir/d2/file$i &&
3584 ls -al $DIR/$tdir/d2/file$i && error "file$i's size > 0"
3589 run_test 101 "Shouldn't reassign precreated objs to other files after recovery"
3598 [[ $(lctl get_param mdc.*.import |
3599 grep "connect_flags:.*multi_mod_rpc") ]] ||
3600 { skip "Need MDC with 'multi_mod_rpcs' feature"; return 0; }
3602 $LFS mkdir -c1 $DIR/$tdir || error "mkdir $DIR/$tdir failed"
3603 idx=$(printf "%04x" $($LFS getdirstripe -i $DIR/$tdir))
3604 facet="mds$((0x$idx + 1))"
3606 # get current value of max_mod_rcps_in_flight
3607 num=$($LCTL get_param -n \
3608 mdc.$FSNAME-MDT$idx-mdc-*.max_mod_rpcs_in_flight)
3609 # set default value if client does not support multi mod RPCs
3610 [ -z "$num" ] && num=1
3612 echo "creating $num files ..."
3614 for i in $(seq $num); do
3615 touch $DIR/$tdir/file-$i
3618 # drop request on MDT to force resend
3619 #define OBD_FAIL_MDS_REINT_MULTI_NET 0x159
3620 do_facet $facet "$LCTL set_param fail_loc=0x159"
3621 echo "launch $num chmod in parallel ($(date +%H:%M:%S)) ..."
3622 for i in $(seq $num); do
3623 chmod 0600 $DIR/$tdir/file-$i &
3627 do_facet $facet "$LCTL set_param fail_loc=0"
3628 for pid in $pids; do
3629 wait $pid || error "chmod failed"
3631 echo "done ($(date +%H:%M:%S))"
3633 # check chmod succeed
3634 for i in $(seq $num); do
3635 checkstat -vp 0600 $DIR/$tdir/file-$i
3640 run_test 102a "check resend (request lost) with multiple modify RPCs in flight"
3649 [[ $(lctl get_param mdc.*.import |
3650 grep "connect_flags:.*multi_mod_rpc") ]] ||
3651 { skip "Need MDC with 'multi_mod_rpcs' feature"; return 0; }
3653 $LFS mkdir -c1 $DIR/$tdir || error "mkdir $DIR/$tdir failed"
3654 idx=$(printf "%04x" $($LFS getdirstripe -i $DIR/$tdir))
3655 facet="mds$((0x$idx + 1))"
3657 # get current value of max_mod_rcps_in_flight
3658 num=$($LCTL get_param -n \
3659 mdc.$FSNAME-MDT$idx-mdc-*.max_mod_rpcs_in_flight)
3660 # set default value if client does not support multi mod RPCs
3661 [ -z "$num" ] && num=1
3663 echo "creating $num files ..."
3665 for i in $(seq $num); do
3666 touch $DIR/$tdir/file-$i
3669 # drop reply on MDT to force reconstruction
3670 #define OBD_FAIL_MDS_REINT_MULTI_NET_REP 0x15a
3671 do_facet $facet "$LCTL set_param fail_loc=0x15a"
3672 echo "launch $num chmod in parallel ($(date +%H:%M:%S)) ..."
3673 for i in $(seq $num); do
3674 chmod 0600 $DIR/$tdir/file-$i &
3678 do_facet $facet "$LCTL set_param fail_loc=0"
3679 for pid in $pids; do
3680 wait $pid || error "chmod failed"
3682 echo "done ($(date +%H:%M:%S))"
3684 # check chmod succeed
3685 for i in $(seq $num); do
3686 checkstat -vp 0600 $DIR/$tdir/file-$i
3691 run_test 102b "check resend (reply lost) with multiple modify RPCs in flight"
3700 [[ $(lctl get_param mdc.*.import |
3701 grep "connect_flags:.*multi_mod_rpc") ]] ||
3702 { skip "Need MDC with 'multi_mod_rpcs' feature"; return 0; }
3704 $LFS mkdir -c1 $DIR/$tdir || error "mkdir $DIR/$tdir failed"
3705 idx=$(printf "%04x" $($LFS getdirstripe -i $DIR/$tdir))
3706 facet="mds$((0x$idx + 1))"
3708 # get current value of max_mod_rcps_in_flight
3709 num=$($LCTL get_param -n \
3710 mdc.$FSNAME-MDT$idx-mdc-*.max_mod_rpcs_in_flight)
3711 # set default value if client does not support multi mod RPCs
3712 [ -z "$num" ] && num=1
3714 echo "creating $num files ..."
3716 for i in $(seq $num); do
3717 touch $DIR/$tdir/file-$i
3720 replay_barrier $facet
3723 #define OBD_FAIL_MDS_REINT_MULTI_NET_REP 0x15a
3724 do_facet $facet "$LCTL set_param fail_loc=0x15a"
3725 echo "launch $num chmod in parallel ($(date +%H:%M:%S)) ..."
3726 for i in $(seq $num); do
3727 chmod 0600 $DIR/$tdir/file-$i &
3731 do_facet $facet "$LCTL set_param fail_loc=0"
3736 for pid in $pids; do
3737 wait $pid || error "chmod failed"
3739 echo "done ($(date +%H:%M:%S))"
3741 # check chmod succeed
3742 for i in $(seq $num); do
3743 checkstat -vp 0600 $DIR/$tdir/file-$i
3748 run_test 102c "check replay w/o reconstruction with multiple mod RPCs in flight"
3757 [[ $(lctl get_param mdc.*.import |
3758 grep "connect_flags:.*multi_mod_rpc") ]] ||
3759 { skip "Need MDC with 'multi_mod_rpcs' feature"; return 0; }
3761 $LFS mkdir -c1 $DIR/$tdir || error "mkdir $DIR/$tdir failed"
3762 idx=$(printf "%04x" $($LFS getdirstripe -i $DIR/$tdir))
3763 facet="mds$((0x$idx + 1))"
3765 # get current value of max_mod_rcps_in_flight
3766 num=$($LCTL get_param -n \
3767 mdc.$FSNAME-MDT$idx-mdc-*.max_mod_rpcs_in_flight)
3768 # set default value if client does not support multi mod RPCs
3769 [ -z "$num" ] && num=1
3771 echo "creating $num files ..."
3773 for i in $(seq $num); do
3774 touch $DIR/$tdir/file-$i
3778 #define OBD_FAIL_MDS_REINT_MULTI_NET_REP 0x15a
3779 do_facet $facet "$LCTL set_param fail_loc=0x15a"
3780 echo "launch $num chmod in parallel ($(date +%H:%M:%S)) ..."
3781 for i in $(seq $num); do
3782 chmod 0600 $DIR/$tdir/file-$i &
3787 # write MDT transactions to disk
3788 do_facet $facet "sync; sync; sync"
3790 do_facet $facet "$LCTL set_param fail_loc=0"
3795 for pid in $pids; do
3796 wait $pid || error "chmod failed"
3798 echo "done ($(date +%H:%M:%S))"
3800 # check chmod succeed
3801 for i in $(seq $num); do
3802 checkstat -vp 0600 $DIR/$tdir/file-$i
3807 run_test 102d "check replay & reconstruction with multiple mod RPCs in flight"
3810 remote_mds_nodsh && skip "remote MDS with nodsh"
3811 [[ "$MDS1_VERSION" -gt $(version_code 2.8.54) ]] ||
3812 skip "Need MDS version 2.8.54+"
3814 #define OBD_FAIL_MDS_TRACK_OVERFLOW 0x162
3815 do_facet mds1 $LCTL set_param fail_loc=0x80000162
3818 createmany -o $DIR/$tdir/t- 30 ||
3819 error "create files on remote directory failed"
3821 rm -rf $DIR/$tdir/t-*
3823 #MDS should crash with tr->otr_next_id overflow
3826 run_test 103 "Check otr_next_id overflow"
3829 check_striped_dir_110()
3831 $CHECKSTAT -t dir $DIR/$tdir/striped_dir ||
3832 error "create striped dir failed"
3833 local stripe_count=$($LFS getdirstripe -c $DIR/$tdir/striped_dir)
3834 [ $stripe_count -eq $MDSCOUNT ] ||
3835 error "$stripe_count != 2 after recovery"
3839 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
3840 [[ "$MDS1_VERSION" -ge $(version_code 2.7.56) ]] ||
3841 skip "Need MDS version at least 2.7.56"
3843 ([ $FAILURE_MODE == "HARD" ] &&
3844 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
3845 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
3850 $LFS mkdir -i1 -c$MDSCOUNT $DIR/$tdir/striped_dir
3853 check_striped_dir_110 || error "check striped_dir failed"
3854 rm -rf $DIR/$tdir || error "rmdir failed"
3858 run_test 110a "DNE: create striped dir, fail MDT1"
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 zconf_mount $(hostname) $MOUNT
3876 client_up || return 1
3878 check_striped_dir_110 || error "check striped_dir failed"
3880 rm -rf $DIR/$tdir || error "rmdir failed"
3884 run_test 110b "DNE: create striped dir, fail MDT1 and client"
3887 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
3888 [[ "$MDS1_VERSION" -ge $(version_code 2.7.56) ]] ||
3889 skip "Need MDS version at least 2.7.56"
3891 ([ $FAILURE_MODE == "HARD" ] &&
3892 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
3893 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
3898 $LFS mkdir -i1 -c$MDSCOUNT $DIR/$tdir/striped_dir
3901 check_striped_dir_110 || error "check striped_dir failed"
3903 rm -rf $DIR/$tdir || error "rmdir failed"
3907 run_test 110c "DNE: create striped dir, fail MDT2"
3910 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
3911 [[ "$MDS1_VERSION" -ge $(version_code 2.7.56) ]] ||
3912 skip "Need MDS version at least 2.7.56"
3914 ([ $FAILURE_MODE == "HARD" ] &&
3915 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
3916 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
3921 $LFS mkdir -i1 -c$MDSCOUNT $DIR/$tdir/striped_dir
3924 zconf_mount $(hostname) $MOUNT
3925 client_up || return 1
3927 check_striped_dir_110 || error "check striped_dir failed"
3929 rm -rf $DIR/$tdir || error "rmdir failed"
3933 run_test 110d "DNE: create striped dir, fail MDT2 and client"
3936 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
3937 [[ "$MDS1_VERSION" -ge $(version_code 2.7.56) ]] ||
3938 skip "Need MDS version at least 2.7.56"
3940 ([ $FAILURE_MODE == "HARD" ] &&
3941 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
3942 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
3947 $LFS mkdir -i1 -c$MDSCOUNT $DIR/$tdir/striped_dir
3951 zconf_mount $(hostname) $MOUNT
3952 client_up || return 1
3954 check_striped_dir_110 || error "check striped_dir failed"
3956 rm -rf $DIR/$tdir || error "rmdir failed"
3960 run_test 110e "DNE: create striped dir, uncommit on MDT2, fail client/MDT1/MDT2"
3963 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
3964 [[ "$MDS1_VERSION" -ge $(version_code 2.7.56) ]] ||
3965 skip "Need MDS version at least 2.7.56"
3967 ([ $FAILURE_MODE == "HARD" ] &&
3968 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
3969 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
3975 $LFS mkdir -i1 -c$MDSCOUNT $DIR/$tdir/striped_dir
3978 check_striped_dir_110 || error "check striped_dir failed"
3980 rm -rf $DIR/$tdir || error "rmdir failed"
3984 run_test 110f "DNE: create striped dir, fail MDT1/MDT2"
3987 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
3988 [[ "$MDS1_VERSION" -ge $(version_code 2.7.56) ]] ||
3989 skip "Need MDS version at least 2.7.56"
3991 ([ $FAILURE_MODE == "HARD" ] &&
3992 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
3993 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
3998 $LFS mkdir -i1 -c$MDSCOUNT $DIR/$tdir/striped_dir
4002 zconf_mount $(hostname) $MOUNT
4003 client_up || return 1
4005 check_striped_dir_110 || error "check striped_dir failed"
4007 rm -rf $DIR/$tdir || error "rmdir failed"
4011 run_test 110g "DNE: create striped dir, uncommit on MDT1, fail client/MDT1/MDT2"
4014 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
4015 [[ "$MDS1_VERSION" -ge $(version_code 2.7.56) ]] ||
4016 skip "Need MDS version at least 2.7.56"
4018 ([ $FAILURE_MODE == "HARD" ] &&
4019 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
4020 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
4024 $LFS mkdir -i1 -c2 $DIR/$tdir/striped_dir
4026 rm -rf $DIR/$tdir/striped_dir
4029 $CHECKSTAT -t dir $DIR/$tdir/striped_dir &&
4030 error "striped dir still exists"
4033 run_test 111a "DNE: unlink striped dir, fail MDT1"
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 zconf_mount $(hostname) $MOUNT
4052 client_up || return 1
4054 $CHECKSTAT -t dir $DIR/$tdir/striped_dir &&
4055 error "striped dir still exists"
4058 run_test 111b "DNE: unlink striped dir, fail MDT2"
4061 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
4062 [[ "$MDS1_VERSION" -ge $(version_code 2.7.56) ]] ||
4063 skip "Need MDS version at least 2.7.56"
4065 ([ $FAILURE_MODE == "HARD" ] &&
4066 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
4067 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
4071 $LFS mkdir -i1 -c2 $DIR/$tdir/striped_dir
4073 rm -rf $DIR/$tdir/striped_dir
4077 zconf_mount $(hostname) $MOUNT
4078 client_up || return 1
4079 $CHECKSTAT -t dir $DIR/$tdir/striped_dir &&
4080 error "striped dir still exists"
4083 run_test 111c "DNE: unlink striped dir, uncommit on MDT1, fail client/MDT1/MDT2"
4086 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
4087 [[ "$MDS1_VERSION" -ge $(version_code 2.7.56) ]] ||
4088 skip "Need MDS version at least 2.7.56"
4090 ([ $FAILURE_MODE == "HARD" ] &&
4091 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
4092 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
4096 $LFS mkdir -i1 -c2 $DIR/$tdir/striped_dir
4098 rm -rf $DIR/$tdir/striped_dir
4102 zconf_mount $(hostname) $MOUNT
4103 client_up || return 1
4104 $CHECKSTAT -t dir $DIR/$tdir/striped_dir &&
4105 error "striped dir still exists"
4109 run_test 111d "DNE: unlink striped dir, uncommit on MDT2, fail client/MDT1/MDT2"
4112 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
4113 [[ "$MDS1_VERSION" -ge $(version_code 2.7.56) ]] ||
4114 skip "Need MDS version at least 2.7.56"
4116 ([ $FAILURE_MODE == "HARD" ] &&
4117 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
4118 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
4122 $LFS mkdir -i1 -c2 $DIR/$tdir/striped_dir
4124 rm -rf $DIR/$tdir/striped_dir
4127 $CHECKSTAT -t dir $DIR/$tdir/striped_dir &&
4128 error "striped dir still exists"
4131 run_test 111e "DNE: unlink striped dir, uncommit on MDT2, fail 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 111f "DNE: unlink striped dir, uncommit on MDT1, fail MDT1/MDT2"
4156 (( $MDSCOUNT >= 2 )) || skip "needs >= 2 MDTs"
4157 (( $MDS1_VERSION >= $(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"
4165 $LFS mkdir -i1 -c2 $DIR/$tdir/striped_dir
4169 rm -rf $DIR/$tdir/striped_dir
4171 $CHECKSTAT -t dir $DIR/$tdir/striped_dir &&
4172 error "striped dir still exists"
4175 run_test 111g "DNE: unlink striped dir, fail MDT1/MDT2"
4177 test_112_rename_prepare() {
4178 mkdir_on_mdt0 $DIR/$tdir
4179 mkdir -p $DIR/$tdir/src_dir
4180 $LFS mkdir -i 1 $DIR/$tdir/src_dir/src_child ||
4181 error "create remote source failed"
4183 touch $DIR/$tdir/src_dir/src_child/a
4185 $LFS mkdir -i 2 $DIR/$tdir/tgt_dir ||
4186 error "create remote target dir failed"
4188 $LFS mkdir -i 3 $DIR/$tdir/tgt_dir/tgt_child ||
4189 error "create remote target child failed"
4194 $CHECKSTAT -t dir $DIR/$tdir/src_dir/src_child &&
4195 error "src_child still exists after rename"
4197 $CHECKSTAT -t file $DIR/$tdir/tgt_dir/tgt_child/a ||
4198 error "missing file(a) after rename"
4202 [ $MDSCOUNT -lt 4 ] && skip "needs >= 4 MDTs" && return 0
4203 [[ "$MDS1_VERSION" -ge $(version_code 2.7.56) ]] ||
4204 skip "Need MDS version at least 2.7.56"
4206 ([ $FAILURE_MODE == "HARD" ] &&
4207 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
4208 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
4211 test_112_rename_prepare
4214 mrename $DIR/$tdir/src_dir/src_child $DIR/$tdir/tgt_dir/tgt_child ||
4215 error "rename dir cross MDT failed!"
4219 rm -rf $DIR/$tdir || error "rmdir failed"
4221 run_test 112a "DNE: cross MDT rename, fail MDT1"
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!"
4242 rm -rf $DIR/$tdir || error "rmdir failed"
4244 run_test 112b "DNE: cross MDT rename, fail MDT2"
4247 [ $MDSCOUNT -lt 4 ] && skip "needs >= 4 MDTs" && return 0
4248 [[ "$MDS1_VERSION" -ge $(version_code 2.7.56) ]] ||
4249 skip "Need MDS version at least 2.7.56"
4251 ([ $FAILURE_MODE == "HARD" ] &&
4252 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
4253 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
4256 test_112_rename_prepare
4259 mrename $DIR/$tdir/src_dir/src_child $DIR/$tdir/tgt_dir/tgt_child ||
4260 error "rename dir cross MDT failed!"
4265 rm -rf $DIR/$tdir || error "rmdir failed"
4267 run_test 112c "DNE: cross MDT rename, fail MDT3"
4270 [ $MDSCOUNT -lt 4 ] && skip "needs >= 4 MDTs" && return 0
4271 [[ "$MDS1_VERSION" -ge $(version_code 2.7.56) ]] ||
4272 skip "Need MDS version at least 2.7.56"
4274 ([ $FAILURE_MODE == "HARD" ] &&
4275 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
4276 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
4279 test_112_rename_prepare
4282 mrename $DIR/$tdir/src_dir/src_child $DIR/$tdir/tgt_dir/tgt_child ||
4283 error "rename dir cross MDT failed!"
4288 rm -rf $DIR/$tdir || error "rmdir failed"
4290 run_test 112d "DNE: cross MDT rename, fail MDT4"
4293 [ $MDSCOUNT -lt 4 ] && skip "needs >= 4 MDTs" && return 0
4294 [[ "$MDS1_VERSION" -ge $(version_code 2.7.56) ]] ||
4295 skip "Need MDS version at least 2.7.56"
4297 ([ $FAILURE_MODE == "HARD" ] &&
4298 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
4299 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
4302 test_112_rename_prepare
4306 mrename $DIR/$tdir/src_dir/src_child $DIR/$tdir/tgt_dir/tgt_child ||
4307 error "rename dir cross MDT failed!"
4312 rm -rf $DIR/$tdir || error "rmdir failed"
4314 run_test 112e "DNE: cross MDT rename, fail MDT1 and MDT2"
4317 [ $MDSCOUNT -lt 4 ] && skip "needs >= 4 MDTs" && return 0
4318 [[ "$MDS1_VERSION" -ge $(version_code 2.7.56) ]] ||
4319 skip "Need MDS version at least 2.7.56"
4321 ([ $FAILURE_MODE == "HARD" ] &&
4322 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
4323 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
4326 test_112_rename_prepare
4330 mrename $DIR/$tdir/src_dir/src_child $DIR/$tdir/tgt_dir/tgt_child ||
4331 error "rename dir cross MDT failed!"
4336 rm -rf $DIR/$tdir || error "rmdir failed"
4338 run_test 112f "DNE: cross MDT rename, fail MDT1 and MDT3"
4341 [ $MDSCOUNT -lt 4 ] && skip "needs >= 4 MDTs" && return 0
4342 [[ "$MDS1_VERSION" -ge $(version_code 2.7.56) ]] ||
4343 skip "Need MDS version at least 2.7.56"
4345 ([ $FAILURE_MODE == "HARD" ] &&
4346 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
4347 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
4350 test_112_rename_prepare
4354 mrename $DIR/$tdir/src_dir/src_child $DIR/$tdir/tgt_dir/tgt_child ||
4355 error "rename dir cross MDT failed!"
4360 rm -rf $DIR/$tdir || error "rmdir failed"
4362 run_test 112g "DNE: cross MDT rename, fail MDT1 and MDT4"
4365 [ $MDSCOUNT -lt 4 ] && skip "needs >= 4 MDTs" && return 0
4366 [[ "$MDS1_VERSION" -ge $(version_code 2.7.56) ]] ||
4367 skip "Need MDS version at least 2.7.56"
4369 ([ $FAILURE_MODE == "HARD" ] &&
4370 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
4371 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
4374 test_112_rename_prepare
4378 mrename $DIR/$tdir/src_dir/src_child $DIR/$tdir/tgt_dir/tgt_child ||
4379 error "rename dir cross MDT failed!"
4384 rm -rf $DIR/$tdir || error "rmdir failed"
4386 run_test 112h "DNE: cross MDT rename, fail MDT2 and MDT3"
4389 [ $MDSCOUNT -lt 4 ] && skip "needs >= 4 MDTs" && return 0
4390 [[ "$MDS1_VERSION" -ge $(version_code 2.7.56) ]] ||
4391 skip "Need MDS version at least 2.7.56"
4393 ([ $FAILURE_MODE == "HARD" ] &&
4394 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
4395 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
4398 test_112_rename_prepare
4402 mrename $DIR/$tdir/src_dir/src_child $DIR/$tdir/tgt_dir/tgt_child ||
4403 error "rename dir cross MDT failed!"
4408 rm -rf $DIR/$tdir || error "rmdir failed"
4410 run_test 112i "DNE: cross MDT rename, fail MDT2 and MDT4"
4413 [ $MDSCOUNT -lt 4 ] && skip "needs >= 4 MDTs" && return 0
4414 [[ "$MDS1_VERSION" -ge $(version_code 2.7.56) ]] ||
4415 skip "Need MDS version at least 2.7.56"
4417 ([ $FAILURE_MODE == "HARD" ] &&
4418 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
4419 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
4422 test_112_rename_prepare
4426 mrename $DIR/$tdir/src_dir/src_child $DIR/$tdir/tgt_dir/tgt_child ||
4427 error "rename dir cross MDT failed!"
4432 rm -rf $DIR/$tdir || error "rmdir failed"
4434 run_test 112j "DNE: cross MDT rename, fail MDT3 and MDT4"
4437 [ $MDSCOUNT -lt 4 ] && skip "needs >= 4 MDTs" && return 0
4438 [[ "$MDS1_VERSION" -ge $(version_code 2.7.56) ]] ||
4439 skip "Need MDS version at least 2.7.56"
4441 ([ $FAILURE_MODE == "HARD" ] &&
4442 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
4443 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
4446 test_112_rename_prepare
4451 mrename $DIR/$tdir/src_dir/src_child $DIR/$tdir/tgt_dir/tgt_child ||
4452 error "rename dir cross MDT failed!"
4457 rm -rf $DIR/$tdir || error "rmdir failed"
4459 run_test 112k "DNE: cross MDT rename, fail MDT1,MDT2,MDT3"
4462 [ $MDSCOUNT -lt 4 ] && skip "needs >= 4 MDTs" && return 0
4463 [[ "$MDS1_VERSION" -ge $(version_code 2.7.56) ]] ||
4464 skip "Need MDS version at least 2.7.56"
4466 ([ $FAILURE_MODE == "HARD" ] &&
4467 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
4468 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
4471 test_112_rename_prepare
4476 mrename $DIR/$tdir/src_dir/src_child $DIR/$tdir/tgt_dir/tgt_child ||
4477 error "rename dir cross MDT failed!"
4482 rm -rf $DIR/$tdir || error "rmdir failed"
4484 run_test 112l "DNE: cross MDT rename, fail MDT1,MDT2,MDT4"
4487 [ $MDSCOUNT -lt 4 ] && skip "needs >= 4 MDTs" && return 0
4488 [[ "$MDS1_VERSION" -ge $(version_code 2.7.56) ]] ||
4489 skip "Need MDS version at least 2.7.56"
4491 ([ $FAILURE_MODE == "HARD" ] &&
4492 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
4493 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
4496 test_112_rename_prepare
4501 mrename $DIR/$tdir/src_dir/src_child $DIR/$tdir/tgt_dir/tgt_child ||
4502 error "rename dir cross MDT failed!"
4507 rm -rf $DIR/$tdir || error "rmdir failed"
4509 run_test 112m "DNE: cross MDT rename, fail MDT1,MDT3,MDT4"
4512 [ $MDSCOUNT -lt 4 ] && skip "needs >= 4 MDTs" && return 0
4513 [[ "$MDS1_VERSION" -ge $(version_code 2.7.56) ]] ||
4514 skip "Need MDS version at least 2.7.56"
4516 ([ $FAILURE_MODE == "HARD" ] &&
4517 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
4518 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
4521 test_112_rename_prepare
4526 mrename $DIR/$tdir/src_dir/src_child $DIR/$tdir/tgt_dir/tgt_child ||
4527 error "rename dir cross MDT failed!"
4532 rm -rf $DIR/$tdir || error "rmdir failed"
4534 run_test 112n "DNE: cross MDT rename, fail MDT2,MDT3,MDT4"
4537 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
4538 [[ "$MDS1_VERSION" -ge $(version_code 2.7.56) ]] ||
4539 skip "Need MDS version at least 2.7.56"
4541 ([ $FAILURE_MODE == "HARD" ] &&
4542 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
4543 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
4551 for ((j=0;j<$((MDSCOUNT));j++)); do
4552 fail_index=$((fail_index+1))
4553 index=$((fail_index % MDSCOUNT))
4554 replay_barrier mds$((index + 1))
4555 for ((i=0;i<5;i++)); do
4556 test_mkdir -i$index -c$MDSCOUNT $DIR/$tdir/test_$i ||
4557 error "create striped dir $DIR/$tdir/test_$i"
4560 fail mds$((index + 1))
4561 for ((i=0;i<5;i++)); do
4562 checkstat -t dir $DIR/$tdir/test_$i ||
4563 error "$DIR/$tdir/test_$i does not exist!"
4565 rm -rf $DIR/$tdir/test_* ||
4569 run_test 115 "failover for create/unlink striped directory"
4572 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
4573 [ "$MDS1_VERSION" -lt $(version_code 2.7.55) ] &&
4574 skip "Do not support large update log before 2.7.55" &&
4576 ([ $FAILURE_MODE == "HARD" ] &&
4577 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
4578 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
4582 mkdir_on_mdt0 $DIR/$tdir
4585 # OBD_FAIL_SPLIT_UPDATE_REC 0x1702
4586 do_facet mds1 "lctl set_param fail_loc=0x80001702"
4587 $LFS setdirstripe -i0 -c$MDSCOUNT $DIR/$tdir/striped_dir
4590 $CHECKSTAT -t dir $DIR/$tdir/striped_dir ||
4591 error "stried_dir does not exists"
4593 run_test 116a "large update log master MDT recovery"
4596 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
4597 [ "$MDS1_VERSION" -lt $(version_code 2.7.55) ] &&
4598 skip "Do not support large update log before 2.7.55" &&
4601 ([ $FAILURE_MODE == "HARD" ] &&
4602 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
4603 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
4607 mkdir_on_mdt0 $DIR/$tdir
4610 # OBD_FAIL_SPLIT_UPDATE_REC 0x1702
4611 do_facet mds2 "lctl set_param fail_loc=0x80001702"
4612 $LFS setdirstripe -i0 -c$MDSCOUNT $DIR/$tdir/striped_dir
4615 $CHECKSTAT -t dir $DIR/$tdir/striped_dir ||
4616 error "stried_dir does not exists"
4618 run_test 116b "large update log slave MDT recovery"
4621 [ $MDSCOUNT -lt 4 ] && skip "needs >= 4 MDTs" && return 0
4622 ([ $FAILURE_MODE == "HARD" ] &&
4623 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
4624 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
4630 $LFS setdirstripe -i0 -c$MDSCOUNT $DIR/$tdir/remote_dir
4631 $LFS setdirstripe -i1 -c$MDSCOUNT $DIR/$tdir/remote_dir_1
4634 # Let's set rdonly on all MDTs, so client will send
4635 # replay requests on all MDTs and replay these requests
4636 # at the same time. This test will verify the recovery
4637 # will not be deadlock in this case, LU-7531.
4638 for ((index = 0; index < $((MDSCOUNT)); index++)); do
4639 replay_barrier mds$((index + 1))
4640 if [ -z $mds_indexs ]; then
4641 mds_indexs="${mds_indexs}mds$((index+1))"
4643 mds_indexs="${mds_indexs},mds$((index+1))"
4647 rm -rf $DIR/$tdir/remote_dir
4648 rm -rf $DIR/$tdir/remote_dir_1
4652 rm -rf $DIR/$tdir || error "rmdir failed"
4654 run_test 117 "DNE: cross MDT unlink, fail MDT1 and MDT2"
4657 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
4658 [ "$MDS1_VERSION" -lt $(version_code 2.7.64) ] &&
4659 skip "Do not support large update log before 2.7.64" &&
4664 $LFS setdirstripe -c2 $DIR/$tdir/striped_dir ||
4665 error "setdirstripe fails"
4666 $LFS setdirstripe -c2 $DIR/$tdir/striped_dir1 ||
4667 error "setdirstripe fails 1"
4668 rm -rf $DIR/$tdir/striped_dir* || error "rmdir fails"
4670 # OBD_FAIL_INVALIDATE_UPDATE 0x1705
4671 do_facet mds1 "lctl set_param fail_loc=0x1705"
4672 $LFS setdirstripe -c2 $DIR/$tdir/striped_dir
4673 $LFS setdirstripe -c2 $DIR/$tdir/striped_dir1
4674 do_facet mds1 "lctl set_param fail_loc=0x0"
4677 $LFS setdirstripe -c2 $DIR/$tdir/striped_dir
4678 $LFS setdirstripe -c2 $DIR/$tdir/striped_dir1
4683 run_test 118 "invalidate osp update will not cause update log corruption"
4686 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
4687 [ "$MDS1_VERSION" -lt $(version_code 2.7.64) ] &&
4688 skip "Do not support large update log before 2.7.64" &&
4691 local hard_timeout=$(do_facet mds1 \
4692 "lctl get_param -n mdt.$FSNAME-MDT0000.recovery_time_hard")
4694 local clients=${CLIENTS:-$HOSTNAME}
4695 local time_min=$(recovery_time_min)
4697 mkdir_on_mdt0 $DIR/$tdir
4698 mkdir $DIR/$tdir/tmp
4699 rmdir $DIR/$tdir/tmp
4702 mkdir $DIR/$tdir/dir_1
4703 for ((i = 0; i < 20; i++)); do
4704 $LFS setdirstripe -i0 -c2 $DIR/$tdir/stripe_dir-$i
4711 #define OBD_FAIL_TGT_REPLAY_DELAY 0x714
4712 do_facet mds1 $LCTL set_param fail_loc=0x80000714
4713 #sleep (timeout + 5), so mds will evict the client exports,
4714 #but DNE update recovery will keep going.
4715 do_facet mds1 $LCTL set_param fail_val=$((time_min + 5))
4717 mount_facet mds1 "-o recovery_time_hard=$time_min"
4719 wait_clients_import_state "$clients" mds1 FULL
4721 clients_up || clients_up || error "failover df: $?"
4723 #revert back the hard timeout
4724 do_facet mds1 $LCTL set_param \
4725 mdt.$FSNAME-MDT0000.recovery_time_hard=$hard_timeout
4727 for ((i = 0; i < 20; i++)); do
4728 stripe_count=$($LFS getdirstripe -c $DIR/$tdir/stripe_dir-$i)
4729 [ $stripe_count == 2 ] || {
4730 error "stripe_dir-$i creation replay fails"
4735 run_test 119 "timeout of normal replay does not cause DNE replay fails "
4738 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
4739 [ "$MDS1_VERSION" -lt $(version_code 2.7.64) ] &&
4740 skip "Do not support large update log before 2.7.64" &&
4743 mkdir_on_mdt0 $DIR/$tdir
4744 replay_barrier_nosync mds1
4745 for ((i = 0; i < 20; i++)); do
4746 mkdir $DIR/$tdir/dir-$i || {
4747 error "create dir-$i fails"
4750 $LFS setdirstripe -i0 -c2 $DIR/$tdir/stripe_dir-$i || {
4751 error "create stripe_dir-$i fails"
4756 stack_trap fail_abort_cleanup RETURN
4759 for ((i = 0; i < 20; i++)); do
4760 [ ! -e "$DIR/$tdir/dir-$i" ] || {
4761 error "dir-$i still exists"
4764 [ ! -e "$DIR/$tdir/stripe_dir-$i" ] || {
4765 error "stripe_dir-$i still exists"
4770 run_test 120 "DNE fail abort should stop both normal and DNE replay"
4773 [ "$MDS1_VERSION" -lt $(version_code 2.10.90) ] &&
4774 skip "Don't support it before 2.11" &&
4777 local at_max_saved=$(at_max_get mds)
4779 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
4780 cancel_lru_locks mdc
4782 multiop_bg_pause $DIR/$tfile s_s || error "multiop $DIR/$tfile failed"
4785 lctl set_param -n ldlm.cancel_unused_locks_before_replay "0"
4791 #define OBD_FAIL_TGT_RECOVERY_REQ_RACE 0x721
4792 do_facet $SINGLEMDS "lctl set_param fail_loc=0x721 fail_val=0"
4796 wait_clients_import_state "$clients" mds1 FULL
4797 clients_up || clients_up || error "failover df: $?"
4800 wait $mpid || error "multiop_bg_pause pid failed"
4802 do_facet $SINGLEMDS "lctl set_param fail_loc=0x0"
4803 lctl set_param -n ldlm.cancel_unused_locks_before_replay "1"
4804 at_max_set $at_max_saved mds
4807 run_test 121 "lock replay timed out and race"
4810 [ "$MDS1_VERSION" -lt $(version_code 2.10.90) ] &&
4811 skip "Do not support Data-on-MDT before 2.11"
4813 replay_barrier $SINGLEMDS
4814 $LFS setstripe -E 1M -L mdt -E EOF -c 2 $DIR/$tfile
4817 [ $($LFS getstripe -L $DIR/$tfile) == "mdt" ] ||
4818 error "Fail to replay DoM file creation"
4820 run_test 130a "DoM file create (setstripe) replay"
4823 [ "$MDS1_VERSION" -lt $(version_code 2.10.90) ] &&
4824 skip "Do not support Data-on-MDT before 2.11"
4826 mkdir_on_mdt0 $DIR/$tdir
4827 $LFS setstripe -E 1M -L mdt -E EOF -c 2 $DIR/$tdir
4828 replay_barrier $SINGLEMDS
4829 touch $DIR/$tdir/$tfile
4832 [ $($LFS getstripe -L $DIR/$tdir/$tfile) == "mdt" ] ||
4833 error "Fail to replay DoM file creation"
4835 run_test 130b "DoM file create (inherited) replay"
4838 [ "$MDS1_VERSION" -lt $(version_code 2.10.90) ] &&
4839 skip "Do not support Data-on-MDT before 2.11"
4841 $LFS setstripe -E 1M -L mdt -E EOF -c 2 $DIR/$tfile
4842 replay_barrier $SINGLEMDS
4843 echo "dom_data" | dd of=$DIR/$tfile bs=8 count=1
4844 # lock is not canceled and will be replayed
4847 [ $(cat $DIR/$tfile) == "dom_data" ] ||
4848 error "Wrong file content after failover"
4850 run_test 131a "DoM file write lock replay"
4853 [ "$MDS1_VERSION" -lt $(version_code 2.10.90) ] &&
4854 skip "Do not support Data-on-MDT before 2.11"
4856 $LFS setstripe -E 1M -L mdt -E EOF -c 2 $DIR/$tfile
4857 replay_barrier $SINGLEMDS
4858 echo "dom_data" | dd of=$DIR/$tfile bs=8 count=1
4859 cancel_lru_locks mdc
4863 [ $(cat $DIR/$tfile) == "dom_data" ] ||
4864 error "Wrong file content after failover"
4866 run_test 131b "DoM file write replay"
4869 [ "$MDS1_VERSION" -lt $(version_code 2.12.0) ] &&
4870 skip "Need MDS version 2.12.0 or later"
4872 $LFS setstripe -E 1M -c 1 -E EOF -c 2 $DIR/$tfile
4873 replay_barrier $SINGLEMDS
4874 # write over the first component size cause next component instantiation
4875 dd if=/dev/urandom of=$DIR/$tfile bs=1M count=1 seek=1 ||
4876 error "dd to $DIR/$tfile failed"
4877 lfs getstripe $DIR/$tfile
4879 cksum=$(md5sum $DIR/$tfile | awk '{print $1}')
4880 $LFS getstripe -I2 $DIR/$tfile | grep -q lmm_objects ||
4881 error "Component #1 was not instantiated"
4885 lfs getstripe $DIR/$tfile
4886 $LFS getstripe -I2 $DIR/$tfile | grep -q lmm_objects ||
4887 error "Component #1 instantiation was not replayed"
4888 cksum2=$(md5sum $DIR/$tfile | awk '{print $1}')
4889 if [ $cksum != $cksum2 ] ; then
4890 error_noexit "New cksum $cksum2 does not match original $cksum"
4893 run_test 132a "PFL new component instantiate replay"
4896 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
4897 ([ $FAILURE_MODE == "HARD" ] &&
4898 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
4899 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
4902 local remote_dir=$DIR/$tdir/remote_dir
4904 mkdir -p $DIR/$tdir || error "mkdir $DIR/$tdir failed"
4905 $LFS mkdir -i 1 $remote_dir
4908 do_facet mds2 $LCTL set_param seq.srv*MDT0001.space=clear
4910 zconf_mount $(hostname) $MOUNT
4911 client_up || return 1
4913 #define OBD_FAIL_MDS_ALL_REQUEST_NET 0x123
4915 do_facet mds1 $LCTL set_param fail_val=700 fail_loc=0x80000123
4916 cp /etc/hosts $remote_dir/file &
4922 wait $pid || error "cp failed"
4923 rm -rf $DIR/$tdir || error "rmdir failed"
4927 run_test 133 "check resend of ongoing requests for lwp during failover"
4930 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs" && return 0
4931 (( $MDS1_VERSION >= $(version_code 2.13.56) )) ||
4932 skip "need MDS version >= 2.13.56"
4935 pool_add_targets pool_134 1 1
4937 mkdir -p $DIR/$tdir/{A,B}
4938 $LFS setstripe -p pool_134 $DIR/$tdir/A
4939 $LFS setstripe -E EOF -p pool_134 $DIR/$tdir/B
4943 touch $DIR/$tdir/A/$tfile || error "touch non-pfl file failed"
4944 touch $DIR/$tdir/B/$tfile || error "touch pfl failed"
4948 [ -f $DIR/$tdir/A/$tfile ] || error "non-pfl file does not exist"
4949 [ -f $DIR/$tdir/B/$tfile ] || error "pfl file does not exist"
4951 run_test 134 "replay creation of a file created in a pool"
4955 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
4958 $LFS setstripe -S $((128 * 1024)) -i 0 $DIR/$tdir
4962 # Create 20 files so we have 20 ost locks
4963 for i in $(seq 20) ; do
4964 echo blah > $DIR/$tdir/file.${i}
4972 #define OBD_FAIL_TGT_REPLAY_RECONNECT 0x32d
4973 # Make sure lock replay server side never completes and errors out.
4974 do_facet ost1 "$LCTL set_param fail_val=20"
4975 do_facet ost1 "$LCTL set_param fail_loc=0x32d"
4979 # Now make sure we notice
4982 sleep 20 # should we do something proactive to make reconnects go?
4983 kill -0 $PID || error "Unexpected sync success"
4990 do_facet ost1 "$LCTL set_param fail_loc=0"
4992 echo blah > $DIR/$tdir/file.test2
4996 run_test 135 "Server failure in lock replay phase"
4999 (( $MDSCOUNT >= 3 )) || skip "needs > 2 MDTs"
5000 (( MDS1_VERSION >= $(version_code 2.15.53) )) ||
5001 skip "need MDS version >= 2.15.53 for LU-16536 fix"
5003 $LFS mkdir -i0 -c3 $DIR/$tdir || error "can't mkdir"
5004 $LFS getdirstripe $DIR/$tdir
5007 #define OBD_FAIL_OUT_DROP_DESTROY 0x170b
5008 local mdts=$(comma_list $(mdts_nodes))
5009 do_nodes $mdts $LCTL set_param fail_loc=0x170b
5015 start mds1 $(mdsdevname 1) $MDS_MOUNT_OPTS || error "MDT1 start failed"
5016 start mds2 $(mdsdevname 2) $MDS_MOUNT_OPTS || error "MDT2 start failed"
5017 start mds3 $(mdsdevname 3) $MDS_MOUNT_OPTS || error "MDT3 star"
5019 run_test 136 "MDS to disconnect all OSPs first, then cleanup ldlm"
5022 [[ -z $RCLIENTS ]] && skip "Need remote client"
5026 rcli=$(echo "$RCLIENTS" | cut -d ' ' -f 1)
5027 old=$(do_node "$rcli" "$LCTL get_param -n osc.*OST0000*.idle_timeout")
5029 if ((old != 0)); then
5030 do_node "$rcli" "$LCTL set_param osc.*OST0000*.idle_timeout=0"
5031 stack_trap "do_node $rcli $LCTL set_param osc.*OST0000*.idle_timeout=$old"
5034 # Ensure OST0 import is idle
5035 wait_update "$rcli" \
5036 "$LCTL get_param osc.*OST0000*.import | \
5037 awk 'BEGIN{ count=0 } /idle: 0/ { count+=1 } \
5038 END { print count }'" \
5041 (( $? != 0 )) && error "OST0000 not idle after 30s"
5043 # Send ping to ensure import is FULL
5044 do_node "$rcli" "lctl set_param osc.*OST0000*.ping=1" ||
5045 error "OBD ping failed"
5049 conns=( $(do_node "$rcli" "$LCTL get_param *.*.import" |
5050 awk '/connection_attempts:/{print $NF}' | xargs echo) )
5054 saved_debug=$(do_node "$rcli" \
5055 "cat /sys/module/libcfs/parameters/libcfs_debug" \
5057 [[ -z $saved_debug ]] && error "Failed to get existing debug"
5058 stack_trap "do_node $rcli $LCTL set_param debug=$saved_debug"
5059 do_node "$rcli" "$LCTL set_param debug=+info+rpctrace"
5061 # From lustre/obdclass/class_obd.c
5062 # unsigned int ping_interval = (OBD_TIMEOUT_DEFAULT > 4) ?
5063 # (OBD_TIMEOUT_DEFAULT / 4) : 1;
5064 # Delay a ping for 3 intervals
5065 local timeout delay ts1 ts2 elapsed
5067 timeout=$(do_node "$rcli" "$LCTL get_param -n timeout")
5068 (( timeout > 4 )) && delay=$((3 * timeout / 4)) || delay=3
5070 do_node "$rcli" "$LCTL clear"
5071 log "delay ping ${delay}s"
5075 #define OBD_FAIL_PTLRPC_DELAY_SEND_FAIL 0x535
5076 do_node "$rcli" "$LCTL set_param fail_loc=0x80000535 fail_val=${delay}"
5077 # Send ping that will be delayed for ${delay} seconds
5078 # This races with the pinger, but it is okay if a ping sent by pinger
5079 # thread is delayed instead
5080 do_node "$rcli" "lctl set_param osc.*OST0000*.ping=1"
5082 # Make sure we hit the fail_loc
5083 wait_update --quiet "$rcli" \
5084 "dmesg | tail -n 10 | \
5085 grep -c 'fail_timeout id 535 sleeping for'" \
5088 (( $? != 0 )) && error "Did not hit fail_loc"
5092 # If we raced with pinger thread then we need to wait ${delay} seconds
5093 # for the ping to fail
5094 elapsed=$((ts2 - ts1))
5096 if (( elapsed < delay )); then
5097 sleep $(((delay - elapsed) + 1))
5100 do_node "$rcli" "$LCTL dk" > "$TMP/lustre-log-${TESTNAME}.log"
5104 nsent=$(grep -c "ptl_send_rpc.*o400->.*OST0000" \
5105 "$TMP/lustre-log-${TESTNAME}.log")
5107 if (( nsent <= 1)); then
5108 cat "$TMP/lustre-log-${TESTNAME}.log"
5109 rm -f "$TMP/lustre-log-${TESTNAME}.log"
5110 error "Did not send more than 1 obd ping"
5115 expired=$(grep "Request sent has timed out .* o400->" \
5116 "$TMP/lustre-log-${TESTNAME}.log")
5118 if [[ -z $expired ]]; then
5119 cat "$TMP/lustre-log-${TESTNAME}.log"
5120 rm -f "$TMP/lustre-log-${TESTNAME}.log"
5121 error "RPC did not time out"
5124 rm -f "$TMP/lustre-log-${TESTNAME}.log"
5129 conns2=( $(do_node "$rcli" "$LCTL get_param *.*.import" |
5130 awk '/connection_attempts:/{print $NF}' | xargs echo) )
5132 echo "conns: ${conns[*]}"
5134 echo "conns2: ${conns2[*]}"
5136 (( ${#conns[@]} != ${#conns2[@]} )) &&
5137 error "Expected ${#conns[@]} imports found ${#conns2[@]}"
5141 for ((i = 0; i < ${#conns[@]}; i++)); do
5142 if (( conns[i] != conns2[i] )); then
5143 error "New connection attempt ${conns[i]} -> ${conns2[i]}"
5149 run_test 200 "Dropping one OBD_PING should not cause disconnect"
5152 check_and_cleanup_lustre