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 ost1) -lt $(version_code 2.4.50) ]] &&
46 ALWAYS_EXCEPT="$ALWAYS_EXCEPT 11 12 13 14"
50 MDT_DEV="${FSNAME}-MDT0000"
51 OST_DEV="${FSNAME}-OST0000"
52 MDT_DEVNAME=$(mdsdevname ${SINGLEMDS//mds/})
58 for n in $(seq $MDSCOUNT); do
59 do_facet mds$n $LCTL lfsck_start -M $(facet_svc mds$n) "$@" ||
60 error "($error_id) Failed to start OI scrub on mds$n"
68 for n in $(seq $MDSCOUNT); do
69 do_facet mds$n $LCTL lfsck_stop -M $(facet_svc mds$n) ||
70 error "($error_id) Failed to stop OI scrub on mds$n"
77 do_facet mds$n $LCTL get_param -n \
78 osd-ldiskfs.$(facet_svc mds$n).oi_scrub
81 START_SCRUB="do_facet $SINGLEMDS $LCTL lfsck_start -M ${MDT_DEV}"
82 START_SCRUB_ON_OST="do_facet ost1 $LCTL lfsck_start -M ${OST_DEV}"
83 STOP_SCRUB="do_facet $SINGLEMDS $LCTL lfsck_stop -M ${MDT_DEV}"
84 SHOW_SCRUB="do_facet $SINGLEMDS \
85 $LCTL get_param -n osd-ldiskfs.${MDT_DEV}.oi_scrub"
86 SHOW_SCRUB_ON_OST="do_facet ost1 \
87 $LCTL get_param -n osd-ldiskfs.${OST_DEV}.oi_scrub"
88 MOUNT_OPTS_SCRUB="-o user_xattr"
89 MOUNT_OPTS_NOSCRUB="-o user_xattr,noscrub"
101 for n in $(seq $MDSCOUNT); do
102 echo "creating $nfiles files on mds$n"
103 if [ $n -eq 1 ]; then
104 mkdir -p $DIR/$tdir/mds$n ||
105 error "Failed to create directory mds$n"
107 $LFS mkdir -i $((n - 1)) $DIR/$tdir/mds$n ||
108 error "Failed to create remote directory mds$n"
110 cp $LUSTRE/tests/*.sh $DIR/$tdir/mds$n ||
111 error "Failed to copy files to mds$n"
112 if [[ $nfiles -gt 0 ]]; then
113 createmany -o $DIR/$tdir/mds$n/$tfile $nfiles ||
114 error "createmany failed on mds$n"
118 cleanup_mount $MOUNT > /dev/null || error "Fail to stop client!"
119 for n in $(seq $MDSCOUNT); do
121 stop mds$n > /dev/null || error "Fail to stop MDS$n!"
130 for n in $(seq $MDSCOUNT); do
131 start mds$n $(mdsdevname $n) $opts >/dev/null ||
132 error "($error_id) Failed to start mds$n"
140 for n in $(seq $MDSCOUNT); do
141 echo "stopping mds$n"
142 stop mds$n >/dev/null ||
143 error "($error_id) Failed to stop mds$n"
147 scrub_check_status() {
153 for n in $(seq $MDSCOUNT); do
154 actual=$(do_facet mds$n $LCTL get_param -n \
155 osd-ldiskfs.$(facet_svc mds$n).oi_scrub |
156 awk '/^status/ { print $2 }')
157 if [ "$actual" != "$expected" ]; then
158 error "($error_id) Expected '$expected' on mds$n, but" \
164 scrub_check_flags() {
170 for n in $(seq $MDSCOUNT); do
171 actual=$(do_facet mds$n $LCTL get_param -n \
172 osd-ldiskfs.$(facet_svc mds$n).oi_scrub |
173 awk '/^flags/ { print $2 }')
174 if [ "$actual" != "$expected" ]; then
175 error "($error_id) Expected '$expected' on mds$n, but" \
181 scrub_check_params() {
187 for n in $(seq $MDSCOUNT); do
188 actual=$(do_facet mds$n $LCTL get_param -n \
189 osd-ldiskfs.$(facet_svc mds$n).oi_scrub |
190 awk '/^param/ { print $2 }')
191 if [ "$actual" != "$expected" ]; then
192 error "($error_id) Expected '$expected' on mds$n, but" \
198 scrub_check_repaired() {
204 for n in $(seq $MDSCOUNT); do
205 actual=$(do_facet mds$n $LCTL get_param -n \
206 osd-ldiskfs.$(facet_svc mds$n).oi_scrub |
207 awk '/^updated/ { print $2 }')
209 if [ $expected -eq 0 -a $actual -ne 0 ]; then
210 error "($error_id) Expected no repaired on mds$n, but" \
214 if [ $expected -ne 0 -a $actual -lt $expected ]; then
215 error "($error_id) Expected '$expected' on mds$n, but" \
225 for n in $(seq $MDSCOUNT); do
226 diff -q $LUSTRE/tests/test-framework.sh \
227 $DIR/$tdir/mds$n/test-framework.sh ||
228 error "($error_id) File data check failed"
237 for n in $(seq $MDSCOUNT); do
238 mds_remove_ois mds$n $index ||
239 error "($error_id) Failed to remove OI .$index on mds$n"
243 scrub_backup_restore() {
248 for n in $(seq $MDSCOUNT); do
249 mds_backup_restore mds$n $igif ||
250 error "(error_id) Backup/restore on mds$n failed"
254 scrub_enable_auto() {
257 for n in $(seq $MDSCOUNT); do
258 do_facet mds$n $LCTL set_param -n \
259 osd-ldiskfs.$(facet_svc mds$n).auto_scrub 1
265 echo "starting MDTs without disabling OI scrub"
266 scrub_start_mds 1 "$MOUNT_OPTS_SCRUB"
267 scrub_check_status 2 init
268 scrub_check_flags 3 ""
269 mount_client $MOUNT || error "(4) Fail to start client!"
272 run_test 0 "Do not auto trigger OI scrub for non-backup/restore case"
276 echo "start $SINGLEMDS without disabling OI scrub"
277 start $SINGLEMDS $MDT_DEVNAME $MOUNT_OPTS_SCRUB > /dev/null ||
278 error "(1) Fail to start MDS!"
280 local STATUS=$($SHOW_SCRUB | awk '/^status/ { print $2 }')
281 [ "$STATUS" == "init" ] ||
282 error "(2) Expect 'init', but got '$STATUS'"
284 local FLAGS=$($SHOW_SCRUB | awk '/^flags/ { print $2 }')
285 [ -z "$FLAGS" ] || error "(3) Expect empty flags, but got '$FLAGS'"
287 mount_client $MOUNT || error "(4) Fail to start client!"
289 #define OBD_FAIL_OSD_FID_MAPPING 0x193
290 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x193
291 # update .lustre OI mapping
293 do_facet $SINGLEMDS $LCTL set_param fail_loc=0
295 umount_client $MOUNT || error "(5) Fail to stop client!"
297 echo "stop $SINGLEMDS"
298 stop $SINGLEMDS > /dev/null || error "(6) Fail to stop MDS!"
300 echo "start $SINGLEMDS with disabling OI scrub"
301 start $SINGLEMDS $MDT_DEVNAME $MOUNT_OPTS_NOSCRUB > /dev/null ||
302 error "(7) Fail to start MDS!"
304 local STATUS=$($SHOW_SCRUB | awk '/^status/ { print $2 }')
305 [ "$STATUS" == "init" ] ||
306 error "(8) Expect 'init', but got '$STATUS'"
308 local FLAGS=$($SHOW_SCRUB | awk '/^flags/ { print $2 }')
309 [ "$FLAGS" == "inconsistent" ] ||
310 error "(9) Expect 'inconsistent', but got '$FLAGS'"
312 run_test 1a "Auto trigger initial OI scrub when server mounts"
317 echo "start MDTs without disabling OI scrub"
318 scrub_start_mds 2 "$MOUNT_OPTS_SCRUB"
320 scrub_check_status 3 completed
321 mount_client $MOUNT || error "(4) Fail to start client!"
324 run_test 1b "Trigger OI scrub when MDT mounts for OI files remove/recreate case"
329 # OI files to be removed:
332 # idx 2: oi.16.{2,4,8,16,32}
333 # idx 3: oi.16.{3,9,27}
334 # idx 5: oi.16.{5,25}
335 # idx 7: oi.16.{7,49}
336 for index in 0 1 2 3 5 7; do
338 scrub_remove_ois 1 $index
340 echo "start MDTs with OI scrub disabled"
341 scrub_start_mds 2 "$MOUNT_OPTS_NOSCRUB"
342 scrub_check_flags 3 recreated
345 scrub_check_status 5 completed
346 scrub_check_flags 6 ""
349 run_test 1c "Auto detect kinds of OI file(s) removed/recreated cases"
353 scrub_backup_restore 1
354 echo "starting MDTs without disabling OI scrub"
355 scrub_start_mds 2 "$MOUNT_OPTS_SCRUB"
357 scrub_check_status 3 completed
358 mount_client $MOUNT || error "(4) Fail to start client!"
361 run_test 2 "Trigger OI scrub when MDT mounts for backup/restore case"
365 scrub_backup_restore 1
366 echo "starting MDTs with OI scrub disabled"
367 scrub_start_mds 2 "$MOUNT_OPTS_NOSCRUB"
369 scrub_check_status 3 init
370 scrub_check_flags 4 inconsistent
374 run_test 3 "Do not trigger OI scrub when MDT mounts if 'noscrub' specified"
378 scrub_backup_restore 1
379 echo "starting MDTs with OI scrub disabled"
380 scrub_start_mds 2 "$MOUNT_OPTS_NOSCRUB"
381 scrub_check_status 3 init
382 scrub_check_flags 4 inconsistent
383 mount_client $MOUNT || error "(5) Fail to start client!"
387 scrub_check_status 7 completed
389 run_test 4 "Trigger OI scrub automatically if inconsistent OI mapping was found"
393 scrub_backup_restore 1
394 echo "starting MDTs with OI scrub disabled"
395 scrub_start_mds 2 "$MOUNT_OPTS_NOSCRUB"
396 scrub_check_status 3 init
397 scrub_check_flags 4 inconsistent
398 mount_client $MOUNT || error "(5) Fail to start client!"
402 for n in $(seq $MDSCOUNT); do
403 #define OBD_FAIL_OSD_SCRUB_DELAY 0x190
404 do_facet mds$n $LCTL set_param fail_val=3
405 do_facet mds$n $LCTL set_param fail_loc=0x190
409 umount_client $MOUNT || error "(7) Fail to stop client!"
411 scrub_check_status 8 scanning
413 for n in $(seq $MDSCOUNT); do
414 #define OBD_FAIL_OSD_SCRUB_CRASH 0x191
415 do_facet mds$n $LCTL set_param fail_loc=0x191
420 for n in $(seq $MDSCOUNT); do
421 do_facet mds$n $LCTL set_param fail_loc=0
422 do_facet mds$n $LCTL set_param fail_val=0
425 echo "starting MDTs with OI scrub disabled"
426 scrub_start_mds 10 "$MOUNT_OPTS_NOSCRUB"
428 scrub_check_status 11 crashed
432 for n in $(seq $MDSCOUNT); do
433 #define OBD_FAIL_OSD_SCRUB_DELAY 0x190
434 do_facet mds$n $LCTL set_param fail_val=3
435 do_facet mds$n $LCTL set_param fail_loc=0x190
437 echo "starting MDTs without disabling OI scrub"
438 scrub_start_mds 13 "$MOUNT_OPTS_SCRUB"
440 scrub_check_status 14 scanning
442 for n in $(seq $MDSCOUNT); do
443 #define OBD_FAIL_OSD_SCRUB_FATAL 0x192
444 do_facet mds$n $LCTL set_param fail_loc=0x192
447 scrub_check_status 15 failed
449 mount_client $MOUNT || error "(16) Fail to start client!"
451 for n in $(seq $MDSCOUNT); do
452 #define OBD_FAIL_OSD_SCRUB_DELAY 0x190
453 do_facet mds$n $LCTL set_param fail_val=3
454 do_facet mds$n $LCTL set_param fail_loc=0x190
455 stat $DIR/$tdir/mds$n/${tfile}1000 ||
456 error "(17) Failed to stat mds$n/${tfile}1000"
459 scrub_check_status 18 scanning
461 for n in $(seq $MDSCOUNT); do
462 do_facet mds$n $LCTL set_param fail_loc=0
463 do_facet mds$n $LCTL set_param fail_val=0
466 scrub_check_status 19 completed
468 scrub_check_flags 20 ""
470 run_test 5 "OI scrub state machine"
474 scrub_backup_restore 1
475 echo "starting MDTs with OI scrub disabled"
476 scrub_start_mds 2 "$MOUNT_OPTS_NOSCRUB"
477 scrub_check_status 3 init
478 scrub_check_flags 4 inconsistent
479 mount_client $MOUNT || error "(5) Fail to start client!"
482 for n in $(seq $MDSCOUNT); do
483 #define OBD_FAIL_OSD_SCRUB_DELAY 0x190
484 do_facet mds$n $LCTL set_param fail_val=3
485 do_facet mds$n $LCTL set_param fail_loc=0x190
489 # Sleep 5 sec to guarantee at least one object processed by OI scrub
491 # Fail the OI scrub to guarantee there is at least one checkpoint
492 for n in $(seq $MDSCOUNT); do
493 #define OBD_FAIL_OSD_SCRUB_FATAL 0x192
494 do_facet mds$n $LCTL set_param fail_loc=0x192
497 scrub_check_status 7 failed
499 for n in $(seq $MDSCOUNT); do
500 #define OBD_FAIL_OSD_SCRUB_DELAY 0x190
501 do_facet mds$n $LCTL set_param fail_val=3
502 do_facet mds$n $LCTL set_param fail_loc=0x190
503 # stat will re-trigger OI scrub
504 stat $DIR/$tdir/mds$n/${tfile}800 ||
505 error "(8) Failed to stat mds$n/${tfile}800"
508 umount_client $MOUNT || error "(9) Fail to stop client!"
510 scrub_check_status 10 scanning
512 for n in $(seq $MDSCOUNT); do
513 #define OBD_FAIL_OSD_SCRUB_CRASH 0x191
514 do_facet mds$n $LCTL set_param fail_loc=0x191
518 for n in $(seq $MDSCOUNT); do
519 position0[$n]=$(scrub_status $n |
520 awk '/^last_checkpoint_position/ {print $2}')
521 position0[$n]=$((${position0[$n]} + 1))
526 for n in $(seq $MDSCOUNT); do
527 #define OBD_FAIL_OSD_SCRUB_DELAY 0x190
528 do_facet mds$n $LCTL set_param fail_val=3
529 do_facet mds$n $LCTL set_param fail_loc=0x190
531 echo "starting MDTs without disabling OI scrub"
532 scrub_start_mds 12 "$MOUNT_OPTS_SCRUB"
534 scrub_check_status 13 scanning
537 for n in $(seq $MDSCOUNT); do
538 positions1[$n]=$(scrub_status $n |
539 awk '/^latest_start_position/ {print $2}')
540 if [ ${position0[$n]} -ne ${position1[$n]} ]; then
541 error "(14) Expected position ${position0[$n]}, but" \
542 "got ${position1[$n]}"
546 for n in $(seq $MDSCOUNT); do
547 do_facet mds$n $LCTL set_param fail_loc=0
548 do_facet mds$n $LCTL set_param fail_val=0
551 scrub_check_status 15 completed
553 scrub_check_flags 16 ""
555 run_test 6 "OI scrub resumes from last checkpoint"
558 # skip test_7 for LU-4149
559 [ $MDSCOUNT -ge 2 ] && skip "skip now for >= 2 MDTs" && return
562 scrub_backup_restore 1
564 echo "starting MDTs with OI scrub disabled"
565 scrub_start_mds 2 "$MOUNT_OPTS_NOSCRUB"
566 scrub_check_status 3 init
567 scrub_check_flags 4 inconsistent
569 mount_client $MOUNT || error "(5) Fail to start client!"
573 for n in $(seq $MDSCOUNT); do
574 #define OBD_FAIL_OSD_SCRUB_DELAY 0x190
575 do_facet mds$n $LCTL set_param fail_val=3
576 do_facet mds$n $LCTL set_param fail_loc=0x190
580 for n in $(seq $MDSCOUNT); do
581 stat $DIR/$tdir/mds$n/${tfile}300 ||
582 error "(7) Failed to stat mds$n/${tfile}300!"
585 scrub_check_status 8 scanning
587 scrub_check_flags 9 inconsistent,auto
589 for n in $(seq $MDSCOUNT); do
590 do_facet mds$n $LCTL set_param fail_loc=0
591 do_facet mds$n $LCTL set_param fail_val=0
594 scrub_check_status 10 completed
598 run_test 7 "System is available during OI scrub scanning"
602 scrub_backup_restore 1
604 echo "starting MDTs with OI scrub disabled"
605 scrub_start_mds 2 "$MOUNT_OPTS_NOSCRUB"
607 scrub_check_status 3 init
609 scrub_check_flags 4 inconsistent
612 for n in $(seq $MDSCOUNT); do
613 #define OBD_FAIL_OSD_SCRUB_DELAY 0x190
614 do_facet mds$n $LCTL set_param fail_val=1
615 do_facet mds$n $LCTL set_param fail_loc=0x190
619 scrub_check_status 6 scanning
623 scrub_check_status 8 stopped
627 scrub_check_status 10 scanning
629 for n in $(seq $MDSCOUNT); do
630 do_facet mds$n $LCTL set_param fail_loc=0
631 do_facet mds$n $LCTL set_param fail_val=0
634 scrub_check_status 11 completed
636 scrub_check_flags 12 ""
638 run_test 8 "Control OI scrub manually"
641 if [ -z "$(grep "processor.*: 1" /proc/cpuinfo)" ]; then
642 skip "Testing on UP system, the speed may be inaccurate."
647 scrub_backup_restore 1
649 echo "starting MDTs with OI scrub disabled"
650 scrub_start_mds 2 "$MOUNT_OPTS_NOSCRUB"
652 scrub_check_status 3 init
654 scrub_check_flags 4 inconsistent
656 local BASE_SPEED1=100
658 # OI scrub should run with full speed under inconsistent case
659 scrub_start 5 -s $BASE_SPEED1
662 scrub_check_status 6 completed
664 scrub_check_flags 7 ""
666 # OI scrub should run with limited speed under non-inconsistent case
667 scrub_start 8 -s $BASE_SPEED1 -r
670 scrub_check_status 9 scanning
672 # Do NOT ignore that there are 1024 pre-fetched items. And there
673 # may be time error, normally it should be less than 2 seconds.
674 # We allow another 20% schedule error.
675 local PRE_FETCHED=1024
677 # MAX_MARGIN = 1.2 = 12 / 10
678 local MAX_SPEED=$(((PRE_FETCHED + BASE_SPEED1 * \
679 (RUN_TIME1 + TIME_DIFF)) / RUN_TIME1 * 12 / 10))
681 for n in $(seq $MDSCOUNT); do
682 local SPEED=$(scrub_status $n | \
683 awk '/^average_speed/ { print $2 }')
684 [ $SPEED -lt $MAX_SPEED ] ||
685 error "(10) Got speed $SPEED, expected less than" \
690 local BASE_SPEED2=300
692 for n in $(seq $MDSCOUNT); do
693 do_facet mds$n $LCTL set_param -n \
694 mdd.$(facet_svc mds$n).lfsck_speed_limit $BASE_SPEED2
698 # MIN_MARGIN = 0.8 = 8 / 10
699 local MIN_SPEED=$(((PRE_FETCHED + \
700 BASE_SPEED1 * (RUN_TIME1 - TIME_DIFF) + \
701 BASE_SPEED2 * (RUN_TIME2 - TIME_DIFF)) / \
702 (RUN_TIME1 + RUN_TIME2) * 8 / 10))
703 # MAX_MARGIN = 1.2 = 12 / 10
704 MAX_SPEED=$(((PRE_FETCHED + \
705 BASE_SPEED1 * (RUN_TIME1 + TIME_DIFF) + \
706 BASE_SPEED2 * (RUN_TIME2 + TIME_DIFF)) / \
707 (RUN_TIME1 + RUN_TIME2) * 12 / 10))
708 for n in $(seq $MDSCOUNT); do
709 SPEED=$(scrub_status $n | awk '/^average_speed/ { print $2 }')
710 [ $SPEED -gt $MIN_SPEED ] ||
711 error "(11) Got speed $SPEED, expected more than" \
713 [ $SPEED -lt $MAX_SPEED ] ||
714 error "(12) Got speed $SPEED, expected less than" \
717 do_facet mds$n $LCTL set_param -n \
718 mdd.$(facet_svc mds$n).lfsck_speed_limit 0
721 scrub_check_status 13 completed
723 run_test 9 "OI scrub speed control"
727 scrub_backup_restore 1
729 echo "starting mds$n with OI scrub disabled"
730 scrub_start_mds 2 "$MOUNT_OPTS_NOSCRUB"
732 scrub_check_status 3 init
734 scrub_check_flags 4 inconsistent
736 mount_client $MOUNT || error "(5) Fail to start client!"
740 for n in $(seq $MDSCOUNT); do
741 #define OBD_FAIL_OSD_SCRUB_DELAY 0x190
742 do_facet mds$n $LCTL set_param fail_val=1
743 do_facet mds$n $LCTL set_param fail_loc=0x190
747 scrub_check_status 7 scanning
749 umount_client $MOUNT || error "(8) Fail to stop client!"
753 echo "starting MDTs with OI scrub disabled"
754 scrub_start_mds 10 "$MOUNT_OPTS_NOSCRUB"
756 scrub_check_status 11 paused
760 echo "starting MDTs without disabling OI scrub"
761 scrub_start_mds 13 "$MOUNT_OPTS_SCRUB"
763 scrub_check_status 14 scanning
765 for n in $(seq $MDSCOUNT); do
766 do_facet mds$n $LCTL set_param fail_loc=0
767 do_facet mds$n $LCTL set_param fail_val=0
770 scrub_check_status 15 completed
772 scrub_check_flags 16 ""
774 run_test 10a "non-stopped OI scrub should auto restarts after MDS remount (1)"
776 # test_10b is obsolete, it will be coverded by related sanity-lfsck tests.
779 scrub_backup_restore 1
781 echo "starting MDTs with OI scrub disabled"
782 scrub_start_mds 2 "$MOUNT_OPTS_NOSCRUB"
784 scrub_check_status 3 init
786 scrub_check_flags 4 inconsistent
789 for n in $(seq $MDSCOUNT); do
790 #define OBD_FAIL_OSD_SCRUB_DELAY 0x190
791 do_facet mds$n $LCTL set_param fail_val=3
792 do_facet mds$n $LCTL set_param fail_loc=0x190
797 scrub_check_status 6 scanning
801 echo "starting MDTs with OI scrub disabled"
802 scrub_start_mds 8 "$MOUNT_OPTS_NOSCRUB"
804 scrub_check_status 9 paused
808 echo "starting MDTs without disabling OI scrub"
809 scrub_start_mds 11 "$MOUNT_OPTS_SCRUB"
811 scrub_check_status 12 scanning
813 for n in $(seq $MDSCOUNT); do
814 do_facet mds$n $LCTL set_param fail_loc=0
815 do_facet mds$n $LCTL set_param fail_val=0
818 scrub_check_status 13 completed
820 scrub_check_flags 14 ""
822 #run_test 10b "non-stopped OI scrub should auto restarts after MDS remount (2)"
828 formatall > /dev/null
833 local tname=`date +%s`
834 rm -rf $MOUNT/$tname > /dev/null
835 mkdir -p $MOUNT/$tname || error "(0) Failed to create $MOUNT/$tname"
837 for n in $(seq $MDSCOUNT); do
838 $LFS mkdir -i $((n - 1)) $MOUNT/$tname/mds$n ||
839 error "(1) Fail to mkdir $MOUNT/$tname/mds$n"
841 createmany -o $MOUNT/$tname/mds$n/f $CREATED ||
842 error "(2) Fail to create in $tname/mds$n"
846 do_facet $SINGLEMDS $LCTL clear
847 start_full_debug_logging
848 # reset OI scrub start point by force
851 scrub_check_status 4 completed
853 # OI scrub should skip the new created objects for the first accessing
854 # notice we're creating a new llog for every OST on every startup
855 # new features can make this even less stable, so we only check
856 # that the number of skipped files is less than 2x the number of files
857 local MAXIMUM=$((CREATED * 2))
858 local MINIMUM=$((CREATED + 1)) # files + directory
859 for n in $(seq $MDSCOUNT); do
860 local SKIPPED=$(scrub_status $n | awk '/^noscrub/ { print $2 }')
861 [ $SKIPPED -ge $MAXIMUM -o $SKIPPED -lt $MINIMUM ] &&
862 error "(5) Expect [ $MINIMUM , $MAXIMUM ) objects" \
863 "skipped on mds$n, but got $SKIPPED"
866 # reset OI scrub start point by force
869 scrub_check_status 7 completed
871 # OI scrub should skip the new created object only once
872 for n in $(seq $MDSCOUNT); do
873 SKIPPED=$(scrub_status $n | awk '/^noscrub/ { print $2 }')
874 [ $SKIPPED -eq 0 ] ||
875 error "(8) Expect 0 objects skipped on mds$n, but" \
879 stop_full_debug_logging
880 restore_mount $MOUNT || error "(9) Fail to start client!"
881 rm -rf $MOUNT/$tname > /dev/null
883 run_test 11 "OI scrub skips the new created objects only once"
889 formatall > /dev/null
894 $SETSTRIPE -c 1 -i 0 $DIR/$tdir
896 #define OBD_FAIL_OSD_COMPAT_INVALID_ENTRY 0x195
897 do_facet ost1 $LCTL set_param fail_loc=0x195
898 createmany -o $DIR/$tdir/f 1000
905 do_facet ost1 $LCTL set_param fail_loc=0
906 local STATUS=$($SHOW_SCRUB_ON_OST | awk '/^status/ { print $2 }')
907 [ "$STATUS" == "init" ] ||
908 error "(1) Expect 'init', but got '$STATUS'"
910 ls -ail $DIR/$tdir > /dev/null 2>&1 && error "(2) ls should fail"
913 local STATUS=$($SHOW_SCRUB_ON_OST | awk '/^status/ { print $2 }')
914 [ "$STATUS" == "completed" ] ||
915 error "(3) Expect 'completed', but got '$STATUS'"
917 ls -ail $DIR/$tdir > /dev/null 2>&1 || error "(4) ls should succeed"
919 run_test 12 "OI scrub can rebuild invalid /O entries"
925 formatall > /dev/null
930 $SETSTRIPE -c 1 -i 0 $DIR/$tdir
932 #define OBD_FAIL_OSD_COMPAT_NO_ENTRY 0x196
933 do_facet ost1 $LCTL set_param fail_loc=0x196
934 createmany -o $DIR/$tdir/f 1000
935 do_facet ost1 $LCTL set_param fail_loc=0
942 local STATUS=$($SHOW_SCRUB_ON_OST | awk '/^status/ { print $2 }')
943 [ "$STATUS" == "init" ] ||
944 error "(1) Expect 'init', but got '$STATUS'"
946 ls -ail $DIR/$tdir > /dev/null 2>&1 && error "(2) ls should fail"
948 $START_SCRUB_ON_OST || error "(3) Fail to start OI scrub on OST!"
950 local STATUS=$($SHOW_SCRUB_ON_OST | awk '/^status/ { print $2 }')
951 [ "$STATUS" == "completed" ] ||
952 error "(4) Expect 'completed', but got '$STATUS'"
954 ls -ail $DIR/$tdir > /dev/null 2>&1 || error "(5) ls should succeed"
956 run_test 13 "OI scrub can rebuild missed /O entries"
962 formatall > /dev/null
967 $SETSTRIPE -c 1 -i 0 $DIR/$tdir
969 #define OBD_FAIL_OSD_COMPAT_NO_ENTRY 0x196
970 do_facet ost1 $LCTL set_param fail_loc=0x196
971 createmany -o $DIR/$tdir/f 64
972 do_facet ost1 $LCTL set_param fail_loc=0
979 local STATUS=$($SHOW_SCRUB_ON_OST | awk '/^status/ { print $2 }')
980 [ "$STATUS" == "init" ] ||
981 error "(1) Expect 'init', but got '$STATUS'"
983 ls -ail $DIR/$tdir > /dev/null 2>&1 && error "(2) ls should fail"
989 run_e2fsck $(facet_host ost1) $(ostdevname 1) "-y" ||
990 error "(3) Fail to run e2fsck error"
995 local LF_REPAIRED=$($SHOW_SCRUB_ON_OST |
996 awk '/^lf_reparied/ { print $2 }')
997 [ $LF_REPAIRED -gt 0 ] ||
998 error "(4) Some entry under /lost+found should be repaired"
1000 ls -ail $DIR/$tdir > /dev/null 2>&1 || error "(5) ls should succeed"
1002 run_test 14 "OI scrub can repair objects under lost+found"
1005 # skip test_15 for LU-4182
1006 [ $MDSCOUNT -ge 2 ] && skip "skip now for >= 2 MDTs" && return
1008 scrub_backup_restore 1
1009 echo "starting MDTs with OI scrub disabled"
1010 scrub_start_mds 2 "$MOUNT_OPTS_NOSCRUB"
1011 scrub_check_status 3 init
1012 scrub_check_flags 4 inconsistent
1014 # run under dryrun mode
1017 scrub_check_status 6 completed
1018 scrub_check_flags 7 inconsistent
1019 scrub_check_params 8 dryrun
1020 scrub_check_repaired 9 20
1022 # run under dryrun mode again
1023 scrub_start 10 -n on
1025 scrub_check_status 11 completed
1026 scrub_check_flags 12 inconsistent
1027 scrub_check_params 13 dryrun
1028 scrub_check_repaired 14 20
1030 # run under normal mode
1031 scrub_start 15 -n off
1033 scrub_check_status 16 completed
1034 scrub_check_flags 17 ""
1035 scrub_check_params 18 ""
1036 scrub_check_repaired 19 20
1038 # run under normal mode again
1039 scrub_start 20 -n off
1041 scrub_check_status 21 completed
1042 scrub_check_flags 22 ""
1043 scrub_check_params 23 ""
1044 scrub_check_repaired 24 0
1046 run_test 15 "Dryrun mode OI scrub"
1048 # restore MDS/OST size
1049 MDSSIZE=${SAVED_MDSSIZE}
1050 OSTSIZE=${SAVED_OSTSIZE}
1052 # cleanup the system at last