5 LUSTRE=${LUSTRE:-$(dirname $0)/..}
6 . $LUSTRE/tests/test-framework.sh
10 ALWAYS_EXCEPT="$REPLAY_SINGLE_EXCEPT "
12 if [ "$mds1_FSTYPE" = zfs ]; then
13 # bug number for skipped test: LU-11388
14 ALWAYS_EXCEPT+=" 131b"
15 # UPDATE THE COMMENT ABOVE WITH BUG NUMBERS WHEN CHANGING ALWAYS_EXCEPT!
18 # bug number for skipped tests: LU-9795 (all below)
19 ALWAYS_EXCEPT="$ALWAYS_EXCEPT 0b 0c 0d 34 45"
20 ALWAYS_EXCEPT="$ALWAYS_EXCEPT 47 58b 58c 71a 85a"
21 ALWAYS_EXCEPT="$ALWAYS_EXCEPT 85b 86 88 89 90"
22 ALWAYS_EXCEPT="$ALWAYS_EXCEPT 93a 100a 100b 120"
27 CHECK_GRANT=${CHECK_GRANT:-"yes"}
28 GRANT_CHECK_LIST=${GRANT_CHECK_LIST:-""}
30 require_dsh_mds || exit 0
31 check_and_setup_lustre
36 rm -rf $DIR/[df][0-9]* $DIR/f.$TESTSUITE.*
38 # LU-482 Avert LVM and VM inability to flush caches in pre .33 kernels
39 if [ $LINUX_VERSION_CODE -lt $(version_code 2.6.33) ]; then
41 do_facet $SINGLEMDS sync
44 test_0a() { # was test_0
45 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
46 replay_barrier $SINGLEMDS
50 run_test 0a "empty replay"
53 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
55 # this test attempts to trigger a race in the precreation code,
56 # and must run before any other objects are created on the filesystem
58 createmany -o $DIR/$tfile 20 || error "createmany -o $DIR/$tfile failed"
59 unlinkmany $DIR/$tfile 20 || error "unlinkmany $DIR/$tfile failed"
61 run_test 0b "ensure object created after recover exists. (3284)"
64 replay_barrier $SINGLEMDS
67 facet_failover $SINGLEMDS
68 zconf_mount $(hostname) $MOUNT || error "mount fails"
69 client_up || error "post-failover df failed"
70 # file shouldn't exist if replay-barrier works as expected
71 rm $DIR/$tfile && error "File exists and it shouldn't"
74 run_test 0c "check replay-barrier"
77 replay_barrier $SINGLEMDS
79 facet_failover $SINGLEMDS
80 zconf_mount $(hostname) $MOUNT || error "mount fails"
81 client_up || error "post-failover df failed"
83 run_test 0d "expired recovery with no clients"
86 replay_barrier $SINGLEMDS
89 $CHECKSTAT -t file $DIR/$tfile ||
90 error "$CHECKSTAT $DIR/$tfile attribute check failed"
93 run_test 1 "simple create"
96 replay_barrier $SINGLEMDS
99 $CHECKSTAT -t file $DIR/$tfile ||
100 error "$CHECKSTAT $DIR/$tfile attribute check failed"
106 mcreate $DIR/$tfile || error "mcreate $DIR/$tfile failed"
107 replay_barrier $SINGLEMDS
110 $CHECKSTAT -t file $DIR/$tfile ||
111 error "$CHECKSTAT $DIR/$tfile attribute check failed"
117 replay_barrier $SINGLEMDS
118 $LFS setstripe -c $OSTCOUNT $DIR/$tfile
120 $CHECKSTAT -t file $DIR/$tfile ||
121 error "$CHECKSTAT $DIR/$tfile check failed"
123 run_test 2c "setstripe replay"
126 [[ "$mds1_FSTYPE" = zfs ]] &&
127 [[ "$MDS1_VERSION" -lt $(version_code 2.12.51) ]] &&
128 skip "requires LU-10143 fix on MDS"
129 replay_barrier $SINGLEMDS
130 $LFS setdirstripe -i 0 -c $MDSCOUNT $DIR/$tdir
132 $CHECKSTAT -t dir $DIR/$tdir ||
133 error "$CHECKSTAT $DIR/$tdir check failed"
135 run_test 2d "setdirstripe replay"
138 local file=$DIR/$tfile
139 replay_barrier $SINGLEMDS
141 openfile -f O_DIRECTORY $file
143 $CHECKSTAT -t file $file ||
144 error "$CHECKSTAT $file attribute check failed"
147 run_test 3a "replay failed open(O_DIRECTORY)"
150 replay_barrier $SINGLEMDS
151 #define OBD_FAIL_MDS_OPEN_PACK | OBD_FAIL_ONCE
152 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000114"
154 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
156 $CHECKSTAT -t file $DIR/$tfile &&
157 error "$CHECKSTAT $DIR/$tfile attribute check should fail"
160 run_test 3b "replay failed open -ENOMEM"
163 replay_barrier $SINGLEMDS
164 #define OBD_FAIL_MDS_ALLOC_OBDO | OBD_FAIL_ONCE
165 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000128"
167 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
170 $CHECKSTAT -t file $DIR/$tfile &&
171 error "$CHECKSTAT $DIR/$tfile attribute check should fail"
174 run_test 3c "replay failed open -ENOMEM"
176 test_4a() { # was test_4
177 replay_barrier $SINGLEMDS
178 for i in $(seq 10); do
179 echo "tag-$i" > $DIR/$tfile-$i
182 for i in $(seq 10); do
183 grep -q "tag-$i" $DIR/$tfile-$i || error "$tfile-$i"
186 run_test 4a "|x| 10 open(O_CREAT)s"
189 for i in $(seq 10); do
190 echo "tag-$i" > $DIR/$tfile-$i
192 replay_barrier $SINGLEMDS
195 $CHECKSTAT -t file $DIR/$tfile-* &&
196 error "$CHECKSTAT $DIR/$tfile-* attribute check should fail" ||
199 run_test 4b "|x| rm 10 files"
201 # The idea is to get past the first block of precreated files on both
202 # osts, and then replay.
204 replay_barrier $SINGLEMDS
205 for i in $(seq 220); do
206 echo "tag-$i" > $DIR/$tfile-$i
209 for i in $(seq 220); do
210 grep -q "tag-$i" $DIR/$tfile-$i || error "$tfile-$i"
214 # waiting for commitment of removal
216 run_test 5 "|x| 220 open(O_CREAT)"
218 test_6a() { # was test_6
219 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
220 replay_barrier $SINGLEMDS
221 mcreate $DIR/$tdir/$tfile
223 $CHECKSTAT -t dir $DIR/$tdir ||
224 error "$CHECKSTAT $DIR/$tdir attribute check failed"
225 $CHECKSTAT -t file $DIR/$tdir/$tfile ||
226 error "$CHECKSTAT $DIR/$tdir/$tfile attribute check failed"
228 # waiting for log process thread
230 run_test 6a "mkdir + contained create"
233 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
234 replay_barrier $SINGLEMDS
237 $CHECKSTAT -t dir $DIR/$tdir &&
238 error "$CHECKSTAT $DIR/$tdir attribute check should fail" ||
241 run_test 6b "|X| rmdir"
244 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
245 replay_barrier $SINGLEMDS
246 mcreate $DIR/$tdir/$tfile
248 $CHECKSTAT -t dir $DIR/$tdir ||
249 error "$CHECKSTAT $DIR/$tdir attribute check failed"
250 $CHECKSTAT -t file $DIR/$tdir/$tfile ||
251 error "$CHECKSTAT $DIR/$tdir/$tfile attribute check failed"
254 run_test 7 "mkdir |X| contained create"
257 replay_barrier $SINGLEMDS
258 multiop_bg_pause $DIR/$tfile mo_c ||
259 error "multiop mknod $DIR/$tfile failed"
263 $CHECKSTAT -t file $DIR/$tfile ||
264 error "$CHECKSTAT $DIR/$tfile attribute check failed"
265 kill -USR1 $MULTIPID || error "multiop mknod $MULTIPID not running"
266 wait $MULTIPID || error "multiop mknod $MULTIPID failed"
269 run_test 8 "creat open |X| close"
272 replay_barrier $SINGLEMDS
274 local old_inum=$(ls -i $DIR/$tfile | awk '{print $1}')
276 local new_inum=$(ls -i $DIR/$tfile | awk '{print $1}')
278 echo " old_inum == $old_inum, new_inum == $new_inum"
279 if [ $old_inum -eq $new_inum ] ;
281 echo "old_inum and new_inum match"
283 echo " old_inum and new_inum do not match"
284 error "old index($old_inum) does not match new index($new_inum)"
288 run_test 9 "|X| create (same inum/gen)"
291 mcreate $DIR/$tfile || error "mcreate $DIR/$tfile failed"
292 replay_barrier $SINGLEMDS
293 mv $DIR/$tfile $DIR/$tfile-2
296 $CHECKSTAT $DIR/$tfile &&
297 error "$CHECKSTAT $DIR/$tfile attribute check should fail"
298 $CHECKSTAT $DIR/$tfile-2 ||
299 error "$CHECKSTAT $DIR/$tfile-2 attribute check failed"
303 run_test 10 "create |X| rename unlink"
306 mcreate $DIR/$tfile || error "mcreate $DIR/$tfile failed"
307 echo "old" > $DIR/$tfile
308 mv $DIR/$tfile $DIR/$tfile-2
309 replay_barrier $SINGLEMDS
310 echo "new" > $DIR/$tfile
312 grep old $DIR/$tfile-2
314 grep new $DIR/$tfile || error "grep $DIR/$tfile failed"
315 grep old $DIR/$tfile-2 || error "grep $DIR/$tfile-2 failed"
317 run_test 11 "create open write rename |X| create-old-name read"
320 mcreate $DIR/$tfile || error "mcreate $DIR/$tfile failed"
321 multiop_bg_pause $DIR/$tfile o_tSc ||
322 error "multiop_bg_pause $DIR/$tfile failed"
325 replay_barrier $SINGLEMDS
326 kill -USR1 $pid || error "multiop $pid not running"
327 wait $pid || error "multiop $pid failed"
330 [ -e $DIR/$tfile ] && error "file $DIR/$tfile should not exist"
333 run_test 12 "open, unlink |X| close"
335 # 1777 - replay open after committed chmod that would make
336 # a regular open a failure
338 mcreate $DIR/$tfile || error "mcreate $DIR/$tfile failed"
339 multiop_bg_pause $DIR/$tfile O_wc ||
340 error "multiop_bg_pause $DIR/$tfile failed"
343 $CHECKSTAT -p 0 $DIR/$tfile ||
344 error "$CHECKSTAT $DIR/$tfile attribute check failed"
345 replay_barrier $SINGLEMDS
347 kill -USR1 $pid || error "multiop $pid not running"
348 wait $pid || error "multiop $pid failed"
350 $CHECKSTAT -s 1 -p 0 $DIR/$tfile ||
351 error "second $CHECKSTAT $DIR/$tfile attribute check failed"
352 rm $DIR/$tfile || error "rm $DIR/$tfile failed"
355 run_test 13 "open chmod 0 |x| write close"
358 multiop_bg_pause $DIR/$tfile O_tSc ||
359 error "multiop_bg_pause $DIR/$tfile failed"
362 replay_barrier $SINGLEMDS
363 kill -USR1 $pid || error "multiop $pid not running"
364 wait $pid || error "multiop $pid failed"
367 [ -e $DIR/$tfile ] && error "file $DIR/$tfile should not exist"
370 run_test 14 "open(O_CREAT), unlink |X| close"
373 multiop_bg_pause $DIR/$tfile O_tSc ||
374 error "multiop_bg_pause $DIR/$tfile failed"
377 replay_barrier $SINGLEMDS
378 touch $DIR/$tfile-1 || error "touch $DIR/$tfile-1 failed"
379 kill -USR1 $pid || error "multiop $pid not running"
380 wait $pid || error "multiop $pid failed"
383 [ -e $DIR/$tfile ] && error "file $DIR/$tfile should not exist"
384 touch $DIR/$tfile-2 || error "touch $DIR/$tfile-2 failed"
387 run_test 15 "open(O_CREAT), unlink |X| touch new, close"
390 replay_barrier $SINGLEMDS
393 mcreate $DIR/$tfile-2
395 [ -e $DIR/$tfile ] && error "file $DIR/$tfile should not exist"
396 [ -e $DIR/$tfile-2 ] || error "file $DIR/$tfile-2 does not exist"
397 munlink $DIR/$tfile-2 || error "munlink $DIR/$tfile-2 failed"
399 run_test 16 "|X| open(O_CREAT), unlink, touch new, unlink new"
402 replay_barrier $SINGLEMDS
403 multiop_bg_pause $DIR/$tfile O_c ||
404 error "multiop_bg_pause $DIR/$tfile failed"
407 kill -USR1 $pid || error "multiop $pid not running"
408 wait $pid || error "multiop $pid failed"
409 $CHECKSTAT -t file $DIR/$tfile ||
410 error "$CHECKSTAT $DIR/$tfile attribute check failed"
413 run_test 17 "|X| open(O_CREAT), |replay| close"
416 replay_barrier $SINGLEMDS
417 multiop_bg_pause $DIR/$tfile O_tSc ||
418 error "multiop_bg_pause $DIR/$tfile failed"
421 touch $DIR/$tfile-2 || error "touch $DIR/$tfile-2 failed"
422 echo "pid: $pid will close"
423 kill -USR1 $pid || error "multiop $pid not running"
424 wait $pid || error "multiop $pid failed"
427 [ -e $DIR/$tfile ] && error "file $DIR/$tfile should not exist"
428 [ -e $DIR/$tfile-2 ] || error "file $DIR/$tfile-2 does not exist"
429 # this touch frequently fails
430 touch $DIR/$tfile-3 || error "touch $DIR/$tfile-3 failed"
431 munlink $DIR/$tfile-2 || error "munlink $DIR/$tfile-2 failed"
432 munlink $DIR/$tfile-3 || error "munlink $DIR/$tfile-3 failed"
435 run_test 18 "open(O_CREAT), unlink, touch new, close, touch, unlink"
437 # bug 1855 (a simpler form of test_11 above)
439 replay_barrier $SINGLEMDS
441 echo "old" > $DIR/$tfile
442 mv $DIR/$tfile $DIR/$tfile-2
443 grep old $DIR/$tfile-2
445 grep old $DIR/$tfile-2 || error "grep $DIR/$tfile-2 failed"
447 run_test 19 "mcreate, open, write, rename "
449 test_20a() { # was test_20
450 replay_barrier $SINGLEMDS
451 multiop_bg_pause $DIR/$tfile O_tSc ||
452 error "multiop_bg_pause $DIR/$tfile failed"
457 kill -USR1 $pid || error "multiop $pid not running"
458 wait $pid || error "multiop $pid failed"
459 [ -e $DIR/$tfile ] && error "file $DIR/$tfile should not exist"
462 run_test 20a "|X| open(O_CREAT), unlink, replay, close (test mds_cleanup_orphans)"
464 test_20b() { # bug 10480
465 local wait_timeout=$((TIMEOUT * 4))
466 local extra=$(fs_log_size)
470 $LFS setstripe -i 0 -c 1 $DIR
472 local beforeused=$(df -P $DIR | tail -1 | awk '{ print $3 }')
474 dd if=/dev/zero of=$DIR/$tfile bs=4k count=10000 &
475 while [ ! -e $DIR/$tfile ] ; do
476 usleep 60 # give dd a chance to start
479 $LFS getstripe $DIR/$tfile || error "$LFS getstripe $DIR/$tfile failed"
481 rm -f $DIR/$tfile || error "rm -f $DIR/$tfile failed"
483 client_up || client_up || true # reconnect
485 do_facet $SINGLEMDS "lctl set_param -n osd*.*MDT*.force_sync=1"
487 fail $SINGLEMDS # start orphan recovery
488 wait_recovery_complete $SINGLEMDS || error "MDS recovery not done"
489 wait_delete_completed $wait_timeout || error "delete did not finish"
493 local afterused=$(df -P $DIR | tail -1 | awk '{ print $3 }')
494 log "before $beforeused, after $afterused"
496 (( $beforeused + $extra >= $afterused )) && break
497 n_attempts=$((n_attempts + 1))
498 [ $n_attempts -gt 3 ] &&
499 error "after $afterused > before $beforeused + $extra"
501 wait_zfs_commit $SINGLEMDS 5
506 run_test 20b "write, unlink, eviction, replay (test mds_cleanup_orphans)"
508 test_20c() { # bug 10480
509 multiop_bg_pause $DIR/$tfile Ow_c ||
510 error "multiop_bg_pause $DIR/$tfile failed"
516 client_up || client_up || true # reconnect
518 kill -USR1 $pid || error "multiop $pid not running"
519 wait $pid || error "multiop $pid failed"
520 [ -s $DIR/$tfile ] || error "File was truncated"
524 run_test 20c "check that client eviction does not affect file content"
527 replay_barrier $SINGLEMDS
528 multiop_bg_pause $DIR/$tfile O_tSc ||
529 error "multiop_bg_pause $DIR/$tfile failed"
532 touch $DIR/$tfile-1 || error "touch $DIR/$tfile-1 failed"
535 kill -USR1 $pid || error "multiop $pid not running"
536 wait $pid || error "multiop $pid failed"
537 [ -e $DIR/$tfile ] && error "file $DIR/$tfile should not exist"
538 touch $DIR/$tfile-2 || error "touch $DIR/$tfile-2 failed"
541 run_test 21 "|X| open(O_CREAT), unlink touch new, replay, close (test mds_cleanup_orphans)"
544 multiop_bg_pause $DIR/$tfile O_tSc ||
545 error "multiop_bg_pause $DIR/$tfile failed"
548 replay_barrier $SINGLEMDS
552 kill -USR1 $pid || error "multiop $pid not running"
553 wait $pid || error "multiop $pid failed"
554 [ -e $DIR/$tfile ] && error "file $DIR/$tfile should not exist"
557 run_test 22 "open(O_CREAT), |X| unlink, replay, close (test mds_cleanup_orphans)"
560 multiop_bg_pause $DIR/$tfile O_tSc ||
561 error "multiop_bg_pause $DIR/$tfile failed"
564 replay_barrier $SINGLEMDS
566 touch $DIR/$tfile-1 || error "touch $DIR/$tfile-1 failed"
569 kill -USR1 $pid || error "multiop $pid not running"
570 wait $pid || error "multiop $pid failed"
571 [ -e $DIR/$tfile ] && error "file $DIR/$tfile should not exist"
572 touch $DIR/$tfile-2 || error "touch $DIR/$tfile-2 failed"
575 run_test 23 "open(O_CREAT), |X| unlink touch new, replay, close (test mds_cleanup_orphans)"
578 multiop_bg_pause $DIR/$tfile O_tSc ||
579 error "multiop_bg_pause $DIR/$tfile failed"
582 replay_barrier $SINGLEMDS
585 kill -USR1 $pid || error "multiop $pid not running"
586 wait $pid || error "multiop $pid failed"
587 [ -e $DIR/$tfile ] && error "file $DIR/$tfile should not exist"
590 run_test 24 "open(O_CREAT), replay, unlink, close (test mds_cleanup_orphans)"
593 multiop_bg_pause $DIR/$tfile O_tSc ||
594 error "multiop_bg_pause $DIR/$tfile failed"
598 replay_barrier $SINGLEMDS
600 kill -USR1 $pid || error "multiop $pid not running"
601 wait $pid || error "multiop $pid failed"
602 [ -e $DIR/$tfile ] && error "file $DIR/$tfile should not exist"
605 run_test 25 "open(O_CREAT), unlink, replay, close (test mds_cleanup_orphans)"
608 replay_barrier $SINGLEMDS
609 multiop_bg_pause $DIR/$tfile-1 O_tSc ||
610 error "multiop_bg_pause $DIR/$tfile-1 failed"
612 multiop_bg_pause $DIR/$tfile-2 O_tSc ||
613 error "multiop_bg_pause $DIR/$tfile-2 failed"
617 kill -USR1 $pid2 || error "second multiop $pid2 not running"
618 wait $pid2 || error "second multiop $pid2 failed"
621 kill -USR1 $pid1 || error "multiop $pid1 not running"
622 wait $pid1 || error "multiop $pid1 failed"
623 [ -e $DIR/$tfile-1 ] && error "file $DIR/$tfile-1 should not exist"
624 [ -e $DIR/$tfile-2 ] && error "file $DIR/$tfile-2 should not exist"
627 run_test 26 "|X| open(O_CREAT), unlink two, close one, replay, close one (test mds_cleanup_orphans)"
630 replay_barrier $SINGLEMDS
631 multiop_bg_pause $DIR/$tfile-1 O_tSc ||
632 error "multiop_bg_pause $DIR/$tfile-1 failed"
634 multiop_bg_pause $DIR/$tfile-2 O_tSc ||
635 error "multiop_bg_pause $DIR/$tfile-2 failed"
641 kill -USR1 $pid1 || error "multiop $pid1 not running"
642 wait $pid1 || error "multiop $pid1 failed"
643 kill -USR1 $pid2 || error "second multiop $pid2 not running"
644 wait $pid2 || error "second multiop $pid2 failed"
645 [ -e $DIR/$tfile-1 ] && error "file $DIR/$tfile-1 should not exist"
646 [ -e $DIR/$tfile-2 ] && error "file $DIR/$tfile-2 should not exist"
649 run_test 27 "|X| open(O_CREAT), unlink two, replay, close two (test mds_cleanup_orphans)"
652 multiop_bg_pause $DIR/$tfile-1 O_tSc ||
653 error "multiop_bg_pause $DIR/$tfile-1 failed"
655 multiop_bg_pause $DIR/$tfile-2 O_tSc ||
656 error "multiop_bg_pause $DIR/$tfile-2 failed"
658 replay_barrier $SINGLEMDS
661 kill -USR1 $pid2 || error "second multiop $pid2 not running"
662 wait $pid2 || error "second multiop $pid2 failed"
665 kill -USR1 $pid1 || error "multiop $pid1 not running"
666 wait $pid1 || error "multiop $pid1 failed"
667 [ -e $DIR/$tfile-1 ] && error "file $DIR/$tfile-1 should not exist"
668 [ -e $DIR/$tfile-2 ] && error "file $DIR/$tfile-2 should not exist"
671 run_test 28 "open(O_CREAT), |X| unlink two, close one, replay, close one (test mds_cleanup_orphans)"
674 multiop_bg_pause $DIR/$tfile-1 O_tSc ||
675 error "multiop_bg_pause $DIR/$tfile-1 failed"
677 multiop_bg_pause $DIR/$tfile-2 O_tSc ||
678 error "multiop_bg_pause $DIR/$tfile-2 failed"
680 replay_barrier $SINGLEMDS
685 kill -USR1 $pid1 || error "multiop $pid1 not running"
686 wait $pid1 || error "multiop $pid1 failed"
687 kill -USR1 $pid2 || error "second multiop $pid2 not running"
688 wait $pid2 || error "second multiop $pid2 failed"
689 [ -e $DIR/$tfile-1 ] && error "file $DIR/$tfile-1 should not exist"
690 [ -e $DIR/$tfile-2 ] && error "file $DIR/$tfile-2 should not exist"
693 run_test 29 "open(O_CREAT), |X| unlink two, replay, close two (test mds_cleanup_orphans)"
696 multiop_bg_pause $DIR/$tfile-1 O_tSc ||
697 error "multiop_bg_pause $DIR/$tfile-1 failed"
699 multiop_bg_pause $DIR/$tfile-2 O_tSc ||
700 error "multiop_bg_pause $DIR/$tfile-2 failed"
705 replay_barrier $SINGLEMDS
707 kill -USR1 $pid1 || error "multiop $pid1 not running"
708 wait $pid1 || error "multiop $pid1 failed"
709 kill -USR1 $pid2 || error "second multiop $pid2 not running"
710 wait $pid2 || error "second multiop $pid2 failed"
711 [ -e $DIR/$tfile-1 ] && error "file $DIR/$tfile-1 should not exist"
712 [ -e $DIR/$tfile-2 ] && error "file $DIR/$tfile-2 should not exist"
715 run_test 30 "open(O_CREAT) two, unlink two, replay, close two (test mds_cleanup_orphans)"
718 multiop_bg_pause $DIR/$tfile-1 O_tSc ||
719 error "multiop_bg_pause $DIR/$tfile-1 failed"
721 multiop_bg_pause $DIR/$tfile-2 O_tSc ||
722 error "multiop_bg_pause $DIR/$tfile-2 failed"
726 replay_barrier $SINGLEMDS
729 kill -USR1 $pid1 || error "multiop $pid1 not running"
730 wait $pid1 || error "multiop $pid1 failed"
731 kill -USR1 $pid2 || error "second multiop $pid2 not running"
732 wait $pid2 || error "second multiop $pid2 failed"
733 [ -e $DIR/$tfile-1 ] && error "file $DIR/$tfile-1 should not exist"
734 [ -e $DIR/$tfile-2 ] && error "file $DIR/$tfile-2 should not exist"
737 run_test 31 "open(O_CREAT) two, unlink one, |X| unlink one, close two (test mds_cleanup_orphans)"
739 # tests for bug 2104; completion without crashing is success. The close is
740 # stale, but we always return 0 for close, so the app never sees it.
742 multiop_bg_pause $DIR/$tfile O_c ||
743 error "multiop_bg_pause $DIR/$tfile failed"
745 multiop_bg_pause $DIR/$tfile O_c ||
746 error "second multiop_bg_pause $DIR/$tfile failed"
749 client_up || client_up || error "client_up failed"
750 kill -USR1 $pid1 || error "multiop $pid1 not running"
751 kill -USR1 $pid2 || error "second multiop $pid2 not running"
752 wait $pid1 || error "multiop $pid1 failed"
753 wait $pid2 || error "second multiop $pid2 failed"
756 run_test 32 "close() notices client eviction; close() after client eviction"
759 createmany -o $DIR/$tfile-%d 10 ||
760 error "createmany create $DIR/$tfile failed"
761 replay_barrier_nosync $SINGLEMDS
762 fail_abort $SINGLEMDS
763 # recreate shouldn't fail
764 createmany -o $DIR/$tfile--%d 10 ||
765 error "createmany recreate $DIR/$tfile failed"
769 run_test 33a "fid seq shouldn't be reused after abort recovery"
772 #define OBD_FAIL_SEQ_ALLOC 0x1311
773 do_facet $SINGLEMDS "lctl set_param fail_loc=0x1311"
775 createmany -o $DIR/$tfile-%d 10
776 replay_barrier_nosync $SINGLEMDS
777 fail_abort $SINGLEMDS
778 # recreate shouldn't fail
779 createmany -o $DIR/$tfile--%d 10 ||
780 error "createmany recreate $DIR/$tfile failed"
784 run_test 33b "test fid seq allocation"
787 multiop_bg_pause $DIR/$tfile O_c ||
788 error "multiop_bg_pause $DIR/$tfile failed"
792 replay_barrier $SINGLEMDS
793 fail_abort $SINGLEMDS
794 kill -USR1 $pid || error "multiop $pid not running"
795 wait $pid || error "multiop $pid failed"
796 [ -e $DIR/$tfile ] && error "file $DIR/$tfile should not exist"
800 run_test 34 "abort recovery before client does replay (test mds_cleanup_orphans)"
802 # bug 2278 - generate one orphan on OST, then destroy it during recovery from llog
804 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
806 #define OBD_FAIL_MDS_REINT_NET_REP 0x119
807 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000119"
812 # give a chance to remove from MDS
813 fail_abort $SINGLEMDS
814 $CHECKSTAT -t file $DIR/$tfile &&
815 error "$CHECKSTAT $DIR/$tfile attribute check should fail" ||
818 run_test 35 "test recovery from llog for unlink op"
820 # b=2432 resent cancel after replay uses wrong cookie,
821 # so don't resend cancels
823 replay_barrier $SINGLEMDS
825 checkstat $DIR/$tfile
826 facet_failover $SINGLEMDS
828 if $LCTL dk | grep "stale lock .*cookie"; then
829 error "cancel after replay failed"
832 run_test 36 "don't resend cancel"
835 # directory orphans can't be unlinked from PENDING directory
837 rmdir $DIR/$tfile 2>/dev/null
838 multiop_bg_pause $DIR/$tfile dD_c ||
839 error "multiop_bg_pause $DIR/$tfile failed"
843 replay_barrier $SINGLEMDS
844 # clear the dmesg buffer so we only see errors from this recovery
845 do_facet $SINGLEMDS dmesg -c >/dev/null
846 fail_abort $SINGLEMDS
847 kill -USR1 $pid || error "multiop $pid not running"
848 do_facet $SINGLEMDS dmesg | grep "error unlinking orphan" &&
849 error "error unlinking files"
850 wait $pid || error "multiop $pid failed"
854 run_test 37 "abort recovery before client does replay (test mds_cleanup_orphans for directories)"
857 createmany -o $DIR/$tfile-%d 800 ||
858 error "createmany -o $DIR/$tfile failed"
859 unlinkmany $DIR/$tfile-%d 0 400 || error "unlinkmany $DIR/$tfile failed"
860 replay_barrier $SINGLEMDS
862 unlinkmany $DIR/$tfile-%d 400 400 ||
863 error "unlinkmany $DIR/$tfile 400 failed"
865 $CHECKSTAT -t file $DIR/$tfile-* &&
866 error "$CHECKSTAT $DIR/$tfile-* attribute check should fail" ||
869 run_test 38 "test recovery from unlink llog (test llog_gen_rec) "
871 test_39() { # bug 4176
872 createmany -o $DIR/$tfile-%d 800 ||
873 error "createmany -o $DIR/$tfile failed"
874 replay_barrier $SINGLEMDS
875 unlinkmany $DIR/$tfile-%d 0 400
877 unlinkmany $DIR/$tfile-%d 400 400 ||
878 error "unlinkmany $DIR/$tfile 400 failed"
880 $CHECKSTAT -t file $DIR/$tfile-* &&
881 error "$CHECKSTAT $DIR/$tfile-* attribute check should fail" ||
884 run_test 39 "test recovery from unlink llog (test llog_gen_rec) "
887 lctl get_param -n osc.*.stats | awk -vwrites=0 '/ost_write/ { writes += $2 } END { print writes; }'
892 # always need connection to MDS to verify layout during IO. LU-2628.
893 lctl get_param mdc.*.connect_flags | grep -q layout_lock &&
894 skip "layout_lock needs MDS connection for IO" && return 0
896 $LCTL mark multiop $MOUNT/$tfile OS_c
897 multiop $MOUNT/$tfile OS_c &
899 writeme -s $MOUNT/${tfile}-2 &
902 facet_failover $SINGLEMDS
903 #define OBD_FAIL_MDS_CONNECT_NET 0x117
904 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000117"
906 stat1=$(count_ost_writes)
908 stat2=$(count_ost_writes)
909 echo "$stat1, $stat2"
910 if [ $stat1 -lt $stat2 ]; then
911 echo "writes continuing during recovery"
914 echo "writes not continuing during recovery, bug 2477"
917 echo "waiting for writeme $WRITE_PID"
921 echo "waiting for multiop $PID"
922 wait $PID || error "multiop $PID failed"
923 do_facet client munlink $MOUNT/$tfile ||
924 error "munlink $MOUNT/$tfile failed"
925 do_facet client munlink $MOUNT/${tfile}-2 ||
926 error "munlink $MOUNT/$tfile-2 failed"
929 run_test 40 "cause recovery in ptlrpc, ensure IO continues"
932 # make sure that a read to one osc doesn't try to double-unlock its page just
933 # because another osc is invalid. trigger_group_io used to mistakenly return
934 # an error if any oscs were invalid even after having successfully put rpcs
935 # on valid oscs. This was fatal if the caller was ll_readpage who unlocked
936 # the page, guarnateeing that the unlock from the RPC completion would
937 # assert on trying to unlock the unlocked page.
939 [ $OSTCOUNT -lt 2 ] && skip_env "needs >= 2 OSTs" && return
941 local f=$MOUNT/$tfile
942 # make sure the start of the file is ost1
943 $LFS setstripe -S $((128 * 1024)) -i 0 $f
944 do_facet client dd if=/dev/zero of=$f bs=4k count=1 ||
945 error "dd on client failed"
947 # fail ost2 and read from ost1
948 local mdtosc=$(get_mdtosc_proc_path $SINGLEMDS $ost2_svc)
949 local osc2dev=$(do_facet $SINGLEMDS "lctl get_param -n devices" |
950 grep $mdtosc | awk '{print $1}')
951 [ -z "$osc2dev" ] && echo "OST: $ost2_svc" &&
952 lctl get_param -n devices &&
953 error "OST 2 $osc2dev does not exist"
954 do_facet $SINGLEMDS $LCTL --device $osc2dev deactivate ||
955 error "deactive device on $SINGLEMDS failed"
956 do_facet client dd if=$f of=/dev/null bs=4k count=1 ||
957 error "second dd on client failed"
958 do_facet $SINGLEMDS $LCTL --device $osc2dev activate ||
959 error "active device on $SINGLEMDS failed"
962 run_test 41 "read from a valid osc while other oscs are invalid"
964 # test MDS recovery after ost failure
966 blocks=$(df -P $MOUNT | tail -n 1 | awk '{ print $2 }')
967 createmany -o $DIR/$tfile-%d 800 ||
968 error "createmany -o $DIR/$tfile failed"
970 unlinkmany $DIR/$tfile-%d 0 400
972 lctl set_param debug=-1
975 # osc is evicted, fs is smaller (but only with failout OSTs (bug 7287)
976 #blocks_after=`df -P $MOUNT | tail -n 1 | awk '{ print $2 }'`
977 #[ $blocks_after -lt $blocks ] || return 1
978 echo "wait for MDS to timeout and recover"
979 sleep $((TIMEOUT * 2))
981 unlinkmany $DIR/$tfile-%d 400 400 ||
982 error "unlinkmany $DIR/$tfile 400 failed"
983 $CHECKSTAT -t file $DIR/$tfile-* &&
984 error "$CHECKSTAT $DIR/$tfile-* attribute check should fail" ||
987 run_test 42 "recovery after ost failure"
989 # timeout in MDS/OST recovery RPC will LBUG MDS
990 test_43() { # bug 2530
991 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
993 replay_barrier $SINGLEMDS
995 # OBD_FAIL_OST_CREATE_NET 0x204
996 do_facet ost1 "lctl set_param fail_loc=0x80000204"
1002 run_test 43 "mds osc import failure during recovery; don't LBUG"
1004 test_44a() { # was test_44
1005 local at_max_saved=0
1007 local mdcdev=$($LCTL dl |
1008 awk "/${FSNAME}-MDT0000-mdc-/ {if (\$2 == \"UP\") {print \$1}}")
1009 [ "$mdcdev" ] || error "${FSNAME}-MDT0000-mdc- not UP"
1010 [ $(echo $mdcdev | wc -w) -eq 1 ] ||
1011 { $LCTL dl; error "looking for mdcdev=$mdcdev"; }
1013 # adaptive timeouts slow this way down
1014 if at_is_enabled; then
1015 at_max_saved=$(at_max_get mds)
1019 for i in $(seq 1 10); do
1020 echo "$i of 10 ($(date +%s))"
1021 do_facet $SINGLEMDS \
1022 "lctl get_param -n md[ts].*.mdt.timeouts | grep service"
1023 #define OBD_FAIL_TGT_CONN_RACE 0x701
1024 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000701"
1025 # lctl below may fail, it is valid case
1026 $LCTL --device $mdcdev recover
1029 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
1030 [ $at_max_saved -ne 0 ] && at_max_set $at_max_saved mds
1033 run_test 44a "race in target handle connect"
1036 local mdcdev=$($LCTL dl |
1037 awk "/${FSNAME}-MDT0000-mdc-/ {if (\$2 == \"UP\") {print \$1}}")
1038 [ "$mdcdev" ] || error "${FSNAME}-MDT0000-mdc not up"
1039 [ $(echo $mdcdev | wc -w) -eq 1 ] ||
1040 { echo mdcdev=$mdcdev; $LCTL dl;
1041 error "more than one ${FSNAME}-MDT0000-mdc"; }
1043 for i in $(seq 1 10); do
1044 echo "$i of 10 ($(date +%s))"
1045 do_facet $SINGLEMDS \
1046 "lctl get_param -n md[ts].*.mdt.timeouts | grep service"
1047 #define OBD_FAIL_TGT_DELAY_RECONNECT 0x704
1048 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000704"
1049 # lctl below may fail, it is valid case
1050 $LCTL --device $mdcdev recover
1055 run_test 44b "race in target handle connect"
1058 replay_barrier $SINGLEMDS
1059 createmany -m $DIR/$tfile-%d 100 || error "failed to create directories"
1060 #define OBD_FAIL_TGT_RCVG_FLAG 0x712
1061 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000712"
1062 fail_abort $SINGLEMDS
1063 unlinkmany $DIR/$tfile-%d 100 && error "unliked after fail abort"
1065 unlinkmany $DIR/$tfile-%d 100 && error "unliked after fail"
1068 run_test 44c "race in target handle connect"
1070 # Handle failed close
1072 local mdcdev=$($LCTL get_param -n devices |
1073 awk "/ ${FSNAME}-MDT0000-mdc-/ {print \$1}")
1074 [ "$mdcdev" ] || error "${FSNAME}-MDT0000-mdc not up"
1075 [ $(echo $mdcdev | wc -w) -eq 1 ] ||
1076 { echo mdcdev=$mdcdev; $LCTL dl;
1077 error "more than one ${FSNAME}-MDT0000-mdc"; }
1079 $LCTL --device $mdcdev recover ||
1080 error "$LCTL --device $mdcdev recover failed"
1082 multiop_bg_pause $DIR/$tfile O_c ||
1083 error "multiop_bg_pause $DIR/$tfile failed"
1086 # This will cause the CLOSE to fail before even
1087 # allocating a reply buffer
1088 $LCTL --device $mdcdev deactivate ||
1089 error "$LCTL --device $mdcdev deactivate failed"
1092 kill -USR1 $pid || error "multiop $pid not running"
1093 wait $pid || error "multiop $pid failed"
1095 $LCTL --device $mdcdev activate ||
1096 error "$LCTL --device $mdcdev activate failed"
1099 $CHECKSTAT -t file $DIR/$tfile ||
1100 error "$CHECKSTAT $DIR/$tfile attribute check failed"
1103 run_test 45 "Handle failed close"
1106 drop_reply "touch $DIR/$tfile"
1108 # ironically, the previous test, 45, will cause a real forced close,
1109 # so just look for one for this test
1110 local FID=$($LFS path2fid $tfile)
1111 $LCTL dk | grep -i "force closing file handle $FID" &&
1112 error "found force closing in dmesg"
1115 run_test 46 "Don't leak file handle after open resend (3325)"
1117 test_47() { # bug 2824
1118 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1120 # create some files to make sure precreate has been done on all
1121 # OSTs. (just in case this test is run independently)
1122 createmany -o $DIR/$tfile 20 ||
1123 error "createmany create $DIR/$tfile failed"
1125 # OBD_FAIL_OST_CREATE_NET 0x204
1127 do_facet ost1 "lctl set_param fail_loc=0x80000204"
1128 client_up || error "client_up failed"
1130 # let the MDS discover the OST failure, attempt to recover, fail
1131 # and recover again.
1132 sleep $((3 * TIMEOUT))
1134 # Without 2824, this createmany would hang
1135 createmany -o $DIR/$tfile 20 ||
1136 error "createmany recraete $DIR/$tfile failed"
1137 unlinkmany $DIR/$tfile 20 || error "unlinkmany $DIR/$tfile failed"
1141 run_test 47 "MDS->OSC failure during precreate cleanup (2824)"
1144 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1145 [ "$OSTCOUNT" -lt "2" ] && skip_env "needs >= 2 OSTs" && return
1147 replay_barrier $SINGLEMDS
1148 createmany -o $DIR/$tfile 20 ||
1149 error "createmany -o $DIR/$tfile failed"
1150 # OBD_FAIL_OST_EROFS 0x216
1151 facet_failover $SINGLEMDS
1152 do_facet ost1 "lctl set_param fail_loc=0x80000216"
1153 client_up || error "client_up failed"
1155 # let the MDS discover the OST failure, attempt to recover, fail
1156 # and recover again.
1157 sleep $((3 * TIMEOUT))
1159 createmany -o $DIR/$tfile 20 20 ||
1160 error "createmany recraete $DIR/$tfile failed"
1161 unlinkmany $DIR/$tfile 40 || error "unlinkmany $DIR/$tfile failed"
1164 run_test 48 "MDS->OSC failure during precreate cleanup (2824)"
1167 local mdtosc=$(get_mdtosc_proc_path $SINGLEMDS $ost1_svc)
1168 local oscdev=$(do_facet $SINGLEMDS "lctl get_param -n devices" |
1169 grep $mdtosc | awk '{print $1}')
1170 [ "$oscdev" ] || error "could not find OSC device on MDS"
1171 do_facet $SINGLEMDS $LCTL --device $oscdev recover ||
1172 error "OSC device $oscdev recovery failed"
1173 do_facet $SINGLEMDS $LCTL --device $oscdev recover ||
1174 error "second OSC device $oscdev recovery failed"
1175 # give the mds_lov_sync threads a chance to run
1178 run_test 50 "Double OSC recovery, don't LASSERT (3812)"
1180 # b3764 timed out lock replay
1182 [ "$MDS1_VERSION" -lt $(version_code 2.6.90) ] &&
1183 skip "MDS prior to 2.6.90 handle LDLM_REPLY_NET incorrectly"
1185 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
1186 cancel_lru_locks mdc
1188 multiop_bg_pause $DIR/$tfile s_s || error "multiop $DIR/$tfile failed"
1191 #define OBD_FAIL_MDS_LDLM_REPLY_NET 0x157
1192 lctl set_param -n ldlm.cancel_unused_locks_before_replay "0"
1193 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000157"
1195 fail $SINGLEMDS || error "fail $SINGLEMDS failed"
1197 wait $mpid || error "multiop_bg_pause pid failed"
1199 do_facet $SINGLEMDS "lctl set_param fail_loc=0x0"
1200 lctl set_param fail_loc=0x0
1201 lctl set_param -n ldlm.cancel_unused_locks_before_replay "1"
1204 run_test 52 "time out lock replay (3764)"
1206 # bug 3462 - simultaneous MDC requests
1208 [[ $(lctl get_param mdc.*.import |
1209 grep "connect_flags:.*multi_mod_rpc") ]] ||
1210 { skip "Need MDC with 'multi_mod_rpcs' feature"; return 0; }
1212 cancel_lru_locks mdc # cleanup locks from former test cases
1213 mkdir $DIR/${tdir}-1 || error "mkdir $DIR/${tdir}-1 failed"
1214 mkdir $DIR/${tdir}-2 || error "mkdir $DIR/${tdir}-2 failed"
1215 multiop $DIR/${tdir}-1/f O_c &
1217 # give multiop a change to open
1220 #define OBD_FAIL_MDS_CLOSE_NET 0x115
1221 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000115"
1222 kill -USR1 $close_pid
1223 cancel_lru_locks mdc # force the close
1224 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
1226 mcreate $DIR/${tdir}-2/f || error "mcreate $DIR/${tdir}-2/f failed"
1228 # close should still be here
1229 [ -d /proc/$close_pid ] || error "close_pid doesn't exist"
1231 replay_barrier_nodf $SINGLEMDS
1233 wait $close_pid || error "close_pid $close_pid failed"
1235 $CHECKSTAT -t file $DIR/${tdir}-1/f ||
1236 error "$CHECKSTAT $DIR/${tdir}-1/f attribute check failed"
1237 $CHECKSTAT -t file $DIR/${tdir}-2/f ||
1238 error "$CHECKSTAT $DIR/${tdir}-2/f attribute check failed"
1239 rm -rf $DIR/${tdir}-*
1241 run_test 53a "|X| close request while two MDC requests in flight"
1244 cancel_lru_locks mdc # cleanup locks from former test cases
1246 mkdir $DIR/${tdir}-1 || error "mkdir $DIR/${tdir}-1 failed"
1247 mkdir $DIR/${tdir}-2 || error "mkdir $DIR/${tdir}-2 failed"
1248 multiop_bg_pause $DIR/${tdir}-1/f O_c ||
1249 error "multiop_bg_pause $DIR/${tdir}-1/f failed"
1252 #define OBD_FAIL_MDS_REINT_NET 0x107
1253 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000107"
1254 mcreate $DIR/${tdir}-2/f &
1258 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
1259 kill -USR1 $close_pid
1260 cancel_lru_locks mdc # force the close
1261 wait $close_pid || error "close_pid $close_pid failed"
1262 # open should still be here
1263 [ -d /proc/$open_pid ] || error "open_pid doesn't exist"
1265 replay_barrier_nodf $SINGLEMDS
1267 wait $open_pid || error "open_pid failed"
1269 $CHECKSTAT -t file $DIR/${tdir}-1/f ||
1270 error "$CHECKSTAT $DIR/${tdir}-1/f attribute check failed"
1271 $CHECKSTAT -t file $DIR/${tdir}-2/f ||
1272 error "$CHECKSTAT $DIR/${tdir}-2/f attribute check failed"
1273 rm -rf $DIR/${tdir}-*
1275 run_test 53b "|X| open request while two MDC requests in flight"
1278 cancel_lru_locks mdc # cleanup locks from former test cases
1280 mkdir $DIR/${tdir}-1 || error "mkdir $DIR/${tdir}-1 failed"
1281 mkdir $DIR/${tdir}-2 || error "mkdir $DIR/${tdir}-2 failed"
1282 multiop $DIR/${tdir}-1/f O_c &
1285 #define OBD_FAIL_MDS_REINT_NET 0x107
1286 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000107"
1287 mcreate $DIR/${tdir}-2/f &
1291 #define OBD_FAIL_MDS_CLOSE_NET 0x115
1292 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000115"
1293 kill -USR1 $close_pid
1294 cancel_lru_locks mdc # force the close
1296 #bz20647: make sure all pids exist before failover
1297 [ -d /proc/$close_pid ] || error "close_pid doesn't exist"
1298 [ -d /proc/$open_pid ] || error "open_pid doesn't exists"
1299 replay_barrier_nodf $SINGLEMDS
1300 fail_nodf $SINGLEMDS
1301 wait $open_pid || error "open_pid failed"
1303 # close should be gone
1304 [ -d /proc/$close_pid ] && error "close_pid should not exist"
1305 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
1307 $CHECKSTAT -t file $DIR/${tdir}-1/f ||
1308 error "$CHECKSTAT $DIR/${tdir}-1/f attribute check failed"
1309 $CHECKSTAT -t file $DIR/${tdir}-2/f ||
1310 error "$CHECKSTAT $DIR/${tdir}-2/f attribute check failed"
1311 rm -rf $DIR/${tdir}-*
1313 run_test 53c "|X| open request and close request while two MDC requests in flight"
1316 [[ $(lctl get_param mdc.*.import |
1317 grep "connect_flags:.*multi_mod_rpc") ]] ||
1318 { skip "Need MDC with 'multi_mod_rpcs' feature"; return 0; }
1320 cancel_lru_locks mdc # cleanup locks from former test cases
1322 mkdir $DIR/${tdir}-1 || error "mkdir $DIR/${tdir}-1 failed"
1323 mkdir $DIR/${tdir}-2 || error "mkdir $DIR/${tdir}-2 failed"
1324 multiop $DIR/${tdir}-1/f O_c &
1326 # give multiop a chance to open
1329 #define OBD_FAIL_MDS_CLOSE_NET_REP 0x13b
1330 do_facet $SINGLEMDS "lctl set_param fail_loc=0x8000013b"
1331 kill -USR1 $close_pid
1332 cancel_lru_locks mdc # force the close
1333 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
1334 mcreate $DIR/${tdir}-2/f || error "mcreate $DIR/${tdir}-2/f failed"
1336 # close should still be here
1337 [ -d /proc/$close_pid ] || error "close_pid doesn't exist"
1339 wait $close_pid || error "close_pid failed"
1341 $CHECKSTAT -t file $DIR/${tdir}-1/f ||
1342 error "$CHECKSTAT $DIR/${tdir}-1/f attribute check failed"
1343 $CHECKSTAT -t file $DIR/${tdir}-2/f ||
1344 error "$CHECKSTAT $DIR/${tdir}-2/f attribute check failed"
1345 rm -rf $DIR/${tdir}-*
1347 run_test 53d "close reply while two MDC requests in flight"
1350 cancel_lru_locks mdc # cleanup locks from former test cases
1352 mkdir $DIR/${tdir}-1 || error "mkdir $DIR/${tdir}-1 failed"
1353 mkdir $DIR/${tdir}-2 || error "mkdir $DIR/${tdir}-2 failed"
1354 multiop $DIR/${tdir}-1/f O_c &
1357 #define OBD_FAIL_MDS_REINT_NET_REP 0x119
1358 do_facet $SINGLEMDS "lctl set_param fail_loc=0x119"
1359 mcreate $DIR/${tdir}-2/f &
1363 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
1364 kill -USR1 $close_pid
1365 cancel_lru_locks mdc # force the close
1366 wait $close_pid || error "close_pid failed"
1367 # open should still be here
1368 [ -d /proc/$open_pid ] || error "open_pid doesn't exists"
1370 replay_barrier_nodf $SINGLEMDS
1372 wait $open_pid || error "open_pid failed"
1374 $CHECKSTAT -t file $DIR/${tdir}-1/f ||
1375 error "$CHECKSTAT $DIR/${tdir}-1/f attribute check failed"
1376 $CHECKSTAT -t file $DIR/${tdir}-2/f ||
1377 error "$CHECKSTAT $DIR/${tdir}-2/f attribute check failed"
1378 rm -rf $DIR/${tdir}-*
1380 run_test 53e "|X| open reply while two MDC requests in flight"
1383 cancel_lru_locks mdc # cleanup locks from former test cases
1385 mkdir $DIR/${tdir}-1 || error "mkdir $DIR/${tdir}-1 failed"
1386 mkdir $DIR/${tdir}-2 || error "mkdir $DIR/${tdir}-2 failed"
1387 multiop $DIR/${tdir}-1/f O_c &
1390 #define OBD_FAIL_MDS_REINT_NET_REP 0x119
1391 do_facet $SINGLEMDS "lctl set_param fail_loc=0x119"
1392 mcreate $DIR/${tdir}-2/f &
1396 #define OBD_FAIL_MDS_CLOSE_NET_REP 0x13b
1397 do_facet $SINGLEMDS "lctl set_param fail_loc=0x8000013b"
1398 kill -USR1 $close_pid
1399 cancel_lru_locks mdc # force the close
1401 #bz20647: make sure all pids are exists before failover
1402 [ -d /proc/$close_pid ] || error "close_pid doesn't exist"
1403 [ -d /proc/$open_pid ] || error "open_pid doesn't exists"
1404 replay_barrier_nodf $SINGLEMDS
1405 fail_nodf $SINGLEMDS
1406 wait $open_pid || error "open_pid failed"
1408 # close should be gone
1409 [ -d /proc/$close_pid ] && error "close_pid should not exist"
1410 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
1412 $CHECKSTAT -t file $DIR/${tdir}-1/f ||
1413 error "$CHECKSTAT $DIR/${tdir}-1/f attribute check failed"
1414 $CHECKSTAT -t file $DIR/${tdir}-2/f ||
1415 error "$CHECKSTAT $DIR/${tdir}-2/f attribute check failed"
1416 rm -rf $DIR/${tdir}-*
1418 run_test 53f "|X| open reply and close reply while two MDC requests in flight"
1421 cancel_lru_locks mdc # cleanup locks from former test cases
1423 mkdir $DIR/${tdir}-1 || error "mkdir $DIR/${tdir}-1 failed"
1424 mkdir $DIR/${tdir}-2 || error "mkdir $DIR/${tdir}-2 failed"
1425 multiop $DIR/${tdir}-1/f O_c &
1428 #define OBD_FAIL_MDS_REINT_NET_REP 0x119
1429 do_facet $SINGLEMDS "lctl set_param fail_loc=0x119"
1430 mcreate $DIR/${tdir}-2/f &
1434 #define OBD_FAIL_MDS_CLOSE_NET 0x115
1435 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000115"
1436 kill -USR1 $close_pid
1437 cancel_lru_locks mdc # force the close
1438 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
1440 #bz20647: make sure all pids are exists before failover
1441 [ -d /proc/$close_pid ] || error "close_pid doesn't exist"
1442 [ -d /proc/$open_pid ] || error "open_pid doesn't exists"
1443 replay_barrier_nodf $SINGLEMDS
1444 fail_nodf $SINGLEMDS
1445 wait $open_pid || error "open_pid failed"
1447 # close should be gone
1448 [ -d /proc/$close_pid ] && error "close_pid should not exist"
1450 $CHECKSTAT -t file $DIR/${tdir}-1/f ||
1451 error "$CHECKSTAT $DIR/${tdir}-1/f attribute check failed"
1452 $CHECKSTAT -t file $DIR/${tdir}-2/f ||
1453 error "$CHECKSTAT $DIR/${tdir}-2/f attribute check failed"
1454 rm -rf $DIR/${tdir}-*
1456 run_test 53g "|X| drop open reply and close request while close and open are both in flight"
1459 cancel_lru_locks mdc # cleanup locks from former test cases
1461 mkdir $DIR/${tdir}-1 || error "mkdir $DIR/${tdir}-1 failed"
1462 mkdir $DIR/${tdir}-2 || error "mkdir $DIR/${tdir}-2 failed"
1463 multiop $DIR/${tdir}-1/f O_c &
1466 #define OBD_FAIL_MDS_REINT_NET 0x107
1467 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000107"
1468 mcreate $DIR/${tdir}-2/f &
1472 #define OBD_FAIL_MDS_CLOSE_NET_REP 0x13b
1473 do_facet $SINGLEMDS "lctl set_param fail_loc=0x8000013b"
1474 kill -USR1 $close_pid
1475 cancel_lru_locks mdc # force the close
1478 #bz20647: make sure all pids are exists before failover
1479 [ -d /proc/$close_pid ] || error "close_pid doesn't exist"
1480 [ -d /proc/$open_pid ] || error "open_pid doesn't exists"
1481 replay_barrier_nodf $SINGLEMDS
1482 fail_nodf $SINGLEMDS
1483 wait $open_pid || error "open_pid failed"
1485 # close should be gone
1486 [ -d /proc/$close_pid ] && error "close_pid should not exist"
1487 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
1489 $CHECKSTAT -t file $DIR/${tdir}-1/f ||
1490 error "$CHECKSTAT $DIR/${tdir}-1/f attribute check failed"
1491 $CHECKSTAT -t file $DIR/${tdir}-2/f ||
1492 error "$CHECKSTAT $DIR/${tdir}-2/f attribute check failed"
1493 rm -rf $DIR/${tdir}-*
1495 run_test 53h "open request and close reply while two MDC requests in flight"
1497 #b3761 ASSERTION(hash != 0) failed
1499 # OBD_FAIL_MDS_OPEN_CREATE | OBD_FAIL_ONCE
1500 do_facet $SINGLEMDS "lctl set_param fail_loc=0x8000012b"
1502 # give touch a chance to run
1504 do_facet $SINGLEMDS "lctl set_param fail_loc=0x0"
1508 run_test 55 "let MDS_CHECK_RESENT return the original return code instead of 0"
1510 #b3440 ASSERTION(rec->ur_fid2->id) failed
1512 ln -s foo $DIR/$tfile
1513 replay_barrier $SINGLEMDS
1514 #drop_reply "cat $DIR/$tfile"
1518 run_test 56 "don't replay a symlink open request (3440)"
1520 #recovery one mds-ost setattr from llog
1522 #define OBD_FAIL_MDS_OST_SETATTR 0x12c
1523 do_facet $SINGLEMDS "lctl set_param fail_loc=0x8000012c"
1524 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
1525 replay_barrier $SINGLEMDS
1527 wait_recovery_complete $SINGLEMDS || error "MDS recovery is not done"
1528 wait_mds_ost_sync || error "wait_mds_ost_sync failed"
1529 $CHECKSTAT -t file $DIR/$tfile ||
1530 error "$CHECKSTAT $DIR/$tfile attribute check failed"
1531 do_facet $SINGLEMDS "lctl set_param fail_loc=0x0"
1534 run_test 57 "test recovery from llog for setattr op"
1537 zconf_umount $(hostname) $MOUNT2
1541 #recovery many mds-ost setattr from llog
1543 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
1544 #define OBD_FAIL_MDS_OST_SETATTR 0x12c
1545 do_facet $SINGLEMDS "lctl set_param fail_loc=0x8000012c"
1546 createmany -o $DIR/$tdir/$tfile-%d 2500
1547 replay_barrier $SINGLEMDS
1550 $CHECKSTAT -t file $DIR/$tdir/$tfile-* >/dev/null ||
1551 error "$CHECKSTAT $DIR/$tfile-* attribute check failed"
1552 do_facet $SINGLEMDS "lctl set_param fail_loc=0x0"
1553 unlinkmany $DIR/$tdir/$tfile-%d 2500 ||
1554 error "unlinkmany $DIR/$tfile failed"
1557 run_test 58a "test recovery from llog for setattr op (test llog_gen_rec)"
1563 trap cleanup_58 EXIT
1565 large_xattr_enabled &&
1566 orig="$(generate_string $(max_xattr_size))" || orig="bar"
1567 # Original extended attribute can be long. Print a small version of
1568 # attribute if an error occurs
1569 local sm_msg=$(printf "%.9s" $orig)
1571 mount_client $MOUNT2 || error "mount_client on $MOUNT2 failed"
1572 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
1573 touch $DIR/$tdir/$tfile || error "touch $DIR/$tdir/$tfile failed"
1574 replay_barrier $SINGLEMDS
1575 setfattr -n trusted.foo -v $orig $DIR/$tdir/$tfile
1577 new=$(get_xattr_value trusted.foo $MOUNT2/$tdir/$tfile)
1578 [[ "$new" = "$orig" ]] ||
1579 error "xattr set ($sm_msg...) differs from xattr get ($new)"
1580 rm -f $DIR/$tdir/$tfile
1583 wait_clients_import_state ${CLIENTS:-$HOSTNAME} "mgs" FULL
1585 run_test 58b "test replay of setxattr op"
1587 test_58c() { # bug 16570
1592 trap cleanup_58 EXIT
1594 if large_xattr_enabled; then
1595 local xattr_size=$(max_xattr_size)
1596 orig="$(generate_string $((xattr_size / 2)))"
1597 orig1="$(generate_string $xattr_size)"
1603 # PING_INTERVAL max(obd_timeout / 4, 1U)
1604 sleep $((TIMEOUT / 4))
1606 # Original extended attribute can be long. Print a small version of
1607 # attribute if an error occurs
1608 local sm_msg=$(printf "%.9s" $orig)
1609 local sm_msg1=$(printf "%.9s" $orig1)
1611 mount_client $MOUNT2 || error "mount_client on $MOUNT2 failed"
1612 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
1613 touch $DIR/$tdir/$tfile || error "touch $DIR/$tdir/$tfile failed"
1614 drop_request "setfattr -n trusted.foo -v $orig $DIR/$tdir/$tfile" ||
1615 error "drop_request for setfattr failed"
1616 new=$(get_xattr_value trusted.foo $MOUNT2/$tdir/$tfile)
1617 [[ "$new" = "$orig" ]] ||
1618 error "xattr set ($sm_msg...) differs from xattr get ($new)"
1619 drop_reint_reply "setfattr -n trusted.foo1 \
1620 -v $orig1 $DIR/$tdir/$tfile" ||
1621 error "drop_reint_reply for setfattr failed"
1622 new=$(get_xattr_value trusted.foo1 $MOUNT2/$tdir/$tfile)
1623 [[ "$new" = "$orig1" ]] ||
1624 error "second xattr set ($sm_msg1...) differs xattr get ($new)"
1625 rm -f $DIR/$tdir/$tfile
1629 run_test 58c "resend/reconstruct setxattr op"
1631 # log_commit_thread vs filter_destroy race used to lead to import use after free
1634 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1636 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
1637 createmany -o $DIR/$tdir/$tfile-%d 200 ||
1638 error "createmany create files failed"
1640 unlinkmany $DIR/$tdir/$tfile-%d 200 ||
1641 error "unlinkmany $DIR/$tdir/$tfile failed"
1642 #define OBD_FAIL_PTLRPC_DELAY_RECOV 0x507
1643 do_facet ost1 "lctl set_param fail_loc=0x507"
1646 do_facet ost1 "lctl set_param fail_loc=0x0"
1650 run_test 59 "test log_commit_thread vs filter_destroy race"
1652 # race between add unlink llog vs cat log init in post_recovery (only for b1_6)
1653 # bug 12086: should no oops and No ctxt error for this test
1655 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
1656 createmany -o $DIR/$tdir/$tfile-%d 200 ||
1657 error "createmany create files failed"
1658 replay_barrier $SINGLEMDS
1659 unlinkmany $DIR/$tdir/$tfile-%d 0 100
1661 unlinkmany $DIR/$tdir/$tfile-%d 100 100
1662 local no_ctxt=$(dmesg | grep "No ctxt")
1663 [ -z "$no_ctxt" ] || error "ctxt is not initialized in recovery"
1665 run_test 60 "test llog post recovery init vs llog unlink"
1667 #test race llog recovery thread vs llog cleanup
1668 test_61a() { # was test_61
1669 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1671 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
1672 createmany -o $DIR/$tdir/$tfile-%d 800 ||
1673 error "createmany create files failed"
1675 unlinkmany $DIR/$tdir/$tfile-%d 800
1676 # OBD_FAIL_OST_LLOG_RECOVERY_TIMEOUT 0x221
1677 set_nodes_failloc "$(osts_nodes)" 0x80000221
1682 set_nodes_failloc "$(osts_nodes)" 0x0
1684 $CHECKSTAT -t file $DIR/$tdir/$tfile-* &&
1685 error "$CHECKSTAT $DIR/$tdir/$tfile attribute check should fail"
1688 run_test 61a "test race llog recovery vs llog cleanup"
1690 #test race mds llog sync vs llog cleanup
1692 # OBD_FAIL_MDS_LLOG_SYNC_TIMEOUT 0x13a
1693 do_facet $SINGLEMDS "lctl set_param fail_loc=0x8000013a"
1694 facet_failover $SINGLEMDS
1697 do_facet client dd if=/dev/zero of=$DIR/$tfile bs=4k count=1 ||
1700 run_test 61b "test race mds llog sync vs llog cleanup"
1702 #test race cancel cookie cb vs llog cleanup
1704 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1706 # OBD_FAIL_OST_CANCEL_COOKIE_TIMEOUT 0x222
1707 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
1708 set_nodes_failloc "$(osts_nodes)" 0x80000222
1712 set_nodes_failloc "$(osts_nodes)" 0x0
1714 run_test 61c "test race mds llog sync vs llog cleanup"
1716 test_61d() { # bug 16002 # bug 17466 # bug 22137
1717 # OBD_FAIL_OBD_LLOG_SETUP 0x605
1719 do_facet mgs "lctl set_param fail_loc=0x80000605"
1720 start mgs $(mgsdevname) $MGS_MOUNT_OPTS &&
1721 error "mgs start should have failed"
1722 do_facet mgs "lctl set_param fail_loc=0"
1723 start mgs $(mgsdevname) $MGS_MOUNT_OPTS || error "cannot restart mgs"
1725 run_test 61d "error in llog_setup should cleanup the llog context correctly"
1727 test_62() { # Bug 15756 - don't mis-drop resent replay
1728 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
1729 replay_barrier $SINGLEMDS
1730 createmany -o $DIR/$tdir/$tfile- 25 ||
1731 error "createmany create files failed"
1732 #define OBD_FAIL_TGT_REPLAY_DROP 0x707
1733 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000707"
1735 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
1736 unlinkmany $DIR/$tdir/$tfile- 25 ||
1737 error "unlinkmany $DIR/$tdir/$tfile failed"
1740 run_test 62 "don't mis-drop resent replay"
1742 #Adaptive Timeouts (bug 3055)
1750 echo "Cleaning up AT ..."
1751 if [ -n "$ATOLDBASE" ]; then
1752 local at_history=$($LCTL get_param -n at_history)
1753 do_facet $SINGLEMDS "lctl set_param at_history=$at_history" || true
1754 do_facet ost1 "lctl set_param at_history=$at_history" || true
1757 if [ $AT_MAX_SET -ne 0 ]; then
1758 for facet in mds client ost; do
1759 var=AT_MAX_SAVE_${facet}
1760 echo restore AT on $facet to saved value ${!var}
1761 at_max_set ${!var} $facet
1762 at_new=$(at_max_get $facet)
1763 echo Restored AT value on $facet $at_new
1764 [ $at_new -eq ${!var} ] ||
1765 error "AT value not restored SAVED ${!var} NEW $at_new"
1772 local at_max_new=600
1774 # Save at_max original values
1776 if [ $AT_MAX_SET -eq 0 ]; then
1777 # Suppose that all osts have the same at_max
1778 for facet in mds client ost; do
1779 eval AT_MAX_SAVE_${facet}=$(at_max_get $facet)
1783 for facet in mds client ost; do
1784 at_max=$(at_max_get $facet)
1785 if [ $at_max -ne $at_max_new ]; then
1786 echo "AT value on $facet is $at_max, set it by force temporarily to $at_max_new"
1787 at_max_set $at_max_new $facet
1792 if [ -z "$ATOLDBASE" ]; then
1793 ATOLDBASE=$(do_facet $SINGLEMDS "lctl get_param -n at_history")
1794 # speed up the timebase so we can check decreasing AT
1795 do_facet $SINGLEMDS "lctl set_param at_history=8" || true
1796 do_facet ost1 "lctl set_param at_history=8" || true
1798 # sleep for a while to cool down, should be > 8s and also allow
1799 # at least one ping to be sent. simply use TIMEOUT to be safe.
1804 test_65a() #bug 3055
1806 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1808 at_start || return 0
1809 $LCTL dk > /dev/null
1811 $LCTL set_param debug="other"
1812 # Slow down a request to the current service time, this is critical
1813 # because previous tests may have caused this value to increase.
1814 REQ_DELAY=`lctl get_param -n mdc.${FSNAME}-MDT0000-mdc-*.timeouts |
1815 awk '/portal 12/ {print $5}'`
1816 REQ_DELAY=$((${REQ_DELAY} + ${REQ_DELAY} / 4 + 5))
1818 do_facet $SINGLEMDS lctl set_param fail_val=$((${REQ_DELAY} * 1000))
1819 #define OBD_FAIL_PTLRPC_PAUSE_REQ 0x50a
1820 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x8000050a
1821 createmany -o $DIR/$tfile 10 > /dev/null
1822 unlinkmany $DIR/$tfile 10 > /dev/null
1823 # check for log message
1824 $LCTL dk | grep -i "Early reply #" || error "No early reply"
1826 # client should show REQ_DELAY estimates
1827 lctl get_param -n mdc.${FSNAME}-MDT0000-mdc-*.timeouts | grep portal
1829 lctl get_param -n mdc.${FSNAME}-MDT0000-mdc-*.timeouts | grep portal
1831 run_test 65a "AT: verify early replies"
1833 test_65b() #bug 3055
1835 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1837 at_start || return 0
1840 $LCTL set_param debug="other trace"
1841 $LCTL dk > /dev/null
1842 # Slow down a request to the current service time, this is critical
1843 # because previous tests may have caused this value to increase.
1844 $LFS setstripe --stripe-index=0 --stripe-count=1 $DIR/$tfile ||
1845 error "$LFS setstripe failed for $DIR/$tfile"
1847 multiop $DIR/$tfile Ow1yc
1848 REQ_DELAY=`lctl get_param -n osc.${FSNAME}-OST0000-osc-*.timeouts |
1849 awk '/portal 6/ {print $5}'`
1850 REQ_DELAY=$((${REQ_DELAY} + ${REQ_DELAY} / 4 + 5))
1852 do_facet ost1 lctl set_param fail_val=${REQ_DELAY}
1853 #define OBD_FAIL_OST_BRW_PAUSE_PACK 0x224
1854 do_facet ost1 $LCTL set_param fail_loc=0x224
1857 $LFS setstripe --stripe-index=0 --stripe-count=1 $DIR/$tfile ||
1858 error "$LFS setstripe failed"
1859 # force some real bulk transfer
1860 multiop $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
1862 do_facet ost1 $LCTL set_param fail_loc=0
1863 # check for log message
1864 $LCTL dk | grep -i "Early reply #" || error "No early reply"
1866 # client should show REQ_DELAY estimates
1867 lctl get_param -n osc.${FSNAME}-OST0000-osc-*.timeouts | grep portal
1869 run_test 65b "AT: verify early replies on packed reply / bulk"
1871 test_66a() #bug 3055
1873 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1875 at_start || return 0
1876 lctl get_param -n mdc.${FSNAME}-MDT0000-mdc-*.timeouts | grep "portal 12"
1877 # adjust 5s at a time so no early reply is sent (within deadline)
1878 do_facet $SINGLEMDS "$LCTL set_param fail_val=5000"
1879 #define OBD_FAIL_PTLRPC_PAUSE_REQ 0x50a
1880 do_facet $SINGLEMDS "$LCTL set_param fail_loc=0x8000050a"
1881 createmany -o $DIR/$tfile 20 > /dev/null
1882 unlinkmany $DIR/$tfile 20 > /dev/null
1883 lctl get_param -n mdc.${FSNAME}-MDT0000-mdc-*.timeouts | grep "portal 12"
1884 do_facet $SINGLEMDS "$LCTL set_param fail_val=10000"
1885 do_facet $SINGLEMDS "$LCTL set_param fail_loc=0x8000050a"
1886 createmany -o $DIR/$tfile 20 > /dev/null
1887 unlinkmany $DIR/$tfile 20 > /dev/null
1888 lctl get_param -n mdc.${FSNAME}-MDT0000-mdc-*.timeouts | grep "portal 12"
1889 do_facet $SINGLEMDS "$LCTL set_param fail_loc=0"
1891 createmany -o $DIR/$tfile 20 > /dev/null
1892 unlinkmany $DIR/$tfile 20 > /dev/null
1893 lctl get_param -n mdc.${FSNAME}-MDT0000-mdc-*.timeouts | grep "portal 12"
1894 CUR=$(lctl get_param -n mdc.${FSNAME}-MDT0000-mdc-*.timeouts | awk '/portal 12/ {print $5}')
1895 WORST=$(lctl get_param -n mdc.${FSNAME}-MDT0000-mdc-*.timeouts | awk '/portal 12/ {print $7}')
1896 echo "Current MDT timeout $CUR, worst $WORST"
1897 [ $CUR -lt $WORST ] || error "Current $CUR should be less than worst $WORST"
1899 run_test 66a "AT: verify MDT service time adjusts with no early replies"
1901 test_66b() #bug 3055
1903 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1905 at_start || return 0
1906 ORIG=$(lctl get_param -n mdc.${FSNAME}-MDT0000*.timeouts |
1907 awk '/network/ {print $4}')
1908 $LCTL set_param fail_val=$(($ORIG + 5))
1909 #define OBD_FAIL_PTLRPC_PAUSE_REP 0x50c
1910 $LCTL set_param fail_loc=0x50c
1911 touch $DIR/$tfile > /dev/null 2>&1
1912 $LCTL set_param fail_loc=0
1913 CUR=$(lctl get_param -n mdc.${FSNAME}-MDT0000*.timeouts |
1914 awk '/network/ {print $4}')
1915 WORST=$(lctl get_param -n mdc.${FSNAME}-MDT0000*.timeouts |
1916 awk '/network/ {print $6}')
1917 echo "network timeout orig $ORIG, cur $CUR, worst $WORST"
1918 [ $WORST -gt $ORIG ] ||
1919 error "Worst $WORST should be worse than orig $ORIG"
1921 run_test 66b "AT: verify net latency adjusts"
1923 test_67a() #bug 3055
1925 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1927 at_start || return 0
1928 CONN1=$(lctl get_param -n osc.*.stats | awk '/_connect/ {total+=$2} END {print total}')
1929 # sleeping threads may drive values above this
1930 do_facet ost1 "$LCTL set_param fail_val=400"
1931 #define OBD_FAIL_PTLRPC_PAUSE_REQ 0x50a
1932 do_facet ost1 "$LCTL set_param fail_loc=0x50a"
1933 createmany -o $DIR/$tfile 20 > /dev/null
1934 unlinkmany $DIR/$tfile 20 > /dev/null
1935 do_facet ost1 "$LCTL set_param fail_loc=0"
1936 CONN2=$(lctl get_param -n osc.*.stats | awk '/_connect/ {total+=$2} END {print total}')
1937 ATTEMPTS=$(($CONN2 - $CONN1))
1938 echo "$ATTEMPTS osc reconnect attempts on gradual slow"
1939 [ $ATTEMPTS -gt 0 ] &&
1940 error_ignore bz13721 "AT should have prevented reconnect"
1943 run_test 67a "AT: verify slow request processing doesn't induce reconnects"
1945 test_67b() #bug 3055
1947 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1949 at_start || return 0
1950 CONN1=$(lctl get_param -n osc.*.stats | awk '/_connect/ {total+=$2} END {print total}')
1952 # exhaust precreations on ost1
1953 local OST=$(ostname_from_index 0)
1954 local mdtosc=$(get_mdtosc_proc_path mds $OST)
1955 local last_id=$(do_facet $SINGLEMDS lctl get_param -n \
1956 osp.$mdtosc.prealloc_last_id)
1957 local next_id=$(do_facet $SINGLEMDS lctl get_param -n \
1958 osp.$mdtosc.prealloc_next_id)
1960 mkdir -p $DIR/$tdir/${OST} || error "mkdir $DIR/$tdir/${OST} failed"
1961 $LFS setstripe -i 0 -c 1 $DIR/$tdir/${OST} ||
1962 error "$LFS setstripe failed"
1963 echo "Creating to objid $last_id on ost $OST..."
1964 #define OBD_FAIL_OST_PAUSE_CREATE 0x223
1965 do_facet ost1 "$LCTL set_param fail_val=20000"
1966 do_facet ost1 "$LCTL set_param fail_loc=0x80000223"
1967 createmany -o $DIR/$tdir/${OST}/f $next_id $((last_id - next_id + 2))
1970 do_facet ost1 "lctl get_param -n ost.OSS.ost_create.timeouts"
1972 CONN2=$(lctl get_param -n osc.*.stats | awk '/_connect/ {total+=$2} END {print total}')
1973 ATTEMPTS=$(($CONN2 - $CONN1))
1974 echo "$ATTEMPTS osc reconnect attempts on instant slow"
1975 # do it again; should not timeout
1976 do_facet ost1 "$LCTL set_param fail_loc=0x80000223"
1977 cp /etc/profile $DIR/$tfile || error "cp failed"
1978 do_facet ost1 "$LCTL set_param fail_loc=0"
1980 do_facet ost1 "lctl get_param -n ost.OSS.ost_create.timeouts"
1981 CONN3=$(lctl get_param -n osc.*.stats | awk '/_connect/ {total+=$2} END {print total}')
1982 ATTEMPTS=$(($CONN3 - $CONN2))
1983 echo "$ATTEMPTS osc reconnect attempts on 2nd slow"
1984 [ $ATTEMPTS -gt 0 ] && error "AT should have prevented reconnect"
1987 run_test 67b "AT: verify instant slowdown doesn't induce reconnects"
1989 test_68 () #bug 13813
1991 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1993 at_start || return 0
1994 local ldlm_enqueue_min=$(find /sys -name ldlm_enqueue_min)
1995 [ -z "$ldlm_enqueue_min" ] && skip "missing /sys/.../ldlm_enqueue_min" && return 0
1996 local ldlm_enqueue_min_r=$(do_facet ost1 "find /sys -name ldlm_enqueue_min")
1997 [ -z "$ldlm_enqueue_min_r" ] && skip "missing /sys/.../ldlm_enqueue_min in the ost1" && return 0
1998 local ENQ_MIN=$(cat $ldlm_enqueue_min)
1999 local ENQ_MIN_R=$(do_facet ost1 "cat $ldlm_enqueue_min_r")
2000 echo $TIMEOUT >> $ldlm_enqueue_min
2001 do_facet ost1 "echo $TIMEOUT >> $ldlm_enqueue_min_r"
2003 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
2004 $LFS setstripe --stripe-index=0 -c 1 $DIR/$tdir ||
2005 error "$LFS setstripe failed for $DIR/$tdir"
2006 #define OBD_FAIL_LDLM_PAUSE_CANCEL 0x312
2007 $LCTL set_param fail_val=$(($TIMEOUT - 1))
2008 $LCTL set_param fail_loc=0x80000312
2009 cp /etc/profile $DIR/$tdir/${tfile}_1 || error "1st cp failed $?"
2010 $LCTL set_param fail_val=$((TIMEOUT * 5 / 4))
2011 $LCTL set_param fail_loc=0x80000312
2012 cp /etc/profile $DIR/$tdir/${tfile}_2 || error "2nd cp failed $?"
2013 $LCTL set_param fail_loc=0
2015 echo $ENQ_MIN >> $ldlm_enqueue_min
2016 do_facet ost1 "echo $ENQ_MIN_R >> $ldlm_enqueue_min_r"
2020 run_test 68 "AT: verify slowing locks"
2023 # end of AT tests includes above lines
2025 # start multi-client tests
2027 [ -z "$CLIENTS" ] &&
2028 { skip "Need two or more clients." && return; }
2029 [ $CLIENTCOUNT -lt 2 ] &&
2030 { skip "Need two or more clients, have $CLIENTCOUNT" && return; }
2032 echo "mount clients $CLIENTS ..."
2033 zconf_mount_clients $CLIENTS $MOUNT
2035 local clients=${CLIENTS//,/ }
2036 echo "Write/read files on $DIR ; clients $CLIENTS ... "
2037 for CLIENT in $clients; do
2038 do_node $CLIENT dd bs=1M count=10 if=/dev/zero \
2039 of=$DIR/${tfile}_${CLIENT} 2>/dev/null ||
2040 error "dd failed on $CLIENT"
2043 local prev_client=$(echo $clients | sed 's/^.* \(.\+\)$/\1/')
2044 for C in ${CLIENTS//,/ }; do
2045 do_node $prev_client dd if=$DIR/${tfile}_${C} \
2046 of=/dev/null 2>/dev/null ||
2047 error "dd if=$DIR/${tfile}_${C} failed on $prev_client"
2053 run_test 70a "check multi client t-f"
2055 check_for_process () {
2060 killall_process $clients "$prog" -0
2064 local clients=${CLIENTS:-$HOSTNAME}
2066 zconf_mount_clients $clients $MOUNT
2069 [ "$SLOW" = "no" ] && duration=120
2070 # set duration to 900 because it takes some time to boot node
2071 [ "$FAILURE_MODE" = HARD ] && duration=900
2074 local start_ts=$(date +%s)
2075 local cmd="rundbench 1 -t $duration"
2077 if [ $MDSCOUNT -ge 2 ]; then
2078 test_mkdir -p -c$MDSCOUNT $DIR/$tdir
2079 $LFS setdirstripe -D -c$MDSCOUNT $DIR/$tdir
2081 do_nodesv $clients "set -x; MISSING_DBENCH_OK=$MISSING_DBENCH_OK \
2082 PATH=\$PATH:$LUSTRE/utils:$LUSTRE/tests/:$DBENCH_LIB \
2083 DBENCH_LIB=$DBENCH_LIB TESTSUITE=$TESTSUITE TESTNAME=$TESTNAME \
2084 MOUNT=$MOUNT DIR=$DIR/$tdir/\\\$(hostname) LCTL=$LCTL $cmd" &
2087 #LU-1897 wait for all dbench copies to start
2088 while ! check_for_process $clients dbench; do
2089 elapsed=$(($(date +%s) - start_ts))
2090 if [ $elapsed -gt $duration ]; then
2091 killall_process $clients dbench
2092 error "dbench failed to start on $clients!"
2097 log "Started rundbench load pid=$pid ..."
2099 elapsed=$(($(date +%s) - start_ts))
2100 local num_failovers=0
2102 while [ $elapsed -lt $duration ]; do
2103 if ! check_for_process $clients dbench; then
2104 error_noexit "dbench stopped on some of $clients!"
2105 killall_process $clients dbench
2109 replay_barrier mds$fail_index
2110 sleep 1 # give clients a time to do operations
2111 # Increment the number of failovers
2112 num_failovers=$((num_failovers+1))
2113 log "$TESTNAME fail mds$fail_index $num_failovers times"
2115 elapsed=$(($(date +%s) - start_ts))
2116 if [ $fail_index -ge $MDSCOUNT ]; then
2119 fail_index=$((fail_index+1))
2123 wait $pid || error "rundbench load on $clients failed!"
2125 run_test 70b "dbench ${MDSCOUNT}mdts recovery; $CLIENTCOUNT clients"
2126 # end multi-client tests
2131 local monitor_pid=$3
2133 local start_ts=$(date +%s)
2134 local num_failovers=0
2137 elapsed=$(($(date +%s) - start_ts))
2138 while [ $elapsed -lt $duration ]; do
2139 fail_index=$((RANDOM%max_index+1))
2140 kill -0 $monitor_pid ||
2141 error "$monitor_pid stopped"
2143 replay_barrier mds$fail_index
2145 # Increment the number of failovers
2146 num_failovers=$((num_failovers+1))
2147 log "$TESTNAME fail mds$fail_index $num_failovers times"
2149 elapsed=$(($(date +%s) - start_ts))
2155 rm -f $DIR/replay-single.70c.lck
2160 local clients=${CLIENTS:-$HOSTNAME}
2163 zconf_mount_clients $clients $MOUNT
2166 [ "$SLOW" = "no" ] && duration=180
2167 # set duration to 900 because it takes some time to boot node
2168 [ "$FAILURE_MODE" = HARD ] && duration=600
2171 local start_ts=$(date +%s)
2173 trap cleanup_70c EXIT
2175 while [ ! -e $DIR/replay-single.70c.lck ]; do
2176 test_mkdir -p -c$MDSCOUNT $DIR/$tdir || break
2177 if [ $MDSCOUNT -ge 2 ]; then
2178 $LFS setdirstripe -D -c$MDSCOUNT $DIR/$tdir ||
2179 error "set default dirstripe failed"
2181 cd $DIR/$tdir || break
2182 tar cf - /etc | tar xf - || error "tar failed in loop"
2186 echo "Started tar $tar_70c_pid"
2188 random_fail_mdt $MDSCOUNT $duration $tar_70c_pid
2189 kill -0 $tar_70c_pid || error "tar $tar_70c_pid stopped"
2191 touch $DIR/replay-single.70c.lck
2192 wait $tar_70c_pid || error "$?: tar failed"
2197 run_test 70c "tar ${MDSCOUNT}mdts recovery"
2201 kill -9 $mkdir_70d_pid
2205 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2206 local clients=${CLIENTS:-$HOSTNAME}
2209 zconf_mount_clients $clients $MOUNT
2212 [ "$SLOW" = "no" ] && duration=180
2213 # set duration to 900 because it takes some time to boot node
2214 [ "$FAILURE_MODE" = HARD ] && duration=900
2219 local start_ts=$(date +%s)
2221 trap cleanup_70d EXIT
2224 $LFS mkdir -i0 -c2 $DIR/$tdir/test || {
2228 $LFS mkdir -i1 -c2 $DIR/$tdir/test1 || {
2233 touch $DIR/$tdir/test/a || {
2237 mkdir $DIR/$tdir/test/b || {
2241 rm -rf $DIR/$tdir/test || {
2247 touch $DIR/$tdir/test1/a || {
2251 mkdir $DIR/$tdir/test1/b || {
2256 rm -rf $DIR/$tdir/test1 || {
2258 ls -lR $DIR/$tdir/test1
2264 echo "Started $mkdir_70d_pid"
2266 random_fail_mdt $MDSCOUNT $duration $mkdir_70d_pid
2267 kill -0 $mkdir_70d_pid || error "mkdir/rmdir $mkdir_70d_pid stopped"
2272 run_test 70d "mkdir/rmdir striped dir ${MDSCOUNT}mdts recovery"
2275 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2276 local clients=${CLIENTS:-$HOSTNAME}
2279 lctl set_param debug=+ha
2280 zconf_mount_clients $clients $MOUNT
2283 [ "$SLOW" = "no" ] && duration=180
2284 # set duration to 900 because it takes some time to boot node
2285 [ "$FAILURE_MODE" = HARD ] && duration=900
2288 $LFS mkdir -i0 $DIR/$tdir/test_0
2289 $LFS mkdir -i0 $DIR/$tdir/test_1
2290 touch $DIR/$tdir/test_0/a
2291 touch $DIR/$tdir/test_1/b
2294 mrename $DIR/$tdir/test_0/a $DIR/$tdir/test_1/b > /dev/null || {
2299 checkstat $DIR/$tdir/test_0/a && {
2300 echo "a still exists"
2304 checkstat $DIR/$tdir/test_1/b || {
2305 echo "b still exists"
2309 touch $DIR/$tdir/test_0/a || {
2310 echo "touch a fails"
2314 mrename $DIR/$tdir/test_1/b $DIR/$tdir/test_0/a > /dev/null || {
2321 stack_trap "kill -9 $rename_70e_pid" EXIT
2322 echo "Started PID=$rename_70e_pid"
2324 random_fail_mdt 2 $duration $rename_70e_pid
2325 kill -0 $rename_70e_pid || error "rename $rename_70e_pid stopped"
2327 run_test 70e "rename cross-MDT with random fails"
2329 test_70f_write_and_read(){
2334 echo "Write/read files in: '$DIR/$tdir', clients: '$CLIENTS' ..."
2335 for client in ${CLIENTS//,/ }; do
2336 [ -f $stopflag ] || return
2338 local tgtfile=$DIR/$tdir/$tfile.$client
2339 do_node $client dd $DD_OPTS bs=1M count=10 if=$srcfile \
2340 of=$tgtfile 2>/dev/null ||
2341 error "dd $DD_OPTS bs=1M count=10 if=$srcfile " \
2342 "of=$tgtfile failed on $client, rc=$?"
2345 local prev_client=$(echo ${CLIENTS//,/ } | awk '{ print $NF }')
2348 for client in ${CLIENTS//,/ }; do
2349 [ -f $stopflag ] || return
2351 # flush client cache in case test is running on only one client
2352 # do_node $client cancel_lru_locks osc
2353 do_node $client $LCTL set_param ldlm.namespaces.*.lru_size=clear
2355 tgtfile=$DIR/$tdir/$tfile.$client
2356 local md5=$(do_node $prev_client "md5sum $tgtfile")
2357 [ ${checksum[$index]// */} = ${md5// */} ] ||
2358 error "$tgtfile: checksum doesn't match on $prev_client"
2359 index=$((index + 1))
2369 mkdir -p $DIR/$tdir || error "cannot create $DIR/$tdir directory"
2370 $LFS setstripe -c -1 $DIR/$tdir ||
2371 error "cannot $LFS setstripe $DIR/$tdir"
2374 while [ -f $stopflag ]; do
2375 test_70f_write_and_read $srcfile $stopflag
2376 # use direct IO and buffer cache in turns if loop
2377 [ -n "$DD_OPTS" ] && DD_OPTS="" || DD_OPTS="oflag=direct"
2381 test_70f_cleanup() {
2383 rm -f $TMP/$tfile.stop
2384 do_nodes $CLIENTS rm -f $TMP/$tfile
2385 rm -f $DIR/$tdir/$tfile.*
2389 # [ x$ost1failover_HOST = x$ost_HOST ] &&
2390 # { skip "Failover host not defined" && return; }
2391 # [ -z "$CLIENTS" ] &&
2392 # { skip "CLIENTS are not specified." && return; }
2393 # [ $CLIENTCOUNT -lt 2 ] &&
2394 # { skip "Need 2 or more clients, have $CLIENTCOUNT" && return; }
2396 [[ "$OST1_VERSION" -lt $(version_code 2.9.53) ]] &&
2397 skip "Need server version at least 2.9.53"
2399 echo "mount clients $CLIENTS ..."
2400 zconf_mount_clients $CLIENTS $MOUNT
2402 local srcfile=$TMP/$tfile
2406 trap test_70f_cleanup EXIT
2407 # create a different source file local to each client node so we can
2408 # detect if the file wasn't written out properly after failover
2409 do_nodes $CLIENTS dd bs=1M count=10 if=/dev/urandom of=$srcfile \
2410 2>/dev/null || error "can't create $srcfile on $CLIENTS"
2411 for client in ${CLIENTS//,/ }; do
2412 checksum[$index]=$(do_node $client "md5sum $srcfile")
2413 index=$((index + 1))
2417 [ "$SLOW" = "no" ] && duration=60
2418 # set duration to 900 because it takes some time to boot node
2419 [ "$FAILURE_MODE" = HARD ] && duration=900
2421 local stopflag=$TMP/$tfile.stop
2422 test_70f_loop $srcfile $stopflag &
2426 local num_failovers=0
2427 local start_ts=$SECONDS
2428 while [ $elapsed -lt $duration ]; do
2432 num_failovers=$((num_failovers + 1))
2433 log "$TESTNAME failing OST $num_failovers times"
2436 elapsed=$((SECONDS - start_ts))
2443 run_test 70f "OSS O_DIRECT recovery with $CLIENTCOUNT clients"
2447 kill -9 $mkdir_71a_pid
2450 random_double_fail_mdt() {
2453 local monitor_pid=$3
2455 local start_ts=$(date +%s)
2456 local num_failovers=0
2460 elapsed=$(($(date +%s) - start_ts))
2461 while [ $elapsed -lt $duration ]; do
2462 fail_index=$((RANDOM%max_index + 1))
2463 if [ $fail_index -eq $max_index ]; then
2466 second_index=$((fail_index + 1))
2468 kill -0 $monitor_pid ||
2469 error "$monitor_pid stopped"
2471 replay_barrier mds$fail_index
2472 replay_barrier mds$second_index
2474 # Increment the number of failovers
2475 num_failovers=$((num_failovers+1))
2476 log "fail mds$fail_index mds$second_index $num_failovers times"
2477 fail mds${fail_index},mds${second_index}
2478 elapsed=$(($(date +%s) - start_ts))
2483 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2484 local clients=${CLIENTS:-$HOSTNAME}
2487 zconf_mount_clients $clients $MOUNT
2490 [ "$SLOW" = "no" ] && duration=180
2491 # set duration to 900 because it takes some time to boot node
2492 [ "$FAILURE_MODE" = HARD ] && duration=900
2497 local start_ts=$(date +%s)
2499 trap cleanup_71a EXIT
2502 $LFS mkdir -i0 -c2 $DIR/$tdir/test
2503 rmdir $DIR/$tdir/test
2507 echo "Started $mkdir_71a_pid"
2509 random_double_fail_mdt 2 $duration $mkdir_71a_pid
2510 kill -0 $mkdir_71a_pid || error "mkdir/rmdir $mkdir_71a_pid stopped"
2515 run_test 71a "mkdir/rmdir striped dir with 2 mdts recovery"
2518 multiop_bg_pause $DIR/$tfile O_tSc ||
2519 error "multiop_bg_pause $DIR/$tfile failed"
2523 replay_barrier $SINGLEMDS
2524 #define OBD_FAIL_LDLM_ENQUEUE_NET 0x302
2525 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000302"
2528 wait $pid || error "multiop pid failed"
2529 [ -e $DIR/$tfile ] && error "file $DIR/$tfile should not exist"
2532 run_test 73a "open(O_CREAT), unlink, replay, reconnect before open replay, close"
2535 multiop_bg_pause $DIR/$tfile O_tSc ||
2536 error "multiop_bg_pause $DIR/$tfile failed"
2540 replay_barrier $SINGLEMDS
2541 #define OBD_FAIL_MDS_LDLM_REPLY_NET 0x157
2542 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000157"
2545 wait $pid || error "multiop pid failed"
2546 [ -e $DIR/$tfile ] && error "file $DIR/$tfile should not exist"
2549 run_test 73b "open(O_CREAT), unlink, replay, reconnect at open_replay reply, close"
2553 local clients=${CLIENTS:-$HOSTNAME}
2555 zconf_umount_clients $clients $MOUNT
2557 facet_failover $SINGLEMDS
2558 zconf_mount_clients $clients $MOUNT
2560 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
2561 rm $DIR/$tfile || error "rm $DIR/$tfile failed"
2562 clients_up || error "client evicted: $?"
2565 run_test 74 "Ensure applications don't fail waiting for OST recovery"
2567 remote_dir_check_80() {
2572 diridx=$($LFS getstripe -m $remote_dir) ||
2573 error "$LFS getstripe -m $remote_dir failed"
2574 [ $diridx -eq $mdtidx ] || error "$diridx != $mdtidx"
2576 createmany -o $remote_dir/f-%d 20 || error "creation failed"
2577 fileidx=$($LFS getstripe -m $remote_dir/f-1) ||
2578 error "$LFS getstripe -m $remote_dir/f-1 failed"
2579 [ $fileidx -eq $mdtidx ] || error "$fileidx != $mdtidx"
2585 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2586 ([ $FAILURE_MODE == "HARD" ] &&
2587 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
2588 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
2592 local remote_dir=$DIR/$tdir/remote_dir
2594 mkdir -p $DIR/$tdir || error "mkdir $DIR/$tdir failed"
2595 #define OBD_FAIL_OUT_UPDATE_NET_REP 0x1701
2596 do_facet mds${MDTIDX} lctl set_param fail_loc=0x1701
2597 $LFS mkdir -i $MDTIDX $remote_dir &
2603 wait $CLIENT_PID || error "remote creation failed"
2605 remote_dir_check_80 || error "remote dir check failed"
2606 rm -rf $DIR/$tdir || error "rmdir failed"
2610 run_test 80a "DNE: create remote dir, drop update rep from MDT0, fail MDT0"
2613 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2614 ([ $FAILURE_MODE == "HARD" ] &&
2615 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
2616 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
2620 local remote_dir=$DIR/$tdir/remote_dir
2622 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
2623 #define OBD_FAIL_OUT_UPDATE_NET_REP 0x1701
2624 do_facet mds${MDTIDX} lctl set_param fail_loc=0x1701
2625 $LFS mkdir -i $MDTIDX $remote_dir &
2630 fail mds$((MDTIDX + 1))
2632 wait $CLIENT_PID || error "remote creation failed"
2634 remote_dir_check_80 || error "remote dir check failed"
2635 rm -rf $DIR/$tdir || error "rmdir failed"
2639 run_test 80b "DNE: create remote dir, drop update rep from MDT0, fail MDT1"
2642 [[ "$mds1_FSTYPE" = zfs ]] &&
2643 [[ $MDS1_VERSION -lt $(version_code 2.12.51) ]] &&
2644 skip "requires LU-10143 fix on MDS"
2645 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
2646 ([ $FAILURE_MODE == "HARD" ] &&
2647 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
2648 skip "MDTs needs to be on diff hosts for HARD fail mode"
2651 local remote_dir=$DIR/$tdir/remote_dir
2653 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
2654 #define OBD_FAIL_OUT_UPDATE_NET_REP 0x1701
2655 do_facet mds${MDTIDX} lctl set_param fail_loc=0x1701
2656 $LFS mkdir -i $MDTIDX $remote_dir &
2662 fail mds$((MDTIDX + 1))
2664 wait $CLIENT_PID || error "remote creation failed"
2666 remote_dir_check_80 || error "remote dir check failed"
2667 rm -rf $DIR/$tdir || error "rmdir failed"
2671 run_test 80c "DNE: create remote dir, drop update rep from MDT1, fail MDT[0,1]"
2674 [[ "$mds1_FSTYPE" = zfs ]] &&
2675 [[ $MDS1_VERSION -lt $(version_code 2.12.51) ]] &&
2676 skip "requires LU-10143 fix on MDS"
2677 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
2679 local remote_dir=$DIR/$tdir/remote_dir
2681 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
2682 #define OBD_FAIL_OUT_UPDATE_NET_REP 0x1701
2683 do_facet mds${MDTIDX} lctl set_param fail_loc=0x1701
2684 $LFS mkdir -i $MDTIDX $remote_dir &
2687 # sleep 3 seconds to make sure MDTs are failed after
2688 # lfs mkdir -i has finished on all of MDTs.
2693 fail mds${MDTIDX},mds$((MDTIDX + 1))
2695 wait $CLIENT_PID || error "remote creation failed"
2697 remote_dir_check_80 || error "remote dir check failed"
2698 rm -rf $DIR/$tdir || error "rmdir failed"
2702 run_test 80d "DNE: create remote dir, drop update rep from MDT1, fail 2 MDTs"
2705 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2706 ([ $FAILURE_MODE == "HARD" ] &&
2707 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
2708 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
2712 local remote_dir=$DIR/$tdir/remote_dir
2714 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
2715 # OBD_FAIL_MDS_REINT_NET_REP 0x119
2716 do_facet mds$((MDTIDX + 1)) lctl set_param fail_loc=0x119
2717 $LFS mkdir -i $MDTIDX $remote_dir &
2720 # sleep 3 seconds to make sure MDTs are failed after
2721 # lfs mkdir -i has finished on all of MDTs.
2727 wait $CLIENT_PID || error "remote creation failed"
2729 remote_dir_check_80 || error "remote dir check failed"
2730 rm -rf $DIR/$tdir || error "rmdir failed"
2734 run_test 80e "DNE: create remote dir, drop MDT1 rep, fail MDT0"
2737 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2738 ([ $FAILURE_MODE == "HARD" ] &&
2739 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
2740 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
2743 local remote_dir=$DIR/$tdir/remote_dir
2745 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
2746 # OBD_FAIL_MDS_REINT_NET_REP 0x119
2747 do_facet mds$((MDTIDX + 1)) lctl set_param fail_loc=0x119
2748 $LFS mkdir -i $MDTIDX $remote_dir &
2752 fail mds$((MDTIDX + 1))
2754 wait $CLIENT_PID || error "remote creation failed"
2756 remote_dir_check_80 || error "remote dir check failed"
2757 rm -rf $DIR/$tdir || error "rmdir failed"
2761 run_test 80f "DNE: create remote dir, drop MDT1 rep, fail MDT1"
2764 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2765 ([ $FAILURE_MODE == "HARD" ] &&
2766 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
2767 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
2771 local remote_dir=$DIR/$tdir/remote_dir
2773 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
2774 # OBD_FAIL_MDS_REINT_NET_REP 0x119
2775 do_facet mds$((MDTIDX + 1)) lctl set_param fail_loc=0x119
2776 $LFS mkdir -i $MDTIDX $remote_dir &
2779 # sleep 3 seconds to make sure MDTs are failed after
2780 # lfs mkdir -i has finished on all of MDTs.
2786 fail mds$((MDTIDX + 1))
2788 wait $CLIENT_PID || error "remote creation failed"
2790 remote_dir_check_80 || error "remote dir check failed"
2791 rm -rf $DIR/$tdir || error "rmdir failed"
2795 run_test 80g "DNE: create remote dir, drop MDT1 rep, fail MDT0, then MDT1"
2798 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2800 local remote_dir=$DIR/$tdir/remote_dir
2802 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
2803 # OBD_FAIL_MDS_REINT_NET_REP 0x119
2804 do_facet mds$((MDTIDX + 1)) lctl set_param fail_loc=0x119
2805 $LFS mkdir -i $MDTIDX $remote_dir &
2808 # sleep 3 seconds to make sure MDTs are failed after
2809 # lfs mkdir -i has finished on all of MDTs.
2814 fail mds${MDTIDX},mds$((MDTIDX + 1))
2816 wait $CLIENT_PID || error "remote dir creation failed"
2818 remote_dir_check_80 || error "remote dir check failed"
2819 rm -rf $DIR/$tdir || error "rmdir failed"
2823 run_test 80h "DNE: create remote dir, drop MDT1 rep, fail 2 MDTs"
2826 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2827 ([ $FAILURE_MODE == "HARD" ] &&
2828 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
2829 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
2833 local remote_dir=$DIR/$tdir/remote_dir
2835 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
2836 $LFS mkdir -i $MDTIDX $remote_dir || error "lfs mkdir failed"
2838 touch $remote_dir || error "touch $remote_dir failed"
2839 # OBD_FAIL_OUT_UPDATE_NET_REP 0x1701
2840 do_facet mds${MDTIDX} lctl set_param fail_loc=0x1701
2845 fail mds$((MDTIDX + 1))
2847 wait $CLIENT_PID || error "rm remote dir failed"
2849 stat $remote_dir &>/dev/null && error "$remote_dir still exist!"
2851 rm -rf $DIR/$tdir || error "rmdir failed"
2855 run_test 81a "DNE: unlink remote dir, drop MDT0 update rep, fail MDT1"
2858 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2859 ([ $FAILURE_MODE == "HARD" ] &&
2860 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
2861 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
2864 local remote_dir=$DIR/$tdir/remote_dir
2866 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
2867 $LFS mkdir -i $MDTIDX $remote_dir || error "lfs mkdir failed"
2869 # OBD_FAIL_OUT_UPDATE_NET_REP 0x1701
2870 do_facet mds${MDTIDX} lctl set_param fail_loc=0x1701
2877 wait $CLIENT_PID || error "rm remote dir failed"
2879 stat $remote_dir &>/dev/null && error "$remote_dir still exist!"
2881 rm -rf $DIR/$tdir || error "rmdir failed"
2885 run_test 81b "DNE: unlink remote dir, drop MDT0 update reply, fail MDT0"
2888 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2889 ([ $FAILURE_MODE == "HARD" ] &&
2890 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
2891 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
2895 local remote_dir=$DIR/$tdir/remote_dir
2897 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
2898 $LFS mkdir -i $MDTIDX $remote_dir || error "lfs mkdir failed"
2900 # OBD_FAIL_OUT_UPDATE_NET_REP 0x1701
2901 do_facet mds${MDTIDX} lctl set_param fail_loc=0x1701
2908 fail mds$((MDTIDX + 1))
2910 wait $CLIENT_PID || error "rm remote dir failed"
2912 stat $remote_dir &>/dev/null && error "$remote_dir still exist!"
2914 rm -rf $DIR/$tdir || error "rmdir failed"
2918 run_test 81c "DNE: unlink remote dir, drop MDT0 update reply, fail MDT0,MDT1"
2921 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2923 local remote_dir=$DIR/$tdir/remote_dir
2925 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
2926 $LFS mkdir -i $MDTIDX $remote_dir || error "lfs mkdir failed"
2928 # OBD_FAIL_OUT_UPDATE_NET_REP 0x1701
2929 do_facet mds${MDTIDX} lctl set_param fail_loc=0x1701
2935 fail mds${MDTIDX},mds$((MDTIDX + 1))
2937 wait $CLIENT_PID || error "rm remote dir failed"
2939 stat $remote_dir &>/dev/null && error "$remote_dir still exist!"
2941 rm -rf $DIR/$tdir || error "rmdir failed"
2945 run_test 81d "DNE: unlink remote dir, drop MDT0 update reply, fail 2 MDTs"
2948 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2949 ([ $FAILURE_MODE == "HARD" ] &&
2950 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
2951 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
2955 local remote_dir=$DIR/$tdir/remote_dir
2957 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
2958 $LFS mkdir -i $MDTIDX $remote_dir || error "lfs mkdir failed"
2960 # OBD_FAIL_MDS_REINT_NET_REP 0x119
2961 do_facet mds$((MDTIDX + 1)) lctl set_param fail_loc=0x119
2964 do_facet mds$((MDTIDX + 1)) lctl set_param fail_loc=0
2969 wait $CLIENT_PID || error "rm remote dir failed"
2971 stat $remote_dir &>/dev/null && error "$remote_dir still exist!"
2973 rm -rf $DIR/$tdir || error "rmdir failed"
2977 run_test 81e "DNE: unlink remote dir, drop MDT1 req reply, fail MDT0"
2980 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2981 ([ $FAILURE_MODE == "HARD" ] &&
2982 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
2983 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
2987 local remote_dir=$DIR/$tdir/remote_dir
2989 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
2990 $LFS mkdir -i $MDTIDX $remote_dir || error "lfs mkdir failed"
2992 # OBD_FAIL_MDS_REINT_NET_REP 0x119
2993 do_facet mds$((MDTIDX + 1)) lctl set_param fail_loc=0x119
2998 fail mds$((MDTIDX + 1))
3000 wait $CLIENT_PID || error "rm remote dir failed"
3002 stat $remote_dir &>/dev/null && error "$remote_dir still exist!"
3004 rm -rf $DIR/$tdir || error "rmdir failed"
3008 run_test 81f "DNE: unlink remote dir, drop MDT1 req reply, fail MDT1"
3011 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
3012 ([ $FAILURE_MODE == "HARD" ] &&
3013 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
3014 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
3018 local remote_dir=$DIR/$tdir/remote_dir
3020 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
3021 $LFS mkdir -i $MDTIDX $remote_dir || error "lfs mkdir failed"
3023 # OBD_FAIL_MDS_REINT_NET_REP 0x119
3024 do_facet mds$((MDTIDX + 1)) lctl set_param fail_loc=0x119
3031 fail mds$((MDTIDX + 1))
3033 wait $CLIENT_PID || error "rm remote dir failed"
3035 stat $remote_dir &>/dev/null && error "$remote_dir still exist!"
3037 rm -rf $DIR/$tdir || error "rmdir failed"
3041 run_test 81g "DNE: unlink remote dir, drop req reply, fail M0, then M1"
3044 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
3046 local remote_dir=$DIR/$tdir/remote_dir
3048 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
3049 $LFS mkdir -i $MDTIDX $remote_dir || error "lfs mkdir failed"
3051 # OBD_FAIL_MDS_REINT_NET_REP 0x119
3052 do_facet mds$((MDTIDX + 1)) lctl set_param fail_loc=0x119
3058 fail mds${MDTIDX},mds$((MDTIDX + 1))
3060 wait $CLIENT_PID || error "rm remote dir failed"
3062 stat $remote_dir &>/dev/null && error "$remote_dir still exist!"
3064 rm -rf $DIR/$tdir || error "rmdir failed"
3068 run_test 81h "DNE: unlink remote dir, drop request reply, fail 2 MDTs"
3071 #define OBD_FAIL_MDS_OPEN_WAIT_CREATE 0x144
3072 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000144"
3073 createmany -o $DIR/$tfile- 1 &
3077 client_up || client_up || true # reconnect
3079 run_test 84a "stale open during export disconnect"
3081 test_85a() { #bug 16774
3082 lctl set_param -n ldlm.cancel_unused_locks_before_replay "1"
3084 for i in $(seq 100); do
3085 echo "tag-$i" > $DIR/$tfile-$i
3086 grep -q "tag-$i" $DIR/$tfile-$i || error "f2-$i"
3089 lov_id=$(lctl dl | grep "clilov")
3090 addr=$(echo $lov_id | awk '{print $4}' | awk -F '-' '{print $NF}')
3091 count=$(lctl get_param -n \
3092 ldlm.namespaces.*MDT0000*$addr.lock_unused_count)
3093 echo "before recovery: unused locks count = $count"
3097 count2=$(lctl get_param -n \
3098 ldlm.namespaces.*MDT0000*$addr.lock_unused_count)
3099 echo "after recovery: unused locks count = $count2"
3101 if [ $count2 -ge $count ]; then
3102 error "unused locks are not canceled"
3105 run_test 85a "check the cancellation of unused locks during recovery(IBITS)"
3107 test_85b() { #bug 16774
3111 lctl set_param -n ldlm.cancel_unused_locks_before_replay "1"
3113 $LFS setstripe -c 1 -i 0 $DIR/$tdir
3115 for i in $(seq 100); do
3116 dd if=/dev/urandom of=$DIR/$tdir/$tfile-$i bs=4096 \
3117 count=32 >/dev/null 2>&1
3120 cancel_lru_locks osc
3122 for i in $(seq 100); do
3123 dd if=$DIR/$tdir/$tfile-$i of=/dev/null bs=4096 \
3124 count=32 >/dev/null 2>&1
3127 lov_id=$(lctl dl | grep "clilov")
3128 addr=$(echo $lov_id | awk '{print $4}' | awk -F '-' '{print $NF}')
3129 count=$(lctl get_param -n \
3130 ldlm.namespaces.*OST0000*$addr.lock_unused_count)
3131 echo "before recovery: unused locks count = $count"
3132 [ $count -ne 0 ] || error "unused locks ($count) should be zero"
3136 count2=$(lctl get_param \
3137 -n ldlm.namespaces.*OST0000*$addr.lock_unused_count)
3138 echo "after recovery: unused locks count = $count2"
3140 if [ $count2 -ge $count ]; then
3141 error "unused locks are not canceled"
3146 run_test 85b "check the cancellation of unused locks during recovery(EXTENT)"
3149 local clients=${CLIENTS:-$HOSTNAME}
3151 zconf_umount_clients $clients $MOUNT
3152 do_facet $SINGLEMDS lctl set_param mdt.${FSNAME}-MDT*.exports.clear=0
3153 remount_facet $SINGLEMDS
3154 zconf_mount_clients $clients $MOUNT
3156 run_test 86 "umount server after clear nid_stats should not hit LBUG"
3159 do_facet ost1 "lctl set_param -n obdfilter.${ost1_svc}.sync_journal 0"
3162 $LFS setstripe -i 0 -c 1 $DIR/$tfile
3163 dd if=/dev/urandom of=$DIR/$tfile bs=1024k count=8 ||
3164 error "dd to $DIR/$tfile failed"
3165 cksum=$(md5sum $DIR/$tfile | awk '{print $1}')
3166 cancel_lru_locks osc
3168 dd if=$DIR/$tfile of=/dev/null bs=1024k count=8 || error "Cannot read"
3169 cksum2=$(md5sum $DIR/$tfile | awk '{print $1}')
3170 if [ $cksum != $cksum2 ] ; then
3171 error "New checksum $cksum2 does not match original $cksum"
3174 run_test 87a "write replay"
3177 do_facet ost1 "lctl set_param -n obdfilter.${ost1_svc}.sync_journal 0"
3180 $LFS setstripe -i 0 -c 1 $DIR/$tfile
3181 dd if=/dev/urandom of=$DIR/$tfile bs=1024k count=8 ||
3182 error "dd to $DIR/$tfile failed"
3183 sleep 1 # Give it a chance to flush dirty data
3184 echo TESTTEST | dd of=$DIR/$tfile bs=1 count=8 seek=64
3185 cksum=$(md5sum $DIR/$tfile | awk '{print $1}')
3186 cancel_lru_locks osc
3188 dd if=$DIR/$tfile of=/dev/null bs=1024k count=8 || error "Cannot read"
3189 cksum2=$(md5sum $DIR/$tfile | awk '{print $1}')
3190 if [ $cksum != $cksum2 ] ; then
3191 error "New checksum $cksum2 does not match original $cksum"
3194 run_test 87b "write replay with changed data (checksum resend)"
3196 test_88() { #bug 17485
3197 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
3198 mkdir -p $TMP/$tdir || error "mkdir $TMP/$tdir failed"
3200 $LFS setstripe -i 0 -c 1 $DIR/$tdir || error "$LFS setstripe failed"
3203 replay_barrier $SINGLEMDS
3205 # exhaust precreations on ost1
3206 local OST=$(ostname_from_index 0)
3207 local mdtosc=$(get_mdtosc_proc_path $SINGLEMDS $OST)
3208 local last_id=$(do_facet $SINGLEMDS lctl get_param -n osp.$mdtosc.prealloc_last_id)
3209 local next_id=$(do_facet $SINGLEMDS lctl get_param -n osp.$mdtosc.prealloc_next_id)
3210 echo "before test: last_id = $last_id, next_id = $next_id"
3212 echo "Creating to objid $last_id on ost $OST..."
3213 createmany -o $DIR/$tdir/f-%d $next_id $((last_id - next_id + 2)) ||
3214 error "createmany create files to last_id failed"
3216 #create some files to use some uncommitted objids
3217 last_id=$(($last_id + 1))
3218 createmany -o $DIR/$tdir/f-%d $last_id 8 ||
3219 error "createmany create files with uncommitted objids failed"
3221 last_id2=$(do_facet $SINGLEMDS lctl get_param -n osp.$mdtosc.prealloc_last_id)
3222 next_id2=$(do_facet $SINGLEMDS lctl get_param -n osp.$mdtosc.prealloc_next_id)
3223 echo "before recovery: last_id = $last_id2, next_id = $next_id2"
3225 # if test uses shutdown_facet && reboot_facet instead of facet_failover ()
3226 # it has to take care about the affected facets, bug20407
3227 local affected_mds1=$(affected_facets mds1)
3228 local affected_ost1=$(affected_facets ost1)
3230 shutdown_facet $SINGLEMDS
3233 reboot_facet $SINGLEMDS
3234 change_active $affected_mds1
3235 wait_for_facet $affected_mds1
3236 mount_facets $affected_mds1 || error "Restart of mds failed"
3239 change_active $affected_ost1
3240 wait_for_facet $affected_ost1
3241 mount_facets $affected_ost1 || error "Restart of ost1 failed"
3245 last_id2=$(do_facet $SINGLEMDS lctl get_param -n osp.$mdtosc.prealloc_last_id)
3246 next_id2=$(do_facet $SINGLEMDS lctl get_param -n osp.$mdtosc.prealloc_next_id)
3247 echo "after recovery: last_id = $last_id2, next_id = $next_id2"
3249 # create new files, which should use new objids, and ensure the orphan
3250 # cleanup phase for ost1 is completed at the same time
3251 for i in $(seq 8); do
3252 file_id=$(($last_id + 10 + $i))
3253 dd if=/dev/urandom of=$DIR/$tdir/f-$file_id bs=4096 count=128
3256 # if the objids were not recreated, then "ls" will fail with -ENOENT
3257 ls -l $DIR/$tdir/* || error "can't get the status of precreated files"
3260 # write into previously created files
3261 for i in $(seq 8); do
3262 file_id=$(($last_id + $i))
3263 dd if=/dev/urandom of=$DIR/$tdir/f-$file_id bs=4096 count=128
3264 cp -f $DIR/$tdir/f-$file_id $TMP/$tdir/
3267 # compare the content
3268 for i in $(seq 8); do
3269 file_id=$(($last_id + $i))
3270 cmp $TMP/$tdir/f-$file_id $DIR/$tdir/f-$file_id ||
3271 error "the content of file is modified!"
3276 run_test 88 "MDS should not assign same objid to different files "
3278 function calc_osc_kbytes_used() {
3279 local kbtotal=$(calc_osc_kbytes kbytestotal)
3280 local kbfree=$(calc_osc_kbytes kbytesfree)
3281 echo $((kbtotal-kbfree))
3285 cancel_lru_locks osc
3286 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
3287 rm -f $DIR/$tdir/$tfile
3288 wait_mds_ost_sync || error "initial MDS-OST sync timed out"
3289 wait_delete_completed || error "initial wait delete timed out"
3290 local blocks1=$(calc_osc_kbytes_used)
3291 local write_size=$(fs_log_size)
3293 $LFS setstripe -i 0 -c 1 $DIR/$tdir/$tfile
3294 [ $write_size -lt 1024 ] && write_size=1024
3295 dd if=/dev/zero bs=${write_size}k count=10 of=$DIR/$tdir/$tfile
3298 facet_failover $SINGLEMDS
3299 rm $DIR/$tdir/$tfile
3302 zconf_mount $(hostname) $MOUNT || error "mount fails"
3303 client_up || error "client_up failed"
3305 # wait for the remounted client to connect to ost1
3306 local target=$(get_osc_import_name client ost1)
3307 wait_import_state "FULL" "osc.${target}.ost_server_uuid" \
3308 $(max_recovery_time)
3310 wait_mds_ost_sync || error "MDS-OST sync timed out"
3311 wait_delete_completed || error "wait delete timed out"
3312 local blocks2=$(calc_osc_kbytes_used)
3314 [ $((blocks2 - blocks1)) -le $(fs_log_size) ] ||
3315 error $((blocks2 - blocks1)) blocks leaked
3317 run_test 89 "no disk space leak on late ost connection"
3324 change_active $facet
3325 wait_for_facet $facet
3326 mount_facet $facet || error "Restart of $facet failed"
3330 test_90() { # bug 19494
3331 local dir=$DIR/$tdir
3332 local ostfail=$(get_random_entry $(get_facets OST))
3334 if [[ $FAILURE_MODE = HARD ]]; then
3335 local affected=$(affected_facets $ostfail);
3336 if [[ "$affected" != $ostfail ]]; then
3337 skip not functional with FAILURE_MODE=$FAILURE_MODE, affected: $affected
3341 # ensure all OSTs are active to allow allocations
3344 mkdir $dir || error "mkdir $dir failed"
3346 echo "Create the files"
3348 # file "f${index}" striped over 1 OST
3349 # file "all" striped over all OSTs
3351 $LFS setstripe -c $OSTCOUNT $dir/all ||
3352 error "setstripe failed to create $dir/all"
3354 for ((i = 0; i < $OSTCOUNT; i++)); do
3357 $LFS setstripe -i $i -c 1 $f ||
3358 error "$LFS setstripe failed to create $f"
3360 # confirm setstripe actually created stripe on requested OST
3361 local uuid=$(ostuuid_from_index $i)
3363 for file in f$i all; do
3364 local found=$($LFS find --obd $uuid --name $file $dir)
3366 if [[ $dir/$file != $found ]]; then
3367 $LFS getstripe $dir/$file
3368 error "wrong stripe: $file, uuid: $uuid"
3373 # Before failing an OST, get its obd name and index
3374 local varsvc=${ostfail}_svc
3375 local obd=$(do_facet $ostfail lctl get_param \
3376 -n obdfilter.${!varsvc}.uuid)
3377 local index=$(($(facet_number $ostfail) - 1))
3379 echo "Fail $ostfail $obd, display the list of affected files"
3380 shutdown_facet $ostfail || error "shutdown_facet $ostfail failed"
3382 trap "cleanup_90 $ostfail" EXIT INT
3383 echo "General Query: lfs find $dir"
3384 local list=$($LFS find $dir)
3386 for (( i=0; i<$OSTCOUNT; i++ )); do
3387 list_member "$list" $dir/f$i ||
3388 error_noexit "lfs find $dir: no file f$i"
3390 list_member "$list" $dir/all ||
3391 error_noexit "lfs find $dir: no file all"
3393 # focus on the missing OST,
3394 # we expect to see only two files affected: "f$(index)" and "all"
3396 echo "Querying files on shutdown $ostfail: lfs find --obd $obd"
3397 list=$($LFS find --obd $obd $dir)
3399 for file in all f$index; do
3400 list_member "$list" $dir/$file ||
3401 error_noexit "lfs find does not report the affected $obd for $file"
3404 [[ $(echo $list | wc -w) -eq 2 ]] ||
3405 error_noexit "lfs find reports the wrong list of affected files ${#list[@]}"
3407 echo "Check getstripe: $LFS getstripe -r --obd $obd"
3408 list=$($LFS getstripe -r --obd $obd $dir)
3410 for file in all f$index; do
3411 echo "$list" | grep $dir/$file ||
3412 error_noexit "lfs getsripe does not report the affected $obd for $file"
3417 run_test 90 "lfs find identifies the missing striped file segments"
3420 [[ "$MDS1_VERSION" -ge $(version_code 2.6.90) ]] ||
3421 [[ "$MDS1_VERSION" -ge $(version_code 2.5.4) &&
3422 "$MDS1_VERSION" -lt $(version_code 2.5.50) ]] ||
3423 skip "Need MDS version 2.5.4+ or 2.6.90+"
3425 cancel_lru_locks osc
3427 $LFS setstripe -i 0 -c 1 $DIR/$tfile ||
3428 error "$LFS setstripe $DIR/$tfile failed"
3429 dd if=/dev/zero of=$DIR/$tfile bs=1024 count=1 ||
3430 error "dd to $DIR/$tfile failed"
3431 #define OBD_FAIL_TGT_REPLAY_RECONNECT 0x715
3432 # We need to emulate a state that OST is waiting for other clients
3433 # not completing the recovery. Final ping is queued, but reply will be
3434 # sent on the recovery completion. It is done by sleep before
3435 # processing final pings
3436 do_facet ost1 "$LCTL set_param fail_val=40"
3437 do_facet ost1 "$LCTL set_param fail_loc=0x715"
3440 run_test 93a "replay + reconnect"
3443 [[ "$MDS1_VERSION" -ge $(version_code 2.7.90) ]] ||
3444 skip "Need MDS version 2.7.90+"
3446 cancel_lru_locks mdc
3448 createmany -o $DIR/$tfile 20 ||
3449 error "createmany -o $DIR/$tfile failed"
3451 #define OBD_FAIL_TGT_REPLAY_RECONNECT 0x715
3452 # We need to emulate a state that MDT is waiting for other clients
3453 # not completing the recovery. Final ping is queued, but reply will be
3454 # sent on the recovery completion. It is done by sleep before
3455 # processing final pings
3456 do_facet mds1 "$LCTL set_param fail_val=80"
3457 do_facet mds1 "$LCTL set_param fail_loc=0x715"
3460 run_test 93b "replay + reconnect on mds"
3462 striped_dir_check_100() {
3463 local striped_dir=$DIR/$tdir/striped_dir
3464 local stripe_count=$($LFS getdirstripe -c $striped_dir)
3466 $LFS getdirstripe $striped_dir
3467 [ $stripe_count -eq 2 ] || error "$stripe_count != 2"
3469 createmany -o $striped_dir/f-%d 20 ||
3470 error "creation failed under striped dir"
3474 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
3475 ([ $FAILURE_MODE == "HARD" ] &&
3476 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
3477 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
3480 local striped_dir=$DIR/$tdir/striped_dir
3483 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
3485 #To make sure MDT1 and MDT0 are connected
3486 #otherwise it may create single stripe dir here
3487 $LFS setdirstripe -i1 $DIR/$tdir/remote_dir
3489 #define OBD_FAIL_OUT_UPDATE_NET_REP 0x1701
3490 do_facet mds$((MDTIDX+1)) lctl set_param fail_loc=0x1701
3491 $LFS setdirstripe -i0 -c2 $striped_dir &
3494 fail mds$((MDTIDX + 1))
3496 wait $CLIENT_PID || error "striped dir creation failed"
3498 striped_dir_check_100 || error "striped dir check failed"
3499 rm -rf $DIR/$tdir || error "rmdir failed"
3501 run_test 100a "DNE: create striped dir, drop update rep from MDT1, fail MDT1"
3504 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
3505 ([ $FAILURE_MODE == "HARD" ] &&
3506 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
3507 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
3510 local striped_dir=$DIR/$tdir/striped_dir
3513 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
3515 #To make sure MDT1 and MDT0 are connected
3516 #otherwise it may create single stripe dir here
3517 $LFS setdirstripe -i1 $DIR/$tdir/remote_dir
3519 # OBD_FAIL_MDS_REINT_NET_REP 0x119
3520 do_facet mds$MDTIDX lctl set_param fail_loc=0x119
3521 $LFS mkdir -i0 -c2 $striped_dir &
3526 wait $CLIENT_PID || error "striped dir creation failed"
3528 striped_dir_check_100 || error "striped dir check failed"
3529 rm -rf $DIR/$tdir || error "rmdir failed"
3531 run_test 100b "DNE: create striped dir, fail MDT0"
3533 test_101() { #LU-5648
3534 mkdir -p $DIR/$tdir/d1
3535 mkdir -p $DIR/$tdir/d2
3536 touch $DIR/$tdir/file0
3539 replay_barrier $SINGLEMDS
3540 for i in $(seq $num) ; do
3541 echo test$i > $DIR/$tdir/d1/file$i
3544 fail_abort $SINGLEMDS
3545 for i in $(seq $num) ; do
3546 touch $DIR/$tdir/d2/file$i
3547 test -s $DIR/$tdir/d2/file$i &&
3548 ls -al $DIR/$tdir/d2/file$i && error "file$i's size > 0"
3553 run_test 101 "Shouldn't reassign precreated objs to other files after recovery"
3562 [[ $(lctl get_param mdc.*.import |
3563 grep "connect_flags:.*multi_mod_rpc") ]] ||
3564 { skip "Need MDC with 'multi_mod_rpcs' feature"; return 0; }
3566 $LFS mkdir -c1 $DIR/$tdir || error "mkdir $DIR/$tdir failed"
3567 idx=$(printf "%04x" $($LFS getdirstripe -i $DIR/$tdir))
3568 facet="mds$((0x$idx + 1))"
3570 # get current value of max_mod_rcps_in_flight
3571 num=$($LCTL get_param -n \
3572 mdc.$FSNAME-MDT$idx-mdc-*.max_mod_rpcs_in_flight)
3573 # set default value if client does not support multi mod RPCs
3574 [ -z "$num" ] && num=1
3576 echo "creating $num files ..."
3578 for i in $(seq $num); do
3579 touch $DIR/$tdir/file-$i
3582 # drop request on MDT to force resend
3583 #define OBD_FAIL_MDS_REINT_MULTI_NET 0x159
3584 do_facet $facet "$LCTL set_param fail_loc=0x159"
3585 echo "launch $num chmod in parallel ($(date +%H:%M:%S)) ..."
3586 for i in $(seq $num); do
3587 chmod 0600 $DIR/$tdir/file-$i &
3591 do_facet $facet "$LCTL set_param fail_loc=0"
3592 for pid in $pids; do
3593 wait $pid || error "chmod failed"
3595 echo "done ($(date +%H:%M:%S))"
3597 # check chmod succeed
3598 for i in $(seq $num); do
3599 checkstat -vp 0600 $DIR/$tdir/file-$i
3604 run_test 102a "check resend (request lost) with multiple modify RPCs in flight"
3613 [[ $(lctl get_param mdc.*.import |
3614 grep "connect_flags:.*multi_mod_rpc") ]] ||
3615 { skip "Need MDC with 'multi_mod_rpcs' feature"; return 0; }
3617 $LFS mkdir -c1 $DIR/$tdir || error "mkdir $DIR/$tdir failed"
3618 idx=$(printf "%04x" $($LFS getdirstripe -i $DIR/$tdir))
3619 facet="mds$((0x$idx + 1))"
3621 # get current value of max_mod_rcps_in_flight
3622 num=$($LCTL get_param -n \
3623 mdc.$FSNAME-MDT$idx-mdc-*.max_mod_rpcs_in_flight)
3624 # set default value if client does not support multi mod RPCs
3625 [ -z "$num" ] && num=1
3627 echo "creating $num files ..."
3629 for i in $(seq $num); do
3630 touch $DIR/$tdir/file-$i
3633 # drop reply on MDT to force reconstruction
3634 #define OBD_FAIL_MDS_REINT_MULTI_NET_REP 0x15a
3635 do_facet $facet "$LCTL set_param fail_loc=0x15a"
3636 echo "launch $num chmod in parallel ($(date +%H:%M:%S)) ..."
3637 for i in $(seq $num); do
3638 chmod 0600 $DIR/$tdir/file-$i &
3642 do_facet $facet "$LCTL set_param fail_loc=0"
3643 for pid in $pids; do
3644 wait $pid || error "chmod failed"
3646 echo "done ($(date +%H:%M:%S))"
3648 # check chmod succeed
3649 for i in $(seq $num); do
3650 checkstat -vp 0600 $DIR/$tdir/file-$i
3655 run_test 102b "check resend (reply lost) with multiple modify RPCs in flight"
3664 [[ $(lctl get_param mdc.*.import |
3665 grep "connect_flags:.*multi_mod_rpc") ]] ||
3666 { skip "Need MDC with 'multi_mod_rpcs' feature"; return 0; }
3668 $LFS mkdir -c1 $DIR/$tdir || error "mkdir $DIR/$tdir failed"
3669 idx=$(printf "%04x" $($LFS getdirstripe -i $DIR/$tdir))
3670 facet="mds$((0x$idx + 1))"
3672 # get current value of max_mod_rcps_in_flight
3673 num=$($LCTL get_param -n \
3674 mdc.$FSNAME-MDT$idx-mdc-*.max_mod_rpcs_in_flight)
3675 # set default value if client does not support multi mod RPCs
3676 [ -z "$num" ] && num=1
3678 echo "creating $num files ..."
3680 for i in $(seq $num); do
3681 touch $DIR/$tdir/file-$i
3684 replay_barrier $facet
3687 #define OBD_FAIL_MDS_REINT_MULTI_NET_REP 0x15a
3688 do_facet $facet "$LCTL set_param fail_loc=0x15a"
3689 echo "launch $num chmod in parallel ($(date +%H:%M:%S)) ..."
3690 for i in $(seq $num); do
3691 chmod 0600 $DIR/$tdir/file-$i &
3695 do_facet $facet "$LCTL set_param fail_loc=0"
3700 for pid in $pids; do
3701 wait $pid || error "chmod failed"
3703 echo "done ($(date +%H:%M:%S))"
3705 # check chmod succeed
3706 for i in $(seq $num); do
3707 checkstat -vp 0600 $DIR/$tdir/file-$i
3712 run_test 102c "check replay w/o reconstruction with multiple mod RPCs in flight"
3721 [[ $(lctl get_param mdc.*.import |
3722 grep "connect_flags:.*multi_mod_rpc") ]] ||
3723 { skip "Need MDC with 'multi_mod_rpcs' feature"; return 0; }
3725 $LFS mkdir -c1 $DIR/$tdir || error "mkdir $DIR/$tdir failed"
3726 idx=$(printf "%04x" $($LFS getdirstripe -i $DIR/$tdir))
3727 facet="mds$((0x$idx + 1))"
3729 # get current value of max_mod_rcps_in_flight
3730 num=$($LCTL get_param -n \
3731 mdc.$FSNAME-MDT$idx-mdc-*.max_mod_rpcs_in_flight)
3732 # set default value if client does not support multi mod RPCs
3733 [ -z "$num" ] && num=1
3735 echo "creating $num files ..."
3737 for i in $(seq $num); do
3738 touch $DIR/$tdir/file-$i
3742 #define OBD_FAIL_MDS_REINT_MULTI_NET_REP 0x15a
3743 do_facet $facet "$LCTL set_param fail_loc=0x15a"
3744 echo "launch $num chmod in parallel ($(date +%H:%M:%S)) ..."
3745 for i in $(seq $num); do
3746 chmod 0600 $DIR/$tdir/file-$i &
3751 # write MDT transactions to disk
3752 do_facet $facet "sync; sync; sync"
3754 do_facet $facet "$LCTL set_param fail_loc=0"
3759 for pid in $pids; do
3760 wait $pid || error "chmod failed"
3762 echo "done ($(date +%H:%M:%S))"
3764 # check chmod succeed
3765 for i in $(seq $num); do
3766 checkstat -vp 0600 $DIR/$tdir/file-$i
3771 run_test 102d "check replay & reconstruction with multiple mod RPCs in flight"
3774 remote_mds_nodsh && skip "remote MDS with nodsh"
3775 [[ "$MDS1_VERSION" -gt $(version_code 2.8.54) ]] ||
3776 skip "Need MDS version 2.8.54+"
3778 #define OBD_FAIL_MDS_TRACK_OVERFLOW 0x162
3779 do_facet mds1 $LCTL set_param fail_loc=0x80000162
3782 createmany -o $DIR/$tdir/t- 30 ||
3783 error "create files on remote directory failed"
3785 rm -rf $DIR/$tdir/t-*
3787 #MDS should crash with tr->otr_next_id overflow
3790 run_test 103 "Check otr_next_id overflow"
3793 check_striped_dir_110()
3795 $CHECKSTAT -t dir $DIR/$tdir/striped_dir ||
3796 error "create striped dir failed"
3797 local stripe_count=$($LFS getdirstripe -c $DIR/$tdir/striped_dir)
3798 [ $stripe_count -eq $MDSCOUNT ] ||
3799 error "$stripe_count != 2 after recovery"
3803 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
3804 [[ "$MDS1_VERSION" -ge $(version_code 2.7.56) ]] ||
3805 skip "Need MDS version at least 2.7.56"
3807 ([ $FAILURE_MODE == "HARD" ] &&
3808 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
3809 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
3814 $LFS mkdir -i1 -c$MDSCOUNT $DIR/$tdir/striped_dir
3817 check_striped_dir_110 || error "check striped_dir failed"
3818 rm -rf $DIR/$tdir || error "rmdir failed"
3822 run_test 110a "DNE: create striped dir, fail MDT1"
3825 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
3826 [[ "$MDS1_VERSION" -ge $(version_code 2.7.56) ]] ||
3827 skip "Need MDS version at least 2.7.56"
3829 ([ $FAILURE_MODE == "HARD" ] &&
3830 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
3831 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
3836 $LFS mkdir -i1 -c$MDSCOUNT $DIR/$tdir/striped_dir
3839 zconf_mount $(hostname) $MOUNT
3840 client_up || return 1
3842 check_striped_dir_110 || error "check striped_dir failed"
3844 rm -rf $DIR/$tdir || error "rmdir failed"
3848 run_test 110b "DNE: create striped dir, fail MDT1 and client"
3851 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
3852 [[ "$MDS1_VERSION" -ge $(version_code 2.7.56) ]] ||
3853 skip "Need MDS version at least 2.7.56"
3855 ([ $FAILURE_MODE == "HARD" ] &&
3856 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
3857 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
3862 $LFS mkdir -i1 -c$MDSCOUNT $DIR/$tdir/striped_dir
3865 check_striped_dir_110 || error "check striped_dir failed"
3867 rm -rf $DIR/$tdir || error "rmdir failed"
3871 run_test 110c "DNE: create striped dir, fail MDT2"
3874 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
3875 [[ "$MDS1_VERSION" -ge $(version_code 2.7.56) ]] ||
3876 skip "Need MDS version at least 2.7.56"
3878 ([ $FAILURE_MODE == "HARD" ] &&
3879 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
3880 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
3885 $LFS mkdir -i1 -c$MDSCOUNT $DIR/$tdir/striped_dir
3888 zconf_mount $(hostname) $MOUNT
3889 client_up || return 1
3891 check_striped_dir_110 || error "check striped_dir failed"
3893 rm -rf $DIR/$tdir || error "rmdir failed"
3897 run_test 110d "DNE: create striped dir, fail MDT2 and client"
3900 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
3901 [[ "$MDS1_VERSION" -ge $(version_code 2.7.56) ]] ||
3902 skip "Need MDS version at least 2.7.56"
3904 ([ $FAILURE_MODE == "HARD" ] &&
3905 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
3906 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
3911 $LFS mkdir -i1 -c$MDSCOUNT $DIR/$tdir/striped_dir
3915 zconf_mount $(hostname) $MOUNT
3916 client_up || return 1
3918 check_striped_dir_110 || error "check striped_dir failed"
3920 rm -rf $DIR/$tdir || error "rmdir failed"
3924 run_test 110e "DNE: create striped dir, uncommit on MDT2, fail client/MDT1/MDT2"
3927 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
3928 [[ "$MDS1_VERSION" -ge $(version_code 2.7.56) ]] ||
3929 skip "Need MDS version at least 2.7.56"
3931 ([ $FAILURE_MODE == "HARD" ] &&
3932 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
3933 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
3939 $LFS mkdir -i1 -c$MDSCOUNT $DIR/$tdir/striped_dir
3942 check_striped_dir_110 || error "check striped_dir failed"
3944 rm -rf $DIR/$tdir || error "rmdir failed"
3948 run_test 110f "DNE: create striped dir, fail MDT1/MDT2"
3951 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
3952 [[ "$MDS1_VERSION" -ge $(version_code 2.7.56) ]] ||
3953 skip "Need MDS version at least 2.7.56"
3955 ([ $FAILURE_MODE == "HARD" ] &&
3956 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
3957 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
3962 $LFS mkdir -i1 -c$MDSCOUNT $DIR/$tdir/striped_dir
3966 zconf_mount $(hostname) $MOUNT
3967 client_up || return 1
3969 check_striped_dir_110 || error "check striped_dir failed"
3971 rm -rf $DIR/$tdir || error "rmdir failed"
3975 run_test 110g "DNE: create striped dir, uncommit on MDT1, fail client/MDT1/MDT2"
3978 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
3979 [[ "$MDS1_VERSION" -ge $(version_code 2.7.56) ]] ||
3980 skip "Need MDS version at least 2.7.56"
3982 ([ $FAILURE_MODE == "HARD" ] &&
3983 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
3984 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
3988 $LFS mkdir -i1 -c2 $DIR/$tdir/striped_dir
3990 rm -rf $DIR/$tdir/striped_dir
3993 $CHECKSTAT -t dir $DIR/$tdir/striped_dir &&
3994 error "striped dir still exists"
3997 run_test 111a "DNE: unlink striped dir, fail MDT1"
4000 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
4001 [[ "$MDS1_VERSION" -ge $(version_code 2.7.56) ]] ||
4002 skip "Need MDS version at least 2.7.56"
4004 ([ $FAILURE_MODE == "HARD" ] &&
4005 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
4006 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
4010 $LFS mkdir -i1 -c2 $DIR/$tdir/striped_dir
4012 rm -rf $DIR/$tdir/striped_dir
4015 zconf_mount $(hostname) $MOUNT
4016 client_up || return 1
4018 $CHECKSTAT -t dir $DIR/$tdir/striped_dir &&
4019 error "striped dir still exists"
4022 run_test 111b "DNE: unlink striped dir, fail MDT2"
4025 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
4026 [[ "$MDS1_VERSION" -ge $(version_code 2.7.56) ]] ||
4027 skip "Need MDS version at least 2.7.56"
4029 ([ $FAILURE_MODE == "HARD" ] &&
4030 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
4031 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
4035 $LFS mkdir -i1 -c2 $DIR/$tdir/striped_dir
4037 rm -rf $DIR/$tdir/striped_dir
4041 zconf_mount $(hostname) $MOUNT
4042 client_up || return 1
4043 $CHECKSTAT -t dir $DIR/$tdir/striped_dir &&
4044 error "striped dir still exists"
4047 run_test 111c "DNE: unlink striped dir, uncommit on MDT1, fail client/MDT1/MDT2"
4050 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
4051 [[ "$MDS1_VERSION" -ge $(version_code 2.7.56) ]] ||
4052 skip "Need MDS version at least 2.7.56"
4054 ([ $FAILURE_MODE == "HARD" ] &&
4055 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
4056 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
4060 $LFS mkdir -i1 -c2 $DIR/$tdir/striped_dir
4062 rm -rf $DIR/$tdir/striped_dir
4066 zconf_mount $(hostname) $MOUNT
4067 client_up || return 1
4068 $CHECKSTAT -t dir $DIR/$tdir/striped_dir &&
4069 error "striped dir still exists"
4073 run_test 111d "DNE: unlink striped dir, uncommit on MDT2, fail client/MDT1/MDT2"
4076 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
4077 [[ "$MDS1_VERSION" -ge $(version_code 2.7.56) ]] ||
4078 skip "Need MDS version at least 2.7.56"
4080 ([ $FAILURE_MODE == "HARD" ] &&
4081 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
4082 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
4086 $LFS mkdir -i1 -c2 $DIR/$tdir/striped_dir
4088 rm -rf $DIR/$tdir/striped_dir
4091 $CHECKSTAT -t dir $DIR/$tdir/striped_dir &&
4092 error "striped dir still exists"
4095 run_test 111e "DNE: unlink striped dir, uncommit on MDT2, fail MDT1/MDT2"
4098 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
4099 [[ "$MDS1_VERSION" -ge $(version_code 2.7.56) ]] ||
4100 skip "Need MDS version at least 2.7.56"
4102 ([ $FAILURE_MODE == "HARD" ] &&
4103 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
4104 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
4108 $LFS mkdir -i1 -c2 $DIR/$tdir/striped_dir
4110 rm -rf $DIR/$tdir/striped_dir
4113 $CHECKSTAT -t dir $DIR/$tdir/striped_dir &&
4114 error "striped dir still exists"
4117 run_test 111f "DNE: unlink striped dir, uncommit on MDT1, fail MDT1/MDT2"
4120 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
4121 [[ "$MDS1_VERSION" -ge $(version_code 2.7.56) ]] ||
4122 skip "Need MDS version at least 2.7.56"
4124 ([ $FAILURE_MODE == "HARD" ] &&
4125 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
4126 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
4130 $LFS mkdir -i1 -c2 $DIR/$tdir/striped_dir
4133 rm -rf $DIR/$tdir/striped_dir
4135 $CHECKSTAT -t dir $DIR/$tdir/striped_dir &&
4136 error "striped dir still exists"
4139 run_test 111g "DNE: unlink striped dir, fail MDT1/MDT2"
4141 test_112_rename_prepare() {
4142 mkdir -p $DIR/$tdir/src_dir
4143 $LFS mkdir -i 1 $DIR/$tdir/src_dir/src_child ||
4144 error "create remote source failed"
4146 touch $DIR/$tdir/src_dir/src_child/a
4148 $LFS mkdir -i 2 $DIR/$tdir/tgt_dir ||
4149 error "create remote target dir failed"
4151 $LFS mkdir -i 3 $DIR/$tdir/tgt_dir/tgt_child ||
4152 error "create remote target child failed"
4157 $CHECKSTAT -t dir $DIR/$tdir/src_dir/src_child &&
4158 error "src_child still exists after rename"
4160 $CHECKSTAT -t file $DIR/$tdir/tgt_dir/tgt_child/a ||
4161 error "missing file(a) after rename"
4165 [ $MDSCOUNT -lt 4 ] && skip "needs >= 4 MDTs" && return 0
4166 [[ "$MDS1_VERSION" -ge $(version_code 2.7.56) ]] ||
4167 skip "Need MDS version at least 2.7.56"
4169 ([ $FAILURE_MODE == "HARD" ] &&
4170 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
4171 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
4174 test_112_rename_prepare
4177 mrename $DIR/$tdir/src_dir/src_child $DIR/$tdir/tgt_dir/tgt_child ||
4178 error "rename dir cross MDT failed!"
4182 rm -rf $DIR/$tdir || error "rmdir failed"
4184 run_test 112a "DNE: cross MDT rename, fail MDT1"
4187 [ $MDSCOUNT -lt 4 ] && skip "needs >= 4 MDTs" && return 0
4188 [[ "$MDS1_VERSION" -ge $(version_code 2.7.56) ]] ||
4189 skip "Need MDS version at least 2.7.56"
4191 ([ $FAILURE_MODE == "HARD" ] &&
4192 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
4193 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
4196 test_112_rename_prepare
4199 mrename $DIR/$tdir/src_dir/src_child $DIR/$tdir/tgt_dir/tgt_child ||
4200 error "rename dir cross MDT failed!"
4205 rm -rf $DIR/$tdir || error "rmdir failed"
4207 run_test 112b "DNE: cross MDT rename, fail MDT2"
4210 [ $MDSCOUNT -lt 4 ] && skip "needs >= 4 MDTs" && return 0
4211 [[ "$MDS1_VERSION" -ge $(version_code 2.7.56) ]] ||
4212 skip "Need MDS version at least 2.7.56"
4214 ([ $FAILURE_MODE == "HARD" ] &&
4215 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
4216 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
4219 test_112_rename_prepare
4222 mrename $DIR/$tdir/src_dir/src_child $DIR/$tdir/tgt_dir/tgt_child ||
4223 error "rename dir cross MDT failed!"
4228 rm -rf $DIR/$tdir || error "rmdir failed"
4230 run_test 112c "DNE: cross MDT rename, fail MDT3"
4233 [ $MDSCOUNT -lt 4 ] && skip "needs >= 4 MDTs" && return 0
4234 [[ "$MDS1_VERSION" -ge $(version_code 2.7.56) ]] ||
4235 skip "Need MDS version at least 2.7.56"
4237 ([ $FAILURE_MODE == "HARD" ] &&
4238 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
4239 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
4242 test_112_rename_prepare
4245 mrename $DIR/$tdir/src_dir/src_child $DIR/$tdir/tgt_dir/tgt_child ||
4246 error "rename dir cross MDT failed!"
4251 rm -rf $DIR/$tdir || error "rmdir failed"
4253 run_test 112d "DNE: cross MDT rename, fail MDT4"
4256 [ $MDSCOUNT -lt 4 ] && skip "needs >= 4 MDTs" && return 0
4257 [[ "$MDS1_VERSION" -ge $(version_code 2.7.56) ]] ||
4258 skip "Need MDS version at least 2.7.56"
4260 ([ $FAILURE_MODE == "HARD" ] &&
4261 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
4262 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
4265 test_112_rename_prepare
4269 mrename $DIR/$tdir/src_dir/src_child $DIR/$tdir/tgt_dir/tgt_child ||
4270 error "rename dir cross MDT failed!"
4275 rm -rf $DIR/$tdir || error "rmdir failed"
4277 run_test 112e "DNE: cross MDT rename, fail MDT1 and MDT2"
4280 [ $MDSCOUNT -lt 4 ] && skip "needs >= 4 MDTs" && return 0
4281 [[ "$MDS1_VERSION" -ge $(version_code 2.7.56) ]] ||
4282 skip "Need MDS version at least 2.7.56"
4284 ([ $FAILURE_MODE == "HARD" ] &&
4285 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
4286 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
4289 test_112_rename_prepare
4293 mrename $DIR/$tdir/src_dir/src_child $DIR/$tdir/tgt_dir/tgt_child ||
4294 error "rename dir cross MDT failed!"
4299 rm -rf $DIR/$tdir || error "rmdir failed"
4301 run_test 112f "DNE: cross MDT rename, fail MDT1 and MDT3"
4304 [ $MDSCOUNT -lt 4 ] && skip "needs >= 4 MDTs" && return 0
4305 [[ "$MDS1_VERSION" -ge $(version_code 2.7.56) ]] ||
4306 skip "Need MDS version at least 2.7.56"
4308 ([ $FAILURE_MODE == "HARD" ] &&
4309 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
4310 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
4313 test_112_rename_prepare
4317 mrename $DIR/$tdir/src_dir/src_child $DIR/$tdir/tgt_dir/tgt_child ||
4318 error "rename dir cross MDT failed!"
4323 rm -rf $DIR/$tdir || error "rmdir failed"
4325 run_test 112g "DNE: cross MDT rename, fail MDT1 and MDT4"
4328 [ $MDSCOUNT -lt 4 ] && skip "needs >= 4 MDTs" && return 0
4329 [[ "$MDS1_VERSION" -ge $(version_code 2.7.56) ]] ||
4330 skip "Need MDS version at least 2.7.56"
4332 ([ $FAILURE_MODE == "HARD" ] &&
4333 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
4334 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
4337 test_112_rename_prepare
4341 mrename $DIR/$tdir/src_dir/src_child $DIR/$tdir/tgt_dir/tgt_child ||
4342 error "rename dir cross MDT failed!"
4347 rm -rf $DIR/$tdir || error "rmdir failed"
4349 run_test 112h "DNE: cross MDT rename, fail MDT2 and MDT3"
4352 [ $MDSCOUNT -lt 4 ] && skip "needs >= 4 MDTs" && return 0
4353 [[ "$MDS1_VERSION" -ge $(version_code 2.7.56) ]] ||
4354 skip "Need MDS version at least 2.7.56"
4356 ([ $FAILURE_MODE == "HARD" ] &&
4357 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
4358 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
4361 test_112_rename_prepare
4365 mrename $DIR/$tdir/src_dir/src_child $DIR/$tdir/tgt_dir/tgt_child ||
4366 error "rename dir cross MDT failed!"
4371 rm -rf $DIR/$tdir || error "rmdir failed"
4373 run_test 112i "DNE: cross MDT rename, fail MDT2 and MDT4"
4376 [ $MDSCOUNT -lt 4 ] && skip "needs >= 4 MDTs" && return 0
4377 [[ "$MDS1_VERSION" -ge $(version_code 2.7.56) ]] ||
4378 skip "Need MDS version at least 2.7.56"
4380 ([ $FAILURE_MODE == "HARD" ] &&
4381 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
4382 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
4385 test_112_rename_prepare
4389 mrename $DIR/$tdir/src_dir/src_child $DIR/$tdir/tgt_dir/tgt_child ||
4390 error "rename dir cross MDT failed!"
4395 rm -rf $DIR/$tdir || error "rmdir failed"
4397 run_test 112j "DNE: cross MDT rename, fail MDT3 and MDT4"
4400 [ $MDSCOUNT -lt 4 ] && skip "needs >= 4 MDTs" && return 0
4401 [[ "$MDS1_VERSION" -ge $(version_code 2.7.56) ]] ||
4402 skip "Need MDS version at least 2.7.56"
4404 ([ $FAILURE_MODE == "HARD" ] &&
4405 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
4406 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
4409 test_112_rename_prepare
4414 mrename $DIR/$tdir/src_dir/src_child $DIR/$tdir/tgt_dir/tgt_child ||
4415 error "rename dir cross MDT failed!"
4420 rm -rf $DIR/$tdir || error "rmdir failed"
4422 run_test 112k "DNE: cross MDT rename, fail MDT1,MDT2,MDT3"
4425 [ $MDSCOUNT -lt 4 ] && skip "needs >= 4 MDTs" && return 0
4426 [[ "$MDS1_VERSION" -ge $(version_code 2.7.56) ]] ||
4427 skip "Need MDS version at least 2.7.56"
4429 ([ $FAILURE_MODE == "HARD" ] &&
4430 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
4431 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
4434 test_112_rename_prepare
4439 mrename $DIR/$tdir/src_dir/src_child $DIR/$tdir/tgt_dir/tgt_child ||
4440 error "rename dir cross MDT failed!"
4445 rm -rf $DIR/$tdir || error "rmdir failed"
4447 run_test 112l "DNE: cross MDT rename, fail MDT1,MDT2,MDT4"
4450 [ $MDSCOUNT -lt 4 ] && skip "needs >= 4 MDTs" && return 0
4451 [[ "$MDS1_VERSION" -ge $(version_code 2.7.56) ]] ||
4452 skip "Need MDS version at least 2.7.56"
4454 ([ $FAILURE_MODE == "HARD" ] &&
4455 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
4456 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
4459 test_112_rename_prepare
4464 mrename $DIR/$tdir/src_dir/src_child $DIR/$tdir/tgt_dir/tgt_child ||
4465 error "rename dir cross MDT failed!"
4470 rm -rf $DIR/$tdir || error "rmdir failed"
4472 run_test 112m "DNE: cross MDT rename, fail MDT1,MDT3,MDT4"
4475 [ $MDSCOUNT -lt 4 ] && skip "needs >= 4 MDTs" && return 0
4476 [[ "$MDS1_VERSION" -ge $(version_code 2.7.56) ]] ||
4477 skip "Need MDS version at least 2.7.56"
4479 ([ $FAILURE_MODE == "HARD" ] &&
4480 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
4481 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
4484 test_112_rename_prepare
4489 mrename $DIR/$tdir/src_dir/src_child $DIR/$tdir/tgt_dir/tgt_child ||
4490 error "rename dir cross MDT failed!"
4495 rm -rf $DIR/$tdir || error "rmdir failed"
4497 run_test 112n "DNE: cross MDT rename, fail MDT2,MDT3,MDT4"
4500 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
4501 [[ "$MDS1_VERSION" -ge $(version_code 2.7.56) ]] ||
4502 skip "Need MDS version at least 2.7.56"
4504 ([ $FAILURE_MODE == "HARD" ] &&
4505 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
4506 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
4514 for ((j=0;j<$((MDSCOUNT));j++)); do
4515 fail_index=$((fail_index+1))
4516 index=$((fail_index % MDSCOUNT))
4517 replay_barrier mds$((index + 1))
4518 for ((i=0;i<5;i++)); do
4519 test_mkdir -i$index -c$MDSCOUNT $DIR/$tdir/test_$i ||
4520 error "create striped dir $DIR/$tdir/test_$i"
4523 fail mds$((index + 1))
4524 for ((i=0;i<5;i++)); do
4525 checkstat -t dir $DIR/$tdir/test_$i ||
4526 error "$DIR/$tdir/test_$i does not exist!"
4528 rm -rf $DIR/$tdir/test_* ||
4532 run_test 115 "failover for create/unlink striped directory"
4535 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
4536 [ "$MDS1_VERSION" -lt $(version_code 2.7.55) ] &&
4537 skip "Do not support large update log before 2.7.55" &&
4539 ([ $FAILURE_MODE == "HARD" ] &&
4540 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
4541 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
4548 # OBD_FAIL_SPLIT_UPDATE_REC 0x1702
4549 do_facet mds1 "lctl set_param fail_loc=0x80001702"
4550 $LFS setdirstripe -i0 -c$MDSCOUNT $DIR/$tdir/striped_dir
4553 $CHECKSTAT -t dir $DIR/$tdir/striped_dir ||
4554 error "stried_dir does not exists"
4556 run_test 116a "large update log master MDT recovery"
4559 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
4560 [ "$MDS1_VERSION" -lt $(version_code 2.7.55) ] &&
4561 skip "Do not support large update log before 2.7.55" &&
4564 ([ $FAILURE_MODE == "HARD" ] &&
4565 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
4566 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
4573 # OBD_FAIL_SPLIT_UPDATE_REC 0x1702
4574 do_facet mds2 "lctl set_param fail_loc=0x80001702"
4575 $LFS setdirstripe -i0 -c$MDSCOUNT $DIR/$tdir/striped_dir
4578 $CHECKSTAT -t dir $DIR/$tdir/striped_dir ||
4579 error "stried_dir does not exists"
4581 run_test 116b "large update log slave MDT recovery"
4584 [ $MDSCOUNT -lt 4 ] && skip "needs >= 4 MDTs" && return 0
4585 ([ $FAILURE_MODE == "HARD" ] &&
4586 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
4587 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
4593 $LFS setdirstripe -i0 -c$MDSCOUNT $DIR/$tdir/remote_dir
4594 $LFS setdirstripe -i1 -c$MDSCOUNT $DIR/$tdir/remote_dir_1
4597 # Let's set rdonly on all MDTs, so client will send
4598 # replay requests on all MDTs and replay these requests
4599 # at the same time. This test will verify the recovery
4600 # will not be deadlock in this case, LU-7531.
4601 for ((index = 0; index < $((MDSCOUNT)); index++)); do
4602 replay_barrier mds$((index + 1))
4603 if [ -z $mds_indexs ]; then
4604 mds_indexs="${mds_indexs}mds$((index+1))"
4606 mds_indexs="${mds_indexs},mds$((index+1))"
4610 rm -rf $DIR/$tdir/remote_dir
4611 rm -rf $DIR/$tdir/remote_dir_1
4615 rm -rf $DIR/$tdir || error "rmdir failed"
4617 run_test 117 "DNE: cross MDT unlink, fail MDT1 and MDT2"
4620 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
4621 [ "$MDS1_VERSION" -lt $(version_code 2.7.64) ] &&
4622 skip "Do not support large update log before 2.7.64" &&
4627 $LFS setdirstripe -c2 $DIR/$tdir/striped_dir ||
4628 error "setdirstripe fails"
4629 $LFS setdirstripe -c2 $DIR/$tdir/striped_dir1 ||
4630 error "setdirstripe fails 1"
4631 rm -rf $DIR/$tdir/striped_dir* || error "rmdir fails"
4633 # OBD_FAIL_INVALIDATE_UPDATE 0x1705
4634 do_facet mds1 "lctl set_param fail_loc=0x1705"
4635 $LFS setdirstripe -c2 $DIR/$tdir/striped_dir
4636 $LFS setdirstripe -c2 $DIR/$tdir/striped_dir1
4637 do_facet mds1 "lctl set_param fail_loc=0x0"
4640 $LFS setdirstripe -c2 $DIR/$tdir/striped_dir
4641 $LFS setdirstripe -c2 $DIR/$tdir/striped_dir1
4646 run_test 118 "invalidate osp update will not cause update log corruption"
4649 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
4650 [ "$MDS1_VERSION" -lt $(version_code 2.7.64) ] &&
4651 skip "Do not support large update log before 2.7.64" &&
4654 local hard_timeout=$(do_facet mds1 \
4655 "lctl get_param -n mdt.$FSNAME-MDT0000.recovery_time_hard")
4657 local clients=${CLIENTS:-$HOSTNAME}
4658 local time_min=$(recovery_time_min)
4661 mkdir $DIR/$tdir/tmp
4662 rmdir $DIR/$tdir/tmp
4665 mkdir $DIR/$tdir/dir_1
4666 for ((i = 0; i < 20; i++)); do
4667 $LFS setdirstripe -i0 -c2 $DIR/$tdir/stripe_dir-$i
4674 #define OBD_FAIL_TGT_REPLAY_DELAY 0x714
4675 do_facet mds1 $LCTL set_param fail_loc=0x80000714
4676 #sleep (timeout + 5), so mds will evict the client exports,
4677 #but DNE update recovery will keep going.
4678 do_facet mds1 $LCTL set_param fail_val=$((time_min + 5))
4680 mount_facet mds1 "-o recovery_time_hard=$time_min"
4682 wait_clients_import_state "$clients" mds1 FULL
4684 clients_up || clients_up || error "failover df: $?"
4686 #revert back the hard timeout
4687 do_facet mds1 $LCTL set_param \
4688 mdt.$FSNAME-MDT0000.recovery_time_hard=$hard_timeout
4690 for ((i = 0; i < 20; i++)); do
4691 stripe_count=$($LFS getdirstripe -c $DIR/$tdir/stripe_dir-$i)
4692 [ $stripe_count == 2 ] || {
4693 error "stripe_dir-$i creation replay fails"
4698 run_test 119 "timeout of normal replay does not cause DNE replay fails "
4701 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
4702 [ "$MDS1_VERSION" -lt $(version_code 2.7.64) ] &&
4703 skip "Do not support large update log before 2.7.64" &&
4707 replay_barrier_nosync mds1
4708 for ((i = 0; i < 20; i++)); do
4709 mkdir $DIR/$tdir/dir-$i || {
4710 error "create dir-$i fails"
4713 $LFS setdirstripe -i0 -c2 $DIR/$tdir/stripe_dir-$i || {
4714 error "create stripe_dir-$i fails"
4721 for ((i = 0; i < 20; i++)); do
4722 [ ! -e "$DIR/$tdir/dir-$i" ] || {
4723 error "dir-$i still exists"
4726 [ ! -e "$DIR/$tdir/stripe_dir-$i" ] || {
4727 error "stripe_dir-$i still exists"
4732 run_test 120 "DNE fail abort should stop both normal and DNE replay"
4735 [ "$MDS1_VERSION" -lt $(version_code 2.10.90) ] &&
4736 skip "Don't support it before 2.11" &&
4739 local at_max_saved=$(at_max_get mds)
4741 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
4742 cancel_lru_locks mdc
4744 multiop_bg_pause $DIR/$tfile s_s || error "multiop $DIR/$tfile failed"
4747 lctl set_param -n ldlm.cancel_unused_locks_before_replay "0"
4753 #define OBD_FAIL_TGT_RECOVERY_REQ_RACE 0x721
4754 do_facet $SINGLEMDS "lctl set_param fail_loc=0x721 fail_val=0"
4758 wait_clients_import_state "$clients" mds1 FULL
4759 clients_up || clients_up || error "failover df: $?"
4762 wait $mpid || error "multiop_bg_pause pid failed"
4764 do_facet $SINGLEMDS "lctl set_param fail_loc=0x0"
4765 lctl set_param -n ldlm.cancel_unused_locks_before_replay "1"
4766 at_max_set $at_max_saved mds
4769 run_test 121 "lock replay timed out and race"
4772 [ "$MDS1_VERSION" -lt $(version_code 2.10.90) ] &&
4773 skip "Do not support Data-on-MDT before 2.11"
4775 replay_barrier $SINGLEMDS
4776 $LFS setstripe -E 1M -L mdt -E EOF -c 2 $DIR/$tfile
4779 [ $($LFS getstripe -L $DIR/$tfile) == "mdt" ] ||
4780 error "Fail to replay DoM file creation"
4782 run_test 130a "DoM file create (setstripe) replay"
4785 [ "$MDS1_VERSION" -lt $(version_code 2.10.90) ] &&
4786 skip "Do not support Data-on-MDT before 2.11"
4789 $LFS setstripe -E 1M -L mdt -E EOF -c 2 $DIR/$tdir
4790 replay_barrier $SINGLEMDS
4791 touch $DIR/$tdir/$tfile
4794 [ $($LFS getstripe -L $DIR/$tdir/$tfile) == "mdt" ] ||
4795 error "Fail to replay DoM file creation"
4797 run_test 130b "DoM file create (inherited) replay"
4800 [ "$MDS1_VERSION" -lt $(version_code 2.10.90) ] &&
4801 skip "Do not support Data-on-MDT before 2.11"
4803 $LFS setstripe -E 1M -L mdt -E EOF -c 2 $DIR/$tfile
4804 replay_barrier $SINGLEMDS
4805 echo "dom_data" | dd of=$DIR/$tfile bs=8 count=1
4806 # lock is not canceled and will be replayed
4809 [ $(cat $DIR/$tfile) == "dom_data" ] ||
4810 error "Wrong file content after failover"
4812 run_test 131a "DoM file write lock replay"
4815 [ "$MDS1_VERSION" -lt $(version_code 2.10.90) ] &&
4816 skip "Do not support Data-on-MDT before 2.11"
4818 $LFS setstripe -E 1M -L mdt -E EOF -c 2 $DIR/$tfile
4819 replay_barrier $SINGLEMDS
4820 echo "dom_data" | dd of=$DIR/$tfile bs=8 count=1
4821 cancel_lru_locks mdc
4825 [ $(cat $DIR/$tfile) == "dom_data" ] ||
4826 error "Wrong file content after failover"
4828 run_test 131b "DoM file write replay"
4831 [ "$MDS1_VERSION" -lt $(version_code 2.12.0) ] &&
4832 skip "Need MDS version 2.12.0 or later"
4834 $LFS setstripe -E 1M -c 1 -E EOF -c 2 $DIR/$tfile
4835 replay_barrier $SINGLEMDS
4836 # write over the first component size cause next component instantiation
4837 dd if=/dev/urandom of=$DIR/$tfile bs=1M count=1 seek=1 ||
4838 error "dd to $DIR/$tfile failed"
4839 lfs getstripe $DIR/$tfile
4841 cksum=$(md5sum $DIR/$tfile | awk '{print $1}')
4842 $LFS getstripe -I2 $DIR/$tfile | grep -q lmm_objects ||
4843 error "Component #1 was not instantiated"
4847 lfs getstripe $DIR/$tfile
4848 $LFS getstripe -I2 $DIR/$tfile | grep -q lmm_objects ||
4849 error "Component #1 instantiation was not replayed"
4850 cksum2=$(md5sum $DIR/$tfile | awk '{print $1}')
4851 if [ $cksum != $cksum2 ] ; then
4852 error_noexit "New cksum $cksum2 does not match original $cksum"
4855 run_test 132a "PFL new component instantiate replay"
4858 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
4859 ([ $FAILURE_MODE == "HARD" ] &&
4860 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
4861 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
4864 local remote_dir=$DIR/$tdir/remote_dir
4866 mkdir -p $DIR/$tdir || error "mkdir $DIR/$tdir failed"
4867 $LFS mkdir -i 1 $remote_dir
4870 do_facet mds2 $LCTL set_param seq.srv*MDT0001.space=clear
4872 zconf_mount $(hostname) $MOUNT
4873 client_up || return 1
4875 #define OBD_FAIL_MDS_ALL_REQUEST_NET 0x123
4877 do_facet mds1 $LCTL set_param fail_val=700 fail_loc=0x80000123
4878 cp /etc/hosts $remote_dir/file &
4884 wait $pid || error "cp failed"
4885 rm -rf $DIR/$tdir || error "rmdir failed"
4889 run_test 133 "check resend of ongoing requests for lwp during failover"
4892 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs" && return 0
4895 pool_add_targets pool_134 1 1
4898 $LFS setstripe -p pool_134 $DIR/$tdir
4902 touch $DIR/$tdir/$tfile
4906 [ -f $DIR/$tdir/$tfile ] || error "file does not exist"
4908 run_test 134 "replay creation of a file created in a pool"
4911 check_and_cleanup_lustre