7 # This test needs to be run on the client
10 export MULTIOP=${MULTIOP:-multiop}
11 LUSTRE=${LUSTRE:-$(cd $(dirname $0)/..; echo $PWD)}
14 . $LUSTRE/tests/test-framework.sh
16 . ${CONFIG:=$LUSTRE/tests/cfg/$NAME.sh}
18 CHECK_GRANT=${CHECK_GRANT:-"yes"}
19 GRANT_CHECK_LIST=${GRANT_CHECK_LIST:-""}
21 require_dsh_mds || exit 0
24 # bug number for skipped tests:
25 # b=17466/LU-472 : 61d
27 # LU-6780 : 80d 80h 81d 81h 110e 110f 110g 111c 111d 111e 111f 111g 112
28 ALWAYS_EXCEPT="61d 53a 53d 80d 80h 81d 81h 110e 110f 110g 111c 111d 111e 111f 111g 112 $REPLAY_SINGLE_EXCEPT"
29 # UPDATE THE COMMENT ABOVE WITH BUG NUMBERS WHEN CHANGING ALWAYS_EXCEPT!
31 case "$(lsb_release -sr)" in # only disable tests for el7
32 7*) # bug number: LU-6455-----
33 ALWAYS_EXCEPT="$ALWAYS_EXCEPT 28"
37 # 63 min 7 min AT AT AT AT"
38 [ "$SLOW" = "no" ] && EXCEPT_SLOW="1 2 3 4 6 12 16 44a 44b 65 66 67 68"
40 [ $(facet_fstype $SINGLEMDS) = "zfs" ] &&
41 # bug number for skipped test: LU-1867 LU-3127
42 ALWAYS_EXCEPT="$ALWAYS_EXCEPT 89 73b"
46 check_and_setup_lustre
51 rm -rf $DIR/[df][0-9]* $DIR/f.$TESTSUITE.*
53 # LU-482 Avert LVM and VM inability to flush caches in pre .33 kernels
54 if [ $LINUX_VERSION_CODE -lt $(version_code 2.6.33) ]; then
56 do_facet $SINGLEMDS sync
59 test_0a() { # was test_0
60 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
61 replay_barrier $SINGLEMDS
65 run_test 0a "empty replay"
68 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
70 # this test attempts to trigger a race in the precreation code,
71 # and must run before any other objects are created on the filesystem
73 createmany -o $DIR/$tfile 20 || error "createmany -o $DIR/$tfile failed"
74 unlinkmany $DIR/$tfile 20 || error "unlinkmany $DIR/$tfile failed"
76 run_test 0b "ensure object created after recover exists. (3284)"
79 replay_barrier $SINGLEMDS
82 facet_failover $SINGLEMDS
83 zconf_mount $(hostname) $MOUNT || error "mount fails"
84 client_up || error "post-failover df failed"
85 # file shouldn't exist if replay-barrier works as expected
86 rm $DIR/$tfile && error "File exists and it shouldn't"
89 run_test 0c "check replay-barrier"
92 replay_barrier $SINGLEMDS
94 facet_failover $SINGLEMDS
95 zconf_mount $(hostname) $MOUNT || error "mount fails"
96 client_up || error "post-failover df failed"
98 run_test 0d "expired recovery with no clients"
101 replay_barrier $SINGLEMDS
104 $CHECKSTAT -t file $DIR/$tfile ||
105 error "$CHECKSTAT $DIR/$tfile attribute check failed"
108 run_test 1 "simple create"
111 replay_barrier $SINGLEMDS
114 $CHECKSTAT -t file $DIR/$tfile ||
115 error "$CHECKSTAT $DIR/$tfile attribute check failed"
121 mcreate $DIR/$tfile || error "mcreate $DIR/$tfile failed"
122 replay_barrier $SINGLEMDS
125 $CHECKSTAT -t file $DIR/$tfile ||
126 error "$CHECKSTAT $DIR/$tfile attribute check failed"
132 local file=$DIR/$tfile
133 replay_barrier $SINGLEMDS
135 openfile -f O_DIRECTORY $file
137 $CHECKSTAT -t file $file ||
138 error "$CHECKSTAT $file attribute check failed"
141 run_test 3a "replay failed open(O_DIRECTORY)"
144 replay_barrier $SINGLEMDS
145 #define OBD_FAIL_MDS_OPEN_PACK | OBD_FAIL_ONCE
146 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000114"
148 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
150 $CHECKSTAT -t file $DIR/$tfile &&
151 error "$CHECKSTAT $DIR/$tfile attribute check should fail"
154 run_test 3b "replay failed open -ENOMEM"
157 replay_barrier $SINGLEMDS
158 #define OBD_FAIL_MDS_ALLOC_OBDO | OBD_FAIL_ONCE
159 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000128"
161 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
164 $CHECKSTAT -t file $DIR/$tfile &&
165 error "$CHECKSTAT $DIR/$tfile attribute check should fail"
168 run_test 3c "replay failed open -ENOMEM"
170 test_4a() { # was test_4
171 replay_barrier $SINGLEMDS
172 for i in $(seq 10); do
173 echo "tag-$i" > $DIR/$tfile-$i
176 for i in $(seq 10); do
177 grep -q "tag-$i" $DIR/$tfile-$i || error "$tfile-$i"
180 run_test 4a "|x| 10 open(O_CREAT)s"
183 for i in $(seq 10); do
184 echo "tag-$i" > $DIR/$tfile-$i
186 replay_barrier $SINGLEMDS
189 $CHECKSTAT -t file $DIR/$tfile-* &&
190 error "$CHECKSTAT $DIR/$tfile-* attribute check should fail" ||
193 run_test 4b "|x| rm 10 files"
195 # The idea is to get past the first block of precreated files on both
196 # osts, and then replay.
198 replay_barrier $SINGLEMDS
199 for i in $(seq 220); do
200 echo "tag-$i" > $DIR/$tfile-$i
203 for i in $(seq 220); do
204 grep -q "tag-$i" $DIR/$tfile-$i || error "$tfile-$i"
208 # waiting for commitment of removal
210 run_test 5 "|x| 220 open(O_CREAT)"
212 test_6a() { # was test_6
213 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
214 replay_barrier $SINGLEMDS
215 mcreate $DIR/$tdir/$tfile
217 $CHECKSTAT -t dir $DIR/$tdir ||
218 error "$CHECKSTAT $DIR/$tdir attribute check failed"
219 $CHECKSTAT -t file $DIR/$tdir/$tfile ||
220 error "$CHECKSTAT $DIR/$tdir/$tfile attribute check failed"
222 # waiting for log process thread
224 run_test 6a "mkdir + contained create"
227 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
228 replay_barrier $SINGLEMDS
231 $CHECKSTAT -t dir $DIR/$tdir &&
232 error "$CHECKSTAT $DIR/$tdir attribute check should fail" ||
235 run_test 6b "|X| rmdir"
238 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
239 replay_barrier $SINGLEMDS
240 mcreate $DIR/$tdir/$tfile
242 $CHECKSTAT -t dir $DIR/$tdir ||
243 error "$CHECKSTAT $DIR/$tdir attribute check failed"
244 $CHECKSTAT -t file $DIR/$tdir/$tfile ||
245 error "$CHECKSTAT $DIR/$tdir/$tfile attribute check failed"
248 run_test 7 "mkdir |X| contained create"
251 replay_barrier $SINGLEMDS
252 multiop_bg_pause $DIR/$tfile mo_c ||
253 error "multiop mknod $DIR/$tfile failed"
257 $CHECKSTAT -t file $DIR/$tfile ||
258 error "$CHECKSTAT $DIR/$tfile attribute check failed"
259 kill -USR1 $MULTIPID || error "multiop mknod $MULTIPID not running"
260 wait $MULTIPID || error "multiop mknod $MULTIPID failed"
263 run_test 8 "creat open |X| close"
266 replay_barrier $SINGLEMDS
268 local old_inum=$(ls -i $DIR/$tfile | awk '{print $1}')
270 local new_inum=$(ls -i $DIR/$tfile | awk '{print $1}')
272 echo " old_inum == $old_inum, new_inum == $new_inum"
273 if [ $old_inum -eq $new_inum ] ;
275 echo "old_inum and new_inum match"
277 echo " old_inum and new_inum do not match"
278 error "old index($old_inum) does not match new index($new_inum)"
282 run_test 9 "|X| create (same inum/gen)"
285 mcreate $DIR/$tfile || error "mcreate $DIR/$tfile failed"
286 replay_barrier $SINGLEMDS
287 mv $DIR/$tfile $DIR/$tfile-2
290 $CHECKSTAT $DIR/$tfile &&
291 error "$CHECKSTAT $DIR/$tfile attribute check should fail"
292 $CHECKSTAT $DIR/$tfile-2 ||
293 error "$CHECKSTAT $DIR/$tfile-2 attribute check failed"
297 run_test 10 "create |X| rename unlink"
300 mcreate $DIR/$tfile || error "mcreate $DIR/$tfile failed"
301 echo "old" > $DIR/$tfile
302 mv $DIR/$tfile $DIR/$tfile-2
303 replay_barrier $SINGLEMDS
304 echo "new" > $DIR/$tfile
306 grep old $DIR/$tfile-2
308 grep new $DIR/$tfile || error "grep $DIR/$tfile failed"
309 grep old $DIR/$tfile-2 || error "grep $DIR/$tfile-2 failed"
311 run_test 11 "create open write rename |X| create-old-name read"
314 mcreate $DIR/$tfile || error "mcreate $DIR/$tfile failed"
315 multiop_bg_pause $DIR/$tfile o_tSc ||
316 error "multiop_bg_pause $DIR/$tfile failed"
319 replay_barrier $SINGLEMDS
320 kill -USR1 $pid || error "multiop $pid not running"
321 wait $pid || error "multiop $pid failed"
324 [ -e $DIR/$tfile ] && error "file $DIR/$tfile should not exist"
327 run_test 12 "open, unlink |X| close"
329 # 1777 - replay open after committed chmod that would make
330 # a regular open a failure
332 mcreate $DIR/$tfile || error "mcreate $DIR/$tfile failed"
333 multiop_bg_pause $DIR/$tfile O_wc ||
334 error "multiop_bg_pause $DIR/$tfile failed"
337 $CHECKSTAT -p 0 $DIR/$tfile ||
338 error "$CHECKSTAT $DIR/$tfile attribute check failed"
339 replay_barrier $SINGLEMDS
341 kill -USR1 $pid || error "multiop $pid not running"
342 wait $pid || error "multiop $pid failed"
344 $CHECKSTAT -s 1 -p 0 $DIR/$tfile ||
345 error "second $CHECKSTAT $DIR/$tfile attribute check failed"
346 rm $DIR/$tfile || error "rm $DIR/$tfile failed"
349 run_test 13 "open chmod 0 |x| write close"
352 multiop_bg_pause $DIR/$tfile O_tSc ||
353 error "multiop_bg_pause $DIR/$tfile failed"
356 replay_barrier $SINGLEMDS
357 kill -USR1 $pid || error "multiop $pid not running"
358 wait $pid || error "multiop $pid failed"
361 [ -e $DIR/$tfile ] && error "file $DIR/$tfile should not exist"
364 run_test 14 "open(O_CREAT), unlink |X| close"
367 multiop_bg_pause $DIR/$tfile O_tSc ||
368 error "multiop_bg_pause $DIR/$tfile failed"
371 replay_barrier $SINGLEMDS
372 touch $DIR/$tfile-1 || error "touch $DIR/$tfile-1 failed"
373 kill -USR1 $pid || error "multiop $pid not running"
374 wait $pid || error "multiop $pid failed"
377 [ -e $DIR/$tfile ] && error "file $DIR/$tfile should not exist"
378 touch $DIR/$tfile-2 || error "touch $DIR/$tfile-2 failed"
381 run_test 15 "open(O_CREAT), unlink |X| touch new, close"
384 replay_barrier $SINGLEMDS
387 mcreate $DIR/$tfile-2
389 [ -e $DIR/$tfile ] && error "file $DIR/$tfile should not exist"
390 [ -e $DIR/$tfile-2 ] || error "file $DIR/$tfile-2 does not exist"
391 munlink $DIR/$tfile-2 || error "munlink $DIR/$tfile-2 failed"
393 run_test 16 "|X| open(O_CREAT), unlink, touch new, unlink new"
396 replay_barrier $SINGLEMDS
397 multiop_bg_pause $DIR/$tfile O_c ||
398 error "multiop_bg_pause $DIR/$tfile failed"
401 kill -USR1 $pid || error "multiop $pid not running"
402 wait $pid || error "multiop $pid failed"
403 $CHECKSTAT -t file $DIR/$tfile ||
404 error "$CHECKSTAT $DIR/$tfile attribute check failed"
407 run_test 17 "|X| open(O_CREAT), |replay| close"
410 replay_barrier $SINGLEMDS
411 multiop_bg_pause $DIR/$tfile O_tSc ||
412 error "multiop_bg_pause $DIR/$tfile failed"
415 touch $DIR/$tfile-2 || error "touch $DIR/$tfile-2 failed"
416 echo "pid: $pid will close"
417 kill -USR1 $pid || error "multiop $pid not running"
418 wait $pid || error "multiop $pid failed"
421 [ -e $DIR/$tfile ] && error "file $DIR/$tfile should not exist"
422 [ -e $DIR/$tfile-2 ] || error "file $DIR/$tfile-2 does not exist"
423 # this touch frequently fails
424 touch $DIR/$tfile-3 || error "touch $DIR/$tfile-3 failed"
425 munlink $DIR/$tfile-2 || error "munlink $DIR/$tfile-2 failed"
426 munlink $DIR/$tfile-3 || error "munlink $DIR/$tfile-3 failed"
429 run_test 18 "open(O_CREAT), unlink, touch new, close, touch, unlink"
431 # bug 1855 (a simpler form of test_11 above)
433 replay_barrier $SINGLEMDS
435 echo "old" > $DIR/$tfile
436 mv $DIR/$tfile $DIR/$tfile-2
437 grep old $DIR/$tfile-2
439 grep old $DIR/$tfile-2 || error "grep $DIR/$tfile-2 failed"
441 run_test 19 "mcreate, open, write, rename "
443 test_20a() { # was test_20
444 replay_barrier $SINGLEMDS
445 multiop_bg_pause $DIR/$tfile O_tSc ||
446 error "multiop_bg_pause $DIR/$tfile failed"
451 kill -USR1 $pid || error "multiop $pid not running"
452 wait $pid || error "multiop $pid failed"
453 [ -e $DIR/$tfile ] && error "file $DIR/$tfile should not exist"
456 run_test 20a "|X| open(O_CREAT), unlink, replay, close (test mds_cleanup_orphans)"
458 test_20b() { # bug 10480
459 local wait_timeout=$((TIMEOUT * 4))
463 BEFOREUSED=$(df -P $DIR | tail -1 | awk '{ print $3 }')
464 dd if=/dev/zero of=$DIR/$tfile bs=4k count=10000 &
465 while [ ! -e $DIR/$tfile ] ; do
466 usleep 60 # give dd a chance to start
469 $GETSTRIPE $DIR/$tfile || error "$GETSTRIPE $DIR/$tfile failed"
471 rm -f $DIR/$tfile || error "rm -f $DIR/$tfile failed"
473 client_up || client_up || true # reconnect
475 do_facet $SINGLEMDS "lctl set_param -n osd*.*MDT*.force_sync 1"
477 fail $SINGLEMDS # start orphan recovery
478 wait_recovery_complete $SINGLEMDS || error "MDS recovery not done"
479 wait_delete_completed_mds $wait_timeout ||
480 error "delete did not complete"
482 AFTERUSED=$(df -P $DIR | tail -1 | awk '{ print $3 }')
483 log "before $BEFOREUSED, after $AFTERUSED"
484 (( $AFTERUSED > $BEFOREUSED + $(fs_log_size) )) &&
485 error "after $AFTERUSED > before $BEFOREUSED"
488 run_test 20b "write, unlink, eviction, replay, (test mds_cleanup_orphans)"
490 test_20c() { # bug 10480
491 multiop_bg_pause $DIR/$tfile Ow_c ||
492 error "multiop_bg_pause $DIR/$tfile failed"
498 client_up || client_up || true # reconnect
500 kill -USR1 $pid || error "multiop $pid not running"
501 wait $pid || error "multiop $pid failed"
502 [ -s $DIR/$tfile ] || error "File was truncated"
506 run_test 20c "check that client eviction does not affect file content"
509 replay_barrier $SINGLEMDS
510 multiop_bg_pause $DIR/$tfile O_tSc ||
511 error "multiop_bg_pause $DIR/$tfile failed"
514 touch $DIR/$tfile-1 || error "touch $DIR/$tfile-1 failed"
517 kill -USR1 $pid || error "multiop $pid not running"
518 wait $pid || error "multiop $pid failed"
519 [ -e $DIR/$tfile ] && error "file $DIR/$tfile should not exist"
520 touch $DIR/$tfile-2 || error "touch $DIR/$tfile-2 failed"
523 run_test 21 "|X| open(O_CREAT), unlink touch new, replay, close (test mds_cleanup_orphans)"
526 multiop_bg_pause $DIR/$tfile O_tSc ||
527 error "multiop_bg_pause $DIR/$tfile failed"
530 replay_barrier $SINGLEMDS
534 kill -USR1 $pid || error "multiop $pid not running"
535 wait $pid || error "multiop $pid failed"
536 [ -e $DIR/$tfile ] && error "file $DIR/$tfile should not exist"
539 run_test 22 "open(O_CREAT), |X| unlink, replay, close (test mds_cleanup_orphans)"
542 multiop_bg_pause $DIR/$tfile O_tSc ||
543 error "multiop_bg_pause $DIR/$tfile failed"
546 replay_barrier $SINGLEMDS
548 touch $DIR/$tfile-1 || error "touch $DIR/$tfile-1 failed"
551 kill -USR1 $pid || error "multiop $pid not running"
552 wait $pid || error "multiop $pid failed"
553 [ -e $DIR/$tfile ] && error "file $DIR/$tfile should not exist"
554 touch $DIR/$tfile-2 || error "touch $DIR/$tfile-2 failed"
557 run_test 23 "open(O_CREAT), |X| unlink touch new, replay, close (test mds_cleanup_orphans)"
560 multiop_bg_pause $DIR/$tfile O_tSc ||
561 error "multiop_bg_pause $DIR/$tfile failed"
564 replay_barrier $SINGLEMDS
567 kill -USR1 $pid || error "multiop $pid not running"
568 wait $pid || error "multiop $pid failed"
569 [ -e $DIR/$tfile ] && error "file $DIR/$tfile should not exist"
572 run_test 24 "open(O_CREAT), replay, unlink, close (test mds_cleanup_orphans)"
575 multiop_bg_pause $DIR/$tfile O_tSc ||
576 error "multiop_bg_pause $DIR/$tfile failed"
580 replay_barrier $SINGLEMDS
582 kill -USR1 $pid || error "multiop $pid not running"
583 wait $pid || error "multiop $pid failed"
584 [ -e $DIR/$tfile ] && error "file $DIR/$tfile should not exist"
587 run_test 25 "open(O_CREAT), unlink, replay, close (test mds_cleanup_orphans)"
590 replay_barrier $SINGLEMDS
591 multiop_bg_pause $DIR/$tfile-1 O_tSc ||
592 error "multiop_bg_pause $DIR/$tfile-1 failed"
594 multiop_bg_pause $DIR/$tfile-2 O_tSc ||
595 error "multiop_bg_pause $DIR/$tfile-2 failed"
599 kill -USR1 $pid2 || error "second multiop $pid2 not running"
600 wait $pid2 || error "second multiop $pid2 failed"
603 kill -USR1 $pid1 || error "multiop $pid1 not running"
604 wait $pid1 || error "multiop $pid1 failed"
605 [ -e $DIR/$tfile-1 ] && error "file $DIR/$tfile-1 should not exist"
606 [ -e $DIR/$tfile-2 ] && error "file $DIR/$tfile-2 should not exist"
609 run_test 26 "|X| open(O_CREAT), unlink two, close one, replay, close one (test mds_cleanup_orphans)"
612 replay_barrier $SINGLEMDS
613 multiop_bg_pause $DIR/$tfile-1 O_tSc ||
614 error "multiop_bg_pause $DIR/$tfile-1 failed"
616 multiop_bg_pause $DIR/$tfile-2 O_tSc ||
617 error "multiop_bg_pause $DIR/$tfile-2 failed"
623 kill -USR1 $pid1 || error "multiop $pid1 not running"
624 wait $pid1 || error "multiop $pid1 failed"
625 kill -USR1 $pid2 || error "second multiop $pid2 not running"
626 wait $pid2 || error "second multiop $pid2 failed"
627 [ -e $DIR/$tfile-1 ] && error "file $DIR/$tfile-1 should not exist"
628 [ -e $DIR/$tfile-2 ] && error "file $DIR/$tfile-2 should not exist"
631 run_test 27 "|X| open(O_CREAT), unlink two, replay, close two (test mds_cleanup_orphans)"
634 multiop_bg_pause $DIR/$tfile-1 O_tSc ||
635 error "multiop_bg_pause $DIR/$tfile-1 failed"
637 multiop_bg_pause $DIR/$tfile-2 O_tSc ||
638 error "multiop_bg_pause $DIR/$tfile-2 failed"
640 replay_barrier $SINGLEMDS
643 kill -USR1 $pid2 || error "second multiop $pid2 not running"
644 wait $pid2 || error "second multiop $pid2 failed"
647 kill -USR1 $pid1 || error "multiop $pid1 not running"
648 wait $pid1 || error "multiop $pid1 failed"
649 [ -e $DIR/$tfile-1 ] && error "file $DIR/$tfile-1 should not exist"
650 [ -e $DIR/$tfile-2 ] && error "file $DIR/$tfile-2 should not exist"
653 run_test 28 "open(O_CREAT), |X| unlink two, close one, replay, close one (test mds_cleanup_orphans)"
656 multiop_bg_pause $DIR/$tfile-1 O_tSc ||
657 error "multiop_bg_pause $DIR/$tfile-1 failed"
659 multiop_bg_pause $DIR/$tfile-2 O_tSc ||
660 error "multiop_bg_pause $DIR/$tfile-2 failed"
662 replay_barrier $SINGLEMDS
667 kill -USR1 $pid1 || error "multiop $pid1 not running"
668 wait $pid1 || error "multiop $pid1 failed"
669 kill -USR1 $pid2 || error "second multiop $pid2 not running"
670 wait $pid2 || error "second multiop $pid2 failed"
671 [ -e $DIR/$tfile-1 ] && error "file $DIR/$tfile-1 should not exist"
672 [ -e $DIR/$tfile-2 ] && error "file $DIR/$tfile-2 should not exist"
675 run_test 29 "open(O_CREAT), |X| unlink two, replay, close two (test mds_cleanup_orphans)"
678 multiop_bg_pause $DIR/$tfile-1 O_tSc ||
679 error "multiop_bg_pause $DIR/$tfile-1 failed"
681 multiop_bg_pause $DIR/$tfile-2 O_tSc ||
682 error "multiop_bg_pause $DIR/$tfile-2 failed"
687 replay_barrier $SINGLEMDS
689 kill -USR1 $pid1 || error "multiop $pid1 not running"
690 wait $pid1 || error "multiop $pid1 failed"
691 kill -USR1 $pid2 || error "second multiop $pid2 not running"
692 wait $pid2 || error "second multiop $pid2 failed"
693 [ -e $DIR/$tfile-1 ] && error "file $DIR/$tfile-1 should not exist"
694 [ -e $DIR/$tfile-2 ] && error "file $DIR/$tfile-2 should not exist"
697 run_test 30 "open(O_CREAT) two, unlink two, replay, close two (test mds_cleanup_orphans)"
700 multiop_bg_pause $DIR/$tfile-1 O_tSc ||
701 error "multiop_bg_pause $DIR/$tfile-1 failed"
703 multiop_bg_pause $DIR/$tfile-2 O_tSc ||
704 error "multiop_bg_pause $DIR/$tfile-2 failed"
708 replay_barrier $SINGLEMDS
711 kill -USR1 $pid1 || error "multiop $pid1 not running"
712 wait $pid1 || error "multiop $pid1 failed"
713 kill -USR1 $pid2 || error "second multiop $pid2 not running"
714 wait $pid2 || error "second multiop $pid2 failed"
715 [ -e $DIR/$tfile-1 ] && error "file $DIR/$tfile-1 should not exist"
716 [ -e $DIR/$tfile-2 ] && error "file $DIR/$tfile-2 should not exist"
719 run_test 31 "open(O_CREAT) two, unlink one, |X| unlink one, close two (test mds_cleanup_orphans)"
721 # tests for bug 2104; completion without crashing is success. The close is
722 # stale, but we always return 0 for close, so the app never sees it.
724 multiop_bg_pause $DIR/$tfile O_c ||
725 error "multiop_bg_pause $DIR/$tfile failed"
727 multiop_bg_pause $DIR/$tfile O_c ||
728 error "second multiop_bg_pause $DIR/$tfile failed"
731 client_up || client_up || error "client_up failed"
732 kill -USR1 $pid1 || error "multiop $pid1 not running"
733 kill -USR1 $pid2 || error "second multiop $pid2 not running"
734 wait $pid1 || error "multiop $pid1 failed"
735 wait $pid2 || error "second multiop $pid2 failed"
738 run_test 32 "close() notices client eviction; close() after client eviction"
741 createmany -o $DIR/$tfile-%d 10 ||
742 error "createmany create $DIR/$tfile failed"
743 replay_barrier_nosync $SINGLEMDS
744 fail_abort $SINGLEMDS
745 # recreate shouldn't fail
746 createmany -o $DIR/$tfile--%d 10 ||
747 error "createmany recreate $DIR/$tfile failed"
751 run_test 33a "fid seq shouldn't be reused after abort recovery"
754 #define OBD_FAIL_SEQ_ALLOC 0x1311
755 do_facet $SINGLEMDS "lctl set_param fail_loc=0x1311"
757 createmany -o $DIR/$tfile-%d 10
758 replay_barrier_nosync $SINGLEMDS
759 fail_abort $SINGLEMDS
760 # recreate shouldn't fail
761 createmany -o $DIR/$tfile--%d 10 ||
762 error "createmany recreate $DIR/$tfile failed"
766 run_test 33b "test fid seq allocation"
769 multiop_bg_pause $DIR/$tfile O_c ||
770 error "multiop_bg_pause $DIR/$tfile failed"
774 replay_barrier $SINGLEMDS
775 fail_abort $SINGLEMDS
776 kill -USR1 $pid || error "multiop $pid not running"
777 wait $pid || error "multiop $pid failed"
778 [ -e $DIR/$tfile ] && error "file $DIR/$tfile should not exist"
782 run_test 34 "abort recovery before client does replay (test mds_cleanup_orphans)"
784 # bug 2278 - generate one orphan on OST, then destroy it during recovery from llog
786 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
788 #define OBD_FAIL_MDS_REINT_NET_REP 0x119
789 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000119"
794 # give a chance to remove from MDS
795 fail_abort $SINGLEMDS
796 $CHECKSTAT -t file $DIR/$tfile &&
797 error "$CHECKSTAT $DIR/$tfile attribute check should fail" ||
800 run_test 35 "test recovery from llog for unlink op"
802 # b=2432 resent cancel after replay uses wrong cookie,
803 # so don't resend cancels
805 replay_barrier $SINGLEMDS
807 checkstat $DIR/$tfile
808 facet_failover $SINGLEMDS
810 if dmesg | grep "unknown lock cookie"; then
811 error "cancel after replay failed"
814 run_test 36 "don't resend cancel"
817 # directory orphans can't be unlinked from PENDING directory
819 rmdir $DIR/$tfile 2>/dev/null
820 multiop_bg_pause $DIR/$tfile dD_c ||
821 error "multiop_bg_pause $DIR/$tfile failed"
825 replay_barrier $SINGLEMDS
826 # clear the dmesg buffer so we only see errors from this recovery
827 do_facet $SINGLEMDS dmesg -c >/dev/null
828 fail_abort $SINGLEMDS
829 kill -USR1 $pid || error "multiop $pid not running"
830 do_facet $SINGLEMDS dmesg | grep "error .* unlinking .* from PENDING" &&
831 error "error unlinking files"
832 wait $pid || error "multiop $pid failed"
836 run_test 37 "abort recovery before client does replay (test mds_cleanup_orphans for directories)"
839 createmany -o $DIR/$tfile-%d 800 ||
840 error "createmany -o $DIR/$tfile failed"
841 unlinkmany $DIR/$tfile-%d 0 400 || error "unlinkmany $DIR/$tfile failed"
842 replay_barrier $SINGLEMDS
844 unlinkmany $DIR/$tfile-%d 400 400 ||
845 error "unlinkmany $DIR/$tfile 400 failed"
847 $CHECKSTAT -t file $DIR/$tfile-* &&
848 error "$CHECKSTAT $DIR/$tfile-* attribute check should fail" ||
851 run_test 38 "test recovery from unlink llog (test llog_gen_rec) "
853 test_39() { # bug 4176
854 createmany -o $DIR/$tfile-%d 800 ||
855 error "createmany -o $DIR/$tfile failed"
856 replay_barrier $SINGLEMDS
857 unlinkmany $DIR/$tfile-%d 0 400
859 unlinkmany $DIR/$tfile-%d 400 400 ||
860 error "unlinkmany $DIR/$tfile 400 failed"
862 $CHECKSTAT -t file $DIR/$tfile-* &&
863 error "$CHECKSTAT $DIR/$tfile-* attribute check should fail" ||
866 run_test 39 "test recovery from unlink llog (test llog_gen_rec) "
869 lctl get_param -n osc.*.stats | awk -vwrites=0 '/ost_write/ { writes += $2 } END { print writes; }'
874 # always need connection to MDS to verify layout during IO. LU-2628.
875 lctl get_param mdc.*.connect_flags | grep -q layout_lock &&
876 skip "layout_lock needs MDS connection for IO" && return 0
878 $LCTL mark multiop $MOUNT/$tfile OS_c
879 multiop $MOUNT/$tfile OS_c &
881 writeme -s $MOUNT/${tfile}-2 &
884 facet_failover $SINGLEMDS
885 #define OBD_FAIL_MDS_CONNECT_NET 0x117
886 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000117"
888 stat1=$(count_ost_writes)
890 stat2=$(count_ost_writes)
891 echo "$stat1, $stat2"
892 if [ $stat1 -lt $stat2 ]; then
893 echo "writes continuing during recovery"
896 echo "writes not continuing during recovery, bug 2477"
899 echo "waiting for writeme $WRITE_PID"
903 echo "waiting for multiop $PID"
904 wait $PID || error "multiop $PID failed"
905 do_facet client munlink $MOUNT/$tfile ||
906 error "munlink $MOUNT/$tfile failed"
907 do_facet client munlink $MOUNT/${tfile}-2 ||
908 error "munlink $MOUNT/$tfile-2 failed"
911 run_test 40 "cause recovery in ptlrpc, ensure IO continues"
914 # make sure that a read to one osc doesn't try to double-unlock its page just
915 # because another osc is invalid. trigger_group_io used to mistakenly return
916 # an error if any oscs were invalid even after having successfully put rpcs
917 # on valid oscs. This was fatal if the caller was ll_readpage who unlocked
918 # the page, guarnateeing that the unlock from the RPC completion would
919 # assert on trying to unlock the unlocked page.
921 [ $OSTCOUNT -lt 2 ] &&
922 skip_env "skipping test 41: we don't have a second OST to test with" &&
925 local f=$MOUNT/$tfile
926 # make sure the start of the file is ost1
927 $SETSTRIPE -S $((128 * 1024)) -i 0 $f
928 do_facet client dd if=/dev/zero of=$f bs=4k count=1 ||
929 error "dd on client failed"
931 # fail ost2 and read from ost1
932 local mdtosc=$(get_mdtosc_proc_path $SINGLEMDS $ost2_svc)
933 local osc2dev=$(do_facet $SINGLEMDS "lctl get_param -n devices" |
934 grep $mdtosc | awk '{print $1}')
935 [ -z "$osc2dev" ] && echo "OST: $ost2_svc" &&
936 lctl get_param -n devices &&
937 error "OST 2 $osc2dev does not exist"
938 do_facet $SINGLEMDS $LCTL --device $osc2dev deactivate ||
939 error "deactive device on $SINGLEMDS failed"
940 do_facet client dd if=$f of=/dev/null bs=4k count=1 ||
941 error "second dd on client failed"
942 do_facet $SINGLEMDS $LCTL --device $osc2dev activate ||
943 error "active device on $SINGLEMDS failed"
946 run_test 41 "read from a valid osc while other oscs are invalid"
948 # test MDS recovery after ost failure
950 blocks=$(df -P $MOUNT | tail -n 1 | awk '{ print $2 }')
951 createmany -o $DIR/$tfile-%d 800 ||
952 error "createmany -o $DIR/$tfile failed"
954 unlinkmany $DIR/$tfile-%d 0 400
956 lctl set_param debug=-1
959 # osc is evicted, fs is smaller (but only with failout OSTs (bug 7287)
960 #blocks_after=`df -P $MOUNT | tail -n 1 | awk '{ print $2 }'`
961 #[ $blocks_after -lt $blocks ] || return 1
962 echo "wait for MDS to timeout and recover"
963 sleep $((TIMEOUT * 2))
965 unlinkmany $DIR/$tfile-%d 400 400 ||
966 error "unlinkmany $DIR/$tfile 400 failed"
967 $CHECKSTAT -t file $DIR/$tfile-* &&
968 error "$CHECKSTAT $DIR/$tfile-* attribute check should fail" ||
971 run_test 42 "recovery after ost failure"
973 # timeout in MDS/OST recovery RPC will LBUG MDS
974 test_43() { # bug 2530
975 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
977 replay_barrier $SINGLEMDS
979 # OBD_FAIL_OST_CREATE_NET 0x204
980 do_facet ost1 "lctl set_param fail_loc=0x80000204"
986 run_test 43 "mds osc import failure during recovery; don't LBUG"
988 test_44a() { # was test_44
991 local mdcdev=$($LCTL dl |
992 awk "/${FSNAME}-MDT0000-mdc-/ {if (\$2 == \"UP\") {print \$1}}")
993 [ "$mdcdev" ] || error "${FSNAME}-MDT0000-mdc- not UP"
994 [ $(echo $mdcdev | wc -w) -eq 1 ] ||
995 { $LCTL dl; error "looking for mdcdev=$mdcdev"; }
997 # adaptive timeouts slow this way down
998 if at_is_enabled; then
999 at_max_saved=$(at_max_get mds)
1003 for i in $(seq 1 10); do
1004 echo "$i of 10 ($(date +%s))"
1005 do_facet $SINGLEMDS \
1006 "lctl get_param -n md[ts].*.mdt.timeouts | grep service"
1007 #define OBD_FAIL_TGT_CONN_RACE 0x701
1008 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000701"
1009 # lctl below may fail, it is valid case
1010 $LCTL --device $mdcdev recover
1013 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
1014 [ $at_max_saved -ne 0 ] && at_max_set $at_max_saved mds
1017 run_test 44a "race in target handle connect"
1020 local mdcdev=$($LCTL dl |
1021 awk "/${FSNAME}-MDT0000-mdc-/ {if (\$2 == \"UP\") {print \$1}}")
1022 [ "$mdcdev" ] || error "${FSNAME}-MDT0000-mdc not up"
1023 [ $(echo $mdcdev | wc -w) -eq 1 ] ||
1024 { echo mdcdev=$mdcdev; $LCTL dl;
1025 error "more than one ${FSNAME}-MDT0000-mdc"; }
1027 for i in $(seq 1 10); do
1028 echo "$i of 10 ($(date +%s))"
1029 do_facet $SINGLEMDS \
1030 "lctl get_param -n md[ts].*.mdt.timeouts | grep service"
1031 #define OBD_FAIL_TGT_DELAY_RECONNECT 0x704
1032 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000704"
1033 # lctl below may fail, it is valid case
1034 $LCTL --device $mdcdev recover
1039 run_test 44b "race in target handle connect"
1042 replay_barrier $SINGLEMDS
1043 createmany -m $DIR/$tfile-%d 100 || error "failed to create directories"
1044 #define OBD_FAIL_TGT_RCVG_FLAG 0x712
1045 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000712"
1046 fail_abort $SINGLEMDS
1047 unlinkmany $DIR/$tfile-%d 100 && error "unliked after fail abort"
1049 unlinkmany $DIR/$tfile-%d 100 && error "unliked after fail"
1052 run_test 44c "race in target handle connect"
1054 # Handle failed close
1056 local mdcdev=$($LCTL get_param -n devices |
1057 awk "/ ${FSNAME}-MDT0000-mdc-/ {print \$1}")
1058 [ "$mdcdev" ] || error "${FSNAME}-MDT0000-mdc not up"
1059 [ $(echo $mdcdev | wc -w) -eq 1 ] ||
1060 { echo mdcdev=$mdcdev; $LCTL dl;
1061 error "more than one ${FSNAME}-MDT0000-mdc"; }
1063 $LCTL --device $mdcdev recover ||
1064 error "$LCTL --device $mdcdev recover failed"
1066 multiop_bg_pause $DIR/$tfile O_c ||
1067 error "multiop_bg_pause $DIR/$tfile failed"
1070 # This will cause the CLOSE to fail before even
1071 # allocating a reply buffer
1072 $LCTL --device $mdcdev deactivate ||
1073 error "$LCTL --device $mdcdev deactivate failed"
1076 kill -USR1 $pid || error "multiop $pid not running"
1077 wait $pid || error "multiop $pid failed"
1079 $LCTL --device $mdcdev activate ||
1080 error "$LCTL --device $mdcdev activate failed"
1083 $CHECKSTAT -t file $DIR/$tfile ||
1084 error "$CHECKSTAT $DIR/$tfile attribute check failed"
1087 run_test 45 "Handle failed close"
1091 drop_reply "touch $DIR/$tfile"
1093 # ironically, the previous test, 45, will cause a real forced close,
1094 # so just look for one for this test
1095 dmesg | grep -i "force closing client file handle for $tfile" &&
1096 error "found force closing in dmesg"
1099 run_test 46 "Don't leak file handle after open resend (3325)"
1101 test_47() { # bug 2824
1102 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1104 # create some files to make sure precreate has been done on all
1105 # OSTs. (just in case this test is run independently)
1106 createmany -o $DIR/$tfile 20 ||
1107 error "createmany create $DIR/$tfile failed"
1109 # OBD_FAIL_OST_CREATE_NET 0x204
1111 do_facet ost1 "lctl set_param fail_loc=0x80000204"
1112 client_up || error "client_up failed"
1114 # let the MDS discover the OST failure, attempt to recover, fail
1115 # and recover again.
1116 sleep $((3 * TIMEOUT))
1118 # Without 2824, this createmany would hang
1119 createmany -o $DIR/$tfile 20 ||
1120 error "createmany recraete $DIR/$tfile failed"
1121 unlinkmany $DIR/$tfile 20 || error "unlinkmany $DIR/$tfile failed"
1125 run_test 47 "MDS->OSC failure during precreate cleanup (2824)"
1128 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1129 [ "$OSTCOUNT" -lt "2" ] &&
1130 skip_env "$OSTCOUNT < 2 OSTs -- skipping" && return
1132 replay_barrier $SINGLEMDS
1133 createmany -o $DIR/$tfile 20 ||
1134 error "createmany -o $DIR/$tfile failed"
1135 # OBD_FAIL_OST_EROFS 0x216
1136 facet_failover $SINGLEMDS
1137 do_facet ost1 "lctl set_param fail_loc=0x80000216"
1138 client_up || error "client_up failed"
1140 createmany -o $DIR/$tfile 20 20 ||
1141 error "createmany recraete $DIR/$tfile failed"
1142 unlinkmany $DIR/$tfile 40 || error "unlinkmany $DIR/$tfile failed"
1145 run_test 48 "MDS->OSC failure during precreate cleanup (2824)"
1148 local mdtosc=$(get_mdtosc_proc_path $SINGLEMDS $ost1_svc)
1149 local oscdev=$(do_facet $SINGLEMDS "lctl get_param -n devices" |
1150 grep $mdtosc | awk '{print $1}')
1151 [ "$oscdev" ] || error "could not find OSC device on MDS"
1152 do_facet $SINGLEMDS $LCTL --device $oscdev recover ||
1153 error "OSC device $oscdev recovery failed"
1154 do_facet $SINGLEMDS $LCTL --device $oscdev recover ||
1155 error "second OSC device $oscdev recovery failed"
1156 # give the mds_lov_sync threads a chance to run
1159 run_test 50 "Double OSC recovery, don't LASSERT (3812)"
1161 # b3764 timed out lock replay
1163 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.6.90) ] &&
1164 skip "MDS prior to 2.6.90 handle LDLM_REPLY_NET incorrectly" &&
1167 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
1168 cancel_lru_locks mdc
1170 multiop_bg_pause $DIR/$tfile s_s || error "multiop $DIR/$tfile failed"
1173 #define OBD_FAIL_MDS_LDLM_REPLY_NET 0x157
1174 lctl set_param -n ldlm.cancel_unused_locks_before_replay "0"
1175 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000157"
1177 fail $SINGLEMDS || error "fail $SINGLEMDS failed"
1179 wait $mpid || error "multiop_bg_pause pid failed"
1181 do_facet $SINGLEMDS "lctl set_param fail_loc=0x0"
1182 lctl set_param fail_loc=0x0
1183 lctl set_param -n ldlm.cancel_unused_locks_before_replay "1"
1186 run_test 52 "time out lock replay (3764)"
1188 # bug 3462 - simultaneous MDC requests
1190 cancel_lru_locks mdc # cleanup locks from former test cases
1191 mkdir $DIR/${tdir}-1 || error "mkdir $DIR/${tdir}-1 failed"
1192 mkdir $DIR/${tdir}-2 || error "mkdir $DIR/${tdir}-2 failed"
1193 multiop $DIR/${tdir}-1/f O_c &
1195 # give multiop a change to open
1198 #define OBD_FAIL_MDS_CLOSE_NET 0x115
1199 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000115"
1200 kill -USR1 $close_pid
1201 cancel_lru_locks mdc # force the close
1202 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
1204 mcreate $DIR/${tdir}-2/f || error "mcreate $DIR/${tdir}-2/f failed"
1206 # close should still be here
1207 [ -d /proc/$close_pid ] || error "close_pid doesn't exist"
1209 replay_barrier_nodf $SINGLEMDS
1211 wait $close_pid || error "close_pid $close_pid failed"
1213 $CHECKSTAT -t file $DIR/${tdir}-1/f ||
1214 error "$CHECKSTAT $DIR/${tdir}-1/f attribute check failed"
1215 $CHECKSTAT -t file $DIR/${tdir}-2/f ||
1216 error "$CHECKSTAT $DIR/${tdir}-2/f attribute check failed"
1217 rm -rf $DIR/${tdir}-*
1219 run_test 53a "|X| close request while two MDC requests in flight"
1222 cancel_lru_locks mdc # cleanup locks from former test cases
1224 mkdir $DIR/${tdir}-1 || error "mkdir $DIR/${tdir}-1 failed"
1225 mkdir $DIR/${tdir}-2 || error "mkdir $DIR/${tdir}-2 failed"
1226 multiop_bg_pause $DIR/${tdir}-1/f O_c ||
1227 error "multiop_bg_pause $DIR/${tdir}-1/f failed"
1230 #define OBD_FAIL_MDS_REINT_NET 0x107
1231 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000107"
1232 mcreate $DIR/${tdir}-2/f &
1236 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
1237 kill -USR1 $close_pid
1238 cancel_lru_locks mdc # force the close
1239 wait $close_pid || error "close_pid $close_pid failed"
1240 # open should still be here
1241 [ -d /proc/$open_pid ] || error "open_pid doesn't exist"
1243 replay_barrier_nodf $SINGLEMDS
1245 wait $open_pid || error "open_pid failed"
1247 $CHECKSTAT -t file $DIR/${tdir}-1/f ||
1248 error "$CHECKSTAT $DIR/${tdir}-1/f attribute check failed"
1249 $CHECKSTAT -t file $DIR/${tdir}-2/f ||
1250 error "$CHECKSTAT $DIR/${tdir}-2/f attribute check failed"
1251 rm -rf $DIR/${tdir}-*
1253 run_test 53b "|X| open request while two MDC requests in flight"
1256 cancel_lru_locks mdc # cleanup locks from former test cases
1258 mkdir $DIR/${tdir}-1 || error "mkdir $DIR/${tdir}-1 failed"
1259 mkdir $DIR/${tdir}-2 || error "mkdir $DIR/${tdir}-2 failed"
1260 multiop $DIR/${tdir}-1/f O_c &
1263 #define OBD_FAIL_MDS_REINT_NET 0x107
1264 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000107"
1265 mcreate $DIR/${tdir}-2/f &
1269 #define OBD_FAIL_MDS_CLOSE_NET 0x115
1270 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000115"
1271 kill -USR1 $close_pid
1272 cancel_lru_locks mdc # force the close
1274 #bz20647: make sure all pids exist before failover
1275 [ -d /proc/$close_pid ] || error "close_pid doesn't exist"
1276 [ -d /proc/$open_pid ] || error "open_pid doesn't exists"
1277 replay_barrier_nodf $SINGLEMDS
1278 fail_nodf $SINGLEMDS
1279 wait $open_pid || error "open_pid failed"
1281 # close should be gone
1282 [ -d /proc/$close_pid ] && error "close_pid should not exist"
1283 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
1285 $CHECKSTAT -t file $DIR/${tdir}-1/f ||
1286 error "$CHECKSTAT $DIR/${tdir}-1/f attribute check failed"
1287 $CHECKSTAT -t file $DIR/${tdir}-2/f ||
1288 error "$CHECKSTAT $DIR/${tdir}-2/f attribute check failed"
1289 rm -rf $DIR/${tdir}-*
1291 run_test 53c "|X| open request and close request while two MDC requests in flight"
1294 cancel_lru_locks mdc # cleanup locks from former test cases
1296 mkdir $DIR/${tdir}-1 || error "mkdir $DIR/${tdir}-1 failed"
1297 mkdir $DIR/${tdir}-2 || error "mkdir $DIR/${tdir}-2 failed"
1298 multiop $DIR/${tdir}-1/f O_c &
1300 # give multiop a chance to open
1303 #define OBD_FAIL_MDS_CLOSE_NET_REP 0x13b
1304 do_facet $SINGLEMDS "lctl set_param fail_loc=0x8000013b"
1305 kill -USR1 $close_pid
1306 cancel_lru_locks mdc # force the close
1307 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
1308 mcreate $DIR/${tdir}-2/f || error "mcreate $DIR/${tdir}-2/f failed"
1310 # close should still be here
1311 [ -d /proc/$close_pid ] || error "close_pid doesn't exist"
1313 wait $close_pid || error "close_pid failed"
1315 $CHECKSTAT -t file $DIR/${tdir}-1/f ||
1316 error "$CHECKSTAT $DIR/${tdir}-1/f attribute check failed"
1317 $CHECKSTAT -t file $DIR/${tdir}-2/f ||
1318 error "$CHECKSTAT $DIR/${tdir}-2/f attribute check failed"
1319 rm -rf $DIR/${tdir}-*
1321 run_test 53d "close reply while two MDC requests in flight"
1324 cancel_lru_locks mdc # cleanup locks from former test cases
1326 mkdir $DIR/${tdir}-1 || error "mkdir $DIR/${tdir}-1 failed"
1327 mkdir $DIR/${tdir}-2 || error "mkdir $DIR/${tdir}-2 failed"
1328 multiop $DIR/${tdir}-1/f O_c &
1331 #define OBD_FAIL_MDS_REINT_NET_REP 0x119
1332 do_facet $SINGLEMDS "lctl set_param fail_loc=0x119"
1333 mcreate $DIR/${tdir}-2/f &
1337 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
1338 kill -USR1 $close_pid
1339 cancel_lru_locks mdc # force the close
1340 wait $close_pid || error "close_pid failed"
1341 # open should still be here
1342 [ -d /proc/$open_pid ] || error "open_pid doesn't exists"
1344 replay_barrier_nodf $SINGLEMDS
1346 wait $open_pid || error "open_pid failed"
1348 $CHECKSTAT -t file $DIR/${tdir}-1/f ||
1349 error "$CHECKSTAT $DIR/${tdir}-1/f attribute check failed"
1350 $CHECKSTAT -t file $DIR/${tdir}-2/f ||
1351 error "$CHECKSTAT $DIR/${tdir}-2/f attribute check failed"
1352 rm -rf $DIR/${tdir}-*
1354 run_test 53e "|X| open reply while two MDC requests in flight"
1357 cancel_lru_locks mdc # cleanup locks from former test cases
1359 mkdir $DIR/${tdir}-1 || error "mkdir $DIR/${tdir}-1 failed"
1360 mkdir $DIR/${tdir}-2 || error "mkdir $DIR/${tdir}-2 failed"
1361 multiop $DIR/${tdir}-1/f O_c &
1364 #define OBD_FAIL_MDS_REINT_NET_REP 0x119
1365 do_facet $SINGLEMDS "lctl set_param fail_loc=0x119"
1366 mcreate $DIR/${tdir}-2/f &
1370 #define OBD_FAIL_MDS_CLOSE_NET_REP 0x13b
1371 do_facet $SINGLEMDS "lctl set_param fail_loc=0x8000013b"
1372 kill -USR1 $close_pid
1373 cancel_lru_locks mdc # force the close
1375 #bz20647: make sure all pids are exists before failover
1376 [ -d /proc/$close_pid ] || error "close_pid doesn't exist"
1377 [ -d /proc/$open_pid ] || error "open_pid doesn't exists"
1378 replay_barrier_nodf $SINGLEMDS
1379 fail_nodf $SINGLEMDS
1380 wait $open_pid || error "open_pid failed"
1382 # close should be gone
1383 [ -d /proc/$close_pid ] && error "close_pid should not exist"
1384 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
1386 $CHECKSTAT -t file $DIR/${tdir}-1/f ||
1387 error "$CHECKSTAT $DIR/${tdir}-1/f attribute check failed"
1388 $CHECKSTAT -t file $DIR/${tdir}-2/f ||
1389 error "$CHECKSTAT $DIR/${tdir}-2/f attribute check failed"
1390 rm -rf $DIR/${tdir}-*
1392 run_test 53f "|X| open reply and close reply while two MDC requests in flight"
1395 cancel_lru_locks mdc # cleanup locks from former test cases
1397 mkdir $DIR/${tdir}-1 || error "mkdir $DIR/${tdir}-1 failed"
1398 mkdir $DIR/${tdir}-2 || error "mkdir $DIR/${tdir}-2 failed"
1399 multiop $DIR/${tdir}-1/f O_c &
1402 #define OBD_FAIL_MDS_REINT_NET_REP 0x119
1403 do_facet $SINGLEMDS "lctl set_param fail_loc=0x119"
1404 mcreate $DIR/${tdir}-2/f &
1408 #define OBD_FAIL_MDS_CLOSE_NET 0x115
1409 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000115"
1410 kill -USR1 $close_pid
1411 cancel_lru_locks mdc # force the close
1412 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
1414 #bz20647: make sure all pids are exists before failover
1415 [ -d /proc/$close_pid ] || error "close_pid doesn't exist"
1416 [ -d /proc/$open_pid ] || error "open_pid doesn't exists"
1417 replay_barrier_nodf $SINGLEMDS
1418 fail_nodf $SINGLEMDS
1419 wait $open_pid || error "open_pid failed"
1421 # close should be gone
1422 [ -d /proc/$close_pid ] && error "close_pid should not exist"
1424 $CHECKSTAT -t file $DIR/${tdir}-1/f ||
1425 error "$CHECKSTAT $DIR/${tdir}-1/f attribute check failed"
1426 $CHECKSTAT -t file $DIR/${tdir}-2/f ||
1427 error "$CHECKSTAT $DIR/${tdir}-2/f attribute check failed"
1428 rm -rf $DIR/${tdir}-*
1430 run_test 53g "|X| drop open reply and close request while close and open are both in flight"
1433 cancel_lru_locks mdc # cleanup locks from former test cases
1435 mkdir $DIR/${tdir}-1 || error "mkdir $DIR/${tdir}-1 failed"
1436 mkdir $DIR/${tdir}-2 || error "mkdir $DIR/${tdir}-2 failed"
1437 multiop $DIR/${tdir}-1/f O_c &
1440 #define OBD_FAIL_MDS_REINT_NET 0x107
1441 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000107"
1442 mcreate $DIR/${tdir}-2/f &
1446 #define OBD_FAIL_MDS_CLOSE_NET_REP 0x13b
1447 do_facet $SINGLEMDS "lctl set_param fail_loc=0x8000013b"
1448 kill -USR1 $close_pid
1449 cancel_lru_locks mdc # force the close
1452 #bz20647: make sure all pids are exists before failover
1453 [ -d /proc/$close_pid ] || error "close_pid doesn't exist"
1454 [ -d /proc/$open_pid ] || error "open_pid doesn't exists"
1455 replay_barrier_nodf $SINGLEMDS
1456 fail_nodf $SINGLEMDS
1457 wait $open_pid || error "open_pid failed"
1459 # close should be gone
1460 [ -d /proc/$close_pid ] && error "close_pid should not exist"
1461 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
1463 $CHECKSTAT -t file $DIR/${tdir}-1/f ||
1464 error "$CHECKSTAT $DIR/${tdir}-1/f attribute check failed"
1465 $CHECKSTAT -t file $DIR/${tdir}-2/f ||
1466 error "$CHECKSTAT $DIR/${tdir}-2/f attribute check failed"
1467 rm -rf $DIR/${tdir}-*
1469 run_test 53h "open request and close reply while two MDC requests in flight"
1471 #b3761 ASSERTION(hash != 0) failed
1473 # OBD_FAIL_MDS_OPEN_CREATE | OBD_FAIL_ONCE
1474 do_facet $SINGLEMDS "lctl set_param fail_loc=0x8000012b"
1476 # give touch a chance to run
1478 do_facet $SINGLEMDS "lctl set_param fail_loc=0x0"
1482 run_test 55 "let MDS_CHECK_RESENT return the original return code instead of 0"
1484 #b3440 ASSERTION(rec->ur_fid2->id) failed
1486 ln -s foo $DIR/$tfile
1487 replay_barrier $SINGLEMDS
1488 #drop_reply "cat $DIR/$tfile"
1492 run_test 56 "don't replay a symlink open request (3440)"
1494 #recovery one mds-ost setattr from llog
1496 #define OBD_FAIL_MDS_OST_SETATTR 0x12c
1497 do_facet $SINGLEMDS "lctl set_param fail_loc=0x8000012c"
1498 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
1499 replay_barrier $SINGLEMDS
1502 $CHECKSTAT -t file $DIR/$tfile ||
1503 error "$CHECKSTAT $DIR/$tfile attribute check failed"
1504 do_facet $SINGLEMDS "lctl set_param fail_loc=0x0"
1507 run_test 57 "test recovery from llog for setattr op"
1510 zconf_umount $(hostname) $MOUNT2
1514 #recovery many mds-ost setattr from llog
1516 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
1517 #define OBD_FAIL_MDS_OST_SETATTR 0x12c
1518 do_facet $SINGLEMDS "lctl set_param fail_loc=0x8000012c"
1519 createmany -o $DIR/$tdir/$tfile-%d 2500
1520 replay_barrier $SINGLEMDS
1523 $CHECKSTAT -t file $DIR/$tdir/$tfile-* >/dev/null ||
1524 error "$CHECKSTAT $DIR/$tfile-* attribute check failed"
1525 do_facet $SINGLEMDS "lctl set_param fail_loc=0x0"
1526 unlinkmany $DIR/$tdir/$tfile-%d 2500 ||
1527 error "unlinkmany $DIR/$tfile failed"
1530 run_test 58a "test recovery from llog for setattr op (test llog_gen_rec)"
1536 trap cleanup_58 EXIT
1538 large_xattr_enabled &&
1539 orig="$(generate_string $(max_xattr_size))" || orig="bar"
1540 # Original extended attribute can be long. Print a small version of
1541 # attribute if an error occurs
1542 local sm_msg=$(printf "%.9s" $orig)
1544 mount_client $MOUNT2 || error "mount_client on $MOUNT2 failed"
1545 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
1546 touch $DIR/$tdir/$tfile || error "touch $DIR/$tdir/$tfile failed"
1547 replay_barrier $SINGLEMDS
1548 setfattr -n trusted.foo -v $orig $DIR/$tdir/$tfile
1550 new=$(get_xattr_value trusted.foo $MOUNT2/$tdir/$tfile)
1551 [[ "$new" = "$orig" ]] ||
1552 error "xattr set ($sm_msg...) differs from xattr get ($new)"
1553 rm -f $DIR/$tdir/$tfile
1556 wait_clients_import_state ${CLIENTS:-$HOSTNAME} "mgs" FULL
1558 run_test 58b "test replay of setxattr op"
1560 test_58c() { # bug 16570
1565 trap cleanup_58 EXIT
1567 if large_xattr_enabled; then
1568 local xattr_size=$(max_xattr_size)
1569 orig="$(generate_string $((xattr_size / 2)))"
1570 orig1="$(generate_string $xattr_size)"
1576 # PING_INTERVAL max(obd_timeout / 4, 1U)
1577 sleep $((TIMEOUT / 4))
1579 # Original extended attribute can be long. Print a small version of
1580 # attribute if an error occurs
1581 local sm_msg=$(printf "%.9s" $orig)
1582 local sm_msg1=$(printf "%.9s" $orig1)
1584 mount_client $MOUNT2 || error "mount_client on $MOUNT2 failed"
1585 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
1586 touch $DIR/$tdir/$tfile || error "touch $DIR/$tdir/$tfile failed"
1587 drop_request "setfattr -n trusted.foo -v $orig $DIR/$tdir/$tfile" ||
1588 error "drop_request for setfattr failed"
1589 new=$(get_xattr_value trusted.foo $MOUNT2/$tdir/$tfile)
1590 [[ "$new" = "$orig" ]] ||
1591 error "xattr set ($sm_msg...) differs from xattr get ($new)"
1592 drop_reint_reply "setfattr -n trusted.foo1 \
1593 -v $orig1 $DIR/$tdir/$tfile" ||
1594 error "drop_reint_reply for setfattr failed"
1595 new=$(get_xattr_value trusted.foo1 $MOUNT2/$tdir/$tfile)
1596 [[ "$new" = "$orig1" ]] ||
1597 error "second xattr set ($sm_msg1...) differs xattr get ($new)"
1598 rm -f $DIR/$tdir/$tfile
1602 run_test 58c "resend/reconstruct setxattr op"
1604 # log_commit_thread vs filter_destroy race used to lead to import use after free
1607 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1609 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
1610 createmany -o $DIR/$tdir/$tfile-%d 200 ||
1611 error "createmany create files failed"
1613 unlinkmany $DIR/$tdir/$tfile-%d 200 ||
1614 error "unlinkmany $DIR/$tdir/$tfile failed"
1615 #define OBD_FAIL_PTLRPC_DELAY_RECOV 0x507
1616 do_facet ost1 "lctl set_param fail_loc=0x507"
1619 do_facet ost1 "lctl set_param fail_loc=0x0"
1623 run_test 59 "test log_commit_thread vs filter_destroy race"
1625 # race between add unlink llog vs cat log init in post_recovery (only for b1_6)
1626 # bug 12086: should no oops and No ctxt error for this test
1628 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
1629 createmany -o $DIR/$tdir/$tfile-%d 200 ||
1630 error "createmany create files failed"
1631 replay_barrier $SINGLEMDS
1632 unlinkmany $DIR/$tdir/$tfile-%d 0 100
1634 unlinkmany $DIR/$tdir/$tfile-%d 100 100
1635 local no_ctxt=$(dmesg | grep "No ctxt")
1636 [ -z "$no_ctxt" ] || error "ctxt is not initialized in recovery"
1638 run_test 60 "test llog post recovery init vs llog unlink"
1640 #test race llog recovery thread vs llog cleanup
1641 test_61a() { # was test_61
1642 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1644 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
1645 createmany -o $DIR/$tdir/$tfile-%d 800 ||
1646 error "createmany create files failed"
1648 unlinkmany $DIR/$tdir/$tfile-%d 800
1649 # OBD_FAIL_OST_LLOG_RECOVERY_TIMEOUT 0x221
1650 set_nodes_failloc "$(osts_nodes)" 0x80000221
1655 set_nodes_failloc "$(osts_nodes)" 0x0
1657 $CHECKSTAT -t file $DIR/$tdir/$tfile-* &&
1658 error "$CHECKSTAT $DIR/$tdir/$tfile attribute check should fail"
1661 run_test 61a "test race llog recovery vs llog cleanup"
1663 #test race mds llog sync vs llog cleanup
1665 # OBD_FAIL_MDS_LLOG_SYNC_TIMEOUT 0x13a
1666 do_facet $SINGLEMDS "lctl set_param fail_loc=0x8000013a"
1667 facet_failover $SINGLEMDS
1670 do_facet client dd if=/dev/zero of=$DIR/$tfile bs=4k count=1 ||
1673 run_test 61b "test race mds llog sync vs llog cleanup"
1675 #test race cancel cookie cb vs llog cleanup
1677 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1679 # OBD_FAIL_OST_CANCEL_COOKIE_TIMEOUT 0x222
1680 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
1681 set_nodes_failloc "$(osts_nodes)" 0x80000222
1685 set_nodes_failloc "$(osts_nodes)" 0x0
1687 run_test 61c "test race mds llog sync vs llog cleanup"
1689 test_61d() { # bug 16002 # bug 17466 # bug 22137
1690 # OBD_FAIL_OBD_LLOG_SETUP 0x605
1692 do_facet mgs "lctl set_param fail_loc=0x80000605"
1693 start mgs $(mgsdevname) $MGS_MOUNT_OPTS &&
1694 error "mgs start should have failed"
1695 do_facet mgs "lctl set_param fail_loc=0"
1696 start mgs $(mgsdevname) $MGS_MOUNT_OPTS || error "cannot restart mgs"
1698 run_test 61d "error in llog_setup should cleanup the llog context correctly"
1700 test_62() { # Bug 15756 - don't mis-drop resent replay
1701 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
1702 replay_barrier $SINGLEMDS
1703 createmany -o $DIR/$tdir/$tfile- 25 ||
1704 error "createmany create files failed"
1705 #define OBD_FAIL_TGT_REPLAY_DROP 0x707
1706 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000707"
1708 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
1709 unlinkmany $DIR/$tdir/$tfile- 25 ||
1710 error "unlinkmany $DIR/$tdir/$tfile failed"
1713 run_test 62 "don't mis-drop resent replay"
1715 #Adaptive Timeouts (bug 3055)
1723 echo "Cleaning up AT ..."
1724 if [ -n "$ATOLDBASE" ]; then
1725 local at_history=$($LCTL get_param -n at_history)
1726 do_facet $SINGLEMDS "lctl set_param at_history=$at_history" || true
1727 do_facet ost1 "lctl set_param at_history=$at_history" || true
1730 if [ $AT_MAX_SET -ne 0 ]; then
1731 for facet in mds client ost; do
1732 var=AT_MAX_SAVE_${facet}
1733 echo restore AT on $facet to saved value ${!var}
1734 at_max_set ${!var} $facet
1735 at_new=$(at_max_get $facet)
1736 echo Restored AT value on $facet $at_new
1737 [ $at_new -eq ${!var} ] ||
1738 error "AT value not restored SAVED ${!var} NEW $at_new"
1745 local at_max_new=600
1747 # Save at_max original values
1749 if [ $AT_MAX_SET -eq 0 ]; then
1750 # Suppose that all osts have the same at_max
1751 for facet in mds client ost; do
1752 eval AT_MAX_SAVE_${facet}=$(at_max_get $facet)
1756 for facet in mds client ost; do
1757 at_max=$(at_max_get $facet)
1758 if [ $at_max -ne $at_max_new ]; then
1759 echo "AT value on $facet is $at_max, set it by force temporarily to $at_max_new"
1760 at_max_set $at_max_new $facet
1765 if [ -z "$ATOLDBASE" ]; then
1766 ATOLDBASE=$(do_facet $SINGLEMDS "lctl get_param -n at_history")
1767 # speed up the timebase so we can check decreasing AT
1768 do_facet $SINGLEMDS "lctl set_param at_history=8" || true
1769 do_facet ost1 "lctl set_param at_history=8" || true
1771 # sleep for a while to cool down, should be > 8s and also allow
1772 # at least one ping to be sent. simply use TIMEOUT to be safe.
1777 test_65a() #bug 3055
1779 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1781 at_start || return 0
1782 $LCTL dk > /dev/null
1784 $LCTL set_param debug="other"
1785 # Slow down a request to the current service time, this is critical
1786 # because previous tests may have caused this value to increase.
1787 REQ_DELAY=`lctl get_param -n mdc.${FSNAME}-MDT0000-mdc-*.timeouts |
1788 awk '/portal 12/ {print $5}'`
1789 REQ_DELAY=$((${REQ_DELAY} + ${REQ_DELAY} / 4 + 5))
1791 do_facet $SINGLEMDS lctl set_param fail_val=$((${REQ_DELAY} * 1000))
1792 #define OBD_FAIL_PTLRPC_PAUSE_REQ 0x50a
1793 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x8000050a
1794 createmany -o $DIR/$tfile 10 > /dev/null
1795 unlinkmany $DIR/$tfile 10 > /dev/null
1796 # check for log message
1797 $LCTL dk | grep "Early reply #" || error "No early reply"
1799 # client should show REQ_DELAY estimates
1800 lctl get_param -n mdc.${FSNAME}-MDT0000-mdc-*.timeouts | grep portal
1802 lctl get_param -n mdc.${FSNAME}-MDT0000-mdc-*.timeouts | grep portal
1804 run_test 65a "AT: verify early replies"
1806 test_65b() #bug 3055
1808 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1810 at_start || return 0
1813 $LCTL set_param debug="other trace"
1814 $LCTL dk > /dev/null
1815 # Slow down a request to the current service time, this is critical
1816 # because previous tests may have caused this value to increase.
1817 $SETSTRIPE --stripe-index=0 --count=1 $DIR/$tfile
1818 multiop $DIR/$tfile Ow1yc
1819 REQ_DELAY=`lctl get_param -n osc.${FSNAME}-OST0000-osc-*.timeouts |
1820 awk '/portal 6/ {print $5}'`
1821 REQ_DELAY=$((${REQ_DELAY} + ${REQ_DELAY} / 4 + 5))
1823 do_facet ost1 lctl set_param fail_val=${REQ_DELAY}
1824 #define OBD_FAIL_OST_BRW_PAUSE_PACK 0x224
1825 do_facet ost1 $LCTL set_param fail_loc=0x224
1828 $SETSTRIPE --stripe-index=0 --count=1 $DIR/$tfile
1829 # force some real bulk transfer
1830 multiop $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
1832 do_facet ost1 $LCTL set_param fail_loc=0
1833 # check for log message
1834 $LCTL dk | grep "Early reply #" || error "No early reply"
1836 # client should show REQ_DELAY estimates
1837 lctl get_param -n osc.${FSNAME}-OST0000-osc-*.timeouts | grep portal
1839 run_test 65b "AT: verify early replies on packed reply / bulk"
1841 test_66a() #bug 3055
1843 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1845 at_start || return 0
1846 lctl get_param -n mdc.${FSNAME}-MDT0000-mdc-*.timeouts | grep "portal 12"
1847 # adjust 5s at a time so no early reply is sent (within deadline)
1848 do_facet $SINGLEMDS "$LCTL set_param fail_val=5000"
1849 #define OBD_FAIL_PTLRPC_PAUSE_REQ 0x50a
1850 do_facet $SINGLEMDS "$LCTL set_param fail_loc=0x8000050a"
1851 createmany -o $DIR/$tfile 20 > /dev/null
1852 unlinkmany $DIR/$tfile 20 > /dev/null
1853 lctl get_param -n mdc.${FSNAME}-MDT0000-mdc-*.timeouts | grep "portal 12"
1854 do_facet $SINGLEMDS "$LCTL set_param fail_val=10000"
1855 do_facet $SINGLEMDS "$LCTL set_param fail_loc=0x8000050a"
1856 createmany -o $DIR/$tfile 20 > /dev/null
1857 unlinkmany $DIR/$tfile 20 > /dev/null
1858 lctl get_param -n mdc.${FSNAME}-MDT0000-mdc-*.timeouts | grep "portal 12"
1859 do_facet $SINGLEMDS "$LCTL set_param fail_loc=0"
1861 createmany -o $DIR/$tfile 20 > /dev/null
1862 unlinkmany $DIR/$tfile 20 > /dev/null
1863 lctl get_param -n mdc.${FSNAME}-MDT0000-mdc-*.timeouts | grep "portal 12"
1864 CUR=$(lctl get_param -n mdc.${FSNAME}-MDT0000-mdc-*.timeouts | awk '/portal 12/ {print $5}')
1865 WORST=$(lctl get_param -n mdc.${FSNAME}-MDT0000-mdc-*.timeouts | awk '/portal 12/ {print $7}')
1866 echo "Current MDT timeout $CUR, worst $WORST"
1867 [ $CUR -lt $WORST ] || error "Current $CUR should be less than worst $WORST"
1869 run_test 66a "AT: verify MDT service time adjusts with no early replies"
1871 test_66b() #bug 3055
1873 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1875 at_start || return 0
1876 ORIG=$(lctl get_param -n mdc.${FSNAME}-MDT0000*.timeouts |
1877 awk '/network/ {print $4}')
1878 $LCTL set_param fail_val=$(($ORIG + 5))
1879 #define OBD_FAIL_PTLRPC_PAUSE_REP 0x50c
1880 $LCTL set_param fail_loc=0x50c
1881 ls $DIR/$tfile > /dev/null 2>&1
1882 $LCTL set_param fail_loc=0
1883 CUR=$(lctl get_param -n mdc.${FSNAME}-MDT0000*.timeouts |
1884 awk '/network/ {print $4}')
1885 WORST=$(lctl get_param -n mdc.${FSNAME}-MDT0000*.timeouts |
1886 awk '/network/ {print $6}')
1887 echo "network timeout orig $ORIG, cur $CUR, worst $WORST"
1888 [ $WORST -gt $ORIG ] ||
1889 error "Worst $WORST should be worse than orig $ORIG"
1891 run_test 66b "AT: verify net latency adjusts"
1893 test_67a() #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}')
1899 # sleeping threads may drive values above this
1900 do_facet ost1 "$LCTL set_param fail_val=400"
1901 #define OBD_FAIL_PTLRPC_PAUSE_REQ 0x50a
1902 do_facet ost1 "$LCTL set_param fail_loc=0x50a"
1903 createmany -o $DIR/$tfile 20 > /dev/null
1904 unlinkmany $DIR/$tfile 20 > /dev/null
1905 do_facet ost1 "$LCTL set_param fail_loc=0"
1906 CONN2=$(lctl get_param -n osc.*.stats | awk '/_connect/ {total+=$2} END {print total}')
1907 ATTEMPTS=$(($CONN2 - $CONN1))
1908 echo "$ATTEMPTS osc reconnect attempts on gradual slow"
1909 [ $ATTEMPTS -gt 0 ] &&
1910 error_ignore bz13721 "AT should have prevented reconnect"
1913 run_test 67a "AT: verify slow request processing doesn't induce reconnects"
1915 test_67b() #bug 3055
1917 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1919 at_start || return 0
1920 CONN1=$(lctl get_param -n osc.*.stats | awk '/_connect/ {total+=$2} END {print total}')
1922 # exhaust precreations on ost1
1923 local OST=$(ostname_from_index 0)
1924 local mdtosc=$(get_mdtosc_proc_path mds $OST)
1925 local last_id=$(do_facet $SINGLEMDS lctl get_param -n \
1926 osc.$mdtosc.prealloc_last_id)
1927 local next_id=$(do_facet $SINGLEMDS lctl get_param -n \
1928 osc.$mdtosc.prealloc_next_id)
1930 mkdir -p $DIR/$tdir/${OST} || error "mkdir $DIR/$tdir/${OST} failed"
1931 $SETSTRIPE -i 0 -c 1 $DIR/$tdir/${OST} || error "$SETSTRIPE failed"
1932 echo "Creating to objid $last_id on ost $OST..."
1933 #define OBD_FAIL_OST_PAUSE_CREATE 0x223
1934 do_facet ost1 "$LCTL set_param fail_val=20000"
1935 do_facet ost1 "$LCTL set_param fail_loc=0x80000223"
1936 createmany -o $DIR/$tdir/${OST}/f $next_id $((last_id - next_id + 2))
1939 do_facet ost1 "lctl get_param -n ost.OSS.ost_create.timeouts"
1941 CONN2=$(lctl get_param -n osc.*.stats | awk '/_connect/ {total+=$2} END {print total}')
1942 ATTEMPTS=$(($CONN2 - $CONN1))
1943 echo "$ATTEMPTS osc reconnect attempts on instant slow"
1944 # do it again; should not timeout
1945 do_facet ost1 "$LCTL set_param fail_loc=0x80000223"
1946 cp /etc/profile $DIR/$tfile || error "cp failed"
1947 do_facet ost1 "$LCTL set_param fail_loc=0"
1949 do_facet ost1 "lctl get_param -n ost.OSS.ost_create.timeouts"
1950 CONN3=$(lctl get_param -n osc.*.stats | awk '/_connect/ {total+=$2} END {print total}')
1951 ATTEMPTS=$(($CONN3 - $CONN2))
1952 echo "$ATTEMPTS osc reconnect attempts on 2nd slow"
1953 [ $ATTEMPTS -gt 0 ] && error "AT should have prevented reconnect"
1956 run_test 67b "AT: verify instant slowdown doesn't induce reconnects"
1958 test_68 () #bug 13813
1960 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1962 at_start || return 0
1963 local ldlm_enqueue_min=$(find /sys -name ldlm_enqueue_min)
1964 [ -z "$ldlm_enqueue_min" ] && skip "missing /sys/.../ldlm_enqueue_min" && return 0
1965 local ldlm_enqueue_min_r=$(do_facet ost1 "find /sys -name ldlm_enqueue_min")
1966 [ -z "$ldlm_enqueue_min_r" ] && skip "missing /sys/.../ldlm_enqueue_min in the ost1" && return 0
1967 local ENQ_MIN=$(cat $ldlm_enqueue_min)
1968 local ENQ_MIN_R=$(do_facet ost1 "cat $ldlm_enqueue_min_r")
1969 echo $TIMEOUT >> $ldlm_enqueue_min
1970 do_facet ost1 "echo $TIMEOUT >> $ldlm_enqueue_min_r"
1972 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
1973 $SETSTRIPE --stripe-index=0 --count=1 $DIR/$tdir
1974 #define OBD_FAIL_LDLM_PAUSE_CANCEL 0x312
1975 $LCTL set_param fail_val=$(($TIMEOUT - 1))
1976 $LCTL set_param fail_loc=0x80000312
1977 cp /etc/profile $DIR/$tdir/${tfile}_1 || error "1st cp failed $?"
1978 $LCTL set_param fail_val=$((TIMEOUT * 5 / 4))
1979 $LCTL set_param fail_loc=0x80000312
1980 cp /etc/profile $DIR/$tdir/${tfile}_2 || error "2nd cp failed $?"
1981 $LCTL set_param fail_loc=0
1983 echo $ENQ_MIN >> $ldlm_enqueue_min
1984 do_facet ost1 "echo $ENQ_MIN_R >> $ldlm_enqueue_min_r"
1988 run_test 68 "AT: verify slowing locks"
1991 # end of AT tests includes above lines
1993 # start multi-client tests
1995 [ -z "$CLIENTS" ] &&
1996 { skip "Need two or more clients." && return; }
1997 [ $CLIENTCOUNT -lt 2 ] &&
1998 { skip "Need two or more clients, have $CLIENTCOUNT" && return; }
2000 echo "mount clients $CLIENTS ..."
2001 zconf_mount_clients $CLIENTS $MOUNT
2003 local clients=${CLIENTS//,/ }
2004 echo "Write/read files on $DIR ; clients $CLIENTS ... "
2005 for CLIENT in $clients; do
2006 do_node $CLIENT dd bs=1M count=10 if=/dev/zero \
2007 of=$DIR/${tfile}_${CLIENT} 2>/dev/null ||
2008 error "dd failed on $CLIENT"
2011 local prev_client=$(echo $clients | sed 's/^.* \(.\+\)$/\1/')
2012 for C in ${CLIENTS//,/ }; do
2013 do_node $prev_client dd if=$DIR/${tfile}_${C} \
2014 of=/dev/null 2>/dev/null ||
2015 error "dd if=$DIR/${tfile}_${C} failed on $prev_client"
2021 run_test 70a "check multi client t-f"
2023 check_for_process () {
2028 killall_process $clients "$prog" -0
2031 killall_process () {
2032 local clients=${1:-$(hostname)}
2037 do_nodes $clients "killall $signal $name"
2041 local clients=${CLIENTS:-$HOSTNAME}
2043 zconf_mount_clients $clients $MOUNT
2046 [ "$SLOW" = "no" ] && duration=120
2047 # set duration to 900 because it takes some time to boot node
2048 [ "$FAILURE_MODE" = HARD ] && duration=900
2051 local start_ts=$(date +%s)
2052 local cmd="rundbench 1 -t $duration"
2054 if [ $MDSCOUNT -ge 2 ]; then
2055 test_mkdir -p -c$MDSCOUNT $DIR/$tdir
2056 $LFS setdirstripe -D -c$MDSCOUNT $DIR/$tdir
2058 do_nodesv $clients "set -x; MISSING_DBENCH_OK=$MISSING_DBENCH_OK \
2059 PATH=\$PATH:$LUSTRE/utils:$LUSTRE/tests/:$DBENCH_LIB \
2060 DBENCH_LIB=$DBENCH_LIB TESTSUITE=$TESTSUITE TESTNAME=$TESTNAME \
2061 MOUNT=$MOUNT DIR=$DIR/$tdir/\\\$(hostname) LCTL=$LCTL $cmd" &
2064 #LU-1897 wait for all dbench copies to start
2065 while ! check_for_process $clients dbench; do
2066 elapsed=$(($(date +%s) - start_ts))
2067 if [ $elapsed -gt $duration ]; then
2068 killall_process $clients dbench
2069 error "dbench failed to start on $clients!"
2074 log "Started rundbench load pid=$pid ..."
2076 elapsed=$(($(date +%s) - start_ts))
2077 local num_failovers=0
2079 while [ $elapsed -lt $duration ]; do
2080 if ! check_for_process $clients dbench; then
2081 error_noexit "dbench stopped on some of $clients!"
2082 killall_process $clients dbench
2086 replay_barrier mds$fail_index
2087 sleep 1 # give clients a time to do operations
2088 # Increment the number of failovers
2089 num_failovers=$((num_failovers+1))
2090 log "$TESTNAME fail mds$fail_index $num_failovers times"
2092 elapsed=$(($(date +%s) - start_ts))
2093 if [ $fail_index -ge $MDSCOUNT ]; then
2096 fail_index=$((fail_index+1))
2100 wait $pid || error "rundbench load on $clients failed!"
2102 run_test 70b "dbench ${MDSCOUNT}mdts recovery; $CLIENTCOUNT clients"
2103 # end multi-client tests
2106 multiop_bg_pause $DIR/$tfile O_tSc ||
2107 error "multiop_bg_pause $DIR/$tfile failed"
2111 replay_barrier $SINGLEMDS
2112 #define OBD_FAIL_LDLM_ENQUEUE_NET 0x302
2113 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000302"
2116 wait $pid || error "multiop pid failed"
2117 [ -e $DIR/$tfile ] && error "file $DIR/$tfile should not exist"
2120 run_test 73a "open(O_CREAT), unlink, replay, reconnect before open replay, close"
2123 multiop_bg_pause $DIR/$tfile O_tSc ||
2124 error "multiop_bg_pause $DIR/$tfile failed"
2128 replay_barrier $SINGLEMDS
2129 #define OBD_FAIL_LDLM_REPLY 0x30c
2130 do_facet $SINGLEMDS "lctl set_param fail_loc=0x8000030c"
2133 wait $pid || error "multiop pid failed"
2134 [ -e $DIR/$tfile ] && error "file $DIR/$tfile should not exist"
2137 run_test 73b "open(O_CREAT), unlink, replay, reconnect at open_replay reply, close"
2141 local clients=${CLIENTS:-$HOSTNAME}
2143 zconf_umount_clients $clients $MOUNT
2145 facet_failover $SINGLEMDS
2146 zconf_mount_clients $clients $MOUNT
2148 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
2149 rm $DIR/$tfile || error "rm $DIR/$tfile failed"
2150 clients_up || error "client evicted: $?"
2153 run_test 74 "Ensure applications don't fail waiting for OST recovery"
2155 remote_dir_check_80() {
2160 diridx=$($GETSTRIPE -M $remote_dir) ||
2161 error "$GETSTRIPE -M $remote_dir failed"
2162 [ $diridx -eq $MDTIDX ] || error "$diridx != $MDTIDX"
2164 createmany -o $remote_dir/f-%d 20 || error "creation failed"
2165 fileidx=$($GETSTRIPE -M $remote_dir/f-1) ||
2166 error "$GETSTRIPE -M $remote_dir/f-1 failed"
2167 [ $fileidx -eq $MDTIDX ] || error "$fileidx != $MDTIDX"
2173 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2174 ([ $FAILURE_MODE == "HARD" ] &&
2175 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
2176 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
2180 local remote_dir=$DIR/$tdir/remote_dir
2182 mkdir -p $DIR/$tdir || error "mkdir $DIR/$tdir failed"
2183 #define OBD_FAIL_OUT_UPDATE_NET_REP 0x1701
2184 do_facet mds${MDTIDX} lctl set_param fail_loc=0x1701
2185 $LFS mkdir -i $MDTIDX $remote_dir &
2191 wait $CLIENT_PID || error "remote creation failed"
2193 remote_dir_check_80 || error "remote dir check failed"
2194 rm -rf $DIR/$tdir || error "rmdir failed"
2198 run_test 80a "DNE: create remote dir, drop update rep from MDT0, fail MDT0"
2201 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2202 ([ $FAILURE_MODE == "HARD" ] &&
2203 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
2204 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
2208 local remote_dir=$DIR/$tdir/remote_dir
2210 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
2211 #define OBD_FAIL_UPDATE_OBJ_NET_REP 0x1701
2212 do_facet mds${MDTIDX} lctl set_param fail_loc=0x1701
2213 $LFS mkdir -i $MDTIDX $remote_dir &
2218 fail mds$((MDTIDX + 1))
2220 wait $CLIENT_PID || error "remote creation failed"
2222 remote_dir_check_80 || error "remote dir check failed"
2223 rm -rf $DIR/$tdir || error "rmdir failed"
2227 run_test 80b "DNE: create remote dir, drop update rep from MDT0, fail MDT1"
2230 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2231 ([ $FAILURE_MODE == "HARD" ] &&
2232 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
2233 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
2237 local remote_dir=$DIR/$tdir/remote_dir
2239 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
2240 #define OBD_FAIL_UPDATE_OBJ_NET_REP 0x1701
2241 do_facet mds${MDTIDX} lctl set_param fail_loc=0x1701
2242 $LFS mkdir -i $MDTIDX $remote_dir &
2248 fail mds$((MDTIDX + 1))
2250 wait $CLIENT_PID || error "remote creation failed"
2252 remote_dir_check_80 || error "remote dir check failed"
2253 rm -rf $DIR/$tdir || error "rmdir failed"
2257 run_test 80c "DNE: create remote dir, drop update rep from MDT1, fail MDT[0,1]"
2260 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2262 local remote_dir=$DIR/$tdir/remote_dir
2264 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
2265 #define OBD_FAIL_UPDATE_OBJ_NET_REP 0x1701
2266 do_facet mds${MDTIDX} lctl set_param fail_loc=0x1701
2267 $LFS mkdir -i $MDTIDX $remote_dir &
2270 # sleep 3 seconds to make sure MDTs are failed after
2271 # lfs mkdir -i has finished on all of MDTs.
2276 fail mds${MDTIDX},mds$((MDTIDX + 1))
2278 wait $CLIENT_PID || error "remote creation failed"
2280 remote_dir_check_80 || error "remote dir check failed"
2281 rm -rf $DIR/$tdir || error "rmdir failed"
2285 run_test 80d "DNE: create remote dir, drop update rep from MDT1, fail 2 MDTs"
2288 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2289 ([ $FAILURE_MODE == "HARD" ] &&
2290 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
2291 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
2295 local remote_dir=$DIR/$tdir/remote_dir
2297 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
2298 # OBD_FAIL_MDS_REINT_NET_REP 0x119
2299 do_facet mds$((MDTIDX + 1)) lctl set_param fail_loc=0x119
2300 $LFS mkdir -i $MDTIDX $remote_dir &
2303 # sleep 3 seconds to make sure MDTs are failed after
2304 # lfs mkdir -i has finished on all of MDTs.
2310 wait $CLIENT_PID || error "remote creation failed"
2312 remote_dir_check_80 || error "remote dir check failed"
2313 rm -rf $DIR/$tdir || error "rmdir failed"
2317 run_test 80e "DNE: create remote dir, drop MDT1 rep, fail MDT0"
2320 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2321 ([ $FAILURE_MODE == "HARD" ] &&
2322 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
2323 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
2326 local remote_dir=$DIR/$tdir/remote_dir
2328 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
2329 # OBD_FAIL_MDS_REINT_NET_REP 0x119
2330 do_facet mds$((MDTIDX + 1)) lctl set_param fail_loc=0x119
2331 $LFS mkdir -i $MDTIDX $remote_dir &
2335 fail mds$((MDTIDX + 1))
2337 wait $CLIENT_PID || error "remote creation failed"
2339 remote_dir_check_80 || error "remote dir check failed"
2340 rm -rf $DIR/$tdir || error "rmdir failed"
2344 run_test 80f "DNE: create remote dir, drop MDT1 rep, fail MDT1"
2347 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2348 ([ $FAILURE_MODE == "HARD" ] &&
2349 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
2350 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
2354 local remote_dir=$DIR/$tdir/remote_dir
2356 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
2357 # OBD_FAIL_MDS_REINT_NET_REP 0x119
2358 do_facet mds$((MDTIDX + 1)) lctl set_param fail_loc=0x119
2359 $LFS mkdir -i $MDTIDX $remote_dir &
2362 # sleep 3 seconds to make sure MDTs are failed after
2363 # lfs mkdir -i has finished on all of MDTs.
2369 fail mds$((MDTIDX + 1))
2371 wait $CLIENT_PID || error "remote creation failed"
2373 remote_dir_check_80 || error "remote dir check failed"
2374 rm -rf $DIR/$tdir || error "rmdir failed"
2378 run_test 80g "DNE: create remote dir, drop MDT1 rep, fail MDT0, then MDT1"
2381 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2383 local remote_dir=$DIR/$tdir/remote_dir
2385 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
2386 # OBD_FAIL_MDS_REINT_NET_REP 0x119
2387 do_facet mds$((MDTIDX + 1)) lctl set_param fail_loc=0x119
2388 $LFS mkdir -i $MDTIDX $remote_dir &
2391 # sleep 3 seconds to make sure MDTs are failed after
2392 # lfs mkdir -i has finished on all of MDTs.
2397 fail mds${MDTIDX},mds$((MDTIDX + 1))
2399 wait $CLIENT_PID || error "remote dir creation failed"
2401 remote_dir_check_80 || error "remote dir check failed"
2402 rm -rf $DIR/$tdir || error "rmdir failed"
2406 run_test 80h "DNE: create remote dir, drop MDT1 rep, fail 2 MDTs"
2409 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2410 ([ $FAILURE_MODE == "HARD" ] &&
2411 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
2412 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
2416 local remote_dir=$DIR/$tdir/remote_dir
2418 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
2419 $LFS mkdir -i $MDTIDX $remote_dir || error "lfs mkdir failed"
2421 touch $remote_dir || error "touch $remote_dir failed"
2422 # OBD_FAIL_OBJ_UPDATE_NET_REP 0x1701
2423 do_facet mds${MDTIDX} lctl set_param fail_loc=0x1701
2428 fail mds$((MDTIDX + 1))
2430 wait $CLIENT_PID || error "rm remote dir failed"
2432 stat $remote_dir 2&>/dev/null && error "$remote_dir still exist!"
2434 rm -rf $DIR/$tdir || error "rmdir failed"
2438 run_test 81a "DNE: unlink remote dir, drop MDT0 update rep, fail MDT1"
2441 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2442 ([ $FAILURE_MODE == "HARD" ] &&
2443 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
2444 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
2447 local remote_dir=$DIR/$tdir/remote_dir
2449 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
2450 $LFS mkdir -i $MDTIDX $remote_dir || error "lfs mkdir failed"
2452 # OBD_FAIL_OBJ_UPDATE_NET_REP 0x1701
2453 do_facet mds${MDTIDX} lctl set_param fail_loc=0x1701
2460 wait $CLIENT_PID || error "rm remote dir failed"
2462 stat $remote_dir 2&>/dev/null && error "$remote_dir still exist!"
2464 rm -rf $DIR/$tdir || error "rmdir failed"
2468 run_test 81b "DNE: unlink remote dir, drop MDT0 update reply, fail MDT0"
2471 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2472 ([ $FAILURE_MODE == "HARD" ] &&
2473 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
2474 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
2478 local remote_dir=$DIR/$tdir/remote_dir
2480 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
2481 $LFS mkdir -i $MDTIDX $remote_dir || error "lfs mkdir failed"
2483 # OBD_FAIL_OBJ_UPDATE_NET_REP 0x1701
2484 do_facet mds${MDTIDX} lctl set_param fail_loc=0x1701
2491 fail mds$((MDTIDX + 1))
2493 wait $CLIENT_PID || error "rm remote dir failed"
2495 stat $remote_dir 2&>/dev/null && error "$remote_dir still exist!"
2497 rm -rf $DIR/$tdir || error "rmdir failed"
2501 run_test 81c "DNE: unlink remote dir, drop MDT0 update reply, fail MDT0,MDT1"
2504 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2506 local remote_dir=$DIR/$tdir/remote_dir
2508 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
2509 $LFS mkdir -i $MDTIDX $remote_dir || error "lfs mkdir failed"
2511 # OBD_FAIL_OBJ_UPDATE_NET_REP 0x1701
2512 do_facet mds${MDTIDX} lctl set_param fail_loc=0x1701
2518 fail mds${MDTIDX},mds$((MDTIDX + 1))
2520 wait $CLIENT_PID || error "rm remote dir failed"
2522 stat $remote_dir 2&>/dev/null && error "$remote_dir still exist!"
2524 rm -rf $DIR/$tdir || error "rmdir failed"
2528 run_test 81d "DNE: unlink remote dir, drop MDT0 update reply, fail 2 MDTs"
2531 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2532 ([ $FAILURE_MODE == "HARD" ] &&
2533 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
2534 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
2538 local remote_dir=$DIR/$tdir/remote_dir
2540 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
2541 $LFS mkdir -i $MDTIDX $remote_dir || error "lfs mkdir failed"
2543 # OBD_FAIL_MDS_REINT_NET_REP 0x119
2544 do_facet mds$((MDTIDX + 1)) lctl set_param fail_loc=0x119
2547 do_facet mds$((MDTIDX + 1)) lctl set_param fail_loc=0
2552 wait $CLIENT_PID || error "rm remote dir failed"
2554 stat $remote_dir 2&>/dev/null && error "$remote_dir still exist!"
2556 rm -rf $DIR/$tdir || error "rmdir failed"
2560 run_test 81e "DNE: unlink remote dir, drop MDT1 req reply, fail MDT0"
2563 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2564 ([ $FAILURE_MODE == "HARD" ] &&
2565 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
2566 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
2570 local remote_dir=$DIR/$tdir/remote_dir
2572 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
2573 $LFS mkdir -i $MDTIDX $remote_dir || error "lfs mkdir failed"
2575 # OBD_FAIL_MDS_REINT_NET_REP 0x119
2576 do_facet mds$((MDTIDX + 1)) lctl set_param fail_loc=0x119
2581 fail mds$((MDTIDX + 1))
2583 wait $CLIENT_PID || error "rm remote dir failed"
2585 stat $remote_dir 2&>/dev/null && error "$remote_dir still exist!"
2587 rm -rf $DIR/$tdir || error "rmdir failed"
2591 run_test 81f "DNE: unlink remote dir, drop MDT1 req reply, fail MDT1"
2594 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2595 ([ $FAILURE_MODE == "HARD" ] &&
2596 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
2597 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
2601 local remote_dir=$DIR/$tdir/remote_dir
2603 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
2604 $LFS mkdir -i $MDTIDX $remote_dir || error "lfs mkdir failed"
2606 # OBD_FAIL_MDS_REINT_NET_REP 0x119
2607 do_facet mds$((MDTIDX + 1)) lctl set_param fail_loc=0x119
2614 fail mds$((MDTIDX + 1))
2616 wait $CLIENT_PID || error "rm remote dir failed"
2618 stat $remote_dir 2&>/dev/null && error "$remote_dir still exist!"
2620 rm -rf $DIR/$tdir || error "rmdir failed"
2624 run_test 81g "DNE: unlink remote dir, drop req reply, fail M0, then M1"
2627 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2629 local remote_dir=$DIR/$tdir/remote_dir
2631 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
2632 $LFS mkdir -i $MDTIDX $remote_dir || error "lfs mkdir failed"
2634 # OBD_FAIL_MDS_REINT_NET_REP 0x119
2635 do_facet mds$((MDTIDX + 1)) lctl set_param fail_loc=0x119
2641 fail mds${MDTIDX},mds$((MDTIDX + 1))
2643 wait $CLIENT_PID || error "rm remote dir failed"
2645 stat $remote_dir 2&>/dev/null && error "$remote_dir still exist!"
2647 rm -rf $DIR/$tdir || error "rmdir failed"
2651 run_test 81h "DNE: unlink remote dir, drop request reply, fail 2 MDTs"
2654 #define OBD_FAIL_MDS_OPEN_WAIT_CREATE 0x144
2655 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000144"
2656 createmany -o $DIR/$tfile- 1 &
2660 client_up || client_up || true # reconnect
2662 run_test 84a "stale open during export disconnect"
2664 test_85a() { #bug 16774
2665 lctl set_param -n ldlm.cancel_unused_locks_before_replay "1"
2667 for i in $(seq 100); do
2668 echo "tag-$i" > $DIR/$tfile-$i
2669 grep -q "tag-$i" $DIR/$tfile-$i || error "f2-$i"
2672 lov_id=$(lctl dl | grep "clilov")
2673 addr=$(echo $lov_id | awk '{print $4}' | awk -F '-' '{print $3}')
2674 count=$(lctl get_param -n \
2675 ldlm.namespaces.*MDT0000*$addr.lock_unused_count)
2676 echo "before recovery: unused locks count = $count"
2680 count2=$(lctl get_param -n \
2681 ldlm.namespaces.*MDT0000*$addr.lock_unused_count)
2682 echo "after recovery: unused locks count = $count2"
2684 if [ $count2 -ge $count ]; then
2685 error "unused locks are not canceled"
2688 run_test 85a "check the cancellation of unused locks during recovery(IBITS)"
2690 test_85b() { #bug 16774
2691 lctl set_param -n ldlm.cancel_unused_locks_before_replay "1"
2693 do_facet mgs $LCTL pool_new $FSNAME.$TESTNAME ||
2694 error "unable to create pool $TESTNAME"
2695 do_facet mgs $LCTL pool_add $FSNAME.$TESTNAME $FSNAME-OST0000 ||
2696 error "unable to add pool $TESTNAME"
2698 $SETSTRIPE -c 1 -p $FSNAME.$TESTNAME $DIR
2700 for i in $(seq 100); do
2701 dd if=/dev/urandom of=$DIR/$tfile-$i bs=4096 \
2702 count=32 >/dev/null 2>&1
2705 cancel_lru_locks osc
2707 for i in $(seq 100); do
2708 dd if=$DIR/$tfile-$i of=/dev/null bs=4096 \
2709 count=32 >/dev/null 2>&1
2712 lov_id=$(lctl dl | grep "clilov")
2713 addr=$(echo $lov_id | awk '{print $4}' | awk -F '-' '{print $3}')
2714 count=$(lctl get_param \
2715 -n ldlm.namespaces.*OST0000*$addr.lock_unused_count)
2716 echo "before recovery: unused locks count = $count"
2717 [ $count != 0 ] || error "unused locks ($count) should be zero"
2721 count2=$(lctl get_param \
2722 -n ldlm.namespaces.*OST0000*$addr.lock_unused_count)
2723 echo "after recovery: unused locks count = $count2"
2725 do_facet mgs $LCTL pool_remove $FSNAME.$TESTNAME $FSNAME-OST0000 ||
2726 error "unable to remove pool $TESTNAME"
2727 do_facet mgs $LCTL pool_destroy $FSNAME.$TESTNAME ||
2728 error "unable to destroy the pool $TESTNAME"
2730 if [ $count2 -ge $count ]; then
2731 error "unused locks are not canceled"
2734 run_test 85b "check the cancellation of unused locks during recovery(EXTENT)"
2737 local clients=${CLIENTS:-$HOSTNAME}
2739 zconf_umount_clients $clients $MOUNT
2740 do_facet $SINGLEMDS lctl set_param mdt.${FSNAME}-MDT*.exports.clear=0
2741 remount_facet $SINGLEMDS
2742 zconf_mount_clients $clients $MOUNT
2744 run_test 86 "umount server after clear nid_stats should not hit LBUG"
2747 do_facet ost1 "lctl set_param -n obdfilter.${ost1_svc}.sync_journal 0"
2750 $SETSTRIPE -i 0 -c 1 $DIR/$tfile
2751 dd if=/dev/urandom of=$DIR/$tfile bs=1024k count=8 ||
2752 error "dd to $DIR/$tfile failed"
2753 cksum=$(md5sum $DIR/$tfile | awk '{print $1}')
2754 cancel_lru_locks osc
2756 dd if=$DIR/$tfile of=/dev/null bs=1024k count=8 || error "Cannot read"
2757 cksum2=$(md5sum $DIR/$tfile | awk '{print $1}')
2758 if [ $cksum != $cksum2 ] ; then
2759 error "New checksum $cksum2 does not match original $cksum"
2762 run_test 87 "write replay"
2765 do_facet ost1 "lctl set_param -n obdfilter.${ost1_svc}.sync_journal 0"
2768 $SETSTRIPE -i 0 -c 1 $DIR/$tfile
2769 dd if=/dev/urandom of=$DIR/$tfile bs=1024k count=8 ||
2770 error "dd to $DIR/$tfile failed"
2771 sleep 1 # Give it a chance to flush dirty data
2772 echo TESTTEST | dd of=$DIR/$tfile bs=1 count=8 seek=64
2773 cksum=$(md5sum $DIR/$tfile | awk '{print $1}')
2774 cancel_lru_locks osc
2776 dd if=$DIR/$tfile of=/dev/null bs=1024k count=8 || error "Cannot read"
2777 cksum2=$(md5sum $DIR/$tfile | awk '{print $1}')
2778 if [ $cksum != $cksum2 ] ; then
2779 error "New checksum $cksum2 does not match original $cksum"
2782 run_test 87b "write replay with changed data (checksum resend)"
2784 test_88() { #bug 17485
2785 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
2786 mkdir -p $TMP/$tdir || error "mkdir $TMP/$tdir failed"
2788 $SETSTRIPE -i 0 -c 1 $DIR/$tdir || error "$SETSTRIPE"
2791 replay_barrier $SINGLEMDS
2793 # exhaust precreations on ost1
2794 local OST=$(ostname_from_index 0)
2795 local mdtosc=$(get_mdtosc_proc_path $SINGLEMDS $OST)
2796 local last_id=$(do_facet $SINGLEMDS lctl get_param -n osc.$mdtosc.prealloc_last_id)
2797 local next_id=$(do_facet $SINGLEMDS lctl get_param -n osc.$mdtosc.prealloc_next_id)
2798 echo "before test: last_id = $last_id, next_id = $next_id"
2800 echo "Creating to objid $last_id on ost $OST..."
2801 createmany -o $DIR/$tdir/f-%d $next_id $((last_id - next_id + 2)) ||
2802 error "createmany create files to last_id failed"
2804 #create some files to use some uncommitted objids
2805 last_id=$(($last_id + 1))
2806 createmany -o $DIR/$tdir/f-%d $last_id 8 ||
2807 error "createmany create files with uncommitted objids failed"
2809 last_id2=$(do_facet $SINGLEMDS lctl get_param -n osc.$mdtosc.prealloc_last_id)
2810 next_id2=$(do_facet $SINGLEMDS lctl get_param -n osc.$mdtosc.prealloc_next_id)
2811 echo "before recovery: last_id = $last_id2, next_id = $next_id2"
2813 # if test uses shutdown_facet && reboot_facet instead of facet_failover ()
2814 # it has to take care about the affected facets, bug20407
2815 local affected_mds1=$(affected_facets mds1)
2816 local affected_ost1=$(affected_facets ost1)
2818 shutdown_facet $SINGLEMDS
2821 reboot_facet $SINGLEMDS
2822 change_active $affected_mds1
2823 wait_for_facet $affected_mds1
2824 mount_facets $affected_mds1 || error "Restart of mds failed"
2827 change_active $affected_ost1
2828 wait_for_facet $affected_ost1
2829 mount_facets $affected_ost1 || error "Restart of ost1 failed"
2833 last_id2=$(do_facet $SINGLEMDS lctl get_param -n osc.$mdtosc.prealloc_last_id)
2834 next_id2=$(do_facet $SINGLEMDS lctl get_param -n osc.$mdtosc.prealloc_next_id)
2835 echo "after recovery: last_id = $last_id2, next_id = $next_id2"
2837 # create new files, which should use new objids, and ensure the orphan
2838 # cleanup phase for ost1 is completed at the same time
2839 for i in $(seq 8); do
2840 file_id=$(($last_id + 10 + $i))
2841 dd if=/dev/urandom of=$DIR/$tdir/f-$file_id bs=4096 count=128
2844 # if the objids were not recreated, then "ls" will fail with -ENOENT
2845 ls -l $DIR/$tdir/* || error "can't get the status of precreated files"
2848 # write into previously created files
2849 for i in $(seq 8); do
2850 file_id=$(($last_id + $i))
2851 dd if=/dev/urandom of=$DIR/$tdir/f-$file_id bs=4096 count=128
2852 cp -f $DIR/$tdir/f-$file_id $TMP/$tdir/
2855 # compare the content
2856 for i in $(seq 8); do
2857 file_id=$(($last_id + $i))
2858 cmp $TMP/$tdir/f-$file_id $DIR/$tdir/f-$file_id ||
2859 error "the content of file is modified!"
2864 run_test 88 "MDS should not assign same objid to different files "
2867 cancel_lru_locks osc
2868 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
2869 rm -f $DIR/$tdir/$tfile
2871 wait_delete_completed
2872 BLOCKS1=$(df -P $MOUNT | tail -n 1 | awk '{ print $3 }')
2873 $SETSTRIPE -i 0 -c 1 $DIR/$tdir/$tfile
2874 dd if=/dev/zero bs=1M count=10 of=$DIR/$tdir/$tfile
2877 facet_failover $SINGLEMDS
2878 rm $DIR/$tdir/$tfile
2881 zconf_mount $(hostname) $MOUNT || error "mount fails"
2882 client_up || error "client_up failed"
2884 wait_delete_completed
2885 BLOCKS2=$(df -P $MOUNT | tail -n 1 | awk '{ print $3 }')
2886 [ $((BLOCKS2 - BLOCKS1)) -le 4 ] ||
2887 error $((BLOCKS2 - BLOCKS1)) blocks leaked
2890 run_test 89 "no disk space leak on late ost connection"
2896 change_active $facet
2897 wait_for_facet $facet
2898 mount_facet $facet || error "Restart of $facet failed"
2902 test_90() { # bug 19494
2903 local dir=$DIR/$tdir
2904 local ostfail=$(get_random_entry $(get_facets OST))
2906 if [[ $FAILURE_MODE = HARD ]]; then
2907 local affected=$(affected_facets $ostfail);
2908 if [[ "$affected" != $ostfail ]]; then
2909 skip not functional with FAILURE_MODE=$FAILURE_MODE, affected: $affected
2914 mkdir $dir || error "mkdir $dir failed"
2916 echo "Create the files"
2918 # file "f${index}" striped over 1 OST
2919 # file "all" striped over all OSTs
2921 $SETSTRIPE -c $OSTCOUNT $dir/all ||
2922 error "setstripe failed to create $dir/all"
2924 for (( i=0; i<$OSTCOUNT; i++ )); do
2926 $SETSTRIPE -i $i -c 1 $f || error "$SETSTRIPE failed to create $f"
2928 # confirm setstripe actually created the stripe on the requested OST
2929 local uuid=$(ostuuid_from_index $i)
2930 for file in f$i all; do
2931 if [[ $dir/$file != $($LFS find --obd $uuid --name $file $dir) ]]; then
2932 $GETSTRIPE $dir/$file
2933 error wrong stripe: $file, uuid: $uuid
2938 # Before failing an OST, get its obd name and index
2939 local varsvc=${ostfail}_svc
2940 local obd=$(do_facet $ostfail lctl get_param \
2941 -n obdfilter.${!varsvc}.uuid)
2942 local index=$(($(facet_number $ostfail) - 1))
2944 echo "Fail $ostfail $obd, display the list of affected files"
2945 shutdown_facet $ostfail || error "shutdown_facet $ostfail failed"
2947 trap "cleanup_90 $ostfail" EXIT INT
2948 echo "General Query: lfs find $dir"
2949 local list=$($LFS find $dir)
2951 for (( i=0; i<$OSTCOUNT; i++ )); do
2952 list_member "$list" $dir/f$i ||
2953 error_noexit "lfs find $dir: no file f$i"
2955 list_member "$list" $dir/all ||
2956 error_noexit "lfs find $dir: no file all"
2958 # focus on the missing OST,
2959 # we expect to see only two files affected: "f$(index)" and "all"
2961 echo "Querying files on shutdown $ostfail: lfs find --obd $obd"
2962 list=$($LFS find --obd $obd $dir)
2964 for file in all f$index; do
2965 list_member "$list" $dir/$file ||
2966 error_noexit "lfs find does not report the affected $obd for $file"
2969 [[ $(echo $list | wc -w) -eq 2 ]] ||
2970 error_noexit "lfs find reports the wrong list of affected files ${#list[@]}"
2972 echo "Check getstripe: $GETSTRIPE -r --obd $obd"
2973 list=$($GETSTRIPE -r --obd $obd $dir)
2975 for file in all f$index; do
2976 echo "$list" | grep $dir/$file ||
2977 error_noexit "lfs getsripe does not report the affected $obd for $file"
2982 run_test 90 "lfs find identifies the missing striped file segments"
2985 local server_version=$(lustre_version_code $SINGLEMDS)
2986 [[ $server_version -ge $(version_code 2.6.90) ]] ||
2987 [[ $server_version -ge $(version_code 2.5.4) &&
2988 $server_version -lt $(version_code 2.5.50) ]] ||
2989 { skip "Need MDS version 2.5.4+ or 2.6.90+"; return; }
2991 cancel_lru_locks osc
2993 $SETSTRIPE -i 0 -c 1 $DIR/$tfile ||
2994 error "$SETSTRIPE $DIR/$tfile failed"
2995 dd if=/dev/zero of=$DIR/$tfile bs=1024 count=1 ||
2996 error "dd to $DIR/$tfile failed"
2997 #define OBD_FAIL_TGT_REPLAY_RECONNECT 0x715
2998 # We need to emulate a state that OST is waiting for other clients
2999 # not completing the recovery. Final ping is queued, but reply will be
3000 # sent on the recovery completion. It is done by sleep before
3001 # processing final pings
3002 do_facet ost1 "$LCTL set_param fail_val=40"
3003 do_facet ost1 "$LCTL set_param fail_loc=0x715"
3006 run_test 93 "replay + reconnect"
3008 striped_dir_check_100() {
3009 local striped_dir=$DIR/$tdir/striped_dir
3010 local stripe_count=$($LFS getdirstripe -c $striped_dir)
3012 $LFS getdirstripe $striped_dir
3013 [ $stripe_count -eq 2 ] || error "$stripe_count != 2"
3015 createmany -o $striped_dir/f-%d 20 ||
3016 error "creation failed under striped dir"
3020 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
3021 ([ $FAILURE_MODE == "HARD" ] &&
3022 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
3023 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
3026 local striped_dir=$DIR/$tdir/striped_dir
3029 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
3031 #To make sure MDT1 and MDT0 are connected
3032 #otherwise it may create single stripe dir here
3033 $LFS setdirstripe -i1 $DIR/$tdir/remote_dir
3035 #define OBD_FAIL_OUT_UPDATE_NET_REP 0x1701
3036 do_facet mds$((MDTIDX+1)) lctl set_param fail_loc=0x1701
3037 $LFS setdirstripe -i0 -c2 $striped_dir &
3040 fail mds$((MDTIDX + 1))
3042 wait $CLIENT_PID || error "striped dir creation failed"
3044 striped_dir_check_100 || error "striped dir check failed"
3045 rm -rf $DIR/$tdir || error "rmdir failed"
3047 run_test 100a "DNE: create striped dir, drop update rep from MDT1, fail MDT1"
3050 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
3051 ([ $FAILURE_MODE == "HARD" ] &&
3052 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
3053 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
3056 local striped_dir=$DIR/$tdir/striped_dir
3059 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
3061 #To make sure MDT1 and MDT0 are connected
3062 #otherwise it may create single stripe dir here
3063 $LFS setdirstripe -i1 $DIR/$tdir/remote_dir
3065 # OBD_FAIL_MDS_REINT_NET_REP 0x119
3066 do_facet mds$MDTIDX lctl set_param fail_loc=0x119
3067 $LFS mkdir -i0 -c2 $striped_dir &
3072 wait $CLIENT_PID || error "striped dir creation failed"
3074 striped_dir_check_100 || error "striped dir check failed"
3075 rm -rf $DIR/$tdir || error "rmdir failed"
3077 run_test 100b "DNE: create striped dir, fail MDT0"
3079 test_101() { #LU-5648
3080 mkdir -p $DIR/$tdir/d1
3081 mkdir -p $DIR/$tdir/d2
3082 touch $DIR/$tdir/file0
3085 replay_barrier $SINGLEMDS
3086 for i in $(seq $num) ; do
3087 echo test$i > $DIR/$tdir/d1/file$i
3090 fail_abort $SINGLEMDS
3091 for i in $(seq $num) ; do
3092 touch $DIR/$tdir/d2/file$i
3093 test -s $DIR/$tdir/d2/file$i &&
3094 ls -al $DIR/$tdir/d2/file$i && error "file$i's size > 0"
3099 run_test 101 "Shouldn't reassign precreated objs to other files after recovery"
3101 check_striped_dir_110()
3103 $CHECKSTAT -t dir $DIR/$tdir/striped_dir ||
3104 error "create striped dir failed"
3105 local stripe_count=$($LFS getdirstripe -c $DIR/$tdir/striped_dir)
3106 [ $stripe_count -eq $MDSCOUNT ] ||
3107 error "$stripe_count != 2 after recovery"
3111 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
3112 ([ $FAILURE_MODE == "HARD" ] &&
3113 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
3114 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
3119 $LFS mkdir -i1 -c$MDSCOUNT $DIR/$tdir/striped_dir
3122 check_striped_dir_110 || error "check striped_dir failed"
3123 rm -rf $DIR/$tdir || error "rmdir failed"
3127 run_test 110a "DNE: create striped dir, fail MDT1"
3130 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
3131 ([ $FAILURE_MODE == "HARD" ] &&
3132 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
3133 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
3138 $LFS mkdir -i1 -c$MDSCOUNT $DIR/$tdir/striped_dir
3141 zconf_mount $(hostname) $MOUNT
3142 client_up || return 1
3144 check_striped_dir_110 || error "check striped_dir failed"
3146 rm -rf $DIR/$tdir || error "rmdir failed"
3150 run_test 110b "DNE: create striped dir, fail MDT1 and client"
3153 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
3154 ([ $FAILURE_MODE == "HARD" ] &&
3155 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
3156 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
3161 $LFS mkdir -i1 -c$MDSCOUNT $DIR/$tdir/striped_dir
3164 check_striped_dir_110 || error "check striped_dir failed"
3166 rm -rf $DIR/$tdir || error "rmdir failed"
3170 run_test 110c "DNE: create striped dir, fail MDT2"
3173 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
3174 ([ $FAILURE_MODE == "HARD" ] &&
3175 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
3176 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
3181 $LFS mkdir -i1 -c$MDSCOUNT $DIR/$tdir/striped_dir
3184 zconf_mount $(hostname) $MOUNT
3185 client_up || return 1
3187 check_striped_dir_110 || error "check striped_dir failed"
3189 rm -rf $DIR/$tdir || error "rmdir failed"
3193 run_test 110d "DNE: create striped dir, fail MDT2 and client"
3196 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
3197 ([ $FAILURE_MODE == "HARD" ] &&
3198 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
3199 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
3204 $LFS mkdir -i1 -c$MDSCOUNT $DIR/$tdir/striped_dir
3208 zconf_mount $(hostname) $MOUNT
3209 client_up || return 1
3211 check_striped_dir_110 || error "check striped_dir failed"
3213 rm -rf $DIR/$tdir || error "rmdir failed"
3217 run_test 110e "DNE: create striped dir, uncommit on MDT2, fail client/MDT1/MDT2"
3220 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
3221 ([ $FAILURE_MODE == "HARD" ] &&
3222 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
3223 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
3229 $LFS mkdir -i1 -c$MDSCOUNT $DIR/$tdir/striped_dir
3232 check_striped_dir_110 || error "check striped_dir failed"
3234 rm -rf $DIR/$tdir || error "rmdir failed"
3238 run_test 110f "DNE: create striped dir, fail MDT1/MDT2"
3241 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
3242 ([ $FAILURE_MODE == "HARD" ] &&
3243 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
3244 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
3249 $LFS mkdir -i1 -c$MDSCOUNT $DIR/$tdir/striped_dir
3253 zconf_mount $(hostname) $MOUNT
3254 client_up || return 1
3256 check_striped_dir_110 || error "check striped_dir failed"
3258 rm -rf $DIR/$tdir || error "rmdir failed"
3262 run_test 110g "DNE: create striped dir, uncommit on MDT1, fail client/MDT1/MDT2"
3265 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
3266 ([ $FAILURE_MODE == "HARD" ] &&
3267 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
3268 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
3272 $LFS mkdir -i1 -c2 $DIR/$tdir/striped_dir
3274 rm -rf $DIR/$tdir/striped_dir
3277 $CHECKSTAT -t dir $DIR/$tdir/striped_dir &&
3278 error "striped dir still exists"
3281 run_test 111a "DNE: unlink striped dir, fail MDT1"
3284 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
3285 ([ $FAILURE_MODE == "HARD" ] &&
3286 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
3287 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
3291 $LFS mkdir -i1 -c2 $DIR/$tdir/striped_dir
3293 rm -rf $DIR/$tdir/striped_dir
3296 zconf_mount $(hostname) $MOUNT
3297 client_up || return 1
3299 $CHECKSTAT -t dir $DIR/$tdir/striped_dir &&
3300 error "striped dir still exists"
3303 run_test 111b "DNE: unlink striped dir, fail MDT2"
3306 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
3307 ([ $FAILURE_MODE == "HARD" ] &&
3308 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
3309 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
3313 $LFS mkdir -i1 -c2 $DIR/$tdir/striped_dir
3315 rm -rf $DIR/$tdir/striped_dir
3319 zconf_mount $(hostname) $MOUNT
3320 client_up || return 1
3321 $CHECKSTAT -t dir $DIR/$tdir/striped_dir &&
3322 error "striped dir still exists"
3325 run_test 111c "DNE: unlink striped dir, uncommit on MDT1, fail client/MDT1/MDT2"
3328 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
3329 ([ $FAILURE_MODE == "HARD" ] &&
3330 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
3331 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
3335 $LFS mkdir -i1 -c2 $DIR/$tdir/striped_dir
3337 rm -rf $DIR/$tdir/striped_dir
3341 zconf_mount $(hostname) $MOUNT
3342 client_up || return 1
3343 $CHECKSTAT -t dir $DIR/$tdir/striped_dir &&
3344 error "striped dir still exists"
3348 run_test 111d "DNE: unlink striped dir, uncommit on MDT2, fail client/MDT1/MDT2"
3351 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
3352 ([ $FAILURE_MODE == "HARD" ] &&
3353 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
3354 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
3358 $LFS mkdir -i1 -c2 $DIR/$tdir/striped_dir
3360 rm -rf $DIR/$tdir/striped_dir
3363 $CHECKSTAT -t dir $DIR/$tdir/striped_dir &&
3364 error "striped dir still exists"
3367 run_test 111e "DNE: unlink striped dir, uncommit on MDT2, fail MDT1/MDT2"
3370 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
3371 ([ $FAILURE_MODE == "HARD" ] &&
3372 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
3373 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
3377 $LFS mkdir -i1 -c2 $DIR/$tdir/striped_dir
3379 rm -rf $DIR/$tdir/striped_dir
3382 $CHECKSTAT -t dir $DIR/$tdir/striped_dir &&
3383 error "striped dir still exists"
3386 run_test 111f "DNE: unlink striped dir, uncommit on MDT1, fail MDT1/MDT2"
3389 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
3390 ([ $FAILURE_MODE == "HARD" ] &&
3391 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
3392 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
3396 $LFS mkdir -i1 -c2 $DIR/$tdir/striped_dir
3399 rm -rf $DIR/$tdir/striped_dir
3401 $CHECKSTAT -t dir $DIR/$tdir/striped_dir &&
3402 error "striped dir still exists"
3405 run_test 111g "DNE: unlink striped dir, fail MDT1/MDT2"
3407 test_112_rename_prepare() {
3408 mkdir -p $DIR/$tdir/src_dir
3409 $LFS mkdir -i 1 $DIR/$tdir/src_dir/src_child ||
3410 error "create remote source failed"
3412 touch $DIR/$tdir/src_dir/src_child/a
3414 $LFS mkdir -i 2 $DIR/$tdir/tgt_dir ||
3415 error "create remote target dir failed"
3417 $LFS mkdir -i 3 $DIR/$tdir/tgt_dir/tgt_child ||
3418 error "create remote target child failed"
3423 $CHECKSTAT -t dir $DIR/$tdir/src_dir/src_child &&
3424 error "src_child still exists after rename"
3426 $CHECKSTAT -t file $DIR/$tdir/tgt_dir/tgt_child/a ||
3427 error "missing file(a) after rename"
3431 [ $MDSCOUNT -lt 4 ] && skip "needs >= 4 MDTs" && return 0
3432 ([ $FAILURE_MODE == "HARD" ] &&
3433 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
3434 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
3437 test_112_rename_prepare
3440 mrename $DIR/$tdir/src_dir/src_child $DIR/$tdir/tgt_dir/tgt_child ||
3441 error "rename dir cross MDT failed!"
3445 rm -rf $DIR/$tdir || error "rmdir failed"
3447 run_test 112a "DNE: cross MDT rename, fail MDT1"
3450 [ $MDSCOUNT -lt 4 ] && skip "needs >= 4 MDTs" && return 0
3451 ([ $FAILURE_MODE == "HARD" ] &&
3452 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
3453 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
3456 test_112_rename_prepare
3459 mrename $DIR/$tdir/src_dir/src_child $DIR/$tdir/tgt_dir/tgt_child ||
3460 error "rename dir cross MDT failed!"
3465 rm -rf $DIR/$tdir || error "rmdir failed"
3467 run_test 112b "DNE: cross MDT rename, fail MDT2"
3470 [ $MDSCOUNT -lt 4 ] && skip "needs >= 4 MDTs" && return 0
3471 ([ $FAILURE_MODE == "HARD" ] &&
3472 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
3473 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
3476 test_112_rename_prepare
3479 mrename $DIR/$tdir/src_dir/src_child $DIR/$tdir/tgt_dir/tgt_child ||
3480 error "rename dir cross MDT failed!"
3485 rm -rf $DIR/$tdir || error "rmdir failed"
3487 run_test 112c "DNE: cross MDT rename, fail MDT3"
3490 [ $MDSCOUNT -lt 4 ] && skip "needs >= 4 MDTs" && return 0
3491 ([ $FAILURE_MODE == "HARD" ] &&
3492 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
3493 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
3496 test_112_rename_prepare
3499 mrename $DIR/$tdir/src_dir/src_child $DIR/$tdir/tgt_dir/tgt_child ||
3500 error "rename dir cross MDT failed!"
3505 rm -rf $DIR/$tdir || error "rmdir failed"
3507 run_test 112d "DNE: cross MDT rename, fail MDT4"
3510 [ $MDSCOUNT -lt 4 ] && skip "needs >= 4 MDTs" && return 0
3511 ([ $FAILURE_MODE == "HARD" ] &&
3512 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
3513 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
3516 test_112_rename_prepare
3520 mrename $DIR/$tdir/src_dir/src_child $DIR/$tdir/tgt_dir/tgt_child ||
3521 error "rename dir cross MDT failed!"
3526 rm -rf $DIR/$tdir || error "rmdir failed"
3528 run_test 112e "DNE: cross MDT rename, fail MDT1 and MDT2"
3531 [ $MDSCOUNT -lt 4 ] && skip "needs >= 4 MDTs" && return 0
3532 ([ $FAILURE_MODE == "HARD" ] &&
3533 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
3534 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
3537 test_112_rename_prepare
3541 mrename $DIR/$tdir/src_dir/src_child $DIR/$tdir/tgt_dir/tgt_child ||
3542 error "rename dir cross MDT failed!"
3547 rm -rf $DIR/$tdir || error "rmdir failed"
3549 run_test 112f "DNE: cross MDT rename, fail MDT1 and MDT3"
3552 [ $MDSCOUNT -lt 4 ] && skip "needs >= 4 MDTs" && return 0
3553 ([ $FAILURE_MODE == "HARD" ] &&
3554 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
3555 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
3558 test_112_rename_prepare
3562 mrename $DIR/$tdir/src_dir/src_child $DIR/$tdir/tgt_dir/tgt_child ||
3563 error "rename dir cross MDT failed!"
3568 rm -rf $DIR/$tdir || error "rmdir failed"
3570 run_test 112g "DNE: cross MDT rename, fail MDT1 and MDT4"
3573 [ $MDSCOUNT -lt 4 ] && skip "needs >= 4 MDTs" && return 0
3574 ([ $FAILURE_MODE == "HARD" ] &&
3575 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
3576 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
3579 test_112_rename_prepare
3583 mrename $DIR/$tdir/src_dir/src_child $DIR/$tdir/tgt_dir/tgt_child ||
3584 error "rename dir cross MDT failed!"
3589 rm -rf $DIR/$tdir || error "rmdir failed"
3591 run_test 112h "DNE: cross MDT rename, fail MDT2 and MDT3"
3594 [ $MDSCOUNT -lt 4 ] && skip "needs >= 4 MDTs" && return 0
3595 ([ $FAILURE_MODE == "HARD" ] &&
3596 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
3597 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
3600 test_112_rename_prepare
3604 mrename $DIR/$tdir/src_dir/src_child $DIR/$tdir/tgt_dir/tgt_child ||
3605 error "rename dir cross MDT failed!"
3610 rm -rf $DIR/$tdir || error "rmdir failed"
3612 run_test 112i "DNE: cross MDT rename, fail MDT2 and MDT4"
3615 [ $MDSCOUNT -lt 4 ] && skip "needs >= 4 MDTs" && return 0
3616 ([ $FAILURE_MODE == "HARD" ] &&
3617 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
3618 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
3621 test_112_rename_prepare
3625 mrename $DIR/$tdir/src_dir/src_child $DIR/$tdir/tgt_dir/tgt_child ||
3626 error "rename dir cross MDT failed!"
3631 rm -rf $DIR/$tdir || error "rmdir failed"
3633 run_test 112j "DNE: cross MDT rename, fail MDT3 and MDT4"
3636 [ $MDSCOUNT -lt 4 ] && skip "needs >= 4 MDTs" && return 0
3637 ([ $FAILURE_MODE == "HARD" ] &&
3638 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
3639 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
3642 test_112_rename_prepare
3647 mrename $DIR/$tdir/src_dir/src_child $DIR/$tdir/tgt_dir/tgt_child ||
3648 error "rename dir cross MDT failed!"
3653 rm -rf $DIR/$tdir || error "rmdir failed"
3655 run_test 112k "DNE: cross MDT rename, fail MDT1,MDT2,MDT3"
3658 [ $MDSCOUNT -lt 4 ] && skip "needs >= 4 MDTs" && return 0
3659 ([ $FAILURE_MODE == "HARD" ] &&
3660 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
3661 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
3664 test_112_rename_prepare
3669 mrename $DIR/$tdir/src_dir/src_child $DIR/$tdir/tgt_dir/tgt_child ||
3670 error "rename dir cross MDT failed!"
3675 rm -rf $DIR/$tdir || error "rmdir failed"
3677 run_test 112l "DNE: cross MDT rename, fail MDT1,MDT2,MDT4"
3680 [ $MDSCOUNT -lt 4 ] && skip "needs >= 4 MDTs" && return 0
3681 ([ $FAILURE_MODE == "HARD" ] &&
3682 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
3683 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
3686 test_112_rename_prepare
3691 mrename $DIR/$tdir/src_dir/src_child $DIR/$tdir/tgt_dir/tgt_child ||
3692 error "rename dir cross MDT failed!"
3697 rm -rf $DIR/$tdir || error "rmdir failed"
3699 run_test 112m "DNE: cross MDT rename, fail MDT1,MDT3,MDT4"
3702 [ $MDSCOUNT -lt 4 ] && skip "needs >= 4 MDTs" && return 0
3703 ([ $FAILURE_MODE == "HARD" ] &&
3704 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
3705 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
3708 test_112_rename_prepare
3713 mrename $DIR/$tdir/src_dir/src_child $DIR/$tdir/tgt_dir/tgt_child ||
3714 error "rename dir cross MDT failed!"
3719 rm -rf $DIR/$tdir || error "rmdir failed"
3721 run_test 112n "DNE: cross MDT rename, fail MDT2,MDT3,MDT4"
3724 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
3725 ([ $FAILURE_MODE == "HARD" ] &&
3726 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
3727 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
3735 for ((j=0;j<$((MDSCOUNT));j++)); do
3736 fail_index=$((fail_index+1))
3737 index=$((fail_index % MDSCOUNT))
3738 replay_barrier mds$((index + 1))
3739 for ((i=0;i<5;i++)); do
3740 test_mkdir -i$index -c$MDSCOUNT $DIR/$tdir/test_$i ||
3741 error "create striped dir $DIR/$tdir/test_$i"
3744 fail mds$((index + 1))
3745 for ((i=0;i<5;i++)); do
3746 checkstat -t dir $DIR/$tdir/test_$i ||
3747 error "$DIR/$tdir/test_$i does not exist!"
3749 rm -rf $DIR/$tdir/test_* ||
3753 run_test 115 "failover for create/unlink striped directory"
3756 check_and_cleanup_lustre