3 # Run select tests by setting ONLY, or as arguments to the script.
4 # Skip specific tests by setting EXCEPT.
10 ALWAYS_EXCEPT="$SANITY_SCRUB_EXCEPT"
11 [ "$SLOW" = "no" ] && EXCEPT_SLOW=""
12 # UPDATE THE COMMENT ABOVE WITH BUG NUMBERS WHEN CHANGING ALWAYS_EXCEPT!
14 LUSTRE=${LUSTRE:-$(cd $(dirname $0)/..; echo $PWD)}
15 . $LUSTRE/tests/test-framework.sh
17 . ${CONFIG:=$LUSTRE/tests/cfg/$NAME.sh}
20 require_dsh_mds || exit 0
22 SAVED_MDSSIZE=${MDSSIZE}
23 SAVED_OSTSIZE=${OSTSIZE}
24 # use small MDS + OST size to speed formatting time
25 # do not use too small MDSSIZE/OSTSIZE, which affect the default journal size
30 check_and_setup_lustre
32 [ $(facet_fstype $SINGLEMDS) != "ldiskfs" ] &&
33 skip "test OI scrub only for ldiskfs" && check_and_cleanup_lustre &&
35 [ $(facet_fstype ost1) != "ldiskfs" ] &&
36 skip "test OI scrub only for ldiskfs" && check_and_cleanup_lustre &&
38 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.2.90) ]] &&
39 skip "Need MDS version at least 2.2.90" && check_and_cleanup_lustre &&
42 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.3.90) ]] &&
43 ALWAYS_EXCEPT="$ALWAYS_EXCEPT 1a"
45 [[ $(lustre_version_code $SINGLEMDS) -le $(version_code 2.4.1) ]] &&
46 ALWAYS_EXCEPT="$ALWAYS_EXCEPT 15"
48 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.90) ]] &&
49 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.4.50) ]] &&
50 ALWAYS_EXCEPT="$ALWAYS_EXCEPT 15"
52 [[ $(lustre_version_code ost1) -lt $(version_code 2.4.50) ]] &&
53 ALWAYS_EXCEPT="$ALWAYS_EXCEPT 11 12 13 14"
57 MDT_DEV="${FSNAME}-MDT0000"
58 OST_DEV="${FSNAME}-OST0000"
59 MDT_DEVNAME=$(mdsdevname ${SINGLEMDS//mds/})
65 for n in $(seq $MDSCOUNT); do
66 do_facet mds$n $LCTL lfsck_start -M $(facet_svc mds$n) "$@" ||
67 error "($error_id) Failed to start OI scrub on mds$n"
75 for n in $(seq $MDSCOUNT); do
76 do_facet mds$n $LCTL lfsck_stop -M $(facet_svc mds$n) ||
77 error "($error_id) Failed to stop OI scrub on mds$n"
84 do_facet mds$n $LCTL get_param -n \
85 osd-ldiskfs.$(facet_svc mds$n).oi_scrub
88 START_SCRUB="do_facet $SINGLEMDS $LCTL lfsck_start -M ${MDT_DEV}"
89 START_SCRUB_ON_OST="do_facet ost1 $LCTL lfsck_start -M ${OST_DEV}"
90 STOP_SCRUB="do_facet $SINGLEMDS $LCTL lfsck_stop -M ${MDT_DEV}"
91 SHOW_SCRUB="do_facet $SINGLEMDS \
92 $LCTL get_param -n osd-ldiskfs.${MDT_DEV}.oi_scrub"
93 SHOW_SCRUB_ON_OST="do_facet ost1 \
94 $LCTL get_param -n osd-ldiskfs.${OST_DEV}.oi_scrub"
95 MOUNT_OPTS_SCRUB="-o user_xattr"
96 MOUNT_OPTS_NOSCRUB="-o user_xattr,noscrub"
103 formatall > /dev/null
108 for n in $(seq $MDSCOUNT); do
109 echo "creating $nfiles files on mds$n"
110 if [ $n -eq 1 ]; then
111 mkdir -p $DIR/$tdir/mds$n ||
112 error "Failed to create directory mds$n"
114 $LFS mkdir -i $((n - 1)) $DIR/$tdir/mds$n ||
115 error "Failed to create remote directory mds$n"
117 cp $LUSTRE/tests/*.sh $DIR/$tdir/mds$n ||
118 error "Failed to copy files to mds$n"
119 if [[ $nfiles -gt 0 ]]; then
120 createmany -o $DIR/$tdir/mds$n/$tfile $nfiles ||
121 error "createmany failed on mds$n"
125 cleanup_mount $MOUNT > /dev/null || error "Fail to stop client!"
126 for n in $(seq $MDSCOUNT); do
128 stop mds$n > /dev/null || error "Fail to stop MDS$n!"
137 for n in $(seq $MDSCOUNT); do
138 start mds$n $(mdsdevname $n) $opts >/dev/null ||
139 error "($error_id) Failed to start mds$n"
147 for n in $(seq $MDSCOUNT); do
148 echo "stopping mds$n"
149 stop mds$n >/dev/null ||
150 error "($error_id) Failed to stop mds$n"
154 scrub_check_status() {
160 for n in $(seq $MDSCOUNT); do
161 actual=$(do_facet mds$n $LCTL get_param -n \
162 osd-ldiskfs.$(facet_svc mds$n).oi_scrub |
163 awk '/^status/ { print $2 }')
164 if [ "$actual" != "$expected" ]; then
165 error "($error_id) Expected '$expected' on mds$n, but" \
171 scrub_check_flags() {
177 for n in $(seq $MDSCOUNT); do
178 actual=$(do_facet mds$n $LCTL get_param -n \
179 osd-ldiskfs.$(facet_svc mds$n).oi_scrub |
180 awk '/^flags/ { print $2 }')
181 if [ "$actual" != "$expected" ]; then
182 error "($error_id) Expected '$expected' on mds$n, but" \
188 scrub_check_params() {
194 for n in $(seq $MDSCOUNT); do
195 actual=$(do_facet mds$n $LCTL get_param -n \
196 osd-ldiskfs.$(facet_svc mds$n).oi_scrub |
197 awk '/^param/ { print $2 }')
198 if [ "$actual" != "$expected" ]; then
199 error "($error_id) Expected '$expected' on mds$n, but" \
205 scrub_check_repaired() {
211 for n in $(seq $MDSCOUNT); do
212 actual=$(do_facet mds$n $LCTL get_param -n \
213 osd-ldiskfs.$(facet_svc mds$n).oi_scrub |
214 awk '/^updated/ { print $2 }')
216 if [ $expected -eq 0 -a $actual -ne 0 ]; then
217 error "($error_id) Expected no repaired on mds$n, but" \
221 if [ $expected -ne 0 -a $actual -lt $expected ]; then
222 error "($error_id) Expected '$expected' on mds$n, but" \
232 for n in $(seq $MDSCOUNT); do
233 diff -q $LUSTRE/tests/test-framework.sh \
234 $DIR/$tdir/mds$n/test-framework.sh ||
235 error "($error_id) File data check failed"
244 for n in $(seq $MDSCOUNT); do
245 mds_remove_ois mds$n $index ||
246 error "($error_id) Failed to remove OI .$index on mds$n"
250 scrub_backup_restore() {
255 for n in $(seq $MDSCOUNT); do
256 mds_backup_restore mds$n $igif ||
257 error "(error_id) Backup/restore on mds$n failed"
261 scrub_enable_auto() {
264 for n in $(seq $MDSCOUNT); do
265 do_facet mds$n $LCTL set_param -n \
266 osd-ldiskfs.$(facet_svc mds$n).auto_scrub 1
272 echo "starting MDTs without disabling OI scrub"
273 scrub_start_mds 1 "$MOUNT_OPTS_SCRUB"
274 scrub_check_status 2 init
275 scrub_check_flags 3 ""
276 mount_client $MOUNT || error "(4) Fail to start client!"
279 run_test 0 "Do not auto trigger OI scrub for non-backup/restore case"
283 echo "start $SINGLEMDS without disabling OI scrub"
284 start $SINGLEMDS $MDT_DEVNAME $MOUNT_OPTS_SCRUB > /dev/null ||
285 error "(1) Fail to start MDS!"
287 local STATUS=$($SHOW_SCRUB | awk '/^status/ { print $2 }')
288 [ "$STATUS" == "init" ] ||
289 error "(2) Expect 'init', but got '$STATUS'"
291 local FLAGS=$($SHOW_SCRUB | awk '/^flags/ { print $2 }')
292 [ -z "$FLAGS" ] || error "(3) Expect empty flags, but got '$FLAGS'"
294 mount_client $MOUNT || error "(4) Fail to start client!"
296 #define OBD_FAIL_OSD_FID_MAPPING 0x193
297 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x193
298 # update .lustre OI mapping
300 do_facet $SINGLEMDS $LCTL set_param fail_loc=0
302 umount_client $MOUNT || error "(5) Fail to stop client!"
304 echo "stop $SINGLEMDS"
305 stop $SINGLEMDS > /dev/null || error "(6) Fail to stop MDS!"
307 echo "start $SINGLEMDS with disabling OI scrub"
308 start $SINGLEMDS $MDT_DEVNAME $MOUNT_OPTS_NOSCRUB > /dev/null ||
309 error "(7) Fail to start MDS!"
311 local STATUS=$($SHOW_SCRUB | awk '/^status/ { print $2 }')
312 [ "$STATUS" == "init" ] ||
313 error "(8) Expect 'init', but got '$STATUS'"
315 local FLAGS=$($SHOW_SCRUB | awk '/^flags/ { print $2 }')
316 [ "$FLAGS" == "inconsistent" ] ||
317 error "(9) Expect 'inconsistent', but got '$FLAGS'"
319 run_test 1a "Auto trigger initial OI scrub when server mounts"
324 echo "start MDTs without disabling OI scrub"
325 scrub_start_mds 2 "$MOUNT_OPTS_SCRUB"
327 scrub_check_status 3 completed
328 mount_client $MOUNT || error "(4) Fail to start client!"
331 run_test 1b "Trigger OI scrub when MDT mounts for OI files remove/recreate case"
336 # OI files to be removed:
339 # idx 2: oi.16.{2,4,8,16,32}
340 # idx 3: oi.16.{3,9,27}
341 # idx 5: oi.16.{5,25}
342 # idx 7: oi.16.{7,49}
343 for index in 0 1 2 3 5 7; do
345 scrub_remove_ois 1 $index
347 echo "start MDTs with OI scrub disabled"
348 scrub_start_mds 2 "$MOUNT_OPTS_NOSCRUB"
349 scrub_check_flags 3 recreated
352 scrub_check_status 5 completed
353 scrub_check_flags 6 ""
356 run_test 1c "Auto detect kinds of OI file(s) removed/recreated cases"
360 scrub_backup_restore 1
361 echo "starting MDTs without disabling OI scrub"
362 scrub_start_mds 2 "$MOUNT_OPTS_SCRUB"
364 scrub_check_status 3 completed
365 mount_client $MOUNT || error "(4) Fail to start client!"
368 run_test 2 "Trigger OI scrub when MDT mounts for backup/restore case"
372 scrub_backup_restore 1
373 echo "starting MDTs with OI scrub disabled"
374 scrub_start_mds 2 "$MOUNT_OPTS_NOSCRUB"
376 scrub_check_status 3 init
377 scrub_check_flags 4 inconsistent
381 run_test 3 "Do not trigger OI scrub when MDT mounts if 'noscrub' specified"
385 scrub_backup_restore 1
386 echo "starting MDTs with OI scrub disabled"
387 scrub_start_mds 2 "$MOUNT_OPTS_NOSCRUB"
388 scrub_check_status 3 init
389 scrub_check_flags 4 inconsistent
390 mount_client $MOUNT || error "(5) Fail to start client!"
394 scrub_check_status 7 completed
396 run_test 4 "Trigger OI scrub automatically if inconsistent OI mapping was found"
400 scrub_backup_restore 1
401 echo "starting MDTs with OI scrub disabled"
402 scrub_start_mds 2 "$MOUNT_OPTS_NOSCRUB"
403 scrub_check_status 3 init
404 scrub_check_flags 4 inconsistent
405 mount_client $MOUNT || error "(5) Fail to start client!"
409 for n in $(seq $MDSCOUNT); do
410 #define OBD_FAIL_OSD_SCRUB_DELAY 0x190
411 do_facet mds$n $LCTL set_param fail_val=3
412 do_facet mds$n $LCTL set_param fail_loc=0x190
416 umount_client $MOUNT || error "(7) Fail to stop client!"
418 scrub_check_status 8 scanning
420 for n in $(seq $MDSCOUNT); do
421 #define OBD_FAIL_OSD_SCRUB_CRASH 0x191
422 do_facet mds$n $LCTL set_param fail_loc=0x191
427 for n in $(seq $MDSCOUNT); do
428 do_facet mds$n $LCTL set_param fail_loc=0
429 do_facet mds$n $LCTL set_param fail_val=0
432 echo "starting MDTs with OI scrub disabled"
433 scrub_start_mds 10 "$MOUNT_OPTS_NOSCRUB"
435 scrub_check_status 11 crashed
439 for n in $(seq $MDSCOUNT); do
440 #define OBD_FAIL_OSD_SCRUB_DELAY 0x190
441 do_facet mds$n $LCTL set_param fail_val=3
442 do_facet mds$n $LCTL set_param fail_loc=0x190
444 echo "starting MDTs without disabling OI scrub"
445 scrub_start_mds 13 "$MOUNT_OPTS_SCRUB"
447 scrub_check_status 14 scanning
449 for n in $(seq $MDSCOUNT); do
450 #define OBD_FAIL_OSD_SCRUB_FATAL 0x192
451 do_facet mds$n $LCTL set_param fail_loc=0x192
454 scrub_check_status 15 failed
456 mount_client $MOUNT || error "(16) Fail to start client!"
458 for n in $(seq $MDSCOUNT); do
459 #define OBD_FAIL_OSD_SCRUB_DELAY 0x190
460 do_facet mds$n $LCTL set_param fail_val=3
461 do_facet mds$n $LCTL set_param fail_loc=0x190
462 stat $DIR/$tdir/mds$n/${tfile}1000 ||
463 error "(17) Failed to stat mds$n/${tfile}1000"
466 scrub_check_status 18 scanning
468 for n in $(seq $MDSCOUNT); do
469 do_facet mds$n $LCTL set_param fail_loc=0
470 do_facet mds$n $LCTL set_param fail_val=0
473 scrub_check_status 19 completed
475 scrub_check_flags 20 ""
477 run_test 5 "OI scrub state machine"
481 scrub_backup_restore 1
482 echo "starting MDTs with OI scrub disabled"
483 scrub_start_mds 2 "$MOUNT_OPTS_NOSCRUB"
484 scrub_check_status 3 init
485 scrub_check_flags 4 inconsistent
486 mount_client $MOUNT || error "(5) Fail to start client!"
489 for n in $(seq $MDSCOUNT); do
490 #define OBD_FAIL_OSD_SCRUB_DELAY 0x190
491 do_facet mds$n $LCTL set_param fail_val=3
492 do_facet mds$n $LCTL set_param fail_loc=0x190
496 # Sleep 5 sec to guarantee at least one object processed by OI scrub
498 # Fail the OI scrub to guarantee there is at least one checkpoint
499 for n in $(seq $MDSCOUNT); do
500 #define OBD_FAIL_OSD_SCRUB_FATAL 0x192
501 do_facet mds$n $LCTL set_param fail_loc=0x192
504 scrub_check_status 7 failed
506 for n in $(seq $MDSCOUNT); do
507 #define OBD_FAIL_OSD_SCRUB_DELAY 0x190
508 do_facet mds$n $LCTL set_param fail_val=3
509 do_facet mds$n $LCTL set_param fail_loc=0x190
510 # stat will re-trigger OI scrub
511 stat $DIR/$tdir/mds$n/${tfile}800 ||
512 error "(8) Failed to stat mds$n/${tfile}800"
515 umount_client $MOUNT || error "(9) Fail to stop client!"
517 scrub_check_status 10 scanning
519 for n in $(seq $MDSCOUNT); do
520 #define OBD_FAIL_OSD_SCRUB_CRASH 0x191
521 do_facet mds$n $LCTL set_param fail_loc=0x191
525 for n in $(seq $MDSCOUNT); do
526 position0[$n]=$(scrub_status $n |
527 awk '/^last_checkpoint_position/ {print $2}')
528 position0[$n]=$((${position0[$n]} + 1))
533 for n in $(seq $MDSCOUNT); do
534 #define OBD_FAIL_OSD_SCRUB_DELAY 0x190
535 do_facet mds$n $LCTL set_param fail_val=3
536 do_facet mds$n $LCTL set_param fail_loc=0x190
538 echo "starting MDTs without disabling OI scrub"
539 scrub_start_mds 12 "$MOUNT_OPTS_SCRUB"
541 scrub_check_status 13 scanning
544 for n in $(seq $MDSCOUNT); do
545 position1[$n]=$(scrub_status $n |
546 awk '/^latest_start_position/ {print $2}')
547 if [ ${position0[$n]} -ne ${position1[$n]} ]; then
548 error "(14) Expected position ${position0[$n]}, but" \
549 "got ${position1[$n]}"
553 for n in $(seq $MDSCOUNT); do
554 do_facet mds$n $LCTL set_param fail_loc=0
555 do_facet mds$n $LCTL set_param fail_val=0
558 scrub_check_status 15 completed
560 scrub_check_flags 16 ""
562 run_test 6 "OI scrub resumes from last checkpoint"
566 scrub_backup_restore 1
568 echo "starting MDTs with OI scrub disabled"
569 scrub_start_mds 2 "$MOUNT_OPTS_NOSCRUB"
570 scrub_check_status 3 init
571 scrub_check_flags 4 inconsistent
573 mount_client $MOUNT || error "(5) Fail to start client!"
577 for n in $(seq $MDSCOUNT); do
578 #define OBD_FAIL_OSD_SCRUB_DELAY 0x190
579 do_facet mds$n $LCTL set_param fail_val=3
580 do_facet mds$n $LCTL set_param fail_loc=0x190
584 for n in $(seq $MDSCOUNT); do
585 stat $DIR/$tdir/mds$n/${tfile}300 ||
586 error "(7) Failed to stat mds$n/${tfile}300!"
589 scrub_check_status 8 scanning
591 scrub_check_flags 9 inconsistent,auto
593 for n in $(seq $MDSCOUNT); do
594 do_facet mds$n $LCTL set_param fail_loc=0
595 do_facet mds$n $LCTL set_param fail_val=0
598 scrub_check_status 10 completed
602 run_test 7 "System is available during OI scrub scanning"
606 scrub_backup_restore 1
608 echo "starting MDTs with OI scrub disabled"
609 scrub_start_mds 2 "$MOUNT_OPTS_NOSCRUB"
611 scrub_check_status 3 init
613 scrub_check_flags 4 inconsistent
616 for n in $(seq $MDSCOUNT); do
617 #define OBD_FAIL_OSD_SCRUB_DELAY 0x190
618 do_facet mds$n $LCTL set_param fail_val=1
619 do_facet mds$n $LCTL set_param fail_loc=0x190
623 scrub_check_status 6 scanning
627 scrub_check_status 8 stopped
631 scrub_check_status 10 scanning
633 for n in $(seq $MDSCOUNT); do
634 do_facet mds$n $LCTL set_param fail_loc=0
635 do_facet mds$n $LCTL set_param fail_val=0
638 scrub_check_status 11 completed
640 scrub_check_flags 12 ""
642 run_test 8 "Control OI scrub manually"
645 if [ -z "$(grep "processor.*: 1" /proc/cpuinfo)" ]; then
646 skip "Testing on UP system, the speed may be inaccurate."
651 scrub_backup_restore 1
653 echo "starting MDTs with OI scrub disabled"
654 scrub_start_mds 2 "$MOUNT_OPTS_NOSCRUB"
656 scrub_check_status 3 init
658 scrub_check_flags 4 inconsistent
660 local BASE_SPEED1=100
662 # OI scrub should run with full speed under inconsistent case
663 scrub_start 5 -s $BASE_SPEED1
666 scrub_check_status 6 completed
668 scrub_check_flags 7 ""
670 # OI scrub should run with limited speed under non-inconsistent case
671 scrub_start 8 -s $BASE_SPEED1 -r
674 scrub_check_status 9 scanning
676 # Do NOT ignore that there are 1024 pre-fetched items. And there
677 # may be time error, normally it should be less than 2 seconds.
678 # We allow another 20% schedule error.
679 local PRE_FETCHED=1024
681 # MAX_MARGIN = 1.2 = 12 / 10
682 local MAX_SPEED=$(((PRE_FETCHED + BASE_SPEED1 * \
683 (RUN_TIME1 + TIME_DIFF)) / RUN_TIME1 * 12 / 10))
685 for n in $(seq $MDSCOUNT); do
686 local SPEED=$(scrub_status $n | \
687 awk '/^average_speed/ { print $2 }')
688 [ $SPEED -lt $MAX_SPEED ] ||
689 error "(10) Got speed $SPEED, expected less than" \
694 local BASE_SPEED2=300
696 for n in $(seq $MDSCOUNT); do
697 do_facet mds$n $LCTL set_param -n \
698 mdd.$(facet_svc mds$n).lfsck_speed_limit $BASE_SPEED2
702 # MIN_MARGIN = 0.8 = 8 / 10
703 local MIN_SPEED=$(((PRE_FETCHED + \
704 BASE_SPEED1 * (RUN_TIME1 - TIME_DIFF) + \
705 BASE_SPEED2 * (RUN_TIME2 - TIME_DIFF)) / \
706 (RUN_TIME1 + RUN_TIME2) * 8 / 10))
707 # MAX_MARGIN = 1.2 = 12 / 10
708 MAX_SPEED=$(((PRE_FETCHED + \
709 BASE_SPEED1 * (RUN_TIME1 + TIME_DIFF) + \
710 BASE_SPEED2 * (RUN_TIME2 + TIME_DIFF)) / \
711 (RUN_TIME1 + RUN_TIME2) * 12 / 10))
712 for n in $(seq $MDSCOUNT); do
713 SPEED=$(scrub_status $n | awk '/^average_speed/ { print $2 }')
714 [ $SPEED -gt $MIN_SPEED ] ||
715 error "(11) Got speed $SPEED, expected more than" \
717 [ $SPEED -lt $MAX_SPEED ] ||
718 error "(12) Got speed $SPEED, expected less than" \
721 do_facet mds$n $LCTL set_param -n \
722 mdd.$(facet_svc mds$n).lfsck_speed_limit 0
725 scrub_check_status 13 completed
727 run_test 9 "OI scrub speed control"
731 scrub_backup_restore 1
733 echo "starting mds$n with OI scrub disabled"
734 scrub_start_mds 2 "$MOUNT_OPTS_NOSCRUB"
736 scrub_check_status 3 init
738 scrub_check_flags 4 inconsistent
740 mount_client $MOUNT || error "(5) Fail to start client!"
744 for n in $(seq $MDSCOUNT); do
745 #define OBD_FAIL_OSD_SCRUB_DELAY 0x190
746 do_facet mds$n $LCTL set_param fail_val=1
747 do_facet mds$n $LCTL set_param fail_loc=0x190
751 scrub_check_status 7 scanning
753 umount_client $MOUNT || error "(8) Fail to stop client!"
757 echo "starting MDTs with OI scrub disabled"
758 scrub_start_mds 10 "$MOUNT_OPTS_NOSCRUB"
760 scrub_check_status 11 paused
764 echo "starting MDTs without disabling OI scrub"
765 scrub_start_mds 13 "$MOUNT_OPTS_SCRUB"
767 scrub_check_status 14 scanning
769 for n in $(seq $MDSCOUNT); do
770 do_facet mds$n $LCTL set_param fail_loc=0
771 do_facet mds$n $LCTL set_param fail_val=0
774 scrub_check_status 15 completed
776 scrub_check_flags 16 ""
778 run_test 10a "non-stopped OI scrub should auto restarts after MDS remount (1)"
780 # test_10b is obsolete, it will be coverded by related sanity-lfsck tests.
783 scrub_backup_restore 1
785 echo "starting MDTs with OI scrub disabled"
786 scrub_start_mds 2 "$MOUNT_OPTS_NOSCRUB"
788 scrub_check_status 3 init
790 scrub_check_flags 4 inconsistent
793 for n in $(seq $MDSCOUNT); do
794 #define OBD_FAIL_OSD_SCRUB_DELAY 0x190
795 do_facet mds$n $LCTL set_param fail_val=3
796 do_facet mds$n $LCTL set_param fail_loc=0x190
801 scrub_check_status 6 scanning
805 echo "starting MDTs with OI scrub disabled"
806 scrub_start_mds 8 "$MOUNT_OPTS_NOSCRUB"
808 scrub_check_status 9 paused
812 echo "starting MDTs without disabling OI scrub"
813 scrub_start_mds 11 "$MOUNT_OPTS_SCRUB"
815 scrub_check_status 12 scanning
817 for n in $(seq $MDSCOUNT); do
818 do_facet mds$n $LCTL set_param fail_loc=0
819 do_facet mds$n $LCTL set_param fail_val=0
822 scrub_check_status 13 completed
824 scrub_check_flags 14 ""
826 #run_test 10b "non-stopped OI scrub should auto restarts after MDS remount (2)"
832 formatall > /dev/null
837 local tname=`date +%s`
838 rm -rf $MOUNT/$tname > /dev/null
839 mkdir -p $MOUNT/$tname || error "(0) Failed to create $MOUNT/$tname"
841 for n in $(seq $MDSCOUNT); do
842 $LFS mkdir -i $((n - 1)) $MOUNT/$tname/mds$n ||
843 error "(1) Fail to mkdir $MOUNT/$tname/mds$n"
845 createmany -o $MOUNT/$tname/mds$n/f $CREATED ||
846 error "(2) Fail to create in $tname/mds$n"
850 do_facet $SINGLEMDS $LCTL clear
851 start_full_debug_logging
852 # reset OI scrub start point by force
855 scrub_check_status 4 completed
857 # OI scrub should skip the new created objects for the first accessing
858 # notice we're creating a new llog for every OST on every startup
859 # new features can make this even less stable, so we only check
860 # that the number of skipped files is less than 2x the number of files
861 local MAXIMUM=$((CREATED * 2))
862 local MINIMUM=$((CREATED + 1)) # files + directory
863 for n in $(seq $MDSCOUNT); do
864 local SKIPPED=$(scrub_status $n | awk '/^noscrub/ { print $2 }')
865 [ $SKIPPED -ge $MAXIMUM -o $SKIPPED -lt $MINIMUM ] &&
866 error "(5) Expect [ $MINIMUM , $MAXIMUM ) objects" \
867 "skipped on mds$n, but got $SKIPPED"
870 # reset OI scrub start point by force
873 scrub_check_status 7 completed
875 # OI scrub should skip the new created object only once
876 for n in $(seq $MDSCOUNT); do
877 SKIPPED=$(scrub_status $n | awk '/^noscrub/ { print $2 }')
878 [ $SKIPPED -eq 0 ] ||
879 error "(8) Expect 0 objects skipped on mds$n, but" \
883 stop_full_debug_logging
884 restore_mount $MOUNT || error "(9) Fail to start client!"
885 rm -rf $MOUNT/$tname > /dev/null
887 run_test 11 "OI scrub skips the new created objects only once"
893 formatall > /dev/null
898 $SETSTRIPE -c 1 -i 0 $DIR/$tdir
900 #define OBD_FAIL_OSD_COMPAT_INVALID_ENTRY 0x195
901 do_facet ost1 $LCTL set_param fail_loc=0x195
902 createmany -o $DIR/$tdir/f 1000
909 do_facet ost1 $LCTL set_param fail_loc=0
910 local STATUS=$($SHOW_SCRUB_ON_OST | awk '/^status/ { print $2 }')
911 [ "$STATUS" == "init" ] ||
912 error "(1) Expect 'init', but got '$STATUS'"
914 ls -ail $DIR/$tdir > /dev/null 2>&1 && error "(2) ls should fail"
917 local STATUS=$($SHOW_SCRUB_ON_OST | awk '/^status/ { print $2 }')
918 [ "$STATUS" == "completed" ] ||
919 error "(3) Expect 'completed', but got '$STATUS'"
921 ls -ail $DIR/$tdir > /dev/null 2>&1 || error "(4) ls should succeed"
923 run_test 12 "OI scrub can rebuild invalid /O entries"
929 formatall > /dev/null
934 $SETSTRIPE -c 1 -i 0 $DIR/$tdir
936 #define OBD_FAIL_OSD_COMPAT_NO_ENTRY 0x196
937 do_facet ost1 $LCTL set_param fail_loc=0x196
938 createmany -o $DIR/$tdir/f 1000
939 do_facet ost1 $LCTL set_param fail_loc=0
946 local STATUS=$($SHOW_SCRUB_ON_OST | awk '/^status/ { print $2 }')
947 [ "$STATUS" == "init" ] ||
948 error "(1) Expect 'init', but got '$STATUS'"
950 ls -ail $DIR/$tdir > /dev/null 2>&1 && error "(2) ls should fail"
952 $START_SCRUB_ON_OST || error "(3) Fail to start OI scrub on OST!"
954 local STATUS=$($SHOW_SCRUB_ON_OST | awk '/^status/ { print $2 }')
955 [ "$STATUS" == "completed" ] ||
956 error "(4) Expect 'completed', but got '$STATUS'"
958 ls -ail $DIR/$tdir > /dev/null 2>&1 || error "(5) ls should succeed"
960 run_test 13 "OI scrub can rebuild missed /O entries"
966 formatall > /dev/null
971 $SETSTRIPE -c 1 -i 0 $DIR/$tdir
973 #define OBD_FAIL_OSD_COMPAT_NO_ENTRY 0x196
974 do_facet ost1 $LCTL set_param fail_loc=0x196
975 createmany -o $DIR/$tdir/f 64
976 do_facet ost1 $LCTL set_param fail_loc=0
983 local STATUS=$($SHOW_SCRUB_ON_OST | awk '/^status/ { print $2 }')
984 [ "$STATUS" == "init" ] ||
985 error "(1) Expect 'init', but got '$STATUS'"
987 ls -ail $DIR/$tdir > /dev/null 2>&1 && error "(2) ls should fail"
993 run_e2fsck $(facet_host ost1) $(ostdevname 1) "-y" ||
994 error "(3) Fail to run e2fsck error"
999 local LF_REPAIRED=$($SHOW_SCRUB_ON_OST |
1000 awk '/^lf_reparied/ { print $2 }')
1001 [ $LF_REPAIRED -gt 0 ] ||
1002 error "(4) Some entry under /lost+found should be repaired"
1004 ls -ail $DIR/$tdir > /dev/null 2>&1 || error "(5) ls should succeed"
1006 run_test 14 "OI scrub can repair objects under lost+found"
1009 # skip test_15 for LU-4182
1010 [ $MDSCOUNT -ge 2 ] && skip "skip now for >= 2 MDTs" && return
1012 scrub_backup_restore 1
1013 echo "starting MDTs with OI scrub disabled"
1014 scrub_start_mds 2 "$MOUNT_OPTS_NOSCRUB"
1015 scrub_check_status 3 init
1016 scrub_check_flags 4 inconsistent
1018 # run under dryrun mode
1021 scrub_check_status 6 completed
1022 scrub_check_flags 7 inconsistent
1023 scrub_check_params 8 dryrun
1024 scrub_check_repaired 9 20
1026 # run under dryrun mode again
1027 scrub_start 10 -n on
1029 scrub_check_status 11 completed
1030 scrub_check_flags 12 inconsistent
1031 scrub_check_params 13 dryrun
1032 scrub_check_repaired 14 20
1034 # run under normal mode
1035 scrub_start 15 -n off
1037 scrub_check_status 16 completed
1038 scrub_check_flags 17 ""
1039 scrub_check_params 18 ""
1040 scrub_check_repaired 19 20
1042 # run under normal mode again
1043 scrub_start 20 -n off
1045 scrub_check_status 21 completed
1046 scrub_check_flags 22 ""
1047 scrub_check_params 23 ""
1048 scrub_check_repaired 24 0
1050 run_test 15 "Dryrun mode OI scrub"
1052 # restore MDS/OST size
1053 MDSSIZE=${SAVED_MDSSIZE}
1054 OSTSIZE=${SAVED_OSTSIZE}
1056 # cleanup the system at last