3 # Run select tests by setting ONLY, or as arguments to the script.
4 # Skip specific tests by setting EXCEPT.
11 LUSTRE=${LUSTRE:-$(dirname $0)/..}
12 . $LUSTRE/tests/test-framework.sh
16 ALWAYS_EXCEPT="$SANITY_SCRUB_EXCEPT"
18 [ "$SLOW" = "no" ] && EXCEPT_SLOW=""
19 # UPDATE THE COMMENT ABOVE WITH BUG NUMBERS WHEN CHANGING ALWAYS_EXCEPT!
23 require_dsh_mds || exit 0
27 if ! check_versions; then
28 skip "It is NOT necessary to test scrub under interoperation mode"
34 SAVED_MDSSIZE=${MDSSIZE}
35 SAVED_OSTSIZE=${OSTSIZE}
36 SAVED_OSTCOUNT=${OSTCOUNT}
38 # use small MDS + OST size to speed formatting time
39 # do not use too small MDSSIZE/OSTSIZE, which affect the default journal size
40 # 400M MDT device can guarantee uninitialized groups during the OI scrub
41 [[ $MDSSIZE -lt 400000 || "$mds1_FSTYPE" == ldiskfs ]] && MDSSIZE=400000
42 [[ $OSTSIZE -lt 400000 || "$ost1_FSTYPE" == ldiskfs ]] && OSTSIZE=400000
44 # no need too many OSTs, to reduce the format/start/stop overhead
45 [ $OSTCOUNT -gt 4 ] && OSTCOUNT=4
47 # build up a clean test environment.
48 REFORMAT="yes" check_and_setup_lustre
50 MDT_DEV="${FSNAME}-MDT0000"
51 OST_DEV="${FSNAME}-OST0000"
57 # use "lfsck_start -A" when we no longer need testing interop
58 for n in $(seq $MDSCOUNT); do
59 do_facet mds$n $LCTL lfsck_start -M $(facet_svc mds$n) \
61 error "($error_id) Failed to start OI scrub on mds$n"
69 # use "lfsck_stop -A" when we no longer need testing interop
70 for n in $(seq $MDSCOUNT); do
71 do_facet mds$n $LCTL lfsck_stop -M $(facet_svc mds$n) ||
72 error "($error_id) Failed to stop OI scrub on mds$n"
79 do_facet mds$n $LCTL get_param -n osd-*.$(facet_svc mds$n).oi_scrub
82 START_SCRUB="do_facet $SINGLEMDS $LCTL lfsck_start -M ${MDT_DEV} -t scrub"
83 START_SCRUB_ON_OST="do_facet ost1 $LCTL lfsck_start -M ${OST_DEV} -t scrub"
84 STOP_SCRUB="do_facet $SINGLEMDS $LCTL lfsck_stop -M ${MDT_DEV}"
85 SHOW_SCRUB="do_facet $SINGLEMDS \
86 $LCTL get_param -n osd-*.${MDT_DEV}.oi_scrub"
87 SHOW_SCRUB_ON_OST="do_facet ost1 \
88 $LCTL get_param -n osd-*.${OST_DEV}.oi_scrub"
89 MOUNT_OPTS_SCRUB="$MDS_MOUNT_OPTS -o user_xattr"
90 MOUNT_OPTS_NOSCRUB="$MDS_MOUNT_OPTS -o user_xattr,noscrub"
99 echo "preparing... $(date)"
100 for n in $(seq $MDSCOUNT); do
101 echo "creating $nfiles files on mds$n"
102 test_mkdir -i $((n - 1)) -c1 $DIR/$tdir/mds$n ||
103 error "Failed to create directory mds$n"
104 cp $LUSTRE/tests/*.sh $DIR/$tdir/mds$n ||
105 error "Failed to copy files to mds$n"
106 mkdir -p $DIR/$tdir/mds$n/d_$tfile ||
107 error "mkdir failed on mds$n"
108 touch $DIR/$tdir/mds$n/d_$tfile/f1 > \
109 /dev/null || error "create failed on mds$n"
110 dd if=/dev/zero of=$DIR/$tdir/mds$n/d_$tfile/f2 bs=1M count=1 ||
111 error "write failed on mds$n"
112 if [[ $nfiles -gt 0 ]]; then
113 createmany -m $DIR/$tdir/mds$n/$tfile $nfiles > \
114 /dev/null || error "createmany failed on mds$n"
117 echo "prepared $(date)."
119 [ ! -z $inject ] && [ $inject -eq 2 ] && {
120 #define OBD_FAIL_OSD_NO_OI_ENTRY 0x198
121 do_nodes $(comma_list $(mdts_nodes)) \
122 $LCTL set_param fail_loc=0x198
124 for n in $(seq $MDSCOUNT); do
125 cp $LUSTRE/tests/runas $DIR/$tdir/mds$n ||
126 error "Fail to copy runas to MDS$n"
129 do_nodes $(comma_list $(mdts_nodes)) $LCTL set_param fail_loc=0
132 [ ! -z $inject ] && [ $inject -eq 1 ] &&
133 [ "$mds1_FSTYPE" = "zfs" ] && {
134 #define OBD_FAIL_OSD_FID_MAPPING 0x193
135 do_nodes $(comma_list $(mdts_nodes)) \
136 $LCTL set_param fail_loc=0x193
138 for n in $(seq $MDSCOUNT); do
139 chmod 0400 $DIR/$tdir/mds$n/test-framework.sh
140 chmod 0400 $DIR/$tdir/mds$n/sanity-scrub.sh
143 do_nodes $(comma_list $(mdts_nodes)) $LCTL set_param fail_loc=0
146 cleanup_mount $MOUNT > /dev/null || error "Fail to stop client!"
148 # sync local transactions on every MDT
149 do_nodes $(comma_list $(mdts_nodes)) \
150 "$LCTL set_param -n osd*.*MDT*.force_sync=1"
152 # wait for a while to cancel update logs after transactions committed.
155 # sync again to guarantee all things done.
156 do_nodes $(comma_list $(mdts_nodes)) \
157 "$LCTL set_param -n osd*.*MDT*.force_sync=1"
159 for n in $(seq $MDSCOUNT); do
161 stop mds$n > /dev/null || error "Fail to stop MDS$n!"
164 [ ! -z $inject ] && [ "$mds1_FSTYPE" = "ldiskfs" ] && {
165 if [ $inject -eq 1 ]; then
166 for n in $(seq $MDSCOUNT); do
167 mds_backup_restore mds$n ||
168 error "Backup/restore on mds$n failed"
170 elif [ $inject -eq 2 ]; then
181 for n in $(seq $MDSCOUNT); do
182 start mds$n $(mdsdevname $n) $opts >/dev/null ||
183 error "($error_id) Failed to start mds$n"
191 for n in $(seq $MDSCOUNT); do
192 echo "stopping mds$n"
193 stop mds$n >/dev/null ||
194 error "($error_id) Failed to stop mds$n"
198 scrub_check_status() {
203 for n in $(seq $MDSCOUNT); do
204 wait_update_facet mds$n "$LCTL get_param -n \
205 osd-*.$(facet_svc mds$n).oi_scrub |
206 awk '/^status/ { print \\\$2 }'" "$expected" 6 ||
207 error "($error_id) Expected '$expected' on mds$n"
211 scrub_check_flags() {
217 for n in $(seq $MDSCOUNT); do
218 actual=$(do_facet mds$n $LCTL get_param -n \
219 osd-*.$(facet_svc mds$n).oi_scrub |
220 awk '/^flags/ { print $2 }')
221 if [ "$actual" != "$expected" ]; then
222 error "($error_id) Expected '$expected' on mds$n, but" \
228 scrub_check_params() {
234 for n in $(seq $MDSCOUNT); do
235 actual=$(do_facet mds$n $LCTL get_param -n \
236 osd-*.$(facet_svc mds$n).oi_scrub |
237 awk '/^param/ { print $2 }')
238 if [ "$actual" != "$expected" ]; then
239 error "($error_id) Expected '$expected' on mds$n, but" \
245 scrub_check_repaired() {
252 for n in $(seq $MDSCOUNT); do
253 if [ $dryrun -eq 1 ]; then
254 actual=$(do_facet mds$n $LCTL get_param -n \
255 osd-*.$(facet_svc mds$n).oi_scrub |
256 awk '/^inconsistent:/ { print $2 }')
258 actual=$(do_facet mds$n $LCTL get_param -n \
259 osd-*.$(facet_svc mds$n).oi_scrub |
260 awk '/^updated:/ { print $2 }')
263 if [ $expected -eq 0 -a $actual -ne 0 ]; then
264 error "($error_id) Expected no repaired on mds$n, but" \
268 if [ $expected -ne 0 -a $actual -lt $expected ]; then
269 error "($error_id) Expected '$expected' on mds$n, but" \
279 for n in $(seq $MDSCOUNT); do
280 diff -q $LUSTRE/tests/test-framework.sh \
281 $DIR/$tdir/mds$n/test-framework.sh ||
282 error "($error_id) File data check failed"
286 scrub_check_data2() {
291 for n in $(seq $MDSCOUNT); do
292 diff -q $LUSTRE/tests/$filename \
293 $DIR/$tdir/mds$n/$filename ||
294 error "($error_id) File data check failed"
299 [ "$mds1_FSTYPE" != "ldiskfs" ] && return
305 for n in $(seq $MDSCOUNT); do
306 mds_remove_ois mds$n $index ||
307 error "($error_id) Failed to remove OI .$index on mds$n"
311 scrub_enable_auto() {
312 do_nodes $(comma_list $(mdts_nodes)) $LCTL set_param -n \
317 [ "$mds1_FSTYPE" != "ldiskfs" ] && return
321 do_nodes $(comma_list $(mdts_nodes)) $LCTL set_param -n \
322 osd-*.*.full_scrub_ratio=$ratio
325 full_scrub_threshold_rate() {
326 [ "$mds1_FSTYPE" != "ldiskfs" ] && return
330 do_nodes $(comma_list $(mdts_nodes)) $LCTL set_param -n \
331 osd-*.*.full_scrub_threshold_rate=$rate
334 scrub_enable_index_backup() {
335 do_nodes $(comma_list $(all_server_nodes)) $LCTL set_param -n \
336 osd-*.*.index_backup=1
339 scrub_disable_index_backup() {
340 do_nodes $(comma_list $(all_server_nodes)) $LCTL set_param -n \
341 osd-*.*.index_backup=0
346 echo "starting MDTs without disabling OI scrub"
347 scrub_start_mds 1 "$MOUNT_OPTS_SCRUB"
348 scrub_check_status 2 init
349 scrub_check_flags 3 ""
350 mount_client $MOUNT || error "(4) Fail to start client!"
353 run_test 0 "Do not auto trigger OI scrub for non-backup/restore case"
356 [ -n "$FILESET" ] && skip "Not functional for FILESET set"
359 echo "start $SINGLEMDS without disabling OI scrub: $MOUNT_OPTS_SCRUB"
360 scrub_start_mds 1 "$MOUNT_OPTS_SCRUB"
362 local FLAGS=$($SHOW_SCRUB | awk '/^flags/ { print $2 }')
363 [ -z "$FLAGS" ] || error "(3) Expect empty flags, but got '$FLAGS'"
365 mount_client $MOUNT || error "(4) Fail to start client!"
366 #define OBD_FAIL_OSD_FID_MAPPING 0x193
367 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x193
368 # update .lustre OI mapping
370 do_facet $SINGLEMDS $LCTL set_param fail_loc=0
371 umount_client $MOUNT || error "(5) Fail to stop client!"
373 echo "stop $SINGLEMDS"
374 stop $SINGLEMDS > /dev/null || error "(6) Fail to stop MDS!"
376 echo "start $SINGLEMDS with disabling OI scrub: $MOUNT_OPTS_NOSCRUB"
377 start $SINGLEMDS $(mdsdevname 1) $MOUNT_OPTS_NOSCRUB > /dev/null ||
378 error "(7) Fail to start MDS!"
380 local FLAGS=$($SHOW_SCRUB | awk '/^flags/ { print $2 }')
381 [ "$FLAGS" == "inconsistent" ] ||
382 error "(9) Expect 'inconsistent', but got '$FLAGS'"
384 run_test 1a "Auto trigger initial OI scrub when server mounts"
388 echo "start MDTs without disabling OI scrub"
389 scrub_start_mds 2 "$MOUNT_OPTS_SCRUB"
390 [ "$mds1_FSTYPE" != "ldiskfs" ] ||
391 scrub_check_status 3 completed
392 mount_client $MOUNT || error "(4) Fail to start client!"
393 scrub_check_data2 runas 5
394 scrub_check_status 6 completed
396 run_test 1b "Trigger OI scrub when MDT mounts for OI files remove/recreate case"
399 [ "$mds1_FSTYPE" != "ldiskfs" ] &&
400 skip "ldiskfs special test"
404 # OI files to be removed:
406 # idx 2: oi.16.{2,4,8,16,32}
407 # idx 3: oi.16.{3,9,27}
408 for index in 0 2 3; do
410 scrub_remove_ois 1 $index
411 echo "start MDTs with OI scrub disabled"
412 scrub_start_mds 2 "$MOUNT_OPTS_NOSCRUB"
413 scrub_check_flags 3 recreated
415 scrub_check_status 5 completed
416 scrub_check_flags 6 ""
419 run_test 1c "Auto detect kinds of OI file(s) removed/recreated cases"
422 [ "$mds1_FSTYPE" != "ldiskfs" ] &&
423 skip "ldiskfs special test"
426 echo "starting MDTs without disabling OI scrub"
427 scrub_start_mds 2 "$MOUNT_OPTS_SCRUB"
428 scrub_check_status 3 completed
429 mount_client $MOUNT || error "(4) Fail to start client!"
432 run_test 2 "Trigger OI scrub when MDT mounts for backup/restore case"
434 # test_3 is obsolete, it will be covered by test_5.
436 formatall > /dev/null
440 echo "starting MDTs with OI scrub disabled"
441 scrub_start_mds 2 "$MOUNT_OPTS_NOSCRUB"
442 scrub_check_status 3 init
443 [ "$mds1_FSTYPE" != "ldiskfs" ] ||
444 scrub_check_flags 4 recreated,inconsistent
446 #run_test 3 "Do not trigger OI scrub when MDT mounts if 'noscrub' specified"
450 echo "starting MDTs with OI scrub disabled"
451 scrub_start_mds 2 "$MOUNT_OPTS_NOSCRUB"
452 [ "$mds1_FSTYPE" != "ldiskfs" ] ||
453 scrub_check_flags 4 recreated,inconsistent
454 mount_client $MOUNT || error "(5) Fail to start client!"
460 scrub_check_status 7 completed
461 scrub_check_flags 8 ""
464 for n in $(seq $MDSCOUNT); do
465 updated0[$n]=$(scrub_status $n |
466 awk '/^prior_updated/ { print $2 }')
469 scrub_check_data2 sanity-scrub.sh 9
473 for n in $(seq $MDSCOUNT); do
474 updated1[$n]=$(scrub_status $n |
475 awk '/^prior_updated/ { print $2 }')
476 [ ${updated0[$n]} -eq ${updated1[$n]} ] ||
477 error "(10) NOT auto trigger full scrub as expected"
480 run_test 4a "Auto trigger OI scrub if bad OI mapping was found (1)"
483 [ "$mds1_FSTYPE" != "ldiskfs" ] &&
484 skip "ldiskfs special test"
487 echo "starting MDTs with OI scrub disabled"
488 scrub_start_mds 2 "$MOUNT_OPTS_NOSCRUB"
489 scrub_check_flags 4 recreated,inconsistent
490 mount_client $MOUNT || error "(5) Fail to start client!"
493 full_scrub_threshold_rate 10000
497 scrub_check_status 7 completed
498 scrub_check_flags 8 ""
501 for n in $(seq $MDSCOUNT); do
502 updated0[$n]=$(scrub_status $n |
503 awk '/^prior_updated/ { print $2 }')
505 echo "OI scrub on MDS$n status for the 1st time:"
506 do_facet mds$n $LCTL get_param -n \
507 osd-*.$(facet_svc mds$n).oi_scrub
510 scrub_check_data2 sanity-scrub.sh 9
513 scrub_check_status 10 completed
514 scrub_check_flags 11 ""
517 for n in $(seq $MDSCOUNT); do
518 updated1[$n]=$(scrub_status $n |
519 awk '/^prior_updated/ { print $2 }')
521 echo "OI scrub on MDS$n status for the 2nd time:"
522 do_facet mds$n $LCTL get_param -n \
523 osd-*.$(facet_svc mds$n).oi_scrub
525 [ ${updated0[$n]} -lt ${updated1[$n]} ] ||
526 error "(12) Auto trigger full scrub unexpectedly"
529 for n in $(seq $MDSCOUNT); do
530 ls -l $DIR/$tdir/mds$n/*.sh > /dev/null ||
531 error "(13) fail to ls"
535 scrub_check_status 14 completed
536 scrub_check_flags 15 ""
538 for n in $(seq $MDSCOUNT); do
539 updated0[$n]=$(scrub_status $n |
540 awk '/^prior_updated/ { print $2 }')
542 echo "OI scrub on MDS$n status for the 3rd time:"
543 do_facet mds$n $LCTL get_param -n \
544 osd-*.$(facet_svc mds$n).oi_scrub
546 [ ${updated0[$n]} -gt ${updated1[$n]} ] ||
547 error "(16) Auto trigger full scrub unexpectedly"
550 for n in $(seq $MDSCOUNT); do
551 ls -l $DIR/$tdir/mds$n/d_${tfile}/ || error "(17) fail to ls"
555 for n in $(seq $MDSCOUNT); do
556 updated1[$n]=$(scrub_status $n |
557 awk '/^prior_updated/ { print $2 }')
558 [ ${updated0[$n]} -eq ${updated1[$n]} ] || {
559 echo "OI scrub on MDS$n status for the 4th time:"
560 do_facet mds$n $LCTL get_param -n \
561 osd-*.$(facet_svc mds$n).oi_scrub
563 error "(18) NOT auto trigger full scrub as expected"
567 run_test 4b "Auto trigger OI scrub if bad OI mapping was found (2)"
570 [ "$mds1_FSTYPE" != "ldiskfs" ] &&
571 skip "ldiskfs special test"
574 echo "starting MDTs with OI scrub disabled"
575 scrub_start_mds 2 "$MOUNT_OPTS_NOSCRUB"
576 scrub_check_flags 4 recreated,inconsistent
577 mount_client $MOUNT || error "(5) Fail to start client!"
580 full_scrub_threshold_rate 20
584 scrub_check_status 7 completed
585 scrub_check_flags 8 ""
588 for n in $(seq $MDSCOUNT); do
589 updated0[$n]=$(scrub_status $n |
590 awk '/^prior_updated/ { print $2 }')
592 echo "OI scrub on MDS$n status for the 1st time:"
593 do_facet mds$n $LCTL get_param -n \
594 osd-*.$(facet_svc mds$n).oi_scrub
597 scrub_check_data2 sanity-scrub.sh 9
600 scrub_check_status 10 completed
601 scrub_check_flags 11 ""
604 for n in $(seq $MDSCOUNT); do
605 updated1[$n]=$(scrub_status $n |
606 awk '/^prior_updated/ { print $2 }')
608 echo "OI scrub on MDS$n status for the 2nd time:"
609 do_facet mds$n $LCTL get_param -n \
610 osd-*.$(facet_svc mds$n).oi_scrub
612 [ ${updated0[$n]} -lt ${updated1[$n]} ] ||
613 error "(12) Auto trigger full scrub unexpectedly"
616 for n in $(seq $MDSCOUNT); do
617 ls -l $DIR/$tdir/mds$n/*.sh > /dev/null ||
618 error "(13) fail to ls"
622 scrub_check_status 14 completed
623 scrub_check_flags 15 ""
625 for n in $(seq $MDSCOUNT); do
626 updated0[$n]=$(scrub_status $n |
627 awk '/^prior_updated/ { print $2 }')
629 echo "OI scrub on MDS$n status for the 3rd time:"
630 do_facet mds$n $LCTL get_param -n \
631 osd-*.$(facet_svc mds$n).oi_scrub
633 [ ${updated0[$n]} -gt ${updated1[$n]} ] ||
634 error "(16) Auto trigger full scrub unexpectedly"
637 for n in $(seq $MDSCOUNT); do
638 ls -l $DIR/$tdir/mds$n/${tfile}1 || error "(17) fail to ls"
642 for n in $(seq $MDSCOUNT); do
643 updated1[$n]=$(scrub_status $n |
644 awk '/^prior_updated/ { print $2 }')
645 [ ${updated0[$n]} -eq ${updated1[$n]} ] || {
646 echo "OI scrub on MDS$n status for the 4th time:"
647 do_facet mds$n $LCTL get_param -n \
648 osd-*.$(facet_svc mds$n).oi_scrub
650 error "(18) NOT auto trigger full scrub as expected"
654 run_test 4c "Auto trigger OI scrub if bad OI mapping was found (3)"
657 [ "$mds1_FSTYPE" != "ldiskfs" ] && skip "ldiskfs only test"
661 #define OBD_FAIL_OSD_DUPLICATE_MAP 0x19b
662 do_nodes $(comma_list $(osts_nodes)) $LCTL set_param fail_loc=0x19b
663 for i in {1..100}; do
664 echo $i > $DIR/$tdir/f_$i || error "write f_$i failed"
666 do_nodes $(comma_list $(osts_nodes)) $LCTL set_param fail_loc=0
668 for i in {101..200}; do
669 echo $i > $DIR/$tdir/f_$i || error "write f_$i failed"
672 for i in {1..200}; do
673 echo $i | cmp $DIR/$tdir/f_$i - || error "f_$i data corrupt"
676 run_test 4d "FID in LMA mismatch with object FID won't block create"
679 formatall > /dev/null
683 echo "starting MDTs with OI scrub disabled (1)"
684 scrub_start_mds 2 "$MOUNT_OPTS_NOSCRUB"
685 scrub_check_status 3 init
686 [ "$mds1_FSTYPE" != "ldiskfs" ] ||
687 scrub_check_flags 4 recreated,inconsistent
688 mount_client $MOUNT || error "(5) Fail to start client!"
692 #define OBD_FAIL_OSD_SCRUB_DELAY 0x190
693 do_nodes $(comma_list $(mdts_nodes)) \
694 $LCTL set_param fail_val=3 fail_loc=0x190
697 umount_client $MOUNT || error "(7) Fail to stop client!"
698 scrub_check_status 8 scanning
700 #define OBD_FAIL_OSD_SCRUB_CRASH 0x191
701 do_nodes $(comma_list $(mdts_nodes)) $LCTL set_param fail_loc=0x191
706 do_nodes $(comma_list $(mdts_nodes)) \
707 $LCTL set_param fail_loc=0 fail_val=0
709 echo "starting MDTs with OI scrub disabled (2)"
710 scrub_start_mds 10 "$MOUNT_OPTS_NOSCRUB"
711 scrub_check_status 11 crashed
714 #define OBD_FAIL_OSD_SCRUB_DELAY 0x190
715 do_nodes $(comma_list $(mdts_nodes)) \
716 $LCTL set_param fail_val=3 fail_loc=0x190
718 echo "starting MDTs without disabling OI scrub"
719 scrub_start_mds 13 "$MOUNT_OPTS_SCRUB"
720 scrub_check_status 14 scanning
722 #define OBD_FAIL_OSD_SCRUB_FATAL 0x192
723 do_nodes $(comma_list $(mdts_nodes)) $LCTL set_param fail_loc=0x192
725 scrub_check_status 15 failed
726 mount_client $MOUNT || error "(16) Fail to start client!"
729 do_nodes $(comma_list $(mdts_nodes)) \
730 $LCTL set_param fail_loc=0 fail_val=0
735 for n in $(seq $MDSCOUNT); do
736 stat $DIR/$tdir/mds$n/sanity-scrub.sh &
740 for n in $(seq $MDSCOUNT); do
742 error "(18) Fail to stat mds$n/sanity-scrub.sh"
745 scrub_check_status 19 completed
746 scrub_check_flags 20 ""
748 run_test 5 "OI scrub state machine"
752 echo "starting MDTs with OI scrub disabled"
753 scrub_start_mds 2 "$MOUNT_OPTS_NOSCRUB"
754 [ "$mds1_FSTYPE" != "ldiskfs" ] ||
755 scrub_check_flags 4 recreated,inconsistent
756 mount_client $MOUNT || error "(5) Fail to start client!"
760 #define OBD_FAIL_OSD_SCRUB_DELAY 0x190
761 do_nodes $(comma_list $(mdts_nodes)) \
762 $LCTL set_param fail_val=2 fail_loc=0x190
766 # Sleep 5 sec to guarantee at least one object processed by OI scrub
768 # Fail the OI scrub to guarantee there is at least one checkpoint
769 #define OBD_FAIL_OSD_SCRUB_FATAL 0x192
770 do_nodes $(comma_list $(mdts_nodes)) $LCTL set_param fail_loc=0x192
772 scrub_check_status 7 failed
774 #define OBD_FAIL_OSD_SCRUB_DELAY 0x190
775 do_nodes $(comma_list $(mdts_nodes)) \
776 $LCTL set_param fail_val=3 fail_loc=0x190
779 for n in $(seq $MDSCOUNT); do
780 # stat will re-trigger OI scrub
781 stat $DIR/$tdir/mds$n/sanity-scrub.sh ||
782 error "(8) Failed to stat mds$n/sanity-scrub.sh"
785 umount_client $MOUNT || error "(9) Fail to stop client!"
786 scrub_check_status 10 scanning
788 #define OBD_FAIL_OSD_SCRUB_CRASH 0x191
789 do_nodes $(comma_list $(mdts_nodes)) $LCTL set_param fail_loc=0x191
793 for n in $(seq $MDSCOUNT); do
794 position0[$n]=$(scrub_status $n |
795 awk '/^last_checkpoint_position/ {print $2}')
796 position0[$n]=$((${position0[$n]} + 1))
801 #define OBD_FAIL_OSD_SCRUB_DELAY 0x190
802 do_nodes $(comma_list $(mdts_nodes)) \
803 $LCTL set_param fail_val=3 fail_loc=0x190
805 echo "starting MDTs without disabling OI scrub"
806 scrub_start_mds 12 "$MOUNT_OPTS_SCRUB"
808 scrub_check_status 13 scanning
811 for n in $(seq $MDSCOUNT); do
812 position1[$n]=$(scrub_status $n |
813 awk '/^latest_start_position/ {print $2}')
814 if [ ${position0[$n]} -ne ${position1[$n]} ]; then
815 error "(14) Expected position ${position0[$n]}, but" \
816 "got ${position1[$n]}"
820 do_nodes $(comma_list $(mdts_nodes)) \
821 $LCTL set_param fail_loc=0 fail_val=0
823 scrub_check_status 15 completed
824 scrub_check_flags 16 ""
826 run_test 6 "OI scrub resumes from last checkpoint"
830 echo "starting MDTs with OI scrub disabled"
831 scrub_start_mds 2 "$MOUNT_OPTS_NOSCRUB"
832 [ "$mds1_FSTYPE" != "ldiskfs" ] ||
833 scrub_check_flags 4 recreated,inconsistent
834 mount_client $MOUNT || error "(5) Fail to start client!"
838 #define OBD_FAIL_OSD_SCRUB_DELAY 0x190
839 do_nodes $(comma_list $(mdts_nodes)) \
840 $LCTL set_param fail_val=3 fail_loc=0x190
845 for n in $(seq $MDSCOUNT); do
846 stat $DIR/$tdir/mds$n/${tfile}300 ||
847 error "(7) Failed to stat mds$n/${tfile}300!"
850 scrub_check_status 8 scanning
851 if [ "$mds1_FSTYPE" != "ldiskfs" ]; then
852 scrub_check_flags 9 inconsistent,auto
854 scrub_check_flags 9 recreated,inconsistent,auto
857 do_nodes $(comma_list $(mdts_nodes)) \
858 $LCTL set_param fail_loc=0 fail_val=0
860 scrub_check_status 10 completed
863 run_test 7 "System is available during OI scrub scanning"
867 echo "starting MDTs with OI scrub disabled"
868 scrub_start_mds 2 "$MOUNT_OPTS_NOSCRUB"
869 [ "$mds1_FSTYPE" != "ldiskfs" ] ||
870 scrub_check_flags 4 recreated,inconsistent
872 #define OBD_FAIL_OSD_SCRUB_DELAY 0x190
873 do_nodes $(comma_list $(mdts_nodes)) \
874 $LCTL set_param fail_val=1 fail_loc=0x190
877 scrub_check_status 6 scanning
879 scrub_check_status 8 stopped
881 scrub_check_status 10 scanning
883 do_nodes $(comma_list $(mdts_nodes)) \
884 $LCTL set_param fail_loc=0 fail_val=0
886 scrub_check_status 11 completed
887 scrub_check_flags 12 ""
889 run_test 8 "Control OI scrub manually"
892 # Skip scrub speed test for ZFS because of performance unstable
893 [ "$mds1_FSTYPE" != "ldiskfs" ] &&
894 skip "test scrub speed only on ldiskfs"
896 if [ -z "$(grep "processor.*: 1" /proc/cpuinfo)" ]; then
897 skip "Testing on UP system, the speed may be inaccurate."
902 echo "starting MDTs with OI scrub disabled"
903 scrub_start_mds 2 "$MOUNT_OPTS_NOSCRUB"
904 scrub_check_flags 4 recreated,inconsistent
906 local BASE_SPEED1=100
908 # OI scrub should run with full speed under inconsistent case
909 scrub_start 5 -s $BASE_SPEED1
912 scrub_check_status 6 completed
913 scrub_check_flags 7 ""
915 # OI scrub should run with limited speed under non-inconsistent case
916 scrub_start 8 -s $BASE_SPEED1 -r
919 scrub_check_status 9 scanning
921 # Do NOT ignore that there are 1024 pre-fetched items. And there
922 # may be time error, normally it should be less than 2 seconds.
923 # We allow another 20% schedule error.
924 local PRE_FETCHED=1024
926 # MAX_MARGIN = 1.2 = 12 / 10
927 local MAX_SPEED=$(((PRE_FETCHED + BASE_SPEED1 *
928 (RUN_TIME1 + TIME_DIFF)) / RUN_TIME1 * 12 / 10))
930 for n in $(seq $MDSCOUNT); do
931 local SPEED=$(scrub_status $n | \
932 awk '/^average_speed/ { print $2 }')
933 [ $SPEED -lt $MAX_SPEED ] ||
934 error "(10) Got speed $SPEED, expected less than" \
939 local BASE_SPEED2=300
941 for n in $(seq $MDSCOUNT); do
942 do_facet mds$n $LCTL set_param -n \
943 mdd.$(facet_svc mds$n).lfsck_speed_limit $BASE_SPEED2
949 local MIN_SPEED=$(((PRE_FETCHED +
950 BASE_SPEED1 * (RUN_TIME1 - TIME_DIFF) +
951 BASE_SPEED2 * (RUN_TIME2 - TIME_DIFF)) /
952 (RUN_TIME1 + RUN_TIME2) * (10 - MARGIN) / 10))
953 # MAX_MARGIN = 1.2 = 12 / 10
954 MAX_SPEED=$(((PRE_FETCHED +
955 BASE_SPEED1 * (RUN_TIME1 + TIME_DIFF) +
956 BASE_SPEED2 * (RUN_TIME2 + TIME_DIFF)) /
957 (RUN_TIME1 + RUN_TIME2) * (10 + MARGIN) / 10))
958 for n in $(seq $MDSCOUNT); do
959 SPEED=$(scrub_status $n | awk '/^average_speed/ { print $2 }')
960 [ $SPEED -gt $MIN_SPEED ] ||
961 error "(11) Got speed $SPEED, expected more than" \
963 [ $SPEED -lt $MAX_SPEED ] ||
964 error "(12) Got speed $SPEED, expected less than" \
967 do_facet mds$n $LCTL set_param -n \
968 mdd.$(facet_svc mds$n).lfsck_speed_limit 0
971 scrub_check_status 13 completed
973 run_test 9 "OI scrub speed control"
977 echo "starting mds$n with OI scrub disabled (1)"
978 scrub_start_mds 2 "$MOUNT_OPTS_NOSCRUB"
979 [ "$mds1_FSTYPE" != "ldiskfs" ] ||
980 scrub_check_flags 4 recreated,inconsistent
981 mount_client $MOUNT || error "(5) Fail to start client!"
985 #define OBD_FAIL_OSD_SCRUB_DELAY 0x190
986 do_nodes $(comma_list $(mdts_nodes)) \
987 $LCTL set_param fail_val=1 fail_loc=0x190
990 scrub_check_status 7 scanning
991 umount_client $MOUNT || error "(8) Fail to stop client!"
993 echo "starting MDTs with OI scrub disabled (2)"
994 scrub_start_mds 10 "$MOUNT_OPTS_NOSCRUB"
995 scrub_check_status 11 paused
997 echo "starting MDTs without disabling OI scrub"
998 scrub_start_mds 13 "$MOUNT_OPTS_SCRUB"
999 scrub_check_status 14 scanning
1001 do_nodes $(comma_list $(mdts_nodes)) \
1002 $LCTL set_param fail_loc=0 fail_val=0
1004 scrub_check_status 15 completed
1005 scrub_check_flags 16 ""
1007 run_test 10a "non-stopped OI scrub should auto restarts after MDS remount (1)"
1009 # test_10b is obsolete, it will be coverded by related sanity-lfsck tests.
1012 echo "starting MDTs with OI scrub disabled"
1013 scrub_start_mds 2 "$MOUNT_OPTS_NOSCRUB"
1014 [ "$mds1_FSTYPE" != "ldiskfs" ] ||
1015 scrub_check_flags 4 recreated,inconsistent
1017 #define OBD_FAIL_OSD_SCRUB_DELAY 0x190
1018 do_nodes $(comma_list $(mdts_nodes)) \
1019 $LCTL set_param fail_val=3 fail_loc=0x190
1022 scrub_check_status 6 scanning
1024 echo "starting MDTs with OI scrub disabled"
1025 scrub_start_mds 8 "$MOUNT_OPTS_NOSCRUB"
1026 scrub_check_status 9 paused
1028 echo "starting MDTs without disabling OI scrub"
1029 scrub_start_mds 11 "$MOUNT_OPTS_SCRUB"
1030 scrub_check_status 12 scanning
1032 do_nodes $(comma_list $(mdts_nodes)) \
1033 $LCTL set_param fail_loc=0 fail_val=0
1035 scrub_check_status 13 completed
1036 scrub_check_flags 14 ""
1038 #run_test 10b "non-stopped OI scrub should auto restarts after MDS remount (2)"
1041 [ "$mds1_FSTYPE" != "ldiskfs" ] &&
1042 skip "ldiskfs special test"
1047 check_mount_and_prep
1049 for n in $(seq $MDSCOUNT); do
1050 test_mkdir -i $((n - 1)) -c1 $DIR/$tdir/mds$n ||
1051 error "(1) Fail to mkdir $DIR/$tdir/mds$n"
1053 createmany -o $DIR/$tdir/mds$n/f $CREATED ||
1054 error "(2) Fail to create under $tdir/mds$n"
1057 # reset OI scrub start point by force
1059 scrub_check_status 4 completed
1064 # OI scrub should skip the new created objects for the first accessing
1065 # notice we're creating a new llog for every OST on every startup
1066 # new features can make this even less stable, so we only check that
1067 # the number of skipped files is more than the number or known created
1068 local MINIMUM=$((CREATED + 1)) # files + directory
1069 for n in $(seq $MDSCOUNT); do
1070 local SKIPPED=$(scrub_status $n | awk '/^noscrub/ { print $2 }')
1071 [ $SKIPPED -lt $MINIMUM ] &&
1072 error "(5) Expect at least $MINIMUM objects" \
1073 "skipped on mds$n, but got $SKIPPED"
1075 checked0[$n]=$(scrub_status $n | awk '/^checked/ { print $2 }')
1078 # reset OI scrub start point by force
1080 scrub_check_status 7 completed
1082 # OI scrub should skip the new created object only once
1083 for n in $(seq $MDSCOUNT); do
1084 SKIPPED=$(scrub_status $n | awk '/^noscrub/ { print $2 }')
1085 checked1[$n]=$(scrub_status $n | awk '/^checked/ { print $2 }')
1087 [ ${checked0[$n]} -ne ${checked1[$n]} -o $SKIPPED -eq 0 ] ||
1088 error "(8) Expect 0 objects skipped on mds$n, but" \
1092 run_test 11 "OI scrub skips the new created objects only once"
1095 check_mount_and_prep
1096 $LFS setstripe -c 1 -i 0 $DIR/$tdir
1098 #define OBD_FAIL_OSD_COMPAT_INVALID_ENTRY 0x195
1099 do_facet ost1 $LCTL set_param fail_loc=0x195
1100 local count=$(precreated_ost_obj_count 0 0)
1102 createmany -o $DIR/$tdir/f $((count + 32))
1103 umount_client $MOUNT || error "(1) Fail to stop client!"
1105 stop ost1 || error "(2) Fail to stop ost1"
1107 #define OBD_FAIL_OST_NODESTROY 0x233
1108 do_facet ost1 $LCTL set_param fail_loc=0x233
1110 start ost1 $(ostdevname 1) $MOUNT_OPTS_NOSCRUB ||
1111 error "(3) Fail to start ost1"
1113 mount_client $MOUNT || error "(4) Fail to start client!"
1115 ls -ail $DIR/$tdir > /dev/null 2>&1 && error "(5) ls should fail"
1117 $START_SCRUB_ON_OST -r || error "(6) Fail to start OI scrub on OST!"
1119 do_facet ost1 $LCTL set_param fail_loc=0
1120 wait_update_facet ost1 "$LCTL get_param -n \
1121 osd-*.$(facet_svc ost1).oi_scrub |
1122 awk '/^status/ { print \\\$2 }'" "completed" 6 ||
1123 error "(7) Expected '$expected' on ost1"
1125 ls -ail $DIR/$tdir > /dev/null || {
1127 error "(8) ls should succeed"
1130 run_test 12 "OI scrub can rebuild invalid /O entries"
1133 check_mount_and_prep
1134 $LFS setstripe -c 1 -i 0 $DIR/$tdir
1136 #define OBD_FAIL_OSD_COMPAT_NO_ENTRY 0x196
1137 do_facet ost1 $LCTL set_param fail_loc=0x196
1138 local count=$(precreated_ost_obj_count 0 0)
1140 createmany -o $DIR/$tdir/f $((count + 32))
1141 do_facet ost1 $LCTL set_param fail_loc=0
1143 umount_client $MOUNT || error "(1) Fail to stop client!"
1145 stop ost1 || error "(2) Fail to stop ost1"
1147 start ost1 $(ostdevname 1) $MOUNT_OPTS_NOSCRUB ||
1148 error "(3) Fail to start ost1"
1150 mount_client $MOUNT || error "(4) Fail to start client!"
1152 ls -ail $DIR/$tdir > /dev/null 2>&1 && error "(5) ls should fail"
1154 $START_SCRUB_ON_OST -r || error "(6) Fail to start OI scrub on OST!"
1156 wait_update_facet ost1 "$LCTL get_param -n \
1157 osd-*.$(facet_svc ost1).oi_scrub |
1158 awk '/^status/ { print \\\$2 }'" "completed" 6 ||
1159 error "(7) Expected '$expected' on ost1"
1161 ls -ail $DIR/$tdir > /dev/null || error "(8) ls should succeed"
1163 run_test 13 "OI scrub can rebuild missed /O entries"
1166 [ "$mds1_FSTYPE" != "ldiskfs" ] &&
1167 skip "ldiskfs special test"
1169 check_mount_and_prep
1170 $LFS setstripe -c 1 -i 0 $DIR/$tdir
1172 #define OBD_FAIL_OSD_COMPAT_NO_ENTRY 0x196
1173 do_facet ost1 $LCTL set_param fail_loc=0x196
1174 local count=$(precreated_ost_obj_count 0 0)
1176 createmany -o $DIR/$tdir/f $((count + 1000))
1177 do_facet ost1 $LCTL set_param fail_loc=0
1179 umount_client $MOUNT || error "(1) Fail to stop client!"
1181 stop ost1 || error "(2) Fail to stop ost1"
1184 run_e2fsck $(facet_host ost1) $(ostdevname 1) "-y" ||
1185 error "(3) Fail to run e2fsck error"
1187 start ost1 $(ostdevname 1) $OST_MOUNT_OPTS ||
1188 error "(4) Fail to start ost1"
1190 mount_client $MOUNT || error "(5) Fail to start client!"
1192 local LF_REPAIRED=$($SHOW_SCRUB_ON_OST |
1193 awk '/^lf_repa[ir]*ed/ { print $2 }')
1194 [ $LF_REPAIRED -ge 1000 ] ||
1195 error "(6) Some entry under /lost+found should be repaired"
1197 ls -ail $DIR/$tdir > /dev/null || error "(7) ls should succeed"
1201 echo "run e2fsck again after LFSCK"
1202 run_e2fsck $(facet_host ost1) $(ostdevname 1) "-y" ||
1203 error "(8) Fail to run e2fsck error"
1205 run_test 14 "OI scrub can repair OST objects under lost+found"
1210 formatall > /dev/null
1211 setupall > /dev/null
1214 echo "starting MDTs with OI scrub disabled"
1215 scrub_start_mds 2 "$MOUNT_OPTS_NOSCRUB"
1216 scrub_check_status 3 init
1217 [ "$mds1_FSTYPE" != "ldiskfs" ] ||
1218 scrub_check_flags 4 recreated,inconsistent
1220 # run under dryrun mode
1221 scrub_start 5 --dryrun
1222 scrub_check_status 6 completed
1223 if [ "$mds1_FSTYPE" != "ldiskfs" ]; then
1224 scrub_check_flags 7 inconsistent
1227 scrub_check_flags 7 recreated,inconsistent
1230 scrub_check_params 8 dryrun
1231 scrub_check_repaired 9 $repaired 1
1233 # run under dryrun mode again
1234 scrub_start 10 --dryrun
1235 scrub_check_status 11 completed
1236 if [ "$mds1_FSTYPE" != "ldiskfs" ]; then
1237 scrub_check_flags 12 inconsistent
1239 scrub_check_flags 12 recreated,inconsistent
1241 scrub_check_params 13 dryrun
1242 scrub_check_repaired 14 $repaired 1
1244 # run under normal mode
1246 scrub_check_status 16 completed
1247 scrub_check_flags 17 ""
1248 scrub_check_params 18 ""
1249 scrub_check_repaired 19 $repaired 0
1251 # run under normal mode again
1253 scrub_check_status 21 completed
1254 scrub_check_flags 22 ""
1255 scrub_check_params 23 ""
1256 scrub_check_repaired 24 0 0
1258 run_test 15 "Dryrun mode OI scrub"
1261 check_mount_and_prep
1262 scrub_enable_index_backup
1264 #define OBD_FAIL_OSD_INDEX_CRASH 0x199
1265 do_nodes $(comma_list $(mdts_nodes)) $LCTL set_param fail_loc=0x199
1267 do_nodes $(comma_list $(mdts_nodes)) $LCTL set_param fail_loc=0
1269 echo "starting MDTs without disabling OI scrub"
1270 scrub_start_mds 1 "$MOUNT_OPTS_SCRUB"
1271 mount_client $MOUNT || error "(2) Fail to start client!"
1273 scrub_disable_index_backup
1275 run_test 16 "Initial OI scrub can rebuild crashed index objects"
1278 [ "$mds1_FSTYPE" != "ldiskfs" ] && skip_env "ldiskfs only test"
1280 #define OBD_FAIL_OSD_OI_ENOSPC 0x19d
1281 do_facet mds1 $LCTL set_param fail_loc=0x8000019d
1282 mkdir $DIR/$tdir && error "mkdir should fail"
1284 local devname=$(mdsdevname 1)
1286 stack_trap "start mds1 $devname $MDS_MOUNT_OPTS" EXIT
1287 FSCK_MAX_ERR=0 run_e2fsck $(facet_active_host mds1) $devname -n ||
1288 error "e2fsck returned $?"
1290 run_test 17a "ENOSPC on OI insert shouldn't leak inodes"
1293 [ "$mds1_FSTYPE" != "ldiskfs" ] && skip_env "ldiskfs only test"
1295 #define OBD_FAIL_OSD_DOTDOT_ENOSPC 0x19e
1296 do_facet mds1 $LCTL set_param fail_loc=0x8000019e
1297 mkdir_on_mdt0 $DIR/$tdir && error "mkdir should fail"
1299 local devname=$(mdsdevname 1)
1301 stack_trap "start mds1 $devname $MDS_MOUNT_OPTS" EXIT
1302 FSCK_MAX_ERR=0 run_e2fsck $(facet_active_host mds1) $devname -n ||
1303 error "e2fsck returned $?"
1305 run_test 17b "ENOSPC on .. insertion shouldn't leak inodes"
1310 local opts=$(csa_add "$MOUNT_OPTS_SCRUB" -o resetoi)
1313 scrub_start_mds 1 "$MOUNT_OPTS_SCRUB"
1314 mount_client $MOUNT || error "(2) Fail to start client!"
1315 for n in $(seq $MDSCOUNT); do
1316 fids+=($($LFS path2fid $DIR/$tdir/mds$n/test-framework.sh))
1318 cleanup_mount $MOUNT > /dev/null || error "(3) Fail to stop client!"
1319 for n in $(seq $MDSCOUNT); do
1320 stop mds$n > /dev/null || error "(4) Fail to stop MDS$n!"
1322 scrub_start_mds 5 "$opts"
1323 do_facet mds1 dmesg | grep "reset Object Index" ||
1324 error "(6) reset log not found"
1325 mount_client $MOUNT || error "(7) Fail to start client!"
1330 for n in $(seq $MDSCOUNT); do
1331 path=$($LFS fid2path $DIR ${fids[$((n - 1))]})
1332 [ "$path" == "$DIR/$tdir/mds$n/test-framework.sh" ] ||
1333 error "path mismatch $path != $DIR/$tdir/mds$n/test-framework.sh"
1334 fid=$($LFS path2fid $DIR/$tdir/mds$n/test-framework.sh)
1335 [ "${fids[$((n - 1))]}" == "$fid" ] ||
1336 error "$DIR/$tdir/mds$n/test-framework.sh FID mismatch ${fids[$((n - 1))]} != $fid"
1339 run_test 18 "test mount -o resetoi to recreate OI files"
1342 check_mount_and_prep
1343 $LFS setstripe -c 1 -i 0 $DIR/$tdir
1344 createmany -o $DIR/$tdir/f 64 || error "(0) Fail to create 64 files."
1345 local fid=($($LFS getstripe $DIR/$tdir/f0 | grep 0x))
1346 local seq=${fid[3]#0x}
1350 if [ $seq = 0 ] || [ "$ost1_FSTYPE" == "zfs" ]; then
1353 oid_hex=${fid[2]#0x}
1359 # create mulitple link file
1360 mount_fstype ost1 || error "(1) Fail to mount ost1"
1361 mntpt=$(facet_mntpt ost1)
1363 local path="$mntpt/O/$seq/d$(($oid % 32))"
1365 # create link to the first file
1366 echo "link $path/$(($oid + 1)) to $path/$oid_hex"
1367 do_facet ost1 ln $path/$oid_hex $path/$(($oid + 1)) ||
1368 { do_facet ost1 "ls -l $path"; error "(1b) link error"; }
1369 unmount_fstype ost1 || error "(2) Fail to umount ost1"
1371 start ost1 $(ostdevname 1) $MOUNT_OPTS_NOSCRUB > /dev/null ||
1372 error "(2) Fail to start ost1"
1374 $START_SCRUB_ON_OST -r || error "(3) Fail to start OI scrub on OST!"
1376 wait_update_facet ost1 "$LCTL get_param -n \
1377 osd-*.$(facet_svc ost1).oi_scrub |
1378 awk '/^status/ { print \\\$2 }'" "completed" 6 ||
1379 error "(4) Expected '$expected' on ost1"
1382 mount_fstype ost1 || error "(5) Fail to mount ost1 again"
1383 do_facet ost1 "stat $path/$oid_hex" || do_facet ost1 "ls -l $path"
1384 links=$(do_facet ost1 "stat $path/$oid_hex" | awk '/Links:/ { print $6 }')
1385 unmount_fstype ost1 || error "(6) Fail to umount ost1"
1387 start ost1 $(ostdevname 1) $MOUNT_OPTS_NOSCRUB > /dev/null ||
1388 error "(7) Fail to start ost1"
1390 (( links == 1)) || error "(8) object links $links != 1 after scrub"
1392 run_test 19 "LFSCK can fix multiple linked files on OST"
1395 [ "$mds1_FSTYPE" == "ldiskfs" ] || skip "ldiskfs only test"
1397 check_mount_and_prep
1400 mkdir_on_mdt0 $DIR/$tdir || error "mkdir $tdir failed"
1401 #define OBD_FAIL_OSD_FID_MAPPING 0x193
1402 do_facet mds1 $LCTL set_param fail_loc=0x193
1403 chmod 757 $DIR/$tdir || error "chmod $tdir failed"
1406 start mds1 $(mdsdevname 1) $MOUNT_OPTS_NOSCRUB
1411 #define OBD_FAIL_OSD_SCRUB_IRREPARABLE 0x19f
1412 do_facet mds1 $LCTL set_param fail_loc=0x19f
1413 stat $DIR/$tdir && error "stat $tdir should fail"
1414 sec=$(scrub_status 1 | awk '/^time_since_latest_start/ { print $2 }')
1415 echo "OI scrub was triggerred $sec seconds ago"
1418 # OI mappings are irreparable, which shouldn't trigger scrub again
1419 stat $DIR/$tdir && error "stat $tdir should fail"
1420 sec=$(scrub_status 1 | awk '/^time_since_latest_start/ { print $2 }')
1421 echo "OI scrub was triggerred $sec seconds ago"
1422 (( sec >= 5 )) || error "OI scrub retriggered"
1424 run_test 20 "Don't trigger OI scrub for irreparable oi repeatedly"
1427 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
1428 [ "$mds1_FSTYPE" != "ldiskfs" ] && skip_env "ldiskfs only test"
1432 local device=$(mdsdevname 1)
1436 timeout=$(do_facet mds2 "$LCTL get_param -n \
1437 mdt.$FSNAME-MDT0001.recovery_time_hard")
1438 for idx in $(seq $MDSCOUNT); do
1442 #test reproduce simple situation, when OI record exist
1443 #and inode was reused/wrong. Scrub should handle it.
1444 do_facet mds1 "mkdir -p $td && mount -t ldiskfs $device $td &&
1445 rm -rf $td/update_log_dir/*; umount $td; rm -rf $td"
1447 for idx in $(seq $MDSCOUNT); do
1448 start mds${idx} $(mdsdevname $idx) $MDS_MOUNT_OPTS ||
1449 error "mount mds$idx failed"
1452 wait_recovery_complete mds2 $((timeout + TIMEOUT))
1455 run_test 21 "don't hang MDS recovery when failed to get update log"
1458 # restore MDS/OST size
1459 MDSSIZE=${SAVED_MDSSIZE}
1460 OSTSIZE=${SAVED_OSTSIZE}
1461 OSTCOUNT=${SAVED_OSTCOUNT}
1463 # cleanup the system at last
1464 REFORMAT="yes" cleanup_and_setup_lustre
1466 complete_test $SECONDS
1467 check_and_cleanup_lustre