7 # This test needs to be run on the client
10 export MULTIOP=${MULTIOP:-multiop}
11 LUSTRE=${LUSTRE:-$(cd $(dirname $0)/..; echo $PWD)}
14 . $LUSTRE/tests/test-framework.sh
16 . ${CONFIG:=$LUSTRE/tests/cfg/$NAME.sh}
18 CHECK_GRANT=${CHECK_GRANT:-"yes"}
19 GRANT_CHECK_LIST=${GRANT_CHECK_LIST:-""}
21 require_dsh_mds || exit 0
24 # bug number for skipped tests: b=17466/LU-472
25 ALWAYS_EXCEPT=" 61d $REPLAY_SINGLE_EXCEPT"
26 # UPDATE THE COMMENT ABOVE WITH BUG NUMBERS WHEN CHANGING ALWAYS_EXCEPT!
28 case "$(lsb_release -sr)" in # only disable tests for el7
29 7*) # bug number: LU-6455-----
30 ALWAYS_EXCEPT="$ALWAYS_EXCEPT 28"
34 # 63 min 7 min AT AT AT AT"
35 [ "$SLOW" = "no" ] && EXCEPT_SLOW="1 2 3 4 6 12 16 44a 44b 65 66 67 68"
37 [ $(facet_fstype $SINGLEMDS) = "zfs" ] &&
38 # bug number for skipped test: LU-1867 LU-3127
39 ALWAYS_EXCEPT="$ALWAYS_EXCEPT 89 73b"
43 check_and_setup_lustre
48 rm -rf $DIR/[df][0-9]* $DIR/f.$TESTSUITE.*
50 # LU-482 Avert LVM and VM inability to flush caches in pre .33 kernels
51 if [ $LINUX_VERSION_CODE -lt $(version_code 2.6.33) ]; then
53 do_facet $SINGLEMDS sync
56 test_0a() { # was test_0
57 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
58 replay_barrier $SINGLEMDS
62 run_test 0a "empty replay"
65 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
67 # this test attempts to trigger a race in the precreation code,
68 # and must run before any other objects are created on the filesystem
70 createmany -o $DIR/$tfile 20 || error "createmany -o $DIR/$tfile failed"
71 unlinkmany $DIR/$tfile 20 || error "unlinkmany $DIR/$tfile failed"
73 run_test 0b "ensure object created after recover exists. (3284)"
76 replay_barrier $SINGLEMDS
79 facet_failover $SINGLEMDS
80 zconf_mount $(hostname) $MOUNT || error "mount fails"
81 client_up || error "post-failover df failed"
82 # file shouldn't exist if replay-barrier works as expected
83 rm $DIR/$tfile && error "File exists and it shouldn't"
86 run_test 0c "check replay-barrier"
89 replay_barrier $SINGLEMDS
91 facet_failover $SINGLEMDS
92 zconf_mount $(hostname) $MOUNT || error "mount fails"
93 client_up || error "post-failover df failed"
95 run_test 0d "expired recovery with no clients"
98 replay_barrier $SINGLEMDS
101 $CHECKSTAT -t file $DIR/$tfile ||
102 error "$CHECKSTAT $DIR/$tfile attribute check failed"
105 run_test 1 "simple create"
108 replay_barrier $SINGLEMDS
111 $CHECKSTAT -t file $DIR/$tfile ||
112 error "$CHECKSTAT $DIR/$tfile attribute check failed"
118 mcreate $DIR/$tfile || error "mcreate $DIR/$tfile failed"
119 replay_barrier $SINGLEMDS
122 $CHECKSTAT -t file $DIR/$tfile ||
123 error "$CHECKSTAT $DIR/$tfile attribute check failed"
129 local file=$DIR/$tfile
130 replay_barrier $SINGLEMDS
132 openfile -f O_DIRECTORY $file
134 $CHECKSTAT -t file $file ||
135 error "$CHECKSTAT $file attribute check failed"
138 run_test 3a "replay failed open(O_DIRECTORY)"
141 replay_barrier $SINGLEMDS
142 #define OBD_FAIL_MDS_OPEN_PACK | OBD_FAIL_ONCE
143 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000114"
145 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
147 $CHECKSTAT -t file $DIR/$tfile &&
148 error "$CHECKSTAT $DIR/$tfile attribute check should fail"
151 run_test 3b "replay failed open -ENOMEM"
154 replay_barrier $SINGLEMDS
155 #define OBD_FAIL_MDS_ALLOC_OBDO | OBD_FAIL_ONCE
156 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000128"
158 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
161 $CHECKSTAT -t file $DIR/$tfile &&
162 error "$CHECKSTAT $DIR/$tfile attribute check should fail"
165 run_test 3c "replay failed open -ENOMEM"
167 test_4a() { # was test_4
168 replay_barrier $SINGLEMDS
169 for i in $(seq 10); do
170 echo "tag-$i" > $DIR/$tfile-$i
173 for i in $(seq 10); do
174 grep -q "tag-$i" $DIR/$tfile-$i || error "$tfile-$i"
177 run_test 4a "|x| 10 open(O_CREAT)s"
180 for i in $(seq 10); do
181 echo "tag-$i" > $DIR/$tfile-$i
183 replay_barrier $SINGLEMDS
186 $CHECKSTAT -t file $DIR/$tfile-* &&
187 error "$CHECKSTAT $DIR/$tfile-* attribute check should fail" ||
190 run_test 4b "|x| rm 10 files"
192 # The idea is to get past the first block of precreated files on both
193 # osts, and then replay.
195 replay_barrier $SINGLEMDS
196 for i in $(seq 220); do
197 echo "tag-$i" > $DIR/$tfile-$i
200 for i in $(seq 220); do
201 grep -q "tag-$i" $DIR/$tfile-$i || error "$tfile-$i"
205 # waiting for commitment of removal
207 run_test 5 "|x| 220 open(O_CREAT)"
209 test_6a() { # was test_6
210 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
211 replay_barrier $SINGLEMDS
212 mcreate $DIR/$tdir/$tfile
214 $CHECKSTAT -t dir $DIR/$tdir ||
215 error "$CHECKSTAT $DIR/$tdir attribute check failed"
216 $CHECKSTAT -t file $DIR/$tdir/$tfile ||
217 error "$CHECKSTAT $DIR/$tdir/$tfile attribute check failed"
219 # waiting for log process thread
221 run_test 6a "mkdir + contained create"
224 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
225 replay_barrier $SINGLEMDS
228 $CHECKSTAT -t dir $DIR/$tdir &&
229 error "$CHECKSTAT $DIR/$tdir attribute check should fail" ||
232 run_test 6b "|X| rmdir"
235 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
236 replay_barrier $SINGLEMDS
237 mcreate $DIR/$tdir/$tfile
239 $CHECKSTAT -t dir $DIR/$tdir ||
240 error "$CHECKSTAT $DIR/$tdir attribute check failed"
241 $CHECKSTAT -t file $DIR/$tdir/$tfile ||
242 error "$CHECKSTAT $DIR/$tdir/$tfile attribute check failed"
245 run_test 7 "mkdir |X| contained create"
248 replay_barrier $SINGLEMDS
249 multiop_bg_pause $DIR/$tfile mo_c ||
250 error "multiop mknod $DIR/$tfile failed"
254 $CHECKSTAT -t file $DIR/$tfile ||
255 error "$CHECKSTAT $DIR/$tfile attribute check failed"
256 kill -USR1 $MULTIPID || error "multiop mknod $MULTIPID not running"
257 wait $MULTIPID || error "multiop mknod $MULTIPID failed"
260 run_test 8 "creat open |X| close"
263 replay_barrier $SINGLEMDS
265 local old_inum=$(ls -i $DIR/$tfile | awk '{print $1}')
267 local new_inum=$(ls -i $DIR/$tfile | awk '{print $1}')
269 echo " old_inum == $old_inum, new_inum == $new_inum"
270 if [ $old_inum -eq $new_inum ] ;
272 echo "old_inum and new_inum match"
274 echo " old_inum and new_inum do not match"
275 error "old index($old_inum) does not match new index($new_inum)"
279 run_test 9 "|X| create (same inum/gen)"
282 mcreate $DIR/$tfile || error "mcreate $DIR/$tfile failed"
283 replay_barrier $SINGLEMDS
284 mv $DIR/$tfile $DIR/$tfile-2
287 $CHECKSTAT $DIR/$tfile &&
288 error "$CHECKSTAT $DIR/$tfile attribute check should fail"
289 $CHECKSTAT $DIR/$tfile-2 ||
290 error "$CHECKSTAT $DIR/$tfile-2 attribute check failed"
294 run_test 10 "create |X| rename unlink"
297 mcreate $DIR/$tfile || error "mcreate $DIR/$tfile failed"
298 echo "old" > $DIR/$tfile
299 mv $DIR/$tfile $DIR/$tfile-2
300 replay_barrier $SINGLEMDS
301 echo "new" > $DIR/$tfile
303 grep old $DIR/$tfile-2
305 grep new $DIR/$tfile || error "grep $DIR/$tfile failed"
306 grep old $DIR/$tfile-2 || error "grep $DIR/$tfile-2 failed"
308 run_test 11 "create open write rename |X| create-old-name read"
311 mcreate $DIR/$tfile || error "mcreate $DIR/$tfile failed"
312 multiop_bg_pause $DIR/$tfile o_tSc ||
313 error "multiop_bg_pause $DIR/$tfile failed"
316 replay_barrier $SINGLEMDS
317 kill -USR1 $pid || error "multiop $pid not running"
318 wait $pid || error "multiop $pid failed"
321 [ -e $DIR/$tfile ] && error "file $DIR/$tfile should not exist"
324 run_test 12 "open, unlink |X| close"
326 # 1777 - replay open after committed chmod that would make
327 # a regular open a failure
329 mcreate $DIR/$tfile || error "mcreate $DIR/$tfile failed"
330 multiop_bg_pause $DIR/$tfile O_wc ||
331 error "multiop_bg_pause $DIR/$tfile failed"
334 $CHECKSTAT -p 0 $DIR/$tfile ||
335 error "$CHECKSTAT $DIR/$tfile attribute check failed"
336 replay_barrier $SINGLEMDS
338 kill -USR1 $pid || error "multiop $pid not running"
339 wait $pid || error "multiop $pid failed"
341 $CHECKSTAT -s 1 -p 0 $DIR/$tfile ||
342 error "second $CHECKSTAT $DIR/$tfile attribute check failed"
343 rm $DIR/$tfile || error "rm $DIR/$tfile failed"
346 run_test 13 "open chmod 0 |x| write close"
349 multiop_bg_pause $DIR/$tfile O_tSc ||
350 error "multiop_bg_pause $DIR/$tfile failed"
353 replay_barrier $SINGLEMDS
354 kill -USR1 $pid || error "multiop $pid not running"
355 wait $pid || error "multiop $pid failed"
358 [ -e $DIR/$tfile ] && error "file $DIR/$tfile should not exist"
361 run_test 14 "open(O_CREAT), unlink |X| close"
364 multiop_bg_pause $DIR/$tfile O_tSc ||
365 error "multiop_bg_pause $DIR/$tfile failed"
368 replay_barrier $SINGLEMDS
369 touch $DIR/$tfile-1 || error "touch $DIR/$tfile-1 failed"
370 kill -USR1 $pid || error "multiop $pid not running"
371 wait $pid || error "multiop $pid failed"
374 [ -e $DIR/$tfile ] && error "file $DIR/$tfile should not exist"
375 touch $DIR/$tfile-2 || error "touch $DIR/$tfile-2 failed"
378 run_test 15 "open(O_CREAT), unlink |X| touch new, close"
381 replay_barrier $SINGLEMDS
384 mcreate $DIR/$tfile-2
386 [ -e $DIR/$tfile ] && error "file $DIR/$tfile should not exist"
387 [ -e $DIR/$tfile-2 ] || error "file $DIR/$tfile-2 does not exist"
388 munlink $DIR/$tfile-2 || error "munlink $DIR/$tfile-2 failed"
390 run_test 16 "|X| open(O_CREAT), unlink, touch new, unlink new"
393 replay_barrier $SINGLEMDS
394 multiop_bg_pause $DIR/$tfile O_c ||
395 error "multiop_bg_pause $DIR/$tfile failed"
398 kill -USR1 $pid || error "multiop $pid not running"
399 wait $pid || error "multiop $pid failed"
400 $CHECKSTAT -t file $DIR/$tfile ||
401 error "$CHECKSTAT $DIR/$tfile attribute check failed"
404 run_test 17 "|X| open(O_CREAT), |replay| close"
407 replay_barrier $SINGLEMDS
408 multiop_bg_pause $DIR/$tfile O_tSc ||
409 error "multiop_bg_pause $DIR/$tfile failed"
412 touch $DIR/$tfile-2 || error "touch $DIR/$tfile-2 failed"
413 echo "pid: $pid will close"
414 kill -USR1 $pid || error "multiop $pid not running"
415 wait $pid || error "multiop $pid failed"
418 [ -e $DIR/$tfile ] && error "file $DIR/$tfile should not exist"
419 [ -e $DIR/$tfile-2 ] || error "file $DIR/$tfile-2 does not exist"
420 # this touch frequently fails
421 touch $DIR/$tfile-3 || error "touch $DIR/$tfile-3 failed"
422 munlink $DIR/$tfile-2 || error "munlink $DIR/$tfile-2 failed"
423 munlink $DIR/$tfile-3 || error "munlink $DIR/$tfile-3 failed"
426 run_test 18 "open(O_CREAT), unlink, touch new, close, touch, unlink"
428 # bug 1855 (a simpler form of test_11 above)
430 replay_barrier $SINGLEMDS
432 echo "old" > $DIR/$tfile
433 mv $DIR/$tfile $DIR/$tfile-2
434 grep old $DIR/$tfile-2
436 grep old $DIR/$tfile-2 || error "grep $DIR/$tfile-2 failed"
438 run_test 19 "mcreate, open, write, rename "
440 test_20a() { # was test_20
441 replay_barrier $SINGLEMDS
442 multiop_bg_pause $DIR/$tfile O_tSc ||
443 error "multiop_bg_pause $DIR/$tfile failed"
448 kill -USR1 $pid || error "multiop $pid not running"
449 wait $pid || error "multiop $pid failed"
450 [ -e $DIR/$tfile ] && error "file $DIR/$tfile should not exist"
453 run_test 20a "|X| open(O_CREAT), unlink, replay, close (test mds_cleanup_orphans)"
455 test_20b() { # bug 10480
456 local wait_timeout=$((TIMEOUT * 4))
460 BEFOREUSED=$(df -P $DIR | tail -1 | awk '{ print $3 }')
461 dd if=/dev/zero of=$DIR/$tfile bs=4k count=10000 &
462 while [ ! -e $DIR/$tfile ] ; do
463 usleep 60 # give dd a chance to start
466 $GETSTRIPE $DIR/$tfile || error "$GETSTRIPE $DIR/$tfile failed"
468 rm -f $DIR/$tfile || error "rm -f $DIR/$tfile failed"
470 client_up || client_up || true # reconnect
472 do_facet $SINGLEMDS "lctl set_param -n osd*.*MDT*.force_sync 1"
474 fail $SINGLEMDS # start orphan recovery
475 wait_recovery_complete $SINGLEMDS || error "MDS recovery not done"
476 wait_delete_completed_mds $wait_timeout ||
477 error "delete did not complete"
479 AFTERUSED=$(df -P $DIR | tail -1 | awk '{ print $3 }')
480 log "before $BEFOREUSED, after $AFTERUSED"
481 (( $AFTERUSED > $BEFOREUSED + $(fs_log_size) )) &&
482 error "after $AFTERUSED > before $BEFOREUSED"
485 run_test 20b "write, unlink, eviction, replay, (test mds_cleanup_orphans)"
487 test_20c() { # bug 10480
488 multiop_bg_pause $DIR/$tfile Ow_c ||
489 error "multiop_bg_pause $DIR/$tfile failed"
495 client_up || client_up || true # reconnect
497 kill -USR1 $pid || error "multiop $pid not running"
498 wait $pid || error "multiop $pid failed"
499 [ -s $DIR/$tfile ] || error "File was truncated"
503 run_test 20c "check that client eviction does not affect file content"
506 replay_barrier $SINGLEMDS
507 multiop_bg_pause $DIR/$tfile O_tSc ||
508 error "multiop_bg_pause $DIR/$tfile failed"
511 touch $DIR/$tfile-1 || error "touch $DIR/$tfile-1 failed"
514 kill -USR1 $pid || error "multiop $pid not running"
515 wait $pid || error "multiop $pid failed"
516 [ -e $DIR/$tfile ] && error "file $DIR/$tfile should not exist"
517 touch $DIR/$tfile-2 || error "touch $DIR/$tfile-2 failed"
520 run_test 21 "|X| open(O_CREAT), unlink touch new, replay, close (test mds_cleanup_orphans)"
523 multiop_bg_pause $DIR/$tfile O_tSc ||
524 error "multiop_bg_pause $DIR/$tfile failed"
527 replay_barrier $SINGLEMDS
531 kill -USR1 $pid || error "multiop $pid not running"
532 wait $pid || error "multiop $pid failed"
533 [ -e $DIR/$tfile ] && error "file $DIR/$tfile should not exist"
536 run_test 22 "open(O_CREAT), |X| unlink, replay, close (test mds_cleanup_orphans)"
539 multiop_bg_pause $DIR/$tfile O_tSc ||
540 error "multiop_bg_pause $DIR/$tfile failed"
543 replay_barrier $SINGLEMDS
545 touch $DIR/$tfile-1 || error "touch $DIR/$tfile-1 failed"
548 kill -USR1 $pid || error "multiop $pid not running"
549 wait $pid || error "multiop $pid failed"
550 [ -e $DIR/$tfile ] && error "file $DIR/$tfile should not exist"
551 touch $DIR/$tfile-2 || error "touch $DIR/$tfile-2 failed"
554 run_test 23 "open(O_CREAT), |X| unlink touch new, replay, close (test mds_cleanup_orphans)"
557 multiop_bg_pause $DIR/$tfile O_tSc ||
558 error "multiop_bg_pause $DIR/$tfile failed"
561 replay_barrier $SINGLEMDS
564 kill -USR1 $pid || error "multiop $pid not running"
565 wait $pid || error "multiop $pid failed"
566 [ -e $DIR/$tfile ] && error "file $DIR/$tfile should not exist"
569 run_test 24 "open(O_CREAT), replay, unlink, close (test mds_cleanup_orphans)"
572 multiop_bg_pause $DIR/$tfile O_tSc ||
573 error "multiop_bg_pause $DIR/$tfile failed"
577 replay_barrier $SINGLEMDS
579 kill -USR1 $pid || error "multiop $pid not running"
580 wait $pid || error "multiop $pid failed"
581 [ -e $DIR/$tfile ] && error "file $DIR/$tfile should not exist"
584 run_test 25 "open(O_CREAT), unlink, replay, close (test mds_cleanup_orphans)"
587 replay_barrier $SINGLEMDS
588 multiop_bg_pause $DIR/$tfile-1 O_tSc ||
589 error "multiop_bg_pause $DIR/$tfile-1 failed"
591 multiop_bg_pause $DIR/$tfile-2 O_tSc ||
592 error "multiop_bg_pause $DIR/$tfile-2 failed"
596 kill -USR1 $pid2 || error "second multiop $pid2 not running"
597 wait $pid2 || error "second multiop $pid2 failed"
600 kill -USR1 $pid1 || error "multiop $pid1 not running"
601 wait $pid1 || error "multiop $pid1 failed"
602 [ -e $DIR/$tfile-1 ] && error "file $DIR/$tfile-1 should not exist"
603 [ -e $DIR/$tfile-2 ] && error "file $DIR/$tfile-2 should not exist"
606 run_test 26 "|X| open(O_CREAT), unlink two, close one, replay, close one (test mds_cleanup_orphans)"
609 replay_barrier $SINGLEMDS
610 multiop_bg_pause $DIR/$tfile-1 O_tSc ||
611 error "multiop_bg_pause $DIR/$tfile-1 failed"
613 multiop_bg_pause $DIR/$tfile-2 O_tSc ||
614 error "multiop_bg_pause $DIR/$tfile-2 failed"
620 kill -USR1 $pid1 || error "multiop $pid1 not running"
621 wait $pid1 || error "multiop $pid1 failed"
622 kill -USR1 $pid2 || error "second multiop $pid2 not running"
623 wait $pid2 || error "second multiop $pid2 failed"
624 [ -e $DIR/$tfile-1 ] && error "file $DIR/$tfile-1 should not exist"
625 [ -e $DIR/$tfile-2 ] && error "file $DIR/$tfile-2 should not exist"
628 run_test 27 "|X| open(O_CREAT), unlink two, replay, close two (test mds_cleanup_orphans)"
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"
637 replay_barrier $SINGLEMDS
640 kill -USR1 $pid2 || error "second multiop $pid2 not running"
641 wait $pid2 || error "second multiop $pid2 failed"
644 kill -USR1 $pid1 || error "multiop $pid1 not running"
645 wait $pid1 || error "multiop $pid1 failed"
646 [ -e $DIR/$tfile-1 ] && error "file $DIR/$tfile-1 should not exist"
647 [ -e $DIR/$tfile-2 ] && error "file $DIR/$tfile-2 should not exist"
650 run_test 28 "open(O_CREAT), |X| unlink two, close one, replay, close one (test mds_cleanup_orphans)"
653 multiop_bg_pause $DIR/$tfile-1 O_tSc ||
654 error "multiop_bg_pause $DIR/$tfile-1 failed"
656 multiop_bg_pause $DIR/$tfile-2 O_tSc ||
657 error "multiop_bg_pause $DIR/$tfile-2 failed"
659 replay_barrier $SINGLEMDS
664 kill -USR1 $pid1 || error "multiop $pid1 not running"
665 wait $pid1 || error "multiop $pid1 failed"
666 kill -USR1 $pid2 || error "second multiop $pid2 not running"
667 wait $pid2 || error "second multiop $pid2 failed"
668 [ -e $DIR/$tfile-1 ] && error "file $DIR/$tfile-1 should not exist"
669 [ -e $DIR/$tfile-2 ] && error "file $DIR/$tfile-2 should not exist"
672 run_test 29 "open(O_CREAT), |X| unlink two, replay, close two (test mds_cleanup_orphans)"
675 multiop_bg_pause $DIR/$tfile-1 O_tSc ||
676 error "multiop_bg_pause $DIR/$tfile-1 failed"
678 multiop_bg_pause $DIR/$tfile-2 O_tSc ||
679 error "multiop_bg_pause $DIR/$tfile-2 failed"
684 replay_barrier $SINGLEMDS
686 kill -USR1 $pid1 || error "multiop $pid1 not running"
687 wait $pid1 || error "multiop $pid1 failed"
688 kill -USR1 $pid2 || error "second multiop $pid2 not running"
689 wait $pid2 || error "second multiop $pid2 failed"
690 [ -e $DIR/$tfile-1 ] && error "file $DIR/$tfile-1 should not exist"
691 [ -e $DIR/$tfile-2 ] && error "file $DIR/$tfile-2 should not exist"
694 run_test 30 "open(O_CREAT) two, unlink two, replay, close two (test mds_cleanup_orphans)"
697 multiop_bg_pause $DIR/$tfile-1 O_tSc ||
698 error "multiop_bg_pause $DIR/$tfile-1 failed"
700 multiop_bg_pause $DIR/$tfile-2 O_tSc ||
701 error "multiop_bg_pause $DIR/$tfile-2 failed"
705 replay_barrier $SINGLEMDS
708 kill -USR1 $pid1 || error "multiop $pid1 not running"
709 wait $pid1 || error "multiop $pid1 failed"
710 kill -USR1 $pid2 || error "second multiop $pid2 not running"
711 wait $pid2 || error "second multiop $pid2 failed"
712 [ -e $DIR/$tfile-1 ] && error "file $DIR/$tfile-1 should not exist"
713 [ -e $DIR/$tfile-2 ] && error "file $DIR/$tfile-2 should not exist"
716 run_test 31 "open(O_CREAT) two, unlink one, |X| unlink one, close two (test mds_cleanup_orphans)"
718 # tests for bug 2104; completion without crashing is success. The close is
719 # stale, but we always return 0 for close, so the app never sees it.
721 multiop_bg_pause $DIR/$tfile O_c ||
722 error "multiop_bg_pause $DIR/$tfile failed"
724 multiop_bg_pause $DIR/$tfile O_c ||
725 error "second multiop_bg_pause $DIR/$tfile failed"
728 client_up || client_up || error "client_up failed"
729 kill -USR1 $pid1 || error "multiop $pid1 not running"
730 kill -USR1 $pid2 || error "second multiop $pid2 not running"
731 wait $pid1 || error "multiop $pid1 failed"
732 wait $pid2 || error "second multiop $pid2 failed"
735 run_test 32 "close() notices client eviction; close() after client eviction"
738 createmany -o $DIR/$tfile-%d 10 ||
739 error "createmany create $DIR/$tfile failed"
740 replay_barrier_nosync $SINGLEMDS
741 fail_abort $SINGLEMDS
742 # recreate shouldn't fail
743 createmany -o $DIR/$tfile--%d 10 ||
744 error "createmany recreate $DIR/$tfile failed"
748 run_test 33a "fid seq shouldn't be reused after abort recovery"
751 #define OBD_FAIL_SEQ_ALLOC 0x1311
752 do_facet $SINGLEMDS "lctl set_param fail_loc=0x1311"
754 createmany -o $DIR/$tfile-%d 10
755 replay_barrier_nosync $SINGLEMDS
756 fail_abort $SINGLEMDS
757 # recreate shouldn't fail
758 createmany -o $DIR/$tfile--%d 10 ||
759 error "createmany recreate $DIR/$tfile failed"
763 run_test 33b "test fid seq allocation"
766 multiop_bg_pause $DIR/$tfile O_c ||
767 error "multiop_bg_pause $DIR/$tfile failed"
771 replay_barrier $SINGLEMDS
772 fail_abort $SINGLEMDS
773 kill -USR1 $pid || error "multiop $pid not running"
774 wait $pid || error "multiop $pid failed"
775 [ -e $DIR/$tfile ] && error "file $DIR/$tfile should not exist"
779 run_test 34 "abort recovery before client does replay (test mds_cleanup_orphans)"
781 # bug 2278 - generate one orphan on OST, then destroy it during recovery from llog
783 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
785 #define OBD_FAIL_MDS_REINT_NET_REP 0x119
786 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000119"
791 # give a chance to remove from MDS
792 fail_abort $SINGLEMDS
793 $CHECKSTAT -t file $DIR/$tfile &&
794 error "$CHECKSTAT $DIR/$tfile attribute check should fail" ||
797 run_test 35 "test recovery from llog for unlink op"
799 # b=2432 resent cancel after replay uses wrong cookie,
800 # so don't resend cancels
802 replay_barrier $SINGLEMDS
804 checkstat $DIR/$tfile
805 facet_failover $SINGLEMDS
807 if dmesg | grep "unknown lock cookie"; then
808 error "cancel after replay failed"
811 run_test 36 "don't resend cancel"
814 # directory orphans can't be unlinked from PENDING directory
816 rmdir $DIR/$tfile 2>/dev/null
817 multiop_bg_pause $DIR/$tfile dD_c ||
818 error "multiop_bg_pause $DIR/$tfile failed"
822 replay_barrier $SINGLEMDS
823 # clear the dmesg buffer so we only see errors from this recovery
824 do_facet $SINGLEMDS dmesg -c >/dev/null
825 fail_abort $SINGLEMDS
826 kill -USR1 $pid || error "multiop $pid not running"
827 do_facet $SINGLEMDS dmesg | grep "error .* unlinking .* from PENDING" &&
828 error "error unlinking files"
829 wait $pid || error "multiop $pid failed"
833 run_test 37 "abort recovery before client does replay (test mds_cleanup_orphans for directories)"
836 createmany -o $DIR/$tfile-%d 800 ||
837 error "createmany -o $DIR/$tfile failed"
838 unlinkmany $DIR/$tfile-%d 0 400 || error "unlinkmany $DIR/$tfile failed"
839 replay_barrier $SINGLEMDS
841 unlinkmany $DIR/$tfile-%d 400 400 ||
842 error "unlinkmany $DIR/$tfile 400 failed"
844 $CHECKSTAT -t file $DIR/$tfile-* &&
845 error "$CHECKSTAT $DIR/$tfile-* attribute check should fail" ||
848 run_test 38 "test recovery from unlink llog (test llog_gen_rec) "
850 test_39() { # bug 4176
851 createmany -o $DIR/$tfile-%d 800 ||
852 error "createmany -o $DIR/$tfile failed"
853 replay_barrier $SINGLEMDS
854 unlinkmany $DIR/$tfile-%d 0 400
856 unlinkmany $DIR/$tfile-%d 400 400 ||
857 error "unlinkmany $DIR/$tfile 400 failed"
859 $CHECKSTAT -t file $DIR/$tfile-* &&
860 error "$CHECKSTAT $DIR/$tfile-* attribute check should fail" ||
863 run_test 39 "test recovery from unlink llog (test llog_gen_rec) "
866 lctl get_param -n osc.*.stats | awk -vwrites=0 '/ost_write/ { writes += $2 } END { print writes; }'
871 # always need connection to MDS to verify layout during IO. LU-2628.
872 lctl get_param mdc.*.connect_flags | grep -q layout_lock &&
873 skip "layout_lock needs MDS connection for IO" && return 0
875 $LCTL mark multiop $MOUNT/$tfile OS_c
876 multiop $MOUNT/$tfile OS_c &
878 writeme -s $MOUNT/${tfile}-2 &
881 facet_failover $SINGLEMDS
882 #define OBD_FAIL_MDS_CONNECT_NET 0x117
883 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000117"
885 stat1=$(count_ost_writes)
887 stat2=$(count_ost_writes)
888 echo "$stat1, $stat2"
889 if [ $stat1 -lt $stat2 ]; then
890 echo "writes continuing during recovery"
893 echo "writes not continuing during recovery, bug 2477"
896 echo "waiting for writeme $WRITE_PID"
900 echo "waiting for multiop $PID"
901 wait $PID || error "multiop $PID failed"
902 do_facet client munlink $MOUNT/$tfile ||
903 error "munlink $MOUNT/$tfile failed"
904 do_facet client munlink $MOUNT/${tfile}-2 ||
905 error "munlink $MOUNT/$tfile-2 failed"
908 run_test 40 "cause recovery in ptlrpc, ensure IO continues"
911 # make sure that a read to one osc doesn't try to double-unlock its page just
912 # because another osc is invalid. trigger_group_io used to mistakenly return
913 # an error if any oscs were invalid even after having successfully put rpcs
914 # on valid oscs. This was fatal if the caller was ll_readpage who unlocked
915 # the page, guarnateeing that the unlock from the RPC completion would
916 # assert on trying to unlock the unlocked page.
918 [ $OSTCOUNT -lt 2 ] &&
919 skip_env "skipping test 41: we don't have a second OST to test with" &&
922 local f=$MOUNT/$tfile
923 # make sure the start of the file is ost1
924 $SETSTRIPE -S $((128 * 1024)) -i 0 $f
925 do_facet client dd if=/dev/zero of=$f bs=4k count=1 ||
926 error "dd on client failed"
928 # fail ost2 and read from ost1
929 local mdtosc=$(get_mdtosc_proc_path $SINGLEMDS $ost2_svc)
930 local osc2dev=$(do_facet $SINGLEMDS "lctl get_param -n devices" |
931 grep $mdtosc | awk '{print $1}')
932 [ -z "$osc2dev" ] && echo "OST: $ost2_svc" &&
933 lctl get_param -n devices &&
934 error "OST 2 $osc2dev does not exist"
935 do_facet $SINGLEMDS $LCTL --device $osc2dev deactivate ||
936 error "deactive device on $SINGLEMDS failed"
937 do_facet client dd if=$f of=/dev/null bs=4k count=1 ||
938 error "second dd on client failed"
939 do_facet $SINGLEMDS $LCTL --device $osc2dev activate ||
940 error "active device on $SINGLEMDS failed"
943 run_test 41 "read from a valid osc while other oscs are invalid"
945 # test MDS recovery after ost failure
947 blocks=$(df -P $MOUNT | tail -n 1 | awk '{ print $2 }')
948 createmany -o $DIR/$tfile-%d 800 ||
949 error "createmany -o $DIR/$tfile failed"
951 unlinkmany $DIR/$tfile-%d 0 400
953 lctl set_param debug=-1
956 # osc is evicted, fs is smaller (but only with failout OSTs (bug 7287)
957 #blocks_after=`df -P $MOUNT | tail -n 1 | awk '{ print $2 }'`
958 #[ $blocks_after -lt $blocks ] || return 1
959 echo "wait for MDS to timeout and recover"
960 sleep $((TIMEOUT * 2))
962 unlinkmany $DIR/$tfile-%d 400 400 ||
963 error "unlinkmany $DIR/$tfile 400 failed"
964 $CHECKSTAT -t file $DIR/$tfile-* &&
965 error "$CHECKSTAT $DIR/$tfile-* attribute check should fail" ||
968 run_test 42 "recovery after ost failure"
970 # timeout in MDS/OST recovery RPC will LBUG MDS
971 test_43() { # bug 2530
972 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
974 replay_barrier $SINGLEMDS
976 # OBD_FAIL_OST_CREATE_NET 0x204
977 do_facet ost1 "lctl set_param fail_loc=0x80000204"
983 run_test 43 "mds osc import failure during recovery; don't LBUG"
985 test_44a() { # was test_44
988 local mdcdev=$($LCTL dl |
989 awk "/${FSNAME}-MDT0000-mdc-/ {if (\$2 == \"UP\") {print \$1}}")
990 [ "$mdcdev" ] || error "${FSNAME}-MDT0000-mdc- not UP"
991 [ $(echo $mdcdev | wc -w) -eq 1 ] ||
992 { $LCTL dl; error "looking for mdcdev=$mdcdev"; }
994 # adaptive timeouts slow this way down
995 if at_is_enabled; then
996 at_max_saved=$(at_max_get mds)
1000 for i in $(seq 1 10); do
1001 echo "$i of 10 ($(date +%s))"
1002 do_facet $SINGLEMDS \
1003 "lctl get_param -n md[ts].*.mdt.timeouts | grep service"
1004 #define OBD_FAIL_TGT_CONN_RACE 0x701
1005 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000701"
1006 # lctl below may fail, it is valid case
1007 $LCTL --device $mdcdev recover
1010 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
1011 [ $at_max_saved -ne 0 ] && at_max_set $at_max_saved mds
1014 run_test 44a "race in target handle connect"
1017 local mdcdev=$($LCTL dl |
1018 awk "/${FSNAME}-MDT0000-mdc-/ {if (\$2 == \"UP\") {print \$1}}")
1019 [ "$mdcdev" ] || error "${FSNAME}-MDT0000-mdc not up"
1020 [ $(echo $mdcdev | wc -w) -eq 1 ] ||
1021 { echo mdcdev=$mdcdev; $LCTL dl;
1022 error "more than one ${FSNAME}-MDT0000-mdc"; }
1024 for i in $(seq 1 10); do
1025 echo "$i of 10 ($(date +%s))"
1026 do_facet $SINGLEMDS \
1027 "lctl get_param -n md[ts].*.mdt.timeouts | grep service"
1028 #define OBD_FAIL_TGT_DELAY_RECONNECT 0x704
1029 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000704"
1030 # lctl below may fail, it is valid case
1031 $LCTL --device $mdcdev recover
1036 run_test 44b "race in target handle connect"
1039 replay_barrier $SINGLEMDS
1040 createmany -m $DIR/$tfile-%d 100 || error "failed to create directories"
1041 #define OBD_FAIL_TGT_RCVG_FLAG 0x712
1042 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000712"
1043 fail_abort $SINGLEMDS
1044 unlinkmany $DIR/$tfile-%d 100 && error "unliked after fail abort"
1046 unlinkmany $DIR/$tfile-%d 100 && error "unliked after fail"
1049 run_test 44c "race in target handle connect"
1051 # Handle failed close
1053 local mdcdev=$($LCTL get_param -n devices |
1054 awk "/ ${FSNAME}-MDT0000-mdc-/ {print \$1}")
1055 [ "$mdcdev" ] || error "${FSNAME}-MDT0000-mdc not up"
1056 [ $(echo $mdcdev | wc -w) -eq 1 ] ||
1057 { echo mdcdev=$mdcdev; $LCTL dl;
1058 error "more than one ${FSNAME}-MDT0000-mdc"; }
1060 $LCTL --device $mdcdev recover ||
1061 error "$LCTL --device $mdcdev recover failed"
1063 multiop_bg_pause $DIR/$tfile O_c ||
1064 error "multiop_bg_pause $DIR/$tfile failed"
1067 # This will cause the CLOSE to fail before even
1068 # allocating a reply buffer
1069 $LCTL --device $mdcdev deactivate ||
1070 error "$LCTL --device $mdcdev deactivate failed"
1073 kill -USR1 $pid || error "multiop $pid not running"
1074 wait $pid || error "multiop $pid failed"
1076 $LCTL --device $mdcdev activate ||
1077 error "$LCTL --device $mdcdev activate failed"
1080 $CHECKSTAT -t file $DIR/$tfile ||
1081 error "$CHECKSTAT $DIR/$tfile attribute check failed"
1084 run_test 45 "Handle failed close"
1088 drop_reply "touch $DIR/$tfile"
1090 # ironically, the previous test, 45, will cause a real forced close,
1091 # so just look for one for this test
1092 dmesg | grep -i "force closing client file handle for $tfile" &&
1093 error "found force closing in dmesg"
1096 run_test 46 "Don't leak file handle after open resend (3325)"
1098 test_47() { # bug 2824
1099 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1101 # create some files to make sure precreate has been done on all
1102 # OSTs. (just in case this test is run independently)
1103 createmany -o $DIR/$tfile 20 ||
1104 error "createmany create $DIR/$tfile failed"
1106 # OBD_FAIL_OST_CREATE_NET 0x204
1108 do_facet ost1 "lctl set_param fail_loc=0x80000204"
1109 client_up || error "client_up failed"
1111 # let the MDS discover the OST failure, attempt to recover, fail
1112 # and recover again.
1113 sleep $((3 * TIMEOUT))
1115 # Without 2824, this createmany would hang
1116 createmany -o $DIR/$tfile 20 ||
1117 error "createmany recraete $DIR/$tfile failed"
1118 unlinkmany $DIR/$tfile 20 || error "unlinkmany $DIR/$tfile failed"
1122 run_test 47 "MDS->OSC failure during precreate cleanup (2824)"
1125 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1126 [ "$OSTCOUNT" -lt "2" ] &&
1127 skip_env "$OSTCOUNT < 2 OSTs -- skipping" && return
1129 replay_barrier $SINGLEMDS
1130 createmany -o $DIR/$tfile 20 ||
1131 error "createmany -o $DIR/$tfile failed"
1132 # OBD_FAIL_OST_EROFS 0x216
1133 facet_failover $SINGLEMDS
1134 do_facet ost1 "lctl set_param fail_loc=0x80000216"
1135 client_up || error "client_up failed"
1137 createmany -o $DIR/$tfile 20 20 ||
1138 error "createmany recraete $DIR/$tfile failed"
1139 unlinkmany $DIR/$tfile 40 || error "unlinkmany $DIR/$tfile failed"
1142 run_test 48 "MDS->OSC failure during precreate cleanup (2824)"
1145 local mdtosc=$(get_mdtosc_proc_path $SINGLEMDS $ost1_svc)
1146 local oscdev=$(do_facet $SINGLEMDS "lctl get_param -n devices" |
1147 grep $mdtosc | awk '{print $1}')
1148 [ "$oscdev" ] || error "could not find OSC device on MDS"
1149 do_facet $SINGLEMDS $LCTL --device $oscdev recover ||
1150 error "OSC device $oscdev recovery failed"
1151 do_facet $SINGLEMDS $LCTL --device $oscdev recover ||
1152 error "second OSC device $oscdev recovery failed"
1153 # give the mds_lov_sync threads a chance to run
1156 run_test 50 "Double OSC recovery, don't LASSERT (3812)"
1158 # b3764 timed out lock replay
1160 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.6.90) ] &&
1161 skip "MDS prior to 2.6.90 handle LDLM_REPLY_NET incorrectly" &&
1164 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
1165 cancel_lru_locks mdc
1167 multiop_bg_pause $DIR/$tfile s_s || error "multiop $DIR/$tfile failed"
1170 #define OBD_FAIL_MDS_LDLM_REPLY_NET 0x157
1171 lctl set_param -n ldlm.cancel_unused_locks_before_replay "0"
1172 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000157"
1174 fail $SINGLEMDS || error "fail $SINGLEMDS failed"
1176 wait $mpid || error "multiop_bg_pause pid failed"
1178 do_facet $SINGLEMDS "lctl set_param fail_loc=0x0"
1179 lctl set_param fail_loc=0x0
1180 lctl set_param -n ldlm.cancel_unused_locks_before_replay "1"
1183 run_test 52 "time out lock replay (3764)"
1185 # bug 3462 - simultaneous MDC requests
1187 cancel_lru_locks mdc # cleanup locks from former test cases
1188 mkdir $DIR/${tdir}-1 || error "mkdir $DIR/${tdir}-1 failed"
1189 mkdir $DIR/${tdir}-2 || error "mkdir $DIR/${tdir}-2 failed"
1190 multiop $DIR/${tdir}-1/f O_c &
1192 # give multiop a change to open
1195 #define OBD_FAIL_MDS_CLOSE_NET 0x115
1196 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000115"
1197 kill -USR1 $close_pid
1198 cancel_lru_locks mdc # force the close
1199 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
1201 mcreate $DIR/${tdir}-2/f || error "mcreate $DIR/${tdir}-2/f failed"
1203 # close should still be here
1204 [ -d /proc/$close_pid ] || error "close_pid doesn't exist"
1206 replay_barrier_nodf $SINGLEMDS
1208 wait $close_pid || error "close_pid $close_pid failed"
1210 $CHECKSTAT -t file $DIR/${tdir}-1/f ||
1211 error "$CHECKSTAT $DIR/${tdir}-1/f attribute check failed"
1212 $CHECKSTAT -t file $DIR/${tdir}-2/f ||
1213 error "$CHECKSTAT $DIR/${tdir}-2/f attribute check failed"
1214 rm -rf $DIR/${tdir}-*
1216 run_test 53a "|X| close request while two MDC requests in flight"
1219 cancel_lru_locks mdc # cleanup locks from former test cases
1221 mkdir $DIR/${tdir}-1 || error "mkdir $DIR/${tdir}-1 failed"
1222 mkdir $DIR/${tdir}-2 || error "mkdir $DIR/${tdir}-2 failed"
1223 multiop_bg_pause $DIR/${tdir}-1/f O_c ||
1224 error "multiop_bg_pause $DIR/${tdir}-1/f failed"
1227 #define OBD_FAIL_MDS_REINT_NET 0x107
1228 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000107"
1229 mcreate $DIR/${tdir}-2/f &
1233 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
1234 kill -USR1 $close_pid
1235 cancel_lru_locks mdc # force the close
1236 wait $close_pid || error "close_pid $close_pid failed"
1237 # open should still be here
1238 [ -d /proc/$open_pid ] || error "open_pid doesn't exist"
1240 replay_barrier_nodf $SINGLEMDS
1242 wait $open_pid || error "open_pid failed"
1244 $CHECKSTAT -t file $DIR/${tdir}-1/f ||
1245 error "$CHECKSTAT $DIR/${tdir}-1/f attribute check failed"
1246 $CHECKSTAT -t file $DIR/${tdir}-2/f ||
1247 error "$CHECKSTAT $DIR/${tdir}-2/f attribute check failed"
1248 rm -rf $DIR/${tdir}-*
1250 run_test 53b "|X| open request while two MDC requests in flight"
1253 cancel_lru_locks mdc # cleanup locks from former test cases
1255 mkdir $DIR/${tdir}-1 || error "mkdir $DIR/${tdir}-1 failed"
1256 mkdir $DIR/${tdir}-2 || error "mkdir $DIR/${tdir}-2 failed"
1257 multiop $DIR/${tdir}-1/f O_c &
1260 #define OBD_FAIL_MDS_REINT_NET 0x107
1261 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000107"
1262 mcreate $DIR/${tdir}-2/f &
1266 #define OBD_FAIL_MDS_CLOSE_NET 0x115
1267 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000115"
1268 kill -USR1 $close_pid
1269 cancel_lru_locks mdc # force the close
1271 #bz20647: make sure all pids exist before failover
1272 [ -d /proc/$close_pid ] || error "close_pid doesn't exist"
1273 [ -d /proc/$open_pid ] || error "open_pid doesn't exists"
1274 replay_barrier_nodf $SINGLEMDS
1275 fail_nodf $SINGLEMDS
1276 wait $open_pid || error "open_pid failed"
1278 # close should be gone
1279 [ -d /proc/$close_pid ] && error "close_pid should not exist"
1280 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
1282 $CHECKSTAT -t file $DIR/${tdir}-1/f ||
1283 error "$CHECKSTAT $DIR/${tdir}-1/f attribute check failed"
1284 $CHECKSTAT -t file $DIR/${tdir}-2/f ||
1285 error "$CHECKSTAT $DIR/${tdir}-2/f attribute check failed"
1286 rm -rf $DIR/${tdir}-*
1288 run_test 53c "|X| open request and close request while two MDC requests in flight"
1291 cancel_lru_locks mdc # cleanup locks from former test cases
1293 mkdir $DIR/${tdir}-1 || error "mkdir $DIR/${tdir}-1 failed"
1294 mkdir $DIR/${tdir}-2 || error "mkdir $DIR/${tdir}-2 failed"
1295 multiop $DIR/${tdir}-1/f O_c &
1297 # give multiop a chance to open
1300 #define OBD_FAIL_MDS_CLOSE_NET_REP 0x13b
1301 do_facet $SINGLEMDS "lctl set_param fail_loc=0x8000013b"
1302 kill -USR1 $close_pid
1303 cancel_lru_locks mdc # force the close
1304 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
1305 mcreate $DIR/${tdir}-2/f || error "mcreate $DIR/${tdir}-2/f failed"
1307 # close should still be here
1308 [ -d /proc/$close_pid ] || error "close_pid doesn't exist"
1310 wait $close_pid || error "close_pid failed"
1312 $CHECKSTAT -t file $DIR/${tdir}-1/f ||
1313 error "$CHECKSTAT $DIR/${tdir}-1/f attribute check failed"
1314 $CHECKSTAT -t file $DIR/${tdir}-2/f ||
1315 error "$CHECKSTAT $DIR/${tdir}-2/f attribute check failed"
1316 rm -rf $DIR/${tdir}-*
1318 run_test 53d "close reply while two MDC requests in flight"
1321 cancel_lru_locks mdc # cleanup locks from former test cases
1323 mkdir $DIR/${tdir}-1 || error "mkdir $DIR/${tdir}-1 failed"
1324 mkdir $DIR/${tdir}-2 || error "mkdir $DIR/${tdir}-2 failed"
1325 multiop $DIR/${tdir}-1/f O_c &
1328 #define OBD_FAIL_MDS_REINT_NET_REP 0x119
1329 do_facet $SINGLEMDS "lctl set_param fail_loc=0x119"
1330 mcreate $DIR/${tdir}-2/f &
1334 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
1335 kill -USR1 $close_pid
1336 cancel_lru_locks mdc # force the close
1337 wait $close_pid || error "close_pid failed"
1338 # open should still be here
1339 [ -d /proc/$open_pid ] || error "open_pid doesn't exists"
1341 replay_barrier_nodf $SINGLEMDS
1343 wait $open_pid || error "open_pid failed"
1345 $CHECKSTAT -t file $DIR/${tdir}-1/f ||
1346 error "$CHECKSTAT $DIR/${tdir}-1/f attribute check failed"
1347 $CHECKSTAT -t file $DIR/${tdir}-2/f ||
1348 error "$CHECKSTAT $DIR/${tdir}-2/f attribute check failed"
1349 rm -rf $DIR/${tdir}-*
1351 run_test 53e "|X| open reply while two MDC requests in flight"
1354 cancel_lru_locks mdc # cleanup locks from former test cases
1356 mkdir $DIR/${tdir}-1 || error "mkdir $DIR/${tdir}-1 failed"
1357 mkdir $DIR/${tdir}-2 || error "mkdir $DIR/${tdir}-2 failed"
1358 multiop $DIR/${tdir}-1/f O_c &
1361 #define OBD_FAIL_MDS_REINT_NET_REP 0x119
1362 do_facet $SINGLEMDS "lctl set_param fail_loc=0x119"
1363 mcreate $DIR/${tdir}-2/f &
1367 #define OBD_FAIL_MDS_CLOSE_NET_REP 0x13b
1368 do_facet $SINGLEMDS "lctl set_param fail_loc=0x8000013b"
1369 kill -USR1 $close_pid
1370 cancel_lru_locks mdc # force the close
1372 #bz20647: make sure all pids are exists before failover
1373 [ -d /proc/$close_pid ] || error "close_pid doesn't exist"
1374 [ -d /proc/$open_pid ] || error "open_pid doesn't exists"
1375 replay_barrier_nodf $SINGLEMDS
1376 fail_nodf $SINGLEMDS
1377 wait $open_pid || error "open_pid failed"
1379 # close should be gone
1380 [ -d /proc/$close_pid ] && error "close_pid should not exist"
1381 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
1383 $CHECKSTAT -t file $DIR/${tdir}-1/f ||
1384 error "$CHECKSTAT $DIR/${tdir}-1/f attribute check failed"
1385 $CHECKSTAT -t file $DIR/${tdir}-2/f ||
1386 error "$CHECKSTAT $DIR/${tdir}-2/f attribute check failed"
1387 rm -rf $DIR/${tdir}-*
1389 run_test 53f "|X| open reply and close reply while two MDC requests in flight"
1392 cancel_lru_locks mdc # cleanup locks from former test cases
1394 mkdir $DIR/${tdir}-1 || error "mkdir $DIR/${tdir}-1 failed"
1395 mkdir $DIR/${tdir}-2 || error "mkdir $DIR/${tdir}-2 failed"
1396 multiop $DIR/${tdir}-1/f O_c &
1399 #define OBD_FAIL_MDS_REINT_NET_REP 0x119
1400 do_facet $SINGLEMDS "lctl set_param fail_loc=0x119"
1401 mcreate $DIR/${tdir}-2/f &
1405 #define OBD_FAIL_MDS_CLOSE_NET 0x115
1406 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000115"
1407 kill -USR1 $close_pid
1408 cancel_lru_locks mdc # force the close
1409 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
1411 #bz20647: make sure all pids are exists before failover
1412 [ -d /proc/$close_pid ] || error "close_pid doesn't exist"
1413 [ -d /proc/$open_pid ] || error "open_pid doesn't exists"
1414 replay_barrier_nodf $SINGLEMDS
1415 fail_nodf $SINGLEMDS
1416 wait $open_pid || error "open_pid failed"
1418 # close should be gone
1419 [ -d /proc/$close_pid ] && error "close_pid should not exist"
1421 $CHECKSTAT -t file $DIR/${tdir}-1/f ||
1422 error "$CHECKSTAT $DIR/${tdir}-1/f attribute check failed"
1423 $CHECKSTAT -t file $DIR/${tdir}-2/f ||
1424 error "$CHECKSTAT $DIR/${tdir}-2/f attribute check failed"
1425 rm -rf $DIR/${tdir}-*
1427 run_test 53g "|X| drop open reply and close request while close and open are both in flight"
1430 cancel_lru_locks mdc # cleanup locks from former test cases
1432 mkdir $DIR/${tdir}-1 || error "mkdir $DIR/${tdir}-1 failed"
1433 mkdir $DIR/${tdir}-2 || error "mkdir $DIR/${tdir}-2 failed"
1434 multiop $DIR/${tdir}-1/f O_c &
1437 #define OBD_FAIL_MDS_REINT_NET 0x107
1438 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000107"
1439 mcreate $DIR/${tdir}-2/f &
1443 #define OBD_FAIL_MDS_CLOSE_NET_REP 0x13b
1444 do_facet $SINGLEMDS "lctl set_param fail_loc=0x8000013b"
1445 kill -USR1 $close_pid
1446 cancel_lru_locks mdc # force the close
1449 #bz20647: make sure all pids are exists before failover
1450 [ -d /proc/$close_pid ] || error "close_pid doesn't exist"
1451 [ -d /proc/$open_pid ] || error "open_pid doesn't exists"
1452 replay_barrier_nodf $SINGLEMDS
1453 fail_nodf $SINGLEMDS
1454 wait $open_pid || error "open_pid failed"
1456 # close should be gone
1457 [ -d /proc/$close_pid ] && error "close_pid should not exist"
1458 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
1460 $CHECKSTAT -t file $DIR/${tdir}-1/f ||
1461 error "$CHECKSTAT $DIR/${tdir}-1/f attribute check failed"
1462 $CHECKSTAT -t file $DIR/${tdir}-2/f ||
1463 error "$CHECKSTAT $DIR/${tdir}-2/f attribute check failed"
1464 rm -rf $DIR/${tdir}-*
1466 run_test 53h "open request and close reply while two MDC requests in flight"
1468 #b3761 ASSERTION(hash != 0) failed
1470 # OBD_FAIL_MDS_OPEN_CREATE | OBD_FAIL_ONCE
1471 do_facet $SINGLEMDS "lctl set_param fail_loc=0x8000012b"
1473 # give touch a chance to run
1475 do_facet $SINGLEMDS "lctl set_param fail_loc=0x0"
1479 run_test 55 "let MDS_CHECK_RESENT return the original return code instead of 0"
1481 #b3440 ASSERTION(rec->ur_fid2->id) failed
1483 ln -s foo $DIR/$tfile
1484 replay_barrier $SINGLEMDS
1485 #drop_reply "cat $DIR/$tfile"
1489 run_test 56 "don't replay a symlink open request (3440)"
1491 #recovery one mds-ost setattr from llog
1493 #define OBD_FAIL_MDS_OST_SETATTR 0x12c
1494 do_facet $SINGLEMDS "lctl set_param fail_loc=0x8000012c"
1495 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
1496 replay_barrier $SINGLEMDS
1499 $CHECKSTAT -t file $DIR/$tfile ||
1500 error "$CHECKSTAT $DIR/$tfile attribute check failed"
1501 do_facet $SINGLEMDS "lctl set_param fail_loc=0x0"
1504 run_test 57 "test recovery from llog for setattr op"
1507 zconf_umount $(hostname) $MOUNT2
1511 #recovery many mds-ost setattr from llog
1513 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
1514 #define OBD_FAIL_MDS_OST_SETATTR 0x12c
1515 do_facet $SINGLEMDS "lctl set_param fail_loc=0x8000012c"
1516 createmany -o $DIR/$tdir/$tfile-%d 2500
1517 replay_barrier $SINGLEMDS
1520 $CHECKSTAT -t file $DIR/$tdir/$tfile-* >/dev/null ||
1521 error "$CHECKSTAT $DIR/$tfile-* attribute check failed"
1522 do_facet $SINGLEMDS "lctl set_param fail_loc=0x0"
1523 unlinkmany $DIR/$tdir/$tfile-%d 2500 ||
1524 error "unlinkmany $DIR/$tfile failed"
1527 run_test 58a "test recovery from llog for setattr op (test llog_gen_rec)"
1533 trap cleanup_58 EXIT
1535 large_xattr_enabled &&
1536 orig="$(generate_string $(max_xattr_size))" || orig="bar"
1537 # Original extended attribute can be long. Print a small version of
1538 # attribute if an error occurs
1539 local sm_msg=$(printf "%.9s" $orig)
1541 mount_client $MOUNT2 || error "mount_client on $MOUNT2 failed"
1542 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
1543 touch $DIR/$tdir/$tfile || error "touch $DIR/$tdir/$tfile failed"
1544 replay_barrier $SINGLEMDS
1545 setfattr -n trusted.foo -v $orig $DIR/$tdir/$tfile
1547 new=$(get_xattr_value trusted.foo $MOUNT2/$tdir/$tfile)
1548 [[ "$new" = "$orig" ]] ||
1549 error "xattr set ($sm_msg...) differs from xattr get ($new)"
1550 rm -f $DIR/$tdir/$tfile
1553 wait_clients_import_state ${CLIENTS:-$HOSTNAME} "mgs" FULL
1555 run_test 58b "test replay of setxattr op"
1557 test_58c() { # bug 16570
1562 trap cleanup_58 EXIT
1564 if large_xattr_enabled; then
1565 local xattr_size=$(max_xattr_size)
1566 orig="$(generate_string $((xattr_size / 2)))"
1567 orig1="$(generate_string $xattr_size)"
1573 # PING_INTERVAL max(obd_timeout / 4, 1U)
1574 sleep $((TIMEOUT / 4))
1576 # Original extended attribute can be long. Print a small version of
1577 # attribute if an error occurs
1578 local sm_msg=$(printf "%.9s" $orig)
1579 local sm_msg1=$(printf "%.9s" $orig1)
1581 mount_client $MOUNT2 || error "mount_client on $MOUNT2 failed"
1582 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
1583 touch $DIR/$tdir/$tfile || error "touch $DIR/$tdir/$tfile failed"
1584 drop_request "setfattr -n trusted.foo -v $orig $DIR/$tdir/$tfile" ||
1585 error "drop_request for setfattr failed"
1586 new=$(get_xattr_value trusted.foo $MOUNT2/$tdir/$tfile)
1587 [[ "$new" = "$orig" ]] ||
1588 error "xattr set ($sm_msg...) differs from xattr get ($new)"
1589 drop_reint_reply "setfattr -n trusted.foo1 \
1590 -v $orig1 $DIR/$tdir/$tfile" ||
1591 error "drop_reint_reply for setfattr failed"
1592 new=$(get_xattr_value trusted.foo1 $MOUNT2/$tdir/$tfile)
1593 [[ "$new" = "$orig1" ]] ||
1594 error "second xattr set ($sm_msg1...) differs xattr get ($new)"
1595 rm -f $DIR/$tdir/$tfile
1599 run_test 58c "resend/reconstruct setxattr op"
1601 # log_commit_thread vs filter_destroy race used to lead to import use after free
1604 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1606 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
1607 createmany -o $DIR/$tdir/$tfile-%d 200 ||
1608 error "createmany create files failed"
1610 unlinkmany $DIR/$tdir/$tfile-%d 200 ||
1611 error "unlinkmany $DIR/$tdir/$tfile failed"
1612 #define OBD_FAIL_PTLRPC_DELAY_RECOV 0x507
1613 do_facet ost1 "lctl set_param fail_loc=0x507"
1616 do_facet ost1 "lctl set_param fail_loc=0x0"
1620 run_test 59 "test log_commit_thread vs filter_destroy race"
1622 # race between add unlink llog vs cat log init in post_recovery (only for b1_6)
1623 # bug 12086: should no oops and No ctxt error for this test
1625 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
1626 createmany -o $DIR/$tdir/$tfile-%d 200 ||
1627 error "createmany create files failed"
1628 replay_barrier $SINGLEMDS
1629 unlinkmany $DIR/$tdir/$tfile-%d 0 100
1631 unlinkmany $DIR/$tdir/$tfile-%d 100 100
1632 local no_ctxt=$(dmesg | grep "No ctxt")
1633 [ -z "$no_ctxt" ] || error "ctxt is not initialized in recovery"
1635 run_test 60 "test llog post recovery init vs llog unlink"
1637 #test race llog recovery thread vs llog cleanup
1638 test_61a() { # was test_61
1639 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1641 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
1642 createmany -o $DIR/$tdir/$tfile-%d 800 ||
1643 error "createmany create files failed"
1645 unlinkmany $DIR/$tdir/$tfile-%d 800
1646 # OBD_FAIL_OST_LLOG_RECOVERY_TIMEOUT 0x221
1647 set_nodes_failloc "$(osts_nodes)" 0x80000221
1652 set_nodes_failloc "$(osts_nodes)" 0x0
1654 $CHECKSTAT -t file $DIR/$tdir/$tfile-* &&
1655 error "$CHECKSTAT $DIR/$tdir/$tfile attribute check should fail"
1658 run_test 61a "test race llog recovery vs llog cleanup"
1660 #test race mds llog sync vs llog cleanup
1662 # OBD_FAIL_MDS_LLOG_SYNC_TIMEOUT 0x13a
1663 do_facet $SINGLEMDS "lctl set_param fail_loc=0x8000013a"
1664 facet_failover $SINGLEMDS
1667 do_facet client dd if=/dev/zero of=$DIR/$tfile bs=4k count=1 ||
1670 run_test 61b "test race mds llog sync vs llog cleanup"
1672 #test race cancel cookie cb vs llog cleanup
1674 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1676 # OBD_FAIL_OST_CANCEL_COOKIE_TIMEOUT 0x222
1677 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
1678 set_nodes_failloc "$(osts_nodes)" 0x80000222
1682 set_nodes_failloc "$(osts_nodes)" 0x0
1684 run_test 61c "test race mds llog sync vs llog cleanup"
1686 test_61d() { # bug 16002 # bug 17466 # bug 22137
1687 # OBD_FAIL_OBD_LLOG_SETUP 0x605
1689 do_facet mgs "lctl set_param fail_loc=0x80000605"
1690 start mgs $(mgsdevname) $MGS_MOUNT_OPTS &&
1691 error "mgs start should have failed"
1692 do_facet mgs "lctl set_param fail_loc=0"
1693 start mgs $(mgsdevname) $MGS_MOUNT_OPTS || error "cannot restart mgs"
1695 run_test 61d "error in llog_setup should cleanup the llog context correctly"
1697 test_62() { # Bug 15756 - don't mis-drop resent replay
1698 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
1699 replay_barrier $SINGLEMDS
1700 createmany -o $DIR/$tdir/$tfile- 25 ||
1701 error "createmany create files failed"
1702 #define OBD_FAIL_TGT_REPLAY_DROP 0x707
1703 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000707"
1705 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
1706 unlinkmany $DIR/$tdir/$tfile- 25 ||
1707 error "unlinkmany $DIR/$tdir/$tfile failed"
1710 run_test 62 "don't mis-drop resent replay"
1712 #Adaptive Timeouts (bug 3055)
1720 echo "Cleaning up AT ..."
1721 if [ -n "$ATOLDBASE" ]; then
1722 local at_history=$($LCTL get_param -n at_history)
1723 do_facet $SINGLEMDS "lctl set_param at_history=$at_history" || true
1724 do_facet ost1 "lctl set_param at_history=$at_history" || true
1727 if [ $AT_MAX_SET -ne 0 ]; then
1728 for facet in mds client ost; do
1729 var=AT_MAX_SAVE_${facet}
1730 echo restore AT on $facet to saved value ${!var}
1731 at_max_set ${!var} $facet
1732 at_new=$(at_max_get $facet)
1733 echo Restored AT value on $facet $at_new
1734 [ $at_new -eq ${!var} ] ||
1735 error "AT value not restored SAVED ${!var} NEW $at_new"
1742 local at_max_new=600
1744 # Save at_max original values
1746 if [ $AT_MAX_SET -eq 0 ]; then
1747 # Suppose that all osts have the same at_max
1748 for facet in mds client ost; do
1749 eval AT_MAX_SAVE_${facet}=$(at_max_get $facet)
1753 for facet in mds client ost; do
1754 at_max=$(at_max_get $facet)
1755 if [ $at_max -ne $at_max_new ]; then
1756 echo "AT value on $facet is $at_max, set it by force temporarily to $at_max_new"
1757 at_max_set $at_max_new $facet
1762 if [ -z "$ATOLDBASE" ]; then
1763 ATOLDBASE=$(do_facet $SINGLEMDS "lctl get_param -n at_history")
1764 # speed up the timebase so we can check decreasing AT
1765 do_facet $SINGLEMDS "lctl set_param at_history=8" || true
1766 do_facet ost1 "lctl set_param at_history=8" || true
1768 # sleep for a while to cool down, should be > 8s and also allow
1769 # at least one ping to be sent. simply use TIMEOUT to be safe.
1774 test_65a() #bug 3055
1776 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1778 at_start || return 0
1779 $LCTL dk > /dev/null
1781 $LCTL set_param debug="other"
1782 # Slow down a request to the current service time, this is critical
1783 # because previous tests may have caused this value to increase.
1784 REQ_DELAY=`lctl get_param -n mdc.${FSNAME}-MDT0000-mdc-*.timeouts |
1785 awk '/portal 12/ {print $5}'`
1786 REQ_DELAY=$((${REQ_DELAY} + ${REQ_DELAY} / 4 + 5))
1788 do_facet $SINGLEMDS lctl set_param fail_val=$((${REQ_DELAY} * 1000))
1789 #define OBD_FAIL_PTLRPC_PAUSE_REQ 0x50a
1790 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x8000050a
1791 createmany -o $DIR/$tfile 10 > /dev/null
1792 unlinkmany $DIR/$tfile 10 > /dev/null
1793 # check for log message
1794 $LCTL dk | grep "Early reply #" || error "No early reply"
1796 # client should show REQ_DELAY estimates
1797 lctl get_param -n mdc.${FSNAME}-MDT0000-mdc-*.timeouts | grep portal
1799 lctl get_param -n mdc.${FSNAME}-MDT0000-mdc-*.timeouts | grep portal
1801 run_test 65a "AT: verify early replies"
1803 test_65b() #bug 3055
1805 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1807 at_start || return 0
1810 $LCTL set_param debug="other trace"
1811 $LCTL dk > /dev/null
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 $SETSTRIPE --stripe-index=0 --count=1 $DIR/$tfile
1815 multiop $DIR/$tfile Ow1yc
1816 REQ_DELAY=`lctl get_param -n osc.${FSNAME}-OST0000-osc-*.timeouts |
1817 awk '/portal 6/ {print $5}'`
1818 REQ_DELAY=$((${REQ_DELAY} + ${REQ_DELAY} / 4 + 5))
1820 do_facet ost1 lctl set_param fail_val=${REQ_DELAY}
1821 #define OBD_FAIL_OST_BRW_PAUSE_PACK 0x224
1822 do_facet ost1 $LCTL set_param fail_loc=0x224
1825 $SETSTRIPE --stripe-index=0 --count=1 $DIR/$tfile
1826 # force some real bulk transfer
1827 multiop $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
1829 do_facet ost1 $LCTL set_param fail_loc=0
1830 # check for log message
1831 $LCTL dk | grep "Early reply #" || error "No early reply"
1833 # client should show REQ_DELAY estimates
1834 lctl get_param -n osc.${FSNAME}-OST0000-osc-*.timeouts | grep portal
1836 run_test 65b "AT: verify early replies on packed reply / bulk"
1838 test_66a() #bug 3055
1840 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1842 at_start || return 0
1843 lctl get_param -n mdc.${FSNAME}-MDT0000-mdc-*.timeouts | grep "portal 12"
1844 # adjust 5s at a time so no early reply is sent (within deadline)
1845 do_facet $SINGLEMDS "$LCTL set_param fail_val=5000"
1846 #define OBD_FAIL_PTLRPC_PAUSE_REQ 0x50a
1847 do_facet $SINGLEMDS "$LCTL set_param fail_loc=0x8000050a"
1848 createmany -o $DIR/$tfile 20 > /dev/null
1849 unlinkmany $DIR/$tfile 20 > /dev/null
1850 lctl get_param -n mdc.${FSNAME}-MDT0000-mdc-*.timeouts | grep "portal 12"
1851 do_facet $SINGLEMDS "$LCTL set_param fail_val=10000"
1852 do_facet $SINGLEMDS "$LCTL set_param fail_loc=0x8000050a"
1853 createmany -o $DIR/$tfile 20 > /dev/null
1854 unlinkmany $DIR/$tfile 20 > /dev/null
1855 lctl get_param -n mdc.${FSNAME}-MDT0000-mdc-*.timeouts | grep "portal 12"
1856 do_facet $SINGLEMDS "$LCTL set_param fail_loc=0"
1858 createmany -o $DIR/$tfile 20 > /dev/null
1859 unlinkmany $DIR/$tfile 20 > /dev/null
1860 lctl get_param -n mdc.${FSNAME}-MDT0000-mdc-*.timeouts | grep "portal 12"
1861 CUR=$(lctl get_param -n mdc.${FSNAME}-MDT0000-mdc-*.timeouts | awk '/portal 12/ {print $5}')
1862 WORST=$(lctl get_param -n mdc.${FSNAME}-MDT0000-mdc-*.timeouts | awk '/portal 12/ {print $7}')
1863 echo "Current MDT timeout $CUR, worst $WORST"
1864 [ $CUR -lt $WORST ] || error "Current $CUR should be less than worst $WORST"
1866 run_test 66a "AT: verify MDT service time adjusts with no early replies"
1868 test_66b() #bug 3055
1870 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1872 at_start || return 0
1873 ORIG=$(lctl get_param -n mdc.${FSNAME}-MDT0000*.timeouts |
1874 awk '/network/ {print $4}')
1875 $LCTL set_param fail_val=$(($ORIG + 5))
1876 #define OBD_FAIL_PTLRPC_PAUSE_REP 0x50c
1877 $LCTL set_param fail_loc=0x50c
1878 ls $DIR/$tfile > /dev/null 2>&1
1879 $LCTL set_param fail_loc=0
1880 CUR=$(lctl get_param -n mdc.${FSNAME}-MDT0000*.timeouts |
1881 awk '/network/ {print $4}')
1882 WORST=$(lctl get_param -n mdc.${FSNAME}-MDT0000*.timeouts |
1883 awk '/network/ {print $6}')
1884 echo "network timeout orig $ORIG, cur $CUR, worst $WORST"
1885 [ $WORST -gt $ORIG ] ||
1886 error "Worst $WORST should be worse than orig $ORIG"
1888 run_test 66b "AT: verify net latency adjusts"
1890 test_67a() #bug 3055
1892 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1894 at_start || return 0
1895 CONN1=$(lctl get_param -n osc.*.stats | awk '/_connect/ {total+=$2} END {print total}')
1896 # sleeping threads may drive values above this
1897 do_facet ost1 "$LCTL set_param fail_val=400"
1898 #define OBD_FAIL_PTLRPC_PAUSE_REQ 0x50a
1899 do_facet ost1 "$LCTL set_param fail_loc=0x50a"
1900 createmany -o $DIR/$tfile 20 > /dev/null
1901 unlinkmany $DIR/$tfile 20 > /dev/null
1902 do_facet ost1 "$LCTL set_param fail_loc=0"
1903 CONN2=$(lctl get_param -n osc.*.stats | awk '/_connect/ {total+=$2} END {print total}')
1904 ATTEMPTS=$(($CONN2 - $CONN1))
1905 echo "$ATTEMPTS osc reconnect attempts on gradual slow"
1906 [ $ATTEMPTS -gt 0 ] &&
1907 error_ignore bz13721 "AT should have prevented reconnect"
1910 run_test 67a "AT: verify slow request processing doesn't induce reconnects"
1912 test_67b() #bug 3055
1914 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1916 at_start || return 0
1917 CONN1=$(lctl get_param -n osc.*.stats | awk '/_connect/ {total+=$2} END {print total}')
1919 # exhaust precreations on ost1
1920 local OST=$(ostname_from_index 0)
1921 local mdtosc=$(get_mdtosc_proc_path mds $OST)
1922 local last_id=$(do_facet $SINGLEMDS lctl get_param -n \
1923 osc.$mdtosc.prealloc_last_id)
1924 local next_id=$(do_facet $SINGLEMDS lctl get_param -n \
1925 osc.$mdtosc.prealloc_next_id)
1927 mkdir -p $DIR/$tdir/${OST} || error "mkdir $DIR/$tdir/${OST} failed"
1928 $SETSTRIPE -i 0 -c 1 $DIR/$tdir/${OST} || error "$SETSTRIPE failed"
1929 echo "Creating to objid $last_id on ost $OST..."
1930 #define OBD_FAIL_OST_PAUSE_CREATE 0x223
1931 do_facet ost1 "$LCTL set_param fail_val=20000"
1932 do_facet ost1 "$LCTL set_param fail_loc=0x80000223"
1933 createmany -o $DIR/$tdir/${OST}/f $next_id $((last_id - next_id + 2))
1936 do_facet ost1 "lctl get_param -n ost.OSS.ost_create.timeouts"
1938 CONN2=$(lctl get_param -n osc.*.stats | awk '/_connect/ {total+=$2} END {print total}')
1939 ATTEMPTS=$(($CONN2 - $CONN1))
1940 echo "$ATTEMPTS osc reconnect attempts on instant slow"
1941 # do it again; should not timeout
1942 do_facet ost1 "$LCTL set_param fail_loc=0x80000223"
1943 cp /etc/profile $DIR/$tfile || error "cp failed"
1944 do_facet ost1 "$LCTL set_param fail_loc=0"
1946 do_facet ost1 "lctl get_param -n ost.OSS.ost_create.timeouts"
1947 CONN3=$(lctl get_param -n osc.*.stats | awk '/_connect/ {total+=$2} END {print total}')
1948 ATTEMPTS=$(($CONN3 - $CONN2))
1949 echo "$ATTEMPTS osc reconnect attempts on 2nd slow"
1950 [ $ATTEMPTS -gt 0 ] && error "AT should have prevented reconnect"
1953 run_test 67b "AT: verify instant slowdown doesn't induce reconnects"
1955 test_68 () #bug 13813
1957 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1959 at_start || return 0
1960 local ldlm_enqueue_min=$(find /sys -name ldlm_enqueue_min)
1961 [ -z "$ldlm_enqueue_min" ] && skip "missing /sys/.../ldlm_enqueue_min" && return 0
1962 local ldlm_enqueue_min_r=$(do_facet ost1 "find /sys -name ldlm_enqueue_min")
1963 [ -z "$ldlm_enqueue_min_r" ] && skip "missing /sys/.../ldlm_enqueue_min in the ost1" && return 0
1964 local ENQ_MIN=$(cat $ldlm_enqueue_min)
1965 local ENQ_MIN_R=$(do_facet ost1 "cat $ldlm_enqueue_min_r")
1966 echo $TIMEOUT >> $ldlm_enqueue_min
1967 do_facet ost1 "echo $TIMEOUT >> $ldlm_enqueue_min_r"
1969 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
1970 $SETSTRIPE --stripe-index=0 --count=1 $DIR/$tdir
1971 #define OBD_FAIL_LDLM_PAUSE_CANCEL 0x312
1972 $LCTL set_param fail_val=$(($TIMEOUT - 1))
1973 $LCTL set_param fail_loc=0x80000312
1974 cp /etc/profile $DIR/$tdir/${tfile}_1 || error "1st cp failed $?"
1975 $LCTL set_param fail_val=$((TIMEOUT * 5 / 4))
1976 $LCTL set_param fail_loc=0x80000312
1977 cp /etc/profile $DIR/$tdir/${tfile}_2 || error "2nd cp failed $?"
1978 $LCTL set_param fail_loc=0
1980 echo $ENQ_MIN >> $ldlm_enqueue_min
1981 do_facet ost1 "echo $ENQ_MIN_R >> $ldlm_enqueue_min_r"
1985 run_test 68 "AT: verify slowing locks"
1988 # end of AT tests includes above lines
1990 # start multi-client tests
1992 [ -z "$CLIENTS" ] &&
1993 { skip "Need two or more clients." && return; }
1994 [ $CLIENTCOUNT -lt 2 ] &&
1995 { skip "Need two or more clients, have $CLIENTCOUNT" && return; }
1997 echo "mount clients $CLIENTS ..."
1998 zconf_mount_clients $CLIENTS $MOUNT
2000 local clients=${CLIENTS//,/ }
2001 echo "Write/read files on $DIR ; clients $CLIENTS ... "
2002 for CLIENT in $clients; do
2003 do_node $CLIENT dd bs=1M count=10 if=/dev/zero \
2004 of=$DIR/${tfile}_${CLIENT} 2>/dev/null ||
2005 error "dd failed on $CLIENT"
2008 local prev_client=$(echo $clients | sed 's/^.* \(.\+\)$/\1/')
2009 for C in ${CLIENTS//,/ }; do
2010 do_node $prev_client dd if=$DIR/${tfile}_${C} \
2011 of=/dev/null 2>/dev/null ||
2012 error "dd if=$DIR/${tfile}_${C} failed on $prev_client"
2018 run_test 70a "check multi client t-f"
2020 check_for_process () {
2025 killall_process $clients "$prog" -0
2028 killall_process () {
2029 local clients=${1:-$(hostname)}
2034 do_nodes $clients "killall $signal $name"
2038 local clients=${CLIENTS:-$HOSTNAME}
2040 zconf_mount_clients $clients $MOUNT
2043 [ "$SLOW" = "no" ] && duration=120
2044 # set duration to 900 because it takes some time to boot node
2045 [ "$FAILURE_MODE" = HARD ] && duration=900
2048 local start_ts=$(date +%s)
2049 local cmd="rundbench 1 -t $duration"
2051 do_nodesv $clients "set -x; MISSING_DBENCH_OK=$MISSING_DBENCH_OK \
2052 PATH=\$PATH:$LUSTRE/utils:$LUSTRE/tests/:$DBENCH_LIB \
2053 DBENCH_LIB=$DBENCH_LIB TESTSUITE=$TESTSUITE TESTNAME=$TESTNAME \
2054 MOUNT=$MOUNT DIR=$DIR/$tdir/\\\$(hostname) LCTL=$LCTL $cmd" &
2057 #LU-1897 wait for all dbench copies to start
2058 while ! check_for_process $clients dbench; do
2059 elapsed=$(($(date +%s) - start_ts))
2060 if [ $elapsed -gt $duration ]; then
2061 killall_process $clients dbench
2062 error "dbench failed to start on $clients!"
2067 log "Started rundbench load pid=$pid ..."
2069 elapsed=$(($(date +%s) - start_ts))
2070 local num_failovers=0
2071 while [ $elapsed -lt $duration ]; do
2072 if ! check_for_process $clients dbench; then
2073 error_noexit "dbench stopped on some of $clients!"
2074 killall_process $clients dbench
2078 replay_barrier $SINGLEMDS
2079 sleep 1 # give clients a time to do operations
2080 # Increment the number of failovers
2081 num_failovers=$((num_failovers+1))
2082 log "$TESTNAME fail $SINGLEMDS $num_failovers times"
2084 elapsed=$(($(date +%s) - start_ts))
2087 wait $pid || error "rundbench load on $clients failed!"
2089 run_test 70b "mds recovery; $CLIENTCOUNT clients"
2090 # end multi-client tests
2093 multiop_bg_pause $DIR/$tfile O_tSc ||
2094 error "multiop_bg_pause $DIR/$tfile failed"
2098 replay_barrier $SINGLEMDS
2099 #define OBD_FAIL_LDLM_ENQUEUE_NET 0x302
2100 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000302"
2103 wait $pid || error "multiop pid failed"
2104 [ -e $DIR/$tfile ] && error "file $DIR/$tfile should not exist"
2107 run_test 73a "open(O_CREAT), unlink, replay, reconnect before open replay, close"
2110 multiop_bg_pause $DIR/$tfile O_tSc ||
2111 error "multiop_bg_pause $DIR/$tfile failed"
2115 replay_barrier $SINGLEMDS
2116 #define OBD_FAIL_LDLM_REPLY 0x30c
2117 do_facet $SINGLEMDS "lctl set_param fail_loc=0x8000030c"
2120 wait $pid || error "multiop pid failed"
2121 [ -e $DIR/$tfile ] && error "file $DIR/$tfile should not exist"
2124 run_test 73b "open(O_CREAT), unlink, replay, reconnect at open_replay reply, close"
2128 local clients=${CLIENTS:-$HOSTNAME}
2130 zconf_umount_clients $clients $MOUNT
2132 facet_failover $SINGLEMDS
2133 zconf_mount_clients $clients $MOUNT
2135 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
2136 rm $DIR/$tfile || error "rm $DIR/$tfile failed"
2137 clients_up || error "client evicted: $?"
2140 run_test 74 "Ensure applications don't fail waiting for OST recovery"
2142 remote_dir_check_80() {
2147 diridx=$($GETSTRIPE -M $remote_dir) ||
2148 error "$GETSTRIPE -M $remote_dir failed"
2149 [ $diridx -eq $MDTIDX ] || error "$diridx != $MDTIDX"
2151 createmany -o $remote_dir/f-%d 20 || error "creation failed"
2152 fileidx=$($GETSTRIPE -M $remote_dir/f-1) ||
2153 error "$GETSTRIPE -M $remote_dir/f-1 failed"
2154 [ $fileidx -eq $MDTIDX ] || error "$fileidx != $MDTIDX"
2160 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2161 ([ $FAILURE_MODE == "HARD" ] &&
2162 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
2163 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
2167 local remote_dir=$DIR/$tdir/remote_dir
2169 mkdir -p $DIR/$tdir || error "mkdir $DIR/$tdir failed"
2170 #define OBD_FAIL_OUT_UPDATE_NET_REP 0x1701
2171 do_facet mds${MDTIDX} lctl set_param fail_loc=0x1701
2172 $LFS mkdir -i $MDTIDX $remote_dir &
2177 wait $CLIENT_PID || error "remote creation failed"
2179 remote_dir_check_80 || error "remote dir check failed"
2180 rm -rf $DIR/$tdir || error "rmdir failed"
2184 run_test 80a "DNE: create remote dir, drop update rep from MDT0, fail MDT0"
2187 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2188 ([ $FAILURE_MODE == "HARD" ] &&
2189 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
2190 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
2194 local remote_dir=$DIR/$tdir/remote_dir
2196 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
2197 #define OBD_FAIL_UPDATE_OBJ_NET_REP 0x1701
2198 do_facet mds${MDTIDX} lctl set_param fail_loc=0x1701
2199 $LFS mkdir -i $MDTIDX $remote_dir &
2202 fail mds$((MDTIDX + 1))
2204 wait $CLIENT_PID || error "remote creation failed"
2206 remote_dir_check_80 || error "remote dir check failed"
2207 rm -rf $DIR/$tdir || error "rmdir failed"
2211 run_test 80b "DNE: create remote dir, drop update rep from MDT0, fail MDT1"
2214 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2215 ([ $FAILURE_MODE == "HARD" ] &&
2216 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
2217 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
2221 local remote_dir=$DIR/$tdir/remote_dir
2223 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
2224 #define OBD_FAIL_UPDATE_OBJ_NET_REP 0x1701
2225 do_facet mds${MDTIDX} lctl set_param fail_loc=0x1701
2226 $LFS mkdir -i $MDTIDX $remote_dir &
2230 fail mds$((MDTIDX + 1))
2232 wait $CLIENT_PID || error "remote creation failed"
2234 remote_dir_check_80 || error "remote dir check failed"
2235 rm -rf $DIR/$tdir || error "rmdir failed"
2239 run_test 80c "DNE: create remote dir, drop update rep from MDT1, fail MDT[0,1]"
2242 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2244 local remote_dir=$DIR/$tdir/remote_dir
2246 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
2247 #define OBD_FAIL_UPDATE_OBJ_NET_REP 0x1701
2248 do_facet mds${MDTIDX} lctl set_param fail_loc=0x1701
2249 $LFS mkdir -i $MDTIDX $remote_dir &
2252 # sleep 3 seconds to make sure MDTs are failed after
2253 # lfs mkdir -i has finished on all of MDTs.
2255 fail mds${MDTIDX},mds$((MDTIDX + 1))
2257 wait $CLIENT_PID || error "remote creation failed"
2259 remote_dir_check_80 || error "remote dir check failed"
2260 rm -rf $DIR/$tdir || error "rmdir failed"
2264 run_test 80d "DNE: create remote dir, drop update rep from MDT1, fail 2 MDTs"
2267 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2268 ([ $FAILURE_MODE == "HARD" ] &&
2269 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
2270 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
2274 local remote_dir=$DIR/$tdir/remote_dir
2276 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
2277 # OBD_FAIL_MDS_REINT_NET_REP 0x119
2278 do_facet mds$((MDTIDX + 1)) lctl set_param fail_loc=0x119
2279 $LFS mkdir -i $MDTIDX $remote_dir &
2282 # sleep 3 seconds to make sure MDTs are failed after
2283 # lfs mkdir -i has finished on all of MDTs.
2288 wait $CLIENT_PID || error "remote creation failed"
2290 remote_dir_check_80 || error "remote dir check failed"
2291 rm -rf $DIR/$tdir || error "rmdir failed"
2295 run_test 80e "DNE: create remote dir, drop MDT1 rep, fail MDT0"
2298 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2299 ([ $FAILURE_MODE == "HARD" ] &&
2300 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
2301 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
2304 local remote_dir=$DIR/$tdir/remote_dir
2306 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
2307 # OBD_FAIL_MDS_REINT_NET_REP 0x119
2308 do_facet mds$((MDTIDX + 1)) lctl set_param fail_loc=0x119
2309 $LFS mkdir -i $MDTIDX $remote_dir &
2312 fail mds$((MDTIDX + 1))
2314 wait $CLIENT_PID || error "remote creation failed"
2316 remote_dir_check_80 || error "remote dir check failed"
2317 rm -rf $DIR/$tdir || error "rmdir failed"
2321 run_test 80f "DNE: create remote dir, drop MDT1 rep, fail MDT1"
2324 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2325 ([ $FAILURE_MODE == "HARD" ] &&
2326 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
2327 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
2331 local remote_dir=$DIR/$tdir/remote_dir
2333 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
2334 # OBD_FAIL_MDS_REINT_NET_REP 0x119
2335 do_facet mds$((MDTIDX + 1)) lctl set_param fail_loc=0x119
2336 $LFS mkdir -i $MDTIDX $remote_dir &
2339 # sleep 3 seconds to make sure MDTs are failed after
2340 # lfs mkdir -i has finished on all of MDTs.
2344 fail mds$((MDTIDX + 1))
2346 wait $CLIENT_PID || error "remote creation failed"
2348 remote_dir_check_80 || error "remote dir check failed"
2349 rm -rf $DIR/$tdir || error "rmdir failed"
2353 run_test 80g "DNE: create remote dir, drop MDT1 rep, fail MDT0, then MDT1"
2356 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2358 local remote_dir=$DIR/$tdir/remote_dir
2360 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
2361 # OBD_FAIL_MDS_REINT_NET_REP 0x119
2362 do_facet mds$((MDTIDX + 1)) lctl set_param fail_loc=0x119
2363 $LFS mkdir -i $MDTIDX $remote_dir &
2366 # sleep 3 seconds to make sure MDTs are failed after
2367 # lfs mkdir -i has finished on all of MDTs.
2370 fail mds${MDTIDX},mds$((MDTIDX + 1))
2372 wait $CLIENT_PID || error "remote dir creation failed"
2374 remote_dir_check_80 || error "remote dir check failed"
2375 rm -rf $DIR/$tdir || error "rmdir failed"
2379 run_test 80h "DNE: create remote dir, drop MDT1 rep, fail 2 MDTs"
2382 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2383 ([ $FAILURE_MODE == "HARD" ] &&
2384 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
2385 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
2389 local remote_dir=$DIR/$tdir/remote_dir
2391 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
2392 $LFS mkdir -i $MDTIDX $remote_dir || error "lfs mkdir failed"
2394 touch $remote_dir || error "touch $remote_dir failed"
2395 # OBD_FAIL_OBJ_UPDATE_NET_REP 0x1701
2396 do_facet mds${MDTIDX} lctl set_param fail_loc=0x1701
2400 fail mds$((MDTIDX + 1))
2402 wait $CLIENT_PID || error "rm remote dir failed"
2404 stat $remote_dir 2&>/dev/null && error "$remote_dir still exist!"
2406 rm -rf $DIR/$tdir || error "rmdir failed"
2410 run_test 81a "DNE: unlink remote dir, drop MDT0 update rep, fail MDT1"
2413 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2414 ([ $FAILURE_MODE == "HARD" ] &&
2415 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
2416 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
2419 local remote_dir=$DIR/$tdir/remote_dir
2421 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
2422 $LFS mkdir -i $MDTIDX $remote_dir || error "lfs mkdir failed"
2424 # OBD_FAIL_OBJ_UPDATE_NET_REP 0x1701
2425 do_facet mds${MDTIDX} lctl set_param fail_loc=0x1701
2431 wait $CLIENT_PID || error "rm remote dir failed"
2433 stat $remote_dir 2&>/dev/null && error "$remote_dir still exist!"
2435 rm -rf $DIR/$tdir || error "rmdir failed"
2439 run_test 81b "DNE: unlink remote dir, drop MDT0 update reply, fail MDT0"
2442 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2443 ([ $FAILURE_MODE == "HARD" ] &&
2444 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
2445 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
2449 local remote_dir=$DIR/$tdir/remote_dir
2451 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
2452 $LFS mkdir -i $MDTIDX $remote_dir || error "lfs mkdir failed"
2454 # OBD_FAIL_OBJ_UPDATE_NET_REP 0x1701
2455 do_facet mds${MDTIDX} lctl set_param fail_loc=0x1701
2460 fail mds$((MDTIDX + 1))
2462 wait $CLIENT_PID || error "rm remote dir failed"
2464 stat $remote_dir 2&>/dev/null && error "$remote_dir still exist!"
2466 rm -rf $DIR/$tdir || error "rmdir failed"
2470 run_test 81c "DNE: unlink remote dir, drop MDT0 update reply, fail MDT0,MDT1"
2473 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2475 local remote_dir=$DIR/$tdir/remote_dir
2477 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
2478 $LFS mkdir -i $MDTIDX $remote_dir || error "lfs mkdir failed"
2480 # OBD_FAIL_OBJ_UPDATE_NET_REP 0x1701
2481 do_facet mds${MDTIDX} lctl set_param fail_loc=0x1701
2485 fail mds${MDTIDX},mds$((MDTIDX + 1))
2487 wait $CLIENT_PID || error "rm remote dir failed"
2489 stat $remote_dir 2&>/dev/null && error "$remote_dir still exist!"
2491 rm -rf $DIR/$tdir || error "rmdir failed"
2495 run_test 81d "DNE: unlink remote dir, drop MDT0 update reply, fail 2 MDTs"
2498 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2499 ([ $FAILURE_MODE == "HARD" ] &&
2500 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
2501 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
2505 local remote_dir=$DIR/$tdir/remote_dir
2507 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
2508 $LFS mkdir -i $MDTIDX $remote_dir || error "lfs mkdir failed"
2510 # OBD_FAIL_MDS_REINT_NET_REP 0x119
2511 do_facet mds$((MDTIDX + 1)) lctl set_param fail_loc=0x119
2514 do_facet mds$((MDTIDX + 1)) lctl set_param fail_loc=0
2518 wait $CLIENT_PID || error "rm remote dir failed"
2520 stat $remote_dir 2&>/dev/null && error "$remote_dir still exist!"
2522 rm -rf $DIR/$tdir || error "rmdir failed"
2526 run_test 81e "DNE: unlink remote dir, drop MDT1 req reply, fail MDT0"
2529 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2530 ([ $FAILURE_MODE == "HARD" ] &&
2531 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
2532 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
2536 local remote_dir=$DIR/$tdir/remote_dir
2538 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
2539 $LFS mkdir -i $MDTIDX $remote_dir || error "lfs mkdir failed"
2541 # OBD_FAIL_MDS_REINT_NET_REP 0x119
2542 do_facet mds$((MDTIDX + 1)) lctl set_param fail_loc=0x119
2546 fail mds$((MDTIDX + 1))
2548 wait $CLIENT_PID || error "rm remote dir failed"
2550 stat $remote_dir 2&>/dev/null && error "$remote_dir still exist!"
2552 rm -rf $DIR/$tdir || error "rmdir failed"
2556 run_test 81f "DNE: unlink remote dir, drop MDT1 req reply, fail MDT1"
2559 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2560 ([ $FAILURE_MODE == "HARD" ] &&
2561 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
2562 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
2566 local remote_dir=$DIR/$tdir/remote_dir
2568 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
2569 $LFS mkdir -i $MDTIDX $remote_dir || error "lfs mkdir failed"
2571 # OBD_FAIL_MDS_REINT_NET_REP 0x119
2572 do_facet mds$((MDTIDX + 1)) lctl set_param fail_loc=0x119
2577 fail mds$((MDTIDX + 1))
2579 wait $CLIENT_PID || error "rm remote dir failed"
2581 stat $remote_dir 2&>/dev/null && error "$remote_dir still exist!"
2583 rm -rf $DIR/$tdir || error "rmdir failed"
2587 run_test 81g "DNE: unlink remote dir, drop req reply, fail M0, then M1"
2590 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2592 local remote_dir=$DIR/$tdir/remote_dir
2594 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
2595 $LFS mkdir -i $MDTIDX $remote_dir || error "lfs mkdir failed"
2597 # OBD_FAIL_MDS_REINT_NET_REP 0x119
2598 do_facet mds$((MDTIDX + 1)) lctl set_param fail_loc=0x119
2602 fail mds${MDTIDX},mds$((MDTIDX + 1))
2604 wait $CLIENT_PID || error "rm remote dir failed"
2606 stat $remote_dir 2&>/dev/null && error "$remote_dir still exist!"
2608 rm -rf $DIR/$tdir || error "rmdir failed"
2612 run_test 81h "DNE: unlink remote dir, drop request reply, fail 2 MDTs"
2615 #define OBD_FAIL_MDS_OPEN_WAIT_CREATE 0x144
2616 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000144"
2617 createmany -o $DIR/$tfile- 1 &
2621 client_up || client_up || true # reconnect
2623 run_test 84a "stale open during export disconnect"
2625 test_85a() { #bug 16774
2626 lctl set_param -n ldlm.cancel_unused_locks_before_replay "1"
2628 for i in $(seq 100); do
2629 echo "tag-$i" > $DIR/$tfile-$i
2630 grep -q "tag-$i" $DIR/$tfile-$i || error "f2-$i"
2633 lov_id=$(lctl dl | grep "clilov")
2634 addr=$(echo $lov_id | awk '{print $4}' | awk -F '-' '{print $3}')
2635 count=$(lctl get_param -n \
2636 ldlm.namespaces.*MDT0000*$addr.lock_unused_count)
2637 echo "before recovery: unused locks count = $count"
2641 count2=$(lctl get_param -n \
2642 ldlm.namespaces.*MDT0000*$addr.lock_unused_count)
2643 echo "after recovery: unused locks count = $count2"
2645 if [ $count2 -ge $count ]; then
2646 error "unused locks are not canceled"
2649 run_test 85a "check the cancellation of unused locks during recovery(IBITS)"
2651 test_85b() { #bug 16774
2652 lctl set_param -n ldlm.cancel_unused_locks_before_replay "1"
2654 do_facet mgs $LCTL pool_new $FSNAME.$TESTNAME ||
2655 error "unable to create pool $TESTNAME"
2656 do_facet mgs $LCTL pool_add $FSNAME.$TESTNAME $FSNAME-OST0000 ||
2657 error "unable to add pool $TESTNAME"
2659 $SETSTRIPE -c 1 -p $FSNAME.$TESTNAME $DIR
2661 for i in $(seq 100); do
2662 dd if=/dev/urandom of=$DIR/$tfile-$i bs=4096 \
2663 count=32 >/dev/null 2>&1
2666 cancel_lru_locks osc
2668 for i in $(seq 100); do
2669 dd if=$DIR/$tfile-$i of=/dev/null bs=4096 \
2670 count=32 >/dev/null 2>&1
2673 lov_id=$(lctl dl | grep "clilov")
2674 addr=$(echo $lov_id | awk '{print $4}' | awk -F '-' '{print $3}')
2675 count=$(lctl get_param \
2676 -n ldlm.namespaces.*OST0000*$addr.lock_unused_count)
2677 echo "before recovery: unused locks count = $count"
2678 [ $count != 0 ] || error "unused locks ($count) should be zero"
2682 count2=$(lctl get_param \
2683 -n ldlm.namespaces.*OST0000*$addr.lock_unused_count)
2684 echo "after recovery: unused locks count = $count2"
2686 do_facet mgs $LCTL pool_remove $FSNAME.$TESTNAME $FSNAME-OST0000 ||
2687 error "unable to remove pool $TESTNAME"
2688 do_facet mgs $LCTL pool_destroy $FSNAME.$TESTNAME ||
2689 error "unable to destroy the pool $TESTNAME"
2691 if [ $count2 -ge $count ]; then
2692 error "unused locks are not canceled"
2695 run_test 85b "check the cancellation of unused locks during recovery(EXTENT)"
2698 local clients=${CLIENTS:-$HOSTNAME}
2700 zconf_umount_clients $clients $MOUNT
2701 do_facet $SINGLEMDS lctl set_param mdt.${FSNAME}-MDT*.exports.clear=0
2702 remount_facet $SINGLEMDS
2703 zconf_mount_clients $clients $MOUNT
2705 run_test 86 "umount server after clear nid_stats should not hit LBUG"
2708 do_facet ost1 "lctl set_param -n obdfilter.${ost1_svc}.sync_journal 0"
2711 $SETSTRIPE -i 0 -c 1 $DIR/$tfile
2712 dd if=/dev/urandom of=$DIR/$tfile bs=1024k count=8 ||
2713 error "dd to $DIR/$tfile failed"
2714 cksum=$(md5sum $DIR/$tfile | awk '{print $1}')
2715 cancel_lru_locks osc
2717 dd if=$DIR/$tfile of=/dev/null bs=1024k count=8 || error "Cannot read"
2718 cksum2=$(md5sum $DIR/$tfile | awk '{print $1}')
2719 if [ $cksum != $cksum2 ] ; then
2720 error "New checksum $cksum2 does not match original $cksum"
2723 run_test 87 "write replay"
2726 do_facet ost1 "lctl set_param -n obdfilter.${ost1_svc}.sync_journal 0"
2729 $SETSTRIPE -i 0 -c 1 $DIR/$tfile
2730 dd if=/dev/urandom of=$DIR/$tfile bs=1024k count=8 ||
2731 error "dd to $DIR/$tfile failed"
2732 sleep 1 # Give it a chance to flush dirty data
2733 echo TESTTEST | dd of=$DIR/$tfile bs=1 count=8 seek=64
2734 cksum=$(md5sum $DIR/$tfile | awk '{print $1}')
2735 cancel_lru_locks osc
2737 dd if=$DIR/$tfile of=/dev/null bs=1024k count=8 || error "Cannot read"
2738 cksum2=$(md5sum $DIR/$tfile | awk '{print $1}')
2739 if [ $cksum != $cksum2 ] ; then
2740 error "New checksum $cksum2 does not match original $cksum"
2743 run_test 87b "write replay with changed data (checksum resend)"
2745 test_88() { #bug 17485
2746 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
2747 mkdir -p $TMP/$tdir || error "mkdir $TMP/$tdir failed"
2749 $SETSTRIPE -i 0 -c 1 $DIR/$tdir || error "$SETSTRIPE"
2752 replay_barrier $SINGLEMDS
2754 # exhaust precreations on ost1
2755 local OST=$(ostname_from_index 0)
2756 local mdtosc=$(get_mdtosc_proc_path $SINGLEMDS $OST)
2757 local last_id=$(do_facet $SINGLEMDS lctl get_param -n osc.$mdtosc.prealloc_last_id)
2758 local next_id=$(do_facet $SINGLEMDS lctl get_param -n osc.$mdtosc.prealloc_next_id)
2759 echo "before test: last_id = $last_id, next_id = $next_id"
2761 echo "Creating to objid $last_id on ost $OST..."
2762 createmany -o $DIR/$tdir/f-%d $next_id $((last_id - next_id + 2)) ||
2763 error "createmany create files to last_id failed"
2765 #create some files to use some uncommitted objids
2766 last_id=$(($last_id + 1))
2767 createmany -o $DIR/$tdir/f-%d $last_id 8 ||
2768 error "createmany create files with uncommitted objids failed"
2770 last_id2=$(do_facet $SINGLEMDS lctl get_param -n osc.$mdtosc.prealloc_last_id)
2771 next_id2=$(do_facet $SINGLEMDS lctl get_param -n osc.$mdtosc.prealloc_next_id)
2772 echo "before recovery: last_id = $last_id2, next_id = $next_id2"
2774 # if test uses shutdown_facet && reboot_facet instead of facet_failover ()
2775 # it has to take care about the affected facets, bug20407
2776 local affected_mds1=$(affected_facets mds1)
2777 local affected_ost1=$(affected_facets ost1)
2779 shutdown_facet $SINGLEMDS
2782 reboot_facet $SINGLEMDS
2783 change_active $affected_mds1
2784 wait_for_facet $affected_mds1
2785 mount_facets $affected_mds1 || error "Restart of mds failed"
2788 change_active $affected_ost1
2789 wait_for_facet $affected_ost1
2790 mount_facets $affected_ost1 || error "Restart of ost1 failed"
2794 last_id2=$(do_facet $SINGLEMDS lctl get_param -n osc.$mdtosc.prealloc_last_id)
2795 next_id2=$(do_facet $SINGLEMDS lctl get_param -n osc.$mdtosc.prealloc_next_id)
2796 echo "after recovery: last_id = $last_id2, next_id = $next_id2"
2798 # create new files, which should use new objids, and ensure the orphan
2799 # cleanup phase for ost1 is completed at the same time
2800 for i in $(seq 8); do
2801 file_id=$(($last_id + 10 + $i))
2802 dd if=/dev/urandom of=$DIR/$tdir/f-$file_id bs=4096 count=128
2805 # if the objids were not recreated, then "ls" will fail with -ENOENT
2806 ls -l $DIR/$tdir/* || error "can't get the status of precreated files"
2809 # write into previously created files
2810 for i in $(seq 8); do
2811 file_id=$(($last_id + $i))
2812 dd if=/dev/urandom of=$DIR/$tdir/f-$file_id bs=4096 count=128
2813 cp -f $DIR/$tdir/f-$file_id $TMP/$tdir/
2816 # compare the content
2817 for i in $(seq 8); do
2818 file_id=$(($last_id + $i))
2819 cmp $TMP/$tdir/f-$file_id $DIR/$tdir/f-$file_id ||
2820 error "the content of file is modified!"
2825 run_test 88 "MDS should not assign same objid to different files "
2828 cancel_lru_locks osc
2829 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
2830 rm -f $DIR/$tdir/$tfile
2832 wait_delete_completed
2833 BLOCKS1=$(df -P $MOUNT | tail -n 1 | awk '{ print $3 }')
2834 $SETSTRIPE -i 0 -c 1 $DIR/$tdir/$tfile
2835 dd if=/dev/zero bs=1M count=10 of=$DIR/$tdir/$tfile
2838 facet_failover $SINGLEMDS
2839 rm $DIR/$tdir/$tfile
2842 zconf_mount $(hostname) $MOUNT || error "mount fails"
2843 client_up || error "client_up failed"
2845 wait_delete_completed
2846 BLOCKS2=$(df -P $MOUNT | tail -n 1 | awk '{ print $3 }')
2847 [ $((BLOCKS2 - BLOCKS1)) -le 4 ] ||
2848 error $((BLOCKS2 - BLOCKS1)) blocks leaked
2851 run_test 89 "no disk space leak on late ost connection"
2857 change_active $facet
2858 wait_for_facet $facet
2859 mount_facet $facet || error "Restart of $facet failed"
2863 test_90() { # bug 19494
2864 local dir=$DIR/$tdir
2865 local ostfail=$(get_random_entry $(get_facets OST))
2867 if [[ $FAILURE_MODE = HARD ]]; then
2868 local affected=$(affected_facets $ostfail);
2869 if [[ "$affected" != $ostfail ]]; then
2870 skip not functional with FAILURE_MODE=$FAILURE_MODE, affected: $affected
2875 mkdir $dir || error "mkdir $dir failed"
2877 echo "Create the files"
2879 # file "f${index}" striped over 1 OST
2880 # file "all" striped over all OSTs
2882 $SETSTRIPE -c $OSTCOUNT $dir/all ||
2883 error "setstripe failed to create $dir/all"
2885 for (( i=0; i<$OSTCOUNT; i++ )); do
2887 $SETSTRIPE -i $i -c 1 $f || error "$SETSTRIPE failed to create $f"
2889 # confirm setstripe actually created the stripe on the requested OST
2890 local uuid=$(ostuuid_from_index $i)
2891 for file in f$i all; do
2892 if [[ $dir/$file != $($LFS find --obd $uuid --name $file $dir) ]]; then
2893 $GETSTRIPE $dir/$file
2894 error wrong stripe: $file, uuid: $uuid
2899 # Before failing an OST, get its obd name and index
2900 local varsvc=${ostfail}_svc
2901 local obd=$(do_facet $ostfail lctl get_param \
2902 -n obdfilter.${!varsvc}.uuid)
2903 local index=$(($(facet_number $ostfail) - 1))
2905 echo "Fail $ostfail $obd, display the list of affected files"
2906 shutdown_facet $ostfail || error "shutdown_facet $ostfail failed"
2908 trap "cleanup_90 $ostfail" EXIT INT
2909 echo "General Query: lfs find $dir"
2910 local list=$($LFS find $dir)
2912 for (( i=0; i<$OSTCOUNT; i++ )); do
2913 list_member "$list" $dir/f$i ||
2914 error_noexit "lfs find $dir: no file f$i"
2916 list_member "$list" $dir/all ||
2917 error_noexit "lfs find $dir: no file all"
2919 # focus on the missing OST,
2920 # we expect to see only two files affected: "f$(index)" and "all"
2922 echo "Querying files on shutdown $ostfail: lfs find --obd $obd"
2923 list=$($LFS find --obd $obd $dir)
2925 for file in all f$index; do
2926 list_member "$list" $dir/$file ||
2927 error_noexit "lfs find does not report the affected $obd for $file"
2930 [[ $(echo $list | wc -w) -eq 2 ]] ||
2931 error_noexit "lfs find reports the wrong list of affected files ${#list[@]}"
2933 echo "Check getstripe: $GETSTRIPE -r --obd $obd"
2934 list=$($GETSTRIPE -r --obd $obd $dir)
2936 for file in all f$index; do
2937 echo "$list" | grep $dir/$file ||
2938 error_noexit "lfs getsripe does not report the affected $obd for $file"
2943 run_test 90 "lfs find identifies the missing striped file segments"
2946 local server_version=$(lustre_version_code $SINGLEMDS)
2947 [[ $server_version -ge $(version_code 2.6.90) ]] ||
2948 [[ $server_version -ge $(version_code 2.5.4) &&
2949 $server_version -lt $(version_code 2.5.50) ]] ||
2950 { skip "Need MDS version 2.5.4+ or 2.6.90+"; return; }
2952 cancel_lru_locks osc
2954 $SETSTRIPE -i 0 -c 1 $DIR/$tfile ||
2955 error "$SETSTRIPE $DIR/$tfile failed"
2956 dd if=/dev/zero of=$DIR/$tfile bs=1024 count=1 ||
2957 error "dd to $DIR/$tfile failed"
2958 #define OBD_FAIL_TGT_REPLAY_RECONNECT 0x715
2959 # We need to emulate a state that OST is waiting for other clients
2960 # not completing the recovery. Final ping is queued, but reply will be
2961 # sent on the recovery completion. It is done by sleep before
2962 # processing final pings
2963 do_facet ost1 "$LCTL set_param fail_val=40"
2964 do_facet ost1 "$LCTL set_param fail_loc=0x715"
2967 run_test 93 "replay + reconnect"
2969 striped_dir_check_100() {
2970 local striped_dir=$DIR/$tdir/striped_dir
2971 local stripe_count=$($LFS getdirstripe -c $striped_dir)
2973 $LFS getdirstripe $striped_dir
2974 [ $stripe_count -eq 2 ] || error "$stripe_count != 2"
2976 createmany -o $striped_dir/f-%d 20 ||
2977 error "creation failed under striped dir"
2981 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2982 ([ $FAILURE_MODE == "HARD" ] &&
2983 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
2984 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
2987 local striped_dir=$DIR/$tdir/striped_dir
2990 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
2992 #To make sure MDT1 and MDT0 are connected
2993 #otherwise it may create single stripe dir here
2994 $LFS setdirstripe -i1 $DIR/$tdir/remote_dir
2996 #define OBD_FAIL_OUT_UPDATE_NET_REP 0x1701
2997 do_facet mds$((MDTIDX+1)) lctl set_param fail_loc=0x1701
2998 $LFS setdirstripe -i0 -c2 $striped_dir &
3001 fail mds$((MDTIDX + 1))
3003 wait $CLIENT_PID || error "striped dir creation failed"
3005 striped_dir_check_100 || error "striped dir check failed"
3006 rm -rf $DIR/$tdir || error "rmdir failed"
3008 run_test 100a "DNE: create striped dir, drop update rep from MDT1, 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" &&
3017 local striped_dir=$DIR/$tdir/striped_dir
3020 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
3022 #To make sure MDT1 and MDT0 are connected
3023 #otherwise it may create single stripe dir here
3024 $LFS setdirstripe -i1 $DIR/$tdir/remote_dir
3026 # OBD_FAIL_MDS_REINT_NET_REP 0x119
3027 do_facet mds$MDTIDX lctl set_param fail_loc=0x119
3028 $LFS mkdir -i0 -c2 $striped_dir &
3033 wait $CLIENT_PID || error "striped dir creation failed"
3035 striped_dir_check_100 || error "striped dir check failed"
3036 rm -rf $DIR/$tdir || error "rmdir failed"
3038 run_test 100b "DNE: create striped dir, fail MDT0"
3040 test_101() { #LU-5648
3041 mkdir -p $DIR/$tdir/d1
3042 mkdir -p $DIR/$tdir/d2
3043 touch $DIR/$tdir/file0
3046 replay_barrier $SINGLEMDS
3047 for i in $(seq $num) ; do
3048 echo test$i > $DIR/$tdir/d1/file$i
3051 fail_abort $SINGLEMDS
3052 for i in $(seq $num) ; do
3053 touch $DIR/$tdir/d2/file$i
3054 test -s $DIR/$tdir/d2/file$i &&
3055 ls -al $DIR/$tdir/d2/file$i && error "file$i's size > 0"
3060 run_test 101 "Shouldn't reassign precreated objs to other files after recovery"
3063 check_and_cleanup_lustre