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 positions1[$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"
565 # skip test_7 for LU-4149
566 [ $MDSCOUNT -ge 2 ] && skip "skip now for >= 2 MDTs" && return
569 scrub_backup_restore 1
571 echo "starting MDTs with OI scrub disabled"
572 scrub_start_mds 2 "$MOUNT_OPTS_NOSCRUB"
573 scrub_check_status 3 init
574 scrub_check_flags 4 inconsistent
576 mount_client $MOUNT || error "(5) Fail to start client!"
580 for n in $(seq $MDSCOUNT); do
581 #define OBD_FAIL_OSD_SCRUB_DELAY 0x190
582 do_facet mds$n $LCTL set_param fail_val=3
583 do_facet mds$n $LCTL set_param fail_loc=0x190
587 for n in $(seq $MDSCOUNT); do
588 stat $DIR/$tdir/mds$n/${tfile}300 ||
589 error "(7) Failed to stat mds$n/${tfile}300!"
592 scrub_check_status 8 scanning
594 scrub_check_flags 9 inconsistent,auto
596 for n in $(seq $MDSCOUNT); do
597 do_facet mds$n $LCTL set_param fail_loc=0
598 do_facet mds$n $LCTL set_param fail_val=0
601 scrub_check_status 10 completed
605 run_test 7 "System is available during OI scrub scanning"
609 scrub_backup_restore 1
611 echo "starting MDTs with OI scrub disabled"
612 scrub_start_mds 2 "$MOUNT_OPTS_NOSCRUB"
614 scrub_check_status 3 init
616 scrub_check_flags 4 inconsistent
619 for n in $(seq $MDSCOUNT); do
620 #define OBD_FAIL_OSD_SCRUB_DELAY 0x190
621 do_facet mds$n $LCTL set_param fail_val=1
622 do_facet mds$n $LCTL set_param fail_loc=0x190
626 scrub_check_status 6 scanning
630 scrub_check_status 8 stopped
634 scrub_check_status 10 scanning
636 for n in $(seq $MDSCOUNT); do
637 do_facet mds$n $LCTL set_param fail_loc=0
638 do_facet mds$n $LCTL set_param fail_val=0
641 scrub_check_status 11 completed
643 scrub_check_flags 12 ""
645 run_test 8 "Control OI scrub manually"
648 if [ -z "$(grep "processor.*: 1" /proc/cpuinfo)" ]; then
649 skip "Testing on UP system, the speed may be inaccurate."
654 scrub_backup_restore 1
656 echo "starting MDTs with OI scrub disabled"
657 scrub_start_mds 2 "$MOUNT_OPTS_NOSCRUB"
659 scrub_check_status 3 init
661 scrub_check_flags 4 inconsistent
663 local BASE_SPEED1=100
665 # OI scrub should run with full speed under inconsistent case
666 scrub_start 5 -s $BASE_SPEED1
669 scrub_check_status 6 completed
671 scrub_check_flags 7 ""
673 # OI scrub should run with limited speed under non-inconsistent case
674 scrub_start 8 -s $BASE_SPEED1 -r
677 scrub_check_status 9 scanning
679 # Do NOT ignore that there are 1024 pre-fetched items. And there
680 # may be time error, normally it should be less than 2 seconds.
681 # We allow another 20% schedule error.
682 local PRE_FETCHED=1024
684 # MAX_MARGIN = 1.2 = 12 / 10
685 local MAX_SPEED=$(((PRE_FETCHED + BASE_SPEED1 * \
686 (RUN_TIME1 + TIME_DIFF)) / RUN_TIME1 * 12 / 10))
688 for n in $(seq $MDSCOUNT); do
689 local SPEED=$(scrub_status $n | \
690 awk '/^average_speed/ { print $2 }')
691 [ $SPEED -lt $MAX_SPEED ] ||
692 error "(10) Got speed $SPEED, expected less than" \
697 local BASE_SPEED2=300
699 for n in $(seq $MDSCOUNT); do
700 do_facet mds$n $LCTL set_param -n \
701 mdd.$(facet_svc mds$n).lfsck_speed_limit $BASE_SPEED2
705 # MIN_MARGIN = 0.8 = 8 / 10
706 local MIN_SPEED=$(((PRE_FETCHED + \
707 BASE_SPEED1 * (RUN_TIME1 - TIME_DIFF) + \
708 BASE_SPEED2 * (RUN_TIME2 - TIME_DIFF)) / \
709 (RUN_TIME1 + RUN_TIME2) * 8 / 10))
710 # MAX_MARGIN = 1.2 = 12 / 10
711 MAX_SPEED=$(((PRE_FETCHED + \
712 BASE_SPEED1 * (RUN_TIME1 + TIME_DIFF) + \
713 BASE_SPEED2 * (RUN_TIME2 + TIME_DIFF)) / \
714 (RUN_TIME1 + RUN_TIME2) * 12 / 10))
715 for n in $(seq $MDSCOUNT); do
716 SPEED=$(scrub_status $n | awk '/^average_speed/ { print $2 }')
717 [ $SPEED -gt $MIN_SPEED ] ||
718 error "(11) Got speed $SPEED, expected more than" \
720 [ $SPEED -lt $MAX_SPEED ] ||
721 error "(12) Got speed $SPEED, expected less than" \
724 do_facet mds$n $LCTL set_param -n \
725 mdd.$(facet_svc mds$n).lfsck_speed_limit 0
728 scrub_check_status 13 completed
730 run_test 9 "OI scrub speed control"
734 scrub_backup_restore 1
736 echo "starting mds$n with OI scrub disabled"
737 scrub_start_mds 2 "$MOUNT_OPTS_NOSCRUB"
739 scrub_check_status 3 init
741 scrub_check_flags 4 inconsistent
743 mount_client $MOUNT || error "(5) Fail to start client!"
747 for n in $(seq $MDSCOUNT); do
748 #define OBD_FAIL_OSD_SCRUB_DELAY 0x190
749 do_facet mds$n $LCTL set_param fail_val=1
750 do_facet mds$n $LCTL set_param fail_loc=0x190
754 scrub_check_status 7 scanning
756 umount_client $MOUNT || error "(8) Fail to stop client!"
760 echo "starting MDTs with OI scrub disabled"
761 scrub_start_mds 10 "$MOUNT_OPTS_NOSCRUB"
763 scrub_check_status 11 paused
767 echo "starting MDTs without disabling OI scrub"
768 scrub_start_mds 13 "$MOUNT_OPTS_SCRUB"
770 scrub_check_status 14 scanning
772 for n in $(seq $MDSCOUNT); do
773 do_facet mds$n $LCTL set_param fail_loc=0
774 do_facet mds$n $LCTL set_param fail_val=0
777 scrub_check_status 15 completed
779 scrub_check_flags 16 ""
781 run_test 10a "non-stopped OI scrub should auto restarts after MDS remount (1)"
783 # test_10b is obsolete, it will be coverded by related sanity-lfsck tests.
786 scrub_backup_restore 1
788 echo "starting MDTs with OI scrub disabled"
789 scrub_start_mds 2 "$MOUNT_OPTS_NOSCRUB"
791 scrub_check_status 3 init
793 scrub_check_flags 4 inconsistent
796 for n in $(seq $MDSCOUNT); do
797 #define OBD_FAIL_OSD_SCRUB_DELAY 0x190
798 do_facet mds$n $LCTL set_param fail_val=3
799 do_facet mds$n $LCTL set_param fail_loc=0x190
804 scrub_check_status 6 scanning
808 echo "starting MDTs with OI scrub disabled"
809 scrub_start_mds 8 "$MOUNT_OPTS_NOSCRUB"
811 scrub_check_status 9 paused
815 echo "starting MDTs without disabling OI scrub"
816 scrub_start_mds 11 "$MOUNT_OPTS_SCRUB"
818 scrub_check_status 12 scanning
820 for n in $(seq $MDSCOUNT); do
821 do_facet mds$n $LCTL set_param fail_loc=0
822 do_facet mds$n $LCTL set_param fail_val=0
825 scrub_check_status 13 completed
827 scrub_check_flags 14 ""
829 #run_test 10b "non-stopped OI scrub should auto restarts after MDS remount (2)"
835 formatall > /dev/null
840 local tname=`date +%s`
841 rm -rf $MOUNT/$tname > /dev/null
842 mkdir -p $MOUNT/$tname || error "(0) Failed to create $MOUNT/$tname"
844 for n in $(seq $MDSCOUNT); do
845 $LFS mkdir -i $((n - 1)) $MOUNT/$tname/mds$n ||
846 error "(1) Fail to mkdir $MOUNT/$tname/mds$n"
848 createmany -o $MOUNT/$tname/mds$n/f $CREATED ||
849 error "(2) Fail to create in $tname/mds$n"
853 do_facet $SINGLEMDS $LCTL clear
854 start_full_debug_logging
855 # reset OI scrub start point by force
858 scrub_check_status 4 completed
860 # OI scrub should skip the new created objects for the first accessing
861 # notice we're creating a new llog for every OST on every startup
862 # new features can make this even less stable, so we only check
863 # that the number of skipped files is less than 2x the number of files
864 local MAXIMUM=$((CREATED * 2))
865 local MINIMUM=$((CREATED + 1)) # files + directory
866 for n in $(seq $MDSCOUNT); do
867 local SKIPPED=$(scrub_status $n | awk '/^noscrub/ { print $2 }')
868 [ $SKIPPED -ge $MAXIMUM -o $SKIPPED -lt $MINIMUM ] &&
869 error "(5) Expect [ $MINIMUM , $MAXIMUM ) objects" \
870 "skipped on mds$n, but got $SKIPPED"
873 # reset OI scrub start point by force
876 scrub_check_status 7 completed
878 # OI scrub should skip the new created object only once
879 for n in $(seq $MDSCOUNT); do
880 SKIPPED=$(scrub_status $n | awk '/^noscrub/ { print $2 }')
881 [ $SKIPPED -eq 0 ] ||
882 error "(8) Expect 0 objects skipped on mds$n, but" \
886 stop_full_debug_logging
887 restore_mount $MOUNT || error "(9) Fail to start client!"
888 rm -rf $MOUNT/$tname > /dev/null
890 run_test 11 "OI scrub skips the new created objects only once"
896 formatall > /dev/null
901 $SETSTRIPE -c 1 -i 0 $DIR/$tdir
903 #define OBD_FAIL_OSD_COMPAT_INVALID_ENTRY 0x195
904 do_facet ost1 $LCTL set_param fail_loc=0x195
905 createmany -o $DIR/$tdir/f 1000
912 do_facet ost1 $LCTL set_param fail_loc=0
913 local STATUS=$($SHOW_SCRUB_ON_OST | awk '/^status/ { print $2 }')
914 [ "$STATUS" == "init" ] ||
915 error "(1) Expect 'init', but got '$STATUS'"
917 ls -ail $DIR/$tdir > /dev/null 2>&1 && error "(2) ls should fail"
920 local STATUS=$($SHOW_SCRUB_ON_OST | awk '/^status/ { print $2 }')
921 [ "$STATUS" == "completed" ] ||
922 error "(3) Expect 'completed', but got '$STATUS'"
924 ls -ail $DIR/$tdir > /dev/null 2>&1 || error "(4) ls should succeed"
926 run_test 12 "OI scrub can rebuild invalid /O entries"
932 formatall > /dev/null
937 $SETSTRIPE -c 1 -i 0 $DIR/$tdir
939 #define OBD_FAIL_OSD_COMPAT_NO_ENTRY 0x196
940 do_facet ost1 $LCTL set_param fail_loc=0x196
941 createmany -o $DIR/$tdir/f 1000
942 do_facet ost1 $LCTL set_param fail_loc=0
949 local STATUS=$($SHOW_SCRUB_ON_OST | awk '/^status/ { print $2 }')
950 [ "$STATUS" == "init" ] ||
951 error "(1) Expect 'init', but got '$STATUS'"
953 ls -ail $DIR/$tdir > /dev/null 2>&1 && error "(2) ls should fail"
955 $START_SCRUB_ON_OST || error "(3) Fail to start OI scrub on OST!"
957 local STATUS=$($SHOW_SCRUB_ON_OST | awk '/^status/ { print $2 }')
958 [ "$STATUS" == "completed" ] ||
959 error "(4) Expect 'completed', but got '$STATUS'"
961 ls -ail $DIR/$tdir > /dev/null 2>&1 || error "(5) ls should succeed"
963 run_test 13 "OI scrub can rebuild missed /O entries"
969 formatall > /dev/null
974 $SETSTRIPE -c 1 -i 0 $DIR/$tdir
976 #define OBD_FAIL_OSD_COMPAT_NO_ENTRY 0x196
977 do_facet ost1 $LCTL set_param fail_loc=0x196
978 createmany -o $DIR/$tdir/f 64
979 do_facet ost1 $LCTL set_param fail_loc=0
986 local STATUS=$($SHOW_SCRUB_ON_OST | awk '/^status/ { print $2 }')
987 [ "$STATUS" == "init" ] ||
988 error "(1) Expect 'init', but got '$STATUS'"
990 ls -ail $DIR/$tdir > /dev/null 2>&1 && error "(2) ls should fail"
996 run_e2fsck $(facet_host ost1) $(ostdevname 1) "-y" ||
997 error "(3) Fail to run e2fsck error"
1000 setupall > /dev/null
1002 local LF_REPAIRED=$($SHOW_SCRUB_ON_OST |
1003 awk '/^lf_reparied/ { print $2 }')
1004 [ $LF_REPAIRED -gt 0 ] ||
1005 error "(4) Some entry under /lost+found should be repaired"
1007 ls -ail $DIR/$tdir > /dev/null 2>&1 || error "(5) ls should succeed"
1009 run_test 14 "OI scrub can repair objects under lost+found"
1012 # skip test_15 for LU-4182
1013 [ $MDSCOUNT -ge 2 ] && skip "skip now for >= 2 MDTs" && return
1015 scrub_backup_restore 1
1016 echo "starting MDTs with OI scrub disabled"
1017 scrub_start_mds 2 "$MOUNT_OPTS_NOSCRUB"
1018 scrub_check_status 3 init
1019 scrub_check_flags 4 inconsistent
1021 # run under dryrun mode
1024 scrub_check_status 6 completed
1025 scrub_check_flags 7 inconsistent
1026 scrub_check_params 8 dryrun
1027 scrub_check_repaired 9 20
1029 # run under dryrun mode again
1030 scrub_start 10 -n on
1032 scrub_check_status 11 completed
1033 scrub_check_flags 12 inconsistent
1034 scrub_check_params 13 dryrun
1035 scrub_check_repaired 14 20
1037 # run under normal mode
1038 scrub_start 15 -n off
1040 scrub_check_status 16 completed
1041 scrub_check_flags 17 ""
1042 scrub_check_params 18 ""
1043 scrub_check_repaired 19 20
1045 # run under normal mode again
1046 scrub_start 20 -n off
1048 scrub_check_status 21 completed
1049 scrub_check_flags 22 ""
1050 scrub_check_params 23 ""
1051 scrub_check_repaired 24 0
1053 run_test 15 "Dryrun mode OI scrub"
1055 # restore MDS/OST size
1056 MDSSIZE=${SAVED_MDSSIZE}
1057 OSTSIZE=${SAVED_OSTSIZE}
1059 # cleanup the system at last