5 LUSTRE=${LUSTRE:-$(dirname $0)/..}
6 . $LUSTRE/tests/test-framework.sh
10 ALWAYS_EXCEPT="$REPLAY_SINGLE_EXCEPT "
11 if [ "$mds1_FSTYPE" = zfs ]; then
15 always_except LU-13614 59
16 always_except LU-12805 36
18 always_except LU-9795 121
23 CHECK_GRANT=${CHECK_GRANT:-"yes"}
24 GRANT_CHECK_LIST=${GRANT_CHECK_LIST:-""}
26 require_dsh_mds || exit 0
27 check_and_setup_lustre
32 rm -rf $DIR/[df][0-9]* $DIR/f.$TESTSUITE.*
36 test_0a() { # was test_0
37 mkdir_on_mdt0 $DIR/$tdir || error "mkdir $DIR/$tdir failed"
38 replay_barrier $SINGLEMDS
42 run_test 0a "empty replay"
45 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
47 # this test attempts to trigger a race in the precreation code,
48 # and must run before any other objects are created on the filesystem
50 createmany -o $DIR/$tfile 20 || error "createmany -o $DIR/$tfile failed"
51 unlinkmany $DIR/$tfile 20 || error "unlinkmany $DIR/$tfile failed"
53 run_test 0b "ensure object created after recover exists. (3284)"
56 replay_barrier $SINGLEMDS
59 facet_failover $SINGLEMDS
60 zconf_mount $(hostname) $MOUNT || error "mount fails"
61 client_up || error "post-failover df failed"
62 # file shouldn't exist if replay-barrier works as expected
63 rm $DIR/$tfile && error "File exists and it shouldn't"
66 run_test 0c "check replay-barrier"
69 replay_barrier $SINGLEMDS
71 facet_failover $SINGLEMDS
72 zconf_mount $(hostname) $MOUNT || error "mount fails"
73 client_up || error "post-failover df failed"
75 run_test 0d "expired recovery with no clients"
78 replay_barrier $SINGLEMDS
81 $CHECKSTAT -t file $DIR/$tfile ||
82 error "$CHECKSTAT $DIR/$tfile attribute check failed"
85 run_test 1 "simple create"
88 replay_barrier $SINGLEMDS
91 $CHECKSTAT -t file $DIR/$tfile ||
92 error "$CHECKSTAT $DIR/$tfile attribute check failed"
98 mcreate $DIR/$tfile || error "mcreate $DIR/$tfile failed"
99 replay_barrier $SINGLEMDS
102 $CHECKSTAT -t file $DIR/$tfile ||
103 error "$CHECKSTAT $DIR/$tfile attribute check failed"
109 replay_barrier $SINGLEMDS
110 $LFS setstripe -c $OSTCOUNT $DIR/$tfile
112 $CHECKSTAT -t file $DIR/$tfile ||
113 error "$CHECKSTAT $DIR/$tfile check failed"
115 run_test 2c "setstripe replay"
118 [[ "$mds1_FSTYPE" = zfs ]] &&
119 [[ "$MDS1_VERSION" -lt $(version_code 2.12.51) ]] &&
120 skip "requires LU-10143 fix on MDS"
121 replay_barrier $SINGLEMDS
122 $LFS setdirstripe -i 0 -c $MDSCOUNT $DIR/$tdir
124 $CHECKSTAT -t dir $DIR/$tdir ||
125 error "$CHECKSTAT $DIR/$tdir check failed"
127 run_test 2d "setdirstripe replay"
130 testid=$(echo $TESTNAME | tr '_' ' ')
131 #define OBD_FAIL_MDS_CLOSE_NET_REP 0x13b
132 do_facet $SINGLEMDS "$LCTL set_param fail_loc=0x8000013b"
133 openfile -f O_CREAT:O_EXCL $DIR/$tfile &
135 replay_barrier $SINGLEMDS
138 $CHECKSTAT -t file $DIR/$tfile ||
139 error "$CHECKSTAT $DIR/$tfile attribute check failed"
140 dmesg | tac | sed "/$testid/,$ d" | \
141 grep "Open request replay failed with -17" &&
142 error "open replay failed" || true
144 run_test 2e "O_CREAT|O_EXCL create replay"
147 local file=$DIR/$tfile
148 replay_barrier $SINGLEMDS
150 openfile -f O_DIRECTORY $file
152 $CHECKSTAT -t file $file ||
153 error "$CHECKSTAT $file attribute check failed"
156 run_test 3a "replay failed open(O_DIRECTORY)"
159 replay_barrier $SINGLEMDS
160 #define OBD_FAIL_MDS_OPEN_PACK | CFS_FAIL_ONCE
161 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000114"
163 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
165 $CHECKSTAT -t file $DIR/$tfile &&
166 error "$CHECKSTAT $DIR/$tfile attribute check should fail"
169 run_test 3b "replay failed open -ENOMEM"
172 replay_barrier $SINGLEMDS
173 #define OBD_FAIL_MDS_ALLOC_OBDO | CFS_FAIL_ONCE
174 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000128"
176 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
179 $CHECKSTAT -t file $DIR/$tfile &&
180 error "$CHECKSTAT $DIR/$tfile attribute check should fail"
183 run_test 3c "replay failed open -ENOMEM"
185 test_4a() { # was test_4
186 replay_barrier $SINGLEMDS
187 for i in $(seq 10); do
188 echo "tag-$i" > $DIR/$tfile-$i
191 for i in $(seq 10); do
192 grep -q "tag-$i" $DIR/$tfile-$i || error "$tfile-$i"
195 run_test 4a "|x| 10 open(O_CREAT)s"
198 for i in $(seq 10); do
199 echo "tag-$i" > $DIR/$tfile-$i
201 replay_barrier $SINGLEMDS
204 $CHECKSTAT -t file $DIR/$tfile-* &&
205 error "$CHECKSTAT $DIR/$tfile-* attribute check should fail" ||
208 run_test 4b "|x| rm 10 files"
210 # The idea is to get past the first block of precreated files on both
211 # osts, and then replay.
213 replay_barrier $SINGLEMDS
214 for i in $(seq 220); do
215 echo "tag-$i" > $DIR/$tfile-$i
218 for i in $(seq 220); do
219 grep -q "tag-$i" $DIR/$tfile-$i || error "$tfile-$i"
223 # waiting for commitment of removal
225 run_test 5 "|x| 220 open(O_CREAT)"
227 test_6a() { # was test_6
228 mkdir_on_mdt0 $DIR/$tdir || error "mkdir $DIR/$tdir failed"
229 replay_barrier $SINGLEMDS
230 mcreate $DIR/$tdir/$tfile
232 $CHECKSTAT -t dir $DIR/$tdir ||
233 error "$CHECKSTAT $DIR/$tdir attribute check failed"
234 $CHECKSTAT -t file $DIR/$tdir/$tfile ||
235 error "$CHECKSTAT $DIR/$tdir/$tfile attribute check failed"
237 # waiting for log process thread
239 run_test 6a "mkdir + contained create"
242 mkdir_on_mdt0 $DIR/$tdir || error "mkdir $DIR/$tdir failed"
243 replay_barrier $SINGLEMDS
246 $CHECKSTAT -t dir $DIR/$tdir &&
247 error "$CHECKSTAT $DIR/$tdir attribute check should fail" ||
250 run_test 6b "|X| rmdir"
253 mkdir_on_mdt0 $DIR/$tdir || error "mkdir $DIR/$tdir failed"
254 replay_barrier $SINGLEMDS
255 mcreate $DIR/$tdir/$tfile
257 $CHECKSTAT -t dir $DIR/$tdir ||
258 error "$CHECKSTAT $DIR/$tdir attribute check failed"
259 $CHECKSTAT -t file $DIR/$tdir/$tfile ||
260 error "$CHECKSTAT $DIR/$tdir/$tfile attribute check failed"
263 run_test 7 "mkdir |X| contained create"
266 replay_barrier $SINGLEMDS
267 multiop_bg_pause $DIR/$tfile mo_c ||
268 error "multiop mknod $DIR/$tfile failed"
272 $CHECKSTAT -t file $DIR/$tfile ||
273 error "$CHECKSTAT $DIR/$tfile attribute check failed"
274 kill -USR1 $MULTIPID || error "multiop mknod $MULTIPID not running"
275 wait $MULTIPID || error "multiop mknod $MULTIPID failed"
278 run_test 8 "creat open |X| close"
281 replay_barrier $SINGLEMDS
283 local old_inum=$(ls -i $DIR/$tfile | awk '{print $1}')
285 local new_inum=$(ls -i $DIR/$tfile | awk '{print $1}')
287 echo " old_inum == $old_inum, new_inum == $new_inum"
288 if [ $old_inum -eq $new_inum ] ;
290 echo "old_inum and new_inum match"
292 echo " old_inum and new_inum do not match"
293 error "old index($old_inum) does not match new index($new_inum)"
297 run_test 9 "|X| create (same inum/gen)"
300 mcreate $DIR/$tfile || error "mcreate $DIR/$tfile failed"
301 replay_barrier $SINGLEMDS
302 mv $DIR/$tfile $DIR/$tfile-2
305 $CHECKSTAT $DIR/$tfile &&
306 error "$CHECKSTAT $DIR/$tfile attribute check should fail"
307 $CHECKSTAT $DIR/$tfile-2 ||
308 error "$CHECKSTAT $DIR/$tfile-2 attribute check failed"
312 run_test 10 "create |X| rename unlink"
315 mcreate $DIR/$tfile || error "mcreate $DIR/$tfile failed"
316 echo "old" > $DIR/$tfile
317 mv $DIR/$tfile $DIR/$tfile-2
318 replay_barrier $SINGLEMDS
319 echo "new" > $DIR/$tfile
321 grep old $DIR/$tfile-2
323 grep new $DIR/$tfile || error "grep $DIR/$tfile failed"
324 grep old $DIR/$tfile-2 || error "grep $DIR/$tfile-2 failed"
326 run_test 11 "create open write rename |X| create-old-name read"
329 mcreate $DIR/$tfile || error "mcreate $DIR/$tfile failed"
330 multiop_bg_pause $DIR/$tfile o_tSc ||
331 error "multiop_bg_pause $DIR/$tfile failed"
334 replay_barrier $SINGLEMDS
335 kill -USR1 $pid || error "multiop $pid not running"
336 wait $pid || error "multiop $pid failed"
339 [ -e $DIR/$tfile ] && error "file $DIR/$tfile should not exist"
342 run_test 12 "open, unlink |X| close"
344 # 1777 - replay open after committed chmod that would make
345 # a regular open a failure
347 mcreate $DIR/$tfile || error "mcreate $DIR/$tfile failed"
348 multiop_bg_pause $DIR/$tfile O_wc ||
349 error "multiop_bg_pause $DIR/$tfile failed"
352 $CHECKSTAT -p 0 $DIR/$tfile ||
353 error "$CHECKSTAT $DIR/$tfile attribute check failed"
354 replay_barrier $SINGLEMDS
356 kill -USR1 $pid || error "multiop $pid not running"
357 wait $pid || error "multiop $pid failed"
359 $CHECKSTAT -s 1 -p 0 $DIR/$tfile ||
360 error "second $CHECKSTAT $DIR/$tfile attribute check failed"
361 rm $DIR/$tfile || error "rm $DIR/$tfile failed"
364 run_test 13 "open chmod 0 |x| write close"
367 multiop_bg_pause $DIR/$tfile O_tSc ||
368 error "multiop_bg_pause $DIR/$tfile failed"
371 replay_barrier $SINGLEMDS
372 kill -USR1 $pid || error "multiop $pid not running"
373 wait $pid || error "multiop $pid failed"
376 [ -e $DIR/$tfile ] && error "file $DIR/$tfile should not exist"
379 run_test 14 "open(O_CREAT), unlink |X| close"
382 multiop_bg_pause $DIR/$tfile O_tSc ||
383 error "multiop_bg_pause $DIR/$tfile failed"
386 replay_barrier $SINGLEMDS
387 touch $DIR/$tfile-1 || error "touch $DIR/$tfile-1 failed"
388 kill -USR1 $pid || error "multiop $pid not running"
389 wait $pid || error "multiop $pid failed"
392 [ -e $DIR/$tfile ] && error "file $DIR/$tfile should not exist"
393 touch $DIR/$tfile-2 || error "touch $DIR/$tfile-2 failed"
396 run_test 15 "open(O_CREAT), unlink |X| touch new, close"
399 replay_barrier $SINGLEMDS
402 mcreate $DIR/$tfile-2
404 [ -e $DIR/$tfile ] && error "file $DIR/$tfile should not exist"
405 [ -e $DIR/$tfile-2 ] || error "file $DIR/$tfile-2 does not exist"
406 unlink $DIR/$tfile-2 || error "unlink $DIR/$tfile-2 failed"
408 run_test 16 "|X| open(O_CREAT), unlink, touch new, unlink new"
411 replay_barrier $SINGLEMDS
412 multiop_bg_pause $DIR/$tfile O_c ||
413 error "multiop_bg_pause $DIR/$tfile failed"
416 kill -USR1 $pid || error "multiop $pid not running"
417 wait $pid || error "multiop $pid failed"
418 $CHECKSTAT -t file $DIR/$tfile ||
419 error "$CHECKSTAT $DIR/$tfile attribute check failed"
422 run_test 17 "|X| open(O_CREAT), |replay| close"
425 replay_barrier $SINGLEMDS
426 multiop_bg_pause $DIR/$tfile O_tSc ||
427 error "multiop_bg_pause $DIR/$tfile failed"
430 touch $DIR/$tfile-2 || error "touch $DIR/$tfile-2 failed"
431 echo "pid: $pid will close"
432 kill -USR1 $pid || error "multiop $pid not running"
433 wait $pid || error "multiop $pid failed"
436 [ -e $DIR/$tfile ] && error "file $DIR/$tfile should not exist"
437 [ -e $DIR/$tfile-2 ] || error "file $DIR/$tfile-2 does not exist"
438 # this touch frequently fails
439 touch $DIR/$tfile-3 || error "touch $DIR/$tfile-3 failed"
440 unlink $DIR/$tfile-2 || error "unlink $DIR/$tfile-2 failed"
441 unlink $DIR/$tfile-3 || error "unlink $DIR/$tfile-3 failed"
444 run_test 18 "open(O_CREAT), unlink, touch new, close, touch, unlink"
446 # bug 1855 (a simpler form of test_11 above)
448 replay_barrier $SINGLEMDS
450 echo "old" > $DIR/$tfile
451 mv $DIR/$tfile $DIR/$tfile-2
452 grep old $DIR/$tfile-2
454 grep old $DIR/$tfile-2 || error "grep $DIR/$tfile-2 failed"
456 run_test 19 "mcreate, open, write, rename "
458 test_20a() { # was test_20
459 replay_barrier $SINGLEMDS
460 multiop_bg_pause $DIR/$tfile O_tSc ||
461 error "multiop_bg_pause $DIR/$tfile failed"
466 kill -USR1 $pid || error "multiop $pid not running"
467 wait $pid || error "multiop $pid failed"
468 [ -e $DIR/$tfile ] && error "file $DIR/$tfile should not exist"
471 run_test 20a "|X| open(O_CREAT), unlink, replay, close (test mds_cleanup_orphans)"
473 test_20b() { # bug 10480
474 local wait_timeout=$((TIMEOUT * 4))
475 local extra=$(fs_log_size)
479 save_layout_restore_at_exit $MOUNT
480 $LFS setstripe -i 0 -c 1 $DIR
482 local beforeused=$(df -P $DIR | tail -1 | awk '{ print $3 }')
484 dd if=/dev/zero of=$DIR/$tfile bs=4k count=10000 &
485 while [ ! -e $DIR/$tfile ] ; do
486 sleep 0.01 # give dd a chance to start
489 $LFS getstripe $DIR/$tfile || error "$LFS getstripe $DIR/$tfile failed"
491 rm -f $DIR/$tfile || error "rm -f $DIR/$tfile failed"
493 client_up || client_up || true # reconnect
495 do_facet $SINGLEMDS "lctl set_param -n osd*.*MDT*.force_sync=1"
497 fail $SINGLEMDS # start orphan recovery
498 wait_recovery_complete $SINGLEMDS || error "MDS recovery not done"
499 wait_delete_completed $wait_timeout || error "delete did not finish"
503 local afterused=$(df -P $DIR | tail -1 | awk '{ print $3 }')
504 log "before $beforeused, after $afterused"
506 (( $beforeused + $extra >= $afterused )) && break
507 n_attempts=$((n_attempts + 1))
508 [ $n_attempts -gt 3 ] &&
509 error "after $afterused > before $beforeused + $extra"
511 wait_zfs_commit $SINGLEMDS 5
516 run_test 20b "write, unlink, eviction, replay (test mds_cleanup_orphans)"
518 test_20c() { # bug 10480
519 multiop_bg_pause $DIR/$tfile Ow_c ||
520 error "multiop_bg_pause $DIR/$tfile failed"
526 client_up || client_up || true # reconnect
528 kill -USR1 $pid || error "multiop $pid not running"
529 wait $pid || error "multiop $pid failed"
530 [ -s $DIR/$tfile ] || error "File was truncated"
534 run_test 20c "check that client eviction does not affect file content"
537 replay_barrier $SINGLEMDS
538 multiop_bg_pause $DIR/$tfile O_tSc ||
539 error "multiop_bg_pause $DIR/$tfile failed"
542 touch $DIR/$tfile-1 || error "touch $DIR/$tfile-1 failed"
545 kill -USR1 $pid || error "multiop $pid not running"
546 wait $pid || error "multiop $pid failed"
547 [ -e $DIR/$tfile ] && error "file $DIR/$tfile should not exist"
548 touch $DIR/$tfile-2 || error "touch $DIR/$tfile-2 failed"
551 run_test 21 "|X| open(O_CREAT), unlink touch new, replay, close (test mds_cleanup_orphans)"
554 multiop_bg_pause $DIR/$tfile O_tSc ||
555 error "multiop_bg_pause $DIR/$tfile failed"
558 replay_barrier $SINGLEMDS
562 kill -USR1 $pid || error "multiop $pid not running"
563 wait $pid || error "multiop $pid failed"
564 [ -e $DIR/$tfile ] && error "file $DIR/$tfile should not exist"
567 run_test 22 "open(O_CREAT), |X| unlink, replay, close (test mds_cleanup_orphans)"
570 multiop_bg_pause $DIR/$tfile O_tSc ||
571 error "multiop_bg_pause $DIR/$tfile failed"
574 replay_barrier $SINGLEMDS
576 touch $DIR/$tfile-1 || error "touch $DIR/$tfile-1 failed"
579 kill -USR1 $pid || error "multiop $pid not running"
580 wait $pid || error "multiop $pid failed"
581 [ -e $DIR/$tfile ] && error "file $DIR/$tfile should not exist"
582 touch $DIR/$tfile-2 || error "touch $DIR/$tfile-2 failed"
585 run_test 23 "open(O_CREAT), |X| unlink touch new, replay, close (test mds_cleanup_orphans)"
588 multiop_bg_pause $DIR/$tfile O_tSc ||
589 error "multiop_bg_pause $DIR/$tfile failed"
592 replay_barrier $SINGLEMDS
595 kill -USR1 $pid || error "multiop $pid not running"
596 wait $pid || error "multiop $pid failed"
597 [ -e $DIR/$tfile ] && error "file $DIR/$tfile should not exist"
600 run_test 24 "open(O_CREAT), replay, unlink, close (test mds_cleanup_orphans)"
603 multiop_bg_pause $DIR/$tfile O_tSc ||
604 error "multiop_bg_pause $DIR/$tfile failed"
608 replay_barrier $SINGLEMDS
610 kill -USR1 $pid || error "multiop $pid not running"
611 wait $pid || error "multiop $pid failed"
612 [ -e $DIR/$tfile ] && error "file $DIR/$tfile should not exist"
615 run_test 25 "open(O_CREAT), unlink, replay, close (test mds_cleanup_orphans)"
618 replay_barrier $SINGLEMDS
619 multiop_bg_pause $DIR/$tfile-1 O_tSc ||
620 error "multiop_bg_pause $DIR/$tfile-1 failed"
622 multiop_bg_pause $DIR/$tfile-2 O_tSc ||
623 error "multiop_bg_pause $DIR/$tfile-2 failed"
627 kill -USR1 $pid2 || error "second multiop $pid2 not running"
628 wait $pid2 || error "second multiop $pid2 failed"
631 kill -USR1 $pid1 || error "multiop $pid1 not running"
632 wait $pid1 || error "multiop $pid1 failed"
633 [ -e $DIR/$tfile-1 ] && error "file $DIR/$tfile-1 should not exist"
634 [ -e $DIR/$tfile-2 ] && error "file $DIR/$tfile-2 should not exist"
637 run_test 26 "|X| open(O_CREAT), unlink two, close one, replay, close one (test mds_cleanup_orphans)"
640 replay_barrier $SINGLEMDS
641 multiop_bg_pause $DIR/$tfile-1 O_tSc ||
642 error "multiop_bg_pause $DIR/$tfile-1 failed"
644 multiop_bg_pause $DIR/$tfile-2 O_tSc ||
645 error "multiop_bg_pause $DIR/$tfile-2 failed"
651 kill -USR1 $pid1 || error "multiop $pid1 not running"
652 wait $pid1 || error "multiop $pid1 failed"
653 kill -USR1 $pid2 || error "second multiop $pid2 not running"
654 wait $pid2 || error "second multiop $pid2 failed"
655 [ -e $DIR/$tfile-1 ] && error "file $DIR/$tfile-1 should not exist"
656 [ -e $DIR/$tfile-2 ] && error "file $DIR/$tfile-2 should not exist"
659 run_test 27 "|X| open(O_CREAT), unlink two, replay, close two (test mds_cleanup_orphans)"
662 multiop_bg_pause $DIR/$tfile-1 O_tSc ||
663 error "multiop_bg_pause $DIR/$tfile-1 failed"
665 multiop_bg_pause $DIR/$tfile-2 O_tSc ||
666 error "multiop_bg_pause $DIR/$tfile-2 failed"
668 replay_barrier $SINGLEMDS
671 kill -USR1 $pid2 || error "second multiop $pid2 not running"
672 wait $pid2 || error "second multiop $pid2 failed"
675 kill -USR1 $pid1 || error "multiop $pid1 not running"
676 wait $pid1 || error "multiop $pid1 failed"
677 [ -e $DIR/$tfile-1 ] && error "file $DIR/$tfile-1 should not exist"
678 [ -e $DIR/$tfile-2 ] && error "file $DIR/$tfile-2 should not exist"
681 run_test 28 "open(O_CREAT), |X| unlink two, close one, replay, close one (test mds_cleanup_orphans)"
684 multiop_bg_pause $DIR/$tfile-1 O_tSc ||
685 error "multiop_bg_pause $DIR/$tfile-1 failed"
687 multiop_bg_pause $DIR/$tfile-2 O_tSc ||
688 error "multiop_bg_pause $DIR/$tfile-2 failed"
690 replay_barrier $SINGLEMDS
695 kill -USR1 $pid1 || error "multiop $pid1 not running"
696 wait $pid1 || error "multiop $pid1 failed"
697 kill -USR1 $pid2 || error "second multiop $pid2 not running"
698 wait $pid2 || error "second multiop $pid2 failed"
699 [ -e $DIR/$tfile-1 ] && error "file $DIR/$tfile-1 should not exist"
700 [ -e $DIR/$tfile-2 ] && error "file $DIR/$tfile-2 should not exist"
703 run_test 29 "open(O_CREAT), |X| unlink two, replay, close two (test mds_cleanup_orphans)"
706 multiop_bg_pause $DIR/$tfile-1 O_tSc ||
707 error "multiop_bg_pause $DIR/$tfile-1 failed"
709 multiop_bg_pause $DIR/$tfile-2 O_tSc ||
710 error "multiop_bg_pause $DIR/$tfile-2 failed"
715 replay_barrier $SINGLEMDS
717 kill -USR1 $pid1 || error "multiop $pid1 not running"
718 wait $pid1 || error "multiop $pid1 failed"
719 kill -USR1 $pid2 || error "second multiop $pid2 not running"
720 wait $pid2 || error "second multiop $pid2 failed"
721 [ -e $DIR/$tfile-1 ] && error "file $DIR/$tfile-1 should not exist"
722 [ -e $DIR/$tfile-2 ] && error "file $DIR/$tfile-2 should not exist"
725 run_test 30 "open(O_CREAT) two, unlink two, replay, close two (test mds_cleanup_orphans)"
728 multiop_bg_pause $DIR/$tfile-1 O_tSc ||
729 error "multiop_bg_pause $DIR/$tfile-1 failed"
731 multiop_bg_pause $DIR/$tfile-2 O_tSc ||
732 error "multiop_bg_pause $DIR/$tfile-2 failed"
736 replay_barrier $SINGLEMDS
739 kill -USR1 $pid1 || error "multiop $pid1 not running"
740 wait $pid1 || error "multiop $pid1 failed"
741 kill -USR1 $pid2 || error "second multiop $pid2 not running"
742 wait $pid2 || error "second multiop $pid2 failed"
743 [ -e $DIR/$tfile-1 ] && error "file $DIR/$tfile-1 should not exist"
744 [ -e $DIR/$tfile-2 ] && error "file $DIR/$tfile-2 should not exist"
747 run_test 31 "open(O_CREAT) two, unlink one, |X| unlink one, close two (test mds_cleanup_orphans)"
749 # tests for bug 2104; completion without crashing is success. The close is
750 # stale, but we always return 0 for close, so the app never sees it.
752 multiop_bg_pause $DIR/$tfile O_c ||
753 error "multiop_bg_pause $DIR/$tfile failed"
755 multiop_bg_pause $DIR/$tfile O_c ||
756 error "second multiop_bg_pause $DIR/$tfile failed"
759 client_up || client_up || error "client_up failed"
760 kill -USR1 $pid1 || error "multiop $pid1 not running"
761 kill -USR1 $pid2 || error "second multiop $pid2 not running"
762 wait $pid1 || error "multiop $pid1 failed"
763 wait $pid2 || error "second multiop $pid2 failed"
766 run_test 32 "close() notices client eviction; close() after client eviction"
769 createmany -o $DIR/$tfile-%d 10 ||
770 error "createmany create $DIR/$tfile failed"
771 replay_barrier_nosync $SINGLEMDS
772 fail_abort $SINGLEMDS
773 # recreate shouldn't fail
774 createmany -o $DIR/$tfile--%d 10 ||
775 error "createmany recreate $DIR/$tfile failed"
779 run_test 33a "fid seq shouldn't be reused after abort recovery"
782 #define OBD_FAIL_SEQ_ALLOC 0x1311
783 do_facet $SINGLEMDS "lctl set_param fail_loc=0x1311"
785 createmany -o $DIR/$tfile-%d 10
786 replay_barrier_nosync $SINGLEMDS
787 fail_abort $SINGLEMDS
788 # recreate shouldn't fail
789 createmany -o $DIR/$tfile--%d 10 ||
790 error "createmany recreate $DIR/$tfile failed"
794 run_test 33b "test fid seq allocation"
797 multiop_bg_pause $DIR/$tfile O_c ||
798 error "multiop_bg_pause $DIR/$tfile failed"
802 replay_barrier $SINGLEMDS
803 fail_abort $SINGLEMDS
804 kill -USR1 $pid || error "multiop $pid not running"
805 wait $pid || error "multiop $pid failed"
806 [ -e $DIR/$tfile ] && error "file $DIR/$tfile should not exist"
810 run_test 34 "abort recovery before client does replay (test mds_cleanup_orphans)"
812 # bug 2278 - generate one orphan on OST, then destroy it during recovery from llog
814 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
816 #define OBD_FAIL_MDS_REINT_NET_REP 0x119
817 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000119"
822 # give a chance to remove from MDS
823 fail_abort $SINGLEMDS
824 $CHECKSTAT -t file $DIR/$tfile &&
825 error "$CHECKSTAT $DIR/$tfile attribute check should fail" ||
828 run_test 35 "test recovery from llog for unlink op"
830 # b=2432 resent cancel after replay uses wrong cookie,
831 # so don't resend cancels
833 replay_barrier $SINGLEMDS
835 checkstat $DIR/$tfile
836 facet_failover $SINGLEMDS
838 if do_facet $SINGLEMDS $LCTL dk | grep "stale lock .*cookie"; then
839 error "cancel after replay failed"
842 run_test 36 "don't resend cancel"
845 # directory orphans can't be unlinked from PENDING directory
847 mkdir_on_mdt0 $DIR/$tdir || error "mkdir $tdir failed"
848 rmdir $DIR/$tdir/$tfile 2>/dev/null
849 multiop_bg_pause $DIR/$tdir/$tfile dD_c ||
850 error "multiop_bg_pause $tfile failed"
852 rmdir $DIR/$tdir/$tfile
854 replay_barrier $SINGLEMDS
855 # clear the dmesg buffer so we only see errors from this recovery
856 do_facet $SINGLEMDS dmesg -c >/dev/null
857 fail_abort $SINGLEMDS
858 kill -USR1 $pid || error "multiop $pid not running"
859 do_facet $SINGLEMDS dmesg | grep "error unlinking orphan" &&
860 error "error unlinking files"
861 wait $pid || error "multiop $pid failed"
865 run_test 37 "abort recovery before client does replay (test mds_cleanup_orphans for directories)"
868 createmany -o $DIR/$tfile-%d 800 ||
869 error "createmany -o $DIR/$tfile failed"
870 unlinkmany $DIR/$tfile-%d 0 400 || error "unlinkmany $DIR/$tfile failed"
871 replay_barrier $SINGLEMDS
873 unlinkmany $DIR/$tfile-%d 400 400 ||
874 error "unlinkmany $DIR/$tfile 400 failed"
876 $CHECKSTAT -t file $DIR/$tfile-* &&
877 error "$CHECKSTAT $DIR/$tfile-* attribute check should fail" ||
880 run_test 38 "test recovery from unlink llog (test llog_gen_rec) "
882 test_39() { # bug 4176
883 createmany -o $DIR/$tfile-%d 800 ||
884 error "createmany -o $DIR/$tfile failed"
885 replay_barrier $SINGLEMDS
886 unlinkmany $DIR/$tfile-%d 0 400
888 unlinkmany $DIR/$tfile-%d 400 400 ||
889 error "unlinkmany $DIR/$tfile 400 failed"
891 $CHECKSTAT -t file $DIR/$tfile-* &&
892 error "$CHECKSTAT $DIR/$tfile-* attribute check should fail" ||
895 run_test 39 "test recovery from unlink llog (test llog_gen_rec) "
898 lctl get_param -n osc.*.stats | awk -vwrites=0 '/ost_write/ { writes += $2 } END { print writes; }'
902 # make sure that a read to one osc doesn't try to double-unlock its page just
903 # because another osc is invalid. trigger_group_io used to mistakenly return
904 # an error if any oscs were invalid even after having successfully put rpcs
905 # on valid oscs. This was fatal if the caller was ll_readpage who unlocked
906 # the page, guarnateeing that the unlock from the RPC completion would
907 # assert on trying to unlock the unlocked page.
909 [ $OSTCOUNT -lt 2 ] && skip_env "needs >= 2 OSTs" && return
911 local f=$MOUNT/$tfile
912 # make sure the start of the file is ost1
913 $LFS setstripe -S $((128 * 1024)) -i 0 $f
914 do_facet client dd if=/dev/zero of=$f bs=4k count=1 ||
915 error "dd on client failed"
917 # fail ost2 and read from ost1
918 local mdtosc=$(get_mdtosc_proc_path $SINGLEMDS $ost2_svc)
919 local osc2dev=$(do_facet $SINGLEMDS "lctl get_param -n devices" |
920 grep $mdtosc | awk '{print $1}')
921 [ -z "$osc2dev" ] && echo "OST: $ost2_svc" &&
922 lctl get_param -n devices &&
923 error "OST 2 $osc2dev does not exist"
924 do_facet $SINGLEMDS $LCTL --device $osc2dev deactivate ||
925 error "deactive device on $SINGLEMDS failed"
926 do_facet client dd if=$f of=/dev/null bs=4k count=1 ||
927 error "second dd on client failed"
928 do_facet $SINGLEMDS $LCTL --device $osc2dev activate ||
929 error "active device on $SINGLEMDS failed"
932 run_test 41 "read from a valid osc while other oscs are invalid"
934 # test MDS recovery after ost failure
936 blocks=$(df -P $MOUNT | tail -n 1 | awk '{ print $2 }')
937 createmany -o $DIR/$tfile-%d 800 ||
938 error "createmany -o $DIR/$tfile failed"
940 unlinkmany $DIR/$tfile-%d 0 400
942 lctl set_param debug=-1
945 # osc is evicted, fs is smaller (but only with failout OSTs (bug 7287)
946 #blocks_after=`df -P $MOUNT | tail -n 1 | awk '{ print $2 }'`
947 #[ $blocks_after -lt $blocks ] || return 1
948 echo "wait for MDS to timeout and recover"
949 sleep $((TIMEOUT * 2))
951 unlinkmany $DIR/$tfile-%d 400 400 ||
952 error "unlinkmany $DIR/$tfile 400 failed"
953 $CHECKSTAT -t file $DIR/$tfile-* &&
954 error "$CHECKSTAT $DIR/$tfile-* attribute check should fail" ||
957 run_test 42 "recovery after ost failure"
959 # timeout in MDS/OST recovery RPC will LBUG MDS
960 test_43() { # bug 2530
961 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
963 replay_barrier $SINGLEMDS
965 # OBD_FAIL_OST_CREATE_NET 0x204
966 do_facet ost1 "lctl set_param fail_loc=0x80000204"
972 run_test 43 "mds osc import failure during recovery; don't LBUG"
974 test_44a() { # was test_44
977 local mdcdev=$($LCTL dl |
978 awk "/${FSNAME}-MDT0000-mdc-/ {if (\$2 == \"UP\") {print \$1}}")
979 [ "$mdcdev" ] || error "${FSNAME}-MDT0000-mdc- not UP"
980 [ $(echo $mdcdev | wc -w) -eq 1 ] ||
981 { $LCTL dl; error "looking for mdcdev=$mdcdev"; }
983 # adaptive timeouts slow this way down
984 if at_is_enabled; then
985 at_max_saved=$(at_max_get mds)
989 for i in $(seq 1 10); do
990 echo "$i of 10 ($(date +%s))"
991 do_facet $SINGLEMDS \
992 "lctl get_param -n md[ts].*.mdt.timeouts | grep service"
993 #define OBD_FAIL_TGT_CONN_RACE 0x701
994 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000701"
995 # lctl below may fail, it is valid case
996 $LCTL --device $mdcdev recover
999 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
1000 [ $at_max_saved -ne 0 ] && at_max_set $at_max_saved mds
1003 run_test 44a "race in target handle connect"
1006 local mdcdev=$($LCTL dl |
1007 awk "/${FSNAME}-MDT0000-mdc-/ {if (\$2 == \"UP\") {print \$1}}")
1008 [ "$mdcdev" ] || error "${FSNAME}-MDT0000-mdc not up"
1009 [ $(echo $mdcdev | wc -w) -eq 1 ] ||
1010 { echo mdcdev=$mdcdev; $LCTL dl;
1011 error "more than one ${FSNAME}-MDT0000-mdc"; }
1013 for i in $(seq 1 10); do
1014 echo "$i of 10 ($(date +%s))"
1015 do_facet $SINGLEMDS \
1016 "lctl get_param -n md[ts].*.mdt.timeouts | grep service"
1017 #define OBD_FAIL_TGT_DELAY_RECONNECT 0x704
1018 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000704"
1019 # lctl below may fail, it is valid case
1020 $LCTL --device $mdcdev recover
1025 run_test 44b "race in target handle connect"
1028 replay_barrier $SINGLEMDS
1029 createmany -m $DIR/$tfile-%d 100 || error "failed to create directories"
1030 #define OBD_FAIL_TGT_RCVG_FLAG 0x712
1031 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000712"
1032 fail_abort $SINGLEMDS
1033 unlinkmany $DIR/$tfile-%d 100 && error "unliked after fail abort"
1035 unlinkmany $DIR/$tfile-%d 100 && error "unliked after fail"
1038 run_test 44c "race in target handle connect"
1040 # Handle failed close
1042 local mdcdev=$($LCTL get_param -n devices |
1043 awk "/ ${FSNAME}-MDT0000-mdc-/ {print \$1}")
1044 [ "$mdcdev" ] || error "${FSNAME}-MDT0000-mdc not up"
1045 [ $(echo $mdcdev | wc -w) -eq 1 ] ||
1046 { echo mdcdev=$mdcdev; $LCTL dl;
1047 error "more than one ${FSNAME}-MDT0000-mdc"; }
1049 $LCTL --device $mdcdev recover ||
1050 error "$LCTL --device $mdcdev recover failed"
1052 multiop_bg_pause $DIR/$tfile O_c ||
1053 error "multiop_bg_pause $DIR/$tfile failed"
1056 # This will cause the CLOSE to fail before even
1057 # allocating a reply buffer
1058 $LCTL --device $mdcdev deactivate ||
1059 error "$LCTL --device $mdcdev deactivate failed"
1062 kill -USR1 $pid || error "multiop $pid not running"
1063 wait $pid || error "multiop $pid failed"
1065 $LCTL --device $mdcdev activate ||
1066 error "$LCTL --device $mdcdev activate failed"
1069 $CHECKSTAT -t file $DIR/$tfile ||
1070 error "$CHECKSTAT $DIR/$tfile attribute check failed"
1073 run_test 45 "Handle failed close"
1076 drop_reply "touch $DIR/$tfile"
1078 # ironically, the previous test, 45, will cause a real forced close,
1079 # so just look for one for this test
1080 local FID=$($LFS path2fid $tfile)
1081 $LCTL dk | grep -i "force closing file handle $FID" &&
1082 error "found force closing in dmesg"
1085 run_test 46 "Don't leak file handle after open resend (3325)"
1087 test_47() { # bug 2824
1088 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1090 # create some files to make sure precreate has been done on all
1091 # OSTs. (just in case this test is run independently)
1092 createmany -o $DIR/$tfile 20 ||
1093 error "createmany create $DIR/$tfile failed"
1095 # OBD_FAIL_OST_CREATE_NET 0x204
1097 do_facet ost1 "lctl set_param fail_loc=0x80000204"
1098 client_up || error "client_up failed"
1100 # let the MDS discover the OST failure, attempt to recover, fail
1101 # and recover again.
1102 sleep $((3 * TIMEOUT))
1104 # Without 2824, this createmany would hang
1105 createmany -o $DIR/$tfile 20 ||
1106 error "createmany recraete $DIR/$tfile failed"
1107 unlinkmany $DIR/$tfile 20 || error "unlinkmany $DIR/$tfile failed"
1111 run_test 47 "MDS->OSC failure during precreate cleanup (2824)"
1114 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1115 [ "$OSTCOUNT" -lt "2" ] && skip_env "needs >= 2 OSTs" && return
1117 replay_barrier $SINGLEMDS
1118 createmany -o $DIR/$tfile 20 ||
1119 error "createmany -o $DIR/$tfile failed"
1120 # OBD_FAIL_OST_EROFS 0x216
1121 facet_failover $SINGLEMDS
1122 do_facet ost1 "lctl set_param fail_loc=0x80000216"
1123 client_up || error "client_up failed"
1125 # let the MDS discover the OST failure, attempt to recover, fail
1126 # and recover again.
1127 sleep $((3 * TIMEOUT))
1129 createmany -o $DIR/$tfile 20 20 ||
1130 error "createmany recraete $DIR/$tfile failed"
1131 unlinkmany $DIR/$tfile 40 || error "unlinkmany $DIR/$tfile failed"
1134 run_test 48 "MDS->OSC failure during precreate cleanup (2824)"
1137 local mdtosc=$(get_mdtosc_proc_path $SINGLEMDS $ost1_svc)
1138 local oscdev=$(do_facet $SINGLEMDS "lctl get_param -n devices" |
1139 grep $mdtosc | awk '{print $1}')
1140 [ "$oscdev" ] || error "could not find OSC device on MDS"
1141 do_facet $SINGLEMDS $LCTL --device $oscdev recover ||
1142 error "OSC device $oscdev recovery failed"
1143 do_facet $SINGLEMDS $LCTL --device $oscdev recover ||
1144 error "second OSC device $oscdev recovery failed"
1145 # give the mds_lov_sync threads a chance to run
1148 run_test 50 "Double OSC recovery, don't LASSERT (3812)"
1150 # b3764 timed out lock replay
1152 [ "$MDS1_VERSION" -lt $(version_code 2.6.90) ] &&
1153 skip "MDS prior to 2.6.90 handle LDLM_REPLY_NET incorrectly"
1155 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
1156 cancel_lru_locks mdc
1158 multiop_bg_pause $DIR/$tfile s_s || error "multiop $DIR/$tfile failed"
1161 #define OBD_FAIL_MDS_LDLM_REPLY_NET 0x157
1162 lctl set_param -n ldlm.cancel_unused_locks_before_replay "0"
1163 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000157"
1165 fail $SINGLEMDS || error "fail $SINGLEMDS failed"
1167 wait $mpid || error "multiop_bg_pause pid failed"
1169 do_facet $SINGLEMDS "lctl set_param fail_loc=0x0"
1170 lctl set_param fail_loc=0x0
1171 lctl set_param -n ldlm.cancel_unused_locks_before_replay "1"
1174 run_test 52 "time out lock replay (3764)"
1176 # bug 3462 - simultaneous MDC requests
1178 [[ $(lctl get_param mdc.*.import |
1179 grep "connect_flags:.*multi_mod_rpc") ]] ||
1180 { skip "Need MDC with 'multi_mod_rpcs' feature"; return 0; }
1182 cancel_lru_locks mdc # cleanup locks from former test cases
1183 mkdir_on_mdt0 $DIR/${tdir}-1 || error "mkdir $DIR/${tdir}-1 failed"
1184 mkdir_on_mdt0 $DIR/${tdir}-2 || error "mkdir $DIR/${tdir}-2 failed"
1185 multiop $DIR/${tdir}-1/f O_c &
1187 # give multiop a change to open
1190 #define OBD_FAIL_MDS_CLOSE_NET 0x115
1191 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000115"
1192 kill -USR1 $close_pid
1193 cancel_lru_locks mdc # force the close
1194 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
1196 mcreate $DIR/${tdir}-2/f || error "mcreate $DIR/${tdir}-2/f failed"
1198 # close should still be here
1199 [ -d /proc/$close_pid ] || error "close_pid doesn't exist"
1201 replay_barrier_nodf $SINGLEMDS
1203 wait $close_pid || error "close_pid $close_pid failed"
1205 $CHECKSTAT -t file $DIR/${tdir}-1/f ||
1206 error "$CHECKSTAT $DIR/${tdir}-1/f attribute check failed"
1207 $CHECKSTAT -t file $DIR/${tdir}-2/f ||
1208 error "$CHECKSTAT $DIR/${tdir}-2/f attribute check failed"
1209 rm -rf $DIR/${tdir}-*
1211 run_test 53a "|X| close request while two MDC requests in flight"
1214 cancel_lru_locks mdc # cleanup locks from former test cases
1216 mkdir_on_mdt0 $DIR/${tdir}-1 || error "mkdir $DIR/${tdir}-1 failed"
1217 mkdir_on_mdt0 $DIR/${tdir}-2 || error "mkdir $DIR/${tdir}-2 failed"
1218 multiop_bg_pause $DIR/${tdir}-1/f O_c ||
1219 error "multiop_bg_pause $DIR/${tdir}-1/f failed"
1222 #define OBD_FAIL_MDS_REINT_NET 0x107
1223 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000107"
1224 mcreate $DIR/${tdir}-2/f &
1228 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
1229 kill -USR1 $close_pid
1230 cancel_lru_locks mdc # force the close
1231 wait $close_pid || error "close_pid $close_pid failed"
1232 # open should still be here
1233 [ -d /proc/$open_pid ] || error "open_pid doesn't exist"
1235 replay_barrier_nodf $SINGLEMDS
1237 wait $open_pid || error "open_pid failed"
1239 $CHECKSTAT -t file $DIR/${tdir}-1/f ||
1240 error "$CHECKSTAT $DIR/${tdir}-1/f attribute check failed"
1241 $CHECKSTAT -t file $DIR/${tdir}-2/f ||
1242 error "$CHECKSTAT $DIR/${tdir}-2/f attribute check failed"
1243 rm -rf $DIR/${tdir}-*
1245 run_test 53b "|X| open request while two MDC requests in flight"
1248 cancel_lru_locks mdc # cleanup locks from former test cases
1250 mkdir_on_mdt0 $DIR/${tdir}-1 || error "mkdir $DIR/${tdir}-1 failed"
1251 mkdir_on_mdt0 $DIR/${tdir}-2 || error "mkdir $DIR/${tdir}-2 failed"
1252 multiop $DIR/${tdir}-1/f O_c &
1255 #define OBD_FAIL_MDS_REINT_NET 0x107
1256 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000107"
1257 mcreate $DIR/${tdir}-2/f &
1261 #define OBD_FAIL_MDS_CLOSE_NET 0x115
1262 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000115"
1263 kill -USR1 $close_pid
1264 cancel_lru_locks mdc # force the close
1266 #bz20647: make sure all pids exist before failover
1267 [ -d /proc/$close_pid ] || error "close_pid doesn't exist"
1268 [ -d /proc/$open_pid ] || error "open_pid doesn't exists"
1269 replay_barrier_nodf $SINGLEMDS
1270 fail_nodf $SINGLEMDS
1271 wait $open_pid || error "open_pid failed"
1273 # close should be gone
1274 [ -d /proc/$close_pid ] && error "close_pid should not exist"
1275 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
1277 $CHECKSTAT -t file $DIR/${tdir}-1/f ||
1278 error "$CHECKSTAT $DIR/${tdir}-1/f attribute check failed"
1279 $CHECKSTAT -t file $DIR/${tdir}-2/f ||
1280 error "$CHECKSTAT $DIR/${tdir}-2/f attribute check failed"
1281 rm -rf $DIR/${tdir}-*
1283 run_test 53c "|X| open request and close request while two MDC requests in flight"
1286 [[ $(lctl get_param mdc.*.import |
1287 grep "connect_flags:.*multi_mod_rpc") ]] ||
1288 { skip "Need MDC with 'multi_mod_rpcs' feature"; return 0; }
1290 cancel_lru_locks mdc # cleanup locks from former test cases
1292 mkdir_on_mdt0 $DIR/${tdir}-1 || error "mkdir $DIR/${tdir}-1 failed"
1293 mkdir_on_mdt0 $DIR/${tdir}-2 || error "mkdir $DIR/${tdir}-2 failed"
1294 multiop $DIR/${tdir}-1/f O_c &
1296 # give multiop a chance to open
1299 #define OBD_FAIL_MDS_CLOSE_NET_REP 0x13b
1300 do_facet $SINGLEMDS "lctl set_param fail_loc=0x8000013b"
1301 kill -USR1 $close_pid
1302 cancel_lru_locks mdc # force the close
1303 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
1304 mcreate $DIR/${tdir}-2/f || error "mcreate $DIR/${tdir}-2/f failed"
1306 # close should still be here
1307 [ -d /proc/$close_pid ] || error "close_pid doesn't exist"
1309 wait $close_pid || error "close_pid failed"
1311 $CHECKSTAT -t file $DIR/${tdir}-1/f ||
1312 error "$CHECKSTAT $DIR/${tdir}-1/f attribute check failed"
1313 $CHECKSTAT -t file $DIR/${tdir}-2/f ||
1314 error "$CHECKSTAT $DIR/${tdir}-2/f attribute check failed"
1315 rm -rf $DIR/${tdir}-*
1317 run_test 53d "close reply while two MDC requests in flight"
1320 cancel_lru_locks mdc # cleanup locks from former test cases
1322 mkdir_on_mdt0 $DIR/${tdir}-1 || error "mkdir $DIR/${tdir}-1 failed"
1323 mkdir_on_mdt0 $DIR/${tdir}-2 || error "mkdir $DIR/${tdir}-2 failed"
1324 multiop $DIR/${tdir}-1/f O_c &
1327 #define OBD_FAIL_MDS_REINT_NET_REP 0x119
1328 do_facet $SINGLEMDS "lctl set_param fail_loc=0x119"
1329 mcreate $DIR/${tdir}-2/f &
1333 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
1334 kill -USR1 $close_pid
1335 cancel_lru_locks mdc # force the close
1336 wait $close_pid || error "close_pid failed"
1337 # open should still be here
1338 [ -d /proc/$open_pid ] || error "open_pid doesn't exists"
1340 replay_barrier_nodf $SINGLEMDS
1342 wait $open_pid || error "open_pid failed"
1344 $CHECKSTAT -t file $DIR/${tdir}-1/f ||
1345 error "$CHECKSTAT $DIR/${tdir}-1/f attribute check failed"
1346 $CHECKSTAT -t file $DIR/${tdir}-2/f ||
1347 error "$CHECKSTAT $DIR/${tdir}-2/f attribute check failed"
1348 rm -rf $DIR/${tdir}-*
1350 run_test 53e "|X| open reply while two MDC requests in flight"
1353 cancel_lru_locks mdc # cleanup locks from former test cases
1355 mkdir_on_mdt0 $DIR/${tdir}-1 || error "mkdir $DIR/${tdir}-1 failed"
1356 mkdir_on_mdt0 $DIR/${tdir}-2 || error "mkdir $DIR/${tdir}-2 failed"
1357 multiop $DIR/${tdir}-1/f O_c &
1360 #define OBD_FAIL_MDS_REINT_NET_REP 0x119
1361 do_facet $SINGLEMDS "lctl set_param fail_loc=0x119"
1362 mcreate $DIR/${tdir}-2/f &
1366 #define OBD_FAIL_MDS_CLOSE_NET_REP 0x13b
1367 do_facet $SINGLEMDS "lctl set_param fail_loc=0x8000013b"
1368 kill -USR1 $close_pid
1369 cancel_lru_locks mdc # force the close
1371 #bz20647: make sure all pids are exists before failover
1372 [ -d /proc/$close_pid ] || error "close_pid doesn't exist"
1373 [ -d /proc/$open_pid ] || error "open_pid doesn't exists"
1374 replay_barrier_nodf $SINGLEMDS
1375 fail_nodf $SINGLEMDS
1376 wait $open_pid || error "open_pid failed"
1378 # close should be gone
1379 [ -d /proc/$close_pid ] && error "close_pid should not exist"
1380 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
1382 $CHECKSTAT -t file $DIR/${tdir}-1/f ||
1383 error "$CHECKSTAT $DIR/${tdir}-1/f attribute check failed"
1384 $CHECKSTAT -t file $DIR/${tdir}-2/f ||
1385 error "$CHECKSTAT $DIR/${tdir}-2/f attribute check failed"
1386 rm -rf $DIR/${tdir}-*
1388 run_test 53f "|X| open reply and close reply while two MDC requests in flight"
1391 cancel_lru_locks mdc # cleanup locks from former test cases
1393 mkdir_on_mdt0 $DIR/${tdir}-1 || error "mkdir $DIR/${tdir}-1 failed"
1394 mkdir_on_mdt0 $DIR/${tdir}-2 || error "mkdir $DIR/${tdir}-2 failed"
1395 multiop $DIR/${tdir}-1/f O_c &
1398 #define OBD_FAIL_MDS_REINT_NET_REP 0x119
1399 do_facet $SINGLEMDS "lctl set_param fail_loc=0x119"
1400 mcreate $DIR/${tdir}-2/f &
1404 #define OBD_FAIL_MDS_CLOSE_NET 0x115
1405 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000115"
1406 kill -USR1 $close_pid
1407 cancel_lru_locks mdc # force the close
1408 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
1410 #bz20647: make sure all pids are exists before failover
1411 [ -d /proc/$close_pid ] || error "close_pid doesn't exist"
1412 [ -d /proc/$open_pid ] || error "open_pid doesn't exists"
1413 replay_barrier_nodf $SINGLEMDS
1414 fail_nodf $SINGLEMDS
1415 wait $open_pid || error "open_pid failed"
1417 # close should be gone
1418 [ -d /proc/$close_pid ] && error "close_pid should not exist"
1420 $CHECKSTAT -t file $DIR/${tdir}-1/f ||
1421 error "$CHECKSTAT $DIR/${tdir}-1/f attribute check failed"
1422 $CHECKSTAT -t file $DIR/${tdir}-2/f ||
1423 error "$CHECKSTAT $DIR/${tdir}-2/f attribute check failed"
1424 rm -rf $DIR/${tdir}-*
1426 run_test 53g "|X| drop open reply and close request while close and open are both in flight"
1429 cancel_lru_locks mdc # cleanup locks from former test cases
1431 mkdir_on_mdt0 $DIR/${tdir}-1 || error "mkdir $DIR/${tdir}-1 failed"
1432 mkdir_on_mdt0 $DIR/${tdir}-2 || error "mkdir $DIR/${tdir}-2 failed"
1433 multiop $DIR/${tdir}-1/f O_c &
1436 #define OBD_FAIL_MDS_REINT_NET 0x107
1437 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000107"
1438 mcreate $DIR/${tdir}-2/f &
1442 #define OBD_FAIL_MDS_CLOSE_NET_REP 0x13b
1443 do_facet $SINGLEMDS "lctl set_param fail_loc=0x8000013b"
1444 kill -USR1 $close_pid
1445 cancel_lru_locks mdc # force the close
1448 #bz20647: make sure all pids are exists before failover
1449 [ -d /proc/$close_pid ] || error "close_pid doesn't exist"
1450 [ -d /proc/$open_pid ] || error "open_pid doesn't exists"
1451 replay_barrier_nodf $SINGLEMDS
1452 fail_nodf $SINGLEMDS
1453 wait $open_pid || error "open_pid failed"
1455 # close should be gone
1456 [ -d /proc/$close_pid ] && error "close_pid should not exist"
1457 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
1459 $CHECKSTAT -t file $DIR/${tdir}-1/f ||
1460 error "$CHECKSTAT $DIR/${tdir}-1/f attribute check failed"
1461 $CHECKSTAT -t file $DIR/${tdir}-2/f ||
1462 error "$CHECKSTAT $DIR/${tdir}-2/f attribute check failed"
1463 rm -rf $DIR/${tdir}-*
1465 run_test 53h "open request and close reply while two MDC requests in flight"
1467 #b3761 ASSERTION(hash != 0) failed
1469 # OBD_FAIL_MDS_OPEN_CREATE | CFS_FAIL_ONCE
1470 do_facet $SINGLEMDS "lctl set_param fail_loc=0x8000012b"
1472 # give touch a chance to run
1474 do_facet $SINGLEMDS "lctl set_param fail_loc=0x0"
1478 run_test 55 "let MDS_CHECK_RESENT return the original return code instead of 0"
1480 #b3440 ASSERTION(rec->ur_fid2->id) failed
1482 ln -s foo $DIR/$tfile
1483 replay_barrier $SINGLEMDS
1484 #drop_reply "cat $DIR/$tfile"
1488 run_test 56 "don't replay a symlink open request (3440)"
1490 #recovery one mds-ost setattr from llog
1492 #define OBD_FAIL_MDS_OST_SETATTR 0x12c
1493 do_facet $SINGLEMDS "lctl set_param fail_loc=0x8000012c"
1494 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
1495 replay_barrier $SINGLEMDS
1497 wait_recovery_complete $SINGLEMDS || error "MDS recovery is not done"
1498 wait_mds_ost_sync || error "wait_mds_ost_sync failed"
1499 $CHECKSTAT -t file $DIR/$tfile ||
1500 error "$CHECKSTAT $DIR/$tfile attribute check failed"
1501 do_facet $SINGLEMDS "lctl set_param fail_loc=0x0"
1504 run_test 57 "test recovery from llog for setattr op"
1507 zconf_umount $(hostname) $MOUNT2
1511 #recovery many mds-ost setattr from llog
1513 mkdir_on_mdt0 $DIR/$tdir || error "mkdir $DIR/$tdir failed"
1514 #define OBD_FAIL_MDS_OST_SETATTR 0x12c
1515 do_facet $SINGLEMDS "lctl set_param fail_loc=0x8000012c"
1516 createmany -o $DIR/$tdir/$tfile-%d 2500
1517 replay_barrier $SINGLEMDS
1520 $CHECKSTAT -t file $DIR/$tdir/$tfile-* >/dev/null ||
1521 error "$CHECKSTAT $DIR/$tfile-* attribute check failed"
1522 do_facet $SINGLEMDS "lctl set_param fail_loc=0x0"
1523 unlinkmany $DIR/$tdir/$tfile-%d 2500 ||
1524 error "unlinkmany $DIR/$tfile failed"
1527 run_test 58a "test recovery from llog for setattr op (test llog_gen_rec)"
1533 trap cleanup_58 EXIT
1535 large_xattr_enabled &&
1536 orig="$(generate_string $(max_xattr_size))" || orig="bar"
1537 # Original extended attribute can be long. Print a small version of
1538 # attribute if an error occurs
1539 local sm_msg=$(printf "%.9s" $orig)
1541 mount_client $MOUNT2 || error "mount_client on $MOUNT2 failed"
1542 mkdir_on_mdt0 $DIR/$tdir || error "mkdir $DIR/$tdir failed"
1543 touch $DIR/$tdir/$tfile || error "touch $DIR/$tdir/$tfile failed"
1544 replay_barrier $SINGLEMDS
1545 setfattr -n trusted.foo -v $orig $DIR/$tdir/$tfile
1547 new=$(get_xattr_value trusted.foo $MOUNT2/$tdir/$tfile)
1548 [[ "$new" = "$orig" ]] ||
1549 error "xattr set ($sm_msg...) differs from xattr get ($new)"
1550 rm -f $DIR/$tdir/$tfile
1553 wait_clients_import_state ${CLIENTS:-$HOSTNAME} "mgs" FULL
1555 run_test 58b "test replay of setxattr op"
1557 test_58c() { # bug 16570
1562 trap cleanup_58 EXIT
1564 if large_xattr_enabled; then
1565 local xattr_size=$(max_xattr_size)
1566 orig="$(generate_string $((xattr_size / 2)))"
1567 orig1="$(generate_string $xattr_size)"
1573 # PING_INTERVAL max(obd_timeout / 4, 1U)
1574 sleep $((TIMEOUT / 4))
1576 # Original extended attribute can be long. Print a small version of
1577 # attribute if an error occurs
1578 local sm_msg=$(printf "%.9s" $orig)
1579 local sm_msg1=$(printf "%.9s" $orig1)
1581 mount_client $MOUNT2 || error "mount_client on $MOUNT2 failed"
1582 mkdir_on_mdt0 $DIR/$tdir || error "mkdir $DIR/$tdir failed"
1583 touch $DIR/$tdir/$tfile || error "touch $DIR/$tdir/$tfile failed"
1584 drop_request "setfattr -n trusted.foo -v $orig $DIR/$tdir/$tfile" ||
1585 error "drop_request for setfattr failed"
1586 new=$(get_xattr_value trusted.foo $MOUNT2/$tdir/$tfile)
1587 [[ "$new" = "$orig" ]] ||
1588 error "xattr set ($sm_msg...) differs from xattr get ($new)"
1589 drop_reint_reply "setfattr -n trusted.foo1 \
1590 -v $orig1 $DIR/$tdir/$tfile" ||
1591 error "drop_reint_reply for setfattr failed"
1592 new=$(get_xattr_value trusted.foo1 $MOUNT2/$tdir/$tfile)
1593 [[ "$new" = "$orig1" ]] ||
1594 error "second xattr set ($sm_msg1...) differs xattr get ($new)"
1595 rm -f $DIR/$tdir/$tfile
1599 run_test 58c "resend/reconstruct setxattr op"
1601 # log_commit_thread vs filter_destroy race used to lead to import use after free
1604 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1606 mkdir_on_mdt0 $DIR/$tdir || error "mkdir $DIR/$tdir failed"
1607 createmany -o $DIR/$tdir/$tfile-%d 200 ||
1608 error "createmany create files failed"
1610 unlinkmany $DIR/$tdir/$tfile-%d 200 ||
1611 error "unlinkmany $DIR/$tdir/$tfile failed"
1612 #define OBD_FAIL_PTLRPC_DELAY_RECOV 0x507
1613 do_facet ost1 "lctl set_param fail_loc=0x507"
1616 do_facet ost1 "lctl set_param fail_loc=0x0"
1620 run_test 59 "test log_commit_thread vs filter_destroy race"
1622 # race between add unlink llog vs cat log init in post_recovery (only for b1_6)
1623 # bug 12086: should no oops and No ctxt error for this test
1625 mkdir_on_mdt0 $DIR/$tdir || error "mkdir $DIR/$tdir failed"
1626 createmany -o $DIR/$tdir/$tfile-%d 200 ||
1627 error "createmany create files failed"
1628 replay_barrier $SINGLEMDS
1629 unlinkmany $DIR/$tdir/$tfile-%d 0 100
1631 unlinkmany $DIR/$tdir/$tfile-%d 100 100
1632 local no_ctxt=$(dmesg | grep "No ctxt")
1633 [ -z "$no_ctxt" ] || error "ctxt is not initialized in recovery"
1635 run_test 60 "test llog post recovery init vs llog unlink"
1637 #test race llog recovery thread vs llog cleanup
1638 test_61a() { # was test_61
1639 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1641 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
1642 createmany -o $DIR/$tdir/$tfile-%d 800 ||
1643 error "createmany create files failed"
1645 unlinkmany $DIR/$tdir/$tfile-%d 800
1646 # OBD_FAIL_OST_LLOG_RECOVERY_TIMEOUT 0x221
1647 set_nodes_failloc "$(osts_nodes)" 0x80000221
1652 set_nodes_failloc "$(osts_nodes)" 0x0
1654 $CHECKSTAT -t file $DIR/$tdir/$tfile-* &&
1655 error "$CHECKSTAT $DIR/$tdir/$tfile attribute check should fail"
1658 run_test 61a "test race llog recovery vs llog cleanup"
1660 #test race mds llog sync vs llog cleanup
1662 # OBD_FAIL_MDS_LLOG_SYNC_TIMEOUT 0x13a
1663 do_facet $SINGLEMDS "lctl set_param fail_loc=0x8000013a"
1664 facet_failover $SINGLEMDS
1667 do_facet client dd if=/dev/zero of=$DIR/$tfile bs=4k count=1 ||
1670 run_test 61b "test race mds llog sync vs llog cleanup"
1672 #test race cancel cookie cb vs llog cleanup
1674 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1676 # OBD_FAIL_OST_CANCEL_COOKIE_TIMEOUT 0x222
1677 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
1678 set_nodes_failloc "$(osts_nodes)" 0x80000222
1682 set_nodes_failloc "$(osts_nodes)" 0x0
1684 run_test 61c "test race mds llog sync vs llog cleanup"
1686 test_61d() { # bug 16002 # bug 17466 # bug 22137
1687 # OBD_FAIL_OBD_LLOG_SETUP 0x605
1689 do_facet mgs "lctl set_param fail_loc=0x80000605"
1690 start mgs $(mgsdevname) $MGS_MOUNT_OPTS &&
1691 error "mgs start should have failed"
1692 do_facet mgs "lctl set_param fail_loc=0"
1693 start mgs $(mgsdevname) $MGS_MOUNT_OPTS || error "cannot restart mgs"
1695 run_test 61d "error in llog_setup should cleanup the llog context correctly"
1697 test_62() { # Bug 15756 - don't mis-drop resent replay
1698 mkdir_on_mdt0 $DIR/$tdir || error "mkdir $DIR/$tdir failed"
1699 replay_barrier $SINGLEMDS
1700 createmany -o $DIR/$tdir/$tfile- 25 ||
1701 error "createmany create files failed"
1702 #define OBD_FAIL_TGT_REPLAY_DROP 0x707
1703 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000707"
1705 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
1706 unlinkmany $DIR/$tdir/$tfile- 25 ||
1707 error "unlinkmany $DIR/$tdir/$tfile failed"
1710 run_test 62 "don't mis-drop resent replay"
1712 #Adaptive Timeouts (bug 3055)
1720 echo "Cleaning up AT ..."
1721 if [ -n "$ATOLDBASE" ]; then
1722 local at_history=$($LCTL get_param -n at_history)
1723 do_facet $SINGLEMDS "lctl set_param at_history=$at_history" || true
1724 do_facet ost1 "lctl set_param at_history=$at_history" || true
1727 if [ $AT_MAX_SET -ne 0 ]; then
1728 for facet in mds client ost; do
1729 var=AT_MAX_SAVE_${facet}
1730 echo restore AT on $facet to saved value ${!var}
1731 at_max_set ${!var} $facet
1732 at_new=$(at_max_get $facet)
1733 echo Restored AT value on $facet $at_new
1734 [ $at_new -eq ${!var} ] ||
1735 error "AT value not restored SAVED ${!var} NEW $at_new"
1742 local at_max_new=600
1744 # Save at_max original values
1746 if [ $AT_MAX_SET -eq 0 ]; then
1747 # Suppose that all osts have the same at_max
1748 for facet in mds client ost; do
1749 eval AT_MAX_SAVE_${facet}=$(at_max_get $facet)
1753 for facet in mds client ost; do
1754 at_max=$(at_max_get $facet)
1755 if [ $at_max -ne $at_max_new ]; then
1756 echo "AT value on $facet is $at_max, set it by force temporarily to $at_max_new"
1757 at_max_set $at_max_new $facet
1762 if [ -z "$ATOLDBASE" ]; then
1763 ATOLDBASE=$(do_facet $SINGLEMDS "lctl get_param -n at_history")
1764 # speed up the timebase so we can check decreasing AT
1765 do_facet $SINGLEMDS "lctl set_param at_history=8" || true
1766 do_facet ost1 "lctl set_param at_history=8" || true
1768 # sleep for a while to cool down, should be > 8s and also allow
1769 # at least one ping to be sent. simply use TIMEOUT to be safe.
1774 test_65a() #bug 3055
1776 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1778 at_start || return 0
1779 $LCTL dk > /dev/null
1781 $LCTL set_param debug="other"
1782 # Slow down a request to the current service time, this is critical
1783 # because previous tests may have caused this value to increase.
1784 REQ_DELAY=`lctl get_param -n mdc.${FSNAME}-MDT0000-mdc-*.timeouts |
1785 awk '/portal 12/ {print $5}'`
1786 REQ_DELAY=$((${REQ_DELAY} + ${REQ_DELAY} / 4 + 5))
1788 do_facet $SINGLEMDS lctl set_param fail_val=$((${REQ_DELAY} * 1000))
1789 #define OBD_FAIL_PTLRPC_PAUSE_REQ 0x50a
1790 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x8000050a
1791 createmany -o $DIR/$tfile 10 > /dev/null
1792 unlinkmany $DIR/$tfile 10 > /dev/null
1793 # check for log message
1794 $LCTL dk | grep -i "Early reply #" || error "No early reply"
1796 # client should show REQ_DELAY estimates
1797 lctl get_param -n mdc.${FSNAME}-MDT0000-mdc-*.timeouts | grep portal
1799 lctl get_param -n mdc.${FSNAME}-MDT0000-mdc-*.timeouts | grep portal
1801 run_test 65a "AT: verify early replies"
1803 test_65b() #bug 3055
1805 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1807 at_start || return 0
1810 $LCTL set_param debug="other trace"
1811 $LCTL dk > /dev/null
1812 # Slow down a request to the current service time, this is critical
1813 # because previous tests may have caused this value to increase.
1814 $LFS setstripe --stripe-index=0 --stripe-count=1 $DIR/$tfile ||
1815 error "$LFS setstripe failed for $DIR/$tfile"
1817 multiop $DIR/$tfile Ow1yc
1818 REQ_DELAY=`lctl get_param -n osc.${FSNAME}-OST0000-osc-*.timeouts |
1819 awk '/portal 6/ {print $5}'`
1820 REQ_DELAY=$((${REQ_DELAY} + ${REQ_DELAY} / 4 + 5))
1822 do_facet ost1 lctl set_param fail_val=${REQ_DELAY}
1823 #define OBD_FAIL_OST_BRW_PAUSE_PACK 0x224
1824 do_facet ost1 $LCTL set_param fail_loc=0x224
1827 $LFS setstripe --stripe-index=0 --stripe-count=1 $DIR/$tfile ||
1828 error "$LFS setstripe failed"
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 -i "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 touch $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 osp.$mdtosc.prealloc_last_id)
1927 local next_id=$(do_facet $SINGLEMDS lctl get_param -n \
1928 osp.$mdtosc.prealloc_next_id)
1930 mkdir -p $DIR/$tdir/${OST} || error "mkdir $DIR/$tdir/${OST} failed"
1931 $LFS setstripe -i 0 -c 1 $DIR/$tdir/${OST} ||
1932 error "$LFS setstripe failed"
1933 echo "Creating to objid $last_id on ost $OST..."
1934 #define OBD_FAIL_OST_PAUSE_CREATE 0x223
1935 do_facet ost1 "$LCTL set_param fail_val=20000"
1936 do_facet ost1 "$LCTL set_param fail_loc=0x80000223"
1937 createmany -o $DIR/$tdir/${OST}/f $next_id $((last_id - next_id + 2))
1940 do_facet ost1 "lctl get_param -n ost.OSS.ost_create.timeouts"
1942 CONN2=$(lctl get_param -n osc.*.stats | awk '/_connect/ {total+=$2} END {print total}')
1943 ATTEMPTS=$(($CONN2 - $CONN1))
1944 echo "$ATTEMPTS osc reconnect attempts on instant slow"
1945 # do it again; should not timeout
1946 do_facet ost1 "$LCTL set_param fail_loc=0x80000223"
1947 cp /etc/profile $DIR/$tfile || error "cp failed"
1948 do_facet ost1 "$LCTL set_param fail_loc=0"
1950 do_facet ost1 "lctl get_param -n ost.OSS.ost_create.timeouts"
1951 CONN3=$(lctl get_param -n osc.*.stats | awk '/_connect/ {total+=$2} END {print total}')
1952 ATTEMPTS=$(($CONN3 - $CONN2))
1953 echo "$ATTEMPTS osc reconnect attempts on 2nd slow"
1954 [ $ATTEMPTS -gt 0 ] && error "AT should have prevented reconnect"
1957 run_test 67b "AT: verify instant slowdown doesn't induce reconnects"
1959 test_68 () #bug 13813
1961 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1963 at_start || return 0
1964 local ldlm_enqueue_min=$(find /sys -name ldlm_enqueue_min)
1965 [ -z "$ldlm_enqueue_min" ] && skip "missing /sys/.../ldlm_enqueue_min" && return 0
1966 local ldlm_enqueue_min_r=$(do_facet ost1 "find /sys -name ldlm_enqueue_min")
1967 [ -z "$ldlm_enqueue_min_r" ] && skip "missing /sys/.../ldlm_enqueue_min in the ost1" && return 0
1968 local ENQ_MIN=$(cat $ldlm_enqueue_min)
1969 local ENQ_MIN_R=$(do_facet ost1 "cat $ldlm_enqueue_min_r")
1970 echo $TIMEOUT >> $ldlm_enqueue_min
1971 do_facet ost1 "echo $TIMEOUT >> $ldlm_enqueue_min_r"
1973 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
1974 $LFS setstripe --stripe-index=0 -c 1 $DIR/$tdir ||
1975 error "$LFS setstripe failed for $DIR/$tdir"
1976 #define OBD_FAIL_LDLM_PAUSE_CANCEL 0x312
1977 $LCTL set_param fail_val=$(($TIMEOUT - 1))
1978 $LCTL set_param fail_loc=0x80000312
1979 cp /etc/profile $DIR/$tdir/${tfile}_1 || error "1st cp failed $?"
1980 $LCTL set_param fail_val=$((TIMEOUT * 5 / 4))
1981 $LCTL set_param fail_loc=0x80000312
1982 cp /etc/profile $DIR/$tdir/${tfile}_2 || error "2nd cp failed $?"
1983 $LCTL set_param fail_loc=0
1985 echo $ENQ_MIN >> $ldlm_enqueue_min
1986 do_facet ost1 "echo $ENQ_MIN_R >> $ldlm_enqueue_min_r"
1990 run_test 68 "AT: verify slowing locks"
1993 # end of AT tests includes above lines
1995 # start multi-client tests
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
2032 local clients=${CLIENTS:-$HOSTNAME}
2034 zconf_mount_clients $clients $MOUNT
2037 [ "$SLOW" = "no" ] && duration=120
2038 # set duration to 900 because it takes some time to boot node
2039 [ "$FAILURE_MODE" = HARD ] && duration=900
2042 local start_ts=$(date +%s)
2043 local cmd="rundbench 1 -t $duration"
2045 if [ $MDSCOUNT -ge 2 ]; then
2046 test_mkdir -p -c$MDSCOUNT $DIR/$tdir
2047 $LFS setdirstripe -D -c$MDSCOUNT $DIR/$tdir
2049 do_nodesv $clients "set -x; MISSING_DBENCH_OK=$MISSING_DBENCH_OK \
2050 PATH=\$PATH:$LUSTRE/utils:$LUSTRE/tests/:$DBENCH_LIB \
2051 DBENCH_LIB=$DBENCH_LIB TESTSUITE=$TESTSUITE TESTNAME=$TESTNAME \
2052 MOUNT=$MOUNT DIR=$DIR/$tdir/\\\$(hostname) LCTL=$LCTL $cmd" &
2055 #LU-1897 wait for all dbench copies to start
2056 while ! check_for_process $clients dbench; do
2057 elapsed=$(($(date +%s) - start_ts))
2058 if [ $elapsed -gt $duration ]; then
2059 killall_process $clients dbench
2060 error "dbench failed to start on $clients!"
2065 log "Started rundbench load pid=$pid ..."
2067 elapsed=$(($(date +%s) - start_ts))
2068 local num_failovers=0
2070 while [ $elapsed -lt $duration ]; do
2071 if ! check_for_process $clients dbench; then
2072 error_noexit "dbench stopped on some of $clients!"
2073 killall_process $clients dbench
2077 replay_barrier mds$fail_index
2078 sleep 1 # give clients a time to do operations
2079 # Increment the number of failovers
2080 num_failovers=$((num_failovers+1))
2081 log "$TESTNAME fail mds$fail_index $num_failovers times"
2083 elapsed=$(($(date +%s) - start_ts))
2084 if [ $fail_index -ge $MDSCOUNT ]; then
2087 fail_index=$((fail_index+1))
2091 wait $pid || error "rundbench load on $clients failed!"
2093 run_test 70b "dbench ${MDSCOUNT}mdts recovery; $CLIENTCOUNT clients"
2094 # end multi-client tests
2099 local monitor_pid=$3
2101 local start_ts=$(date +%s)
2102 local num_failovers=0
2105 elapsed=$(($(date +%s) - start_ts))
2106 while [ $elapsed -lt $duration ]; do
2107 fail_index=$((RANDOM%max_index+1))
2108 kill -0 $monitor_pid ||
2109 error "$monitor_pid stopped"
2111 replay_barrier mds$fail_index
2113 # Increment the number of failovers
2114 num_failovers=$((num_failovers+1))
2115 log "$TESTNAME fail mds$fail_index $num_failovers times"
2117 elapsed=$(($(date +%s) - start_ts))
2123 rm -f $DIR/replay-single.70c.lck
2128 local clients=${CLIENTS:-$HOSTNAME}
2131 zconf_mount_clients $clients $MOUNT
2134 [ "$SLOW" = "no" ] && duration=180
2135 # set duration to 900 because it takes some time to boot node
2136 [ "$FAILURE_MODE" = HARD ] && duration=600
2139 local start_ts=$(date +%s)
2141 stack_trap cleanup_70c EXIT
2143 while [ ! -e $DIR/replay-single.70c.lck ]; do
2144 test_mkdir -p -c$MDSCOUNT $DIR/$tdir || break
2145 if [ $MDSCOUNT -ge 2 ]; then
2146 $LFS setdirstripe -D -c$MDSCOUNT $DIR/$tdir ||
2147 error "set default dirstripe failed"
2149 cd $DIR/$tdir || break
2150 tar cf - /etc | tar xf - || error "tar failed in loop"
2154 echo "Started tar $tar_70c_pid"
2156 random_fail_mdt $MDSCOUNT $duration $tar_70c_pid
2157 kill -0 $tar_70c_pid || error "tar $tar_70c_pid stopped"
2159 touch $DIR/replay-single.70c.lck
2160 wait $tar_70c_pid || error "$?: tar failed"
2165 run_test 70c "tar ${MDSCOUNT}mdts recovery"
2169 kill -9 $mkdir_70d_pid
2173 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2174 local clients=${CLIENTS:-$HOSTNAME}
2177 zconf_mount_clients $clients $MOUNT
2180 [ "$SLOW" = "no" ] && duration=180
2181 # set duration to 900 because it takes some time to boot node
2182 [ "$FAILURE_MODE" = HARD ] && duration=900
2187 local start_ts=$(date +%s)
2189 trap cleanup_70d EXIT
2192 $LFS mkdir -i0 -c2 $DIR/$tdir/test || {
2196 $LFS mkdir -i1 -c2 $DIR/$tdir/test1 || {
2201 touch $DIR/$tdir/test/a || {
2205 mkdir $DIR/$tdir/test/b || {
2209 rm -rf $DIR/$tdir/test || {
2215 touch $DIR/$tdir/test1/a || {
2219 mkdir $DIR/$tdir/test1/b || {
2224 rm -rf $DIR/$tdir/test1 || {
2226 ls -lR $DIR/$tdir/test1
2232 echo "Started $mkdir_70d_pid"
2234 random_fail_mdt $MDSCOUNT $duration $mkdir_70d_pid
2235 kill -0 $mkdir_70d_pid || error "mkdir/rmdir $mkdir_70d_pid stopped"
2240 run_test 70d "mkdir/rmdir striped dir ${MDSCOUNT}mdts recovery"
2243 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2244 local clients=${CLIENTS:-$HOSTNAME}
2247 lctl set_param debug=+ha
2248 zconf_mount_clients $clients $MOUNT
2251 [ "$SLOW" = "no" ] && duration=180
2252 # set duration to 900 because it takes some time to boot node
2253 [ "$FAILURE_MODE" = HARD ] && duration=900
2256 $LFS mkdir -i0 $DIR/$tdir/test_0
2257 $LFS mkdir -i0 $DIR/$tdir/test_1
2258 touch $DIR/$tdir/test_0/a
2259 touch $DIR/$tdir/test_1/b
2262 mrename $DIR/$tdir/test_0/a $DIR/$tdir/test_1/b > /dev/null || {
2267 checkstat $DIR/$tdir/test_0/a && {
2268 echo "a still exists"
2272 checkstat $DIR/$tdir/test_1/b || {
2273 echo "b still exists"
2277 touch $DIR/$tdir/test_0/a || {
2278 echo "touch a fails"
2282 mrename $DIR/$tdir/test_1/b $DIR/$tdir/test_0/a > /dev/null || {
2289 stack_trap "kill -9 $rename_70e_pid" EXIT
2290 echo "Started PID=$rename_70e_pid"
2292 random_fail_mdt 2 $duration $rename_70e_pid
2293 kill -0 $rename_70e_pid || error "rename $rename_70e_pid stopped"
2295 run_test 70e "rename cross-MDT with random fails"
2297 test_70f_write_and_read(){
2302 echo "Write/read files in: '$DIR/$tdir', clients: '$CLIENTS' ..."
2303 for client in ${CLIENTS//,/ }; do
2304 [ -f $stopflag ] || return
2306 local tgtfile=$DIR/$tdir/$tfile.$client
2307 do_node $client dd $DD_OPTS bs=1M count=10 if=$srcfile \
2308 of=$tgtfile 2>/dev/null ||
2309 error "dd $DD_OPTS bs=1M count=10 if=$srcfile " \
2310 "of=$tgtfile failed on $client, rc=$?"
2313 local prev_client=$(echo ${CLIENTS//,/ } | awk '{ print $NF }')
2316 for client in ${CLIENTS//,/ }; do
2317 [ -f $stopflag ] || return
2319 # flush client cache in case test is running on only one client
2320 # do_node $client cancel_lru_locks osc
2321 do_node $client $LCTL set_param ldlm.namespaces.*.lru_size=clear
2323 tgtfile=$DIR/$tdir/$tfile.$client
2324 local md5=$(do_node $prev_client "md5sum $tgtfile")
2325 [ ${checksum[$index]// */} = ${md5// */} ] ||
2326 error "$tgtfile: checksum doesn't match on $prev_client"
2327 index=$((index + 1))
2337 mkdir -p $DIR/$tdir || error "cannot create $DIR/$tdir directory"
2338 $LFS setstripe -c -1 $DIR/$tdir ||
2339 error "cannot $LFS setstripe $DIR/$tdir"
2342 while [ -f $stopflag ]; do
2343 test_70f_write_and_read $srcfile $stopflag
2344 # use direct IO and buffer cache in turns if loop
2345 [ -n "$DD_OPTS" ] && DD_OPTS="" || DD_OPTS="oflag=direct"
2349 test_70f_cleanup() {
2351 rm -f $TMP/$tfile.stop
2352 do_nodes $CLIENTS rm -f $TMP/$tfile
2353 rm -f $DIR/$tdir/$tfile.*
2357 # [ x$ost1failover_HOST = x$ost_HOST ] &&
2358 # { skip "Failover host not defined" && return; }
2359 # [ $CLIENTCOUNT -lt 2 ] &&
2360 # { skip "Need 2 or more clients, have $CLIENTCOUNT" && return; }
2362 [[ "$OST1_VERSION" -lt $(version_code 2.9.53) ]] &&
2363 skip "Need server version at least 2.9.53"
2365 echo "mount clients $CLIENTS ..."
2366 zconf_mount_clients $CLIENTS $MOUNT
2368 local srcfile=$TMP/$tfile
2372 trap test_70f_cleanup EXIT
2373 # create a different source file local to each client node so we can
2374 # detect if the file wasn't written out properly after failover
2375 do_nodes $CLIENTS dd bs=1M count=10 if=/dev/urandom of=$srcfile \
2376 2>/dev/null || error "can't create $srcfile on $CLIENTS"
2377 for client in ${CLIENTS//,/ }; do
2378 checksum[$index]=$(do_node $client "md5sum $srcfile")
2379 index=$((index + 1))
2383 [ "$SLOW" = "no" ] && duration=60
2384 # set duration to 900 because it takes some time to boot node
2385 [ "$FAILURE_MODE" = HARD ] && duration=900
2387 local stopflag=$TMP/$tfile.stop
2388 test_70f_loop $srcfile $stopflag &
2392 local num_failovers=0
2393 local start_ts=$SECONDS
2394 while [ $elapsed -lt $duration ]; do
2398 num_failovers=$((num_failovers + 1))
2399 log "$TESTNAME failing OST $num_failovers times"
2402 elapsed=$((SECONDS - start_ts))
2409 run_test 70f "OSS O_DIRECT recovery with $CLIENTCOUNT clients"
2413 kill -9 $mkdir_71a_pid
2416 random_double_fail_mdt() {
2419 local monitor_pid=$3
2421 local start_ts=$(date +%s)
2422 local num_failovers=0
2426 elapsed=$(($(date +%s) - start_ts))
2427 while [ $elapsed -lt $duration ]; do
2428 fail_index=$((RANDOM%max_index + 1))
2429 if [ $fail_index -eq $max_index ]; then
2432 second_index=$((fail_index + 1))
2434 kill -0 $monitor_pid ||
2435 error "$monitor_pid stopped"
2437 replay_barrier mds$fail_index
2438 replay_barrier mds$second_index
2440 # Increment the number of failovers
2441 num_failovers=$((num_failovers+1))
2442 log "fail mds$fail_index mds$second_index $num_failovers times"
2443 fail mds${fail_index},mds${second_index}
2444 elapsed=$(($(date +%s) - start_ts))
2449 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2450 local clients=${CLIENTS:-$HOSTNAME}
2453 zconf_mount_clients $clients $MOUNT
2456 [ "$SLOW" = "no" ] && duration=180
2457 # set duration to 900 because it takes some time to boot node
2458 [ "$FAILURE_MODE" = HARD ] && duration=900
2460 mkdir_on_mdt0 $DIR/$tdir
2463 local start_ts=$(date +%s)
2465 trap cleanup_71a EXIT
2468 $LFS mkdir -i0 -c2 $DIR/$tdir/test
2469 rmdir $DIR/$tdir/test
2473 echo "Started $mkdir_71a_pid"
2475 random_double_fail_mdt 2 $duration $mkdir_71a_pid
2476 kill -0 $mkdir_71a_pid || error "mkdir/rmdir $mkdir_71a_pid stopped"
2481 run_test 71a "mkdir/rmdir striped dir with 2 mdts recovery"
2484 multiop_bg_pause $DIR/$tfile O_tSc ||
2485 error "multiop_bg_pause $DIR/$tfile failed"
2489 replay_barrier $SINGLEMDS
2490 #define OBD_FAIL_LDLM_ENQUEUE_NET 0x302
2491 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000302"
2494 wait $pid || error "multiop pid failed"
2495 [ -e $DIR/$tfile ] && error "file $DIR/$tfile should not exist"
2498 run_test 73a "open(O_CREAT), unlink, replay, reconnect before open replay, close"
2501 multiop_bg_pause $DIR/$tfile O_tSc ||
2502 error "multiop_bg_pause $DIR/$tfile failed"
2506 replay_barrier $SINGLEMDS
2507 #define OBD_FAIL_MDS_LDLM_REPLY_NET 0x157
2508 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000157"
2511 wait $pid || error "multiop pid failed"
2512 [ -e $DIR/$tfile ] && error "file $DIR/$tfile should not exist"
2515 run_test 73b "open(O_CREAT), unlink, replay, reconnect at open_replay reply, close"
2519 local clients=${CLIENTS:-$HOSTNAME}
2521 zconf_umount_clients $clients $MOUNT
2523 facet_failover $SINGLEMDS
2524 zconf_mount_clients $clients $MOUNT
2526 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
2527 rm $DIR/$tfile || error "rm $DIR/$tfile failed"
2528 clients_up || error "client evicted: $?"
2531 run_test 74 "Ensure applications don't fail waiting for OST recovery"
2533 remote_dir_check_80() {
2538 diridx=$($LFS getstripe -m $remote_dir) ||
2539 error "$LFS getstripe -m $remote_dir failed"
2540 [ $diridx -eq $mdtidx ] || error "$diridx != $mdtidx"
2542 createmany -o $remote_dir/f-%d 20 || error "creation failed"
2543 fileidx=$($LFS getstripe -m $remote_dir/f-1) ||
2544 error "$LFS getstripe -m $remote_dir/f-1 failed"
2545 [ $fileidx -eq $mdtidx ] || error "$fileidx != $mdtidx"
2551 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2552 ([ $FAILURE_MODE == "HARD" ] &&
2553 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
2554 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
2558 local remote_dir=$DIR/$tdir/remote_dir
2560 mkdir_on_mdt0 $DIR/$tdir || error "mkdir $DIR/$tdir failed"
2561 #define OBD_FAIL_OUT_UPDATE_NET_REP 0x1701
2562 do_facet mds${MDTIDX} lctl set_param fail_loc=0x1701
2563 $LFS mkdir -i $MDTIDX $remote_dir &
2569 wait $CLIENT_PID || error "remote creation failed"
2571 remote_dir_check_80 || error "remote dir check failed"
2572 rm -rf $DIR/$tdir || error "rmdir failed"
2576 run_test 80a "DNE: create remote dir, drop update rep from MDT0, fail MDT0"
2579 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2580 ([ $FAILURE_MODE == "HARD" ] &&
2581 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
2582 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
2586 local remote_dir=$DIR/$tdir/remote_dir
2588 mkdir_on_mdt0 $DIR/$tdir || error "mkdir $DIR/$tdir failed"
2589 #define OBD_FAIL_OUT_UPDATE_NET_REP 0x1701
2590 do_facet mds${MDTIDX} lctl set_param fail_loc=0x1701
2591 $LFS mkdir -i $MDTIDX $remote_dir &
2596 fail mds$((MDTIDX + 1))
2598 wait $CLIENT_PID || error "remote creation failed"
2600 remote_dir_check_80 || error "remote dir check failed"
2601 rm -rf $DIR/$tdir || error "rmdir failed"
2605 run_test 80b "DNE: create remote dir, drop update rep from MDT0, fail MDT1"
2608 [[ "$mds1_FSTYPE" = zfs ]] &&
2609 [[ $MDS1_VERSION -lt $(version_code 2.12.51) ]] &&
2610 skip "requires LU-10143 fix on MDS"
2611 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
2612 ([ $FAILURE_MODE == "HARD" ] &&
2613 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
2614 skip "MDTs needs to be on diff hosts for HARD fail mode"
2617 local remote_dir=$DIR/$tdir/remote_dir
2619 mkdir_on_mdt0 $DIR/$tdir || error "mkdir $DIR/$tdir failed"
2620 #define OBD_FAIL_OUT_UPDATE_NET_REP 0x1701
2621 do_facet mds${MDTIDX} lctl set_param fail_loc=0x1701
2622 $LFS mkdir -i $MDTIDX $remote_dir &
2628 fail mds$((MDTIDX + 1))
2630 wait $CLIENT_PID || error "remote creation failed"
2632 remote_dir_check_80 || error "remote dir check failed"
2633 rm -rf $DIR/$tdir || error "rmdir failed"
2637 run_test 80c "DNE: create remote dir, drop update rep from MDT1, fail MDT[0,1]"
2640 [[ "$mds1_FSTYPE" = zfs ]] &&
2641 [[ $MDS1_VERSION -lt $(version_code 2.12.51) ]] &&
2642 skip "requires LU-10143 fix on MDS"
2643 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
2645 local remote_dir=$DIR/$tdir/remote_dir
2647 mkdir_on_mdt0 $DIR/$tdir || error "mkdir $DIR/$tdir failed"
2648 #define OBD_FAIL_OUT_UPDATE_NET_REP 0x1701
2649 do_facet mds${MDTIDX} lctl set_param fail_loc=0x1701
2650 $LFS mkdir -i $MDTIDX $remote_dir &
2653 # sleep 3 seconds to make sure MDTs are failed after
2654 # lfs mkdir -i has finished on all of MDTs.
2659 fail mds${MDTIDX},mds$((MDTIDX + 1))
2661 wait $CLIENT_PID || error "remote creation failed"
2663 remote_dir_check_80 || error "remote dir check failed"
2664 rm -rf $DIR/$tdir || error "rmdir failed"
2668 run_test 80d "DNE: create remote dir, drop update rep from MDT1, fail 2 MDTs"
2671 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2672 ([ $FAILURE_MODE == "HARD" ] &&
2673 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
2674 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
2678 local remote_dir=$DIR/$tdir/remote_dir
2680 mkdir_on_mdt0 $DIR/$tdir || error "mkdir $DIR/$tdir failed"
2681 # OBD_FAIL_MDS_REINT_NET_REP 0x119
2682 do_facet mds$((MDTIDX + 1)) lctl set_param fail_loc=0x119
2683 $LFS mkdir -i $MDTIDX $remote_dir &
2686 # sleep 3 seconds to make sure MDTs are failed after
2687 # lfs mkdir -i has finished on all of MDTs.
2693 wait $CLIENT_PID || error "remote creation failed"
2695 remote_dir_check_80 || error "remote dir check failed"
2696 rm -rf $DIR/$tdir || error "rmdir failed"
2700 run_test 80e "DNE: create remote dir, drop MDT1 rep, fail MDT0"
2703 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2704 ([ $FAILURE_MODE == "HARD" ] &&
2705 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
2706 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
2709 local remote_dir=$DIR/$tdir/remote_dir
2711 mkdir_on_mdt0 $DIR/$tdir || error "mkdir $DIR/$tdir failed"
2712 # OBD_FAIL_MDS_REINT_NET_REP 0x119
2713 do_facet mds$((MDTIDX + 1)) lctl set_param fail_loc=0x119
2714 $LFS mkdir -i $MDTIDX $remote_dir &
2718 fail mds$((MDTIDX + 1))
2720 wait $CLIENT_PID || error "remote creation failed"
2722 remote_dir_check_80 || error "remote dir check failed"
2723 rm -rf $DIR/$tdir || error "rmdir failed"
2727 run_test 80f "DNE: create remote dir, drop MDT1 rep, fail MDT1"
2730 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2731 ([ $FAILURE_MODE == "HARD" ] &&
2732 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
2733 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
2737 local remote_dir=$DIR/$tdir/remote_dir
2739 mkdir_on_mdt0 $DIR/$tdir || error "mkdir $DIR/$tdir failed"
2740 # OBD_FAIL_MDS_REINT_NET_REP 0x119
2741 do_facet mds$((MDTIDX + 1)) lctl set_param fail_loc=0x119
2742 $LFS mkdir -i $MDTIDX $remote_dir &
2745 # sleep 3 seconds to make sure MDTs are failed after
2746 # lfs mkdir -i has finished on all of MDTs.
2752 fail mds$((MDTIDX + 1))
2754 wait $CLIENT_PID || error "remote creation failed"
2756 remote_dir_check_80 || error "remote dir check failed"
2757 rm -rf $DIR/$tdir || error "rmdir failed"
2761 run_test 80g "DNE: create remote dir, drop MDT1 rep, fail MDT0, then MDT1"
2764 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2766 local remote_dir=$DIR/$tdir/remote_dir
2768 mkdir_on_mdt0 $DIR/$tdir || error "mkdir $DIR/$tdir failed"
2769 # OBD_FAIL_MDS_REINT_NET_REP 0x119
2770 do_facet mds$((MDTIDX + 1)) lctl set_param fail_loc=0x119
2771 $LFS mkdir -i $MDTIDX $remote_dir &
2774 # sleep 3 seconds to make sure MDTs are failed after
2775 # lfs mkdir -i has finished on all of MDTs.
2780 fail mds${MDTIDX},mds$((MDTIDX + 1))
2782 wait $CLIENT_PID || error "remote dir creation failed"
2784 remote_dir_check_80 || error "remote dir check failed"
2785 rm -rf $DIR/$tdir || error "rmdir failed"
2789 run_test 80h "DNE: create remote dir, drop MDT1 rep, fail 2 MDTs"
2792 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2793 ([ $FAILURE_MODE == "HARD" ] &&
2794 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
2795 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
2799 local remote_dir=$DIR/$tdir/remote_dir
2801 mkdir_on_mdt0 $DIR/$tdir || error "mkdir $DIR/$tdir failed"
2802 $LFS mkdir -i $MDTIDX $remote_dir || error "lfs mkdir failed"
2804 touch $remote_dir || error "touch $remote_dir failed"
2805 # OBD_FAIL_OUT_UPDATE_NET_REP 0x1701
2806 do_facet mds${MDTIDX} lctl set_param fail_loc=0x1701
2811 fail mds$((MDTIDX + 1))
2813 wait $CLIENT_PID || error "rm remote dir failed"
2815 stat $remote_dir &>/dev/null && error "$remote_dir still exist!"
2817 rm -rf $DIR/$tdir || error "rmdir failed"
2821 run_test 81a "DNE: unlink remote dir, drop MDT0 update rep, fail MDT1"
2824 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2825 ([ $FAILURE_MODE == "HARD" ] &&
2826 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
2827 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
2830 local remote_dir=$DIR/$tdir/remote_dir
2832 mkdir_on_mdt0 $DIR/$tdir || error "mkdir $DIR/$tdir failed"
2833 $LFS mkdir -i $MDTIDX $remote_dir || error "lfs mkdir failed"
2835 # OBD_FAIL_OUT_UPDATE_NET_REP 0x1701
2836 do_facet mds${MDTIDX} lctl set_param fail_loc=0x1701
2843 wait $CLIENT_PID || error "rm remote dir failed"
2845 stat $remote_dir &>/dev/null && error "$remote_dir still exist!"
2847 rm -rf $DIR/$tdir || error "rmdir failed"
2851 run_test 81b "DNE: unlink remote dir, drop MDT0 update reply, fail MDT0"
2854 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2855 ([ $FAILURE_MODE == "HARD" ] &&
2856 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
2857 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
2861 local remote_dir=$DIR/$tdir/remote_dir
2863 mkdir_on_mdt0 $DIR/$tdir || error "mkdir $DIR/$tdir failed"
2864 $LFS mkdir -i $MDTIDX $remote_dir || error "lfs mkdir failed"
2866 # OBD_FAIL_OUT_UPDATE_NET_REP 0x1701
2867 do_facet mds${MDTIDX} lctl set_param fail_loc=0x1701
2874 fail mds$((MDTIDX + 1))
2876 wait $CLIENT_PID || error "rm remote dir failed"
2878 stat $remote_dir &>/dev/null && error "$remote_dir still exist!"
2880 rm -rf $DIR/$tdir || error "rmdir failed"
2884 run_test 81c "DNE: unlink remote dir, drop MDT0 update reply, fail MDT0,MDT1"
2887 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2889 local remote_dir=$DIR/$tdir/remote_dir
2891 mkdir_on_mdt0 $DIR/$tdir || error "mkdir $DIR/$tdir failed"
2892 $LFS mkdir -i $MDTIDX $remote_dir || error "lfs mkdir failed"
2894 # OBD_FAIL_OUT_UPDATE_NET_REP 0x1701
2895 do_facet mds${MDTIDX} lctl set_param fail_loc=0x1701
2901 fail mds${MDTIDX},mds$((MDTIDX + 1))
2903 wait $CLIENT_PID || error "rm remote dir failed"
2905 stat $remote_dir &>/dev/null && error "$remote_dir still exist!"
2907 rm -rf $DIR/$tdir || error "rmdir failed"
2911 run_test 81d "DNE: unlink remote dir, drop MDT0 update reply, fail 2 MDTs"
2914 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2915 ([ $FAILURE_MODE == "HARD" ] &&
2916 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
2917 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
2921 local remote_dir=$DIR/$tdir/remote_dir
2923 mkdir_on_mdt0 $DIR/$tdir || error "mkdir $DIR/$tdir failed"
2924 $LFS mkdir -i $MDTIDX $remote_dir || error "lfs mkdir failed"
2926 # OBD_FAIL_MDS_REINT_NET_REP 0x119
2927 do_facet mds$((MDTIDX + 1)) lctl set_param fail_loc=0x119
2930 do_facet mds$((MDTIDX + 1)) lctl set_param fail_loc=0
2935 wait $CLIENT_PID || error "rm remote dir failed"
2937 stat $remote_dir &>/dev/null && error "$remote_dir still exist!"
2939 rm -rf $DIR/$tdir || error "rmdir failed"
2943 run_test 81e "DNE: unlink remote dir, drop MDT1 req reply, fail MDT0"
2946 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2947 ([ $FAILURE_MODE == "HARD" ] &&
2948 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
2949 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
2953 local remote_dir=$DIR/$tdir/remote_dir
2955 mkdir_on_mdt0 $DIR/$tdir || error "mkdir $DIR/$tdir failed"
2956 $LFS mkdir -i $MDTIDX $remote_dir || error "lfs mkdir failed"
2958 # OBD_FAIL_MDS_REINT_NET_REP 0x119
2959 do_facet mds$((MDTIDX + 1)) lctl set_param fail_loc=0x119
2964 fail mds$((MDTIDX + 1))
2966 wait $CLIENT_PID || error "rm remote dir failed"
2968 stat $remote_dir &>/dev/null && error "$remote_dir still exist!"
2970 rm -rf $DIR/$tdir || error "rmdir failed"
2974 run_test 81f "DNE: unlink remote dir, drop MDT1 req reply, fail MDT1"
2977 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2978 ([ $FAILURE_MODE == "HARD" ] &&
2979 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
2980 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
2984 local remote_dir=$DIR/$tdir/remote_dir
2986 mkdir_on_mdt0 $DIR/$tdir || error "mkdir $DIR/$tdir failed"
2987 $LFS mkdir -i $MDTIDX $remote_dir || error "lfs mkdir failed"
2989 # OBD_FAIL_MDS_REINT_NET_REP 0x119
2990 do_facet mds$((MDTIDX + 1)) lctl set_param fail_loc=0x119
2997 fail mds$((MDTIDX + 1))
2999 wait $CLIENT_PID || error "rm remote dir failed"
3001 stat $remote_dir &>/dev/null && error "$remote_dir still exist!"
3003 rm -rf $DIR/$tdir || error "rmdir failed"
3007 run_test 81g "DNE: unlink remote dir, drop req reply, fail M0, then M1"
3010 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
3012 local remote_dir=$DIR/$tdir/remote_dir
3014 mkdir_on_mdt0 $DIR/$tdir || error "mkdir $DIR/$tdir failed"
3015 $LFS mkdir -i $MDTIDX $remote_dir || error "lfs mkdir failed"
3017 # OBD_FAIL_MDS_REINT_NET_REP 0x119
3018 do_facet mds$((MDTIDX + 1)) lctl set_param fail_loc=0x119
3024 fail mds${MDTIDX},mds$((MDTIDX + 1))
3026 wait $CLIENT_PID || error "rm remote dir failed"
3028 stat $remote_dir &>/dev/null && error "$remote_dir still exist!"
3030 rm -rf $DIR/$tdir || error "rmdir failed"
3034 run_test 81h "DNE: unlink remote dir, drop request reply, fail 2 MDTs"
3037 #define OBD_FAIL_MDS_OPEN_WAIT_CREATE 0x144
3038 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000144"
3039 createmany -o $DIR/$tfile- 1 &
3043 client_up || client_up || true # reconnect
3045 run_test 84a "stale open during export disconnect"
3047 test_85a() { #bug 16774
3048 lctl set_param -n ldlm.cancel_unused_locks_before_replay "1"
3050 for i in $(seq 100); do
3051 echo "tag-$i" > $DIR/$tfile-$i
3052 grep -q "tag-$i" $DIR/$tfile-$i || error "f2-$i"
3055 lov_id=$(lctl dl | grep "clilov")
3056 addr=$(echo $lov_id | awk '{print $4}' | awk -F '-' '{print $NF}')
3057 count=$(lctl get_param -n \
3058 ldlm.namespaces.*MDT0000*$addr.lock_unused_count)
3059 echo "before recovery: unused locks count = $count"
3063 count2=$(lctl get_param -n \
3064 ldlm.namespaces.*MDT0000*$addr.lock_unused_count)
3065 echo "after recovery: unused locks count = $count2"
3067 if [ $count2 -ge $count ]; then
3068 error "unused locks are not canceled"
3071 run_test 85a "check the cancellation of unused locks during recovery(IBITS)"
3073 test_85b() { #bug 16774
3077 lctl set_param -n ldlm.cancel_unused_locks_before_replay "1"
3079 $LFS setstripe -c 1 -i 0 $DIR/$tdir
3081 for i in $(seq 100); do
3082 dd if=/dev/urandom of=$DIR/$tdir/$tfile-$i bs=4096 \
3083 count=32 >/dev/null 2>&1
3086 cancel_lru_locks osc
3088 for i in $(seq 100); do
3089 dd if=$DIR/$tdir/$tfile-$i of=/dev/null bs=4096 \
3090 count=32 >/dev/null 2>&1
3093 lov_id=$(lctl dl | grep "clilov")
3094 addr=$(echo $lov_id | awk '{print $4}' | awk -F '-' '{print $NF}')
3095 count=$(lctl get_param -n \
3096 ldlm.namespaces.*OST0000*$addr.lock_unused_count)
3097 echo "before recovery: unused locks count = $count"
3098 [ $count -ne 0 ] || error "unused locks ($count) should be zero"
3102 count2=$(lctl get_param \
3103 -n ldlm.namespaces.*OST0000*$addr.lock_unused_count)
3104 echo "after recovery: unused locks count = $count2"
3106 if [ $count2 -ge $count ]; then
3107 error "unused locks are not canceled"
3112 run_test 85b "check the cancellation of unused locks during recovery(EXTENT)"
3115 local clients=${CLIENTS:-$HOSTNAME}
3117 zconf_umount_clients $clients $MOUNT
3118 do_facet $SINGLEMDS lctl set_param mdt.${FSNAME}-MDT*.exports.clear=0
3119 remount_facet $SINGLEMDS
3120 zconf_mount_clients $clients $MOUNT
3122 run_test 86 "umount server after clear nid_stats should not hit LBUG"
3125 do_facet ost1 "lctl set_param -n obdfilter.${ost1_svc}.sync_journal 0"
3128 $LFS setstripe -i 0 -c 1 $DIR/$tfile
3129 dd if=/dev/urandom of=$DIR/$tfile bs=1024k count=8 ||
3130 error "dd to $DIR/$tfile failed"
3131 cksum=$(md5sum $DIR/$tfile | awk '{print $1}')
3132 cancel_lru_locks osc
3134 dd if=$DIR/$tfile of=/dev/null bs=1024k count=8 || error "Cannot read"
3135 cksum2=$(md5sum $DIR/$tfile | awk '{print $1}')
3136 if [ $cksum != $cksum2 ] ; then
3137 error "New checksum $cksum2 does not match original $cksum"
3140 run_test 87a "write replay"
3143 do_facet ost1 "lctl set_param -n obdfilter.${ost1_svc}.sync_journal 0"
3146 $LFS setstripe -i 0 -c 1 $DIR/$tfile
3147 dd if=/dev/urandom of=$DIR/$tfile bs=1024k count=8 ||
3148 error "dd to $DIR/$tfile failed"
3149 sleep 1 # Give it a chance to flush dirty data
3150 echo TESTTEST | dd of=$DIR/$tfile bs=1 count=8 seek=64
3151 cksum=$(md5sum $DIR/$tfile | awk '{print $1}')
3152 cancel_lru_locks osc
3154 dd if=$DIR/$tfile of=/dev/null bs=1024k count=8 || error "Cannot read"
3155 cksum2=$(md5sum $DIR/$tfile | awk '{print $1}')
3156 if [ $cksum != $cksum2 ] ; then
3157 error "New checksum $cksum2 does not match original $cksum"
3160 run_test 87b "write replay with changed data (checksum resend)"
3162 test_88() { #bug 17485
3163 mkdir_on_mdt0 $DIR/$tdir || error "mkdir $DIR/$tdir failed"
3164 mkdir -p $TMP/$tdir || error "mkdir $TMP/$tdir failed"
3166 $LFS setstripe -i 0 -c 1 $DIR/$tdir || error "$LFS setstripe failed"
3169 replay_barrier $SINGLEMDS
3171 # exhaust precreations on ost1
3172 local OST=$(ostname_from_index 0)
3173 local mdtosc=$(get_mdtosc_proc_path $SINGLEMDS $OST)
3174 local last_id=$(do_facet $SINGLEMDS lctl get_param -n osp.$mdtosc.prealloc_last_id)
3175 local next_id=$(do_facet $SINGLEMDS lctl get_param -n osp.$mdtosc.prealloc_next_id)
3176 echo "before test: last_id = $last_id, next_id = $next_id"
3178 echo "Creating to objid $last_id on ost $OST..."
3179 createmany -o $DIR/$tdir/f-%d $next_id $((last_id - next_id + 2)) ||
3180 error "createmany create files to last_id failed"
3182 #create some files to use some uncommitted objids
3183 last_id=$(($last_id + 1))
3184 createmany -o $DIR/$tdir/f-%d $last_id 8 ||
3185 error "createmany create files with uncommitted objids failed"
3187 last_id2=$(do_facet $SINGLEMDS lctl get_param -n osp.$mdtosc.prealloc_last_id)
3188 next_id2=$(do_facet $SINGLEMDS lctl get_param -n osp.$mdtosc.prealloc_next_id)
3189 echo "before recovery: last_id = $last_id2, next_id = $next_id2"
3191 # if test uses shutdown_facet && reboot_facet instead of facet_failover ()
3192 # it has to take care about the affected facets, bug20407
3193 local affected_mds1=$(affected_facets mds1)
3194 local affected_ost1=$(affected_facets ost1)
3196 shutdown_facet $SINGLEMDS
3199 reboot_facet $SINGLEMDS
3200 change_active $affected_mds1
3201 wait_for_facet $affected_mds1
3202 mount_facets $affected_mds1 || error "Restart of mds failed"
3205 change_active $affected_ost1
3206 wait_for_facet $affected_ost1
3207 mount_facets $affected_ost1 || error "Restart of ost1 failed"
3211 last_id2=$(do_facet $SINGLEMDS lctl get_param -n osp.$mdtosc.prealloc_last_id)
3212 next_id2=$(do_facet $SINGLEMDS lctl get_param -n osp.$mdtosc.prealloc_next_id)
3213 echo "after recovery: last_id = $last_id2, next_id = $next_id2"
3215 # create new files, which should use new objids, and ensure the orphan
3216 # cleanup phase for ost1 is completed at the same time
3217 for i in $(seq 8); do
3218 file_id=$(($last_id + 10 + $i))
3219 dd if=/dev/urandom of=$DIR/$tdir/f-$file_id bs=4096 count=128
3222 # if the objids were not recreated, then "ls" will fail with -ENOENT
3223 ls -l $DIR/$tdir/* || error "can't get the status of precreated files"
3226 # write into previously created files
3227 for i in $(seq 8); do
3228 file_id=$(($last_id + $i))
3229 dd if=/dev/urandom of=$DIR/$tdir/f-$file_id bs=4096 count=128
3230 cp -f $DIR/$tdir/f-$file_id $TMP/$tdir/
3233 # compare the content
3234 for i in $(seq 8); do
3235 file_id=$(($last_id + $i))
3236 cmp $TMP/$tdir/f-$file_id $DIR/$tdir/f-$file_id ||
3237 error "the content of file is modified!"
3242 run_test 88 "MDS should not assign same objid to different files "
3245 cancel_lru_locks osc
3246 mkdir_on_mdt0 $DIR/$tdir || error "mkdir $DIR/$tdir failed"
3247 rm -f $DIR/$tdir/$tfile
3248 wait_mds_ost_sync || error "initial MDS-OST sync timed out"
3249 wait_delete_completed || error "initial wait delete timed out"
3250 local before=$(calc_osc_kbytes kbytesfree)
3251 local write_size=$(fs_log_size)
3253 $LFS setstripe -i 0 -c 1 $DIR/$tdir/$tfile
3254 (( $write_size >= 1024 )) || write_size=1024
3255 dd if=/dev/zero bs=${write_size}k count=10 of=$DIR/$tdir/$tfile
3258 facet_failover $SINGLEMDS
3259 rm $DIR/$tdir/$tfile
3262 zconf_mount $(hostname) $MOUNT || error "mount fails"
3263 client_up || error "client_up failed"
3265 # wait for the remounted client to connect to ost1
3266 local target=$(get_osc_import_name client ost1)
3267 wait_import_state "FULL" "osc.${target}.ost_server_uuid" \
3268 $(max_recovery_time)
3270 wait_mds_ost_sync || error "MDS-OST sync timed out"
3271 wait_delete_completed || error "wait delete timed out"
3272 local after=$(calc_osc_kbytes kbytesfree)
3274 log "free_before: $before free_after: $after"
3275 (( $before <= $after + $(fs_log_size) )) ||
3276 error "kbytesfree $before > $after + margin $(fs_log_size)"
3278 run_test 89 "no disk space leak on late ost connection"
3285 change_active $facet
3286 wait_for_facet $facet
3287 mount_facet $facet || error "Restart of $facet failed"
3291 test_90() { # bug 19494
3292 local dir=$DIR/$tdir
3293 local ostfail=$(get_random_entry $(get_facets OST))
3295 if [[ $FAILURE_MODE = HARD ]]; then
3296 local affected=$(affected_facets $ostfail);
3298 [[ "$affected" == $ostfail ]] ||
3299 skip "cannot use FAILURE_MODE=$FAILURE_MODE, affected: $affected"
3301 # ensure all OSTs are active to allow allocations
3304 mkdir $dir || error "mkdir $dir failed"
3306 echo "Create the files"
3308 # file "f${index}" striped over 1 OST
3309 # file "all" striped over all OSTs
3311 $LFS setstripe -c $OSTCOUNT $dir/all ||
3312 error "setstripe failed to create $dir/all"
3314 for ((i = 0; i < $OSTCOUNT; i++)); do
3317 $LFS setstripe -i $i -c 1 $f ||
3318 error "$LFS setstripe failed to create $f"
3320 # confirm setstripe actually created stripe on requested OST
3321 local uuid=$(ostuuid_from_index $i)
3323 for file in f$i all; do
3324 local found=$($LFS find --obd $uuid --name $file $dir)
3326 if [[ $dir/$file != $found ]]; then
3327 $LFS getstripe $dir/$file
3328 error "wrong stripe: $file, uuid: $uuid"
3333 # Before failing an OST, get its obd name and index
3334 local varsvc=${ostfail}_svc
3335 local obd=$(do_facet $ostfail lctl get_param \
3336 -n obdfilter.${!varsvc}.uuid)
3337 local index=$(($(facet_number $ostfail) - 1))
3339 echo "Fail $ostfail $obd, display the list of affected files"
3340 shutdown_facet $ostfail || error "shutdown_facet $ostfail failed"
3342 trap "cleanup_90 $ostfail" EXIT INT
3343 echo "General Query: lfs find $dir"
3344 local list=$($LFS find $dir)
3346 for (( i=0; i<$OSTCOUNT; i++ )); do
3347 list_member "$list" $dir/f$i ||
3348 error_noexit "lfs find $dir: no file f$i"
3350 list_member "$list" $dir/all ||
3351 error_noexit "lfs find $dir: no file all"
3353 # focus on the missing OST,
3354 # we expect to see only two files affected: "f$(index)" and "all"
3356 echo "Querying files on shutdown $ostfail: lfs find --obd $obd"
3357 list=$($LFS find --obd $obd $dir)
3359 for file in all f$index; do
3360 list_member "$list" $dir/$file ||
3361 error_noexit "lfs find does not report the affected $obd for $file"
3364 [[ $(echo $list | wc -w) -eq 2 ]] ||
3365 error_noexit "lfs find reports the wrong list of affected files ${#list[@]}"
3367 echo "Check getstripe: $LFS getstripe -r --obd $obd"
3368 list=$($LFS getstripe -r --obd $obd $dir)
3370 for file in all f$index; do
3371 echo "$list" | grep $dir/$file ||
3372 error_noexit "lfs getsripe does not report the affected $obd for $file"
3377 run_test 90 "lfs find identifies the missing striped file segments"
3380 [[ "$MDS1_VERSION" -ge $(version_code 2.6.90) ]] ||
3381 [[ "$MDS1_VERSION" -ge $(version_code 2.5.4) &&
3382 "$MDS1_VERSION" -lt $(version_code 2.5.50) ]] ||
3383 skip "Need MDS version 2.5.4+ or 2.6.90+"
3385 cancel_lru_locks osc
3387 $LFS setstripe -i 0 -c 1 $DIR/$tfile ||
3388 error "$LFS setstripe $DIR/$tfile failed"
3389 dd if=/dev/zero of=$DIR/$tfile bs=1024 count=1 ||
3390 error "dd to $DIR/$tfile failed"
3391 #define OBD_FAIL_TGT_REPLAY_RECONNECT 0x715
3392 # We need to emulate a state that OST is waiting for other clients
3393 # not completing the recovery. Final ping is queued, but reply will be
3394 # sent on the recovery completion. It is done by sleep before
3395 # processing final pings
3396 do_facet ost1 "$LCTL set_param fail_val=40"
3397 do_facet ost1 "$LCTL set_param fail_loc=0x715"
3400 run_test 93a "replay + reconnect"
3403 [[ "$MDS1_VERSION" -ge $(version_code 2.7.90) ]] ||
3404 skip "Need MDS version 2.7.90+"
3406 cancel_lru_locks mdc
3408 createmany -o $DIR/$tfile 20 ||
3409 error "createmany -o $DIR/$tfile failed"
3411 #define OBD_FAIL_TGT_REPLAY_RECONNECT 0x715
3412 # We need to emulate a state that MDT is waiting for other clients
3413 # not completing the recovery. Final ping is queued, but reply will be
3414 # sent on the recovery completion. It is done by sleep before
3415 # processing final pings
3416 do_facet mds1 "$LCTL set_param fail_val=80"
3417 do_facet mds1 "$LCTL set_param fail_loc=0x715"
3420 run_test 93b "replay + reconnect on mds"
3422 striped_dir_check_100() {
3423 local striped_dir=$DIR/$tdir/striped_dir
3424 local stripe_count=$($LFS getdirstripe -c $striped_dir)
3426 $LFS getdirstripe $striped_dir
3427 [ $stripe_count -eq 2 ] || error "$stripe_count != 2"
3429 createmany -o $striped_dir/f-%d 20 ||
3430 error "creation failed under striped dir"
3434 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
3435 ([ $FAILURE_MODE == "HARD" ] &&
3436 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
3437 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
3440 local striped_dir=$DIR/$tdir/striped_dir
3443 mkdir_on_mdt0 $DIR/$tdir || error "mkdir $DIR/$tdir failed"
3445 #To make sure MDT1 and MDT0 are connected
3446 #otherwise it may create single stripe dir here
3447 $LFS setdirstripe -i1 $DIR/$tdir/remote_dir
3449 #define OBD_FAIL_OUT_UPDATE_NET_REP 0x1701
3450 do_facet mds$((MDTIDX+1)) lctl set_param fail_loc=0x1701
3451 $LFS setdirstripe -i0 -c2 $striped_dir &
3454 fail mds$((MDTIDX + 1))
3456 wait $CLIENT_PID || error "striped dir creation failed"
3458 striped_dir_check_100 || error "striped dir check failed"
3459 rm -rf $DIR/$tdir || error "rmdir failed"
3461 run_test 100a "DNE: create striped dir, drop update rep from MDT1, fail MDT1"
3464 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
3465 ([ $FAILURE_MODE == "HARD" ] &&
3466 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
3467 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
3470 local striped_dir=$DIR/$tdir/striped_dir
3473 mkdir_on_mdt0 $DIR/$tdir || error "mkdir $DIR/$tdir failed"
3475 #To make sure MDT1 and MDT0 are connected
3476 #otherwise it may create single stripe dir here
3477 $LFS setdirstripe -i1 $DIR/$tdir/remote_dir
3479 # OBD_FAIL_MDS_REINT_NET_REP 0x119
3480 do_facet mds$MDTIDX lctl set_param fail_loc=0x119
3481 $LFS mkdir -i0 -c2 $striped_dir &
3486 wait $CLIENT_PID || error "striped dir creation failed"
3488 striped_dir_check_100 || error "striped dir check failed"
3489 rm -rf $DIR/$tdir || error "rmdir failed"
3491 run_test 100b "DNE: create striped dir, fail MDT0"
3494 (( $MDSCOUNT >= 2 )) || skip "needs >= 2 MDTs"
3495 [[ "$FAILURE_MODE" != "HARD" ||
3496 "$(facet_host mds1)" != "$(facet_host mds2)" ]] ||
3497 skip "MDTs needs to be on diff hosts for HARD fail mode"
3499 local striped_dir=$DIR/$tdir/striped_dir
3501 mkdir_on_mdt0 $DIR/$tdir || error "mkdir $DIR/$tdir failed"
3503 #To make sure MDT1 and MDT0 are connected
3504 #otherwise it may create single stripe dir here
3505 $LFS setdirstripe -i1 $DIR/$tdir/remote_dir
3508 $LFS mkdir -i1 -c2 $striped_dir
3510 fail_abort mds2 abort_recov_mdt
3512 if (( $MDS1_VERSION >= $(version_code 2.15.54.138) )); then
3513 # after 2.15.54.138 striped mkdir can replay by client request
3514 createmany -o $striped_dir/f-%d 20 ||
3515 error "createmany -o $DIR/$tfile failed"
3520 # LU-16159 abort_recovery will cancel update logs, the second recovery
3521 # won't replay $striped_dir creation
3522 (( $MDS1_VERSION >= $(version_code 2.15.52) &&
3523 $MDS1_VERSION < $(version_code 2.15.54.138) )) &&
3524 fail_abort_cleanup && return 0
3526 striped_dir_check_100 || error "striped dir check failed"
3528 run_test 100c "DNE: create striped dir, abort_recov_mdt mds2"
3531 (( $MDSCOUNT > 1 )) || skip "needs > 1 MDTs"
3532 (( $MDS1_VERSION >= $(version_code 2.15.52.144) )) ||
3533 skip "Need MDS version 2.15.52.144+"
3535 test_mkdir -c $MDSCOUNT $DIR/$tdir || error "mkdir $tdir failed"
3536 $LFS setdirstripe -D -i -1 -c $MDSCOUNT $DIR/$tdir ||
3537 error "set $tdir default LMV failed"
3538 createmany -d $DIR/$tdir/s 100 || error "create subdir failed"
3540 local index=$((RANDOM % MDSCOUNT))
3541 local devname=$(mdtname_from_index $index)
3542 local mdt=mds$((index + 1))
3547 # cancel update llog upon recovery abort
3548 do_facet $mdt $LCTL --device $devname llog_print update_log
3549 log=$(do_facet $mdt "$LCTL --device $devname llog_print update_log |
3550 awk '/index/ { print \\\$4; exit }'")
3552 count=$(do_facet $mdt "$LCTL --device $devname llog_print update_log |
3554 (( count > 0 )) || error "no update logs found"
3555 stack_trap fail_abort_cleanup RETURN
3556 fail_abort $mdt || error "fail_abort $mdt failed"
3557 wait_update_facet $mdt "$LCTL --device $devname llog_print update_log |
3558 grep -c index" 0 60 || error "update logs not canceled"
3560 run_test 100d "DNE: cancel update logs upon recovery abort"
3563 (( MDSCOUNT > 1 )) || skip "needs >= 2 MDTs"
3564 (( MDS1_VERSION >= $(version_code 2.15.54.79) )) ||
3565 skip "Need MDS version 2.15.54.79+"
3566 [[ $FAILURE_MODE != "HARD" ||
3567 "$(facet_host mds1)" != "$(facet_host mds2)" ]] ||
3568 skip "MDTs needs to be on diff hosts for HARD fail mode"
3572 local striped_dir=$DIR/$tdir/striped_dir
3574 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
3579 $LFS mkdir -i 0,1 $striped_dir
3580 old=$($LFS getdirstripe $striped_dir)
3585 new=$($LFS getdirstripe $striped_dir)
3587 [ "$old" == "$new" ] ||
3588 error "$striped_dir layout mismatch"
3589 rm -rf $DIR/$tdir || error "rmdir failed"
3591 run_test 100e "DNE: create striped dir on MDT0 and MDT1, fail MDT0, MDT1"
3593 test_101() { #LU-5648
3594 mkdir -p $DIR/$tdir/d1
3595 mkdir -p $DIR/$tdir/d2
3596 touch $DIR/$tdir/file0
3599 replay_barrier $SINGLEMDS
3600 for i in $(seq $num) ; do
3601 echo test$i > $DIR/$tdir/d1/file$i
3604 fail_abort $SINGLEMDS
3605 for i in $(seq $num) ; do
3606 touch $DIR/$tdir/d2/file$i
3607 test -s $DIR/$tdir/d2/file$i &&
3608 ls -al $DIR/$tdir/d2/file$i && error "file$i's size > 0"
3613 run_test 101 "Shouldn't reassign precreated objs to other files after recovery"
3622 [[ $(lctl get_param mdc.*.import |
3623 grep "connect_flags:.*multi_mod_rpc") ]] ||
3624 { skip "Need MDC with 'multi_mod_rpcs' feature"; return 0; }
3626 $LFS mkdir -c1 $DIR/$tdir || error "mkdir $DIR/$tdir failed"
3627 idx=$(printf "%04x" $($LFS getdirstripe -i $DIR/$tdir))
3628 facet="mds$((0x$idx + 1))"
3630 # get current value of max_mod_rcps_in_flight
3631 num=$($LCTL get_param -n \
3632 mdc.$FSNAME-MDT$idx-mdc-*.max_mod_rpcs_in_flight)
3633 # set default value if client does not support multi mod RPCs
3634 [ -z "$num" ] && num=1
3636 echo "creating $num files ..."
3638 for i in $(seq $num); do
3639 touch $DIR/$tdir/file-$i
3642 # drop request on MDT to force resend
3643 #define OBD_FAIL_MDS_REINT_MULTI_NET 0x159
3644 do_facet $facet "$LCTL set_param fail_loc=0x159"
3645 echo "launch $num chmod in parallel ($(date +%H:%M:%S)) ..."
3646 for i in $(seq $num); do
3647 chmod 0600 $DIR/$tdir/file-$i &
3651 do_facet $facet "$LCTL set_param fail_loc=0"
3652 for pid in $pids; do
3653 wait $pid || error "chmod failed"
3655 echo "done ($(date +%H:%M:%S))"
3657 # check chmod succeed
3658 for i in $(seq $num); do
3659 checkstat -vp 0600 $DIR/$tdir/file-$i
3664 run_test 102a "check resend (request lost) with multiple modify RPCs in flight"
3673 [[ $(lctl get_param mdc.*.import |
3674 grep "connect_flags:.*multi_mod_rpc") ]] ||
3675 { skip "Need MDC with 'multi_mod_rpcs' feature"; return 0; }
3677 $LFS mkdir -c1 $DIR/$tdir || error "mkdir $DIR/$tdir failed"
3678 idx=$(printf "%04x" $($LFS getdirstripe -i $DIR/$tdir))
3679 facet="mds$((0x$idx + 1))"
3681 # get current value of max_mod_rcps_in_flight
3682 num=$($LCTL get_param -n \
3683 mdc.$FSNAME-MDT$idx-mdc-*.max_mod_rpcs_in_flight)
3684 # set default value if client does not support multi mod RPCs
3685 [ -z "$num" ] && num=1
3687 echo "creating $num files ..."
3689 for i in $(seq $num); do
3690 touch $DIR/$tdir/file-$i
3693 # drop reply on MDT to force reconstruction
3694 #define OBD_FAIL_MDS_REINT_MULTI_NET_REP 0x15a
3695 do_facet $facet "$LCTL set_param fail_loc=0x15a"
3696 echo "launch $num chmod in parallel ($(date +%H:%M:%S)) ..."
3697 for i in $(seq $num); do
3698 chmod 0600 $DIR/$tdir/file-$i &
3702 do_facet $facet "$LCTL set_param fail_loc=0"
3703 for pid in $pids; do
3704 wait $pid || error "chmod failed"
3706 echo "done ($(date +%H:%M:%S))"
3708 # check chmod succeed
3709 for i in $(seq $num); do
3710 checkstat -vp 0600 $DIR/$tdir/file-$i
3715 run_test 102b "check resend (reply lost) with multiple modify RPCs in flight"
3724 [[ $(lctl get_param mdc.*.import |
3725 grep "connect_flags:.*multi_mod_rpc") ]] ||
3726 { skip "Need MDC with 'multi_mod_rpcs' feature"; return 0; }
3728 $LFS mkdir -c1 $DIR/$tdir || error "mkdir $DIR/$tdir failed"
3729 idx=$(printf "%04x" $($LFS getdirstripe -i $DIR/$tdir))
3730 facet="mds$((0x$idx + 1))"
3732 # get current value of max_mod_rcps_in_flight
3733 num=$($LCTL get_param -n \
3734 mdc.$FSNAME-MDT$idx-mdc-*.max_mod_rpcs_in_flight)
3735 # set default value if client does not support multi mod RPCs
3736 [ -z "$num" ] && num=1
3738 echo "creating $num files ..."
3740 for i in $(seq $num); do
3741 touch $DIR/$tdir/file-$i
3744 replay_barrier $facet
3747 #define OBD_FAIL_MDS_REINT_MULTI_NET_REP 0x15a
3748 do_facet $facet "$LCTL set_param fail_loc=0x15a"
3749 echo "launch $num chmod in parallel ($(date +%H:%M:%S)) ..."
3750 for i in $(seq $num); do
3751 chmod 0600 $DIR/$tdir/file-$i &
3755 do_facet $facet "$LCTL set_param fail_loc=0"
3760 for pid in $pids; do
3761 wait $pid || error "chmod failed"
3763 echo "done ($(date +%H:%M:%S))"
3765 # check chmod succeed
3766 for i in $(seq $num); do
3767 checkstat -vp 0600 $DIR/$tdir/file-$i
3772 run_test 102c "check replay w/o reconstruction with multiple mod RPCs in flight"
3781 [[ $(lctl get_param mdc.*.import |
3782 grep "connect_flags:.*multi_mod_rpc") ]] ||
3783 { skip "Need MDC with 'multi_mod_rpcs' feature"; return 0; }
3785 $LFS mkdir -c1 $DIR/$tdir || error "mkdir $DIR/$tdir failed"
3786 idx=$(printf "%04x" $($LFS getdirstripe -i $DIR/$tdir))
3787 facet="mds$((0x$idx + 1))"
3789 # get current value of max_mod_rcps_in_flight
3790 num=$($LCTL get_param -n \
3791 mdc.$FSNAME-MDT$idx-mdc-*.max_mod_rpcs_in_flight)
3792 # set default value if client does not support multi mod RPCs
3793 [ -z "$num" ] && num=1
3795 echo "creating $num files ..."
3797 for i in $(seq $num); do
3798 touch $DIR/$tdir/file-$i
3802 #define OBD_FAIL_MDS_REINT_MULTI_NET_REP 0x15a
3803 do_facet $facet "$LCTL set_param fail_loc=0x15a"
3804 echo "launch $num chmod in parallel ($(date +%H:%M:%S)) ..."
3805 for i in $(seq $num); do
3806 chmod 0600 $DIR/$tdir/file-$i &
3811 # write MDT transactions to disk
3812 do_facet $facet "sync; sync; sync"
3814 do_facet $facet "$LCTL set_param fail_loc=0"
3819 for pid in $pids; do
3820 wait $pid || error "chmod failed"
3822 echo "done ($(date +%H:%M:%S))"
3824 # check chmod succeed
3825 for i in $(seq $num); do
3826 checkstat -vp 0600 $DIR/$tdir/file-$i
3831 run_test 102d "check replay & reconstruction with multiple mod RPCs in flight"
3834 remote_mds_nodsh && skip "remote MDS with nodsh"
3835 [[ "$MDS1_VERSION" -gt $(version_code 2.8.54) ]] ||
3836 skip "Need MDS version 2.8.54+"
3838 #define OBD_FAIL_MDS_TRACK_OVERFLOW 0x162
3839 do_facet mds1 $LCTL set_param fail_loc=0x80000162
3842 createmany -o $DIR/$tdir/t- 30 ||
3843 error "create files on remote directory failed"
3845 rm -rf $DIR/$tdir/t-*
3847 #MDS should crash with tr->otr_next_id overflow
3850 run_test 103 "Check otr_next_id overflow"
3853 check_striped_dir_110()
3855 $CHECKSTAT -t dir $DIR/$tdir/striped_dir ||
3856 error "create striped dir failed"
3857 local stripe_count=$($LFS getdirstripe -c $DIR/$tdir/striped_dir)
3858 [ $stripe_count -eq $MDSCOUNT ] ||
3859 error "$stripe_count != 2 after recovery"
3863 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
3864 [[ "$MDS1_VERSION" -ge $(version_code 2.7.56) ]] ||
3865 skip "Need MDS version at least 2.7.56"
3867 ([ $FAILURE_MODE == "HARD" ] &&
3868 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
3869 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
3874 $LFS mkdir -i1 -c$MDSCOUNT $DIR/$tdir/striped_dir
3877 check_striped_dir_110 || error "check striped_dir failed"
3878 rm -rf $DIR/$tdir || error "rmdir failed"
3882 run_test 110a "DNE: create striped dir, fail MDT1"
3885 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
3886 [[ "$MDS1_VERSION" -ge $(version_code 2.7.56) ]] ||
3887 skip "Need MDS version at least 2.7.56"
3889 ([ $FAILURE_MODE == "HARD" ] &&
3890 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
3891 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
3896 $LFS mkdir -i1 -c$MDSCOUNT $DIR/$tdir/striped_dir
3899 zconf_mount $(hostname) $MOUNT
3900 client_up || return 1
3902 check_striped_dir_110 || error "check striped_dir failed"
3904 rm -rf $DIR/$tdir || error "rmdir failed"
3908 run_test 110b "DNE: create striped dir, fail MDT1 and client"
3911 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
3912 [[ "$MDS1_VERSION" -ge $(version_code 2.7.56) ]] ||
3913 skip "Need MDS version at least 2.7.56"
3915 ([ $FAILURE_MODE == "HARD" ] &&
3916 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
3917 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
3922 $LFS mkdir -i1 -c$MDSCOUNT $DIR/$tdir/striped_dir
3925 check_striped_dir_110 || error "check striped_dir failed"
3927 rm -rf $DIR/$tdir || error "rmdir failed"
3931 run_test 110c "DNE: create striped dir, fail MDT2"
3934 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
3935 [[ "$MDS1_VERSION" -ge $(version_code 2.7.56) ]] ||
3936 skip "Need MDS version at least 2.7.56"
3938 ([ $FAILURE_MODE == "HARD" ] &&
3939 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
3940 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
3945 $LFS mkdir -i1 -c$MDSCOUNT $DIR/$tdir/striped_dir
3948 zconf_mount $(hostname) $MOUNT
3949 client_up || return 1
3951 check_striped_dir_110 || error "check striped_dir failed"
3953 rm -rf $DIR/$tdir || error "rmdir failed"
3957 run_test 110d "DNE: create striped dir, fail MDT2 and client"
3960 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
3961 [[ "$MDS1_VERSION" -ge $(version_code 2.7.56) ]] ||
3962 skip "Need MDS version at least 2.7.56"
3964 ([ $FAILURE_MODE == "HARD" ] &&
3965 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
3966 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
3971 $LFS mkdir -i1 -c$MDSCOUNT $DIR/$tdir/striped_dir
3975 zconf_mount $(hostname) $MOUNT
3976 client_up || return 1
3978 check_striped_dir_110 || error "check striped_dir failed"
3980 rm -rf $DIR/$tdir || error "rmdir failed"
3984 run_test 110e "DNE: create striped dir, uncommit on MDT2, fail client/MDT1/MDT2"
3987 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
3988 [[ "$MDS1_VERSION" -ge $(version_code 2.7.56) ]] ||
3989 skip "Need MDS version at least 2.7.56"
3991 ([ $FAILURE_MODE == "HARD" ] &&
3992 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
3993 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
3999 $LFS mkdir -i1 -c$MDSCOUNT $DIR/$tdir/striped_dir
4002 check_striped_dir_110 || error "check striped_dir failed"
4004 rm -rf $DIR/$tdir || error "rmdir failed"
4008 run_test 110f "DNE: create striped dir, fail MDT1/MDT2"
4011 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
4012 [[ "$MDS1_VERSION" -ge $(version_code 2.7.56) ]] ||
4013 skip "Need MDS version at least 2.7.56"
4015 ([ $FAILURE_MODE == "HARD" ] &&
4016 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
4017 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
4022 $LFS mkdir -i1 -c$MDSCOUNT $DIR/$tdir/striped_dir
4026 zconf_mount $(hostname) $MOUNT
4027 client_up || return 1
4029 check_striped_dir_110 || error "check striped_dir failed"
4031 rm -rf $DIR/$tdir || error "rmdir failed"
4035 run_test 110g "DNE: create striped dir, uncommit on MDT1, fail client/MDT1/MDT2"
4038 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
4039 [[ "$MDS1_VERSION" -ge $(version_code 2.7.56) ]] ||
4040 skip "Need MDS version at least 2.7.56"
4042 ([ $FAILURE_MODE == "HARD" ] &&
4043 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
4044 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
4048 $LFS mkdir -i1 -c2 $DIR/$tdir/striped_dir
4050 rm -rf $DIR/$tdir/striped_dir
4053 $CHECKSTAT -t dir $DIR/$tdir/striped_dir &&
4054 error "striped dir still exists"
4057 run_test 111a "DNE: unlink striped dir, fail MDT1"
4060 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
4061 [[ "$MDS1_VERSION" -ge $(version_code 2.7.56) ]] ||
4062 skip "Need MDS version at least 2.7.56"
4064 ([ $FAILURE_MODE == "HARD" ] &&
4065 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
4066 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
4070 $LFS mkdir -i1 -c2 $DIR/$tdir/striped_dir
4072 rm -rf $DIR/$tdir/striped_dir
4075 zconf_mount $(hostname) $MOUNT
4076 client_up || return 1
4078 $CHECKSTAT -t dir $DIR/$tdir/striped_dir &&
4079 error "striped dir still exists"
4082 run_test 111b "DNE: unlink striped dir, fail MDT2"
4085 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
4086 [[ "$MDS1_VERSION" -ge $(version_code 2.7.56) ]] ||
4087 skip "Need MDS version at least 2.7.56"
4089 ([ $FAILURE_MODE == "HARD" ] &&
4090 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
4091 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
4095 $LFS mkdir -i1 -c2 $DIR/$tdir/striped_dir
4097 rm -rf $DIR/$tdir/striped_dir
4101 zconf_mount $(hostname) $MOUNT
4102 client_up || return 1
4103 $CHECKSTAT -t dir $DIR/$tdir/striped_dir &&
4104 error "striped dir still exists"
4107 run_test 111c "DNE: unlink striped dir, uncommit on MDT1, fail client/MDT1/MDT2"
4110 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
4111 [[ "$MDS1_VERSION" -ge $(version_code 2.7.56) ]] ||
4112 skip "Need MDS version at least 2.7.56"
4114 ([ $FAILURE_MODE == "HARD" ] &&
4115 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
4116 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
4120 $LFS mkdir -i1 -c2 $DIR/$tdir/striped_dir
4122 rm -rf $DIR/$tdir/striped_dir
4126 zconf_mount $(hostname) $MOUNT
4127 client_up || return 1
4128 $CHECKSTAT -t dir $DIR/$tdir/striped_dir &&
4129 error "striped dir still exists"
4133 run_test 111d "DNE: unlink striped dir, uncommit on MDT2, fail client/MDT1/MDT2"
4136 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
4137 [[ "$MDS1_VERSION" -ge $(version_code 2.7.56) ]] ||
4138 skip "Need MDS version at least 2.7.56"
4140 ([ $FAILURE_MODE == "HARD" ] &&
4141 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
4142 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
4146 $LFS mkdir -i1 -c2 $DIR/$tdir/striped_dir
4148 rm -rf $DIR/$tdir/striped_dir
4151 $CHECKSTAT -t dir $DIR/$tdir/striped_dir &&
4152 error "striped dir still exists"
4155 run_test 111e "DNE: unlink striped dir, uncommit on MDT2, fail MDT1/MDT2"
4158 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
4159 [[ "$MDS1_VERSION" -ge $(version_code 2.7.56) ]] ||
4160 skip "Need MDS version at least 2.7.56"
4162 ([ $FAILURE_MODE == "HARD" ] &&
4163 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
4164 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
4168 $LFS mkdir -i1 -c2 $DIR/$tdir/striped_dir
4170 rm -rf $DIR/$tdir/striped_dir
4173 $CHECKSTAT -t dir $DIR/$tdir/striped_dir &&
4174 error "striped dir still exists"
4177 run_test 111f "DNE: unlink striped dir, uncommit on MDT1, fail MDT1/MDT2"
4180 (( $MDSCOUNT >= 2 )) || skip "needs >= 2 MDTs"
4181 (( $MDS1_VERSION >= $(version_code 2.7.56) )) ||
4182 skip "Need MDS version at least 2.7.56"
4184 ([ $FAILURE_MODE != "HARD" ] ||
4185 [ "$(facet_host mds1)" != "$(facet_host mds2)" ]) ||
4186 skip "MDTs needs to be on diff hosts for HARD fail mode"
4189 $LFS mkdir -i1 -c2 $DIR/$tdir/striped_dir
4193 rm -rf $DIR/$tdir/striped_dir
4195 $CHECKSTAT -t dir $DIR/$tdir/striped_dir &&
4196 error "striped dir still exists"
4199 run_test 111g "DNE: unlink striped dir, fail MDT1/MDT2"
4201 test_112_rename_prepare() {
4202 mkdir_on_mdt0 $DIR/$tdir
4203 mkdir -p $DIR/$tdir/src_dir
4204 $LFS mkdir -i 1 $DIR/$tdir/src_dir/src_child ||
4205 error "create remote source failed"
4207 touch $DIR/$tdir/src_dir/src_child/a
4209 $LFS mkdir -i 2 $DIR/$tdir/tgt_dir ||
4210 error "create remote target dir failed"
4212 $LFS mkdir -i 3 $DIR/$tdir/tgt_dir/tgt_child ||
4213 error "create remote target child failed"
4218 $CHECKSTAT -t dir $DIR/$tdir/src_dir/src_child &&
4219 error "src_child still exists after rename"
4221 $CHECKSTAT -t file $DIR/$tdir/tgt_dir/tgt_child/a ||
4222 error "missing file(a) after rename"
4226 [ $MDSCOUNT -lt 4 ] && skip "needs >= 4 MDTs" && return 0
4227 [[ "$MDS1_VERSION" -ge $(version_code 2.7.56) ]] ||
4228 skip "Need MDS version at least 2.7.56"
4230 ([ $FAILURE_MODE == "HARD" ] &&
4231 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
4232 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
4235 test_112_rename_prepare
4238 mrename $DIR/$tdir/src_dir/src_child $DIR/$tdir/tgt_dir/tgt_child ||
4239 error "rename dir cross MDT failed!"
4243 rm -rf $DIR/$tdir || error "rmdir failed"
4245 run_test 112a "DNE: cross MDT rename, fail MDT1"
4248 [ $MDSCOUNT -lt 4 ] && skip "needs >= 4 MDTs" && return 0
4249 [[ "$MDS1_VERSION" -ge $(version_code 2.7.56) ]] ||
4250 skip "Need MDS version at least 2.7.56"
4252 ([ $FAILURE_MODE == "HARD" ] &&
4253 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
4254 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
4257 test_112_rename_prepare
4260 mrename $DIR/$tdir/src_dir/src_child $DIR/$tdir/tgt_dir/tgt_child ||
4261 error "rename dir cross MDT failed!"
4266 rm -rf $DIR/$tdir || error "rmdir failed"
4268 run_test 112b "DNE: cross MDT rename, fail MDT2"
4271 [ $MDSCOUNT -lt 4 ] && skip "needs >= 4 MDTs" && return 0
4272 [[ "$MDS1_VERSION" -ge $(version_code 2.7.56) ]] ||
4273 skip "Need MDS version at least 2.7.56"
4275 ([ $FAILURE_MODE == "HARD" ] &&
4276 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
4277 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
4280 test_112_rename_prepare
4283 mrename $DIR/$tdir/src_dir/src_child $DIR/$tdir/tgt_dir/tgt_child ||
4284 error "rename dir cross MDT failed!"
4289 rm -rf $DIR/$tdir || error "rmdir failed"
4291 run_test 112c "DNE: cross MDT rename, fail MDT3"
4294 [ $MDSCOUNT -lt 4 ] && skip "needs >= 4 MDTs" && return 0
4295 [[ "$MDS1_VERSION" -ge $(version_code 2.7.56) ]] ||
4296 skip "Need MDS version at least 2.7.56"
4298 ([ $FAILURE_MODE == "HARD" ] &&
4299 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
4300 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
4303 test_112_rename_prepare
4306 mrename $DIR/$tdir/src_dir/src_child $DIR/$tdir/tgt_dir/tgt_child ||
4307 error "rename dir cross MDT failed!"
4312 rm -rf $DIR/$tdir || error "rmdir failed"
4314 run_test 112d "DNE: cross MDT rename, fail MDT4"
4317 [ $MDSCOUNT -lt 4 ] && skip "needs >= 4 MDTs" && return 0
4318 [[ "$MDS1_VERSION" -ge $(version_code 2.7.56) ]] ||
4319 skip "Need MDS version at least 2.7.56"
4321 ([ $FAILURE_MODE == "HARD" ] &&
4322 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
4323 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
4326 test_112_rename_prepare
4330 mrename $DIR/$tdir/src_dir/src_child $DIR/$tdir/tgt_dir/tgt_child ||
4331 error "rename dir cross MDT failed!"
4336 rm -rf $DIR/$tdir || error "rmdir failed"
4338 run_test 112e "DNE: cross MDT rename, fail MDT1 and MDT2"
4341 [ $MDSCOUNT -lt 4 ] && skip "needs >= 4 MDTs" && return 0
4342 [[ "$MDS1_VERSION" -ge $(version_code 2.7.56) ]] ||
4343 skip "Need MDS version at least 2.7.56"
4345 ([ $FAILURE_MODE == "HARD" ] &&
4346 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
4347 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
4350 test_112_rename_prepare
4354 mrename $DIR/$tdir/src_dir/src_child $DIR/$tdir/tgt_dir/tgt_child ||
4355 error "rename dir cross MDT failed!"
4360 rm -rf $DIR/$tdir || error "rmdir failed"
4362 run_test 112f "DNE: cross MDT rename, fail MDT1 and MDT3"
4365 [ $MDSCOUNT -lt 4 ] && skip "needs >= 4 MDTs" && return 0
4366 [[ "$MDS1_VERSION" -ge $(version_code 2.7.56) ]] ||
4367 skip "Need MDS version at least 2.7.56"
4369 ([ $FAILURE_MODE == "HARD" ] &&
4370 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
4371 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
4374 test_112_rename_prepare
4378 mrename $DIR/$tdir/src_dir/src_child $DIR/$tdir/tgt_dir/tgt_child ||
4379 error "rename dir cross MDT failed!"
4384 rm -rf $DIR/$tdir || error "rmdir failed"
4386 run_test 112g "DNE: cross MDT rename, fail MDT1 and MDT4"
4389 [ $MDSCOUNT -lt 4 ] && skip "needs >= 4 MDTs" && return 0
4390 [[ "$MDS1_VERSION" -ge $(version_code 2.7.56) ]] ||
4391 skip "Need MDS version at least 2.7.56"
4393 ([ $FAILURE_MODE == "HARD" ] &&
4394 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
4395 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
4398 test_112_rename_prepare
4402 mrename $DIR/$tdir/src_dir/src_child $DIR/$tdir/tgt_dir/tgt_child ||
4403 error "rename dir cross MDT failed!"
4408 rm -rf $DIR/$tdir || error "rmdir failed"
4410 run_test 112h "DNE: cross MDT rename, fail MDT2 and MDT3"
4413 [ $MDSCOUNT -lt 4 ] && skip "needs >= 4 MDTs" && return 0
4414 [[ "$MDS1_VERSION" -ge $(version_code 2.7.56) ]] ||
4415 skip "Need MDS version at least 2.7.56"
4417 ([ $FAILURE_MODE == "HARD" ] &&
4418 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
4419 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
4422 test_112_rename_prepare
4426 mrename $DIR/$tdir/src_dir/src_child $DIR/$tdir/tgt_dir/tgt_child ||
4427 error "rename dir cross MDT failed!"
4432 rm -rf $DIR/$tdir || error "rmdir failed"
4434 run_test 112i "DNE: cross MDT rename, fail MDT2 and MDT4"
4437 [ $MDSCOUNT -lt 4 ] && skip "needs >= 4 MDTs" && return 0
4438 [[ "$MDS1_VERSION" -ge $(version_code 2.7.56) ]] ||
4439 skip "Need MDS version at least 2.7.56"
4441 ([ $FAILURE_MODE == "HARD" ] &&
4442 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
4443 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
4446 test_112_rename_prepare
4450 mrename $DIR/$tdir/src_dir/src_child $DIR/$tdir/tgt_dir/tgt_child ||
4451 error "rename dir cross MDT failed!"
4456 rm -rf $DIR/$tdir || error "rmdir failed"
4458 run_test 112j "DNE: cross MDT rename, fail MDT3 and MDT4"
4461 [ $MDSCOUNT -lt 4 ] && skip "needs >= 4 MDTs" && return 0
4462 [[ "$MDS1_VERSION" -ge $(version_code 2.7.56) ]] ||
4463 skip "Need MDS version at least 2.7.56"
4465 ([ $FAILURE_MODE == "HARD" ] &&
4466 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
4467 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
4470 test_112_rename_prepare
4475 mrename $DIR/$tdir/src_dir/src_child $DIR/$tdir/tgt_dir/tgt_child ||
4476 error "rename dir cross MDT failed!"
4481 rm -rf $DIR/$tdir || error "rmdir failed"
4483 run_test 112k "DNE: cross MDT rename, fail MDT1,MDT2,MDT3"
4486 [ $MDSCOUNT -lt 4 ] && skip "needs >= 4 MDTs" && return 0
4487 [[ "$MDS1_VERSION" -ge $(version_code 2.7.56) ]] ||
4488 skip "Need MDS version at least 2.7.56"
4490 ([ $FAILURE_MODE == "HARD" ] &&
4491 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
4492 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
4495 test_112_rename_prepare
4500 mrename $DIR/$tdir/src_dir/src_child $DIR/$tdir/tgt_dir/tgt_child ||
4501 error "rename dir cross MDT failed!"
4506 rm -rf $DIR/$tdir || error "rmdir failed"
4508 run_test 112l "DNE: cross MDT rename, fail MDT1,MDT2,MDT4"
4511 [ $MDSCOUNT -lt 4 ] && skip "needs >= 4 MDTs" && return 0
4512 [[ "$MDS1_VERSION" -ge $(version_code 2.7.56) ]] ||
4513 skip "Need MDS version at least 2.7.56"
4515 ([ $FAILURE_MODE == "HARD" ] &&
4516 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
4517 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
4520 test_112_rename_prepare
4525 mrename $DIR/$tdir/src_dir/src_child $DIR/$tdir/tgt_dir/tgt_child ||
4526 error "rename dir cross MDT failed!"
4531 rm -rf $DIR/$tdir || error "rmdir failed"
4533 run_test 112m "DNE: cross MDT rename, fail MDT1,MDT3,MDT4"
4536 [ $MDSCOUNT -lt 4 ] && skip "needs >= 4 MDTs" && return 0
4537 [[ "$MDS1_VERSION" -ge $(version_code 2.7.56) ]] ||
4538 skip "Need MDS version at least 2.7.56"
4540 ([ $FAILURE_MODE == "HARD" ] &&
4541 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
4542 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
4545 test_112_rename_prepare
4550 mrename $DIR/$tdir/src_dir/src_child $DIR/$tdir/tgt_dir/tgt_child ||
4551 error "rename dir cross MDT failed!"
4556 rm -rf $DIR/$tdir || error "rmdir failed"
4558 run_test 112n "DNE: cross MDT rename, fail MDT2,MDT3,MDT4"
4561 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
4562 [[ "$MDS1_VERSION" -ge $(version_code 2.7.56) ]] ||
4563 skip "Need MDS version at least 2.7.56"
4565 ([ $FAILURE_MODE == "HARD" ] &&
4566 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
4567 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
4575 for ((j=0;j<$((MDSCOUNT));j++)); do
4576 fail_index=$((fail_index+1))
4577 index=$((fail_index % MDSCOUNT))
4578 replay_barrier mds$((index + 1))
4579 for ((i=0;i<5;i++)); do
4580 test_mkdir -i$index -c$MDSCOUNT $DIR/$tdir/test_$i ||
4581 error "create striped dir $DIR/$tdir/test_$i"
4584 fail mds$((index + 1))
4585 for ((i=0;i<5;i++)); do
4586 checkstat -t dir $DIR/$tdir/test_$i ||
4587 error "$DIR/$tdir/test_$i does not exist!"
4589 rm -rf $DIR/$tdir/test_* ||
4593 run_test 115 "failover for create/unlink striped directory"
4596 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
4597 [ "$MDS1_VERSION" -lt $(version_code 2.7.55) ] &&
4598 skip "Do not support large update log before 2.7.55" &&
4600 ([ $FAILURE_MODE == "HARD" ] &&
4601 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
4602 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
4606 mkdir_on_mdt0 $DIR/$tdir
4609 # OBD_FAIL_SPLIT_UPDATE_REC 0x1702
4610 do_facet mds1 "lctl set_param fail_loc=0x80001702"
4611 $LFS setdirstripe -i0 -c$MDSCOUNT $DIR/$tdir/striped_dir
4614 $CHECKSTAT -t dir $DIR/$tdir/striped_dir ||
4615 error "stried_dir does not exists"
4617 run_test 116a "large update log master MDT recovery"
4620 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
4621 [ "$MDS1_VERSION" -lt $(version_code 2.7.55) ] &&
4622 skip "Do not support large update log before 2.7.55" &&
4625 ([ $FAILURE_MODE == "HARD" ] &&
4626 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
4627 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
4631 mkdir_on_mdt0 $DIR/$tdir
4634 # OBD_FAIL_SPLIT_UPDATE_REC 0x1702
4635 do_facet mds2 "lctl set_param fail_loc=0x80001702"
4636 $LFS setdirstripe -i0 -c$MDSCOUNT $DIR/$tdir/striped_dir
4639 $CHECKSTAT -t dir $DIR/$tdir/striped_dir ||
4640 error "stried_dir does not exists"
4642 run_test 116b "large update log slave MDT recovery"
4645 [ $MDSCOUNT -lt 4 ] && skip "needs >= 4 MDTs" && return 0
4646 ([ $FAILURE_MODE == "HARD" ] &&
4647 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
4648 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
4654 $LFS setdirstripe -i0 -c$MDSCOUNT $DIR/$tdir/remote_dir
4655 $LFS setdirstripe -i1 -c$MDSCOUNT $DIR/$tdir/remote_dir_1
4658 # Let's set rdonly on all MDTs, so client will send
4659 # replay requests on all MDTs and replay these requests
4660 # at the same time. This test will verify the recovery
4661 # will not be deadlock in this case, LU-7531.
4662 for ((index = 0; index < $((MDSCOUNT)); index++)); do
4663 replay_barrier mds$((index + 1))
4664 if [ -z $mds_indexs ]; then
4665 mds_indexs="${mds_indexs}mds$((index+1))"
4667 mds_indexs="${mds_indexs},mds$((index+1))"
4671 rm -rf $DIR/$tdir/remote_dir
4672 rm -rf $DIR/$tdir/remote_dir_1
4676 rm -rf $DIR/$tdir || error "rmdir failed"
4678 run_test 117 "DNE: cross MDT unlink, fail MDT1 and MDT2"
4681 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
4682 [ "$MDS1_VERSION" -lt $(version_code 2.7.64) ] &&
4683 skip "Do not support large update log before 2.7.64" &&
4688 $LFS setdirstripe -c2 $DIR/$tdir/striped_dir ||
4689 error "setdirstripe fails"
4690 $LFS setdirstripe -c2 $DIR/$tdir/striped_dir1 ||
4691 error "setdirstripe fails 1"
4692 rm -rf $DIR/$tdir/striped_dir* || error "rmdir fails"
4694 # OBD_FAIL_INVALIDATE_UPDATE 0x1705
4695 do_facet mds1 "lctl set_param fail_loc=0x1705"
4696 $LFS setdirstripe -c2 $DIR/$tdir/striped_dir
4697 $LFS setdirstripe -c2 $DIR/$tdir/striped_dir1
4698 do_facet mds1 "lctl set_param fail_loc=0x0"
4701 $LFS setdirstripe -c2 $DIR/$tdir/striped_dir
4702 $LFS setdirstripe -c2 $DIR/$tdir/striped_dir1
4707 run_test 118 "invalidate osp update will not cause update log corruption"
4710 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
4711 [ "$MDS1_VERSION" -lt $(version_code 2.7.64) ] &&
4712 skip "Do not support large update log before 2.7.64" &&
4715 local hard_timeout=$(do_facet mds1 \
4716 "lctl get_param -n mdt.$FSNAME-MDT0000.recovery_time_hard")
4718 local clients=${CLIENTS:-$HOSTNAME}
4719 local time_min=$(recovery_time_min)
4721 mkdir_on_mdt0 $DIR/$tdir
4722 mkdir $DIR/$tdir/tmp
4723 rmdir $DIR/$tdir/tmp
4726 mkdir $DIR/$tdir/dir_1
4727 for ((i = 0; i < 20; i++)); do
4728 $LFS setdirstripe -i0 -c2 $DIR/$tdir/stripe_dir-$i
4735 #define OBD_FAIL_TGT_REPLAY_DELAY 0x714
4736 do_facet mds1 $LCTL set_param fail_loc=0x80000714
4737 #sleep (timeout + 5), so mds will evict the client exports,
4738 #but DNE update recovery will keep going.
4739 do_facet mds1 $LCTL set_param fail_val=$((time_min + 5))
4741 mount_facet mds1 "-o recovery_time_hard=$time_min"
4743 wait_clients_import_state "$clients" mds1 FULL
4745 clients_up || clients_up || error "failover df: $?"
4747 #revert back the hard timeout
4748 do_facet mds1 $LCTL set_param \
4749 mdt.$FSNAME-MDT0000.recovery_time_hard=$hard_timeout
4751 for ((i = 0; i < 20; i++)); do
4752 stripe_count=$($LFS getdirstripe -c $DIR/$tdir/stripe_dir-$i)
4753 [ $stripe_count == 2 ] || {
4754 error "stripe_dir-$i creation replay fails"
4759 run_test 119 "timeout of normal replay does not cause DNE replay fails "
4762 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
4763 [ "$MDS1_VERSION" -lt $(version_code 2.7.64) ] &&
4764 skip "Do not support large update log before 2.7.64" &&
4767 mkdir_on_mdt0 $DIR/$tdir
4768 replay_barrier_nosync mds1
4769 for ((i = 0; i < 20; i++)); do
4770 mkdir $DIR/$tdir/dir-$i || {
4771 error "create dir-$i fails"
4774 $LFS setdirstripe -i0 -c2 $DIR/$tdir/stripe_dir-$i || {
4775 error "create stripe_dir-$i fails"
4780 stack_trap fail_abort_cleanup RETURN
4783 for ((i = 0; i < 20; i++)); do
4784 [ ! -e "$DIR/$tdir/dir-$i" ] || {
4785 error "dir-$i still exists"
4788 [ ! -e "$DIR/$tdir/stripe_dir-$i" ] || {
4789 error "stripe_dir-$i still exists"
4794 run_test 120 "DNE fail abort should stop both normal and DNE replay"
4797 [ "$MDS1_VERSION" -lt $(version_code 2.10.90) ] &&
4798 skip "Don't support it before 2.11" &&
4801 local at_max_saved=$(at_max_get mds)
4803 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
4804 cancel_lru_locks mdc
4806 multiop_bg_pause $DIR/$tfile s_s || error "multiop $DIR/$tfile failed"
4809 lctl set_param -n ldlm.cancel_unused_locks_before_replay "0"
4815 #define OBD_FAIL_TGT_RECOVERY_REQ_RACE 0x721
4816 do_facet $SINGLEMDS "lctl set_param fail_loc=0x721 fail_val=0"
4820 wait_clients_import_state "$clients" mds1 FULL
4821 clients_up || clients_up || error "failover df: $?"
4824 wait $mpid || error "multiop_bg_pause pid failed"
4826 do_facet $SINGLEMDS "lctl set_param fail_loc=0x0"
4827 lctl set_param -n ldlm.cancel_unused_locks_before_replay "1"
4828 at_max_set $at_max_saved mds
4831 run_test 121 "lock replay timed out and race"
4834 [ "$MDS1_VERSION" -lt $(version_code 2.10.90) ] &&
4835 skip "Do not support Data-on-MDT before 2.11"
4837 replay_barrier $SINGLEMDS
4838 $LFS setstripe -E 1M -L mdt -E EOF -c 2 $DIR/$tfile
4841 [ $($LFS getstripe -L $DIR/$tfile) == "mdt" ] ||
4842 error "Fail to replay DoM file creation"
4844 run_test 130a "DoM file create (setstripe) replay"
4847 [ "$MDS1_VERSION" -lt $(version_code 2.10.90) ] &&
4848 skip "Do not support Data-on-MDT before 2.11"
4850 mkdir_on_mdt0 $DIR/$tdir
4851 $LFS setstripe -E 1M -L mdt -E EOF -c 2 $DIR/$tdir
4852 replay_barrier $SINGLEMDS
4853 touch $DIR/$tdir/$tfile
4856 [ $($LFS getstripe -L $DIR/$tdir/$tfile) == "mdt" ] ||
4857 error "Fail to replay DoM file creation"
4859 run_test 130b "DoM file create (inherited) replay"
4862 [ "$MDS1_VERSION" -lt $(version_code 2.10.90) ] &&
4863 skip "Do not support Data-on-MDT before 2.11"
4865 $LFS setstripe -E 1M -L mdt -E EOF -c 2 $DIR/$tfile
4866 replay_barrier $SINGLEMDS
4867 echo "dom_data" | dd of=$DIR/$tfile bs=8 count=1
4868 # lock is not canceled and will be replayed
4871 [ $(cat $DIR/$tfile) == "dom_data" ] ||
4872 error "Wrong file content after failover"
4874 run_test 131a "DoM file write lock replay"
4877 [ "$MDS1_VERSION" -lt $(version_code 2.10.90) ] &&
4878 skip "Do not support Data-on-MDT before 2.11"
4880 # refresh grants so write after replay_barrier doesn't
4882 $LFS setstripe -E 1M -L mdt -E EOF -c 2 $DIR/$tfile-2
4883 stack_trap "rm -f $DIR/$tfile-2"
4884 dd if=/dev/zero of=$DIR/$tfile-2 bs=64k count=2 ||
4886 $LFS setstripe -E 1M -L mdt -E EOF -c 2 $DIR/$tfile
4887 replay_barrier $SINGLEMDS
4888 echo "dom_data" | dd of=$DIR/$tfile bs=8 count=1
4889 cancel_lru_locks mdc
4893 [ $(cat $DIR/$tfile) == "dom_data" ] ||
4894 error "Wrong file content after failover"
4896 run_test 131b "DoM file write replay"
4899 [ "$MDS1_VERSION" -lt $(version_code 2.12.0) ] &&
4900 skip "Need MDS version 2.12.0 or later"
4902 $LFS setstripe -E 1M -c 1 -E EOF -c 2 $DIR/$tfile
4903 replay_barrier $SINGLEMDS
4904 # write over the first component size cause next component instantiation
4905 dd if=/dev/urandom of=$DIR/$tfile bs=1M count=1 seek=1 ||
4906 error "dd to $DIR/$tfile failed"
4907 lfs getstripe $DIR/$tfile
4909 cksum=$(md5sum $DIR/$tfile | awk '{print $1}')
4910 $LFS getstripe -I2 $DIR/$tfile | grep -q lmm_objects ||
4911 error "Component #1 was not instantiated"
4915 lfs getstripe $DIR/$tfile
4916 $LFS getstripe -I2 $DIR/$tfile | grep -q lmm_objects ||
4917 error "Component #1 instantiation was not replayed"
4918 cksum2=$(md5sum $DIR/$tfile | awk '{print $1}')
4919 if [ $cksum != $cksum2 ] ; then
4920 error_noexit "New cksum $cksum2 does not match original $cksum"
4923 run_test 132a "PFL new component instantiate replay"
4926 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
4927 ([ $FAILURE_MODE == "HARD" ] &&
4928 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
4929 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
4932 local remote_dir=$DIR/$tdir/remote_dir
4934 mkdir -p $DIR/$tdir || error "mkdir $DIR/$tdir failed"
4935 $LFS mkdir -i 1 $remote_dir
4938 do_facet mds2 $LCTL set_param seq.srv*MDT0001.space=clear
4940 zconf_mount $(hostname) $MOUNT
4941 client_up || return 1
4943 #define OBD_FAIL_MDS_ALL_REQUEST_NET 0x123
4945 do_facet mds1 $LCTL set_param fail_val=700 fail_loc=0x80000123
4946 cp /etc/hosts $remote_dir/file &
4952 wait $pid || error "cp failed"
4953 rm -rf $DIR/$tdir || error "rmdir failed"
4957 run_test 133 "check resend of ongoing requests for lwp during failover"
4960 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs" && return 0
4961 (( $MDS1_VERSION >= $(version_code 2.13.56) )) ||
4962 skip "need MDS version >= 2.13.56"
4965 pool_add_targets pool_134 1 1
4967 mkdir -p $DIR/$tdir/{A,B}
4968 $LFS setstripe -p pool_134 $DIR/$tdir/A
4969 $LFS setstripe -E EOF -p pool_134 $DIR/$tdir/B
4973 touch $DIR/$tdir/A/$tfile || error "touch non-pfl file failed"
4974 touch $DIR/$tdir/B/$tfile || error "touch pfl failed"
4978 [ -f $DIR/$tdir/A/$tfile ] || error "non-pfl file does not exist"
4979 [ -f $DIR/$tdir/B/$tfile ] || error "pfl file does not exist"
4981 run_test 134 "replay creation of a file created in a pool"
4988 # make sure we are using the primary server
4989 [[ $(facet_active ost1) == "ost1" ]] || fail ost1
4991 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
4994 $LFS setstripe -S $((128 * 1024)) -i 0 $DIR/$tdir
4996 # Init all the clients connections (write lastrcv on the OST)
5000 old_replay=$($LCTL get_param ldlm.cancel_unused_locks_before_replay)
5001 $LCTL set_param ldlm.cancel_unused_locks_before_replay=0
5002 stack_trap "$LCTL set_param $old_replay" EXIT
5004 # Create 20 files so we have 20 ost locks
5005 for i in $(seq 20) ; do
5006 echo blah > $DIR/$tdir/file.${i} & PID+="$! "
5014 #define OBD_FAIL_LDLM_LOCK_REPLAY 0x32d
5015 # Make sure lock replay server side never completes and errors out.
5016 do_rpc_nodes $(facet_active_host ost1) \
5017 load_module ../libcfs/libcfs/libcfs
5018 do_facet ost1 "$LCTL set_param fail_loc=0x32d fail_val=20"
5021 # Now make sure we notice
5022 (sync;sync;sync;echo "End of sync") & PID=$!
5023 wait_clients_import_state ${HOSTNAME} ost1 REPLAY_LOCKS
5024 kill -0 $PID || error "Unexpected sync success"
5031 do_rpc_nodes $(facet_active_host ost1) \
5032 load_module ../libcfs/libcfs/libcfs
5033 do_facet ost1 "$LCTL set_param fail_loc=0"
5037 clients_up || clients_up || error "$LFS df $MOUNT failed"
5039 wait $PID || error "Fail to sync"
5040 echo blah > $DIR/$tdir/file.test2
5044 run_test 135 "Server failure in lock replay phase"
5047 (( $MDSCOUNT >= 3 )) || skip "needs > 2 MDTs"
5048 (( MDS1_VERSION >= $(version_code 2.15.53) )) ||
5049 skip "need MDS version >= 2.15.53 for LU-16536 fix"
5051 $LFS mkdir -i0 -c3 $DIR/$tdir || error "can't mkdir"
5052 $LFS getdirstripe $DIR/$tdir
5055 #define OBD_FAIL_OUT_DROP_DESTROY 0x170b
5056 local mdts=$(comma_list $(mdts_nodes))
5057 do_nodes $mdts $LCTL set_param fail_loc=0x170b
5063 start mds1 $(mdsdevname 1) $MDS_MOUNT_OPTS || error "MDT1 start failed"
5064 start mds2 $(mdsdevname 2) $MDS_MOUNT_OPTS || error "MDT2 start failed"
5065 start mds3 $(mdsdevname 3) $MDS_MOUNT_OPTS || error "MDT3 star"
5067 run_test 136 "MDS to disconnect all OSPs first, then cleanup ldlm"
5070 [[ -z $RCLIENTS ]] && skip "Need remote client"
5074 rcli=$(echo $RCLIENTS | cut -d ' ' -f 1)
5076 echo "Selected \"$rcli\" from \"$RCLIENTS\""
5078 # We want idle disconnect enabled on all targets except OST0000. Test
5079 # assumes all nodes are configured the same.
5080 old=$(do_node $rcli "$LCTL get_param -n *.*.idle_timeout 2>/dev/null |
5082 [[ -n $old ]] || error "Cannot determine current idle_timeout"
5084 if ((old == 0)); then
5085 do_node "$rcli" "$LCTL set_param *.*.idle_timeout=10"
5086 do_node "$rcli" "$LCTL set_param osc.*OST0000*.idle_timeout=0"
5087 stack_trap "do_node $rcli $LCTL set_param *.*.idle_timeout=$old"
5089 do_node "$rcli" "$LCTL set_param osc.*OST0000*.idle_timeout=0"
5090 stack_trap "do_node $rcli $LCTL set_param osc.*OST0000*.idle_timeout=$old"
5093 # Ensure OST0 import is idle
5094 wait_update "$rcli" \
5095 "$LCTL get_param osc.*OST0000*.import | \
5096 awk 'BEGIN{ count=0 } /idle: 0/ { count+=1 } \
5097 END { print count }'" \
5100 (( $? != 0 )) && error "OST0000 not idle after 30s"
5102 # Send ping to ensure import is FULL
5103 do_node "$rcli" "lctl set_param osc.*OST0000*.ping=1" ||
5104 error "OBD ping failed"
5108 conns=( $(do_node "$rcli" "$LCTL get_param *.*.import" |
5109 awk '/connection_attempts:/{print $NF}' | xargs echo) )
5113 saved_debug=$(do_node "$rcli" \
5114 "cat /sys/module/libcfs/parameters/libcfs_debug" \
5116 [[ -z $saved_debug ]] && error "Failed to get existing debug"
5117 stack_trap "do_node $rcli $LCTL set_param debug=$saved_debug"
5118 do_node "$rcli" "$LCTL set_param debug=+info+rpctrace"
5120 # From lustre/obdclass/class_obd.c
5121 # unsigned int ping_interval = (OBD_TIMEOUT_DEFAULT > 4) ?
5122 # (OBD_TIMEOUT_DEFAULT / 4) : 1;
5123 # Delay a ping for 3 intervals
5126 timeout=$(do_node "$rcli" "$LCTL get_param -n timeout")
5127 (( timeout > 4 )) && delay=$((3 * timeout / 4)) || delay=3
5129 do_node "$rcli" "$LCTL clear"
5130 log "delay ping ${delay}s"
5132 #define OBD_FAIL_PTLRPC_DELAY_SEND_FAIL 0x535
5133 do_node "$rcli" "$LCTL set_param fail_loc=0x80000535 fail_val=${delay}"
5134 # Send ping that will be delayed for ${delay} seconds
5135 # This races with the pinger, but it is okay if a ping sent by pinger
5136 # thread is delayed instead
5137 do_node "$rcli" "lctl set_param osc.*OST0000*.ping=1"
5139 local logfile="$TMP/lustre-log-${TESTNAME}.log"
5143 local begin=$SECONDS
5144 local max_wait=$((delay + 1))
5147 while (( $waited <= $max_wait )); do
5148 [[ -z $sleep ]] || sleep $sleep
5150 waited=$((SECONDS - begin))
5151 do_node "$rcli" "$LCTL dk" >> ${logfile}
5153 if ! grep -q 'fail_timeout id 535 sleeping for' $logfile; then
5154 reason="Did not hit fail_loc"
5158 if ! grep -q 'cfs_fail_timeout id 535 awake' $logfile; then
5159 reason="Delayed send did not wake"
5163 nsent=$(grep -c "ptl_send_rpc.*o400->.*OST0000" $logfile)
5164 if (( nsent <= 1 )); then
5165 reason="Did not send more than 1 obd ping"
5169 expired=$(grep "Request sent has timed out .* o400->" $logfile)
5170 if [[ -z $expired ]]; then
5171 reason="RPC did not time out"
5178 if [[ -n $reason ]]; then
5189 conns2=( $(do_node "$rcli" "$LCTL get_param *.*.import" |
5190 awk '/connection_attempts:/{print $NF}' | xargs echo) )
5192 echo "conns: ${conns[*]}"
5194 echo "conns2: ${conns2[*]}"
5196 (( ${#conns[@]} != ${#conns2[@]} )) &&
5197 error "Expected ${#conns[@]} imports found ${#conns2[@]}"
5201 for ((i = 0; i < ${#conns[@]}; i++)); do
5202 if (( conns[i] != conns2[i] )); then
5203 error "New connection attempt ${conns[i]} -> ${conns2[i]}"
5209 run_test 200 "Dropping one OBD_PING should not cause disconnect"
5211 complete_test $SECONDS
5212 check_and_cleanup_lustre