7 # This test needs to be run on the client
10 export MULTIOP=${MULTIOP:-multiop}
11 LUSTRE=${LUSTRE:-$(cd $(dirname $0)/..; echo $PWD)}
14 . $LUSTRE/tests/test-framework.sh
16 . ${CONFIG:=$LUSTRE/tests/cfg/$NAME.sh}
18 CHECK_GRANT=${CHECK_GRANT:-"yes"}
19 GRANT_CHECK_LIST=${GRANT_CHECK_LIST:-""}
21 require_dsh_mds || exit 0
24 # bug number for skipped tests:
25 ALWAYS_EXCEPT="$REPLAY_SINGLE_EXCEPT "
26 # UPDATE THE COMMENT ABOVE WITH BUG NUMBERS WHEN CHANGING ALWAYS_EXCEPT!
28 # time in minutes: 7.5"
29 [ "$SLOW" = "no" ] && EXCEPT_SLOW="44b"
31 if [ $(facet_fstype $SINGLEMDS) = "zfs" ]; then
32 # bug number for skipped test: LU-11388
36 # bug number for skipped tests: LU-9795 (all below)
37 ALWAYS_EXCEPT="$ALWAYS_EXCEPT 0b 0c 0d 34 45"
38 ALWAYS_EXCEPT="$ALWAYS_EXCEPT 47 58b 58c 71a 85a"
39 ALWAYS_EXCEPT="$ALWAYS_EXCEPT 85b 86 88 89 90"
40 ALWAYS_EXCEPT="$ALWAYS_EXCEPT 93a 100a 100b 120"
45 check_and_setup_lustre
50 rm -rf $DIR/[df][0-9]* $DIR/f.$TESTSUITE.*
52 # LU-482 Avert LVM and VM inability to flush caches in pre .33 kernels
53 if [ $LINUX_VERSION_CODE -lt $(version_code 2.6.33) ]; then
55 do_facet $SINGLEMDS sync
58 test_0a() { # was test_0
59 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
60 replay_barrier $SINGLEMDS
64 run_test 0a "empty replay"
67 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
69 # this test attempts to trigger a race in the precreation code,
70 # and must run before any other objects are created on the filesystem
72 createmany -o $DIR/$tfile 20 || error "createmany -o $DIR/$tfile failed"
73 unlinkmany $DIR/$tfile 20 || error "unlinkmany $DIR/$tfile failed"
75 run_test 0b "ensure object created after recover exists. (3284)"
78 replay_barrier $SINGLEMDS
81 facet_failover $SINGLEMDS
82 zconf_mount $(hostname) $MOUNT || error "mount fails"
83 client_up || error "post-failover df failed"
84 # file shouldn't exist if replay-barrier works as expected
85 rm $DIR/$tfile && error "File exists and it shouldn't"
88 run_test 0c "check replay-barrier"
91 replay_barrier $SINGLEMDS
93 facet_failover $SINGLEMDS
94 zconf_mount $(hostname) $MOUNT || error "mount fails"
95 client_up || error "post-failover df failed"
97 run_test 0d "expired recovery with no clients"
100 replay_barrier $SINGLEMDS
103 $CHECKSTAT -t file $DIR/$tfile ||
104 error "$CHECKSTAT $DIR/$tfile attribute check failed"
107 run_test 1 "simple create"
110 replay_barrier $SINGLEMDS
113 $CHECKSTAT -t file $DIR/$tfile ||
114 error "$CHECKSTAT $DIR/$tfile attribute check failed"
120 mcreate $DIR/$tfile || error "mcreate $DIR/$tfile failed"
121 replay_barrier $SINGLEMDS
124 $CHECKSTAT -t file $DIR/$tfile ||
125 error "$CHECKSTAT $DIR/$tfile attribute check failed"
131 replay_barrier $SINGLEMDS
132 $LFS setstripe -c $OSTCOUNT $DIR/$tfile
134 $CHECKSTAT -t file $DIR/$tfile ||
135 error "$CHECKSTAT $DIR/$tfile check failed"
137 run_test 2c "setstripe replay"
140 replay_barrier $SINGLEMDS
141 $LFS setdirstripe -i 0 -c $MDSCOUNT $DIR/$tdir
143 $CHECKSTAT -t dir $DIR/$tdir ||
144 error "$CHECKSTAT $DIR/$tdir check failed"
146 run_test 2d "setdirstripe replay"
149 local file=$DIR/$tfile
150 replay_barrier $SINGLEMDS
152 openfile -f O_DIRECTORY $file
154 $CHECKSTAT -t file $file ||
155 error "$CHECKSTAT $file attribute check failed"
158 run_test 3a "replay failed open(O_DIRECTORY)"
161 replay_barrier $SINGLEMDS
162 #define OBD_FAIL_MDS_OPEN_PACK | OBD_FAIL_ONCE
163 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000114"
165 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
167 $CHECKSTAT -t file $DIR/$tfile &&
168 error "$CHECKSTAT $DIR/$tfile attribute check should fail"
171 run_test 3b "replay failed open -ENOMEM"
174 replay_barrier $SINGLEMDS
175 #define OBD_FAIL_MDS_ALLOC_OBDO | OBD_FAIL_ONCE
176 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000128"
178 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
181 $CHECKSTAT -t file $DIR/$tfile &&
182 error "$CHECKSTAT $DIR/$tfile attribute check should fail"
185 run_test 3c "replay failed open -ENOMEM"
187 test_4a() { # was test_4
188 replay_barrier $SINGLEMDS
189 for i in $(seq 10); do
190 echo "tag-$i" > $DIR/$tfile-$i
193 for i in $(seq 10); do
194 grep -q "tag-$i" $DIR/$tfile-$i || error "$tfile-$i"
197 run_test 4a "|x| 10 open(O_CREAT)s"
200 for i in $(seq 10); do
201 echo "tag-$i" > $DIR/$tfile-$i
203 replay_barrier $SINGLEMDS
206 $CHECKSTAT -t file $DIR/$tfile-* &&
207 error "$CHECKSTAT $DIR/$tfile-* attribute check should fail" ||
210 run_test 4b "|x| rm 10 files"
212 # The idea is to get past the first block of precreated files on both
213 # osts, and then replay.
215 replay_barrier $SINGLEMDS
216 for i in $(seq 220); do
217 echo "tag-$i" > $DIR/$tfile-$i
220 for i in $(seq 220); do
221 grep -q "tag-$i" $DIR/$tfile-$i || error "$tfile-$i"
225 # waiting for commitment of removal
227 run_test 5 "|x| 220 open(O_CREAT)"
229 test_6a() { # was test_6
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"
239 # waiting for log process thread
241 run_test 6a "mkdir + contained create"
244 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
245 replay_barrier $SINGLEMDS
248 $CHECKSTAT -t dir $DIR/$tdir &&
249 error "$CHECKSTAT $DIR/$tdir attribute check should fail" ||
252 run_test 6b "|X| rmdir"
255 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
256 replay_barrier $SINGLEMDS
257 mcreate $DIR/$tdir/$tfile
259 $CHECKSTAT -t dir $DIR/$tdir ||
260 error "$CHECKSTAT $DIR/$tdir attribute check failed"
261 $CHECKSTAT -t file $DIR/$tdir/$tfile ||
262 error "$CHECKSTAT $DIR/$tdir/$tfile attribute check failed"
265 run_test 7 "mkdir |X| contained create"
268 replay_barrier $SINGLEMDS
269 multiop_bg_pause $DIR/$tfile mo_c ||
270 error "multiop mknod $DIR/$tfile failed"
274 $CHECKSTAT -t file $DIR/$tfile ||
275 error "$CHECKSTAT $DIR/$tfile attribute check failed"
276 kill -USR1 $MULTIPID || error "multiop mknod $MULTIPID not running"
277 wait $MULTIPID || error "multiop mknod $MULTIPID failed"
280 run_test 8 "creat open |X| close"
283 replay_barrier $SINGLEMDS
285 local old_inum=$(ls -i $DIR/$tfile | awk '{print $1}')
287 local new_inum=$(ls -i $DIR/$tfile | awk '{print $1}')
289 echo " old_inum == $old_inum, new_inum == $new_inum"
290 if [ $old_inum -eq $new_inum ] ;
292 echo "old_inum and new_inum match"
294 echo " old_inum and new_inum do not match"
295 error "old index($old_inum) does not match new index($new_inum)"
299 run_test 9 "|X| create (same inum/gen)"
302 mcreate $DIR/$tfile || error "mcreate $DIR/$tfile failed"
303 replay_barrier $SINGLEMDS
304 mv $DIR/$tfile $DIR/$tfile-2
307 $CHECKSTAT $DIR/$tfile &&
308 error "$CHECKSTAT $DIR/$tfile attribute check should fail"
309 $CHECKSTAT $DIR/$tfile-2 ||
310 error "$CHECKSTAT $DIR/$tfile-2 attribute check failed"
314 run_test 10 "create |X| rename unlink"
317 mcreate $DIR/$tfile || error "mcreate $DIR/$tfile failed"
318 echo "old" > $DIR/$tfile
319 mv $DIR/$tfile $DIR/$tfile-2
320 replay_barrier $SINGLEMDS
321 echo "new" > $DIR/$tfile
323 grep old $DIR/$tfile-2
325 grep new $DIR/$tfile || error "grep $DIR/$tfile failed"
326 grep old $DIR/$tfile-2 || error "grep $DIR/$tfile-2 failed"
328 run_test 11 "create open write rename |X| create-old-name read"
331 mcreate $DIR/$tfile || error "mcreate $DIR/$tfile failed"
332 multiop_bg_pause $DIR/$tfile o_tSc ||
333 error "multiop_bg_pause $DIR/$tfile failed"
336 replay_barrier $SINGLEMDS
337 kill -USR1 $pid || error "multiop $pid not running"
338 wait $pid || error "multiop $pid failed"
341 [ -e $DIR/$tfile ] && error "file $DIR/$tfile should not exist"
344 run_test 12 "open, unlink |X| close"
346 # 1777 - replay open after committed chmod that would make
347 # a regular open a failure
349 mcreate $DIR/$tfile || error "mcreate $DIR/$tfile failed"
350 multiop_bg_pause $DIR/$tfile O_wc ||
351 error "multiop_bg_pause $DIR/$tfile failed"
354 $CHECKSTAT -p 0 $DIR/$tfile ||
355 error "$CHECKSTAT $DIR/$tfile attribute check failed"
356 replay_barrier $SINGLEMDS
358 kill -USR1 $pid || error "multiop $pid not running"
359 wait $pid || error "multiop $pid failed"
361 $CHECKSTAT -s 1 -p 0 $DIR/$tfile ||
362 error "second $CHECKSTAT $DIR/$tfile attribute check failed"
363 rm $DIR/$tfile || error "rm $DIR/$tfile failed"
366 run_test 13 "open chmod 0 |x| write close"
369 multiop_bg_pause $DIR/$tfile O_tSc ||
370 error "multiop_bg_pause $DIR/$tfile failed"
373 replay_barrier $SINGLEMDS
374 kill -USR1 $pid || error "multiop $pid not running"
375 wait $pid || error "multiop $pid failed"
378 [ -e $DIR/$tfile ] && error "file $DIR/$tfile should not exist"
381 run_test 14 "open(O_CREAT), unlink |X| close"
384 multiop_bg_pause $DIR/$tfile O_tSc ||
385 error "multiop_bg_pause $DIR/$tfile failed"
388 replay_barrier $SINGLEMDS
389 touch $DIR/$tfile-1 || error "touch $DIR/$tfile-1 failed"
390 kill -USR1 $pid || error "multiop $pid not running"
391 wait $pid || error "multiop $pid failed"
394 [ -e $DIR/$tfile ] && error "file $DIR/$tfile should not exist"
395 touch $DIR/$tfile-2 || error "touch $DIR/$tfile-2 failed"
398 run_test 15 "open(O_CREAT), unlink |X| touch new, close"
401 replay_barrier $SINGLEMDS
404 mcreate $DIR/$tfile-2
406 [ -e $DIR/$tfile ] && error "file $DIR/$tfile should not exist"
407 [ -e $DIR/$tfile-2 ] || error "file $DIR/$tfile-2 does not exist"
408 munlink $DIR/$tfile-2 || error "munlink $DIR/$tfile-2 failed"
410 run_test 16 "|X| open(O_CREAT), unlink, touch new, unlink new"
413 replay_barrier $SINGLEMDS
414 multiop_bg_pause $DIR/$tfile O_c ||
415 error "multiop_bg_pause $DIR/$tfile failed"
418 kill -USR1 $pid || error "multiop $pid not running"
419 wait $pid || error "multiop $pid failed"
420 $CHECKSTAT -t file $DIR/$tfile ||
421 error "$CHECKSTAT $DIR/$tfile attribute check failed"
424 run_test 17 "|X| open(O_CREAT), |replay| close"
427 replay_barrier $SINGLEMDS
428 multiop_bg_pause $DIR/$tfile O_tSc ||
429 error "multiop_bg_pause $DIR/$tfile failed"
432 touch $DIR/$tfile-2 || error "touch $DIR/$tfile-2 failed"
433 echo "pid: $pid will close"
434 kill -USR1 $pid || error "multiop $pid not running"
435 wait $pid || error "multiop $pid failed"
438 [ -e $DIR/$tfile ] && error "file $DIR/$tfile should not exist"
439 [ -e $DIR/$tfile-2 ] || error "file $DIR/$tfile-2 does not exist"
440 # this touch frequently fails
441 touch $DIR/$tfile-3 || error "touch $DIR/$tfile-3 failed"
442 munlink $DIR/$tfile-2 || error "munlink $DIR/$tfile-2 failed"
443 munlink $DIR/$tfile-3 || error "munlink $DIR/$tfile-3 failed"
446 run_test 18 "open(O_CREAT), unlink, touch new, close, touch, unlink"
448 # bug 1855 (a simpler form of test_11 above)
450 replay_barrier $SINGLEMDS
452 echo "old" > $DIR/$tfile
453 mv $DIR/$tfile $DIR/$tfile-2
454 grep old $DIR/$tfile-2
456 grep old $DIR/$tfile-2 || error "grep $DIR/$tfile-2 failed"
458 run_test 19 "mcreate, open, write, rename "
460 test_20a() { # was test_20
461 replay_barrier $SINGLEMDS
462 multiop_bg_pause $DIR/$tfile O_tSc ||
463 error "multiop_bg_pause $DIR/$tfile failed"
468 kill -USR1 $pid || error "multiop $pid not running"
469 wait $pid || error "multiop $pid failed"
470 [ -e $DIR/$tfile ] && error "file $DIR/$tfile should not exist"
473 run_test 20a "|X| open(O_CREAT), unlink, replay, close (test mds_cleanup_orphans)"
475 test_20b() { # bug 10480
476 local wait_timeout=$((TIMEOUT * 4))
477 local extra=$(fs_log_size)
481 $LFS setstripe -i 0 -c 1 $DIR
483 local beforeused=$(df -P $DIR | tail -1 | awk '{ print $3 }')
485 dd if=/dev/zero of=$DIR/$tfile bs=4k count=10000 &
486 while [ ! -e $DIR/$tfile ] ; do
487 usleep 60 # give dd a chance to start
490 $LFS getstripe $DIR/$tfile || error "$LFS getstripe $DIR/$tfile failed"
492 rm -f $DIR/$tfile || error "rm -f $DIR/$tfile failed"
494 client_up || client_up || true # reconnect
496 do_facet $SINGLEMDS "lctl set_param -n osd*.*MDT*.force_sync=1"
498 fail $SINGLEMDS # start orphan recovery
499 wait_recovery_complete $SINGLEMDS || error "MDS recovery not done"
500 wait_delete_completed $wait_timeout || error "delete did not finish"
504 local afterused=$(df -P $DIR | tail -1 | awk '{ print $3 }')
505 log "before $beforeused, after $afterused"
507 (( $beforeused + $extra >= $afterused )) && break
508 n_attempts=$((n_attempts + 1))
509 [ $n_attempts -gt 3 ] &&
510 error "after $afterused > before $beforeused + $extra"
512 wait_zfs_commit $SINGLEMDS 5
517 run_test 20b "write, unlink, eviction, replay (test mds_cleanup_orphans)"
519 test_20c() { # bug 10480
520 multiop_bg_pause $DIR/$tfile Ow_c ||
521 error "multiop_bg_pause $DIR/$tfile failed"
527 client_up || client_up || true # reconnect
529 kill -USR1 $pid || error "multiop $pid not running"
530 wait $pid || error "multiop $pid failed"
531 [ -s $DIR/$tfile ] || error "File was truncated"
535 run_test 20c "check that client eviction does not affect file content"
538 replay_barrier $SINGLEMDS
539 multiop_bg_pause $DIR/$tfile O_tSc ||
540 error "multiop_bg_pause $DIR/$tfile failed"
543 touch $DIR/$tfile-1 || error "touch $DIR/$tfile-1 failed"
546 kill -USR1 $pid || error "multiop $pid not running"
547 wait $pid || error "multiop $pid failed"
548 [ -e $DIR/$tfile ] && error "file $DIR/$tfile should not exist"
549 touch $DIR/$tfile-2 || error "touch $DIR/$tfile-2 failed"
552 run_test 21 "|X| open(O_CREAT), unlink touch new, replay, close (test mds_cleanup_orphans)"
555 multiop_bg_pause $DIR/$tfile O_tSc ||
556 error "multiop_bg_pause $DIR/$tfile failed"
559 replay_barrier $SINGLEMDS
563 kill -USR1 $pid || error "multiop $pid not running"
564 wait $pid || error "multiop $pid failed"
565 [ -e $DIR/$tfile ] && error "file $DIR/$tfile should not exist"
568 run_test 22 "open(O_CREAT), |X| unlink, replay, close (test mds_cleanup_orphans)"
571 multiop_bg_pause $DIR/$tfile O_tSc ||
572 error "multiop_bg_pause $DIR/$tfile failed"
575 replay_barrier $SINGLEMDS
577 touch $DIR/$tfile-1 || error "touch $DIR/$tfile-1 failed"
580 kill -USR1 $pid || error "multiop $pid not running"
581 wait $pid || error "multiop $pid failed"
582 [ -e $DIR/$tfile ] && error "file $DIR/$tfile should not exist"
583 touch $DIR/$tfile-2 || error "touch $DIR/$tfile-2 failed"
586 run_test 23 "open(O_CREAT), |X| unlink touch new, replay, close (test mds_cleanup_orphans)"
589 multiop_bg_pause $DIR/$tfile O_tSc ||
590 error "multiop_bg_pause $DIR/$tfile failed"
593 replay_barrier $SINGLEMDS
596 kill -USR1 $pid || error "multiop $pid not running"
597 wait $pid || error "multiop $pid failed"
598 [ -e $DIR/$tfile ] && error "file $DIR/$tfile should not exist"
601 run_test 24 "open(O_CREAT), replay, unlink, close (test mds_cleanup_orphans)"
604 multiop_bg_pause $DIR/$tfile O_tSc ||
605 error "multiop_bg_pause $DIR/$tfile failed"
609 replay_barrier $SINGLEMDS
611 kill -USR1 $pid || error "multiop $pid not running"
612 wait $pid || error "multiop $pid failed"
613 [ -e $DIR/$tfile ] && error "file $DIR/$tfile should not exist"
616 run_test 25 "open(O_CREAT), unlink, replay, close (test mds_cleanup_orphans)"
619 replay_barrier $SINGLEMDS
620 multiop_bg_pause $DIR/$tfile-1 O_tSc ||
621 error "multiop_bg_pause $DIR/$tfile-1 failed"
623 multiop_bg_pause $DIR/$tfile-2 O_tSc ||
624 error "multiop_bg_pause $DIR/$tfile-2 failed"
628 kill -USR1 $pid2 || error "second multiop $pid2 not running"
629 wait $pid2 || error "second multiop $pid2 failed"
632 kill -USR1 $pid1 || error "multiop $pid1 not running"
633 wait $pid1 || error "multiop $pid1 failed"
634 [ -e $DIR/$tfile-1 ] && error "file $DIR/$tfile-1 should not exist"
635 [ -e $DIR/$tfile-2 ] && error "file $DIR/$tfile-2 should not exist"
638 run_test 26 "|X| open(O_CREAT), unlink two, close one, replay, close one (test mds_cleanup_orphans)"
641 replay_barrier $SINGLEMDS
642 multiop_bg_pause $DIR/$tfile-1 O_tSc ||
643 error "multiop_bg_pause $DIR/$tfile-1 failed"
645 multiop_bg_pause $DIR/$tfile-2 O_tSc ||
646 error "multiop_bg_pause $DIR/$tfile-2 failed"
652 kill -USR1 $pid1 || error "multiop $pid1 not running"
653 wait $pid1 || error "multiop $pid1 failed"
654 kill -USR1 $pid2 || error "second multiop $pid2 not running"
655 wait $pid2 || error "second multiop $pid2 failed"
656 [ -e $DIR/$tfile-1 ] && error "file $DIR/$tfile-1 should not exist"
657 [ -e $DIR/$tfile-2 ] && error "file $DIR/$tfile-2 should not exist"
660 run_test 27 "|X| open(O_CREAT), unlink two, replay, close two (test mds_cleanup_orphans)"
663 multiop_bg_pause $DIR/$tfile-1 O_tSc ||
664 error "multiop_bg_pause $DIR/$tfile-1 failed"
666 multiop_bg_pause $DIR/$tfile-2 O_tSc ||
667 error "multiop_bg_pause $DIR/$tfile-2 failed"
669 replay_barrier $SINGLEMDS
672 kill -USR1 $pid2 || error "second multiop $pid2 not running"
673 wait $pid2 || error "second multiop $pid2 failed"
676 kill -USR1 $pid1 || error "multiop $pid1 not running"
677 wait $pid1 || error "multiop $pid1 failed"
678 [ -e $DIR/$tfile-1 ] && error "file $DIR/$tfile-1 should not exist"
679 [ -e $DIR/$tfile-2 ] && error "file $DIR/$tfile-2 should not exist"
682 run_test 28 "open(O_CREAT), |X| unlink two, close one, replay, close one (test mds_cleanup_orphans)"
685 multiop_bg_pause $DIR/$tfile-1 O_tSc ||
686 error "multiop_bg_pause $DIR/$tfile-1 failed"
688 multiop_bg_pause $DIR/$tfile-2 O_tSc ||
689 error "multiop_bg_pause $DIR/$tfile-2 failed"
691 replay_barrier $SINGLEMDS
696 kill -USR1 $pid1 || error "multiop $pid1 not running"
697 wait $pid1 || error "multiop $pid1 failed"
698 kill -USR1 $pid2 || error "second multiop $pid2 not running"
699 wait $pid2 || error "second multiop $pid2 failed"
700 [ -e $DIR/$tfile-1 ] && error "file $DIR/$tfile-1 should not exist"
701 [ -e $DIR/$tfile-2 ] && error "file $DIR/$tfile-2 should not exist"
704 run_test 29 "open(O_CREAT), |X| unlink two, replay, close two (test mds_cleanup_orphans)"
707 multiop_bg_pause $DIR/$tfile-1 O_tSc ||
708 error "multiop_bg_pause $DIR/$tfile-1 failed"
710 multiop_bg_pause $DIR/$tfile-2 O_tSc ||
711 error "multiop_bg_pause $DIR/$tfile-2 failed"
716 replay_barrier $SINGLEMDS
718 kill -USR1 $pid1 || error "multiop $pid1 not running"
719 wait $pid1 || error "multiop $pid1 failed"
720 kill -USR1 $pid2 || error "second multiop $pid2 not running"
721 wait $pid2 || error "second multiop $pid2 failed"
722 [ -e $DIR/$tfile-1 ] && error "file $DIR/$tfile-1 should not exist"
723 [ -e $DIR/$tfile-2 ] && error "file $DIR/$tfile-2 should not exist"
726 run_test 30 "open(O_CREAT) two, unlink two, replay, close two (test mds_cleanup_orphans)"
729 multiop_bg_pause $DIR/$tfile-1 O_tSc ||
730 error "multiop_bg_pause $DIR/$tfile-1 failed"
732 multiop_bg_pause $DIR/$tfile-2 O_tSc ||
733 error "multiop_bg_pause $DIR/$tfile-2 failed"
737 replay_barrier $SINGLEMDS
740 kill -USR1 $pid1 || error "multiop $pid1 not running"
741 wait $pid1 || error "multiop $pid1 failed"
742 kill -USR1 $pid2 || error "second multiop $pid2 not running"
743 wait $pid2 || error "second multiop $pid2 failed"
744 [ -e $DIR/$tfile-1 ] && error "file $DIR/$tfile-1 should not exist"
745 [ -e $DIR/$tfile-2 ] && error "file $DIR/$tfile-2 should not exist"
748 run_test 31 "open(O_CREAT) two, unlink one, |X| unlink one, close two (test mds_cleanup_orphans)"
750 # tests for bug 2104; completion without crashing is success. The close is
751 # stale, but we always return 0 for close, so the app never sees it.
753 multiop_bg_pause $DIR/$tfile O_c ||
754 error "multiop_bg_pause $DIR/$tfile failed"
756 multiop_bg_pause $DIR/$tfile O_c ||
757 error "second multiop_bg_pause $DIR/$tfile failed"
760 client_up || client_up || error "client_up failed"
761 kill -USR1 $pid1 || error "multiop $pid1 not running"
762 kill -USR1 $pid2 || error "second multiop $pid2 not running"
763 wait $pid1 || error "multiop $pid1 failed"
764 wait $pid2 || error "second multiop $pid2 failed"
767 run_test 32 "close() notices client eviction; close() after client eviction"
770 createmany -o $DIR/$tfile-%d 10 ||
771 error "createmany create $DIR/$tfile failed"
772 replay_barrier_nosync $SINGLEMDS
773 fail_abort $SINGLEMDS
774 # recreate shouldn't fail
775 createmany -o $DIR/$tfile--%d 10 ||
776 error "createmany recreate $DIR/$tfile failed"
780 run_test 33a "fid seq shouldn't be reused after abort recovery"
783 #define OBD_FAIL_SEQ_ALLOC 0x1311
784 do_facet $SINGLEMDS "lctl set_param fail_loc=0x1311"
786 createmany -o $DIR/$tfile-%d 10
787 replay_barrier_nosync $SINGLEMDS
788 fail_abort $SINGLEMDS
789 # recreate shouldn't fail
790 createmany -o $DIR/$tfile--%d 10 ||
791 error "createmany recreate $DIR/$tfile failed"
795 run_test 33b "test fid seq allocation"
798 multiop_bg_pause $DIR/$tfile O_c ||
799 error "multiop_bg_pause $DIR/$tfile failed"
803 replay_barrier $SINGLEMDS
804 fail_abort $SINGLEMDS
805 kill -USR1 $pid || error "multiop $pid not running"
806 wait $pid || error "multiop $pid failed"
807 [ -e $DIR/$tfile ] && error "file $DIR/$tfile should not exist"
811 run_test 34 "abort recovery before client does replay (test mds_cleanup_orphans)"
813 # bug 2278 - generate one orphan on OST, then destroy it during recovery from llog
815 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
817 #define OBD_FAIL_MDS_REINT_NET_REP 0x119
818 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000119"
823 # give a chance to remove from MDS
824 fail_abort $SINGLEMDS
825 $CHECKSTAT -t file $DIR/$tfile &&
826 error "$CHECKSTAT $DIR/$tfile attribute check should fail" ||
829 run_test 35 "test recovery from llog for unlink op"
831 # b=2432 resent cancel after replay uses wrong cookie,
832 # so don't resend cancels
834 replay_barrier $SINGLEMDS
836 checkstat $DIR/$tfile
837 facet_failover $SINGLEMDS
839 if dmesg | grep "unknown lock cookie"; then
840 error "cancel after replay failed"
843 run_test 36 "don't resend cancel"
846 # directory orphans can't be unlinked from PENDING directory
848 rmdir $DIR/$tfile 2>/dev/null
849 multiop_bg_pause $DIR/$tfile dD_c ||
850 error "multiop_bg_pause $DIR/$tfile failed"
854 replay_barrier $SINGLEMDS
855 # clear the dmesg buffer so we only see errors from this recovery
856 do_facet $SINGLEMDS dmesg -c >/dev/null
857 fail_abort $SINGLEMDS
858 kill -USR1 $pid || error "multiop $pid not running"
859 do_facet $SINGLEMDS dmesg | grep "error .* unlinking .* from PENDING" &&
860 error "error unlinking files"
861 wait $pid || error "multiop $pid failed"
865 run_test 37 "abort recovery before client does replay (test mds_cleanup_orphans for directories)"
868 createmany -o $DIR/$tfile-%d 800 ||
869 error "createmany -o $DIR/$tfile failed"
870 unlinkmany $DIR/$tfile-%d 0 400 || error "unlinkmany $DIR/$tfile failed"
871 replay_barrier $SINGLEMDS
873 unlinkmany $DIR/$tfile-%d 400 400 ||
874 error "unlinkmany $DIR/$tfile 400 failed"
876 $CHECKSTAT -t file $DIR/$tfile-* &&
877 error "$CHECKSTAT $DIR/$tfile-* attribute check should fail" ||
880 run_test 38 "test recovery from unlink llog (test llog_gen_rec) "
882 test_39() { # bug 4176
883 createmany -o $DIR/$tfile-%d 800 ||
884 error "createmany -o $DIR/$tfile failed"
885 replay_barrier $SINGLEMDS
886 unlinkmany $DIR/$tfile-%d 0 400
888 unlinkmany $DIR/$tfile-%d 400 400 ||
889 error "unlinkmany $DIR/$tfile 400 failed"
891 $CHECKSTAT -t file $DIR/$tfile-* &&
892 error "$CHECKSTAT $DIR/$tfile-* attribute check should fail" ||
895 run_test 39 "test recovery from unlink llog (test llog_gen_rec) "
898 lctl get_param -n osc.*.stats | awk -vwrites=0 '/ost_write/ { writes += $2 } END { print writes; }'
903 # always need connection to MDS to verify layout during IO. LU-2628.
904 lctl get_param mdc.*.connect_flags | grep -q layout_lock &&
905 skip "layout_lock needs MDS connection for IO" && return 0
907 $LCTL mark multiop $MOUNT/$tfile OS_c
908 multiop $MOUNT/$tfile OS_c &
910 writeme -s $MOUNT/${tfile}-2 &
913 facet_failover $SINGLEMDS
914 #define OBD_FAIL_MDS_CONNECT_NET 0x117
915 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000117"
917 stat1=$(count_ost_writes)
919 stat2=$(count_ost_writes)
920 echo "$stat1, $stat2"
921 if [ $stat1 -lt $stat2 ]; then
922 echo "writes continuing during recovery"
925 echo "writes not continuing during recovery, bug 2477"
928 echo "waiting for writeme $WRITE_PID"
932 echo "waiting for multiop $PID"
933 wait $PID || error "multiop $PID failed"
934 do_facet client munlink $MOUNT/$tfile ||
935 error "munlink $MOUNT/$tfile failed"
936 do_facet client munlink $MOUNT/${tfile}-2 ||
937 error "munlink $MOUNT/$tfile-2 failed"
940 run_test 40 "cause recovery in ptlrpc, ensure IO continues"
943 # make sure that a read to one osc doesn't try to double-unlock its page just
944 # because another osc is invalid. trigger_group_io used to mistakenly return
945 # an error if any oscs were invalid even after having successfully put rpcs
946 # on valid oscs. This was fatal if the caller was ll_readpage who unlocked
947 # the page, guarnateeing that the unlock from the RPC completion would
948 # assert on trying to unlock the unlocked page.
950 [ $OSTCOUNT -lt 2 ] && skip_env "needs >= 2 OSTs" && return
952 local f=$MOUNT/$tfile
953 # make sure the start of the file is ost1
954 $LFS setstripe -S $((128 * 1024)) -i 0 $f
955 do_facet client dd if=/dev/zero of=$f bs=4k count=1 ||
956 error "dd on client failed"
958 # fail ost2 and read from ost1
959 local mdtosc=$(get_mdtosc_proc_path $SINGLEMDS $ost2_svc)
960 local osc2dev=$(do_facet $SINGLEMDS "lctl get_param -n devices" |
961 grep $mdtosc | awk '{print $1}')
962 [ -z "$osc2dev" ] && echo "OST: $ost2_svc" &&
963 lctl get_param -n devices &&
964 error "OST 2 $osc2dev does not exist"
965 do_facet $SINGLEMDS $LCTL --device $osc2dev deactivate ||
966 error "deactive device on $SINGLEMDS failed"
967 do_facet client dd if=$f of=/dev/null bs=4k count=1 ||
968 error "second dd on client failed"
969 do_facet $SINGLEMDS $LCTL --device $osc2dev activate ||
970 error "active device on $SINGLEMDS failed"
973 run_test 41 "read from a valid osc while other oscs are invalid"
975 # test MDS recovery after ost failure
977 blocks=$(df -P $MOUNT | tail -n 1 | awk '{ print $2 }')
978 createmany -o $DIR/$tfile-%d 800 ||
979 error "createmany -o $DIR/$tfile failed"
981 unlinkmany $DIR/$tfile-%d 0 400
983 lctl set_param debug=-1
986 # osc is evicted, fs is smaller (but only with failout OSTs (bug 7287)
987 #blocks_after=`df -P $MOUNT | tail -n 1 | awk '{ print $2 }'`
988 #[ $blocks_after -lt $blocks ] || return 1
989 echo "wait for MDS to timeout and recover"
990 sleep $((TIMEOUT * 2))
992 unlinkmany $DIR/$tfile-%d 400 400 ||
993 error "unlinkmany $DIR/$tfile 400 failed"
994 $CHECKSTAT -t file $DIR/$tfile-* &&
995 error "$CHECKSTAT $DIR/$tfile-* attribute check should fail" ||
998 run_test 42 "recovery after ost failure"
1000 # timeout in MDS/OST recovery RPC will LBUG MDS
1001 test_43() { # bug 2530
1002 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1004 replay_barrier $SINGLEMDS
1006 # OBD_FAIL_OST_CREATE_NET 0x204
1007 do_facet ost1 "lctl set_param fail_loc=0x80000204"
1013 run_test 43 "mds osc import failure during recovery; don't LBUG"
1015 test_44a() { # was test_44
1016 local at_max_saved=0
1018 local mdcdev=$($LCTL dl |
1019 awk "/${FSNAME}-MDT0000-mdc-/ {if (\$2 == \"UP\") {print \$1}}")
1020 [ "$mdcdev" ] || error "${FSNAME}-MDT0000-mdc- not UP"
1021 [ $(echo $mdcdev | wc -w) -eq 1 ] ||
1022 { $LCTL dl; error "looking for mdcdev=$mdcdev"; }
1024 # adaptive timeouts slow this way down
1025 if at_is_enabled; then
1026 at_max_saved=$(at_max_get mds)
1030 for i in $(seq 1 10); do
1031 echo "$i of 10 ($(date +%s))"
1032 do_facet $SINGLEMDS \
1033 "lctl get_param -n md[ts].*.mdt.timeouts | grep service"
1034 #define OBD_FAIL_TGT_CONN_RACE 0x701
1035 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000701"
1036 # lctl below may fail, it is valid case
1037 $LCTL --device $mdcdev recover
1040 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
1041 [ $at_max_saved -ne 0 ] && at_max_set $at_max_saved mds
1044 run_test 44a "race in target handle connect"
1047 local mdcdev=$($LCTL dl |
1048 awk "/${FSNAME}-MDT0000-mdc-/ {if (\$2 == \"UP\") {print \$1}}")
1049 [ "$mdcdev" ] || error "${FSNAME}-MDT0000-mdc not up"
1050 [ $(echo $mdcdev | wc -w) -eq 1 ] ||
1051 { echo mdcdev=$mdcdev; $LCTL dl;
1052 error "more than one ${FSNAME}-MDT0000-mdc"; }
1054 for i in $(seq 1 10); do
1055 echo "$i of 10 ($(date +%s))"
1056 do_facet $SINGLEMDS \
1057 "lctl get_param -n md[ts].*.mdt.timeouts | grep service"
1058 #define OBD_FAIL_TGT_DELAY_RECONNECT 0x704
1059 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000704"
1060 # lctl below may fail, it is valid case
1061 $LCTL --device $mdcdev recover
1066 run_test 44b "race in target handle connect"
1069 replay_barrier $SINGLEMDS
1070 createmany -m $DIR/$tfile-%d 100 || error "failed to create directories"
1071 #define OBD_FAIL_TGT_RCVG_FLAG 0x712
1072 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000712"
1073 fail_abort $SINGLEMDS
1074 unlinkmany $DIR/$tfile-%d 100 && error "unliked after fail abort"
1076 unlinkmany $DIR/$tfile-%d 100 && error "unliked after fail"
1079 run_test 44c "race in target handle connect"
1081 # Handle failed close
1083 local mdcdev=$($LCTL get_param -n devices |
1084 awk "/ ${FSNAME}-MDT0000-mdc-/ {print \$1}")
1085 [ "$mdcdev" ] || error "${FSNAME}-MDT0000-mdc not up"
1086 [ $(echo $mdcdev | wc -w) -eq 1 ] ||
1087 { echo mdcdev=$mdcdev; $LCTL dl;
1088 error "more than one ${FSNAME}-MDT0000-mdc"; }
1090 $LCTL --device $mdcdev recover ||
1091 error "$LCTL --device $mdcdev recover failed"
1093 multiop_bg_pause $DIR/$tfile O_c ||
1094 error "multiop_bg_pause $DIR/$tfile failed"
1097 # This will cause the CLOSE to fail before even
1098 # allocating a reply buffer
1099 $LCTL --device $mdcdev deactivate ||
1100 error "$LCTL --device $mdcdev deactivate failed"
1103 kill -USR1 $pid || error "multiop $pid not running"
1104 wait $pid || error "multiop $pid failed"
1106 $LCTL --device $mdcdev activate ||
1107 error "$LCTL --device $mdcdev activate failed"
1110 $CHECKSTAT -t file $DIR/$tfile ||
1111 error "$CHECKSTAT $DIR/$tfile attribute check failed"
1114 run_test 45 "Handle failed close"
1118 drop_reply "touch $DIR/$tfile"
1120 # ironically, the previous test, 45, will cause a real forced close,
1121 # so just look for one for this test
1122 dmesg | grep -i "force closing client file handle for $tfile" &&
1123 error "found force closing in dmesg"
1126 run_test 46 "Don't leak file handle after open resend (3325)"
1128 test_47() { # bug 2824
1129 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1131 # create some files to make sure precreate has been done on all
1132 # OSTs. (just in case this test is run independently)
1133 createmany -o $DIR/$tfile 20 ||
1134 error "createmany create $DIR/$tfile failed"
1136 # OBD_FAIL_OST_CREATE_NET 0x204
1138 do_facet ost1 "lctl set_param fail_loc=0x80000204"
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 # Without 2824, this createmany would hang
1146 createmany -o $DIR/$tfile 20 ||
1147 error "createmany recraete $DIR/$tfile failed"
1148 unlinkmany $DIR/$tfile 20 || error "unlinkmany $DIR/$tfile failed"
1152 run_test 47 "MDS->OSC failure during precreate cleanup (2824)"
1155 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1156 [ "$OSTCOUNT" -lt "2" ] && skip_env "needs >= 2 OSTs" && return
1158 replay_barrier $SINGLEMDS
1159 createmany -o $DIR/$tfile 20 ||
1160 error "createmany -o $DIR/$tfile failed"
1161 # OBD_FAIL_OST_EROFS 0x216
1162 facet_failover $SINGLEMDS
1163 do_facet ost1 "lctl set_param fail_loc=0x80000216"
1164 client_up || error "client_up failed"
1166 # let the MDS discover the OST failure, attempt to recover, fail
1167 # and recover again.
1168 sleep $((3 * TIMEOUT))
1170 createmany -o $DIR/$tfile 20 20 ||
1171 error "createmany recraete $DIR/$tfile failed"
1172 unlinkmany $DIR/$tfile 40 || error "unlinkmany $DIR/$tfile failed"
1175 run_test 48 "MDS->OSC failure during precreate cleanup (2824)"
1178 local mdtosc=$(get_mdtosc_proc_path $SINGLEMDS $ost1_svc)
1179 local oscdev=$(do_facet $SINGLEMDS "lctl get_param -n devices" |
1180 grep $mdtosc | awk '{print $1}')
1181 [ "$oscdev" ] || error "could not find OSC device on MDS"
1182 do_facet $SINGLEMDS $LCTL --device $oscdev recover ||
1183 error "OSC device $oscdev recovery failed"
1184 do_facet $SINGLEMDS $LCTL --device $oscdev recover ||
1185 error "second OSC device $oscdev recovery failed"
1186 # give the mds_lov_sync threads a chance to run
1189 run_test 50 "Double OSC recovery, don't LASSERT (3812)"
1191 # b3764 timed out lock replay
1193 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.6.90) ] &&
1194 skip "MDS prior to 2.6.90 handle LDLM_REPLY_NET incorrectly" &&
1197 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
1198 cancel_lru_locks mdc
1200 multiop_bg_pause $DIR/$tfile s_s || error "multiop $DIR/$tfile failed"
1203 #define OBD_FAIL_MDS_LDLM_REPLY_NET 0x157
1204 lctl set_param -n ldlm.cancel_unused_locks_before_replay "0"
1205 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000157"
1207 fail $SINGLEMDS || error "fail $SINGLEMDS failed"
1209 wait $mpid || error "multiop_bg_pause pid failed"
1211 do_facet $SINGLEMDS "lctl set_param fail_loc=0x0"
1212 lctl set_param fail_loc=0x0
1213 lctl set_param -n ldlm.cancel_unused_locks_before_replay "1"
1216 run_test 52 "time out lock replay (3764)"
1218 # bug 3462 - simultaneous MDC requests
1220 [[ $(lctl get_param mdc.*.import |
1221 grep "connect_flags:.*multi_mod_rpc") ]] ||
1222 { skip "Need MDC with 'multi_mod_rpcs' feature"; return 0; }
1224 cancel_lru_locks mdc # cleanup locks from former test cases
1225 mkdir $DIR/${tdir}-1 || error "mkdir $DIR/${tdir}-1 failed"
1226 mkdir $DIR/${tdir}-2 || error "mkdir $DIR/${tdir}-2 failed"
1227 multiop $DIR/${tdir}-1/f O_c &
1229 # give multiop a change to open
1232 #define OBD_FAIL_MDS_CLOSE_NET 0x115
1233 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000115"
1234 kill -USR1 $close_pid
1235 cancel_lru_locks mdc # force the close
1236 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
1238 mcreate $DIR/${tdir}-2/f || error "mcreate $DIR/${tdir}-2/f failed"
1240 # close should still be here
1241 [ -d /proc/$close_pid ] || error "close_pid doesn't exist"
1243 replay_barrier_nodf $SINGLEMDS
1245 wait $close_pid || error "close_pid $close_pid failed"
1247 $CHECKSTAT -t file $DIR/${tdir}-1/f ||
1248 error "$CHECKSTAT $DIR/${tdir}-1/f attribute check failed"
1249 $CHECKSTAT -t file $DIR/${tdir}-2/f ||
1250 error "$CHECKSTAT $DIR/${tdir}-2/f attribute check failed"
1251 rm -rf $DIR/${tdir}-*
1253 run_test 53a "|X| close request while two MDC requests in flight"
1256 cancel_lru_locks mdc # cleanup locks from former test cases
1258 mkdir $DIR/${tdir}-1 || error "mkdir $DIR/${tdir}-1 failed"
1259 mkdir $DIR/${tdir}-2 || error "mkdir $DIR/${tdir}-2 failed"
1260 multiop_bg_pause $DIR/${tdir}-1/f O_c ||
1261 error "multiop_bg_pause $DIR/${tdir}-1/f failed"
1264 #define OBD_FAIL_MDS_REINT_NET 0x107
1265 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000107"
1266 mcreate $DIR/${tdir}-2/f &
1270 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
1271 kill -USR1 $close_pid
1272 cancel_lru_locks mdc # force the close
1273 wait $close_pid || error "close_pid $close_pid failed"
1274 # open should still be here
1275 [ -d /proc/$open_pid ] || error "open_pid doesn't exist"
1277 replay_barrier_nodf $SINGLEMDS
1279 wait $open_pid || error "open_pid failed"
1281 $CHECKSTAT -t file $DIR/${tdir}-1/f ||
1282 error "$CHECKSTAT $DIR/${tdir}-1/f attribute check failed"
1283 $CHECKSTAT -t file $DIR/${tdir}-2/f ||
1284 error "$CHECKSTAT $DIR/${tdir}-2/f attribute check failed"
1285 rm -rf $DIR/${tdir}-*
1287 run_test 53b "|X| open request while two MDC requests in flight"
1290 cancel_lru_locks mdc # cleanup locks from former test cases
1292 mkdir $DIR/${tdir}-1 || error "mkdir $DIR/${tdir}-1 failed"
1293 mkdir $DIR/${tdir}-2 || error "mkdir $DIR/${tdir}-2 failed"
1294 multiop $DIR/${tdir}-1/f O_c &
1297 #define OBD_FAIL_MDS_REINT_NET 0x107
1298 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000107"
1299 mcreate $DIR/${tdir}-2/f &
1303 #define OBD_FAIL_MDS_CLOSE_NET 0x115
1304 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000115"
1305 kill -USR1 $close_pid
1306 cancel_lru_locks mdc # force the close
1308 #bz20647: make sure all pids exist before failover
1309 [ -d /proc/$close_pid ] || error "close_pid doesn't exist"
1310 [ -d /proc/$open_pid ] || error "open_pid doesn't exists"
1311 replay_barrier_nodf $SINGLEMDS
1312 fail_nodf $SINGLEMDS
1313 wait $open_pid || error "open_pid failed"
1315 # close should be gone
1316 [ -d /proc/$close_pid ] && error "close_pid should not exist"
1317 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
1319 $CHECKSTAT -t file $DIR/${tdir}-1/f ||
1320 error "$CHECKSTAT $DIR/${tdir}-1/f attribute check failed"
1321 $CHECKSTAT -t file $DIR/${tdir}-2/f ||
1322 error "$CHECKSTAT $DIR/${tdir}-2/f attribute check failed"
1323 rm -rf $DIR/${tdir}-*
1325 run_test 53c "|X| open request and close request while two MDC requests in flight"
1328 [[ $(lctl get_param mdc.*.import |
1329 grep "connect_flags:.*multi_mod_rpc") ]] ||
1330 { skip "Need MDC with 'multi_mod_rpcs' feature"; return 0; }
1332 cancel_lru_locks mdc # cleanup locks from former test cases
1334 mkdir $DIR/${tdir}-1 || error "mkdir $DIR/${tdir}-1 failed"
1335 mkdir $DIR/${tdir}-2 || error "mkdir $DIR/${tdir}-2 failed"
1336 multiop $DIR/${tdir}-1/f O_c &
1338 # give multiop a chance to open
1341 #define OBD_FAIL_MDS_CLOSE_NET_REP 0x13b
1342 do_facet $SINGLEMDS "lctl set_param fail_loc=0x8000013b"
1343 kill -USR1 $close_pid
1344 cancel_lru_locks mdc # force the close
1345 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
1346 mcreate $DIR/${tdir}-2/f || error "mcreate $DIR/${tdir}-2/f failed"
1348 # close should still be here
1349 [ -d /proc/$close_pid ] || error "close_pid doesn't exist"
1351 wait $close_pid || error "close_pid failed"
1353 $CHECKSTAT -t file $DIR/${tdir}-1/f ||
1354 error "$CHECKSTAT $DIR/${tdir}-1/f attribute check failed"
1355 $CHECKSTAT -t file $DIR/${tdir}-2/f ||
1356 error "$CHECKSTAT $DIR/${tdir}-2/f attribute check failed"
1357 rm -rf $DIR/${tdir}-*
1359 run_test 53d "close reply while two MDC requests in flight"
1362 cancel_lru_locks mdc # cleanup locks from former test cases
1364 mkdir $DIR/${tdir}-1 || error "mkdir $DIR/${tdir}-1 failed"
1365 mkdir $DIR/${tdir}-2 || error "mkdir $DIR/${tdir}-2 failed"
1366 multiop $DIR/${tdir}-1/f O_c &
1369 #define OBD_FAIL_MDS_REINT_NET_REP 0x119
1370 do_facet $SINGLEMDS "lctl set_param fail_loc=0x119"
1371 mcreate $DIR/${tdir}-2/f &
1375 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
1376 kill -USR1 $close_pid
1377 cancel_lru_locks mdc # force the close
1378 wait $close_pid || error "close_pid failed"
1379 # open should still be here
1380 [ -d /proc/$open_pid ] || error "open_pid doesn't exists"
1382 replay_barrier_nodf $SINGLEMDS
1384 wait $open_pid || error "open_pid failed"
1386 $CHECKSTAT -t file $DIR/${tdir}-1/f ||
1387 error "$CHECKSTAT $DIR/${tdir}-1/f attribute check failed"
1388 $CHECKSTAT -t file $DIR/${tdir}-2/f ||
1389 error "$CHECKSTAT $DIR/${tdir}-2/f attribute check failed"
1390 rm -rf $DIR/${tdir}-*
1392 run_test 53e "|X| open reply while two MDC requests in flight"
1395 cancel_lru_locks mdc # cleanup locks from former test cases
1397 mkdir $DIR/${tdir}-1 || error "mkdir $DIR/${tdir}-1 failed"
1398 mkdir $DIR/${tdir}-2 || error "mkdir $DIR/${tdir}-2 failed"
1399 multiop $DIR/${tdir}-1/f O_c &
1402 #define OBD_FAIL_MDS_REINT_NET_REP 0x119
1403 do_facet $SINGLEMDS "lctl set_param fail_loc=0x119"
1404 mcreate $DIR/${tdir}-2/f &
1408 #define OBD_FAIL_MDS_CLOSE_NET_REP 0x13b
1409 do_facet $SINGLEMDS "lctl set_param fail_loc=0x8000013b"
1410 kill -USR1 $close_pid
1411 cancel_lru_locks mdc # force the close
1413 #bz20647: make sure all pids are exists before failover
1414 [ -d /proc/$close_pid ] || error "close_pid doesn't exist"
1415 [ -d /proc/$open_pid ] || error "open_pid doesn't exists"
1416 replay_barrier_nodf $SINGLEMDS
1417 fail_nodf $SINGLEMDS
1418 wait $open_pid || error "open_pid failed"
1420 # close should be gone
1421 [ -d /proc/$close_pid ] && error "close_pid should not exist"
1422 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
1424 $CHECKSTAT -t file $DIR/${tdir}-1/f ||
1425 error "$CHECKSTAT $DIR/${tdir}-1/f attribute check failed"
1426 $CHECKSTAT -t file $DIR/${tdir}-2/f ||
1427 error "$CHECKSTAT $DIR/${tdir}-2/f attribute check failed"
1428 rm -rf $DIR/${tdir}-*
1430 run_test 53f "|X| open reply and close reply while two MDC requests in flight"
1433 cancel_lru_locks mdc # cleanup locks from former test cases
1435 mkdir $DIR/${tdir}-1 || error "mkdir $DIR/${tdir}-1 failed"
1436 mkdir $DIR/${tdir}-2 || error "mkdir $DIR/${tdir}-2 failed"
1437 multiop $DIR/${tdir}-1/f O_c &
1440 #define OBD_FAIL_MDS_REINT_NET_REP 0x119
1441 do_facet $SINGLEMDS "lctl set_param fail_loc=0x119"
1442 mcreate $DIR/${tdir}-2/f &
1446 #define OBD_FAIL_MDS_CLOSE_NET 0x115
1447 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000115"
1448 kill -USR1 $close_pid
1449 cancel_lru_locks mdc # force the close
1450 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
1452 #bz20647: make sure all pids are exists before failover
1453 [ -d /proc/$close_pid ] || error "close_pid doesn't exist"
1454 [ -d /proc/$open_pid ] || error "open_pid doesn't exists"
1455 replay_barrier_nodf $SINGLEMDS
1456 fail_nodf $SINGLEMDS
1457 wait $open_pid || error "open_pid failed"
1459 # close should be gone
1460 [ -d /proc/$close_pid ] && error "close_pid should not exist"
1462 $CHECKSTAT -t file $DIR/${tdir}-1/f ||
1463 error "$CHECKSTAT $DIR/${tdir}-1/f attribute check failed"
1464 $CHECKSTAT -t file $DIR/${tdir}-2/f ||
1465 error "$CHECKSTAT $DIR/${tdir}-2/f attribute check failed"
1466 rm -rf $DIR/${tdir}-*
1468 run_test 53g "|X| drop open reply and close request while close and open are both in flight"
1471 cancel_lru_locks mdc # cleanup locks from former test cases
1473 mkdir $DIR/${tdir}-1 || error "mkdir $DIR/${tdir}-1 failed"
1474 mkdir $DIR/${tdir}-2 || error "mkdir $DIR/${tdir}-2 failed"
1475 multiop $DIR/${tdir}-1/f O_c &
1478 #define OBD_FAIL_MDS_REINT_NET 0x107
1479 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000107"
1480 mcreate $DIR/${tdir}-2/f &
1484 #define OBD_FAIL_MDS_CLOSE_NET_REP 0x13b
1485 do_facet $SINGLEMDS "lctl set_param fail_loc=0x8000013b"
1486 kill -USR1 $close_pid
1487 cancel_lru_locks mdc # force the close
1490 #bz20647: make sure all pids are exists before failover
1491 [ -d /proc/$close_pid ] || error "close_pid doesn't exist"
1492 [ -d /proc/$open_pid ] || error "open_pid doesn't exists"
1493 replay_barrier_nodf $SINGLEMDS
1494 fail_nodf $SINGLEMDS
1495 wait $open_pid || error "open_pid failed"
1497 # close should be gone
1498 [ -d /proc/$close_pid ] && error "close_pid should not exist"
1499 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
1501 $CHECKSTAT -t file $DIR/${tdir}-1/f ||
1502 error "$CHECKSTAT $DIR/${tdir}-1/f attribute check failed"
1503 $CHECKSTAT -t file $DIR/${tdir}-2/f ||
1504 error "$CHECKSTAT $DIR/${tdir}-2/f attribute check failed"
1505 rm -rf $DIR/${tdir}-*
1507 run_test 53h "open request and close reply while two MDC requests in flight"
1509 #b3761 ASSERTION(hash != 0) failed
1511 # OBD_FAIL_MDS_OPEN_CREATE | OBD_FAIL_ONCE
1512 do_facet $SINGLEMDS "lctl set_param fail_loc=0x8000012b"
1514 # give touch a chance to run
1516 do_facet $SINGLEMDS "lctl set_param fail_loc=0x0"
1520 run_test 55 "let MDS_CHECK_RESENT return the original return code instead of 0"
1522 #b3440 ASSERTION(rec->ur_fid2->id) failed
1524 ln -s foo $DIR/$tfile
1525 replay_barrier $SINGLEMDS
1526 #drop_reply "cat $DIR/$tfile"
1530 run_test 56 "don't replay a symlink open request (3440)"
1532 #recovery one mds-ost setattr from llog
1534 #define OBD_FAIL_MDS_OST_SETATTR 0x12c
1535 do_facet $SINGLEMDS "lctl set_param fail_loc=0x8000012c"
1536 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
1537 replay_barrier $SINGLEMDS
1539 wait_recovery_complete $SINGLEMDS || error "MDS recovery is not done"
1540 wait_mds_ost_sync || error "wait_mds_ost_sync failed"
1541 $CHECKSTAT -t file $DIR/$tfile ||
1542 error "$CHECKSTAT $DIR/$tfile attribute check failed"
1543 do_facet $SINGLEMDS "lctl set_param fail_loc=0x0"
1546 run_test 57 "test recovery from llog for setattr op"
1549 zconf_umount $(hostname) $MOUNT2
1553 #recovery many mds-ost setattr from llog
1555 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
1556 #define OBD_FAIL_MDS_OST_SETATTR 0x12c
1557 do_facet $SINGLEMDS "lctl set_param fail_loc=0x8000012c"
1558 createmany -o $DIR/$tdir/$tfile-%d 2500
1559 replay_barrier $SINGLEMDS
1562 $CHECKSTAT -t file $DIR/$tdir/$tfile-* >/dev/null ||
1563 error "$CHECKSTAT $DIR/$tfile-* attribute check failed"
1564 do_facet $SINGLEMDS "lctl set_param fail_loc=0x0"
1565 unlinkmany $DIR/$tdir/$tfile-%d 2500 ||
1566 error "unlinkmany $DIR/$tfile failed"
1569 run_test 58a "test recovery from llog for setattr op (test llog_gen_rec)"
1575 trap cleanup_58 EXIT
1577 large_xattr_enabled &&
1578 orig="$(generate_string $(max_xattr_size))" || orig="bar"
1579 # Original extended attribute can be long. Print a small version of
1580 # attribute if an error occurs
1581 local sm_msg=$(printf "%.9s" $orig)
1583 mount_client $MOUNT2 || error "mount_client on $MOUNT2 failed"
1584 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
1585 touch $DIR/$tdir/$tfile || error "touch $DIR/$tdir/$tfile failed"
1586 replay_barrier $SINGLEMDS
1587 setfattr -n trusted.foo -v $orig $DIR/$tdir/$tfile
1589 new=$(get_xattr_value trusted.foo $MOUNT2/$tdir/$tfile)
1590 [[ "$new" = "$orig" ]] ||
1591 error "xattr set ($sm_msg...) differs from xattr get ($new)"
1592 rm -f $DIR/$tdir/$tfile
1595 wait_clients_import_state ${CLIENTS:-$HOSTNAME} "mgs" FULL
1597 run_test 58b "test replay of setxattr op"
1599 test_58c() { # bug 16570
1604 trap cleanup_58 EXIT
1606 if large_xattr_enabled; then
1607 local xattr_size=$(max_xattr_size)
1608 orig="$(generate_string $((xattr_size / 2)))"
1609 orig1="$(generate_string $xattr_size)"
1615 # PING_INTERVAL max(obd_timeout / 4, 1U)
1616 sleep $((TIMEOUT / 4))
1618 # Original extended attribute can be long. Print a small version of
1619 # attribute if an error occurs
1620 local sm_msg=$(printf "%.9s" $orig)
1621 local sm_msg1=$(printf "%.9s" $orig1)
1623 mount_client $MOUNT2 || error "mount_client on $MOUNT2 failed"
1624 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
1625 touch $DIR/$tdir/$tfile || error "touch $DIR/$tdir/$tfile failed"
1626 drop_request "setfattr -n trusted.foo -v $orig $DIR/$tdir/$tfile" ||
1627 error "drop_request for setfattr failed"
1628 new=$(get_xattr_value trusted.foo $MOUNT2/$tdir/$tfile)
1629 [[ "$new" = "$orig" ]] ||
1630 error "xattr set ($sm_msg...) differs from xattr get ($new)"
1631 drop_reint_reply "setfattr -n trusted.foo1 \
1632 -v $orig1 $DIR/$tdir/$tfile" ||
1633 error "drop_reint_reply for setfattr failed"
1634 new=$(get_xattr_value trusted.foo1 $MOUNT2/$tdir/$tfile)
1635 [[ "$new" = "$orig1" ]] ||
1636 error "second xattr set ($sm_msg1...) differs xattr get ($new)"
1637 rm -f $DIR/$tdir/$tfile
1641 run_test 58c "resend/reconstruct setxattr op"
1643 # log_commit_thread vs filter_destroy race used to lead to import use after free
1646 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1648 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
1649 createmany -o $DIR/$tdir/$tfile-%d 200 ||
1650 error "createmany create files failed"
1652 unlinkmany $DIR/$tdir/$tfile-%d 200 ||
1653 error "unlinkmany $DIR/$tdir/$tfile failed"
1654 #define OBD_FAIL_PTLRPC_DELAY_RECOV 0x507
1655 do_facet ost1 "lctl set_param fail_loc=0x507"
1658 do_facet ost1 "lctl set_param fail_loc=0x0"
1662 run_test 59 "test log_commit_thread vs filter_destroy race"
1664 # race between add unlink llog vs cat log init in post_recovery (only for b1_6)
1665 # bug 12086: should no oops and No ctxt error for this test
1667 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
1668 createmany -o $DIR/$tdir/$tfile-%d 200 ||
1669 error "createmany create files failed"
1670 replay_barrier $SINGLEMDS
1671 unlinkmany $DIR/$tdir/$tfile-%d 0 100
1673 unlinkmany $DIR/$tdir/$tfile-%d 100 100
1674 local no_ctxt=$(dmesg | grep "No ctxt")
1675 [ -z "$no_ctxt" ] || error "ctxt is not initialized in recovery"
1677 run_test 60 "test llog post recovery init vs llog unlink"
1679 #test race llog recovery thread vs llog cleanup
1680 test_61a() { # was test_61
1681 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1683 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
1684 createmany -o $DIR/$tdir/$tfile-%d 800 ||
1685 error "createmany create files failed"
1687 unlinkmany $DIR/$tdir/$tfile-%d 800
1688 # OBD_FAIL_OST_LLOG_RECOVERY_TIMEOUT 0x221
1689 set_nodes_failloc "$(osts_nodes)" 0x80000221
1694 set_nodes_failloc "$(osts_nodes)" 0x0
1696 $CHECKSTAT -t file $DIR/$tdir/$tfile-* &&
1697 error "$CHECKSTAT $DIR/$tdir/$tfile attribute check should fail"
1700 run_test 61a "test race llog recovery vs llog cleanup"
1702 #test race mds llog sync vs llog cleanup
1704 # OBD_FAIL_MDS_LLOG_SYNC_TIMEOUT 0x13a
1705 do_facet $SINGLEMDS "lctl set_param fail_loc=0x8000013a"
1706 facet_failover $SINGLEMDS
1709 do_facet client dd if=/dev/zero of=$DIR/$tfile bs=4k count=1 ||
1712 run_test 61b "test race mds llog sync vs llog cleanup"
1714 #test race cancel cookie cb vs llog cleanup
1716 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1718 # OBD_FAIL_OST_CANCEL_COOKIE_TIMEOUT 0x222
1719 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
1720 set_nodes_failloc "$(osts_nodes)" 0x80000222
1724 set_nodes_failloc "$(osts_nodes)" 0x0
1726 run_test 61c "test race mds llog sync vs llog cleanup"
1728 test_61d() { # bug 16002 # bug 17466 # bug 22137
1729 # OBD_FAIL_OBD_LLOG_SETUP 0x605
1731 do_facet mgs "lctl set_param fail_loc=0x80000605"
1732 start mgs $(mgsdevname) $MGS_MOUNT_OPTS &&
1733 error "mgs start should have failed"
1734 do_facet mgs "lctl set_param fail_loc=0"
1735 start mgs $(mgsdevname) $MGS_MOUNT_OPTS || error "cannot restart mgs"
1737 run_test 61d "error in llog_setup should cleanup the llog context correctly"
1739 test_62() { # Bug 15756 - don't mis-drop resent replay
1740 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
1741 replay_barrier $SINGLEMDS
1742 createmany -o $DIR/$tdir/$tfile- 25 ||
1743 error "createmany create files failed"
1744 #define OBD_FAIL_TGT_REPLAY_DROP 0x707
1745 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000707"
1747 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
1748 unlinkmany $DIR/$tdir/$tfile- 25 ||
1749 error "unlinkmany $DIR/$tdir/$tfile failed"
1752 run_test 62 "don't mis-drop resent replay"
1754 #Adaptive Timeouts (bug 3055)
1762 echo "Cleaning up AT ..."
1763 if [ -n "$ATOLDBASE" ]; then
1764 local at_history=$($LCTL get_param -n at_history)
1765 do_facet $SINGLEMDS "lctl set_param at_history=$at_history" || true
1766 do_facet ost1 "lctl set_param at_history=$at_history" || true
1769 if [ $AT_MAX_SET -ne 0 ]; then
1770 for facet in mds client ost; do
1771 var=AT_MAX_SAVE_${facet}
1772 echo restore AT on $facet to saved value ${!var}
1773 at_max_set ${!var} $facet
1774 at_new=$(at_max_get $facet)
1775 echo Restored AT value on $facet $at_new
1776 [ $at_new -eq ${!var} ] ||
1777 error "AT value not restored SAVED ${!var} NEW $at_new"
1784 local at_max_new=600
1786 # Save at_max original values
1788 if [ $AT_MAX_SET -eq 0 ]; then
1789 # Suppose that all osts have the same at_max
1790 for facet in mds client ost; do
1791 eval AT_MAX_SAVE_${facet}=$(at_max_get $facet)
1795 for facet in mds client ost; do
1796 at_max=$(at_max_get $facet)
1797 if [ $at_max -ne $at_max_new ]; then
1798 echo "AT value on $facet is $at_max, set it by force temporarily to $at_max_new"
1799 at_max_set $at_max_new $facet
1804 if [ -z "$ATOLDBASE" ]; then
1805 ATOLDBASE=$(do_facet $SINGLEMDS "lctl get_param -n at_history")
1806 # speed up the timebase so we can check decreasing AT
1807 do_facet $SINGLEMDS "lctl set_param at_history=8" || true
1808 do_facet ost1 "lctl set_param at_history=8" || true
1810 # sleep for a while to cool down, should be > 8s and also allow
1811 # at least one ping to be sent. simply use TIMEOUT to be safe.
1816 test_65a() #bug 3055
1818 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1820 at_start || return 0
1821 $LCTL dk > /dev/null
1823 $LCTL set_param debug="other"
1824 # Slow down a request to the current service time, this is critical
1825 # because previous tests may have caused this value to increase.
1826 REQ_DELAY=`lctl get_param -n mdc.${FSNAME}-MDT0000-mdc-*.timeouts |
1827 awk '/portal 12/ {print $5}'`
1828 REQ_DELAY=$((${REQ_DELAY} + ${REQ_DELAY} / 4 + 5))
1830 do_facet $SINGLEMDS lctl set_param fail_val=$((${REQ_DELAY} * 1000))
1831 #define OBD_FAIL_PTLRPC_PAUSE_REQ 0x50a
1832 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x8000050a
1833 createmany -o $DIR/$tfile 10 > /dev/null
1834 unlinkmany $DIR/$tfile 10 > /dev/null
1835 # check for log message
1836 $LCTL dk | grep "Early reply #" || error "No early reply"
1838 # client should show REQ_DELAY estimates
1839 lctl get_param -n mdc.${FSNAME}-MDT0000-mdc-*.timeouts | grep portal
1841 lctl get_param -n mdc.${FSNAME}-MDT0000-mdc-*.timeouts | grep portal
1843 run_test 65a "AT: verify early replies"
1845 test_65b() #bug 3055
1847 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1849 at_start || return 0
1852 $LCTL set_param debug="other trace"
1853 $LCTL dk > /dev/null
1854 # Slow down a request to the current service time, this is critical
1855 # because previous tests may have caused this value to increase.
1856 $LFS setstripe --stripe-index=0 --stripe-count=1 $DIR/$tfile ||
1857 error "$LFS setstripe failed for $DIR/$tfile"
1859 multiop $DIR/$tfile Ow1yc
1860 REQ_DELAY=`lctl get_param -n osc.${FSNAME}-OST0000-osc-*.timeouts |
1861 awk '/portal 6/ {print $5}'`
1862 REQ_DELAY=$((${REQ_DELAY} + ${REQ_DELAY} / 4 + 5))
1864 do_facet ost1 lctl set_param fail_val=${REQ_DELAY}
1865 #define OBD_FAIL_OST_BRW_PAUSE_PACK 0x224
1866 do_facet ost1 $LCTL set_param fail_loc=0x224
1869 $LFS setstripe --stripe-index=0 --stripe-count=1 $DIR/$tfile ||
1870 error "$LFS setstripe failed"
1871 # force some real bulk transfer
1872 multiop $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
1874 do_facet ost1 $LCTL set_param fail_loc=0
1875 # check for log message
1876 $LCTL dk | grep "Early reply #" || error "No early reply"
1878 # client should show REQ_DELAY estimates
1879 lctl get_param -n osc.${FSNAME}-OST0000-osc-*.timeouts | grep portal
1881 run_test 65b "AT: verify early replies on packed reply / bulk"
1883 test_66a() #bug 3055
1885 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1887 at_start || return 0
1888 lctl get_param -n mdc.${FSNAME}-MDT0000-mdc-*.timeouts | grep "portal 12"
1889 # adjust 5s at a time so no early reply is sent (within deadline)
1890 do_facet $SINGLEMDS "$LCTL set_param fail_val=5000"
1891 #define OBD_FAIL_PTLRPC_PAUSE_REQ 0x50a
1892 do_facet $SINGLEMDS "$LCTL set_param fail_loc=0x8000050a"
1893 createmany -o $DIR/$tfile 20 > /dev/null
1894 unlinkmany $DIR/$tfile 20 > /dev/null
1895 lctl get_param -n mdc.${FSNAME}-MDT0000-mdc-*.timeouts | grep "portal 12"
1896 do_facet $SINGLEMDS "$LCTL set_param fail_val=10000"
1897 do_facet $SINGLEMDS "$LCTL set_param fail_loc=0x8000050a"
1898 createmany -o $DIR/$tfile 20 > /dev/null
1899 unlinkmany $DIR/$tfile 20 > /dev/null
1900 lctl get_param -n mdc.${FSNAME}-MDT0000-mdc-*.timeouts | grep "portal 12"
1901 do_facet $SINGLEMDS "$LCTL set_param fail_loc=0"
1903 createmany -o $DIR/$tfile 20 > /dev/null
1904 unlinkmany $DIR/$tfile 20 > /dev/null
1905 lctl get_param -n mdc.${FSNAME}-MDT0000-mdc-*.timeouts | grep "portal 12"
1906 CUR=$(lctl get_param -n mdc.${FSNAME}-MDT0000-mdc-*.timeouts | awk '/portal 12/ {print $5}')
1907 WORST=$(lctl get_param -n mdc.${FSNAME}-MDT0000-mdc-*.timeouts | awk '/portal 12/ {print $7}')
1908 echo "Current MDT timeout $CUR, worst $WORST"
1909 [ $CUR -lt $WORST ] || error "Current $CUR should be less than worst $WORST"
1911 run_test 66a "AT: verify MDT service time adjusts with no early replies"
1913 test_66b() #bug 3055
1915 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1917 at_start || return 0
1918 ORIG=$(lctl get_param -n mdc.${FSNAME}-MDT0000*.timeouts |
1919 awk '/network/ {print $4}')
1920 $LCTL set_param fail_val=$(($ORIG + 5))
1921 #define OBD_FAIL_PTLRPC_PAUSE_REP 0x50c
1922 $LCTL set_param fail_loc=0x50c
1923 touch $DIR/$tfile > /dev/null 2>&1
1924 $LCTL set_param fail_loc=0
1925 CUR=$(lctl get_param -n mdc.${FSNAME}-MDT0000*.timeouts |
1926 awk '/network/ {print $4}')
1927 WORST=$(lctl get_param -n mdc.${FSNAME}-MDT0000*.timeouts |
1928 awk '/network/ {print $6}')
1929 echo "network timeout orig $ORIG, cur $CUR, worst $WORST"
1930 [ $WORST -gt $ORIG ] ||
1931 error "Worst $WORST should be worse than orig $ORIG"
1933 run_test 66b "AT: verify net latency adjusts"
1935 test_67a() #bug 3055
1937 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1939 at_start || return 0
1940 CONN1=$(lctl get_param -n osc.*.stats | awk '/_connect/ {total+=$2} END {print total}')
1941 # sleeping threads may drive values above this
1942 do_facet ost1 "$LCTL set_param fail_val=400"
1943 #define OBD_FAIL_PTLRPC_PAUSE_REQ 0x50a
1944 do_facet ost1 "$LCTL set_param fail_loc=0x50a"
1945 createmany -o $DIR/$tfile 20 > /dev/null
1946 unlinkmany $DIR/$tfile 20 > /dev/null
1947 do_facet ost1 "$LCTL set_param fail_loc=0"
1948 CONN2=$(lctl get_param -n osc.*.stats | awk '/_connect/ {total+=$2} END {print total}')
1949 ATTEMPTS=$(($CONN2 - $CONN1))
1950 echo "$ATTEMPTS osc reconnect attempts on gradual slow"
1951 [ $ATTEMPTS -gt 0 ] &&
1952 error_ignore bz13721 "AT should have prevented reconnect"
1955 run_test 67a "AT: verify slow request processing doesn't induce reconnects"
1957 test_67b() #bug 3055
1959 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1961 at_start || return 0
1962 CONN1=$(lctl get_param -n osc.*.stats | awk '/_connect/ {total+=$2} END {print total}')
1964 # exhaust precreations on ost1
1965 local OST=$(ostname_from_index 0)
1966 local mdtosc=$(get_mdtosc_proc_path mds $OST)
1967 local last_id=$(do_facet $SINGLEMDS lctl get_param -n \
1968 osc.$mdtosc.prealloc_last_id)
1969 local next_id=$(do_facet $SINGLEMDS lctl get_param -n \
1970 osc.$mdtosc.prealloc_next_id)
1972 mkdir -p $DIR/$tdir/${OST} || error "mkdir $DIR/$tdir/${OST} failed"
1973 $LFS setstripe -i 0 -c 1 $DIR/$tdir/${OST} ||
1974 error "$LFS setstripe failed"
1975 echo "Creating to objid $last_id on ost $OST..."
1976 #define OBD_FAIL_OST_PAUSE_CREATE 0x223
1977 do_facet ost1 "$LCTL set_param fail_val=20000"
1978 do_facet ost1 "$LCTL set_param fail_loc=0x80000223"
1979 createmany -o $DIR/$tdir/${OST}/f $next_id $((last_id - next_id + 2))
1982 do_facet ost1 "lctl get_param -n ost.OSS.ost_create.timeouts"
1984 CONN2=$(lctl get_param -n osc.*.stats | awk '/_connect/ {total+=$2} END {print total}')
1985 ATTEMPTS=$(($CONN2 - $CONN1))
1986 echo "$ATTEMPTS osc reconnect attempts on instant slow"
1987 # do it again; should not timeout
1988 do_facet ost1 "$LCTL set_param fail_loc=0x80000223"
1989 cp /etc/profile $DIR/$tfile || error "cp failed"
1990 do_facet ost1 "$LCTL set_param fail_loc=0"
1992 do_facet ost1 "lctl get_param -n ost.OSS.ost_create.timeouts"
1993 CONN3=$(lctl get_param -n osc.*.stats | awk '/_connect/ {total+=$2} END {print total}')
1994 ATTEMPTS=$(($CONN3 - $CONN2))
1995 echo "$ATTEMPTS osc reconnect attempts on 2nd slow"
1996 [ $ATTEMPTS -gt 0 ] && error "AT should have prevented reconnect"
1999 run_test 67b "AT: verify instant slowdown doesn't induce reconnects"
2001 test_68 () #bug 13813
2003 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
2005 at_start || return 0
2006 local ldlm_enqueue_min=$(find /sys -name ldlm_enqueue_min)
2007 [ -z "$ldlm_enqueue_min" ] && skip "missing /sys/.../ldlm_enqueue_min" && return 0
2008 local ldlm_enqueue_min_r=$(do_facet ost1 "find /sys -name ldlm_enqueue_min")
2009 [ -z "$ldlm_enqueue_min_r" ] && skip "missing /sys/.../ldlm_enqueue_min in the ost1" && return 0
2010 local ENQ_MIN=$(cat $ldlm_enqueue_min)
2011 local ENQ_MIN_R=$(do_facet ost1 "cat $ldlm_enqueue_min_r")
2012 echo $TIMEOUT >> $ldlm_enqueue_min
2013 do_facet ost1 "echo $TIMEOUT >> $ldlm_enqueue_min_r"
2015 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
2016 $LFS setstripe --stripe-index=0 -c 1 $DIR/$tdir ||
2017 error "$LFS setstripe failed for $DIR/$tdir"
2018 #define OBD_FAIL_LDLM_PAUSE_CANCEL 0x312
2019 $LCTL set_param fail_val=$(($TIMEOUT - 1))
2020 $LCTL set_param fail_loc=0x80000312
2021 cp /etc/profile $DIR/$tdir/${tfile}_1 || error "1st cp failed $?"
2022 $LCTL set_param fail_val=$((TIMEOUT * 5 / 4))
2023 $LCTL set_param fail_loc=0x80000312
2024 cp /etc/profile $DIR/$tdir/${tfile}_2 || error "2nd cp failed $?"
2025 $LCTL set_param fail_loc=0
2027 echo $ENQ_MIN >> $ldlm_enqueue_min
2028 do_facet ost1 "echo $ENQ_MIN_R >> $ldlm_enqueue_min_r"
2032 run_test 68 "AT: verify slowing locks"
2035 # end of AT tests includes above lines
2037 # start multi-client tests
2039 [ -z "$CLIENTS" ] &&
2040 { skip "Need two or more clients." && return; }
2041 [ $CLIENTCOUNT -lt 2 ] &&
2042 { skip "Need two or more clients, have $CLIENTCOUNT" && return; }
2044 echo "mount clients $CLIENTS ..."
2045 zconf_mount_clients $CLIENTS $MOUNT
2047 local clients=${CLIENTS//,/ }
2048 echo "Write/read files on $DIR ; clients $CLIENTS ... "
2049 for CLIENT in $clients; do
2050 do_node $CLIENT dd bs=1M count=10 if=/dev/zero \
2051 of=$DIR/${tfile}_${CLIENT} 2>/dev/null ||
2052 error "dd failed on $CLIENT"
2055 local prev_client=$(echo $clients | sed 's/^.* \(.\+\)$/\1/')
2056 for C in ${CLIENTS//,/ }; do
2057 do_node $prev_client dd if=$DIR/${tfile}_${C} \
2058 of=/dev/null 2>/dev/null ||
2059 error "dd if=$DIR/${tfile}_${C} failed on $prev_client"
2065 run_test 70a "check multi client t-f"
2067 check_for_process () {
2072 killall_process $clients "$prog" -0
2076 local clients=${CLIENTS:-$HOSTNAME}
2078 zconf_mount_clients $clients $MOUNT
2081 [ "$SLOW" = "no" ] && duration=120
2082 # set duration to 900 because it takes some time to boot node
2083 [ "$FAILURE_MODE" = HARD ] && duration=900
2086 local start_ts=$(date +%s)
2087 local cmd="rundbench 1 -t $duration"
2089 if [ $MDSCOUNT -ge 2 ]; then
2090 test_mkdir -p -c$MDSCOUNT $DIR/$tdir
2091 $LFS setdirstripe -D -c$MDSCOUNT $DIR/$tdir
2093 do_nodesv $clients "set -x; MISSING_DBENCH_OK=$MISSING_DBENCH_OK \
2094 PATH=\$PATH:$LUSTRE/utils:$LUSTRE/tests/:$DBENCH_LIB \
2095 DBENCH_LIB=$DBENCH_LIB TESTSUITE=$TESTSUITE TESTNAME=$TESTNAME \
2096 MOUNT=$MOUNT DIR=$DIR/$tdir/\\\$(hostname) LCTL=$LCTL $cmd" &
2099 #LU-1897 wait for all dbench copies to start
2100 while ! check_for_process $clients dbench; do
2101 elapsed=$(($(date +%s) - start_ts))
2102 if [ $elapsed -gt $duration ]; then
2103 killall_process $clients dbench
2104 error "dbench failed to start on $clients!"
2109 log "Started rundbench load pid=$pid ..."
2111 elapsed=$(($(date +%s) - start_ts))
2112 local num_failovers=0
2114 while [ $elapsed -lt $duration ]; do
2115 if ! check_for_process $clients dbench; then
2116 error_noexit "dbench stopped on some of $clients!"
2117 killall_process $clients dbench
2121 replay_barrier mds$fail_index
2122 sleep 1 # give clients a time to do operations
2123 # Increment the number of failovers
2124 num_failovers=$((num_failovers+1))
2125 log "$TESTNAME fail mds$fail_index $num_failovers times"
2127 elapsed=$(($(date +%s) - start_ts))
2128 if [ $fail_index -ge $MDSCOUNT ]; then
2131 fail_index=$((fail_index+1))
2135 wait $pid || error "rundbench load on $clients failed!"
2137 run_test 70b "dbench ${MDSCOUNT}mdts recovery; $CLIENTCOUNT clients"
2138 # end multi-client tests
2143 local monitor_pid=$3
2145 local start_ts=$(date +%s)
2146 local num_failovers=0
2149 elapsed=$(($(date +%s) - start_ts))
2150 while [ $elapsed -lt $duration ]; do
2151 fail_index=$((RANDOM%max_index+1))
2152 kill -0 $monitor_pid ||
2153 error "$monitor_pid stopped"
2155 replay_barrier mds$fail_index
2157 # Increment the number of failovers
2158 num_failovers=$((num_failovers+1))
2159 log "$TESTNAME fail mds$fail_index $num_failovers times"
2161 elapsed=$(($(date +%s) - start_ts))
2167 rm -f $DIR/replay-single.70c.lck
2172 local clients=${CLIENTS:-$HOSTNAME}
2175 zconf_mount_clients $clients $MOUNT
2178 [ "$SLOW" = "no" ] && duration=180
2179 # set duration to 900 because it takes some time to boot node
2180 [ "$FAILURE_MODE" = HARD ] && duration=600
2183 local start_ts=$(date +%s)
2185 trap cleanup_70c EXIT
2187 while [ ! -e $DIR/replay-single.70c.lck ]; do
2188 test_mkdir -p -c$MDSCOUNT $DIR/$tdir || break
2189 if [ $MDSCOUNT -ge 2 ]; then
2190 $LFS setdirstripe -D -c$MDSCOUNT $DIR/$tdir ||
2191 error "set default dirstripe failed"
2193 cd $DIR/$tdir || break
2194 tar cf - /etc | tar xf - || error "tar failed in loop"
2198 echo "Started tar $tar_70c_pid"
2200 random_fail_mdt $MDSCOUNT $duration $tar_70c_pid
2201 kill -0 $tar_70c_pid || error "tar $tar_70c_pid stopped"
2203 touch $DIR/replay-single.70c.lck
2204 wait $tar_70c_pid || error "$?: tar failed"
2209 run_test 70c "tar ${MDSCOUNT}mdts recovery"
2213 kill -9 $mkdir_70d_pid
2217 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2218 local clients=${CLIENTS:-$HOSTNAME}
2221 zconf_mount_clients $clients $MOUNT
2224 [ "$SLOW" = "no" ] && duration=180
2225 # set duration to 900 because it takes some time to boot node
2226 [ "$FAILURE_MODE" = HARD ] && duration=900
2231 local start_ts=$(date +%s)
2233 trap cleanup_70d EXIT
2236 $LFS mkdir -i0 -c2 $DIR/$tdir/test || {
2240 $LFS mkdir -i1 -c2 $DIR/$tdir/test1 || {
2245 touch $DIR/$tdir/test/a || {
2249 mkdir $DIR/$tdir/test/b || {
2253 rm -rf $DIR/$tdir/test || {
2259 touch $DIR/$tdir/test1/a || {
2263 mkdir $DIR/$tdir/test1/b || {
2268 rm -rf $DIR/$tdir/test1 || {
2270 ls -lR $DIR/$tdir/test1
2276 echo "Started $mkdir_70d_pid"
2278 random_fail_mdt $MDSCOUNT $duration $mkdir_70d_pid
2279 kill -0 $mkdir_70d_pid || error "mkdir/rmdir $mkdir_70d_pid stopped"
2284 run_test 70d "mkdir/rmdir striped dir ${MDSCOUNT}mdts recovery"
2287 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2288 local clients=${CLIENTS:-$HOSTNAME}
2291 lctl set_param debug=+ha
2292 zconf_mount_clients $clients $MOUNT
2295 [ "$SLOW" = "no" ] && duration=180
2296 # set duration to 900 because it takes some time to boot node
2297 [ "$FAILURE_MODE" = HARD ] && duration=900
2300 $LFS mkdir -i0 $DIR/$tdir/test_0
2301 $LFS mkdir -i0 $DIR/$tdir/test_1
2302 touch $DIR/$tdir/test_0/a
2303 touch $DIR/$tdir/test_1/b
2306 mrename $DIR/$tdir/test_0/a $DIR/$tdir/test_1/b > /dev/null || {
2311 checkstat $DIR/$tdir/test_0/a && {
2312 echo "a still exists"
2316 checkstat $DIR/$tdir/test_1/b || {
2317 echo "b still exists"
2321 touch $DIR/$tdir/test_0/a || {
2322 echo "touch a fails"
2326 mrename $DIR/$tdir/test_1/b $DIR/$tdir/test_0/a > /dev/null || {
2333 stack_trap "kill -9 $rename_70e_pid" EXIT
2334 echo "Started PID=$rename_70e_pid"
2336 random_fail_mdt 2 $duration $rename_70e_pid
2337 kill -0 $rename_70e_pid || error "rename $rename_70e_pid stopped"
2339 run_test 70e "rename cross-MDT with random fails"
2341 test_70f_write_and_read(){
2346 echo "Write/read files in: '$DIR/$tdir', clients: '$CLIENTS' ..."
2347 for client in ${CLIENTS//,/ }; do
2348 [ -f $stopflag ] || return
2350 local tgtfile=$DIR/$tdir/$tfile.$client
2351 do_node $client dd $DD_OPTS bs=1M count=10 if=$srcfile \
2352 of=$tgtfile 2>/dev/null ||
2353 error "dd $DD_OPTS bs=1M count=10 if=$srcfile " \
2354 "of=$tgtfile failed on $client, rc=$?"
2357 local prev_client=$(echo ${CLIENTS//,/ } | awk '{ print $NF }')
2360 for client in ${CLIENTS//,/ }; do
2361 [ -f $stopflag ] || return
2363 # flush client cache in case test is running on only one client
2364 # do_node $client cancel_lru_locks osc
2365 do_node $client $LCTL set_param ldlm.namespaces.*.lru_size=clear
2367 tgtfile=$DIR/$tdir/$tfile.$client
2368 local md5=$(do_node $prev_client "md5sum $tgtfile")
2369 [ ${checksum[$index]// */} = ${md5// */} ] ||
2370 error "$tgtfile: checksum doesn't match on $prev_client"
2371 index=$((index + 1))
2381 mkdir -p $DIR/$tdir || error "cannot create $DIR/$tdir directory"
2382 $LFS setstripe -c -1 $DIR/$tdir ||
2383 error "cannot $LFS setstripe $DIR/$tdir"
2386 while [ -f $stopflag ]; do
2387 test_70f_write_and_read $srcfile $stopflag
2388 # use direct IO and buffer cache in turns if loop
2389 [ -n "$DD_OPTS" ] && DD_OPTS="" || DD_OPTS="oflag=direct"
2393 test_70f_cleanup() {
2395 rm -f $TMP/$tfile.stop
2396 do_nodes $CLIENTS rm -f $TMP/$tfile
2397 rm -f $DIR/$tdir/$tfile.*
2401 # [ x$ost1failover_HOST = x$ost_HOST ] &&
2402 # { skip "Failover host not defined" && return; }
2403 # [ -z "$CLIENTS" ] &&
2404 # { skip "CLIENTS are not specified." && return; }
2405 # [ $CLIENTCOUNT -lt 2 ] &&
2406 # { skip "Need 2 or more clients, have $CLIENTCOUNT" && return; }
2408 [[ $(lustre_version_code ost1) -lt $(version_code 2.9.53) ]] &&
2409 skip "Need server version at least 2.9.53" && return
2411 echo "mount clients $CLIENTS ..."
2412 zconf_mount_clients $CLIENTS $MOUNT
2414 local srcfile=$TMP/$tfile
2418 trap test_70f_cleanup EXIT
2419 # create a different source file local to each client node so we can
2420 # detect if the file wasn't written out properly after failover
2421 do_nodes $CLIENTS dd bs=1M count=10 if=/dev/urandom of=$srcfile \
2422 2>/dev/null || error "can't create $srcfile on $CLIENTS"
2423 for client in ${CLIENTS//,/ }; do
2424 checksum[$index]=$(do_node $client "md5sum $srcfile")
2425 index=$((index + 1))
2429 [ "$SLOW" = "no" ] && duration=60
2430 # set duration to 900 because it takes some time to boot node
2431 [ "$FAILURE_MODE" = HARD ] && duration=900
2433 local stopflag=$TMP/$tfile.stop
2434 test_70f_loop $srcfile $stopflag &
2438 local num_failovers=0
2439 local start_ts=$SECONDS
2440 while [ $elapsed -lt $duration ]; do
2444 num_failovers=$((num_failovers + 1))
2445 log "$TESTNAME failing OST $num_failovers times"
2448 elapsed=$((SECONDS - start_ts))
2455 run_test 70f "OSS O_DIRECT recovery with $CLIENTCOUNT clients"
2459 kill -9 $mkdir_71a_pid
2462 random_double_fail_mdt() {
2465 local monitor_pid=$3
2467 local start_ts=$(date +%s)
2468 local num_failovers=0
2472 elapsed=$(($(date +%s) - start_ts))
2473 while [ $elapsed -lt $duration ]; do
2474 fail_index=$((RANDOM%max_index + 1))
2475 if [ $fail_index -eq $max_index ]; then
2478 second_index=$((fail_index + 1))
2480 kill -0 $monitor_pid ||
2481 error "$monitor_pid stopped"
2483 replay_barrier mds$fail_index
2484 replay_barrier mds$second_index
2486 # Increment the number of failovers
2487 num_failovers=$((num_failovers+1))
2488 log "fail mds$fail_index mds$second_index $num_failovers times"
2489 fail mds${fail_index},mds${second_index}
2490 elapsed=$(($(date +%s) - start_ts))
2495 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2496 local clients=${CLIENTS:-$HOSTNAME}
2499 zconf_mount_clients $clients $MOUNT
2502 [ "$SLOW" = "no" ] && duration=180
2503 # set duration to 900 because it takes some time to boot node
2504 [ "$FAILURE_MODE" = HARD ] && duration=900
2509 local start_ts=$(date +%s)
2511 trap cleanup_71a EXIT
2514 $LFS mkdir -i0 -c2 $DIR/$tdir/test
2515 rmdir $DIR/$tdir/test
2519 echo "Started $mkdir_71a_pid"
2521 random_double_fail_mdt 2 $duration $mkdir_71a_pid
2522 kill -0 $mkdir_71a_pid || error "mkdir/rmdir $mkdir_71a_pid stopped"
2527 run_test 71a "mkdir/rmdir striped dir with 2 mdts recovery"
2530 multiop_bg_pause $DIR/$tfile O_tSc ||
2531 error "multiop_bg_pause $DIR/$tfile failed"
2535 replay_barrier $SINGLEMDS
2536 #define OBD_FAIL_LDLM_ENQUEUE_NET 0x302
2537 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000302"
2540 wait $pid || error "multiop pid failed"
2541 [ -e $DIR/$tfile ] && error "file $DIR/$tfile should not exist"
2544 run_test 73a "open(O_CREAT), unlink, replay, reconnect before open replay, close"
2547 multiop_bg_pause $DIR/$tfile O_tSc ||
2548 error "multiop_bg_pause $DIR/$tfile failed"
2552 replay_barrier $SINGLEMDS
2553 #define OBD_FAIL_MDS_LDLM_REPLY_NET 0x157
2554 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000157"
2557 wait $pid || error "multiop pid failed"
2558 [ -e $DIR/$tfile ] && error "file $DIR/$tfile should not exist"
2561 run_test 73b "open(O_CREAT), unlink, replay, reconnect at open_replay reply, close"
2565 local clients=${CLIENTS:-$HOSTNAME}
2567 zconf_umount_clients $clients $MOUNT
2569 facet_failover $SINGLEMDS
2570 zconf_mount_clients $clients $MOUNT
2572 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
2573 rm $DIR/$tfile || error "rm $DIR/$tfile failed"
2574 clients_up || error "client evicted: $?"
2577 run_test 74 "Ensure applications don't fail waiting for OST recovery"
2579 remote_dir_check_80() {
2584 diridx=$($LFS getstripe -m $remote_dir) ||
2585 error "$LFS getstripe -m $remote_dir failed"
2586 [ $diridx -eq $mdtidx ] || error "$diridx != $mdtidx"
2588 createmany -o $remote_dir/f-%d 20 || error "creation failed"
2589 fileidx=$($LFS getstripe -m $remote_dir/f-1) ||
2590 error "$LFS getstripe -m $remote_dir/f-1 failed"
2591 [ $fileidx -eq $mdtidx ] || error "$fileidx != $mdtidx"
2597 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2598 ([ $FAILURE_MODE == "HARD" ] &&
2599 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
2600 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
2604 local remote_dir=$DIR/$tdir/remote_dir
2606 mkdir -p $DIR/$tdir || error "mkdir $DIR/$tdir failed"
2607 #define OBD_FAIL_OUT_UPDATE_NET_REP 0x1701
2608 do_facet mds${MDTIDX} lctl set_param fail_loc=0x1701
2609 $LFS mkdir -i $MDTIDX $remote_dir &
2615 wait $CLIENT_PID || error "remote creation failed"
2617 remote_dir_check_80 || error "remote dir check failed"
2618 rm -rf $DIR/$tdir || error "rmdir failed"
2622 run_test 80a "DNE: create remote dir, drop update rep from MDT0, fail MDT0"
2625 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2626 ([ $FAILURE_MODE == "HARD" ] &&
2627 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
2628 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
2632 local remote_dir=$DIR/$tdir/remote_dir
2634 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
2635 #define OBD_FAIL_OUT_UPDATE_NET_REP 0x1701
2636 do_facet mds${MDTIDX} lctl set_param fail_loc=0x1701
2637 $LFS mkdir -i $MDTIDX $remote_dir &
2642 fail mds$((MDTIDX + 1))
2644 wait $CLIENT_PID || error "remote creation failed"
2646 remote_dir_check_80 || error "remote dir check failed"
2647 rm -rf $DIR/$tdir || error "rmdir failed"
2651 run_test 80b "DNE: create remote dir, drop update rep from MDT0, fail MDT1"
2654 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2655 ([ $FAILURE_MODE == "HARD" ] &&
2656 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
2657 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
2661 local remote_dir=$DIR/$tdir/remote_dir
2663 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
2664 #define OBD_FAIL_OUT_UPDATE_NET_REP 0x1701
2665 do_facet mds${MDTIDX} lctl set_param fail_loc=0x1701
2666 $LFS mkdir -i $MDTIDX $remote_dir &
2672 fail mds$((MDTIDX + 1))
2674 wait $CLIENT_PID || error "remote creation failed"
2676 remote_dir_check_80 || error "remote dir check failed"
2677 rm -rf $DIR/$tdir || error "rmdir failed"
2681 run_test 80c "DNE: create remote dir, drop update rep from MDT1, fail MDT[0,1]"
2684 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2686 local remote_dir=$DIR/$tdir/remote_dir
2688 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
2689 #define OBD_FAIL_OUT_UPDATE_NET_REP 0x1701
2690 do_facet mds${MDTIDX} lctl set_param fail_loc=0x1701
2691 $LFS mkdir -i $MDTIDX $remote_dir &
2694 # sleep 3 seconds to make sure MDTs are failed after
2695 # lfs mkdir -i has finished on all of MDTs.
2700 fail mds${MDTIDX},mds$((MDTIDX + 1))
2702 wait $CLIENT_PID || error "remote creation failed"
2704 remote_dir_check_80 || error "remote dir check failed"
2705 rm -rf $DIR/$tdir || error "rmdir failed"
2709 run_test 80d "DNE: create remote dir, drop update rep from MDT1, fail 2 MDTs"
2712 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2713 ([ $FAILURE_MODE == "HARD" ] &&
2714 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
2715 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
2719 local remote_dir=$DIR/$tdir/remote_dir
2721 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
2722 # OBD_FAIL_MDS_REINT_NET_REP 0x119
2723 do_facet mds$((MDTIDX + 1)) lctl set_param fail_loc=0x119
2724 $LFS mkdir -i $MDTIDX $remote_dir &
2727 # sleep 3 seconds to make sure MDTs are failed after
2728 # lfs mkdir -i has finished on all of MDTs.
2734 wait $CLIENT_PID || error "remote creation failed"
2736 remote_dir_check_80 || error "remote dir check failed"
2737 rm -rf $DIR/$tdir || error "rmdir failed"
2741 run_test 80e "DNE: create remote dir, drop MDT1 rep, fail MDT0"
2744 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2745 ([ $FAILURE_MODE == "HARD" ] &&
2746 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
2747 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
2750 local remote_dir=$DIR/$tdir/remote_dir
2752 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
2753 # OBD_FAIL_MDS_REINT_NET_REP 0x119
2754 do_facet mds$((MDTIDX + 1)) lctl set_param fail_loc=0x119
2755 $LFS mkdir -i $MDTIDX $remote_dir &
2759 fail mds$((MDTIDX + 1))
2761 wait $CLIENT_PID || error "remote creation failed"
2763 remote_dir_check_80 || error "remote dir check failed"
2764 rm -rf $DIR/$tdir || error "rmdir failed"
2768 run_test 80f "DNE: create remote dir, drop MDT1 rep, fail MDT1"
2771 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2772 ([ $FAILURE_MODE == "HARD" ] &&
2773 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
2774 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
2778 local remote_dir=$DIR/$tdir/remote_dir
2780 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
2781 # OBD_FAIL_MDS_REINT_NET_REP 0x119
2782 do_facet mds$((MDTIDX + 1)) lctl set_param fail_loc=0x119
2783 $LFS mkdir -i $MDTIDX $remote_dir &
2786 # sleep 3 seconds to make sure MDTs are failed after
2787 # lfs mkdir -i has finished on all of MDTs.
2793 fail mds$((MDTIDX + 1))
2795 wait $CLIENT_PID || error "remote creation failed"
2797 remote_dir_check_80 || error "remote dir check failed"
2798 rm -rf $DIR/$tdir || error "rmdir failed"
2802 run_test 80g "DNE: create remote dir, drop MDT1 rep, fail MDT0, then MDT1"
2805 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2807 local remote_dir=$DIR/$tdir/remote_dir
2809 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
2810 # OBD_FAIL_MDS_REINT_NET_REP 0x119
2811 do_facet mds$((MDTIDX + 1)) lctl set_param fail_loc=0x119
2812 $LFS mkdir -i $MDTIDX $remote_dir &
2815 # sleep 3 seconds to make sure MDTs are failed after
2816 # lfs mkdir -i has finished on all of MDTs.
2821 fail mds${MDTIDX},mds$((MDTIDX + 1))
2823 wait $CLIENT_PID || error "remote dir creation failed"
2825 remote_dir_check_80 || error "remote dir check failed"
2826 rm -rf $DIR/$tdir || error "rmdir failed"
2830 run_test 80h "DNE: create remote dir, drop MDT1 rep, fail 2 MDTs"
2833 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2834 ([ $FAILURE_MODE == "HARD" ] &&
2835 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
2836 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
2840 local remote_dir=$DIR/$tdir/remote_dir
2842 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
2843 $LFS mkdir -i $MDTIDX $remote_dir || error "lfs mkdir failed"
2845 touch $remote_dir || error "touch $remote_dir failed"
2846 # OBD_FAIL_OUT_UPDATE_NET_REP 0x1701
2847 do_facet mds${MDTIDX} lctl set_param fail_loc=0x1701
2852 fail mds$((MDTIDX + 1))
2854 wait $CLIENT_PID || error "rm remote dir failed"
2856 stat $remote_dir &>/dev/null && error "$remote_dir still exist!"
2858 rm -rf $DIR/$tdir || error "rmdir failed"
2862 run_test 81a "DNE: unlink remote dir, drop MDT0 update rep, fail MDT1"
2865 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2866 ([ $FAILURE_MODE == "HARD" ] &&
2867 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
2868 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
2871 local remote_dir=$DIR/$tdir/remote_dir
2873 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
2874 $LFS mkdir -i $MDTIDX $remote_dir || error "lfs mkdir failed"
2876 # OBD_FAIL_OUT_UPDATE_NET_REP 0x1701
2877 do_facet mds${MDTIDX} lctl set_param fail_loc=0x1701
2884 wait $CLIENT_PID || error "rm remote dir failed"
2886 stat $remote_dir &>/dev/null && error "$remote_dir still exist!"
2888 rm -rf $DIR/$tdir || error "rmdir failed"
2892 run_test 81b "DNE: unlink remote dir, drop MDT0 update reply, fail MDT0"
2895 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2896 ([ $FAILURE_MODE == "HARD" ] &&
2897 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
2898 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
2902 local remote_dir=$DIR/$tdir/remote_dir
2904 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
2905 $LFS mkdir -i $MDTIDX $remote_dir || error "lfs mkdir failed"
2907 # OBD_FAIL_OUT_UPDATE_NET_REP 0x1701
2908 do_facet mds${MDTIDX} lctl set_param fail_loc=0x1701
2915 fail mds$((MDTIDX + 1))
2917 wait $CLIENT_PID || error "rm remote dir failed"
2919 stat $remote_dir &>/dev/null && error "$remote_dir still exist!"
2921 rm -rf $DIR/$tdir || error "rmdir failed"
2925 run_test 81c "DNE: unlink remote dir, drop MDT0 update reply, fail MDT0,MDT1"
2928 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2930 local remote_dir=$DIR/$tdir/remote_dir
2932 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
2933 $LFS mkdir -i $MDTIDX $remote_dir || error "lfs mkdir failed"
2935 # OBD_FAIL_OUT_UPDATE_NET_REP 0x1701
2936 do_facet mds${MDTIDX} lctl set_param fail_loc=0x1701
2942 fail mds${MDTIDX},mds$((MDTIDX + 1))
2944 wait $CLIENT_PID || error "rm remote dir failed"
2946 stat $remote_dir &>/dev/null && error "$remote_dir still exist!"
2948 rm -rf $DIR/$tdir || error "rmdir failed"
2952 run_test 81d "DNE: unlink remote dir, drop MDT0 update reply, fail 2 MDTs"
2955 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2956 ([ $FAILURE_MODE == "HARD" ] &&
2957 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
2958 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
2962 local remote_dir=$DIR/$tdir/remote_dir
2964 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
2965 $LFS mkdir -i $MDTIDX $remote_dir || error "lfs mkdir failed"
2967 # OBD_FAIL_MDS_REINT_NET_REP 0x119
2968 do_facet mds$((MDTIDX + 1)) lctl set_param fail_loc=0x119
2971 do_facet mds$((MDTIDX + 1)) lctl set_param fail_loc=0
2976 wait $CLIENT_PID || error "rm remote dir failed"
2978 stat $remote_dir &>/dev/null && error "$remote_dir still exist!"
2980 rm -rf $DIR/$tdir || error "rmdir failed"
2984 run_test 81e "DNE: unlink remote dir, drop MDT1 req reply, fail MDT0"
2987 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2988 ([ $FAILURE_MODE == "HARD" ] &&
2989 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
2990 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
2994 local remote_dir=$DIR/$tdir/remote_dir
2996 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
2997 $LFS mkdir -i $MDTIDX $remote_dir || error "lfs mkdir failed"
2999 # OBD_FAIL_MDS_REINT_NET_REP 0x119
3000 do_facet mds$((MDTIDX + 1)) lctl set_param fail_loc=0x119
3005 fail mds$((MDTIDX + 1))
3007 wait $CLIENT_PID || error "rm remote dir failed"
3009 stat $remote_dir &>/dev/null && error "$remote_dir still exist!"
3011 rm -rf $DIR/$tdir || error "rmdir failed"
3015 run_test 81f "DNE: unlink remote dir, drop MDT1 req reply, fail MDT1"
3018 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
3019 ([ $FAILURE_MODE == "HARD" ] &&
3020 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
3021 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
3025 local remote_dir=$DIR/$tdir/remote_dir
3027 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
3028 $LFS mkdir -i $MDTIDX $remote_dir || error "lfs mkdir failed"
3030 # OBD_FAIL_MDS_REINT_NET_REP 0x119
3031 do_facet mds$((MDTIDX + 1)) lctl set_param fail_loc=0x119
3038 fail mds$((MDTIDX + 1))
3040 wait $CLIENT_PID || error "rm remote dir failed"
3042 stat $remote_dir &>/dev/null && error "$remote_dir still exist!"
3044 rm -rf $DIR/$tdir || error "rmdir failed"
3048 run_test 81g "DNE: unlink remote dir, drop req reply, fail M0, then M1"
3051 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
3053 local remote_dir=$DIR/$tdir/remote_dir
3055 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
3056 $LFS mkdir -i $MDTIDX $remote_dir || error "lfs mkdir failed"
3058 # OBD_FAIL_MDS_REINT_NET_REP 0x119
3059 do_facet mds$((MDTIDX + 1)) lctl set_param fail_loc=0x119
3065 fail mds${MDTIDX},mds$((MDTIDX + 1))
3067 wait $CLIENT_PID || error "rm remote dir failed"
3069 stat $remote_dir &>/dev/null && error "$remote_dir still exist!"
3071 rm -rf $DIR/$tdir || error "rmdir failed"
3075 run_test 81h "DNE: unlink remote dir, drop request reply, fail 2 MDTs"
3078 #define OBD_FAIL_MDS_OPEN_WAIT_CREATE 0x144
3079 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000144"
3080 createmany -o $DIR/$tfile- 1 &
3084 client_up || client_up || true # reconnect
3086 run_test 84a "stale open during export disconnect"
3088 test_85a() { #bug 16774
3089 lctl set_param -n ldlm.cancel_unused_locks_before_replay "1"
3091 for i in $(seq 100); do
3092 echo "tag-$i" > $DIR/$tfile-$i
3093 grep -q "tag-$i" $DIR/$tfile-$i || error "f2-$i"
3096 lov_id=$(lctl dl | grep "clilov")
3097 addr=$(echo $lov_id | awk '{print $4}' | awk -F '-' '{print $NF}')
3098 count=$(lctl get_param -n \
3099 ldlm.namespaces.*MDT0000*$addr.lock_unused_count)
3100 echo "before recovery: unused locks count = $count"
3104 count2=$(lctl get_param -n \
3105 ldlm.namespaces.*MDT0000*$addr.lock_unused_count)
3106 echo "after recovery: unused locks count = $count2"
3108 if [ $count2 -ge $count ]; then
3109 error "unused locks are not canceled"
3112 run_test 85a "check the cancellation of unused locks during recovery(IBITS)"
3114 test_85b() { #bug 16774
3118 lctl set_param -n ldlm.cancel_unused_locks_before_replay "1"
3120 if ! combined_mgs_mds ; then
3124 $LFS setstripe -c 1 -i 0 $DIR/$tdir
3126 for i in $(seq 100); do
3127 dd if=/dev/urandom of=$DIR/$tdir/$tfile-$i bs=4096 \
3128 count=32 >/dev/null 2>&1
3131 cancel_lru_locks osc
3133 for i in $(seq 100); do
3134 dd if=$DIR/$tdir/$tfile-$i of=/dev/null bs=4096 \
3135 count=32 >/dev/null 2>&1
3138 lov_id=$(lctl dl | grep "clilov")
3139 addr=$(echo $lov_id | awk '{print $4}' | awk -F '-' '{print $NF}')
3140 count=$(lctl get_param -n \
3141 ldlm.namespaces.*OST0000*$addr.lock_unused_count)
3142 echo "before recovery: unused locks count = $count"
3143 [ $count -ne 0 ] || error "unused locks ($count) should be zero"
3147 count2=$(lctl get_param \
3148 -n ldlm.namespaces.*OST0000*$addr.lock_unused_count)
3149 echo "after recovery: unused locks count = $count2"
3151 if ! combined_mgs_mds ; then
3155 if [ $count2 -ge $count ]; then
3156 error "unused locks are not canceled"
3161 run_test 85b "check the cancellation of unused locks during recovery(EXTENT)"
3164 local clients=${CLIENTS:-$HOSTNAME}
3166 zconf_umount_clients $clients $MOUNT
3167 do_facet $SINGLEMDS lctl set_param mdt.${FSNAME}-MDT*.exports.clear=0
3168 remount_facet $SINGLEMDS
3169 zconf_mount_clients $clients $MOUNT
3171 run_test 86 "umount server after clear nid_stats should not hit LBUG"
3174 do_facet ost1 "lctl set_param -n obdfilter.${ost1_svc}.sync_journal 0"
3177 $LFS setstripe -i 0 -c 1 $DIR/$tfile
3178 dd if=/dev/urandom of=$DIR/$tfile bs=1024k count=8 ||
3179 error "dd to $DIR/$tfile failed"
3180 cksum=$(md5sum $DIR/$tfile | awk '{print $1}')
3181 cancel_lru_locks osc
3183 dd if=$DIR/$tfile of=/dev/null bs=1024k count=8 || error "Cannot read"
3184 cksum2=$(md5sum $DIR/$tfile | awk '{print $1}')
3185 if [ $cksum != $cksum2 ] ; then
3186 error "New checksum $cksum2 does not match original $cksum"
3189 run_test 87a "write replay"
3192 do_facet ost1 "lctl set_param -n obdfilter.${ost1_svc}.sync_journal 0"
3195 $LFS setstripe -i 0 -c 1 $DIR/$tfile
3196 dd if=/dev/urandom of=$DIR/$tfile bs=1024k count=8 ||
3197 error "dd to $DIR/$tfile failed"
3198 sleep 1 # Give it a chance to flush dirty data
3199 echo TESTTEST | dd of=$DIR/$tfile bs=1 count=8 seek=64
3200 cksum=$(md5sum $DIR/$tfile | awk '{print $1}')
3201 cancel_lru_locks osc
3203 dd if=$DIR/$tfile of=/dev/null bs=1024k count=8 || error "Cannot read"
3204 cksum2=$(md5sum $DIR/$tfile | awk '{print $1}')
3205 if [ $cksum != $cksum2 ] ; then
3206 error "New checksum $cksum2 does not match original $cksum"
3209 run_test 87b "write replay with changed data (checksum resend)"
3211 test_88() { #bug 17485
3212 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
3213 mkdir -p $TMP/$tdir || error "mkdir $TMP/$tdir failed"
3215 $LFS setstripe -i 0 -c 1 $DIR/$tdir || error "$LFS setstripe failed"
3218 replay_barrier $SINGLEMDS
3220 # exhaust precreations on ost1
3221 local OST=$(ostname_from_index 0)
3222 local mdtosc=$(get_mdtosc_proc_path $SINGLEMDS $OST)
3223 local last_id=$(do_facet $SINGLEMDS lctl get_param -n osc.$mdtosc.prealloc_last_id)
3224 local next_id=$(do_facet $SINGLEMDS lctl get_param -n osc.$mdtosc.prealloc_next_id)
3225 echo "before test: last_id = $last_id, next_id = $next_id"
3227 echo "Creating to objid $last_id on ost $OST..."
3228 createmany -o $DIR/$tdir/f-%d $next_id $((last_id - next_id + 2)) ||
3229 error "createmany create files to last_id failed"
3231 #create some files to use some uncommitted objids
3232 last_id=$(($last_id + 1))
3233 createmany -o $DIR/$tdir/f-%d $last_id 8 ||
3234 error "createmany create files with uncommitted objids failed"
3236 last_id2=$(do_facet $SINGLEMDS lctl get_param -n osc.$mdtosc.prealloc_last_id)
3237 next_id2=$(do_facet $SINGLEMDS lctl get_param -n osc.$mdtosc.prealloc_next_id)
3238 echo "before recovery: last_id = $last_id2, next_id = $next_id2"
3240 # if test uses shutdown_facet && reboot_facet instead of facet_failover ()
3241 # it has to take care about the affected facets, bug20407
3242 local affected_mds1=$(affected_facets mds1)
3243 local affected_ost1=$(affected_facets ost1)
3245 shutdown_facet $SINGLEMDS
3248 reboot_facet $SINGLEMDS
3249 change_active $affected_mds1
3250 wait_for_facet $affected_mds1
3251 mount_facets $affected_mds1 || error "Restart of mds failed"
3254 change_active $affected_ost1
3255 wait_for_facet $affected_ost1
3256 mount_facets $affected_ost1 || error "Restart of ost1 failed"
3260 last_id2=$(do_facet $SINGLEMDS lctl get_param -n osc.$mdtosc.prealloc_last_id)
3261 next_id2=$(do_facet $SINGLEMDS lctl get_param -n osc.$mdtosc.prealloc_next_id)
3262 echo "after recovery: last_id = $last_id2, next_id = $next_id2"
3264 # create new files, which should use new objids, and ensure the orphan
3265 # cleanup phase for ost1 is completed at the same time
3266 for i in $(seq 8); do
3267 file_id=$(($last_id + 10 + $i))
3268 dd if=/dev/urandom of=$DIR/$tdir/f-$file_id bs=4096 count=128
3271 # if the objids were not recreated, then "ls" will fail with -ENOENT
3272 ls -l $DIR/$tdir/* || error "can't get the status of precreated files"
3275 # write into previously created files
3276 for i in $(seq 8); do
3277 file_id=$(($last_id + $i))
3278 dd if=/dev/urandom of=$DIR/$tdir/f-$file_id bs=4096 count=128
3279 cp -f $DIR/$tdir/f-$file_id $TMP/$tdir/
3282 # compare the content
3283 for i in $(seq 8); do
3284 file_id=$(($last_id + $i))
3285 cmp $TMP/$tdir/f-$file_id $DIR/$tdir/f-$file_id ||
3286 error "the content of file is modified!"
3291 run_test 88 "MDS should not assign same objid to different files "
3293 function calc_osc_kbytes_used() {
3294 local kbtotal=$(calc_osc_kbytes kbytestotal)
3295 local kbfree=$(calc_osc_kbytes kbytesfree)
3296 echo $((kbtotal-kbfree))
3300 cancel_lru_locks osc
3301 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
3302 rm -f $DIR/$tdir/$tfile
3303 wait_mds_ost_sync || error "initial MDS-OST sync timed out"
3304 wait_delete_completed || error "initial wait delete timed out"
3305 local blocks1=$(calc_osc_kbytes_used)
3306 local write_size=$(fs_log_size)
3308 $LFS setstripe -i 0 -c 1 $DIR/$tdir/$tfile
3309 [ $write_size -lt 1024 ] && write_size=1024
3310 dd if=/dev/zero bs=${write_size}k count=10 of=$DIR/$tdir/$tfile
3313 facet_failover $SINGLEMDS
3314 rm $DIR/$tdir/$tfile
3317 zconf_mount $(hostname) $MOUNT || error "mount fails"
3318 client_up || error "client_up failed"
3320 # wait for the remounted client to connect to ost1
3321 local target=$(get_osc_import_name client ost1)
3322 wait_import_state "FULL" "osc.${target}.ost_server_uuid" \
3323 $(max_recovery_time)
3325 wait_mds_ost_sync || error "MDS-OST sync timed out"
3326 wait_delete_completed || error "wait delete timed out"
3327 local blocks2=$(calc_osc_kbytes_used)
3329 [ $((blocks2 - blocks1)) -le $(fs_log_size) ] ||
3330 error $((blocks2 - blocks1)) blocks leaked
3332 run_test 89 "no disk space leak on late ost connection"
3339 change_active $facet
3340 wait_for_facet $facet
3341 mount_facet $facet || error "Restart of $facet failed"
3345 test_90() { # bug 19494
3346 local dir=$DIR/$tdir
3347 local ostfail=$(get_random_entry $(get_facets OST))
3349 if [[ $FAILURE_MODE = HARD ]]; then
3350 local affected=$(affected_facets $ostfail);
3351 if [[ "$affected" != $ostfail ]]; then
3352 skip not functional with FAILURE_MODE=$FAILURE_MODE, affected: $affected
3356 # ensure all OSTs are active to allow allocations
3359 mkdir $dir || error "mkdir $dir failed"
3361 echo "Create the files"
3363 # file "f${index}" striped over 1 OST
3364 # file "all" striped over all OSTs
3366 $LFS setstripe -c $OSTCOUNT $dir/all ||
3367 error "setstripe failed to create $dir/all"
3369 for ((i = 0; i < $OSTCOUNT; i++)); do
3372 $LFS setstripe -i $i -c 1 $f ||
3373 error "$LFS setstripe failed to create $f"
3375 # confirm setstripe actually created stripe on requested OST
3376 local uuid=$(ostuuid_from_index $i)
3378 for file in f$i all; do
3379 local found=$($LFS find --obd $uuid --name $file $dir)
3381 if [[ $dir/$file != $found ]]; then
3382 $LFS getstripe $dir/$file
3383 error "wrong stripe: $file, uuid: $uuid"
3388 # Before failing an OST, get its obd name and index
3389 local varsvc=${ostfail}_svc
3390 local obd=$(do_facet $ostfail lctl get_param \
3391 -n obdfilter.${!varsvc}.uuid)
3392 local index=$(($(facet_number $ostfail) - 1))
3394 echo "Fail $ostfail $obd, display the list of affected files"
3395 shutdown_facet $ostfail || error "shutdown_facet $ostfail failed"
3397 trap "cleanup_90 $ostfail" EXIT INT
3398 echo "General Query: lfs find $dir"
3399 local list=$($LFS find $dir)
3401 for (( i=0; i<$OSTCOUNT; i++ )); do
3402 list_member "$list" $dir/f$i ||
3403 error_noexit "lfs find $dir: no file f$i"
3405 list_member "$list" $dir/all ||
3406 error_noexit "lfs find $dir: no file all"
3408 # focus on the missing OST,
3409 # we expect to see only two files affected: "f$(index)" and "all"
3411 echo "Querying files on shutdown $ostfail: lfs find --obd $obd"
3412 list=$($LFS find --obd $obd $dir)
3414 for file in all f$index; do
3415 list_member "$list" $dir/$file ||
3416 error_noexit "lfs find does not report the affected $obd for $file"
3419 [[ $(echo $list | wc -w) -eq 2 ]] ||
3420 error_noexit "lfs find reports the wrong list of affected files ${#list[@]}"
3422 echo "Check getstripe: $LFS getstripe -r --obd $obd"
3423 list=$($LFS getstripe -r --obd $obd $dir)
3425 for file in all f$index; do
3426 echo "$list" | grep $dir/$file ||
3427 error_noexit "lfs getsripe does not report the affected $obd for $file"
3432 run_test 90 "lfs find identifies the missing striped file segments"
3435 local server_version=$(lustre_version_code $SINGLEMDS)
3436 [[ $server_version -ge $(version_code 2.6.90) ]] ||
3437 [[ $server_version -ge $(version_code 2.5.4) &&
3438 $server_version -lt $(version_code 2.5.50) ]] ||
3439 { skip "Need MDS version 2.5.4+ or 2.6.90+"; return; }
3441 cancel_lru_locks osc
3443 $LFS setstripe -i 0 -c 1 $DIR/$tfile ||
3444 error "$LFS setstripe $DIR/$tfile failed"
3445 dd if=/dev/zero of=$DIR/$tfile bs=1024 count=1 ||
3446 error "dd to $DIR/$tfile failed"
3447 #define OBD_FAIL_TGT_REPLAY_RECONNECT 0x715
3448 # We need to emulate a state that OST is waiting for other clients
3449 # not completing the recovery. Final ping is queued, but reply will be
3450 # sent on the recovery completion. It is done by sleep before
3451 # processing final pings
3452 do_facet ost1 "$LCTL set_param fail_val=40"
3453 do_facet ost1 "$LCTL set_param fail_loc=0x715"
3456 run_test 93a "replay + reconnect"
3459 local server_version=$(lustre_version_code $SINGLEMDS)
3460 [[ $server_version -ge $(version_code 2.7.90) ]] ||
3461 { skip "Need MDS version 2.7.90+"; return; }
3463 cancel_lru_locks mdc
3465 createmany -o $DIR/$tfile 20 ||
3466 error "createmany -o $DIR/$tfile failed"
3468 #define OBD_FAIL_TGT_REPLAY_RECONNECT 0x715
3469 # We need to emulate a state that MDT is waiting for other clients
3470 # not completing the recovery. Final ping is queued, but reply will be
3471 # sent on the recovery completion. It is done by sleep before
3472 # processing final pings
3473 do_facet mds1 "$LCTL set_param fail_val=80"
3474 do_facet mds1 "$LCTL set_param fail_loc=0x715"
3477 run_test 93b "replay + reconnect on mds"
3479 striped_dir_check_100() {
3480 local striped_dir=$DIR/$tdir/striped_dir
3481 local stripe_count=$($LFS getdirstripe -c $striped_dir)
3483 $LFS getdirstripe $striped_dir
3484 [ $stripe_count -eq 2 ] || error "$stripe_count != 2"
3486 createmany -o $striped_dir/f-%d 20 ||
3487 error "creation failed under striped dir"
3491 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
3492 ([ $FAILURE_MODE == "HARD" ] &&
3493 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
3494 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
3497 local striped_dir=$DIR/$tdir/striped_dir
3500 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
3502 #To make sure MDT1 and MDT0 are connected
3503 #otherwise it may create single stripe dir here
3504 $LFS setdirstripe -i1 $DIR/$tdir/remote_dir
3506 #define OBD_FAIL_OUT_UPDATE_NET_REP 0x1701
3507 do_facet mds$((MDTIDX+1)) lctl set_param fail_loc=0x1701
3508 $LFS setdirstripe -i0 -c2 $striped_dir &
3511 fail mds$((MDTIDX + 1))
3513 wait $CLIENT_PID || error "striped dir creation failed"
3515 striped_dir_check_100 || error "striped dir check failed"
3516 rm -rf $DIR/$tdir || error "rmdir failed"
3518 run_test 100a "DNE: create striped dir, drop update rep from MDT1, fail MDT1"
3521 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
3522 ([ $FAILURE_MODE == "HARD" ] &&
3523 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
3524 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
3527 local striped_dir=$DIR/$tdir/striped_dir
3530 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
3532 #To make sure MDT1 and MDT0 are connected
3533 #otherwise it may create single stripe dir here
3534 $LFS setdirstripe -i1 $DIR/$tdir/remote_dir
3536 # OBD_FAIL_MDS_REINT_NET_REP 0x119
3537 do_facet mds$MDTIDX lctl set_param fail_loc=0x119
3538 $LFS mkdir -i0 -c2 $striped_dir &
3543 wait $CLIENT_PID || error "striped dir creation failed"
3545 striped_dir_check_100 || error "striped dir check failed"
3546 rm -rf $DIR/$tdir || error "rmdir failed"
3548 run_test 100b "DNE: create striped dir, fail MDT0"
3550 test_101() { #LU-5648
3551 mkdir -p $DIR/$tdir/d1
3552 mkdir -p $DIR/$tdir/d2
3553 touch $DIR/$tdir/file0
3556 replay_barrier $SINGLEMDS
3557 for i in $(seq $num) ; do
3558 echo test$i > $DIR/$tdir/d1/file$i
3561 fail_abort $SINGLEMDS
3562 for i in $(seq $num) ; do
3563 touch $DIR/$tdir/d2/file$i
3564 test -s $DIR/$tdir/d2/file$i &&
3565 ls -al $DIR/$tdir/d2/file$i && error "file$i's size > 0"
3570 run_test 101 "Shouldn't reassign precreated objs to other files after recovery"
3579 [[ $(lctl get_param mdc.*.import |
3580 grep "connect_flags:.*multi_mod_rpc") ]] ||
3581 { skip "Need MDC with 'multi_mod_rpcs' feature"; return 0; }
3583 $LFS mkdir -c1 $DIR/$tdir || error "mkdir $DIR/$tdir failed"
3584 idx=$(printf "%04x" $($LFS getdirstripe -i $DIR/$tdir))
3585 facet="mds$((0x$idx + 1))"
3587 # get current value of max_mod_rcps_in_flight
3588 num=$($LCTL get_param -n \
3589 mdc.$FSNAME-MDT$idx-mdc-*.max_mod_rpcs_in_flight)
3590 # set default value if client does not support multi mod RPCs
3591 [ -z "$num" ] && num=1
3593 echo "creating $num files ..."
3595 for i in $(seq $num); do
3596 touch $DIR/$tdir/file-$i
3599 # drop request on MDT to force resend
3600 #define OBD_FAIL_MDS_REINT_MULTI_NET 0x159
3601 do_facet $facet "$LCTL set_param fail_loc=0x159"
3602 echo "launch $num chmod in parallel ($(date +%H:%M:%S)) ..."
3603 for i in $(seq $num); do
3604 chmod 0600 $DIR/$tdir/file-$i &
3608 do_facet $facet "$LCTL set_param fail_loc=0"
3609 for pid in $pids; do
3610 wait $pid || error "chmod failed"
3612 echo "done ($(date +%H:%M:%S))"
3614 # check chmod succeed
3615 for i in $(seq $num); do
3616 checkstat -vp 0600 $DIR/$tdir/file-$i
3621 run_test 102a "check resend (request lost) with multiple modify RPCs in flight"
3630 [[ $(lctl get_param mdc.*.import |
3631 grep "connect_flags:.*multi_mod_rpc") ]] ||
3632 { skip "Need MDC with 'multi_mod_rpcs' feature"; return 0; }
3634 $LFS mkdir -c1 $DIR/$tdir || error "mkdir $DIR/$tdir failed"
3635 idx=$(printf "%04x" $($LFS getdirstripe -i $DIR/$tdir))
3636 facet="mds$((0x$idx + 1))"
3638 # get current value of max_mod_rcps_in_flight
3639 num=$($LCTL get_param -n \
3640 mdc.$FSNAME-MDT$idx-mdc-*.max_mod_rpcs_in_flight)
3641 # set default value if client does not support multi mod RPCs
3642 [ -z "$num" ] && num=1
3644 echo "creating $num files ..."
3646 for i in $(seq $num); do
3647 touch $DIR/$tdir/file-$i
3650 # drop reply on MDT to force reconstruction
3651 #define OBD_FAIL_MDS_REINT_MULTI_NET_REP 0x15a
3652 do_facet $facet "$LCTL set_param fail_loc=0x15a"
3653 echo "launch $num chmod in parallel ($(date +%H:%M:%S)) ..."
3654 for i in $(seq $num); do
3655 chmod 0600 $DIR/$tdir/file-$i &
3659 do_facet $facet "$LCTL set_param fail_loc=0"
3660 for pid in $pids; do
3661 wait $pid || error "chmod failed"
3663 echo "done ($(date +%H:%M:%S))"
3665 # check chmod succeed
3666 for i in $(seq $num); do
3667 checkstat -vp 0600 $DIR/$tdir/file-$i
3672 run_test 102b "check resend (reply lost) with multiple modify RPCs in flight"
3681 [[ $(lctl get_param mdc.*.import |
3682 grep "connect_flags:.*multi_mod_rpc") ]] ||
3683 { skip "Need MDC with 'multi_mod_rpcs' feature"; return 0; }
3685 $LFS mkdir -c1 $DIR/$tdir || error "mkdir $DIR/$tdir failed"
3686 idx=$(printf "%04x" $($LFS getdirstripe -i $DIR/$tdir))
3687 facet="mds$((0x$idx + 1))"
3689 # get current value of max_mod_rcps_in_flight
3690 num=$($LCTL get_param -n \
3691 mdc.$FSNAME-MDT$idx-mdc-*.max_mod_rpcs_in_flight)
3692 # set default value if client does not support multi mod RPCs
3693 [ -z "$num" ] && num=1
3695 echo "creating $num files ..."
3697 for i in $(seq $num); do
3698 touch $DIR/$tdir/file-$i
3701 replay_barrier $facet
3704 #define OBD_FAIL_MDS_REINT_MULTI_NET_REP 0x15a
3705 do_facet $facet "$LCTL set_param fail_loc=0x15a"
3706 echo "launch $num chmod in parallel ($(date +%H:%M:%S)) ..."
3707 for i in $(seq $num); do
3708 chmod 0600 $DIR/$tdir/file-$i &
3712 do_facet $facet "$LCTL set_param fail_loc=0"
3717 for pid in $pids; do
3718 wait $pid || error "chmod failed"
3720 echo "done ($(date +%H:%M:%S))"
3722 # check chmod succeed
3723 for i in $(seq $num); do
3724 checkstat -vp 0600 $DIR/$tdir/file-$i
3729 run_test 102c "check replay w/o reconstruction with multiple mod RPCs in flight"
3738 [[ $(lctl get_param mdc.*.import |
3739 grep "connect_flags:.*multi_mod_rpc") ]] ||
3740 { skip "Need MDC with 'multi_mod_rpcs' feature"; return 0; }
3742 $LFS mkdir -c1 $DIR/$tdir || error "mkdir $DIR/$tdir failed"
3743 idx=$(printf "%04x" $($LFS getdirstripe -i $DIR/$tdir))
3744 facet="mds$((0x$idx + 1))"
3746 # get current value of max_mod_rcps_in_flight
3747 num=$($LCTL get_param -n \
3748 mdc.$FSNAME-MDT$idx-mdc-*.max_mod_rpcs_in_flight)
3749 # set default value if client does not support multi mod RPCs
3750 [ -z "$num" ] && num=1
3752 echo "creating $num files ..."
3754 for i in $(seq $num); do
3755 touch $DIR/$tdir/file-$i
3759 #define OBD_FAIL_MDS_REINT_MULTI_NET_REP 0x15a
3760 do_facet $facet "$LCTL set_param fail_loc=0x15a"
3761 echo "launch $num chmod in parallel ($(date +%H:%M:%S)) ..."
3762 for i in $(seq $num); do
3763 chmod 0600 $DIR/$tdir/file-$i &
3768 # write MDT transactions to disk
3769 do_facet $facet "sync; sync; sync"
3771 do_facet $facet "$LCTL set_param fail_loc=0"
3776 for pid in $pids; do
3777 wait $pid || error "chmod failed"
3779 echo "done ($(date +%H:%M:%S))"
3781 # check chmod succeed
3782 for i in $(seq $num); do
3783 checkstat -vp 0600 $DIR/$tdir/file-$i
3788 run_test 102d "check replay & reconstruction with multiple mod RPCs in flight"
3791 remote_mds_nodsh && skip "remote MDS with nodsh" && return
3792 local mds_version=$(lustre_version_code $SINGLEMDS)
3793 [[ $mds_version -gt $(version_code 2.8.54) ]] ||
3794 { skip "Need MDS version 2.8.54+"; return; }
3796 #define OBD_FAIL_MDS_TRACK_OVERFLOW 0x162
3797 do_facet mds1 $LCTL set_param fail_loc=0x80000162
3800 createmany -o $DIR/$tdir/t- 30 ||
3801 error "create files on remote directory failed"
3803 rm -rf $DIR/$tdir/t-*
3805 #MDS should crash with tr->otr_next_id overflow
3808 run_test 103 "Check otr_next_id overflow"
3811 check_striped_dir_110()
3813 $CHECKSTAT -t dir $DIR/$tdir/striped_dir ||
3814 error "create striped dir failed"
3815 local stripe_count=$($LFS getdirstripe -c $DIR/$tdir/striped_dir)
3816 [ $stripe_count -eq $MDSCOUNT ] ||
3817 error "$stripe_count != 2 after recovery"
3821 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
3822 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.7.56) ]] ||
3823 skip "Need MDS version at least 2.7.56"
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"
3836 rm -rf $DIR/$tdir || error "rmdir failed"
3840 run_test 110a "DNE: create striped dir, fail MDT1"
3843 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
3844 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.7.56) ]] ||
3845 skip "Need MDS version at least 2.7.56"
3847 ([ $FAILURE_MODE == "HARD" ] &&
3848 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
3849 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
3854 $LFS mkdir -i1 -c$MDSCOUNT $DIR/$tdir/striped_dir
3857 zconf_mount $(hostname) $MOUNT
3858 client_up || return 1
3860 check_striped_dir_110 || error "check striped_dir failed"
3862 rm -rf $DIR/$tdir || error "rmdir failed"
3866 run_test 110b "DNE: create striped dir, fail MDT1 and client"
3869 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
3870 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.7.56) ]] ||
3871 skip "Need MDS version at least 2.7.56"
3873 ([ $FAILURE_MODE == "HARD" ] &&
3874 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
3875 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
3880 $LFS mkdir -i1 -c$MDSCOUNT $DIR/$tdir/striped_dir
3883 check_striped_dir_110 || error "check striped_dir failed"
3885 rm -rf $DIR/$tdir || error "rmdir failed"
3889 run_test 110c "DNE: create striped dir, fail MDT2"
3892 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
3893 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.7.56) ]] ||
3894 skip "Need MDS version at least 2.7.56"
3896 ([ $FAILURE_MODE == "HARD" ] &&
3897 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
3898 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
3903 $LFS mkdir -i1 -c$MDSCOUNT $DIR/$tdir/striped_dir
3906 zconf_mount $(hostname) $MOUNT
3907 client_up || return 1
3909 check_striped_dir_110 || error "check striped_dir failed"
3911 rm -rf $DIR/$tdir || error "rmdir failed"
3915 run_test 110d "DNE: create striped dir, fail MDT2 and client"
3918 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
3919 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.7.56) ]] ||
3920 skip "Need MDS version at least 2.7.56"
3922 ([ $FAILURE_MODE == "HARD" ] &&
3923 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
3924 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
3929 $LFS mkdir -i1 -c$MDSCOUNT $DIR/$tdir/striped_dir
3933 zconf_mount $(hostname) $MOUNT
3934 client_up || return 1
3936 check_striped_dir_110 || error "check striped_dir failed"
3938 rm -rf $DIR/$tdir || error "rmdir failed"
3942 run_test 110e "DNE: create striped dir, uncommit on MDT2, fail client/MDT1/MDT2"
3945 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
3946 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.7.56) ]] ||
3947 skip "Need MDS version at least 2.7.56"
3949 ([ $FAILURE_MODE == "HARD" ] &&
3950 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
3951 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
3957 $LFS mkdir -i1 -c$MDSCOUNT $DIR/$tdir/striped_dir
3960 check_striped_dir_110 || error "check striped_dir failed"
3962 rm -rf $DIR/$tdir || error "rmdir failed"
3966 run_test 110f "DNE: create striped dir, fail MDT1/MDT2"
3969 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
3970 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.7.56) ]] ||
3971 skip "Need MDS version at least 2.7.56"
3973 ([ $FAILURE_MODE == "HARD" ] &&
3974 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
3975 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
3980 $LFS mkdir -i1 -c$MDSCOUNT $DIR/$tdir/striped_dir
3984 zconf_mount $(hostname) $MOUNT
3985 client_up || return 1
3987 check_striped_dir_110 || error "check striped_dir failed"
3989 rm -rf $DIR/$tdir || error "rmdir failed"
3993 run_test 110g "DNE: create striped dir, uncommit on MDT1, fail client/MDT1/MDT2"
3996 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
3997 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.7.56) ]] ||
3998 skip "Need MDS version at least 2.7.56"
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
4011 $CHECKSTAT -t dir $DIR/$tdir/striped_dir &&
4012 error "striped dir still exists"
4015 run_test 111a "DNE: unlink striped dir, fail MDT1"
4018 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
4019 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.7.56) ]] ||
4020 skip "Need MDS version at least 2.7.56"
4022 ([ $FAILURE_MODE == "HARD" ] &&
4023 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
4024 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
4028 $LFS mkdir -i1 -c2 $DIR/$tdir/striped_dir
4030 rm -rf $DIR/$tdir/striped_dir
4033 zconf_mount $(hostname) $MOUNT
4034 client_up || return 1
4036 $CHECKSTAT -t dir $DIR/$tdir/striped_dir &&
4037 error "striped dir still exists"
4040 run_test 111b "DNE: unlink striped dir, fail MDT2"
4043 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
4044 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.7.56) ]] ||
4045 skip "Need MDS version at least 2.7.56"
4047 ([ $FAILURE_MODE == "HARD" ] &&
4048 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
4049 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
4053 $LFS mkdir -i1 -c2 $DIR/$tdir/striped_dir
4055 rm -rf $DIR/$tdir/striped_dir
4059 zconf_mount $(hostname) $MOUNT
4060 client_up || return 1
4061 $CHECKSTAT -t dir $DIR/$tdir/striped_dir &&
4062 error "striped dir still exists"
4065 run_test 111c "DNE: unlink striped dir, uncommit on MDT1, fail client/MDT1/MDT2"
4068 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
4069 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.7.56) ]] ||
4070 skip "Need MDS version at least 2.7.56"
4072 ([ $FAILURE_MODE == "HARD" ] &&
4073 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
4074 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
4078 $LFS mkdir -i1 -c2 $DIR/$tdir/striped_dir
4080 rm -rf $DIR/$tdir/striped_dir
4084 zconf_mount $(hostname) $MOUNT
4085 client_up || return 1
4086 $CHECKSTAT -t dir $DIR/$tdir/striped_dir &&
4087 error "striped dir still exists"
4091 run_test 111d "DNE: unlink striped dir, uncommit on MDT2, fail client/MDT1/MDT2"
4094 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
4095 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.7.56) ]] ||
4096 skip "Need MDS version at least 2.7.56"
4098 ([ $FAILURE_MODE == "HARD" ] &&
4099 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
4100 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
4104 $LFS mkdir -i1 -c2 $DIR/$tdir/striped_dir
4106 rm -rf $DIR/$tdir/striped_dir
4109 $CHECKSTAT -t dir $DIR/$tdir/striped_dir &&
4110 error "striped dir still exists"
4113 run_test 111e "DNE: unlink striped dir, uncommit on MDT2, fail MDT1/MDT2"
4116 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
4117 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.7.56) ]] ||
4118 skip "Need MDS version at least 2.7.56"
4120 ([ $FAILURE_MODE == "HARD" ] &&
4121 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
4122 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
4126 $LFS mkdir -i1 -c2 $DIR/$tdir/striped_dir
4128 rm -rf $DIR/$tdir/striped_dir
4131 $CHECKSTAT -t dir $DIR/$tdir/striped_dir &&
4132 error "striped dir still exists"
4135 run_test 111f "DNE: unlink striped dir, uncommit on MDT1, fail MDT1/MDT2"
4138 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
4139 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.7.56) ]] ||
4140 skip "Need MDS version at least 2.7.56"
4142 ([ $FAILURE_MODE == "HARD" ] &&
4143 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
4144 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
4148 $LFS mkdir -i1 -c2 $DIR/$tdir/striped_dir
4151 rm -rf $DIR/$tdir/striped_dir
4153 $CHECKSTAT -t dir $DIR/$tdir/striped_dir &&
4154 error "striped dir still exists"
4157 run_test 111g "DNE: unlink striped dir, fail MDT1/MDT2"
4159 test_112_rename_prepare() {
4160 mkdir -p $DIR/$tdir/src_dir
4161 $LFS mkdir -i 1 $DIR/$tdir/src_dir/src_child ||
4162 error "create remote source failed"
4164 touch $DIR/$tdir/src_dir/src_child/a
4166 $LFS mkdir -i 2 $DIR/$tdir/tgt_dir ||
4167 error "create remote target dir failed"
4169 $LFS mkdir -i 3 $DIR/$tdir/tgt_dir/tgt_child ||
4170 error "create remote target child failed"
4175 $CHECKSTAT -t dir $DIR/$tdir/src_dir/src_child &&
4176 error "src_child still exists after rename"
4178 $CHECKSTAT -t file $DIR/$tdir/tgt_dir/tgt_child/a ||
4179 error "missing file(a) after rename"
4183 [ $MDSCOUNT -lt 4 ] && skip "needs >= 4 MDTs" && return 0
4184 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.7.56) ]] ||
4185 skip "Need MDS version at least 2.7.56"
4187 ([ $FAILURE_MODE == "HARD" ] &&
4188 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
4189 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
4192 test_112_rename_prepare
4195 mrename $DIR/$tdir/src_dir/src_child $DIR/$tdir/tgt_dir/tgt_child ||
4196 error "rename dir cross MDT failed!"
4200 rm -rf $DIR/$tdir || error "rmdir failed"
4202 run_test 112a "DNE: cross MDT rename, fail MDT1"
4205 [ $MDSCOUNT -lt 4 ] && skip "needs >= 4 MDTs" && return 0
4206 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.7.56) ]] ||
4207 skip "Need MDS version at least 2.7.56"
4209 ([ $FAILURE_MODE == "HARD" ] &&
4210 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
4211 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
4214 test_112_rename_prepare
4217 mrename $DIR/$tdir/src_dir/src_child $DIR/$tdir/tgt_dir/tgt_child ||
4218 error "rename dir cross MDT failed!"
4223 rm -rf $DIR/$tdir || error "rmdir failed"
4225 run_test 112b "DNE: cross MDT rename, fail MDT2"
4228 [ $MDSCOUNT -lt 4 ] && skip "needs >= 4 MDTs" && return 0
4229 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.7.56) ]] ||
4230 skip "Need MDS version at least 2.7.56"
4232 ([ $FAILURE_MODE == "HARD" ] &&
4233 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
4234 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
4237 test_112_rename_prepare
4240 mrename $DIR/$tdir/src_dir/src_child $DIR/$tdir/tgt_dir/tgt_child ||
4241 error "rename dir cross MDT failed!"
4246 rm -rf $DIR/$tdir || error "rmdir failed"
4248 run_test 112c "DNE: cross MDT rename, fail MDT3"
4251 [ $MDSCOUNT -lt 4 ] && skip "needs >= 4 MDTs" && return 0
4252 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.7.56) ]] ||
4253 skip "Need MDS version at least 2.7.56"
4255 ([ $FAILURE_MODE == "HARD" ] &&
4256 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
4257 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
4260 test_112_rename_prepare
4263 mrename $DIR/$tdir/src_dir/src_child $DIR/$tdir/tgt_dir/tgt_child ||
4264 error "rename dir cross MDT failed!"
4269 rm -rf $DIR/$tdir || error "rmdir failed"
4271 run_test 112d "DNE: cross MDT rename, fail MDT4"
4274 [ $MDSCOUNT -lt 4 ] && skip "needs >= 4 MDTs" && return 0
4275 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.7.56) ]] ||
4276 skip "Need MDS version at least 2.7.56"
4278 ([ $FAILURE_MODE == "HARD" ] &&
4279 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
4280 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
4283 test_112_rename_prepare
4287 mrename $DIR/$tdir/src_dir/src_child $DIR/$tdir/tgt_dir/tgt_child ||
4288 error "rename dir cross MDT failed!"
4293 rm -rf $DIR/$tdir || error "rmdir failed"
4295 run_test 112e "DNE: cross MDT rename, fail MDT1 and MDT2"
4298 [ $MDSCOUNT -lt 4 ] && skip "needs >= 4 MDTs" && return 0
4299 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.7.56) ]] ||
4300 skip "Need MDS version at least 2.7.56"
4302 ([ $FAILURE_MODE == "HARD" ] &&
4303 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
4304 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
4307 test_112_rename_prepare
4311 mrename $DIR/$tdir/src_dir/src_child $DIR/$tdir/tgt_dir/tgt_child ||
4312 error "rename dir cross MDT failed!"
4317 rm -rf $DIR/$tdir || error "rmdir failed"
4319 run_test 112f "DNE: cross MDT rename, fail MDT1 and MDT3"
4322 [ $MDSCOUNT -lt 4 ] && skip "needs >= 4 MDTs" && return 0
4323 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.7.56) ]] ||
4324 skip "Need MDS version at least 2.7.56"
4326 ([ $FAILURE_MODE == "HARD" ] &&
4327 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
4328 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
4331 test_112_rename_prepare
4335 mrename $DIR/$tdir/src_dir/src_child $DIR/$tdir/tgt_dir/tgt_child ||
4336 error "rename dir cross MDT failed!"
4341 rm -rf $DIR/$tdir || error "rmdir failed"
4343 run_test 112g "DNE: cross MDT rename, fail MDT1 and MDT4"
4346 [ $MDSCOUNT -lt 4 ] && skip "needs >= 4 MDTs" && return 0
4347 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.7.56) ]] ||
4348 skip "Need MDS version at least 2.7.56"
4350 ([ $FAILURE_MODE == "HARD" ] &&
4351 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
4352 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
4355 test_112_rename_prepare
4359 mrename $DIR/$tdir/src_dir/src_child $DIR/$tdir/tgt_dir/tgt_child ||
4360 error "rename dir cross MDT failed!"
4365 rm -rf $DIR/$tdir || error "rmdir failed"
4367 run_test 112h "DNE: cross MDT rename, fail MDT2 and MDT3"
4370 [ $MDSCOUNT -lt 4 ] && skip "needs >= 4 MDTs" && return 0
4371 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.7.56) ]] ||
4372 skip "Need MDS version at least 2.7.56"
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
4383 mrename $DIR/$tdir/src_dir/src_child $DIR/$tdir/tgt_dir/tgt_child ||
4384 error "rename dir cross MDT failed!"
4389 rm -rf $DIR/$tdir || error "rmdir failed"
4391 run_test 112i "DNE: cross MDT rename, fail MDT2 and MDT4"
4394 [ $MDSCOUNT -lt 4 ] && skip "needs >= 4 MDTs" && return 0
4395 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.7.56) ]] ||
4396 skip "Need MDS version at least 2.7.56"
4398 ([ $FAILURE_MODE == "HARD" ] &&
4399 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
4400 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
4403 test_112_rename_prepare
4407 mrename $DIR/$tdir/src_dir/src_child $DIR/$tdir/tgt_dir/tgt_child ||
4408 error "rename dir cross MDT failed!"
4413 rm -rf $DIR/$tdir || error "rmdir failed"
4415 run_test 112j "DNE: cross MDT rename, fail MDT3 and MDT4"
4418 [ $MDSCOUNT -lt 4 ] && skip "needs >= 4 MDTs" && return 0
4419 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.7.56) ]] ||
4420 skip "Need MDS version at least 2.7.56"
4422 ([ $FAILURE_MODE == "HARD" ] &&
4423 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
4424 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
4427 test_112_rename_prepare
4432 mrename $DIR/$tdir/src_dir/src_child $DIR/$tdir/tgt_dir/tgt_child ||
4433 error "rename dir cross MDT failed!"
4438 rm -rf $DIR/$tdir || error "rmdir failed"
4440 run_test 112k "DNE: cross MDT rename, fail MDT1,MDT2,MDT3"
4443 [ $MDSCOUNT -lt 4 ] && skip "needs >= 4 MDTs" && return 0
4444 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.7.56) ]] ||
4445 skip "Need MDS version at least 2.7.56"
4447 ([ $FAILURE_MODE == "HARD" ] &&
4448 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
4449 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
4452 test_112_rename_prepare
4457 mrename $DIR/$tdir/src_dir/src_child $DIR/$tdir/tgt_dir/tgt_child ||
4458 error "rename dir cross MDT failed!"
4463 rm -rf $DIR/$tdir || error "rmdir failed"
4465 run_test 112l "DNE: cross MDT rename, fail MDT1,MDT2,MDT4"
4468 [ $MDSCOUNT -lt 4 ] && skip "needs >= 4 MDTs" && return 0
4469 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.7.56) ]] ||
4470 skip "Need MDS version at least 2.7.56"
4472 ([ $FAILURE_MODE == "HARD" ] &&
4473 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
4474 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
4477 test_112_rename_prepare
4482 mrename $DIR/$tdir/src_dir/src_child $DIR/$tdir/tgt_dir/tgt_child ||
4483 error "rename dir cross MDT failed!"
4488 rm -rf $DIR/$tdir || error "rmdir failed"
4490 run_test 112m "DNE: cross MDT rename, fail MDT1,MDT3,MDT4"
4493 [ $MDSCOUNT -lt 4 ] && skip "needs >= 4 MDTs" && return 0
4494 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.7.56) ]] ||
4495 skip "Need MDS version at least 2.7.56"
4497 ([ $FAILURE_MODE == "HARD" ] &&
4498 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
4499 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
4502 test_112_rename_prepare
4507 mrename $DIR/$tdir/src_dir/src_child $DIR/$tdir/tgt_dir/tgt_child ||
4508 error "rename dir cross MDT failed!"
4513 rm -rf $DIR/$tdir || error "rmdir failed"
4515 run_test 112n "DNE: cross MDT rename, fail MDT2,MDT3,MDT4"
4518 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
4519 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.7.56) ]] ||
4520 skip "Need MDS version at least 2.7.56"
4522 ([ $FAILURE_MODE == "HARD" ] &&
4523 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
4524 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
4532 for ((j=0;j<$((MDSCOUNT));j++)); do
4533 fail_index=$((fail_index+1))
4534 index=$((fail_index % MDSCOUNT))
4535 replay_barrier mds$((index + 1))
4536 for ((i=0;i<5;i++)); do
4537 test_mkdir -i$index -c$MDSCOUNT $DIR/$tdir/test_$i ||
4538 error "create striped dir $DIR/$tdir/test_$i"
4541 fail mds$((index + 1))
4542 for ((i=0;i<5;i++)); do
4543 checkstat -t dir $DIR/$tdir/test_$i ||
4544 error "$DIR/$tdir/test_$i does not exist!"
4546 rm -rf $DIR/$tdir/test_* ||
4550 run_test 115 "failover for create/unlink striped directory"
4553 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
4554 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.55) ] &&
4555 skip "Do not support large update log before 2.7.55" &&
4557 ([ $FAILURE_MODE == "HARD" ] &&
4558 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
4559 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
4566 # OBD_FAIL_SPLIT_UPDATE_REC 0x1702
4567 do_facet mds1 "lctl set_param fail_loc=0x80001702"
4568 $LFS setdirstripe -i0 -c$MDSCOUNT $DIR/$tdir/striped_dir
4571 $CHECKSTAT -t dir $DIR/$tdir/striped_dir ||
4572 error "stried_dir does not exists"
4574 run_test 116a "large update log master MDT recovery"
4577 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
4578 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.55) ] &&
4579 skip "Do not support large update log before 2.7.55" &&
4582 ([ $FAILURE_MODE == "HARD" ] &&
4583 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
4584 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
4591 # OBD_FAIL_SPLIT_UPDATE_REC 0x1702
4592 do_facet mds2 "lctl set_param fail_loc=0x80001702"
4593 $LFS setdirstripe -i0 -c$MDSCOUNT $DIR/$tdir/striped_dir
4596 $CHECKSTAT -t dir $DIR/$tdir/striped_dir ||
4597 error "stried_dir does not exists"
4599 run_test 116b "large update log slave MDT recovery"
4602 [ $MDSCOUNT -lt 4 ] && skip "needs >= 4 MDTs" && return 0
4603 ([ $FAILURE_MODE == "HARD" ] &&
4604 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
4605 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
4611 $LFS setdirstripe -i0 -c$MDSCOUNT $DIR/$tdir/remote_dir
4612 $LFS setdirstripe -i1 -c$MDSCOUNT $DIR/$tdir/remote_dir_1
4615 # Let's set rdonly on all MDTs, so client will send
4616 # replay requests on all MDTs and replay these requests
4617 # at the same time. This test will verify the recovery
4618 # will not be deadlock in this case, LU-7531.
4619 for ((index = 0; index < $((MDSCOUNT)); index++)); do
4620 replay_barrier mds$((index + 1))
4621 if [ -z $mds_indexs ]; then
4622 mds_indexs="${mds_indexs}mds$((index+1))"
4624 mds_indexs="${mds_indexs},mds$((index+1))"
4628 rm -rf $DIR/$tdir/remote_dir
4629 rm -rf $DIR/$tdir/remote_dir_1
4633 rm -rf $DIR/$tdir || error "rmdir failed"
4635 run_test 117 "DNE: cross MDT unlink, fail MDT1 and MDT2"
4638 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
4639 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.64) ] &&
4640 skip "Do not support large update log before 2.7.64" &&
4645 $LFS setdirstripe -c2 $DIR/$tdir/striped_dir ||
4646 error "setdirstripe fails"
4647 $LFS setdirstripe -c2 $DIR/$tdir/striped_dir1 ||
4648 error "setdirstripe fails 1"
4649 rm -rf $DIR/$tdir/striped_dir* || error "rmdir fails"
4651 # OBD_FAIL_INVALIDATE_UPDATE 0x1705
4652 do_facet mds1 "lctl set_param fail_loc=0x1705"
4653 $LFS setdirstripe -c2 $DIR/$tdir/striped_dir
4654 $LFS setdirstripe -c2 $DIR/$tdir/striped_dir1
4655 do_facet mds1 "lctl set_param fail_loc=0x0"
4658 $LFS setdirstripe -c2 $DIR/$tdir/striped_dir
4659 $LFS setdirstripe -c2 $DIR/$tdir/striped_dir1
4664 run_test 118 "invalidate osp update will not cause update log corruption"
4667 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
4668 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.64) ] &&
4669 skip "Do not support large update log before 2.7.64" &&
4672 local hard_timeout=$(do_facet mds1 \
4673 "lctl get_param -n mdt.$FSNAME-MDT0000.recovery_time_hard")
4675 local clients=${CLIENTS:-$HOSTNAME}
4676 local time_min=$(recovery_time_min)
4679 mkdir $DIR/$tdir/tmp
4680 rmdir $DIR/$tdir/tmp
4683 mkdir $DIR/$tdir/dir_1
4684 for ((i = 0; i < 20; i++)); do
4685 $LFS setdirstripe -i0 -c2 $DIR/$tdir/stripe_dir-$i
4692 #define OBD_FAIL_TGT_REPLAY_DELAY 0x714
4693 do_facet mds1 $LCTL set_param fail_loc=0x80000714
4694 #sleep (timeout + 5), so mds will evict the client exports,
4695 #but DNE update recovery will keep going.
4696 do_facet mds1 $LCTL set_param fail_val=$((time_min + 5))
4698 mount_facet mds1 "-o recovery_time_hard=$time_min"
4700 wait_clients_import_state "$clients" mds1 FULL
4702 clients_up || clients_up || error "failover df: $?"
4704 #revert back the hard timeout
4705 do_facet mds1 $LCTL set_param \
4706 mdt.$FSNAME-MDT0000.recovery_time_hard=$hard_timeout
4708 for ((i = 0; i < 20; i++)); do
4709 stripe_count=$($LFS getdirstripe -c $DIR/$tdir/stripe_dir-$i)
4710 [ $stripe_count == 2 ] || {
4711 error "stripe_dir-$i creation replay fails"
4716 run_test 119 "timeout of normal replay does not cause DNE replay fails "
4719 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
4720 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.64) ] &&
4721 skip "Do not support large update log before 2.7.64" &&
4725 replay_barrier_nosync mds1
4726 for ((i = 0; i < 20; i++)); do
4727 mkdir $DIR/$tdir/dir-$i || {
4728 error "create dir-$i fails"
4731 $LFS setdirstripe -i0 -c2 $DIR/$tdir/stripe_dir-$i || {
4732 error "create stripe_dir-$i fails"
4739 for ((i = 0; i < 20; i++)); do
4740 [ ! -e "$DIR/$tdir/dir-$i" ] || {
4741 error "dir-$i still exists"
4744 [ ! -e "$DIR/$tdir/stripe_dir-$i" ] || {
4745 error "stripe_dir-$i still exists"
4750 run_test 120 "DNE fail abort should stop both normal and DNE replay"
4753 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.10.90) ] &&
4754 skip "Don't support it before 2.11" &&
4757 local at_max_saved=$(at_max_get mds)
4759 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
4760 cancel_lru_locks mdc
4762 multiop_bg_pause $DIR/$tfile s_s || error "multiop $DIR/$tfile failed"
4765 lctl set_param -n ldlm.cancel_unused_locks_before_replay "0"
4771 #define OBD_FAIL_TGT_RECOVERY_REQ_RACE 0x721
4772 do_facet $SINGLEMDS "lctl set_param fail_loc=0x721 fail_val=0"
4776 wait_clients_import_state "$clients" mds1 FULL
4777 clients_up || clients_up || error "failover df: $?"
4780 wait $mpid || error "multiop_bg_pause pid failed"
4782 do_facet $SINGLEMDS "lctl set_param fail_loc=0x0"
4783 lctl set_param -n ldlm.cancel_unused_locks_before_replay "1"
4784 at_max_set $at_max_saved mds
4787 run_test 121 "lock replay timed out and race"
4790 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.10.90) ] &&
4791 skip "Do not support Data-on-MDT before 2.11"
4793 replay_barrier $SINGLEMDS
4794 $LFS setstripe -E 1M -L mdt -E EOF -c 2 $DIR/$tfile
4797 [ $($LFS getstripe -L $DIR/$tfile) == "mdt" ] ||
4798 error "Fail to replay DoM file creation"
4800 run_test 130a "DoM file create (setstripe) replay"
4803 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.10.90) ] &&
4804 skip "Do not support Data-on-MDT before 2.11"
4807 $LFS setstripe -E 1M -L mdt -E EOF -c 2 $DIR/$tdir
4808 replay_barrier $SINGLEMDS
4809 touch $DIR/$tdir/$tfile
4812 [ $($LFS getstripe -L $DIR/$tdir/$tfile) == "mdt" ] ||
4813 error "Fail to replay DoM file creation"
4815 run_test 130b "DoM file create (inherited) replay"
4818 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.10.90) ] &&
4819 skip "Do not support Data-on-MDT before 2.11"
4821 $LFS setstripe -E 1M -L mdt -E EOF -c 2 $DIR/$tfile
4822 replay_barrier $SINGLEMDS
4823 echo "dom_data" | dd of=$DIR/$tfile bs=8 count=1
4824 # lock is not canceled and will be replayed
4827 [ $(cat $DIR/$tfile) == "dom_data" ] ||
4828 error "Wrong file content after failover"
4830 run_test 131a "DoM file write lock replay"
4833 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.10.90) ] &&
4834 skip "Do not support Data-on-MDT before 2.11"
4836 $LFS setstripe -E 1M -L mdt -E EOF -c 2 $DIR/$tfile
4837 replay_barrier $SINGLEMDS
4838 echo "dom_data" | dd of=$DIR/$tfile bs=8 count=1
4839 cancel_lru_locks mdc
4843 [ $(cat $DIR/$tfile) == "dom_data" ] ||
4844 error "Wrong file content after failover"
4846 run_test 131b "DoM file write replay"
4849 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.9.90) ] &&
4850 skip "Do not support PFL files before 2.10"
4852 $LFS setstripe -E 1M -c 1 -E EOF -c 2 $DIR/$tfile
4853 replay_barrier $SINGLEMDS
4854 # write over the first component size cause next component instantiation
4855 dd if=/dev/urandom of=$DIR/$tfile bs=1M count=1 seek=1 ||
4856 error "dd to $DIR/$tfile failed"
4857 lfs getstripe $DIR/$tfile
4859 cksum=$(md5sum $DIR/$tfile | awk '{print $1}')
4860 $LFS getstripe -I2 $DIR/$tfile | grep -q lmm_objects ||
4861 error "Component #1 was not instantiated"
4865 lfs getstripe $DIR/$tfile
4866 $LFS getstripe -I2 $DIR/$tfile | grep -q lmm_objects ||
4867 error "Component #1 instantiation was not replayed"
4868 cksum2=$(md5sum $DIR/$tfile | awk '{print $1}')
4869 if [ $cksum != $cksum2 ] ; then
4870 error_noexit "New cksum $cksum2 does not match original $cksum"
4873 run_test 132a "PFL new component instantiate replay"
4876 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
4877 ([ $FAILURE_MODE == "HARD" ] &&
4878 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
4879 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
4882 local remote_dir=$DIR/$tdir/remote_dir
4884 mkdir -p $DIR/$tdir || error "mkdir $DIR/$tdir failed"
4885 $LFS mkdir -i 1 $remote_dir
4888 do_facet mds2 $LCTL set_param seq.srv*MDT0001.space=clear
4890 zconf_mount $(hostname) $MOUNT
4891 client_up || return 1
4893 #define OBD_FAIL_MDS_ALL_REQUEST_NET 0x123
4895 do_facet mds1 $LCTL set_param fail_val=700 fail_loc=0x80000123
4896 cp /etc/hosts $remote_dir/file &
4902 wait $pid || error "cp failed"
4903 rm -rf $DIR/$tdir || error "rmdir failed"
4907 run_test 133 "check resend of ongoing requests for lwp during failover"
4910 check_and_cleanup_lustre