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))
452 local extra=$(fs_log_size)
456 $LFS setstripe -i 0 -c 1 $DIR
458 local beforeused=$(df -P $DIR | tail -1 | awk '{ print $3 }')
460 dd if=/dev/zero of=$DIR/$tfile bs=4k count=10000 &
461 while [ ! -e $DIR/$tfile ] ; do
462 usleep 60 # give dd a chance to start
465 $LFS getstripe $DIR/$tfile || error "$LFS getstripe $DIR/$tfile failed"
467 rm -f $DIR/$tfile || error "rm -f $DIR/$tfile failed"
469 client_up || client_up || true # reconnect
471 do_facet $SINGLEMDS "lctl set_param -n osd*.*MDT*.force_sync=1"
473 fail $SINGLEMDS # start orphan recovery
474 wait_recovery_complete $SINGLEMDS || error "MDS recovery not done"
475 wait_delete_completed $wait_timeout || error "delete did not finish"
479 local afterused=$(df -P $DIR | tail -1 | awk '{ print $3 }')
480 log "before $beforeused, after $afterused"
482 (( $beforeused + $extra >= $afterused )) && break
483 n_attempts=$((n_attempts + 1))
484 [ $n_attempts -gt 3 ] &&
485 error "after $afterused > before $beforeused"
487 wait_zfs_commit $SINGLEMDS 5
492 run_test 20b "write, unlink, eviction, replay (test mds_cleanup_orphans)"
494 test_20c() { # bug 10480
495 multiop_bg_pause $DIR/$tfile Ow_c ||
496 error "multiop_bg_pause $DIR/$tfile failed"
502 client_up || client_up || true # reconnect
504 kill -USR1 $pid || error "multiop $pid not running"
505 wait $pid || error "multiop $pid failed"
506 [ -s $DIR/$tfile ] || error "File was truncated"
510 run_test 20c "check that client eviction does not affect file content"
513 replay_barrier $SINGLEMDS
514 multiop_bg_pause $DIR/$tfile O_tSc ||
515 error "multiop_bg_pause $DIR/$tfile failed"
518 touch $DIR/$tfile-1 || error "touch $DIR/$tfile-1 failed"
521 kill -USR1 $pid || error "multiop $pid not running"
522 wait $pid || error "multiop $pid failed"
523 [ -e $DIR/$tfile ] && error "file $DIR/$tfile should not exist"
524 touch $DIR/$tfile-2 || error "touch $DIR/$tfile-2 failed"
527 run_test 21 "|X| open(O_CREAT), unlink touch new, replay, close (test mds_cleanup_orphans)"
530 multiop_bg_pause $DIR/$tfile O_tSc ||
531 error "multiop_bg_pause $DIR/$tfile failed"
534 replay_barrier $SINGLEMDS
538 kill -USR1 $pid || error "multiop $pid not running"
539 wait $pid || error "multiop $pid failed"
540 [ -e $DIR/$tfile ] && error "file $DIR/$tfile should not exist"
543 run_test 22 "open(O_CREAT), |X| unlink, replay, close (test mds_cleanup_orphans)"
546 multiop_bg_pause $DIR/$tfile O_tSc ||
547 error "multiop_bg_pause $DIR/$tfile failed"
550 replay_barrier $SINGLEMDS
552 touch $DIR/$tfile-1 || error "touch $DIR/$tfile-1 failed"
555 kill -USR1 $pid || error "multiop $pid not running"
556 wait $pid || error "multiop $pid failed"
557 [ -e $DIR/$tfile ] && error "file $DIR/$tfile should not exist"
558 touch $DIR/$tfile-2 || error "touch $DIR/$tfile-2 failed"
561 run_test 23 "open(O_CREAT), |X| unlink touch new, replay, close (test mds_cleanup_orphans)"
564 multiop_bg_pause $DIR/$tfile O_tSc ||
565 error "multiop_bg_pause $DIR/$tfile failed"
568 replay_barrier $SINGLEMDS
571 kill -USR1 $pid || error "multiop $pid not running"
572 wait $pid || error "multiop $pid failed"
573 [ -e $DIR/$tfile ] && error "file $DIR/$tfile should not exist"
576 run_test 24 "open(O_CREAT), replay, unlink, close (test mds_cleanup_orphans)"
579 multiop_bg_pause $DIR/$tfile O_tSc ||
580 error "multiop_bg_pause $DIR/$tfile failed"
584 replay_barrier $SINGLEMDS
586 kill -USR1 $pid || error "multiop $pid not running"
587 wait $pid || error "multiop $pid failed"
588 [ -e $DIR/$tfile ] && error "file $DIR/$tfile should not exist"
591 run_test 25 "open(O_CREAT), unlink, replay, close (test mds_cleanup_orphans)"
594 replay_barrier $SINGLEMDS
595 multiop_bg_pause $DIR/$tfile-1 O_tSc ||
596 error "multiop_bg_pause $DIR/$tfile-1 failed"
598 multiop_bg_pause $DIR/$tfile-2 O_tSc ||
599 error "multiop_bg_pause $DIR/$tfile-2 failed"
603 kill -USR1 $pid2 || error "second multiop $pid2 not running"
604 wait $pid2 || error "second multiop $pid2 failed"
607 kill -USR1 $pid1 || error "multiop $pid1 not running"
608 wait $pid1 || error "multiop $pid1 failed"
609 [ -e $DIR/$tfile-1 ] && error "file $DIR/$tfile-1 should not exist"
610 [ -e $DIR/$tfile-2 ] && error "file $DIR/$tfile-2 should not exist"
613 run_test 26 "|X| open(O_CREAT), unlink two, close one, replay, close one (test mds_cleanup_orphans)"
616 replay_barrier $SINGLEMDS
617 multiop_bg_pause $DIR/$tfile-1 O_tSc ||
618 error "multiop_bg_pause $DIR/$tfile-1 failed"
620 multiop_bg_pause $DIR/$tfile-2 O_tSc ||
621 error "multiop_bg_pause $DIR/$tfile-2 failed"
627 kill -USR1 $pid1 || error "multiop $pid1 not running"
628 wait $pid1 || error "multiop $pid1 failed"
629 kill -USR1 $pid2 || error "second multiop $pid2 not running"
630 wait $pid2 || error "second multiop $pid2 failed"
631 [ -e $DIR/$tfile-1 ] && error "file $DIR/$tfile-1 should not exist"
632 [ -e $DIR/$tfile-2 ] && error "file $DIR/$tfile-2 should not exist"
635 run_test 27 "|X| open(O_CREAT), unlink two, replay, close two (test mds_cleanup_orphans)"
638 multiop_bg_pause $DIR/$tfile-1 O_tSc ||
639 error "multiop_bg_pause $DIR/$tfile-1 failed"
641 multiop_bg_pause $DIR/$tfile-2 O_tSc ||
642 error "multiop_bg_pause $DIR/$tfile-2 failed"
644 replay_barrier $SINGLEMDS
647 kill -USR1 $pid2 || error "second multiop $pid2 not running"
648 wait $pid2 || error "second multiop $pid2 failed"
651 kill -USR1 $pid1 || error "multiop $pid1 not running"
652 wait $pid1 || error "multiop $pid1 failed"
653 [ -e $DIR/$tfile-1 ] && error "file $DIR/$tfile-1 should not exist"
654 [ -e $DIR/$tfile-2 ] && error "file $DIR/$tfile-2 should not exist"
657 run_test 28 "open(O_CREAT), |X| unlink two, close one, replay, close one (test mds_cleanup_orphans)"
660 multiop_bg_pause $DIR/$tfile-1 O_tSc ||
661 error "multiop_bg_pause $DIR/$tfile-1 failed"
663 multiop_bg_pause $DIR/$tfile-2 O_tSc ||
664 error "multiop_bg_pause $DIR/$tfile-2 failed"
666 replay_barrier $SINGLEMDS
671 kill -USR1 $pid1 || error "multiop $pid1 not running"
672 wait $pid1 || error "multiop $pid1 failed"
673 kill -USR1 $pid2 || error "second multiop $pid2 not running"
674 wait $pid2 || error "second multiop $pid2 failed"
675 [ -e $DIR/$tfile-1 ] && error "file $DIR/$tfile-1 should not exist"
676 [ -e $DIR/$tfile-2 ] && error "file $DIR/$tfile-2 should not exist"
679 run_test 29 "open(O_CREAT), |X| unlink two, replay, close two (test mds_cleanup_orphans)"
682 multiop_bg_pause $DIR/$tfile-1 O_tSc ||
683 error "multiop_bg_pause $DIR/$tfile-1 failed"
685 multiop_bg_pause $DIR/$tfile-2 O_tSc ||
686 error "multiop_bg_pause $DIR/$tfile-2 failed"
691 replay_barrier $SINGLEMDS
693 kill -USR1 $pid1 || error "multiop $pid1 not running"
694 wait $pid1 || error "multiop $pid1 failed"
695 kill -USR1 $pid2 || error "second multiop $pid2 not running"
696 wait $pid2 || error "second multiop $pid2 failed"
697 [ -e $DIR/$tfile-1 ] && error "file $DIR/$tfile-1 should not exist"
698 [ -e $DIR/$tfile-2 ] && error "file $DIR/$tfile-2 should not exist"
701 run_test 30 "open(O_CREAT) two, unlink two, replay, close two (test mds_cleanup_orphans)"
704 multiop_bg_pause $DIR/$tfile-1 O_tSc ||
705 error "multiop_bg_pause $DIR/$tfile-1 failed"
707 multiop_bg_pause $DIR/$tfile-2 O_tSc ||
708 error "multiop_bg_pause $DIR/$tfile-2 failed"
712 replay_barrier $SINGLEMDS
715 kill -USR1 $pid1 || error "multiop $pid1 not running"
716 wait $pid1 || error "multiop $pid1 failed"
717 kill -USR1 $pid2 || error "second multiop $pid2 not running"
718 wait $pid2 || error "second multiop $pid2 failed"
719 [ -e $DIR/$tfile-1 ] && error "file $DIR/$tfile-1 should not exist"
720 [ -e $DIR/$tfile-2 ] && error "file $DIR/$tfile-2 should not exist"
723 run_test 31 "open(O_CREAT) two, unlink one, |X| unlink one, close two (test mds_cleanup_orphans)"
725 # tests for bug 2104; completion without crashing is success. The close is
726 # stale, but we always return 0 for close, so the app never sees it.
728 multiop_bg_pause $DIR/$tfile O_c ||
729 error "multiop_bg_pause $DIR/$tfile failed"
731 multiop_bg_pause $DIR/$tfile O_c ||
732 error "second multiop_bg_pause $DIR/$tfile failed"
735 client_up || client_up || error "client_up failed"
736 kill -USR1 $pid1 || error "multiop $pid1 not running"
737 kill -USR1 $pid2 || error "second multiop $pid2 not running"
738 wait $pid1 || error "multiop $pid1 failed"
739 wait $pid2 || error "second multiop $pid2 failed"
742 run_test 32 "close() notices client eviction; close() after client eviction"
745 createmany -o $DIR/$tfile-%d 10 ||
746 error "createmany create $DIR/$tfile failed"
747 replay_barrier_nosync $SINGLEMDS
748 fail_abort $SINGLEMDS
749 # recreate shouldn't fail
750 createmany -o $DIR/$tfile--%d 10 ||
751 error "createmany recreate $DIR/$tfile failed"
755 run_test 33a "fid seq shouldn't be reused after abort recovery"
758 #define OBD_FAIL_SEQ_ALLOC 0x1311
759 do_facet $SINGLEMDS "lctl set_param fail_loc=0x1311"
761 createmany -o $DIR/$tfile-%d 10
762 replay_barrier_nosync $SINGLEMDS
763 fail_abort $SINGLEMDS
764 # recreate shouldn't fail
765 createmany -o $DIR/$tfile--%d 10 ||
766 error "createmany recreate $DIR/$tfile failed"
770 run_test 33b "test fid seq allocation"
773 multiop_bg_pause $DIR/$tfile O_c ||
774 error "multiop_bg_pause $DIR/$tfile failed"
778 replay_barrier $SINGLEMDS
779 fail_abort $SINGLEMDS
780 kill -USR1 $pid || error "multiop $pid not running"
781 wait $pid || error "multiop $pid failed"
782 [ -e $DIR/$tfile ] && error "file $DIR/$tfile should not exist"
786 run_test 34 "abort recovery before client does replay (test mds_cleanup_orphans)"
788 # bug 2278 - generate one orphan on OST, then destroy it during recovery from llog
790 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
792 #define OBD_FAIL_MDS_REINT_NET_REP 0x119
793 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000119"
798 # give a chance to remove from MDS
799 fail_abort $SINGLEMDS
800 $CHECKSTAT -t file $DIR/$tfile &&
801 error "$CHECKSTAT $DIR/$tfile attribute check should fail" ||
804 run_test 35 "test recovery from llog for unlink op"
806 # b=2432 resent cancel after replay uses wrong cookie,
807 # so don't resend cancels
809 replay_barrier $SINGLEMDS
811 checkstat $DIR/$tfile
812 facet_failover $SINGLEMDS
814 if dmesg | grep "unknown lock cookie"; then
815 error "cancel after replay failed"
818 run_test 36 "don't resend cancel"
821 # directory orphans can't be unlinked from PENDING directory
823 rmdir $DIR/$tfile 2>/dev/null
824 multiop_bg_pause $DIR/$tfile dD_c ||
825 error "multiop_bg_pause $DIR/$tfile failed"
829 replay_barrier $SINGLEMDS
830 # clear the dmesg buffer so we only see errors from this recovery
831 do_facet $SINGLEMDS dmesg -c >/dev/null
832 fail_abort $SINGLEMDS
833 kill -USR1 $pid || error "multiop $pid not running"
834 do_facet $SINGLEMDS dmesg | grep "error .* unlinking .* from PENDING" &&
835 error "error unlinking files"
836 wait $pid || error "multiop $pid failed"
840 run_test 37 "abort recovery before client does replay (test mds_cleanup_orphans for directories)"
843 createmany -o $DIR/$tfile-%d 800 ||
844 error "createmany -o $DIR/$tfile failed"
845 unlinkmany $DIR/$tfile-%d 0 400 || error "unlinkmany $DIR/$tfile failed"
846 replay_barrier $SINGLEMDS
848 unlinkmany $DIR/$tfile-%d 400 400 ||
849 error "unlinkmany $DIR/$tfile 400 failed"
851 $CHECKSTAT -t file $DIR/$tfile-* &&
852 error "$CHECKSTAT $DIR/$tfile-* attribute check should fail" ||
855 run_test 38 "test recovery from unlink llog (test llog_gen_rec) "
857 test_39() { # bug 4176
858 createmany -o $DIR/$tfile-%d 800 ||
859 error "createmany -o $DIR/$tfile failed"
860 replay_barrier $SINGLEMDS
861 unlinkmany $DIR/$tfile-%d 0 400
863 unlinkmany $DIR/$tfile-%d 400 400 ||
864 error "unlinkmany $DIR/$tfile 400 failed"
866 $CHECKSTAT -t file $DIR/$tfile-* &&
867 error "$CHECKSTAT $DIR/$tfile-* attribute check should fail" ||
870 run_test 39 "test recovery from unlink llog (test llog_gen_rec) "
873 lctl get_param -n osc.*.stats | awk -vwrites=0 '/ost_write/ { writes += $2 } END { print writes; }'
878 # always need connection to MDS to verify layout during IO. LU-2628.
879 lctl get_param mdc.*.connect_flags | grep -q layout_lock &&
880 skip "layout_lock needs MDS connection for IO" && return 0
882 $LCTL mark multiop $MOUNT/$tfile OS_c
883 multiop $MOUNT/$tfile OS_c &
885 writeme -s $MOUNT/${tfile}-2 &
888 facet_failover $SINGLEMDS
889 #define OBD_FAIL_MDS_CONNECT_NET 0x117
890 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000117"
892 stat1=$(count_ost_writes)
894 stat2=$(count_ost_writes)
895 echo "$stat1, $stat2"
896 if [ $stat1 -lt $stat2 ]; then
897 echo "writes continuing during recovery"
900 echo "writes not continuing during recovery, bug 2477"
903 echo "waiting for writeme $WRITE_PID"
907 echo "waiting for multiop $PID"
908 wait $PID || error "multiop $PID failed"
909 do_facet client munlink $MOUNT/$tfile ||
910 error "munlink $MOUNT/$tfile failed"
911 do_facet client munlink $MOUNT/${tfile}-2 ||
912 error "munlink $MOUNT/$tfile-2 failed"
915 run_test 40 "cause recovery in ptlrpc, ensure IO continues"
918 # make sure that a read to one osc doesn't try to double-unlock its page just
919 # because another osc is invalid. trigger_group_io used to mistakenly return
920 # an error if any oscs were invalid even after having successfully put rpcs
921 # on valid oscs. This was fatal if the caller was ll_readpage who unlocked
922 # the page, guarnateeing that the unlock from the RPC completion would
923 # assert on trying to unlock the unlocked page.
925 [ $OSTCOUNT -lt 2 ] && skip_env "needs >= 2 OSTs" && return
927 local f=$MOUNT/$tfile
928 # make sure the start of the file is ost1
929 $SETSTRIPE -S $((128 * 1024)) -i 0 $f
930 do_facet client dd if=/dev/zero of=$f bs=4k count=1 ||
931 error "dd on client failed"
933 # fail ost2 and read from ost1
934 local mdtosc=$(get_mdtosc_proc_path $SINGLEMDS $ost2_svc)
935 local osc2dev=$(do_facet $SINGLEMDS "lctl get_param -n devices" |
936 grep $mdtosc | awk '{print $1}')
937 [ -z "$osc2dev" ] && echo "OST: $ost2_svc" &&
938 lctl get_param -n devices &&
939 error "OST 2 $osc2dev does not exist"
940 do_facet $SINGLEMDS $LCTL --device $osc2dev deactivate ||
941 error "deactive device on $SINGLEMDS failed"
942 do_facet client dd if=$f of=/dev/null bs=4k count=1 ||
943 error "second dd on client failed"
944 do_facet $SINGLEMDS $LCTL --device $osc2dev activate ||
945 error "active device on $SINGLEMDS failed"
948 run_test 41 "read from a valid osc while other oscs are invalid"
950 # test MDS recovery after ost failure
952 blocks=$(df -P $MOUNT | tail -n 1 | awk '{ print $2 }')
953 createmany -o $DIR/$tfile-%d 800 ||
954 error "createmany -o $DIR/$tfile failed"
956 unlinkmany $DIR/$tfile-%d 0 400
958 lctl set_param debug=-1
961 # osc is evicted, fs is smaller (but only with failout OSTs (bug 7287)
962 #blocks_after=`df -P $MOUNT | tail -n 1 | awk '{ print $2 }'`
963 #[ $blocks_after -lt $blocks ] || return 1
964 echo "wait for MDS to timeout and recover"
965 sleep $((TIMEOUT * 2))
967 unlinkmany $DIR/$tfile-%d 400 400 ||
968 error "unlinkmany $DIR/$tfile 400 failed"
969 $CHECKSTAT -t file $DIR/$tfile-* &&
970 error "$CHECKSTAT $DIR/$tfile-* attribute check should fail" ||
973 run_test 42 "recovery after ost failure"
975 # timeout in MDS/OST recovery RPC will LBUG MDS
976 test_43() { # bug 2530
977 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
979 replay_barrier $SINGLEMDS
981 # OBD_FAIL_OST_CREATE_NET 0x204
982 do_facet ost1 "lctl set_param fail_loc=0x80000204"
988 run_test 43 "mds osc import failure during recovery; don't LBUG"
990 test_44a() { # was test_44
993 local mdcdev=$($LCTL dl |
994 awk "/${FSNAME}-MDT0000-mdc-/ {if (\$2 == \"UP\") {print \$1}}")
995 [ "$mdcdev" ] || error "${FSNAME}-MDT0000-mdc- not UP"
996 [ $(echo $mdcdev | wc -w) -eq 1 ] ||
997 { $LCTL dl; error "looking for mdcdev=$mdcdev"; }
999 # adaptive timeouts slow this way down
1000 if at_is_enabled; then
1001 at_max_saved=$(at_max_get mds)
1005 for i in $(seq 1 10); do
1006 echo "$i of 10 ($(date +%s))"
1007 do_facet $SINGLEMDS \
1008 "lctl get_param -n md[ts].*.mdt.timeouts | grep service"
1009 #define OBD_FAIL_TGT_CONN_RACE 0x701
1010 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000701"
1011 # lctl below may fail, it is valid case
1012 $LCTL --device $mdcdev recover
1015 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
1016 [ $at_max_saved -ne 0 ] && at_max_set $at_max_saved mds
1019 run_test 44a "race in target handle connect"
1022 local mdcdev=$($LCTL dl |
1023 awk "/${FSNAME}-MDT0000-mdc-/ {if (\$2 == \"UP\") {print \$1}}")
1024 [ "$mdcdev" ] || error "${FSNAME}-MDT0000-mdc not up"
1025 [ $(echo $mdcdev | wc -w) -eq 1 ] ||
1026 { echo mdcdev=$mdcdev; $LCTL dl;
1027 error "more than one ${FSNAME}-MDT0000-mdc"; }
1029 for i in $(seq 1 10); do
1030 echo "$i of 10 ($(date +%s))"
1031 do_facet $SINGLEMDS \
1032 "lctl get_param -n md[ts].*.mdt.timeouts | grep service"
1033 #define OBD_FAIL_TGT_DELAY_RECONNECT 0x704
1034 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000704"
1035 # lctl below may fail, it is valid case
1036 $LCTL --device $mdcdev recover
1041 run_test 44b "race in target handle connect"
1044 replay_barrier $SINGLEMDS
1045 createmany -m $DIR/$tfile-%d 100 || error "failed to create directories"
1046 #define OBD_FAIL_TGT_RCVG_FLAG 0x712
1047 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000712"
1048 fail_abort $SINGLEMDS
1049 unlinkmany $DIR/$tfile-%d 100 && error "unliked after fail abort"
1051 unlinkmany $DIR/$tfile-%d 100 && error "unliked after fail"
1054 run_test 44c "race in target handle connect"
1056 # Handle failed close
1058 local mdcdev=$($LCTL get_param -n devices |
1059 awk "/ ${FSNAME}-MDT0000-mdc-/ {print \$1}")
1060 [ "$mdcdev" ] || error "${FSNAME}-MDT0000-mdc not up"
1061 [ $(echo $mdcdev | wc -w) -eq 1 ] ||
1062 { echo mdcdev=$mdcdev; $LCTL dl;
1063 error "more than one ${FSNAME}-MDT0000-mdc"; }
1065 $LCTL --device $mdcdev recover ||
1066 error "$LCTL --device $mdcdev recover failed"
1068 multiop_bg_pause $DIR/$tfile O_c ||
1069 error "multiop_bg_pause $DIR/$tfile failed"
1072 # This will cause the CLOSE to fail before even
1073 # allocating a reply buffer
1074 $LCTL --device $mdcdev deactivate ||
1075 error "$LCTL --device $mdcdev deactivate failed"
1078 kill -USR1 $pid || error "multiop $pid not running"
1079 wait $pid || error "multiop $pid failed"
1081 $LCTL --device $mdcdev activate ||
1082 error "$LCTL --device $mdcdev activate failed"
1085 $CHECKSTAT -t file $DIR/$tfile ||
1086 error "$CHECKSTAT $DIR/$tfile attribute check failed"
1089 run_test 45 "Handle failed close"
1093 drop_reply "touch $DIR/$tfile"
1095 # ironically, the previous test, 45, will cause a real forced close,
1096 # so just look for one for this test
1097 dmesg | grep -i "force closing client file handle for $tfile" &&
1098 error "found force closing in dmesg"
1101 run_test 46 "Don't leak file handle after open resend (3325)"
1103 test_47() { # bug 2824
1104 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1106 # create some files to make sure precreate has been done on all
1107 # OSTs. (just in case this test is run independently)
1108 createmany -o $DIR/$tfile 20 ||
1109 error "createmany create $DIR/$tfile failed"
1111 # OBD_FAIL_OST_CREATE_NET 0x204
1113 do_facet ost1 "lctl set_param fail_loc=0x80000204"
1114 client_up || error "client_up failed"
1116 # let the MDS discover the OST failure, attempt to recover, fail
1117 # and recover again.
1118 sleep $((3 * TIMEOUT))
1120 # Without 2824, this createmany would hang
1121 createmany -o $DIR/$tfile 20 ||
1122 error "createmany recraete $DIR/$tfile failed"
1123 unlinkmany $DIR/$tfile 20 || error "unlinkmany $DIR/$tfile failed"
1127 run_test 47 "MDS->OSC failure during precreate cleanup (2824)"
1130 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1131 [ "$OSTCOUNT" -lt "2" ] && skip_env "needs >= 2 OSTs" && return
1133 replay_barrier $SINGLEMDS
1134 createmany -o $DIR/$tfile 20 ||
1135 error "createmany -o $DIR/$tfile failed"
1136 # OBD_FAIL_OST_EROFS 0x216
1137 facet_failover $SINGLEMDS
1138 do_facet ost1 "lctl set_param fail_loc=0x80000216"
1139 client_up || error "client_up failed"
1141 createmany -o $DIR/$tfile 20 20 ||
1142 error "createmany recraete $DIR/$tfile failed"
1143 unlinkmany $DIR/$tfile 40 || error "unlinkmany $DIR/$tfile failed"
1146 run_test 48 "MDS->OSC failure during precreate cleanup (2824)"
1149 local mdtosc=$(get_mdtosc_proc_path $SINGLEMDS $ost1_svc)
1150 local oscdev=$(do_facet $SINGLEMDS "lctl get_param -n devices" |
1151 grep $mdtosc | awk '{print $1}')
1152 [ "$oscdev" ] || error "could not find OSC device on MDS"
1153 do_facet $SINGLEMDS $LCTL --device $oscdev recover ||
1154 error "OSC device $oscdev recovery failed"
1155 do_facet $SINGLEMDS $LCTL --device $oscdev recover ||
1156 error "second OSC device $oscdev recovery failed"
1157 # give the mds_lov_sync threads a chance to run
1160 run_test 50 "Double OSC recovery, don't LASSERT (3812)"
1162 # b3764 timed out lock replay
1164 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.6.90) ] &&
1165 skip "MDS prior to 2.6.90 handle LDLM_REPLY_NET incorrectly" &&
1168 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
1169 cancel_lru_locks mdc
1171 multiop_bg_pause $DIR/$tfile s_s || error "multiop $DIR/$tfile failed"
1174 #define OBD_FAIL_MDS_LDLM_REPLY_NET 0x157
1175 lctl set_param -n ldlm.cancel_unused_locks_before_replay "0"
1176 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000157"
1178 fail $SINGLEMDS || error "fail $SINGLEMDS failed"
1180 wait $mpid || error "multiop_bg_pause pid failed"
1182 do_facet $SINGLEMDS "lctl set_param fail_loc=0x0"
1183 lctl set_param fail_loc=0x0
1184 lctl set_param -n ldlm.cancel_unused_locks_before_replay "1"
1187 run_test 52 "time out lock replay (3764)"
1189 # bug 3462 - simultaneous MDC requests
1191 [[ $(lctl get_param mdc.*.import |
1192 grep "connect_flags:.*multi_mod_rpc") ]] ||
1193 { skip "Need MDC with 'multi_mod_rpcs' feature"; return 0; }
1195 cancel_lru_locks mdc # cleanup locks from former test cases
1196 mkdir $DIR/${tdir}-1 || error "mkdir $DIR/${tdir}-1 failed"
1197 mkdir $DIR/${tdir}-2 || error "mkdir $DIR/${tdir}-2 failed"
1198 multiop $DIR/${tdir}-1/f O_c &
1200 # give multiop a change to open
1203 #define OBD_FAIL_MDS_CLOSE_NET 0x115
1204 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000115"
1205 kill -USR1 $close_pid
1206 cancel_lru_locks mdc # force the close
1207 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
1209 mcreate $DIR/${tdir}-2/f || error "mcreate $DIR/${tdir}-2/f failed"
1211 # close should still be here
1212 [ -d /proc/$close_pid ] || error "close_pid doesn't exist"
1214 replay_barrier_nodf $SINGLEMDS
1216 wait $close_pid || error "close_pid $close_pid failed"
1218 $CHECKSTAT -t file $DIR/${tdir}-1/f ||
1219 error "$CHECKSTAT $DIR/${tdir}-1/f attribute check failed"
1220 $CHECKSTAT -t file $DIR/${tdir}-2/f ||
1221 error "$CHECKSTAT $DIR/${tdir}-2/f attribute check failed"
1222 rm -rf $DIR/${tdir}-*
1224 run_test 53a "|X| close request while two MDC requests in flight"
1227 cancel_lru_locks mdc # cleanup locks from former test cases
1229 mkdir $DIR/${tdir}-1 || error "mkdir $DIR/${tdir}-1 failed"
1230 mkdir $DIR/${tdir}-2 || error "mkdir $DIR/${tdir}-2 failed"
1231 multiop_bg_pause $DIR/${tdir}-1/f O_c ||
1232 error "multiop_bg_pause $DIR/${tdir}-1/f failed"
1235 #define OBD_FAIL_MDS_REINT_NET 0x107
1236 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000107"
1237 mcreate $DIR/${tdir}-2/f &
1241 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
1242 kill -USR1 $close_pid
1243 cancel_lru_locks mdc # force the close
1244 wait $close_pid || error "close_pid $close_pid failed"
1245 # open should still be here
1246 [ -d /proc/$open_pid ] || error "open_pid doesn't exist"
1248 replay_barrier_nodf $SINGLEMDS
1250 wait $open_pid || error "open_pid failed"
1252 $CHECKSTAT -t file $DIR/${tdir}-1/f ||
1253 error "$CHECKSTAT $DIR/${tdir}-1/f attribute check failed"
1254 $CHECKSTAT -t file $DIR/${tdir}-2/f ||
1255 error "$CHECKSTAT $DIR/${tdir}-2/f attribute check failed"
1256 rm -rf $DIR/${tdir}-*
1258 run_test 53b "|X| open request while two MDC requests in flight"
1261 cancel_lru_locks mdc # cleanup locks from former test cases
1263 mkdir $DIR/${tdir}-1 || error "mkdir $DIR/${tdir}-1 failed"
1264 mkdir $DIR/${tdir}-2 || error "mkdir $DIR/${tdir}-2 failed"
1265 multiop $DIR/${tdir}-1/f O_c &
1268 #define OBD_FAIL_MDS_REINT_NET 0x107
1269 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000107"
1270 mcreate $DIR/${tdir}-2/f &
1274 #define OBD_FAIL_MDS_CLOSE_NET 0x115
1275 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000115"
1276 kill -USR1 $close_pid
1277 cancel_lru_locks mdc # force the close
1279 #bz20647: make sure all pids exist before failover
1280 [ -d /proc/$close_pid ] || error "close_pid doesn't exist"
1281 [ -d /proc/$open_pid ] || error "open_pid doesn't exists"
1282 replay_barrier_nodf $SINGLEMDS
1283 fail_nodf $SINGLEMDS
1284 wait $open_pid || error "open_pid failed"
1286 # close should be gone
1287 [ -d /proc/$close_pid ] && error "close_pid should not exist"
1288 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
1290 $CHECKSTAT -t file $DIR/${tdir}-1/f ||
1291 error "$CHECKSTAT $DIR/${tdir}-1/f attribute check failed"
1292 $CHECKSTAT -t file $DIR/${tdir}-2/f ||
1293 error "$CHECKSTAT $DIR/${tdir}-2/f attribute check failed"
1294 rm -rf $DIR/${tdir}-*
1296 run_test 53c "|X| open request and close request while two MDC requests in flight"
1299 [[ $(lctl get_param mdc.*.import |
1300 grep "connect_flags:.*multi_mod_rpc") ]] ||
1301 { skip "Need MDC with 'multi_mod_rpcs' feature"; return 0; }
1303 cancel_lru_locks mdc # cleanup locks from former test cases
1305 mkdir $DIR/${tdir}-1 || error "mkdir $DIR/${tdir}-1 failed"
1306 mkdir $DIR/${tdir}-2 || error "mkdir $DIR/${tdir}-2 failed"
1307 multiop $DIR/${tdir}-1/f O_c &
1309 # give multiop a chance to open
1312 #define OBD_FAIL_MDS_CLOSE_NET_REP 0x13b
1313 do_facet $SINGLEMDS "lctl set_param fail_loc=0x8000013b"
1314 kill -USR1 $close_pid
1315 cancel_lru_locks mdc # force the close
1316 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
1317 mcreate $DIR/${tdir}-2/f || error "mcreate $DIR/${tdir}-2/f failed"
1319 # close should still be here
1320 [ -d /proc/$close_pid ] || error "close_pid doesn't exist"
1322 wait $close_pid || error "close_pid failed"
1324 $CHECKSTAT -t file $DIR/${tdir}-1/f ||
1325 error "$CHECKSTAT $DIR/${tdir}-1/f attribute check failed"
1326 $CHECKSTAT -t file $DIR/${tdir}-2/f ||
1327 error "$CHECKSTAT $DIR/${tdir}-2/f attribute check failed"
1328 rm -rf $DIR/${tdir}-*
1330 run_test 53d "close reply while two MDC requests in flight"
1333 cancel_lru_locks mdc # cleanup locks from former test cases
1335 mkdir $DIR/${tdir}-1 || error "mkdir $DIR/${tdir}-1 failed"
1336 mkdir $DIR/${tdir}-2 || error "mkdir $DIR/${tdir}-2 failed"
1337 multiop $DIR/${tdir}-1/f O_c &
1340 #define OBD_FAIL_MDS_REINT_NET_REP 0x119
1341 do_facet $SINGLEMDS "lctl set_param fail_loc=0x119"
1342 mcreate $DIR/${tdir}-2/f &
1346 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
1347 kill -USR1 $close_pid
1348 cancel_lru_locks mdc # force the close
1349 wait $close_pid || error "close_pid failed"
1350 # open should still be here
1351 [ -d /proc/$open_pid ] || error "open_pid doesn't exists"
1353 replay_barrier_nodf $SINGLEMDS
1355 wait $open_pid || error "open_pid failed"
1357 $CHECKSTAT -t file $DIR/${tdir}-1/f ||
1358 error "$CHECKSTAT $DIR/${tdir}-1/f attribute check failed"
1359 $CHECKSTAT -t file $DIR/${tdir}-2/f ||
1360 error "$CHECKSTAT $DIR/${tdir}-2/f attribute check failed"
1361 rm -rf $DIR/${tdir}-*
1363 run_test 53e "|X| open reply while two MDC requests in flight"
1366 cancel_lru_locks mdc # cleanup locks from former test cases
1368 mkdir $DIR/${tdir}-1 || error "mkdir $DIR/${tdir}-1 failed"
1369 mkdir $DIR/${tdir}-2 || error "mkdir $DIR/${tdir}-2 failed"
1370 multiop $DIR/${tdir}-1/f O_c &
1373 #define OBD_FAIL_MDS_REINT_NET_REP 0x119
1374 do_facet $SINGLEMDS "lctl set_param fail_loc=0x119"
1375 mcreate $DIR/${tdir}-2/f &
1379 #define OBD_FAIL_MDS_CLOSE_NET_REP 0x13b
1380 do_facet $SINGLEMDS "lctl set_param fail_loc=0x8000013b"
1381 kill -USR1 $close_pid
1382 cancel_lru_locks mdc # force the close
1384 #bz20647: make sure all pids are exists before failover
1385 [ -d /proc/$close_pid ] || error "close_pid doesn't exist"
1386 [ -d /proc/$open_pid ] || error "open_pid doesn't exists"
1387 replay_barrier_nodf $SINGLEMDS
1388 fail_nodf $SINGLEMDS
1389 wait $open_pid || error "open_pid failed"
1391 # close should be gone
1392 [ -d /proc/$close_pid ] && error "close_pid should not exist"
1393 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
1395 $CHECKSTAT -t file $DIR/${tdir}-1/f ||
1396 error "$CHECKSTAT $DIR/${tdir}-1/f attribute check failed"
1397 $CHECKSTAT -t file $DIR/${tdir}-2/f ||
1398 error "$CHECKSTAT $DIR/${tdir}-2/f attribute check failed"
1399 rm -rf $DIR/${tdir}-*
1401 run_test 53f "|X| open reply and close reply while two MDC requests in flight"
1404 cancel_lru_locks mdc # cleanup locks from former test cases
1406 mkdir $DIR/${tdir}-1 || error "mkdir $DIR/${tdir}-1 failed"
1407 mkdir $DIR/${tdir}-2 || error "mkdir $DIR/${tdir}-2 failed"
1408 multiop $DIR/${tdir}-1/f O_c &
1411 #define OBD_FAIL_MDS_REINT_NET_REP 0x119
1412 do_facet $SINGLEMDS "lctl set_param fail_loc=0x119"
1413 mcreate $DIR/${tdir}-2/f &
1417 #define OBD_FAIL_MDS_CLOSE_NET 0x115
1418 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000115"
1419 kill -USR1 $close_pid
1420 cancel_lru_locks mdc # force the close
1421 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
1423 #bz20647: make sure all pids are exists before failover
1424 [ -d /proc/$close_pid ] || error "close_pid doesn't exist"
1425 [ -d /proc/$open_pid ] || error "open_pid doesn't exists"
1426 replay_barrier_nodf $SINGLEMDS
1427 fail_nodf $SINGLEMDS
1428 wait $open_pid || error "open_pid failed"
1430 # close should be gone
1431 [ -d /proc/$close_pid ] && error "close_pid should not exist"
1433 $CHECKSTAT -t file $DIR/${tdir}-1/f ||
1434 error "$CHECKSTAT $DIR/${tdir}-1/f attribute check failed"
1435 $CHECKSTAT -t file $DIR/${tdir}-2/f ||
1436 error "$CHECKSTAT $DIR/${tdir}-2/f attribute check failed"
1437 rm -rf $DIR/${tdir}-*
1439 run_test 53g "|X| drop open reply and close request while close and open are both in flight"
1442 cancel_lru_locks mdc # cleanup locks from former test cases
1444 mkdir $DIR/${tdir}-1 || error "mkdir $DIR/${tdir}-1 failed"
1445 mkdir $DIR/${tdir}-2 || error "mkdir $DIR/${tdir}-2 failed"
1446 multiop $DIR/${tdir}-1/f O_c &
1449 #define OBD_FAIL_MDS_REINT_NET 0x107
1450 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000107"
1451 mcreate $DIR/${tdir}-2/f &
1455 #define OBD_FAIL_MDS_CLOSE_NET_REP 0x13b
1456 do_facet $SINGLEMDS "lctl set_param fail_loc=0x8000013b"
1457 kill -USR1 $close_pid
1458 cancel_lru_locks mdc # force the close
1461 #bz20647: make sure all pids are exists before failover
1462 [ -d /proc/$close_pid ] || error "close_pid doesn't exist"
1463 [ -d /proc/$open_pid ] || error "open_pid doesn't exists"
1464 replay_barrier_nodf $SINGLEMDS
1465 fail_nodf $SINGLEMDS
1466 wait $open_pid || error "open_pid failed"
1468 # close should be gone
1469 [ -d /proc/$close_pid ] && error "close_pid should not exist"
1470 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
1472 $CHECKSTAT -t file $DIR/${tdir}-1/f ||
1473 error "$CHECKSTAT $DIR/${tdir}-1/f attribute check failed"
1474 $CHECKSTAT -t file $DIR/${tdir}-2/f ||
1475 error "$CHECKSTAT $DIR/${tdir}-2/f attribute check failed"
1476 rm -rf $DIR/${tdir}-*
1478 run_test 53h "open request and close reply while two MDC requests in flight"
1480 #b3761 ASSERTION(hash != 0) failed
1482 # OBD_FAIL_MDS_OPEN_CREATE | OBD_FAIL_ONCE
1483 do_facet $SINGLEMDS "lctl set_param fail_loc=0x8000012b"
1485 # give touch a chance to run
1487 do_facet $SINGLEMDS "lctl set_param fail_loc=0x0"
1491 run_test 55 "let MDS_CHECK_RESENT return the original return code instead of 0"
1493 #b3440 ASSERTION(rec->ur_fid2->id) failed
1495 ln -s foo $DIR/$tfile
1496 replay_barrier $SINGLEMDS
1497 #drop_reply "cat $DIR/$tfile"
1501 run_test 56 "don't replay a symlink open request (3440)"
1503 #recovery one mds-ost setattr from llog
1505 #define OBD_FAIL_MDS_OST_SETATTR 0x12c
1506 do_facet $SINGLEMDS "lctl set_param fail_loc=0x8000012c"
1507 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
1508 replay_barrier $SINGLEMDS
1510 wait_recovery_complete $SINGLEMDS || error "MDS recovery is not done"
1511 wait_mds_ost_sync || error "wait_mds_ost_sync failed"
1512 $CHECKSTAT -t file $DIR/$tfile ||
1513 error "$CHECKSTAT $DIR/$tfile attribute check failed"
1514 do_facet $SINGLEMDS "lctl set_param fail_loc=0x0"
1517 run_test 57 "test recovery from llog for setattr op"
1520 zconf_umount $(hostname) $MOUNT2
1524 #recovery many mds-ost setattr from llog
1526 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
1527 #define OBD_FAIL_MDS_OST_SETATTR 0x12c
1528 do_facet $SINGLEMDS "lctl set_param fail_loc=0x8000012c"
1529 createmany -o $DIR/$tdir/$tfile-%d 2500
1530 replay_barrier $SINGLEMDS
1533 $CHECKSTAT -t file $DIR/$tdir/$tfile-* >/dev/null ||
1534 error "$CHECKSTAT $DIR/$tfile-* attribute check failed"
1535 do_facet $SINGLEMDS "lctl set_param fail_loc=0x0"
1536 unlinkmany $DIR/$tdir/$tfile-%d 2500 ||
1537 error "unlinkmany $DIR/$tfile failed"
1540 run_test 58a "test recovery from llog for setattr op (test llog_gen_rec)"
1546 trap cleanup_58 EXIT
1548 large_xattr_enabled &&
1549 orig="$(generate_string $(max_xattr_size))" || orig="bar"
1550 # Original extended attribute can be long. Print a small version of
1551 # attribute if an error occurs
1552 local sm_msg=$(printf "%.9s" $orig)
1554 mount_client $MOUNT2 || error "mount_client on $MOUNT2 failed"
1555 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
1556 touch $DIR/$tdir/$tfile || error "touch $DIR/$tdir/$tfile failed"
1557 replay_barrier $SINGLEMDS
1558 setfattr -n trusted.foo -v $orig $DIR/$tdir/$tfile
1560 new=$(get_xattr_value trusted.foo $MOUNT2/$tdir/$tfile)
1561 [[ "$new" = "$orig" ]] ||
1562 error "xattr set ($sm_msg...) differs from xattr get ($new)"
1563 rm -f $DIR/$tdir/$tfile
1566 wait_clients_import_state ${CLIENTS:-$HOSTNAME} "mgs" FULL
1568 run_test 58b "test replay of setxattr op"
1570 test_58c() { # bug 16570
1575 trap cleanup_58 EXIT
1577 if large_xattr_enabled; then
1578 local xattr_size=$(max_xattr_size)
1579 orig="$(generate_string $((xattr_size / 2)))"
1580 orig1="$(generate_string $xattr_size)"
1586 # PING_INTERVAL max(obd_timeout / 4, 1U)
1587 sleep $((TIMEOUT / 4))
1589 # Original extended attribute can be long. Print a small version of
1590 # attribute if an error occurs
1591 local sm_msg=$(printf "%.9s" $orig)
1592 local sm_msg1=$(printf "%.9s" $orig1)
1594 mount_client $MOUNT2 || error "mount_client on $MOUNT2 failed"
1595 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
1596 touch $DIR/$tdir/$tfile || error "touch $DIR/$tdir/$tfile failed"
1597 drop_request "setfattr -n trusted.foo -v $orig $DIR/$tdir/$tfile" ||
1598 error "drop_request for setfattr failed"
1599 new=$(get_xattr_value trusted.foo $MOUNT2/$tdir/$tfile)
1600 [[ "$new" = "$orig" ]] ||
1601 error "xattr set ($sm_msg...) differs from xattr get ($new)"
1602 drop_reint_reply "setfattr -n trusted.foo1 \
1603 -v $orig1 $DIR/$tdir/$tfile" ||
1604 error "drop_reint_reply for setfattr failed"
1605 new=$(get_xattr_value trusted.foo1 $MOUNT2/$tdir/$tfile)
1606 [[ "$new" = "$orig1" ]] ||
1607 error "second xattr set ($sm_msg1...) differs xattr get ($new)"
1608 rm -f $DIR/$tdir/$tfile
1612 run_test 58c "resend/reconstruct setxattr op"
1614 # log_commit_thread vs filter_destroy race used to lead to import use after free
1617 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1619 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
1620 createmany -o $DIR/$tdir/$tfile-%d 200 ||
1621 error "createmany create files failed"
1623 unlinkmany $DIR/$tdir/$tfile-%d 200 ||
1624 error "unlinkmany $DIR/$tdir/$tfile failed"
1625 #define OBD_FAIL_PTLRPC_DELAY_RECOV 0x507
1626 do_facet ost1 "lctl set_param fail_loc=0x507"
1629 do_facet ost1 "lctl set_param fail_loc=0x0"
1633 run_test 59 "test log_commit_thread vs filter_destroy race"
1635 # race between add unlink llog vs cat log init in post_recovery (only for b1_6)
1636 # bug 12086: should no oops and No ctxt error for this test
1638 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
1639 createmany -o $DIR/$tdir/$tfile-%d 200 ||
1640 error "createmany create files failed"
1641 replay_barrier $SINGLEMDS
1642 unlinkmany $DIR/$tdir/$tfile-%d 0 100
1644 unlinkmany $DIR/$tdir/$tfile-%d 100 100
1645 local no_ctxt=$(dmesg | grep "No ctxt")
1646 [ -z "$no_ctxt" ] || error "ctxt is not initialized in recovery"
1648 run_test 60 "test llog post recovery init vs llog unlink"
1650 #test race llog recovery thread vs llog cleanup
1651 test_61a() { # was test_61
1652 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1654 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
1655 createmany -o $DIR/$tdir/$tfile-%d 800 ||
1656 error "createmany create files failed"
1658 unlinkmany $DIR/$tdir/$tfile-%d 800
1659 # OBD_FAIL_OST_LLOG_RECOVERY_TIMEOUT 0x221
1660 set_nodes_failloc "$(osts_nodes)" 0x80000221
1665 set_nodes_failloc "$(osts_nodes)" 0x0
1667 $CHECKSTAT -t file $DIR/$tdir/$tfile-* &&
1668 error "$CHECKSTAT $DIR/$tdir/$tfile attribute check should fail"
1671 run_test 61a "test race llog recovery vs llog cleanup"
1673 #test race mds llog sync vs llog cleanup
1675 # OBD_FAIL_MDS_LLOG_SYNC_TIMEOUT 0x13a
1676 do_facet $SINGLEMDS "lctl set_param fail_loc=0x8000013a"
1677 facet_failover $SINGLEMDS
1680 do_facet client dd if=/dev/zero of=$DIR/$tfile bs=4k count=1 ||
1683 run_test 61b "test race mds llog sync vs llog cleanup"
1685 #test race cancel cookie cb vs llog cleanup
1687 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1689 # OBD_FAIL_OST_CANCEL_COOKIE_TIMEOUT 0x222
1690 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
1691 set_nodes_failloc "$(osts_nodes)" 0x80000222
1695 set_nodes_failloc "$(osts_nodes)" 0x0
1697 run_test 61c "test race mds llog sync vs llog cleanup"
1699 test_61d() { # bug 16002 # bug 17466 # bug 22137
1700 # OBD_FAIL_OBD_LLOG_SETUP 0x605
1702 do_facet mgs "lctl set_param fail_loc=0x80000605"
1703 start mgs $(mgsdevname) $MGS_MOUNT_OPTS &&
1704 error "mgs start should have failed"
1705 do_facet mgs "lctl set_param fail_loc=0"
1706 start mgs $(mgsdevname) $MGS_MOUNT_OPTS || error "cannot restart mgs"
1708 run_test 61d "error in llog_setup should cleanup the llog context correctly"
1710 test_62() { # Bug 15756 - don't mis-drop resent replay
1711 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
1712 replay_barrier $SINGLEMDS
1713 createmany -o $DIR/$tdir/$tfile- 25 ||
1714 error "createmany create files failed"
1715 #define OBD_FAIL_TGT_REPLAY_DROP 0x707
1716 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000707"
1718 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
1719 unlinkmany $DIR/$tdir/$tfile- 25 ||
1720 error "unlinkmany $DIR/$tdir/$tfile failed"
1723 run_test 62 "don't mis-drop resent replay"
1725 #Adaptive Timeouts (bug 3055)
1733 echo "Cleaning up AT ..."
1734 if [ -n "$ATOLDBASE" ]; then
1735 local at_history=$($LCTL get_param -n at_history)
1736 do_facet $SINGLEMDS "lctl set_param at_history=$at_history" || true
1737 do_facet ost1 "lctl set_param at_history=$at_history" || true
1740 if [ $AT_MAX_SET -ne 0 ]; then
1741 for facet in mds client ost; do
1742 var=AT_MAX_SAVE_${facet}
1743 echo restore AT on $facet to saved value ${!var}
1744 at_max_set ${!var} $facet
1745 at_new=$(at_max_get $facet)
1746 echo Restored AT value on $facet $at_new
1747 [ $at_new -eq ${!var} ] ||
1748 error "AT value not restored SAVED ${!var} NEW $at_new"
1755 local at_max_new=600
1757 # Save at_max original values
1759 if [ $AT_MAX_SET -eq 0 ]; then
1760 # Suppose that all osts have the same at_max
1761 for facet in mds client ost; do
1762 eval AT_MAX_SAVE_${facet}=$(at_max_get $facet)
1766 for facet in mds client ost; do
1767 at_max=$(at_max_get $facet)
1768 if [ $at_max -ne $at_max_new ]; then
1769 echo "AT value on $facet is $at_max, set it by force temporarily to $at_max_new"
1770 at_max_set $at_max_new $facet
1775 if [ -z "$ATOLDBASE" ]; then
1776 ATOLDBASE=$(do_facet $SINGLEMDS "lctl get_param -n at_history")
1777 # speed up the timebase so we can check decreasing AT
1778 do_facet $SINGLEMDS "lctl set_param at_history=8" || true
1779 do_facet ost1 "lctl set_param at_history=8" || true
1781 # sleep for a while to cool down, should be > 8s and also allow
1782 # at least one ping to be sent. simply use TIMEOUT to be safe.
1787 test_65a() #bug 3055
1789 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1791 at_start || return 0
1792 $LCTL dk > /dev/null
1794 $LCTL set_param debug="other"
1795 # Slow down a request to the current service time, this is critical
1796 # because previous tests may have caused this value to increase.
1797 REQ_DELAY=`lctl get_param -n mdc.${FSNAME}-MDT0000-mdc-*.timeouts |
1798 awk '/portal 12/ {print $5}'`
1799 REQ_DELAY=$((${REQ_DELAY} + ${REQ_DELAY} / 4 + 5))
1801 do_facet $SINGLEMDS lctl set_param fail_val=$((${REQ_DELAY} * 1000))
1802 #define OBD_FAIL_PTLRPC_PAUSE_REQ 0x50a
1803 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x8000050a
1804 createmany -o $DIR/$tfile 10 > /dev/null
1805 unlinkmany $DIR/$tfile 10 > /dev/null
1806 # check for log message
1807 $LCTL dk | grep "Early reply #" || error "No early reply"
1809 # client should show REQ_DELAY estimates
1810 lctl get_param -n mdc.${FSNAME}-MDT0000-mdc-*.timeouts | grep portal
1812 lctl get_param -n mdc.${FSNAME}-MDT0000-mdc-*.timeouts | grep portal
1814 run_test 65a "AT: verify early replies"
1816 test_65b() #bug 3055
1818 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1820 at_start || return 0
1823 $LCTL set_param debug="other trace"
1824 $LCTL dk > /dev/null
1825 # Slow down a request to the current service time, this is critical
1826 # because previous tests may have caused this value to increase.
1827 $SETSTRIPE --stripe-index=0 --stripe-count=1 $DIR/$tfile ||
1828 error "$SETSTRIPE failed for $DIR/$tfile"
1830 multiop $DIR/$tfile Ow1yc
1831 REQ_DELAY=`lctl get_param -n osc.${FSNAME}-OST0000-osc-*.timeouts |
1832 awk '/portal 6/ {print $5}'`
1833 REQ_DELAY=$((${REQ_DELAY} + ${REQ_DELAY} / 4 + 5))
1835 do_facet ost1 lctl set_param fail_val=${REQ_DELAY}
1836 #define OBD_FAIL_OST_BRW_PAUSE_PACK 0x224
1837 do_facet ost1 $LCTL set_param fail_loc=0x224
1840 $SETSTRIPE --stripe-index=0 --stripe-count=1 $DIR/$tfile ||
1841 error "$SETSTRIPE failed"
1842 # force some real bulk transfer
1843 multiop $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
1845 do_facet ost1 $LCTL set_param fail_loc=0
1846 # check for log message
1847 $LCTL dk | grep "Early reply #" || error "No early reply"
1849 # client should show REQ_DELAY estimates
1850 lctl get_param -n osc.${FSNAME}-OST0000-osc-*.timeouts | grep portal
1852 run_test 65b "AT: verify early replies on packed reply / bulk"
1854 test_66a() #bug 3055
1856 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1858 at_start || return 0
1859 lctl get_param -n mdc.${FSNAME}-MDT0000-mdc-*.timeouts | grep "portal 12"
1860 # adjust 5s at a time so no early reply is sent (within deadline)
1861 do_facet $SINGLEMDS "$LCTL set_param fail_val=5000"
1862 #define OBD_FAIL_PTLRPC_PAUSE_REQ 0x50a
1863 do_facet $SINGLEMDS "$LCTL set_param fail_loc=0x8000050a"
1864 createmany -o $DIR/$tfile 20 > /dev/null
1865 unlinkmany $DIR/$tfile 20 > /dev/null
1866 lctl get_param -n mdc.${FSNAME}-MDT0000-mdc-*.timeouts | grep "portal 12"
1867 do_facet $SINGLEMDS "$LCTL set_param fail_val=10000"
1868 do_facet $SINGLEMDS "$LCTL set_param fail_loc=0x8000050a"
1869 createmany -o $DIR/$tfile 20 > /dev/null
1870 unlinkmany $DIR/$tfile 20 > /dev/null
1871 lctl get_param -n mdc.${FSNAME}-MDT0000-mdc-*.timeouts | grep "portal 12"
1872 do_facet $SINGLEMDS "$LCTL set_param fail_loc=0"
1874 createmany -o $DIR/$tfile 20 > /dev/null
1875 unlinkmany $DIR/$tfile 20 > /dev/null
1876 lctl get_param -n mdc.${FSNAME}-MDT0000-mdc-*.timeouts | grep "portal 12"
1877 CUR=$(lctl get_param -n mdc.${FSNAME}-MDT0000-mdc-*.timeouts | awk '/portal 12/ {print $5}')
1878 WORST=$(lctl get_param -n mdc.${FSNAME}-MDT0000-mdc-*.timeouts | awk '/portal 12/ {print $7}')
1879 echo "Current MDT timeout $CUR, worst $WORST"
1880 [ $CUR -lt $WORST ] || error "Current $CUR should be less than worst $WORST"
1882 run_test 66a "AT: verify MDT service time adjusts with no early replies"
1884 test_66b() #bug 3055
1886 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1888 at_start || return 0
1889 ORIG=$(lctl get_param -n mdc.${FSNAME}-MDT0000*.timeouts |
1890 awk '/network/ {print $4}')
1891 $LCTL set_param fail_val=$(($ORIG + 5))
1892 #define OBD_FAIL_PTLRPC_PAUSE_REP 0x50c
1893 $LCTL set_param fail_loc=0x50c
1894 ls $DIR/$tfile > /dev/null 2>&1
1895 $LCTL set_param fail_loc=0
1896 CUR=$(lctl get_param -n mdc.${FSNAME}-MDT0000*.timeouts |
1897 awk '/network/ {print $4}')
1898 WORST=$(lctl get_param -n mdc.${FSNAME}-MDT0000*.timeouts |
1899 awk '/network/ {print $6}')
1900 echo "network timeout orig $ORIG, cur $CUR, worst $WORST"
1901 [ $WORST -gt $ORIG ] ||
1902 error "Worst $WORST should be worse than orig $ORIG"
1904 run_test 66b "AT: verify net latency adjusts"
1906 test_67a() #bug 3055
1908 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1910 at_start || return 0
1911 CONN1=$(lctl get_param -n osc.*.stats | awk '/_connect/ {total+=$2} END {print total}')
1912 # sleeping threads may drive values above this
1913 do_facet ost1 "$LCTL set_param fail_val=400"
1914 #define OBD_FAIL_PTLRPC_PAUSE_REQ 0x50a
1915 do_facet ost1 "$LCTL set_param fail_loc=0x50a"
1916 createmany -o $DIR/$tfile 20 > /dev/null
1917 unlinkmany $DIR/$tfile 20 > /dev/null
1918 do_facet ost1 "$LCTL set_param fail_loc=0"
1919 CONN2=$(lctl get_param -n osc.*.stats | awk '/_connect/ {total+=$2} END {print total}')
1920 ATTEMPTS=$(($CONN2 - $CONN1))
1921 echo "$ATTEMPTS osc reconnect attempts on gradual slow"
1922 [ $ATTEMPTS -gt 0 ] &&
1923 error_ignore bz13721 "AT should have prevented reconnect"
1926 run_test 67a "AT: verify slow request processing doesn't induce reconnects"
1928 test_67b() #bug 3055
1930 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1932 at_start || return 0
1933 CONN1=$(lctl get_param -n osc.*.stats | awk '/_connect/ {total+=$2} END {print total}')
1935 # exhaust precreations on ost1
1936 local OST=$(ostname_from_index 0)
1937 local mdtosc=$(get_mdtosc_proc_path mds $OST)
1938 local last_id=$(do_facet $SINGLEMDS lctl get_param -n \
1939 osc.$mdtosc.prealloc_last_id)
1940 local next_id=$(do_facet $SINGLEMDS lctl get_param -n \
1941 osc.$mdtosc.prealloc_next_id)
1943 mkdir -p $DIR/$tdir/${OST} || error "mkdir $DIR/$tdir/${OST} failed"
1944 $SETSTRIPE -i 0 -c 1 $DIR/$tdir/${OST} || error "$SETSTRIPE failed"
1945 echo "Creating to objid $last_id on ost $OST..."
1946 #define OBD_FAIL_OST_PAUSE_CREATE 0x223
1947 do_facet ost1 "$LCTL set_param fail_val=20000"
1948 do_facet ost1 "$LCTL set_param fail_loc=0x80000223"
1949 createmany -o $DIR/$tdir/${OST}/f $next_id $((last_id - next_id + 2))
1952 do_facet ost1 "lctl get_param -n ost.OSS.ost_create.timeouts"
1954 CONN2=$(lctl get_param -n osc.*.stats | awk '/_connect/ {total+=$2} END {print total}')
1955 ATTEMPTS=$(($CONN2 - $CONN1))
1956 echo "$ATTEMPTS osc reconnect attempts on instant slow"
1957 # do it again; should not timeout
1958 do_facet ost1 "$LCTL set_param fail_loc=0x80000223"
1959 cp /etc/profile $DIR/$tfile || error "cp failed"
1960 do_facet ost1 "$LCTL set_param fail_loc=0"
1962 do_facet ost1 "lctl get_param -n ost.OSS.ost_create.timeouts"
1963 CONN3=$(lctl get_param -n osc.*.stats | awk '/_connect/ {total+=$2} END {print total}')
1964 ATTEMPTS=$(($CONN3 - $CONN2))
1965 echo "$ATTEMPTS osc reconnect attempts on 2nd slow"
1966 [ $ATTEMPTS -gt 0 ] && error "AT should have prevented reconnect"
1969 run_test 67b "AT: verify instant slowdown doesn't induce reconnects"
1971 test_68 () #bug 13813
1973 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1975 at_start || return 0
1976 local ldlm_enqueue_min=$(find /sys -name ldlm_enqueue_min)
1977 [ -z "$ldlm_enqueue_min" ] && skip "missing /sys/.../ldlm_enqueue_min" && return 0
1978 local ldlm_enqueue_min_r=$(do_facet ost1 "find /sys -name ldlm_enqueue_min")
1979 [ -z "$ldlm_enqueue_min_r" ] && skip "missing /sys/.../ldlm_enqueue_min in the ost1" && return 0
1980 local ENQ_MIN=$(cat $ldlm_enqueue_min)
1981 local ENQ_MIN_R=$(do_facet ost1 "cat $ldlm_enqueue_min_r")
1982 echo $TIMEOUT >> $ldlm_enqueue_min
1983 do_facet ost1 "echo $TIMEOUT >> $ldlm_enqueue_min_r"
1985 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
1986 $SETSTRIPE --stripe-index=0 -c 1 $DIR/$tdir ||
1987 error "$SETSTRIPE failed for $DIR/$tdir"
1988 #define OBD_FAIL_LDLM_PAUSE_CANCEL 0x312
1989 $LCTL set_param fail_val=$(($TIMEOUT - 1))
1990 $LCTL set_param fail_loc=0x80000312
1991 cp /etc/profile $DIR/$tdir/${tfile}_1 || error "1st cp failed $?"
1992 $LCTL set_param fail_val=$((TIMEOUT * 5 / 4))
1993 $LCTL set_param fail_loc=0x80000312
1994 cp /etc/profile $DIR/$tdir/${tfile}_2 || error "2nd cp failed $?"
1995 $LCTL set_param fail_loc=0
1997 echo $ENQ_MIN >> $ldlm_enqueue_min
1998 do_facet ost1 "echo $ENQ_MIN_R >> $ldlm_enqueue_min_r"
2002 run_test 68 "AT: verify slowing locks"
2005 # end of AT tests includes above lines
2007 # start multi-client tests
2009 [ -z "$CLIENTS" ] &&
2010 { skip "Need two or more clients." && return; }
2011 [ $CLIENTCOUNT -lt 2 ] &&
2012 { skip "Need two or more clients, have $CLIENTCOUNT" && return; }
2014 echo "mount clients $CLIENTS ..."
2015 zconf_mount_clients $CLIENTS $MOUNT
2017 local clients=${CLIENTS//,/ }
2018 echo "Write/read files on $DIR ; clients $CLIENTS ... "
2019 for CLIENT in $clients; do
2020 do_node $CLIENT dd bs=1M count=10 if=/dev/zero \
2021 of=$DIR/${tfile}_${CLIENT} 2>/dev/null ||
2022 error "dd failed on $CLIENT"
2025 local prev_client=$(echo $clients | sed 's/^.* \(.\+\)$/\1/')
2026 for C in ${CLIENTS//,/ }; do
2027 do_node $prev_client dd if=$DIR/${tfile}_${C} \
2028 of=/dev/null 2>/dev/null ||
2029 error "dd if=$DIR/${tfile}_${C} failed on $prev_client"
2035 run_test 70a "check multi client t-f"
2037 check_for_process () {
2042 killall_process $clients "$prog" -0
2046 local clients=${CLIENTS:-$HOSTNAME}
2048 zconf_mount_clients $clients $MOUNT
2051 [ "$SLOW" = "no" ] && duration=120
2052 # set duration to 900 because it takes some time to boot node
2053 [ "$FAILURE_MODE" = HARD ] && duration=900
2056 local start_ts=$(date +%s)
2057 local cmd="rundbench 1 -t $duration"
2059 if [ $MDSCOUNT -ge 2 ]; then
2060 test_mkdir -p -c$MDSCOUNT $DIR/$tdir
2061 $LFS setdirstripe -D -c$MDSCOUNT $DIR/$tdir
2063 do_nodesv $clients "set -x; MISSING_DBENCH_OK=$MISSING_DBENCH_OK \
2064 PATH=\$PATH:$LUSTRE/utils:$LUSTRE/tests/:$DBENCH_LIB \
2065 DBENCH_LIB=$DBENCH_LIB TESTSUITE=$TESTSUITE TESTNAME=$TESTNAME \
2066 MOUNT=$MOUNT DIR=$DIR/$tdir/\\\$(hostname) LCTL=$LCTL $cmd" &
2069 #LU-1897 wait for all dbench copies to start
2070 while ! check_for_process $clients dbench; do
2071 elapsed=$(($(date +%s) - start_ts))
2072 if [ $elapsed -gt $duration ]; then
2073 killall_process $clients dbench
2074 error "dbench failed to start on $clients!"
2079 log "Started rundbench load pid=$pid ..."
2081 elapsed=$(($(date +%s) - start_ts))
2082 local num_failovers=0
2084 while [ $elapsed -lt $duration ]; do
2085 if ! check_for_process $clients dbench; then
2086 error_noexit "dbench stopped on some of $clients!"
2087 killall_process $clients dbench
2091 replay_barrier mds$fail_index
2092 sleep 1 # give clients a time to do operations
2093 # Increment the number of failovers
2094 num_failovers=$((num_failovers+1))
2095 log "$TESTNAME fail mds$fail_index $num_failovers times"
2097 elapsed=$(($(date +%s) - start_ts))
2098 if [ $fail_index -ge $MDSCOUNT ]; then
2101 fail_index=$((fail_index+1))
2105 wait $pid || error "rundbench load on $clients failed!"
2107 run_test 70b "dbench ${MDSCOUNT}mdts recovery; $CLIENTCOUNT clients"
2108 # end multi-client tests
2113 local monitor_pid=$3
2115 local start_ts=$(date +%s)
2116 local num_failovers=0
2119 elapsed=$(($(date +%s) - start_ts))
2120 while [ $elapsed -lt $duration ]; do
2121 fail_index=$((RANDOM%max_index+1))
2122 kill -0 $monitor_pid ||
2123 error "$monitor_pid stopped"
2125 replay_barrier mds$fail_index
2127 # Increment the number of failovers
2128 num_failovers=$((num_failovers+1))
2129 log "$TESTNAME fail mds$fail_index $num_failovers times"
2131 elapsed=$(($(date +%s) - start_ts))
2137 rm -f $DIR/replay-single.70c.lck
2142 local clients=${CLIENTS:-$HOSTNAME}
2145 zconf_mount_clients $clients $MOUNT
2148 [ "$SLOW" = "no" ] && duration=180
2149 # set duration to 900 because it takes some time to boot node
2150 [ "$FAILURE_MODE" = HARD ] && duration=600
2153 local start_ts=$(date +%s)
2155 trap cleanup_70c EXIT
2157 while [ ! -e $DIR/replay-single.70c.lck ]; do
2158 test_mkdir -p -c$MDSCOUNT $DIR/$tdir || break
2159 if [ $MDSCOUNT -ge 2 ]; then
2160 $LFS setdirstripe -D -c$MDSCOUNT $DIR/$tdir ||
2161 error "set default dirstripe failed"
2163 cd $DIR/$tdir || break
2164 tar cf - /etc | tar xf - || error "tar failed in loop"
2168 echo "Started tar $tar_70c_pid"
2170 random_fail_mdt $MDSCOUNT $duration $tar_70c_pid
2171 kill -0 $tar_70c_pid || error "tar $tar_70c_pid stopped"
2173 touch $DIR/replay-single.70c.lck
2174 wait $tar_70c_pid || error "$?: tar failed"
2179 run_test 70c "tar ${MDSCOUNT}mdts recovery"
2183 kill -9 $mkdir_70d_pid
2187 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2188 local clients=${CLIENTS:-$HOSTNAME}
2191 zconf_mount_clients $clients $MOUNT
2194 [ "$SLOW" = "no" ] && duration=180
2195 # set duration to 900 because it takes some time to boot node
2196 [ "$FAILURE_MODE" = HARD ] && duration=900
2201 local start_ts=$(date +%s)
2203 trap cleanup_70d EXIT
2206 $LFS mkdir -i0 -c2 $DIR/$tdir/test || {
2210 $LFS mkdir -i1 -c2 $DIR/$tdir/test1 || {
2215 touch $DIR/$tdir/test/a || {
2219 mkdir $DIR/$tdir/test/b || {
2223 rm -rf $DIR/$tdir/test || {
2228 touch $DIR/$tdir/test1/a || {
2232 mkdir $DIR/$tdir/test1/b || {
2237 rm -rf $DIR/$tdir/test1 || {
2244 echo "Started $mkdir_70d_pid"
2246 random_fail_mdt $MDSCOUNT $duration $mkdir_70d_pid
2247 kill -0 $mkdir_70d_pid || error "mkdir/rmdir $mkdir_70d_pid stopped"
2252 run_test 70d "mkdir/rmdir striped dir ${MDSCOUNT}mdts recovery"
2256 kill -9 $rename_70e_pid
2260 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2261 local clients=${CLIENTS:-$HOSTNAME}
2264 echo ha > /proc/sys/lnet/debug
2265 zconf_mount_clients $clients $MOUNT
2268 [ "$SLOW" = "no" ] && duration=180
2269 # set duration to 900 because it takes some time to boot node
2270 [ "$FAILURE_MODE" = HARD ] && duration=900
2273 $LFS mkdir -i0 $DIR/$tdir/test_0
2274 $LFS mkdir -i0 $DIR/$tdir/test_1
2275 touch $DIR/$tdir/test_0/a
2276 touch $DIR/$tdir/test_1/b
2277 trap cleanup_70e EXIT
2280 mrename $DIR/$tdir/test_0/a $DIR/$tdir/test_1/b > \
2286 checkstat $DIR/$tdir/test_0/a && {
2287 echo "a still exists"
2291 checkstat $DIR/$tdir/test_1/b || {
2292 echo "b still exists"
2296 touch $DIR/$tdir/test_0/a || {
2297 echo "touch a fails"
2301 mrename $DIR/$tdir/test_1/b $DIR/$tdir/test_0/a > \
2309 echo "Started $rename_70e_pid"
2311 random_fail_mdt 2 $duration $rename_70e_pid
2312 kill -0 $rename_70e_pid || error "rename $rename_70e_pid stopped"
2317 run_test 70e "rename cross-MDT with random fails"
2319 test_70f_write_and_read(){
2324 echo "Write/read files in: '$DIR/$tdir', clients: '$CLIENTS' ..."
2325 for client in ${CLIENTS//,/ }; do
2326 [ -f $stopflag ] || return
2328 local tgtfile=$DIR/$tdir/$tfile.$client
2329 do_node $client dd $DD_OPTS bs=1M count=10 if=$srcfile \
2330 of=$tgtfile 2>/dev/null ||
2331 error "dd $DD_OPTS bs=1M count=10 if=$srcfile " \
2332 "of=$tgtfile failed on $client, rc=$?"
2335 local prev_client=$(echo ${CLIENTS//,/ } | awk '{ print $NF }')
2338 for client in ${CLIENTS//,/ }; do
2339 [ -f $stopflag ] || return
2341 # flush client cache in case test is running on only one client
2342 # do_node $client cancel_lru_locks osc
2343 do_node $client $LCTL set_param ldlm.namespaces.*.lru_size=clear
2345 tgtfile=$DIR/$tdir/$tfile.$client
2346 local md5=$(do_node $prev_client "md5sum $tgtfile")
2347 [ ${checksum[$index]// */} = ${md5// */} ] ||
2348 error "$tgtfile: checksum doesn't match on $prev_client"
2349 index=$((index + 1))
2359 mkdir -p $DIR/$tdir || error "cannot create $DIR/$tdir directory"
2360 $SETSTRIPE -c -1 $DIR/$tdir || error "cannot $SETSTRIPE $DIR/$tdir"
2363 while [ -f $stopflag ]; do
2364 test_70f_write_and_read $srcfile $stopflag
2365 # use direct IO and buffer cache in turns if loop
2366 [ -n "$DD_OPTS" ] && DD_OPTS="" || DD_OPTS="oflag=direct"
2370 test_70f_cleanup() {
2372 rm -f $TMP/$tfile.stop
2373 do_nodes $CLIENTS rm -f $TMP/$tfile
2374 rm -f $DIR/$tdir/$tfile.*
2378 # [ x$ost1failover_HOST = x$ost_HOST ] &&
2379 # { skip "Failover host not defined" && return; }
2380 # [ -z "$CLIENTS" ] &&
2381 # { skip "CLIENTS are not specified." && return; }
2382 # [ $CLIENTCOUNT -lt 2 ] &&
2383 # { skip "Need 2 or more clients, have $CLIENTCOUNT" && return; }
2385 [[ $(lustre_version_code ost1) -lt $(version_code 2.9.53) ]] &&
2386 skip "Need server version at least 2.9.53" && return
2388 echo "mount clients $CLIENTS ..."
2389 zconf_mount_clients $CLIENTS $MOUNT
2391 local srcfile=$TMP/$tfile
2395 trap test_70f_cleanup EXIT
2396 # create a different source file local to each client node so we can
2397 # detect if the file wasn't written out properly after failover
2398 do_nodes $CLIENTS dd bs=1M count=10 if=/dev/urandom of=$srcfile \
2399 2>/dev/null || error "can't create $srcfile on $CLIENTS"
2400 for client in ${CLIENTS//,/ }; do
2401 checksum[$index]=$(do_node $client "md5sum $srcfile")
2402 index=$((index + 1))
2406 [ "$SLOW" = "no" ] && duration=60
2407 # set duration to 900 because it takes some time to boot node
2408 [ "$FAILURE_MODE" = HARD ] && duration=900
2410 local stopflag=$TMP/$tfile.stop
2411 test_70f_loop $srcfile $stopflag &
2415 local num_failovers=0
2416 local start_ts=$SECONDS
2417 while [ $elapsed -lt $duration ]; do
2421 num_failovers=$((num_failovers + 1))
2422 log "$TESTNAME failing OST $num_failovers times"
2425 elapsed=$((SECONDS - start_ts))
2432 run_test 70f "OSS O_DIRECT recovery with $CLIENTCOUNT clients"
2436 kill -9 $mkdir_71a_pid
2439 random_double_fail_mdt() {
2442 local monitor_pid=$3
2444 local start_ts=$(date +%s)
2445 local num_failovers=0
2449 elapsed=$(($(date +%s) - start_ts))
2450 while [ $elapsed -lt $duration ]; do
2451 fail_index=$((RANDOM%max_index + 1))
2452 if [ $fail_index -eq $max_index ]; then
2455 second_index=$((fail_index + 1))
2457 kill -0 $monitor_pid ||
2458 error "$monitor_pid stopped"
2460 replay_barrier mds$fail_index
2461 replay_barrier mds$second_index
2463 # Increment the number of failovers
2464 num_failovers=$((num_failovers+1))
2465 log "fail mds$fail_index mds$second_index $num_failovers times"
2466 fail mds${fail_index},mds${second_index}
2467 elapsed=$(($(date +%s) - start_ts))
2472 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2473 local clients=${CLIENTS:-$HOSTNAME}
2476 zconf_mount_clients $clients $MOUNT
2479 [ "$SLOW" = "no" ] && duration=180
2480 # set duration to 900 because it takes some time to boot node
2481 [ "$FAILURE_MODE" = HARD ] && duration=900
2486 local start_ts=$(date +%s)
2488 trap cleanup_71a EXIT
2491 $LFS mkdir -i0 -c2 $DIR/$tdir/test
2492 rmdir $DIR/$tdir/test
2496 echo "Started $mkdir_71a_pid"
2498 random_double_fail_mdt 2 $duration $mkdir_71a_pid
2499 kill -0 $mkdir_71a_pid || error "mkdir/rmdir $mkdir_71a_pid stopped"
2504 run_test 71a "mkdir/rmdir striped dir with 2 mdts recovery"
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_ENQUEUE_NET 0x302
2514 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000302"
2517 wait $pid || error "multiop pid failed"
2518 [ -e $DIR/$tfile ] && error "file $DIR/$tfile should not exist"
2521 run_test 73a "open(O_CREAT), unlink, replay, reconnect before open replay, close"
2524 multiop_bg_pause $DIR/$tfile O_tSc ||
2525 error "multiop_bg_pause $DIR/$tfile failed"
2529 replay_barrier $SINGLEMDS
2530 #define OBD_FAIL_LDLM_REPLY 0x30c
2531 do_facet $SINGLEMDS "lctl set_param fail_loc=0x8000030c"
2534 wait $pid || error "multiop pid failed"
2535 [ -e $DIR/$tfile ] && error "file $DIR/$tfile should not exist"
2538 run_test 73b "open(O_CREAT), unlink, replay, reconnect at open_replay reply, close"
2542 local clients=${CLIENTS:-$HOSTNAME}
2544 zconf_umount_clients $clients $MOUNT
2546 facet_failover $SINGLEMDS
2547 zconf_mount_clients $clients $MOUNT
2549 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
2550 rm $DIR/$tfile || error "rm $DIR/$tfile failed"
2551 clients_up || error "client evicted: $?"
2554 run_test 74 "Ensure applications don't fail waiting for OST recovery"
2556 remote_dir_check_80() {
2561 diridx=$($GETSTRIPE -M $remote_dir) ||
2562 error "$GETSTRIPE -M $remote_dir failed"
2563 [ $diridx -eq $MDTIDX ] || error "$diridx != $MDTIDX"
2565 createmany -o $remote_dir/f-%d 20 || error "creation failed"
2566 fileidx=$($GETSTRIPE -M $remote_dir/f-1) ||
2567 error "$GETSTRIPE -M $remote_dir/f-1 failed"
2568 [ $fileidx -eq $MDTIDX ] || error "$fileidx != $MDTIDX"
2574 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2575 ([ $FAILURE_MODE == "HARD" ] &&
2576 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
2577 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
2581 local remote_dir=$DIR/$tdir/remote_dir
2583 mkdir -p $DIR/$tdir || error "mkdir $DIR/$tdir failed"
2584 #define OBD_FAIL_OUT_UPDATE_NET_REP 0x1701
2585 do_facet mds${MDTIDX} lctl set_param fail_loc=0x1701
2586 $LFS mkdir -i $MDTIDX $remote_dir &
2592 wait $CLIENT_PID || error "remote creation failed"
2594 remote_dir_check_80 || error "remote dir check failed"
2595 rm -rf $DIR/$tdir || error "rmdir failed"
2599 run_test 80a "DNE: create remote dir, drop update rep from MDT0, fail MDT0"
2602 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2603 ([ $FAILURE_MODE == "HARD" ] &&
2604 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
2605 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
2609 local remote_dir=$DIR/$tdir/remote_dir
2611 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
2612 #define OBD_FAIL_UPDATE_OBJ_NET_REP 0x1701
2613 do_facet mds${MDTIDX} lctl set_param fail_loc=0x1701
2614 $LFS mkdir -i $MDTIDX $remote_dir &
2619 fail mds$((MDTIDX + 1))
2621 wait $CLIENT_PID || error "remote creation failed"
2623 remote_dir_check_80 || error "remote dir check failed"
2624 rm -rf $DIR/$tdir || error "rmdir failed"
2628 run_test 80b "DNE: create remote dir, drop update rep from MDT0, fail MDT1"
2631 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2632 ([ $FAILURE_MODE == "HARD" ] &&
2633 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
2634 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
2638 local remote_dir=$DIR/$tdir/remote_dir
2640 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
2641 #define OBD_FAIL_UPDATE_OBJ_NET_REP 0x1701
2642 do_facet mds${MDTIDX} lctl set_param fail_loc=0x1701
2643 $LFS mkdir -i $MDTIDX $remote_dir &
2649 fail mds$((MDTIDX + 1))
2651 wait $CLIENT_PID || error "remote creation failed"
2653 remote_dir_check_80 || error "remote dir check failed"
2654 rm -rf $DIR/$tdir || error "rmdir failed"
2658 run_test 80c "DNE: create remote dir, drop update rep from MDT1, fail MDT[0,1]"
2661 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2663 local remote_dir=$DIR/$tdir/remote_dir
2665 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
2666 #define OBD_FAIL_UPDATE_OBJ_NET_REP 0x1701
2667 do_facet mds${MDTIDX} lctl set_param fail_loc=0x1701
2668 $LFS mkdir -i $MDTIDX $remote_dir &
2671 # sleep 3 seconds to make sure MDTs are failed after
2672 # lfs mkdir -i has finished on all of MDTs.
2677 fail mds${MDTIDX},mds$((MDTIDX + 1))
2679 wait $CLIENT_PID || error "remote creation failed"
2681 remote_dir_check_80 || error "remote dir check failed"
2682 rm -rf $DIR/$tdir || error "rmdir failed"
2686 run_test 80d "DNE: create remote dir, drop update rep from MDT1, fail 2 MDTs"
2689 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2690 ([ $FAILURE_MODE == "HARD" ] &&
2691 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
2692 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
2696 local remote_dir=$DIR/$tdir/remote_dir
2698 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
2699 # OBD_FAIL_MDS_REINT_NET_REP 0x119
2700 do_facet mds$((MDTIDX + 1)) lctl set_param fail_loc=0x119
2701 $LFS mkdir -i $MDTIDX $remote_dir &
2704 # sleep 3 seconds to make sure MDTs are failed after
2705 # lfs mkdir -i has finished on all of MDTs.
2711 wait $CLIENT_PID || error "remote creation failed"
2713 remote_dir_check_80 || error "remote dir check failed"
2714 rm -rf $DIR/$tdir || error "rmdir failed"
2718 run_test 80e "DNE: create remote dir, drop MDT1 rep, fail MDT0"
2721 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2722 ([ $FAILURE_MODE == "HARD" ] &&
2723 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
2724 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
2727 local remote_dir=$DIR/$tdir/remote_dir
2729 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
2730 # OBD_FAIL_MDS_REINT_NET_REP 0x119
2731 do_facet mds$((MDTIDX + 1)) lctl set_param fail_loc=0x119
2732 $LFS mkdir -i $MDTIDX $remote_dir &
2736 fail mds$((MDTIDX + 1))
2738 wait $CLIENT_PID || error "remote creation failed"
2740 remote_dir_check_80 || error "remote dir check failed"
2741 rm -rf $DIR/$tdir || error "rmdir failed"
2745 run_test 80f "DNE: create remote dir, drop MDT1 rep, fail MDT1"
2748 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2749 ([ $FAILURE_MODE == "HARD" ] &&
2750 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
2751 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
2755 local remote_dir=$DIR/$tdir/remote_dir
2757 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
2758 # OBD_FAIL_MDS_REINT_NET_REP 0x119
2759 do_facet mds$((MDTIDX + 1)) lctl set_param fail_loc=0x119
2760 $LFS mkdir -i $MDTIDX $remote_dir &
2763 # sleep 3 seconds to make sure MDTs are failed after
2764 # lfs mkdir -i has finished on all of MDTs.
2770 fail mds$((MDTIDX + 1))
2772 wait $CLIENT_PID || error "remote creation failed"
2774 remote_dir_check_80 || error "remote dir check failed"
2775 rm -rf $DIR/$tdir || error "rmdir failed"
2779 run_test 80g "DNE: create remote dir, drop MDT1 rep, fail MDT0, then MDT1"
2782 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2784 local remote_dir=$DIR/$tdir/remote_dir
2786 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
2787 # OBD_FAIL_MDS_REINT_NET_REP 0x119
2788 do_facet mds$((MDTIDX + 1)) lctl set_param fail_loc=0x119
2789 $LFS mkdir -i $MDTIDX $remote_dir &
2792 # sleep 3 seconds to make sure MDTs are failed after
2793 # lfs mkdir -i has finished on all of MDTs.
2798 fail mds${MDTIDX},mds$((MDTIDX + 1))
2800 wait $CLIENT_PID || error "remote dir creation failed"
2802 remote_dir_check_80 || error "remote dir check failed"
2803 rm -rf $DIR/$tdir || error "rmdir failed"
2807 run_test 80h "DNE: create remote dir, drop MDT1 rep, fail 2 MDTs"
2810 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2811 ([ $FAILURE_MODE == "HARD" ] &&
2812 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
2813 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
2817 local remote_dir=$DIR/$tdir/remote_dir
2819 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
2820 $LFS mkdir -i $MDTIDX $remote_dir || error "lfs mkdir failed"
2822 touch $remote_dir || error "touch $remote_dir failed"
2823 # OBD_FAIL_OBJ_UPDATE_NET_REP 0x1701
2824 do_facet mds${MDTIDX} lctl set_param fail_loc=0x1701
2829 fail mds$((MDTIDX + 1))
2831 wait $CLIENT_PID || error "rm remote dir failed"
2833 stat $remote_dir &>/dev/null && error "$remote_dir still exist!"
2835 rm -rf $DIR/$tdir || error "rmdir failed"
2839 run_test 81a "DNE: unlink remote dir, drop MDT0 update rep, fail MDT1"
2842 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2843 ([ $FAILURE_MODE == "HARD" ] &&
2844 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
2845 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
2848 local remote_dir=$DIR/$tdir/remote_dir
2850 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
2851 $LFS mkdir -i $MDTIDX $remote_dir || error "lfs mkdir failed"
2853 # OBD_FAIL_OBJ_UPDATE_NET_REP 0x1701
2854 do_facet mds${MDTIDX} lctl set_param fail_loc=0x1701
2861 wait $CLIENT_PID || error "rm remote dir failed"
2863 stat $remote_dir &>/dev/null && error "$remote_dir still exist!"
2865 rm -rf $DIR/$tdir || error "rmdir failed"
2869 run_test 81b "DNE: unlink remote dir, drop MDT0 update reply, fail MDT0"
2872 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2873 ([ $FAILURE_MODE == "HARD" ] &&
2874 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
2875 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
2879 local remote_dir=$DIR/$tdir/remote_dir
2881 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
2882 $LFS mkdir -i $MDTIDX $remote_dir || error "lfs mkdir failed"
2884 # OBD_FAIL_OBJ_UPDATE_NET_REP 0x1701
2885 do_facet mds${MDTIDX} lctl set_param fail_loc=0x1701
2892 fail mds$((MDTIDX + 1))
2894 wait $CLIENT_PID || error "rm remote dir failed"
2896 stat $remote_dir &>/dev/null && error "$remote_dir still exist!"
2898 rm -rf $DIR/$tdir || error "rmdir failed"
2902 run_test 81c "DNE: unlink remote dir, drop MDT0 update reply, fail MDT0,MDT1"
2905 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2907 local remote_dir=$DIR/$tdir/remote_dir
2909 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
2910 $LFS mkdir -i $MDTIDX $remote_dir || error "lfs mkdir failed"
2912 # OBD_FAIL_OBJ_UPDATE_NET_REP 0x1701
2913 do_facet mds${MDTIDX} lctl set_param fail_loc=0x1701
2919 fail mds${MDTIDX},mds$((MDTIDX + 1))
2921 wait $CLIENT_PID || error "rm remote dir failed"
2923 stat $remote_dir &>/dev/null && error "$remote_dir still exist!"
2925 rm -rf $DIR/$tdir || error "rmdir failed"
2929 run_test 81d "DNE: unlink remote dir, drop MDT0 update reply, fail 2 MDTs"
2932 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2933 ([ $FAILURE_MODE == "HARD" ] &&
2934 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
2935 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
2939 local remote_dir=$DIR/$tdir/remote_dir
2941 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
2942 $LFS mkdir -i $MDTIDX $remote_dir || error "lfs mkdir failed"
2944 # OBD_FAIL_MDS_REINT_NET_REP 0x119
2945 do_facet mds$((MDTIDX + 1)) lctl set_param fail_loc=0x119
2948 do_facet mds$((MDTIDX + 1)) lctl set_param fail_loc=0
2953 wait $CLIENT_PID || error "rm remote dir failed"
2955 stat $remote_dir &>/dev/null && error "$remote_dir still exist!"
2957 rm -rf $DIR/$tdir || error "rmdir failed"
2961 run_test 81e "DNE: unlink remote dir, drop MDT1 req reply, fail MDT0"
2964 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2965 ([ $FAILURE_MODE == "HARD" ] &&
2966 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
2967 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
2971 local remote_dir=$DIR/$tdir/remote_dir
2973 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
2974 $LFS mkdir -i $MDTIDX $remote_dir || error "lfs mkdir failed"
2976 # OBD_FAIL_MDS_REINT_NET_REP 0x119
2977 do_facet mds$((MDTIDX + 1)) lctl set_param fail_loc=0x119
2982 fail mds$((MDTIDX + 1))
2984 wait $CLIENT_PID || error "rm remote dir failed"
2986 stat $remote_dir &>/dev/null && error "$remote_dir still exist!"
2988 rm -rf $DIR/$tdir || error "rmdir failed"
2992 run_test 81f "DNE: unlink remote dir, drop MDT1 req reply, fail MDT1"
2995 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2996 ([ $FAILURE_MODE == "HARD" ] &&
2997 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
2998 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
3002 local remote_dir=$DIR/$tdir/remote_dir
3004 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
3005 $LFS mkdir -i $MDTIDX $remote_dir || error "lfs mkdir failed"
3007 # OBD_FAIL_MDS_REINT_NET_REP 0x119
3008 do_facet mds$((MDTIDX + 1)) lctl set_param fail_loc=0x119
3015 fail mds$((MDTIDX + 1))
3017 wait $CLIENT_PID || error "rm remote dir failed"
3019 stat $remote_dir &>/dev/null && error "$remote_dir still exist!"
3021 rm -rf $DIR/$tdir || error "rmdir failed"
3025 run_test 81g "DNE: unlink remote dir, drop req reply, fail M0, then M1"
3028 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
3030 local remote_dir=$DIR/$tdir/remote_dir
3032 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
3033 $LFS mkdir -i $MDTIDX $remote_dir || error "lfs mkdir failed"
3035 # OBD_FAIL_MDS_REINT_NET_REP 0x119
3036 do_facet mds$((MDTIDX + 1)) lctl set_param fail_loc=0x119
3042 fail mds${MDTIDX},mds$((MDTIDX + 1))
3044 wait $CLIENT_PID || error "rm remote dir failed"
3046 stat $remote_dir &>/dev/null && error "$remote_dir still exist!"
3048 rm -rf $DIR/$tdir || error "rmdir failed"
3052 run_test 81h "DNE: unlink remote dir, drop request reply, fail 2 MDTs"
3055 #define OBD_FAIL_MDS_OPEN_WAIT_CREATE 0x144
3056 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000144"
3057 createmany -o $DIR/$tfile- 1 &
3061 client_up || client_up || true # reconnect
3063 run_test 84a "stale open during export disconnect"
3065 test_85a() { #bug 16774
3066 lctl set_param -n ldlm.cancel_unused_locks_before_replay "1"
3068 for i in $(seq 100); do
3069 echo "tag-$i" > $DIR/$tfile-$i
3070 grep -q "tag-$i" $DIR/$tfile-$i || error "f2-$i"
3073 lov_id=$(lctl dl | grep "clilov")
3074 addr=$(echo $lov_id | awk '{print $4}' | awk -F '-' '{print $NF}')
3075 count=$(lctl get_param -n \
3076 ldlm.namespaces.*MDT0000*$addr.lock_unused_count)
3077 echo "before recovery: unused locks count = $count"
3081 count2=$(lctl get_param -n \
3082 ldlm.namespaces.*MDT0000*$addr.lock_unused_count)
3083 echo "after recovery: unused locks count = $count2"
3085 if [ $count2 -ge $count ]; then
3086 error "unused locks are not canceled"
3089 run_test 85a "check the cancellation of unused locks during recovery(IBITS)"
3091 test_85b() { #bug 16774
3092 lctl set_param -n ldlm.cancel_unused_locks_before_replay "1"
3094 if ! combined_mgs_mds ; then
3098 create_pool $FSNAME.$TESTNAME ||
3099 error "unable to create pool $TESTNAME"
3100 do_facet mgs $LCTL pool_add $FSNAME.$TESTNAME $FSNAME-OST0000 ||
3101 error "unable to add pool $TESTNAME"
3103 $SETSTRIPE -c 1 -p $FSNAME.$TESTNAME $DIR
3105 for i in $(seq 100); do
3106 dd if=/dev/urandom of=$DIR/$tfile-$i bs=4096 \
3107 count=32 >/dev/null 2>&1
3110 cancel_lru_locks osc
3112 for i in $(seq 100); do
3113 dd if=$DIR/$tfile-$i of=/dev/null bs=4096 \
3114 count=32 >/dev/null 2>&1
3117 lov_id=$(lctl dl | grep "clilov")
3118 addr=$(echo $lov_id | awk '{print $4}' | awk -F '-' '{print $NF}')
3119 count=$(lctl get_param -n \
3120 ldlm.namespaces.*OST0000*$addr.lock_unused_count)
3121 echo "before recovery: unused locks count = $count"
3122 [ $count -ne 0 ] || error "unused locks ($count) should be zero"
3126 count2=$(lctl get_param \
3127 -n ldlm.namespaces.*OST0000*$addr.lock_unused_count)
3128 echo "after recovery: unused locks count = $count2"
3130 do_facet mgs $LCTL pool_remove $FSNAME.$TESTNAME $FSNAME-OST0000 ||
3131 error "unable to remove pool $TESTNAME"
3132 do_facet mgs $LCTL pool_destroy $FSNAME.$TESTNAME ||
3133 error "unable to destroy the pool $TESTNAME"
3135 if ! combined_mgs_mds ; then
3139 if [ $count2 -ge $count ]; then
3140 error "unused locks are not canceled"
3143 run_test 85b "check the cancellation of unused locks during recovery(EXTENT)"
3146 local clients=${CLIENTS:-$HOSTNAME}
3148 zconf_umount_clients $clients $MOUNT
3149 do_facet $SINGLEMDS lctl set_param mdt.${FSNAME}-MDT*.exports.clear=0
3150 remount_facet $SINGLEMDS
3151 zconf_mount_clients $clients $MOUNT
3153 run_test 86 "umount server after clear nid_stats should not hit LBUG"
3156 do_facet ost1 "lctl set_param -n obdfilter.${ost1_svc}.sync_journal 0"
3159 $SETSTRIPE -i 0 -c 1 $DIR/$tfile
3160 dd if=/dev/urandom of=$DIR/$tfile bs=1024k count=8 ||
3161 error "dd to $DIR/$tfile failed"
3162 cksum=$(md5sum $DIR/$tfile | awk '{print $1}')
3163 cancel_lru_locks osc
3165 dd if=$DIR/$tfile of=/dev/null bs=1024k count=8 || error "Cannot read"
3166 cksum2=$(md5sum $DIR/$tfile | awk '{print $1}')
3167 if [ $cksum != $cksum2 ] ; then
3168 error "New checksum $cksum2 does not match original $cksum"
3171 run_test 87a "write replay"
3174 do_facet ost1 "lctl set_param -n obdfilter.${ost1_svc}.sync_journal 0"
3177 $SETSTRIPE -i 0 -c 1 $DIR/$tfile
3178 dd if=/dev/urandom of=$DIR/$tfile bs=1024k count=8 ||
3179 error "dd to $DIR/$tfile failed"
3180 sleep 1 # Give it a chance to flush dirty data
3181 echo TESTTEST | dd of=$DIR/$tfile bs=1 count=8 seek=64
3182 cksum=$(md5sum $DIR/$tfile | awk '{print $1}')
3183 cancel_lru_locks osc
3185 dd if=$DIR/$tfile of=/dev/null bs=1024k count=8 || error "Cannot read"
3186 cksum2=$(md5sum $DIR/$tfile | awk '{print $1}')
3187 if [ $cksum != $cksum2 ] ; then
3188 error "New checksum $cksum2 does not match original $cksum"
3191 run_test 87b "write replay with changed data (checksum resend)"
3193 test_88() { #bug 17485
3194 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
3195 mkdir -p $TMP/$tdir || error "mkdir $TMP/$tdir failed"
3197 $SETSTRIPE -i 0 -c 1 $DIR/$tdir || error "$SETSTRIPE"
3200 replay_barrier $SINGLEMDS
3202 # exhaust precreations on ost1
3203 local OST=$(ostname_from_index 0)
3204 local mdtosc=$(get_mdtosc_proc_path $SINGLEMDS $OST)
3205 local last_id=$(do_facet $SINGLEMDS lctl get_param -n osc.$mdtosc.prealloc_last_id)
3206 local next_id=$(do_facet $SINGLEMDS lctl get_param -n osc.$mdtosc.prealloc_next_id)
3207 echo "before test: last_id = $last_id, next_id = $next_id"
3209 echo "Creating to objid $last_id on ost $OST..."
3210 createmany -o $DIR/$tdir/f-%d $next_id $((last_id - next_id + 2)) ||
3211 error "createmany create files to last_id failed"
3213 #create some files to use some uncommitted objids
3214 last_id=$(($last_id + 1))
3215 createmany -o $DIR/$tdir/f-%d $last_id 8 ||
3216 error "createmany create files with uncommitted objids failed"
3218 last_id2=$(do_facet $SINGLEMDS lctl get_param -n osc.$mdtosc.prealloc_last_id)
3219 next_id2=$(do_facet $SINGLEMDS lctl get_param -n osc.$mdtosc.prealloc_next_id)
3220 echo "before recovery: last_id = $last_id2, next_id = $next_id2"
3222 # if test uses shutdown_facet && reboot_facet instead of facet_failover ()
3223 # it has to take care about the affected facets, bug20407
3224 local affected_mds1=$(affected_facets mds1)
3225 local affected_ost1=$(affected_facets ost1)
3227 shutdown_facet $SINGLEMDS
3230 reboot_facet $SINGLEMDS
3231 change_active $affected_mds1
3232 wait_for_facet $affected_mds1
3233 mount_facets $affected_mds1 || error "Restart of mds failed"
3236 change_active $affected_ost1
3237 wait_for_facet $affected_ost1
3238 mount_facets $affected_ost1 || error "Restart of ost1 failed"
3242 last_id2=$(do_facet $SINGLEMDS lctl get_param -n osc.$mdtosc.prealloc_last_id)
3243 next_id2=$(do_facet $SINGLEMDS lctl get_param -n osc.$mdtosc.prealloc_next_id)
3244 echo "after recovery: last_id = $last_id2, next_id = $next_id2"
3246 # create new files, which should use new objids, and ensure the orphan
3247 # cleanup phase for ost1 is completed at the same time
3248 for i in $(seq 8); do
3249 file_id=$(($last_id + 10 + $i))
3250 dd if=/dev/urandom of=$DIR/$tdir/f-$file_id bs=4096 count=128
3253 # if the objids were not recreated, then "ls" will fail with -ENOENT
3254 ls -l $DIR/$tdir/* || error "can't get the status of precreated files"
3257 # write into previously created files
3258 for i in $(seq 8); do
3259 file_id=$(($last_id + $i))
3260 dd if=/dev/urandom of=$DIR/$tdir/f-$file_id bs=4096 count=128
3261 cp -f $DIR/$tdir/f-$file_id $TMP/$tdir/
3264 # compare the content
3265 for i in $(seq 8); do
3266 file_id=$(($last_id + $i))
3267 cmp $TMP/$tdir/f-$file_id $DIR/$tdir/f-$file_id ||
3268 error "the content of file is modified!"
3273 run_test 88 "MDS should not assign same objid to different files "
3276 cancel_lru_locks osc
3277 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
3278 rm -f $DIR/$tdir/$tfile
3280 wait_delete_completed
3281 BLOCKS1=$(df -P $MOUNT | tail -n 1 | awk '{ print $3 }')
3282 $SETSTRIPE -i 0 -c 1 $DIR/$tdir/$tfile
3283 dd if=/dev/zero bs=1M count=10 of=$DIR/$tdir/$tfile
3286 facet_failover $SINGLEMDS
3287 rm $DIR/$tdir/$tfile
3290 zconf_mount $(hostname) $MOUNT || error "mount fails"
3291 client_up || error "client_up failed"
3293 wait_delete_completed
3294 BLOCKS2=$(df -P $MOUNT | tail -n 1 | awk '{ print $3 }')
3295 [ $((BLOCKS2 - BLOCKS1)) -le 4 ] ||
3296 error $((BLOCKS2 - BLOCKS1)) blocks leaked
3298 run_test 89 "no disk space leak on late ost connection"
3305 change_active $facet
3306 wait_for_facet $facet
3307 mount_facet $facet || error "Restart of $facet failed"
3311 test_90() { # bug 19494
3312 local dir=$DIR/$tdir
3313 local ostfail=$(get_random_entry $(get_facets OST))
3315 if [[ $FAILURE_MODE = HARD ]]; then
3316 local affected=$(affected_facets $ostfail);
3317 if [[ "$affected" != $ostfail ]]; then
3318 skip not functional with FAILURE_MODE=$FAILURE_MODE, affected: $affected
3322 # ensure all OSTs are active to allow allocations
3325 mkdir $dir || error "mkdir $dir failed"
3327 echo "Create the files"
3329 # file "f${index}" striped over 1 OST
3330 # file "all" striped over all OSTs
3332 $SETSTRIPE -c $OSTCOUNT $dir/all ||
3333 error "setstripe failed to create $dir/all"
3335 for (( i=0; i<$OSTCOUNT; i++ )); do
3337 $SETSTRIPE -i $i -c 1 $f || error "$SETSTRIPE failed to create $f"
3339 # confirm setstripe actually created the stripe on the requested OST
3340 local uuid=$(ostuuid_from_index $i)
3341 for file in f$i all; do
3342 if [[ $dir/$file != $($LFS find --obd $uuid --name $file $dir) ]]; then
3343 $GETSTRIPE $dir/$file
3344 error wrong stripe: $file, uuid: $uuid
3349 # Before failing an OST, get its obd name and index
3350 local varsvc=${ostfail}_svc
3351 local obd=$(do_facet $ostfail lctl get_param \
3352 -n obdfilter.${!varsvc}.uuid)
3353 local index=$(($(facet_number $ostfail) - 1))
3355 echo "Fail $ostfail $obd, display the list of affected files"
3356 shutdown_facet $ostfail || error "shutdown_facet $ostfail failed"
3358 trap "cleanup_90 $ostfail" EXIT INT
3359 echo "General Query: lfs find $dir"
3360 local list=$($LFS find $dir)
3362 for (( i=0; i<$OSTCOUNT; i++ )); do
3363 list_member "$list" $dir/f$i ||
3364 error_noexit "lfs find $dir: no file f$i"
3366 list_member "$list" $dir/all ||
3367 error_noexit "lfs find $dir: no file all"
3369 # focus on the missing OST,
3370 # we expect to see only two files affected: "f$(index)" and "all"
3372 echo "Querying files on shutdown $ostfail: lfs find --obd $obd"
3373 list=$($LFS find --obd $obd $dir)
3375 for file in all f$index; do
3376 list_member "$list" $dir/$file ||
3377 error_noexit "lfs find does not report the affected $obd for $file"
3380 [[ $(echo $list | wc -w) -eq 2 ]] ||
3381 error_noexit "lfs find reports the wrong list of affected files ${#list[@]}"
3383 echo "Check getstripe: $GETSTRIPE -r --obd $obd"
3384 list=$($GETSTRIPE -r --obd $obd $dir)
3386 for file in all f$index; do
3387 echo "$list" | grep $dir/$file ||
3388 error_noexit "lfs getsripe does not report the affected $obd for $file"
3393 run_test 90 "lfs find identifies the missing striped file segments"
3396 local server_version=$(lustre_version_code $SINGLEMDS)
3397 [[ $server_version -ge $(version_code 2.6.90) ]] ||
3398 [[ $server_version -ge $(version_code 2.5.4) &&
3399 $server_version -lt $(version_code 2.5.50) ]] ||
3400 { skip "Need MDS version 2.5.4+ or 2.6.90+"; return; }
3402 cancel_lru_locks osc
3404 $SETSTRIPE -i 0 -c 1 $DIR/$tfile ||
3405 error "$SETSTRIPE $DIR/$tfile failed"
3406 dd if=/dev/zero of=$DIR/$tfile bs=1024 count=1 ||
3407 error "dd to $DIR/$tfile failed"
3408 #define OBD_FAIL_TGT_REPLAY_RECONNECT 0x715
3409 # We need to emulate a state that OST is waiting for other clients
3410 # not completing the recovery. Final ping is queued, but reply will be
3411 # sent on the recovery completion. It is done by sleep before
3412 # processing final pings
3413 do_facet ost1 "$LCTL set_param fail_val=40"
3414 do_facet ost1 "$LCTL set_param fail_loc=0x715"
3417 run_test 93a "replay + reconnect"
3420 local server_version=$(lustre_version_code $SINGLEMDS)
3421 [[ $server_version -ge $(version_code 2.7.90) ]] ||
3422 { skip "Need MDS version 2.7.90+"; return; }
3424 cancel_lru_locks mdc
3426 createmany -o $DIR/$tfile 20 ||
3427 error "createmany -o $DIR/$tfile failed"
3429 #define OBD_FAIL_TGT_REPLAY_RECONNECT 0x715
3430 # We need to emulate a state that MDT is waiting for other clients
3431 # not completing the recovery. Final ping is queued, but reply will be
3432 # sent on the recovery completion. It is done by sleep before
3433 # processing final pings
3434 do_facet mds1 "$LCTL set_param fail_val=80"
3435 do_facet mds1 "$LCTL set_param fail_loc=0x715"
3438 run_test 93b "replay + reconnect on mds"
3440 striped_dir_check_100() {
3441 local striped_dir=$DIR/$tdir/striped_dir
3442 local stripe_count=$($LFS getdirstripe -c $striped_dir)
3444 $LFS getdirstripe $striped_dir
3445 [ $stripe_count -eq 2 ] || error "$stripe_count != 2"
3447 createmany -o $striped_dir/f-%d 20 ||
3448 error "creation failed under striped dir"
3452 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
3453 ([ $FAILURE_MODE == "HARD" ] &&
3454 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
3455 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
3458 local striped_dir=$DIR/$tdir/striped_dir
3461 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
3463 #To make sure MDT1 and MDT0 are connected
3464 #otherwise it may create single stripe dir here
3465 $LFS setdirstripe -i1 $DIR/$tdir/remote_dir
3467 #define OBD_FAIL_OUT_UPDATE_NET_REP 0x1701
3468 do_facet mds$((MDTIDX+1)) lctl set_param fail_loc=0x1701
3469 $LFS setdirstripe -i0 -c2 $striped_dir &
3472 fail mds$((MDTIDX + 1))
3474 wait $CLIENT_PID || error "striped dir creation failed"
3476 striped_dir_check_100 || error "striped dir check failed"
3477 rm -rf $DIR/$tdir || error "rmdir failed"
3479 run_test 100a "DNE: create striped dir, drop update rep from MDT1, fail MDT1"
3482 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
3483 ([ $FAILURE_MODE == "HARD" ] &&
3484 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
3485 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
3488 local striped_dir=$DIR/$tdir/striped_dir
3491 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
3493 #To make sure MDT1 and MDT0 are connected
3494 #otherwise it may create single stripe dir here
3495 $LFS setdirstripe -i1 $DIR/$tdir/remote_dir
3497 # OBD_FAIL_MDS_REINT_NET_REP 0x119
3498 do_facet mds$MDTIDX lctl set_param fail_loc=0x119
3499 $LFS mkdir -i0 -c2 $striped_dir &
3504 wait $CLIENT_PID || error "striped dir creation failed"
3506 striped_dir_check_100 || error "striped dir check failed"
3507 rm -rf $DIR/$tdir || error "rmdir failed"
3509 run_test 100b "DNE: create striped dir, fail MDT0"
3511 test_101() { #LU-5648
3512 mkdir -p $DIR/$tdir/d1
3513 mkdir -p $DIR/$tdir/d2
3514 touch $DIR/$tdir/file0
3517 replay_barrier $SINGLEMDS
3518 for i in $(seq $num) ; do
3519 echo test$i > $DIR/$tdir/d1/file$i
3522 fail_abort $SINGLEMDS
3523 for i in $(seq $num) ; do
3524 touch $DIR/$tdir/d2/file$i
3525 test -s $DIR/$tdir/d2/file$i &&
3526 ls -al $DIR/$tdir/d2/file$i && error "file$i's size > 0"
3531 run_test 101 "Shouldn't reassign precreated objs to other files after recovery"
3540 [[ $(lctl get_param mdc.*.import |
3541 grep "connect_flags:.*multi_mod_rpc") ]] ||
3542 { skip "Need MDC with 'multi_mod_rpcs' feature"; return 0; }
3544 $LFS mkdir -c1 $DIR/$tdir || error "mkdir $DIR/$tdir failed"
3545 idx=$(printf "%04x" $($LFS getdirstripe -i $DIR/$tdir))
3546 facet="mds$((0x$idx + 1))"
3548 # get current value of max_mod_rcps_in_flight
3549 num=$($LCTL get_param -n \
3550 mdc.$FSNAME-MDT$idx-mdc-*.max_mod_rpcs_in_flight)
3551 # set default value if client does not support multi mod RPCs
3552 [ -z "$num" ] && num=1
3554 echo "creating $num files ..."
3556 for i in $(seq $num); do
3557 touch $DIR/$tdir/file-$i
3560 # drop request on MDT to force resend
3561 #define OBD_FAIL_MDS_REINT_MULTI_NET 0x159
3562 do_facet $facet "$LCTL set_param fail_loc=0x159"
3563 echo "launch $num chmod in parallel ($(date +%H:%M:%S)) ..."
3564 for i in $(seq $num); do
3565 chmod 0600 $DIR/$tdir/file-$i &
3569 do_facet $facet "$LCTL set_param fail_loc=0"
3570 for pid in $pids; do
3571 wait $pid || error "chmod failed"
3573 echo "done ($(date +%H:%M:%S))"
3575 # check chmod succeed
3576 for i in $(seq $num); do
3577 checkstat -vp 0600 $DIR/$tdir/file-$i
3582 run_test 102a "check resend (request lost) with multiple modify RPCs in flight"
3591 [[ $(lctl get_param mdc.*.import |
3592 grep "connect_flags:.*multi_mod_rpc") ]] ||
3593 { skip "Need MDC with 'multi_mod_rpcs' feature"; return 0; }
3595 $LFS mkdir -c1 $DIR/$tdir || error "mkdir $DIR/$tdir failed"
3596 idx=$(printf "%04x" $($LFS getdirstripe -i $DIR/$tdir))
3597 facet="mds$((0x$idx + 1))"
3599 # get current value of max_mod_rcps_in_flight
3600 num=$($LCTL get_param -n \
3601 mdc.$FSNAME-MDT$idx-mdc-*.max_mod_rpcs_in_flight)
3602 # set default value if client does not support multi mod RPCs
3603 [ -z "$num" ] && num=1
3605 echo "creating $num files ..."
3607 for i in $(seq $num); do
3608 touch $DIR/$tdir/file-$i
3611 # drop reply on MDT to force reconstruction
3612 #define OBD_FAIL_MDS_REINT_MULTI_NET_REP 0x15a
3613 do_facet $facet "$LCTL set_param fail_loc=0x15a"
3614 echo "launch $num chmod in parallel ($(date +%H:%M:%S)) ..."
3615 for i in $(seq $num); do
3616 chmod 0600 $DIR/$tdir/file-$i &
3620 do_facet $facet "$LCTL set_param fail_loc=0"
3621 for pid in $pids; do
3622 wait $pid || error "chmod failed"
3624 echo "done ($(date +%H:%M:%S))"
3626 # check chmod succeed
3627 for i in $(seq $num); do
3628 checkstat -vp 0600 $DIR/$tdir/file-$i
3633 run_test 102b "check resend (reply lost) with multiple modify RPCs in flight"
3642 [[ $(lctl get_param mdc.*.import |
3643 grep "connect_flags:.*multi_mod_rpc") ]] ||
3644 { skip "Need MDC with 'multi_mod_rpcs' feature"; return 0; }
3646 $LFS mkdir -c1 $DIR/$tdir || error "mkdir $DIR/$tdir failed"
3647 idx=$(printf "%04x" $($LFS getdirstripe -i $DIR/$tdir))
3648 facet="mds$((0x$idx + 1))"
3650 # get current value of max_mod_rcps_in_flight
3651 num=$($LCTL get_param -n \
3652 mdc.$FSNAME-MDT$idx-mdc-*.max_mod_rpcs_in_flight)
3653 # set default value if client does not support multi mod RPCs
3654 [ -z "$num" ] && num=1
3656 echo "creating $num files ..."
3658 for i in $(seq $num); do
3659 touch $DIR/$tdir/file-$i
3662 replay_barrier $facet
3665 #define OBD_FAIL_MDS_REINT_MULTI_NET_REP 0x15a
3666 do_facet $facet "$LCTL set_param fail_loc=0x15a"
3667 echo "launch $num chmod in parallel ($(date +%H:%M:%S)) ..."
3668 for i in $(seq $num); do
3669 chmod 0600 $DIR/$tdir/file-$i &
3673 do_facet $facet "$LCTL set_param fail_loc=0"
3678 for pid in $pids; do
3679 wait $pid || error "chmod failed"
3681 echo "done ($(date +%H:%M:%S))"
3683 # check chmod succeed
3684 for i in $(seq $num); do
3685 checkstat -vp 0600 $DIR/$tdir/file-$i
3690 run_test 102c "check replay w/o reconstruction with multiple mod RPCs in flight"
3699 [[ $(lctl get_param mdc.*.import |
3700 grep "connect_flags:.*multi_mod_rpc") ]] ||
3701 { skip "Need MDC with 'multi_mod_rpcs' feature"; return 0; }
3703 $LFS mkdir -c1 $DIR/$tdir || error "mkdir $DIR/$tdir failed"
3704 idx=$(printf "%04x" $($LFS getdirstripe -i $DIR/$tdir))
3705 facet="mds$((0x$idx + 1))"
3707 # get current value of max_mod_rcps_in_flight
3708 num=$($LCTL get_param -n \
3709 mdc.$FSNAME-MDT$idx-mdc-*.max_mod_rpcs_in_flight)
3710 # set default value if client does not support multi mod RPCs
3711 [ -z "$num" ] && num=1
3713 echo "creating $num files ..."
3715 for i in $(seq $num); do
3716 touch $DIR/$tdir/file-$i
3720 #define OBD_FAIL_MDS_REINT_MULTI_NET_REP 0x15a
3721 do_facet $facet "$LCTL set_param fail_loc=0x15a"
3722 echo "launch $num chmod in parallel ($(date +%H:%M:%S)) ..."
3723 for i in $(seq $num); do
3724 chmod 0600 $DIR/$tdir/file-$i &
3729 # write MDT transactions to disk
3730 do_facet $facet "sync; sync; sync"
3732 do_facet $facet "$LCTL set_param fail_loc=0"
3737 for pid in $pids; do
3738 wait $pid || error "chmod failed"
3740 echo "done ($(date +%H:%M:%S))"
3742 # check chmod succeed
3743 for i in $(seq $num); do
3744 checkstat -vp 0600 $DIR/$tdir/file-$i
3749 run_test 102d "check replay & reconstruction with multiple mod RPCs in flight"
3752 remote_mds_nodsh && skip "remote MDS with nodsh" && return
3753 #define OBD_FAIL_MDS_TRACK_OVERFLOW 0x162
3754 do_facet mds1 $LCTL set_param fail_loc=0x80000162
3757 createmany -o $DIR/$tdir/t- 30 ||
3758 error "create files on remote directory failed"
3760 rm -rf $DIR/$tdir/t-*
3762 #MDS should crash with tr->otr_next_id overflow
3765 run_test 103 "Check otr_next_id overflow"
3768 check_striped_dir_110()
3770 $CHECKSTAT -t dir $DIR/$tdir/striped_dir ||
3771 error "create striped dir failed"
3772 local stripe_count=$($LFS getdirstripe -c $DIR/$tdir/striped_dir)
3773 [ $stripe_count -eq $MDSCOUNT ] ||
3774 error "$stripe_count != 2 after recovery"
3778 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
3779 ([ $FAILURE_MODE == "HARD" ] &&
3780 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
3781 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
3786 $LFS mkdir -i1 -c$MDSCOUNT $DIR/$tdir/striped_dir
3789 check_striped_dir_110 || error "check striped_dir failed"
3790 rm -rf $DIR/$tdir || error "rmdir failed"
3794 run_test 110a "DNE: create striped dir, fail MDT1"
3797 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
3798 ([ $FAILURE_MODE == "HARD" ] &&
3799 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
3800 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
3805 $LFS mkdir -i1 -c$MDSCOUNT $DIR/$tdir/striped_dir
3808 zconf_mount $(hostname) $MOUNT
3809 client_up || return 1
3811 check_striped_dir_110 || error "check striped_dir failed"
3813 rm -rf $DIR/$tdir || error "rmdir failed"
3817 run_test 110b "DNE: create striped dir, fail MDT1 and client"
3820 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
3821 ([ $FAILURE_MODE == "HARD" ] &&
3822 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
3823 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
3828 $LFS mkdir -i1 -c$MDSCOUNT $DIR/$tdir/striped_dir
3831 check_striped_dir_110 || error "check striped_dir failed"
3833 rm -rf $DIR/$tdir || error "rmdir failed"
3837 run_test 110c "DNE: create striped dir, fail MDT2"
3840 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
3841 ([ $FAILURE_MODE == "HARD" ] &&
3842 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
3843 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
3848 $LFS mkdir -i1 -c$MDSCOUNT $DIR/$tdir/striped_dir
3851 zconf_mount $(hostname) $MOUNT
3852 client_up || return 1
3854 check_striped_dir_110 || error "check striped_dir failed"
3856 rm -rf $DIR/$tdir || error "rmdir failed"
3860 run_test 110d "DNE: create striped dir, fail MDT2 and client"
3863 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
3864 ([ $FAILURE_MODE == "HARD" ] &&
3865 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
3866 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
3871 $LFS mkdir -i1 -c$MDSCOUNT $DIR/$tdir/striped_dir
3875 zconf_mount $(hostname) $MOUNT
3876 client_up || return 1
3878 check_striped_dir_110 || error "check striped_dir failed"
3880 rm -rf $DIR/$tdir || error "rmdir failed"
3884 run_test 110e "DNE: create striped dir, uncommit on MDT2, fail client/MDT1/MDT2"
3887 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
3888 ([ $FAILURE_MODE == "HARD" ] &&
3889 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
3890 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
3896 $LFS mkdir -i1 -c$MDSCOUNT $DIR/$tdir/striped_dir
3899 check_striped_dir_110 || error "check striped_dir failed"
3901 rm -rf $DIR/$tdir || error "rmdir failed"
3905 run_test 110f "DNE: create striped dir, fail MDT1/MDT2"
3908 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
3909 ([ $FAILURE_MODE == "HARD" ] &&
3910 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
3911 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
3916 $LFS mkdir -i1 -c$MDSCOUNT $DIR/$tdir/striped_dir
3920 zconf_mount $(hostname) $MOUNT
3921 client_up || return 1
3923 check_striped_dir_110 || error "check striped_dir failed"
3925 rm -rf $DIR/$tdir || error "rmdir failed"
3929 run_test 110g "DNE: create striped dir, uncommit on MDT1, fail client/MDT1/MDT2"
3932 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
3933 ([ $FAILURE_MODE == "HARD" ] &&
3934 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
3935 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
3939 $LFS mkdir -i1 -c2 $DIR/$tdir/striped_dir
3941 rm -rf $DIR/$tdir/striped_dir
3944 $CHECKSTAT -t dir $DIR/$tdir/striped_dir &&
3945 error "striped dir still exists"
3948 run_test 111a "DNE: unlink striped dir, fail MDT1"
3951 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
3952 ([ $FAILURE_MODE == "HARD" ] &&
3953 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
3954 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
3958 $LFS mkdir -i1 -c2 $DIR/$tdir/striped_dir
3960 rm -rf $DIR/$tdir/striped_dir
3963 zconf_mount $(hostname) $MOUNT
3964 client_up || return 1
3966 $CHECKSTAT -t dir $DIR/$tdir/striped_dir &&
3967 error "striped dir still exists"
3970 run_test 111b "DNE: unlink striped dir, fail MDT2"
3973 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
3974 ([ $FAILURE_MODE == "HARD" ] &&
3975 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
3976 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
3980 $LFS mkdir -i1 -c2 $DIR/$tdir/striped_dir
3982 rm -rf $DIR/$tdir/striped_dir
3986 zconf_mount $(hostname) $MOUNT
3987 client_up || return 1
3988 $CHECKSTAT -t dir $DIR/$tdir/striped_dir &&
3989 error "striped dir still exists"
3992 run_test 111c "DNE: unlink striped dir, uncommit on MDT1, fail client/MDT1/MDT2"
3995 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
3996 ([ $FAILURE_MODE == "HARD" ] &&
3997 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
3998 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
4002 $LFS mkdir -i1 -c2 $DIR/$tdir/striped_dir
4004 rm -rf $DIR/$tdir/striped_dir
4008 zconf_mount $(hostname) $MOUNT
4009 client_up || return 1
4010 $CHECKSTAT -t dir $DIR/$tdir/striped_dir &&
4011 error "striped dir still exists"
4015 run_test 111d "DNE: unlink striped dir, uncommit on MDT2, fail client/MDT1/MDT2"
4018 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
4019 ([ $FAILURE_MODE == "HARD" ] &&
4020 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
4021 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
4025 $LFS mkdir -i1 -c2 $DIR/$tdir/striped_dir
4027 rm -rf $DIR/$tdir/striped_dir
4030 $CHECKSTAT -t dir $DIR/$tdir/striped_dir &&
4031 error "striped dir still exists"
4034 run_test 111e "DNE: unlink striped dir, uncommit on MDT2, fail MDT1/MDT2"
4037 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
4038 ([ $FAILURE_MODE == "HARD" ] &&
4039 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
4040 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
4044 $LFS mkdir -i1 -c2 $DIR/$tdir/striped_dir
4046 rm -rf $DIR/$tdir/striped_dir
4049 $CHECKSTAT -t dir $DIR/$tdir/striped_dir &&
4050 error "striped dir still exists"
4053 run_test 111f "DNE: unlink striped dir, uncommit on MDT1, fail MDT1/MDT2"
4056 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
4057 ([ $FAILURE_MODE == "HARD" ] &&
4058 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
4059 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
4063 $LFS mkdir -i1 -c2 $DIR/$tdir/striped_dir
4066 rm -rf $DIR/$tdir/striped_dir
4068 $CHECKSTAT -t dir $DIR/$tdir/striped_dir &&
4069 error "striped dir still exists"
4072 run_test 111g "DNE: unlink striped dir, fail MDT1/MDT2"
4074 test_112_rename_prepare() {
4075 mkdir -p $DIR/$tdir/src_dir
4076 $LFS mkdir -i 1 $DIR/$tdir/src_dir/src_child ||
4077 error "create remote source failed"
4079 touch $DIR/$tdir/src_dir/src_child/a
4081 $LFS mkdir -i 2 $DIR/$tdir/tgt_dir ||
4082 error "create remote target dir failed"
4084 $LFS mkdir -i 3 $DIR/$tdir/tgt_dir/tgt_child ||
4085 error "create remote target child failed"
4090 $CHECKSTAT -t dir $DIR/$tdir/src_dir/src_child &&
4091 error "src_child still exists after rename"
4093 $CHECKSTAT -t file $DIR/$tdir/tgt_dir/tgt_child/a ||
4094 error "missing file(a) after rename"
4098 [ $MDSCOUNT -lt 4 ] && skip "needs >= 4 MDTs" && return 0
4099 ([ $FAILURE_MODE == "HARD" ] &&
4100 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
4101 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
4104 test_112_rename_prepare
4107 mrename $DIR/$tdir/src_dir/src_child $DIR/$tdir/tgt_dir/tgt_child ||
4108 error "rename dir cross MDT failed!"
4112 rm -rf $DIR/$tdir || error "rmdir failed"
4114 run_test 112a "DNE: cross MDT rename, fail MDT1"
4117 [ $MDSCOUNT -lt 4 ] && skip "needs >= 4 MDTs" && return 0
4118 ([ $FAILURE_MODE == "HARD" ] &&
4119 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
4120 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
4123 test_112_rename_prepare
4126 mrename $DIR/$tdir/src_dir/src_child $DIR/$tdir/tgt_dir/tgt_child ||
4127 error "rename dir cross MDT failed!"
4132 rm -rf $DIR/$tdir || error "rmdir failed"
4134 run_test 112b "DNE: cross MDT rename, fail MDT2"
4137 [ $MDSCOUNT -lt 4 ] && skip "needs >= 4 MDTs" && return 0
4138 ([ $FAILURE_MODE == "HARD" ] &&
4139 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
4140 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
4143 test_112_rename_prepare
4146 mrename $DIR/$tdir/src_dir/src_child $DIR/$tdir/tgt_dir/tgt_child ||
4147 error "rename dir cross MDT failed!"
4152 rm -rf $DIR/$tdir || error "rmdir failed"
4154 run_test 112c "DNE: cross MDT rename, fail MDT3"
4157 [ $MDSCOUNT -lt 4 ] && skip "needs >= 4 MDTs" && return 0
4158 ([ $FAILURE_MODE == "HARD" ] &&
4159 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
4160 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
4163 test_112_rename_prepare
4166 mrename $DIR/$tdir/src_dir/src_child $DIR/$tdir/tgt_dir/tgt_child ||
4167 error "rename dir cross MDT failed!"
4172 rm -rf $DIR/$tdir || error "rmdir failed"
4174 run_test 112d "DNE: cross MDT rename, fail MDT4"
4177 [ $MDSCOUNT -lt 4 ] && skip "needs >= 4 MDTs" && return 0
4178 ([ $FAILURE_MODE == "HARD" ] &&
4179 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
4180 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
4183 test_112_rename_prepare
4187 mrename $DIR/$tdir/src_dir/src_child $DIR/$tdir/tgt_dir/tgt_child ||
4188 error "rename dir cross MDT failed!"
4193 rm -rf $DIR/$tdir || error "rmdir failed"
4195 run_test 112e "DNE: cross MDT rename, fail MDT1 and MDT2"
4198 [ $MDSCOUNT -lt 4 ] && skip "needs >= 4 MDTs" && return 0
4199 ([ $FAILURE_MODE == "HARD" ] &&
4200 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
4201 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
4204 test_112_rename_prepare
4208 mrename $DIR/$tdir/src_dir/src_child $DIR/$tdir/tgt_dir/tgt_child ||
4209 error "rename dir cross MDT failed!"
4214 rm -rf $DIR/$tdir || error "rmdir failed"
4216 run_test 112f "DNE: cross MDT rename, fail MDT1 and MDT3"
4219 [ $MDSCOUNT -lt 4 ] && skip "needs >= 4 MDTs" && return 0
4220 ([ $FAILURE_MODE == "HARD" ] &&
4221 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
4222 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
4225 test_112_rename_prepare
4229 mrename $DIR/$tdir/src_dir/src_child $DIR/$tdir/tgt_dir/tgt_child ||
4230 error "rename dir cross MDT failed!"
4235 rm -rf $DIR/$tdir || error "rmdir failed"
4237 run_test 112g "DNE: cross MDT rename, fail MDT1 and MDT4"
4240 [ $MDSCOUNT -lt 4 ] && skip "needs >= 4 MDTs" && return 0
4241 ([ $FAILURE_MODE == "HARD" ] &&
4242 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
4243 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
4246 test_112_rename_prepare
4250 mrename $DIR/$tdir/src_dir/src_child $DIR/$tdir/tgt_dir/tgt_child ||
4251 error "rename dir cross MDT failed!"
4256 rm -rf $DIR/$tdir || error "rmdir failed"
4258 run_test 112h "DNE: cross MDT rename, fail MDT2 and MDT3"
4261 [ $MDSCOUNT -lt 4 ] && skip "needs >= 4 MDTs" && return 0
4262 ([ $FAILURE_MODE == "HARD" ] &&
4263 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
4264 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
4267 test_112_rename_prepare
4271 mrename $DIR/$tdir/src_dir/src_child $DIR/$tdir/tgt_dir/tgt_child ||
4272 error "rename dir cross MDT failed!"
4277 rm -rf $DIR/$tdir || error "rmdir failed"
4279 run_test 112i "DNE: cross MDT rename, fail MDT2 and MDT4"
4282 [ $MDSCOUNT -lt 4 ] && skip "needs >= 4 MDTs" && return 0
4283 ([ $FAILURE_MODE == "HARD" ] &&
4284 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
4285 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
4288 test_112_rename_prepare
4292 mrename $DIR/$tdir/src_dir/src_child $DIR/$tdir/tgt_dir/tgt_child ||
4293 error "rename dir cross MDT failed!"
4298 rm -rf $DIR/$tdir || error "rmdir failed"
4300 run_test 112j "DNE: cross MDT rename, fail MDT3 and MDT4"
4303 [ $MDSCOUNT -lt 4 ] && skip "needs >= 4 MDTs" && return 0
4304 ([ $FAILURE_MODE == "HARD" ] &&
4305 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
4306 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
4309 test_112_rename_prepare
4314 mrename $DIR/$tdir/src_dir/src_child $DIR/$tdir/tgt_dir/tgt_child ||
4315 error "rename dir cross MDT failed!"
4320 rm -rf $DIR/$tdir || error "rmdir failed"
4322 run_test 112k "DNE: cross MDT rename, fail MDT1,MDT2,MDT3"
4325 [ $MDSCOUNT -lt 4 ] && skip "needs >= 4 MDTs" && return 0
4326 ([ $FAILURE_MODE == "HARD" ] &&
4327 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
4328 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
4331 test_112_rename_prepare
4336 mrename $DIR/$tdir/src_dir/src_child $DIR/$tdir/tgt_dir/tgt_child ||
4337 error "rename dir cross MDT failed!"
4342 rm -rf $DIR/$tdir || error "rmdir failed"
4344 run_test 112l "DNE: cross MDT rename, fail MDT1,MDT2,MDT4"
4347 [ $MDSCOUNT -lt 4 ] && skip "needs >= 4 MDTs" && return 0
4348 ([ $FAILURE_MODE == "HARD" ] &&
4349 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
4350 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
4353 test_112_rename_prepare
4358 mrename $DIR/$tdir/src_dir/src_child $DIR/$tdir/tgt_dir/tgt_child ||
4359 error "rename dir cross MDT failed!"
4364 rm -rf $DIR/$tdir || error "rmdir failed"
4366 run_test 112m "DNE: cross MDT rename, fail MDT1,MDT3,MDT4"
4369 [ $MDSCOUNT -lt 4 ] && skip "needs >= 4 MDTs" && return 0
4370 ([ $FAILURE_MODE == "HARD" ] &&
4371 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
4372 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
4375 test_112_rename_prepare
4380 mrename $DIR/$tdir/src_dir/src_child $DIR/$tdir/tgt_dir/tgt_child ||
4381 error "rename dir cross MDT failed!"
4386 rm -rf $DIR/$tdir || error "rmdir failed"
4388 run_test 112n "DNE: cross MDT rename, fail MDT2,MDT3,MDT4"
4391 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
4392 ([ $FAILURE_MODE == "HARD" ] &&
4393 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
4394 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
4402 for ((j=0;j<$((MDSCOUNT));j++)); do
4403 fail_index=$((fail_index+1))
4404 index=$((fail_index % MDSCOUNT))
4405 replay_barrier mds$((index + 1))
4406 for ((i=0;i<5;i++)); do
4407 test_mkdir -i$index -c$MDSCOUNT $DIR/$tdir/test_$i ||
4408 error "create striped dir $DIR/$tdir/test_$i"
4411 fail mds$((index + 1))
4412 for ((i=0;i<5;i++)); do
4413 checkstat -t dir $DIR/$tdir/test_$i ||
4414 error "$DIR/$tdir/test_$i does not exist!"
4416 rm -rf $DIR/$tdir/test_* ||
4420 run_test 115 "failover for create/unlink striped directory"
4423 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
4424 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.55) ] &&
4425 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 mds1 "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 116a "large update log master MDT recovery"
4447 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
4448 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.55) ] &&
4449 skip "Do not support large update log before 2.7.55" &&
4452 ([ $FAILURE_MODE == "HARD" ] &&
4453 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
4454 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
4461 # OBD_FAIL_SPLIT_UPDATE_REC 0x1702
4462 do_facet mds2 "lctl set_param fail_loc=0x80001702"
4463 $LFS setdirstripe -c$MDSCOUNT $DIR/$tdir/striped_dir
4466 $CHECKSTAT -t dir $DIR/$tdir/striped_dir ||
4467 error "stried_dir does not exists"
4469 run_test 116b "large update log slave MDT recovery"
4472 [ $MDSCOUNT -lt 4 ] && skip "needs >= 4 MDTs" && return 0
4473 ([ $FAILURE_MODE == "HARD" ] &&
4474 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
4475 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
4481 $LFS setdirstripe -i0 -c$MDSCOUNT $DIR/$tdir/remote_dir
4482 $LFS setdirstripe -i1 -c$MDSCOUNT $DIR/$tdir/remote_dir_1
4485 # Let's set rdonly on all MDTs, so client will send
4486 # replay requests on all MDTs and replay these requests
4487 # at the same time. This test will verify the recovery
4488 # will not be deadlock in this case, LU-7531.
4489 for ((index = 0; index < $((MDSCOUNT)); index++)); do
4490 replay_barrier mds$((index + 1))
4491 if [ -z $mds_indexs ]; then
4492 mds_indexs="${mds_indexs}mds$((index+1))"
4494 mds_indexs="${mds_indexs},mds$((index+1))"
4498 rm -rf $DIR/$tdir/remote_dir
4499 rm -rf $DIR/$tdir/remote_dir_1
4503 rm -rf $DIR/$tdir || error "rmdir failed"
4505 run_test 117 "DNE: cross MDT unlink, fail MDT1 and MDT2"
4508 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
4509 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.64) ] &&
4510 skip "Do not support large update log before 2.7.64" &&
4515 $LFS setdirstripe -c2 $DIR/$tdir/striped_dir ||
4516 error "setdirstripe fails"
4517 $LFS setdirstripe -c2 $DIR/$tdir/striped_dir1 ||
4518 error "setdirstripe fails 1"
4519 rm -rf $DIR/$tdir/striped_dir* || error "rmdir fails"
4521 # OBD_FAIL_INVALIDATE_UPDATE 0x1705
4522 do_facet mds1 "lctl set_param fail_loc=0x1705"
4523 $LFS setdirstripe -c2 $DIR/$tdir/striped_dir
4524 $LFS setdirstripe -c2 $DIR/$tdir/striped_dir1
4525 do_facet mds1 "lctl set_param fail_loc=0x0"
4528 $LFS setdirstripe -c2 $DIR/$tdir/striped_dir
4529 $LFS setdirstripe -c2 $DIR/$tdir/striped_dir1
4534 run_test 118 "invalidate osp update will not cause update log corruption"
4537 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
4538 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.64) ] &&
4539 skip "Do not support large update log before 2.7.64" &&
4542 local hard_timeout=$(do_facet mds1 \
4543 "lctl get_param -n mdt.$FSNAME-MDT0000.recovery_time_hard")
4545 local clients=${CLIENTS:-$HOSTNAME}
4546 local time_min=$(recovery_time_min)
4549 mkdir $DIR/$tdir/tmp
4550 rmdir $DIR/$tdir/tmp
4553 mkdir $DIR/$tdir/dir_1
4554 for ((i = 0; i < 20; i++)); do
4555 $LFS setdirstripe -c2 $DIR/$tdir/stripe_dir-$i
4562 #define OBD_FAIL_TGT_REPLAY_DELAY 0x714
4563 do_facet mds1 $LCTL set_param fail_loc=0x80000714
4564 #sleep (timeout + 5), so mds will evict the client exports,
4565 #but DNE update recovery will keep going.
4566 do_facet mds1 $LCTL set_param fail_val=$((time_min + 5))
4568 mount_facet mds1 "-o recovery_time_hard=$time_min"
4570 wait_clients_import_state "$clients" mds1 FULL
4572 clients_up || clients_up || error "failover df: $?"
4574 #revert back the hard timeout
4575 do_facet mds1 $LCTL set_param \
4576 mdt.$FSNAME-MDT0000.recovery_time_hard=$hard_timeout
4578 for ((i = 0; i < 20; i++)); do
4579 stripe_count=$($LFS getdirstripe -c $DIR/$tdir/stripe_dir-$i)
4580 [ $stripe_count == 2 ] || {
4581 error "stripe_dir-$i creation replay fails"
4586 run_test 119 "timeout of normal replay does not cause DNE replay fails "
4589 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
4590 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.64) ] &&
4591 skip "Do not support large update log before 2.7.64" &&
4595 replay_barrier_nosync mds1
4596 for ((i = 0; i < 20; i++)); do
4597 mkdir $DIR/$tdir/dir-$i || {
4598 error "create dir-$i fails"
4601 $LFS setdirstripe -c2 $DIR/$tdir/stripe_dir-$i || {
4602 error "create stripe_dir-$i fails"
4609 for ((i = 0; i < 20; i++)); do
4610 [ ! -e "$DIR/$tdir/dir-$i" ] || {
4611 error "dir-$i still exists"
4614 [ ! -e "$DIR/$tdir/stripe_dir-$i" ] || {
4615 error "stripe_dir-$i still exists"
4620 run_test 120 "DNE fail abort should stop both normal and DNE replay"
4623 check_and_cleanup_lustre