7 # This test needs to be run on the client
10 export MULTIOP=${MULTIOP:-multiop}
11 LUSTRE=${LUSTRE:-$(cd $(dirname $0)/..; echo $PWD)}
14 . $LUSTRE/tests/test-framework.sh
16 . ${CONFIG:=$LUSTRE/tests/cfg/$NAME.sh}
18 CHECK_GRANT=${CHECK_GRANT:-"yes"}
19 GRANT_CHECK_LIST=${GRANT_CHECK_LIST:-""}
21 require_dsh_mds || exit 0
24 # bug number for skipped tests:
25 ALWAYS_EXCEPT="$REPLAY_SINGLE_EXCEPT "
26 # UPDATE THE COMMENT ABOVE WITH BUG NUMBERS WHEN CHANGING ALWAYS_EXCEPT!
29 [ "$SLOW" = "no" ] && EXCEPT_SLOW="44b"
31 [ $(facet_fstype $SINGLEMDS) = "zfs" ] &&
32 # bug number for skipped test:
33 ALWAYS_EXCEPT="$ALWAYS_EXCEPT "
37 check_and_setup_lustre
42 rm -rf $DIR/[df][0-9]* $DIR/f.$TESTSUITE.*
44 # LU-482 Avert LVM and VM inability to flush caches in pre .33 kernels
45 if [ $LINUX_VERSION_CODE -lt $(version_code 2.6.33) ]; then
47 do_facet $SINGLEMDS sync
50 test_0a() { # was test_0
51 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
52 replay_barrier $SINGLEMDS
56 run_test 0a "empty replay"
59 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
61 # this test attempts to trigger a race in the precreation code,
62 # and must run before any other objects are created on the filesystem
64 createmany -o $DIR/$tfile 20 || error "createmany -o $DIR/$tfile failed"
65 unlinkmany $DIR/$tfile 20 || error "unlinkmany $DIR/$tfile failed"
67 run_test 0b "ensure object created after recover exists. (3284)"
70 replay_barrier $SINGLEMDS
73 facet_failover $SINGLEMDS
74 zconf_mount $(hostname) $MOUNT || error "mount fails"
75 client_up || error "post-failover df failed"
76 # file shouldn't exist if replay-barrier works as expected
77 rm $DIR/$tfile && error "File exists and it shouldn't"
80 run_test 0c "check replay-barrier"
83 replay_barrier $SINGLEMDS
85 facet_failover $SINGLEMDS
86 zconf_mount $(hostname) $MOUNT || error "mount fails"
87 client_up || error "post-failover df failed"
89 run_test 0d "expired recovery with no clients"
92 replay_barrier $SINGLEMDS
95 $CHECKSTAT -t file $DIR/$tfile ||
96 error "$CHECKSTAT $DIR/$tfile attribute check failed"
99 run_test 1 "simple create"
102 replay_barrier $SINGLEMDS
105 $CHECKSTAT -t file $DIR/$tfile ||
106 error "$CHECKSTAT $DIR/$tfile attribute check failed"
112 mcreate $DIR/$tfile || error "mcreate $DIR/$tfile failed"
113 replay_barrier $SINGLEMDS
116 $CHECKSTAT -t file $DIR/$tfile ||
117 error "$CHECKSTAT $DIR/$tfile attribute check failed"
123 local file=$DIR/$tfile
124 replay_barrier $SINGLEMDS
126 openfile -f O_DIRECTORY $file
128 $CHECKSTAT -t file $file ||
129 error "$CHECKSTAT $file attribute check failed"
132 run_test 3a "replay failed open(O_DIRECTORY)"
135 replay_barrier $SINGLEMDS
136 #define OBD_FAIL_MDS_OPEN_PACK | OBD_FAIL_ONCE
137 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000114"
139 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
141 $CHECKSTAT -t file $DIR/$tfile &&
142 error "$CHECKSTAT $DIR/$tfile attribute check should fail"
145 run_test 3b "replay failed open -ENOMEM"
148 replay_barrier $SINGLEMDS
149 #define OBD_FAIL_MDS_ALLOC_OBDO | OBD_FAIL_ONCE
150 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000128"
152 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
155 $CHECKSTAT -t file $DIR/$tfile &&
156 error "$CHECKSTAT $DIR/$tfile attribute check should fail"
159 run_test 3c "replay failed open -ENOMEM"
161 test_4a() { # was test_4
162 replay_barrier $SINGLEMDS
163 for i in $(seq 10); do
164 echo "tag-$i" > $DIR/$tfile-$i
167 for i in $(seq 10); do
168 grep -q "tag-$i" $DIR/$tfile-$i || error "$tfile-$i"
171 run_test 4a "|x| 10 open(O_CREAT)s"
174 for i in $(seq 10); do
175 echo "tag-$i" > $DIR/$tfile-$i
177 replay_barrier $SINGLEMDS
180 $CHECKSTAT -t file $DIR/$tfile-* &&
181 error "$CHECKSTAT $DIR/$tfile-* attribute check should fail" ||
184 run_test 4b "|x| rm 10 files"
186 # The idea is to get past the first block of precreated files on both
187 # osts, and then replay.
189 replay_barrier $SINGLEMDS
190 for i in $(seq 220); do
191 echo "tag-$i" > $DIR/$tfile-$i
194 for i in $(seq 220); do
195 grep -q "tag-$i" $DIR/$tfile-$i || error "$tfile-$i"
199 # waiting for commitment of removal
201 run_test 5 "|x| 220 open(O_CREAT)"
203 test_6a() { # was test_6
204 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
205 replay_barrier $SINGLEMDS
206 mcreate $DIR/$tdir/$tfile
208 $CHECKSTAT -t dir $DIR/$tdir ||
209 error "$CHECKSTAT $DIR/$tdir attribute check failed"
210 $CHECKSTAT -t file $DIR/$tdir/$tfile ||
211 error "$CHECKSTAT $DIR/$tdir/$tfile attribute check failed"
213 # waiting for log process thread
215 run_test 6a "mkdir + contained create"
218 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
219 replay_barrier $SINGLEMDS
222 $CHECKSTAT -t dir $DIR/$tdir &&
223 error "$CHECKSTAT $DIR/$tdir attribute check should fail" ||
226 run_test 6b "|X| rmdir"
229 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
230 replay_barrier $SINGLEMDS
231 mcreate $DIR/$tdir/$tfile
233 $CHECKSTAT -t dir $DIR/$tdir ||
234 error "$CHECKSTAT $DIR/$tdir attribute check failed"
235 $CHECKSTAT -t file $DIR/$tdir/$tfile ||
236 error "$CHECKSTAT $DIR/$tdir/$tfile attribute check failed"
239 run_test 7 "mkdir |X| contained create"
242 replay_barrier $SINGLEMDS
243 multiop_bg_pause $DIR/$tfile mo_c ||
244 error "multiop mknod $DIR/$tfile failed"
248 $CHECKSTAT -t file $DIR/$tfile ||
249 error "$CHECKSTAT $DIR/$tfile attribute check failed"
250 kill -USR1 $MULTIPID || error "multiop mknod $MULTIPID not running"
251 wait $MULTIPID || error "multiop mknod $MULTIPID failed"
254 run_test 8 "creat open |X| close"
257 replay_barrier $SINGLEMDS
259 local old_inum=$(ls -i $DIR/$tfile | awk '{print $1}')
261 local new_inum=$(ls -i $DIR/$tfile | awk '{print $1}')
263 echo " old_inum == $old_inum, new_inum == $new_inum"
264 if [ $old_inum -eq $new_inum ] ;
266 echo "old_inum and new_inum match"
268 echo " old_inum and new_inum do not match"
269 error "old index($old_inum) does not match new index($new_inum)"
273 run_test 9 "|X| create (same inum/gen)"
276 mcreate $DIR/$tfile || error "mcreate $DIR/$tfile failed"
277 replay_barrier $SINGLEMDS
278 mv $DIR/$tfile $DIR/$tfile-2
281 $CHECKSTAT $DIR/$tfile &&
282 error "$CHECKSTAT $DIR/$tfile attribute check should fail"
283 $CHECKSTAT $DIR/$tfile-2 ||
284 error "$CHECKSTAT $DIR/$tfile-2 attribute check failed"
288 run_test 10 "create |X| rename unlink"
291 mcreate $DIR/$tfile || error "mcreate $DIR/$tfile failed"
292 echo "old" > $DIR/$tfile
293 mv $DIR/$tfile $DIR/$tfile-2
294 replay_barrier $SINGLEMDS
295 echo "new" > $DIR/$tfile
297 grep old $DIR/$tfile-2
299 grep new $DIR/$tfile || error "grep $DIR/$tfile failed"
300 grep old $DIR/$tfile-2 || error "grep $DIR/$tfile-2 failed"
302 run_test 11 "create open write rename |X| create-old-name read"
305 mcreate $DIR/$tfile || error "mcreate $DIR/$tfile failed"
306 multiop_bg_pause $DIR/$tfile o_tSc ||
307 error "multiop_bg_pause $DIR/$tfile failed"
310 replay_barrier $SINGLEMDS
311 kill -USR1 $pid || error "multiop $pid not running"
312 wait $pid || error "multiop $pid failed"
315 [ -e $DIR/$tfile ] && error "file $DIR/$tfile should not exist"
318 run_test 12 "open, unlink |X| close"
320 # 1777 - replay open after committed chmod that would make
321 # a regular open a failure
323 mcreate $DIR/$tfile || error "mcreate $DIR/$tfile failed"
324 multiop_bg_pause $DIR/$tfile O_wc ||
325 error "multiop_bg_pause $DIR/$tfile failed"
328 $CHECKSTAT -p 0 $DIR/$tfile ||
329 error "$CHECKSTAT $DIR/$tfile attribute check failed"
330 replay_barrier $SINGLEMDS
332 kill -USR1 $pid || error "multiop $pid not running"
333 wait $pid || error "multiop $pid failed"
335 $CHECKSTAT -s 1 -p 0 $DIR/$tfile ||
336 error "second $CHECKSTAT $DIR/$tfile attribute check failed"
337 rm $DIR/$tfile || error "rm $DIR/$tfile failed"
340 run_test 13 "open chmod 0 |x| write close"
343 multiop_bg_pause $DIR/$tfile O_tSc ||
344 error "multiop_bg_pause $DIR/$tfile failed"
347 replay_barrier $SINGLEMDS
348 kill -USR1 $pid || error "multiop $pid not running"
349 wait $pid || error "multiop $pid failed"
352 [ -e $DIR/$tfile ] && error "file $DIR/$tfile should not exist"
355 run_test 14 "open(O_CREAT), unlink |X| close"
358 multiop_bg_pause $DIR/$tfile O_tSc ||
359 error "multiop_bg_pause $DIR/$tfile failed"
362 replay_barrier $SINGLEMDS
363 touch $DIR/$tfile-1 || error "touch $DIR/$tfile-1 failed"
364 kill -USR1 $pid || error "multiop $pid not running"
365 wait $pid || error "multiop $pid failed"
368 [ -e $DIR/$tfile ] && error "file $DIR/$tfile should not exist"
369 touch $DIR/$tfile-2 || error "touch $DIR/$tfile-2 failed"
372 run_test 15 "open(O_CREAT), unlink |X| touch new, close"
375 replay_barrier $SINGLEMDS
378 mcreate $DIR/$tfile-2
380 [ -e $DIR/$tfile ] && error "file $DIR/$tfile should not exist"
381 [ -e $DIR/$tfile-2 ] || error "file $DIR/$tfile-2 does not exist"
382 munlink $DIR/$tfile-2 || error "munlink $DIR/$tfile-2 failed"
384 run_test 16 "|X| open(O_CREAT), unlink, touch new, unlink new"
387 replay_barrier $SINGLEMDS
388 multiop_bg_pause $DIR/$tfile O_c ||
389 error "multiop_bg_pause $DIR/$tfile failed"
392 kill -USR1 $pid || error "multiop $pid not running"
393 wait $pid || error "multiop $pid failed"
394 $CHECKSTAT -t file $DIR/$tfile ||
395 error "$CHECKSTAT $DIR/$tfile attribute check failed"
398 run_test 17 "|X| open(O_CREAT), |replay| close"
401 replay_barrier $SINGLEMDS
402 multiop_bg_pause $DIR/$tfile O_tSc ||
403 error "multiop_bg_pause $DIR/$tfile failed"
406 touch $DIR/$tfile-2 || error "touch $DIR/$tfile-2 failed"
407 echo "pid: $pid will close"
408 kill -USR1 $pid || error "multiop $pid not running"
409 wait $pid || error "multiop $pid failed"
412 [ -e $DIR/$tfile ] && error "file $DIR/$tfile should not exist"
413 [ -e $DIR/$tfile-2 ] || error "file $DIR/$tfile-2 does not exist"
414 # this touch frequently fails
415 touch $DIR/$tfile-3 || error "touch $DIR/$tfile-3 failed"
416 munlink $DIR/$tfile-2 || error "munlink $DIR/$tfile-2 failed"
417 munlink $DIR/$tfile-3 || error "munlink $DIR/$tfile-3 failed"
420 run_test 18 "open(O_CREAT), unlink, touch new, close, touch, unlink"
422 # bug 1855 (a simpler form of test_11 above)
424 replay_barrier $SINGLEMDS
426 echo "old" > $DIR/$tfile
427 mv $DIR/$tfile $DIR/$tfile-2
428 grep old $DIR/$tfile-2
430 grep old $DIR/$tfile-2 || error "grep $DIR/$tfile-2 failed"
432 run_test 19 "mcreate, open, write, rename "
434 test_20a() { # was test_20
435 replay_barrier $SINGLEMDS
436 multiop_bg_pause $DIR/$tfile O_tSc ||
437 error "multiop_bg_pause $DIR/$tfile failed"
442 kill -USR1 $pid || error "multiop $pid not running"
443 wait $pid || error "multiop $pid failed"
444 [ -e $DIR/$tfile ] && error "file $DIR/$tfile should not exist"
447 run_test 20a "|X| open(O_CREAT), unlink, replay, close (test mds_cleanup_orphans)"
449 test_20b() { # bug 10480
450 local wait_timeout=$((TIMEOUT * 4))
454 BEFOREUSED=$(df -P $DIR | tail -1 | awk '{ print $3 }')
455 dd if=/dev/zero of=$DIR/$tfile bs=4k count=10000 &
456 while [ ! -e $DIR/$tfile ] ; do
457 usleep 60 # give dd a chance to start
460 $GETSTRIPE $DIR/$tfile || error "$GETSTRIPE $DIR/$tfile failed"
462 rm -f $DIR/$tfile || error "rm -f $DIR/$tfile failed"
464 client_up || client_up || true # reconnect
466 do_facet $SINGLEMDS "lctl set_param -n osd*.*MDT*.force_sync 1"
468 fail $SINGLEMDS # start orphan recovery
469 wait_recovery_complete $SINGLEMDS || error "MDS recovery not done"
470 wait_delete_completed_mds $wait_timeout ||
471 error "delete did not complete"
473 AFTERUSED=$(df -P $DIR | tail -1 | awk '{ print $3 }')
474 log "before $BEFOREUSED, after $AFTERUSED"
475 (( $AFTERUSED > $BEFOREUSED + $(fs_log_size) )) &&
476 error "after $AFTERUSED > before $BEFOREUSED"
479 run_test 20b "write, unlink, eviction, replay, (test mds_cleanup_orphans)"
481 test_20c() { # bug 10480
482 multiop_bg_pause $DIR/$tfile Ow_c ||
483 error "multiop_bg_pause $DIR/$tfile failed"
489 client_up || client_up || true # reconnect
491 kill -USR1 $pid || error "multiop $pid not running"
492 wait $pid || error "multiop $pid failed"
493 [ -s $DIR/$tfile ] || error "File was truncated"
497 run_test 20c "check that client eviction does not affect file content"
500 replay_barrier $SINGLEMDS
501 multiop_bg_pause $DIR/$tfile O_tSc ||
502 error "multiop_bg_pause $DIR/$tfile failed"
505 touch $DIR/$tfile-1 || error "touch $DIR/$tfile-1 failed"
508 kill -USR1 $pid || error "multiop $pid not running"
509 wait $pid || error "multiop $pid failed"
510 [ -e $DIR/$tfile ] && error "file $DIR/$tfile should not exist"
511 touch $DIR/$tfile-2 || error "touch $DIR/$tfile-2 failed"
514 run_test 21 "|X| open(O_CREAT), unlink touch new, replay, close (test mds_cleanup_orphans)"
517 multiop_bg_pause $DIR/$tfile O_tSc ||
518 error "multiop_bg_pause $DIR/$tfile failed"
521 replay_barrier $SINGLEMDS
525 kill -USR1 $pid || error "multiop $pid not running"
526 wait $pid || error "multiop $pid failed"
527 [ -e $DIR/$tfile ] && error "file $DIR/$tfile should not exist"
530 run_test 22 "open(O_CREAT), |X| unlink, replay, close (test mds_cleanup_orphans)"
533 multiop_bg_pause $DIR/$tfile O_tSc ||
534 error "multiop_bg_pause $DIR/$tfile failed"
537 replay_barrier $SINGLEMDS
539 touch $DIR/$tfile-1 || error "touch $DIR/$tfile-1 failed"
542 kill -USR1 $pid || error "multiop $pid not running"
543 wait $pid || error "multiop $pid failed"
544 [ -e $DIR/$tfile ] && error "file $DIR/$tfile should not exist"
545 touch $DIR/$tfile-2 || error "touch $DIR/$tfile-2 failed"
548 run_test 23 "open(O_CREAT), |X| unlink touch new, replay, close (test mds_cleanup_orphans)"
551 multiop_bg_pause $DIR/$tfile O_tSc ||
552 error "multiop_bg_pause $DIR/$tfile failed"
555 replay_barrier $SINGLEMDS
558 kill -USR1 $pid || error "multiop $pid not running"
559 wait $pid || error "multiop $pid failed"
560 [ -e $DIR/$tfile ] && error "file $DIR/$tfile should not exist"
563 run_test 24 "open(O_CREAT), replay, unlink, close (test mds_cleanup_orphans)"
566 multiop_bg_pause $DIR/$tfile O_tSc ||
567 error "multiop_bg_pause $DIR/$tfile failed"
571 replay_barrier $SINGLEMDS
573 kill -USR1 $pid || error "multiop $pid not running"
574 wait $pid || error "multiop $pid failed"
575 [ -e $DIR/$tfile ] && error "file $DIR/$tfile should not exist"
578 run_test 25 "open(O_CREAT), unlink, replay, close (test mds_cleanup_orphans)"
581 replay_barrier $SINGLEMDS
582 multiop_bg_pause $DIR/$tfile-1 O_tSc ||
583 error "multiop_bg_pause $DIR/$tfile-1 failed"
585 multiop_bg_pause $DIR/$tfile-2 O_tSc ||
586 error "multiop_bg_pause $DIR/$tfile-2 failed"
590 kill -USR1 $pid2 || error "second multiop $pid2 not running"
591 wait $pid2 || error "second multiop $pid2 failed"
594 kill -USR1 $pid1 || error "multiop $pid1 not running"
595 wait $pid1 || error "multiop $pid1 failed"
596 [ -e $DIR/$tfile-1 ] && error "file $DIR/$tfile-1 should not exist"
597 [ -e $DIR/$tfile-2 ] && error "file $DIR/$tfile-2 should not exist"
600 run_test 26 "|X| open(O_CREAT), unlink two, close one, replay, close one (test mds_cleanup_orphans)"
603 replay_barrier $SINGLEMDS
604 multiop_bg_pause $DIR/$tfile-1 O_tSc ||
605 error "multiop_bg_pause $DIR/$tfile-1 failed"
607 multiop_bg_pause $DIR/$tfile-2 O_tSc ||
608 error "multiop_bg_pause $DIR/$tfile-2 failed"
614 kill -USR1 $pid1 || error "multiop $pid1 not running"
615 wait $pid1 || error "multiop $pid1 failed"
616 kill -USR1 $pid2 || error "second multiop $pid2 not running"
617 wait $pid2 || error "second multiop $pid2 failed"
618 [ -e $DIR/$tfile-1 ] && error "file $DIR/$tfile-1 should not exist"
619 [ -e $DIR/$tfile-2 ] && error "file $DIR/$tfile-2 should not exist"
622 run_test 27 "|X| open(O_CREAT), unlink two, replay, close two (test mds_cleanup_orphans)"
625 multiop_bg_pause $DIR/$tfile-1 O_tSc ||
626 error "multiop_bg_pause $DIR/$tfile-1 failed"
628 multiop_bg_pause $DIR/$tfile-2 O_tSc ||
629 error "multiop_bg_pause $DIR/$tfile-2 failed"
631 replay_barrier $SINGLEMDS
634 kill -USR1 $pid2 || error "second multiop $pid2 not running"
635 wait $pid2 || error "second multiop $pid2 failed"
638 kill -USR1 $pid1 || error "multiop $pid1 not running"
639 wait $pid1 || error "multiop $pid1 failed"
640 [ -e $DIR/$tfile-1 ] && error "file $DIR/$tfile-1 should not exist"
641 [ -e $DIR/$tfile-2 ] && error "file $DIR/$tfile-2 should not exist"
644 run_test 28 "open(O_CREAT), |X| unlink two, close one, replay, close one (test mds_cleanup_orphans)"
647 multiop_bg_pause $DIR/$tfile-1 O_tSc ||
648 error "multiop_bg_pause $DIR/$tfile-1 failed"
650 multiop_bg_pause $DIR/$tfile-2 O_tSc ||
651 error "multiop_bg_pause $DIR/$tfile-2 failed"
653 replay_barrier $SINGLEMDS
658 kill -USR1 $pid1 || error "multiop $pid1 not running"
659 wait $pid1 || error "multiop $pid1 failed"
660 kill -USR1 $pid2 || error "second multiop $pid2 not running"
661 wait $pid2 || error "second multiop $pid2 failed"
662 [ -e $DIR/$tfile-1 ] && error "file $DIR/$tfile-1 should not exist"
663 [ -e $DIR/$tfile-2 ] && error "file $DIR/$tfile-2 should not exist"
666 run_test 29 "open(O_CREAT), |X| unlink two, replay, close two (test mds_cleanup_orphans)"
669 multiop_bg_pause $DIR/$tfile-1 O_tSc ||
670 error "multiop_bg_pause $DIR/$tfile-1 failed"
672 multiop_bg_pause $DIR/$tfile-2 O_tSc ||
673 error "multiop_bg_pause $DIR/$tfile-2 failed"
678 replay_barrier $SINGLEMDS
680 kill -USR1 $pid1 || error "multiop $pid1 not running"
681 wait $pid1 || error "multiop $pid1 failed"
682 kill -USR1 $pid2 || error "second multiop $pid2 not running"
683 wait $pid2 || error "second multiop $pid2 failed"
684 [ -e $DIR/$tfile-1 ] && error "file $DIR/$tfile-1 should not exist"
685 [ -e $DIR/$tfile-2 ] && error "file $DIR/$tfile-2 should not exist"
688 run_test 30 "open(O_CREAT) two, unlink two, replay, close two (test mds_cleanup_orphans)"
691 multiop_bg_pause $DIR/$tfile-1 O_tSc ||
692 error "multiop_bg_pause $DIR/$tfile-1 failed"
694 multiop_bg_pause $DIR/$tfile-2 O_tSc ||
695 error "multiop_bg_pause $DIR/$tfile-2 failed"
699 replay_barrier $SINGLEMDS
702 kill -USR1 $pid1 || error "multiop $pid1 not running"
703 wait $pid1 || error "multiop $pid1 failed"
704 kill -USR1 $pid2 || error "second multiop $pid2 not running"
705 wait $pid2 || error "second multiop $pid2 failed"
706 [ -e $DIR/$tfile-1 ] && error "file $DIR/$tfile-1 should not exist"
707 [ -e $DIR/$tfile-2 ] && error "file $DIR/$tfile-2 should not exist"
710 run_test 31 "open(O_CREAT) two, unlink one, |X| unlink one, close two (test mds_cleanup_orphans)"
712 # tests for bug 2104; completion without crashing is success. The close is
713 # stale, but we always return 0 for close, so the app never sees it.
715 multiop_bg_pause $DIR/$tfile O_c ||
716 error "multiop_bg_pause $DIR/$tfile failed"
718 multiop_bg_pause $DIR/$tfile O_c ||
719 error "second multiop_bg_pause $DIR/$tfile failed"
722 client_up || client_up || error "client_up failed"
723 kill -USR1 $pid1 || error "multiop $pid1 not running"
724 kill -USR1 $pid2 || error "second multiop $pid2 not running"
725 wait $pid1 || error "multiop $pid1 failed"
726 wait $pid2 || error "second multiop $pid2 failed"
729 run_test 32 "close() notices client eviction; close() after client eviction"
732 createmany -o $DIR/$tfile-%d 10 ||
733 error "createmany create $DIR/$tfile failed"
734 replay_barrier_nosync $SINGLEMDS
735 fail_abort $SINGLEMDS
736 # recreate shouldn't fail
737 createmany -o $DIR/$tfile--%d 10 ||
738 error "createmany recreate $DIR/$tfile failed"
742 run_test 33a "fid seq shouldn't be reused after abort recovery"
745 #define OBD_FAIL_SEQ_ALLOC 0x1311
746 do_facet $SINGLEMDS "lctl set_param fail_loc=0x1311"
748 createmany -o $DIR/$tfile-%d 10
749 replay_barrier_nosync $SINGLEMDS
750 fail_abort $SINGLEMDS
751 # recreate shouldn't fail
752 createmany -o $DIR/$tfile--%d 10 ||
753 error "createmany recreate $DIR/$tfile failed"
757 run_test 33b "test fid seq allocation"
760 multiop_bg_pause $DIR/$tfile O_c ||
761 error "multiop_bg_pause $DIR/$tfile failed"
765 replay_barrier $SINGLEMDS
766 fail_abort $SINGLEMDS
767 kill -USR1 $pid || error "multiop $pid not running"
768 wait $pid || error "multiop $pid failed"
769 [ -e $DIR/$tfile ] && error "file $DIR/$tfile should not exist"
773 run_test 34 "abort recovery before client does replay (test mds_cleanup_orphans)"
775 # bug 2278 - generate one orphan on OST, then destroy it during recovery from llog
777 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
779 #define OBD_FAIL_MDS_REINT_NET_REP 0x119
780 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000119"
785 # give a chance to remove from MDS
786 fail_abort $SINGLEMDS
787 $CHECKSTAT -t file $DIR/$tfile &&
788 error "$CHECKSTAT $DIR/$tfile attribute check should fail" ||
791 run_test 35 "test recovery from llog for unlink op"
793 # b=2432 resent cancel after replay uses wrong cookie,
794 # so don't resend cancels
796 replay_barrier $SINGLEMDS
798 checkstat $DIR/$tfile
799 facet_failover $SINGLEMDS
801 if dmesg | grep "unknown lock cookie"; then
802 error "cancel after replay failed"
805 run_test 36 "don't resend cancel"
808 # directory orphans can't be unlinked from PENDING directory
810 rmdir $DIR/$tfile 2>/dev/null
811 multiop_bg_pause $DIR/$tfile dD_c ||
812 error "multiop_bg_pause $DIR/$tfile failed"
816 replay_barrier $SINGLEMDS
817 # clear the dmesg buffer so we only see errors from this recovery
818 do_facet $SINGLEMDS dmesg -c >/dev/null
819 fail_abort $SINGLEMDS
820 kill -USR1 $pid || error "multiop $pid not running"
821 do_facet $SINGLEMDS dmesg | grep "error .* unlinking .* from PENDING" &&
822 error "error unlinking files"
823 wait $pid || error "multiop $pid failed"
827 run_test 37 "abort recovery before client does replay (test mds_cleanup_orphans for directories)"
830 createmany -o $DIR/$tfile-%d 800 ||
831 error "createmany -o $DIR/$tfile failed"
832 unlinkmany $DIR/$tfile-%d 0 400 || error "unlinkmany $DIR/$tfile failed"
833 replay_barrier $SINGLEMDS
835 unlinkmany $DIR/$tfile-%d 400 400 ||
836 error "unlinkmany $DIR/$tfile 400 failed"
838 $CHECKSTAT -t file $DIR/$tfile-* &&
839 error "$CHECKSTAT $DIR/$tfile-* attribute check should fail" ||
842 run_test 38 "test recovery from unlink llog (test llog_gen_rec) "
844 test_39() { # bug 4176
845 createmany -o $DIR/$tfile-%d 800 ||
846 error "createmany -o $DIR/$tfile failed"
847 replay_barrier $SINGLEMDS
848 unlinkmany $DIR/$tfile-%d 0 400
850 unlinkmany $DIR/$tfile-%d 400 400 ||
851 error "unlinkmany $DIR/$tfile 400 failed"
853 $CHECKSTAT -t file $DIR/$tfile-* &&
854 error "$CHECKSTAT $DIR/$tfile-* attribute check should fail" ||
857 run_test 39 "test recovery from unlink llog (test llog_gen_rec) "
860 lctl get_param -n osc.*.stats | awk -vwrites=0 '/ost_write/ { writes += $2 } END { print writes; }'
865 # always need connection to MDS to verify layout during IO. LU-2628.
866 lctl get_param mdc.*.connect_flags | grep -q layout_lock &&
867 skip "layout_lock needs MDS connection for IO" && return 0
869 $LCTL mark multiop $MOUNT/$tfile OS_c
870 multiop $MOUNT/$tfile OS_c &
872 writeme -s $MOUNT/${tfile}-2 &
875 facet_failover $SINGLEMDS
876 #define OBD_FAIL_MDS_CONNECT_NET 0x117
877 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000117"
879 stat1=$(count_ost_writes)
881 stat2=$(count_ost_writes)
882 echo "$stat1, $stat2"
883 if [ $stat1 -lt $stat2 ]; then
884 echo "writes continuing during recovery"
887 echo "writes not continuing during recovery, bug 2477"
890 echo "waiting for writeme $WRITE_PID"
894 echo "waiting for multiop $PID"
895 wait $PID || error "multiop $PID failed"
896 do_facet client munlink $MOUNT/$tfile ||
897 error "munlink $MOUNT/$tfile failed"
898 do_facet client munlink $MOUNT/${tfile}-2 ||
899 error "munlink $MOUNT/$tfile-2 failed"
902 run_test 40 "cause recovery in ptlrpc, ensure IO continues"
905 # make sure that a read to one osc doesn't try to double-unlock its page just
906 # because another osc is invalid. trigger_group_io used to mistakenly return
907 # an error if any oscs were invalid even after having successfully put rpcs
908 # on valid oscs. This was fatal if the caller was ll_readpage who unlocked
909 # the page, guarnateeing that the unlock from the RPC completion would
910 # assert on trying to unlock the unlocked page.
912 [ $OSTCOUNT -lt 2 ] && skip_env "needs >= 2 OSTs" && return
914 local f=$MOUNT/$tfile
915 # make sure the start of the file is ost1
916 $SETSTRIPE -S $((128 * 1024)) -i 0 $f
917 do_facet client dd if=/dev/zero of=$f bs=4k count=1 ||
918 error "dd on client failed"
920 # fail ost2 and read from ost1
921 local mdtosc=$(get_mdtosc_proc_path $SINGLEMDS $ost2_svc)
922 local osc2dev=$(do_facet $SINGLEMDS "lctl get_param -n devices" |
923 grep $mdtosc | awk '{print $1}')
924 [ -z "$osc2dev" ] && echo "OST: $ost2_svc" &&
925 lctl get_param -n devices &&
926 error "OST 2 $osc2dev does not exist"
927 do_facet $SINGLEMDS $LCTL --device $osc2dev deactivate ||
928 error "deactive device on $SINGLEMDS failed"
929 do_facet client dd if=$f of=/dev/null bs=4k count=1 ||
930 error "second dd on client failed"
931 do_facet $SINGLEMDS $LCTL --device $osc2dev activate ||
932 error "active device on $SINGLEMDS failed"
935 run_test 41 "read from a valid osc while other oscs are invalid"
937 # test MDS recovery after ost failure
939 blocks=$(df -P $MOUNT | tail -n 1 | awk '{ print $2 }')
940 createmany -o $DIR/$tfile-%d 800 ||
941 error "createmany -o $DIR/$tfile failed"
943 unlinkmany $DIR/$tfile-%d 0 400
945 lctl set_param debug=-1
948 # osc is evicted, fs is smaller (but only with failout OSTs (bug 7287)
949 #blocks_after=`df -P $MOUNT | tail -n 1 | awk '{ print $2 }'`
950 #[ $blocks_after -lt $blocks ] || return 1
951 echo "wait for MDS to timeout and recover"
952 sleep $((TIMEOUT * 2))
954 unlinkmany $DIR/$tfile-%d 400 400 ||
955 error "unlinkmany $DIR/$tfile 400 failed"
956 $CHECKSTAT -t file $DIR/$tfile-* &&
957 error "$CHECKSTAT $DIR/$tfile-* attribute check should fail" ||
960 run_test 42 "recovery after ost failure"
962 # timeout in MDS/OST recovery RPC will LBUG MDS
963 test_43() { # bug 2530
964 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
966 replay_barrier $SINGLEMDS
968 # OBD_FAIL_OST_CREATE_NET 0x204
969 do_facet ost1 "lctl set_param fail_loc=0x80000204"
975 run_test 43 "mds osc import failure during recovery; don't LBUG"
977 test_44a() { # was test_44
980 local mdcdev=$($LCTL dl |
981 awk "/${FSNAME}-MDT0000-mdc-/ {if (\$2 == \"UP\") {print \$1}}")
982 [ "$mdcdev" ] || error "${FSNAME}-MDT0000-mdc- not UP"
983 [ $(echo $mdcdev | wc -w) -eq 1 ] ||
984 { $LCTL dl; error "looking for mdcdev=$mdcdev"; }
986 # adaptive timeouts slow this way down
987 if at_is_enabled; then
988 at_max_saved=$(at_max_get mds)
992 for i in $(seq 1 10); do
993 echo "$i of 10 ($(date +%s))"
994 do_facet $SINGLEMDS \
995 "lctl get_param -n md[ts].*.mdt.timeouts | grep service"
996 #define OBD_FAIL_TGT_CONN_RACE 0x701
997 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000701"
998 # lctl below may fail, it is valid case
999 $LCTL --device $mdcdev recover
1002 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
1003 [ $at_max_saved -ne 0 ] && at_max_set $at_max_saved mds
1006 run_test 44a "race in target handle connect"
1009 local mdcdev=$($LCTL dl |
1010 awk "/${FSNAME}-MDT0000-mdc-/ {if (\$2 == \"UP\") {print \$1}}")
1011 [ "$mdcdev" ] || error "${FSNAME}-MDT0000-mdc not up"
1012 [ $(echo $mdcdev | wc -w) -eq 1 ] ||
1013 { echo mdcdev=$mdcdev; $LCTL dl;
1014 error "more than one ${FSNAME}-MDT0000-mdc"; }
1016 for i in $(seq 1 10); do
1017 echo "$i of 10 ($(date +%s))"
1018 do_facet $SINGLEMDS \
1019 "lctl get_param -n md[ts].*.mdt.timeouts | grep service"
1020 #define OBD_FAIL_TGT_DELAY_RECONNECT 0x704
1021 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000704"
1022 # lctl below may fail, it is valid case
1023 $LCTL --device $mdcdev recover
1028 run_test 44b "race in target handle connect"
1031 replay_barrier $SINGLEMDS
1032 createmany -m $DIR/$tfile-%d 100 || error "failed to create directories"
1033 #define OBD_FAIL_TGT_RCVG_FLAG 0x712
1034 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000712"
1035 fail_abort $SINGLEMDS
1036 unlinkmany $DIR/$tfile-%d 100 && error "unliked after fail abort"
1038 unlinkmany $DIR/$tfile-%d 100 && error "unliked after fail"
1041 run_test 44c "race in target handle connect"
1043 # Handle failed close
1045 local mdcdev=$($LCTL get_param -n devices |
1046 awk "/ ${FSNAME}-MDT0000-mdc-/ {print \$1}")
1047 [ "$mdcdev" ] || error "${FSNAME}-MDT0000-mdc not up"
1048 [ $(echo $mdcdev | wc -w) -eq 1 ] ||
1049 { echo mdcdev=$mdcdev; $LCTL dl;
1050 error "more than one ${FSNAME}-MDT0000-mdc"; }
1052 $LCTL --device $mdcdev recover ||
1053 error "$LCTL --device $mdcdev recover failed"
1055 multiop_bg_pause $DIR/$tfile O_c ||
1056 error "multiop_bg_pause $DIR/$tfile failed"
1059 # This will cause the CLOSE to fail before even
1060 # allocating a reply buffer
1061 $LCTL --device $mdcdev deactivate ||
1062 error "$LCTL --device $mdcdev deactivate failed"
1065 kill -USR1 $pid || error "multiop $pid not running"
1066 wait $pid || error "multiop $pid failed"
1068 $LCTL --device $mdcdev activate ||
1069 error "$LCTL --device $mdcdev activate failed"
1072 $CHECKSTAT -t file $DIR/$tfile ||
1073 error "$CHECKSTAT $DIR/$tfile attribute check failed"
1076 run_test 45 "Handle failed close"
1080 drop_reply "touch $DIR/$tfile"
1082 # ironically, the previous test, 45, will cause a real forced close,
1083 # so just look for one for this test
1084 dmesg | grep -i "force closing client file handle for $tfile" &&
1085 error "found force closing in dmesg"
1088 run_test 46 "Don't leak file handle after open resend (3325)"
1090 test_47() { # bug 2824
1091 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1093 # create some files to make sure precreate has been done on all
1094 # OSTs. (just in case this test is run independently)
1095 createmany -o $DIR/$tfile 20 ||
1096 error "createmany create $DIR/$tfile failed"
1098 # OBD_FAIL_OST_CREATE_NET 0x204
1100 do_facet ost1 "lctl set_param fail_loc=0x80000204"
1101 client_up || error "client_up failed"
1103 # let the MDS discover the OST failure, attempt to recover, fail
1104 # and recover again.
1105 sleep $((3 * TIMEOUT))
1107 # Without 2824, this createmany would hang
1108 createmany -o $DIR/$tfile 20 ||
1109 error "createmany recraete $DIR/$tfile failed"
1110 unlinkmany $DIR/$tfile 20 || error "unlinkmany $DIR/$tfile failed"
1114 run_test 47 "MDS->OSC failure during precreate cleanup (2824)"
1117 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1118 [ "$OSTCOUNT" -lt "2" ] && skip_env "needs >= 2 OSTs" && return
1120 replay_barrier $SINGLEMDS
1121 createmany -o $DIR/$tfile 20 ||
1122 error "createmany -o $DIR/$tfile failed"
1123 # OBD_FAIL_OST_EROFS 0x216
1124 facet_failover $SINGLEMDS
1125 do_facet ost1 "lctl set_param fail_loc=0x80000216"
1126 client_up || error "client_up failed"
1128 createmany -o $DIR/$tfile 20 20 ||
1129 error "createmany recraete $DIR/$tfile failed"
1130 unlinkmany $DIR/$tfile 40 || error "unlinkmany $DIR/$tfile failed"
1133 run_test 48 "MDS->OSC failure during precreate cleanup (2824)"
1136 local mdtosc=$(get_mdtosc_proc_path $SINGLEMDS $ost1_svc)
1137 local oscdev=$(do_facet $SINGLEMDS "lctl get_param -n devices" |
1138 grep $mdtosc | awk '{print $1}')
1139 [ "$oscdev" ] || error "could not find OSC device on MDS"
1140 do_facet $SINGLEMDS $LCTL --device $oscdev recover ||
1141 error "OSC device $oscdev recovery failed"
1142 do_facet $SINGLEMDS $LCTL --device $oscdev recover ||
1143 error "second OSC device $oscdev recovery failed"
1144 # give the mds_lov_sync threads a chance to run
1147 run_test 50 "Double OSC recovery, don't LASSERT (3812)"
1149 # b3764 timed out lock replay
1151 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.6.90) ] &&
1152 skip "MDS prior to 2.6.90 handle LDLM_REPLY_NET incorrectly" &&
1155 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
1156 cancel_lru_locks mdc
1158 multiop_bg_pause $DIR/$tfile s_s || error "multiop $DIR/$tfile failed"
1161 #define OBD_FAIL_MDS_LDLM_REPLY_NET 0x157
1162 lctl set_param -n ldlm.cancel_unused_locks_before_replay "0"
1163 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000157"
1165 fail $SINGLEMDS || error "fail $SINGLEMDS failed"
1167 wait $mpid || error "multiop_bg_pause pid failed"
1169 do_facet $SINGLEMDS "lctl set_param fail_loc=0x0"
1170 lctl set_param fail_loc=0x0
1171 lctl set_param -n ldlm.cancel_unused_locks_before_replay "1"
1174 run_test 52 "time out lock replay (3764)"
1176 # bug 3462 - simultaneous MDC requests
1178 [[ $(lctl get_param mdc.*.import |
1179 grep "connect_flags:.*multi_mod_rpc") ]] ||
1180 { skip "Need MDC with 'multi_mod_rpcs' feature"; return 0; }
1182 cancel_lru_locks mdc # cleanup locks from former test cases
1183 mkdir $DIR/${tdir}-1 || error "mkdir $DIR/${tdir}-1 failed"
1184 mkdir $DIR/${tdir}-2 || error "mkdir $DIR/${tdir}-2 failed"
1185 multiop $DIR/${tdir}-1/f O_c &
1187 # give multiop a change to open
1190 #define OBD_FAIL_MDS_CLOSE_NET 0x115
1191 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000115"
1192 kill -USR1 $close_pid
1193 cancel_lru_locks mdc # force the close
1194 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
1196 mcreate $DIR/${tdir}-2/f || error "mcreate $DIR/${tdir}-2/f failed"
1198 # close should still be here
1199 [ -d /proc/$close_pid ] || error "close_pid doesn't exist"
1201 replay_barrier_nodf $SINGLEMDS
1203 wait $close_pid || error "close_pid $close_pid failed"
1205 $CHECKSTAT -t file $DIR/${tdir}-1/f ||
1206 error "$CHECKSTAT $DIR/${tdir}-1/f attribute check failed"
1207 $CHECKSTAT -t file $DIR/${tdir}-2/f ||
1208 error "$CHECKSTAT $DIR/${tdir}-2/f attribute check failed"
1209 rm -rf $DIR/${tdir}-*
1211 run_test 53a "|X| close request while two MDC requests in flight"
1214 cancel_lru_locks mdc # cleanup locks from former test cases
1216 mkdir $DIR/${tdir}-1 || error "mkdir $DIR/${tdir}-1 failed"
1217 mkdir $DIR/${tdir}-2 || error "mkdir $DIR/${tdir}-2 failed"
1218 multiop_bg_pause $DIR/${tdir}-1/f O_c ||
1219 error "multiop_bg_pause $DIR/${tdir}-1/f failed"
1222 #define OBD_FAIL_MDS_REINT_NET 0x107
1223 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000107"
1224 mcreate $DIR/${tdir}-2/f &
1228 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
1229 kill -USR1 $close_pid
1230 cancel_lru_locks mdc # force the close
1231 wait $close_pid || error "close_pid $close_pid failed"
1232 # open should still be here
1233 [ -d /proc/$open_pid ] || error "open_pid doesn't exist"
1235 replay_barrier_nodf $SINGLEMDS
1237 wait $open_pid || error "open_pid failed"
1239 $CHECKSTAT -t file $DIR/${tdir}-1/f ||
1240 error "$CHECKSTAT $DIR/${tdir}-1/f attribute check failed"
1241 $CHECKSTAT -t file $DIR/${tdir}-2/f ||
1242 error "$CHECKSTAT $DIR/${tdir}-2/f attribute check failed"
1243 rm -rf $DIR/${tdir}-*
1245 run_test 53b "|X| open request while two MDC requests in flight"
1248 cancel_lru_locks mdc # cleanup locks from former test cases
1250 mkdir $DIR/${tdir}-1 || error "mkdir $DIR/${tdir}-1 failed"
1251 mkdir $DIR/${tdir}-2 || error "mkdir $DIR/${tdir}-2 failed"
1252 multiop $DIR/${tdir}-1/f O_c &
1255 #define OBD_FAIL_MDS_REINT_NET 0x107
1256 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000107"
1257 mcreate $DIR/${tdir}-2/f &
1261 #define OBD_FAIL_MDS_CLOSE_NET 0x115
1262 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000115"
1263 kill -USR1 $close_pid
1264 cancel_lru_locks mdc # force the close
1266 #bz20647: make sure all pids exist before failover
1267 [ -d /proc/$close_pid ] || error "close_pid doesn't exist"
1268 [ -d /proc/$open_pid ] || error "open_pid doesn't exists"
1269 replay_barrier_nodf $SINGLEMDS
1270 fail_nodf $SINGLEMDS
1271 wait $open_pid || error "open_pid failed"
1273 # close should be gone
1274 [ -d /proc/$close_pid ] && error "close_pid should not exist"
1275 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
1277 $CHECKSTAT -t file $DIR/${tdir}-1/f ||
1278 error "$CHECKSTAT $DIR/${tdir}-1/f attribute check failed"
1279 $CHECKSTAT -t file $DIR/${tdir}-2/f ||
1280 error "$CHECKSTAT $DIR/${tdir}-2/f attribute check failed"
1281 rm -rf $DIR/${tdir}-*
1283 run_test 53c "|X| open request and close request while two MDC requests in flight"
1286 [[ $(lctl get_param mdc.*.import |
1287 grep "connect_flags:.*multi_mod_rpc") ]] ||
1288 { skip "Need MDC with 'multi_mod_rpcs' feature"; return 0; }
1290 cancel_lru_locks mdc # cleanup locks from former test cases
1292 mkdir $DIR/${tdir}-1 || error "mkdir $DIR/${tdir}-1 failed"
1293 mkdir $DIR/${tdir}-2 || error "mkdir $DIR/${tdir}-2 failed"
1294 multiop $DIR/${tdir}-1/f O_c &
1296 # give multiop a chance to open
1299 #define OBD_FAIL_MDS_CLOSE_NET_REP 0x13b
1300 do_facet $SINGLEMDS "lctl set_param fail_loc=0x8000013b"
1301 kill -USR1 $close_pid
1302 cancel_lru_locks mdc # force the close
1303 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
1304 mcreate $DIR/${tdir}-2/f || error "mcreate $DIR/${tdir}-2/f failed"
1306 # close should still be here
1307 [ -d /proc/$close_pid ] || error "close_pid doesn't exist"
1309 wait $close_pid || error "close_pid failed"
1311 $CHECKSTAT -t file $DIR/${tdir}-1/f ||
1312 error "$CHECKSTAT $DIR/${tdir}-1/f attribute check failed"
1313 $CHECKSTAT -t file $DIR/${tdir}-2/f ||
1314 error "$CHECKSTAT $DIR/${tdir}-2/f attribute check failed"
1315 rm -rf $DIR/${tdir}-*
1317 run_test 53d "close reply while two MDC requests in flight"
1320 cancel_lru_locks mdc # cleanup locks from former test cases
1322 mkdir $DIR/${tdir}-1 || error "mkdir $DIR/${tdir}-1 failed"
1323 mkdir $DIR/${tdir}-2 || error "mkdir $DIR/${tdir}-2 failed"
1324 multiop $DIR/${tdir}-1/f O_c &
1327 #define OBD_FAIL_MDS_REINT_NET_REP 0x119
1328 do_facet $SINGLEMDS "lctl set_param fail_loc=0x119"
1329 mcreate $DIR/${tdir}-2/f &
1333 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
1334 kill -USR1 $close_pid
1335 cancel_lru_locks mdc # force the close
1336 wait $close_pid || error "close_pid failed"
1337 # open should still be here
1338 [ -d /proc/$open_pid ] || error "open_pid doesn't exists"
1340 replay_barrier_nodf $SINGLEMDS
1342 wait $open_pid || error "open_pid failed"
1344 $CHECKSTAT -t file $DIR/${tdir}-1/f ||
1345 error "$CHECKSTAT $DIR/${tdir}-1/f attribute check failed"
1346 $CHECKSTAT -t file $DIR/${tdir}-2/f ||
1347 error "$CHECKSTAT $DIR/${tdir}-2/f attribute check failed"
1348 rm -rf $DIR/${tdir}-*
1350 run_test 53e "|X| open reply while two MDC requests in flight"
1353 cancel_lru_locks mdc # cleanup locks from former test cases
1355 mkdir $DIR/${tdir}-1 || error "mkdir $DIR/${tdir}-1 failed"
1356 mkdir $DIR/${tdir}-2 || error "mkdir $DIR/${tdir}-2 failed"
1357 multiop $DIR/${tdir}-1/f O_c &
1360 #define OBD_FAIL_MDS_REINT_NET_REP 0x119
1361 do_facet $SINGLEMDS "lctl set_param fail_loc=0x119"
1362 mcreate $DIR/${tdir}-2/f &
1366 #define OBD_FAIL_MDS_CLOSE_NET_REP 0x13b
1367 do_facet $SINGLEMDS "lctl set_param fail_loc=0x8000013b"
1368 kill -USR1 $close_pid
1369 cancel_lru_locks mdc # force the close
1371 #bz20647: make sure all pids are exists before failover
1372 [ -d /proc/$close_pid ] || error "close_pid doesn't exist"
1373 [ -d /proc/$open_pid ] || error "open_pid doesn't exists"
1374 replay_barrier_nodf $SINGLEMDS
1375 fail_nodf $SINGLEMDS
1376 wait $open_pid || error "open_pid failed"
1378 # close should be gone
1379 [ -d /proc/$close_pid ] && error "close_pid should not exist"
1380 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
1382 $CHECKSTAT -t file $DIR/${tdir}-1/f ||
1383 error "$CHECKSTAT $DIR/${tdir}-1/f attribute check failed"
1384 $CHECKSTAT -t file $DIR/${tdir}-2/f ||
1385 error "$CHECKSTAT $DIR/${tdir}-2/f attribute check failed"
1386 rm -rf $DIR/${tdir}-*
1388 run_test 53f "|X| open reply and close reply while two MDC requests in flight"
1391 cancel_lru_locks mdc # cleanup locks from former test cases
1393 mkdir $DIR/${tdir}-1 || error "mkdir $DIR/${tdir}-1 failed"
1394 mkdir $DIR/${tdir}-2 || error "mkdir $DIR/${tdir}-2 failed"
1395 multiop $DIR/${tdir}-1/f O_c &
1398 #define OBD_FAIL_MDS_REINT_NET_REP 0x119
1399 do_facet $SINGLEMDS "lctl set_param fail_loc=0x119"
1400 mcreate $DIR/${tdir}-2/f &
1404 #define OBD_FAIL_MDS_CLOSE_NET 0x115
1405 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000115"
1406 kill -USR1 $close_pid
1407 cancel_lru_locks mdc # force the close
1408 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
1410 #bz20647: make sure all pids are exists before failover
1411 [ -d /proc/$close_pid ] || error "close_pid doesn't exist"
1412 [ -d /proc/$open_pid ] || error "open_pid doesn't exists"
1413 replay_barrier_nodf $SINGLEMDS
1414 fail_nodf $SINGLEMDS
1415 wait $open_pid || error "open_pid failed"
1417 # close should be gone
1418 [ -d /proc/$close_pid ] && error "close_pid should not exist"
1420 $CHECKSTAT -t file $DIR/${tdir}-1/f ||
1421 error "$CHECKSTAT $DIR/${tdir}-1/f attribute check failed"
1422 $CHECKSTAT -t file $DIR/${tdir}-2/f ||
1423 error "$CHECKSTAT $DIR/${tdir}-2/f attribute check failed"
1424 rm -rf $DIR/${tdir}-*
1426 run_test 53g "|X| drop open reply and close request while close and open are both in flight"
1429 cancel_lru_locks mdc # cleanup locks from former test cases
1431 mkdir $DIR/${tdir}-1 || error "mkdir $DIR/${tdir}-1 failed"
1432 mkdir $DIR/${tdir}-2 || error "mkdir $DIR/${tdir}-2 failed"
1433 multiop $DIR/${tdir}-1/f O_c &
1436 #define OBD_FAIL_MDS_REINT_NET 0x107
1437 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000107"
1438 mcreate $DIR/${tdir}-2/f &
1442 #define OBD_FAIL_MDS_CLOSE_NET_REP 0x13b
1443 do_facet $SINGLEMDS "lctl set_param fail_loc=0x8000013b"
1444 kill -USR1 $close_pid
1445 cancel_lru_locks mdc # force the close
1448 #bz20647: make sure all pids are exists before failover
1449 [ -d /proc/$close_pid ] || error "close_pid doesn't exist"
1450 [ -d /proc/$open_pid ] || error "open_pid doesn't exists"
1451 replay_barrier_nodf $SINGLEMDS
1452 fail_nodf $SINGLEMDS
1453 wait $open_pid || error "open_pid failed"
1455 # close should be gone
1456 [ -d /proc/$close_pid ] && error "close_pid should not exist"
1457 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
1459 $CHECKSTAT -t file $DIR/${tdir}-1/f ||
1460 error "$CHECKSTAT $DIR/${tdir}-1/f attribute check failed"
1461 $CHECKSTAT -t file $DIR/${tdir}-2/f ||
1462 error "$CHECKSTAT $DIR/${tdir}-2/f attribute check failed"
1463 rm -rf $DIR/${tdir}-*
1465 run_test 53h "open request and close reply while two MDC requests in flight"
1467 #b3761 ASSERTION(hash != 0) failed
1469 # OBD_FAIL_MDS_OPEN_CREATE | OBD_FAIL_ONCE
1470 do_facet $SINGLEMDS "lctl set_param fail_loc=0x8000012b"
1472 # give touch a chance to run
1474 do_facet $SINGLEMDS "lctl set_param fail_loc=0x0"
1478 run_test 55 "let MDS_CHECK_RESENT return the original return code instead of 0"
1480 #b3440 ASSERTION(rec->ur_fid2->id) failed
1482 ln -s foo $DIR/$tfile
1483 replay_barrier $SINGLEMDS
1484 #drop_reply "cat $DIR/$tfile"
1488 run_test 56 "don't replay a symlink open request (3440)"
1490 #recovery one mds-ost setattr from llog
1492 #define OBD_FAIL_MDS_OST_SETATTR 0x12c
1493 do_facet $SINGLEMDS "lctl set_param fail_loc=0x8000012c"
1494 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
1495 replay_barrier $SINGLEMDS
1497 wait_recovery_complete $SINGLEMDS || error "MDS recovery is not done"
1498 wait_mds_ost_sync || error "wait_mds_ost_sync failed"
1499 $CHECKSTAT -t file $DIR/$tfile ||
1500 error "$CHECKSTAT $DIR/$tfile attribute check failed"
1501 do_facet $SINGLEMDS "lctl set_param fail_loc=0x0"
1504 run_test 57 "test recovery from llog for setattr op"
1507 zconf_umount $(hostname) $MOUNT2
1511 #recovery many mds-ost setattr from llog
1513 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
1514 #define OBD_FAIL_MDS_OST_SETATTR 0x12c
1515 do_facet $SINGLEMDS "lctl set_param fail_loc=0x8000012c"
1516 createmany -o $DIR/$tdir/$tfile-%d 2500
1517 replay_barrier $SINGLEMDS
1520 $CHECKSTAT -t file $DIR/$tdir/$tfile-* >/dev/null ||
1521 error "$CHECKSTAT $DIR/$tfile-* attribute check failed"
1522 do_facet $SINGLEMDS "lctl set_param fail_loc=0x0"
1523 unlinkmany $DIR/$tdir/$tfile-%d 2500 ||
1524 error "unlinkmany $DIR/$tfile failed"
1527 run_test 58a "test recovery from llog for setattr op (test llog_gen_rec)"
1533 trap cleanup_58 EXIT
1535 large_xattr_enabled &&
1536 orig="$(generate_string $(max_xattr_size))" || orig="bar"
1537 # Original extended attribute can be long. Print a small version of
1538 # attribute if an error occurs
1539 local sm_msg=$(printf "%.9s" $orig)
1541 mount_client $MOUNT2 || error "mount_client on $MOUNT2 failed"
1542 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
1543 touch $DIR/$tdir/$tfile || error "touch $DIR/$tdir/$tfile failed"
1544 replay_barrier $SINGLEMDS
1545 setfattr -n trusted.foo -v $orig $DIR/$tdir/$tfile
1547 new=$(get_xattr_value trusted.foo $MOUNT2/$tdir/$tfile)
1548 [[ "$new" = "$orig" ]] ||
1549 error "xattr set ($sm_msg...) differs from xattr get ($new)"
1550 rm -f $DIR/$tdir/$tfile
1553 wait_clients_import_state ${CLIENTS:-$HOSTNAME} "mgs" FULL
1555 run_test 58b "test replay of setxattr op"
1557 test_58c() { # bug 16570
1562 trap cleanup_58 EXIT
1564 if large_xattr_enabled; then
1565 local xattr_size=$(max_xattr_size)
1566 orig="$(generate_string $((xattr_size / 2)))"
1567 orig1="$(generate_string $xattr_size)"
1573 # PING_INTERVAL max(obd_timeout / 4, 1U)
1574 sleep $((TIMEOUT / 4))
1576 # Original extended attribute can be long. Print a small version of
1577 # attribute if an error occurs
1578 local sm_msg=$(printf "%.9s" $orig)
1579 local sm_msg1=$(printf "%.9s" $orig1)
1581 mount_client $MOUNT2 || error "mount_client on $MOUNT2 failed"
1582 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
1583 touch $DIR/$tdir/$tfile || error "touch $DIR/$tdir/$tfile failed"
1584 drop_request "setfattr -n trusted.foo -v $orig $DIR/$tdir/$tfile" ||
1585 error "drop_request for setfattr failed"
1586 new=$(get_xattr_value trusted.foo $MOUNT2/$tdir/$tfile)
1587 [[ "$new" = "$orig" ]] ||
1588 error "xattr set ($sm_msg...) differs from xattr get ($new)"
1589 drop_reint_reply "setfattr -n trusted.foo1 \
1590 -v $orig1 $DIR/$tdir/$tfile" ||
1591 error "drop_reint_reply for setfattr failed"
1592 new=$(get_xattr_value trusted.foo1 $MOUNT2/$tdir/$tfile)
1593 [[ "$new" = "$orig1" ]] ||
1594 error "second xattr set ($sm_msg1...) differs xattr get ($new)"
1595 rm -f $DIR/$tdir/$tfile
1599 run_test 58c "resend/reconstruct setxattr op"
1601 # log_commit_thread vs filter_destroy race used to lead to import use after free
1604 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1606 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
1607 createmany -o $DIR/$tdir/$tfile-%d 200 ||
1608 error "createmany create files failed"
1610 unlinkmany $DIR/$tdir/$tfile-%d 200 ||
1611 error "unlinkmany $DIR/$tdir/$tfile failed"
1612 #define OBD_FAIL_PTLRPC_DELAY_RECOV 0x507
1613 do_facet ost1 "lctl set_param fail_loc=0x507"
1616 do_facet ost1 "lctl set_param fail_loc=0x0"
1620 run_test 59 "test log_commit_thread vs filter_destroy race"
1622 # race between add unlink llog vs cat log init in post_recovery (only for b1_6)
1623 # bug 12086: should no oops and No ctxt error for this test
1625 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
1626 createmany -o $DIR/$tdir/$tfile-%d 200 ||
1627 error "createmany create files failed"
1628 replay_barrier $SINGLEMDS
1629 unlinkmany $DIR/$tdir/$tfile-%d 0 100
1631 unlinkmany $DIR/$tdir/$tfile-%d 100 100
1632 local no_ctxt=$(dmesg | grep "No ctxt")
1633 [ -z "$no_ctxt" ] || error "ctxt is not initialized in recovery"
1635 run_test 60 "test llog post recovery init vs llog unlink"
1637 #test race llog recovery thread vs llog cleanup
1638 test_61a() { # was test_61
1639 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1641 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
1642 createmany -o $DIR/$tdir/$tfile-%d 800 ||
1643 error "createmany create files failed"
1645 unlinkmany $DIR/$tdir/$tfile-%d 800
1646 # OBD_FAIL_OST_LLOG_RECOVERY_TIMEOUT 0x221
1647 set_nodes_failloc "$(osts_nodes)" 0x80000221
1652 set_nodes_failloc "$(osts_nodes)" 0x0
1654 $CHECKSTAT -t file $DIR/$tdir/$tfile-* &&
1655 error "$CHECKSTAT $DIR/$tdir/$tfile attribute check should fail"
1658 run_test 61a "test race llog recovery vs llog cleanup"
1660 #test race mds llog sync vs llog cleanup
1662 # OBD_FAIL_MDS_LLOG_SYNC_TIMEOUT 0x13a
1663 do_facet $SINGLEMDS "lctl set_param fail_loc=0x8000013a"
1664 facet_failover $SINGLEMDS
1667 do_facet client dd if=/dev/zero of=$DIR/$tfile bs=4k count=1 ||
1670 run_test 61b "test race mds llog sync vs llog cleanup"
1672 #test race cancel cookie cb vs llog cleanup
1674 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1676 # OBD_FAIL_OST_CANCEL_COOKIE_TIMEOUT 0x222
1677 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
1678 set_nodes_failloc "$(osts_nodes)" 0x80000222
1682 set_nodes_failloc "$(osts_nodes)" 0x0
1684 run_test 61c "test race mds llog sync vs llog cleanup"
1686 test_61d() { # bug 16002 # bug 17466 # bug 22137
1687 # OBD_FAIL_OBD_LLOG_SETUP 0x605
1689 do_facet mgs "lctl set_param fail_loc=0x80000605"
1690 start mgs $(mgsdevname) $MGS_MOUNT_OPTS &&
1691 error "mgs start should have failed"
1692 do_facet mgs "lctl set_param fail_loc=0"
1693 start mgs $(mgsdevname) $MGS_MOUNT_OPTS || error "cannot restart mgs"
1695 run_test 61d "error in llog_setup should cleanup the llog context correctly"
1697 test_62() { # Bug 15756 - don't mis-drop resent replay
1698 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
1699 replay_barrier $SINGLEMDS
1700 createmany -o $DIR/$tdir/$tfile- 25 ||
1701 error "createmany create files failed"
1702 #define OBD_FAIL_TGT_REPLAY_DROP 0x707
1703 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000707"
1705 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
1706 unlinkmany $DIR/$tdir/$tfile- 25 ||
1707 error "unlinkmany $DIR/$tdir/$tfile failed"
1710 run_test 62 "don't mis-drop resent replay"
1712 #Adaptive Timeouts (bug 3055)
1720 echo "Cleaning up AT ..."
1721 if [ -n "$ATOLDBASE" ]; then
1722 local at_history=$($LCTL get_param -n at_history)
1723 do_facet $SINGLEMDS "lctl set_param at_history=$at_history" || true
1724 do_facet ost1 "lctl set_param at_history=$at_history" || true
1727 if [ $AT_MAX_SET -ne 0 ]; then
1728 for facet in mds client ost; do
1729 var=AT_MAX_SAVE_${facet}
1730 echo restore AT on $facet to saved value ${!var}
1731 at_max_set ${!var} $facet
1732 at_new=$(at_max_get $facet)
1733 echo Restored AT value on $facet $at_new
1734 [ $at_new -eq ${!var} ] ||
1735 error "AT value not restored SAVED ${!var} NEW $at_new"
1742 local at_max_new=600
1744 # Save at_max original values
1746 if [ $AT_MAX_SET -eq 0 ]; then
1747 # Suppose that all osts have the same at_max
1748 for facet in mds client ost; do
1749 eval AT_MAX_SAVE_${facet}=$(at_max_get $facet)
1753 for facet in mds client ost; do
1754 at_max=$(at_max_get $facet)
1755 if [ $at_max -ne $at_max_new ]; then
1756 echo "AT value on $facet is $at_max, set it by force temporarily to $at_max_new"
1757 at_max_set $at_max_new $facet
1762 if [ -z "$ATOLDBASE" ]; then
1763 ATOLDBASE=$(do_facet $SINGLEMDS "lctl get_param -n at_history")
1764 # speed up the timebase so we can check decreasing AT
1765 do_facet $SINGLEMDS "lctl set_param at_history=8" || true
1766 do_facet ost1 "lctl set_param at_history=8" || true
1768 # sleep for a while to cool down, should be > 8s and also allow
1769 # at least one ping to be sent. simply use TIMEOUT to be safe.
1774 test_65a() #bug 3055
1776 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1778 at_start || return 0
1779 $LCTL dk > /dev/null
1781 $LCTL set_param debug="other"
1782 # Slow down a request to the current service time, this is critical
1783 # because previous tests may have caused this value to increase.
1784 REQ_DELAY=`lctl get_param -n mdc.${FSNAME}-MDT0000-mdc-*.timeouts |
1785 awk '/portal 12/ {print $5}'`
1786 REQ_DELAY=$((${REQ_DELAY} + ${REQ_DELAY} / 4 + 5))
1788 do_facet $SINGLEMDS lctl set_param fail_val=$((${REQ_DELAY} * 1000))
1789 #define OBD_FAIL_PTLRPC_PAUSE_REQ 0x50a
1790 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x8000050a
1791 createmany -o $DIR/$tfile 10 > /dev/null
1792 unlinkmany $DIR/$tfile 10 > /dev/null
1793 # check for log message
1794 $LCTL dk | grep "Early reply #" || error "No early reply"
1796 # client should show REQ_DELAY estimates
1797 lctl get_param -n mdc.${FSNAME}-MDT0000-mdc-*.timeouts | grep portal
1799 lctl get_param -n mdc.${FSNAME}-MDT0000-mdc-*.timeouts | grep portal
1801 run_test 65a "AT: verify early replies"
1803 test_65b() #bug 3055
1805 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1807 at_start || return 0
1810 $LCTL set_param debug="other trace"
1811 $LCTL dk > /dev/null
1812 # Slow down a request to the current service time, this is critical
1813 # because previous tests may have caused this value to increase.
1814 $SETSTRIPE --stripe-index=0 --stripe-count=1 $DIR/$tfile ||
1815 error "$SETSTRIPE failed for $DIR/$tfile"
1817 multiop $DIR/$tfile Ow1yc
1818 REQ_DELAY=`lctl get_param -n osc.${FSNAME}-OST0000-osc-*.timeouts |
1819 awk '/portal 6/ {print $5}'`
1820 REQ_DELAY=$((${REQ_DELAY} + ${REQ_DELAY} / 4 + 5))
1822 do_facet ost1 lctl set_param fail_val=${REQ_DELAY}
1823 #define OBD_FAIL_OST_BRW_PAUSE_PACK 0x224
1824 do_facet ost1 $LCTL set_param fail_loc=0x224
1827 $SETSTRIPE --stripe-index=0 --stripe-count=1 $DIR/$tfile ||
1828 error "$SETSTRIPE failed"
1829 # force some real bulk transfer
1830 multiop $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
1832 do_facet ost1 $LCTL set_param fail_loc=0
1833 # check for log message
1834 $LCTL dk | grep "Early reply #" || error "No early reply"
1836 # client should show REQ_DELAY estimates
1837 lctl get_param -n osc.${FSNAME}-OST0000-osc-*.timeouts | grep portal
1839 run_test 65b "AT: verify early replies on packed reply / bulk"
1841 test_66a() #bug 3055
1843 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1845 at_start || return 0
1846 lctl get_param -n mdc.${FSNAME}-MDT0000-mdc-*.timeouts | grep "portal 12"
1847 # adjust 5s at a time so no early reply is sent (within deadline)
1848 do_facet $SINGLEMDS "$LCTL set_param fail_val=5000"
1849 #define OBD_FAIL_PTLRPC_PAUSE_REQ 0x50a
1850 do_facet $SINGLEMDS "$LCTL set_param fail_loc=0x8000050a"
1851 createmany -o $DIR/$tfile 20 > /dev/null
1852 unlinkmany $DIR/$tfile 20 > /dev/null
1853 lctl get_param -n mdc.${FSNAME}-MDT0000-mdc-*.timeouts | grep "portal 12"
1854 do_facet $SINGLEMDS "$LCTL set_param fail_val=10000"
1855 do_facet $SINGLEMDS "$LCTL set_param fail_loc=0x8000050a"
1856 createmany -o $DIR/$tfile 20 > /dev/null
1857 unlinkmany $DIR/$tfile 20 > /dev/null
1858 lctl get_param -n mdc.${FSNAME}-MDT0000-mdc-*.timeouts | grep "portal 12"
1859 do_facet $SINGLEMDS "$LCTL set_param fail_loc=0"
1861 createmany -o $DIR/$tfile 20 > /dev/null
1862 unlinkmany $DIR/$tfile 20 > /dev/null
1863 lctl get_param -n mdc.${FSNAME}-MDT0000-mdc-*.timeouts | grep "portal 12"
1864 CUR=$(lctl get_param -n mdc.${FSNAME}-MDT0000-mdc-*.timeouts | awk '/portal 12/ {print $5}')
1865 WORST=$(lctl get_param -n mdc.${FSNAME}-MDT0000-mdc-*.timeouts | awk '/portal 12/ {print $7}')
1866 echo "Current MDT timeout $CUR, worst $WORST"
1867 [ $CUR -lt $WORST ] || error "Current $CUR should be less than worst $WORST"
1869 run_test 66a "AT: verify MDT service time adjusts with no early replies"
1871 test_66b() #bug 3055
1873 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1875 at_start || return 0
1876 ORIG=$(lctl get_param -n mdc.${FSNAME}-MDT0000*.timeouts |
1877 awk '/network/ {print $4}')
1878 $LCTL set_param fail_val=$(($ORIG + 5))
1879 #define OBD_FAIL_PTLRPC_PAUSE_REP 0x50c
1880 $LCTL set_param fail_loc=0x50c
1881 ls $DIR/$tfile > /dev/null 2>&1
1882 $LCTL set_param fail_loc=0
1883 CUR=$(lctl get_param -n mdc.${FSNAME}-MDT0000*.timeouts |
1884 awk '/network/ {print $4}')
1885 WORST=$(lctl get_param -n mdc.${FSNAME}-MDT0000*.timeouts |
1886 awk '/network/ {print $6}')
1887 echo "network timeout orig $ORIG, cur $CUR, worst $WORST"
1888 [ $WORST -gt $ORIG ] ||
1889 error "Worst $WORST should be worse than orig $ORIG"
1891 run_test 66b "AT: verify net latency adjusts"
1893 test_67a() #bug 3055
1895 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1897 at_start || return 0
1898 CONN1=$(lctl get_param -n osc.*.stats | awk '/_connect/ {total+=$2} END {print total}')
1899 # sleeping threads may drive values above this
1900 do_facet ost1 "$LCTL set_param fail_val=400"
1901 #define OBD_FAIL_PTLRPC_PAUSE_REQ 0x50a
1902 do_facet ost1 "$LCTL set_param fail_loc=0x50a"
1903 createmany -o $DIR/$tfile 20 > /dev/null
1904 unlinkmany $DIR/$tfile 20 > /dev/null
1905 do_facet ost1 "$LCTL set_param fail_loc=0"
1906 CONN2=$(lctl get_param -n osc.*.stats | awk '/_connect/ {total+=$2} END {print total}')
1907 ATTEMPTS=$(($CONN2 - $CONN1))
1908 echo "$ATTEMPTS osc reconnect attempts on gradual slow"
1909 [ $ATTEMPTS -gt 0 ] &&
1910 error_ignore bz13721 "AT should have prevented reconnect"
1913 run_test 67a "AT: verify slow request processing doesn't induce reconnects"
1915 test_67b() #bug 3055
1917 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1919 at_start || return 0
1920 CONN1=$(lctl get_param -n osc.*.stats | awk '/_connect/ {total+=$2} END {print total}')
1922 # exhaust precreations on ost1
1923 local OST=$(ostname_from_index 0)
1924 local mdtosc=$(get_mdtosc_proc_path mds $OST)
1925 local last_id=$(do_facet $SINGLEMDS lctl get_param -n \
1926 osc.$mdtosc.prealloc_last_id)
1927 local next_id=$(do_facet $SINGLEMDS lctl get_param -n \
1928 osc.$mdtosc.prealloc_next_id)
1930 mkdir -p $DIR/$tdir/${OST} || error "mkdir $DIR/$tdir/${OST} failed"
1931 $SETSTRIPE -i 0 -c 1 $DIR/$tdir/${OST} || error "$SETSTRIPE failed"
1932 echo "Creating to objid $last_id on ost $OST..."
1933 #define OBD_FAIL_OST_PAUSE_CREATE 0x223
1934 do_facet ost1 "$LCTL set_param fail_val=20000"
1935 do_facet ost1 "$LCTL set_param fail_loc=0x80000223"
1936 createmany -o $DIR/$tdir/${OST}/f $next_id $((last_id - next_id + 2))
1939 do_facet ost1 "lctl get_param -n ost.OSS.ost_create.timeouts"
1941 CONN2=$(lctl get_param -n osc.*.stats | awk '/_connect/ {total+=$2} END {print total}')
1942 ATTEMPTS=$(($CONN2 - $CONN1))
1943 echo "$ATTEMPTS osc reconnect attempts on instant slow"
1944 # do it again; should not timeout
1945 do_facet ost1 "$LCTL set_param fail_loc=0x80000223"
1946 cp /etc/profile $DIR/$tfile || error "cp failed"
1947 do_facet ost1 "$LCTL set_param fail_loc=0"
1949 do_facet ost1 "lctl get_param -n ost.OSS.ost_create.timeouts"
1950 CONN3=$(lctl get_param -n osc.*.stats | awk '/_connect/ {total+=$2} END {print total}')
1951 ATTEMPTS=$(($CONN3 - $CONN2))
1952 echo "$ATTEMPTS osc reconnect attempts on 2nd slow"
1953 [ $ATTEMPTS -gt 0 ] && error "AT should have prevented reconnect"
1956 run_test 67b "AT: verify instant slowdown doesn't induce reconnects"
1958 test_68 () #bug 13813
1960 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1962 at_start || return 0
1963 local ldlm_enqueue_min=$(find /sys -name ldlm_enqueue_min)
1964 [ -z "$ldlm_enqueue_min" ] && skip "missing /sys/.../ldlm_enqueue_min" && return 0
1965 local ldlm_enqueue_min_r=$(do_facet ost1 "find /sys -name ldlm_enqueue_min")
1966 [ -z "$ldlm_enqueue_min_r" ] && skip "missing /sys/.../ldlm_enqueue_min in the ost1" && return 0
1967 local ENQ_MIN=$(cat $ldlm_enqueue_min)
1968 local ENQ_MIN_R=$(do_facet ost1 "cat $ldlm_enqueue_min_r")
1969 echo $TIMEOUT >> $ldlm_enqueue_min
1970 do_facet ost1 "echo $TIMEOUT >> $ldlm_enqueue_min_r"
1972 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
1973 $SETSTRIPE --stripe-index=0 -c 1 $DIR/$tdir ||
1974 error "$SETSTRIPE failed for $DIR/$tdir"
1975 #define OBD_FAIL_LDLM_PAUSE_CANCEL 0x312
1976 $LCTL set_param fail_val=$(($TIMEOUT - 1))
1977 $LCTL set_param fail_loc=0x80000312
1978 cp /etc/profile $DIR/$tdir/${tfile}_1 || error "1st cp failed $?"
1979 $LCTL set_param fail_val=$((TIMEOUT * 5 / 4))
1980 $LCTL set_param fail_loc=0x80000312
1981 cp /etc/profile $DIR/$tdir/${tfile}_2 || error "2nd cp failed $?"
1982 $LCTL set_param fail_loc=0
1984 echo $ENQ_MIN >> $ldlm_enqueue_min
1985 do_facet ost1 "echo $ENQ_MIN_R >> $ldlm_enqueue_min_r"
1989 run_test 68 "AT: verify slowing locks"
1992 # end of AT tests includes above lines
1994 # start multi-client tests
1996 [ -z "$CLIENTS" ] &&
1997 { skip "Need two or more clients." && return; }
1998 [ $CLIENTCOUNT -lt 2 ] &&
1999 { skip "Need two or more clients, have $CLIENTCOUNT" && return; }
2001 echo "mount clients $CLIENTS ..."
2002 zconf_mount_clients $CLIENTS $MOUNT
2004 local clients=${CLIENTS//,/ }
2005 echo "Write/read files on $DIR ; clients $CLIENTS ... "
2006 for CLIENT in $clients; do
2007 do_node $CLIENT dd bs=1M count=10 if=/dev/zero \
2008 of=$DIR/${tfile}_${CLIENT} 2>/dev/null ||
2009 error "dd failed on $CLIENT"
2012 local prev_client=$(echo $clients | sed 's/^.* \(.\+\)$/\1/')
2013 for C in ${CLIENTS//,/ }; do
2014 do_node $prev_client dd if=$DIR/${tfile}_${C} \
2015 of=/dev/null 2>/dev/null ||
2016 error "dd if=$DIR/${tfile}_${C} failed on $prev_client"
2022 run_test 70a "check multi client t-f"
2024 check_for_process () {
2029 killall_process $clients "$prog" -0
2033 local clients=${CLIENTS:-$HOSTNAME}
2035 zconf_mount_clients $clients $MOUNT
2038 [ "$SLOW" = "no" ] && duration=120
2039 # set duration to 900 because it takes some time to boot node
2040 [ "$FAILURE_MODE" = HARD ] && duration=900
2043 local start_ts=$(date +%s)
2044 local cmd="rundbench 1 -t $duration"
2046 if [ $MDSCOUNT -ge 2 ]; then
2047 test_mkdir -p -c$MDSCOUNT $DIR/$tdir
2048 $LFS setdirstripe -D -c$MDSCOUNT $DIR/$tdir
2050 do_nodesv $clients "set -x; MISSING_DBENCH_OK=$MISSING_DBENCH_OK \
2051 PATH=\$PATH:$LUSTRE/utils:$LUSTRE/tests/:$DBENCH_LIB \
2052 DBENCH_LIB=$DBENCH_LIB TESTSUITE=$TESTSUITE TESTNAME=$TESTNAME \
2053 MOUNT=$MOUNT DIR=$DIR/$tdir/\\\$(hostname) LCTL=$LCTL $cmd" &
2056 #LU-1897 wait for all dbench copies to start
2057 while ! check_for_process $clients dbench; do
2058 elapsed=$(($(date +%s) - start_ts))
2059 if [ $elapsed -gt $duration ]; then
2060 killall_process $clients dbench
2061 error "dbench failed to start on $clients!"
2066 log "Started rundbench load pid=$pid ..."
2068 elapsed=$(($(date +%s) - start_ts))
2069 local num_failovers=0
2071 while [ $elapsed -lt $duration ]; do
2072 if ! check_for_process $clients dbench; then
2073 error_noexit "dbench stopped on some of $clients!"
2074 killall_process $clients dbench
2078 replay_barrier mds$fail_index
2079 sleep 1 # give clients a time to do operations
2080 # Increment the number of failovers
2081 num_failovers=$((num_failovers+1))
2082 log "$TESTNAME fail mds$fail_index $num_failovers times"
2084 elapsed=$(($(date +%s) - start_ts))
2085 if [ $fail_index -ge $MDSCOUNT ]; then
2088 fail_index=$((fail_index+1))
2092 wait $pid || error "rundbench load on $clients failed!"
2094 run_test 70b "dbench ${MDSCOUNT}mdts recovery; $CLIENTCOUNT clients"
2095 # end multi-client tests
2100 local monitor_pid=$3
2102 local start_ts=$(date +%s)
2103 local num_failovers=0
2106 elapsed=$(($(date +%s) - start_ts))
2107 while [ $elapsed -lt $duration ]; do
2108 fail_index=$((RANDOM%max_index+1))
2109 kill -0 $monitor_pid ||
2110 error "$monitor_pid stopped"
2112 replay_barrier mds$fail_index
2114 # Increment the number of failovers
2115 num_failovers=$((num_failovers+1))
2116 log "$TESTNAME fail mds$fail_index $num_failovers times"
2118 elapsed=$(($(date +%s) - start_ts))
2124 rm -f $DIR/replay-single.70c.lck
2129 local clients=${CLIENTS:-$HOSTNAME}
2132 zconf_mount_clients $clients $MOUNT
2135 [ "$SLOW" = "no" ] && duration=180
2136 # set duration to 900 because it takes some time to boot node
2137 [ "$FAILURE_MODE" = HARD ] && duration=600
2140 local start_ts=$(date +%s)
2142 trap cleanup_70c EXIT
2144 while [ ! -e $DIR/replay-single.70c.lck ]; do
2145 test_mkdir -p -c$MDSCOUNT $DIR/$tdir || break
2146 if [ $MDSCOUNT -ge 2 ]; then
2147 $LFS setdirstripe -D -c$MDSCOUNT $DIR/$tdir ||
2148 error "set default dirstripe failed"
2150 cd $DIR/$tdir || break
2151 tar cf - /etc | tar xf - || error "tar failed in loop"
2155 echo "Started tar $tar_70c_pid"
2157 random_fail_mdt $MDSCOUNT $duration $tar_70c_pid
2158 kill -0 $tar_70c_pid || error "tar $tar_70c_pid stopped"
2160 touch $DIR/replay-single.70c.lck
2161 wait $tar_70c_pid || error "$?: tar failed"
2166 run_test 70c "tar ${MDSCOUNT}mdts recovery"
2170 kill -9 $mkdir_70d_pid
2174 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2175 local clients=${CLIENTS:-$HOSTNAME}
2178 zconf_mount_clients $clients $MOUNT
2181 [ "$SLOW" = "no" ] && duration=180
2182 # set duration to 900 because it takes some time to boot node
2183 [ "$FAILURE_MODE" = HARD ] && duration=900
2188 local start_ts=$(date +%s)
2190 trap cleanup_70d EXIT
2193 $LFS mkdir -i0 -c2 $DIR/$tdir/test || {
2197 $LFS mkdir -i1 -c2 $DIR/$tdir/test1 || {
2202 touch $DIR/$tdir/test/a || {
2206 mkdir $DIR/$tdir/test/b || {
2210 rm -rf $DIR/$tdir/test || {
2215 touch $DIR/$tdir/test1/a || {
2219 mkdir $DIR/$tdir/test1/b || {
2224 rm -rf $DIR/$tdir/test1 || {
2231 echo "Started $mkdir_70d_pid"
2233 random_fail_mdt $MDSCOUNT $duration $mkdir_70d_pid
2234 kill -0 $mkdir_70d_pid || error "mkdir/rmdir $mkdir_70d_pid stopped"
2239 run_test 70d "mkdir/rmdir striped dir ${MDSCOUNT}mdts recovery"
2243 kill -9 $rename_70e_pid
2247 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2248 local clients=${CLIENTS:-$HOSTNAME}
2251 echo ha > /proc/sys/lnet/debug
2252 zconf_mount_clients $clients $MOUNT
2255 [ "$SLOW" = "no" ] && duration=180
2256 # set duration to 900 because it takes some time to boot node
2257 [ "$FAILURE_MODE" = HARD ] && duration=900
2260 $LFS mkdir -i0 $DIR/$tdir/test_0
2261 $LFS mkdir -i0 $DIR/$tdir/test_1
2262 touch $DIR/$tdir/test_0/a
2263 touch $DIR/$tdir/test_1/b
2264 trap cleanup_70e EXIT
2267 mrename $DIR/$tdir/test_0/a $DIR/$tdir/test_1/b > \
2273 checkstat $DIR/$tdir/test_0/a && {
2274 echo "a still exists"
2278 checkstat $DIR/$tdir/test_1/b || {
2279 echo "b still exists"
2283 touch $DIR/$tdir/test_0/a || {
2284 echo "touch a fails"
2288 mrename $DIR/$tdir/test_1/b $DIR/$tdir/test_0/a > \
2296 echo "Started $rename_70e_pid"
2298 random_fail_mdt 2 $duration $rename_70e_pid
2299 kill -0 $rename_70e_pid || error "rename $rename_70e_pid stopped"
2304 run_test 70e "rename cross-MDT with random fails"
2306 test_70f_write_and_read(){
2311 echo "Write/read files in: '$DIR/$tdir', clients: '$CLIENTS' ..."
2312 for client in ${CLIENTS//,/ }; do
2313 [ -f $stopflag ] || return
2315 local tgtfile=$DIR/$tdir/$tfile.$client
2316 do_node $client dd $DD_OPTS bs=1M count=10 if=$srcfile \
2317 of=$tgtfile 2>/dev/null ||
2318 error "dd $DD_OPTS bs=1M count=10 if=$srcfile " \
2319 "of=$tgtfile failed on $client, rc=$?"
2322 local prev_client=$(echo ${CLIENTS//,/ } | awk '{ print $NF }')
2325 for client in ${CLIENTS//,/ }; do
2326 [ -f $stopflag ] || return
2328 # flush client cache in case test is running on only one client
2329 # do_node $client cancel_lru_locks osc
2330 do_node $client $LCTL set_param ldlm.namespaces.*.lru_size=clear
2332 tgtfile=$DIR/$tdir/$tfile.$client
2333 local md5=$(do_node $prev_client "md5sum $tgtfile")
2334 [ ${checksum[$index]// */} = ${md5// */} ] ||
2335 error "$tgtfile: checksum doesn't match on $prev_client"
2336 index=$((index + 1))
2346 mkdir -p $DIR/$tdir || error "cannot create $DIR/$tdir directory"
2347 $SETSTRIPE -c -1 $DIR/$tdir || error "cannot $SETSTRIPE $DIR/$tdir"
2350 while [ -f $stopflag ]; do
2351 test_70f_write_and_read $srcfile $stopflag
2352 # use direct IO and buffer cache in turns if loop
2353 [ -n "$DD_OPTS" ] && DD_OPTS="" || DD_OPTS="oflag=direct"
2357 test_70f_cleanup() {
2359 rm -f $TMP/$tfile.stop
2360 do_nodes $CLIENTS rm -f $TMP/$tfile
2361 rm -f $DIR/$tdir/$tfile.*
2365 # [ x$ost1failover_HOST = x$ost_HOST ] &&
2366 # { skip "Failover host not defined" && return; }
2367 # [ -z "$CLIENTS" ] &&
2368 # { skip "CLIENTS are not specified." && return; }
2369 # [ $CLIENTCOUNT -lt 2 ] &&
2370 # { skip "Need 2 or more clients, have $CLIENTCOUNT" && return; }
2372 [[ $(lustre_version_code ost1) -lt $(version_code 2.9.53) ]] &&
2373 skip "Need server version at least 2.9.53" && return
2375 echo "mount clients $CLIENTS ..."
2376 zconf_mount_clients $CLIENTS $MOUNT
2378 local srcfile=$TMP/$tfile
2382 trap test_70f_cleanup EXIT
2383 # create a different source file local to each client node so we can
2384 # detect if the file wasn't written out properly after failover
2385 do_nodes $CLIENTS dd bs=1M count=10 if=/dev/urandom of=$srcfile \
2386 2>/dev/null || error "can't create $srcfile on $CLIENTS"
2387 for client in ${CLIENTS//,/ }; do
2388 checksum[$index]=$(do_node $client "md5sum $srcfile")
2389 index=$((index + 1))
2393 [ "$SLOW" = "no" ] && duration=60
2394 # set duration to 900 because it takes some time to boot node
2395 [ "$FAILURE_MODE" = HARD ] && duration=900
2397 local stopflag=$TMP/$tfile.stop
2398 test_70f_loop $srcfile $stopflag &
2402 local num_failovers=0
2403 local start_ts=$SECONDS
2404 while [ $elapsed -lt $duration ]; do
2408 num_failovers=$((num_failovers + 1))
2409 log "$TESTNAME failing OST $num_failovers times"
2412 elapsed=$((SECONDS - start_ts))
2419 run_test 70f "OSS O_DIRECT recovery with $CLIENTCOUNT clients"
2423 kill -9 $mkdir_71a_pid
2426 random_double_fail_mdt() {
2429 local monitor_pid=$3
2431 local start_ts=$(date +%s)
2432 local num_failovers=0
2436 elapsed=$(($(date +%s) - start_ts))
2437 while [ $elapsed -lt $duration ]; do
2438 fail_index=$((RANDOM%max_index + 1))
2439 if [ $fail_index -eq $max_index ]; then
2442 second_index=$((fail_index + 1))
2444 kill -0 $monitor_pid ||
2445 error "$monitor_pid stopped"
2447 replay_barrier mds$fail_index
2448 replay_barrier mds$second_index
2450 # Increment the number of failovers
2451 num_failovers=$((num_failovers+1))
2452 log "fail mds$fail_index mds$second_index $num_failovers times"
2453 fail mds${fail_index},mds${second_index}
2454 elapsed=$(($(date +%s) - start_ts))
2459 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2460 local clients=${CLIENTS:-$HOSTNAME}
2463 zconf_mount_clients $clients $MOUNT
2466 [ "$SLOW" = "no" ] && duration=180
2467 # set duration to 900 because it takes some time to boot node
2468 [ "$FAILURE_MODE" = HARD ] && duration=900
2473 local start_ts=$(date +%s)
2475 trap cleanup_71a EXIT
2478 $LFS mkdir -i0 -c2 $DIR/$tdir/test
2479 rmdir $DIR/$tdir/test
2483 echo "Started $mkdir_71a_pid"
2485 random_double_fail_mdt 2 $duration $mkdir_71a_pid
2486 kill -0 $mkdir_71a_pid || error "mkdir/rmdir $mkdir_71a_pid stopped"
2491 run_test 71a "mkdir/rmdir striped dir with 2 mdts recovery"
2494 multiop_bg_pause $DIR/$tfile O_tSc ||
2495 error "multiop_bg_pause $DIR/$tfile failed"
2499 replay_barrier $SINGLEMDS
2500 #define OBD_FAIL_LDLM_ENQUEUE_NET 0x302
2501 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000302"
2504 wait $pid || error "multiop pid failed"
2505 [ -e $DIR/$tfile ] && error "file $DIR/$tfile should not exist"
2508 run_test 73a "open(O_CREAT), unlink, replay, reconnect before open replay, close"
2511 multiop_bg_pause $DIR/$tfile O_tSc ||
2512 error "multiop_bg_pause $DIR/$tfile failed"
2516 replay_barrier $SINGLEMDS
2517 #define OBD_FAIL_LDLM_REPLY 0x30c
2518 do_facet $SINGLEMDS "lctl set_param fail_loc=0x8000030c"
2521 wait $pid || error "multiop pid failed"
2522 [ -e $DIR/$tfile ] && error "file $DIR/$tfile should not exist"
2525 run_test 73b "open(O_CREAT), unlink, replay, reconnect at open_replay reply, close"
2529 local clients=${CLIENTS:-$HOSTNAME}
2531 zconf_umount_clients $clients $MOUNT
2533 facet_failover $SINGLEMDS
2534 zconf_mount_clients $clients $MOUNT
2536 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
2537 rm $DIR/$tfile || error "rm $DIR/$tfile failed"
2538 clients_up || error "client evicted: $?"
2541 run_test 74 "Ensure applications don't fail waiting for OST recovery"
2543 remote_dir_check_80() {
2548 diridx=$($GETSTRIPE -M $remote_dir) ||
2549 error "$GETSTRIPE -M $remote_dir failed"
2550 [ $diridx -eq $MDTIDX ] || error "$diridx != $MDTIDX"
2552 createmany -o $remote_dir/f-%d 20 || error "creation failed"
2553 fileidx=$($GETSTRIPE -M $remote_dir/f-1) ||
2554 error "$GETSTRIPE -M $remote_dir/f-1 failed"
2555 [ $fileidx -eq $MDTIDX ] || error "$fileidx != $MDTIDX"
2561 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2562 ([ $FAILURE_MODE == "HARD" ] &&
2563 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
2564 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
2568 local remote_dir=$DIR/$tdir/remote_dir
2570 mkdir -p $DIR/$tdir || error "mkdir $DIR/$tdir failed"
2571 #define OBD_FAIL_OUT_UPDATE_NET_REP 0x1701
2572 do_facet mds${MDTIDX} lctl set_param fail_loc=0x1701
2573 $LFS mkdir -i $MDTIDX $remote_dir &
2579 wait $CLIENT_PID || error "remote creation failed"
2581 remote_dir_check_80 || error "remote dir check failed"
2582 rm -rf $DIR/$tdir || error "rmdir failed"
2586 run_test 80a "DNE: create remote dir, drop update rep from MDT0, fail MDT0"
2589 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2590 ([ $FAILURE_MODE == "HARD" ] &&
2591 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
2592 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
2596 local remote_dir=$DIR/$tdir/remote_dir
2598 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
2599 #define OBD_FAIL_UPDATE_OBJ_NET_REP 0x1701
2600 do_facet mds${MDTIDX} lctl set_param fail_loc=0x1701
2601 $LFS mkdir -i $MDTIDX $remote_dir &
2606 fail mds$((MDTIDX + 1))
2608 wait $CLIENT_PID || error "remote creation failed"
2610 remote_dir_check_80 || error "remote dir check failed"
2611 rm -rf $DIR/$tdir || error "rmdir failed"
2615 run_test 80b "DNE: create remote dir, drop update rep from MDT0, fail MDT1"
2618 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2619 ([ $FAILURE_MODE == "HARD" ] &&
2620 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
2621 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
2625 local remote_dir=$DIR/$tdir/remote_dir
2627 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
2628 #define OBD_FAIL_UPDATE_OBJ_NET_REP 0x1701
2629 do_facet mds${MDTIDX} lctl set_param fail_loc=0x1701
2630 $LFS mkdir -i $MDTIDX $remote_dir &
2636 fail mds$((MDTIDX + 1))
2638 wait $CLIENT_PID || error "remote creation failed"
2640 remote_dir_check_80 || error "remote dir check failed"
2641 rm -rf $DIR/$tdir || error "rmdir failed"
2645 run_test 80c "DNE: create remote dir, drop update rep from MDT1, fail MDT[0,1]"
2648 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2650 local remote_dir=$DIR/$tdir/remote_dir
2652 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
2653 #define OBD_FAIL_UPDATE_OBJ_NET_REP 0x1701
2654 do_facet mds${MDTIDX} lctl set_param fail_loc=0x1701
2655 $LFS mkdir -i $MDTIDX $remote_dir &
2658 # sleep 3 seconds to make sure MDTs are failed after
2659 # lfs mkdir -i has finished on all of MDTs.
2664 fail mds${MDTIDX},mds$((MDTIDX + 1))
2666 wait $CLIENT_PID || error "remote creation failed"
2668 remote_dir_check_80 || error "remote dir check failed"
2669 rm -rf $DIR/$tdir || error "rmdir failed"
2673 run_test 80d "DNE: create remote dir, drop update rep from MDT1, fail 2 MDTs"
2676 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2677 ([ $FAILURE_MODE == "HARD" ] &&
2678 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
2679 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
2683 local remote_dir=$DIR/$tdir/remote_dir
2685 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
2686 # OBD_FAIL_MDS_REINT_NET_REP 0x119
2687 do_facet mds$((MDTIDX + 1)) lctl set_param fail_loc=0x119
2688 $LFS mkdir -i $MDTIDX $remote_dir &
2691 # sleep 3 seconds to make sure MDTs are failed after
2692 # lfs mkdir -i has finished on all of MDTs.
2698 wait $CLIENT_PID || error "remote creation failed"
2700 remote_dir_check_80 || error "remote dir check failed"
2701 rm -rf $DIR/$tdir || error "rmdir failed"
2705 run_test 80e "DNE: create remote dir, drop MDT1 rep, fail MDT0"
2708 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2709 ([ $FAILURE_MODE == "HARD" ] &&
2710 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
2711 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
2714 local remote_dir=$DIR/$tdir/remote_dir
2716 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
2717 # OBD_FAIL_MDS_REINT_NET_REP 0x119
2718 do_facet mds$((MDTIDX + 1)) lctl set_param fail_loc=0x119
2719 $LFS mkdir -i $MDTIDX $remote_dir &
2723 fail mds$((MDTIDX + 1))
2725 wait $CLIENT_PID || error "remote creation failed"
2727 remote_dir_check_80 || error "remote dir check failed"
2728 rm -rf $DIR/$tdir || error "rmdir failed"
2732 run_test 80f "DNE: create remote dir, drop MDT1 rep, fail MDT1"
2735 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2736 ([ $FAILURE_MODE == "HARD" ] &&
2737 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
2738 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
2742 local remote_dir=$DIR/$tdir/remote_dir
2744 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
2745 # OBD_FAIL_MDS_REINT_NET_REP 0x119
2746 do_facet mds$((MDTIDX + 1)) lctl set_param fail_loc=0x119
2747 $LFS mkdir -i $MDTIDX $remote_dir &
2750 # sleep 3 seconds to make sure MDTs are failed after
2751 # lfs mkdir -i has finished on all of MDTs.
2757 fail mds$((MDTIDX + 1))
2759 wait $CLIENT_PID || error "remote creation failed"
2761 remote_dir_check_80 || error "remote dir check failed"
2762 rm -rf $DIR/$tdir || error "rmdir failed"
2766 run_test 80g "DNE: create remote dir, drop MDT1 rep, fail MDT0, then MDT1"
2769 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2771 local remote_dir=$DIR/$tdir/remote_dir
2773 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
2774 # OBD_FAIL_MDS_REINT_NET_REP 0x119
2775 do_facet mds$((MDTIDX + 1)) lctl set_param fail_loc=0x119
2776 $LFS mkdir -i $MDTIDX $remote_dir &
2779 # sleep 3 seconds to make sure MDTs are failed after
2780 # lfs mkdir -i has finished on all of MDTs.
2785 fail mds${MDTIDX},mds$((MDTIDX + 1))
2787 wait $CLIENT_PID || error "remote dir creation failed"
2789 remote_dir_check_80 || error "remote dir check failed"
2790 rm -rf $DIR/$tdir || error "rmdir failed"
2794 run_test 80h "DNE: create remote dir, drop MDT1 rep, fail 2 MDTs"
2797 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2798 ([ $FAILURE_MODE == "HARD" ] &&
2799 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
2800 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
2804 local remote_dir=$DIR/$tdir/remote_dir
2806 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
2807 $LFS mkdir -i $MDTIDX $remote_dir || error "lfs mkdir failed"
2809 touch $remote_dir || error "touch $remote_dir failed"
2810 # OBD_FAIL_OBJ_UPDATE_NET_REP 0x1701
2811 do_facet mds${MDTIDX} lctl set_param fail_loc=0x1701
2816 fail mds$((MDTIDX + 1))
2818 wait $CLIENT_PID || error "rm remote dir failed"
2820 stat $remote_dir &>/dev/null && error "$remote_dir still exist!"
2822 rm -rf $DIR/$tdir || error "rmdir failed"
2826 run_test 81a "DNE: unlink remote dir, drop MDT0 update rep, fail MDT1"
2829 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2830 ([ $FAILURE_MODE == "HARD" ] &&
2831 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
2832 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
2835 local remote_dir=$DIR/$tdir/remote_dir
2837 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
2838 $LFS mkdir -i $MDTIDX $remote_dir || error "lfs mkdir failed"
2840 # OBD_FAIL_OBJ_UPDATE_NET_REP 0x1701
2841 do_facet mds${MDTIDX} lctl set_param fail_loc=0x1701
2848 wait $CLIENT_PID || error "rm remote dir failed"
2850 stat $remote_dir &>/dev/null && error "$remote_dir still exist!"
2852 rm -rf $DIR/$tdir || error "rmdir failed"
2856 run_test 81b "DNE: unlink remote dir, drop MDT0 update reply, fail MDT0"
2859 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2860 ([ $FAILURE_MODE == "HARD" ] &&
2861 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
2862 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
2866 local remote_dir=$DIR/$tdir/remote_dir
2868 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
2869 $LFS mkdir -i $MDTIDX $remote_dir || error "lfs mkdir failed"
2871 # OBD_FAIL_OBJ_UPDATE_NET_REP 0x1701
2872 do_facet mds${MDTIDX} lctl set_param fail_loc=0x1701
2879 fail mds$((MDTIDX + 1))
2881 wait $CLIENT_PID || error "rm remote dir failed"
2883 stat $remote_dir &>/dev/null && error "$remote_dir still exist!"
2885 rm -rf $DIR/$tdir || error "rmdir failed"
2889 run_test 81c "DNE: unlink remote dir, drop MDT0 update reply, fail MDT0,MDT1"
2892 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2894 local remote_dir=$DIR/$tdir/remote_dir
2896 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
2897 $LFS mkdir -i $MDTIDX $remote_dir || error "lfs mkdir failed"
2899 # OBD_FAIL_OBJ_UPDATE_NET_REP 0x1701
2900 do_facet mds${MDTIDX} lctl set_param fail_loc=0x1701
2906 fail mds${MDTIDX},mds$((MDTIDX + 1))
2908 wait $CLIENT_PID || error "rm remote dir failed"
2910 stat $remote_dir &>/dev/null && error "$remote_dir still exist!"
2912 rm -rf $DIR/$tdir || error "rmdir failed"
2916 run_test 81d "DNE: unlink remote dir, drop MDT0 update reply, fail 2 MDTs"
2919 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2920 ([ $FAILURE_MODE == "HARD" ] &&
2921 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
2922 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
2926 local remote_dir=$DIR/$tdir/remote_dir
2928 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
2929 $LFS mkdir -i $MDTIDX $remote_dir || error "lfs mkdir failed"
2931 # OBD_FAIL_MDS_REINT_NET_REP 0x119
2932 do_facet mds$((MDTIDX + 1)) lctl set_param fail_loc=0x119
2935 do_facet mds$((MDTIDX + 1)) lctl set_param fail_loc=0
2940 wait $CLIENT_PID || error "rm remote dir failed"
2942 stat $remote_dir &>/dev/null && error "$remote_dir still exist!"
2944 rm -rf $DIR/$tdir || error "rmdir failed"
2948 run_test 81e "DNE: unlink remote dir, drop MDT1 req reply, fail MDT0"
2951 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2952 ([ $FAILURE_MODE == "HARD" ] &&
2953 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
2954 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
2958 local remote_dir=$DIR/$tdir/remote_dir
2960 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
2961 $LFS mkdir -i $MDTIDX $remote_dir || error "lfs mkdir failed"
2963 # OBD_FAIL_MDS_REINT_NET_REP 0x119
2964 do_facet mds$((MDTIDX + 1)) lctl set_param fail_loc=0x119
2969 fail mds$((MDTIDX + 1))
2971 wait $CLIENT_PID || error "rm remote dir failed"
2973 stat $remote_dir &>/dev/null && error "$remote_dir still exist!"
2975 rm -rf $DIR/$tdir || error "rmdir failed"
2979 run_test 81f "DNE: unlink remote dir, drop MDT1 req reply, fail MDT1"
2982 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2983 ([ $FAILURE_MODE == "HARD" ] &&
2984 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
2985 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
2989 local remote_dir=$DIR/$tdir/remote_dir
2991 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
2992 $LFS mkdir -i $MDTIDX $remote_dir || error "lfs mkdir failed"
2994 # OBD_FAIL_MDS_REINT_NET_REP 0x119
2995 do_facet mds$((MDTIDX + 1)) lctl set_param fail_loc=0x119
3002 fail mds$((MDTIDX + 1))
3004 wait $CLIENT_PID || error "rm remote dir failed"
3006 stat $remote_dir &>/dev/null && error "$remote_dir still exist!"
3008 rm -rf $DIR/$tdir || error "rmdir failed"
3012 run_test 81g "DNE: unlink remote dir, drop req reply, fail M0, then M1"
3015 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
3017 local remote_dir=$DIR/$tdir/remote_dir
3019 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
3020 $LFS mkdir -i $MDTIDX $remote_dir || error "lfs mkdir failed"
3022 # OBD_FAIL_MDS_REINT_NET_REP 0x119
3023 do_facet mds$((MDTIDX + 1)) lctl set_param fail_loc=0x119
3029 fail mds${MDTIDX},mds$((MDTIDX + 1))
3031 wait $CLIENT_PID || error "rm remote dir failed"
3033 stat $remote_dir &>/dev/null && error "$remote_dir still exist!"
3035 rm -rf $DIR/$tdir || error "rmdir failed"
3039 run_test 81h "DNE: unlink remote dir, drop request reply, fail 2 MDTs"
3042 #define OBD_FAIL_MDS_OPEN_WAIT_CREATE 0x144
3043 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000144"
3044 createmany -o $DIR/$tfile- 1 &
3048 client_up || client_up || true # reconnect
3050 run_test 84a "stale open during export disconnect"
3052 test_85a() { #bug 16774
3053 lctl set_param -n ldlm.cancel_unused_locks_before_replay "1"
3055 for i in $(seq 100); do
3056 echo "tag-$i" > $DIR/$tfile-$i
3057 grep -q "tag-$i" $DIR/$tfile-$i || error "f2-$i"
3060 lov_id=$(lctl dl | grep "clilov")
3061 addr=$(echo $lov_id | awk '{print $4}' | awk -F '-' '{print $NF}')
3062 count=$(lctl get_param -n \
3063 ldlm.namespaces.*MDT0000*$addr.lock_unused_count)
3064 echo "before recovery: unused locks count = $count"
3068 count2=$(lctl get_param -n \
3069 ldlm.namespaces.*MDT0000*$addr.lock_unused_count)
3070 echo "after recovery: unused locks count = $count2"
3072 if [ $count2 -ge $count ]; then
3073 error "unused locks are not canceled"
3076 run_test 85a "check the cancellation of unused locks during recovery(IBITS)"
3078 test_85b() { #bug 16774
3079 lctl set_param -n ldlm.cancel_unused_locks_before_replay "1"
3081 if ! combined_mgs_mds ; then
3085 create_pool $FSNAME.$TESTNAME ||
3086 error "unable to create pool $TESTNAME"
3087 do_facet mgs $LCTL pool_add $FSNAME.$TESTNAME $FSNAME-OST0000 ||
3088 error "unable to add pool $TESTNAME"
3090 $SETSTRIPE -c 1 -p $FSNAME.$TESTNAME $DIR
3092 for i in $(seq 100); do
3093 dd if=/dev/urandom of=$DIR/$tfile-$i bs=4096 \
3094 count=32 >/dev/null 2>&1
3097 cancel_lru_locks osc
3099 for i in $(seq 100); do
3100 dd if=$DIR/$tfile-$i of=/dev/null bs=4096 \
3101 count=32 >/dev/null 2>&1
3104 lov_id=$(lctl dl | grep "clilov")
3105 addr=$(echo $lov_id | awk '{print $4}' | awk -F '-' '{print $NF}')
3106 count=$(lctl get_param -n \
3107 ldlm.namespaces.*OST0000*$addr.lock_unused_count)
3108 echo "before recovery: unused locks count = $count"
3109 [ $count -ne 0 ] || error "unused locks ($count) should be zero"
3113 count2=$(lctl get_param \
3114 -n ldlm.namespaces.*OST0000*$addr.lock_unused_count)
3115 echo "after recovery: unused locks count = $count2"
3117 do_facet mgs $LCTL pool_remove $FSNAME.$TESTNAME $FSNAME-OST0000 ||
3118 error "unable to remove pool $TESTNAME"
3119 do_facet mgs $LCTL pool_destroy $FSNAME.$TESTNAME ||
3120 error "unable to destroy the pool $TESTNAME"
3122 if ! combined_mgs_mds ; then
3126 if [ $count2 -ge $count ]; then
3127 error "unused locks are not canceled"
3130 run_test 85b "check the cancellation of unused locks during recovery(EXTENT)"
3133 local clients=${CLIENTS:-$HOSTNAME}
3135 zconf_umount_clients $clients $MOUNT
3136 do_facet $SINGLEMDS lctl set_param mdt.${FSNAME}-MDT*.exports.clear=0
3137 remount_facet $SINGLEMDS
3138 zconf_mount_clients $clients $MOUNT
3140 run_test 86 "umount server after clear nid_stats should not hit LBUG"
3143 do_facet ost1 "lctl set_param -n obdfilter.${ost1_svc}.sync_journal 0"
3146 $SETSTRIPE -i 0 -c 1 $DIR/$tfile
3147 dd if=/dev/urandom of=$DIR/$tfile bs=1024k count=8 ||
3148 error "dd to $DIR/$tfile failed"
3149 cksum=$(md5sum $DIR/$tfile | awk '{print $1}')
3150 cancel_lru_locks osc
3152 dd if=$DIR/$tfile of=/dev/null bs=1024k count=8 || error "Cannot read"
3153 cksum2=$(md5sum $DIR/$tfile | awk '{print $1}')
3154 if [ $cksum != $cksum2 ] ; then
3155 error "New checksum $cksum2 does not match original $cksum"
3158 run_test 87a "write replay"
3161 do_facet ost1 "lctl set_param -n obdfilter.${ost1_svc}.sync_journal 0"
3164 $SETSTRIPE -i 0 -c 1 $DIR/$tfile
3165 dd if=/dev/urandom of=$DIR/$tfile bs=1024k count=8 ||
3166 error "dd to $DIR/$tfile failed"
3167 sleep 1 # Give it a chance to flush dirty data
3168 echo TESTTEST | dd of=$DIR/$tfile bs=1 count=8 seek=64
3169 cksum=$(md5sum $DIR/$tfile | awk '{print $1}')
3170 cancel_lru_locks osc
3172 dd if=$DIR/$tfile of=/dev/null bs=1024k count=8 || error "Cannot read"
3173 cksum2=$(md5sum $DIR/$tfile | awk '{print $1}')
3174 if [ $cksum != $cksum2 ] ; then
3175 error "New checksum $cksum2 does not match original $cksum"
3178 run_test 87b "write replay with changed data (checksum resend)"
3180 test_88() { #bug 17485
3181 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
3182 mkdir -p $TMP/$tdir || error "mkdir $TMP/$tdir failed"
3184 $SETSTRIPE -i 0 -c 1 $DIR/$tdir || error "$SETSTRIPE"
3187 replay_barrier $SINGLEMDS
3189 # exhaust precreations on ost1
3190 local OST=$(ostname_from_index 0)
3191 local mdtosc=$(get_mdtosc_proc_path $SINGLEMDS $OST)
3192 local last_id=$(do_facet $SINGLEMDS lctl get_param -n osc.$mdtosc.prealloc_last_id)
3193 local next_id=$(do_facet $SINGLEMDS lctl get_param -n osc.$mdtosc.prealloc_next_id)
3194 echo "before test: last_id = $last_id, next_id = $next_id"
3196 echo "Creating to objid $last_id on ost $OST..."
3197 createmany -o $DIR/$tdir/f-%d $next_id $((last_id - next_id + 2)) ||
3198 error "createmany create files to last_id failed"
3200 #create some files to use some uncommitted objids
3201 last_id=$(($last_id + 1))
3202 createmany -o $DIR/$tdir/f-%d $last_id 8 ||
3203 error "createmany create files with uncommitted objids failed"
3205 last_id2=$(do_facet $SINGLEMDS lctl get_param -n osc.$mdtosc.prealloc_last_id)
3206 next_id2=$(do_facet $SINGLEMDS lctl get_param -n osc.$mdtosc.prealloc_next_id)
3207 echo "before recovery: last_id = $last_id2, next_id = $next_id2"
3209 # if test uses shutdown_facet && reboot_facet instead of facet_failover ()
3210 # it has to take care about the affected facets, bug20407
3211 local affected_mds1=$(affected_facets mds1)
3212 local affected_ost1=$(affected_facets ost1)
3214 shutdown_facet $SINGLEMDS
3217 reboot_facet $SINGLEMDS
3218 change_active $affected_mds1
3219 wait_for_facet $affected_mds1
3220 mount_facets $affected_mds1 || error "Restart of mds failed"
3223 change_active $affected_ost1
3224 wait_for_facet $affected_ost1
3225 mount_facets $affected_ost1 || error "Restart of ost1 failed"
3229 last_id2=$(do_facet $SINGLEMDS lctl get_param -n osc.$mdtosc.prealloc_last_id)
3230 next_id2=$(do_facet $SINGLEMDS lctl get_param -n osc.$mdtosc.prealloc_next_id)
3231 echo "after recovery: last_id = $last_id2, next_id = $next_id2"
3233 # create new files, which should use new objids, and ensure the orphan
3234 # cleanup phase for ost1 is completed at the same time
3235 for i in $(seq 8); do
3236 file_id=$(($last_id + 10 + $i))
3237 dd if=/dev/urandom of=$DIR/$tdir/f-$file_id bs=4096 count=128
3240 # if the objids were not recreated, then "ls" will fail with -ENOENT
3241 ls -l $DIR/$tdir/* || error "can't get the status of precreated files"
3244 # write into previously created files
3245 for i in $(seq 8); do
3246 file_id=$(($last_id + $i))
3247 dd if=/dev/urandom of=$DIR/$tdir/f-$file_id bs=4096 count=128
3248 cp -f $DIR/$tdir/f-$file_id $TMP/$tdir/
3251 # compare the content
3252 for i in $(seq 8); do
3253 file_id=$(($last_id + $i))
3254 cmp $TMP/$tdir/f-$file_id $DIR/$tdir/f-$file_id ||
3255 error "the content of file is modified!"
3260 run_test 88 "MDS should not assign same objid to different files "
3263 cancel_lru_locks osc
3264 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
3265 rm -f $DIR/$tdir/$tfile
3267 wait_delete_completed
3268 BLOCKS1=$(df -P $MOUNT | tail -n 1 | awk '{ print $3 }')
3269 $SETSTRIPE -i 0 -c 1 $DIR/$tdir/$tfile
3270 dd if=/dev/zero bs=1M count=10 of=$DIR/$tdir/$tfile
3273 facet_failover $SINGLEMDS
3274 rm $DIR/$tdir/$tfile
3277 zconf_mount $(hostname) $MOUNT || error "mount fails"
3278 client_up || error "client_up failed"
3280 wait_delete_completed
3281 BLOCKS2=$(df -P $MOUNT | tail -n 1 | awk '{ print $3 }')
3282 [ $((BLOCKS2 - BLOCKS1)) -le 4 ] ||
3283 error $((BLOCKS2 - BLOCKS1)) blocks leaked
3286 run_test 89 "no disk space leak on late ost connection"
3292 change_active $facet
3293 wait_for_facet $facet
3294 mount_facet $facet || error "Restart of $facet failed"
3298 test_90() { # bug 19494
3299 local dir=$DIR/$tdir
3300 local ostfail=$(get_random_entry $(get_facets OST))
3302 if [[ $FAILURE_MODE = HARD ]]; then
3303 local affected=$(affected_facets $ostfail);
3304 if [[ "$affected" != $ostfail ]]; then
3305 skip not functional with FAILURE_MODE=$FAILURE_MODE, affected: $affected
3309 # ensure all OSTs are active to allow allocations
3312 mkdir $dir || error "mkdir $dir failed"
3314 echo "Create the files"
3316 # file "f${index}" striped over 1 OST
3317 # file "all" striped over all OSTs
3319 $SETSTRIPE -c $OSTCOUNT $dir/all ||
3320 error "setstripe failed to create $dir/all"
3322 for (( i=0; i<$OSTCOUNT; i++ )); do
3324 $SETSTRIPE -i $i -c 1 $f || error "$SETSTRIPE failed to create $f"
3326 # confirm setstripe actually created the stripe on the requested OST
3327 local uuid=$(ostuuid_from_index $i)
3328 for file in f$i all; do
3329 if [[ $dir/$file != $($LFS find --obd $uuid --name $file $dir) ]]; then
3330 $GETSTRIPE $dir/$file
3331 error wrong stripe: $file, uuid: $uuid
3336 # Before failing an OST, get its obd name and index
3337 local varsvc=${ostfail}_svc
3338 local obd=$(do_facet $ostfail lctl get_param \
3339 -n obdfilter.${!varsvc}.uuid)
3340 local index=$(($(facet_number $ostfail) - 1))
3342 echo "Fail $ostfail $obd, display the list of affected files"
3343 shutdown_facet $ostfail || error "shutdown_facet $ostfail failed"
3345 trap "cleanup_90 $ostfail" EXIT INT
3346 echo "General Query: lfs find $dir"
3347 local list=$($LFS find $dir)
3349 for (( i=0; i<$OSTCOUNT; i++ )); do
3350 list_member "$list" $dir/f$i ||
3351 error_noexit "lfs find $dir: no file f$i"
3353 list_member "$list" $dir/all ||
3354 error_noexit "lfs find $dir: no file all"
3356 # focus on the missing OST,
3357 # we expect to see only two files affected: "f$(index)" and "all"
3359 echo "Querying files on shutdown $ostfail: lfs find --obd $obd"
3360 list=$($LFS find --obd $obd $dir)
3362 for file in all f$index; do
3363 list_member "$list" $dir/$file ||
3364 error_noexit "lfs find does not report the affected $obd for $file"
3367 [[ $(echo $list | wc -w) -eq 2 ]] ||
3368 error_noexit "lfs find reports the wrong list of affected files ${#list[@]}"
3370 echo "Check getstripe: $GETSTRIPE -r --obd $obd"
3371 list=$($GETSTRIPE -r --obd $obd $dir)
3373 for file in all f$index; do
3374 echo "$list" | grep $dir/$file ||
3375 error_noexit "lfs getsripe does not report the affected $obd for $file"
3380 run_test 90 "lfs find identifies the missing striped file segments"
3383 local server_version=$(lustre_version_code $SINGLEMDS)
3384 [[ $server_version -ge $(version_code 2.6.90) ]] ||
3385 [[ $server_version -ge $(version_code 2.5.4) &&
3386 $server_version -lt $(version_code 2.5.50) ]] ||
3387 { skip "Need MDS version 2.5.4+ or 2.6.90+"; return; }
3389 cancel_lru_locks osc
3391 $SETSTRIPE -i 0 -c 1 $DIR/$tfile ||
3392 error "$SETSTRIPE $DIR/$tfile failed"
3393 dd if=/dev/zero of=$DIR/$tfile bs=1024 count=1 ||
3394 error "dd to $DIR/$tfile failed"
3395 #define OBD_FAIL_TGT_REPLAY_RECONNECT 0x715
3396 # We need to emulate a state that OST is waiting for other clients
3397 # not completing the recovery. Final ping is queued, but reply will be
3398 # sent on the recovery completion. It is done by sleep before
3399 # processing final pings
3400 do_facet ost1 "$LCTL set_param fail_val=40"
3401 do_facet ost1 "$LCTL set_param fail_loc=0x715"
3404 run_test 93a "replay + reconnect"
3407 local server_version=$(lustre_version_code $SINGLEMDS)
3408 [[ $server_version -ge $(version_code 2.7.90) ]] ||
3409 { skip "Need MDS version 2.7.90+"; return; }
3411 cancel_lru_locks mdc
3413 createmany -o $DIR/$tfile 20 ||
3414 error "createmany -o $DIR/$tfile failed"
3416 #define OBD_FAIL_TGT_REPLAY_RECONNECT 0x715
3417 # We need to emulate a state that MDT is waiting for other clients
3418 # not completing the recovery. Final ping is queued, but reply will be
3419 # sent on the recovery completion. It is done by sleep before
3420 # processing final pings
3421 do_facet mds1 "$LCTL set_param fail_val=80"
3422 do_facet mds1 "$LCTL set_param fail_loc=0x715"
3425 run_test 93b "replay + reconnect on mds"
3427 striped_dir_check_100() {
3428 local striped_dir=$DIR/$tdir/striped_dir
3429 local stripe_count=$($LFS getdirstripe -c $striped_dir)
3431 $LFS getdirstripe $striped_dir
3432 [ $stripe_count -eq 2 ] || error "$stripe_count != 2"
3434 createmany -o $striped_dir/f-%d 20 ||
3435 error "creation failed under striped dir"
3439 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
3440 ([ $FAILURE_MODE == "HARD" ] &&
3441 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
3442 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
3445 local striped_dir=$DIR/$tdir/striped_dir
3448 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
3450 #To make sure MDT1 and MDT0 are connected
3451 #otherwise it may create single stripe dir here
3452 $LFS setdirstripe -i1 $DIR/$tdir/remote_dir
3454 #define OBD_FAIL_OUT_UPDATE_NET_REP 0x1701
3455 do_facet mds$((MDTIDX+1)) lctl set_param fail_loc=0x1701
3456 $LFS setdirstripe -i0 -c2 $striped_dir &
3459 fail mds$((MDTIDX + 1))
3461 wait $CLIENT_PID || error "striped dir creation failed"
3463 striped_dir_check_100 || error "striped dir check failed"
3464 rm -rf $DIR/$tdir || error "rmdir failed"
3466 run_test 100a "DNE: create striped dir, drop update rep from MDT1, fail MDT1"
3469 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
3470 ([ $FAILURE_MODE == "HARD" ] &&
3471 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
3472 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
3475 local striped_dir=$DIR/$tdir/striped_dir
3478 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
3480 #To make sure MDT1 and MDT0 are connected
3481 #otherwise it may create single stripe dir here
3482 $LFS setdirstripe -i1 $DIR/$tdir/remote_dir
3484 # OBD_FAIL_MDS_REINT_NET_REP 0x119
3485 do_facet mds$MDTIDX lctl set_param fail_loc=0x119
3486 $LFS mkdir -i0 -c2 $striped_dir &
3491 wait $CLIENT_PID || error "striped dir creation failed"
3493 striped_dir_check_100 || error "striped dir check failed"
3494 rm -rf $DIR/$tdir || error "rmdir failed"
3496 run_test 100b "DNE: create striped dir, fail MDT0"
3498 test_101() { #LU-5648
3499 mkdir -p $DIR/$tdir/d1
3500 mkdir -p $DIR/$tdir/d2
3501 touch $DIR/$tdir/file0
3504 replay_barrier $SINGLEMDS
3505 for i in $(seq $num) ; do
3506 echo test$i > $DIR/$tdir/d1/file$i
3509 fail_abort $SINGLEMDS
3510 for i in $(seq $num) ; do
3511 touch $DIR/$tdir/d2/file$i
3512 test -s $DIR/$tdir/d2/file$i &&
3513 ls -al $DIR/$tdir/d2/file$i && error "file$i's size > 0"
3518 run_test 101 "Shouldn't reassign precreated objs to other files after recovery"
3527 [[ $(lctl get_param mdc.*.import |
3528 grep "connect_flags:.*multi_mod_rpc") ]] ||
3529 { skip "Need MDC with 'multi_mod_rpcs' feature"; return 0; }
3531 $LFS mkdir -c1 $DIR/$tdir || error "mkdir $DIR/$tdir failed"
3532 idx=$(printf "%04x" $($LFS getdirstripe -i $DIR/$tdir))
3533 facet="mds$((0x$idx + 1))"
3535 # get current value of max_mod_rcps_in_flight
3536 num=$($LCTL get_param -n \
3537 mdc.$FSNAME-MDT$idx-mdc-*.max_mod_rpcs_in_flight)
3538 # set default value if client does not support multi mod RPCs
3539 [ -z "$num" ] && num=1
3541 echo "creating $num files ..."
3543 for i in $(seq $num); do
3544 touch $DIR/$tdir/file-$i
3547 # drop request on MDT to force resend
3548 #define OBD_FAIL_MDS_REINT_MULTI_NET 0x159
3549 do_facet $facet "$LCTL set_param fail_loc=0x159"
3550 echo "launch $num chmod in parallel ($(date +%H:%M:%S)) ..."
3551 for i in $(seq $num); do
3552 chmod 0600 $DIR/$tdir/file-$i &
3556 do_facet $facet "$LCTL set_param fail_loc=0"
3557 for pid in $pids; do
3558 wait $pid || error "chmod failed"
3560 echo "done ($(date +%H:%M:%S))"
3562 # check chmod succeed
3563 for i in $(seq $num); do
3564 checkstat -vp 0600 $DIR/$tdir/file-$i
3569 run_test 102a "check resend (request lost) with multiple modify RPCs in flight"
3578 [[ $(lctl get_param mdc.*.import |
3579 grep "connect_flags:.*multi_mod_rpc") ]] ||
3580 { skip "Need MDC with 'multi_mod_rpcs' feature"; return 0; }
3582 $LFS mkdir -c1 $DIR/$tdir || error "mkdir $DIR/$tdir failed"
3583 idx=$(printf "%04x" $($LFS getdirstripe -i $DIR/$tdir))
3584 facet="mds$((0x$idx + 1))"
3586 # get current value of max_mod_rcps_in_flight
3587 num=$($LCTL get_param -n \
3588 mdc.$FSNAME-MDT$idx-mdc-*.max_mod_rpcs_in_flight)
3589 # set default value if client does not support multi mod RPCs
3590 [ -z "$num" ] && num=1
3592 echo "creating $num files ..."
3594 for i in $(seq $num); do
3595 touch $DIR/$tdir/file-$i
3598 # drop reply on MDT to force reconstruction
3599 #define OBD_FAIL_MDS_REINT_MULTI_NET_REP 0x15a
3600 do_facet $facet "$LCTL set_param fail_loc=0x15a"
3601 echo "launch $num chmod in parallel ($(date +%H:%M:%S)) ..."
3602 for i in $(seq $num); do
3603 chmod 0600 $DIR/$tdir/file-$i &
3607 do_facet $facet "$LCTL set_param fail_loc=0"
3608 for pid in $pids; do
3609 wait $pid || error "chmod failed"
3611 echo "done ($(date +%H:%M:%S))"
3613 # check chmod succeed
3614 for i in $(seq $num); do
3615 checkstat -vp 0600 $DIR/$tdir/file-$i
3620 run_test 102b "check resend (reply lost) with multiple modify RPCs in flight"
3629 [[ $(lctl get_param mdc.*.import |
3630 grep "connect_flags:.*multi_mod_rpc") ]] ||
3631 { skip "Need MDC with 'multi_mod_rpcs' feature"; return 0; }
3633 $LFS mkdir -c1 $DIR/$tdir || error "mkdir $DIR/$tdir failed"
3634 idx=$(printf "%04x" $($LFS getdirstripe -i $DIR/$tdir))
3635 facet="mds$((0x$idx + 1))"
3637 # get current value of max_mod_rcps_in_flight
3638 num=$($LCTL get_param -n \
3639 mdc.$FSNAME-MDT$idx-mdc-*.max_mod_rpcs_in_flight)
3640 # set default value if client does not support multi mod RPCs
3641 [ -z "$num" ] && num=1
3643 echo "creating $num files ..."
3645 for i in $(seq $num); do
3646 touch $DIR/$tdir/file-$i
3649 replay_barrier $facet
3652 #define OBD_FAIL_MDS_REINT_MULTI_NET_REP 0x15a
3653 do_facet $facet "$LCTL set_param fail_loc=0x15a"
3654 echo "launch $num chmod in parallel ($(date +%H:%M:%S)) ..."
3655 for i in $(seq $num); do
3656 chmod 0600 $DIR/$tdir/file-$i &
3660 do_facet $facet "$LCTL set_param fail_loc=0"
3665 for pid in $pids; do
3666 wait $pid || error "chmod failed"
3668 echo "done ($(date +%H:%M:%S))"
3670 # check chmod succeed
3671 for i in $(seq $num); do
3672 checkstat -vp 0600 $DIR/$tdir/file-$i
3677 run_test 102c "check replay w/o reconstruction with multiple mod RPCs in flight"
3686 [[ $(lctl get_param mdc.*.import |
3687 grep "connect_flags:.*multi_mod_rpc") ]] ||
3688 { skip "Need MDC with 'multi_mod_rpcs' feature"; return 0; }
3690 $LFS mkdir -c1 $DIR/$tdir || error "mkdir $DIR/$tdir failed"
3691 idx=$(printf "%04x" $($LFS getdirstripe -i $DIR/$tdir))
3692 facet="mds$((0x$idx + 1))"
3694 # get current value of max_mod_rcps_in_flight
3695 num=$($LCTL get_param -n \
3696 mdc.$FSNAME-MDT$idx-mdc-*.max_mod_rpcs_in_flight)
3697 # set default value if client does not support multi mod RPCs
3698 [ -z "$num" ] && num=1
3700 echo "creating $num files ..."
3702 for i in $(seq $num); do
3703 touch $DIR/$tdir/file-$i
3707 #define OBD_FAIL_MDS_REINT_MULTI_NET_REP 0x15a
3708 do_facet $facet "$LCTL set_param fail_loc=0x15a"
3709 echo "launch $num chmod in parallel ($(date +%H:%M:%S)) ..."
3710 for i in $(seq $num); do
3711 chmod 0600 $DIR/$tdir/file-$i &
3716 # write MDT transactions to disk
3717 do_facet $facet "sync; sync; sync"
3719 do_facet $facet "$LCTL set_param fail_loc=0"
3724 for pid in $pids; do
3725 wait $pid || error "chmod failed"
3727 echo "done ($(date +%H:%M:%S))"
3729 # check chmod succeed
3730 for i in $(seq $num); do
3731 checkstat -vp 0600 $DIR/$tdir/file-$i
3736 run_test 102d "check replay & reconstruction with multiple mod RPCs in flight"
3739 remote_mds_nodsh && skip "remote MDS with nodsh" && return
3740 #define OBD_FAIL_MDS_TRACK_OVERFLOW 0x162
3741 do_facet mds1 $LCTL set_param fail_loc=0x80000162
3744 createmany -o $DIR/$tdir/t- 30 ||
3745 error "create files on remote directory failed"
3747 rm -rf $DIR/$tdir/t-*
3749 #MDS should crash with tr->otr_next_id overflow
3752 run_test 103 "Check otr_next_id overflow"
3755 check_striped_dir_110()
3757 $CHECKSTAT -t dir $DIR/$tdir/striped_dir ||
3758 error "create striped dir failed"
3759 local stripe_count=$($LFS getdirstripe -c $DIR/$tdir/striped_dir)
3760 [ $stripe_count -eq $MDSCOUNT ] ||
3761 error "$stripe_count != 2 after recovery"
3765 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
3766 ([ $FAILURE_MODE == "HARD" ] &&
3767 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
3768 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
3773 $LFS mkdir -i1 -c$MDSCOUNT $DIR/$tdir/striped_dir
3776 check_striped_dir_110 || error "check striped_dir failed"
3777 rm -rf $DIR/$tdir || error "rmdir failed"
3781 run_test 110a "DNE: create striped dir, fail MDT1"
3784 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
3785 ([ $FAILURE_MODE == "HARD" ] &&
3786 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
3787 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
3792 $LFS mkdir -i1 -c$MDSCOUNT $DIR/$tdir/striped_dir
3795 zconf_mount $(hostname) $MOUNT
3796 client_up || return 1
3798 check_striped_dir_110 || error "check striped_dir failed"
3800 rm -rf $DIR/$tdir || error "rmdir failed"
3804 run_test 110b "DNE: create striped dir, fail MDT1 and client"
3807 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
3808 ([ $FAILURE_MODE == "HARD" ] &&
3809 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
3810 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
3815 $LFS mkdir -i1 -c$MDSCOUNT $DIR/$tdir/striped_dir
3818 check_striped_dir_110 || error "check striped_dir failed"
3820 rm -rf $DIR/$tdir || error "rmdir failed"
3824 run_test 110c "DNE: create striped dir, fail MDT2"
3827 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
3828 ([ $FAILURE_MODE == "HARD" ] &&
3829 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
3830 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
3835 $LFS mkdir -i1 -c$MDSCOUNT $DIR/$tdir/striped_dir
3838 zconf_mount $(hostname) $MOUNT
3839 client_up || return 1
3841 check_striped_dir_110 || error "check striped_dir failed"
3843 rm -rf $DIR/$tdir || error "rmdir failed"
3847 run_test 110d "DNE: create striped dir, fail MDT2 and client"
3850 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
3851 ([ $FAILURE_MODE == "HARD" ] &&
3852 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
3853 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
3858 $LFS mkdir -i1 -c$MDSCOUNT $DIR/$tdir/striped_dir
3862 zconf_mount $(hostname) $MOUNT
3863 client_up || return 1
3865 check_striped_dir_110 || error "check striped_dir failed"
3867 rm -rf $DIR/$tdir || error "rmdir failed"
3871 run_test 110e "DNE: create striped dir, uncommit on MDT2, fail client/MDT1/MDT2"
3874 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
3875 ([ $FAILURE_MODE == "HARD" ] &&
3876 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
3877 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
3883 $LFS mkdir -i1 -c$MDSCOUNT $DIR/$tdir/striped_dir
3886 check_striped_dir_110 || error "check striped_dir failed"
3888 rm -rf $DIR/$tdir || error "rmdir failed"
3892 run_test 110f "DNE: create striped dir, fail MDT1/MDT2"
3895 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
3896 ([ $FAILURE_MODE == "HARD" ] &&
3897 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
3898 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
3903 $LFS mkdir -i1 -c$MDSCOUNT $DIR/$tdir/striped_dir
3907 zconf_mount $(hostname) $MOUNT
3908 client_up || return 1
3910 check_striped_dir_110 || error "check striped_dir failed"
3912 rm -rf $DIR/$tdir || error "rmdir failed"
3916 run_test 110g "DNE: create striped dir, uncommit on MDT1, fail client/MDT1/MDT2"
3919 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
3920 ([ $FAILURE_MODE == "HARD" ] &&
3921 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
3922 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
3926 $LFS mkdir -i1 -c2 $DIR/$tdir/striped_dir
3928 rm -rf $DIR/$tdir/striped_dir
3931 $CHECKSTAT -t dir $DIR/$tdir/striped_dir &&
3932 error "striped dir still exists"
3935 run_test 111a "DNE: unlink striped dir, fail MDT1"
3938 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
3939 ([ $FAILURE_MODE == "HARD" ] &&
3940 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
3941 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
3945 $LFS mkdir -i1 -c2 $DIR/$tdir/striped_dir
3947 rm -rf $DIR/$tdir/striped_dir
3950 zconf_mount $(hostname) $MOUNT
3951 client_up || return 1
3953 $CHECKSTAT -t dir $DIR/$tdir/striped_dir &&
3954 error "striped dir still exists"
3957 run_test 111b "DNE: unlink striped dir, fail MDT2"
3960 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
3961 ([ $FAILURE_MODE == "HARD" ] &&
3962 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
3963 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
3967 $LFS mkdir -i1 -c2 $DIR/$tdir/striped_dir
3969 rm -rf $DIR/$tdir/striped_dir
3973 zconf_mount $(hostname) $MOUNT
3974 client_up || return 1
3975 $CHECKSTAT -t dir $DIR/$tdir/striped_dir &&
3976 error "striped dir still exists"
3979 run_test 111c "DNE: unlink striped dir, uncommit on MDT1, fail client/MDT1/MDT2"
3982 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
3983 ([ $FAILURE_MODE == "HARD" ] &&
3984 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
3985 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
3989 $LFS mkdir -i1 -c2 $DIR/$tdir/striped_dir
3991 rm -rf $DIR/$tdir/striped_dir
3995 zconf_mount $(hostname) $MOUNT
3996 client_up || return 1
3997 $CHECKSTAT -t dir $DIR/$tdir/striped_dir &&
3998 error "striped dir still exists"
4002 run_test 111d "DNE: unlink striped dir, uncommit on MDT2, fail client/MDT1/MDT2"
4005 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
4006 ([ $FAILURE_MODE == "HARD" ] &&
4007 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
4008 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
4012 $LFS mkdir -i1 -c2 $DIR/$tdir/striped_dir
4014 rm -rf $DIR/$tdir/striped_dir
4017 $CHECKSTAT -t dir $DIR/$tdir/striped_dir &&
4018 error "striped dir still exists"
4021 run_test 111e "DNE: unlink striped dir, uncommit on MDT2, fail MDT1/MDT2"
4024 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
4025 ([ $FAILURE_MODE == "HARD" ] &&
4026 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
4027 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
4031 $LFS mkdir -i1 -c2 $DIR/$tdir/striped_dir
4033 rm -rf $DIR/$tdir/striped_dir
4036 $CHECKSTAT -t dir $DIR/$tdir/striped_dir &&
4037 error "striped dir still exists"
4040 run_test 111f "DNE: unlink striped dir, uncommit on MDT1, fail MDT1/MDT2"
4043 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
4044 ([ $FAILURE_MODE == "HARD" ] &&
4045 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
4046 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
4050 $LFS mkdir -i1 -c2 $DIR/$tdir/striped_dir
4053 rm -rf $DIR/$tdir/striped_dir
4055 $CHECKSTAT -t dir $DIR/$tdir/striped_dir &&
4056 error "striped dir still exists"
4059 run_test 111g "DNE: unlink striped dir, fail MDT1/MDT2"
4061 test_112_rename_prepare() {
4062 mkdir -p $DIR/$tdir/src_dir
4063 $LFS mkdir -i 1 $DIR/$tdir/src_dir/src_child ||
4064 error "create remote source failed"
4066 touch $DIR/$tdir/src_dir/src_child/a
4068 $LFS mkdir -i 2 $DIR/$tdir/tgt_dir ||
4069 error "create remote target dir failed"
4071 $LFS mkdir -i 3 $DIR/$tdir/tgt_dir/tgt_child ||
4072 error "create remote target child failed"
4077 $CHECKSTAT -t dir $DIR/$tdir/src_dir/src_child &&
4078 error "src_child still exists after rename"
4080 $CHECKSTAT -t file $DIR/$tdir/tgt_dir/tgt_child/a ||
4081 error "missing file(a) after rename"
4085 [ $MDSCOUNT -lt 4 ] && skip "needs >= 4 MDTs" && return 0
4086 ([ $FAILURE_MODE == "HARD" ] &&
4087 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
4088 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
4091 test_112_rename_prepare
4094 mrename $DIR/$tdir/src_dir/src_child $DIR/$tdir/tgt_dir/tgt_child ||
4095 error "rename dir cross MDT failed!"
4099 rm -rf $DIR/$tdir || error "rmdir failed"
4101 run_test 112a "DNE: cross MDT rename, fail MDT1"
4104 [ $MDSCOUNT -lt 4 ] && skip "needs >= 4 MDTs" && return 0
4105 ([ $FAILURE_MODE == "HARD" ] &&
4106 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
4107 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
4110 test_112_rename_prepare
4113 mrename $DIR/$tdir/src_dir/src_child $DIR/$tdir/tgt_dir/tgt_child ||
4114 error "rename dir cross MDT failed!"
4119 rm -rf $DIR/$tdir || error "rmdir failed"
4121 run_test 112b "DNE: cross MDT rename, fail MDT2"
4124 [ $MDSCOUNT -lt 4 ] && skip "needs >= 4 MDTs" && return 0
4125 ([ $FAILURE_MODE == "HARD" ] &&
4126 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
4127 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
4130 test_112_rename_prepare
4133 mrename $DIR/$tdir/src_dir/src_child $DIR/$tdir/tgt_dir/tgt_child ||
4134 error "rename dir cross MDT failed!"
4139 rm -rf $DIR/$tdir || error "rmdir failed"
4141 run_test 112c "DNE: cross MDT rename, fail MDT3"
4144 [ $MDSCOUNT -lt 4 ] && skip "needs >= 4 MDTs" && return 0
4145 ([ $FAILURE_MODE == "HARD" ] &&
4146 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
4147 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
4150 test_112_rename_prepare
4153 mrename $DIR/$tdir/src_dir/src_child $DIR/$tdir/tgt_dir/tgt_child ||
4154 error "rename dir cross MDT failed!"
4159 rm -rf $DIR/$tdir || error "rmdir failed"
4161 run_test 112d "DNE: cross MDT rename, fail MDT4"
4164 [ $MDSCOUNT -lt 4 ] && skip "needs >= 4 MDTs" && return 0
4165 ([ $FAILURE_MODE == "HARD" ] &&
4166 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
4167 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
4170 test_112_rename_prepare
4174 mrename $DIR/$tdir/src_dir/src_child $DIR/$tdir/tgt_dir/tgt_child ||
4175 error "rename dir cross MDT failed!"
4180 rm -rf $DIR/$tdir || error "rmdir failed"
4182 run_test 112e "DNE: cross MDT rename, fail MDT1 and MDT2"
4185 [ $MDSCOUNT -lt 4 ] && skip "needs >= 4 MDTs" && return 0
4186 ([ $FAILURE_MODE == "HARD" ] &&
4187 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
4188 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
4191 test_112_rename_prepare
4195 mrename $DIR/$tdir/src_dir/src_child $DIR/$tdir/tgt_dir/tgt_child ||
4196 error "rename dir cross MDT failed!"
4201 rm -rf $DIR/$tdir || error "rmdir failed"
4203 run_test 112f "DNE: cross MDT rename, fail MDT1 and MDT3"
4206 [ $MDSCOUNT -lt 4 ] && skip "needs >= 4 MDTs" && return 0
4207 ([ $FAILURE_MODE == "HARD" ] &&
4208 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
4209 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
4212 test_112_rename_prepare
4216 mrename $DIR/$tdir/src_dir/src_child $DIR/$tdir/tgt_dir/tgt_child ||
4217 error "rename dir cross MDT failed!"
4222 rm -rf $DIR/$tdir || error "rmdir failed"
4224 run_test 112g "DNE: cross MDT rename, fail MDT1 and MDT4"
4227 [ $MDSCOUNT -lt 4 ] && skip "needs >= 4 MDTs" && return 0
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
4237 mrename $DIR/$tdir/src_dir/src_child $DIR/$tdir/tgt_dir/tgt_child ||
4238 error "rename dir cross MDT failed!"
4243 rm -rf $DIR/$tdir || error "rmdir failed"
4245 run_test 112h "DNE: cross MDT rename, fail MDT2 and MDT3"
4248 [ $MDSCOUNT -lt 4 ] && skip "needs >= 4 MDTs" && return 0
4249 ([ $FAILURE_MODE == "HARD" ] &&
4250 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
4251 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
4254 test_112_rename_prepare
4258 mrename $DIR/$tdir/src_dir/src_child $DIR/$tdir/tgt_dir/tgt_child ||
4259 error "rename dir cross MDT failed!"
4264 rm -rf $DIR/$tdir || error "rmdir failed"
4266 run_test 112i "DNE: cross MDT rename, fail MDT2 and MDT4"
4269 [ $MDSCOUNT -lt 4 ] && skip "needs >= 4 MDTs" && return 0
4270 ([ $FAILURE_MODE == "HARD" ] &&
4271 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
4272 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
4275 test_112_rename_prepare
4279 mrename $DIR/$tdir/src_dir/src_child $DIR/$tdir/tgt_dir/tgt_child ||
4280 error "rename dir cross MDT failed!"
4285 rm -rf $DIR/$tdir || error "rmdir failed"
4287 run_test 112j "DNE: cross MDT rename, fail MDT3 and MDT4"
4290 [ $MDSCOUNT -lt 4 ] && skip "needs >= 4 MDTs" && return 0
4291 ([ $FAILURE_MODE == "HARD" ] &&
4292 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
4293 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
4296 test_112_rename_prepare
4301 mrename $DIR/$tdir/src_dir/src_child $DIR/$tdir/tgt_dir/tgt_child ||
4302 error "rename dir cross MDT failed!"
4307 rm -rf $DIR/$tdir || error "rmdir failed"
4309 run_test 112k "DNE: cross MDT rename, fail MDT1,MDT2,MDT3"
4312 [ $MDSCOUNT -lt 4 ] && skip "needs >= 4 MDTs" && return 0
4313 ([ $FAILURE_MODE == "HARD" ] &&
4314 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
4315 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
4318 test_112_rename_prepare
4323 mrename $DIR/$tdir/src_dir/src_child $DIR/$tdir/tgt_dir/tgt_child ||
4324 error "rename dir cross MDT failed!"
4329 rm -rf $DIR/$tdir || error "rmdir failed"
4331 run_test 112l "DNE: cross MDT rename, fail MDT1,MDT2,MDT4"
4334 [ $MDSCOUNT -lt 4 ] && skip "needs >= 4 MDTs" && return 0
4335 ([ $FAILURE_MODE == "HARD" ] &&
4336 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
4337 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
4340 test_112_rename_prepare
4345 mrename $DIR/$tdir/src_dir/src_child $DIR/$tdir/tgt_dir/tgt_child ||
4346 error "rename dir cross MDT failed!"
4351 rm -rf $DIR/$tdir || error "rmdir failed"
4353 run_test 112m "DNE: cross MDT rename, fail MDT1,MDT3,MDT4"
4356 [ $MDSCOUNT -lt 4 ] && skip "needs >= 4 MDTs" && return 0
4357 ([ $FAILURE_MODE == "HARD" ] &&
4358 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
4359 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
4362 test_112_rename_prepare
4367 mrename $DIR/$tdir/src_dir/src_child $DIR/$tdir/tgt_dir/tgt_child ||
4368 error "rename dir cross MDT failed!"
4373 rm -rf $DIR/$tdir || error "rmdir failed"
4375 run_test 112n "DNE: cross MDT rename, fail MDT2,MDT3,MDT4"
4378 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
4379 ([ $FAILURE_MODE == "HARD" ] &&
4380 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
4381 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
4389 for ((j=0;j<$((MDSCOUNT));j++)); do
4390 fail_index=$((fail_index+1))
4391 index=$((fail_index % MDSCOUNT))
4392 replay_barrier mds$((index + 1))
4393 for ((i=0;i<5;i++)); do
4394 test_mkdir -i$index -c$MDSCOUNT $DIR/$tdir/test_$i ||
4395 error "create striped dir $DIR/$tdir/test_$i"
4398 fail mds$((index + 1))
4399 for ((i=0;i<5;i++)); do
4400 checkstat -t dir $DIR/$tdir/test_$i ||
4401 error "$DIR/$tdir/test_$i does not exist!"
4403 rm -rf $DIR/$tdir/test_* ||
4407 run_test 115 "failover for create/unlink striped directory"
4410 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
4411 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.55) ] &&
4412 skip "Do not support large update log before 2.7.55" &&
4414 ([ $FAILURE_MODE == "HARD" ] &&
4415 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
4416 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
4423 # OBD_FAIL_SPLIT_UPDATE_REC 0x1702
4424 do_facet mds1 "lctl set_param fail_loc=0x80001702"
4425 $LFS setdirstripe -c$MDSCOUNT $DIR/$tdir/striped_dir
4428 $CHECKSTAT -t dir $DIR/$tdir/striped_dir ||
4429 error "stried_dir does not exists"
4431 run_test 116a "large update log master MDT recovery"
4434 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
4435 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.55) ] &&
4436 skip "Do not support large update log before 2.7.55" &&
4439 ([ $FAILURE_MODE == "HARD" ] &&
4440 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
4441 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
4448 # OBD_FAIL_SPLIT_UPDATE_REC 0x1702
4449 do_facet mds2 "lctl set_param fail_loc=0x80001702"
4450 $LFS setdirstripe -c$MDSCOUNT $DIR/$tdir/striped_dir
4453 $CHECKSTAT -t dir $DIR/$tdir/striped_dir ||
4454 error "stried_dir does not exists"
4456 run_test 116b "large update log slave MDT recovery"
4459 [ $MDSCOUNT -lt 4 ] && skip "needs >= 4 MDTs" && return 0
4460 ([ $FAILURE_MODE == "HARD" ] &&
4461 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
4462 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
4468 $LFS setdirstripe -i0 -c$MDSCOUNT $DIR/$tdir/remote_dir
4469 $LFS setdirstripe -i1 -c$MDSCOUNT $DIR/$tdir/remote_dir_1
4472 # Let's set rdonly on all MDTs, so client will send
4473 # replay requests on all MDTs and replay these requests
4474 # at the same time. This test will verify the recovery
4475 # will not be deadlock in this case, LU-7531.
4476 for ((index = 0; index < $((MDSCOUNT)); index++)); do
4477 replay_barrier mds$((index + 1))
4478 if [ -z $mds_indexs ]; then
4479 mds_indexs="${mds_indexs}mds$((index+1))"
4481 mds_indexs="${mds_indexs},mds$((index+1))"
4485 rm -rf $DIR/$tdir/remote_dir
4486 rm -rf $DIR/$tdir/remote_dir_1
4490 rm -rf $DIR/$tdir || error "rmdir failed"
4492 run_test 117 "DNE: cross MDT unlink, fail MDT1 and MDT2"
4495 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
4496 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.64) ] &&
4497 skip "Do not support large update log before 2.7.64" &&
4502 $LFS setdirstripe -c2 $DIR/$tdir/striped_dir ||
4503 error "setdirstripe fails"
4504 $LFS setdirstripe -c2 $DIR/$tdir/striped_dir1 ||
4505 error "setdirstripe fails 1"
4506 rm -rf $DIR/$tdir/striped_dir* || error "rmdir fails"
4508 # OBD_FAIL_INVALIDATE_UPDATE 0x1705
4509 do_facet mds1 "lctl set_param fail_loc=0x1705"
4510 $LFS setdirstripe -c2 $DIR/$tdir/striped_dir
4511 $LFS setdirstripe -c2 $DIR/$tdir/striped_dir1
4512 do_facet mds1 "lctl set_param fail_loc=0x0"
4515 $LFS setdirstripe -c2 $DIR/$tdir/striped_dir
4516 $LFS setdirstripe -c2 $DIR/$tdir/striped_dir1
4521 run_test 118 "invalidate osp update will not cause update log corruption"
4524 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
4525 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.64) ] &&
4526 skip "Do not support large update log before 2.7.64" &&
4529 local hard_timeout=$(do_facet mds1 \
4530 "lctl get_param -n mdt.$FSNAME-MDT0000.recovery_time_hard")
4532 local clients=${CLIENTS:-$HOSTNAME}
4533 local time_min=$(recovery_time_min)
4536 mkdir $DIR/$tdir/tmp
4537 rmdir $DIR/$tdir/tmp
4540 mkdir $DIR/$tdir/dir_1
4541 for ((i = 0; i < 20; i++)); do
4542 $LFS setdirstripe -c2 $DIR/$tdir/stripe_dir-$i
4549 #define OBD_FAIL_TGT_REPLAY_DELAY 0x714
4550 do_facet mds1 $LCTL set_param fail_loc=0x80000714
4551 #sleep (timeout + 5), so mds will evict the client exports,
4552 #but DNE update recovery will keep going.
4553 do_facet mds1 $LCTL set_param fail_val=$((time_min + 5))
4555 mount_facet mds1 "-o recovery_time_hard=$time_min"
4557 wait_clients_import_state "$clients" mds1 FULL
4559 clients_up || clients_up || error "failover df: $?"
4561 #revert back the hard timeout
4562 do_facet mds1 $LCTL set_param \
4563 mdt.$FSNAME-MDT0000.recovery_time_hard=$hard_timeout
4565 for ((i = 0; i < 20; i++)); do
4566 stripe_count=$($LFS getdirstripe -c $DIR/$tdir/stripe_dir-$i)
4567 [ $stripe_count == 2 ] || {
4568 error "stripe_dir-$i creation replay fails"
4573 run_test 119 "timeout of normal replay does not cause DNE replay fails "
4576 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
4577 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.64) ] &&
4578 skip "Do not support large update log before 2.7.64" &&
4582 replay_barrier_nosync mds1
4583 for ((i = 0; i < 20; i++)); do
4584 mkdir $DIR/$tdir/dir-$i || {
4585 error "create dir-$i fails"
4588 $LFS setdirstripe -c2 $DIR/$tdir/stripe_dir-$i || {
4589 error "create stripe_dir-$i fails"
4596 for ((i = 0; i < 20; i++)); do
4597 [ ! -e "$DIR/$tdir/dir-$i" ] || {
4598 error "dir-$i still exists"
4601 [ ! -e "$DIR/$tdir/stripe_dir-$i" ] || {
4602 error "stripe_dir-$i still exists"
4607 run_test 120 "DNE fail abort should stop both normal and DNE replay"
4610 check_and_cleanup_lustre