7 # This test needs to be run on the client
10 export MULTIOP=${MULTIOP:-multiop}
11 LUSTRE=${LUSTRE:-$(cd $(dirname $0)/..; echo $PWD)}
14 . $LUSTRE/tests/test-framework.sh
16 . ${CONFIG:=$LUSTRE/tests/cfg/$NAME.sh}
18 CHECK_GRANT=${CHECK_GRANT:-"yes"}
19 GRANT_CHECK_LIST=${GRANT_CHECK_LIST:-""}
21 require_dsh_mds || exit 0
24 # bug number for skipped tests:
26 ALWAYS_EXCEPT="$REPLAY_SINGLE_EXCEPT 61d"
27 # UPDATE THE COMMENT ABOVE WITH BUG NUMBERS WHEN CHANGING ALWAYS_EXCEPT!
30 [ "$SLOW" = "no" ] && EXCEPT_SLOW="44b"
32 [ $(facet_fstype $SINGLEMDS) = "zfs" ] &&
33 # bug number for skipped test: LU-1867 LU-3127
34 ALWAYS_EXCEPT="$ALWAYS_EXCEPT 89 73b"
38 check_and_setup_lustre
43 rm -rf $DIR/[df][0-9]* $DIR/f.$TESTSUITE.*
45 # LU-482 Avert LVM and VM inability to flush caches in pre .33 kernels
46 if [ $LINUX_VERSION_CODE -lt $(version_code 2.6.33) ]; then
48 do_facet $SINGLEMDS sync
51 test_0a() { # was test_0
52 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
53 replay_barrier $SINGLEMDS
57 run_test 0a "empty replay"
60 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
62 # this test attempts to trigger a race in the precreation code,
63 # and must run before any other objects are created on the filesystem
65 createmany -o $DIR/$tfile 20 || error "createmany -o $DIR/$tfile failed"
66 unlinkmany $DIR/$tfile 20 || error "unlinkmany $DIR/$tfile failed"
68 run_test 0b "ensure object created after recover exists. (3284)"
71 replay_barrier $SINGLEMDS
74 facet_failover $SINGLEMDS
75 zconf_mount $(hostname) $MOUNT || error "mount fails"
76 client_up || error "post-failover df failed"
77 # file shouldn't exist if replay-barrier works as expected
78 rm $DIR/$tfile && error "File exists and it shouldn't"
81 run_test 0c "check replay-barrier"
84 replay_barrier $SINGLEMDS
86 facet_failover $SINGLEMDS
87 zconf_mount $(hostname) $MOUNT || error "mount fails"
88 client_up || error "post-failover df failed"
90 run_test 0d "expired recovery with no clients"
93 replay_barrier $SINGLEMDS
96 $CHECKSTAT -t file $DIR/$tfile ||
97 error "$CHECKSTAT $DIR/$tfile attribute check failed"
100 run_test 1 "simple create"
103 replay_barrier $SINGLEMDS
106 $CHECKSTAT -t file $DIR/$tfile ||
107 error "$CHECKSTAT $DIR/$tfile attribute check failed"
113 mcreate $DIR/$tfile || error "mcreate $DIR/$tfile failed"
114 replay_barrier $SINGLEMDS
117 $CHECKSTAT -t file $DIR/$tfile ||
118 error "$CHECKSTAT $DIR/$tfile attribute check failed"
124 local file=$DIR/$tfile
125 replay_barrier $SINGLEMDS
127 openfile -f O_DIRECTORY $file
129 $CHECKSTAT -t file $file ||
130 error "$CHECKSTAT $file attribute check failed"
133 run_test 3a "replay failed open(O_DIRECTORY)"
136 replay_barrier $SINGLEMDS
137 #define OBD_FAIL_MDS_OPEN_PACK | OBD_FAIL_ONCE
138 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000114"
140 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
142 $CHECKSTAT -t file $DIR/$tfile &&
143 error "$CHECKSTAT $DIR/$tfile attribute check should fail"
146 run_test 3b "replay failed open -ENOMEM"
149 replay_barrier $SINGLEMDS
150 #define OBD_FAIL_MDS_ALLOC_OBDO | OBD_FAIL_ONCE
151 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000128"
153 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
156 $CHECKSTAT -t file $DIR/$tfile &&
157 error "$CHECKSTAT $DIR/$tfile attribute check should fail"
160 run_test 3c "replay failed open -ENOMEM"
162 test_4a() { # was test_4
163 replay_barrier $SINGLEMDS
164 for i in $(seq 10); do
165 echo "tag-$i" > $DIR/$tfile-$i
168 for i in $(seq 10); do
169 grep -q "tag-$i" $DIR/$tfile-$i || error "$tfile-$i"
172 run_test 4a "|x| 10 open(O_CREAT)s"
175 for i in $(seq 10); do
176 echo "tag-$i" > $DIR/$tfile-$i
178 replay_barrier $SINGLEMDS
181 $CHECKSTAT -t file $DIR/$tfile-* &&
182 error "$CHECKSTAT $DIR/$tfile-* attribute check should fail" ||
185 run_test 4b "|x| rm 10 files"
187 # The idea is to get past the first block of precreated files on both
188 # osts, and then replay.
190 replay_barrier $SINGLEMDS
191 for i in $(seq 220); do
192 echo "tag-$i" > $DIR/$tfile-$i
195 for i in $(seq 220); do
196 grep -q "tag-$i" $DIR/$tfile-$i || error "$tfile-$i"
200 # waiting for commitment of removal
202 run_test 5 "|x| 220 open(O_CREAT)"
204 test_6a() { # was test_6
205 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
206 replay_barrier $SINGLEMDS
207 mcreate $DIR/$tdir/$tfile
209 $CHECKSTAT -t dir $DIR/$tdir ||
210 error "$CHECKSTAT $DIR/$tdir attribute check failed"
211 $CHECKSTAT -t file $DIR/$tdir/$tfile ||
212 error "$CHECKSTAT $DIR/$tdir/$tfile attribute check failed"
214 # waiting for log process thread
216 run_test 6a "mkdir + contained create"
219 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
220 replay_barrier $SINGLEMDS
223 $CHECKSTAT -t dir $DIR/$tdir &&
224 error "$CHECKSTAT $DIR/$tdir attribute check should fail" ||
227 run_test 6b "|X| rmdir"
230 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
231 replay_barrier $SINGLEMDS
232 mcreate $DIR/$tdir/$tfile
234 $CHECKSTAT -t dir $DIR/$tdir ||
235 error "$CHECKSTAT $DIR/$tdir attribute check failed"
236 $CHECKSTAT -t file $DIR/$tdir/$tfile ||
237 error "$CHECKSTAT $DIR/$tdir/$tfile attribute check failed"
240 run_test 7 "mkdir |X| contained create"
243 replay_barrier $SINGLEMDS
244 multiop_bg_pause $DIR/$tfile mo_c ||
245 error "multiop mknod $DIR/$tfile failed"
249 $CHECKSTAT -t file $DIR/$tfile ||
250 error "$CHECKSTAT $DIR/$tfile attribute check failed"
251 kill -USR1 $MULTIPID || error "multiop mknod $MULTIPID not running"
252 wait $MULTIPID || error "multiop mknod $MULTIPID failed"
255 run_test 8 "creat open |X| close"
258 replay_barrier $SINGLEMDS
260 local old_inum=$(ls -i $DIR/$tfile | awk '{print $1}')
262 local new_inum=$(ls -i $DIR/$tfile | awk '{print $1}')
264 echo " old_inum == $old_inum, new_inum == $new_inum"
265 if [ $old_inum -eq $new_inum ] ;
267 echo "old_inum and new_inum match"
269 echo " old_inum and new_inum do not match"
270 error "old index($old_inum) does not match new index($new_inum)"
274 run_test 9 "|X| create (same inum/gen)"
277 mcreate $DIR/$tfile || error "mcreate $DIR/$tfile failed"
278 replay_barrier $SINGLEMDS
279 mv $DIR/$tfile $DIR/$tfile-2
282 $CHECKSTAT $DIR/$tfile &&
283 error "$CHECKSTAT $DIR/$tfile attribute check should fail"
284 $CHECKSTAT $DIR/$tfile-2 ||
285 error "$CHECKSTAT $DIR/$tfile-2 attribute check failed"
289 run_test 10 "create |X| rename unlink"
292 mcreate $DIR/$tfile || error "mcreate $DIR/$tfile failed"
293 echo "old" > $DIR/$tfile
294 mv $DIR/$tfile $DIR/$tfile-2
295 replay_barrier $SINGLEMDS
296 echo "new" > $DIR/$tfile
298 grep old $DIR/$tfile-2
300 grep new $DIR/$tfile || error "grep $DIR/$tfile failed"
301 grep old $DIR/$tfile-2 || error "grep $DIR/$tfile-2 failed"
303 run_test 11 "create open write rename |X| create-old-name read"
306 mcreate $DIR/$tfile || error "mcreate $DIR/$tfile failed"
307 multiop_bg_pause $DIR/$tfile o_tSc ||
308 error "multiop_bg_pause $DIR/$tfile failed"
311 replay_barrier $SINGLEMDS
312 kill -USR1 $pid || error "multiop $pid not running"
313 wait $pid || error "multiop $pid failed"
316 [ -e $DIR/$tfile ] && error "file $DIR/$tfile should not exist"
319 run_test 12 "open, unlink |X| close"
321 # 1777 - replay open after committed chmod that would make
322 # a regular open a failure
324 mcreate $DIR/$tfile || error "mcreate $DIR/$tfile failed"
325 multiop_bg_pause $DIR/$tfile O_wc ||
326 error "multiop_bg_pause $DIR/$tfile failed"
329 $CHECKSTAT -p 0 $DIR/$tfile ||
330 error "$CHECKSTAT $DIR/$tfile attribute check failed"
331 replay_barrier $SINGLEMDS
333 kill -USR1 $pid || error "multiop $pid not running"
334 wait $pid || error "multiop $pid failed"
336 $CHECKSTAT -s 1 -p 0 $DIR/$tfile ||
337 error "second $CHECKSTAT $DIR/$tfile attribute check failed"
338 rm $DIR/$tfile || error "rm $DIR/$tfile failed"
341 run_test 13 "open chmod 0 |x| write close"
344 multiop_bg_pause $DIR/$tfile O_tSc ||
345 error "multiop_bg_pause $DIR/$tfile failed"
348 replay_barrier $SINGLEMDS
349 kill -USR1 $pid || error "multiop $pid not running"
350 wait $pid || error "multiop $pid failed"
353 [ -e $DIR/$tfile ] && error "file $DIR/$tfile should not exist"
356 run_test 14 "open(O_CREAT), unlink |X| close"
359 multiop_bg_pause $DIR/$tfile O_tSc ||
360 error "multiop_bg_pause $DIR/$tfile failed"
363 replay_barrier $SINGLEMDS
364 touch $DIR/$tfile-1 || error "touch $DIR/$tfile-1 failed"
365 kill -USR1 $pid || error "multiop $pid not running"
366 wait $pid || error "multiop $pid failed"
369 [ -e $DIR/$tfile ] && error "file $DIR/$tfile should not exist"
370 touch $DIR/$tfile-2 || error "touch $DIR/$tfile-2 failed"
373 run_test 15 "open(O_CREAT), unlink |X| touch new, close"
376 replay_barrier $SINGLEMDS
379 mcreate $DIR/$tfile-2
381 [ -e $DIR/$tfile ] && error "file $DIR/$tfile should not exist"
382 [ -e $DIR/$tfile-2 ] || error "file $DIR/$tfile-2 does not exist"
383 munlink $DIR/$tfile-2 || error "munlink $DIR/$tfile-2 failed"
385 run_test 16 "|X| open(O_CREAT), unlink, touch new, unlink new"
388 replay_barrier $SINGLEMDS
389 multiop_bg_pause $DIR/$tfile O_c ||
390 error "multiop_bg_pause $DIR/$tfile failed"
393 kill -USR1 $pid || error "multiop $pid not running"
394 wait $pid || error "multiop $pid failed"
395 $CHECKSTAT -t file $DIR/$tfile ||
396 error "$CHECKSTAT $DIR/$tfile attribute check failed"
399 run_test 17 "|X| open(O_CREAT), |replay| close"
402 replay_barrier $SINGLEMDS
403 multiop_bg_pause $DIR/$tfile O_tSc ||
404 error "multiop_bg_pause $DIR/$tfile failed"
407 touch $DIR/$tfile-2 || error "touch $DIR/$tfile-2 failed"
408 echo "pid: $pid will close"
409 kill -USR1 $pid || error "multiop $pid not running"
410 wait $pid || error "multiop $pid failed"
413 [ -e $DIR/$tfile ] && error "file $DIR/$tfile should not exist"
414 [ -e $DIR/$tfile-2 ] || error "file $DIR/$tfile-2 does not exist"
415 # this touch frequently fails
416 touch $DIR/$tfile-3 || error "touch $DIR/$tfile-3 failed"
417 munlink $DIR/$tfile-2 || error "munlink $DIR/$tfile-2 failed"
418 munlink $DIR/$tfile-3 || error "munlink $DIR/$tfile-3 failed"
421 run_test 18 "open(O_CREAT), unlink, touch new, close, touch, unlink"
423 # bug 1855 (a simpler form of test_11 above)
425 replay_barrier $SINGLEMDS
427 echo "old" > $DIR/$tfile
428 mv $DIR/$tfile $DIR/$tfile-2
429 grep old $DIR/$tfile-2
431 grep old $DIR/$tfile-2 || error "grep $DIR/$tfile-2 failed"
433 run_test 19 "mcreate, open, write, rename "
435 test_20a() { # was test_20
436 replay_barrier $SINGLEMDS
437 multiop_bg_pause $DIR/$tfile O_tSc ||
438 error "multiop_bg_pause $DIR/$tfile failed"
443 kill -USR1 $pid || error "multiop $pid not running"
444 wait $pid || error "multiop $pid failed"
445 [ -e $DIR/$tfile ] && error "file $DIR/$tfile should not exist"
448 run_test 20a "|X| open(O_CREAT), unlink, replay, close (test mds_cleanup_orphans)"
450 test_20b() { # bug 10480
451 local wait_timeout=$((TIMEOUT * 4))
455 BEFOREUSED=$(df -P $DIR | tail -1 | awk '{ print $3 }')
456 dd if=/dev/zero of=$DIR/$tfile bs=4k count=10000 &
457 while [ ! -e $DIR/$tfile ] ; do
458 usleep 60 # give dd a chance to start
461 $GETSTRIPE $DIR/$tfile || error "$GETSTRIPE $DIR/$tfile failed"
463 rm -f $DIR/$tfile || error "rm -f $DIR/$tfile failed"
465 client_up || client_up || true # reconnect
467 do_facet $SINGLEMDS "lctl set_param -n osd*.*MDT*.force_sync 1"
469 fail $SINGLEMDS # start orphan recovery
470 wait_recovery_complete $SINGLEMDS || error "MDS recovery not done"
471 wait_delete_completed_mds $wait_timeout ||
472 error "delete did not complete"
474 AFTERUSED=$(df -P $DIR | tail -1 | awk '{ print $3 }')
475 log "before $BEFOREUSED, after $AFTERUSED"
476 (( $AFTERUSED > $BEFOREUSED + $(fs_log_size) )) &&
477 error "after $AFTERUSED > before $BEFOREUSED"
480 run_test 20b "write, unlink, eviction, replay, (test mds_cleanup_orphans)"
482 test_20c() { # bug 10480
483 multiop_bg_pause $DIR/$tfile Ow_c ||
484 error "multiop_bg_pause $DIR/$tfile failed"
490 client_up || client_up || true # reconnect
492 kill -USR1 $pid || error "multiop $pid not running"
493 wait $pid || error "multiop $pid failed"
494 [ -s $DIR/$tfile ] || error "File was truncated"
498 run_test 20c "check that client eviction does not affect file content"
501 replay_barrier $SINGLEMDS
502 multiop_bg_pause $DIR/$tfile O_tSc ||
503 error "multiop_bg_pause $DIR/$tfile failed"
506 touch $DIR/$tfile-1 || error "touch $DIR/$tfile-1 failed"
509 kill -USR1 $pid || error "multiop $pid not running"
510 wait $pid || error "multiop $pid failed"
511 [ -e $DIR/$tfile ] && error "file $DIR/$tfile should not exist"
512 touch $DIR/$tfile-2 || error "touch $DIR/$tfile-2 failed"
515 run_test 21 "|X| open(O_CREAT), unlink touch new, replay, close (test mds_cleanup_orphans)"
518 multiop_bg_pause $DIR/$tfile O_tSc ||
519 error "multiop_bg_pause $DIR/$tfile failed"
522 replay_barrier $SINGLEMDS
526 kill -USR1 $pid || error "multiop $pid not running"
527 wait $pid || error "multiop $pid failed"
528 [ -e $DIR/$tfile ] && error "file $DIR/$tfile should not exist"
531 run_test 22 "open(O_CREAT), |X| unlink, replay, close (test mds_cleanup_orphans)"
534 multiop_bg_pause $DIR/$tfile O_tSc ||
535 error "multiop_bg_pause $DIR/$tfile failed"
538 replay_barrier $SINGLEMDS
540 touch $DIR/$tfile-1 || error "touch $DIR/$tfile-1 failed"
543 kill -USR1 $pid || error "multiop $pid not running"
544 wait $pid || error "multiop $pid failed"
545 [ -e $DIR/$tfile ] && error "file $DIR/$tfile should not exist"
546 touch $DIR/$tfile-2 || error "touch $DIR/$tfile-2 failed"
549 run_test 23 "open(O_CREAT), |X| unlink touch new, replay, close (test mds_cleanup_orphans)"
552 multiop_bg_pause $DIR/$tfile O_tSc ||
553 error "multiop_bg_pause $DIR/$tfile failed"
556 replay_barrier $SINGLEMDS
559 kill -USR1 $pid || error "multiop $pid not running"
560 wait $pid || error "multiop $pid failed"
561 [ -e $DIR/$tfile ] && error "file $DIR/$tfile should not exist"
564 run_test 24 "open(O_CREAT), replay, unlink, close (test mds_cleanup_orphans)"
567 multiop_bg_pause $DIR/$tfile O_tSc ||
568 error "multiop_bg_pause $DIR/$tfile failed"
572 replay_barrier $SINGLEMDS
574 kill -USR1 $pid || error "multiop $pid not running"
575 wait $pid || error "multiop $pid failed"
576 [ -e $DIR/$tfile ] && error "file $DIR/$tfile should not exist"
579 run_test 25 "open(O_CREAT), unlink, replay, close (test mds_cleanup_orphans)"
582 replay_barrier $SINGLEMDS
583 multiop_bg_pause $DIR/$tfile-1 O_tSc ||
584 error "multiop_bg_pause $DIR/$tfile-1 failed"
586 multiop_bg_pause $DIR/$tfile-2 O_tSc ||
587 error "multiop_bg_pause $DIR/$tfile-2 failed"
591 kill -USR1 $pid2 || error "second multiop $pid2 not running"
592 wait $pid2 || error "second multiop $pid2 failed"
595 kill -USR1 $pid1 || error "multiop $pid1 not running"
596 wait $pid1 || error "multiop $pid1 failed"
597 [ -e $DIR/$tfile-1 ] && error "file $DIR/$tfile-1 should not exist"
598 [ -e $DIR/$tfile-2 ] && error "file $DIR/$tfile-2 should not exist"
601 run_test 26 "|X| open(O_CREAT), unlink two, close one, replay, close one (test mds_cleanup_orphans)"
604 replay_barrier $SINGLEMDS
605 multiop_bg_pause $DIR/$tfile-1 O_tSc ||
606 error "multiop_bg_pause $DIR/$tfile-1 failed"
608 multiop_bg_pause $DIR/$tfile-2 O_tSc ||
609 error "multiop_bg_pause $DIR/$tfile-2 failed"
615 kill -USR1 $pid1 || error "multiop $pid1 not running"
616 wait $pid1 || error "multiop $pid1 failed"
617 kill -USR1 $pid2 || error "second multiop $pid2 not running"
618 wait $pid2 || error "second multiop $pid2 failed"
619 [ -e $DIR/$tfile-1 ] && error "file $DIR/$tfile-1 should not exist"
620 [ -e $DIR/$tfile-2 ] && error "file $DIR/$tfile-2 should not exist"
623 run_test 27 "|X| open(O_CREAT), unlink two, replay, close two (test mds_cleanup_orphans)"
626 multiop_bg_pause $DIR/$tfile-1 O_tSc ||
627 error "multiop_bg_pause $DIR/$tfile-1 failed"
629 multiop_bg_pause $DIR/$tfile-2 O_tSc ||
630 error "multiop_bg_pause $DIR/$tfile-2 failed"
632 replay_barrier $SINGLEMDS
635 kill -USR1 $pid2 || error "second multiop $pid2 not running"
636 wait $pid2 || error "second multiop $pid2 failed"
639 kill -USR1 $pid1 || error "multiop $pid1 not running"
640 wait $pid1 || error "multiop $pid1 failed"
641 [ -e $DIR/$tfile-1 ] && error "file $DIR/$tfile-1 should not exist"
642 [ -e $DIR/$tfile-2 ] && error "file $DIR/$tfile-2 should not exist"
645 run_test 28 "open(O_CREAT), |X| unlink two, close one, replay, close one (test mds_cleanup_orphans)"
648 multiop_bg_pause $DIR/$tfile-1 O_tSc ||
649 error "multiop_bg_pause $DIR/$tfile-1 failed"
651 multiop_bg_pause $DIR/$tfile-2 O_tSc ||
652 error "multiop_bg_pause $DIR/$tfile-2 failed"
654 replay_barrier $SINGLEMDS
659 kill -USR1 $pid1 || error "multiop $pid1 not running"
660 wait $pid1 || error "multiop $pid1 failed"
661 kill -USR1 $pid2 || error "second multiop $pid2 not running"
662 wait $pid2 || error "second multiop $pid2 failed"
663 [ -e $DIR/$tfile-1 ] && error "file $DIR/$tfile-1 should not exist"
664 [ -e $DIR/$tfile-2 ] && error "file $DIR/$tfile-2 should not exist"
667 run_test 29 "open(O_CREAT), |X| unlink two, replay, close two (test mds_cleanup_orphans)"
670 multiop_bg_pause $DIR/$tfile-1 O_tSc ||
671 error "multiop_bg_pause $DIR/$tfile-1 failed"
673 multiop_bg_pause $DIR/$tfile-2 O_tSc ||
674 error "multiop_bg_pause $DIR/$tfile-2 failed"
679 replay_barrier $SINGLEMDS
681 kill -USR1 $pid1 || error "multiop $pid1 not running"
682 wait $pid1 || error "multiop $pid1 failed"
683 kill -USR1 $pid2 || error "second multiop $pid2 not running"
684 wait $pid2 || error "second multiop $pid2 failed"
685 [ -e $DIR/$tfile-1 ] && error "file $DIR/$tfile-1 should not exist"
686 [ -e $DIR/$tfile-2 ] && error "file $DIR/$tfile-2 should not exist"
689 run_test 30 "open(O_CREAT) two, unlink two, replay, close two (test mds_cleanup_orphans)"
692 multiop_bg_pause $DIR/$tfile-1 O_tSc ||
693 error "multiop_bg_pause $DIR/$tfile-1 failed"
695 multiop_bg_pause $DIR/$tfile-2 O_tSc ||
696 error "multiop_bg_pause $DIR/$tfile-2 failed"
700 replay_barrier $SINGLEMDS
703 kill -USR1 $pid1 || error "multiop $pid1 not running"
704 wait $pid1 || error "multiop $pid1 failed"
705 kill -USR1 $pid2 || error "second multiop $pid2 not running"
706 wait $pid2 || error "second multiop $pid2 failed"
707 [ -e $DIR/$tfile-1 ] && error "file $DIR/$tfile-1 should not exist"
708 [ -e $DIR/$tfile-2 ] && error "file $DIR/$tfile-2 should not exist"
711 run_test 31 "open(O_CREAT) two, unlink one, |X| unlink one, close two (test mds_cleanup_orphans)"
713 # tests for bug 2104; completion without crashing is success. The close is
714 # stale, but we always return 0 for close, so the app never sees it.
716 multiop_bg_pause $DIR/$tfile O_c ||
717 error "multiop_bg_pause $DIR/$tfile failed"
719 multiop_bg_pause $DIR/$tfile O_c ||
720 error "second multiop_bg_pause $DIR/$tfile failed"
723 client_up || client_up || error "client_up failed"
724 kill -USR1 $pid1 || error "multiop $pid1 not running"
725 kill -USR1 $pid2 || error "second multiop $pid2 not running"
726 wait $pid1 || error "multiop $pid1 failed"
727 wait $pid2 || error "second multiop $pid2 failed"
730 run_test 32 "close() notices client eviction; close() after client eviction"
733 createmany -o $DIR/$tfile-%d 10 ||
734 error "createmany create $DIR/$tfile failed"
735 replay_barrier_nosync $SINGLEMDS
736 fail_abort $SINGLEMDS
737 # recreate shouldn't fail
738 createmany -o $DIR/$tfile--%d 10 ||
739 error "createmany recreate $DIR/$tfile failed"
743 run_test 33a "fid seq shouldn't be reused after abort recovery"
746 #define OBD_FAIL_SEQ_ALLOC 0x1311
747 do_facet $SINGLEMDS "lctl set_param fail_loc=0x1311"
749 createmany -o $DIR/$tfile-%d 10
750 replay_barrier_nosync $SINGLEMDS
751 fail_abort $SINGLEMDS
752 # recreate shouldn't fail
753 createmany -o $DIR/$tfile--%d 10 ||
754 error "createmany recreate $DIR/$tfile failed"
758 run_test 33b "test fid seq allocation"
761 multiop_bg_pause $DIR/$tfile O_c ||
762 error "multiop_bg_pause $DIR/$tfile failed"
766 replay_barrier $SINGLEMDS
767 fail_abort $SINGLEMDS
768 kill -USR1 $pid || error "multiop $pid not running"
769 wait $pid || error "multiop $pid failed"
770 [ -e $DIR/$tfile ] && error "file $DIR/$tfile should not exist"
774 run_test 34 "abort recovery before client does replay (test mds_cleanup_orphans)"
776 # bug 2278 - generate one orphan on OST, then destroy it during recovery from llog
778 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
780 #define OBD_FAIL_MDS_REINT_NET_REP 0x119
781 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000119"
786 # give a chance to remove from MDS
787 fail_abort $SINGLEMDS
788 $CHECKSTAT -t file $DIR/$tfile &&
789 error "$CHECKSTAT $DIR/$tfile attribute check should fail" ||
792 run_test 35 "test recovery from llog for unlink op"
794 # b=2432 resent cancel after replay uses wrong cookie,
795 # so don't resend cancels
797 replay_barrier $SINGLEMDS
799 checkstat $DIR/$tfile
800 facet_failover $SINGLEMDS
802 if dmesg | grep "unknown lock cookie"; then
803 error "cancel after replay failed"
806 run_test 36 "don't resend cancel"
809 # directory orphans can't be unlinked from PENDING directory
811 rmdir $DIR/$tfile 2>/dev/null
812 multiop_bg_pause $DIR/$tfile dD_c ||
813 error "multiop_bg_pause $DIR/$tfile failed"
817 replay_barrier $SINGLEMDS
818 # clear the dmesg buffer so we only see errors from this recovery
819 do_facet $SINGLEMDS dmesg -c >/dev/null
820 fail_abort $SINGLEMDS
821 kill -USR1 $pid || error "multiop $pid not running"
822 do_facet $SINGLEMDS dmesg | grep "error .* unlinking .* from PENDING" &&
823 error "error unlinking files"
824 wait $pid || error "multiop $pid failed"
828 run_test 37 "abort recovery before client does replay (test mds_cleanup_orphans for directories)"
831 createmany -o $DIR/$tfile-%d 800 ||
832 error "createmany -o $DIR/$tfile failed"
833 unlinkmany $DIR/$tfile-%d 0 400 || error "unlinkmany $DIR/$tfile failed"
834 replay_barrier $SINGLEMDS
836 unlinkmany $DIR/$tfile-%d 400 400 ||
837 error "unlinkmany $DIR/$tfile 400 failed"
839 $CHECKSTAT -t file $DIR/$tfile-* &&
840 error "$CHECKSTAT $DIR/$tfile-* attribute check should fail" ||
843 run_test 38 "test recovery from unlink llog (test llog_gen_rec) "
845 test_39() { # bug 4176
846 createmany -o $DIR/$tfile-%d 800 ||
847 error "createmany -o $DIR/$tfile failed"
848 replay_barrier $SINGLEMDS
849 unlinkmany $DIR/$tfile-%d 0 400
851 unlinkmany $DIR/$tfile-%d 400 400 ||
852 error "unlinkmany $DIR/$tfile 400 failed"
854 $CHECKSTAT -t file $DIR/$tfile-* &&
855 error "$CHECKSTAT $DIR/$tfile-* attribute check should fail" ||
858 run_test 39 "test recovery from unlink llog (test llog_gen_rec) "
861 lctl get_param -n osc.*.stats | awk -vwrites=0 '/ost_write/ { writes += $2 } END { print writes; }'
866 # always need connection to MDS to verify layout during IO. LU-2628.
867 lctl get_param mdc.*.connect_flags | grep -q layout_lock &&
868 skip "layout_lock needs MDS connection for IO" && return 0
870 $LCTL mark multiop $MOUNT/$tfile OS_c
871 multiop $MOUNT/$tfile OS_c &
873 writeme -s $MOUNT/${tfile}-2 &
876 facet_failover $SINGLEMDS
877 #define OBD_FAIL_MDS_CONNECT_NET 0x117
878 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000117"
880 stat1=$(count_ost_writes)
882 stat2=$(count_ost_writes)
883 echo "$stat1, $stat2"
884 if [ $stat1 -lt $stat2 ]; then
885 echo "writes continuing during recovery"
888 echo "writes not continuing during recovery, bug 2477"
891 echo "waiting for writeme $WRITE_PID"
895 echo "waiting for multiop $PID"
896 wait $PID || error "multiop $PID failed"
897 do_facet client munlink $MOUNT/$tfile ||
898 error "munlink $MOUNT/$tfile failed"
899 do_facet client munlink $MOUNT/${tfile}-2 ||
900 error "munlink $MOUNT/$tfile-2 failed"
903 run_test 40 "cause recovery in ptlrpc, ensure IO continues"
906 # make sure that a read to one osc doesn't try to double-unlock its page just
907 # because another osc is invalid. trigger_group_io used to mistakenly return
908 # an error if any oscs were invalid even after having successfully put rpcs
909 # on valid oscs. This was fatal if the caller was ll_readpage who unlocked
910 # the page, guarnateeing that the unlock from the RPC completion would
911 # assert on trying to unlock the unlocked page.
913 [ $OSTCOUNT -lt 2 ] &&
914 skip_env "skipping test 41: we don't have a second OST to test with" &&
917 local f=$MOUNT/$tfile
918 # make sure the start of the file is ost1
919 $SETSTRIPE -S $((128 * 1024)) -i 0 $f
920 do_facet client dd if=/dev/zero of=$f bs=4k count=1 ||
921 error "dd on client failed"
923 # fail ost2 and read from ost1
924 local mdtosc=$(get_mdtosc_proc_path $SINGLEMDS $ost2_svc)
925 local osc2dev=$(do_facet $SINGLEMDS "lctl get_param -n devices" |
926 grep $mdtosc | awk '{print $1}')
927 [ -z "$osc2dev" ] && echo "OST: $ost2_svc" &&
928 lctl get_param -n devices &&
929 error "OST 2 $osc2dev does not exist"
930 do_facet $SINGLEMDS $LCTL --device $osc2dev deactivate ||
931 error "deactive device on $SINGLEMDS failed"
932 do_facet client dd if=$f of=/dev/null bs=4k count=1 ||
933 error "second dd on client failed"
934 do_facet $SINGLEMDS $LCTL --device $osc2dev activate ||
935 error "active device on $SINGLEMDS failed"
938 run_test 41 "read from a valid osc while other oscs are invalid"
940 # test MDS recovery after ost failure
942 blocks=$(df -P $MOUNT | tail -n 1 | awk '{ print $2 }')
943 createmany -o $DIR/$tfile-%d 800 ||
944 error "createmany -o $DIR/$tfile failed"
946 unlinkmany $DIR/$tfile-%d 0 400
948 lctl set_param debug=-1
951 # osc is evicted, fs is smaller (but only with failout OSTs (bug 7287)
952 #blocks_after=`df -P $MOUNT | tail -n 1 | awk '{ print $2 }'`
953 #[ $blocks_after -lt $blocks ] || return 1
954 echo "wait for MDS to timeout and recover"
955 sleep $((TIMEOUT * 2))
957 unlinkmany $DIR/$tfile-%d 400 400 ||
958 error "unlinkmany $DIR/$tfile 400 failed"
959 $CHECKSTAT -t file $DIR/$tfile-* &&
960 error "$CHECKSTAT $DIR/$tfile-* attribute check should fail" ||
963 run_test 42 "recovery after ost failure"
965 # timeout in MDS/OST recovery RPC will LBUG MDS
966 test_43() { # bug 2530
967 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
969 replay_barrier $SINGLEMDS
971 # OBD_FAIL_OST_CREATE_NET 0x204
972 do_facet ost1 "lctl set_param fail_loc=0x80000204"
978 run_test 43 "mds osc import failure during recovery; don't LBUG"
980 test_44a() { # was test_44
983 local mdcdev=$($LCTL dl |
984 awk "/${FSNAME}-MDT0000-mdc-/ {if (\$2 == \"UP\") {print \$1}}")
985 [ "$mdcdev" ] || error "${FSNAME}-MDT0000-mdc- not UP"
986 [ $(echo $mdcdev | wc -w) -eq 1 ] ||
987 { $LCTL dl; error "looking for mdcdev=$mdcdev"; }
989 # adaptive timeouts slow this way down
990 if at_is_enabled; then
991 at_max_saved=$(at_max_get mds)
995 for i in $(seq 1 10); do
996 echo "$i of 10 ($(date +%s))"
997 do_facet $SINGLEMDS \
998 "lctl get_param -n md[ts].*.mdt.timeouts | grep service"
999 #define OBD_FAIL_TGT_CONN_RACE 0x701
1000 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000701"
1001 # lctl below may fail, it is valid case
1002 $LCTL --device $mdcdev recover
1005 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
1006 [ $at_max_saved -ne 0 ] && at_max_set $at_max_saved mds
1009 run_test 44a "race in target handle connect"
1012 local mdcdev=$($LCTL dl |
1013 awk "/${FSNAME}-MDT0000-mdc-/ {if (\$2 == \"UP\") {print \$1}}")
1014 [ "$mdcdev" ] || error "${FSNAME}-MDT0000-mdc not up"
1015 [ $(echo $mdcdev | wc -w) -eq 1 ] ||
1016 { echo mdcdev=$mdcdev; $LCTL dl;
1017 error "more than one ${FSNAME}-MDT0000-mdc"; }
1019 for i in $(seq 1 10); do
1020 echo "$i of 10 ($(date +%s))"
1021 do_facet $SINGLEMDS \
1022 "lctl get_param -n md[ts].*.mdt.timeouts | grep service"
1023 #define OBD_FAIL_TGT_DELAY_RECONNECT 0x704
1024 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000704"
1025 # lctl below may fail, it is valid case
1026 $LCTL --device $mdcdev recover
1031 run_test 44b "race in target handle connect"
1034 replay_barrier $SINGLEMDS
1035 createmany -m $DIR/$tfile-%d 100 || error "failed to create directories"
1036 #define OBD_FAIL_TGT_RCVG_FLAG 0x712
1037 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000712"
1038 fail_abort $SINGLEMDS
1039 unlinkmany $DIR/$tfile-%d 100 && error "unliked after fail abort"
1041 unlinkmany $DIR/$tfile-%d 100 && error "unliked after fail"
1044 run_test 44c "race in target handle connect"
1046 # Handle failed close
1048 local mdcdev=$($LCTL get_param -n devices |
1049 awk "/ ${FSNAME}-MDT0000-mdc-/ {print \$1}")
1050 [ "$mdcdev" ] || error "${FSNAME}-MDT0000-mdc not up"
1051 [ $(echo $mdcdev | wc -w) -eq 1 ] ||
1052 { echo mdcdev=$mdcdev; $LCTL dl;
1053 error "more than one ${FSNAME}-MDT0000-mdc"; }
1055 $LCTL --device $mdcdev recover ||
1056 error "$LCTL --device $mdcdev recover failed"
1058 multiop_bg_pause $DIR/$tfile O_c ||
1059 error "multiop_bg_pause $DIR/$tfile failed"
1062 # This will cause the CLOSE to fail before even
1063 # allocating a reply buffer
1064 $LCTL --device $mdcdev deactivate ||
1065 error "$LCTL --device $mdcdev deactivate failed"
1068 kill -USR1 $pid || error "multiop $pid not running"
1069 wait $pid || error "multiop $pid failed"
1071 $LCTL --device $mdcdev activate ||
1072 error "$LCTL --device $mdcdev activate failed"
1075 $CHECKSTAT -t file $DIR/$tfile ||
1076 error "$CHECKSTAT $DIR/$tfile attribute check failed"
1079 run_test 45 "Handle failed close"
1083 drop_reply "touch $DIR/$tfile"
1085 # ironically, the previous test, 45, will cause a real forced close,
1086 # so just look for one for this test
1087 dmesg | grep -i "force closing client file handle for $tfile" &&
1088 error "found force closing in dmesg"
1091 run_test 46 "Don't leak file handle after open resend (3325)"
1093 test_47() { # bug 2824
1094 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1096 # create some files to make sure precreate has been done on all
1097 # OSTs. (just in case this test is run independently)
1098 createmany -o $DIR/$tfile 20 ||
1099 error "createmany create $DIR/$tfile failed"
1101 # OBD_FAIL_OST_CREATE_NET 0x204
1103 do_facet ost1 "lctl set_param fail_loc=0x80000204"
1104 client_up || error "client_up failed"
1106 # let the MDS discover the OST failure, attempt to recover, fail
1107 # and recover again.
1108 sleep $((3 * TIMEOUT))
1110 # Without 2824, this createmany would hang
1111 createmany -o $DIR/$tfile 20 ||
1112 error "createmany recraete $DIR/$tfile failed"
1113 unlinkmany $DIR/$tfile 20 || error "unlinkmany $DIR/$tfile failed"
1117 run_test 47 "MDS->OSC failure during precreate cleanup (2824)"
1120 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1121 [ "$OSTCOUNT" -lt "2" ] &&
1122 skip_env "$OSTCOUNT < 2 OSTs -- skipping" && return
1124 replay_barrier $SINGLEMDS
1125 createmany -o $DIR/$tfile 20 ||
1126 error "createmany -o $DIR/$tfile failed"
1127 # OBD_FAIL_OST_EROFS 0x216
1128 facet_failover $SINGLEMDS
1129 do_facet ost1 "lctl set_param fail_loc=0x80000216"
1130 client_up || error "client_up failed"
1132 createmany -o $DIR/$tfile 20 20 ||
1133 error "createmany recraete $DIR/$tfile failed"
1134 unlinkmany $DIR/$tfile 40 || error "unlinkmany $DIR/$tfile failed"
1137 run_test 48 "MDS->OSC failure during precreate cleanup (2824)"
1140 local mdtosc=$(get_mdtosc_proc_path $SINGLEMDS $ost1_svc)
1141 local oscdev=$(do_facet $SINGLEMDS "lctl get_param -n devices" |
1142 grep $mdtosc | awk '{print $1}')
1143 [ "$oscdev" ] || error "could not find OSC device on MDS"
1144 do_facet $SINGLEMDS $LCTL --device $oscdev recover ||
1145 error "OSC device $oscdev recovery failed"
1146 do_facet $SINGLEMDS $LCTL --device $oscdev recover ||
1147 error "second OSC device $oscdev recovery failed"
1148 # give the mds_lov_sync threads a chance to run
1151 run_test 50 "Double OSC recovery, don't LASSERT (3812)"
1153 # b3764 timed out lock replay
1155 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.6.90) ] &&
1156 skip "MDS prior to 2.6.90 handle LDLM_REPLY_NET incorrectly" &&
1159 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
1160 cancel_lru_locks mdc
1162 multiop_bg_pause $DIR/$tfile s_s || error "multiop $DIR/$tfile failed"
1165 #define OBD_FAIL_MDS_LDLM_REPLY_NET 0x157
1166 lctl set_param -n ldlm.cancel_unused_locks_before_replay "0"
1167 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000157"
1169 fail $SINGLEMDS || error "fail $SINGLEMDS failed"
1171 wait $mpid || error "multiop_bg_pause pid failed"
1173 do_facet $SINGLEMDS "lctl set_param fail_loc=0x0"
1174 lctl set_param fail_loc=0x0
1175 lctl set_param -n ldlm.cancel_unused_locks_before_replay "1"
1178 run_test 52 "time out lock replay (3764)"
1180 # bug 3462 - simultaneous MDC requests
1182 [[ $(lctl get_param mdc.*.import |
1183 grep "connect_flags:.*multi_mod_rpc") ]] ||
1184 { skip "Need MDC with 'multi_mod_rpcs' feature"; return 0; }
1186 cancel_lru_locks mdc # cleanup locks from former test cases
1187 mkdir $DIR/${tdir}-1 || error "mkdir $DIR/${tdir}-1 failed"
1188 mkdir $DIR/${tdir}-2 || error "mkdir $DIR/${tdir}-2 failed"
1189 multiop $DIR/${tdir}-1/f O_c &
1191 # give multiop a change to open
1194 #define OBD_FAIL_MDS_CLOSE_NET 0x115
1195 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000115"
1196 kill -USR1 $close_pid
1197 cancel_lru_locks mdc # force the close
1198 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
1200 mcreate $DIR/${tdir}-2/f || error "mcreate $DIR/${tdir}-2/f failed"
1202 # close should still be here
1203 [ -d /proc/$close_pid ] || error "close_pid doesn't exist"
1205 replay_barrier_nodf $SINGLEMDS
1207 wait $close_pid || error "close_pid $close_pid failed"
1209 $CHECKSTAT -t file $DIR/${tdir}-1/f ||
1210 error "$CHECKSTAT $DIR/${tdir}-1/f attribute check failed"
1211 $CHECKSTAT -t file $DIR/${tdir}-2/f ||
1212 error "$CHECKSTAT $DIR/${tdir}-2/f attribute check failed"
1213 rm -rf $DIR/${tdir}-*
1215 run_test 53a "|X| close request while two MDC requests in flight"
1218 cancel_lru_locks mdc # cleanup locks from former test cases
1220 mkdir $DIR/${tdir}-1 || error "mkdir $DIR/${tdir}-1 failed"
1221 mkdir $DIR/${tdir}-2 || error "mkdir $DIR/${tdir}-2 failed"
1222 multiop_bg_pause $DIR/${tdir}-1/f O_c ||
1223 error "multiop_bg_pause $DIR/${tdir}-1/f failed"
1226 #define OBD_FAIL_MDS_REINT_NET 0x107
1227 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000107"
1228 mcreate $DIR/${tdir}-2/f &
1232 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
1233 kill -USR1 $close_pid
1234 cancel_lru_locks mdc # force the close
1235 wait $close_pid || error "close_pid $close_pid failed"
1236 # open should still be here
1237 [ -d /proc/$open_pid ] || error "open_pid doesn't exist"
1239 replay_barrier_nodf $SINGLEMDS
1241 wait $open_pid || error "open_pid failed"
1243 $CHECKSTAT -t file $DIR/${tdir}-1/f ||
1244 error "$CHECKSTAT $DIR/${tdir}-1/f attribute check failed"
1245 $CHECKSTAT -t file $DIR/${tdir}-2/f ||
1246 error "$CHECKSTAT $DIR/${tdir}-2/f attribute check failed"
1247 rm -rf $DIR/${tdir}-*
1249 run_test 53b "|X| open request while two MDC requests in flight"
1252 cancel_lru_locks mdc # cleanup locks from former test cases
1254 mkdir $DIR/${tdir}-1 || error "mkdir $DIR/${tdir}-1 failed"
1255 mkdir $DIR/${tdir}-2 || error "mkdir $DIR/${tdir}-2 failed"
1256 multiop $DIR/${tdir}-1/f O_c &
1259 #define OBD_FAIL_MDS_REINT_NET 0x107
1260 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000107"
1261 mcreate $DIR/${tdir}-2/f &
1265 #define OBD_FAIL_MDS_CLOSE_NET 0x115
1266 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000115"
1267 kill -USR1 $close_pid
1268 cancel_lru_locks mdc # force the close
1270 #bz20647: make sure all pids exist before failover
1271 [ -d /proc/$close_pid ] || error "close_pid doesn't exist"
1272 [ -d /proc/$open_pid ] || error "open_pid doesn't exists"
1273 replay_barrier_nodf $SINGLEMDS
1274 fail_nodf $SINGLEMDS
1275 wait $open_pid || error "open_pid failed"
1277 # close should be gone
1278 [ -d /proc/$close_pid ] && error "close_pid should not exist"
1279 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
1281 $CHECKSTAT -t file $DIR/${tdir}-1/f ||
1282 error "$CHECKSTAT $DIR/${tdir}-1/f attribute check failed"
1283 $CHECKSTAT -t file $DIR/${tdir}-2/f ||
1284 error "$CHECKSTAT $DIR/${tdir}-2/f attribute check failed"
1285 rm -rf $DIR/${tdir}-*
1287 run_test 53c "|X| open request and close request while two MDC requests in flight"
1290 [[ $(lctl get_param mdc.*.import |
1291 grep "connect_flags:.*multi_mod_rpc") ]] ||
1292 { skip "Need MDC with 'multi_mod_rpcs' feature"; return 0; }
1294 cancel_lru_locks mdc # cleanup locks from former test cases
1296 mkdir $DIR/${tdir}-1 || error "mkdir $DIR/${tdir}-1 failed"
1297 mkdir $DIR/${tdir}-2 || error "mkdir $DIR/${tdir}-2 failed"
1298 multiop $DIR/${tdir}-1/f O_c &
1300 # give multiop a chance to open
1303 #define OBD_FAIL_MDS_CLOSE_NET_REP 0x13b
1304 do_facet $SINGLEMDS "lctl set_param fail_loc=0x8000013b"
1305 kill -USR1 $close_pid
1306 cancel_lru_locks mdc # force the close
1307 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
1308 mcreate $DIR/${tdir}-2/f || error "mcreate $DIR/${tdir}-2/f failed"
1310 # close should still be here
1311 [ -d /proc/$close_pid ] || error "close_pid doesn't exist"
1313 wait $close_pid || error "close_pid failed"
1315 $CHECKSTAT -t file $DIR/${tdir}-1/f ||
1316 error "$CHECKSTAT $DIR/${tdir}-1/f attribute check failed"
1317 $CHECKSTAT -t file $DIR/${tdir}-2/f ||
1318 error "$CHECKSTAT $DIR/${tdir}-2/f attribute check failed"
1319 rm -rf $DIR/${tdir}-*
1321 run_test 53d "close reply while two MDC requests in flight"
1324 cancel_lru_locks mdc # cleanup locks from former test cases
1326 mkdir $DIR/${tdir}-1 || error "mkdir $DIR/${tdir}-1 failed"
1327 mkdir $DIR/${tdir}-2 || error "mkdir $DIR/${tdir}-2 failed"
1328 multiop $DIR/${tdir}-1/f O_c &
1331 #define OBD_FAIL_MDS_REINT_NET_REP 0x119
1332 do_facet $SINGLEMDS "lctl set_param fail_loc=0x119"
1333 mcreate $DIR/${tdir}-2/f &
1337 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
1338 kill -USR1 $close_pid
1339 cancel_lru_locks mdc # force the close
1340 wait $close_pid || error "close_pid failed"
1341 # open should still be here
1342 [ -d /proc/$open_pid ] || error "open_pid doesn't exists"
1344 replay_barrier_nodf $SINGLEMDS
1346 wait $open_pid || error "open_pid failed"
1348 $CHECKSTAT -t file $DIR/${tdir}-1/f ||
1349 error "$CHECKSTAT $DIR/${tdir}-1/f attribute check failed"
1350 $CHECKSTAT -t file $DIR/${tdir}-2/f ||
1351 error "$CHECKSTAT $DIR/${tdir}-2/f attribute check failed"
1352 rm -rf $DIR/${tdir}-*
1354 run_test 53e "|X| open reply while two MDC requests in flight"
1357 cancel_lru_locks mdc # cleanup locks from former test cases
1359 mkdir $DIR/${tdir}-1 || error "mkdir $DIR/${tdir}-1 failed"
1360 mkdir $DIR/${tdir}-2 || error "mkdir $DIR/${tdir}-2 failed"
1361 multiop $DIR/${tdir}-1/f O_c &
1364 #define OBD_FAIL_MDS_REINT_NET_REP 0x119
1365 do_facet $SINGLEMDS "lctl set_param fail_loc=0x119"
1366 mcreate $DIR/${tdir}-2/f &
1370 #define OBD_FAIL_MDS_CLOSE_NET_REP 0x13b
1371 do_facet $SINGLEMDS "lctl set_param fail_loc=0x8000013b"
1372 kill -USR1 $close_pid
1373 cancel_lru_locks mdc # force the close
1375 #bz20647: make sure all pids are exists before failover
1376 [ -d /proc/$close_pid ] || error "close_pid doesn't exist"
1377 [ -d /proc/$open_pid ] || error "open_pid doesn't exists"
1378 replay_barrier_nodf $SINGLEMDS
1379 fail_nodf $SINGLEMDS
1380 wait $open_pid || error "open_pid failed"
1382 # close should be gone
1383 [ -d /proc/$close_pid ] && error "close_pid should not exist"
1384 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
1386 $CHECKSTAT -t file $DIR/${tdir}-1/f ||
1387 error "$CHECKSTAT $DIR/${tdir}-1/f attribute check failed"
1388 $CHECKSTAT -t file $DIR/${tdir}-2/f ||
1389 error "$CHECKSTAT $DIR/${tdir}-2/f attribute check failed"
1390 rm -rf $DIR/${tdir}-*
1392 run_test 53f "|X| open reply and close reply while two MDC requests in flight"
1395 cancel_lru_locks mdc # cleanup locks from former test cases
1397 mkdir $DIR/${tdir}-1 || error "mkdir $DIR/${tdir}-1 failed"
1398 mkdir $DIR/${tdir}-2 || error "mkdir $DIR/${tdir}-2 failed"
1399 multiop $DIR/${tdir}-1/f O_c &
1402 #define OBD_FAIL_MDS_REINT_NET_REP 0x119
1403 do_facet $SINGLEMDS "lctl set_param fail_loc=0x119"
1404 mcreate $DIR/${tdir}-2/f &
1408 #define OBD_FAIL_MDS_CLOSE_NET 0x115
1409 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000115"
1410 kill -USR1 $close_pid
1411 cancel_lru_locks mdc # force the close
1412 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
1414 #bz20647: make sure all pids are exists before failover
1415 [ -d /proc/$close_pid ] || error "close_pid doesn't exist"
1416 [ -d /proc/$open_pid ] || error "open_pid doesn't exists"
1417 replay_barrier_nodf $SINGLEMDS
1418 fail_nodf $SINGLEMDS
1419 wait $open_pid || error "open_pid failed"
1421 # close should be gone
1422 [ -d /proc/$close_pid ] && error "close_pid should not exist"
1424 $CHECKSTAT -t file $DIR/${tdir}-1/f ||
1425 error "$CHECKSTAT $DIR/${tdir}-1/f attribute check failed"
1426 $CHECKSTAT -t file $DIR/${tdir}-2/f ||
1427 error "$CHECKSTAT $DIR/${tdir}-2/f attribute check failed"
1428 rm -rf $DIR/${tdir}-*
1430 run_test 53g "|X| drop open reply and close request while close and open are both in flight"
1433 cancel_lru_locks mdc # cleanup locks from former test cases
1435 mkdir $DIR/${tdir}-1 || error "mkdir $DIR/${tdir}-1 failed"
1436 mkdir $DIR/${tdir}-2 || error "mkdir $DIR/${tdir}-2 failed"
1437 multiop $DIR/${tdir}-1/f O_c &
1440 #define OBD_FAIL_MDS_REINT_NET 0x107
1441 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000107"
1442 mcreate $DIR/${tdir}-2/f &
1446 #define OBD_FAIL_MDS_CLOSE_NET_REP 0x13b
1447 do_facet $SINGLEMDS "lctl set_param fail_loc=0x8000013b"
1448 kill -USR1 $close_pid
1449 cancel_lru_locks mdc # force the close
1452 #bz20647: make sure all pids are exists before failover
1453 [ -d /proc/$close_pid ] || error "close_pid doesn't exist"
1454 [ -d /proc/$open_pid ] || error "open_pid doesn't exists"
1455 replay_barrier_nodf $SINGLEMDS
1456 fail_nodf $SINGLEMDS
1457 wait $open_pid || error "open_pid failed"
1459 # close should be gone
1460 [ -d /proc/$close_pid ] && error "close_pid should not exist"
1461 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
1463 $CHECKSTAT -t file $DIR/${tdir}-1/f ||
1464 error "$CHECKSTAT $DIR/${tdir}-1/f attribute check failed"
1465 $CHECKSTAT -t file $DIR/${tdir}-2/f ||
1466 error "$CHECKSTAT $DIR/${tdir}-2/f attribute check failed"
1467 rm -rf $DIR/${tdir}-*
1469 run_test 53h "open request and close reply while two MDC requests in flight"
1471 #b3761 ASSERTION(hash != 0) failed
1473 # OBD_FAIL_MDS_OPEN_CREATE | OBD_FAIL_ONCE
1474 do_facet $SINGLEMDS "lctl set_param fail_loc=0x8000012b"
1476 # give touch a chance to run
1478 do_facet $SINGLEMDS "lctl set_param fail_loc=0x0"
1482 run_test 55 "let MDS_CHECK_RESENT return the original return code instead of 0"
1484 #b3440 ASSERTION(rec->ur_fid2->id) failed
1486 ln -s foo $DIR/$tfile
1487 replay_barrier $SINGLEMDS
1488 #drop_reply "cat $DIR/$tfile"
1492 run_test 56 "don't replay a symlink open request (3440)"
1494 #recovery one mds-ost setattr from llog
1496 #define OBD_FAIL_MDS_OST_SETATTR 0x12c
1497 do_facet $SINGLEMDS "lctl set_param fail_loc=0x8000012c"
1498 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
1499 replay_barrier $SINGLEMDS
1502 $CHECKSTAT -t file $DIR/$tfile ||
1503 error "$CHECKSTAT $DIR/$tfile attribute check failed"
1504 do_facet $SINGLEMDS "lctl set_param fail_loc=0x0"
1507 run_test 57 "test recovery from llog for setattr op"
1510 zconf_umount $(hostname) $MOUNT2
1514 #recovery many mds-ost setattr from llog
1516 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
1517 #define OBD_FAIL_MDS_OST_SETATTR 0x12c
1518 do_facet $SINGLEMDS "lctl set_param fail_loc=0x8000012c"
1519 createmany -o $DIR/$tdir/$tfile-%d 2500
1520 replay_barrier $SINGLEMDS
1523 $CHECKSTAT -t file $DIR/$tdir/$tfile-* >/dev/null ||
1524 error "$CHECKSTAT $DIR/$tfile-* attribute check failed"
1525 do_facet $SINGLEMDS "lctl set_param fail_loc=0x0"
1526 unlinkmany $DIR/$tdir/$tfile-%d 2500 ||
1527 error "unlinkmany $DIR/$tfile failed"
1530 run_test 58a "test recovery from llog for setattr op (test llog_gen_rec)"
1536 trap cleanup_58 EXIT
1538 large_xattr_enabled &&
1539 orig="$(generate_string $(max_xattr_size))" || orig="bar"
1540 # Original extended attribute can be long. Print a small version of
1541 # attribute if an error occurs
1542 local sm_msg=$(printf "%.9s" $orig)
1544 mount_client $MOUNT2 || error "mount_client on $MOUNT2 failed"
1545 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
1546 touch $DIR/$tdir/$tfile || error "touch $DIR/$tdir/$tfile failed"
1547 replay_barrier $SINGLEMDS
1548 setfattr -n trusted.foo -v $orig $DIR/$tdir/$tfile
1550 new=$(get_xattr_value trusted.foo $MOUNT2/$tdir/$tfile)
1551 [[ "$new" = "$orig" ]] ||
1552 error "xattr set ($sm_msg...) differs from xattr get ($new)"
1553 rm -f $DIR/$tdir/$tfile
1556 wait_clients_import_state ${CLIENTS:-$HOSTNAME} "mgs" FULL
1558 run_test 58b "test replay of setxattr op"
1560 test_58c() { # bug 16570
1565 trap cleanup_58 EXIT
1567 if large_xattr_enabled; then
1568 local xattr_size=$(max_xattr_size)
1569 orig="$(generate_string $((xattr_size / 2)))"
1570 orig1="$(generate_string $xattr_size)"
1576 # PING_INTERVAL max(obd_timeout / 4, 1U)
1577 sleep $((TIMEOUT / 4))
1579 # Original extended attribute can be long. Print a small version of
1580 # attribute if an error occurs
1581 local sm_msg=$(printf "%.9s" $orig)
1582 local sm_msg1=$(printf "%.9s" $orig1)
1584 mount_client $MOUNT2 || error "mount_client on $MOUNT2 failed"
1585 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
1586 touch $DIR/$tdir/$tfile || error "touch $DIR/$tdir/$tfile failed"
1587 drop_request "setfattr -n trusted.foo -v $orig $DIR/$tdir/$tfile" ||
1588 error "drop_request for setfattr failed"
1589 new=$(get_xattr_value trusted.foo $MOUNT2/$tdir/$tfile)
1590 [[ "$new" = "$orig" ]] ||
1591 error "xattr set ($sm_msg...) differs from xattr get ($new)"
1592 drop_reint_reply "setfattr -n trusted.foo1 \
1593 -v $orig1 $DIR/$tdir/$tfile" ||
1594 error "drop_reint_reply for setfattr failed"
1595 new=$(get_xattr_value trusted.foo1 $MOUNT2/$tdir/$tfile)
1596 [[ "$new" = "$orig1" ]] ||
1597 error "second xattr set ($sm_msg1...) differs xattr get ($new)"
1598 rm -f $DIR/$tdir/$tfile
1602 run_test 58c "resend/reconstruct setxattr op"
1604 # log_commit_thread vs filter_destroy race used to lead to import use after free
1607 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1609 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
1610 createmany -o $DIR/$tdir/$tfile-%d 200 ||
1611 error "createmany create files failed"
1613 unlinkmany $DIR/$tdir/$tfile-%d 200 ||
1614 error "unlinkmany $DIR/$tdir/$tfile failed"
1615 #define OBD_FAIL_PTLRPC_DELAY_RECOV 0x507
1616 do_facet ost1 "lctl set_param fail_loc=0x507"
1619 do_facet ost1 "lctl set_param fail_loc=0x0"
1623 run_test 59 "test log_commit_thread vs filter_destroy race"
1625 # race between add unlink llog vs cat log init in post_recovery (only for b1_6)
1626 # bug 12086: should no oops and No ctxt error for this test
1628 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
1629 createmany -o $DIR/$tdir/$tfile-%d 200 ||
1630 error "createmany create files failed"
1631 replay_barrier $SINGLEMDS
1632 unlinkmany $DIR/$tdir/$tfile-%d 0 100
1634 unlinkmany $DIR/$tdir/$tfile-%d 100 100
1635 local no_ctxt=$(dmesg | grep "No ctxt")
1636 [ -z "$no_ctxt" ] || error "ctxt is not initialized in recovery"
1638 run_test 60 "test llog post recovery init vs llog unlink"
1640 #test race llog recovery thread vs llog cleanup
1641 test_61a() { # was test_61
1642 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1644 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
1645 createmany -o $DIR/$tdir/$tfile-%d 800 ||
1646 error "createmany create files failed"
1648 unlinkmany $DIR/$tdir/$tfile-%d 800
1649 # OBD_FAIL_OST_LLOG_RECOVERY_TIMEOUT 0x221
1650 set_nodes_failloc "$(osts_nodes)" 0x80000221
1655 set_nodes_failloc "$(osts_nodes)" 0x0
1657 $CHECKSTAT -t file $DIR/$tdir/$tfile-* &&
1658 error "$CHECKSTAT $DIR/$tdir/$tfile attribute check should fail"
1661 run_test 61a "test race llog recovery vs llog cleanup"
1663 #test race mds llog sync vs llog cleanup
1665 # OBD_FAIL_MDS_LLOG_SYNC_TIMEOUT 0x13a
1666 do_facet $SINGLEMDS "lctl set_param fail_loc=0x8000013a"
1667 facet_failover $SINGLEMDS
1670 do_facet client dd if=/dev/zero of=$DIR/$tfile bs=4k count=1 ||
1673 run_test 61b "test race mds llog sync vs llog cleanup"
1675 #test race cancel cookie cb vs llog cleanup
1677 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1679 # OBD_FAIL_OST_CANCEL_COOKIE_TIMEOUT 0x222
1680 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
1681 set_nodes_failloc "$(osts_nodes)" 0x80000222
1685 set_nodes_failloc "$(osts_nodes)" 0x0
1687 run_test 61c "test race mds llog sync vs llog cleanup"
1689 test_61d() { # bug 16002 # bug 17466 # bug 22137
1690 # OBD_FAIL_OBD_LLOG_SETUP 0x605
1692 do_facet mgs "lctl set_param fail_loc=0x80000605"
1693 start mgs $(mgsdevname) $MGS_MOUNT_OPTS &&
1694 error "mgs start should have failed"
1695 do_facet mgs "lctl set_param fail_loc=0"
1696 start mgs $(mgsdevname) $MGS_MOUNT_OPTS || error "cannot restart mgs"
1698 run_test 61d "error in llog_setup should cleanup the llog context correctly"
1700 test_62() { # Bug 15756 - don't mis-drop resent replay
1701 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
1702 replay_barrier $SINGLEMDS
1703 createmany -o $DIR/$tdir/$tfile- 25 ||
1704 error "createmany create files failed"
1705 #define OBD_FAIL_TGT_REPLAY_DROP 0x707
1706 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000707"
1708 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
1709 unlinkmany $DIR/$tdir/$tfile- 25 ||
1710 error "unlinkmany $DIR/$tdir/$tfile failed"
1713 run_test 62 "don't mis-drop resent replay"
1715 #Adaptive Timeouts (bug 3055)
1723 echo "Cleaning up AT ..."
1724 if [ -n "$ATOLDBASE" ]; then
1725 local at_history=$($LCTL get_param -n at_history)
1726 do_facet $SINGLEMDS "lctl set_param at_history=$at_history" || true
1727 do_facet ost1 "lctl set_param at_history=$at_history" || true
1730 if [ $AT_MAX_SET -ne 0 ]; then
1731 for facet in mds client ost; do
1732 var=AT_MAX_SAVE_${facet}
1733 echo restore AT on $facet to saved value ${!var}
1734 at_max_set ${!var} $facet
1735 at_new=$(at_max_get $facet)
1736 echo Restored AT value on $facet $at_new
1737 [ $at_new -eq ${!var} ] ||
1738 error "AT value not restored SAVED ${!var} NEW $at_new"
1745 local at_max_new=600
1747 # Save at_max original values
1749 if [ $AT_MAX_SET -eq 0 ]; then
1750 # Suppose that all osts have the same at_max
1751 for facet in mds client ost; do
1752 eval AT_MAX_SAVE_${facet}=$(at_max_get $facet)
1756 for facet in mds client ost; do
1757 at_max=$(at_max_get $facet)
1758 if [ $at_max -ne $at_max_new ]; then
1759 echo "AT value on $facet is $at_max, set it by force temporarily to $at_max_new"
1760 at_max_set $at_max_new $facet
1765 if [ -z "$ATOLDBASE" ]; then
1766 ATOLDBASE=$(do_facet $SINGLEMDS "lctl get_param -n at_history")
1767 # speed up the timebase so we can check decreasing AT
1768 do_facet $SINGLEMDS "lctl set_param at_history=8" || true
1769 do_facet ost1 "lctl set_param at_history=8" || true
1771 # sleep for a while to cool down, should be > 8s and also allow
1772 # at least one ping to be sent. simply use TIMEOUT to be safe.
1777 test_65a() #bug 3055
1779 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1781 at_start || return 0
1782 $LCTL dk > /dev/null
1784 $LCTL set_param debug="other"
1785 # Slow down a request to the current service time, this is critical
1786 # because previous tests may have caused this value to increase.
1787 REQ_DELAY=`lctl get_param -n mdc.${FSNAME}-MDT0000-mdc-*.timeouts |
1788 awk '/portal 12/ {print $5}'`
1789 REQ_DELAY=$((${REQ_DELAY} + ${REQ_DELAY} / 4 + 5))
1791 do_facet $SINGLEMDS lctl set_param fail_val=$((${REQ_DELAY} * 1000))
1792 #define OBD_FAIL_PTLRPC_PAUSE_REQ 0x50a
1793 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x8000050a
1794 createmany -o $DIR/$tfile 10 > /dev/null
1795 unlinkmany $DIR/$tfile 10 > /dev/null
1796 # check for log message
1797 $LCTL dk | grep "Early reply #" || error "No early reply"
1799 # client should show REQ_DELAY estimates
1800 lctl get_param -n mdc.${FSNAME}-MDT0000-mdc-*.timeouts | grep portal
1802 lctl get_param -n mdc.${FSNAME}-MDT0000-mdc-*.timeouts | grep portal
1804 run_test 65a "AT: verify early replies"
1806 test_65b() #bug 3055
1808 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1810 at_start || return 0
1813 $LCTL set_param debug="other trace"
1814 $LCTL dk > /dev/null
1815 # Slow down a request to the current service time, this is critical
1816 # because previous tests may have caused this value to increase.
1817 $SETSTRIPE --stripe-index=0 --count=1 $DIR/$tfile
1818 multiop $DIR/$tfile Ow1yc
1819 REQ_DELAY=`lctl get_param -n osc.${FSNAME}-OST0000-osc-*.timeouts |
1820 awk '/portal 6/ {print $5}'`
1821 REQ_DELAY=$((${REQ_DELAY} + ${REQ_DELAY} / 4 + 5))
1823 do_facet ost1 lctl set_param fail_val=${REQ_DELAY}
1824 #define OBD_FAIL_OST_BRW_PAUSE_PACK 0x224
1825 do_facet ost1 $LCTL set_param fail_loc=0x224
1828 $SETSTRIPE --stripe-index=0 --count=1 $DIR/$tfile
1829 # force some real bulk transfer
1830 multiop $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
1832 do_facet ost1 $LCTL set_param fail_loc=0
1833 # check for log message
1834 $LCTL dk | grep "Early reply #" || error "No early reply"
1836 # client should show REQ_DELAY estimates
1837 lctl get_param -n osc.${FSNAME}-OST0000-osc-*.timeouts | grep portal
1839 run_test 65b "AT: verify early replies on packed reply / bulk"
1841 test_66a() #bug 3055
1843 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1845 at_start || return 0
1846 lctl get_param -n mdc.${FSNAME}-MDT0000-mdc-*.timeouts | grep "portal 12"
1847 # adjust 5s at a time so no early reply is sent (within deadline)
1848 do_facet $SINGLEMDS "$LCTL set_param fail_val=5000"
1849 #define OBD_FAIL_PTLRPC_PAUSE_REQ 0x50a
1850 do_facet $SINGLEMDS "$LCTL set_param fail_loc=0x8000050a"
1851 createmany -o $DIR/$tfile 20 > /dev/null
1852 unlinkmany $DIR/$tfile 20 > /dev/null
1853 lctl get_param -n mdc.${FSNAME}-MDT0000-mdc-*.timeouts | grep "portal 12"
1854 do_facet $SINGLEMDS "$LCTL set_param fail_val=10000"
1855 do_facet $SINGLEMDS "$LCTL set_param fail_loc=0x8000050a"
1856 createmany -o $DIR/$tfile 20 > /dev/null
1857 unlinkmany $DIR/$tfile 20 > /dev/null
1858 lctl get_param -n mdc.${FSNAME}-MDT0000-mdc-*.timeouts | grep "portal 12"
1859 do_facet $SINGLEMDS "$LCTL set_param fail_loc=0"
1861 createmany -o $DIR/$tfile 20 > /dev/null
1862 unlinkmany $DIR/$tfile 20 > /dev/null
1863 lctl get_param -n mdc.${FSNAME}-MDT0000-mdc-*.timeouts | grep "portal 12"
1864 CUR=$(lctl get_param -n mdc.${FSNAME}-MDT0000-mdc-*.timeouts | awk '/portal 12/ {print $5}')
1865 WORST=$(lctl get_param -n mdc.${FSNAME}-MDT0000-mdc-*.timeouts | awk '/portal 12/ {print $7}')
1866 echo "Current MDT timeout $CUR, worst $WORST"
1867 [ $CUR -lt $WORST ] || error "Current $CUR should be less than worst $WORST"
1869 run_test 66a "AT: verify MDT service time adjusts with no early replies"
1871 test_66b() #bug 3055
1873 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1875 at_start || return 0
1876 ORIG=$(lctl get_param -n mdc.${FSNAME}-MDT0000*.timeouts |
1877 awk '/network/ {print $4}')
1878 $LCTL set_param fail_val=$(($ORIG + 5))
1879 #define OBD_FAIL_PTLRPC_PAUSE_REP 0x50c
1880 $LCTL set_param fail_loc=0x50c
1881 ls $DIR/$tfile > /dev/null 2>&1
1882 $LCTL set_param fail_loc=0
1883 CUR=$(lctl get_param -n mdc.${FSNAME}-MDT0000*.timeouts |
1884 awk '/network/ {print $4}')
1885 WORST=$(lctl get_param -n mdc.${FSNAME}-MDT0000*.timeouts |
1886 awk '/network/ {print $6}')
1887 echo "network timeout orig $ORIG, cur $CUR, worst $WORST"
1888 [ $WORST -gt $ORIG ] ||
1889 error "Worst $WORST should be worse than orig $ORIG"
1891 run_test 66b "AT: verify net latency adjusts"
1893 test_67a() #bug 3055
1895 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1897 at_start || return 0
1898 CONN1=$(lctl get_param -n osc.*.stats | awk '/_connect/ {total+=$2} END {print total}')
1899 # sleeping threads may drive values above this
1900 do_facet ost1 "$LCTL set_param fail_val=400"
1901 #define OBD_FAIL_PTLRPC_PAUSE_REQ 0x50a
1902 do_facet ost1 "$LCTL set_param fail_loc=0x50a"
1903 createmany -o $DIR/$tfile 20 > /dev/null
1904 unlinkmany $DIR/$tfile 20 > /dev/null
1905 do_facet ost1 "$LCTL set_param fail_loc=0"
1906 CONN2=$(lctl get_param -n osc.*.stats | awk '/_connect/ {total+=$2} END {print total}')
1907 ATTEMPTS=$(($CONN2 - $CONN1))
1908 echo "$ATTEMPTS osc reconnect attempts on gradual slow"
1909 [ $ATTEMPTS -gt 0 ] &&
1910 error_ignore bz13721 "AT should have prevented reconnect"
1913 run_test 67a "AT: verify slow request processing doesn't induce reconnects"
1915 test_67b() #bug 3055
1917 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1919 at_start || return 0
1920 CONN1=$(lctl get_param -n osc.*.stats | awk '/_connect/ {total+=$2} END {print total}')
1922 # exhaust precreations on ost1
1923 local OST=$(ostname_from_index 0)
1924 local mdtosc=$(get_mdtosc_proc_path mds $OST)
1925 local last_id=$(do_facet $SINGLEMDS lctl get_param -n \
1926 osc.$mdtosc.prealloc_last_id)
1927 local next_id=$(do_facet $SINGLEMDS lctl get_param -n \
1928 osc.$mdtosc.prealloc_next_id)
1930 mkdir -p $DIR/$tdir/${OST} || error "mkdir $DIR/$tdir/${OST} failed"
1931 $SETSTRIPE -i 0 -c 1 $DIR/$tdir/${OST} || error "$SETSTRIPE failed"
1932 echo "Creating to objid $last_id on ost $OST..."
1933 #define OBD_FAIL_OST_PAUSE_CREATE 0x223
1934 do_facet ost1 "$LCTL set_param fail_val=20000"
1935 do_facet ost1 "$LCTL set_param fail_loc=0x80000223"
1936 createmany -o $DIR/$tdir/${OST}/f $next_id $((last_id - next_id + 2))
1939 do_facet ost1 "lctl get_param -n ost.OSS.ost_create.timeouts"
1941 CONN2=$(lctl get_param -n osc.*.stats | awk '/_connect/ {total+=$2} END {print total}')
1942 ATTEMPTS=$(($CONN2 - $CONN1))
1943 echo "$ATTEMPTS osc reconnect attempts on instant slow"
1944 # do it again; should not timeout
1945 do_facet ost1 "$LCTL set_param fail_loc=0x80000223"
1946 cp /etc/profile $DIR/$tfile || error "cp failed"
1947 do_facet ost1 "$LCTL set_param fail_loc=0"
1949 do_facet ost1 "lctl get_param -n ost.OSS.ost_create.timeouts"
1950 CONN3=$(lctl get_param -n osc.*.stats | awk '/_connect/ {total+=$2} END {print total}')
1951 ATTEMPTS=$(($CONN3 - $CONN2))
1952 echo "$ATTEMPTS osc reconnect attempts on 2nd slow"
1953 [ $ATTEMPTS -gt 0 ] && error "AT should have prevented reconnect"
1956 run_test 67b "AT: verify instant slowdown doesn't induce reconnects"
1958 test_68 () #bug 13813
1960 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1962 at_start || return 0
1963 local ldlm_enqueue_min=$(find /sys -name ldlm_enqueue_min)
1964 [ -z "$ldlm_enqueue_min" ] && skip "missing /sys/.../ldlm_enqueue_min" && return 0
1965 local ldlm_enqueue_min_r=$(do_facet ost1 "find /sys -name ldlm_enqueue_min")
1966 [ -z "$ldlm_enqueue_min_r" ] && skip "missing /sys/.../ldlm_enqueue_min in the ost1" && return 0
1967 local ENQ_MIN=$(cat $ldlm_enqueue_min)
1968 local ENQ_MIN_R=$(do_facet ost1 "cat $ldlm_enqueue_min_r")
1969 echo $TIMEOUT >> $ldlm_enqueue_min
1970 do_facet ost1 "echo $TIMEOUT >> $ldlm_enqueue_min_r"
1972 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
1973 $SETSTRIPE --stripe-index=0 --count=1 $DIR/$tdir
1974 #define OBD_FAIL_LDLM_PAUSE_CANCEL 0x312
1975 $LCTL set_param fail_val=$(($TIMEOUT - 1))
1976 $LCTL set_param fail_loc=0x80000312
1977 cp /etc/profile $DIR/$tdir/${tfile}_1 || error "1st cp failed $?"
1978 $LCTL set_param fail_val=$((TIMEOUT * 5 / 4))
1979 $LCTL set_param fail_loc=0x80000312
1980 cp /etc/profile $DIR/$tdir/${tfile}_2 || error "2nd cp failed $?"
1981 $LCTL set_param fail_loc=0
1983 echo $ENQ_MIN >> $ldlm_enqueue_min
1984 do_facet ost1 "echo $ENQ_MIN_R >> $ldlm_enqueue_min_r"
1988 run_test 68 "AT: verify slowing locks"
1991 # end of AT tests includes above lines
1993 # start multi-client tests
1995 [ -z "$CLIENTS" ] &&
1996 { skip "Need two or more clients." && return; }
1997 [ $CLIENTCOUNT -lt 2 ] &&
1998 { skip "Need two or more clients, have $CLIENTCOUNT" && return; }
2000 echo "mount clients $CLIENTS ..."
2001 zconf_mount_clients $CLIENTS $MOUNT
2003 local clients=${CLIENTS//,/ }
2004 echo "Write/read files on $DIR ; clients $CLIENTS ... "
2005 for CLIENT in $clients; do
2006 do_node $CLIENT dd bs=1M count=10 if=/dev/zero \
2007 of=$DIR/${tfile}_${CLIENT} 2>/dev/null ||
2008 error "dd failed on $CLIENT"
2011 local prev_client=$(echo $clients | sed 's/^.* \(.\+\)$/\1/')
2012 for C in ${CLIENTS//,/ }; do
2013 do_node $prev_client dd if=$DIR/${tfile}_${C} \
2014 of=/dev/null 2>/dev/null ||
2015 error "dd if=$DIR/${tfile}_${C} failed on $prev_client"
2021 run_test 70a "check multi client t-f"
2023 check_for_process () {
2028 killall_process $clients "$prog" -0
2032 local clients=${CLIENTS:-$HOSTNAME}
2034 zconf_mount_clients $clients $MOUNT
2037 [ "$SLOW" = "no" ] && duration=120
2038 # set duration to 900 because it takes some time to boot node
2039 [ "$FAILURE_MODE" = HARD ] && duration=900
2042 local start_ts=$(date +%s)
2043 local cmd="rundbench 1 -t $duration"
2045 if [ $MDSCOUNT -ge 2 ]; then
2046 test_mkdir -p -c$MDSCOUNT $DIR/$tdir
2047 $LFS setdirstripe -D -c$MDSCOUNT $DIR/$tdir
2049 do_nodesv $clients "set -x; MISSING_DBENCH_OK=$MISSING_DBENCH_OK \
2050 PATH=\$PATH:$LUSTRE/utils:$LUSTRE/tests/:$DBENCH_LIB \
2051 DBENCH_LIB=$DBENCH_LIB TESTSUITE=$TESTSUITE TESTNAME=$TESTNAME \
2052 MOUNT=$MOUNT DIR=$DIR/$tdir/\\\$(hostname) LCTL=$LCTL $cmd" &
2055 #LU-1897 wait for all dbench copies to start
2056 while ! check_for_process $clients dbench; do
2057 elapsed=$(($(date +%s) - start_ts))
2058 if [ $elapsed -gt $duration ]; then
2059 killall_process $clients dbench
2060 error "dbench failed to start on $clients!"
2065 log "Started rundbench load pid=$pid ..."
2067 elapsed=$(($(date +%s) - start_ts))
2068 local num_failovers=0
2070 while [ $elapsed -lt $duration ]; do
2071 if ! check_for_process $clients dbench; then
2072 error_noexit "dbench stopped on some of $clients!"
2073 killall_process $clients dbench
2077 replay_barrier mds$fail_index
2078 sleep 1 # give clients a time to do operations
2079 # Increment the number of failovers
2080 num_failovers=$((num_failovers+1))
2081 log "$TESTNAME fail mds$fail_index $num_failovers times"
2083 elapsed=$(($(date +%s) - start_ts))
2084 if [ $fail_index -ge $MDSCOUNT ]; then
2087 fail_index=$((fail_index+1))
2091 wait $pid || error "rundbench load on $clients failed!"
2093 run_test 70b "dbench ${MDSCOUNT}mdts recovery; $CLIENTCOUNT clients"
2094 # end multi-client tests
2099 local monitor_pid=$3
2101 local start_ts=$(date +%s)
2102 local num_failovers=0
2105 elapsed=$(($(date +%s) - start_ts))
2106 while [ $elapsed -lt $duration ]; do
2107 fail_index=$((RANDOM%max_index+1))
2108 kill -0 $monitor_pid ||
2109 error "$monitor_pid stopped"
2111 replay_barrier mds$fail_index
2113 # Increment the number of failovers
2114 num_failovers=$((num_failovers+1))
2115 log "$TESTNAME fail mds$fail_index $num_failovers times"
2117 elapsed=$(($(date +%s) - start_ts))
2123 rm -f $DIR/replay-single.70c.lck
2128 local clients=${CLIENTS:-$HOSTNAME}
2131 zconf_mount_clients $clients $MOUNT
2134 [ "$SLOW" = "no" ] && duration=180
2135 # set duration to 900 because it takes some time to boot node
2136 [ "$FAILURE_MODE" = HARD ] && duration=600
2139 local start_ts=$(date +%s)
2141 trap cleanup_70c EXIT
2143 while [ ! -e $DIR/replay-single.70c.lck ]; do
2144 test_mkdir -p -c$MDSCOUNT $DIR/$tdir || break
2145 if [ $MDSCOUNT -ge 2 ]; then
2146 $LFS setdirstripe -D -c$MDSCOUNT $DIR/$tdir ||
2147 error "set default dirstripe failed"
2149 cd $DIR/$tdir || break
2150 tar cf - /etc | tar xf - || error "tar failed in loop"
2154 echo "Started tar $tar_70c_pid"
2156 random_fail_mdt $MDSCOUNT $duration $tar_70c_pid
2157 kill -0 $tar_70c_pid || error "tar $tar_70c_pid stopped"
2159 touch $DIR/replay-single.70c.lck
2160 wait $tar_70c_pid || error "$?: tar failed"
2165 run_test 70c "tar ${MDSCOUNT}mdts recovery"
2169 kill -9 $mkdir_70d_pid
2173 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2174 local clients=${CLIENTS:-$HOSTNAME}
2177 zconf_mount_clients $clients $MOUNT
2180 [ "$SLOW" = "no" ] && duration=180
2181 # set duration to 900 because it takes some time to boot node
2182 [ "$FAILURE_MODE" = HARD ] && duration=900
2187 local start_ts=$(date +%s)
2189 trap cleanup_70d EXIT
2192 $LFS mkdir -i0 -c2 $DIR/$tdir/test || {
2196 $LFS mkdir -i1 -c2 $DIR/$tdir/test1 || {
2201 touch $DIR/$tdir/test/a || {
2205 mkdir $DIR/$tdir/test/b || {
2209 rm -rf $DIR/$tdir/test || {
2214 touch $DIR/$tdir/test1/a || {
2218 mkdir $DIR/$tdir/test1/b || {
2223 rm -rf $DIR/$tdir/test1 || {
2230 echo "Started $mkdir_70d_pid"
2232 random_fail_mdt $MDSCOUNT $duration $mkdir_70d_pid
2233 kill -0 $mkdir_70d_pid || error "mkdir/rmdir $mkdir_70d_pid stopped"
2238 run_test 70d "mkdir/rmdir striped dir ${MDSCOUNT}mdts recovery"
2242 kill -9 $rename_70e_pid
2246 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2247 local clients=${CLIENTS:-$HOSTNAME}
2250 echo ha > /proc/sys/lnet/debug
2251 zconf_mount_clients $clients $MOUNT
2254 [ "$SLOW" = "no" ] && duration=180
2255 # set duration to 900 because it takes some time to boot node
2256 [ "$FAILURE_MODE" = HARD ] && duration=900
2259 $LFS mkdir -i0 $DIR/$tdir/test_0
2260 $LFS mkdir -i0 $DIR/$tdir/test_1
2261 touch $DIR/$tdir/test_0/a
2262 touch $DIR/$tdir/test_1/b
2263 trap cleanup_70e EXIT
2266 mrename $DIR/$tdir/test_0/a $DIR/$tdir/test_1/b > \
2272 checkstat $DIR/$tdir/test_0/a && {
2273 echo "a still exists"
2277 checkstat $DIR/$tdir/test_1/b || {
2278 echo "b still exists"
2282 touch $DIR/$tdir/test_0/a || {
2283 echo "touch a fails"
2287 mrename $DIR/$tdir/test_1/b $DIR/$tdir/test_0/a > \
2295 echo "Started $rename_70e_pid"
2297 random_fail_mdt 2 $duration $rename_70e_pid
2298 kill -0 $rename_70e_pid || error "rename $rename_70e_pid stopped"
2303 run_test 70e "rename cross-MDT with random fails"
2305 test_70f_write_and_read(){
2310 echo "Write/read files in: '$DIR/$tdir', clients: '$CLIENTS' ..."
2311 for client in ${CLIENTS//,/ }; do
2312 [ -f $stopflag ] || return
2314 local tgtfile=$DIR/$tdir/$tfile.$client
2315 do_node $client dd $DD_OPTS bs=1M count=10 if=$srcfile \
2316 of=$tgtfile 2>/dev/null ||
2317 error "dd $DD_OPTS bs=1M count=10 if=$srcfile " \
2318 "of=$tgtfile failed on $client, rc=$?"
2321 local prev_client=$(echo ${CLIENTS//,/ } | awk '{ print $NF }')
2324 for client in ${CLIENTS//,/ }; do
2325 [ -f $stopflag ] || return
2327 # flush client cache in case test is running on only one client
2328 # do_node $client cancel_lru_locks osc
2329 do_node $client $LCTL set_param ldlm.namespaces.*.lru_size=clear
2331 tgtfile=$DIR/$tdir/$tfile.$client
2332 local md5=$(do_node $prev_client "md5sum $tgtfile")
2333 [ ${checksum[$index]// */} = ${md5// */} ] ||
2334 error "$tgtfile: checksum doesn't match on $prev_client"
2335 index=$((index + 1))
2345 mkdir -p $DIR/$tdir || error "cannot create $DIR/$tdir directory"
2346 $SETSTRIPE -c -1 $DIR/$tdir || error "cannot $SETSTRIPE $DIR/$tdir"
2349 while [ -f $stopflag ]; do
2350 test_70f_write_and_read $srcfile $stopflag
2351 # use direct IO and buffer cache in turns if loop
2352 [ -n "$DD_OPTS" ] && DD_OPTS="" || DD_OPTS="oflag=direct"
2356 test_70f_cleanup() {
2358 rm -f $TMP/$tfile.stop
2359 do_nodes $CLIENTS rm -f $TMP/$tfile
2360 rm -f $DIR/$tdir/$tfile.*
2364 # [ x$ost1failover_HOST = x$ost_HOST ] &&
2365 # { skip "Failover host not defined" && return; }
2366 # [ -z "$CLIENTS" ] &&
2367 # { skip "CLIENTS are not specified." && return; }
2368 # [ $CLIENTCOUNT -lt 2 ] &&
2369 # { skip "Need 2 or more clients, have $CLIENTCOUNT" && return; }
2371 echo "mount clients $CLIENTS ..."
2372 zconf_mount_clients $CLIENTS $MOUNT
2374 local srcfile=$TMP/$tfile
2378 trap test_70f_cleanup EXIT
2379 # create a different source file local to each client node so we can
2380 # detect if the file wasn't written out properly after failover
2381 do_nodes $CLIENTS dd bs=1M count=10 if=/dev/urandom of=$srcfile \
2382 2>/dev/null || error "can't create $srcfile on $CLIENTS"
2383 for client in ${CLIENTS//,/ }; do
2384 checksum[$index]=$(do_node $client "md5sum $srcfile")
2385 index=$((index + 1))
2389 [ "$SLOW" = "no" ] && duration=60
2390 # set duration to 900 because it takes some time to boot node
2391 [ "$FAILURE_MODE" = HARD ] && duration=900
2393 local stopflag=$TMP/$tfile.stop
2394 test_70f_loop $srcfile $stopflag &
2398 local num_failovers=0
2399 local start_ts=$SECONDS
2400 while [ $elapsed -lt $duration ]; do
2404 num_failovers=$((num_failovers + 1))
2405 log "$TESTNAME failing OST $num_failovers times"
2408 elapsed=$((SECONDS - start_ts))
2415 run_test 70f "OSS O_DIRECT recovery with $CLIENTCOUNT clients"
2419 kill -9 $mkdir_71a_pid
2422 random_double_fail_mdt() {
2425 local monitor_pid=$3
2427 local start_ts=$(date +%s)
2428 local num_failovers=0
2432 elapsed=$(($(date +%s) - start_ts))
2433 while [ $elapsed -lt $duration ]; do
2434 fail_index=$((RANDOM%max_index + 1))
2435 if [ $fail_index -eq $max_index ]; then
2438 second_index=$((fail_index + 1))
2440 kill -0 $monitor_pid ||
2441 error "$monitor_pid stopped"
2443 replay_barrier mds$fail_index
2444 replay_barrier mds$second_index
2446 # Increment the number of failovers
2447 num_failovers=$((num_failovers+1))
2448 log "fail mds$fail_index mds$second_index $num_failovers times"
2449 fail mds${fail_index},mds${second_index}
2450 elapsed=$(($(date +%s) - start_ts))
2455 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2456 local clients=${CLIENTS:-$HOSTNAME}
2459 zconf_mount_clients $clients $MOUNT
2462 [ "$SLOW" = "no" ] && duration=180
2463 # set duration to 900 because it takes some time to boot node
2464 [ "$FAILURE_MODE" = HARD ] && duration=900
2469 local start_ts=$(date +%s)
2471 trap cleanup_71a EXIT
2474 $LFS mkdir -i0 -c2 $DIR/$tdir/test
2475 rmdir $DIR/$tdir/test
2479 echo "Started $mkdir_71a_pid"
2481 random_double_fail_mdt 2 $duration $mkdir_71a_pid
2482 kill -0 $mkdir_71a_pid || error "mkdir/rmdir $mkdir_71a_pid stopped"
2487 run_test 71a "mkdir/rmdir striped dir with 2 mdts recovery"
2490 multiop_bg_pause $DIR/$tfile O_tSc ||
2491 error "multiop_bg_pause $DIR/$tfile failed"
2495 replay_barrier $SINGLEMDS
2496 #define OBD_FAIL_LDLM_ENQUEUE_NET 0x302
2497 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000302"
2500 wait $pid || error "multiop pid failed"
2501 [ -e $DIR/$tfile ] && error "file $DIR/$tfile should not exist"
2504 run_test 73a "open(O_CREAT), unlink, replay, reconnect before open replay, close"
2507 multiop_bg_pause $DIR/$tfile O_tSc ||
2508 error "multiop_bg_pause $DIR/$tfile failed"
2512 replay_barrier $SINGLEMDS
2513 #define OBD_FAIL_LDLM_REPLY 0x30c
2514 do_facet $SINGLEMDS "lctl set_param fail_loc=0x8000030c"
2517 wait $pid || error "multiop pid failed"
2518 [ -e $DIR/$tfile ] && error "file $DIR/$tfile should not exist"
2521 run_test 73b "open(O_CREAT), unlink, replay, reconnect at open_replay reply, close"
2525 local clients=${CLIENTS:-$HOSTNAME}
2527 zconf_umount_clients $clients $MOUNT
2529 facet_failover $SINGLEMDS
2530 zconf_mount_clients $clients $MOUNT
2532 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
2533 rm $DIR/$tfile || error "rm $DIR/$tfile failed"
2534 clients_up || error "client evicted: $?"
2537 run_test 74 "Ensure applications don't fail waiting for OST recovery"
2539 remote_dir_check_80() {
2544 diridx=$($GETSTRIPE -M $remote_dir) ||
2545 error "$GETSTRIPE -M $remote_dir failed"
2546 [ $diridx -eq $MDTIDX ] || error "$diridx != $MDTIDX"
2548 createmany -o $remote_dir/f-%d 20 || error "creation failed"
2549 fileidx=$($GETSTRIPE -M $remote_dir/f-1) ||
2550 error "$GETSTRIPE -M $remote_dir/f-1 failed"
2551 [ $fileidx -eq $MDTIDX ] || error "$fileidx != $MDTIDX"
2557 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2558 ([ $FAILURE_MODE == "HARD" ] &&
2559 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
2560 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
2564 local remote_dir=$DIR/$tdir/remote_dir
2566 mkdir -p $DIR/$tdir || error "mkdir $DIR/$tdir failed"
2567 #define OBD_FAIL_OUT_UPDATE_NET_REP 0x1701
2568 do_facet mds${MDTIDX} lctl set_param fail_loc=0x1701
2569 $LFS mkdir -i $MDTIDX $remote_dir &
2575 wait $CLIENT_PID || error "remote creation failed"
2577 remote_dir_check_80 || error "remote dir check failed"
2578 rm -rf $DIR/$tdir || error "rmdir failed"
2582 run_test 80a "DNE: create remote dir, drop update rep from MDT0, fail MDT0"
2585 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2586 ([ $FAILURE_MODE == "HARD" ] &&
2587 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
2588 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
2592 local remote_dir=$DIR/$tdir/remote_dir
2594 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
2595 #define OBD_FAIL_UPDATE_OBJ_NET_REP 0x1701
2596 do_facet mds${MDTIDX} lctl set_param fail_loc=0x1701
2597 $LFS mkdir -i $MDTIDX $remote_dir &
2602 fail mds$((MDTIDX + 1))
2604 wait $CLIENT_PID || error "remote creation failed"
2606 remote_dir_check_80 || error "remote dir check failed"
2607 rm -rf $DIR/$tdir || error "rmdir failed"
2611 run_test 80b "DNE: create remote dir, drop update rep from MDT0, fail MDT1"
2614 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2615 ([ $FAILURE_MODE == "HARD" ] &&
2616 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
2617 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
2621 local remote_dir=$DIR/$tdir/remote_dir
2623 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
2624 #define OBD_FAIL_UPDATE_OBJ_NET_REP 0x1701
2625 do_facet mds${MDTIDX} lctl set_param fail_loc=0x1701
2626 $LFS mkdir -i $MDTIDX $remote_dir &
2632 fail mds$((MDTIDX + 1))
2634 wait $CLIENT_PID || error "remote creation failed"
2636 remote_dir_check_80 || error "remote dir check failed"
2637 rm -rf $DIR/$tdir || error "rmdir failed"
2641 run_test 80c "DNE: create remote dir, drop update rep from MDT1, fail MDT[0,1]"
2644 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2646 local remote_dir=$DIR/$tdir/remote_dir
2648 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
2649 #define OBD_FAIL_UPDATE_OBJ_NET_REP 0x1701
2650 do_facet mds${MDTIDX} lctl set_param fail_loc=0x1701
2651 $LFS mkdir -i $MDTIDX $remote_dir &
2654 # sleep 3 seconds to make sure MDTs are failed after
2655 # lfs mkdir -i has finished on all of MDTs.
2660 fail mds${MDTIDX},mds$((MDTIDX + 1))
2662 wait $CLIENT_PID || error "remote creation failed"
2664 remote_dir_check_80 || error "remote dir check failed"
2665 rm -rf $DIR/$tdir || error "rmdir failed"
2669 run_test 80d "DNE: create remote dir, drop update rep from MDT1, fail 2 MDTs"
2672 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2673 ([ $FAILURE_MODE == "HARD" ] &&
2674 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
2675 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
2679 local remote_dir=$DIR/$tdir/remote_dir
2681 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
2682 # OBD_FAIL_MDS_REINT_NET_REP 0x119
2683 do_facet mds$((MDTIDX + 1)) lctl set_param fail_loc=0x119
2684 $LFS mkdir -i $MDTIDX $remote_dir &
2687 # sleep 3 seconds to make sure MDTs are failed after
2688 # lfs mkdir -i has finished on all of MDTs.
2694 wait $CLIENT_PID || error "remote creation failed"
2696 remote_dir_check_80 || error "remote dir check failed"
2697 rm -rf $DIR/$tdir || error "rmdir failed"
2701 run_test 80e "DNE: create remote dir, drop MDT1 rep, fail MDT0"
2704 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2705 ([ $FAILURE_MODE == "HARD" ] &&
2706 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
2707 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
2710 local remote_dir=$DIR/$tdir/remote_dir
2712 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
2713 # OBD_FAIL_MDS_REINT_NET_REP 0x119
2714 do_facet mds$((MDTIDX + 1)) lctl set_param fail_loc=0x119
2715 $LFS mkdir -i $MDTIDX $remote_dir &
2719 fail mds$((MDTIDX + 1))
2721 wait $CLIENT_PID || error "remote creation failed"
2723 remote_dir_check_80 || error "remote dir check failed"
2724 rm -rf $DIR/$tdir || error "rmdir failed"
2728 run_test 80f "DNE: create remote dir, drop MDT1 rep, fail MDT1"
2731 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2732 ([ $FAILURE_MODE == "HARD" ] &&
2733 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
2734 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
2738 local remote_dir=$DIR/$tdir/remote_dir
2740 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
2741 # OBD_FAIL_MDS_REINT_NET_REP 0x119
2742 do_facet mds$((MDTIDX + 1)) lctl set_param fail_loc=0x119
2743 $LFS mkdir -i $MDTIDX $remote_dir &
2746 # sleep 3 seconds to make sure MDTs are failed after
2747 # lfs mkdir -i has finished on all of MDTs.
2753 fail mds$((MDTIDX + 1))
2755 wait $CLIENT_PID || error "remote creation failed"
2757 remote_dir_check_80 || error "remote dir check failed"
2758 rm -rf $DIR/$tdir || error "rmdir failed"
2762 run_test 80g "DNE: create remote dir, drop MDT1 rep, fail MDT0, then MDT1"
2765 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2767 local remote_dir=$DIR/$tdir/remote_dir
2769 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
2770 # OBD_FAIL_MDS_REINT_NET_REP 0x119
2771 do_facet mds$((MDTIDX + 1)) lctl set_param fail_loc=0x119
2772 $LFS mkdir -i $MDTIDX $remote_dir &
2775 # sleep 3 seconds to make sure MDTs are failed after
2776 # lfs mkdir -i has finished on all of MDTs.
2781 fail mds${MDTIDX},mds$((MDTIDX + 1))
2783 wait $CLIENT_PID || error "remote dir creation failed"
2785 remote_dir_check_80 || error "remote dir check failed"
2786 rm -rf $DIR/$tdir || error "rmdir failed"
2790 run_test 80h "DNE: create remote dir, drop MDT1 rep, fail 2 MDTs"
2793 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2794 ([ $FAILURE_MODE == "HARD" ] &&
2795 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
2796 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
2800 local remote_dir=$DIR/$tdir/remote_dir
2802 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
2803 $LFS mkdir -i $MDTIDX $remote_dir || error "lfs mkdir failed"
2805 touch $remote_dir || error "touch $remote_dir failed"
2806 # OBD_FAIL_OBJ_UPDATE_NET_REP 0x1701
2807 do_facet mds${MDTIDX} lctl set_param fail_loc=0x1701
2812 fail mds$((MDTIDX + 1))
2814 wait $CLIENT_PID || error "rm remote dir failed"
2816 stat $remote_dir 2&>/dev/null && error "$remote_dir still exist!"
2818 rm -rf $DIR/$tdir || error "rmdir failed"
2822 run_test 81a "DNE: unlink remote dir, drop MDT0 update rep, fail MDT1"
2825 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2826 ([ $FAILURE_MODE == "HARD" ] &&
2827 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
2828 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
2831 local remote_dir=$DIR/$tdir/remote_dir
2833 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
2834 $LFS mkdir -i $MDTIDX $remote_dir || error "lfs mkdir failed"
2836 # OBD_FAIL_OBJ_UPDATE_NET_REP 0x1701
2837 do_facet mds${MDTIDX} lctl set_param fail_loc=0x1701
2844 wait $CLIENT_PID || error "rm remote dir failed"
2846 stat $remote_dir 2&>/dev/null && error "$remote_dir still exist!"
2848 rm -rf $DIR/$tdir || error "rmdir failed"
2852 run_test 81b "DNE: unlink remote dir, drop MDT0 update reply, fail MDT0"
2855 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2856 ([ $FAILURE_MODE == "HARD" ] &&
2857 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
2858 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
2862 local remote_dir=$DIR/$tdir/remote_dir
2864 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
2865 $LFS mkdir -i $MDTIDX $remote_dir || error "lfs mkdir failed"
2867 # OBD_FAIL_OBJ_UPDATE_NET_REP 0x1701
2868 do_facet mds${MDTIDX} lctl set_param fail_loc=0x1701
2875 fail mds$((MDTIDX + 1))
2877 wait $CLIENT_PID || error "rm remote dir failed"
2879 stat $remote_dir 2&>/dev/null && error "$remote_dir still exist!"
2881 rm -rf $DIR/$tdir || error "rmdir failed"
2885 run_test 81c "DNE: unlink remote dir, drop MDT0 update reply, fail MDT0,MDT1"
2888 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2890 local remote_dir=$DIR/$tdir/remote_dir
2892 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
2893 $LFS mkdir -i $MDTIDX $remote_dir || error "lfs mkdir failed"
2895 # OBD_FAIL_OBJ_UPDATE_NET_REP 0x1701
2896 do_facet mds${MDTIDX} lctl set_param fail_loc=0x1701
2902 fail mds${MDTIDX},mds$((MDTIDX + 1))
2904 wait $CLIENT_PID || error "rm remote dir failed"
2906 stat $remote_dir 2&>/dev/null && error "$remote_dir still exist!"
2908 rm -rf $DIR/$tdir || error "rmdir failed"
2912 run_test 81d "DNE: unlink remote dir, drop MDT0 update reply, fail 2 MDTs"
2915 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2916 ([ $FAILURE_MODE == "HARD" ] &&
2917 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
2918 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
2922 local remote_dir=$DIR/$tdir/remote_dir
2924 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
2925 $LFS mkdir -i $MDTIDX $remote_dir || error "lfs mkdir failed"
2927 # OBD_FAIL_MDS_REINT_NET_REP 0x119
2928 do_facet mds$((MDTIDX + 1)) lctl set_param fail_loc=0x119
2931 do_facet mds$((MDTIDX + 1)) lctl set_param fail_loc=0
2936 wait $CLIENT_PID || error "rm remote dir failed"
2938 stat $remote_dir 2&>/dev/null && error "$remote_dir still exist!"
2940 rm -rf $DIR/$tdir || error "rmdir failed"
2944 run_test 81e "DNE: unlink remote dir, drop MDT1 req reply, fail MDT0"
2947 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2948 ([ $FAILURE_MODE == "HARD" ] &&
2949 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
2950 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
2954 local remote_dir=$DIR/$tdir/remote_dir
2956 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
2957 $LFS mkdir -i $MDTIDX $remote_dir || error "lfs mkdir failed"
2959 # OBD_FAIL_MDS_REINT_NET_REP 0x119
2960 do_facet mds$((MDTIDX + 1)) lctl set_param fail_loc=0x119
2965 fail mds$((MDTIDX + 1))
2967 wait $CLIENT_PID || error "rm remote dir failed"
2969 stat $remote_dir 2&>/dev/null && error "$remote_dir still exist!"
2971 rm -rf $DIR/$tdir || error "rmdir failed"
2975 run_test 81f "DNE: unlink remote dir, drop MDT1 req reply, fail MDT1"
2978 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2979 ([ $FAILURE_MODE == "HARD" ] &&
2980 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
2981 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
2985 local remote_dir=$DIR/$tdir/remote_dir
2987 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
2988 $LFS mkdir -i $MDTIDX $remote_dir || error "lfs mkdir failed"
2990 # OBD_FAIL_MDS_REINT_NET_REP 0x119
2991 do_facet mds$((MDTIDX + 1)) lctl set_param fail_loc=0x119
2998 fail mds$((MDTIDX + 1))
3000 wait $CLIENT_PID || error "rm remote dir failed"
3002 stat $remote_dir 2&>/dev/null && error "$remote_dir still exist!"
3004 rm -rf $DIR/$tdir || error "rmdir failed"
3008 run_test 81g "DNE: unlink remote dir, drop req reply, fail M0, then M1"
3011 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
3013 local remote_dir=$DIR/$tdir/remote_dir
3015 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
3016 $LFS mkdir -i $MDTIDX $remote_dir || error "lfs mkdir failed"
3018 # OBD_FAIL_MDS_REINT_NET_REP 0x119
3019 do_facet mds$((MDTIDX + 1)) lctl set_param fail_loc=0x119
3025 fail mds${MDTIDX},mds$((MDTIDX + 1))
3027 wait $CLIENT_PID || error "rm remote dir failed"
3029 stat $remote_dir 2&>/dev/null && error "$remote_dir still exist!"
3031 rm -rf $DIR/$tdir || error "rmdir failed"
3035 run_test 81h "DNE: unlink remote dir, drop request reply, fail 2 MDTs"
3038 #define OBD_FAIL_MDS_OPEN_WAIT_CREATE 0x144
3039 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000144"
3040 createmany -o $DIR/$tfile- 1 &
3044 client_up || client_up || true # reconnect
3046 run_test 84a "stale open during export disconnect"
3048 test_85a() { #bug 16774
3049 lctl set_param -n ldlm.cancel_unused_locks_before_replay "1"
3051 for i in $(seq 100); do
3052 echo "tag-$i" > $DIR/$tfile-$i
3053 grep -q "tag-$i" $DIR/$tfile-$i || error "f2-$i"
3056 lov_id=$(lctl dl | grep "clilov")
3057 addr=$(echo $lov_id | awk '{print $4}' | awk -F '-' '{print $NF}')
3058 count=$(lctl get_param -n \
3059 ldlm.namespaces.*MDT0000*$addr.lock_unused_count)
3060 echo "before recovery: unused locks count = $count"
3064 count2=$(lctl get_param -n \
3065 ldlm.namespaces.*MDT0000*$addr.lock_unused_count)
3066 echo "after recovery: unused locks count = $count2"
3068 if [ $count2 -ge $count ]; then
3069 error "unused locks are not canceled"
3072 run_test 85a "check the cancellation of unused locks during recovery(IBITS)"
3074 test_85b() { #bug 16774
3075 lctl set_param -n ldlm.cancel_unused_locks_before_replay "1"
3077 do_facet mgs $LCTL pool_new $FSNAME.$TESTNAME ||
3078 error "unable to create pool $TESTNAME"
3079 do_facet mgs $LCTL pool_add $FSNAME.$TESTNAME $FSNAME-OST0000 ||
3080 error "unable to add pool $TESTNAME"
3082 $SETSTRIPE -c 1 -p $FSNAME.$TESTNAME $DIR
3084 for i in $(seq 100); do
3085 dd if=/dev/urandom of=$DIR/$tfile-$i bs=4096 \
3086 count=32 >/dev/null 2>&1
3089 cancel_lru_locks osc
3091 for i in $(seq 100); do
3092 dd if=$DIR/$tfile-$i of=/dev/null bs=4096 \
3093 count=32 >/dev/null 2>&1
3096 lov_id=$(lctl dl | grep "clilov")
3097 addr=$(echo $lov_id | awk '{print $4}' | awk -F '-' '{print $NF}')
3098 count=$(lctl get_param -n \
3099 ldlm.namespaces.*OST0000*$addr.lock_unused_count)
3100 echo "before recovery: unused locks count = $count"
3101 [ $count -ne 0 ] || error "unused locks ($count) should be zero"
3105 count2=$(lctl get_param \
3106 -n ldlm.namespaces.*OST0000*$addr.lock_unused_count)
3107 echo "after recovery: unused locks count = $count2"
3109 do_facet mgs $LCTL pool_remove $FSNAME.$TESTNAME $FSNAME-OST0000 ||
3110 error "unable to remove pool $TESTNAME"
3111 do_facet mgs $LCTL pool_destroy $FSNAME.$TESTNAME ||
3112 error "unable to destroy the pool $TESTNAME"
3114 if [ $count2 -ge $count ]; then
3115 error "unused locks are not canceled"
3118 run_test 85b "check the cancellation of unused locks during recovery(EXTENT)"
3121 local clients=${CLIENTS:-$HOSTNAME}
3123 zconf_umount_clients $clients $MOUNT
3124 do_facet $SINGLEMDS lctl set_param mdt.${FSNAME}-MDT*.exports.clear=0
3125 remount_facet $SINGLEMDS
3126 zconf_mount_clients $clients $MOUNT
3128 run_test 86 "umount server after clear nid_stats should not hit LBUG"
3131 do_facet ost1 "lctl set_param -n obdfilter.${ost1_svc}.sync_journal 0"
3134 $SETSTRIPE -i 0 -c 1 $DIR/$tfile
3135 dd if=/dev/urandom of=$DIR/$tfile bs=1024k count=8 ||
3136 error "dd to $DIR/$tfile failed"
3137 cksum=$(md5sum $DIR/$tfile | awk '{print $1}')
3138 cancel_lru_locks osc
3140 dd if=$DIR/$tfile of=/dev/null bs=1024k count=8 || error "Cannot read"
3141 cksum2=$(md5sum $DIR/$tfile | awk '{print $1}')
3142 if [ $cksum != $cksum2 ] ; then
3143 error "New checksum $cksum2 does not match original $cksum"
3146 run_test 87a "write replay"
3149 do_facet ost1 "lctl set_param -n obdfilter.${ost1_svc}.sync_journal 0"
3152 $SETSTRIPE -i 0 -c 1 $DIR/$tfile
3153 dd if=/dev/urandom of=$DIR/$tfile bs=1024k count=8 ||
3154 error "dd to $DIR/$tfile failed"
3155 sleep 1 # Give it a chance to flush dirty data
3156 echo TESTTEST | dd of=$DIR/$tfile bs=1 count=8 seek=64
3157 cksum=$(md5sum $DIR/$tfile | awk '{print $1}')
3158 cancel_lru_locks osc
3160 dd if=$DIR/$tfile of=/dev/null bs=1024k count=8 || error "Cannot read"
3161 cksum2=$(md5sum $DIR/$tfile | awk '{print $1}')
3162 if [ $cksum != $cksum2 ] ; then
3163 error "New checksum $cksum2 does not match original $cksum"
3166 run_test 87b "write replay with changed data (checksum resend)"
3168 test_88() { #bug 17485
3169 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
3170 mkdir -p $TMP/$tdir || error "mkdir $TMP/$tdir failed"
3172 $SETSTRIPE -i 0 -c 1 $DIR/$tdir || error "$SETSTRIPE"
3175 replay_barrier $SINGLEMDS
3177 # exhaust precreations on ost1
3178 local OST=$(ostname_from_index 0)
3179 local mdtosc=$(get_mdtosc_proc_path $SINGLEMDS $OST)
3180 local last_id=$(do_facet $SINGLEMDS lctl get_param -n osc.$mdtosc.prealloc_last_id)
3181 local next_id=$(do_facet $SINGLEMDS lctl get_param -n osc.$mdtosc.prealloc_next_id)
3182 echo "before test: last_id = $last_id, next_id = $next_id"
3184 echo "Creating to objid $last_id on ost $OST..."
3185 createmany -o $DIR/$tdir/f-%d $next_id $((last_id - next_id + 2)) ||
3186 error "createmany create files to last_id failed"
3188 #create some files to use some uncommitted objids
3189 last_id=$(($last_id + 1))
3190 createmany -o $DIR/$tdir/f-%d $last_id 8 ||
3191 error "createmany create files with uncommitted objids failed"
3193 last_id2=$(do_facet $SINGLEMDS lctl get_param -n osc.$mdtosc.prealloc_last_id)
3194 next_id2=$(do_facet $SINGLEMDS lctl get_param -n osc.$mdtosc.prealloc_next_id)
3195 echo "before recovery: last_id = $last_id2, next_id = $next_id2"
3197 # if test uses shutdown_facet && reboot_facet instead of facet_failover ()
3198 # it has to take care about the affected facets, bug20407
3199 local affected_mds1=$(affected_facets mds1)
3200 local affected_ost1=$(affected_facets ost1)
3202 shutdown_facet $SINGLEMDS
3205 reboot_facet $SINGLEMDS
3206 change_active $affected_mds1
3207 wait_for_facet $affected_mds1
3208 mount_facets $affected_mds1 || error "Restart of mds failed"
3211 change_active $affected_ost1
3212 wait_for_facet $affected_ost1
3213 mount_facets $affected_ost1 || error "Restart of ost1 failed"
3217 last_id2=$(do_facet $SINGLEMDS lctl get_param -n osc.$mdtosc.prealloc_last_id)
3218 next_id2=$(do_facet $SINGLEMDS lctl get_param -n osc.$mdtosc.prealloc_next_id)
3219 echo "after recovery: last_id = $last_id2, next_id = $next_id2"
3221 # create new files, which should use new objids, and ensure the orphan
3222 # cleanup phase for ost1 is completed at the same time
3223 for i in $(seq 8); do
3224 file_id=$(($last_id + 10 + $i))
3225 dd if=/dev/urandom of=$DIR/$tdir/f-$file_id bs=4096 count=128
3228 # if the objids were not recreated, then "ls" will fail with -ENOENT
3229 ls -l $DIR/$tdir/* || error "can't get the status of precreated files"
3232 # write into previously created files
3233 for i in $(seq 8); do
3234 file_id=$(($last_id + $i))
3235 dd if=/dev/urandom of=$DIR/$tdir/f-$file_id bs=4096 count=128
3236 cp -f $DIR/$tdir/f-$file_id $TMP/$tdir/
3239 # compare the content
3240 for i in $(seq 8); do
3241 file_id=$(($last_id + $i))
3242 cmp $TMP/$tdir/f-$file_id $DIR/$tdir/f-$file_id ||
3243 error "the content of file is modified!"
3248 run_test 88 "MDS should not assign same objid to different files "
3251 cancel_lru_locks osc
3252 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
3253 rm -f $DIR/$tdir/$tfile
3255 wait_delete_completed
3256 BLOCKS1=$(df -P $MOUNT | tail -n 1 | awk '{ print $3 }')
3257 $SETSTRIPE -i 0 -c 1 $DIR/$tdir/$tfile
3258 dd if=/dev/zero bs=1M count=10 of=$DIR/$tdir/$tfile
3261 facet_failover $SINGLEMDS
3262 rm $DIR/$tdir/$tfile
3265 zconf_mount $(hostname) $MOUNT || error "mount fails"
3266 client_up || error "client_up failed"
3268 wait_delete_completed
3269 BLOCKS2=$(df -P $MOUNT | tail -n 1 | awk '{ print $3 }')
3270 [ $((BLOCKS2 - BLOCKS1)) -le 4 ] ||
3271 error $((BLOCKS2 - BLOCKS1)) blocks leaked
3274 run_test 89 "no disk space leak on late ost connection"
3280 change_active $facet
3281 wait_for_facet $facet
3282 mount_facet $facet || error "Restart of $facet failed"
3286 test_90() { # bug 19494
3287 local dir=$DIR/$tdir
3288 local ostfail=$(get_random_entry $(get_facets OST))
3290 if [[ $FAILURE_MODE = HARD ]]; then
3291 local affected=$(affected_facets $ostfail);
3292 if [[ "$affected" != $ostfail ]]; then
3293 skip not functional with FAILURE_MODE=$FAILURE_MODE, affected: $affected
3297 # maybe effected by previous test
3298 wait_osc_import_state mds ost FULL
3300 mkdir $dir || error "mkdir $dir failed"
3302 echo "Create the files"
3304 # file "f${index}" striped over 1 OST
3305 # file "all" striped over all OSTs
3307 $SETSTRIPE -c $OSTCOUNT $dir/all ||
3308 error "setstripe failed to create $dir/all"
3310 for (( i=0; i<$OSTCOUNT; i++ )); do
3312 $SETSTRIPE -i $i -c 1 $f || error "$SETSTRIPE failed to create $f"
3314 # confirm setstripe actually created the stripe on the requested OST
3315 local uuid=$(ostuuid_from_index $i)
3316 for file in f$i all; do
3317 if [[ $dir/$file != $($LFS find --obd $uuid --name $file $dir) ]]; then
3318 $GETSTRIPE $dir/$file
3319 error wrong stripe: $file, uuid: $uuid
3324 # Before failing an OST, get its obd name and index
3325 local varsvc=${ostfail}_svc
3326 local obd=$(do_facet $ostfail lctl get_param \
3327 -n obdfilter.${!varsvc}.uuid)
3328 local index=$(($(facet_number $ostfail) - 1))
3330 echo "Fail $ostfail $obd, display the list of affected files"
3331 shutdown_facet $ostfail || error "shutdown_facet $ostfail failed"
3333 trap "cleanup_90 $ostfail" EXIT INT
3334 echo "General Query: lfs find $dir"
3335 local list=$($LFS find $dir)
3337 for (( i=0; i<$OSTCOUNT; i++ )); do
3338 list_member "$list" $dir/f$i ||
3339 error_noexit "lfs find $dir: no file f$i"
3341 list_member "$list" $dir/all ||
3342 error_noexit "lfs find $dir: no file all"
3344 # focus on the missing OST,
3345 # we expect to see only two files affected: "f$(index)" and "all"
3347 echo "Querying files on shutdown $ostfail: lfs find --obd $obd"
3348 list=$($LFS find --obd $obd $dir)
3350 for file in all f$index; do
3351 list_member "$list" $dir/$file ||
3352 error_noexit "lfs find does not report the affected $obd for $file"
3355 [[ $(echo $list | wc -w) -eq 2 ]] ||
3356 error_noexit "lfs find reports the wrong list of affected files ${#list[@]}"
3358 echo "Check getstripe: $GETSTRIPE -r --obd $obd"
3359 list=$($GETSTRIPE -r --obd $obd $dir)
3361 for file in all f$index; do
3362 echo "$list" | grep $dir/$file ||
3363 error_noexit "lfs getsripe does not report the affected $obd for $file"
3368 run_test 90 "lfs find identifies the missing striped file segments"
3371 local server_version=$(lustre_version_code $SINGLEMDS)
3372 [[ $server_version -ge $(version_code 2.6.90) ]] ||
3373 [[ $server_version -ge $(version_code 2.5.4) &&
3374 $server_version -lt $(version_code 2.5.50) ]] ||
3375 { skip "Need MDS version 2.5.4+ or 2.6.90+"; return; }
3377 cancel_lru_locks osc
3379 $SETSTRIPE -i 0 -c 1 $DIR/$tfile ||
3380 error "$SETSTRIPE $DIR/$tfile failed"
3381 dd if=/dev/zero of=$DIR/$tfile bs=1024 count=1 ||
3382 error "dd to $DIR/$tfile failed"
3383 #define OBD_FAIL_TGT_REPLAY_RECONNECT 0x715
3384 # We need to emulate a state that OST is waiting for other clients
3385 # not completing the recovery. Final ping is queued, but reply will be
3386 # sent on the recovery completion. It is done by sleep before
3387 # processing final pings
3388 do_facet ost1 "$LCTL set_param fail_val=40"
3389 do_facet ost1 "$LCTL set_param fail_loc=0x715"
3392 run_test 93a "replay + reconnect"
3395 local server_version=$(lustre_version_code $SINGLEMDS)
3396 [[ $server_version -ge $(version_code 2.7.90) ]] ||
3397 { skip "Need MDS version 2.7.90+"; return; }
3399 cancel_lru_locks mdc
3401 createmany -o $DIR/$tfile 20 ||
3402 error "createmany -o $DIR/$tfile failed"
3404 #define OBD_FAIL_TGT_REPLAY_RECONNECT 0x715
3405 # We need to emulate a state that MDT is waiting for other clients
3406 # not completing the recovery. Final ping is queued, but reply will be
3407 # sent on the recovery completion. It is done by sleep before
3408 # processing final pings
3409 do_facet mds1 "$LCTL set_param fail_val=80"
3410 do_facet mds1 "$LCTL set_param fail_loc=0x715"
3413 run_test 93b "replay + reconnect on mds"
3415 striped_dir_check_100() {
3416 local striped_dir=$DIR/$tdir/striped_dir
3417 local stripe_count=$($LFS getdirstripe -c $striped_dir)
3419 $LFS getdirstripe $striped_dir
3420 [ $stripe_count -eq 2 ] || error "$stripe_count != 2"
3422 createmany -o $striped_dir/f-%d 20 ||
3423 error "creation failed under striped dir"
3427 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
3428 ([ $FAILURE_MODE == "HARD" ] &&
3429 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
3430 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
3433 local striped_dir=$DIR/$tdir/striped_dir
3436 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
3438 #To make sure MDT1 and MDT0 are connected
3439 #otherwise it may create single stripe dir here
3440 $LFS setdirstripe -i1 $DIR/$tdir/remote_dir
3442 #define OBD_FAIL_OUT_UPDATE_NET_REP 0x1701
3443 do_facet mds$((MDTIDX+1)) lctl set_param fail_loc=0x1701
3444 $LFS setdirstripe -i0 -c2 $striped_dir &
3447 fail mds$((MDTIDX + 1))
3449 wait $CLIENT_PID || error "striped dir creation failed"
3451 striped_dir_check_100 || error "striped dir check failed"
3452 rm -rf $DIR/$tdir || error "rmdir failed"
3454 run_test 100a "DNE: create striped dir, drop update rep from MDT1, fail MDT1"
3457 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
3458 ([ $FAILURE_MODE == "HARD" ] &&
3459 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
3460 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
3463 local striped_dir=$DIR/$tdir/striped_dir
3466 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
3468 #To make sure MDT1 and MDT0 are connected
3469 #otherwise it may create single stripe dir here
3470 $LFS setdirstripe -i1 $DIR/$tdir/remote_dir
3472 # OBD_FAIL_MDS_REINT_NET_REP 0x119
3473 do_facet mds$MDTIDX lctl set_param fail_loc=0x119
3474 $LFS mkdir -i0 -c2 $striped_dir &
3479 wait $CLIENT_PID || error "striped dir creation failed"
3481 striped_dir_check_100 || error "striped dir check failed"
3482 rm -rf $DIR/$tdir || error "rmdir failed"
3484 run_test 100b "DNE: create striped dir, fail MDT0"
3486 test_101() { #LU-5648
3487 mkdir -p $DIR/$tdir/d1
3488 mkdir -p $DIR/$tdir/d2
3489 touch $DIR/$tdir/file0
3492 replay_barrier $SINGLEMDS
3493 for i in $(seq $num) ; do
3494 echo test$i > $DIR/$tdir/d1/file$i
3497 fail_abort $SINGLEMDS
3498 for i in $(seq $num) ; do
3499 touch $DIR/$tdir/d2/file$i
3500 test -s $DIR/$tdir/d2/file$i &&
3501 ls -al $DIR/$tdir/d2/file$i && error "file$i's size > 0"
3506 run_test 101 "Shouldn't reassign precreated objs to other files after recovery"
3515 [[ $(lctl get_param mdc.*.import |
3516 grep "connect_flags:.*multi_mod_rpc") ]] ||
3517 { skip "Need MDC with 'multi_mod_rpcs' feature"; return 0; }
3519 $LFS mkdir -c1 $DIR/$tdir || error "mkdir $DIR/$tdir failed"
3520 idx=$(printf "%04x" $($LFS getdirstripe -i $DIR/$tdir))
3521 facet="mds$((0x$idx + 1))"
3523 # get current value of max_mod_rcps_in_flight
3524 num=$($LCTL get_param -n \
3525 mdc.$FSNAME-MDT$idx-mdc-*.max_mod_rpcs_in_flight)
3526 # set default value if client does not support multi mod RPCs
3527 [ -z "$num" ] && num=1
3529 echo "creating $num files ..."
3531 for i in $(seq $num); do
3532 touch $DIR/$tdir/file-$i
3535 # drop request on MDT to force resend
3536 #define OBD_FAIL_MDS_REINT_MULTI_NET 0x159
3537 do_facet $facet "$LCTL set_param fail_loc=0x159"
3538 echo "launch $num chmod in parallel ($(date +%H:%M:%S)) ..."
3539 for i in $(seq $num); do
3540 chmod 0600 $DIR/$tdir/file-$i &
3544 do_facet $facet "$LCTL set_param fail_loc=0"
3545 for pid in $pids; do
3546 wait $pid || error "chmod failed"
3548 echo "done ($(date +%H:%M:%S))"
3550 # check chmod succeed
3551 for i in $(seq $num); do
3552 checkstat -vp 0600 $DIR/$tdir/file-$i
3557 run_test 102a "check resend (request lost) with multiple modify RPCs in flight"
3566 [[ $(lctl get_param mdc.*.import |
3567 grep "connect_flags:.*multi_mod_rpc") ]] ||
3568 { skip "Need MDC with 'multi_mod_rpcs' feature"; return 0; }
3570 $LFS mkdir -c1 $DIR/$tdir || error "mkdir $DIR/$tdir failed"
3571 idx=$(printf "%04x" $($LFS getdirstripe -i $DIR/$tdir))
3572 facet="mds$((0x$idx + 1))"
3574 # get current value of max_mod_rcps_in_flight
3575 num=$($LCTL get_param -n \
3576 mdc.$FSNAME-MDT$idx-mdc-*.max_mod_rpcs_in_flight)
3577 # set default value if client does not support multi mod RPCs
3578 [ -z "$num" ] && num=1
3580 echo "creating $num files ..."
3582 for i in $(seq $num); do
3583 touch $DIR/$tdir/file-$i
3586 # drop reply on MDT to force reconstruction
3587 #define OBD_FAIL_MDS_REINT_MULTI_NET_REP 0x15a
3588 do_facet $facet "$LCTL set_param fail_loc=0x15a"
3589 echo "launch $num chmod in parallel ($(date +%H:%M:%S)) ..."
3590 for i in $(seq $num); do
3591 chmod 0600 $DIR/$tdir/file-$i &
3595 do_facet $facet "$LCTL set_param fail_loc=0"
3596 for pid in $pids; do
3597 wait $pid || error "chmod failed"
3599 echo "done ($(date +%H:%M:%S))"
3601 # check chmod succeed
3602 for i in $(seq $num); do
3603 checkstat -vp 0600 $DIR/$tdir/file-$i
3608 run_test 102b "check resend (reply lost) with multiple modify RPCs in flight"
3617 [[ $(lctl get_param mdc.*.import |
3618 grep "connect_flags:.*multi_mod_rpc") ]] ||
3619 { skip "Need MDC with 'multi_mod_rpcs' feature"; return 0; }
3621 $LFS mkdir -c1 $DIR/$tdir || error "mkdir $DIR/$tdir failed"
3622 idx=$(printf "%04x" $($LFS getdirstripe -i $DIR/$tdir))
3623 facet="mds$((0x$idx + 1))"
3625 # get current value of max_mod_rcps_in_flight
3626 num=$($LCTL get_param -n \
3627 mdc.$FSNAME-MDT$idx-mdc-*.max_mod_rpcs_in_flight)
3628 # set default value if client does not support multi mod RPCs
3629 [ -z "$num" ] && num=1
3631 echo "creating $num files ..."
3633 for i in $(seq $num); do
3634 touch $DIR/$tdir/file-$i
3637 replay_barrier $facet
3640 #define OBD_FAIL_MDS_REINT_MULTI_NET_REP 0x15a
3641 do_facet $facet "$LCTL set_param fail_loc=0x15a"
3642 echo "launch $num chmod in parallel ($(date +%H:%M:%S)) ..."
3643 for i in $(seq $num); do
3644 chmod 0600 $DIR/$tdir/file-$i &
3648 do_facet $facet "$LCTL set_param fail_loc=0"
3653 for pid in $pids; do
3654 wait $pid || error "chmod failed"
3656 echo "done ($(date +%H:%M:%S))"
3658 # check chmod succeed
3659 for i in $(seq $num); do
3660 checkstat -vp 0600 $DIR/$tdir/file-$i
3665 run_test 102c "check replay w/o reconstruction with multiple mod RPCs in flight"
3674 [[ $(lctl get_param mdc.*.import |
3675 grep "connect_flags:.*multi_mod_rpc") ]] ||
3676 { skip "Need MDC with 'multi_mod_rpcs' feature"; return 0; }
3678 $LFS mkdir -c1 $DIR/$tdir || error "mkdir $DIR/$tdir failed"
3679 idx=$(printf "%04x" $($LFS getdirstripe -i $DIR/$tdir))
3680 facet="mds$((0x$idx + 1))"
3682 # get current value of max_mod_rcps_in_flight
3683 num=$($LCTL get_param -n \
3684 mdc.$FSNAME-MDT$idx-mdc-*.max_mod_rpcs_in_flight)
3685 # set default value if client does not support multi mod RPCs
3686 [ -z "$num" ] && num=1
3688 echo "creating $num files ..."
3690 for i in $(seq $num); do
3691 touch $DIR/$tdir/file-$i
3695 #define OBD_FAIL_MDS_REINT_MULTI_NET_REP 0x15a
3696 do_facet $facet "$LCTL set_param fail_loc=0x15a"
3697 echo "launch $num chmod in parallel ($(date +%H:%M:%S)) ..."
3698 for i in $(seq $num); do
3699 chmod 0600 $DIR/$tdir/file-$i &
3704 # write MDT transactions to disk
3705 do_facet $facet "sync; sync; sync"
3707 do_facet $facet "$LCTL set_param fail_loc=0"
3712 for pid in $pids; do
3713 wait $pid || error "chmod failed"
3715 echo "done ($(date +%H:%M:%S))"
3717 # check chmod succeed
3718 for i in $(seq $num); do
3719 checkstat -vp 0600 $DIR/$tdir/file-$i
3724 run_test 102d "check replay & reconstruction with multiple mod RPCs in flight"
3727 remote_mds_nodsh && skip "remote MDS with nodsh" && return
3728 #define OBD_FAIL_MDS_TRACK_OVERFLOW 0x162
3729 do_facet mds1 $LCTL set_param fail_loc=0x80000162
3732 createmany -o $DIR/$tdir/t- 30 ||
3733 error "create files on remote directory failed"
3735 rm -rf $DIR/$tdir/t-*
3737 #MDS should crash with tr->otr_next_id overflow
3740 run_test 103 "Check otr_next_id overflow"
3743 check_striped_dir_110()
3745 $CHECKSTAT -t dir $DIR/$tdir/striped_dir ||
3746 error "create striped dir failed"
3747 local stripe_count=$($LFS getdirstripe -c $DIR/$tdir/striped_dir)
3748 [ $stripe_count -eq $MDSCOUNT ] ||
3749 error "$stripe_count != 2 after recovery"
3753 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
3754 ([ $FAILURE_MODE == "HARD" ] &&
3755 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
3756 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
3761 $LFS mkdir -i1 -c$MDSCOUNT $DIR/$tdir/striped_dir
3764 check_striped_dir_110 || error "check striped_dir failed"
3765 rm -rf $DIR/$tdir || error "rmdir failed"
3769 run_test 110a "DNE: create striped dir, fail MDT1"
3772 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
3773 ([ $FAILURE_MODE == "HARD" ] &&
3774 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
3775 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
3780 $LFS mkdir -i1 -c$MDSCOUNT $DIR/$tdir/striped_dir
3783 zconf_mount $(hostname) $MOUNT
3784 client_up || return 1
3786 check_striped_dir_110 || error "check striped_dir failed"
3788 rm -rf $DIR/$tdir || error "rmdir failed"
3792 run_test 110b "DNE: create striped dir, fail MDT1 and client"
3795 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
3796 ([ $FAILURE_MODE == "HARD" ] &&
3797 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
3798 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
3803 $LFS mkdir -i1 -c$MDSCOUNT $DIR/$tdir/striped_dir
3806 check_striped_dir_110 || error "check striped_dir failed"
3808 rm -rf $DIR/$tdir || error "rmdir failed"
3812 run_test 110c "DNE: create striped dir, fail MDT2"
3815 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
3816 ([ $FAILURE_MODE == "HARD" ] &&
3817 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
3818 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
3823 $LFS mkdir -i1 -c$MDSCOUNT $DIR/$tdir/striped_dir
3826 zconf_mount $(hostname) $MOUNT
3827 client_up || return 1
3829 check_striped_dir_110 || error "check striped_dir failed"
3831 rm -rf $DIR/$tdir || error "rmdir failed"
3835 run_test 110d "DNE: create striped dir, fail MDT2 and client"
3838 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
3839 ([ $FAILURE_MODE == "HARD" ] &&
3840 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
3841 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
3846 $LFS mkdir -i1 -c$MDSCOUNT $DIR/$tdir/striped_dir
3850 zconf_mount $(hostname) $MOUNT
3851 client_up || return 1
3853 check_striped_dir_110 || error "check striped_dir failed"
3855 rm -rf $DIR/$tdir || error "rmdir failed"
3859 run_test 110e "DNE: create striped dir, uncommit on MDT2, fail client/MDT1/MDT2"
3862 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
3863 ([ $FAILURE_MODE == "HARD" ] &&
3864 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
3865 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
3871 $LFS mkdir -i1 -c$MDSCOUNT $DIR/$tdir/striped_dir
3874 check_striped_dir_110 || error "check striped_dir failed"
3876 rm -rf $DIR/$tdir || error "rmdir failed"
3880 run_test 110f "DNE: create striped dir, fail MDT1/MDT2"
3883 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
3884 ([ $FAILURE_MODE == "HARD" ] &&
3885 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
3886 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
3891 $LFS mkdir -i1 -c$MDSCOUNT $DIR/$tdir/striped_dir
3895 zconf_mount $(hostname) $MOUNT
3896 client_up || return 1
3898 check_striped_dir_110 || error "check striped_dir failed"
3900 rm -rf $DIR/$tdir || error "rmdir failed"
3904 run_test 110g "DNE: create striped dir, uncommit on MDT1, fail client/MDT1/MDT2"
3907 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
3908 ([ $FAILURE_MODE == "HARD" ] &&
3909 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
3910 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
3914 $LFS mkdir -i1 -c2 $DIR/$tdir/striped_dir
3916 rm -rf $DIR/$tdir/striped_dir
3919 $CHECKSTAT -t dir $DIR/$tdir/striped_dir &&
3920 error "striped dir still exists"
3923 run_test 111a "DNE: unlink striped dir, fail MDT1"
3926 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
3927 ([ $FAILURE_MODE == "HARD" ] &&
3928 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
3929 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
3933 $LFS mkdir -i1 -c2 $DIR/$tdir/striped_dir
3935 rm -rf $DIR/$tdir/striped_dir
3938 zconf_mount $(hostname) $MOUNT
3939 client_up || return 1
3941 $CHECKSTAT -t dir $DIR/$tdir/striped_dir &&
3942 error "striped dir still exists"
3945 run_test 111b "DNE: unlink striped dir, fail MDT2"
3948 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
3949 ([ $FAILURE_MODE == "HARD" ] &&
3950 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
3951 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
3955 $LFS mkdir -i1 -c2 $DIR/$tdir/striped_dir
3957 rm -rf $DIR/$tdir/striped_dir
3961 zconf_mount $(hostname) $MOUNT
3962 client_up || return 1
3963 $CHECKSTAT -t dir $DIR/$tdir/striped_dir &&
3964 error "striped dir still exists"
3967 run_test 111c "DNE: unlink striped dir, uncommit on MDT1, fail client/MDT1/MDT2"
3970 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
3971 ([ $FAILURE_MODE == "HARD" ] &&
3972 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
3973 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
3977 $LFS mkdir -i1 -c2 $DIR/$tdir/striped_dir
3979 rm -rf $DIR/$tdir/striped_dir
3983 zconf_mount $(hostname) $MOUNT
3984 client_up || return 1
3985 $CHECKSTAT -t dir $DIR/$tdir/striped_dir &&
3986 error "striped dir still exists"
3990 run_test 111d "DNE: unlink striped dir, uncommit on MDT2, fail client/MDT1/MDT2"
3993 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
3994 ([ $FAILURE_MODE == "HARD" ] &&
3995 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
3996 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
4000 $LFS mkdir -i1 -c2 $DIR/$tdir/striped_dir
4002 rm -rf $DIR/$tdir/striped_dir
4005 $CHECKSTAT -t dir $DIR/$tdir/striped_dir &&
4006 error "striped dir still exists"
4009 run_test 111e "DNE: unlink striped dir, uncommit on MDT2, fail MDT1/MDT2"
4012 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
4013 ([ $FAILURE_MODE == "HARD" ] &&
4014 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
4015 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
4019 $LFS mkdir -i1 -c2 $DIR/$tdir/striped_dir
4021 rm -rf $DIR/$tdir/striped_dir
4024 $CHECKSTAT -t dir $DIR/$tdir/striped_dir &&
4025 error "striped dir still exists"
4028 run_test 111f "DNE: unlink striped dir, uncommit on MDT1, fail MDT1/MDT2"
4031 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
4032 ([ $FAILURE_MODE == "HARD" ] &&
4033 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
4034 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
4038 $LFS mkdir -i1 -c2 $DIR/$tdir/striped_dir
4041 rm -rf $DIR/$tdir/striped_dir
4043 $CHECKSTAT -t dir $DIR/$tdir/striped_dir &&
4044 error "striped dir still exists"
4047 run_test 111g "DNE: unlink striped dir, fail MDT1/MDT2"
4049 test_112_rename_prepare() {
4050 mkdir -p $DIR/$tdir/src_dir
4051 $LFS mkdir -i 1 $DIR/$tdir/src_dir/src_child ||
4052 error "create remote source failed"
4054 touch $DIR/$tdir/src_dir/src_child/a
4056 $LFS mkdir -i 2 $DIR/$tdir/tgt_dir ||
4057 error "create remote target dir failed"
4059 $LFS mkdir -i 3 $DIR/$tdir/tgt_dir/tgt_child ||
4060 error "create remote target child failed"
4065 $CHECKSTAT -t dir $DIR/$tdir/src_dir/src_child &&
4066 error "src_child still exists after rename"
4068 $CHECKSTAT -t file $DIR/$tdir/tgt_dir/tgt_child/a ||
4069 error "missing file(a) after rename"
4073 [ $MDSCOUNT -lt 4 ] && skip "needs >= 4 MDTs" && return 0
4074 ([ $FAILURE_MODE == "HARD" ] &&
4075 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
4076 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
4079 test_112_rename_prepare
4082 mrename $DIR/$tdir/src_dir/src_child $DIR/$tdir/tgt_dir/tgt_child ||
4083 error "rename dir cross MDT failed!"
4087 rm -rf $DIR/$tdir || error "rmdir failed"
4089 run_test 112a "DNE: cross MDT rename, fail MDT1"
4092 [ $MDSCOUNT -lt 4 ] && skip "needs >= 4 MDTs" && return 0
4093 ([ $FAILURE_MODE == "HARD" ] &&
4094 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
4095 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
4098 test_112_rename_prepare
4101 mrename $DIR/$tdir/src_dir/src_child $DIR/$tdir/tgt_dir/tgt_child ||
4102 error "rename dir cross MDT failed!"
4107 rm -rf $DIR/$tdir || error "rmdir failed"
4109 run_test 112b "DNE: cross MDT rename, fail MDT2"
4112 [ $MDSCOUNT -lt 4 ] && skip "needs >= 4 MDTs" && return 0
4113 ([ $FAILURE_MODE == "HARD" ] &&
4114 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
4115 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
4118 test_112_rename_prepare
4121 mrename $DIR/$tdir/src_dir/src_child $DIR/$tdir/tgt_dir/tgt_child ||
4122 error "rename dir cross MDT failed!"
4127 rm -rf $DIR/$tdir || error "rmdir failed"
4129 run_test 112c "DNE: cross MDT rename, fail MDT3"
4132 [ $MDSCOUNT -lt 4 ] && skip "needs >= 4 MDTs" && return 0
4133 ([ $FAILURE_MODE == "HARD" ] &&
4134 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
4135 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
4138 test_112_rename_prepare
4141 mrename $DIR/$tdir/src_dir/src_child $DIR/$tdir/tgt_dir/tgt_child ||
4142 error "rename dir cross MDT failed!"
4147 rm -rf $DIR/$tdir || error "rmdir failed"
4149 run_test 112d "DNE: cross MDT rename, fail MDT4"
4152 [ $MDSCOUNT -lt 4 ] && skip "needs >= 4 MDTs" && return 0
4153 ([ $FAILURE_MODE == "HARD" ] &&
4154 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
4155 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
4158 test_112_rename_prepare
4162 mrename $DIR/$tdir/src_dir/src_child $DIR/$tdir/tgt_dir/tgt_child ||
4163 error "rename dir cross MDT failed!"
4168 rm -rf $DIR/$tdir || error "rmdir failed"
4170 run_test 112e "DNE: cross MDT rename, fail MDT1 and MDT2"
4173 [ $MDSCOUNT -lt 4 ] && skip "needs >= 4 MDTs" && return 0
4174 ([ $FAILURE_MODE == "HARD" ] &&
4175 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
4176 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
4179 test_112_rename_prepare
4183 mrename $DIR/$tdir/src_dir/src_child $DIR/$tdir/tgt_dir/tgt_child ||
4184 error "rename dir cross MDT failed!"
4189 rm -rf $DIR/$tdir || error "rmdir failed"
4191 run_test 112f "DNE: cross MDT rename, fail MDT1 and MDT3"
4194 [ $MDSCOUNT -lt 4 ] && skip "needs >= 4 MDTs" && return 0
4195 ([ $FAILURE_MODE == "HARD" ] &&
4196 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
4197 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
4200 test_112_rename_prepare
4204 mrename $DIR/$tdir/src_dir/src_child $DIR/$tdir/tgt_dir/tgt_child ||
4205 error "rename dir cross MDT failed!"
4210 rm -rf $DIR/$tdir || error "rmdir failed"
4212 run_test 112g "DNE: cross MDT rename, fail MDT1 and MDT4"
4215 [ $MDSCOUNT -lt 4 ] && skip "needs >= 4 MDTs" && return 0
4216 ([ $FAILURE_MODE == "HARD" ] &&
4217 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
4218 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
4221 test_112_rename_prepare
4225 mrename $DIR/$tdir/src_dir/src_child $DIR/$tdir/tgt_dir/tgt_child ||
4226 error "rename dir cross MDT failed!"
4231 rm -rf $DIR/$tdir || error "rmdir failed"
4233 run_test 112h "DNE: cross MDT rename, fail MDT2 and MDT3"
4236 [ $MDSCOUNT -lt 4 ] && skip "needs >= 4 MDTs" && return 0
4237 ([ $FAILURE_MODE == "HARD" ] &&
4238 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
4239 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
4242 test_112_rename_prepare
4246 mrename $DIR/$tdir/src_dir/src_child $DIR/$tdir/tgt_dir/tgt_child ||
4247 error "rename dir cross MDT failed!"
4252 rm -rf $DIR/$tdir || error "rmdir failed"
4254 run_test 112i "DNE: cross MDT rename, fail MDT2 and MDT4"
4257 [ $MDSCOUNT -lt 4 ] && skip "needs >= 4 MDTs" && return 0
4258 ([ $FAILURE_MODE == "HARD" ] &&
4259 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
4260 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
4263 test_112_rename_prepare
4267 mrename $DIR/$tdir/src_dir/src_child $DIR/$tdir/tgt_dir/tgt_child ||
4268 error "rename dir cross MDT failed!"
4273 rm -rf $DIR/$tdir || error "rmdir failed"
4275 run_test 112j "DNE: cross MDT rename, fail MDT3 and MDT4"
4278 [ $MDSCOUNT -lt 4 ] && skip "needs >= 4 MDTs" && return 0
4279 ([ $FAILURE_MODE == "HARD" ] &&
4280 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
4281 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
4284 test_112_rename_prepare
4289 mrename $DIR/$tdir/src_dir/src_child $DIR/$tdir/tgt_dir/tgt_child ||
4290 error "rename dir cross MDT failed!"
4295 rm -rf $DIR/$tdir || error "rmdir failed"
4297 run_test 112k "DNE: cross MDT rename, fail MDT1,MDT2,MDT3"
4300 [ $MDSCOUNT -lt 4 ] && skip "needs >= 4 MDTs" && return 0
4301 ([ $FAILURE_MODE == "HARD" ] &&
4302 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
4303 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
4306 test_112_rename_prepare
4311 mrename $DIR/$tdir/src_dir/src_child $DIR/$tdir/tgt_dir/tgt_child ||
4312 error "rename dir cross MDT failed!"
4317 rm -rf $DIR/$tdir || error "rmdir failed"
4319 run_test 112l "DNE: cross MDT rename, fail MDT1,MDT2,MDT4"
4322 [ $MDSCOUNT -lt 4 ] && skip "needs >= 4 MDTs" && return 0
4323 ([ $FAILURE_MODE == "HARD" ] &&
4324 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
4325 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
4328 test_112_rename_prepare
4333 mrename $DIR/$tdir/src_dir/src_child $DIR/$tdir/tgt_dir/tgt_child ||
4334 error "rename dir cross MDT failed!"
4339 rm -rf $DIR/$tdir || error "rmdir failed"
4341 run_test 112m "DNE: cross MDT rename, fail MDT1,MDT3,MDT4"
4344 [ $MDSCOUNT -lt 4 ] && skip "needs >= 4 MDTs" && return 0
4345 ([ $FAILURE_MODE == "HARD" ] &&
4346 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
4347 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
4350 test_112_rename_prepare
4355 mrename $DIR/$tdir/src_dir/src_child $DIR/$tdir/tgt_dir/tgt_child ||
4356 error "rename dir cross MDT failed!"
4361 rm -rf $DIR/$tdir || error "rmdir failed"
4363 run_test 112n "DNE: cross MDT rename, fail MDT2,MDT3,MDT4"
4366 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
4367 ([ $FAILURE_MODE == "HARD" ] &&
4368 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
4369 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
4377 for ((j=0;j<$((MDSCOUNT));j++)); do
4378 fail_index=$((fail_index+1))
4379 index=$((fail_index % MDSCOUNT))
4380 replay_barrier mds$((index + 1))
4381 for ((i=0;i<5;i++)); do
4382 test_mkdir -i$index -c$MDSCOUNT $DIR/$tdir/test_$i ||
4383 error "create striped dir $DIR/$tdir/test_$i"
4386 fail mds$((index + 1))
4387 for ((i=0;i<5;i++)); do
4388 checkstat -t dir $DIR/$tdir/test_$i ||
4389 error "$DIR/$tdir/test_$i does not exist!"
4391 rm -rf $DIR/$tdir/test_* ||
4395 run_test 115 "failover for create/unlink striped directory"
4398 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
4399 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.55) ] &&
4400 skip "Do not support large update log before 2.7.55" &&
4402 ([ $FAILURE_MODE == "HARD" ] &&
4403 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
4404 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
4411 # OBD_FAIL_SPLIT_UPDATE_REC 0x1702
4412 do_facet mds1 "lctl set_param fail_loc=0x80001702"
4413 $LFS setdirstripe -c$MDSCOUNT $DIR/$tdir/striped_dir
4416 $CHECKSTAT -t dir $DIR/$tdir/striped_dir ||
4417 error "stried_dir does not exists"
4419 run_test 116a "large update log master MDT recovery"
4422 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
4423 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.55) ] &&
4424 skip "Do not support large update log before 2.7.55" &&
4427 ([ $FAILURE_MODE == "HARD" ] &&
4428 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
4429 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
4436 # OBD_FAIL_SPLIT_UPDATE_REC 0x1702
4437 do_facet mds2 "lctl set_param fail_loc=0x80001702"
4438 $LFS setdirstripe -c$MDSCOUNT $DIR/$tdir/striped_dir
4441 $CHECKSTAT -t dir $DIR/$tdir/striped_dir ||
4442 error "stried_dir does not exists"
4444 run_test 116b "large update log slave MDT recovery"
4447 [ $MDSCOUNT -lt 4 ] && skip "needs >= 4 MDTs" && return 0
4448 ([ $FAILURE_MODE == "HARD" ] &&
4449 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
4450 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
4456 $LFS setdirstripe -i0 -c$MDSCOUNT $DIR/$tdir/remote_dir
4457 $LFS setdirstripe -i1 -c$MDSCOUNT $DIR/$tdir/remote_dir_1
4460 # Let's set rdonly on all MDTs, so client will send
4461 # replay requests on all MDTs and replay these requests
4462 # at the same time. This test will verify the recovery
4463 # will not be deadlock in this case, LU-7531.
4464 for ((index = 0; index < $((MDSCOUNT)); index++)); do
4465 replay_barrier mds$((index + 1))
4466 if [ -z $mds_indexs ]; then
4467 mds_indexs="${mds_indexs}mds$((index+1))"
4469 mds_indexs="${mds_indexs},mds$((index+1))"
4473 rm -rf $DIR/$tdir/remote_dir
4474 rm -rf $DIR/$tdir/remote_dir_1
4478 rm -rf $DIR/$tdir || error "rmdir failed"
4480 run_test 117 "DNE: cross MDT unlink, fail MDT1 and MDT2"
4483 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
4484 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.64) ] &&
4485 skip "Do not support large update log before 2.7.64" &&
4490 $LFS setdirstripe -c2 $DIR/$tdir/striped_dir ||
4491 error "setdirstripe fails"
4492 $LFS setdirstripe -c2 $DIR/$tdir/striped_dir1 ||
4493 error "setdirstripe fails 1"
4494 rm -rf $DIR/$tdir/striped_dir* || error "rmdir fails"
4496 # OBD_FAIL_INVALIDATE_UPDATE 0x1705
4497 do_facet mds1 "lctl set_param fail_loc=0x1705"
4498 $LFS setdirstripe -c2 $DIR/$tdir/striped_dir
4499 $LFS setdirstripe -c2 $DIR/$tdir/striped_dir1
4500 do_facet mds1 "lctl set_param fail_loc=0x0"
4503 $LFS setdirstripe -c2 $DIR/$tdir/striped_dir
4504 $LFS setdirstripe -c2 $DIR/$tdir/striped_dir1
4509 run_test 118 "invalidate osp update will not cause update log corruption"
4512 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
4513 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.64) ] &&
4514 skip "Do not support large update log before 2.7.64" &&
4517 local hard_timeout=$(do_facet mds1 \
4518 "lctl get_param -n mdt.$FSNAME-MDT0000.recovery_time_hard")
4520 local clients=${CLIENTS:-$HOSTNAME}
4521 local time_min=$(recovery_time_min)
4524 mkdir $DIR/$tdir/tmp
4525 rmdir $DIR/$tdir/tmp
4528 mkdir $DIR/$tdir/dir_1
4529 for ((i = 0; i < 20; i++)); do
4530 $LFS setdirstripe -c2 $DIR/$tdir/stripe_dir-$i
4537 #define OBD_FAIL_TGT_REPLAY_DELAY 0x714
4538 do_facet mds1 $LCTL set_param fail_loc=0x80000714
4539 #sleep (timeout + 5), so mds will evict the client exports,
4540 #but DNE update recovery will keep going.
4541 do_facet mds1 $LCTL set_param fail_val=$((time_min + 5))
4543 mount_facet mds1 "-o recovery_time_hard=$time_min"
4545 wait_clients_import_state "$clients" mds1 FULL
4547 clients_up || clients_up || error "failover df: $?"
4549 #revert back the hard timeout
4550 do_facet mds1 $LCTL set_param \
4551 mdt.$FSNAME-MDT0000.recovery_time_hard=$hard_timeout
4553 for ((i = 0; i < 20; i++)); do
4554 stripe_count=$($LFS getdirstripe -c $DIR/$tdir/stripe_dir-$i)
4555 [ $stripe_count == 2 ] || {
4556 error "stripe_dir-$i creation replay fails"
4561 run_test 119 "timeout of normal replay does not cause DNE replay fails "
4564 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
4565 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.64) ] &&
4566 skip "Do not support large update log before 2.7.64" &&
4570 replay_barrier_nosync mds1
4571 for ((i = 0; i < 20; i++)); do
4572 mkdir $DIR/$tdir/dir-$i || {
4573 error "create dir-$i fails"
4576 $LFS setdirstripe -c2 $DIR/$tdir/stripe_dir-$i || {
4577 error "create stripe_dir-$i fails"
4584 for ((i = 0; i < 20; i++)); do
4585 [ ! -e "$DIR/$tdir/dir-$i" ] || {
4586 error "dir-$i still exists"
4589 [ ! -e "$DIR/$tdir/stripe_dir-$i" ] || {
4590 error "stripe_dir-$i still exists"
4595 run_test 120 "DNE fail abort should stop both normal and DNE replay"
4598 check_and_cleanup_lustre