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 # let the MDS discover the OST failure, attempt to recover, fail
1142 # and recover again.
1143 sleep $((3 * TIMEOUT))
1145 createmany -o $DIR/$tfile 20 20 ||
1146 error "createmany recraete $DIR/$tfile failed"
1147 unlinkmany $DIR/$tfile 40 || error "unlinkmany $DIR/$tfile failed"
1150 run_test 48 "MDS->OSC failure during precreate cleanup (2824)"
1153 local mdtosc=$(get_mdtosc_proc_path $SINGLEMDS $ost1_svc)
1154 local oscdev=$(do_facet $SINGLEMDS "lctl get_param -n devices" |
1155 grep $mdtosc | awk '{print $1}')
1156 [ "$oscdev" ] || error "could not find OSC device on MDS"
1157 do_facet $SINGLEMDS $LCTL --device $oscdev recover ||
1158 error "OSC device $oscdev recovery failed"
1159 do_facet $SINGLEMDS $LCTL --device $oscdev recover ||
1160 error "second OSC device $oscdev recovery failed"
1161 # give the mds_lov_sync threads a chance to run
1164 run_test 50 "Double OSC recovery, don't LASSERT (3812)"
1166 # b3764 timed out lock replay
1168 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.6.90) ] &&
1169 skip "MDS prior to 2.6.90 handle LDLM_REPLY_NET incorrectly" &&
1172 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
1173 cancel_lru_locks mdc
1175 multiop_bg_pause $DIR/$tfile s_s || error "multiop $DIR/$tfile failed"
1178 #define OBD_FAIL_MDS_LDLM_REPLY_NET 0x157
1179 lctl set_param -n ldlm.cancel_unused_locks_before_replay "0"
1180 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000157"
1182 fail $SINGLEMDS || error "fail $SINGLEMDS failed"
1184 wait $mpid || error "multiop_bg_pause pid failed"
1186 do_facet $SINGLEMDS "lctl set_param fail_loc=0x0"
1187 lctl set_param fail_loc=0x0
1188 lctl set_param -n ldlm.cancel_unused_locks_before_replay "1"
1191 run_test 52 "time out lock replay (3764)"
1193 # bug 3462 - simultaneous MDC requests
1195 [[ $(lctl get_param mdc.*.import |
1196 grep "connect_flags:.*multi_mod_rpc") ]] ||
1197 { skip "Need MDC with 'multi_mod_rpcs' feature"; return 0; }
1199 cancel_lru_locks mdc # cleanup locks from former test cases
1200 mkdir $DIR/${tdir}-1 || error "mkdir $DIR/${tdir}-1 failed"
1201 mkdir $DIR/${tdir}-2 || error "mkdir $DIR/${tdir}-2 failed"
1202 multiop $DIR/${tdir}-1/f O_c &
1204 # give multiop a change to open
1207 #define OBD_FAIL_MDS_CLOSE_NET 0x115
1208 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000115"
1209 kill -USR1 $close_pid
1210 cancel_lru_locks mdc # force the close
1211 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
1213 mcreate $DIR/${tdir}-2/f || error "mcreate $DIR/${tdir}-2/f failed"
1215 # close should still be here
1216 [ -d /proc/$close_pid ] || error "close_pid doesn't exist"
1218 replay_barrier_nodf $SINGLEMDS
1220 wait $close_pid || error "close_pid $close_pid failed"
1222 $CHECKSTAT -t file $DIR/${tdir}-1/f ||
1223 error "$CHECKSTAT $DIR/${tdir}-1/f attribute check failed"
1224 $CHECKSTAT -t file $DIR/${tdir}-2/f ||
1225 error "$CHECKSTAT $DIR/${tdir}-2/f attribute check failed"
1226 rm -rf $DIR/${tdir}-*
1228 run_test 53a "|X| close request while two MDC requests in flight"
1231 cancel_lru_locks mdc # cleanup locks from former test cases
1233 mkdir $DIR/${tdir}-1 || error "mkdir $DIR/${tdir}-1 failed"
1234 mkdir $DIR/${tdir}-2 || error "mkdir $DIR/${tdir}-2 failed"
1235 multiop_bg_pause $DIR/${tdir}-1/f O_c ||
1236 error "multiop_bg_pause $DIR/${tdir}-1/f failed"
1239 #define OBD_FAIL_MDS_REINT_NET 0x107
1240 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000107"
1241 mcreate $DIR/${tdir}-2/f &
1245 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
1246 kill -USR1 $close_pid
1247 cancel_lru_locks mdc # force the close
1248 wait $close_pid || error "close_pid $close_pid failed"
1249 # open should still be here
1250 [ -d /proc/$open_pid ] || error "open_pid doesn't exist"
1252 replay_barrier_nodf $SINGLEMDS
1254 wait $open_pid || error "open_pid failed"
1256 $CHECKSTAT -t file $DIR/${tdir}-1/f ||
1257 error "$CHECKSTAT $DIR/${tdir}-1/f attribute check failed"
1258 $CHECKSTAT -t file $DIR/${tdir}-2/f ||
1259 error "$CHECKSTAT $DIR/${tdir}-2/f attribute check failed"
1260 rm -rf $DIR/${tdir}-*
1262 run_test 53b "|X| open request while two MDC requests in flight"
1265 cancel_lru_locks mdc # cleanup locks from former test cases
1267 mkdir $DIR/${tdir}-1 || error "mkdir $DIR/${tdir}-1 failed"
1268 mkdir $DIR/${tdir}-2 || error "mkdir $DIR/${tdir}-2 failed"
1269 multiop $DIR/${tdir}-1/f O_c &
1272 #define OBD_FAIL_MDS_REINT_NET 0x107
1273 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000107"
1274 mcreate $DIR/${tdir}-2/f &
1278 #define OBD_FAIL_MDS_CLOSE_NET 0x115
1279 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000115"
1280 kill -USR1 $close_pid
1281 cancel_lru_locks mdc # force the close
1283 #bz20647: make sure all pids exist before failover
1284 [ -d /proc/$close_pid ] || error "close_pid doesn't exist"
1285 [ -d /proc/$open_pid ] || error "open_pid doesn't exists"
1286 replay_barrier_nodf $SINGLEMDS
1287 fail_nodf $SINGLEMDS
1288 wait $open_pid || error "open_pid failed"
1290 # close should be gone
1291 [ -d /proc/$close_pid ] && error "close_pid should not exist"
1292 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
1294 $CHECKSTAT -t file $DIR/${tdir}-1/f ||
1295 error "$CHECKSTAT $DIR/${tdir}-1/f attribute check failed"
1296 $CHECKSTAT -t file $DIR/${tdir}-2/f ||
1297 error "$CHECKSTAT $DIR/${tdir}-2/f attribute check failed"
1298 rm -rf $DIR/${tdir}-*
1300 run_test 53c "|X| open request and close request while two MDC requests in flight"
1303 [[ $(lctl get_param mdc.*.import |
1304 grep "connect_flags:.*multi_mod_rpc") ]] ||
1305 { skip "Need MDC with 'multi_mod_rpcs' feature"; return 0; }
1307 cancel_lru_locks mdc # cleanup locks from former test cases
1309 mkdir $DIR/${tdir}-1 || error "mkdir $DIR/${tdir}-1 failed"
1310 mkdir $DIR/${tdir}-2 || error "mkdir $DIR/${tdir}-2 failed"
1311 multiop $DIR/${tdir}-1/f O_c &
1313 # give multiop a chance to open
1316 #define OBD_FAIL_MDS_CLOSE_NET_REP 0x13b
1317 do_facet $SINGLEMDS "lctl set_param fail_loc=0x8000013b"
1318 kill -USR1 $close_pid
1319 cancel_lru_locks mdc # force the close
1320 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
1321 mcreate $DIR/${tdir}-2/f || error "mcreate $DIR/${tdir}-2/f failed"
1323 # close should still be here
1324 [ -d /proc/$close_pid ] || error "close_pid doesn't exist"
1326 wait $close_pid || error "close_pid failed"
1328 $CHECKSTAT -t file $DIR/${tdir}-1/f ||
1329 error "$CHECKSTAT $DIR/${tdir}-1/f attribute check failed"
1330 $CHECKSTAT -t file $DIR/${tdir}-2/f ||
1331 error "$CHECKSTAT $DIR/${tdir}-2/f attribute check failed"
1332 rm -rf $DIR/${tdir}-*
1334 run_test 53d "close reply while two MDC requests in flight"
1337 cancel_lru_locks mdc # cleanup locks from former test cases
1339 mkdir $DIR/${tdir}-1 || error "mkdir $DIR/${tdir}-1 failed"
1340 mkdir $DIR/${tdir}-2 || error "mkdir $DIR/${tdir}-2 failed"
1341 multiop $DIR/${tdir}-1/f O_c &
1344 #define OBD_FAIL_MDS_REINT_NET_REP 0x119
1345 do_facet $SINGLEMDS "lctl set_param fail_loc=0x119"
1346 mcreate $DIR/${tdir}-2/f &
1350 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
1351 kill -USR1 $close_pid
1352 cancel_lru_locks mdc # force the close
1353 wait $close_pid || error "close_pid failed"
1354 # open should still be here
1355 [ -d /proc/$open_pid ] || error "open_pid doesn't exists"
1357 replay_barrier_nodf $SINGLEMDS
1359 wait $open_pid || error "open_pid failed"
1361 $CHECKSTAT -t file $DIR/${tdir}-1/f ||
1362 error "$CHECKSTAT $DIR/${tdir}-1/f attribute check failed"
1363 $CHECKSTAT -t file $DIR/${tdir}-2/f ||
1364 error "$CHECKSTAT $DIR/${tdir}-2/f attribute check failed"
1365 rm -rf $DIR/${tdir}-*
1367 run_test 53e "|X| open reply while two MDC requests in flight"
1370 cancel_lru_locks mdc # cleanup locks from former test cases
1372 mkdir $DIR/${tdir}-1 || error "mkdir $DIR/${tdir}-1 failed"
1373 mkdir $DIR/${tdir}-2 || error "mkdir $DIR/${tdir}-2 failed"
1374 multiop $DIR/${tdir}-1/f O_c &
1377 #define OBD_FAIL_MDS_REINT_NET_REP 0x119
1378 do_facet $SINGLEMDS "lctl set_param fail_loc=0x119"
1379 mcreate $DIR/${tdir}-2/f &
1383 #define OBD_FAIL_MDS_CLOSE_NET_REP 0x13b
1384 do_facet $SINGLEMDS "lctl set_param fail_loc=0x8000013b"
1385 kill -USR1 $close_pid
1386 cancel_lru_locks mdc # force the close
1388 #bz20647: make sure all pids are exists before failover
1389 [ -d /proc/$close_pid ] || error "close_pid doesn't exist"
1390 [ -d /proc/$open_pid ] || error "open_pid doesn't exists"
1391 replay_barrier_nodf $SINGLEMDS
1392 fail_nodf $SINGLEMDS
1393 wait $open_pid || error "open_pid failed"
1395 # close should be gone
1396 [ -d /proc/$close_pid ] && error "close_pid should not exist"
1397 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
1399 $CHECKSTAT -t file $DIR/${tdir}-1/f ||
1400 error "$CHECKSTAT $DIR/${tdir}-1/f attribute check failed"
1401 $CHECKSTAT -t file $DIR/${tdir}-2/f ||
1402 error "$CHECKSTAT $DIR/${tdir}-2/f attribute check failed"
1403 rm -rf $DIR/${tdir}-*
1405 run_test 53f "|X| open reply and close reply while two MDC requests in flight"
1408 cancel_lru_locks mdc # cleanup locks from former test cases
1410 mkdir $DIR/${tdir}-1 || error "mkdir $DIR/${tdir}-1 failed"
1411 mkdir $DIR/${tdir}-2 || error "mkdir $DIR/${tdir}-2 failed"
1412 multiop $DIR/${tdir}-1/f O_c &
1415 #define OBD_FAIL_MDS_REINT_NET_REP 0x119
1416 do_facet $SINGLEMDS "lctl set_param fail_loc=0x119"
1417 mcreate $DIR/${tdir}-2/f &
1421 #define OBD_FAIL_MDS_CLOSE_NET 0x115
1422 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000115"
1423 kill -USR1 $close_pid
1424 cancel_lru_locks mdc # force the close
1425 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
1427 #bz20647: make sure all pids are exists before failover
1428 [ -d /proc/$close_pid ] || error "close_pid doesn't exist"
1429 [ -d /proc/$open_pid ] || error "open_pid doesn't exists"
1430 replay_barrier_nodf $SINGLEMDS
1431 fail_nodf $SINGLEMDS
1432 wait $open_pid || error "open_pid failed"
1434 # close should be gone
1435 [ -d /proc/$close_pid ] && error "close_pid should not exist"
1437 $CHECKSTAT -t file $DIR/${tdir}-1/f ||
1438 error "$CHECKSTAT $DIR/${tdir}-1/f attribute check failed"
1439 $CHECKSTAT -t file $DIR/${tdir}-2/f ||
1440 error "$CHECKSTAT $DIR/${tdir}-2/f attribute check failed"
1441 rm -rf $DIR/${tdir}-*
1443 run_test 53g "|X| drop open reply and close request while close and open are both in flight"
1446 cancel_lru_locks mdc # cleanup locks from former test cases
1448 mkdir $DIR/${tdir}-1 || error "mkdir $DIR/${tdir}-1 failed"
1449 mkdir $DIR/${tdir}-2 || error "mkdir $DIR/${tdir}-2 failed"
1450 multiop $DIR/${tdir}-1/f O_c &
1453 #define OBD_FAIL_MDS_REINT_NET 0x107
1454 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000107"
1455 mcreate $DIR/${tdir}-2/f &
1459 #define OBD_FAIL_MDS_CLOSE_NET_REP 0x13b
1460 do_facet $SINGLEMDS "lctl set_param fail_loc=0x8000013b"
1461 kill -USR1 $close_pid
1462 cancel_lru_locks mdc # force the close
1465 #bz20647: make sure all pids are exists before failover
1466 [ -d /proc/$close_pid ] || error "close_pid doesn't exist"
1467 [ -d /proc/$open_pid ] || error "open_pid doesn't exists"
1468 replay_barrier_nodf $SINGLEMDS
1469 fail_nodf $SINGLEMDS
1470 wait $open_pid || error "open_pid failed"
1472 # close should be gone
1473 [ -d /proc/$close_pid ] && error "close_pid should not exist"
1474 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
1476 $CHECKSTAT -t file $DIR/${tdir}-1/f ||
1477 error "$CHECKSTAT $DIR/${tdir}-1/f attribute check failed"
1478 $CHECKSTAT -t file $DIR/${tdir}-2/f ||
1479 error "$CHECKSTAT $DIR/${tdir}-2/f attribute check failed"
1480 rm -rf $DIR/${tdir}-*
1482 run_test 53h "open request and close reply while two MDC requests in flight"
1484 #b3761 ASSERTION(hash != 0) failed
1486 # OBD_FAIL_MDS_OPEN_CREATE | OBD_FAIL_ONCE
1487 do_facet $SINGLEMDS "lctl set_param fail_loc=0x8000012b"
1489 # give touch a chance to run
1491 do_facet $SINGLEMDS "lctl set_param fail_loc=0x0"
1495 run_test 55 "let MDS_CHECK_RESENT return the original return code instead of 0"
1497 #b3440 ASSERTION(rec->ur_fid2->id) failed
1499 ln -s foo $DIR/$tfile
1500 replay_barrier $SINGLEMDS
1501 #drop_reply "cat $DIR/$tfile"
1505 run_test 56 "don't replay a symlink open request (3440)"
1507 #recovery one mds-ost setattr from llog
1509 #define OBD_FAIL_MDS_OST_SETATTR 0x12c
1510 do_facet $SINGLEMDS "lctl set_param fail_loc=0x8000012c"
1511 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
1512 replay_barrier $SINGLEMDS
1514 wait_recovery_complete $SINGLEMDS || error "MDS recovery is not done"
1515 wait_mds_ost_sync || error "wait_mds_ost_sync failed"
1516 $CHECKSTAT -t file $DIR/$tfile ||
1517 error "$CHECKSTAT $DIR/$tfile attribute check failed"
1518 do_facet $SINGLEMDS "lctl set_param fail_loc=0x0"
1521 run_test 57 "test recovery from llog for setattr op"
1524 zconf_umount $(hostname) $MOUNT2
1528 #recovery many mds-ost setattr from llog
1530 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
1531 #define OBD_FAIL_MDS_OST_SETATTR 0x12c
1532 do_facet $SINGLEMDS "lctl set_param fail_loc=0x8000012c"
1533 createmany -o $DIR/$tdir/$tfile-%d 2500
1534 replay_barrier $SINGLEMDS
1537 $CHECKSTAT -t file $DIR/$tdir/$tfile-* >/dev/null ||
1538 error "$CHECKSTAT $DIR/$tfile-* attribute check failed"
1539 do_facet $SINGLEMDS "lctl set_param fail_loc=0x0"
1540 unlinkmany $DIR/$tdir/$tfile-%d 2500 ||
1541 error "unlinkmany $DIR/$tfile failed"
1544 run_test 58a "test recovery from llog for setattr op (test llog_gen_rec)"
1550 trap cleanup_58 EXIT
1552 large_xattr_enabled &&
1553 orig="$(generate_string $(max_xattr_size))" || orig="bar"
1554 # Original extended attribute can be long. Print a small version of
1555 # attribute if an error occurs
1556 local sm_msg=$(printf "%.9s" $orig)
1558 mount_client $MOUNT2 || error "mount_client on $MOUNT2 failed"
1559 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
1560 touch $DIR/$tdir/$tfile || error "touch $DIR/$tdir/$tfile failed"
1561 replay_barrier $SINGLEMDS
1562 setfattr -n trusted.foo -v $orig $DIR/$tdir/$tfile
1564 new=$(get_xattr_value trusted.foo $MOUNT2/$tdir/$tfile)
1565 [[ "$new" = "$orig" ]] ||
1566 error "xattr set ($sm_msg...) differs from xattr get ($new)"
1567 rm -f $DIR/$tdir/$tfile
1570 wait_clients_import_state ${CLIENTS:-$HOSTNAME} "mgs" FULL
1572 run_test 58b "test replay of setxattr op"
1574 test_58c() { # bug 16570
1579 trap cleanup_58 EXIT
1581 if large_xattr_enabled; then
1582 local xattr_size=$(max_xattr_size)
1583 orig="$(generate_string $((xattr_size / 2)))"
1584 orig1="$(generate_string $xattr_size)"
1590 # PING_INTERVAL max(obd_timeout / 4, 1U)
1591 sleep $((TIMEOUT / 4))
1593 # Original extended attribute can be long. Print a small version of
1594 # attribute if an error occurs
1595 local sm_msg=$(printf "%.9s" $orig)
1596 local sm_msg1=$(printf "%.9s" $orig1)
1598 mount_client $MOUNT2 || error "mount_client on $MOUNT2 failed"
1599 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
1600 touch $DIR/$tdir/$tfile || error "touch $DIR/$tdir/$tfile failed"
1601 drop_request "setfattr -n trusted.foo -v $orig $DIR/$tdir/$tfile" ||
1602 error "drop_request for setfattr failed"
1603 new=$(get_xattr_value trusted.foo $MOUNT2/$tdir/$tfile)
1604 [[ "$new" = "$orig" ]] ||
1605 error "xattr set ($sm_msg...) differs from xattr get ($new)"
1606 drop_reint_reply "setfattr -n trusted.foo1 \
1607 -v $orig1 $DIR/$tdir/$tfile" ||
1608 error "drop_reint_reply for setfattr failed"
1609 new=$(get_xattr_value trusted.foo1 $MOUNT2/$tdir/$tfile)
1610 [[ "$new" = "$orig1" ]] ||
1611 error "second xattr set ($sm_msg1...) differs xattr get ($new)"
1612 rm -f $DIR/$tdir/$tfile
1616 run_test 58c "resend/reconstruct setxattr op"
1618 # log_commit_thread vs filter_destroy race used to lead to import use after free
1621 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1623 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
1624 createmany -o $DIR/$tdir/$tfile-%d 200 ||
1625 error "createmany create files failed"
1627 unlinkmany $DIR/$tdir/$tfile-%d 200 ||
1628 error "unlinkmany $DIR/$tdir/$tfile failed"
1629 #define OBD_FAIL_PTLRPC_DELAY_RECOV 0x507
1630 do_facet ost1 "lctl set_param fail_loc=0x507"
1633 do_facet ost1 "lctl set_param fail_loc=0x0"
1637 run_test 59 "test log_commit_thread vs filter_destroy race"
1639 # race between add unlink llog vs cat log init in post_recovery (only for b1_6)
1640 # bug 12086: should no oops and No ctxt error for this test
1642 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
1643 createmany -o $DIR/$tdir/$tfile-%d 200 ||
1644 error "createmany create files failed"
1645 replay_barrier $SINGLEMDS
1646 unlinkmany $DIR/$tdir/$tfile-%d 0 100
1648 unlinkmany $DIR/$tdir/$tfile-%d 100 100
1649 local no_ctxt=$(dmesg | grep "No ctxt")
1650 [ -z "$no_ctxt" ] || error "ctxt is not initialized in recovery"
1652 run_test 60 "test llog post recovery init vs llog unlink"
1654 #test race llog recovery thread vs llog cleanup
1655 test_61a() { # was test_61
1656 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1658 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
1659 createmany -o $DIR/$tdir/$tfile-%d 800 ||
1660 error "createmany create files failed"
1662 unlinkmany $DIR/$tdir/$tfile-%d 800
1663 # OBD_FAIL_OST_LLOG_RECOVERY_TIMEOUT 0x221
1664 set_nodes_failloc "$(osts_nodes)" 0x80000221
1669 set_nodes_failloc "$(osts_nodes)" 0x0
1671 $CHECKSTAT -t file $DIR/$tdir/$tfile-* &&
1672 error "$CHECKSTAT $DIR/$tdir/$tfile attribute check should fail"
1675 run_test 61a "test race llog recovery vs llog cleanup"
1677 #test race mds llog sync vs llog cleanup
1679 # OBD_FAIL_MDS_LLOG_SYNC_TIMEOUT 0x13a
1680 do_facet $SINGLEMDS "lctl set_param fail_loc=0x8000013a"
1681 facet_failover $SINGLEMDS
1684 do_facet client dd if=/dev/zero of=$DIR/$tfile bs=4k count=1 ||
1687 run_test 61b "test race mds llog sync vs llog cleanup"
1689 #test race cancel cookie cb vs llog cleanup
1691 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1693 # OBD_FAIL_OST_CANCEL_COOKIE_TIMEOUT 0x222
1694 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
1695 set_nodes_failloc "$(osts_nodes)" 0x80000222
1699 set_nodes_failloc "$(osts_nodes)" 0x0
1701 run_test 61c "test race mds llog sync vs llog cleanup"
1703 test_61d() { # bug 16002 # bug 17466 # bug 22137
1704 # OBD_FAIL_OBD_LLOG_SETUP 0x605
1706 do_facet mgs "lctl set_param fail_loc=0x80000605"
1707 start mgs $(mgsdevname) $MGS_MOUNT_OPTS &&
1708 error "mgs start should have failed"
1709 do_facet mgs "lctl set_param fail_loc=0"
1710 start mgs $(mgsdevname) $MGS_MOUNT_OPTS || error "cannot restart mgs"
1712 run_test 61d "error in llog_setup should cleanup the llog context correctly"
1714 test_62() { # Bug 15756 - don't mis-drop resent replay
1715 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
1716 replay_barrier $SINGLEMDS
1717 createmany -o $DIR/$tdir/$tfile- 25 ||
1718 error "createmany create files failed"
1719 #define OBD_FAIL_TGT_REPLAY_DROP 0x707
1720 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000707"
1722 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
1723 unlinkmany $DIR/$tdir/$tfile- 25 ||
1724 error "unlinkmany $DIR/$tdir/$tfile failed"
1727 run_test 62 "don't mis-drop resent replay"
1729 #Adaptive Timeouts (bug 3055)
1737 echo "Cleaning up AT ..."
1738 if [ -n "$ATOLDBASE" ]; then
1739 local at_history=$($LCTL get_param -n at_history)
1740 do_facet $SINGLEMDS "lctl set_param at_history=$at_history" || true
1741 do_facet ost1 "lctl set_param at_history=$at_history" || true
1744 if [ $AT_MAX_SET -ne 0 ]; then
1745 for facet in mds client ost; do
1746 var=AT_MAX_SAVE_${facet}
1747 echo restore AT on $facet to saved value ${!var}
1748 at_max_set ${!var} $facet
1749 at_new=$(at_max_get $facet)
1750 echo Restored AT value on $facet $at_new
1751 [ $at_new -eq ${!var} ] ||
1752 error "AT value not restored SAVED ${!var} NEW $at_new"
1759 local at_max_new=600
1761 # Save at_max original values
1763 if [ $AT_MAX_SET -eq 0 ]; then
1764 # Suppose that all osts have the same at_max
1765 for facet in mds client ost; do
1766 eval AT_MAX_SAVE_${facet}=$(at_max_get $facet)
1770 for facet in mds client ost; do
1771 at_max=$(at_max_get $facet)
1772 if [ $at_max -ne $at_max_new ]; then
1773 echo "AT value on $facet is $at_max, set it by force temporarily to $at_max_new"
1774 at_max_set $at_max_new $facet
1779 if [ -z "$ATOLDBASE" ]; then
1780 ATOLDBASE=$(do_facet $SINGLEMDS "lctl get_param -n at_history")
1781 # speed up the timebase so we can check decreasing AT
1782 do_facet $SINGLEMDS "lctl set_param at_history=8" || true
1783 do_facet ost1 "lctl set_param at_history=8" || true
1785 # sleep for a while to cool down, should be > 8s and also allow
1786 # at least one ping to be sent. simply use TIMEOUT to be safe.
1791 test_65a() #bug 3055
1793 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1795 at_start || return 0
1796 $LCTL dk > /dev/null
1798 $LCTL set_param debug="other"
1799 # Slow down a request to the current service time, this is critical
1800 # because previous tests may have caused this value to increase.
1801 REQ_DELAY=`lctl get_param -n mdc.${FSNAME}-MDT0000-mdc-*.timeouts |
1802 awk '/portal 12/ {print $5}'`
1803 REQ_DELAY=$((${REQ_DELAY} + ${REQ_DELAY} / 4 + 5))
1805 do_facet $SINGLEMDS lctl set_param fail_val=$((${REQ_DELAY} * 1000))
1806 #define OBD_FAIL_PTLRPC_PAUSE_REQ 0x50a
1807 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x8000050a
1808 createmany -o $DIR/$tfile 10 > /dev/null
1809 unlinkmany $DIR/$tfile 10 > /dev/null
1810 # check for log message
1811 $LCTL dk | grep "Early reply #" || error "No early reply"
1813 # client should show REQ_DELAY estimates
1814 lctl get_param -n mdc.${FSNAME}-MDT0000-mdc-*.timeouts | grep portal
1816 lctl get_param -n mdc.${FSNAME}-MDT0000-mdc-*.timeouts | grep portal
1818 run_test 65a "AT: verify early replies"
1820 test_65b() #bug 3055
1822 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1824 at_start || return 0
1827 $LCTL set_param debug="other trace"
1828 $LCTL dk > /dev/null
1829 # Slow down a request to the current service time, this is critical
1830 # because previous tests may have caused this value to increase.
1831 $SETSTRIPE --stripe-index=0 --stripe-count=1 $DIR/$tfile ||
1832 error "$SETSTRIPE failed for $DIR/$tfile"
1834 multiop $DIR/$tfile Ow1yc
1835 REQ_DELAY=`lctl get_param -n osc.${FSNAME}-OST0000-osc-*.timeouts |
1836 awk '/portal 6/ {print $5}'`
1837 REQ_DELAY=$((${REQ_DELAY} + ${REQ_DELAY} / 4 + 5))
1839 do_facet ost1 lctl set_param fail_val=${REQ_DELAY}
1840 #define OBD_FAIL_OST_BRW_PAUSE_PACK 0x224
1841 do_facet ost1 $LCTL set_param fail_loc=0x224
1844 $SETSTRIPE --stripe-index=0 --stripe-count=1 $DIR/$tfile ||
1845 error "$SETSTRIPE failed"
1846 # force some real bulk transfer
1847 multiop $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
1849 do_facet ost1 $LCTL set_param fail_loc=0
1850 # check for log message
1851 $LCTL dk | grep "Early reply #" || error "No early reply"
1853 # client should show REQ_DELAY estimates
1854 lctl get_param -n osc.${FSNAME}-OST0000-osc-*.timeouts | grep portal
1856 run_test 65b "AT: verify early replies on packed reply / bulk"
1858 test_66a() #bug 3055
1860 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1862 at_start || return 0
1863 lctl get_param -n mdc.${FSNAME}-MDT0000-mdc-*.timeouts | grep "portal 12"
1864 # adjust 5s at a time so no early reply is sent (within deadline)
1865 do_facet $SINGLEMDS "$LCTL set_param fail_val=5000"
1866 #define OBD_FAIL_PTLRPC_PAUSE_REQ 0x50a
1867 do_facet $SINGLEMDS "$LCTL set_param fail_loc=0x8000050a"
1868 createmany -o $DIR/$tfile 20 > /dev/null
1869 unlinkmany $DIR/$tfile 20 > /dev/null
1870 lctl get_param -n mdc.${FSNAME}-MDT0000-mdc-*.timeouts | grep "portal 12"
1871 do_facet $SINGLEMDS "$LCTL set_param fail_val=10000"
1872 do_facet $SINGLEMDS "$LCTL set_param fail_loc=0x8000050a"
1873 createmany -o $DIR/$tfile 20 > /dev/null
1874 unlinkmany $DIR/$tfile 20 > /dev/null
1875 lctl get_param -n mdc.${FSNAME}-MDT0000-mdc-*.timeouts | grep "portal 12"
1876 do_facet $SINGLEMDS "$LCTL set_param fail_loc=0"
1878 createmany -o $DIR/$tfile 20 > /dev/null
1879 unlinkmany $DIR/$tfile 20 > /dev/null
1880 lctl get_param -n mdc.${FSNAME}-MDT0000-mdc-*.timeouts | grep "portal 12"
1881 CUR=$(lctl get_param -n mdc.${FSNAME}-MDT0000-mdc-*.timeouts | awk '/portal 12/ {print $5}')
1882 WORST=$(lctl get_param -n mdc.${FSNAME}-MDT0000-mdc-*.timeouts | awk '/portal 12/ {print $7}')
1883 echo "Current MDT timeout $CUR, worst $WORST"
1884 [ $CUR -lt $WORST ] || error "Current $CUR should be less than worst $WORST"
1886 run_test 66a "AT: verify MDT service time adjusts with no early replies"
1888 test_66b() #bug 3055
1890 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1892 at_start || return 0
1893 ORIG=$(lctl get_param -n mdc.${FSNAME}-MDT0000*.timeouts |
1894 awk '/network/ {print $4}')
1895 $LCTL set_param fail_val=$(($ORIG + 5))
1896 #define OBD_FAIL_PTLRPC_PAUSE_REP 0x50c
1897 $LCTL set_param fail_loc=0x50c
1898 ls $DIR/$tfile > /dev/null 2>&1
1899 $LCTL set_param fail_loc=0
1900 CUR=$(lctl get_param -n mdc.${FSNAME}-MDT0000*.timeouts |
1901 awk '/network/ {print $4}')
1902 WORST=$(lctl get_param -n mdc.${FSNAME}-MDT0000*.timeouts |
1903 awk '/network/ {print $6}')
1904 echo "network timeout orig $ORIG, cur $CUR, worst $WORST"
1905 [ $WORST -gt $ORIG ] ||
1906 error "Worst $WORST should be worse than orig $ORIG"
1908 run_test 66b "AT: verify net latency adjusts"
1910 test_67a() #bug 3055
1912 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1914 at_start || return 0
1915 CONN1=$(lctl get_param -n osc.*.stats | awk '/_connect/ {total+=$2} END {print total}')
1916 # sleeping threads may drive values above this
1917 do_facet ost1 "$LCTL set_param fail_val=400"
1918 #define OBD_FAIL_PTLRPC_PAUSE_REQ 0x50a
1919 do_facet ost1 "$LCTL set_param fail_loc=0x50a"
1920 createmany -o $DIR/$tfile 20 > /dev/null
1921 unlinkmany $DIR/$tfile 20 > /dev/null
1922 do_facet ost1 "$LCTL set_param fail_loc=0"
1923 CONN2=$(lctl get_param -n osc.*.stats | awk '/_connect/ {total+=$2} END {print total}')
1924 ATTEMPTS=$(($CONN2 - $CONN1))
1925 echo "$ATTEMPTS osc reconnect attempts on gradual slow"
1926 [ $ATTEMPTS -gt 0 ] &&
1927 error_ignore bz13721 "AT should have prevented reconnect"
1930 run_test 67a "AT: verify slow request processing doesn't induce reconnects"
1932 test_67b() #bug 3055
1934 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1936 at_start || return 0
1937 CONN1=$(lctl get_param -n osc.*.stats | awk '/_connect/ {total+=$2} END {print total}')
1939 # exhaust precreations on ost1
1940 local OST=$(ostname_from_index 0)
1941 local mdtosc=$(get_mdtosc_proc_path mds $OST)
1942 local last_id=$(do_facet $SINGLEMDS lctl get_param -n \
1943 osc.$mdtosc.prealloc_last_id)
1944 local next_id=$(do_facet $SINGLEMDS lctl get_param -n \
1945 osc.$mdtosc.prealloc_next_id)
1947 mkdir -p $DIR/$tdir/${OST} || error "mkdir $DIR/$tdir/${OST} failed"
1948 $SETSTRIPE -i 0 -c 1 $DIR/$tdir/${OST} || error "$SETSTRIPE failed"
1949 echo "Creating to objid $last_id on ost $OST..."
1950 #define OBD_FAIL_OST_PAUSE_CREATE 0x223
1951 do_facet ost1 "$LCTL set_param fail_val=20000"
1952 do_facet ost1 "$LCTL set_param fail_loc=0x80000223"
1953 createmany -o $DIR/$tdir/${OST}/f $next_id $((last_id - next_id + 2))
1956 do_facet ost1 "lctl get_param -n ost.OSS.ost_create.timeouts"
1958 CONN2=$(lctl get_param -n osc.*.stats | awk '/_connect/ {total+=$2} END {print total}')
1959 ATTEMPTS=$(($CONN2 - $CONN1))
1960 echo "$ATTEMPTS osc reconnect attempts on instant slow"
1961 # do it again; should not timeout
1962 do_facet ost1 "$LCTL set_param fail_loc=0x80000223"
1963 cp /etc/profile $DIR/$tfile || error "cp failed"
1964 do_facet ost1 "$LCTL set_param fail_loc=0"
1966 do_facet ost1 "lctl get_param -n ost.OSS.ost_create.timeouts"
1967 CONN3=$(lctl get_param -n osc.*.stats | awk '/_connect/ {total+=$2} END {print total}')
1968 ATTEMPTS=$(($CONN3 - $CONN2))
1969 echo "$ATTEMPTS osc reconnect attempts on 2nd slow"
1970 [ $ATTEMPTS -gt 0 ] && error "AT should have prevented reconnect"
1973 run_test 67b "AT: verify instant slowdown doesn't induce reconnects"
1975 test_68 () #bug 13813
1977 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1979 at_start || return 0
1980 local ldlm_enqueue_min=$(find /sys -name ldlm_enqueue_min)
1981 [ -z "$ldlm_enqueue_min" ] && skip "missing /sys/.../ldlm_enqueue_min" && return 0
1982 local ldlm_enqueue_min_r=$(do_facet ost1 "find /sys -name ldlm_enqueue_min")
1983 [ -z "$ldlm_enqueue_min_r" ] && skip "missing /sys/.../ldlm_enqueue_min in the ost1" && return 0
1984 local ENQ_MIN=$(cat $ldlm_enqueue_min)
1985 local ENQ_MIN_R=$(do_facet ost1 "cat $ldlm_enqueue_min_r")
1986 echo $TIMEOUT >> $ldlm_enqueue_min
1987 do_facet ost1 "echo $TIMEOUT >> $ldlm_enqueue_min_r"
1989 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
1990 $SETSTRIPE --stripe-index=0 -c 1 $DIR/$tdir ||
1991 error "$SETSTRIPE failed for $DIR/$tdir"
1992 #define OBD_FAIL_LDLM_PAUSE_CANCEL 0x312
1993 $LCTL set_param fail_val=$(($TIMEOUT - 1))
1994 $LCTL set_param fail_loc=0x80000312
1995 cp /etc/profile $DIR/$tdir/${tfile}_1 || error "1st cp failed $?"
1996 $LCTL set_param fail_val=$((TIMEOUT * 5 / 4))
1997 $LCTL set_param fail_loc=0x80000312
1998 cp /etc/profile $DIR/$tdir/${tfile}_2 || error "2nd cp failed $?"
1999 $LCTL set_param fail_loc=0
2001 echo $ENQ_MIN >> $ldlm_enqueue_min
2002 do_facet ost1 "echo $ENQ_MIN_R >> $ldlm_enqueue_min_r"
2006 run_test 68 "AT: verify slowing locks"
2009 # end of AT tests includes above lines
2011 # start multi-client tests
2013 [ -z "$CLIENTS" ] &&
2014 { skip "Need two or more clients." && return; }
2015 [ $CLIENTCOUNT -lt 2 ] &&
2016 { skip "Need two or more clients, have $CLIENTCOUNT" && return; }
2018 echo "mount clients $CLIENTS ..."
2019 zconf_mount_clients $CLIENTS $MOUNT
2021 local clients=${CLIENTS//,/ }
2022 echo "Write/read files on $DIR ; clients $CLIENTS ... "
2023 for CLIENT in $clients; do
2024 do_node $CLIENT dd bs=1M count=10 if=/dev/zero \
2025 of=$DIR/${tfile}_${CLIENT} 2>/dev/null ||
2026 error "dd failed on $CLIENT"
2029 local prev_client=$(echo $clients | sed 's/^.* \(.\+\)$/\1/')
2030 for C in ${CLIENTS//,/ }; do
2031 do_node $prev_client dd if=$DIR/${tfile}_${C} \
2032 of=/dev/null 2>/dev/null ||
2033 error "dd if=$DIR/${tfile}_${C} failed on $prev_client"
2039 run_test 70a "check multi client t-f"
2041 check_for_process () {
2046 killall_process $clients "$prog" -0
2050 local clients=${CLIENTS:-$HOSTNAME}
2052 zconf_mount_clients $clients $MOUNT
2055 [ "$SLOW" = "no" ] && duration=120
2056 # set duration to 900 because it takes some time to boot node
2057 [ "$FAILURE_MODE" = HARD ] && duration=900
2060 local start_ts=$(date +%s)
2061 local cmd="rundbench 1 -t $duration"
2063 if [ $MDSCOUNT -ge 2 ]; then
2064 test_mkdir -p -c$MDSCOUNT $DIR/$tdir
2065 $LFS setdirstripe -D -c$MDSCOUNT $DIR/$tdir
2067 do_nodesv $clients "set -x; MISSING_DBENCH_OK=$MISSING_DBENCH_OK \
2068 PATH=\$PATH:$LUSTRE/utils:$LUSTRE/tests/:$DBENCH_LIB \
2069 DBENCH_LIB=$DBENCH_LIB TESTSUITE=$TESTSUITE TESTNAME=$TESTNAME \
2070 MOUNT=$MOUNT DIR=$DIR/$tdir/\\\$(hostname) LCTL=$LCTL $cmd" &
2073 #LU-1897 wait for all dbench copies to start
2074 while ! check_for_process $clients dbench; do
2075 elapsed=$(($(date +%s) - start_ts))
2076 if [ $elapsed -gt $duration ]; then
2077 killall_process $clients dbench
2078 error "dbench failed to start on $clients!"
2083 log "Started rundbench load pid=$pid ..."
2085 elapsed=$(($(date +%s) - start_ts))
2086 local num_failovers=0
2088 while [ $elapsed -lt $duration ]; do
2089 if ! check_for_process $clients dbench; then
2090 error_noexit "dbench stopped on some of $clients!"
2091 killall_process $clients dbench
2095 replay_barrier mds$fail_index
2096 sleep 1 # give clients a time to do operations
2097 # Increment the number of failovers
2098 num_failovers=$((num_failovers+1))
2099 log "$TESTNAME fail mds$fail_index $num_failovers times"
2101 elapsed=$(($(date +%s) - start_ts))
2102 if [ $fail_index -ge $MDSCOUNT ]; then
2105 fail_index=$((fail_index+1))
2109 wait $pid || error "rundbench load on $clients failed!"
2111 run_test 70b "dbench ${MDSCOUNT}mdts recovery; $CLIENTCOUNT clients"
2112 # end multi-client tests
2117 local monitor_pid=$3
2119 local start_ts=$(date +%s)
2120 local num_failovers=0
2123 elapsed=$(($(date +%s) - start_ts))
2124 while [ $elapsed -lt $duration ]; do
2125 fail_index=$((RANDOM%max_index+1))
2126 kill -0 $monitor_pid ||
2127 error "$monitor_pid stopped"
2129 replay_barrier mds$fail_index
2131 # Increment the number of failovers
2132 num_failovers=$((num_failovers+1))
2133 log "$TESTNAME fail mds$fail_index $num_failovers times"
2135 elapsed=$(($(date +%s) - start_ts))
2141 rm -f $DIR/replay-single.70c.lck
2146 local clients=${CLIENTS:-$HOSTNAME}
2149 zconf_mount_clients $clients $MOUNT
2152 [ "$SLOW" = "no" ] && duration=180
2153 # set duration to 900 because it takes some time to boot node
2154 [ "$FAILURE_MODE" = HARD ] && duration=600
2157 local start_ts=$(date +%s)
2159 trap cleanup_70c EXIT
2161 while [ ! -e $DIR/replay-single.70c.lck ]; do
2162 test_mkdir -p -c$MDSCOUNT $DIR/$tdir || break
2163 if [ $MDSCOUNT -ge 2 ]; then
2164 $LFS setdirstripe -D -c$MDSCOUNT $DIR/$tdir ||
2165 error "set default dirstripe failed"
2167 cd $DIR/$tdir || break
2168 tar cf - /etc | tar xf - || error "tar failed in loop"
2172 echo "Started tar $tar_70c_pid"
2174 random_fail_mdt $MDSCOUNT $duration $tar_70c_pid
2175 kill -0 $tar_70c_pid || error "tar $tar_70c_pid stopped"
2177 touch $DIR/replay-single.70c.lck
2178 wait $tar_70c_pid || error "$?: tar failed"
2183 run_test 70c "tar ${MDSCOUNT}mdts recovery"
2187 kill -9 $mkdir_70d_pid
2191 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2192 local clients=${CLIENTS:-$HOSTNAME}
2195 zconf_mount_clients $clients $MOUNT
2198 [ "$SLOW" = "no" ] && duration=180
2199 # set duration to 900 because it takes some time to boot node
2200 [ "$FAILURE_MODE" = HARD ] && duration=900
2205 local start_ts=$(date +%s)
2207 trap cleanup_70d EXIT
2210 $LFS mkdir -i0 -c2 $DIR/$tdir/test || {
2214 $LFS mkdir -i1 -c2 $DIR/$tdir/test1 || {
2219 touch $DIR/$tdir/test/a || {
2223 mkdir $DIR/$tdir/test/b || {
2227 rm -rf $DIR/$tdir/test || {
2232 touch $DIR/$tdir/test1/a || {
2236 mkdir $DIR/$tdir/test1/b || {
2241 rm -rf $DIR/$tdir/test1 || {
2248 echo "Started $mkdir_70d_pid"
2250 random_fail_mdt $MDSCOUNT $duration $mkdir_70d_pid
2251 kill -0 $mkdir_70d_pid || error "mkdir/rmdir $mkdir_70d_pid stopped"
2256 run_test 70d "mkdir/rmdir striped dir ${MDSCOUNT}mdts recovery"
2260 kill -9 $rename_70e_pid
2264 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2265 local clients=${CLIENTS:-$HOSTNAME}
2268 echo ha > /proc/sys/lnet/debug
2269 zconf_mount_clients $clients $MOUNT
2272 [ "$SLOW" = "no" ] && duration=180
2273 # set duration to 900 because it takes some time to boot node
2274 [ "$FAILURE_MODE" = HARD ] && duration=900
2277 $LFS mkdir -i0 $DIR/$tdir/test_0
2278 $LFS mkdir -i0 $DIR/$tdir/test_1
2279 touch $DIR/$tdir/test_0/a
2280 touch $DIR/$tdir/test_1/b
2281 trap cleanup_70e EXIT
2284 mrename $DIR/$tdir/test_0/a $DIR/$tdir/test_1/b > \
2290 checkstat $DIR/$tdir/test_0/a && {
2291 echo "a still exists"
2295 checkstat $DIR/$tdir/test_1/b || {
2296 echo "b still exists"
2300 touch $DIR/$tdir/test_0/a || {
2301 echo "touch a fails"
2305 mrename $DIR/$tdir/test_1/b $DIR/$tdir/test_0/a > \
2313 echo "Started $rename_70e_pid"
2315 random_fail_mdt 2 $duration $rename_70e_pid
2316 kill -0 $rename_70e_pid || error "rename $rename_70e_pid stopped"
2321 run_test 70e "rename cross-MDT with random fails"
2323 test_70f_write_and_read(){
2328 echo "Write/read files in: '$DIR/$tdir', clients: '$CLIENTS' ..."
2329 for client in ${CLIENTS//,/ }; do
2330 [ -f $stopflag ] || return
2332 local tgtfile=$DIR/$tdir/$tfile.$client
2333 do_node $client dd $DD_OPTS bs=1M count=10 if=$srcfile \
2334 of=$tgtfile 2>/dev/null ||
2335 error "dd $DD_OPTS bs=1M count=10 if=$srcfile " \
2336 "of=$tgtfile failed on $client, rc=$?"
2339 local prev_client=$(echo ${CLIENTS//,/ } | awk '{ print $NF }')
2342 for client in ${CLIENTS//,/ }; do
2343 [ -f $stopflag ] || return
2345 # flush client cache in case test is running on only one client
2346 # do_node $client cancel_lru_locks osc
2347 do_node $client $LCTL set_param ldlm.namespaces.*.lru_size=clear
2349 tgtfile=$DIR/$tdir/$tfile.$client
2350 local md5=$(do_node $prev_client "md5sum $tgtfile")
2351 [ ${checksum[$index]// */} = ${md5// */} ] ||
2352 error "$tgtfile: checksum doesn't match on $prev_client"
2353 index=$((index + 1))
2363 mkdir -p $DIR/$tdir || error "cannot create $DIR/$tdir directory"
2364 $SETSTRIPE -c -1 $DIR/$tdir || error "cannot $SETSTRIPE $DIR/$tdir"
2367 while [ -f $stopflag ]; do
2368 test_70f_write_and_read $srcfile $stopflag
2369 # use direct IO and buffer cache in turns if loop
2370 [ -n "$DD_OPTS" ] && DD_OPTS="" || DD_OPTS="oflag=direct"
2374 test_70f_cleanup() {
2376 rm -f $TMP/$tfile.stop
2377 do_nodes $CLIENTS rm -f $TMP/$tfile
2378 rm -f $DIR/$tdir/$tfile.*
2382 # [ x$ost1failover_HOST = x$ost_HOST ] &&
2383 # { skip "Failover host not defined" && return; }
2384 # [ -z "$CLIENTS" ] &&
2385 # { skip "CLIENTS are not specified." && return; }
2386 # [ $CLIENTCOUNT -lt 2 ] &&
2387 # { skip "Need 2 or more clients, have $CLIENTCOUNT" && return; }
2389 [[ $(lustre_version_code ost1) -lt $(version_code 2.9.53) ]] &&
2390 skip "Need server version at least 2.9.53" && return
2392 echo "mount clients $CLIENTS ..."
2393 zconf_mount_clients $CLIENTS $MOUNT
2395 local srcfile=$TMP/$tfile
2399 trap test_70f_cleanup EXIT
2400 # create a different source file local to each client node so we can
2401 # detect if the file wasn't written out properly after failover
2402 do_nodes $CLIENTS dd bs=1M count=10 if=/dev/urandom of=$srcfile \
2403 2>/dev/null || error "can't create $srcfile on $CLIENTS"
2404 for client in ${CLIENTS//,/ }; do
2405 checksum[$index]=$(do_node $client "md5sum $srcfile")
2406 index=$((index + 1))
2410 [ "$SLOW" = "no" ] && duration=60
2411 # set duration to 900 because it takes some time to boot node
2412 [ "$FAILURE_MODE" = HARD ] && duration=900
2414 local stopflag=$TMP/$tfile.stop
2415 test_70f_loop $srcfile $stopflag &
2419 local num_failovers=0
2420 local start_ts=$SECONDS
2421 while [ $elapsed -lt $duration ]; do
2425 num_failovers=$((num_failovers + 1))
2426 log "$TESTNAME failing OST $num_failovers times"
2429 elapsed=$((SECONDS - start_ts))
2436 run_test 70f "OSS O_DIRECT recovery with $CLIENTCOUNT clients"
2440 kill -9 $mkdir_71a_pid
2443 random_double_fail_mdt() {
2446 local monitor_pid=$3
2448 local start_ts=$(date +%s)
2449 local num_failovers=0
2453 elapsed=$(($(date +%s) - start_ts))
2454 while [ $elapsed -lt $duration ]; do
2455 fail_index=$((RANDOM%max_index + 1))
2456 if [ $fail_index -eq $max_index ]; then
2459 second_index=$((fail_index + 1))
2461 kill -0 $monitor_pid ||
2462 error "$monitor_pid stopped"
2464 replay_barrier mds$fail_index
2465 replay_barrier mds$second_index
2467 # Increment the number of failovers
2468 num_failovers=$((num_failovers+1))
2469 log "fail mds$fail_index mds$second_index $num_failovers times"
2470 fail mds${fail_index},mds${second_index}
2471 elapsed=$(($(date +%s) - start_ts))
2476 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2477 local clients=${CLIENTS:-$HOSTNAME}
2480 zconf_mount_clients $clients $MOUNT
2483 [ "$SLOW" = "no" ] && duration=180
2484 # set duration to 900 because it takes some time to boot node
2485 [ "$FAILURE_MODE" = HARD ] && duration=900
2490 local start_ts=$(date +%s)
2492 trap cleanup_71a EXIT
2495 $LFS mkdir -i0 -c2 $DIR/$tdir/test
2496 rmdir $DIR/$tdir/test
2500 echo "Started $mkdir_71a_pid"
2502 random_double_fail_mdt 2 $duration $mkdir_71a_pid
2503 kill -0 $mkdir_71a_pid || error "mkdir/rmdir $mkdir_71a_pid stopped"
2508 run_test 71a "mkdir/rmdir striped dir with 2 mdts recovery"
2511 multiop_bg_pause $DIR/$tfile O_tSc ||
2512 error "multiop_bg_pause $DIR/$tfile failed"
2516 replay_barrier $SINGLEMDS
2517 #define OBD_FAIL_LDLM_ENQUEUE_NET 0x302
2518 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000302"
2521 wait $pid || error "multiop pid failed"
2522 [ -e $DIR/$tfile ] && error "file $DIR/$tfile should not exist"
2525 run_test 73a "open(O_CREAT), unlink, replay, reconnect before open replay, close"
2528 multiop_bg_pause $DIR/$tfile O_tSc ||
2529 error "multiop_bg_pause $DIR/$tfile failed"
2533 replay_barrier $SINGLEMDS
2534 #define OBD_FAIL_LDLM_REPLY 0x30c
2535 do_facet $SINGLEMDS "lctl set_param fail_loc=0x8000030c"
2538 wait $pid || error "multiop pid failed"
2539 [ -e $DIR/$tfile ] && error "file $DIR/$tfile should not exist"
2542 run_test 73b "open(O_CREAT), unlink, replay, reconnect at open_replay reply, close"
2546 local clients=${CLIENTS:-$HOSTNAME}
2548 zconf_umount_clients $clients $MOUNT
2550 facet_failover $SINGLEMDS
2551 zconf_mount_clients $clients $MOUNT
2553 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
2554 rm $DIR/$tfile || error "rm $DIR/$tfile failed"
2555 clients_up || error "client evicted: $?"
2558 run_test 74 "Ensure applications don't fail waiting for OST recovery"
2560 remote_dir_check_80() {
2565 diridx=$($GETSTRIPE -M $remote_dir) ||
2566 error "$GETSTRIPE -M $remote_dir failed"
2567 [ $diridx -eq $MDTIDX ] || error "$diridx != $MDTIDX"
2569 createmany -o $remote_dir/f-%d 20 || error "creation failed"
2570 fileidx=$($GETSTRIPE -M $remote_dir/f-1) ||
2571 error "$GETSTRIPE -M $remote_dir/f-1 failed"
2572 [ $fileidx -eq $MDTIDX ] || error "$fileidx != $MDTIDX"
2578 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2579 ([ $FAILURE_MODE == "HARD" ] &&
2580 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
2581 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
2585 local remote_dir=$DIR/$tdir/remote_dir
2587 mkdir -p $DIR/$tdir || error "mkdir $DIR/$tdir failed"
2588 #define OBD_FAIL_OUT_UPDATE_NET_REP 0x1701
2589 do_facet mds${MDTIDX} lctl set_param fail_loc=0x1701
2590 $LFS mkdir -i $MDTIDX $remote_dir &
2596 wait $CLIENT_PID || error "remote creation failed"
2598 remote_dir_check_80 || error "remote dir check failed"
2599 rm -rf $DIR/$tdir || error "rmdir failed"
2603 run_test 80a "DNE: create remote dir, drop update rep from MDT0, fail MDT0"
2606 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2607 ([ $FAILURE_MODE == "HARD" ] &&
2608 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
2609 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
2613 local remote_dir=$DIR/$tdir/remote_dir
2615 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
2616 #define OBD_FAIL_UPDATE_OBJ_NET_REP 0x1701
2617 do_facet mds${MDTIDX} lctl set_param fail_loc=0x1701
2618 $LFS mkdir -i $MDTIDX $remote_dir &
2623 fail mds$((MDTIDX + 1))
2625 wait $CLIENT_PID || error "remote creation failed"
2627 remote_dir_check_80 || error "remote dir check failed"
2628 rm -rf $DIR/$tdir || error "rmdir failed"
2632 run_test 80b "DNE: create remote dir, drop update rep from MDT0, fail MDT1"
2635 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2636 ([ $FAILURE_MODE == "HARD" ] &&
2637 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
2638 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
2642 local remote_dir=$DIR/$tdir/remote_dir
2644 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
2645 #define OBD_FAIL_UPDATE_OBJ_NET_REP 0x1701
2646 do_facet mds${MDTIDX} lctl set_param fail_loc=0x1701
2647 $LFS mkdir -i $MDTIDX $remote_dir &
2653 fail mds$((MDTIDX + 1))
2655 wait $CLIENT_PID || error "remote creation failed"
2657 remote_dir_check_80 || error "remote dir check failed"
2658 rm -rf $DIR/$tdir || error "rmdir failed"
2662 run_test 80c "DNE: create remote dir, drop update rep from MDT1, fail MDT[0,1]"
2665 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2667 local remote_dir=$DIR/$tdir/remote_dir
2669 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
2670 #define OBD_FAIL_UPDATE_OBJ_NET_REP 0x1701
2671 do_facet mds${MDTIDX} lctl set_param fail_loc=0x1701
2672 $LFS mkdir -i $MDTIDX $remote_dir &
2675 # sleep 3 seconds to make sure MDTs are failed after
2676 # lfs mkdir -i has finished on all of MDTs.
2681 fail mds${MDTIDX},mds$((MDTIDX + 1))
2683 wait $CLIENT_PID || error "remote creation failed"
2685 remote_dir_check_80 || error "remote dir check failed"
2686 rm -rf $DIR/$tdir || error "rmdir failed"
2690 run_test 80d "DNE: create remote dir, drop update rep from MDT1, fail 2 MDTs"
2693 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2694 ([ $FAILURE_MODE == "HARD" ] &&
2695 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
2696 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
2700 local remote_dir=$DIR/$tdir/remote_dir
2702 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
2703 # OBD_FAIL_MDS_REINT_NET_REP 0x119
2704 do_facet mds$((MDTIDX + 1)) lctl set_param fail_loc=0x119
2705 $LFS mkdir -i $MDTIDX $remote_dir &
2708 # sleep 3 seconds to make sure MDTs are failed after
2709 # lfs mkdir -i has finished on all of MDTs.
2715 wait $CLIENT_PID || error "remote creation failed"
2717 remote_dir_check_80 || error "remote dir check failed"
2718 rm -rf $DIR/$tdir || error "rmdir failed"
2722 run_test 80e "DNE: create remote dir, drop MDT1 rep, fail MDT0"
2725 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2726 ([ $FAILURE_MODE == "HARD" ] &&
2727 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
2728 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
2731 local remote_dir=$DIR/$tdir/remote_dir
2733 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
2734 # OBD_FAIL_MDS_REINT_NET_REP 0x119
2735 do_facet mds$((MDTIDX + 1)) lctl set_param fail_loc=0x119
2736 $LFS mkdir -i $MDTIDX $remote_dir &
2740 fail mds$((MDTIDX + 1))
2742 wait $CLIENT_PID || error "remote creation failed"
2744 remote_dir_check_80 || error "remote dir check failed"
2745 rm -rf $DIR/$tdir || error "rmdir failed"
2749 run_test 80f "DNE: create remote dir, drop MDT1 rep, fail MDT1"
2752 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2753 ([ $FAILURE_MODE == "HARD" ] &&
2754 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
2755 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
2759 local remote_dir=$DIR/$tdir/remote_dir
2761 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
2762 # OBD_FAIL_MDS_REINT_NET_REP 0x119
2763 do_facet mds$((MDTIDX + 1)) lctl set_param fail_loc=0x119
2764 $LFS mkdir -i $MDTIDX $remote_dir &
2767 # sleep 3 seconds to make sure MDTs are failed after
2768 # lfs mkdir -i has finished on all of MDTs.
2774 fail mds$((MDTIDX + 1))
2776 wait $CLIENT_PID || error "remote creation failed"
2778 remote_dir_check_80 || error "remote dir check failed"
2779 rm -rf $DIR/$tdir || error "rmdir failed"
2783 run_test 80g "DNE: create remote dir, drop MDT1 rep, fail MDT0, then MDT1"
2786 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2788 local remote_dir=$DIR/$tdir/remote_dir
2790 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
2791 # OBD_FAIL_MDS_REINT_NET_REP 0x119
2792 do_facet mds$((MDTIDX + 1)) lctl set_param fail_loc=0x119
2793 $LFS mkdir -i $MDTIDX $remote_dir &
2796 # sleep 3 seconds to make sure MDTs are failed after
2797 # lfs mkdir -i has finished on all of MDTs.
2802 fail mds${MDTIDX},mds$((MDTIDX + 1))
2804 wait $CLIENT_PID || error "remote dir creation failed"
2806 remote_dir_check_80 || error "remote dir check failed"
2807 rm -rf $DIR/$tdir || error "rmdir failed"
2811 run_test 80h "DNE: create remote dir, drop MDT1 rep, fail 2 MDTs"
2814 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2815 ([ $FAILURE_MODE == "HARD" ] &&
2816 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
2817 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
2821 local remote_dir=$DIR/$tdir/remote_dir
2823 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
2824 $LFS mkdir -i $MDTIDX $remote_dir || error "lfs mkdir failed"
2826 touch $remote_dir || error "touch $remote_dir failed"
2827 # OBD_FAIL_OBJ_UPDATE_NET_REP 0x1701
2828 do_facet mds${MDTIDX} lctl set_param fail_loc=0x1701
2833 fail mds$((MDTIDX + 1))
2835 wait $CLIENT_PID || error "rm remote dir failed"
2837 stat $remote_dir &>/dev/null && error "$remote_dir still exist!"
2839 rm -rf $DIR/$tdir || error "rmdir failed"
2843 run_test 81a "DNE: unlink remote dir, drop MDT0 update rep, fail MDT1"
2846 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2847 ([ $FAILURE_MODE == "HARD" ] &&
2848 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
2849 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
2852 local remote_dir=$DIR/$tdir/remote_dir
2854 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
2855 $LFS mkdir -i $MDTIDX $remote_dir || error "lfs mkdir failed"
2857 # OBD_FAIL_OBJ_UPDATE_NET_REP 0x1701
2858 do_facet mds${MDTIDX} lctl set_param fail_loc=0x1701
2865 wait $CLIENT_PID || error "rm remote dir failed"
2867 stat $remote_dir &>/dev/null && error "$remote_dir still exist!"
2869 rm -rf $DIR/$tdir || error "rmdir failed"
2873 run_test 81b "DNE: unlink remote dir, drop MDT0 update reply, fail MDT0"
2876 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2877 ([ $FAILURE_MODE == "HARD" ] &&
2878 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
2879 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
2883 local remote_dir=$DIR/$tdir/remote_dir
2885 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
2886 $LFS mkdir -i $MDTIDX $remote_dir || error "lfs mkdir failed"
2888 # OBD_FAIL_OBJ_UPDATE_NET_REP 0x1701
2889 do_facet mds${MDTIDX} lctl set_param fail_loc=0x1701
2896 fail mds$((MDTIDX + 1))
2898 wait $CLIENT_PID || error "rm remote dir failed"
2900 stat $remote_dir &>/dev/null && error "$remote_dir still exist!"
2902 rm -rf $DIR/$tdir || error "rmdir failed"
2906 run_test 81c "DNE: unlink remote dir, drop MDT0 update reply, fail MDT0,MDT1"
2909 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2911 local remote_dir=$DIR/$tdir/remote_dir
2913 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
2914 $LFS mkdir -i $MDTIDX $remote_dir || error "lfs mkdir failed"
2916 # OBD_FAIL_OBJ_UPDATE_NET_REP 0x1701
2917 do_facet mds${MDTIDX} lctl set_param fail_loc=0x1701
2923 fail mds${MDTIDX},mds$((MDTIDX + 1))
2925 wait $CLIENT_PID || error "rm remote dir failed"
2927 stat $remote_dir &>/dev/null && error "$remote_dir still exist!"
2929 rm -rf $DIR/$tdir || error "rmdir failed"
2933 run_test 81d "DNE: unlink remote dir, drop MDT0 update reply, fail 2 MDTs"
2936 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2937 ([ $FAILURE_MODE == "HARD" ] &&
2938 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
2939 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
2943 local remote_dir=$DIR/$tdir/remote_dir
2945 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
2946 $LFS mkdir -i $MDTIDX $remote_dir || error "lfs mkdir failed"
2948 # OBD_FAIL_MDS_REINT_NET_REP 0x119
2949 do_facet mds$((MDTIDX + 1)) lctl set_param fail_loc=0x119
2952 do_facet mds$((MDTIDX + 1)) lctl set_param fail_loc=0
2957 wait $CLIENT_PID || error "rm remote dir failed"
2959 stat $remote_dir &>/dev/null && error "$remote_dir still exist!"
2961 rm -rf $DIR/$tdir || error "rmdir failed"
2965 run_test 81e "DNE: unlink remote dir, drop MDT1 req reply, fail MDT0"
2968 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2969 ([ $FAILURE_MODE == "HARD" ] &&
2970 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
2971 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
2975 local remote_dir=$DIR/$tdir/remote_dir
2977 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
2978 $LFS mkdir -i $MDTIDX $remote_dir || error "lfs mkdir failed"
2980 # OBD_FAIL_MDS_REINT_NET_REP 0x119
2981 do_facet mds$((MDTIDX + 1)) lctl set_param fail_loc=0x119
2986 fail mds$((MDTIDX + 1))
2988 wait $CLIENT_PID || error "rm remote dir failed"
2990 stat $remote_dir &>/dev/null && error "$remote_dir still exist!"
2992 rm -rf $DIR/$tdir || error "rmdir failed"
2996 run_test 81f "DNE: unlink remote dir, drop MDT1 req reply, fail MDT1"
2999 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
3000 ([ $FAILURE_MODE == "HARD" ] &&
3001 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
3002 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
3006 local remote_dir=$DIR/$tdir/remote_dir
3008 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
3009 $LFS mkdir -i $MDTIDX $remote_dir || error "lfs mkdir failed"
3011 # OBD_FAIL_MDS_REINT_NET_REP 0x119
3012 do_facet mds$((MDTIDX + 1)) lctl set_param fail_loc=0x119
3019 fail mds$((MDTIDX + 1))
3021 wait $CLIENT_PID || error "rm remote dir failed"
3023 stat $remote_dir &>/dev/null && error "$remote_dir still exist!"
3025 rm -rf $DIR/$tdir || error "rmdir failed"
3029 run_test 81g "DNE: unlink remote dir, drop req reply, fail M0, then M1"
3032 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
3034 local remote_dir=$DIR/$tdir/remote_dir
3036 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
3037 $LFS mkdir -i $MDTIDX $remote_dir || error "lfs mkdir failed"
3039 # OBD_FAIL_MDS_REINT_NET_REP 0x119
3040 do_facet mds$((MDTIDX + 1)) lctl set_param fail_loc=0x119
3046 fail mds${MDTIDX},mds$((MDTIDX + 1))
3048 wait $CLIENT_PID || error "rm remote dir failed"
3050 stat $remote_dir &>/dev/null && error "$remote_dir still exist!"
3052 rm -rf $DIR/$tdir || error "rmdir failed"
3056 run_test 81h "DNE: unlink remote dir, drop request reply, fail 2 MDTs"
3059 #define OBD_FAIL_MDS_OPEN_WAIT_CREATE 0x144
3060 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000144"
3061 createmany -o $DIR/$tfile- 1 &
3065 client_up || client_up || true # reconnect
3067 run_test 84a "stale open during export disconnect"
3069 test_85a() { #bug 16774
3070 lctl set_param -n ldlm.cancel_unused_locks_before_replay "1"
3072 for i in $(seq 100); do
3073 echo "tag-$i" > $DIR/$tfile-$i
3074 grep -q "tag-$i" $DIR/$tfile-$i || error "f2-$i"
3077 lov_id=$(lctl dl | grep "clilov")
3078 addr=$(echo $lov_id | awk '{print $4}' | awk -F '-' '{print $NF}')
3079 count=$(lctl get_param -n \
3080 ldlm.namespaces.*MDT0000*$addr.lock_unused_count)
3081 echo "before recovery: unused locks count = $count"
3085 count2=$(lctl get_param -n \
3086 ldlm.namespaces.*MDT0000*$addr.lock_unused_count)
3087 echo "after recovery: unused locks count = $count2"
3089 if [ $count2 -ge $count ]; then
3090 error "unused locks are not canceled"
3093 run_test 85a "check the cancellation of unused locks during recovery(IBITS)"
3095 test_85b() { #bug 16774
3096 lctl set_param -n ldlm.cancel_unused_locks_before_replay "1"
3098 if ! combined_mgs_mds ; then
3102 create_pool $FSNAME.$TESTNAME ||
3103 error "unable to create pool $TESTNAME"
3104 do_facet mgs $LCTL pool_add $FSNAME.$TESTNAME $FSNAME-OST0000 ||
3105 error "unable to add pool $TESTNAME"
3107 $SETSTRIPE -c 1 -p $FSNAME.$TESTNAME $DIR
3109 for i in $(seq 100); do
3110 dd if=/dev/urandom of=$DIR/$tfile-$i bs=4096 \
3111 count=32 >/dev/null 2>&1
3114 cancel_lru_locks osc
3116 for i in $(seq 100); do
3117 dd if=$DIR/$tfile-$i of=/dev/null bs=4096 \
3118 count=32 >/dev/null 2>&1
3121 lov_id=$(lctl dl | grep "clilov")
3122 addr=$(echo $lov_id | awk '{print $4}' | awk -F '-' '{print $NF}')
3123 count=$(lctl get_param -n \
3124 ldlm.namespaces.*OST0000*$addr.lock_unused_count)
3125 echo "before recovery: unused locks count = $count"
3126 [ $count -ne 0 ] || error "unused locks ($count) should be zero"
3130 count2=$(lctl get_param \
3131 -n ldlm.namespaces.*OST0000*$addr.lock_unused_count)
3132 echo "after recovery: unused locks count = $count2"
3134 do_facet mgs $LCTL pool_remove $FSNAME.$TESTNAME $FSNAME-OST0000 ||
3135 error "unable to remove pool $TESTNAME"
3136 do_facet mgs $LCTL pool_destroy $FSNAME.$TESTNAME ||
3137 error "unable to destroy the pool $TESTNAME"
3139 if ! combined_mgs_mds ; then
3143 if [ $count2 -ge $count ]; then
3144 error "unused locks are not canceled"
3147 run_test 85b "check the cancellation of unused locks during recovery(EXTENT)"
3150 local clients=${CLIENTS:-$HOSTNAME}
3152 zconf_umount_clients $clients $MOUNT
3153 do_facet $SINGLEMDS lctl set_param mdt.${FSNAME}-MDT*.exports.clear=0
3154 remount_facet $SINGLEMDS
3155 zconf_mount_clients $clients $MOUNT
3157 run_test 86 "umount server after clear nid_stats should not hit LBUG"
3160 do_facet ost1 "lctl set_param -n obdfilter.${ost1_svc}.sync_journal 0"
3163 $SETSTRIPE -i 0 -c 1 $DIR/$tfile
3164 dd if=/dev/urandom of=$DIR/$tfile bs=1024k count=8 ||
3165 error "dd to $DIR/$tfile failed"
3166 cksum=$(md5sum $DIR/$tfile | awk '{print $1}')
3167 cancel_lru_locks osc
3169 dd if=$DIR/$tfile of=/dev/null bs=1024k count=8 || error "Cannot read"
3170 cksum2=$(md5sum $DIR/$tfile | awk '{print $1}')
3171 if [ $cksum != $cksum2 ] ; then
3172 error "New checksum $cksum2 does not match original $cksum"
3175 run_test 87a "write replay"
3178 do_facet ost1 "lctl set_param -n obdfilter.${ost1_svc}.sync_journal 0"
3181 $SETSTRIPE -i 0 -c 1 $DIR/$tfile
3182 dd if=/dev/urandom of=$DIR/$tfile bs=1024k count=8 ||
3183 error "dd to $DIR/$tfile failed"
3184 sleep 1 # Give it a chance to flush dirty data
3185 echo TESTTEST | dd of=$DIR/$tfile bs=1 count=8 seek=64
3186 cksum=$(md5sum $DIR/$tfile | awk '{print $1}')
3187 cancel_lru_locks osc
3189 dd if=$DIR/$tfile of=/dev/null bs=1024k count=8 || error "Cannot read"
3190 cksum2=$(md5sum $DIR/$tfile | awk '{print $1}')
3191 if [ $cksum != $cksum2 ] ; then
3192 error "New checksum $cksum2 does not match original $cksum"
3195 run_test 87b "write replay with changed data (checksum resend)"
3197 test_88() { #bug 17485
3198 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
3199 mkdir -p $TMP/$tdir || error "mkdir $TMP/$tdir failed"
3201 $SETSTRIPE -i 0 -c 1 $DIR/$tdir || error "$SETSTRIPE"
3204 replay_barrier $SINGLEMDS
3206 # exhaust precreations on ost1
3207 local OST=$(ostname_from_index 0)
3208 local mdtosc=$(get_mdtosc_proc_path $SINGLEMDS $OST)
3209 local last_id=$(do_facet $SINGLEMDS lctl get_param -n osc.$mdtosc.prealloc_last_id)
3210 local next_id=$(do_facet $SINGLEMDS lctl get_param -n osc.$mdtosc.prealloc_next_id)
3211 echo "before test: last_id = $last_id, next_id = $next_id"
3213 echo "Creating to objid $last_id on ost $OST..."
3214 createmany -o $DIR/$tdir/f-%d $next_id $((last_id - next_id + 2)) ||
3215 error "createmany create files to last_id failed"
3217 #create some files to use some uncommitted objids
3218 last_id=$(($last_id + 1))
3219 createmany -o $DIR/$tdir/f-%d $last_id 8 ||
3220 error "createmany create files with uncommitted objids failed"
3222 last_id2=$(do_facet $SINGLEMDS lctl get_param -n osc.$mdtosc.prealloc_last_id)
3223 next_id2=$(do_facet $SINGLEMDS lctl get_param -n osc.$mdtosc.prealloc_next_id)
3224 echo "before recovery: last_id = $last_id2, next_id = $next_id2"
3226 # if test uses shutdown_facet && reboot_facet instead of facet_failover ()
3227 # it has to take care about the affected facets, bug20407
3228 local affected_mds1=$(affected_facets mds1)
3229 local affected_ost1=$(affected_facets ost1)
3231 shutdown_facet $SINGLEMDS
3234 reboot_facet $SINGLEMDS
3235 change_active $affected_mds1
3236 wait_for_facet $affected_mds1
3237 mount_facets $affected_mds1 || error "Restart of mds failed"
3240 change_active $affected_ost1
3241 wait_for_facet $affected_ost1
3242 mount_facets $affected_ost1 || error "Restart of ost1 failed"
3246 last_id2=$(do_facet $SINGLEMDS lctl get_param -n osc.$mdtosc.prealloc_last_id)
3247 next_id2=$(do_facet $SINGLEMDS lctl get_param -n osc.$mdtosc.prealloc_next_id)
3248 echo "after recovery: last_id = $last_id2, next_id = $next_id2"
3250 # create new files, which should use new objids, and ensure the orphan
3251 # cleanup phase for ost1 is completed at the same time
3252 for i in $(seq 8); do
3253 file_id=$(($last_id + 10 + $i))
3254 dd if=/dev/urandom of=$DIR/$tdir/f-$file_id bs=4096 count=128
3257 # if the objids were not recreated, then "ls" will fail with -ENOENT
3258 ls -l $DIR/$tdir/* || error "can't get the status of precreated files"
3261 # write into previously created files
3262 for i in $(seq 8); do
3263 file_id=$(($last_id + $i))
3264 dd if=/dev/urandom of=$DIR/$tdir/f-$file_id bs=4096 count=128
3265 cp -f $DIR/$tdir/f-$file_id $TMP/$tdir/
3268 # compare the content
3269 for i in $(seq 8); do
3270 file_id=$(($last_id + $i))
3271 cmp $TMP/$tdir/f-$file_id $DIR/$tdir/f-$file_id ||
3272 error "the content of file is modified!"
3277 run_test 88 "MDS should not assign same objid to different files "
3280 cancel_lru_locks osc
3281 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
3282 rm -f $DIR/$tdir/$tfile
3284 wait_delete_completed
3285 BLOCKS1=$(df -P $MOUNT | tail -n 1 | awk '{ print $3 }')
3286 $SETSTRIPE -i 0 -c 1 $DIR/$tdir/$tfile
3287 dd if=/dev/zero bs=1M count=10 of=$DIR/$tdir/$tfile
3290 facet_failover $SINGLEMDS
3291 rm $DIR/$tdir/$tfile
3294 zconf_mount $(hostname) $MOUNT || error "mount fails"
3295 client_up || error "client_up failed"
3297 wait_delete_completed
3298 BLOCKS2=$(df -P $MOUNT | tail -n 1 | awk '{ print $3 }')
3299 [ $((BLOCKS2 - BLOCKS1)) -le 4 ] ||
3300 error $((BLOCKS2 - BLOCKS1)) blocks leaked
3302 run_test 89 "no disk space leak on late ost connection"
3309 change_active $facet
3310 wait_for_facet $facet
3311 mount_facet $facet || error "Restart of $facet failed"
3315 test_90() { # bug 19494
3316 local dir=$DIR/$tdir
3317 local ostfail=$(get_random_entry $(get_facets OST))
3319 if [[ $FAILURE_MODE = HARD ]]; then
3320 local affected=$(affected_facets $ostfail);
3321 if [[ "$affected" != $ostfail ]]; then
3322 skip not functional with FAILURE_MODE=$FAILURE_MODE, affected: $affected
3326 # ensure all OSTs are active to allow allocations
3329 mkdir $dir || error "mkdir $dir failed"
3331 echo "Create the files"
3333 # file "f${index}" striped over 1 OST
3334 # file "all" striped over all OSTs
3336 $SETSTRIPE -c $OSTCOUNT $dir/all ||
3337 error "setstripe failed to create $dir/all"
3339 for (( i=0; i<$OSTCOUNT; i++ )); do
3341 $SETSTRIPE -i $i -c 1 $f || error "$SETSTRIPE failed to create $f"
3343 # confirm setstripe actually created the stripe on the requested OST
3344 local uuid=$(ostuuid_from_index $i)
3345 for file in f$i all; do
3346 if [[ $dir/$file != $($LFS find --obd $uuid --name $file $dir) ]]; then
3347 $GETSTRIPE $dir/$file
3348 error wrong stripe: $file, uuid: $uuid
3353 # Before failing an OST, get its obd name and index
3354 local varsvc=${ostfail}_svc
3355 local obd=$(do_facet $ostfail lctl get_param \
3356 -n obdfilter.${!varsvc}.uuid)
3357 local index=$(($(facet_number $ostfail) - 1))
3359 echo "Fail $ostfail $obd, display the list of affected files"
3360 shutdown_facet $ostfail || error "shutdown_facet $ostfail failed"
3362 trap "cleanup_90 $ostfail" EXIT INT
3363 echo "General Query: lfs find $dir"
3364 local list=$($LFS find $dir)
3366 for (( i=0; i<$OSTCOUNT; i++ )); do
3367 list_member "$list" $dir/f$i ||
3368 error_noexit "lfs find $dir: no file f$i"
3370 list_member "$list" $dir/all ||
3371 error_noexit "lfs find $dir: no file all"
3373 # focus on the missing OST,
3374 # we expect to see only two files affected: "f$(index)" and "all"
3376 echo "Querying files on shutdown $ostfail: lfs find --obd $obd"
3377 list=$($LFS find --obd $obd $dir)
3379 for file in all f$index; do
3380 list_member "$list" $dir/$file ||
3381 error_noexit "lfs find does not report the affected $obd for $file"
3384 [[ $(echo $list | wc -w) -eq 2 ]] ||
3385 error_noexit "lfs find reports the wrong list of affected files ${#list[@]}"
3387 echo "Check getstripe: $GETSTRIPE -r --obd $obd"
3388 list=$($GETSTRIPE -r --obd $obd $dir)
3390 for file in all f$index; do
3391 echo "$list" | grep $dir/$file ||
3392 error_noexit "lfs getsripe does not report the affected $obd for $file"
3397 run_test 90 "lfs find identifies the missing striped file segments"
3400 local server_version=$(lustre_version_code $SINGLEMDS)
3401 [[ $server_version -ge $(version_code 2.6.90) ]] ||
3402 [[ $server_version -ge $(version_code 2.5.4) &&
3403 $server_version -lt $(version_code 2.5.50) ]] ||
3404 { skip "Need MDS version 2.5.4+ or 2.6.90+"; return; }
3406 cancel_lru_locks osc
3408 $SETSTRIPE -i 0 -c 1 $DIR/$tfile ||
3409 error "$SETSTRIPE $DIR/$tfile failed"
3410 dd if=/dev/zero of=$DIR/$tfile bs=1024 count=1 ||
3411 error "dd to $DIR/$tfile failed"
3412 #define OBD_FAIL_TGT_REPLAY_RECONNECT 0x715
3413 # We need to emulate a state that OST is waiting for other clients
3414 # not completing the recovery. Final ping is queued, but reply will be
3415 # sent on the recovery completion. It is done by sleep before
3416 # processing final pings
3417 do_facet ost1 "$LCTL set_param fail_val=40"
3418 do_facet ost1 "$LCTL set_param fail_loc=0x715"
3421 run_test 93a "replay + reconnect"
3424 local server_version=$(lustre_version_code $SINGLEMDS)
3425 [[ $server_version -ge $(version_code 2.7.90) ]] ||
3426 { skip "Need MDS version 2.7.90+"; return; }
3428 cancel_lru_locks mdc
3430 createmany -o $DIR/$tfile 20 ||
3431 error "createmany -o $DIR/$tfile failed"
3433 #define OBD_FAIL_TGT_REPLAY_RECONNECT 0x715
3434 # We need to emulate a state that MDT is waiting for other clients
3435 # not completing the recovery. Final ping is queued, but reply will be
3436 # sent on the recovery completion. It is done by sleep before
3437 # processing final pings
3438 do_facet mds1 "$LCTL set_param fail_val=80"
3439 do_facet mds1 "$LCTL set_param fail_loc=0x715"
3442 run_test 93b "replay + reconnect on mds"
3444 striped_dir_check_100() {
3445 local striped_dir=$DIR/$tdir/striped_dir
3446 local stripe_count=$($LFS getdirstripe -c $striped_dir)
3448 $LFS getdirstripe $striped_dir
3449 [ $stripe_count -eq 2 ] || error "$stripe_count != 2"
3451 createmany -o $striped_dir/f-%d 20 ||
3452 error "creation failed under striped dir"
3456 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
3457 ([ $FAILURE_MODE == "HARD" ] &&
3458 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
3459 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
3462 local striped_dir=$DIR/$tdir/striped_dir
3465 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
3467 #To make sure MDT1 and MDT0 are connected
3468 #otherwise it may create single stripe dir here
3469 $LFS setdirstripe -i1 $DIR/$tdir/remote_dir
3471 #define OBD_FAIL_OUT_UPDATE_NET_REP 0x1701
3472 do_facet mds$((MDTIDX+1)) lctl set_param fail_loc=0x1701
3473 $LFS setdirstripe -i0 -c2 $striped_dir &
3476 fail mds$((MDTIDX + 1))
3478 wait $CLIENT_PID || error "striped dir creation failed"
3480 striped_dir_check_100 || error "striped dir check failed"
3481 rm -rf $DIR/$tdir || error "rmdir failed"
3483 run_test 100a "DNE: create striped dir, drop update rep from MDT1, fail MDT1"
3486 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
3487 ([ $FAILURE_MODE == "HARD" ] &&
3488 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
3489 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
3492 local striped_dir=$DIR/$tdir/striped_dir
3495 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
3497 #To make sure MDT1 and MDT0 are connected
3498 #otherwise it may create single stripe dir here
3499 $LFS setdirstripe -i1 $DIR/$tdir/remote_dir
3501 # OBD_FAIL_MDS_REINT_NET_REP 0x119
3502 do_facet mds$MDTIDX lctl set_param fail_loc=0x119
3503 $LFS mkdir -i0 -c2 $striped_dir &
3508 wait $CLIENT_PID || error "striped dir creation failed"
3510 striped_dir_check_100 || error "striped dir check failed"
3511 rm -rf $DIR/$tdir || error "rmdir failed"
3513 run_test 100b "DNE: create striped dir, fail MDT0"
3515 test_101() { #LU-5648
3516 mkdir -p $DIR/$tdir/d1
3517 mkdir -p $DIR/$tdir/d2
3518 touch $DIR/$tdir/file0
3521 replay_barrier $SINGLEMDS
3522 for i in $(seq $num) ; do
3523 echo test$i > $DIR/$tdir/d1/file$i
3526 fail_abort $SINGLEMDS
3527 for i in $(seq $num) ; do
3528 touch $DIR/$tdir/d2/file$i
3529 test -s $DIR/$tdir/d2/file$i &&
3530 ls -al $DIR/$tdir/d2/file$i && error "file$i's size > 0"
3535 run_test 101 "Shouldn't reassign precreated objs to other files after recovery"
3544 [[ $(lctl get_param mdc.*.import |
3545 grep "connect_flags:.*multi_mod_rpc") ]] ||
3546 { skip "Need MDC with 'multi_mod_rpcs' feature"; return 0; }
3548 $LFS mkdir -c1 $DIR/$tdir || error "mkdir $DIR/$tdir failed"
3549 idx=$(printf "%04x" $($LFS getdirstripe -i $DIR/$tdir))
3550 facet="mds$((0x$idx + 1))"
3552 # get current value of max_mod_rcps_in_flight
3553 num=$($LCTL get_param -n \
3554 mdc.$FSNAME-MDT$idx-mdc-*.max_mod_rpcs_in_flight)
3555 # set default value if client does not support multi mod RPCs
3556 [ -z "$num" ] && num=1
3558 echo "creating $num files ..."
3560 for i in $(seq $num); do
3561 touch $DIR/$tdir/file-$i
3564 # drop request on MDT to force resend
3565 #define OBD_FAIL_MDS_REINT_MULTI_NET 0x159
3566 do_facet $facet "$LCTL set_param fail_loc=0x159"
3567 echo "launch $num chmod in parallel ($(date +%H:%M:%S)) ..."
3568 for i in $(seq $num); do
3569 chmod 0600 $DIR/$tdir/file-$i &
3573 do_facet $facet "$LCTL set_param fail_loc=0"
3574 for pid in $pids; do
3575 wait $pid || error "chmod failed"
3577 echo "done ($(date +%H:%M:%S))"
3579 # check chmod succeed
3580 for i in $(seq $num); do
3581 checkstat -vp 0600 $DIR/$tdir/file-$i
3586 run_test 102a "check resend (request lost) with multiple modify RPCs in flight"
3595 [[ $(lctl get_param mdc.*.import |
3596 grep "connect_flags:.*multi_mod_rpc") ]] ||
3597 { skip "Need MDC with 'multi_mod_rpcs' feature"; return 0; }
3599 $LFS mkdir -c1 $DIR/$tdir || error "mkdir $DIR/$tdir failed"
3600 idx=$(printf "%04x" $($LFS getdirstripe -i $DIR/$tdir))
3601 facet="mds$((0x$idx + 1))"
3603 # get current value of max_mod_rcps_in_flight
3604 num=$($LCTL get_param -n \
3605 mdc.$FSNAME-MDT$idx-mdc-*.max_mod_rpcs_in_flight)
3606 # set default value if client does not support multi mod RPCs
3607 [ -z "$num" ] && num=1
3609 echo "creating $num files ..."
3611 for i in $(seq $num); do
3612 touch $DIR/$tdir/file-$i
3615 # drop reply on MDT to force reconstruction
3616 #define OBD_FAIL_MDS_REINT_MULTI_NET_REP 0x15a
3617 do_facet $facet "$LCTL set_param fail_loc=0x15a"
3618 echo "launch $num chmod in parallel ($(date +%H:%M:%S)) ..."
3619 for i in $(seq $num); do
3620 chmod 0600 $DIR/$tdir/file-$i &
3624 do_facet $facet "$LCTL set_param fail_loc=0"
3625 for pid in $pids; do
3626 wait $pid || error "chmod failed"
3628 echo "done ($(date +%H:%M:%S))"
3630 # check chmod succeed
3631 for i in $(seq $num); do
3632 checkstat -vp 0600 $DIR/$tdir/file-$i
3637 run_test 102b "check resend (reply lost) with multiple modify RPCs in flight"
3646 [[ $(lctl get_param mdc.*.import |
3647 grep "connect_flags:.*multi_mod_rpc") ]] ||
3648 { skip "Need MDC with 'multi_mod_rpcs' feature"; return 0; }
3650 $LFS mkdir -c1 $DIR/$tdir || error "mkdir $DIR/$tdir failed"
3651 idx=$(printf "%04x" $($LFS getdirstripe -i $DIR/$tdir))
3652 facet="mds$((0x$idx + 1))"
3654 # get current value of max_mod_rcps_in_flight
3655 num=$($LCTL get_param -n \
3656 mdc.$FSNAME-MDT$idx-mdc-*.max_mod_rpcs_in_flight)
3657 # set default value if client does not support multi mod RPCs
3658 [ -z "$num" ] && num=1
3660 echo "creating $num files ..."
3662 for i in $(seq $num); do
3663 touch $DIR/$tdir/file-$i
3666 replay_barrier $facet
3669 #define OBD_FAIL_MDS_REINT_MULTI_NET_REP 0x15a
3670 do_facet $facet "$LCTL set_param fail_loc=0x15a"
3671 echo "launch $num chmod in parallel ($(date +%H:%M:%S)) ..."
3672 for i in $(seq $num); do
3673 chmod 0600 $DIR/$tdir/file-$i &
3677 do_facet $facet "$LCTL set_param fail_loc=0"
3682 for pid in $pids; do
3683 wait $pid || error "chmod failed"
3685 echo "done ($(date +%H:%M:%S))"
3687 # check chmod succeed
3688 for i in $(seq $num); do
3689 checkstat -vp 0600 $DIR/$tdir/file-$i
3694 run_test 102c "check replay w/o reconstruction with multiple mod RPCs in flight"
3703 [[ $(lctl get_param mdc.*.import |
3704 grep "connect_flags:.*multi_mod_rpc") ]] ||
3705 { skip "Need MDC with 'multi_mod_rpcs' feature"; return 0; }
3707 $LFS mkdir -c1 $DIR/$tdir || error "mkdir $DIR/$tdir failed"
3708 idx=$(printf "%04x" $($LFS getdirstripe -i $DIR/$tdir))
3709 facet="mds$((0x$idx + 1))"
3711 # get current value of max_mod_rcps_in_flight
3712 num=$($LCTL get_param -n \
3713 mdc.$FSNAME-MDT$idx-mdc-*.max_mod_rpcs_in_flight)
3714 # set default value if client does not support multi mod RPCs
3715 [ -z "$num" ] && num=1
3717 echo "creating $num files ..."
3719 for i in $(seq $num); do
3720 touch $DIR/$tdir/file-$i
3724 #define OBD_FAIL_MDS_REINT_MULTI_NET_REP 0x15a
3725 do_facet $facet "$LCTL set_param fail_loc=0x15a"
3726 echo "launch $num chmod in parallel ($(date +%H:%M:%S)) ..."
3727 for i in $(seq $num); do
3728 chmod 0600 $DIR/$tdir/file-$i &
3733 # write MDT transactions to disk
3734 do_facet $facet "sync; sync; sync"
3736 do_facet $facet "$LCTL set_param fail_loc=0"
3741 for pid in $pids; do
3742 wait $pid || error "chmod failed"
3744 echo "done ($(date +%H:%M:%S))"
3746 # check chmod succeed
3747 for i in $(seq $num); do
3748 checkstat -vp 0600 $DIR/$tdir/file-$i
3753 run_test 102d "check replay & reconstruction with multiple mod RPCs in flight"
3756 remote_mds_nodsh && skip "remote MDS with nodsh" && return
3757 #define OBD_FAIL_MDS_TRACK_OVERFLOW 0x162
3758 do_facet mds1 $LCTL set_param fail_loc=0x80000162
3761 createmany -o $DIR/$tdir/t- 30 ||
3762 error "create files on remote directory failed"
3764 rm -rf $DIR/$tdir/t-*
3766 #MDS should crash with tr->otr_next_id overflow
3769 run_test 103 "Check otr_next_id overflow"
3772 check_striped_dir_110()
3774 $CHECKSTAT -t dir $DIR/$tdir/striped_dir ||
3775 error "create striped dir failed"
3776 local stripe_count=$($LFS getdirstripe -c $DIR/$tdir/striped_dir)
3777 [ $stripe_count -eq $MDSCOUNT ] ||
3778 error "$stripe_count != 2 after recovery"
3782 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
3783 ([ $FAILURE_MODE == "HARD" ] &&
3784 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
3785 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
3790 $LFS mkdir -i1 -c$MDSCOUNT $DIR/$tdir/striped_dir
3793 check_striped_dir_110 || error "check striped_dir failed"
3794 rm -rf $DIR/$tdir || error "rmdir failed"
3798 run_test 110a "DNE: create striped dir, fail MDT1"
3801 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
3802 ([ $FAILURE_MODE == "HARD" ] &&
3803 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
3804 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
3809 $LFS mkdir -i1 -c$MDSCOUNT $DIR/$tdir/striped_dir
3812 zconf_mount $(hostname) $MOUNT
3813 client_up || return 1
3815 check_striped_dir_110 || error "check striped_dir failed"
3817 rm -rf $DIR/$tdir || error "rmdir failed"
3821 run_test 110b "DNE: create striped dir, fail MDT1 and client"
3824 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
3825 ([ $FAILURE_MODE == "HARD" ] &&
3826 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
3827 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
3832 $LFS mkdir -i1 -c$MDSCOUNT $DIR/$tdir/striped_dir
3835 check_striped_dir_110 || error "check striped_dir failed"
3837 rm -rf $DIR/$tdir || error "rmdir failed"
3841 run_test 110c "DNE: create striped dir, fail MDT2"
3844 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
3845 ([ $FAILURE_MODE == "HARD" ] &&
3846 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
3847 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
3852 $LFS mkdir -i1 -c$MDSCOUNT $DIR/$tdir/striped_dir
3855 zconf_mount $(hostname) $MOUNT
3856 client_up || return 1
3858 check_striped_dir_110 || error "check striped_dir failed"
3860 rm -rf $DIR/$tdir || error "rmdir failed"
3864 run_test 110d "DNE: create striped dir, fail MDT2 and client"
3867 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
3868 ([ $FAILURE_MODE == "HARD" ] &&
3869 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
3870 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
3875 $LFS mkdir -i1 -c$MDSCOUNT $DIR/$tdir/striped_dir
3879 zconf_mount $(hostname) $MOUNT
3880 client_up || return 1
3882 check_striped_dir_110 || error "check striped_dir failed"
3884 rm -rf $DIR/$tdir || error "rmdir failed"
3888 run_test 110e "DNE: create striped dir, uncommit on MDT2, fail client/MDT1/MDT2"
3891 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
3892 ([ $FAILURE_MODE == "HARD" ] &&
3893 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
3894 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
3900 $LFS mkdir -i1 -c$MDSCOUNT $DIR/$tdir/striped_dir
3903 check_striped_dir_110 || error "check striped_dir failed"
3905 rm -rf $DIR/$tdir || error "rmdir failed"
3909 run_test 110f "DNE: create striped dir, fail MDT1/MDT2"
3912 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
3913 ([ $FAILURE_MODE == "HARD" ] &&
3914 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
3915 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
3920 $LFS mkdir -i1 -c$MDSCOUNT $DIR/$tdir/striped_dir
3924 zconf_mount $(hostname) $MOUNT
3925 client_up || return 1
3927 check_striped_dir_110 || error "check striped_dir failed"
3929 rm -rf $DIR/$tdir || error "rmdir failed"
3933 run_test 110g "DNE: create striped dir, uncommit on MDT1, fail client/MDT1/MDT2"
3936 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
3937 ([ $FAILURE_MODE == "HARD" ] &&
3938 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
3939 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
3943 $LFS mkdir -i1 -c2 $DIR/$tdir/striped_dir
3945 rm -rf $DIR/$tdir/striped_dir
3948 $CHECKSTAT -t dir $DIR/$tdir/striped_dir &&
3949 error "striped dir still exists"
3952 run_test 111a "DNE: unlink striped dir, fail MDT1"
3955 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
3956 ([ $FAILURE_MODE == "HARD" ] &&
3957 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
3958 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
3962 $LFS mkdir -i1 -c2 $DIR/$tdir/striped_dir
3964 rm -rf $DIR/$tdir/striped_dir
3967 zconf_mount $(hostname) $MOUNT
3968 client_up || return 1
3970 $CHECKSTAT -t dir $DIR/$tdir/striped_dir &&
3971 error "striped dir still exists"
3974 run_test 111b "DNE: unlink striped dir, fail MDT2"
3977 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
3978 ([ $FAILURE_MODE == "HARD" ] &&
3979 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
3980 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
3984 $LFS mkdir -i1 -c2 $DIR/$tdir/striped_dir
3986 rm -rf $DIR/$tdir/striped_dir
3990 zconf_mount $(hostname) $MOUNT
3991 client_up || return 1
3992 $CHECKSTAT -t dir $DIR/$tdir/striped_dir &&
3993 error "striped dir still exists"
3996 run_test 111c "DNE: unlink striped dir, uncommit on MDT1, fail client/MDT1/MDT2"
3999 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
4000 ([ $FAILURE_MODE == "HARD" ] &&
4001 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
4002 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
4006 $LFS mkdir -i1 -c2 $DIR/$tdir/striped_dir
4008 rm -rf $DIR/$tdir/striped_dir
4012 zconf_mount $(hostname) $MOUNT
4013 client_up || return 1
4014 $CHECKSTAT -t dir $DIR/$tdir/striped_dir &&
4015 error "striped dir still exists"
4019 run_test 111d "DNE: unlink striped dir, uncommit on MDT2, fail client/MDT1/MDT2"
4022 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
4023 ([ $FAILURE_MODE == "HARD" ] &&
4024 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
4025 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
4029 $LFS mkdir -i1 -c2 $DIR/$tdir/striped_dir
4031 rm -rf $DIR/$tdir/striped_dir
4034 $CHECKSTAT -t dir $DIR/$tdir/striped_dir &&
4035 error "striped dir still exists"
4038 run_test 111e "DNE: unlink striped dir, uncommit on MDT2, fail MDT1/MDT2"
4041 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
4042 ([ $FAILURE_MODE == "HARD" ] &&
4043 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
4044 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
4048 $LFS mkdir -i1 -c2 $DIR/$tdir/striped_dir
4050 rm -rf $DIR/$tdir/striped_dir
4053 $CHECKSTAT -t dir $DIR/$tdir/striped_dir &&
4054 error "striped dir still exists"
4057 run_test 111f "DNE: unlink striped dir, uncommit on MDT1, fail MDT1/MDT2"
4060 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
4061 ([ $FAILURE_MODE == "HARD" ] &&
4062 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
4063 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
4067 $LFS mkdir -i1 -c2 $DIR/$tdir/striped_dir
4070 rm -rf $DIR/$tdir/striped_dir
4072 $CHECKSTAT -t dir $DIR/$tdir/striped_dir &&
4073 error "striped dir still exists"
4076 run_test 111g "DNE: unlink striped dir, fail MDT1/MDT2"
4078 test_112_rename_prepare() {
4079 mkdir -p $DIR/$tdir/src_dir
4080 $LFS mkdir -i 1 $DIR/$tdir/src_dir/src_child ||
4081 error "create remote source failed"
4083 touch $DIR/$tdir/src_dir/src_child/a
4085 $LFS mkdir -i 2 $DIR/$tdir/tgt_dir ||
4086 error "create remote target dir failed"
4088 $LFS mkdir -i 3 $DIR/$tdir/tgt_dir/tgt_child ||
4089 error "create remote target child failed"
4094 $CHECKSTAT -t dir $DIR/$tdir/src_dir/src_child &&
4095 error "src_child still exists after rename"
4097 $CHECKSTAT -t file $DIR/$tdir/tgt_dir/tgt_child/a ||
4098 error "missing file(a) after rename"
4102 [ $MDSCOUNT -lt 4 ] && skip "needs >= 4 MDTs" && return 0
4103 ([ $FAILURE_MODE == "HARD" ] &&
4104 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
4105 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
4108 test_112_rename_prepare
4111 mrename $DIR/$tdir/src_dir/src_child $DIR/$tdir/tgt_dir/tgt_child ||
4112 error "rename dir cross MDT failed!"
4116 rm -rf $DIR/$tdir || error "rmdir failed"
4118 run_test 112a "DNE: cross MDT rename, fail MDT1"
4121 [ $MDSCOUNT -lt 4 ] && skip "needs >= 4 MDTs" && return 0
4122 ([ $FAILURE_MODE == "HARD" ] &&
4123 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
4124 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
4127 test_112_rename_prepare
4130 mrename $DIR/$tdir/src_dir/src_child $DIR/$tdir/tgt_dir/tgt_child ||
4131 error "rename dir cross MDT failed!"
4136 rm -rf $DIR/$tdir || error "rmdir failed"
4138 run_test 112b "DNE: cross MDT rename, fail MDT2"
4141 [ $MDSCOUNT -lt 4 ] && skip "needs >= 4 MDTs" && return 0
4142 ([ $FAILURE_MODE == "HARD" ] &&
4143 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
4144 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
4147 test_112_rename_prepare
4150 mrename $DIR/$tdir/src_dir/src_child $DIR/$tdir/tgt_dir/tgt_child ||
4151 error "rename dir cross MDT failed!"
4156 rm -rf $DIR/$tdir || error "rmdir failed"
4158 run_test 112c "DNE: cross MDT rename, fail MDT3"
4161 [ $MDSCOUNT -lt 4 ] && skip "needs >= 4 MDTs" && return 0
4162 ([ $FAILURE_MODE == "HARD" ] &&
4163 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
4164 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
4167 test_112_rename_prepare
4170 mrename $DIR/$tdir/src_dir/src_child $DIR/$tdir/tgt_dir/tgt_child ||
4171 error "rename dir cross MDT failed!"
4176 rm -rf $DIR/$tdir || error "rmdir failed"
4178 run_test 112d "DNE: cross MDT rename, fail MDT4"
4181 [ $MDSCOUNT -lt 4 ] && skip "needs >= 4 MDTs" && return 0
4182 ([ $FAILURE_MODE == "HARD" ] &&
4183 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
4184 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
4187 test_112_rename_prepare
4191 mrename $DIR/$tdir/src_dir/src_child $DIR/$tdir/tgt_dir/tgt_child ||
4192 error "rename dir cross MDT failed!"
4197 rm -rf $DIR/$tdir || error "rmdir failed"
4199 run_test 112e "DNE: cross MDT rename, fail MDT1 and MDT2"
4202 [ $MDSCOUNT -lt 4 ] && skip "needs >= 4 MDTs" && return 0
4203 ([ $FAILURE_MODE == "HARD" ] &&
4204 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
4205 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
4208 test_112_rename_prepare
4212 mrename $DIR/$tdir/src_dir/src_child $DIR/$tdir/tgt_dir/tgt_child ||
4213 error "rename dir cross MDT failed!"
4218 rm -rf $DIR/$tdir || error "rmdir failed"
4220 run_test 112f "DNE: cross MDT rename, fail MDT1 and MDT3"
4223 [ $MDSCOUNT -lt 4 ] && skip "needs >= 4 MDTs" && return 0
4224 ([ $FAILURE_MODE == "HARD" ] &&
4225 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
4226 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
4229 test_112_rename_prepare
4233 mrename $DIR/$tdir/src_dir/src_child $DIR/$tdir/tgt_dir/tgt_child ||
4234 error "rename dir cross MDT failed!"
4239 rm -rf $DIR/$tdir || error "rmdir failed"
4241 run_test 112g "DNE: cross MDT rename, fail MDT1 and MDT4"
4244 [ $MDSCOUNT -lt 4 ] && skip "needs >= 4 MDTs" && return 0
4245 ([ $FAILURE_MODE == "HARD" ] &&
4246 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
4247 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
4250 test_112_rename_prepare
4254 mrename $DIR/$tdir/src_dir/src_child $DIR/$tdir/tgt_dir/tgt_child ||
4255 error "rename dir cross MDT failed!"
4260 rm -rf $DIR/$tdir || error "rmdir failed"
4262 run_test 112h "DNE: cross MDT rename, fail MDT2 and MDT3"
4265 [ $MDSCOUNT -lt 4 ] && skip "needs >= 4 MDTs" && return 0
4266 ([ $FAILURE_MODE == "HARD" ] &&
4267 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
4268 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
4271 test_112_rename_prepare
4275 mrename $DIR/$tdir/src_dir/src_child $DIR/$tdir/tgt_dir/tgt_child ||
4276 error "rename dir cross MDT failed!"
4281 rm -rf $DIR/$tdir || error "rmdir failed"
4283 run_test 112i "DNE: cross MDT rename, fail MDT2 and MDT4"
4286 [ $MDSCOUNT -lt 4 ] && skip "needs >= 4 MDTs" && return 0
4287 ([ $FAILURE_MODE == "HARD" ] &&
4288 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
4289 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
4292 test_112_rename_prepare
4296 mrename $DIR/$tdir/src_dir/src_child $DIR/$tdir/tgt_dir/tgt_child ||
4297 error "rename dir cross MDT failed!"
4302 rm -rf $DIR/$tdir || error "rmdir failed"
4304 run_test 112j "DNE: cross MDT rename, fail MDT3 and MDT4"
4307 [ $MDSCOUNT -lt 4 ] && skip "needs >= 4 MDTs" && return 0
4308 ([ $FAILURE_MODE == "HARD" ] &&
4309 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
4310 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
4313 test_112_rename_prepare
4318 mrename $DIR/$tdir/src_dir/src_child $DIR/$tdir/tgt_dir/tgt_child ||
4319 error "rename dir cross MDT failed!"
4324 rm -rf $DIR/$tdir || error "rmdir failed"
4326 run_test 112k "DNE: cross MDT rename, fail MDT1,MDT2,MDT3"
4329 [ $MDSCOUNT -lt 4 ] && skip "needs >= 4 MDTs" && return 0
4330 ([ $FAILURE_MODE == "HARD" ] &&
4331 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
4332 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
4335 test_112_rename_prepare
4340 mrename $DIR/$tdir/src_dir/src_child $DIR/$tdir/tgt_dir/tgt_child ||
4341 error "rename dir cross MDT failed!"
4346 rm -rf $DIR/$tdir || error "rmdir failed"
4348 run_test 112l "DNE: cross MDT rename, fail MDT1,MDT2,MDT4"
4351 [ $MDSCOUNT -lt 4 ] && skip "needs >= 4 MDTs" && return 0
4352 ([ $FAILURE_MODE == "HARD" ] &&
4353 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
4354 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
4357 test_112_rename_prepare
4362 mrename $DIR/$tdir/src_dir/src_child $DIR/$tdir/tgt_dir/tgt_child ||
4363 error "rename dir cross MDT failed!"
4368 rm -rf $DIR/$tdir || error "rmdir failed"
4370 run_test 112m "DNE: cross MDT rename, fail MDT1,MDT3,MDT4"
4373 [ $MDSCOUNT -lt 4 ] && skip "needs >= 4 MDTs" && return 0
4374 ([ $FAILURE_MODE == "HARD" ] &&
4375 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
4376 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
4379 test_112_rename_prepare
4384 mrename $DIR/$tdir/src_dir/src_child $DIR/$tdir/tgt_dir/tgt_child ||
4385 error "rename dir cross MDT failed!"
4390 rm -rf $DIR/$tdir || error "rmdir failed"
4392 run_test 112n "DNE: cross MDT rename, fail MDT2,MDT3,MDT4"
4395 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
4396 ([ $FAILURE_MODE == "HARD" ] &&
4397 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
4398 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
4406 for ((j=0;j<$((MDSCOUNT));j++)); do
4407 fail_index=$((fail_index+1))
4408 index=$((fail_index % MDSCOUNT))
4409 replay_barrier mds$((index + 1))
4410 for ((i=0;i<5;i++)); do
4411 test_mkdir -i$index -c$MDSCOUNT $DIR/$tdir/test_$i ||
4412 error "create striped dir $DIR/$tdir/test_$i"
4415 fail mds$((index + 1))
4416 for ((i=0;i<5;i++)); do
4417 checkstat -t dir $DIR/$tdir/test_$i ||
4418 error "$DIR/$tdir/test_$i does not exist!"
4420 rm -rf $DIR/$tdir/test_* ||
4424 run_test 115 "failover for create/unlink striped directory"
4427 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
4428 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.55) ] &&
4429 skip "Do not support large update log before 2.7.55" &&
4431 ([ $FAILURE_MODE == "HARD" ] &&
4432 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
4433 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
4440 # OBD_FAIL_SPLIT_UPDATE_REC 0x1702
4441 do_facet mds1 "lctl set_param fail_loc=0x80001702"
4442 $LFS setdirstripe -c$MDSCOUNT $DIR/$tdir/striped_dir
4445 $CHECKSTAT -t dir $DIR/$tdir/striped_dir ||
4446 error "stried_dir does not exists"
4448 run_test 116a "large update log master MDT recovery"
4451 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
4452 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.55) ] &&
4453 skip "Do not support large update log before 2.7.55" &&
4456 ([ $FAILURE_MODE == "HARD" ] &&
4457 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
4458 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
4465 # OBD_FAIL_SPLIT_UPDATE_REC 0x1702
4466 do_facet mds2 "lctl set_param fail_loc=0x80001702"
4467 $LFS setdirstripe -c$MDSCOUNT $DIR/$tdir/striped_dir
4470 $CHECKSTAT -t dir $DIR/$tdir/striped_dir ||
4471 error "stried_dir does not exists"
4473 run_test 116b "large update log slave MDT recovery"
4476 [ $MDSCOUNT -lt 4 ] && skip "needs >= 4 MDTs" && return 0
4477 ([ $FAILURE_MODE == "HARD" ] &&
4478 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
4479 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
4485 $LFS setdirstripe -i0 -c$MDSCOUNT $DIR/$tdir/remote_dir
4486 $LFS setdirstripe -i1 -c$MDSCOUNT $DIR/$tdir/remote_dir_1
4489 # Let's set rdonly on all MDTs, so client will send
4490 # replay requests on all MDTs and replay these requests
4491 # at the same time. This test will verify the recovery
4492 # will not be deadlock in this case, LU-7531.
4493 for ((index = 0; index < $((MDSCOUNT)); index++)); do
4494 replay_barrier mds$((index + 1))
4495 if [ -z $mds_indexs ]; then
4496 mds_indexs="${mds_indexs}mds$((index+1))"
4498 mds_indexs="${mds_indexs},mds$((index+1))"
4502 rm -rf $DIR/$tdir/remote_dir
4503 rm -rf $DIR/$tdir/remote_dir_1
4507 rm -rf $DIR/$tdir || error "rmdir failed"
4509 run_test 117 "DNE: cross MDT unlink, fail MDT1 and MDT2"
4512 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
4513 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.64) ] &&
4514 skip "Do not support large update log before 2.7.64" &&
4519 $LFS setdirstripe -c2 $DIR/$tdir/striped_dir ||
4520 error "setdirstripe fails"
4521 $LFS setdirstripe -c2 $DIR/$tdir/striped_dir1 ||
4522 error "setdirstripe fails 1"
4523 rm -rf $DIR/$tdir/striped_dir* || error "rmdir fails"
4525 # OBD_FAIL_INVALIDATE_UPDATE 0x1705
4526 do_facet mds1 "lctl set_param fail_loc=0x1705"
4527 $LFS setdirstripe -c2 $DIR/$tdir/striped_dir
4528 $LFS setdirstripe -c2 $DIR/$tdir/striped_dir1
4529 do_facet mds1 "lctl set_param fail_loc=0x0"
4532 $LFS setdirstripe -c2 $DIR/$tdir/striped_dir
4533 $LFS setdirstripe -c2 $DIR/$tdir/striped_dir1
4538 run_test 118 "invalidate osp update will not cause update log corruption"
4541 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
4542 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.64) ] &&
4543 skip "Do not support large update log before 2.7.64" &&
4546 local hard_timeout=$(do_facet mds1 \
4547 "lctl get_param -n mdt.$FSNAME-MDT0000.recovery_time_hard")
4549 local clients=${CLIENTS:-$HOSTNAME}
4550 local time_min=$(recovery_time_min)
4553 mkdir $DIR/$tdir/tmp
4554 rmdir $DIR/$tdir/tmp
4557 mkdir $DIR/$tdir/dir_1
4558 for ((i = 0; i < 20; i++)); do
4559 $LFS setdirstripe -c2 $DIR/$tdir/stripe_dir-$i
4566 #define OBD_FAIL_TGT_REPLAY_DELAY 0x714
4567 do_facet mds1 $LCTL set_param fail_loc=0x80000714
4568 #sleep (timeout + 5), so mds will evict the client exports,
4569 #but DNE update recovery will keep going.
4570 do_facet mds1 $LCTL set_param fail_val=$((time_min + 5))
4572 mount_facet mds1 "-o recovery_time_hard=$time_min"
4574 wait_clients_import_state "$clients" mds1 FULL
4576 clients_up || clients_up || error "failover df: $?"
4578 #revert back the hard timeout
4579 do_facet mds1 $LCTL set_param \
4580 mdt.$FSNAME-MDT0000.recovery_time_hard=$hard_timeout
4582 for ((i = 0; i < 20; i++)); do
4583 stripe_count=$($LFS getdirstripe -c $DIR/$tdir/stripe_dir-$i)
4584 [ $stripe_count == 2 ] || {
4585 error "stripe_dir-$i creation replay fails"
4590 run_test 119 "timeout of normal replay does not cause DNE replay fails "
4593 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
4594 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.64) ] &&
4595 skip "Do not support large update log before 2.7.64" &&
4599 replay_barrier_nosync mds1
4600 for ((i = 0; i < 20; i++)); do
4601 mkdir $DIR/$tdir/dir-$i || {
4602 error "create dir-$i fails"
4605 $LFS setdirstripe -c2 $DIR/$tdir/stripe_dir-$i || {
4606 error "create stripe_dir-$i fails"
4613 for ((i = 0; i < 20; i++)); do
4614 [ ! -e "$DIR/$tdir/dir-$i" ] || {
4615 error "dir-$i still exists"
4618 [ ! -e "$DIR/$tdir/stripe_dir-$i" ] || {
4619 error "stripe_dir-$i still exists"
4624 run_test 120 "DNE fail abort should stop both normal and DNE replay"
4627 check_and_cleanup_lustre