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: 17466 18857 LU-1473
25 ALWAYS_EXCEPT="61d 33a 33b 62 $REPLAY_SINGLE_EXCEPT"
27 # 63 min 7 min AT AT AT AT"
28 [ "$SLOW" = "no" ] && EXCEPT_SLOW="1 2 3 4 6 12 16 44a 44b 65 66 67 68"
30 [ $(facet_fstype $SINGLEMDS) = "zfs" ] &&
31 # bug number for skipped test: LU-1867 LU-3127
32 ALWAYS_EXCEPT="$ALWAYS_EXCEPT 89 73b"
36 check_and_setup_lustre
41 rm -rf $DIR/[df][0-9]* $DIR/f.$TESTSUITE.*
43 # LU-482 Avert LVM and VM inability to flush caches in pre .33 kernels
44 if [ $LINUX_VERSION_CODE -lt $(version_code 2.6.33) ]; then
46 do_facet $SINGLEMDS sync
49 test_0a() { # was test_0
50 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
51 replay_barrier $SINGLEMDS
55 run_test 0a "empty replay"
58 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
60 # this test attempts to trigger a race in the precreation code,
61 # and must run before any other objects are created on the filesystem
63 createmany -o $DIR/$tfile 20 || error "createmany -o $DIR/$tfile failed"
64 unlinkmany $DIR/$tfile 20 || error "unlinkmany $DIR/$tfile failed"
66 run_test 0b "ensure object created after recover exists. (3284)"
69 replay_barrier $SINGLEMDS
72 facet_failover $SINGLEMDS
73 zconf_mount $(hostname) $MOUNT || error "mount fails"
74 client_up || error "post-failover df failed"
75 # file shouldn't exist if replay-barrier works as expected
76 rm $DIR/$tfile && error "File exists and it shouldn't"
79 run_test 0c "check replay-barrier"
82 replay_barrier $SINGLEMDS
84 facet_failover $SINGLEMDS
85 zconf_mount $(hostname) $MOUNT || error "mount fails"
86 client_up || error "post-failover df failed"
88 run_test 0d "expired recovery with no clients"
91 replay_barrier $SINGLEMDS
94 $CHECKSTAT -t file $DIR/$tfile ||
95 error "$CHECKSTAT $DIR/$tfile attribute check failed"
98 run_test 1 "simple create"
101 replay_barrier $SINGLEMDS
104 $CHECKSTAT -t file $DIR/$tfile ||
105 error "$CHECKSTAT $DIR/$tfile attribute check failed"
111 mcreate $DIR/$tfile || error "mcreate $DIR/$tfile failed"
112 replay_barrier $SINGLEMDS
115 $CHECKSTAT -t file $DIR/$tfile ||
116 error "$CHECKSTAT $DIR/$tfile attribute check failed"
122 local file=$DIR/$tfile
123 replay_barrier $SINGLEMDS
125 openfile -f O_DIRECTORY $file
127 $CHECKSTAT -t file $file ||
128 error "$CHECKSTAT $file attribute check failed"
131 run_test 3a "replay failed open(O_DIRECTORY)"
134 replay_barrier $SINGLEMDS
135 #define OBD_FAIL_MDS_OPEN_PACK | OBD_FAIL_ONCE
136 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000114"
138 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
140 $CHECKSTAT -t file $DIR/$tfile &&
141 error "$CHECKSTAT $DIR/$tfile attribute check should fail"
144 run_test 3b "replay failed open -ENOMEM"
147 replay_barrier $SINGLEMDS
148 #define OBD_FAIL_MDS_ALLOC_OBDO | OBD_FAIL_ONCE
149 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000128"
151 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
154 $CHECKSTAT -t file $DIR/$tfile &&
155 error "$CHECKSTAT $DIR/$tfile attribute check should fail"
158 run_test 3c "replay failed open -ENOMEM"
160 test_4a() { # was test_4
161 replay_barrier $SINGLEMDS
162 for i in $(seq 10); do
163 echo "tag-$i" > $DIR/$tfile-$i
166 for i in $(seq 10); do
167 grep -q "tag-$i" $DIR/$tfile-$i || error "$tfile-$i"
170 run_test 4a "|x| 10 open(O_CREAT)s"
173 for i in $(seq 10); do
174 echo "tag-$i" > $DIR/$tfile-$i
176 replay_barrier $SINGLEMDS
179 $CHECKSTAT -t file $DIR/$tfile-* &&
180 error "$CHECKSTAT $DIR/$tfile-* attribute check should fail" ||
183 run_test 4b "|x| rm 10 files"
185 # The idea is to get past the first block of precreated files on both
186 # osts, and then replay.
188 replay_barrier $SINGLEMDS
189 for i in $(seq 220); do
190 echo "tag-$i" > $DIR/$tfile-$i
193 for i in $(seq 220); do
194 grep -q "tag-$i" $DIR/$tfile-$i || error "$tfile-$i"
198 # waiting for commitment of removal
200 run_test 5 "|x| 220 open(O_CREAT)"
202 test_6a() { # was test_6
203 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
204 replay_barrier $SINGLEMDS
205 mcreate $DIR/$tdir/$tfile
207 $CHECKSTAT -t dir $DIR/$tdir ||
208 error "$CHECKSTAT $DIR/$tdir attribute check failed"
209 $CHECKSTAT -t file $DIR/$tdir/$tfile ||
210 error "$CHECKSTAT $DIR/$tdir/$tfile attribute check failed"
212 # waiting for log process thread
214 run_test 6a "mkdir + contained create"
217 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
218 replay_barrier $SINGLEMDS
221 $CHECKSTAT -t dir $DIR/$tdir &&
222 error "$CHECKSTAT $DIR/$tdir attribute check should fail" ||
225 run_test 6b "|X| rmdir"
228 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
229 replay_barrier $SINGLEMDS
230 mcreate $DIR/$tdir/$tfile
232 $CHECKSTAT -t dir $DIR/$tdir ||
233 error "$CHECKSTAT $DIR/$tdir attribute check failed"
234 $CHECKSTAT -t file $DIR/$tdir/$tfile ||
235 error "$CHECKSTAT $DIR/$tdir/$tfile attribute check failed"
238 run_test 7 "mkdir |X| contained create"
241 replay_barrier $SINGLEMDS
242 multiop_bg_pause $DIR/$tfile mo_c ||
243 error "multiop mknod $DIR/$tfile failed"
247 $CHECKSTAT -t file $DIR/$tfile ||
248 error "$CHECKSTAT $DIR/$tfile attribute check failed"
249 kill -USR1 $MULTIPID || error "multiop mknod $MULTIPID not running"
250 wait $MULTIPID || error "multiop mknod $MULTIPID failed"
253 run_test 8 "creat open |X| close"
256 replay_barrier $SINGLEMDS
258 local old_inum=$(ls -i $DIR/$tfile | awk '{print $1}')
260 local new_inum=$(ls -i $DIR/$tfile | awk '{print $1}')
262 echo " old_inum == $old_inum, new_inum == $new_inum"
263 if [ $old_inum -eq $new_inum ] ;
265 echo "old_inum and new_inum match"
267 echo " old_inum and new_inum do not match"
268 error "old index($old_inum) does not match new index($new_inum)"
272 run_test 9 "|X| create (same inum/gen)"
275 mcreate $DIR/$tfile || error "mcreate $DIR/$tfile failed"
276 replay_barrier $SINGLEMDS
277 mv $DIR/$tfile $DIR/$tfile-2
280 $CHECKSTAT $DIR/$tfile &&
281 error "$CHECKSTAT $DIR/$tfile attribute check should fail"
282 $CHECKSTAT $DIR/$tfile-2 ||
283 error "$CHECKSTAT $DIR/$tfile-2 attribute check failed"
287 run_test 10 "create |X| rename unlink"
290 mcreate $DIR/$tfile || error "mcreate $DIR/$tfile failed"
291 echo "old" > $DIR/$tfile
292 mv $DIR/$tfile $DIR/$tfile-2
293 replay_barrier $SINGLEMDS
294 echo "new" > $DIR/$tfile
296 grep old $DIR/$tfile-2
298 grep new $DIR/$tfile || error "grep $DIR/$tfile failed"
299 grep old $DIR/$tfile-2 || error "grep $DIR/$tfile-2 failed"
301 run_test 11 "create open write rename |X| create-old-name read"
304 mcreate $DIR/$tfile || error "mcreate $DIR/$tfile failed"
305 multiop_bg_pause $DIR/$tfile o_tSc ||
306 error "multiop_bg_pause $DIR/$tfile failed"
309 replay_barrier $SINGLEMDS
310 kill -USR1 $pid || error "multiop $pid not running"
311 wait $pid || error "multiop $pid failed"
314 [ -e $DIR/$tfile ] && error "file $DIR/$tfile should not exist"
317 run_test 12 "open, unlink |X| close"
319 # 1777 - replay open after committed chmod that would make
320 # a regular open a failure
322 mcreate $DIR/$tfile || error "mcreate $DIR/$tfile failed"
323 multiop_bg_pause $DIR/$tfile O_wc ||
324 error "multiop_bg_pause $DIR/$tfile failed"
327 $CHECKSTAT -p 0 $DIR/$tfile ||
328 error "$CHECKSTAT $DIR/$tfile attribute check failed"
329 replay_barrier $SINGLEMDS
331 kill -USR1 $pid || error "multiop $pid not running"
332 wait $pid || error "multiop $pid failed"
334 $CHECKSTAT -s 1 -p 0 $DIR/$tfile ||
335 error "second $CHECKSTAT $DIR/$tfile attribute check failed"
336 rm $DIR/$tfile || error "rm $DIR/$tfile failed"
339 run_test 13 "open chmod 0 |x| write close"
342 multiop_bg_pause $DIR/$tfile O_tSc ||
343 error "multiop_bg_pause $DIR/$tfile failed"
346 replay_barrier $SINGLEMDS
347 kill -USR1 $pid || error "multiop $pid not running"
348 wait $pid || error "multiop $pid failed"
351 [ -e $DIR/$tfile ] && error "file $DIR/$tfile should not exist"
354 run_test 14 "open(O_CREAT), unlink |X| close"
357 multiop_bg_pause $DIR/$tfile O_tSc ||
358 error "multiop_bg_pause $DIR/$tfile failed"
361 replay_barrier $SINGLEMDS
362 touch $DIR/$tfile-1 || error "touch $DIR/$tfile-1 failed"
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"
368 touch $DIR/$tfile-2 || error "touch $DIR/$tfile-2 failed"
371 run_test 15 "open(O_CREAT), unlink |X| touch new, close"
374 replay_barrier $SINGLEMDS
377 mcreate $DIR/$tfile-2
379 [ -e $DIR/$tfile ] && error "file $DIR/$tfile should not exist"
380 [ -e $DIR/$tfile-2 ] || error "file $DIR/$tfile-2 does not exist"
381 munlink $DIR/$tfile-2 || error "munlink $DIR/$tfile-2 failed"
383 run_test 16 "|X| open(O_CREAT), unlink, touch new, unlink new"
386 replay_barrier $SINGLEMDS
387 multiop_bg_pause $DIR/$tfile O_c ||
388 error "multiop_bg_pause $DIR/$tfile failed"
391 kill -USR1 $pid || error "multiop $pid not running"
392 wait $pid || error "multiop $pid failed"
393 $CHECKSTAT -t file $DIR/$tfile ||
394 error "$CHECKSTAT $DIR/$tfile attribute check failed"
397 run_test 17 "|X| open(O_CREAT), |replay| close"
400 replay_barrier $SINGLEMDS
401 multiop_bg_pause $DIR/$tfile O_tSc ||
402 error "multiop_bg_pause $DIR/$tfile failed"
405 touch $DIR/$tfile-2 || error "touch $DIR/$tfile-2 failed"
406 echo "pid: $pid will close"
407 kill -USR1 $pid || error "multiop $pid not running"
408 wait $pid || error "multiop $pid failed"
411 [ -e $DIR/$tfile ] && error "file $DIR/$tfile should not exist"
412 [ -e $DIR/$tfile-2 ] || error "file $DIR/$tfile-2 does not exist"
413 # this touch frequently fails
414 touch $DIR/$tfile-3 || error "touch $DIR/$tfile-3 failed"
415 munlink $DIR/$tfile-2 || error "munlink $DIR/$tfile-2 failed"
416 munlink $DIR/$tfile-3 || error "munlink $DIR/$tfile-3 failed"
419 run_test 18 "open(O_CREAT), unlink, touch new, close, touch, unlink"
421 # bug 1855 (a simpler form of test_11 above)
423 replay_barrier $SINGLEMDS
425 echo "old" > $DIR/$tfile
426 mv $DIR/$tfile $DIR/$tfile-2
427 grep old $DIR/$tfile-2
429 grep old $DIR/$tfile-2 || error "grep $DIR/$tfile-2 failed"
431 run_test 19 "mcreate, open, write, rename "
433 test_20a() { # was test_20
434 replay_barrier $SINGLEMDS
435 multiop_bg_pause $DIR/$tfile O_tSc ||
436 error "multiop_bg_pause $DIR/$tfile failed"
441 kill -USR1 $pid || error "multiop $pid not running"
442 wait $pid || error "multiop $pid failed"
443 [ -e $DIR/$tfile ] && error "file $DIR/$tfile should not exist"
446 run_test 20a "|X| open(O_CREAT), unlink, replay, close (test mds_cleanup_orphans)"
448 test_20b() { # bug 10480
449 local wait_timeout=$((TIMEOUT * 4))
453 BEFOREUSED=$(df -P $DIR | tail -1 | awk '{ print $3 }')
454 dd if=/dev/zero of=$DIR/$tfile bs=4k count=10000 &
455 while [ ! -e $DIR/$tfile ] ; do
456 usleep 60 # give dd a chance to start
459 $GETSTRIPE $DIR/$tfile || error "$GETSTRIPE $DIR/$tfile failed"
461 rm -f $DIR/$tfile || error "rm -f $DIR/$tfile failed"
463 client_up || client_up || true # reconnect
465 do_facet $SINGLEMDS "lctl set_param -n osd*.*MDT*.force_sync 1"
467 fail $SINGLEMDS # start orphan recovery
468 wait_recovery_complete $SINGLEMDS || error "MDS recovery not done"
469 wait_delete_completed_mds $wait_timeout ||
470 error "delete did not complete"
472 AFTERUSED=$(df -P $DIR | tail -1 | awk '{ print $3 }')
473 log "before $BEFOREUSED, after $AFTERUSED"
474 (( $AFTERUSED > $BEFOREUSED + $(fs_log_size) )) &&
475 error "after $AFTERUSED > before $BEFOREUSED"
478 run_test 20b "write, unlink, eviction, replay, (test mds_cleanup_orphans)"
480 test_20c() { # bug 10480
481 multiop_bg_pause $DIR/$tfile Ow_c ||
482 error "multiop_bg_pause $DIR/$tfile failed"
488 client_up || client_up || true # reconnect
490 kill -USR1 $pid || error "multiop $pid not running"
491 wait $pid || error "multiop $pid failed"
492 [ -s $DIR/$tfile ] || error "File was truncated"
496 run_test 20c "check that client eviction does not affect file content"
499 replay_barrier $SINGLEMDS
500 multiop_bg_pause $DIR/$tfile O_tSc ||
501 error "multiop_bg_pause $DIR/$tfile failed"
504 touch $DIR/$tfile-1 || error "touch $DIR/$tfile-1 failed"
507 kill -USR1 $pid || error "multiop $pid not running"
508 wait $pid || error "multiop $pid failed"
509 [ -e $DIR/$tfile ] && error "file $DIR/$tfile should not exist"
510 touch $DIR/$tfile-2 || error "touch $DIR/$tfile-2 failed"
513 run_test 21 "|X| open(O_CREAT), unlink touch new, replay, close (test mds_cleanup_orphans)"
516 multiop_bg_pause $DIR/$tfile O_tSc ||
517 error "multiop_bg_pause $DIR/$tfile failed"
520 replay_barrier $SINGLEMDS
524 kill -USR1 $pid || error "multiop $pid not running"
525 wait $pid || error "multiop $pid failed"
526 [ -e $DIR/$tfile ] && error "file $DIR/$tfile should not exist"
529 run_test 22 "open(O_CREAT), |X| unlink, replay, close (test mds_cleanup_orphans)"
532 multiop_bg_pause $DIR/$tfile O_tSc ||
533 error "multiop_bg_pause $DIR/$tfile failed"
536 replay_barrier $SINGLEMDS
538 touch $DIR/$tfile-1 || error "touch $DIR/$tfile-1 failed"
541 kill -USR1 $pid || error "multiop $pid not running"
542 wait $pid || error "multiop $pid failed"
543 [ -e $DIR/$tfile ] && error "file $DIR/$tfile should not exist"
544 touch $DIR/$tfile-2 || error "touch $DIR/$tfile-2 failed"
547 run_test 23 "open(O_CREAT), |X| unlink touch new, replay, close (test mds_cleanup_orphans)"
550 multiop_bg_pause $DIR/$tfile O_tSc ||
551 error "multiop_bg_pause $DIR/$tfile failed"
554 replay_barrier $SINGLEMDS
557 kill -USR1 $pid || error "multiop $pid not running"
558 wait $pid || error "multiop $pid failed"
559 [ -e $DIR/$tfile ] && error "file $DIR/$tfile should not exist"
562 run_test 24 "open(O_CREAT), replay, unlink, close (test mds_cleanup_orphans)"
565 multiop_bg_pause $DIR/$tfile O_tSc ||
566 error "multiop_bg_pause $DIR/$tfile failed"
570 replay_barrier $SINGLEMDS
572 kill -USR1 $pid || error "multiop $pid not running"
573 wait $pid || error "multiop $pid failed"
574 [ -e $DIR/$tfile ] && error "file $DIR/$tfile should not exist"
577 run_test 25 "open(O_CREAT), unlink, replay, close (test mds_cleanup_orphans)"
580 replay_barrier $SINGLEMDS
581 multiop_bg_pause $DIR/$tfile-1 O_tSc ||
582 error "multiop_bg_pause $DIR/$tfile-1 failed"
584 multiop_bg_pause $DIR/$tfile-2 O_tSc ||
585 error "multiop_bg_pause $DIR/$tfile-2 failed"
589 kill -USR1 $pid2 || error "second multiop $pid2 not running"
590 wait $pid2 || error "second multiop $pid2 failed"
593 kill -USR1 $pid1 || error "multiop $pid1 not running"
594 wait $pid1 || error "multiop $pid1 failed"
595 [ -e $DIR/$tfile-1 ] && error "file $DIR/$tfile-1 should not exist"
596 [ -e $DIR/$tfile-2 ] && error "file $DIR/$tfile-2 should not exist"
599 run_test 26 "|X| open(O_CREAT), unlink two, close one, replay, close one (test mds_cleanup_orphans)"
602 replay_barrier $SINGLEMDS
603 multiop_bg_pause $DIR/$tfile-1 O_tSc ||
604 error "multiop_bg_pause $DIR/$tfile-1 failed"
606 multiop_bg_pause $DIR/$tfile-2 O_tSc ||
607 error "multiop_bg_pause $DIR/$tfile-2 failed"
613 kill -USR1 $pid1 || error "multiop $pid1 not running"
614 wait $pid1 || error "multiop $pid1 failed"
615 kill -USR1 $pid2 || error "second multiop $pid2 not running"
616 wait $pid2 || error "second multiop $pid2 failed"
617 [ -e $DIR/$tfile-1 ] && error "file $DIR/$tfile-1 should not exist"
618 [ -e $DIR/$tfile-2 ] && error "file $DIR/$tfile-2 should not exist"
621 run_test 27 "|X| open(O_CREAT), unlink two, replay, close two (test mds_cleanup_orphans)"
624 multiop_bg_pause $DIR/$tfile-1 O_tSc ||
625 error "multiop_bg_pause $DIR/$tfile-1 failed"
627 multiop_bg_pause $DIR/$tfile-2 O_tSc ||
628 error "multiop_bg_pause $DIR/$tfile-2 failed"
630 replay_barrier $SINGLEMDS
633 kill -USR1 $pid2 || error "second multiop $pid2 not running"
634 wait $pid2 || error "second multiop $pid2 failed"
637 kill -USR1 $pid1 || error "multiop $pid1 not running"
638 wait $pid1 || error "multiop $pid1 failed"
639 [ -e $DIR/$tfile-1 ] && error "file $DIR/$tfile-1 should not exist"
640 [ -e $DIR/$tfile-2 ] && error "file $DIR/$tfile-2 should not exist"
643 run_test 28 "open(O_CREAT), |X| unlink two, close one, replay, close one (test mds_cleanup_orphans)"
646 multiop_bg_pause $DIR/$tfile-1 O_tSc ||
647 error "multiop_bg_pause $DIR/$tfile-1 failed"
649 multiop_bg_pause $DIR/$tfile-2 O_tSc ||
650 error "multiop_bg_pause $DIR/$tfile-2 failed"
652 replay_barrier $SINGLEMDS
657 kill -USR1 $pid1 || error "multiop $pid1 not running"
658 wait $pid1 || error "multiop $pid1 failed"
659 kill -USR1 $pid2 || error "second multiop $pid2 not running"
660 wait $pid2 || error "second multiop $pid2 failed"
661 [ -e $DIR/$tfile-1 ] && error "file $DIR/$tfile-1 should not exist"
662 [ -e $DIR/$tfile-2 ] && error "file $DIR/$tfile-2 should not exist"
665 run_test 29 "open(O_CREAT), |X| unlink two, replay, close two (test mds_cleanup_orphans)"
668 multiop_bg_pause $DIR/$tfile-1 O_tSc ||
669 error "multiop_bg_pause $DIR/$tfile-1 failed"
671 multiop_bg_pause $DIR/$tfile-2 O_tSc ||
672 error "multiop_bg_pause $DIR/$tfile-2 failed"
677 replay_barrier $SINGLEMDS
679 kill -USR1 $pid1 || error "multiop $pid1 not running"
680 wait $pid1 || error "multiop $pid1 failed"
681 kill -USR1 $pid2 || error "second multiop $pid2 not running"
682 wait $pid2 || error "second multiop $pid2 failed"
683 [ -e $DIR/$tfile-1 ] && error "file $DIR/$tfile-1 should not exist"
684 [ -e $DIR/$tfile-2 ] && error "file $DIR/$tfile-2 should not exist"
687 run_test 30 "open(O_CREAT) two, unlink two, replay, close two (test mds_cleanup_orphans)"
690 multiop_bg_pause $DIR/$tfile-1 O_tSc ||
691 error "multiop_bg_pause $DIR/$tfile-1 failed"
693 multiop_bg_pause $DIR/$tfile-2 O_tSc ||
694 error "multiop_bg_pause $DIR/$tfile-2 failed"
698 replay_barrier $SINGLEMDS
701 kill -USR1 $pid1 || error "multiop $pid1 not running"
702 wait $pid1 || error "multiop $pid1 failed"
703 kill -USR1 $pid2 || error "second multiop $pid2 not running"
704 wait $pid2 || error "second multiop $pid2 failed"
705 [ -e $DIR/$tfile-1 ] && error "file $DIR/$tfile-1 should not exist"
706 [ -e $DIR/$tfile-2 ] && error "file $DIR/$tfile-2 should not exist"
709 run_test 31 "open(O_CREAT) two, unlink one, |X| unlink one, close two (test mds_cleanup_orphans)"
711 # tests for bug 2104; completion without crashing is success. The close is
712 # stale, but we always return 0 for close, so the app never sees it.
714 multiop_bg_pause $DIR/$tfile O_c ||
715 error "multiop_bg_pause $DIR/$tfile failed"
717 multiop_bg_pause $DIR/$tfile O_c ||
718 error "second multiop_bg_pause $DIR/$tfile failed"
721 client_up || client_up || error "client_up failed"
722 kill -USR1 $pid1 || error "multiop $pid1 not running"
723 kill -USR1 $pid2 || error "second multiop $pid2 not running"
724 wait $pid1 || error "multiop $pid1 failed"
725 wait $pid2 || error "second multiop $pid2 failed"
728 run_test 32 "close() notices client eviction; close() after client eviction"
731 createmany -o $DIR/$tfile-%d 10 ||
732 error "createmany create $DIR/$tfile failed"
733 replay_barrier_nosync $SINGLEMDS
734 fail_abort $SINGLEMDS
735 # recreate shouldn't fail
736 createmany -o $DIR/$tfile--%d 10 ||
737 error "createmany recreate $DIR/$tfile failed"
741 run_test 33a "fid seq shouldn't be reused after abort recovery"
744 #define OBD_FAIL_SEQ_ALLOC 0x1311
745 do_facet $SINGLEMDS "lctl set_param fail_loc=0x1311"
747 createmany -o $DIR/$tfile-%d 10
748 replay_barrier_nosync $SINGLEMDS
749 fail_abort $SINGLEMDS
750 # recreate shouldn't fail
751 createmany -o $DIR/$tfile--%d 10 ||
752 error "createmany recreate $DIR/$tfile failed"
756 run_test 33b "test fid seq allocation"
759 multiop_bg_pause $DIR/$tfile O_c ||
760 error "multiop_bg_pause $DIR/$tfile failed"
764 replay_barrier $SINGLEMDS
765 fail_abort $SINGLEMDS
766 kill -USR1 $pid || error "multiop $pid not running"
767 wait $pid || error "multiop $pid failed"
768 [ -e $DIR/$tfile ] && error "file $DIR/$tfile should not exist"
772 run_test 34 "abort recovery before client does replay (test mds_cleanup_orphans)"
774 # bug 2278 - generate one orphan on OST, then destroy it during recovery from llog
776 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
778 #define OBD_FAIL_MDS_REINT_NET_REP 0x119
779 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000119"
784 # give a chance to remove from MDS
785 fail_abort $SINGLEMDS
786 $CHECKSTAT -t file $DIR/$tfile &&
787 error "$CHECKSTAT $DIR/$tfile attribute check should fail" ||
790 run_test 35 "test recovery from llog for unlink op"
792 # b=2432 resent cancel after replay uses wrong cookie,
793 # so don't resend cancels
795 replay_barrier $SINGLEMDS
797 checkstat $DIR/$tfile
798 facet_failover $SINGLEMDS
800 if dmesg | grep "unknown lock cookie"; then
801 error "cancel after replay failed"
804 run_test 36 "don't resend cancel"
807 # directory orphans can't be unlinked from PENDING directory
809 rmdir $DIR/$tfile 2>/dev/null
810 multiop_bg_pause $DIR/$tfile dD_c ||
811 error "multiop_bg_pause $DIR/$tfile failed"
815 replay_barrier $SINGLEMDS
816 # clear the dmesg buffer so we only see errors from this recovery
817 do_facet $SINGLEMDS dmesg -c >/dev/null
818 fail_abort $SINGLEMDS
819 kill -USR1 $pid || error "multiop $pid not running"
820 do_facet $SINGLEMDS dmesg | grep "error .* unlinking .* from PENDING" &&
821 error "error unlinking files"
822 wait $pid || error "multiop $pid failed"
826 run_test 37 "abort recovery before client does replay (test mds_cleanup_orphans for directories)"
829 createmany -o $DIR/$tfile-%d 800 ||
830 error "createmany -o $DIR/$tfile failed"
831 unlinkmany $DIR/$tfile-%d 0 400 || error "unlinkmany $DIR/$tfile failed"
832 replay_barrier $SINGLEMDS
834 unlinkmany $DIR/$tfile-%d 400 400 ||
835 error "unlinkmany $DIR/$tfile 400 failed"
837 $CHECKSTAT -t file $DIR/$tfile-* &&
838 error "$CHECKSTAT $DIR/$tfile-* attribute check should fail" ||
841 run_test 38 "test recovery from unlink llog (test llog_gen_rec) "
843 test_39() { # bug 4176
844 createmany -o $DIR/$tfile-%d 800 ||
845 error "createmany -o $DIR/$tfile failed"
846 replay_barrier $SINGLEMDS
847 unlinkmany $DIR/$tfile-%d 0 400
849 unlinkmany $DIR/$tfile-%d 400 400 ||
850 error "unlinkmany $DIR/$tfile 400 failed"
852 $CHECKSTAT -t file $DIR/$tfile-* &&
853 error "$CHECKSTAT $DIR/$tfile-* attribute check should fail" ||
856 run_test 39 "test recovery from unlink llog (test llog_gen_rec) "
859 lctl get_param -n osc.*.stats | awk -vwrites=0 '/ost_write/ { writes += $2 } END { print writes; }'
864 # always need connection to MDS to verify layout during IO. LU-2628.
865 lctl get_param mdc.*.connect_flags | grep -q layout_lock &&
866 skip "layout_lock needs MDS connection for IO" && return 0
868 $LCTL mark multiop $MOUNT/$tfile OS_c
869 multiop $MOUNT/$tfile OS_c &
871 writeme -s $MOUNT/${tfile}-2 &
874 facet_failover $SINGLEMDS
875 #define OBD_FAIL_MDS_CONNECT_NET 0x117
876 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000117"
878 stat1=$(count_ost_writes)
880 stat2=$(count_ost_writes)
881 echo "$stat1, $stat2"
882 if [ $stat1 -lt $stat2 ]; then
883 echo "writes continuing during recovery"
886 echo "writes not continuing during recovery, bug 2477"
889 echo "waiting for writeme $WRITE_PID"
893 echo "waiting for multiop $PID"
894 wait $PID || error "multiop $PID failed"
895 do_facet client munlink $MOUNT/$tfile ||
896 error "munlink $MOUNT/$tfile failed"
897 do_facet client munlink $MOUNT/${tfile}-2 ||
898 error "munlink $MOUNT/$tfile-2 failed"
901 run_test 40 "cause recovery in ptlrpc, ensure IO continues"
904 # make sure that a read to one osc doesn't try to double-unlock its page just
905 # because another osc is invalid. trigger_group_io used to mistakenly return
906 # an error if any oscs were invalid even after having successfully put rpcs
907 # on valid oscs. This was fatal if the caller was ll_readpage who unlocked
908 # the page, guarnateeing that the unlock from the RPC completion would
909 # assert on trying to unlock the unlocked page.
911 [ $OSTCOUNT -lt 2 ] &&
912 skip_env "skipping test 41: we don't have a second OST to test with" &&
915 local f=$MOUNT/$tfile
916 # make sure the start of the file is ost1
917 $SETSTRIPE -S $((128 * 1024)) -i 0 $f
918 do_facet client dd if=/dev/zero of=$f bs=4k count=1 ||
919 error "dd on client failed"
921 # fail ost2 and read from ost1
922 local mdtosc=$(get_mdtosc_proc_path $SINGLEMDS $ost2_svc)
923 local osc2dev=$(do_facet $SINGLEMDS "lctl get_param -n devices" |
924 grep $mdtosc | awk '{print $1}')
925 [ -z "$osc2dev" ] && echo "OST: $ost2_svc" &&
926 lctl get_param -n devices &&
927 error "OST 2 $osc2dev does not exist"
928 do_facet $SINGLEMDS $LCTL --device $osc2dev deactivate ||
929 error "deactive device on $SINGLEMDS failed"
930 do_facet client dd if=$f of=/dev/null bs=4k count=1 ||
931 error "second dd on client failed"
932 do_facet $SINGLEMDS $LCTL --device $osc2dev activate ||
933 error "active device on $SINGLEMDS failed"
936 run_test 41 "read from a valid osc while other oscs are invalid"
938 # test MDS recovery after ost failure
940 blocks=$(df -P $MOUNT | tail -n 1 | awk '{ print $2 }')
941 createmany -o $DIR/$tfile-%d 800 ||
942 error "createmany -o $DIR/$tfile failed"
944 unlinkmany $DIR/$tfile-%d 0 400
946 lctl set_param debug=-1
949 # osc is evicted, fs is smaller (but only with failout OSTs (bug 7287)
950 #blocks_after=`df -P $MOUNT | tail -n 1 | awk '{ print $2 }'`
951 #[ $blocks_after -lt $blocks ] || return 1
952 echo "wait for MDS to timeout and recover"
953 sleep $((TIMEOUT * 2))
955 unlinkmany $DIR/$tfile-%d 400 400 ||
956 error "unlinkmany $DIR/$tfile 400 failed"
957 $CHECKSTAT -t file $DIR/$tfile-* &&
958 error "$CHECKSTAT $DIR/$tfile-* attribute check should fail" ||
961 run_test 42 "recovery after ost failure"
963 # timeout in MDS/OST recovery RPC will LBUG MDS
964 test_43() { # bug 2530
965 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
967 replay_barrier $SINGLEMDS
969 # OBD_FAIL_OST_CREATE_NET 0x204
970 do_facet ost1 "lctl set_param fail_loc=0x80000204"
976 run_test 43 "mds osc import failure during recovery; don't LBUG"
978 test_44a() { # was test_44
981 local mdcdev=$($LCTL dl |
982 awk "/${FSNAME}-MDT0000-mdc-/ {if (\$2 == \"UP\") {print \$1}}")
983 [ "$mdcdev" ] || error "${FSNAME}-MDT0000-mdc- not UP"
984 [ $(echo $mdcdev | wc -w) -eq 1 ] ||
985 { $LCTL dl; error "looking for mdcdev=$mdcdev"; }
987 # adaptive timeouts slow this way down
988 if at_is_enabled; then
989 at_max_saved=$(at_max_get mds)
993 for i in $(seq 1 10); do
994 echo "$i of 10 ($(date +%s))"
995 do_facet $SINGLEMDS \
996 "lctl get_param -n md[ts].*.mdt.timeouts | grep service"
997 #define OBD_FAIL_TGT_CONN_RACE 0x701
998 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000701"
999 # lctl below may fail, it is valid case
1000 $LCTL --device $mdcdev recover
1003 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
1004 [ $at_max_saved -ne 0 ] && at_max_set $at_max_saved mds
1007 run_test 44a "race in target handle connect"
1010 local mdcdev=$($LCTL dl |
1011 awk "/${FSNAME}-MDT0000-mdc-/ {if (\$2 == \"UP\") {print \$1}}")
1012 [ "$mdcdev" ] || error "${FSNAME}-MDT0000-mdc not up"
1013 [ $(echo $mdcdev | wc -w) -eq 1 ] ||
1014 { echo mdcdev=$mdcdev; $LCTL dl;
1015 error "more than one ${FSNAME}-MDT0000-mdc"; }
1017 for i in $(seq 1 10); do
1018 echo "$i of 10 ($(date +%s))"
1019 do_facet $SINGLEMDS \
1020 "lctl get_param -n md[ts].*.mdt.timeouts | grep service"
1021 #define OBD_FAIL_TGT_DELAY_RECONNECT 0x704
1022 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000704"
1023 # lctl below may fail, it is valid case
1024 $LCTL --device $mdcdev recover
1029 run_test 44b "race in target handle connect"
1032 replay_barrier $SINGLEMDS
1033 createmany -m $DIR/$tfile-%d 100 || error "failed to create directories"
1034 #define OBD_FAIL_TGT_RCVG_FLAG 0x712
1035 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000712"
1036 fail_abort $SINGLEMDS
1037 unlinkmany $DIR/$tfile-%d 100 && error "unliked after fail abort"
1039 unlinkmany $DIR/$tfile-%d 100 && error "unliked after fail"
1042 run_test 44c "race in target handle connect"
1044 # Handle failed close
1046 local mdcdev=$($LCTL get_param -n devices |
1047 awk "/ ${FSNAME}-MDT0000-mdc-/ {print \$1}")
1048 [ "$mdcdev" ] || error "${FSNAME}-MDT0000-mdc not up"
1049 [ $(echo $mdcdev | wc -w) -eq 1 ] ||
1050 { echo mdcdev=$mdcdev; $LCTL dl;
1051 error "more than one ${FSNAME}-MDT0000-mdc"; }
1053 $LCTL --device $mdcdev recover ||
1054 error "$LCTL --device $mdcdev recover failed"
1056 multiop_bg_pause $DIR/$tfile O_c ||
1057 error "multiop_bg_pause $DIR/$tfile failed"
1060 # This will cause the CLOSE to fail before even
1061 # allocating a reply buffer
1062 $LCTL --device $mdcdev deactivate ||
1063 error "$LCTL --device $mdcdev deactivate failed"
1066 kill -USR1 $pid || error "multiop $pid not running"
1067 wait $pid || error "multiop $pid failed"
1069 $LCTL --device $mdcdev activate ||
1070 error "$LCTL --device $mdcdev activate failed"
1073 $CHECKSTAT -t file $DIR/$tfile ||
1074 error "$CHECKSTAT $DIR/$tfile attribute check failed"
1077 run_test 45 "Handle failed close"
1081 drop_reply "touch $DIR/$tfile"
1083 # ironically, the previous test, 45, will cause a real forced close,
1084 # so just look for one for this test
1085 dmesg | grep -i "force closing client file handle for $tfile" &&
1086 error "found force closing in dmesg"
1089 run_test 46 "Don't leak file handle after open resend (3325)"
1091 test_47() { # bug 2824
1092 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1094 # create some files to make sure precreate has been done on all
1095 # OSTs. (just in case this test is run independently)
1096 createmany -o $DIR/$tfile 20 ||
1097 error "createmany create $DIR/$tfile failed"
1099 # OBD_FAIL_OST_CREATE_NET 0x204
1101 do_facet ost1 "lctl set_param fail_loc=0x80000204"
1102 client_up || error "client_up failed"
1104 # let the MDS discover the OST failure, attempt to recover, fail
1105 # and recover again.
1106 sleep $((3 * TIMEOUT))
1108 # Without 2824, this createmany would hang
1109 createmany -o $DIR/$tfile 20 ||
1110 error "createmany recraete $DIR/$tfile failed"
1111 unlinkmany $DIR/$tfile 20 || error "unlinkmany $DIR/$tfile failed"
1115 run_test 47 "MDS->OSC failure during precreate cleanup (2824)"
1118 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1119 [ "$OSTCOUNT" -lt "2" ] &&
1120 skip_env "$OSTCOUNT < 2 OSTs -- skipping" && return
1122 replay_barrier $SINGLEMDS
1123 createmany -o $DIR/$tfile 20 ||
1124 error "createmany -o $DIR/$tfile failed"
1125 # OBD_FAIL_OST_EROFS 0x216
1126 facet_failover $SINGLEMDS
1127 do_facet ost1 "lctl set_param fail_loc=0x80000216"
1128 client_up || error "client_up failed"
1130 createmany -o $DIR/$tfile 20 20 ||
1131 error "createmany recraete $DIR/$tfile failed"
1132 unlinkmany $DIR/$tfile 40 || error "unlinkmany $DIR/$tfile failed"
1135 run_test 48 "MDS->OSC failure during precreate cleanup (2824)"
1138 local mdtosc=$(get_mdtosc_proc_path $SINGLEMDS $ost1_svc)
1139 local oscdev=$(do_facet $SINGLEMDS "lctl get_param -n devices" |
1140 grep $mdtosc | awk '{print $1}')
1141 [ "$oscdev" ] || error "could not find OSC device on MDS"
1142 do_facet $SINGLEMDS $LCTL --device $oscdev recover ||
1143 error "OSC device $oscdev recovery failed"
1144 do_facet $SINGLEMDS $LCTL --device $oscdev recover ||
1145 error "second OSC device $oscdev recovery failed"
1146 # give the mds_lov_sync threads a chance to run
1149 run_test 50 "Double OSC recovery, don't LASSERT (3812)"
1151 # b3764 timed out lock replay
1153 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.6.90) ] &&
1154 skip "MDS prior to 2.6.90 handle LDLM_REPLY_NET incorrectly" &&
1157 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
1158 cancel_lru_locks mdc
1160 multiop_bg_pause $DIR/$tfile s_s || error "multiop $DIR/$tfile failed"
1163 #define OBD_FAIL_MDS_LDLM_REPLY_NET 0x157
1164 lctl set_param -n ldlm.cancel_unused_locks_before_replay "0"
1165 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000157"
1167 fail $SINGLEMDS || error "fail $SINGLEMDS failed"
1169 wait $mpid || error "multiop_bg_pause pid failed"
1171 do_facet $SINGLEMDS "lctl set_param fail_loc=0x0"
1172 lctl set_param fail_loc=0x0
1173 lctl set_param -n ldlm.cancel_unused_locks_before_replay "1"
1176 run_test 52 "time out lock replay (3764)"
1178 # bug 3462 - simultaneous MDC requests
1180 cancel_lru_locks mdc # cleanup locks from former test cases
1181 mkdir $DIR/${tdir}-1 || error "mkdir $DIR/${tdir}-1 failed"
1182 mkdir $DIR/${tdir}-2 || error "mkdir $DIR/${tdir}-2 failed"
1183 multiop $DIR/${tdir}-1/f O_c &
1185 # give multiop a change to open
1188 #define OBD_FAIL_MDS_CLOSE_NET 0x115
1189 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000115"
1190 kill -USR1 $close_pid
1191 cancel_lru_locks mdc # force the close
1192 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
1194 mcreate $DIR/${tdir}-2/f || error "mcreate $DIR/${tdir}-2/f failed"
1196 # close should still be here
1197 [ -d /proc/$close_pid ] || error "close_pid doesn't exist"
1199 replay_barrier_nodf $SINGLEMDS
1201 wait $close_pid || error "close_pid $close_pid failed"
1203 $CHECKSTAT -t file $DIR/${tdir}-1/f ||
1204 error "$CHECKSTAT $DIR/${tdir}-1/f attribute check failed"
1205 $CHECKSTAT -t file $DIR/${tdir}-2/f ||
1206 error "$CHECKSTAT $DIR/${tdir}-2/f attribute check failed"
1207 rm -rf $DIR/${tdir}-*
1209 run_test 53a "|X| close request while two MDC requests in flight"
1212 cancel_lru_locks mdc # cleanup locks from former test cases
1214 mkdir $DIR/${tdir}-1 || error "mkdir $DIR/${tdir}-1 failed"
1215 mkdir $DIR/${tdir}-2 || error "mkdir $DIR/${tdir}-2 failed"
1216 multiop_bg_pause $DIR/${tdir}-1/f O_c ||
1217 error "multiop_bg_pause $DIR/${tdir}-1/f failed"
1220 #define OBD_FAIL_MDS_REINT_NET 0x107
1221 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000107"
1222 mcreate $DIR/${tdir}-2/f &
1226 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
1227 kill -USR1 $close_pid
1228 cancel_lru_locks mdc # force the close
1229 wait $close_pid || error "close_pid $close_pid failed"
1230 # open should still be here
1231 [ -d /proc/$open_pid ] || error "open_pid doesn't exist"
1233 replay_barrier_nodf $SINGLEMDS
1235 wait $open_pid || error "open_pid failed"
1237 $CHECKSTAT -t file $DIR/${tdir}-1/f ||
1238 error "$CHECKSTAT $DIR/${tdir}-1/f attribute check failed"
1239 $CHECKSTAT -t file $DIR/${tdir}-2/f ||
1240 error "$CHECKSTAT $DIR/${tdir}-2/f attribute check failed"
1241 rm -rf $DIR/${tdir}-*
1243 run_test 53b "|X| open request while two MDC requests in flight"
1246 cancel_lru_locks mdc # cleanup locks from former test cases
1248 mkdir $DIR/${tdir}-1 || error "mkdir $DIR/${tdir}-1 failed"
1249 mkdir $DIR/${tdir}-2 || error "mkdir $DIR/${tdir}-2 failed"
1250 multiop $DIR/${tdir}-1/f O_c &
1253 #define OBD_FAIL_MDS_REINT_NET 0x107
1254 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000107"
1255 mcreate $DIR/${tdir}-2/f &
1259 #define OBD_FAIL_MDS_CLOSE_NET 0x115
1260 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000115"
1261 kill -USR1 $close_pid
1262 cancel_lru_locks mdc # force the close
1264 #bz20647: make sure all pids exist before failover
1265 [ -d /proc/$close_pid ] || error "close_pid doesn't exist"
1266 [ -d /proc/$open_pid ] || error "open_pid doesn't exists"
1267 replay_barrier_nodf $SINGLEMDS
1268 fail_nodf $SINGLEMDS
1269 wait $open_pid || error "open_pid failed"
1271 # close should be gone
1272 [ -d /proc/$close_pid ] && error "close_pid should not exist"
1273 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
1275 $CHECKSTAT -t file $DIR/${tdir}-1/f ||
1276 error "$CHECKSTAT $DIR/${tdir}-1/f attribute check failed"
1277 $CHECKSTAT -t file $DIR/${tdir}-2/f ||
1278 error "$CHECKSTAT $DIR/${tdir}-2/f attribute check failed"
1279 rm -rf $DIR/${tdir}-*
1281 run_test 53c "|X| open request and close request while two MDC requests in flight"
1284 cancel_lru_locks mdc # cleanup locks from former test cases
1286 mkdir $DIR/${tdir}-1 || error "mkdir $DIR/${tdir}-1 failed"
1287 mkdir $DIR/${tdir}-2 || error "mkdir $DIR/${tdir}-2 failed"
1288 multiop $DIR/${tdir}-1/f O_c &
1290 # give multiop a chance to open
1293 #define OBD_FAIL_MDS_CLOSE_NET_REP 0x13b
1294 do_facet $SINGLEMDS "lctl set_param fail_loc=0x8000013b"
1295 kill -USR1 $close_pid
1296 cancel_lru_locks mdc # force the close
1297 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
1298 mcreate $DIR/${tdir}-2/f || error "mcreate $DIR/${tdir}-2/f failed"
1300 # close should still be here
1301 [ -d /proc/$close_pid ] || error "close_pid doesn't exist"
1303 wait $close_pid || error "close_pid failed"
1305 $CHECKSTAT -t file $DIR/${tdir}-1/f ||
1306 error "$CHECKSTAT $DIR/${tdir}-1/f attribute check failed"
1307 $CHECKSTAT -t file $DIR/${tdir}-2/f ||
1308 error "$CHECKSTAT $DIR/${tdir}-2/f attribute check failed"
1309 rm -rf $DIR/${tdir}-*
1311 run_test 53d "close reply while two MDC requests in flight"
1314 cancel_lru_locks mdc # cleanup locks from former test cases
1316 mkdir $DIR/${tdir}-1 || error "mkdir $DIR/${tdir}-1 failed"
1317 mkdir $DIR/${tdir}-2 || error "mkdir $DIR/${tdir}-2 failed"
1318 multiop $DIR/${tdir}-1/f O_c &
1321 #define OBD_FAIL_MDS_REINT_NET_REP 0x119
1322 do_facet $SINGLEMDS "lctl set_param fail_loc=0x119"
1323 mcreate $DIR/${tdir}-2/f &
1327 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
1328 kill -USR1 $close_pid
1329 cancel_lru_locks mdc # force the close
1330 wait $close_pid || error "close_pid failed"
1331 # open should still be here
1332 [ -d /proc/$open_pid ] || error "open_pid doesn't exists"
1334 replay_barrier_nodf $SINGLEMDS
1336 wait $open_pid || error "open_pid failed"
1338 $CHECKSTAT -t file $DIR/${tdir}-1/f ||
1339 error "$CHECKSTAT $DIR/${tdir}-1/f attribute check failed"
1340 $CHECKSTAT -t file $DIR/${tdir}-2/f ||
1341 error "$CHECKSTAT $DIR/${tdir}-2/f attribute check failed"
1342 rm -rf $DIR/${tdir}-*
1344 run_test 53e "|X| open reply while two MDC requests in flight"
1347 cancel_lru_locks mdc # cleanup locks from former test cases
1349 mkdir $DIR/${tdir}-1 || error "mkdir $DIR/${tdir}-1 failed"
1350 mkdir $DIR/${tdir}-2 || error "mkdir $DIR/${tdir}-2 failed"
1351 multiop $DIR/${tdir}-1/f O_c &
1354 #define OBD_FAIL_MDS_REINT_NET_REP 0x119
1355 do_facet $SINGLEMDS "lctl set_param fail_loc=0x119"
1356 mcreate $DIR/${tdir}-2/f &
1360 #define OBD_FAIL_MDS_CLOSE_NET_REP 0x13b
1361 do_facet $SINGLEMDS "lctl set_param fail_loc=0x8000013b"
1362 kill -USR1 $close_pid
1363 cancel_lru_locks mdc # force the close
1365 #bz20647: make sure all pids are exists before failover
1366 [ -d /proc/$close_pid ] || error "close_pid doesn't exist"
1367 [ -d /proc/$open_pid ] || error "open_pid doesn't exists"
1368 replay_barrier_nodf $SINGLEMDS
1369 fail_nodf $SINGLEMDS
1370 wait $open_pid || error "open_pid failed"
1372 # close should be gone
1373 [ -d /proc/$close_pid ] && error "close_pid should not exist"
1374 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
1376 $CHECKSTAT -t file $DIR/${tdir}-1/f ||
1377 error "$CHECKSTAT $DIR/${tdir}-1/f attribute check failed"
1378 $CHECKSTAT -t file $DIR/${tdir}-2/f ||
1379 error "$CHECKSTAT $DIR/${tdir}-2/f attribute check failed"
1380 rm -rf $DIR/${tdir}-*
1382 run_test 53f "|X| open reply and close reply while two MDC requests in flight"
1385 cancel_lru_locks mdc # cleanup locks from former test cases
1387 mkdir $DIR/${tdir}-1 || error "mkdir $DIR/${tdir}-1 failed"
1388 mkdir $DIR/${tdir}-2 || error "mkdir $DIR/${tdir}-2 failed"
1389 multiop $DIR/${tdir}-1/f O_c &
1392 #define OBD_FAIL_MDS_REINT_NET_REP 0x119
1393 do_facet $SINGLEMDS "lctl set_param fail_loc=0x119"
1394 mcreate $DIR/${tdir}-2/f &
1398 #define OBD_FAIL_MDS_CLOSE_NET 0x115
1399 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000115"
1400 kill -USR1 $close_pid
1401 cancel_lru_locks mdc # force the close
1402 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
1404 #bz20647: make sure all pids are exists before failover
1405 [ -d /proc/$close_pid ] || error "close_pid doesn't exist"
1406 [ -d /proc/$open_pid ] || error "open_pid doesn't exists"
1407 replay_barrier_nodf $SINGLEMDS
1408 fail_nodf $SINGLEMDS
1409 wait $open_pid || error "open_pid failed"
1411 # close should be gone
1412 [ -d /proc/$close_pid ] && error "close_pid should not exist"
1414 $CHECKSTAT -t file $DIR/${tdir}-1/f ||
1415 error "$CHECKSTAT $DIR/${tdir}-1/f attribute check failed"
1416 $CHECKSTAT -t file $DIR/${tdir}-2/f ||
1417 error "$CHECKSTAT $DIR/${tdir}-2/f attribute check failed"
1418 rm -rf $DIR/${tdir}-*
1420 run_test 53g "|X| drop open reply and close request while close and open are both in flight"
1423 cancel_lru_locks mdc # cleanup locks from former test cases
1425 mkdir $DIR/${tdir}-1 || error "mkdir $DIR/${tdir}-1 failed"
1426 mkdir $DIR/${tdir}-2 || error "mkdir $DIR/${tdir}-2 failed"
1427 multiop $DIR/${tdir}-1/f O_c &
1430 #define OBD_FAIL_MDS_REINT_NET 0x107
1431 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000107"
1432 mcreate $DIR/${tdir}-2/f &
1436 #define OBD_FAIL_MDS_CLOSE_NET_REP 0x13b
1437 do_facet $SINGLEMDS "lctl set_param fail_loc=0x8000013b"
1438 kill -USR1 $close_pid
1439 cancel_lru_locks mdc # force the close
1442 #bz20647: make sure all pids are exists before failover
1443 [ -d /proc/$close_pid ] || error "close_pid doesn't exist"
1444 [ -d /proc/$open_pid ] || error "open_pid doesn't exists"
1445 replay_barrier_nodf $SINGLEMDS
1446 fail_nodf $SINGLEMDS
1447 wait $open_pid || error "open_pid failed"
1449 # close should be gone
1450 [ -d /proc/$close_pid ] && error "close_pid should not exist"
1451 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
1453 $CHECKSTAT -t file $DIR/${tdir}-1/f ||
1454 error "$CHECKSTAT $DIR/${tdir}-1/f attribute check failed"
1455 $CHECKSTAT -t file $DIR/${tdir}-2/f ||
1456 error "$CHECKSTAT $DIR/${tdir}-2/f attribute check failed"
1457 rm -rf $DIR/${tdir}-*
1459 run_test 53h "open request and close reply while two MDC requests in flight"
1461 #b3761 ASSERTION(hash != 0) failed
1463 # OBD_FAIL_MDS_OPEN_CREATE | OBD_FAIL_ONCE
1464 do_facet $SINGLEMDS "lctl set_param fail_loc=0x8000012b"
1466 # give touch a chance to run
1468 do_facet $SINGLEMDS "lctl set_param fail_loc=0x0"
1472 run_test 55 "let MDS_CHECK_RESENT return the original return code instead of 0"
1474 #b3440 ASSERTION(rec->ur_fid2->id) failed
1476 ln -s foo $DIR/$tfile
1477 replay_barrier $SINGLEMDS
1478 #drop_reply "cat $DIR/$tfile"
1482 run_test 56 "don't replay a symlink open request (3440)"
1484 #recovery one mds-ost setattr from llog
1486 #define OBD_FAIL_MDS_OST_SETATTR 0x12c
1487 do_facet $SINGLEMDS "lctl set_param fail_loc=0x8000012c"
1488 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
1489 replay_barrier $SINGLEMDS
1492 $CHECKSTAT -t file $DIR/$tfile ||
1493 error "$CHECKSTAT $DIR/$tfile attribute check failed"
1494 do_facet $SINGLEMDS "lctl set_param fail_loc=0x0"
1497 run_test 57 "test recovery from llog for setattr op"
1500 zconf_umount $(hostname) $MOUNT2
1504 #recovery many mds-ost setattr from llog
1506 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
1507 #define OBD_FAIL_MDS_OST_SETATTR 0x12c
1508 do_facet $SINGLEMDS "lctl set_param fail_loc=0x8000012c"
1509 createmany -o $DIR/$tdir/$tfile-%d 2500
1510 replay_barrier $SINGLEMDS
1513 $CHECKSTAT -t file $DIR/$tdir/$tfile-* >/dev/null ||
1514 error "$CHECKSTAT $DIR/$tfile-* attribute check failed"
1515 do_facet $SINGLEMDS "lctl set_param fail_loc=0x0"
1516 unlinkmany $DIR/$tdir/$tfile-%d 2500 ||
1517 error "unlinkmany $DIR/$tfile failed"
1520 run_test 58a "test recovery from llog for setattr op (test llog_gen_rec)"
1526 trap cleanup_58 EXIT
1528 large_xattr_enabled &&
1529 orig="$(generate_string $(max_xattr_size))" || orig="bar"
1531 mount_client $MOUNT2
1532 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
1533 touch $DIR/$tdir/$tfile || error "touch $DIR/$tdir/$tfile failed"
1534 replay_barrier $SINGLEMDS
1535 setfattr -n trusted.foo -v $orig $DIR/$tdir/$tfile
1537 new=$(get_xattr_value trusted.foo $MOUNT2/$tdir/$tfile)
1538 [[ "$new" = "$orig" ]] ||
1539 error "xattr set ($orig) is not what was returned ($new)"
1540 rm -f $DIR/$tdir/$tfile
1544 run_test 58b "test replay of setxattr op"
1546 test_58c() { # bug 16570
1551 trap cleanup_58 EXIT
1553 if large_xattr_enabled; then
1554 local xattr_size=$(max_xattr_size)
1555 orig="$(generate_string $((xattr_size / 2)))"
1556 orig1="$(generate_string $xattr_size)"
1562 mount_client $MOUNT2
1563 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
1564 touch $DIR/$tdir/$tfile || error "touch $DIR/$tdir/$tfile failed"
1565 drop_request "setfattr -n trusted.foo -v $orig $DIR/$tdir/$tfile" ||
1566 error "drop_request for setfattr failed"
1567 new=$(get_xattr_value trusted.foo $MOUNT2/$tdir/$tfile)
1568 [[ "$new" = "$orig" ]] ||
1569 error "xattr set ($orig) is not what was returned ($new)"
1570 drop_reint_reply "setfattr -n trusted.foo1 \
1571 -v $orig1 $DIR/$tdir/$tfile" ||
1572 error "drop_request for setfattr failed"
1573 new=$(get_xattr_value trusted.foo1 $MOUNT2/$tdir/$tfile)
1574 [[ "$new" = "$orig1" ]] ||
1575 error "second xattr set ($orig1) not what was returned ($new)"
1576 rm -f $DIR/$tdir/$tfile
1580 run_test 58c "resend/reconstruct setxattr op"
1582 # log_commit_thread vs filter_destroy race used to lead to import use after free
1585 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1587 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
1588 createmany -o $DIR/$tdir/$tfile-%d 200 ||
1589 error "createmany create files failed"
1591 unlinkmany $DIR/$tdir/$tfile-%d 200 ||
1592 error "unlinkmany $DIR/$tdir/$tfile failed"
1593 #define OBD_FAIL_PTLRPC_DELAY_RECOV 0x507
1594 do_facet ost1 "lctl set_param fail_loc=0x507"
1597 do_facet ost1 "lctl set_param fail_loc=0x0"
1601 run_test 59 "test log_commit_thread vs filter_destroy race"
1603 # race between add unlink llog vs cat log init in post_recovery (only for b1_6)
1604 # bug 12086: should no oops and No ctxt error for this test
1606 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
1607 createmany -o $DIR/$tdir/$tfile-%d 200 ||
1608 error "createmany create files failed"
1609 replay_barrier $SINGLEMDS
1610 unlinkmany $DIR/$tdir/$tfile-%d 0 100
1612 unlinkmany $DIR/$tdir/$tfile-%d 100 100
1613 local no_ctxt=$(dmesg | grep "No ctxt")
1614 [ -z "$no_ctxt" ] || error "ctxt is not initialized in recovery"
1616 run_test 60 "test llog post recovery init vs llog unlink"
1618 #test race llog recovery thread vs llog cleanup
1619 test_61a() { # was test_61
1620 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1622 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
1623 createmany -o $DIR/$tdir/$tfile-%d 800 ||
1624 error "createmany create files failed"
1626 unlinkmany $DIR/$tdir/$tfile-%d 800
1627 # OBD_FAIL_OST_LLOG_RECOVERY_TIMEOUT 0x221
1628 set_nodes_failloc "$(osts_nodes)" 0x80000221
1633 set_nodes_failloc "$(osts_nodes)" 0x0
1635 $CHECKSTAT -t file $DIR/$tdir/$tfile-* &&
1636 error "$CHECKSTAT $DIR/$tdir/$tfile attribute check should fail"
1639 run_test 61a "test race llog recovery vs llog cleanup"
1641 #test race mds llog sync vs llog cleanup
1643 # OBD_FAIL_MDS_LLOG_SYNC_TIMEOUT 0x13a
1644 do_facet $SINGLEMDS "lctl set_param fail_loc=0x8000013a"
1645 facet_failover $SINGLEMDS
1648 do_facet client dd if=/dev/zero of=$DIR/$tfile bs=4k count=1 ||
1651 run_test 61b "test race mds llog sync vs llog cleanup"
1653 #test race cancel cookie cb vs llog cleanup
1655 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1657 # OBD_FAIL_OST_CANCEL_COOKIE_TIMEOUT 0x222
1658 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
1659 set_nodes_failloc "$(osts_nodes)" 0x80000222
1663 set_nodes_failloc "$(osts_nodes)" 0x0
1665 run_test 61c "test race mds llog sync vs llog cleanup"
1667 test_61d() { # bug 16002 # bug 17466 # bug 22137
1668 # OBD_FAIL_OBD_LLOG_SETUP 0x605
1670 do_facet mgs "lctl set_param fail_loc=0x80000605"
1671 start mgs $(mgsdevname) $MGS_MOUNT_OPTS &&
1672 error "mgs start should have failed"
1673 do_facet mgs "lctl set_param fail_loc=0"
1674 start mgs $(mgsdevname) $MGS_MOUNT_OPTS || error "cannot restart mgs"
1676 run_test 61d "error in llog_setup should cleanup the llog context correctly"
1678 test_62() { # Bug 15756 - don't mis-drop resent replay
1679 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
1680 replay_barrier $SINGLEMDS
1681 createmany -o $DIR/$tdir/$tfile- 25 ||
1682 error "createmany create files failed"
1683 #define OBD_FAIL_TGT_REPLAY_DROP 0x707
1684 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000707"
1686 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
1687 unlinkmany $DIR/$tdir/$tfile- 25 ||
1688 error "unlinkmany $DIR/$tdir/$tfile failed"
1691 run_test 62 "don't mis-drop resent replay"
1693 #Adaptive Timeouts (bug 3055)
1701 echo "Cleaning up AT ..."
1702 if [ -n "$ATOLDBASE" ]; then
1703 local at_history=$($LCTL get_param -n at_history)
1704 do_facet $SINGLEMDS "lctl set_param at_history=$at_history" || true
1705 do_facet ost1 "lctl set_param at_history=$at_history" || true
1708 if [ $AT_MAX_SET -ne 0 ]; then
1709 for facet in mds client ost; do
1710 var=AT_MAX_SAVE_${facet}
1711 echo restore AT on $facet to saved value ${!var}
1712 at_max_set ${!var} $facet
1713 at_new=$(at_max_get $facet)
1714 echo Restored AT value on $facet $at_new
1715 [ $at_new -eq ${!var} ] ||
1716 error "AT value not restored SAVED ${!var} NEW $at_new"
1723 local at_max_new=600
1725 # Save at_max original values
1727 if [ $AT_MAX_SET -eq 0 ]; then
1728 # Suppose that all osts have the same at_max
1729 for facet in mds client ost; do
1730 eval AT_MAX_SAVE_${facet}=$(at_max_get $facet)
1734 for facet in mds client ost; do
1735 at_max=$(at_max_get $facet)
1736 if [ $at_max -ne $at_max_new ]; then
1737 echo "AT value on $facet is $at_max, set it by force temporarily to $at_max_new"
1738 at_max_set $at_max_new $facet
1743 if [ -z "$ATOLDBASE" ]; then
1744 ATOLDBASE=$(do_facet $SINGLEMDS "lctl get_param -n at_history")
1745 # speed up the timebase so we can check decreasing AT
1746 do_facet $SINGLEMDS "lctl set_param at_history=8" || true
1747 do_facet ost1 "lctl set_param at_history=8" || true
1749 # sleep for a while to cool down, should be > 8s and also allow
1750 # at least one ping to be sent. simply use TIMEOUT to be safe.
1755 test_65a() #bug 3055
1757 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1759 at_start || return 0
1760 $LCTL dk > /dev/null
1762 $LCTL set_param debug="other"
1763 # Slow down a request to the current service time, this is critical
1764 # because previous tests may have caused this value to increase.
1765 REQ_DELAY=`lctl get_param -n mdc.${FSNAME}-MDT0000-mdc-*.timeouts |
1766 awk '/portal 12/ {print $5}'`
1767 REQ_DELAY=$((${REQ_DELAY} + ${REQ_DELAY} / 4 + 5))
1769 do_facet $SINGLEMDS lctl set_param fail_val=$((${REQ_DELAY} * 1000))
1770 #define OBD_FAIL_PTLRPC_PAUSE_REQ 0x50a
1771 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x8000050a
1772 createmany -o $DIR/$tfile 10 > /dev/null
1773 unlinkmany $DIR/$tfile 10 > /dev/null
1774 # check for log message
1775 $LCTL dk | grep "Early reply #" || error "No early reply"
1777 # client should show REQ_DELAY estimates
1778 lctl get_param -n mdc.${FSNAME}-MDT0000-mdc-*.timeouts | grep portal
1780 lctl get_param -n mdc.${FSNAME}-MDT0000-mdc-*.timeouts | grep portal
1782 run_test 65a "AT: verify early replies"
1784 test_65b() #bug 3055
1786 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1788 at_start || return 0
1791 $LCTL set_param debug="other trace"
1792 $LCTL dk > /dev/null
1793 # Slow down a request to the current service time, this is critical
1794 # because previous tests may have caused this value to increase.
1795 $SETSTRIPE --stripe-index=0 --count=1 $DIR/$tfile
1796 multiop $DIR/$tfile Ow1yc
1797 REQ_DELAY=`lctl get_param -n osc.${FSNAME}-OST0000-osc-*.timeouts |
1798 awk '/portal 6/ {print $5}'`
1799 REQ_DELAY=$((${REQ_DELAY} + ${REQ_DELAY} / 4 + 5))
1801 do_facet ost1 lctl set_param fail_val=${REQ_DELAY}
1802 #define OBD_FAIL_OST_BRW_PAUSE_PACK 0x224
1803 do_facet ost1 $LCTL set_param fail_loc=0x224
1806 $SETSTRIPE --stripe-index=0 --count=1 $DIR/$tfile
1807 # force some real bulk transfer
1808 multiop $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
1810 do_facet ost1 $LCTL set_param fail_loc=0
1811 # check for log message
1812 $LCTL dk | grep "Early reply #" || error "No early reply"
1814 # client should show REQ_DELAY estimates
1815 lctl get_param -n osc.${FSNAME}-OST0000-osc-*.timeouts | grep portal
1817 run_test 65b "AT: verify early replies on packed reply / bulk"
1819 test_66a() #bug 3055
1821 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1823 at_start || return 0
1824 lctl get_param -n mdc.${FSNAME}-MDT0000-mdc-*.timeouts | grep "portal 12"
1825 # adjust 5s at a time so no early reply is sent (within deadline)
1826 do_facet $SINGLEMDS "$LCTL set_param fail_val=5000"
1827 #define OBD_FAIL_PTLRPC_PAUSE_REQ 0x50a
1828 do_facet $SINGLEMDS "$LCTL set_param fail_loc=0x8000050a"
1829 createmany -o $DIR/$tfile 20 > /dev/null
1830 unlinkmany $DIR/$tfile 20 > /dev/null
1831 lctl get_param -n mdc.${FSNAME}-MDT0000-mdc-*.timeouts | grep "portal 12"
1832 do_facet $SINGLEMDS "$LCTL set_param fail_val=10000"
1833 do_facet $SINGLEMDS "$LCTL set_param fail_loc=0x8000050a"
1834 createmany -o $DIR/$tfile 20 > /dev/null
1835 unlinkmany $DIR/$tfile 20 > /dev/null
1836 lctl get_param -n mdc.${FSNAME}-MDT0000-mdc-*.timeouts | grep "portal 12"
1837 do_facet $SINGLEMDS "$LCTL set_param fail_loc=0"
1839 createmany -o $DIR/$tfile 20 > /dev/null
1840 unlinkmany $DIR/$tfile 20 > /dev/null
1841 lctl get_param -n mdc.${FSNAME}-MDT0000-mdc-*.timeouts | grep "portal 12"
1842 CUR=$(lctl get_param -n mdc.${FSNAME}-MDT0000-mdc-*.timeouts | awk '/portal 12/ {print $5}')
1843 WORST=$(lctl get_param -n mdc.${FSNAME}-MDT0000-mdc-*.timeouts | awk '/portal 12/ {print $7}')
1844 echo "Current MDT timeout $CUR, worst $WORST"
1845 [ $CUR -lt $WORST ] || error "Current $CUR should be less than worst $WORST"
1847 run_test 66a "AT: verify MDT service time adjusts with no early replies"
1849 test_66b() #bug 3055
1851 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1853 at_start || return 0
1854 ORIG=$(lctl get_param -n mdc.${FSNAME}-MDT0000*.timeouts |
1855 awk '/network/ {print $4}')
1856 $LCTL set_param fail_val=$(($ORIG + 5))
1857 #define OBD_FAIL_PTLRPC_PAUSE_REP 0x50c
1858 $LCTL set_param fail_loc=0x50c
1859 ls $DIR/$tfile > /dev/null 2>&1
1860 $LCTL set_param fail_loc=0
1861 CUR=$(lctl get_param -n mdc.${FSNAME}-MDT0000*.timeouts |
1862 awk '/network/ {print $4}')
1863 WORST=$(lctl get_param -n mdc.${FSNAME}-MDT0000*.timeouts |
1864 awk '/network/ {print $6}')
1865 echo "network timeout orig $ORIG, cur $CUR, worst $WORST"
1866 [ $WORST -gt $ORIG ] ||
1867 error "Worst $WORST should be worse than orig $ORIG"
1869 run_test 66b "AT: verify net latency adjusts"
1871 test_67a() #bug 3055
1873 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1875 at_start || return 0
1876 CONN1=$(lctl get_param -n osc.*.stats | awk '/_connect/ {total+=$2} END {print total}')
1877 # sleeping threads may drive values above this
1878 do_facet ost1 "$LCTL set_param fail_val=400"
1879 #define OBD_FAIL_PTLRPC_PAUSE_REQ 0x50a
1880 do_facet ost1 "$LCTL set_param fail_loc=0x50a"
1881 createmany -o $DIR/$tfile 20 > /dev/null
1882 unlinkmany $DIR/$tfile 20 > /dev/null
1883 do_facet ost1 "$LCTL set_param fail_loc=0"
1884 CONN2=$(lctl get_param -n osc.*.stats | awk '/_connect/ {total+=$2} END {print total}')
1885 ATTEMPTS=$(($CONN2 - $CONN1))
1886 echo "$ATTEMPTS osc reconnect attempts on gradual slow"
1887 [ $ATTEMPTS -gt 0 ] &&
1888 error_ignore bz13721 "AT should have prevented reconnect"
1891 run_test 67a "AT: verify slow request processing doesn't induce reconnects"
1893 test_67b() #bug 3055
1895 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1897 at_start || return 0
1898 CONN1=$(lctl get_param -n osc.*.stats | awk '/_connect/ {total+=$2} END {print total}')
1900 # exhaust precreations on ost1
1901 local OST=$(ostname_from_index 0)
1902 local mdtosc=$(get_mdtosc_proc_path mds $OST)
1903 local last_id=$(do_facet $SINGLEMDS lctl get_param -n \
1904 osc.$mdtosc.prealloc_last_id)
1905 local next_id=$(do_facet $SINGLEMDS lctl get_param -n \
1906 osc.$mdtosc.prealloc_next_id)
1908 mkdir -p $DIR/$tdir/${OST} || error "mkdir $DIR/$tdir/${OST} failed"
1909 $SETSTRIPE -i 0 -c 1 $DIR/$tdir/${OST} || error "$SETSTRIPE failed"
1910 echo "Creating to objid $last_id on ost $OST..."
1911 #define OBD_FAIL_OST_PAUSE_CREATE 0x223
1912 do_facet ost1 "$LCTL set_param fail_val=20000"
1913 do_facet ost1 "$LCTL set_param fail_loc=0x80000223"
1914 createmany -o $DIR/$tdir/${OST}/f $next_id $((last_id - next_id + 2))
1917 do_facet ost1 "lctl get_param -n ost.OSS.ost_create.timeouts"
1919 CONN2=$(lctl get_param -n osc.*.stats | awk '/_connect/ {total+=$2} END {print total}')
1920 ATTEMPTS=$(($CONN2 - $CONN1))
1921 echo "$ATTEMPTS osc reconnect attempts on instant slow"
1922 # do it again; should not timeout
1923 do_facet ost1 "$LCTL set_param fail_loc=0x80000223"
1924 cp /etc/profile $DIR/$tfile || error "cp failed"
1925 do_facet ost1 "$LCTL set_param fail_loc=0"
1927 do_facet ost1 "lctl get_param -n ost.OSS.ost_create.timeouts"
1928 CONN3=$(lctl get_param -n osc.*.stats | awk '/_connect/ {total+=$2} END {print total}')
1929 ATTEMPTS=$(($CONN3 - $CONN2))
1930 echo "$ATTEMPTS osc reconnect attempts on 2nd slow"
1931 [ $ATTEMPTS -gt 0 ] && error "AT should have prevented reconnect"
1934 run_test 67b "AT: verify instant slowdown doesn't induce reconnects"
1936 test_68 () #bug 13813
1938 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1940 at_start || return 0
1941 local ldlm_enqueue_min=$(find /sys -name ldlm_enqueue_min)
1942 [ -z "$ldlm_enqueue_min" ] && skip "missing /sys/.../ldlm_enqueue_min" && return 0
1943 local ldlm_enqueue_min_r=$(do_facet ost1 "find /sys -name ldlm_enqueue_min")
1944 [ -z "$ldlm_enqueue_min_r" ] && skip "missing /sys/.../ldlm_enqueue_min in the ost1" && return 0
1945 local ENQ_MIN=$(cat $ldlm_enqueue_min)
1946 local ENQ_MIN_R=$(do_facet ost1 "cat $ldlm_enqueue_min_r")
1947 echo $TIMEOUT >> $ldlm_enqueue_min
1948 do_facet ost1 "echo $TIMEOUT >> $ldlm_enqueue_min_r"
1950 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
1951 $SETSTRIPE --stripe-index=0 --count=1 $DIR/$tdir
1952 #define OBD_FAIL_LDLM_PAUSE_CANCEL 0x312
1953 $LCTL set_param fail_val=$(($TIMEOUT - 1))
1954 $LCTL set_param fail_loc=0x80000312
1955 cp /etc/profile $DIR/$tdir/${tfile}_1 || error "1st cp failed $?"
1956 $LCTL set_param fail_val=$((TIMEOUT * 5 / 4))
1957 $LCTL set_param fail_loc=0x80000312
1958 cp /etc/profile $DIR/$tdir/${tfile}_2 || error "2nd cp failed $?"
1959 $LCTL set_param fail_loc=0
1961 echo $ENQ_MIN >> $ldlm_enqueue_min
1962 do_facet ost1 "echo $ENQ_MIN_R >> $ldlm_enqueue_min_r"
1966 run_test 68 "AT: verify slowing locks"
1969 # end of AT tests includes above lines
1971 # start multi-client tests
1973 [ -z "$CLIENTS" ] &&
1974 { skip "Need two or more clients." && return; }
1975 [ $CLIENTCOUNT -lt 2 ] &&
1976 { skip "Need two or more clients, have $CLIENTCOUNT" && return; }
1978 echo "mount clients $CLIENTS ..."
1979 zconf_mount_clients $CLIENTS $MOUNT
1981 local clients=${CLIENTS//,/ }
1982 echo "Write/read files on $DIR ; clients $CLIENTS ... "
1983 for CLIENT in $clients; do
1984 do_node $CLIENT dd bs=1M count=10 if=/dev/zero \
1985 of=$DIR/${tfile}_${CLIENT} 2>/dev/null ||
1986 error "dd failed on $CLIENT"
1989 local prev_client=$(echo $clients | sed 's/^.* \(.\+\)$/\1/')
1990 for C in ${CLIENTS//,/ }; do
1991 do_node $prev_client dd if=$DIR/${tfile}_${C} \
1992 of=/dev/null 2>/dev/null ||
1993 error "dd if=$DIR/${tfile}_${C} failed on $prev_client"
1999 run_test 70a "check multi client t-f"
2001 check_for_process () {
2006 killall_process $clients "$prog" -0
2009 killall_process () {
2010 local clients=${1:-$(hostname)}
2015 do_nodes $clients "killall $signal $name"
2019 local clients=${CLIENTS:-$HOSTNAME}
2021 zconf_mount_clients $clients $MOUNT
2024 [ "$SLOW" = "no" ] && duration=120
2025 # set duration to 900 because it takes some time to boot node
2026 [ "$FAILURE_MODE" = HARD ] && duration=900
2029 local start_ts=$(date +%s)
2030 local cmd="rundbench 1 -t $duration"
2032 do_nodesv $clients "set -x; MISSING_DBENCH_OK=$MISSING_DBENCH_OK \
2033 PATH=\$PATH:$LUSTRE/utils:$LUSTRE/tests/:$DBENCH_LIB \
2034 DBENCH_LIB=$DBENCH_LIB TESTSUITE=$TESTSUITE TESTNAME=$TESTNAME \
2035 MOUNT=$MOUNT DIR=$DIR/$tdir/\\\$(hostname) LCTL=$LCTL $cmd" &
2038 #LU-1897 wait for all dbench copies to start
2039 while ! check_for_process $clients dbench; do
2040 elapsed=$(($(date +%s) - start_ts))
2041 if [ $elapsed -gt $duration ]; then
2042 killall_process $clients dbench
2043 error "dbench failed to start on $clients!"
2048 log "Started rundbench load pid=$pid ..."
2050 elapsed=$(($(date +%s) - start_ts))
2051 local num_failovers=0
2052 while [ $elapsed -lt $duration ]; do
2053 if ! check_for_process $clients dbench; then
2054 error_noexit "dbench stopped on some of $clients!"
2055 killall_process $clients dbench
2059 replay_barrier $SINGLEMDS
2060 sleep 1 # give clients a time to do operations
2061 # Increment the number of failovers
2062 num_failovers=$((num_failovers+1))
2063 log "$TESTNAME fail $SINGLEMDS $num_failovers times"
2065 elapsed=$(($(date +%s) - start_ts))
2068 wait $pid || error "rundbench load on $clients failed!"
2070 run_test 70b "mds recovery; $CLIENTCOUNT clients"
2071 # end multi-client tests
2074 multiop_bg_pause $DIR/$tfile O_tSc ||
2075 error "multiop_bg_pause $DIR/$tfile failed"
2079 replay_barrier $SINGLEMDS
2080 #define OBD_FAIL_LDLM_ENQUEUE_NET 0x302
2081 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000302"
2084 wait $pid || error "multiop pid failed"
2085 [ -e $DIR/$tfile ] && error "file $DIR/$tfile should not exist"
2088 run_test 73a "open(O_CREAT), unlink, replay, reconnect before open replay, close"
2091 multiop_bg_pause $DIR/$tfile O_tSc ||
2092 error "multiop_bg_pause $DIR/$tfile failed"
2096 replay_barrier $SINGLEMDS
2097 #define OBD_FAIL_LDLM_REPLY 0x30c
2098 do_facet $SINGLEMDS "lctl set_param fail_loc=0x8000030c"
2101 wait $pid || error "multiop pid failed"
2102 [ -e $DIR/$tfile ] && error "file $DIR/$tfile should not exist"
2105 run_test 73b "open(O_CREAT), unlink, replay, reconnect at open_replay reply, close"
2109 local clients=${CLIENTS:-$HOSTNAME}
2111 zconf_umount_clients $clients $MOUNT
2113 facet_failover $SINGLEMDS
2114 zconf_mount_clients $clients $MOUNT
2116 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
2117 rm $DIR/$tfile || error "rm $DIR/$tfile failed"
2118 clients_up || error "client evicted: $?"
2121 run_test 74 "Ensure applications don't fail waiting for OST recovery"
2123 remote_dir_check_80() {
2125 local diridx=$($GETSTRIPE -M $remote_dir)
2126 [ $diridx -eq $MDTIDX ] || error "$diridx != $MDTIDX"
2128 createmany -o $remote_dir/f-%d 20 || error "creation failed"
2129 local fileidx=$($GETSTRIPE -M $remote_dir/f-1)
2130 [ $fileidx -eq $MDTIDX ] || error "$fileidx != $MDTIDX"
2136 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2137 ([ $FAILURE_MODE == "HARD" ] &&
2138 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
2139 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
2143 local remote_dir=$DIR/$tdir/remote_dir
2145 mkdir -p $DIR/$tdir || error "mkdir $DIR/$tdir failed"
2146 #define OBD_FAIL_OUT_UPDATE_NET_REP 0x1701
2147 do_facet mds${MDTIDX} lctl set_param fail_loc=0x1701
2148 $LFS mkdir -i $MDTIDX $remote_dir &
2153 wait $CLIENT_PID || error "remote creation failed"
2155 remote_dir_check_80 || error "remote dir check failed"
2156 rm -rf $DIR/$tdir || error "rmdir failed"
2160 run_test 80a "DNE: create remote dir, drop update rep from MDT0, fail MDT0"
2163 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2164 ([ $FAILURE_MODE == "HARD" ] &&
2165 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
2166 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
2170 local remote_dir=$DIR/$tdir/remote_dir
2172 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
2173 #define OBD_FAIL_UPDATE_OBJ_NET_REP 0x1701
2174 do_facet mds${MDTIDX} lctl set_param fail_loc=0x1701
2175 $LFS mkdir -i $MDTIDX $remote_dir &
2178 fail mds$((MDTIDX + 1))
2180 wait $CLIENT_PID || error "remote creation failed"
2182 remote_dir_check_80 || error "remote dir check failed"
2183 rm -rf $DIR/$tdir || error "rmdir failed"
2187 run_test 80b "DNE: create remote dir, drop update rep from MDT0, fail MDT1"
2190 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2191 ([ $FAILURE_MODE == "HARD" ] &&
2192 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
2193 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
2197 local remote_dir=$DIR/$tdir/remote_dir
2199 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
2200 #define OBD_FAIL_UPDATE_OBJ_NET_REP 0x1701
2201 do_facet mds${MDTIDX} lctl set_param fail_loc=0x1701
2202 $LFS mkdir -i $MDTIDX $remote_dir &
2206 fail mds$((MDTIDX + 1))
2208 wait $CLIENT_PID || error "remote creation failed"
2210 remote_dir_check_80 || error "remote dir check failed"
2211 rm -rf $DIR/$tdir || error "rmdir failed"
2215 run_test 80c "DNE: create remote dir, drop update rep from MDT1, fail MDT[0,1]"
2218 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2220 local remote_dir=$DIR/$tdir/remote_dir
2222 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
2223 #define OBD_FAIL_UPDATE_OBJ_NET_REP 0x1701
2224 do_facet mds${MDTIDX} lctl set_param fail_loc=0x1701
2225 $LFS mkdir -i $MDTIDX $remote_dir &
2228 # sleep 3 seconds to make sure MDTs are failed after
2229 # lfs mkdir -i has finished on all of MDTs.
2231 fail mds${MDTIDX},mds$((MDTIDX + 1))
2233 wait $CLIENT_PID || error "remote creation failed"
2235 remote_dir_check_80 || error "remote dir check failed"
2236 rm -rf $DIR/$tdir || error "rmdir failed"
2240 run_test 80d "DNE: create remote dir, drop update rep from MDT1, fail 2 MDTs"
2243 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2244 ([ $FAILURE_MODE == "HARD" ] &&
2245 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
2246 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
2250 local remote_dir=$DIR/$tdir/remote_dir
2252 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
2253 # OBD_FAIL_MDS_REINT_NET_REP 0x119
2254 do_facet mds$((MDTIDX + 1)) lctl set_param fail_loc=0x119
2255 $LFS mkdir -i $MDTIDX $remote_dir &
2258 # sleep 3 seconds to make sure MDTs are failed after
2259 # lfs mkdir -i has finished on all of MDTs.
2264 wait $CLIENT_PID || error "remote creation failed"
2266 remote_dir_check_80 || error "remote dir check failed"
2267 rm -rf $DIR/$tdir || error "rmdir failed"
2271 run_test 80e "DNE: create remote dir, drop MDT1 rep, fail MDT0"
2274 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2275 ([ $FAILURE_MODE == "HARD" ] &&
2276 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
2277 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
2280 local remote_dir=$DIR/$tdir/remote_dir
2282 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
2283 # OBD_FAIL_MDS_REINT_NET_REP 0x119
2284 do_facet mds$((MDTIDX + 1)) lctl set_param fail_loc=0x119
2285 $LFS mkdir -i $MDTIDX $remote_dir &
2288 fail mds$((MDTIDX + 1))
2290 wait $CLIENT_PID || error "remote creation failed"
2292 remote_dir_check_80 || error "remote dir check failed"
2293 rm -rf $DIR/$tdir || error "rmdir failed"
2297 run_test 80f "DNE: create remote dir, drop MDT1 rep, fail MDT1"
2300 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2301 ([ $FAILURE_MODE == "HARD" ] &&
2302 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
2303 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
2307 local remote_dir=$DIR/$tdir/remote_dir
2309 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
2310 # OBD_FAIL_MDS_REINT_NET_REP 0x119
2311 do_facet mds$((MDTIDX + 1)) lctl set_param fail_loc=0x119
2312 $LFS mkdir -i $MDTIDX $remote_dir &
2315 # sleep 3 seconds to make sure MDTs are failed after
2316 # lfs mkdir -i has finished on all of MDTs.
2320 fail mds$((MDTIDX + 1))
2322 wait $CLIENT_PID || error "remote creation failed"
2324 remote_dir_check_80 || error "remote dir check failed"
2325 rm -rf $DIR/$tdir || error "rmdir failed"
2329 run_test 80g "DNE: create remote dir, drop MDT1 rep, fail MDT0, then MDT1"
2332 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2334 local remote_dir=$DIR/$tdir/remote_dir
2336 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
2337 # OBD_FAIL_MDS_REINT_NET_REP 0x119
2338 do_facet mds$((MDTIDX + 1)) lctl set_param fail_loc=0x119
2339 $LFS mkdir -i $MDTIDX $remote_dir &
2342 # sleep 3 seconds to make sure MDTs are failed after
2343 # lfs mkdir -i has finished on all of MDTs.
2346 fail mds${MDTIDX},mds$((MDTIDX + 1))
2348 wait $CLIENT_PID || error "remote dir creation failed"
2350 remote_dir_check_80 || error "remote dir check failed"
2351 rm -rf $DIR/$tdir || error "rmdir failed"
2355 run_test 80h "DNE: create remote dir, drop MDT1 rep, fail 2 MDTs"
2358 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2359 ([ $FAILURE_MODE == "HARD" ] &&
2360 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
2361 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
2365 local remote_dir=$DIR/$tdir/remote_dir
2367 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
2368 $LFS mkdir -i $MDTIDX $remote_dir || error "lfs mkdir failed"
2370 touch $remote_dir || error "touch $remote_dir failed"
2371 # OBD_FAIL_OBJ_UPDATE_NET_REP 0x1701
2372 do_facet mds${MDTIDX} lctl set_param fail_loc=0x1701
2376 fail mds$((MDTIDX + 1))
2378 wait $CLIENT_PID || error "rm remote dir failed"
2380 stat $remote_dir 2&>/dev/null && error "$remote_dir still exist!"
2382 rm -rf $DIR/$tdir || error "rmdir failed"
2386 run_test 81a "DNE: unlink remote dir, drop MDT0 update rep, fail MDT1"
2389 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2390 ([ $FAILURE_MODE == "HARD" ] &&
2391 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
2392 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
2395 local remote_dir=$DIR/$tdir/remote_dir
2397 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
2398 $LFS mkdir -i $MDTIDX $remote_dir || error "lfs mkdir failed"
2400 # OBD_FAIL_OBJ_UPDATE_NET_REP 0x1701
2401 do_facet mds${MDTIDX} lctl set_param fail_loc=0x1701
2407 wait $CLIENT_PID || error "rm remote dir failed"
2409 stat $remote_dir 2&>/dev/null && error "$remote_dir still exist!"
2411 rm -rf $DIR/$tdir || error "rmdir failed"
2415 run_test 81b "DNE: unlink remote dir, drop MDT0 update reply, fail MDT0"
2418 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2419 ([ $FAILURE_MODE == "HARD" ] &&
2420 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
2421 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
2425 local remote_dir=$DIR/$tdir/remote_dir
2427 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
2428 $LFS mkdir -i $MDTIDX $remote_dir || error "lfs mkdir failed"
2430 # OBD_FAIL_OBJ_UPDATE_NET_REP 0x1701
2431 do_facet mds${MDTIDX} lctl set_param fail_loc=0x1701
2436 fail mds$((MDTIDX + 1))
2438 wait $CLIENT_PID || error "rm remote dir failed"
2440 stat $remote_dir 2&>/dev/null && error "$remote_dir still exist!"
2442 rm -rf $DIR/$tdir || error "rmdir failed"
2446 run_test 81c "DNE: unlink remote dir, drop MDT0 update reply, fail MDT0,MDT1"
2449 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2451 local remote_dir=$DIR/$tdir/remote_dir
2453 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
2454 $LFS mkdir -i $MDTIDX $remote_dir || error "lfs mkdir failed"
2456 # OBD_FAIL_OBJ_UPDATE_NET_REP 0x1701
2457 do_facet mds${MDTIDX} lctl set_param fail_loc=0x1701
2461 fail mds${MDTIDX},mds$((MDTIDX + 1))
2463 wait $CLIENT_PID || error "rm remote dir failed"
2465 stat $remote_dir 2&>/dev/null && error "$remote_dir still exist!"
2467 rm -rf $DIR/$tdir || error "rmdir failed"
2471 run_test 81d "DNE: unlink remote dir, drop MDT0 update reply, fail 2 MDTs"
2474 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2475 ([ $FAILURE_MODE == "HARD" ] &&
2476 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
2477 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
2481 local remote_dir=$DIR/$tdir/remote_dir
2483 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
2484 $LFS mkdir -i $MDTIDX $remote_dir || error "lfs mkdir failed"
2486 # OBD_FAIL_MDS_REINT_NET_REP 0x119
2487 do_facet mds$((MDTIDX + 1)) lctl set_param fail_loc=0x119
2490 do_facet mds$((MDTIDX + 1)) lctl set_param fail_loc=0
2494 wait $CLIENT_PID || error "rm remote dir failed"
2496 stat $remote_dir 2&>/dev/null && error "$remote_dir still exist!"
2498 rm -rf $DIR/$tdir || error "rmdir failed"
2502 run_test 81e "DNE: unlink remote dir, drop MDT1 req reply, fail MDT0"
2505 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2506 ([ $FAILURE_MODE == "HARD" ] &&
2507 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
2508 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
2512 local remote_dir=$DIR/$tdir/remote_dir
2514 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
2515 $LFS mkdir -i $MDTIDX $remote_dir || error "lfs mkdir failed"
2517 # OBD_FAIL_MDS_REINT_NET_REP 0x119
2518 do_facet mds$((MDTIDX + 1)) lctl set_param fail_loc=0x119
2522 fail mds$((MDTIDX + 1))
2524 wait $CLIENT_PID || error "rm remote dir failed"
2526 stat $remote_dir 2&>/dev/null && error "$remote_dir still exist!"
2528 rm -rf $DIR/$tdir || error "rmdir failed"
2532 run_test 81f "DNE: unlink remote dir, drop MDT1 req reply, fail MDT1"
2535 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2536 ([ $FAILURE_MODE == "HARD" ] &&
2537 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
2538 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
2542 local remote_dir=$DIR/$tdir/remote_dir
2544 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
2545 $LFS mkdir -i $MDTIDX $remote_dir || error "lfs mkdir failed"
2547 # OBD_FAIL_MDS_REINT_NET_REP 0x119
2548 do_facet mds$((MDTIDX + 1)) lctl set_param fail_loc=0x119
2553 fail mds$((MDTIDX + 1))
2555 wait $CLIENT_PID || error "rm remote dir failed"
2557 stat $remote_dir 2&>/dev/null && error "$remote_dir still exist!"
2559 rm -rf $DIR/$tdir || error "rmdir failed"
2563 run_test 81g "DNE: unlink remote dir, drop req reply, fail M0, then M1"
2566 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2568 local remote_dir=$DIR/$tdir/remote_dir
2570 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
2571 $LFS mkdir -i $MDTIDX $remote_dir || error "lfs mkdir failed"
2573 # OBD_FAIL_MDS_REINT_NET_REP 0x119
2574 do_facet mds$((MDTIDX + 1)) lctl set_param fail_loc=0x119
2578 fail mds${MDTIDX},mds$((MDTIDX + 1))
2580 wait $CLIENT_PID || error "rm remote dir failed"
2582 stat $remote_dir 2&>/dev/null && error "$remote_dir still exist!"
2584 rm -rf $DIR/$tdir || error "rmdir failed"
2588 run_test 81h "DNE: unlink remote dir, drop request reply, fail 2 MDTs"
2591 #define OBD_FAIL_MDS_OPEN_WAIT_CREATE 0x144
2592 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000144"
2593 createmany -o $DIR/$tfile- 1 &
2597 client_up || client_up || true # reconnect
2599 run_test 84a "stale open during export disconnect"
2601 test_85a() { #bug 16774
2602 lctl set_param -n ldlm.cancel_unused_locks_before_replay "1"
2604 for i in $(seq 100); do
2605 echo "tag-$i" > $DIR/$tfile-$i
2606 grep -q "tag-$i" $DIR/$tfile-$i || error "f2-$i"
2609 lov_id=$(lctl dl | grep "clilov")
2610 addr=$(echo $lov_id | awk '{print $4}' | awk -F '-' '{print $3}')
2611 count=$(lctl get_param -n \
2612 ldlm.namespaces.*MDT0000*$addr.lock_unused_count)
2613 echo "before recovery: unused locks count = $count"
2617 count2=$(lctl get_param -n \
2618 ldlm.namespaces.*MDT0000*$addr.lock_unused_count)
2619 echo "after recovery: unused locks count = $count2"
2621 if [ $count2 -ge $count ]; then
2622 error "unused locks are not canceled"
2625 run_test 85a "check the cancellation of unused locks during recovery(IBITS)"
2627 test_85b() { #bug 16774
2628 lctl set_param -n ldlm.cancel_unused_locks_before_replay "1"
2630 do_facet mgs $LCTL pool_new $FSNAME.$TESTNAME ||
2631 error "unable to create pool $TESTNAME"
2632 do_facet mgs $LCTL pool_add $FSNAME.$TESTNAME $FSNAME-OST0000 ||
2633 error "unable to add pool $TESTNAME"
2635 $SETSTRIPE -c 1 -p $FSNAME.$TESTNAME $DIR
2637 for i in $(seq 100); do
2638 dd if=/dev/urandom of=$DIR/$tfile-$i bs=4096 \
2639 count=32 >/dev/null 2>&1
2642 cancel_lru_locks osc
2644 for i in $(seq 100); do
2645 dd if=$DIR/$tfile-$i of=/dev/null bs=4096 \
2646 count=32 >/dev/null 2>&1
2649 lov_id=$(lctl dl | grep "clilov")
2650 addr=$(echo $lov_id | awk '{print $4}' | awk -F '-' '{print $3}')
2651 count=$(lctl get_param \
2652 -n ldlm.namespaces.*OST0000*$addr.lock_unused_count)
2653 echo "before recovery: unused locks count = $count"
2654 [ $count != 0 ] || error "unused locks ($count) should be zero"
2658 count2=$(lctl get_param \
2659 -n ldlm.namespaces.*OST0000*$addr.lock_unused_count)
2660 echo "after recovery: unused locks count = $count2"
2662 do_facet mgs $LCTL pool_remove $FSNAME.$TESTNAME $FSNAME-OST0000 ||
2663 error "unable to remove pool $TESTNAME"
2664 do_facet mgs $LCTL pool_destroy $FSNAME.$TESTNAME ||
2665 error "unable to destroy the pool $TESTNAME"
2667 if [ $count2 -ge $count ]; then
2668 error "unused locks are not canceled"
2671 run_test 85b "check the cancellation of unused locks during recovery(EXTENT)"
2674 local clients=${CLIENTS:-$HOSTNAME}
2676 zconf_umount_clients $clients $MOUNT
2677 do_facet $SINGLEMDS lctl set_param mdt.${FSNAME}-MDT*.exports.clear=0
2678 remount_facet $SINGLEMDS
2679 zconf_mount_clients $clients $MOUNT
2681 run_test 86 "umount server after clear nid_stats should not hit LBUG"
2684 do_facet ost1 "lctl set_param -n obdfilter.${ost1_svc}.sync_journal 0"
2687 $SETSTRIPE -i 0 -c 1 $DIR/$tfile
2688 dd if=/dev/urandom of=$DIR/$tfile bs=1024k count=8 ||
2689 error "dd to $DIR/$tfile failed"
2690 cksum=$(md5sum $DIR/$tfile | awk '{print $1}')
2691 cancel_lru_locks osc
2693 dd if=$DIR/$tfile of=/dev/null bs=1024k count=8 || error "Cannot read"
2694 cksum2=$(md5sum $DIR/$tfile | awk '{print $1}')
2695 if [ $cksum != $cksum2 ] ; then
2696 error "New checksum $cksum2 does not match original $cksum"
2699 run_test 87 "write replay"
2702 do_facet ost1 "lctl set_param -n obdfilter.${ost1_svc}.sync_journal 0"
2705 $SETSTRIPE -i 0 -c 1 $DIR/$tfile
2706 dd if=/dev/urandom of=$DIR/$tfile bs=1024k count=8 ||
2707 error "dd to $DIR/$tfile failed"
2708 sleep 1 # Give it a chance to flush dirty data
2709 echo TESTTEST | dd of=$DIR/$tfile bs=1 count=8 seek=64
2710 cksum=$(md5sum $DIR/$tfile | awk '{print $1}')
2711 cancel_lru_locks osc
2713 dd if=$DIR/$tfile of=/dev/null bs=1024k count=8 || error "Cannot read"
2714 cksum2=$(md5sum $DIR/$tfile | awk '{print $1}')
2715 if [ $cksum != $cksum2 ] ; then
2716 error "New checksum $cksum2 does not match original $cksum"
2719 run_test 87b "write replay with changed data (checksum resend)"
2721 test_88() { #bug 17485
2722 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
2723 mkdir -p $TMP/$tdir || error "mkdir $TMP/$tdir failed"
2725 $SETSTRIPE -i 0 -c 1 $DIR/$tdir || error "$SETSTRIPE"
2728 replay_barrier $SINGLEMDS
2730 # exhaust precreations on ost1
2731 local OST=$(ostname_from_index 0)
2732 local mdtosc=$(get_mdtosc_proc_path $SINGLEMDS $OST)
2733 local last_id=$(do_facet $SINGLEMDS lctl get_param -n osc.$mdtosc.prealloc_last_id)
2734 local next_id=$(do_facet $SINGLEMDS lctl get_param -n osc.$mdtosc.prealloc_next_id)
2735 echo "before test: last_id = $last_id, next_id = $next_id"
2737 echo "Creating to objid $last_id on ost $OST..."
2738 createmany -o $DIR/$tdir/f-%d $next_id $((last_id - next_id + 2)) ||
2739 error "createmany create files to last_id failed"
2741 #create some files to use some uncommitted objids
2742 last_id=$(($last_id + 1))
2743 createmany -o $DIR/$tdir/f-%d $last_id 8 ||
2744 error "createmany create files with uncommitted objids failed"
2746 last_id2=$(do_facet $SINGLEMDS lctl get_param -n osc.$mdtosc.prealloc_last_id)
2747 next_id2=$(do_facet $SINGLEMDS lctl get_param -n osc.$mdtosc.prealloc_next_id)
2748 echo "before recovery: last_id = $last_id2, next_id = $next_id2"
2750 # if test uses shutdown_facet && reboot_facet instead of facet_failover ()
2751 # it has to take care about the affected facets, bug20407
2752 local affected_mds1=$(affected_facets mds1)
2753 local affected_ost1=$(affected_facets ost1)
2755 shutdown_facet $SINGLEMDS
2758 reboot_facet $SINGLEMDS
2759 change_active $affected_mds1
2760 wait_for_facet $affected_mds1
2761 mount_facets $affected_mds1 || error "Restart of mds failed"
2764 change_active $affected_ost1
2765 wait_for_facet $affected_ost1
2766 mount_facets $affected_ost1 || error "Restart of ost1 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 "after recovery: last_id = $last_id2, next_id = $next_id2"
2774 # create new files, which should use new objids, and ensure the orphan
2775 # cleanup phase for ost1 is completed at the same time
2776 for i in $(seq 8); do
2777 file_id=$(($last_id + 10 + $i))
2778 dd if=/dev/urandom of=$DIR/$tdir/f-$file_id bs=4096 count=128
2781 # if the objids were not recreated, then "ls" will fail with -ENOENT
2782 ls -l $DIR/$tdir/* || error "can't get the status of precreated files"
2785 # write into previously created files
2786 for i in $(seq 8); do
2787 file_id=$(($last_id + $i))
2788 dd if=/dev/urandom of=$DIR/$tdir/f-$file_id bs=4096 count=128
2789 cp -f $DIR/$tdir/f-$file_id $TMP/$tdir/
2792 # compare the content
2793 for i in $(seq 8); do
2794 file_id=$(($last_id + $i))
2795 cmp $TMP/$tdir/f-$file_id $DIR/$tdir/f-$file_id ||
2796 error "the content of file is modified!"
2801 run_test 88 "MDS should not assign same objid to different files "
2804 cancel_lru_locks osc
2805 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
2806 rm -f $DIR/$tdir/$tfile
2808 wait_delete_completed
2809 BLOCKS1=$(df -P $MOUNT | tail -n 1 | awk '{ print $3 }')
2810 $SETSTRIPE -i 0 -c 1 $DIR/$tdir/$tfile
2811 dd if=/dev/zero bs=1M count=10 of=$DIR/$tdir/$tfile
2814 facet_failover $SINGLEMDS
2815 rm $DIR/$tdir/$tfile
2818 zconf_mount $(hostname) $MOUNT || error "mount fails"
2819 client_up || error "client_up failed"
2821 wait_delete_completed
2822 BLOCKS2=$(df -P $MOUNT | tail -n 1 | awk '{ print $3 }')
2823 [ $((BLOCKS2 - BLOCKS1)) -le 4 ] ||
2824 error $((BLOCKS2 - BLOCKS1)) blocks leaked
2827 run_test 89 "no disk space leak on late ost connection"
2833 change_active $facet
2834 wait_for_facet $facet
2835 mount_facet $facet || error "Restart of $facet failed"
2839 test_90() { # bug 19494
2840 local dir=$DIR/$tdir
2841 local ostfail=$(get_random_entry $(get_facets OST))
2843 if [[ $FAILURE_MODE = HARD ]]; then
2844 local affected=$(affected_facets $ostfail);
2845 if [[ "$affected" != $ostfail ]]; then
2846 skip not functional with FAILURE_MODE=$FAILURE_MODE, affected: $affected
2851 mkdir $dir || error "mkdir $dir failed"
2853 echo "Create the files"
2855 # file "f${index}" striped over 1 OST
2856 # file "all" striped over all OSTs
2858 $SETSTRIPE -c $OSTCOUNT $dir/all ||
2859 error "setstripe failed to create $dir/all"
2861 for (( i=0; i<$OSTCOUNT; i++ )); do
2863 $SETSTRIPE -i $i -c 1 $f || error "$SETSTRIPE failed to create $f"
2865 # confirm setstripe actually created the stripe on the requested OST
2866 local uuid=$(ostuuid_from_index $i)
2867 for file in f$i all; do
2868 if [[ $dir/$file != $($LFS find --obd $uuid --name $file $dir) ]]; then
2869 $GETSTRIPE $dir/$file
2870 error wrong stripe: $file, uuid: $uuid
2875 # Before failing an OST, get its obd name and index
2876 local varsvc=${ostfail}_svc
2877 local obd=$(do_facet $ostfail lctl get_param \
2878 -n obdfilter.${!varsvc}.uuid)
2879 local index=$(($(facet_number $ostfail) - 1))
2881 echo "Fail $ostfail $obd, display the list of affected files"
2882 shutdown_facet $ostfail || error "shutdown_facet $ostfail failed"
2884 trap "cleanup_90 $ostfail" EXIT INT
2885 echo "General Query: lfs find $dir"
2886 local list=$($LFS find $dir)
2888 for (( i=0; i<$OSTCOUNT; i++ )); do
2889 list_member "$list" $dir/f$i ||
2890 error_noexit "lfs find $dir: no file f$i"
2892 list_member "$list" $dir/all ||
2893 error_noexit "lfs find $dir: no file all"
2895 # focus on the missing OST,
2896 # we expect to see only two files affected: "f$(index)" and "all"
2898 echo "Querying files on shutdown $ostfail: lfs find --obd $obd"
2899 list=$($LFS find --obd $obd $dir)
2901 for file in all f$index; do
2902 list_member "$list" $dir/$file ||
2903 error_noexit "lfs find does not report the affected $obd for $file"
2906 [[ $(echo $list | wc -w) -eq 2 ]] ||
2907 error_noexit "lfs find reports the wrong list of affected files ${#list[@]}"
2909 echo "Check getstripe: $GETSTRIPE -r --obd $obd"
2910 list=$($GETSTRIPE -r --obd $obd $dir)
2912 for file in all f$index; do
2913 echo "$list" | grep $dir/$file ||
2914 error_noexit "lfs getsripe does not report the affected $obd for $file"
2919 run_test 90 "lfs find identifies the missing striped file segments"
2922 local server_version=$(lustre_version_code $SINGLEMDS)
2923 [[ $server_version -ge $(version_code 2.6.90) ]] ||
2924 [[ $server_version -ge $(version_code 2.5.4) &&
2925 $server_version -lt $(version_code 2.5.50) ]] ||
2926 { skip "Need MDS version 2.5.4+ or 2.6.90+"; return; }
2928 cancel_lru_locks osc
2930 $SETSTRIPE -i 0 -c 1 $DIR/$tfile ||
2931 error "$SETSTRIPE $DIR/$tfile failed"
2932 dd if=/dev/zero of=$DIR/$tfile bs=1024 count=1 ||
2933 error "dd to $DIR/$tfile failed"
2934 #define OBD_FAIL_TGT_REPLAY_RECONNECT 0x715
2935 # We need to emulate a state that OST is waiting for other clients
2936 # not completing the recovery. Final ping is queued, but reply will be
2937 # sent on the recovery completion. It is done by sleep before
2938 # processing final pings
2939 do_facet ost1 "$LCTL set_param fail_val=40"
2940 do_facet ost1 "$LCTL set_param fail_loc=0x715"
2943 run_test 93 "replay + reconnect"
2945 striped_dir_check_100() {
2946 local striped_dir=$DIR/$tdir/striped_dir
2947 local stripe_count=$($LFS getdirstripe -c $striped_dir)
2949 $LFS getdirstripe $striped_dir
2950 [ $stripe_count -eq 2 ] || error "$stripe_count != 2"
2952 createmany -o $striped_dir/f-%d 20 ||
2953 error "creation failed under striped dir"
2957 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2958 ([ $FAILURE_MODE == "HARD" ] &&
2959 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
2960 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
2963 local striped_dir=$DIR/$tdir/striped_dir
2966 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
2968 #To make sure MDT1 and MDT0 are connected
2969 #otherwise it may create single stripe dir here
2970 $LFS setdirstripe -i1 $DIR/$tdir/remote_dir
2972 #define OBD_FAIL_OUT_UPDATE_NET_REP 0x1701
2973 do_facet mds$((MDTIDX+1)) lctl set_param fail_loc=0x1701
2974 $LFS setdirstripe -i0 -c2 $striped_dir &
2977 fail mds$((MDTIDX + 1))
2979 wait $CLIENT_PID || error "striped dir creation failed"
2981 striped_dir_check_100 || error "striped dir check failed"
2982 rm -rf $DIR/$tdir || error "rmdir failed"
2984 run_test 100a "DNE: create striped dir, drop update rep from MDT1, fail MDT1"
2987 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2988 ([ $FAILURE_MODE == "HARD" ] &&
2989 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
2990 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
2993 local striped_dir=$DIR/$tdir/striped_dir
2996 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
2998 #To make sure MDT1 and MDT0 are connected
2999 #otherwise it may create single stripe dir here
3000 $LFS setdirstripe -i1 $DIR/$tdir/remote_dir
3002 # OBD_FAIL_MDS_REINT_NET_REP 0x119
3003 do_facet mds$MDTIDX lctl set_param fail_loc=0x119
3004 $LFS mkdir -i0 -c2 $striped_dir &
3009 wait $CLIENT_PID || error "striped dir creation failed"
3011 striped_dir_check_100 || error "striped dir check failed"
3012 rm -rf $DIR/$tdir || error "rmdir failed"
3014 run_test 100b "DNE: create striped dir, fail MDT0"
3016 test_101() { #LU-5648
3017 mkdir -p $DIR/$tdir/d1
3018 mkdir -p $DIR/$tdir/d2
3019 touch $DIR/$tdir/file0
3022 replay_barrier $SINGLEMDS
3023 for i in $(seq $num) ; do
3024 echo test$i > $DIR/$tdir/d1/file$i
3027 fail_abort $SINGLEMDS
3028 for i in $(seq $num) ; do
3029 touch $DIR/$tdir/d2/file$i
3030 test -s $DIR/$tdir/d2/file$i &&
3031 ls -al $DIR/$tdir/d2/file$i && error "file$i's size > 0"
3036 run_test 101 "Shouldn't reassign precreated objs to other files after recovery"
3039 check_and_cleanup_lustre