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 # 63 min 7 min AT AT AT AT"
29 [ "$SLOW" = "no" ] && EXCEPT_SLOW="1 2 3 4 6 12 16 44a 44b 65 66 67 68"
31 [ $(facet_fstype $SINGLEMDS) = "zfs" ] &&
32 # bug number for skipped test: LU-1867 LU-3127
33 ALWAYS_EXCEPT="$ALWAYS_EXCEPT 89 73b"
37 check_and_setup_lustre
42 rm -rf $DIR/[df][0-9]* $DIR/f.$TESTSUITE.*
44 # LU-482 Avert LVM and VM inability to flush caches in pre .33 kernels
45 if [ $LINUX_VERSION_CODE -lt $(version_code 2.6.33) ]; then
47 do_facet $SINGLEMDS sync
50 test_0a() { # was test_0
51 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
52 replay_barrier $SINGLEMDS
56 run_test 0a "empty replay"
59 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
61 # this test attempts to trigger a race in the precreation code,
62 # and must run before any other objects are created on the filesystem
64 createmany -o $DIR/$tfile 20 || error "createmany -o $DIR/$tfile failed"
65 unlinkmany $DIR/$tfile 20 || error "unlinkmany $DIR/$tfile failed"
67 run_test 0b "ensure object created after recover exists. (3284)"
70 replay_barrier $SINGLEMDS
73 facet_failover $SINGLEMDS
74 zconf_mount $(hostname) $MOUNT || error "mount fails"
75 client_up || error "post-failover df failed"
76 # file shouldn't exist if replay-barrier works as expected
77 rm $DIR/$tfile && error "File exists and it shouldn't"
80 run_test 0c "check replay-barrier"
83 replay_barrier $SINGLEMDS
85 facet_failover $SINGLEMDS
86 zconf_mount $(hostname) $MOUNT || error "mount fails"
87 client_up || error "post-failover df failed"
89 run_test 0d "expired recovery with no clients"
92 replay_barrier $SINGLEMDS
95 $CHECKSTAT -t file $DIR/$tfile ||
96 error "$CHECKSTAT $DIR/$tfile attribute check failed"
99 run_test 1 "simple create"
102 replay_barrier $SINGLEMDS
105 $CHECKSTAT -t file $DIR/$tfile ||
106 error "$CHECKSTAT $DIR/$tfile attribute check failed"
112 mcreate $DIR/$tfile || error "mcreate $DIR/$tfile failed"
113 replay_barrier $SINGLEMDS
116 $CHECKSTAT -t file $DIR/$tfile ||
117 error "$CHECKSTAT $DIR/$tfile attribute check failed"
123 local file=$DIR/$tfile
124 replay_barrier $SINGLEMDS
126 openfile -f O_DIRECTORY $file
128 $CHECKSTAT -t file $file ||
129 error "$CHECKSTAT $file attribute check failed"
132 run_test 3a "replay failed open(O_DIRECTORY)"
135 replay_barrier $SINGLEMDS
136 #define OBD_FAIL_MDS_OPEN_PACK | OBD_FAIL_ONCE
137 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000114"
139 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
141 $CHECKSTAT -t file $DIR/$tfile &&
142 error "$CHECKSTAT $DIR/$tfile attribute check should fail"
145 run_test 3b "replay failed open -ENOMEM"
148 replay_barrier $SINGLEMDS
149 #define OBD_FAIL_MDS_ALLOC_OBDO | OBD_FAIL_ONCE
150 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000128"
152 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
155 $CHECKSTAT -t file $DIR/$tfile &&
156 error "$CHECKSTAT $DIR/$tfile attribute check should fail"
159 run_test 3c "replay failed open -ENOMEM"
161 test_4a() { # was test_4
162 replay_barrier $SINGLEMDS
163 for i in $(seq 10); do
164 echo "tag-$i" > $DIR/$tfile-$i
167 for i in $(seq 10); do
168 grep -q "tag-$i" $DIR/$tfile-$i || error "$tfile-$i"
171 run_test 4a "|x| 10 open(O_CREAT)s"
174 for i in $(seq 10); do
175 echo "tag-$i" > $DIR/$tfile-$i
177 replay_barrier $SINGLEMDS
180 $CHECKSTAT -t file $DIR/$tfile-* &&
181 error "$CHECKSTAT $DIR/$tfile-* attribute check should fail" ||
184 run_test 4b "|x| rm 10 files"
186 # The idea is to get past the first block of precreated files on both
187 # osts, and then replay.
189 replay_barrier $SINGLEMDS
190 for i in $(seq 220); do
191 echo "tag-$i" > $DIR/$tfile-$i
194 for i in $(seq 220); do
195 grep -q "tag-$i" $DIR/$tfile-$i || error "$tfile-$i"
199 # waiting for commitment of removal
201 run_test 5 "|x| 220 open(O_CREAT)"
203 test_6a() { # was test_6
204 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
205 replay_barrier $SINGLEMDS
206 mcreate $DIR/$tdir/$tfile
208 $CHECKSTAT -t dir $DIR/$tdir ||
209 error "$CHECKSTAT $DIR/$tdir attribute check failed"
210 $CHECKSTAT -t file $DIR/$tdir/$tfile ||
211 error "$CHECKSTAT $DIR/$tdir/$tfile attribute check failed"
213 # waiting for log process thread
215 run_test 6a "mkdir + contained create"
218 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
219 replay_barrier $SINGLEMDS
222 $CHECKSTAT -t dir $DIR/$tdir &&
223 error "$CHECKSTAT $DIR/$tdir attribute check should fail" ||
226 run_test 6b "|X| rmdir"
229 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
230 replay_barrier $SINGLEMDS
231 mcreate $DIR/$tdir/$tfile
233 $CHECKSTAT -t dir $DIR/$tdir ||
234 error "$CHECKSTAT $DIR/$tdir attribute check failed"
235 $CHECKSTAT -t file $DIR/$tdir/$tfile ||
236 error "$CHECKSTAT $DIR/$tdir/$tfile attribute check failed"
239 run_test 7 "mkdir |X| contained create"
242 replay_barrier $SINGLEMDS
243 multiop_bg_pause $DIR/$tfile mo_c ||
244 error "multiop mknod $DIR/$tfile failed"
248 $CHECKSTAT -t file $DIR/$tfile ||
249 error "$CHECKSTAT $DIR/$tfile attribute check failed"
250 kill -USR1 $MULTIPID || error "multiop mknod $MULTIPID not running"
251 wait $MULTIPID || error "multiop mknod $MULTIPID failed"
254 run_test 8 "creat open |X| close"
257 replay_barrier $SINGLEMDS
259 local old_inum=$(ls -i $DIR/$tfile | awk '{print $1}')
261 local new_inum=$(ls -i $DIR/$tfile | awk '{print $1}')
263 echo " old_inum == $old_inum, new_inum == $new_inum"
264 if [ $old_inum -eq $new_inum ] ;
266 echo "old_inum and new_inum match"
268 echo " old_inum and new_inum do not match"
269 error "old index($old_inum) does not match new index($new_inum)"
273 run_test 9 "|X| create (same inum/gen)"
276 mcreate $DIR/$tfile || error "mcreate $DIR/$tfile failed"
277 replay_barrier $SINGLEMDS
278 mv $DIR/$tfile $DIR/$tfile-2
281 $CHECKSTAT $DIR/$tfile &&
282 error "$CHECKSTAT $DIR/$tfile attribute check should fail"
283 $CHECKSTAT $DIR/$tfile-2 ||
284 error "$CHECKSTAT $DIR/$tfile-2 attribute check failed"
288 run_test 10 "create |X| rename unlink"
291 mcreate $DIR/$tfile || error "mcreate $DIR/$tfile failed"
292 echo "old" > $DIR/$tfile
293 mv $DIR/$tfile $DIR/$tfile-2
294 replay_barrier $SINGLEMDS
295 echo "new" > $DIR/$tfile
297 grep old $DIR/$tfile-2
299 grep new $DIR/$tfile || error "grep $DIR/$tfile failed"
300 grep old $DIR/$tfile-2 || error "grep $DIR/$tfile-2 failed"
302 run_test 11 "create open write rename |X| create-old-name read"
305 mcreate $DIR/$tfile || error "mcreate $DIR/$tfile failed"
306 multiop_bg_pause $DIR/$tfile o_tSc ||
307 error "multiop_bg_pause $DIR/$tfile failed"
310 replay_barrier $SINGLEMDS
311 kill -USR1 $pid || error "multiop $pid not running"
312 wait $pid || error "multiop $pid failed"
315 [ -e $DIR/$tfile ] && error "file $DIR/$tfile should not exist"
318 run_test 12 "open, unlink |X| close"
320 # 1777 - replay open after committed chmod that would make
321 # a regular open a failure
323 mcreate $DIR/$tfile || error "mcreate $DIR/$tfile failed"
324 multiop_bg_pause $DIR/$tfile O_wc ||
325 error "multiop_bg_pause $DIR/$tfile failed"
328 $CHECKSTAT -p 0 $DIR/$tfile ||
329 error "$CHECKSTAT $DIR/$tfile attribute check failed"
330 replay_barrier $SINGLEMDS
332 kill -USR1 $pid || error "multiop $pid not running"
333 wait $pid || error "multiop $pid failed"
335 $CHECKSTAT -s 1 -p 0 $DIR/$tfile ||
336 error "second $CHECKSTAT $DIR/$tfile attribute check failed"
337 rm $DIR/$tfile || error "rm $DIR/$tfile failed"
340 run_test 13 "open chmod 0 |x| write close"
343 multiop_bg_pause $DIR/$tfile O_tSc ||
344 error "multiop_bg_pause $DIR/$tfile failed"
347 replay_barrier $SINGLEMDS
348 kill -USR1 $pid || error "multiop $pid not running"
349 wait $pid || error "multiop $pid failed"
352 [ -e $DIR/$tfile ] && error "file $DIR/$tfile should not exist"
355 run_test 14 "open(O_CREAT), unlink |X| close"
358 multiop_bg_pause $DIR/$tfile O_tSc ||
359 error "multiop_bg_pause $DIR/$tfile failed"
362 replay_barrier $SINGLEMDS
363 touch $DIR/$tfile-1 || error "touch $DIR/$tfile-1 failed"
364 kill -USR1 $pid || error "multiop $pid not running"
365 wait $pid || error "multiop $pid failed"
368 [ -e $DIR/$tfile ] && error "file $DIR/$tfile should not exist"
369 touch $DIR/$tfile-2 || error "touch $DIR/$tfile-2 failed"
372 run_test 15 "open(O_CREAT), unlink |X| touch new, close"
375 replay_barrier $SINGLEMDS
378 mcreate $DIR/$tfile-2
380 [ -e $DIR/$tfile ] && error "file $DIR/$tfile should not exist"
381 [ -e $DIR/$tfile-2 ] || error "file $DIR/$tfile-2 does not exist"
382 munlink $DIR/$tfile-2 || error "munlink $DIR/$tfile-2 failed"
384 run_test 16 "|X| open(O_CREAT), unlink, touch new, unlink new"
387 replay_barrier $SINGLEMDS
388 multiop_bg_pause $DIR/$tfile O_c ||
389 error "multiop_bg_pause $DIR/$tfile failed"
392 kill -USR1 $pid || error "multiop $pid not running"
393 wait $pid || error "multiop $pid failed"
394 $CHECKSTAT -t file $DIR/$tfile ||
395 error "$CHECKSTAT $DIR/$tfile attribute check failed"
398 run_test 17 "|X| open(O_CREAT), |replay| close"
401 replay_barrier $SINGLEMDS
402 multiop_bg_pause $DIR/$tfile O_tSc ||
403 error "multiop_bg_pause $DIR/$tfile failed"
406 touch $DIR/$tfile-2 || error "touch $DIR/$tfile-2 failed"
407 echo "pid: $pid will close"
408 kill -USR1 $pid || error "multiop $pid not running"
409 wait $pid || error "multiop $pid failed"
412 [ -e $DIR/$tfile ] && error "file $DIR/$tfile should not exist"
413 [ -e $DIR/$tfile-2 ] || error "file $DIR/$tfile-2 does not exist"
414 # this touch frequently fails
415 touch $DIR/$tfile-3 || error "touch $DIR/$tfile-3 failed"
416 munlink $DIR/$tfile-2 || error "munlink $DIR/$tfile-2 failed"
417 munlink $DIR/$tfile-3 || error "munlink $DIR/$tfile-3 failed"
420 run_test 18 "open(O_CREAT), unlink, touch new, close, touch, unlink"
422 # bug 1855 (a simpler form of test_11 above)
424 replay_barrier $SINGLEMDS
426 echo "old" > $DIR/$tfile
427 mv $DIR/$tfile $DIR/$tfile-2
428 grep old $DIR/$tfile-2
430 grep old $DIR/$tfile-2 || error "grep $DIR/$tfile-2 failed"
432 run_test 19 "mcreate, open, write, rename "
434 test_20a() { # was test_20
435 replay_barrier $SINGLEMDS
436 multiop_bg_pause $DIR/$tfile O_tSc ||
437 error "multiop_bg_pause $DIR/$tfile failed"
442 kill -USR1 $pid || error "multiop $pid not running"
443 wait $pid || error "multiop $pid failed"
444 [ -e $DIR/$tfile ] && error "file $DIR/$tfile should not exist"
447 run_test 20a "|X| open(O_CREAT), unlink, replay, close (test mds_cleanup_orphans)"
449 test_20b() { # bug 10480
450 local wait_timeout=$((TIMEOUT * 4))
454 BEFOREUSED=$(df -P $DIR | tail -1 | awk '{ print $3 }')
455 dd if=/dev/zero of=$DIR/$tfile bs=4k count=10000 &
456 while [ ! -e $DIR/$tfile ] ; do
457 usleep 60 # give dd a chance to start
460 $GETSTRIPE $DIR/$tfile || error "$GETSTRIPE $DIR/$tfile failed"
462 rm -f $DIR/$tfile || error "rm -f $DIR/$tfile failed"
464 client_up || client_up || true # reconnect
466 do_facet $SINGLEMDS "lctl set_param -n osd*.*MDT*.force_sync 1"
468 fail $SINGLEMDS # start orphan recovery
469 wait_recovery_complete $SINGLEMDS || error "MDS recovery not done"
470 wait_delete_completed_mds $wait_timeout ||
471 error "delete did not complete"
473 AFTERUSED=$(df -P $DIR | tail -1 | awk '{ print $3 }')
474 log "before $BEFOREUSED, after $AFTERUSED"
475 (( $AFTERUSED > $BEFOREUSED + $(fs_log_size) )) &&
476 error "after $AFTERUSED > before $BEFOREUSED"
479 run_test 20b "write, unlink, eviction, replay, (test mds_cleanup_orphans)"
481 test_20c() { # bug 10480
482 multiop_bg_pause $DIR/$tfile Ow_c ||
483 error "multiop_bg_pause $DIR/$tfile failed"
489 client_up || client_up || true # reconnect
491 kill -USR1 $pid || error "multiop $pid not running"
492 wait $pid || error "multiop $pid failed"
493 [ -s $DIR/$tfile ] || error "File was truncated"
497 run_test 20c "check that client eviction does not affect file content"
500 replay_barrier $SINGLEMDS
501 multiop_bg_pause $DIR/$tfile O_tSc ||
502 error "multiop_bg_pause $DIR/$tfile failed"
505 touch $DIR/$tfile-1 || error "touch $DIR/$tfile-1 failed"
508 kill -USR1 $pid || error "multiop $pid not running"
509 wait $pid || error "multiop $pid failed"
510 [ -e $DIR/$tfile ] && error "file $DIR/$tfile should not exist"
511 touch $DIR/$tfile-2 || error "touch $DIR/$tfile-2 failed"
514 run_test 21 "|X| open(O_CREAT), unlink touch new, replay, close (test mds_cleanup_orphans)"
517 multiop_bg_pause $DIR/$tfile O_tSc ||
518 error "multiop_bg_pause $DIR/$tfile failed"
521 replay_barrier $SINGLEMDS
525 kill -USR1 $pid || error "multiop $pid not running"
526 wait $pid || error "multiop $pid failed"
527 [ -e $DIR/$tfile ] && error "file $DIR/$tfile should not exist"
530 run_test 22 "open(O_CREAT), |X| unlink, replay, close (test mds_cleanup_orphans)"
533 multiop_bg_pause $DIR/$tfile O_tSc ||
534 error "multiop_bg_pause $DIR/$tfile failed"
537 replay_barrier $SINGLEMDS
539 touch $DIR/$tfile-1 || error "touch $DIR/$tfile-1 failed"
542 kill -USR1 $pid || error "multiop $pid not running"
543 wait $pid || error "multiop $pid failed"
544 [ -e $DIR/$tfile ] && error "file $DIR/$tfile should not exist"
545 touch $DIR/$tfile-2 || error "touch $DIR/$tfile-2 failed"
548 run_test 23 "open(O_CREAT), |X| unlink touch new, replay, close (test mds_cleanup_orphans)"
551 multiop_bg_pause $DIR/$tfile O_tSc ||
552 error "multiop_bg_pause $DIR/$tfile failed"
555 replay_barrier $SINGLEMDS
558 kill -USR1 $pid || error "multiop $pid not running"
559 wait $pid || error "multiop $pid failed"
560 [ -e $DIR/$tfile ] && error "file $DIR/$tfile should not exist"
563 run_test 24 "open(O_CREAT), replay, unlink, close (test mds_cleanup_orphans)"
566 multiop_bg_pause $DIR/$tfile O_tSc ||
567 error "multiop_bg_pause $DIR/$tfile failed"
571 replay_barrier $SINGLEMDS
573 kill -USR1 $pid || error "multiop $pid not running"
574 wait $pid || error "multiop $pid failed"
575 [ -e $DIR/$tfile ] && error "file $DIR/$tfile should not exist"
578 run_test 25 "open(O_CREAT), unlink, replay, close (test mds_cleanup_orphans)"
581 replay_barrier $SINGLEMDS
582 multiop_bg_pause $DIR/$tfile-1 O_tSc ||
583 error "multiop_bg_pause $DIR/$tfile-1 failed"
585 multiop_bg_pause $DIR/$tfile-2 O_tSc ||
586 error "multiop_bg_pause $DIR/$tfile-2 failed"
590 kill -USR1 $pid2 || error "second multiop $pid2 not running"
591 wait $pid2 || error "second multiop $pid2 failed"
594 kill -USR1 $pid1 || error "multiop $pid1 not running"
595 wait $pid1 || error "multiop $pid1 failed"
596 [ -e $DIR/$tfile-1 ] && error "file $DIR/$tfile-1 should not exist"
597 [ -e $DIR/$tfile-2 ] && error "file $DIR/$tfile-2 should not exist"
600 run_test 26 "|X| open(O_CREAT), unlink two, close one, replay, close one (test mds_cleanup_orphans)"
603 replay_barrier $SINGLEMDS
604 multiop_bg_pause $DIR/$tfile-1 O_tSc ||
605 error "multiop_bg_pause $DIR/$tfile-1 failed"
607 multiop_bg_pause $DIR/$tfile-2 O_tSc ||
608 error "multiop_bg_pause $DIR/$tfile-2 failed"
614 kill -USR1 $pid1 || error "multiop $pid1 not running"
615 wait $pid1 || error "multiop $pid1 failed"
616 kill -USR1 $pid2 || error "second multiop $pid2 not running"
617 wait $pid2 || error "second multiop $pid2 failed"
618 [ -e $DIR/$tfile-1 ] && error "file $DIR/$tfile-1 should not exist"
619 [ -e $DIR/$tfile-2 ] && error "file $DIR/$tfile-2 should not exist"
622 run_test 27 "|X| open(O_CREAT), unlink two, replay, close two (test mds_cleanup_orphans)"
625 multiop_bg_pause $DIR/$tfile-1 O_tSc ||
626 error "multiop_bg_pause $DIR/$tfile-1 failed"
628 multiop_bg_pause $DIR/$tfile-2 O_tSc ||
629 error "multiop_bg_pause $DIR/$tfile-2 failed"
631 replay_barrier $SINGLEMDS
634 kill -USR1 $pid2 || error "second multiop $pid2 not running"
635 wait $pid2 || error "second multiop $pid2 failed"
638 kill -USR1 $pid1 || error "multiop $pid1 not running"
639 wait $pid1 || error "multiop $pid1 failed"
640 [ -e $DIR/$tfile-1 ] && error "file $DIR/$tfile-1 should not exist"
641 [ -e $DIR/$tfile-2 ] && error "file $DIR/$tfile-2 should not exist"
644 run_test 28 "open(O_CREAT), |X| unlink two, close one, replay, close one (test mds_cleanup_orphans)"
647 multiop_bg_pause $DIR/$tfile-1 O_tSc ||
648 error "multiop_bg_pause $DIR/$tfile-1 failed"
650 multiop_bg_pause $DIR/$tfile-2 O_tSc ||
651 error "multiop_bg_pause $DIR/$tfile-2 failed"
653 replay_barrier $SINGLEMDS
658 kill -USR1 $pid1 || error "multiop $pid1 not running"
659 wait $pid1 || error "multiop $pid1 failed"
660 kill -USR1 $pid2 || error "second multiop $pid2 not running"
661 wait $pid2 || error "second multiop $pid2 failed"
662 [ -e $DIR/$tfile-1 ] && error "file $DIR/$tfile-1 should not exist"
663 [ -e $DIR/$tfile-2 ] && error "file $DIR/$tfile-2 should not exist"
666 run_test 29 "open(O_CREAT), |X| unlink two, replay, close two (test mds_cleanup_orphans)"
669 multiop_bg_pause $DIR/$tfile-1 O_tSc ||
670 error "multiop_bg_pause $DIR/$tfile-1 failed"
672 multiop_bg_pause $DIR/$tfile-2 O_tSc ||
673 error "multiop_bg_pause $DIR/$tfile-2 failed"
678 replay_barrier $SINGLEMDS
680 kill -USR1 $pid1 || error "multiop $pid1 not running"
681 wait $pid1 || error "multiop $pid1 failed"
682 kill -USR1 $pid2 || error "second multiop $pid2 not running"
683 wait $pid2 || error "second multiop $pid2 failed"
684 [ -e $DIR/$tfile-1 ] && error "file $DIR/$tfile-1 should not exist"
685 [ -e $DIR/$tfile-2 ] && error "file $DIR/$tfile-2 should not exist"
688 run_test 30 "open(O_CREAT) two, unlink two, replay, close two (test mds_cleanup_orphans)"
691 multiop_bg_pause $DIR/$tfile-1 O_tSc ||
692 error "multiop_bg_pause $DIR/$tfile-1 failed"
694 multiop_bg_pause $DIR/$tfile-2 O_tSc ||
695 error "multiop_bg_pause $DIR/$tfile-2 failed"
699 replay_barrier $SINGLEMDS
702 kill -USR1 $pid1 || error "multiop $pid1 not running"
703 wait $pid1 || error "multiop $pid1 failed"
704 kill -USR1 $pid2 || error "second multiop $pid2 not running"
705 wait $pid2 || error "second multiop $pid2 failed"
706 [ -e $DIR/$tfile-1 ] && error "file $DIR/$tfile-1 should not exist"
707 [ -e $DIR/$tfile-2 ] && error "file $DIR/$tfile-2 should not exist"
710 run_test 31 "open(O_CREAT) two, unlink one, |X| unlink one, close two (test mds_cleanup_orphans)"
712 # tests for bug 2104; completion without crashing is success. The close is
713 # stale, but we always return 0 for close, so the app never sees it.
715 multiop_bg_pause $DIR/$tfile O_c ||
716 error "multiop_bg_pause $DIR/$tfile failed"
718 multiop_bg_pause $DIR/$tfile O_c ||
719 error "second multiop_bg_pause $DIR/$tfile failed"
722 client_up || client_up || error "client_up failed"
723 kill -USR1 $pid1 || error "multiop $pid1 not running"
724 kill -USR1 $pid2 || error "second multiop $pid2 not running"
725 wait $pid1 || error "multiop $pid1 failed"
726 wait $pid2 || error "second multiop $pid2 failed"
729 run_test 32 "close() notices client eviction; close() after client eviction"
732 createmany -o $DIR/$tfile-%d 10 ||
733 error "createmany create $DIR/$tfile failed"
734 replay_barrier_nosync $SINGLEMDS
735 fail_abort $SINGLEMDS
736 # recreate shouldn't fail
737 createmany -o $DIR/$tfile--%d 10 ||
738 error "createmany recreate $DIR/$tfile failed"
742 run_test 33a "fid seq shouldn't be reused after abort recovery"
745 #define OBD_FAIL_SEQ_ALLOC 0x1311
746 do_facet $SINGLEMDS "lctl set_param fail_loc=0x1311"
748 createmany -o $DIR/$tfile-%d 10
749 replay_barrier_nosync $SINGLEMDS
750 fail_abort $SINGLEMDS
751 # recreate shouldn't fail
752 createmany -o $DIR/$tfile--%d 10 ||
753 error "createmany recreate $DIR/$tfile failed"
757 run_test 33b "test fid seq allocation"
760 multiop_bg_pause $DIR/$tfile O_c ||
761 error "multiop_bg_pause $DIR/$tfile failed"
765 replay_barrier $SINGLEMDS
766 fail_abort $SINGLEMDS
767 kill -USR1 $pid || error "multiop $pid not running"
768 wait $pid || error "multiop $pid failed"
769 [ -e $DIR/$tfile ] && error "file $DIR/$tfile should not exist"
773 run_test 34 "abort recovery before client does replay (test mds_cleanup_orphans)"
775 # bug 2278 - generate one orphan on OST, then destroy it during recovery from llog
777 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
779 #define OBD_FAIL_MDS_REINT_NET_REP 0x119
780 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000119"
785 # give a chance to remove from MDS
786 fail_abort $SINGLEMDS
787 $CHECKSTAT -t file $DIR/$tfile &&
788 error "$CHECKSTAT $DIR/$tfile attribute check should fail" ||
791 run_test 35 "test recovery from llog for unlink op"
793 # b=2432 resent cancel after replay uses wrong cookie,
794 # so don't resend cancels
796 replay_barrier $SINGLEMDS
798 checkstat $DIR/$tfile
799 facet_failover $SINGLEMDS
801 if dmesg | grep "unknown lock cookie"; then
802 error "cancel after replay failed"
805 run_test 36 "don't resend cancel"
808 # directory orphans can't be unlinked from PENDING directory
810 rmdir $DIR/$tfile 2>/dev/null
811 multiop_bg_pause $DIR/$tfile dD_c ||
812 error "multiop_bg_pause $DIR/$tfile failed"
816 replay_barrier $SINGLEMDS
817 # clear the dmesg buffer so we only see errors from this recovery
818 do_facet $SINGLEMDS dmesg -c >/dev/null
819 fail_abort $SINGLEMDS
820 kill -USR1 $pid || error "multiop $pid not running"
821 do_facet $SINGLEMDS dmesg | grep "error .* unlinking .* from PENDING" &&
822 error "error unlinking files"
823 wait $pid || error "multiop $pid failed"
827 run_test 37 "abort recovery before client does replay (test mds_cleanup_orphans for directories)"
830 createmany -o $DIR/$tfile-%d 800 ||
831 error "createmany -o $DIR/$tfile failed"
832 unlinkmany $DIR/$tfile-%d 0 400 || error "unlinkmany $DIR/$tfile failed"
833 replay_barrier $SINGLEMDS
835 unlinkmany $DIR/$tfile-%d 400 400 ||
836 error "unlinkmany $DIR/$tfile 400 failed"
838 $CHECKSTAT -t file $DIR/$tfile-* &&
839 error "$CHECKSTAT $DIR/$tfile-* attribute check should fail" ||
842 run_test 38 "test recovery from unlink llog (test llog_gen_rec) "
844 test_39() { # bug 4176
845 createmany -o $DIR/$tfile-%d 800 ||
846 error "createmany -o $DIR/$tfile failed"
847 replay_barrier $SINGLEMDS
848 unlinkmany $DIR/$tfile-%d 0 400
850 unlinkmany $DIR/$tfile-%d 400 400 ||
851 error "unlinkmany $DIR/$tfile 400 failed"
853 $CHECKSTAT -t file $DIR/$tfile-* &&
854 error "$CHECKSTAT $DIR/$tfile-* attribute check should fail" ||
857 run_test 39 "test recovery from unlink llog (test llog_gen_rec) "
860 lctl get_param -n osc.*.stats | awk -vwrites=0 '/ost_write/ { writes += $2 } END { print writes; }'
865 # always need connection to MDS to verify layout during IO. LU-2628.
866 lctl get_param mdc.*.connect_flags | grep -q layout_lock &&
867 skip "layout_lock needs MDS connection for IO" && return 0
869 $LCTL mark multiop $MOUNT/$tfile OS_c
870 multiop $MOUNT/$tfile OS_c &
872 writeme -s $MOUNT/${tfile}-2 &
875 facet_failover $SINGLEMDS
876 #define OBD_FAIL_MDS_CONNECT_NET 0x117
877 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000117"
879 stat1=$(count_ost_writes)
881 stat2=$(count_ost_writes)
882 echo "$stat1, $stat2"
883 if [ $stat1 -lt $stat2 ]; then
884 echo "writes continuing during recovery"
887 echo "writes not continuing during recovery, bug 2477"
890 echo "waiting for writeme $WRITE_PID"
894 echo "waiting for multiop $PID"
895 wait $PID || error "multiop $PID failed"
896 do_facet client munlink $MOUNT/$tfile ||
897 error "munlink $MOUNT/$tfile failed"
898 do_facet client munlink $MOUNT/${tfile}-2 ||
899 error "munlink $MOUNT/$tfile-2 failed"
902 run_test 40 "cause recovery in ptlrpc, ensure IO continues"
905 # make sure that a read to one osc doesn't try to double-unlock its page just
906 # because another osc is invalid. trigger_group_io used to mistakenly return
907 # an error if any oscs were invalid even after having successfully put rpcs
908 # on valid oscs. This was fatal if the caller was ll_readpage who unlocked
909 # the page, guarnateeing that the unlock from the RPC completion would
910 # assert on trying to unlock the unlocked page.
912 [ $OSTCOUNT -lt 2 ] &&
913 skip_env "skipping test 41: we don't have a second OST to test with" &&
916 local f=$MOUNT/$tfile
917 # make sure the start of the file is ost1
918 $SETSTRIPE -S $((128 * 1024)) -i 0 $f
919 do_facet client dd if=/dev/zero of=$f bs=4k count=1 ||
920 error "dd on client failed"
922 # fail ost2 and read from ost1
923 local mdtosc=$(get_mdtosc_proc_path $SINGLEMDS $ost2_svc)
924 local osc2dev=$(do_facet $SINGLEMDS "lctl get_param -n devices" |
925 grep $mdtosc | awk '{print $1}')
926 [ -z "$osc2dev" ] && echo "OST: $ost2_svc" &&
927 lctl get_param -n devices &&
928 error "OST 2 $osc2dev does not exist"
929 do_facet $SINGLEMDS $LCTL --device $osc2dev deactivate ||
930 error "deactive device on $SINGLEMDS failed"
931 do_facet client dd if=$f of=/dev/null bs=4k count=1 ||
932 error "second dd on client failed"
933 do_facet $SINGLEMDS $LCTL --device $osc2dev activate ||
934 error "active device on $SINGLEMDS failed"
937 run_test 41 "read from a valid osc while other oscs are invalid"
939 # test MDS recovery after ost failure
941 blocks=$(df -P $MOUNT | tail -n 1 | awk '{ print $2 }')
942 createmany -o $DIR/$tfile-%d 800 ||
943 error "createmany -o $DIR/$tfile failed"
945 unlinkmany $DIR/$tfile-%d 0 400
947 lctl set_param debug=-1
950 # osc is evicted, fs is smaller (but only with failout OSTs (bug 7287)
951 #blocks_after=`df -P $MOUNT | tail -n 1 | awk '{ print $2 }'`
952 #[ $blocks_after -lt $blocks ] || return 1
953 echo "wait for MDS to timeout and recover"
954 sleep $((TIMEOUT * 2))
956 unlinkmany $DIR/$tfile-%d 400 400 ||
957 error "unlinkmany $DIR/$tfile 400 failed"
958 $CHECKSTAT -t file $DIR/$tfile-* &&
959 error "$CHECKSTAT $DIR/$tfile-* attribute check should fail" ||
962 run_test 42 "recovery after ost failure"
964 # timeout in MDS/OST recovery RPC will LBUG MDS
965 test_43() { # bug 2530
966 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
968 replay_barrier $SINGLEMDS
970 # OBD_FAIL_OST_CREATE_NET 0x204
971 do_facet ost1 "lctl set_param fail_loc=0x80000204"
977 run_test 43 "mds osc import failure during recovery; don't LBUG"
979 test_44a() { # was test_44
982 local mdcdev=$($LCTL dl |
983 awk "/${FSNAME}-MDT0000-mdc-/ {if (\$2 == \"UP\") {print \$1}}")
984 [ "$mdcdev" ] || error "${FSNAME}-MDT0000-mdc- not UP"
985 [ $(echo $mdcdev | wc -w) -eq 1 ] ||
986 { $LCTL dl; error "looking for mdcdev=$mdcdev"; }
988 # adaptive timeouts slow this way down
989 if at_is_enabled; then
990 at_max_saved=$(at_max_get mds)
994 for i in $(seq 1 10); do
995 echo "$i of 10 ($(date +%s))"
996 do_facet $SINGLEMDS \
997 "lctl get_param -n md[ts].*.mdt.timeouts | grep service"
998 #define OBD_FAIL_TGT_CONN_RACE 0x701
999 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000701"
1000 # lctl below may fail, it is valid case
1001 $LCTL --device $mdcdev recover
1004 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
1005 [ $at_max_saved -ne 0 ] && at_max_set $at_max_saved mds
1008 run_test 44a "race in target handle connect"
1011 local mdcdev=$($LCTL dl |
1012 awk "/${FSNAME}-MDT0000-mdc-/ {if (\$2 == \"UP\") {print \$1}}")
1013 [ "$mdcdev" ] || error "${FSNAME}-MDT0000-mdc not up"
1014 [ $(echo $mdcdev | wc -w) -eq 1 ] ||
1015 { echo mdcdev=$mdcdev; $LCTL dl;
1016 error "more than one ${FSNAME}-MDT0000-mdc"; }
1018 for i in $(seq 1 10); do
1019 echo "$i of 10 ($(date +%s))"
1020 do_facet $SINGLEMDS \
1021 "lctl get_param -n md[ts].*.mdt.timeouts | grep service"
1022 #define OBD_FAIL_TGT_DELAY_RECONNECT 0x704
1023 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000704"
1024 # lctl below may fail, it is valid case
1025 $LCTL --device $mdcdev recover
1030 run_test 44b "race in target handle connect"
1033 replay_barrier $SINGLEMDS
1034 createmany -m $DIR/$tfile-%d 100 || error "failed to create directories"
1035 #define OBD_FAIL_TGT_RCVG_FLAG 0x712
1036 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000712"
1037 fail_abort $SINGLEMDS
1038 unlinkmany $DIR/$tfile-%d 100 && error "unliked after fail abort"
1040 unlinkmany $DIR/$tfile-%d 100 && error "unliked after fail"
1043 run_test 44c "race in target handle connect"
1045 # Handle failed close
1047 local mdcdev=$($LCTL get_param -n devices |
1048 awk "/ ${FSNAME}-MDT0000-mdc-/ {print \$1}")
1049 [ "$mdcdev" ] || error "${FSNAME}-MDT0000-mdc not up"
1050 [ $(echo $mdcdev | wc -w) -eq 1 ] ||
1051 { echo mdcdev=$mdcdev; $LCTL dl;
1052 error "more than one ${FSNAME}-MDT0000-mdc"; }
1054 $LCTL --device $mdcdev recover ||
1055 error "$LCTL --device $mdcdev recover failed"
1057 multiop_bg_pause $DIR/$tfile O_c ||
1058 error "multiop_bg_pause $DIR/$tfile failed"
1061 # This will cause the CLOSE to fail before even
1062 # allocating a reply buffer
1063 $LCTL --device $mdcdev deactivate ||
1064 error "$LCTL --device $mdcdev deactivate failed"
1067 kill -USR1 $pid || error "multiop $pid not running"
1068 wait $pid || error "multiop $pid failed"
1070 $LCTL --device $mdcdev activate ||
1071 error "$LCTL --device $mdcdev activate failed"
1074 $CHECKSTAT -t file $DIR/$tfile ||
1075 error "$CHECKSTAT $DIR/$tfile attribute check failed"
1078 run_test 45 "Handle failed close"
1082 drop_reply "touch $DIR/$tfile"
1084 # ironically, the previous test, 45, will cause a real forced close,
1085 # so just look for one for this test
1086 dmesg | grep -i "force closing client file handle for $tfile" &&
1087 error "found force closing in dmesg"
1090 run_test 46 "Don't leak file handle after open resend (3325)"
1092 test_47() { # bug 2824
1093 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1095 # create some files to make sure precreate has been done on all
1096 # OSTs. (just in case this test is run independently)
1097 createmany -o $DIR/$tfile 20 ||
1098 error "createmany create $DIR/$tfile failed"
1100 # OBD_FAIL_OST_CREATE_NET 0x204
1102 do_facet ost1 "lctl set_param fail_loc=0x80000204"
1103 client_up || error "client_up failed"
1105 # let the MDS discover the OST failure, attempt to recover, fail
1106 # and recover again.
1107 sleep $((3 * TIMEOUT))
1109 # Without 2824, this createmany would hang
1110 createmany -o $DIR/$tfile 20 ||
1111 error "createmany recraete $DIR/$tfile failed"
1112 unlinkmany $DIR/$tfile 20 || error "unlinkmany $DIR/$tfile failed"
1116 run_test 47 "MDS->OSC failure during precreate cleanup (2824)"
1119 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1120 [ "$OSTCOUNT" -lt "2" ] &&
1121 skip_env "$OSTCOUNT < 2 OSTs -- skipping" && return
1123 replay_barrier $SINGLEMDS
1124 createmany -o $DIR/$tfile 20 ||
1125 error "createmany -o $DIR/$tfile failed"
1126 # OBD_FAIL_OST_EROFS 0x216
1127 facet_failover $SINGLEMDS
1128 do_facet ost1 "lctl set_param fail_loc=0x80000216"
1129 client_up || error "client_up failed"
1131 createmany -o $DIR/$tfile 20 20 ||
1132 error "createmany recraete $DIR/$tfile failed"
1133 unlinkmany $DIR/$tfile 40 || error "unlinkmany $DIR/$tfile failed"
1136 run_test 48 "MDS->OSC failure during precreate cleanup (2824)"
1139 local mdtosc=$(get_mdtosc_proc_path $SINGLEMDS $ost1_svc)
1140 local oscdev=$(do_facet $SINGLEMDS "lctl get_param -n devices" |
1141 grep $mdtosc | awk '{print $1}')
1142 [ "$oscdev" ] || error "could not find OSC device on MDS"
1143 do_facet $SINGLEMDS $LCTL --device $oscdev recover ||
1144 error "OSC device $oscdev recovery failed"
1145 do_facet $SINGLEMDS $LCTL --device $oscdev recover ||
1146 error "second OSC device $oscdev recovery failed"
1147 # give the mds_lov_sync threads a chance to run
1150 run_test 50 "Double OSC recovery, don't LASSERT (3812)"
1152 # b3764 timed out lock replay
1154 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.6.90) ] &&
1155 skip "MDS prior to 2.6.90 handle LDLM_REPLY_NET incorrectly" &&
1158 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
1159 cancel_lru_locks mdc
1161 multiop_bg_pause $DIR/$tfile s_s || error "multiop $DIR/$tfile failed"
1164 #define OBD_FAIL_MDS_LDLM_REPLY_NET 0x157
1165 lctl set_param -n ldlm.cancel_unused_locks_before_replay "0"
1166 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000157"
1168 fail $SINGLEMDS || error "fail $SINGLEMDS failed"
1170 wait $mpid || error "multiop_bg_pause pid failed"
1172 do_facet $SINGLEMDS "lctl set_param fail_loc=0x0"
1173 lctl set_param fail_loc=0x0
1174 lctl set_param -n ldlm.cancel_unused_locks_before_replay "1"
1177 run_test 52 "time out lock replay (3764)"
1179 # bug 3462 - simultaneous MDC requests
1181 cancel_lru_locks mdc # cleanup locks from former test cases
1182 mkdir $DIR/${tdir}-1 || error "mkdir $DIR/${tdir}-1 failed"
1183 mkdir $DIR/${tdir}-2 || error "mkdir $DIR/${tdir}-2 failed"
1184 multiop $DIR/${tdir}-1/f O_c &
1186 # give multiop a change to open
1189 #define OBD_FAIL_MDS_CLOSE_NET 0x115
1190 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000115"
1191 kill -USR1 $close_pid
1192 cancel_lru_locks mdc # force the close
1193 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
1195 mcreate $DIR/${tdir}-2/f || error "mcreate $DIR/${tdir}-2/f failed"
1197 # close should still be here
1198 [ -d /proc/$close_pid ] || error "close_pid doesn't exist"
1200 replay_barrier_nodf $SINGLEMDS
1202 wait $close_pid || error "close_pid $close_pid failed"
1204 $CHECKSTAT -t file $DIR/${tdir}-1/f ||
1205 error "$CHECKSTAT $DIR/${tdir}-1/f attribute check failed"
1206 $CHECKSTAT -t file $DIR/${tdir}-2/f ||
1207 error "$CHECKSTAT $DIR/${tdir}-2/f attribute check failed"
1208 rm -rf $DIR/${tdir}-*
1210 run_test 53a "|X| close request while two MDC requests in flight"
1213 cancel_lru_locks mdc # cleanup locks from former test cases
1215 mkdir $DIR/${tdir}-1 || error "mkdir $DIR/${tdir}-1 failed"
1216 mkdir $DIR/${tdir}-2 || error "mkdir $DIR/${tdir}-2 failed"
1217 multiop_bg_pause $DIR/${tdir}-1/f O_c ||
1218 error "multiop_bg_pause $DIR/${tdir}-1/f failed"
1221 #define OBD_FAIL_MDS_REINT_NET 0x107
1222 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000107"
1223 mcreate $DIR/${tdir}-2/f &
1227 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
1228 kill -USR1 $close_pid
1229 cancel_lru_locks mdc # force the close
1230 wait $close_pid || error "close_pid $close_pid failed"
1231 # open should still be here
1232 [ -d /proc/$open_pid ] || error "open_pid doesn't exist"
1234 replay_barrier_nodf $SINGLEMDS
1236 wait $open_pid || error "open_pid failed"
1238 $CHECKSTAT -t file $DIR/${tdir}-1/f ||
1239 error "$CHECKSTAT $DIR/${tdir}-1/f attribute check failed"
1240 $CHECKSTAT -t file $DIR/${tdir}-2/f ||
1241 error "$CHECKSTAT $DIR/${tdir}-2/f attribute check failed"
1242 rm -rf $DIR/${tdir}-*
1244 run_test 53b "|X| open request while two MDC requests in flight"
1247 cancel_lru_locks mdc # cleanup locks from former test cases
1249 mkdir $DIR/${tdir}-1 || error "mkdir $DIR/${tdir}-1 failed"
1250 mkdir $DIR/${tdir}-2 || error "mkdir $DIR/${tdir}-2 failed"
1251 multiop $DIR/${tdir}-1/f O_c &
1254 #define OBD_FAIL_MDS_REINT_NET 0x107
1255 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000107"
1256 mcreate $DIR/${tdir}-2/f &
1260 #define OBD_FAIL_MDS_CLOSE_NET 0x115
1261 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000115"
1262 kill -USR1 $close_pid
1263 cancel_lru_locks mdc # force the close
1265 #bz20647: make sure all pids exist before failover
1266 [ -d /proc/$close_pid ] || error "close_pid doesn't exist"
1267 [ -d /proc/$open_pid ] || error "open_pid doesn't exists"
1268 replay_barrier_nodf $SINGLEMDS
1269 fail_nodf $SINGLEMDS
1270 wait $open_pid || error "open_pid failed"
1272 # close should be gone
1273 [ -d /proc/$close_pid ] && error "close_pid should not exist"
1274 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
1276 $CHECKSTAT -t file $DIR/${tdir}-1/f ||
1277 error "$CHECKSTAT $DIR/${tdir}-1/f attribute check failed"
1278 $CHECKSTAT -t file $DIR/${tdir}-2/f ||
1279 error "$CHECKSTAT $DIR/${tdir}-2/f attribute check failed"
1280 rm -rf $DIR/${tdir}-*
1282 run_test 53c "|X| open request and close request while two MDC requests in flight"
1285 cancel_lru_locks mdc # cleanup locks from former test cases
1287 mkdir $DIR/${tdir}-1 || error "mkdir $DIR/${tdir}-1 failed"
1288 mkdir $DIR/${tdir}-2 || error "mkdir $DIR/${tdir}-2 failed"
1289 multiop $DIR/${tdir}-1/f O_c &
1291 # give multiop a chance to open
1294 #define OBD_FAIL_MDS_CLOSE_NET_REP 0x13b
1295 do_facet $SINGLEMDS "lctl set_param fail_loc=0x8000013b"
1296 kill -USR1 $close_pid
1297 cancel_lru_locks mdc # force the close
1298 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
1299 mcreate $DIR/${tdir}-2/f || error "mcreate $DIR/${tdir}-2/f failed"
1301 # close should still be here
1302 [ -d /proc/$close_pid ] || error "close_pid doesn't exist"
1304 wait $close_pid || error "close_pid failed"
1306 $CHECKSTAT -t file $DIR/${tdir}-1/f ||
1307 error "$CHECKSTAT $DIR/${tdir}-1/f attribute check failed"
1308 $CHECKSTAT -t file $DIR/${tdir}-2/f ||
1309 error "$CHECKSTAT $DIR/${tdir}-2/f attribute check failed"
1310 rm -rf $DIR/${tdir}-*
1312 run_test 53d "close reply while two MDC requests in flight"
1315 cancel_lru_locks mdc # cleanup locks from former test cases
1317 mkdir $DIR/${tdir}-1 || error "mkdir $DIR/${tdir}-1 failed"
1318 mkdir $DIR/${tdir}-2 || error "mkdir $DIR/${tdir}-2 failed"
1319 multiop $DIR/${tdir}-1/f O_c &
1322 #define OBD_FAIL_MDS_REINT_NET_REP 0x119
1323 do_facet $SINGLEMDS "lctl set_param fail_loc=0x119"
1324 mcreate $DIR/${tdir}-2/f &
1328 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
1329 kill -USR1 $close_pid
1330 cancel_lru_locks mdc # force the close
1331 wait $close_pid || error "close_pid failed"
1332 # open should still be here
1333 [ -d /proc/$open_pid ] || error "open_pid doesn't exists"
1335 replay_barrier_nodf $SINGLEMDS
1337 wait $open_pid || error "open_pid failed"
1339 $CHECKSTAT -t file $DIR/${tdir}-1/f ||
1340 error "$CHECKSTAT $DIR/${tdir}-1/f attribute check failed"
1341 $CHECKSTAT -t file $DIR/${tdir}-2/f ||
1342 error "$CHECKSTAT $DIR/${tdir}-2/f attribute check failed"
1343 rm -rf $DIR/${tdir}-*
1345 run_test 53e "|X| open reply while two MDC requests in flight"
1348 cancel_lru_locks mdc # cleanup locks from former test cases
1350 mkdir $DIR/${tdir}-1 || error "mkdir $DIR/${tdir}-1 failed"
1351 mkdir $DIR/${tdir}-2 || error "mkdir $DIR/${tdir}-2 failed"
1352 multiop $DIR/${tdir}-1/f O_c &
1355 #define OBD_FAIL_MDS_REINT_NET_REP 0x119
1356 do_facet $SINGLEMDS "lctl set_param fail_loc=0x119"
1357 mcreate $DIR/${tdir}-2/f &
1361 #define OBD_FAIL_MDS_CLOSE_NET_REP 0x13b
1362 do_facet $SINGLEMDS "lctl set_param fail_loc=0x8000013b"
1363 kill -USR1 $close_pid
1364 cancel_lru_locks mdc # force the close
1366 #bz20647: make sure all pids are exists before failover
1367 [ -d /proc/$close_pid ] || error "close_pid doesn't exist"
1368 [ -d /proc/$open_pid ] || error "open_pid doesn't exists"
1369 replay_barrier_nodf $SINGLEMDS
1370 fail_nodf $SINGLEMDS
1371 wait $open_pid || error "open_pid failed"
1373 # close should be gone
1374 [ -d /proc/$close_pid ] && error "close_pid should not exist"
1375 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
1377 $CHECKSTAT -t file $DIR/${tdir}-1/f ||
1378 error "$CHECKSTAT $DIR/${tdir}-1/f attribute check failed"
1379 $CHECKSTAT -t file $DIR/${tdir}-2/f ||
1380 error "$CHECKSTAT $DIR/${tdir}-2/f attribute check failed"
1381 rm -rf $DIR/${tdir}-*
1383 run_test 53f "|X| open reply and close reply while two MDC requests in flight"
1386 cancel_lru_locks mdc # cleanup locks from former test cases
1388 mkdir $DIR/${tdir}-1 || error "mkdir $DIR/${tdir}-1 failed"
1389 mkdir $DIR/${tdir}-2 || error "mkdir $DIR/${tdir}-2 failed"
1390 multiop $DIR/${tdir}-1/f O_c &
1393 #define OBD_FAIL_MDS_REINT_NET_REP 0x119
1394 do_facet $SINGLEMDS "lctl set_param fail_loc=0x119"
1395 mcreate $DIR/${tdir}-2/f &
1399 #define OBD_FAIL_MDS_CLOSE_NET 0x115
1400 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000115"
1401 kill -USR1 $close_pid
1402 cancel_lru_locks mdc # force the close
1403 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
1405 #bz20647: make sure all pids are exists before failover
1406 [ -d /proc/$close_pid ] || error "close_pid doesn't exist"
1407 [ -d /proc/$open_pid ] || error "open_pid doesn't exists"
1408 replay_barrier_nodf $SINGLEMDS
1409 fail_nodf $SINGLEMDS
1410 wait $open_pid || error "open_pid failed"
1412 # close should be gone
1413 [ -d /proc/$close_pid ] && error "close_pid should not exist"
1415 $CHECKSTAT -t file $DIR/${tdir}-1/f ||
1416 error "$CHECKSTAT $DIR/${tdir}-1/f attribute check failed"
1417 $CHECKSTAT -t file $DIR/${tdir}-2/f ||
1418 error "$CHECKSTAT $DIR/${tdir}-2/f attribute check failed"
1419 rm -rf $DIR/${tdir}-*
1421 run_test 53g "|X| drop open reply and close request while close and open are both in flight"
1424 cancel_lru_locks mdc # cleanup locks from former test cases
1426 mkdir $DIR/${tdir}-1 || error "mkdir $DIR/${tdir}-1 failed"
1427 mkdir $DIR/${tdir}-2 || error "mkdir $DIR/${tdir}-2 failed"
1428 multiop $DIR/${tdir}-1/f O_c &
1431 #define OBD_FAIL_MDS_REINT_NET 0x107
1432 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000107"
1433 mcreate $DIR/${tdir}-2/f &
1437 #define OBD_FAIL_MDS_CLOSE_NET_REP 0x13b
1438 do_facet $SINGLEMDS "lctl set_param fail_loc=0x8000013b"
1439 kill -USR1 $close_pid
1440 cancel_lru_locks mdc # force the close
1443 #bz20647: make sure all pids are exists before failover
1444 [ -d /proc/$close_pid ] || error "close_pid doesn't exist"
1445 [ -d /proc/$open_pid ] || error "open_pid doesn't exists"
1446 replay_barrier_nodf $SINGLEMDS
1447 fail_nodf $SINGLEMDS
1448 wait $open_pid || error "open_pid failed"
1450 # close should be gone
1451 [ -d /proc/$close_pid ] && error "close_pid should not exist"
1452 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
1454 $CHECKSTAT -t file $DIR/${tdir}-1/f ||
1455 error "$CHECKSTAT $DIR/${tdir}-1/f attribute check failed"
1456 $CHECKSTAT -t file $DIR/${tdir}-2/f ||
1457 error "$CHECKSTAT $DIR/${tdir}-2/f attribute check failed"
1458 rm -rf $DIR/${tdir}-*
1460 run_test 53h "open request and close reply while two MDC requests in flight"
1462 #b3761 ASSERTION(hash != 0) failed
1464 # OBD_FAIL_MDS_OPEN_CREATE | OBD_FAIL_ONCE
1465 do_facet $SINGLEMDS "lctl set_param fail_loc=0x8000012b"
1467 # give touch a chance to run
1469 do_facet $SINGLEMDS "lctl set_param fail_loc=0x0"
1473 run_test 55 "let MDS_CHECK_RESENT return the original return code instead of 0"
1475 #b3440 ASSERTION(rec->ur_fid2->id) failed
1477 ln -s foo $DIR/$tfile
1478 replay_barrier $SINGLEMDS
1479 #drop_reply "cat $DIR/$tfile"
1483 run_test 56 "don't replay a symlink open request (3440)"
1485 #recovery one mds-ost setattr from llog
1487 #define OBD_FAIL_MDS_OST_SETATTR 0x12c
1488 do_facet $SINGLEMDS "lctl set_param fail_loc=0x8000012c"
1489 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
1490 replay_barrier $SINGLEMDS
1493 $CHECKSTAT -t file $DIR/$tfile ||
1494 error "$CHECKSTAT $DIR/$tfile attribute check failed"
1495 do_facet $SINGLEMDS "lctl set_param fail_loc=0x0"
1498 run_test 57 "test recovery from llog for setattr op"
1501 zconf_umount $(hostname) $MOUNT2
1505 #recovery many mds-ost setattr from llog
1507 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
1508 #define OBD_FAIL_MDS_OST_SETATTR 0x12c
1509 do_facet $SINGLEMDS "lctl set_param fail_loc=0x8000012c"
1510 createmany -o $DIR/$tdir/$tfile-%d 2500
1511 replay_barrier $SINGLEMDS
1514 $CHECKSTAT -t file $DIR/$tdir/$tfile-* >/dev/null ||
1515 error "$CHECKSTAT $DIR/$tfile-* attribute check failed"
1516 do_facet $SINGLEMDS "lctl set_param fail_loc=0x0"
1517 unlinkmany $DIR/$tdir/$tfile-%d 2500 ||
1518 error "unlinkmany $DIR/$tfile failed"
1521 run_test 58a "test recovery from llog for setattr op (test llog_gen_rec)"
1527 trap cleanup_58 EXIT
1529 large_xattr_enabled &&
1530 orig="$(generate_string $(max_xattr_size))" || orig="bar"
1532 mount_client $MOUNT2
1533 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
1534 touch $DIR/$tdir/$tfile || error "touch $DIR/$tdir/$tfile failed"
1535 replay_barrier $SINGLEMDS
1536 setfattr -n trusted.foo -v $orig $DIR/$tdir/$tfile
1538 new=$(get_xattr_value trusted.foo $MOUNT2/$tdir/$tfile)
1539 [[ "$new" = "$orig" ]] ||
1540 error "xattr set ($orig) is not what was returned ($new)"
1541 rm -f $DIR/$tdir/$tfile
1545 run_test 58b "test replay of setxattr op"
1547 test_58c() { # bug 16570
1552 trap cleanup_58 EXIT
1554 if large_xattr_enabled; then
1555 local xattr_size=$(max_xattr_size)
1556 orig="$(generate_string $((xattr_size / 2)))"
1557 orig1="$(generate_string $xattr_size)"
1563 mount_client $MOUNT2
1564 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
1565 touch $DIR/$tdir/$tfile || error "touch $DIR/$tdir/$tfile failed"
1566 drop_request "setfattr -n trusted.foo -v $orig $DIR/$tdir/$tfile" ||
1567 error "drop_request for setfattr failed"
1568 new=$(get_xattr_value trusted.foo $MOUNT2/$tdir/$tfile)
1569 [[ "$new" = "$orig" ]] ||
1570 error "xattr set ($orig) is not what was returned ($new)"
1571 drop_reint_reply "setfattr -n trusted.foo1 \
1572 -v $orig1 $DIR/$tdir/$tfile" ||
1573 error "drop_request for setfattr failed"
1574 new=$(get_xattr_value trusted.foo1 $MOUNT2/$tdir/$tfile)
1575 [[ "$new" = "$orig1" ]] ||
1576 error "second xattr set ($orig1) not what was returned ($new)"
1577 rm -f $DIR/$tdir/$tfile
1581 run_test 58c "resend/reconstruct setxattr op"
1583 # log_commit_thread vs filter_destroy race used to lead to import use after free
1586 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1588 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
1589 createmany -o $DIR/$tdir/$tfile-%d 200 ||
1590 error "createmany create files failed"
1592 unlinkmany $DIR/$tdir/$tfile-%d 200 ||
1593 error "unlinkmany $DIR/$tdir/$tfile failed"
1594 #define OBD_FAIL_PTLRPC_DELAY_RECOV 0x507
1595 do_facet ost1 "lctl set_param fail_loc=0x507"
1598 do_facet ost1 "lctl set_param fail_loc=0x0"
1602 run_test 59 "test log_commit_thread vs filter_destroy race"
1604 # race between add unlink llog vs cat log init in post_recovery (only for b1_6)
1605 # bug 12086: should no oops and No ctxt error for this test
1607 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
1608 createmany -o $DIR/$tdir/$tfile-%d 200 ||
1609 error "createmany create files failed"
1610 replay_barrier $SINGLEMDS
1611 unlinkmany $DIR/$tdir/$tfile-%d 0 100
1613 unlinkmany $DIR/$tdir/$tfile-%d 100 100
1614 local no_ctxt=$(dmesg | grep "No ctxt")
1615 [ -z "$no_ctxt" ] || error "ctxt is not initialized in recovery"
1617 run_test 60 "test llog post recovery init vs llog unlink"
1619 #test race llog recovery thread vs llog cleanup
1620 test_61a() { # was test_61
1621 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1623 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
1624 createmany -o $DIR/$tdir/$tfile-%d 800 ||
1625 error "createmany create files failed"
1627 unlinkmany $DIR/$tdir/$tfile-%d 800
1628 # OBD_FAIL_OST_LLOG_RECOVERY_TIMEOUT 0x221
1629 set_nodes_failloc "$(osts_nodes)" 0x80000221
1634 set_nodes_failloc "$(osts_nodes)" 0x0
1636 $CHECKSTAT -t file $DIR/$tdir/$tfile-* &&
1637 error "$CHECKSTAT $DIR/$tdir/$tfile attribute check should fail"
1640 run_test 61a "test race llog recovery vs llog cleanup"
1642 #test race mds llog sync vs llog cleanup
1644 # OBD_FAIL_MDS_LLOG_SYNC_TIMEOUT 0x13a
1645 do_facet $SINGLEMDS "lctl set_param fail_loc=0x8000013a"
1646 facet_failover $SINGLEMDS
1649 do_facet client dd if=/dev/zero of=$DIR/$tfile bs=4k count=1 ||
1652 run_test 61b "test race mds llog sync vs llog cleanup"
1654 #test race cancel cookie cb vs llog cleanup
1656 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1658 # OBD_FAIL_OST_CANCEL_COOKIE_TIMEOUT 0x222
1659 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
1660 set_nodes_failloc "$(osts_nodes)" 0x80000222
1664 set_nodes_failloc "$(osts_nodes)" 0x0
1666 run_test 61c "test race mds llog sync vs llog cleanup"
1668 test_61d() { # bug 16002 # bug 17466 # bug 22137
1669 # OBD_FAIL_OBD_LLOG_SETUP 0x605
1671 do_facet mgs "lctl set_param fail_loc=0x80000605"
1672 start mgs $(mgsdevname) $MGS_MOUNT_OPTS &&
1673 error "mgs start should have failed"
1674 do_facet mgs "lctl set_param fail_loc=0"
1675 start mgs $(mgsdevname) $MGS_MOUNT_OPTS || error "cannot restart mgs"
1677 run_test 61d "error in llog_setup should cleanup the llog context correctly"
1679 test_62() { # Bug 15756 - don't mis-drop resent replay
1680 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
1681 replay_barrier $SINGLEMDS
1682 createmany -o $DIR/$tdir/$tfile- 25 ||
1683 error "createmany create files failed"
1684 #define OBD_FAIL_TGT_REPLAY_DROP 0x707
1685 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000707"
1687 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
1688 unlinkmany $DIR/$tdir/$tfile- 25 ||
1689 error "unlinkmany $DIR/$tdir/$tfile failed"
1692 run_test 62 "don't mis-drop resent replay"
1694 #Adaptive Timeouts (bug 3055)
1702 echo "Cleaning up AT ..."
1703 if [ -n "$ATOLDBASE" ]; then
1704 local at_history=$($LCTL get_param -n at_history)
1705 do_facet $SINGLEMDS "lctl set_param at_history=$at_history" || true
1706 do_facet ost1 "lctl set_param at_history=$at_history" || true
1709 if [ $AT_MAX_SET -ne 0 ]; then
1710 for facet in mds client ost; do
1711 var=AT_MAX_SAVE_${facet}
1712 echo restore AT on $facet to saved value ${!var}
1713 at_max_set ${!var} $facet
1714 at_new=$(at_max_get $facet)
1715 echo Restored AT value on $facet $at_new
1716 [ $at_new -eq ${!var} ] ||
1717 error "AT value not restored SAVED ${!var} NEW $at_new"
1724 local at_max_new=600
1726 # Save at_max original values
1728 if [ $AT_MAX_SET -eq 0 ]; then
1729 # Suppose that all osts have the same at_max
1730 for facet in mds client ost; do
1731 eval AT_MAX_SAVE_${facet}=$(at_max_get $facet)
1735 for facet in mds client ost; do
1736 at_max=$(at_max_get $facet)
1737 if [ $at_max -ne $at_max_new ]; then
1738 echo "AT value on $facet is $at_max, set it by force temporarily to $at_max_new"
1739 at_max_set $at_max_new $facet
1744 if [ -z "$ATOLDBASE" ]; then
1745 ATOLDBASE=$(do_facet $SINGLEMDS "lctl get_param -n at_history")
1746 # speed up the timebase so we can check decreasing AT
1747 do_facet $SINGLEMDS "lctl set_param at_history=8" || true
1748 do_facet ost1 "lctl set_param at_history=8" || true
1750 # sleep for a while to cool down, should be > 8s and also allow
1751 # at least one ping to be sent. simply use TIMEOUT to be safe.
1756 test_65a() #bug 3055
1758 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1760 at_start || return 0
1761 $LCTL dk > /dev/null
1763 $LCTL set_param debug="other"
1764 # Slow down a request to the current service time, this is critical
1765 # because previous tests may have caused this value to increase.
1766 REQ_DELAY=`lctl get_param -n mdc.${FSNAME}-MDT0000-mdc-*.timeouts |
1767 awk '/portal 12/ {print $5}'`
1768 REQ_DELAY=$((${REQ_DELAY} + ${REQ_DELAY} / 4 + 5))
1770 do_facet $SINGLEMDS lctl set_param fail_val=$((${REQ_DELAY} * 1000))
1771 #define OBD_FAIL_PTLRPC_PAUSE_REQ 0x50a
1772 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x8000050a
1773 createmany -o $DIR/$tfile 10 > /dev/null
1774 unlinkmany $DIR/$tfile 10 > /dev/null
1775 # check for log message
1776 $LCTL dk | grep "Early reply #" || error "No early reply"
1778 # client should show REQ_DELAY estimates
1779 lctl get_param -n mdc.${FSNAME}-MDT0000-mdc-*.timeouts | grep portal
1781 lctl get_param -n mdc.${FSNAME}-MDT0000-mdc-*.timeouts | grep portal
1783 run_test 65a "AT: verify early replies"
1785 test_65b() #bug 3055
1787 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1789 at_start || return 0
1792 $LCTL set_param debug="other trace"
1793 $LCTL dk > /dev/null
1794 # Slow down a request to the current service time, this is critical
1795 # because previous tests may have caused this value to increase.
1796 $SETSTRIPE --stripe-index=0 --count=1 $DIR/$tfile
1797 multiop $DIR/$tfile Ow1yc
1798 REQ_DELAY=`lctl get_param -n osc.${FSNAME}-OST0000-osc-*.timeouts |
1799 awk '/portal 6/ {print $5}'`
1800 REQ_DELAY=$((${REQ_DELAY} + ${REQ_DELAY} / 4 + 5))
1802 do_facet ost1 lctl set_param fail_val=${REQ_DELAY}
1803 #define OBD_FAIL_OST_BRW_PAUSE_PACK 0x224
1804 do_facet ost1 $LCTL set_param fail_loc=0x224
1807 $SETSTRIPE --stripe-index=0 --count=1 $DIR/$tfile
1808 # force some real bulk transfer
1809 multiop $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
1811 do_facet ost1 $LCTL set_param fail_loc=0
1812 # check for log message
1813 $LCTL dk | grep "Early reply #" || error "No early reply"
1815 # client should show REQ_DELAY estimates
1816 lctl get_param -n osc.${FSNAME}-OST0000-osc-*.timeouts | grep portal
1818 run_test 65b "AT: verify early replies on packed reply / bulk"
1820 test_66a() #bug 3055
1822 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1824 at_start || return 0
1825 lctl get_param -n mdc.${FSNAME}-MDT0000-mdc-*.timeouts | grep "portal 12"
1826 # adjust 5s at a time so no early reply is sent (within deadline)
1827 do_facet $SINGLEMDS "$LCTL set_param fail_val=5000"
1828 #define OBD_FAIL_PTLRPC_PAUSE_REQ 0x50a
1829 do_facet $SINGLEMDS "$LCTL set_param fail_loc=0x8000050a"
1830 createmany -o $DIR/$tfile 20 > /dev/null
1831 unlinkmany $DIR/$tfile 20 > /dev/null
1832 lctl get_param -n mdc.${FSNAME}-MDT0000-mdc-*.timeouts | grep "portal 12"
1833 do_facet $SINGLEMDS "$LCTL set_param fail_val=10000"
1834 do_facet $SINGLEMDS "$LCTL set_param fail_loc=0x8000050a"
1835 createmany -o $DIR/$tfile 20 > /dev/null
1836 unlinkmany $DIR/$tfile 20 > /dev/null
1837 lctl get_param -n mdc.${FSNAME}-MDT0000-mdc-*.timeouts | grep "portal 12"
1838 do_facet $SINGLEMDS "$LCTL set_param fail_loc=0"
1840 createmany -o $DIR/$tfile 20 > /dev/null
1841 unlinkmany $DIR/$tfile 20 > /dev/null
1842 lctl get_param -n mdc.${FSNAME}-MDT0000-mdc-*.timeouts | grep "portal 12"
1843 CUR=$(lctl get_param -n mdc.${FSNAME}-MDT0000-mdc-*.timeouts | awk '/portal 12/ {print $5}')
1844 WORST=$(lctl get_param -n mdc.${FSNAME}-MDT0000-mdc-*.timeouts | awk '/portal 12/ {print $7}')
1845 echo "Current MDT timeout $CUR, worst $WORST"
1846 [ $CUR -lt $WORST ] || error "Current $CUR should be less than worst $WORST"
1848 run_test 66a "AT: verify MDT service time adjusts with no early replies"
1850 test_66b() #bug 3055
1852 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1854 at_start || return 0
1855 ORIG=$(lctl get_param -n mdc.${FSNAME}-MDT0000*.timeouts |
1856 awk '/network/ {print $4}')
1857 $LCTL set_param fail_val=$(($ORIG + 5))
1858 #define OBD_FAIL_PTLRPC_PAUSE_REP 0x50c
1859 $LCTL set_param fail_loc=0x50c
1860 ls $DIR/$tfile > /dev/null 2>&1
1861 $LCTL set_param fail_loc=0
1862 CUR=$(lctl get_param -n mdc.${FSNAME}-MDT0000*.timeouts |
1863 awk '/network/ {print $4}')
1864 WORST=$(lctl get_param -n mdc.${FSNAME}-MDT0000*.timeouts |
1865 awk '/network/ {print $6}')
1866 echo "network timeout orig $ORIG, cur $CUR, worst $WORST"
1867 [ $WORST -gt $ORIG ] ||
1868 error "Worst $WORST should be worse than orig $ORIG"
1870 run_test 66b "AT: verify net latency adjusts"
1872 test_67a() #bug 3055
1874 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1876 at_start || return 0
1877 CONN1=$(lctl get_param -n osc.*.stats | awk '/_connect/ {total+=$2} END {print total}')
1878 # sleeping threads may drive values above this
1879 do_facet ost1 "$LCTL set_param fail_val=400"
1880 #define OBD_FAIL_PTLRPC_PAUSE_REQ 0x50a
1881 do_facet ost1 "$LCTL set_param fail_loc=0x50a"
1882 createmany -o $DIR/$tfile 20 > /dev/null
1883 unlinkmany $DIR/$tfile 20 > /dev/null
1884 do_facet ost1 "$LCTL set_param fail_loc=0"
1885 CONN2=$(lctl get_param -n osc.*.stats | awk '/_connect/ {total+=$2} END {print total}')
1886 ATTEMPTS=$(($CONN2 - $CONN1))
1887 echo "$ATTEMPTS osc reconnect attempts on gradual slow"
1888 [ $ATTEMPTS -gt 0 ] &&
1889 error_ignore bz13721 "AT should have prevented reconnect"
1892 run_test 67a "AT: verify slow request processing doesn't induce reconnects"
1894 test_67b() #bug 3055
1896 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1898 at_start || return 0
1899 CONN1=$(lctl get_param -n osc.*.stats | awk '/_connect/ {total+=$2} END {print total}')
1901 # exhaust precreations on ost1
1902 local OST=$(ostname_from_index 0)
1903 local mdtosc=$(get_mdtosc_proc_path mds $OST)
1904 local last_id=$(do_facet $SINGLEMDS lctl get_param -n \
1905 osc.$mdtosc.prealloc_last_id)
1906 local next_id=$(do_facet $SINGLEMDS lctl get_param -n \
1907 osc.$mdtosc.prealloc_next_id)
1909 mkdir -p $DIR/$tdir/${OST} || error "mkdir $DIR/$tdir/${OST} failed"
1910 $SETSTRIPE -i 0 -c 1 $DIR/$tdir/${OST} || error "$SETSTRIPE failed"
1911 echo "Creating to objid $last_id on ost $OST..."
1912 #define OBD_FAIL_OST_PAUSE_CREATE 0x223
1913 do_facet ost1 "$LCTL set_param fail_val=20000"
1914 do_facet ost1 "$LCTL set_param fail_loc=0x80000223"
1915 createmany -o $DIR/$tdir/${OST}/f $next_id $((last_id - next_id + 2))
1918 do_facet ost1 "lctl get_param -n ost.OSS.ost_create.timeouts"
1920 CONN2=$(lctl get_param -n osc.*.stats | awk '/_connect/ {total+=$2} END {print total}')
1921 ATTEMPTS=$(($CONN2 - $CONN1))
1922 echo "$ATTEMPTS osc reconnect attempts on instant slow"
1923 # do it again; should not timeout
1924 do_facet ost1 "$LCTL set_param fail_loc=0x80000223"
1925 cp /etc/profile $DIR/$tfile || error "cp failed"
1926 do_facet ost1 "$LCTL set_param fail_loc=0"
1928 do_facet ost1 "lctl get_param -n ost.OSS.ost_create.timeouts"
1929 CONN3=$(lctl get_param -n osc.*.stats | awk '/_connect/ {total+=$2} END {print total}')
1930 ATTEMPTS=$(($CONN3 - $CONN2))
1931 echo "$ATTEMPTS osc reconnect attempts on 2nd slow"
1932 [ $ATTEMPTS -gt 0 ] && error "AT should have prevented reconnect"
1935 run_test 67b "AT: verify instant slowdown doesn't induce reconnects"
1937 test_68 () #bug 13813
1939 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1941 at_start || return 0
1942 local ldlm_enqueue_min=$(find /sys -name ldlm_enqueue_min)
1943 [ -z "$ldlm_enqueue_min" ] && skip "missing /sys/.../ldlm_enqueue_min" && return 0
1944 local ldlm_enqueue_min_r=$(do_facet ost1 "find /sys -name ldlm_enqueue_min")
1945 [ -z "$ldlm_enqueue_min_r" ] && skip "missing /sys/.../ldlm_enqueue_min in the ost1" && return 0
1946 local ENQ_MIN=$(cat $ldlm_enqueue_min)
1947 local ENQ_MIN_R=$(do_facet ost1 "cat $ldlm_enqueue_min_r")
1948 echo $TIMEOUT >> $ldlm_enqueue_min
1949 do_facet ost1 "echo $TIMEOUT >> $ldlm_enqueue_min_r"
1951 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
1952 $SETSTRIPE --stripe-index=0 --count=1 $DIR/$tdir
1953 #define OBD_FAIL_LDLM_PAUSE_CANCEL 0x312
1954 $LCTL set_param fail_val=$(($TIMEOUT - 1))
1955 $LCTL set_param fail_loc=0x80000312
1956 cp /etc/profile $DIR/$tdir/${tfile}_1 || error "1st cp failed $?"
1957 $LCTL set_param fail_val=$((TIMEOUT * 5 / 4))
1958 $LCTL set_param fail_loc=0x80000312
1959 cp /etc/profile $DIR/$tdir/${tfile}_2 || error "2nd cp failed $?"
1960 $LCTL set_param fail_loc=0
1962 echo $ENQ_MIN >> $ldlm_enqueue_min
1963 do_facet ost1 "echo $ENQ_MIN_R >> $ldlm_enqueue_min_r"
1967 run_test 68 "AT: verify slowing locks"
1970 # end of AT tests includes above lines
1972 # start multi-client tests
1974 [ -z "$CLIENTS" ] &&
1975 { skip "Need two or more clients." && return; }
1976 [ $CLIENTCOUNT -lt 2 ] &&
1977 { skip "Need two or more clients, have $CLIENTCOUNT" && return; }
1979 echo "mount clients $CLIENTS ..."
1980 zconf_mount_clients $CLIENTS $MOUNT
1982 local clients=${CLIENTS//,/ }
1983 echo "Write/read files on $DIR ; clients $CLIENTS ... "
1984 for CLIENT in $clients; do
1985 do_node $CLIENT dd bs=1M count=10 if=/dev/zero \
1986 of=$DIR/${tfile}_${CLIENT} 2>/dev/null ||
1987 error "dd failed on $CLIENT"
1990 local prev_client=$(echo $clients | sed 's/^.* \(.\+\)$/\1/')
1991 for C in ${CLIENTS//,/ }; do
1992 do_node $prev_client dd if=$DIR/${tfile}_${C} \
1993 of=/dev/null 2>/dev/null ||
1994 error "dd if=$DIR/${tfile}_${C} failed on $prev_client"
2000 run_test 70a "check multi client t-f"
2002 check_for_process () {
2007 killall_process $clients "$prog" -0
2010 killall_process () {
2011 local clients=${1:-$(hostname)}
2016 do_nodes $clients "killall $signal $name"
2020 local clients=${CLIENTS:-$HOSTNAME}
2022 zconf_mount_clients $clients $MOUNT
2025 [ "$SLOW" = "no" ] && duration=120
2026 # set duration to 900 because it takes some time to boot node
2027 [ "$FAILURE_MODE" = HARD ] && duration=900
2030 local start_ts=$(date +%s)
2031 local cmd="rundbench 1 -t $duration"
2033 do_nodesv $clients "set -x; MISSING_DBENCH_OK=$MISSING_DBENCH_OK \
2034 PATH=\$PATH:$LUSTRE/utils:$LUSTRE/tests/:$DBENCH_LIB \
2035 DBENCH_LIB=$DBENCH_LIB TESTSUITE=$TESTSUITE TESTNAME=$TESTNAME \
2036 MOUNT=$MOUNT DIR=$DIR/$tdir/\\\$(hostname) LCTL=$LCTL $cmd" &
2039 #LU-1897 wait for all dbench copies to start
2040 while ! check_for_process $clients dbench; do
2041 elapsed=$(($(date +%s) - start_ts))
2042 if [ $elapsed -gt $duration ]; then
2043 killall_process $clients dbench
2044 error "dbench failed to start on $clients!"
2049 log "Started rundbench load pid=$pid ..."
2051 elapsed=$(($(date +%s) - start_ts))
2052 local num_failovers=0
2053 while [ $elapsed -lt $duration ]; do
2054 if ! check_for_process $clients dbench; then
2055 error_noexit "dbench stopped on some of $clients!"
2056 killall_process $clients dbench
2060 replay_barrier $SINGLEMDS
2061 sleep 1 # give clients a time to do operations
2062 # Increment the number of failovers
2063 num_failovers=$((num_failovers+1))
2064 log "$TESTNAME fail $SINGLEMDS $num_failovers times"
2066 elapsed=$(($(date +%s) - start_ts))
2069 wait $pid || error "rundbench load on $clients failed!"
2071 run_test 70b "mds recovery; $CLIENTCOUNT clients"
2072 # end multi-client tests
2075 multiop_bg_pause $DIR/$tfile O_tSc ||
2076 error "multiop_bg_pause $DIR/$tfile failed"
2080 replay_barrier $SINGLEMDS
2081 #define OBD_FAIL_LDLM_ENQUEUE_NET 0x302
2082 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000302"
2085 wait $pid || error "multiop pid failed"
2086 [ -e $DIR/$tfile ] && error "file $DIR/$tfile should not exist"
2089 run_test 73a "open(O_CREAT), unlink, replay, reconnect before open replay, close"
2092 multiop_bg_pause $DIR/$tfile O_tSc ||
2093 error "multiop_bg_pause $DIR/$tfile failed"
2097 replay_barrier $SINGLEMDS
2098 #define OBD_FAIL_LDLM_REPLY 0x30c
2099 do_facet $SINGLEMDS "lctl set_param fail_loc=0x8000030c"
2102 wait $pid || error "multiop pid failed"
2103 [ -e $DIR/$tfile ] && error "file $DIR/$tfile should not exist"
2106 run_test 73b "open(O_CREAT), unlink, replay, reconnect at open_replay reply, close"
2110 local clients=${CLIENTS:-$HOSTNAME}
2112 zconf_umount_clients $clients $MOUNT
2114 facet_failover $SINGLEMDS
2115 zconf_mount_clients $clients $MOUNT
2117 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
2118 rm $DIR/$tfile || error "rm $DIR/$tfile failed"
2119 clients_up || error "client evicted: $?"
2122 run_test 74 "Ensure applications don't fail waiting for OST recovery"
2124 remote_dir_check_80() {
2126 local diridx=$($GETSTRIPE -M $remote_dir)
2127 [ $diridx -eq $MDTIDX ] || error "$diridx != $MDTIDX"
2129 createmany -o $remote_dir/f-%d 20 || error "creation failed"
2130 local fileidx=$($GETSTRIPE -M $remote_dir/f-1)
2131 [ $fileidx -eq $MDTIDX ] || error "$fileidx != $MDTIDX"
2137 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2138 ([ $FAILURE_MODE == "HARD" ] &&
2139 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
2140 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
2144 local remote_dir=$DIR/$tdir/remote_dir
2146 mkdir -p $DIR/$tdir || error "mkdir $DIR/$tdir failed"
2147 #define OBD_FAIL_OUT_UPDATE_NET_REP 0x1701
2148 do_facet mds${MDTIDX} lctl set_param fail_loc=0x1701
2149 $LFS mkdir -i $MDTIDX $remote_dir &
2154 wait $CLIENT_PID || error "remote creation failed"
2156 remote_dir_check_80 || error "remote dir check failed"
2157 rm -rf $DIR/$tdir || error "rmdir failed"
2161 run_test 80a "DNE: create remote dir, drop update rep from MDT0, fail MDT0"
2164 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2165 ([ $FAILURE_MODE == "HARD" ] &&
2166 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
2167 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
2171 local remote_dir=$DIR/$tdir/remote_dir
2173 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
2174 #define OBD_FAIL_UPDATE_OBJ_NET_REP 0x1701
2175 do_facet mds${MDTIDX} lctl set_param fail_loc=0x1701
2176 $LFS mkdir -i $MDTIDX $remote_dir &
2179 fail mds$((MDTIDX + 1))
2181 wait $CLIENT_PID || error "remote creation failed"
2183 remote_dir_check_80 || error "remote dir check failed"
2184 rm -rf $DIR/$tdir || error "rmdir failed"
2188 run_test 80b "DNE: create remote dir, drop update rep from MDT0, fail MDT1"
2191 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2192 ([ $FAILURE_MODE == "HARD" ] &&
2193 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
2194 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
2198 local remote_dir=$DIR/$tdir/remote_dir
2200 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
2201 #define OBD_FAIL_UPDATE_OBJ_NET_REP 0x1701
2202 do_facet mds${MDTIDX} lctl set_param fail_loc=0x1701
2203 $LFS mkdir -i $MDTIDX $remote_dir &
2207 fail mds$((MDTIDX + 1))
2209 wait $CLIENT_PID || error "remote creation failed"
2211 remote_dir_check_80 || error "remote dir check failed"
2212 rm -rf $DIR/$tdir || error "rmdir failed"
2216 run_test 80c "DNE: create remote dir, drop update rep from MDT1, fail MDT[0,1]"
2219 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
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 &
2229 # sleep 3 seconds to make sure MDTs are failed after
2230 # lfs mkdir -i has finished on all of MDTs.
2232 fail mds${MDTIDX},mds$((MDTIDX + 1))
2234 wait $CLIENT_PID || error "remote creation failed"
2236 remote_dir_check_80 || error "remote dir check failed"
2237 rm -rf $DIR/$tdir || error "rmdir failed"
2241 run_test 80d "DNE: create remote dir, drop update rep from MDT1, fail 2 MDTs"
2244 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2245 ([ $FAILURE_MODE == "HARD" ] &&
2246 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
2247 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
2251 local remote_dir=$DIR/$tdir/remote_dir
2253 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
2254 # OBD_FAIL_MDS_REINT_NET_REP 0x119
2255 do_facet mds$((MDTIDX + 1)) lctl set_param fail_loc=0x119
2256 $LFS mkdir -i $MDTIDX $remote_dir &
2259 # sleep 3 seconds to make sure MDTs are failed after
2260 # lfs mkdir -i has finished on all of MDTs.
2265 wait $CLIENT_PID || error "remote creation failed"
2267 remote_dir_check_80 || error "remote dir check failed"
2268 rm -rf $DIR/$tdir || error "rmdir failed"
2272 run_test 80e "DNE: create remote dir, drop MDT1 rep, fail MDT0"
2275 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2276 ([ $FAILURE_MODE == "HARD" ] &&
2277 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
2278 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
2281 local remote_dir=$DIR/$tdir/remote_dir
2283 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
2284 # OBD_FAIL_MDS_REINT_NET_REP 0x119
2285 do_facet mds$((MDTIDX + 1)) lctl set_param fail_loc=0x119
2286 $LFS mkdir -i $MDTIDX $remote_dir &
2289 fail mds$((MDTIDX + 1))
2291 wait $CLIENT_PID || error "remote creation failed"
2293 remote_dir_check_80 || error "remote dir check failed"
2294 rm -rf $DIR/$tdir || error "rmdir failed"
2298 run_test 80f "DNE: create remote dir, drop MDT1 rep, fail MDT1"
2301 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2302 ([ $FAILURE_MODE == "HARD" ] &&
2303 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
2304 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
2308 local remote_dir=$DIR/$tdir/remote_dir
2310 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
2311 # OBD_FAIL_MDS_REINT_NET_REP 0x119
2312 do_facet mds$((MDTIDX + 1)) lctl set_param fail_loc=0x119
2313 $LFS mkdir -i $MDTIDX $remote_dir &
2316 # sleep 3 seconds to make sure MDTs are failed after
2317 # lfs mkdir -i has finished on all of MDTs.
2321 fail mds$((MDTIDX + 1))
2323 wait $CLIENT_PID || error "remote creation failed"
2325 remote_dir_check_80 || error "remote dir check failed"
2326 rm -rf $DIR/$tdir || error "rmdir failed"
2330 run_test 80g "DNE: create remote dir, drop MDT1 rep, fail MDT0, then MDT1"
2333 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2335 local remote_dir=$DIR/$tdir/remote_dir
2337 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
2338 # OBD_FAIL_MDS_REINT_NET_REP 0x119
2339 do_facet mds$((MDTIDX + 1)) lctl set_param fail_loc=0x119
2340 $LFS mkdir -i $MDTIDX $remote_dir &
2343 # sleep 3 seconds to make sure MDTs are failed after
2344 # lfs mkdir -i has finished on all of MDTs.
2347 fail mds${MDTIDX},mds$((MDTIDX + 1))
2349 wait $CLIENT_PID || error "remote dir creation failed"
2351 remote_dir_check_80 || error "remote dir check failed"
2352 rm -rf $DIR/$tdir || error "rmdir failed"
2356 run_test 80h "DNE: create remote dir, drop MDT1 rep, fail 2 MDTs"
2359 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2360 ([ $FAILURE_MODE == "HARD" ] &&
2361 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
2362 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
2366 local remote_dir=$DIR/$tdir/remote_dir
2368 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
2369 $LFS mkdir -i $MDTIDX $remote_dir || error "lfs mkdir failed"
2371 touch $remote_dir || error "touch $remote_dir failed"
2372 # OBD_FAIL_OBJ_UPDATE_NET_REP 0x1701
2373 do_facet mds${MDTIDX} lctl set_param fail_loc=0x1701
2377 fail mds$((MDTIDX + 1))
2379 wait $CLIENT_PID || error "rm remote dir failed"
2381 stat $remote_dir 2&>/dev/null && error "$remote_dir still exist!"
2383 rm -rf $DIR/$tdir || error "rmdir failed"
2387 run_test 81a "DNE: unlink remote dir, drop MDT0 update rep, fail MDT1"
2390 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2391 ([ $FAILURE_MODE == "HARD" ] &&
2392 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
2393 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
2396 local remote_dir=$DIR/$tdir/remote_dir
2398 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
2399 $LFS mkdir -i $MDTIDX $remote_dir || error "lfs mkdir failed"
2401 # OBD_FAIL_OBJ_UPDATE_NET_REP 0x1701
2402 do_facet mds${MDTIDX} lctl set_param fail_loc=0x1701
2408 wait $CLIENT_PID || error "rm remote dir failed"
2410 stat $remote_dir 2&>/dev/null && error "$remote_dir still exist!"
2412 rm -rf $DIR/$tdir || error "rmdir failed"
2416 run_test 81b "DNE: unlink remote dir, drop MDT0 update reply, fail MDT0"
2419 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2420 ([ $FAILURE_MODE == "HARD" ] &&
2421 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
2422 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
2426 local remote_dir=$DIR/$tdir/remote_dir
2428 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
2429 $LFS mkdir -i $MDTIDX $remote_dir || error "lfs mkdir failed"
2431 # OBD_FAIL_OBJ_UPDATE_NET_REP 0x1701
2432 do_facet mds${MDTIDX} lctl set_param fail_loc=0x1701
2437 fail mds$((MDTIDX + 1))
2439 wait $CLIENT_PID || error "rm remote dir failed"
2441 stat $remote_dir 2&>/dev/null && error "$remote_dir still exist!"
2443 rm -rf $DIR/$tdir || error "rmdir failed"
2447 run_test 81c "DNE: unlink remote dir, drop MDT0 update reply, fail MDT0,MDT1"
2450 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2452 local remote_dir=$DIR/$tdir/remote_dir
2454 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
2455 $LFS mkdir -i $MDTIDX $remote_dir || error "lfs mkdir failed"
2457 # OBD_FAIL_OBJ_UPDATE_NET_REP 0x1701
2458 do_facet mds${MDTIDX} lctl set_param fail_loc=0x1701
2462 fail mds${MDTIDX},mds$((MDTIDX + 1))
2464 wait $CLIENT_PID || error "rm remote dir failed"
2466 stat $remote_dir 2&>/dev/null && error "$remote_dir still exist!"
2468 rm -rf $DIR/$tdir || error "rmdir failed"
2472 run_test 81d "DNE: unlink remote dir, drop MDT0 update reply, fail 2 MDTs"
2475 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2476 ([ $FAILURE_MODE == "HARD" ] &&
2477 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
2478 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
2482 local remote_dir=$DIR/$tdir/remote_dir
2484 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
2485 $LFS mkdir -i $MDTIDX $remote_dir || error "lfs mkdir failed"
2487 # OBD_FAIL_MDS_REINT_NET_REP 0x119
2488 do_facet mds$((MDTIDX + 1)) lctl set_param fail_loc=0x119
2491 do_facet mds$((MDTIDX + 1)) lctl set_param fail_loc=0
2495 wait $CLIENT_PID || error "rm remote dir failed"
2497 stat $remote_dir 2&>/dev/null && error "$remote_dir still exist!"
2499 rm -rf $DIR/$tdir || error "rmdir failed"
2503 run_test 81e "DNE: unlink remote dir, drop MDT1 req reply, fail MDT0"
2506 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2507 ([ $FAILURE_MODE == "HARD" ] &&
2508 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
2509 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
2513 local remote_dir=$DIR/$tdir/remote_dir
2515 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
2516 $LFS mkdir -i $MDTIDX $remote_dir || error "lfs mkdir failed"
2518 # OBD_FAIL_MDS_REINT_NET_REP 0x119
2519 do_facet mds$((MDTIDX + 1)) lctl set_param fail_loc=0x119
2523 fail mds$((MDTIDX + 1))
2525 wait $CLIENT_PID || error "rm remote dir failed"
2527 stat $remote_dir 2&>/dev/null && error "$remote_dir still exist!"
2529 rm -rf $DIR/$tdir || error "rmdir failed"
2533 run_test 81f "DNE: unlink remote dir, drop MDT1 req reply, fail MDT1"
2536 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2537 ([ $FAILURE_MODE == "HARD" ] &&
2538 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
2539 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
2543 local remote_dir=$DIR/$tdir/remote_dir
2545 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
2546 $LFS mkdir -i $MDTIDX $remote_dir || error "lfs mkdir failed"
2548 # OBD_FAIL_MDS_REINT_NET_REP 0x119
2549 do_facet mds$((MDTIDX + 1)) lctl set_param fail_loc=0x119
2554 fail mds$((MDTIDX + 1))
2556 wait $CLIENT_PID || error "rm remote dir failed"
2558 stat $remote_dir 2&>/dev/null && error "$remote_dir still exist!"
2560 rm -rf $DIR/$tdir || error "rmdir failed"
2564 run_test 81g "DNE: unlink remote dir, drop req reply, fail M0, then M1"
2567 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2569 local remote_dir=$DIR/$tdir/remote_dir
2571 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
2572 $LFS mkdir -i $MDTIDX $remote_dir || error "lfs mkdir failed"
2574 # OBD_FAIL_MDS_REINT_NET_REP 0x119
2575 do_facet mds$((MDTIDX + 1)) lctl set_param fail_loc=0x119
2579 fail mds${MDTIDX},mds$((MDTIDX + 1))
2581 wait $CLIENT_PID || error "rm remote dir failed"
2583 stat $remote_dir 2&>/dev/null && error "$remote_dir still exist!"
2585 rm -rf $DIR/$tdir || error "rmdir failed"
2589 run_test 81h "DNE: unlink remote dir, drop request reply, fail 2 MDTs"
2592 #define OBD_FAIL_MDS_OPEN_WAIT_CREATE 0x144
2593 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000144"
2594 createmany -o $DIR/$tfile- 1 &
2598 client_up || client_up || true # reconnect
2600 run_test 84a "stale open during export disconnect"
2602 test_85a() { #bug 16774
2603 lctl set_param -n ldlm.cancel_unused_locks_before_replay "1"
2605 for i in $(seq 100); do
2606 echo "tag-$i" > $DIR/$tfile-$i
2607 grep -q "tag-$i" $DIR/$tfile-$i || error "f2-$i"
2610 lov_id=$(lctl dl | grep "clilov")
2611 addr=$(echo $lov_id | awk '{print $4}' | awk -F '-' '{print $3}')
2612 count=$(lctl get_param -n \
2613 ldlm.namespaces.*MDT0000*$addr.lock_unused_count)
2614 echo "before recovery: unused locks count = $count"
2618 count2=$(lctl get_param -n \
2619 ldlm.namespaces.*MDT0000*$addr.lock_unused_count)
2620 echo "after recovery: unused locks count = $count2"
2622 if [ $count2 -ge $count ]; then
2623 error "unused locks are not canceled"
2626 run_test 85a "check the cancellation of unused locks during recovery(IBITS)"
2628 test_85b() { #bug 16774
2629 lctl set_param -n ldlm.cancel_unused_locks_before_replay "1"
2631 do_facet mgs $LCTL pool_new $FSNAME.$TESTNAME ||
2632 error "unable to create pool $TESTNAME"
2633 do_facet mgs $LCTL pool_add $FSNAME.$TESTNAME $FSNAME-OST0000 ||
2634 error "unable to add pool $TESTNAME"
2636 $SETSTRIPE -c 1 -p $FSNAME.$TESTNAME $DIR
2638 for i in $(seq 100); do
2639 dd if=/dev/urandom of=$DIR/$tfile-$i bs=4096 \
2640 count=32 >/dev/null 2>&1
2643 cancel_lru_locks osc
2645 for i in $(seq 100); do
2646 dd if=$DIR/$tfile-$i of=/dev/null bs=4096 \
2647 count=32 >/dev/null 2>&1
2650 lov_id=$(lctl dl | grep "clilov")
2651 addr=$(echo $lov_id | awk '{print $4}' | awk -F '-' '{print $3}')
2652 count=$(lctl get_param \
2653 -n ldlm.namespaces.*OST0000*$addr.lock_unused_count)
2654 echo "before recovery: unused locks count = $count"
2655 [ $count != 0 ] || error "unused locks ($count) should be zero"
2659 count2=$(lctl get_param \
2660 -n ldlm.namespaces.*OST0000*$addr.lock_unused_count)
2661 echo "after recovery: unused locks count = $count2"
2663 do_facet mgs $LCTL pool_remove $FSNAME.$TESTNAME $FSNAME-OST0000 ||
2664 error "unable to remove pool $TESTNAME"
2665 do_facet mgs $LCTL pool_destroy $FSNAME.$TESTNAME ||
2666 error "unable to destroy the pool $TESTNAME"
2668 if [ $count2 -ge $count ]; then
2669 error "unused locks are not canceled"
2672 run_test 85b "check the cancellation of unused locks during recovery(EXTENT)"
2675 local clients=${CLIENTS:-$HOSTNAME}
2677 zconf_umount_clients $clients $MOUNT
2678 do_facet $SINGLEMDS lctl set_param mdt.${FSNAME}-MDT*.exports.clear=0
2679 remount_facet $SINGLEMDS
2680 zconf_mount_clients $clients $MOUNT
2682 run_test 86 "umount server after clear nid_stats should not hit LBUG"
2685 do_facet ost1 "lctl set_param -n obdfilter.${ost1_svc}.sync_journal 0"
2688 $SETSTRIPE -i 0 -c 1 $DIR/$tfile
2689 dd if=/dev/urandom of=$DIR/$tfile bs=1024k count=8 ||
2690 error "dd to $DIR/$tfile failed"
2691 cksum=$(md5sum $DIR/$tfile | awk '{print $1}')
2692 cancel_lru_locks osc
2694 dd if=$DIR/$tfile of=/dev/null bs=1024k count=8 || error "Cannot read"
2695 cksum2=$(md5sum $DIR/$tfile | awk '{print $1}')
2696 if [ $cksum != $cksum2 ] ; then
2697 error "New checksum $cksum2 does not match original $cksum"
2700 run_test 87 "write replay"
2703 do_facet ost1 "lctl set_param -n obdfilter.${ost1_svc}.sync_journal 0"
2706 $SETSTRIPE -i 0 -c 1 $DIR/$tfile
2707 dd if=/dev/urandom of=$DIR/$tfile bs=1024k count=8 ||
2708 error "dd to $DIR/$tfile failed"
2709 sleep 1 # Give it a chance to flush dirty data
2710 echo TESTTEST | dd of=$DIR/$tfile bs=1 count=8 seek=64
2711 cksum=$(md5sum $DIR/$tfile | awk '{print $1}')
2712 cancel_lru_locks osc
2714 dd if=$DIR/$tfile of=/dev/null bs=1024k count=8 || error "Cannot read"
2715 cksum2=$(md5sum $DIR/$tfile | awk '{print $1}')
2716 if [ $cksum != $cksum2 ] ; then
2717 error "New checksum $cksum2 does not match original $cksum"
2720 run_test 87b "write replay with changed data (checksum resend)"
2722 test_88() { #bug 17485
2723 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
2724 mkdir -p $TMP/$tdir || error "mkdir $TMP/$tdir failed"
2726 $SETSTRIPE -i 0 -c 1 $DIR/$tdir || error "$SETSTRIPE"
2729 replay_barrier $SINGLEMDS
2731 # exhaust precreations on ost1
2732 local OST=$(ostname_from_index 0)
2733 local mdtosc=$(get_mdtosc_proc_path $SINGLEMDS $OST)
2734 local last_id=$(do_facet $SINGLEMDS lctl get_param -n osc.$mdtosc.prealloc_last_id)
2735 local next_id=$(do_facet $SINGLEMDS lctl get_param -n osc.$mdtosc.prealloc_next_id)
2736 echo "before test: last_id = $last_id, next_id = $next_id"
2738 echo "Creating to objid $last_id on ost $OST..."
2739 createmany -o $DIR/$tdir/f-%d $next_id $((last_id - next_id + 2)) ||
2740 error "createmany create files to last_id failed"
2742 #create some files to use some uncommitted objids
2743 last_id=$(($last_id + 1))
2744 createmany -o $DIR/$tdir/f-%d $last_id 8 ||
2745 error "createmany create files with uncommitted objids failed"
2747 last_id2=$(do_facet $SINGLEMDS lctl get_param -n osc.$mdtosc.prealloc_last_id)
2748 next_id2=$(do_facet $SINGLEMDS lctl get_param -n osc.$mdtosc.prealloc_next_id)
2749 echo "before recovery: last_id = $last_id2, next_id = $next_id2"
2751 # if test uses shutdown_facet && reboot_facet instead of facet_failover ()
2752 # it has to take care about the affected facets, bug20407
2753 local affected_mds1=$(affected_facets mds1)
2754 local affected_ost1=$(affected_facets ost1)
2756 shutdown_facet $SINGLEMDS
2759 reboot_facet $SINGLEMDS
2760 change_active $affected_mds1
2761 wait_for_facet $affected_mds1
2762 mount_facets $affected_mds1 || error "Restart of mds failed"
2765 change_active $affected_ost1
2766 wait_for_facet $affected_ost1
2767 mount_facets $affected_ost1 || error "Restart of ost1 failed"
2771 last_id2=$(do_facet $SINGLEMDS lctl get_param -n osc.$mdtosc.prealloc_last_id)
2772 next_id2=$(do_facet $SINGLEMDS lctl get_param -n osc.$mdtosc.prealloc_next_id)
2773 echo "after recovery: last_id = $last_id2, next_id = $next_id2"
2775 # create new files, which should use new objids, and ensure the orphan
2776 # cleanup phase for ost1 is completed at the same time
2777 for i in $(seq 8); do
2778 file_id=$(($last_id + 10 + $i))
2779 dd if=/dev/urandom of=$DIR/$tdir/f-$file_id bs=4096 count=128
2782 # if the objids were not recreated, then "ls" will fail with -ENOENT
2783 ls -l $DIR/$tdir/* || error "can't get the status of precreated files"
2786 # write into previously created files
2787 for i in $(seq 8); do
2788 file_id=$(($last_id + $i))
2789 dd if=/dev/urandom of=$DIR/$tdir/f-$file_id bs=4096 count=128
2790 cp -f $DIR/$tdir/f-$file_id $TMP/$tdir/
2793 # compare the content
2794 for i in $(seq 8); do
2795 file_id=$(($last_id + $i))
2796 cmp $TMP/$tdir/f-$file_id $DIR/$tdir/f-$file_id ||
2797 error "the content of file is modified!"
2802 run_test 88 "MDS should not assign same objid to different files "
2805 cancel_lru_locks osc
2806 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
2807 rm -f $DIR/$tdir/$tfile
2809 wait_delete_completed
2810 BLOCKS1=$(df -P $MOUNT | tail -n 1 | awk '{ print $3 }')
2811 $SETSTRIPE -i 0 -c 1 $DIR/$tdir/$tfile
2812 dd if=/dev/zero bs=1M count=10 of=$DIR/$tdir/$tfile
2815 facet_failover $SINGLEMDS
2816 rm $DIR/$tdir/$tfile
2819 zconf_mount $(hostname) $MOUNT || error "mount fails"
2820 client_up || error "client_up failed"
2822 wait_delete_completed
2823 BLOCKS2=$(df -P $MOUNT | tail -n 1 | awk '{ print $3 }')
2824 [ $((BLOCKS2 - BLOCKS1)) -le 4 ] ||
2825 error $((BLOCKS2 - BLOCKS1)) blocks leaked
2828 run_test 89 "no disk space leak on late ost connection"
2834 change_active $facet
2835 wait_for_facet $facet
2836 mount_facet $facet || error "Restart of $facet failed"
2840 test_90() { # bug 19494
2841 local dir=$DIR/$tdir
2842 local ostfail=$(get_random_entry $(get_facets OST))
2844 if [[ $FAILURE_MODE = HARD ]]; then
2845 local affected=$(affected_facets $ostfail);
2846 if [[ "$affected" != $ostfail ]]; then
2847 skip not functional with FAILURE_MODE=$FAILURE_MODE, affected: $affected
2852 mkdir $dir || error "mkdir $dir failed"
2854 echo "Create the files"
2856 # file "f${index}" striped over 1 OST
2857 # file "all" striped over all OSTs
2859 $SETSTRIPE -c $OSTCOUNT $dir/all ||
2860 error "setstripe failed to create $dir/all"
2862 for (( i=0; i<$OSTCOUNT; i++ )); do
2864 $SETSTRIPE -i $i -c 1 $f || error "$SETSTRIPE failed to create $f"
2866 # confirm setstripe actually created the stripe on the requested OST
2867 local uuid=$(ostuuid_from_index $i)
2868 for file in f$i all; do
2869 if [[ $dir/$file != $($LFS find --obd $uuid --name $file $dir) ]]; then
2870 $GETSTRIPE $dir/$file
2871 error wrong stripe: $file, uuid: $uuid
2876 # Before failing an OST, get its obd name and index
2877 local varsvc=${ostfail}_svc
2878 local obd=$(do_facet $ostfail lctl get_param \
2879 -n obdfilter.${!varsvc}.uuid)
2880 local index=$(($(facet_number $ostfail) - 1))
2882 echo "Fail $ostfail $obd, display the list of affected files"
2883 shutdown_facet $ostfail || error "shutdown_facet $ostfail failed"
2885 trap "cleanup_90 $ostfail" EXIT INT
2886 echo "General Query: lfs find $dir"
2887 local list=$($LFS find $dir)
2889 for (( i=0; i<$OSTCOUNT; i++ )); do
2890 list_member "$list" $dir/f$i ||
2891 error_noexit "lfs find $dir: no file f$i"
2893 list_member "$list" $dir/all ||
2894 error_noexit "lfs find $dir: no file all"
2896 # focus on the missing OST,
2897 # we expect to see only two files affected: "f$(index)" and "all"
2899 echo "Querying files on shutdown $ostfail: lfs find --obd $obd"
2900 list=$($LFS find --obd $obd $dir)
2902 for file in all f$index; do
2903 list_member "$list" $dir/$file ||
2904 error_noexit "lfs find does not report the affected $obd for $file"
2907 [[ $(echo $list | wc -w) -eq 2 ]] ||
2908 error_noexit "lfs find reports the wrong list of affected files ${#list[@]}"
2910 echo "Check getstripe: $GETSTRIPE -r --obd $obd"
2911 list=$($GETSTRIPE -r --obd $obd $dir)
2913 for file in all f$index; do
2914 echo "$list" | grep $dir/$file ||
2915 error_noexit "lfs getsripe does not report the affected $obd for $file"
2920 run_test 90 "lfs find identifies the missing striped file segments"
2923 local server_version=$(lustre_version_code $SINGLEMDS)
2924 [[ $server_version -ge $(version_code 2.6.90) ]] ||
2925 [[ $server_version -ge $(version_code 2.5.4) &&
2926 $server_version -lt $(version_code 2.5.50) ]] ||
2927 { skip "Need MDS version 2.5.4+ or 2.6.90+"; return; }
2929 cancel_lru_locks osc
2931 $SETSTRIPE -i 0 -c 1 $DIR/$tfile ||
2932 error "$SETSTRIPE $DIR/$tfile failed"
2933 dd if=/dev/zero of=$DIR/$tfile bs=1024 count=1 ||
2934 error "dd to $DIR/$tfile failed"
2935 #define OBD_FAIL_TGT_REPLAY_RECONNECT 0x715
2936 # We need to emulate a state that OST is waiting for other clients
2937 # not completing the recovery. Final ping is queued, but reply will be
2938 # sent on the recovery completion. It is done by sleep before
2939 # processing final pings
2940 do_facet ost1 "$LCTL set_param fail_val=40"
2941 do_facet ost1 "$LCTL set_param fail_loc=0x715"
2944 run_test 93 "replay + reconnect"
2946 striped_dir_check_100() {
2947 local striped_dir=$DIR/$tdir/striped_dir
2948 local stripe_count=$($LFS getdirstripe -c $striped_dir)
2950 $LFS getdirstripe $striped_dir
2951 [ $stripe_count -eq 2 ] || error "$stripe_count != 2"
2953 createmany -o $striped_dir/f-%d 20 ||
2954 error "creation failed under striped dir"
2958 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2959 ([ $FAILURE_MODE == "HARD" ] &&
2960 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
2961 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
2964 local striped_dir=$DIR/$tdir/striped_dir
2967 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
2969 #To make sure MDT1 and MDT0 are connected
2970 #otherwise it may create single stripe dir here
2971 $LFS setdirstripe -i1 $DIR/$tdir/remote_dir
2973 #define OBD_FAIL_OUT_UPDATE_NET_REP 0x1701
2974 do_facet mds$((MDTIDX+1)) lctl set_param fail_loc=0x1701
2975 $LFS setdirstripe -i0 -c2 $striped_dir &
2978 fail mds$((MDTIDX + 1))
2980 wait $CLIENT_PID || error "striped dir creation failed"
2982 striped_dir_check_100 || error "striped dir check failed"
2983 rm -rf $DIR/$tdir || error "rmdir failed"
2985 run_test 100a "DNE: create striped dir, drop update rep from MDT1, fail MDT1"
2988 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2989 ([ $FAILURE_MODE == "HARD" ] &&
2990 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
2991 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
2994 local striped_dir=$DIR/$tdir/striped_dir
2997 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
2999 #To make sure MDT1 and MDT0 are connected
3000 #otherwise it may create single stripe dir here
3001 $LFS setdirstripe -i1 $DIR/$tdir/remote_dir
3003 # OBD_FAIL_MDS_REINT_NET_REP 0x119
3004 do_facet mds$MDTIDX lctl set_param fail_loc=0x119
3005 $LFS mkdir -i0 -c2 $striped_dir &
3010 wait $CLIENT_PID || error "striped dir creation failed"
3012 striped_dir_check_100 || error "striped dir check failed"
3013 rm -rf $DIR/$tdir || error "rmdir failed"
3015 run_test 100b "DNE: create striped dir, fail MDT0"
3017 test_101() { #LU-5648
3018 mkdir -p $DIR/$tdir/d1
3019 mkdir -p $DIR/$tdir/d2
3020 touch $DIR/$tdir/file0
3023 replay_barrier $SINGLEMDS
3024 for i in $(seq $num) ; do
3025 echo test$i > $DIR/$tdir/d1/file$i
3028 fail_abort $SINGLEMDS
3029 for i in $(seq $num) ; do
3030 touch $DIR/$tdir/d2/file$i
3031 test -s $DIR/$tdir/d2/file$i &&
3032 ls -al $DIR/$tdir/d2/file$i && error "file$i's size > 0"
3037 run_test 101 "Shouldn't reassign precreated objs to other files after recovery"
3040 check_and_cleanup_lustre