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 SAVED_OSTCOUNT=${OSTCOUNT}
25 # use small MDS + OST size to speed formatting time
26 # do not use too small MDSSIZE/OSTSIZE, which affect the default journal size
29 # no need too much OSTs, to reduce the format/start/stop overhead
30 [ $OSTCOUNT -gt 4 ] && OSTCOUNT=4
34 # build up a clean test environment.
38 [ $(facet_fstype $SINGLEMDS) != "ldiskfs" ] &&
39 skip "test OI scrub only for ldiskfs" && check_and_cleanup_lustre &&
41 [ $(facet_fstype ost1) != "ldiskfs" ] &&
42 skip "test OI scrub only for ldiskfs" && check_and_cleanup_lustre &&
44 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.2.90) ]] &&
45 skip "Need MDS version at least 2.2.90" && check_and_cleanup_lustre &&
48 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.3.90) ]] &&
49 ALWAYS_EXCEPT="$ALWAYS_EXCEPT 1a"
51 [[ $(lustre_version_code $SINGLEMDS) -le $(version_code 2.4.1) ]] &&
52 ALWAYS_EXCEPT="$ALWAYS_EXCEPT 15"
54 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.90) ]] &&
55 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.4.50) ]] &&
56 ALWAYS_EXCEPT="$ALWAYS_EXCEPT 15"
58 [[ $(lustre_version_code ost1) -lt $(version_code 2.4.50) ]] &&
59 ALWAYS_EXCEPT="$ALWAYS_EXCEPT 11 12 13 14"
63 MDT_DEV="${FSNAME}-MDT0000"
64 OST_DEV="${FSNAME}-OST0000"
65 MDT_DEVNAME=$(mdsdevname ${SINGLEMDS//mds/})
71 for n in $(seq $MDSCOUNT); do
72 do_facet mds$n $LCTL lfsck_start -M $(facet_svc mds$n) "$@" ||
73 error "($error_id) Failed to start OI scrub on mds$n"
81 for n in $(seq $MDSCOUNT); do
82 do_facet mds$n $LCTL lfsck_stop -M $(facet_svc mds$n) ||
83 error "($error_id) Failed to stop OI scrub on mds$n"
90 do_facet mds$n $LCTL get_param -n \
91 osd-ldiskfs.$(facet_svc mds$n).oi_scrub
94 START_SCRUB="do_facet $SINGLEMDS $LCTL lfsck_start -M ${MDT_DEV}"
95 START_SCRUB_ON_OST="do_facet ost1 $LCTL lfsck_start -M ${OST_DEV}"
96 STOP_SCRUB="do_facet $SINGLEMDS $LCTL lfsck_stop -M ${MDT_DEV}"
97 SHOW_SCRUB="do_facet $SINGLEMDS \
98 $LCTL get_param -n osd-ldiskfs.${MDT_DEV}.oi_scrub"
99 SHOW_SCRUB_ON_OST="do_facet ost1 \
100 $LCTL get_param -n osd-ldiskfs.${OST_DEV}.oi_scrub"
101 MOUNT_OPTS_SCRUB="-o user_xattr"
102 MOUNT_OPTS_NOSCRUB="-o user_xattr,noscrub"
110 echo "preparing... $(date)"
111 for n in $(seq $MDSCOUNT); do
112 echo "creating $nfiles files on mds$n"
113 if [ $n -eq 1 ]; then
114 mkdir $DIR/$tdir/mds$n ||
115 error "Failed to create directory mds$n"
117 $LFS mkdir -i $((n - 1)) $DIR/$tdir/mds$n ||
118 error "Failed to create remote directory mds$n"
120 cp $LUSTRE/tests/*.sh $DIR/$tdir/mds$n ||
121 error "Failed to copy files to mds$n"
122 if [[ $nfiles -gt 0 ]]; then
123 createmany -m $DIR/$tdir/mds$n/$tfile $nfiles > \
124 /dev/null || error "createmany failed on mds$n"
127 echo "prepared $(date)."
128 cleanup_mount $MOUNT > /dev/null || error "Fail to stop client!"
129 for n in $(seq $MDSCOUNT); do
131 stop mds$n > /dev/null || error "Fail to stop MDS$n!"
140 for n in $(seq $MDSCOUNT); do
141 start mds$n $(mdsdevname $n) $opts >/dev/null ||
142 error "($error_id) Failed to start mds$n"
150 for n in $(seq $MDSCOUNT); do
151 echo "stopping mds$n"
152 stop mds$n >/dev/null ||
153 error "($error_id) Failed to stop mds$n"
157 scrub_check_status() {
162 for n in $(seq $MDSCOUNT); do
163 wait_update_facet mds$n "$LCTL get_param -n \
164 osd-ldiskfs.$(facet_svc mds$n).oi_scrub |
165 awk '/^status/ { print \\\$2 }'" "$expected" 6 ||
166 error "($error_id) Expected '$expected' on mds$n"
170 scrub_check_flags() {
176 for n in $(seq $MDSCOUNT); do
177 actual=$(do_facet mds$n $LCTL get_param -n \
178 osd-ldiskfs.$(facet_svc mds$n).oi_scrub |
179 awk '/^flags/ { print $2 }')
180 if [ "$actual" != "$expected" ]; then
181 error "($error_id) Expected '$expected' on mds$n, but" \
187 scrub_check_params() {
193 for n in $(seq $MDSCOUNT); do
194 actual=$(do_facet mds$n $LCTL get_param -n \
195 osd-ldiskfs.$(facet_svc mds$n).oi_scrub |
196 awk '/^param/ { print $2 }')
197 if [ "$actual" != "$expected" ]; then
198 error "($error_id) Expected '$expected' on mds$n, but" \
204 scrub_check_repaired() {
210 for n in $(seq $MDSCOUNT); do
211 actual=$(do_facet mds$n $LCTL get_param -n \
212 osd-ldiskfs.$(facet_svc mds$n).oi_scrub |
213 awk '/^updated/ { print $2 }')
215 if [ $expected -eq 0 -a $actual -ne 0 ]; then
216 error "($error_id) Expected no repaired on mds$n, but" \
220 if [ $expected -ne 0 -a $actual -lt $expected ]; then
221 error "($error_id) Expected '$expected' on mds$n, but" \
231 for n in $(seq $MDSCOUNT); do
232 diff -q $LUSTRE/tests/test-framework.sh \
233 $DIR/$tdir/mds$n/test-framework.sh ||
234 error "($error_id) File data check failed"
243 for n in $(seq $MDSCOUNT); do
244 mds_remove_ois mds$n $index ||
245 error "($error_id) Failed to remove OI .$index on mds$n"
249 scrub_backup_restore() {
254 for n in $(seq $MDSCOUNT); do
255 mds_backup_restore mds$n $igif ||
256 error "(error_id) Backup/restore on mds$n failed"
260 scrub_enable_auto() {
263 for n in $(seq $MDSCOUNT); do
264 do_facet mds$n $LCTL set_param -n \
265 osd-ldiskfs.$(facet_svc mds$n).auto_scrub 1
271 echo "starting MDTs without disabling OI scrub"
272 scrub_start_mds 1 "$MOUNT_OPTS_SCRUB"
273 scrub_check_status 2 init
274 scrub_check_flags 3 ""
275 mount_client $MOUNT || error "(4) Fail to start client!"
278 run_test 0 "Do not auto trigger OI scrub for non-backup/restore case"
282 echo "start $SINGLEMDS without disabling OI scrub"
283 start $SINGLEMDS $MDT_DEVNAME $MOUNT_OPTS_SCRUB > /dev/null ||
284 error "(1) Fail to start MDS!"
286 local FLAGS=$($SHOW_SCRUB | awk '/^flags/ { print $2 }')
287 [ -z "$FLAGS" ] || error "(3) Expect empty flags, but got '$FLAGS'"
289 mount_client $MOUNT || error "(4) Fail to start client!"
290 #define OBD_FAIL_OSD_FID_MAPPING 0x193
291 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x193
292 # update .lustre OI mapping
294 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 FLAGS=$($SHOW_SCRUB | awk '/^flags/ { print $2 }')
305 [ "$FLAGS" == "inconsistent" ] ||
306 error "(9) Expect 'inconsistent', but got '$FLAGS'"
308 run_test 1a "Auto trigger initial OI scrub when server mounts"
313 echo "start MDTs without disabling OI scrub"
314 scrub_start_mds 2 "$MOUNT_OPTS_SCRUB"
315 scrub_check_status 3 completed
316 mount_client $MOUNT || error "(4) Fail to start client!"
319 run_test 1b "Trigger OI scrub when MDT mounts for OI files remove/recreate case"
324 # OI files to be removed:
326 # idx 2: oi.16.{2,4,8,16,32}
327 # idx 3: oi.16.{3,9,27}
328 for index in 0 2 3; do
330 scrub_remove_ois 1 $index
331 echo "start MDTs with OI scrub disabled"
332 scrub_start_mds 2 "$MOUNT_OPTS_NOSCRUB"
333 scrub_check_flags 3 recreated
335 scrub_check_status 5 completed
336 scrub_check_flags 6 ""
339 run_test 1c "Auto detect kinds of OI file(s) removed/recreated cases"
343 scrub_backup_restore 1
344 echo "starting MDTs without disabling OI scrub"
345 scrub_start_mds 2 "$MOUNT_OPTS_SCRUB"
346 scrub_check_status 3 completed
347 mount_client $MOUNT || error "(4) Fail to start client!"
350 run_test 2 "Trigger OI scrub when MDT mounts for backup/restore case"
352 # test_3 is obsolete, it will be covered by test_5.
354 formatall > /dev/null
358 scrub_backup_restore 1
359 echo "starting MDTs with OI scrub disabled"
360 scrub_start_mds 2 "$MOUNT_OPTS_NOSCRUB"
361 scrub_check_status 3 init
362 scrub_check_flags 4 inconsistent
364 #run_test 3 "Do not trigger OI scrub when MDT mounts if 'noscrub' specified"
368 scrub_backup_restore 1
369 echo "starting MDTs with OI scrub disabled"
370 scrub_start_mds 2 "$MOUNT_OPTS_NOSCRUB"
371 scrub_check_flags 4 inconsistent
372 mount_client $MOUNT || error "(5) Fail to start client!"
375 scrub_check_status 7 completed
376 scrub_check_flags 8 ""
378 run_test 4 "Trigger OI scrub automatically if inconsistent OI mapping was found"
381 formatall > /dev/null
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!"
393 #define OBD_FAIL_OSD_SCRUB_DELAY 0x190
394 do_nodes $(comma_list $(mdts_nodes)) \
395 $LCTL set_param fail_val=3 fail_loc=0x190
398 umount_client $MOUNT || error "(7) Fail to stop client!"
399 scrub_check_status 8 scanning
401 #define OBD_FAIL_OSD_SCRUB_CRASH 0x191
402 do_nodes $(comma_list $(mdts_nodes)) $LCTL set_param fail_loc=0x191
407 do_nodes $(comma_list $(mdts_nodes)) \
408 $LCTL set_param fail_loc=0 fail_val=0
410 echo "starting MDTs with OI scrub disabled"
411 scrub_start_mds 10 "$MOUNT_OPTS_NOSCRUB"
412 scrub_check_status 11 crashed
415 #define OBD_FAIL_OSD_SCRUB_DELAY 0x190
416 do_nodes $(comma_list $(mdts_nodes)) \
417 $LCTL set_param fail_val=3 fail_loc=0x190
419 echo "starting MDTs without disabling OI scrub"
420 scrub_start_mds 13 "$MOUNT_OPTS_SCRUB"
421 scrub_check_status 14 scanning
423 #define OBD_FAIL_OSD_SCRUB_FATAL 0x192
424 do_nodes $(comma_list $(mdts_nodes)) $LCTL set_param fail_loc=0x192
426 scrub_check_status 15 failed
427 mount_client $MOUNT || error "(16) Fail to start client!"
429 #define OBD_FAIL_OSD_SCRUB_DELAY 0x190
430 do_nodes $(comma_list $(mdts_nodes)) \
431 $LCTL set_param fail_val=3 fail_loc=0x190
434 for n in $(seq $MDSCOUNT); do
435 stat $DIR/$tdir/mds$n/${tfile}800 ||
436 error "(17) Failed to stat mds$n/${tfile}800"
439 scrub_check_status 18 scanning
441 do_nodes $(comma_list $(mdts_nodes)) \
442 $LCTL set_param fail_loc=0 fail_val=0
444 scrub_check_status 19 completed
445 scrub_check_flags 20 ""
447 run_test 5 "OI scrub state machine"
451 scrub_backup_restore 1
452 echo "starting MDTs with OI scrub disabled"
453 scrub_start_mds 2 "$MOUNT_OPTS_NOSCRUB"
454 scrub_check_flags 4 inconsistent
455 mount_client $MOUNT || error "(5) Fail to start client!"
458 #define OBD_FAIL_OSD_SCRUB_DELAY 0x190
459 do_nodes $(comma_list $(mdts_nodes)) \
460 $LCTL set_param fail_val=3 fail_loc=0x190
464 # Sleep 5 sec to guarantee at least one object processed by OI scrub
466 # Fail the OI scrub to guarantee there is at least one checkpoint
467 #define OBD_FAIL_OSD_SCRUB_FATAL 0x192
468 do_nodes $(comma_list $(mdts_nodes)) $LCTL set_param fail_loc=0x192
470 scrub_check_status 7 failed
472 #define OBD_FAIL_OSD_SCRUB_DELAY 0x190
473 do_nodes $(comma_list $(mdts_nodes)) \
474 $LCTL set_param fail_val=3 fail_loc=0x190
477 for n in $(seq $MDSCOUNT); do
478 # stat will re-trigger OI scrub
479 stat $DIR/$tdir/mds$n/${tfile}800 ||
480 error "(8) Failed to stat mds$n/${tfile}800"
483 umount_client $MOUNT || error "(9) Fail to stop client!"
484 scrub_check_status 10 scanning
486 #define OBD_FAIL_OSD_SCRUB_CRASH 0x191
487 do_nodes $(comma_list $(mdts_nodes)) $LCTL set_param fail_loc=0x191
491 for n in $(seq $MDSCOUNT); do
492 position0[$n]=$(scrub_status $n |
493 awk '/^last_checkpoint_position/ {print $2}')
494 position0[$n]=$((${position0[$n]} + 1))
499 #define OBD_FAIL_OSD_SCRUB_DELAY 0x190
500 do_nodes $(comma_list $(mdts_nodes)) \
501 $LCTL set_param fail_val=3 fail_loc=0x190
503 echo "starting MDTs without disabling OI scrub"
504 scrub_start_mds 12 "$MOUNT_OPTS_SCRUB"
506 scrub_check_status 13 scanning
509 for n in $(seq $MDSCOUNT); do
510 position1[$n]=$(scrub_status $n |
511 awk '/^latest_start_position/ {print $2}')
512 if [ ${position0[$n]} -ne ${position1[$n]} ]; then
513 error "(14) Expected position ${position0[$n]}, but" \
514 "got ${position1[$n]}"
518 do_nodes $(comma_list $(mdts_nodes)) \
519 $LCTL set_param fail_loc=0 fail_val=0
521 scrub_check_status 15 completed
522 scrub_check_flags 16 ""
524 run_test 6 "OI scrub resumes from last checkpoint"
528 scrub_backup_restore 1
529 echo "starting MDTs with OI scrub disabled"
530 scrub_start_mds 2 "$MOUNT_OPTS_NOSCRUB"
531 scrub_check_flags 4 inconsistent
532 mount_client $MOUNT || error "(5) Fail to start client!"
535 #define OBD_FAIL_OSD_SCRUB_DELAY 0x190
536 do_nodes $(comma_list $(mdts_nodes)) \
537 $LCTL set_param fail_val=3 fail_loc=0x190
542 for n in $(seq $MDSCOUNT); do
543 stat $DIR/$tdir/mds$n/${tfile}300 ||
544 error "(7) Failed to stat mds$n/${tfile}300!"
547 scrub_check_status 8 scanning
548 scrub_check_flags 9 inconsistent,auto
550 do_nodes $(comma_list $(mdts_nodes)) \
551 $LCTL set_param fail_loc=0 fail_val=0
553 scrub_check_status 10 completed
556 run_test 7 "System is available during OI scrub scanning"
560 scrub_backup_restore 1
561 echo "starting MDTs with OI scrub disabled"
562 scrub_start_mds 2 "$MOUNT_OPTS_NOSCRUB"
563 scrub_check_flags 4 inconsistent
565 #define OBD_FAIL_OSD_SCRUB_DELAY 0x190
566 do_nodes $(comma_list $(mdts_nodes)) \
567 $LCTL set_param fail_val=1 fail_loc=0x190
570 scrub_check_status 6 scanning
572 scrub_check_status 8 stopped
574 scrub_check_status 10 scanning
576 do_nodes $(comma_list $(mdts_nodes)) \
577 $LCTL set_param fail_loc=0 fail_val=0
579 scrub_check_status 11 completed
580 scrub_check_flags 12 ""
582 run_test 8 "Control OI scrub manually"
585 if [ -z "$(grep "processor.*: 1" /proc/cpuinfo)" ]; then
586 skip "Testing on UP system, the speed may be inaccurate."
591 scrub_backup_restore 1
593 echo "starting MDTs with OI scrub disabled"
594 scrub_start_mds 2 "$MOUNT_OPTS_NOSCRUB"
595 scrub_check_flags 4 inconsistent
597 local BASE_SPEED1=100
599 # OI scrub should run with full speed under inconsistent case
600 scrub_start 5 -s $BASE_SPEED1
603 scrub_check_status 6 completed
604 scrub_check_flags 7 ""
605 # OI scrub should run with limited speed under non-inconsistent case
606 scrub_start 8 -s $BASE_SPEED1 -r
609 scrub_check_status 9 scanning
611 # Do NOT ignore that there are 1024 pre-fetched items. And there
612 # may be time error, normally it should be less than 2 seconds.
613 # We allow another 20% schedule error.
614 local PRE_FETCHED=1024
616 # MAX_MARGIN = 1.2 = 12 / 10
617 local MAX_SPEED=$(((PRE_FETCHED + BASE_SPEED1 * \
618 (RUN_TIME1 + TIME_DIFF)) / RUN_TIME1 * 12 / 10))
620 for n in $(seq $MDSCOUNT); do
621 local SPEED=$(scrub_status $n | \
622 awk '/^average_speed/ { print $2 }')
623 [ $SPEED -lt $MAX_SPEED ] ||
624 error "(10) Got speed $SPEED, expected less than" \
629 local BASE_SPEED2=300
631 for n in $(seq $MDSCOUNT); do
632 do_facet mds$n $LCTL set_param -n \
633 mdd.$(facet_svc mds$n).lfsck_speed_limit $BASE_SPEED2
637 # MIN_MARGIN = 0.8 = 8 / 10
638 local MIN_SPEED=$(((PRE_FETCHED + \
639 BASE_SPEED1 * (RUN_TIME1 - TIME_DIFF) + \
640 BASE_SPEED2 * (RUN_TIME2 - TIME_DIFF)) / \
641 (RUN_TIME1 + RUN_TIME2) * 8 / 10))
642 # MAX_MARGIN = 1.2 = 12 / 10
643 MAX_SPEED=$(((PRE_FETCHED + \
644 BASE_SPEED1 * (RUN_TIME1 + TIME_DIFF) + \
645 BASE_SPEED2 * (RUN_TIME2 + TIME_DIFF)) / \
646 (RUN_TIME1 + RUN_TIME2) * 12 / 10))
647 for n in $(seq $MDSCOUNT); do
648 SPEED=$(scrub_status $n | awk '/^average_speed/ { print $2 }')
649 [ $SPEED -gt $MIN_SPEED ] ||
650 error "(11) Got speed $SPEED, expected more than" \
652 [ $SPEED -lt $MAX_SPEED ] ||
653 error "(12) Got speed $SPEED, expected less than" \
656 do_facet mds$n $LCTL set_param -n \
657 mdd.$(facet_svc mds$n).lfsck_speed_limit 0
660 scrub_check_status 13 completed
662 run_test 9 "OI scrub speed control"
666 scrub_backup_restore 1
667 echo "starting mds$n with OI scrub disabled"
668 scrub_start_mds 2 "$MOUNT_OPTS_NOSCRUB"
669 scrub_check_flags 4 inconsistent
670 mount_client $MOUNT || error "(5) Fail to start client!"
673 #define OBD_FAIL_OSD_SCRUB_DELAY 0x190
674 do_nodes $(comma_list $(mdts_nodes)) \
675 $LCTL set_param fail_val=1 fail_loc=0x190
678 scrub_check_status 7 scanning
679 umount_client $MOUNT || error "(8) Fail to stop client!"
681 echo "starting MDTs with OI scrub disabled"
682 scrub_start_mds 10 "$MOUNT_OPTS_NOSCRUB"
683 scrub_check_status 11 paused
685 echo "starting MDTs without disabling OI scrub"
686 scrub_start_mds 13 "$MOUNT_OPTS_SCRUB"
687 scrub_check_status 14 scanning
689 do_nodes $(comma_list $(mdts_nodes)) \
690 $LCTL set_param fail_loc=0 fail_val=0
692 scrub_check_status 15 completed
693 scrub_check_flags 16 ""
695 run_test 10a "non-stopped OI scrub should auto restarts after MDS remount (1)"
697 # test_10b is obsolete, it will be coverded by related sanity-lfsck tests.
700 scrub_backup_restore 1
701 echo "starting MDTs with OI scrub disabled"
702 scrub_start_mds 2 "$MOUNT_OPTS_NOSCRUB"
703 scrub_check_flags 4 inconsistent
705 #define OBD_FAIL_OSD_SCRUB_DELAY 0x190
706 do_nodes $(comma_list $(mdts_nodes)) \
707 $LCTL set_param fail_val=3 fail_loc=0x190
710 scrub_check_status 6 scanning
712 echo "starting MDTs with OI scrub disabled"
713 scrub_start_mds 8 "$MOUNT_OPTS_NOSCRUB"
714 scrub_check_status 9 paused
716 echo "starting MDTs without disabling OI scrub"
717 scrub_start_mds 11 "$MOUNT_OPTS_SCRUB"
718 scrub_check_status 12 scanning
720 do_nodes $(comma_list $(mdts_nodes)) \
721 $LCTL set_param fail_loc=0 fail_val=0
723 scrub_check_status 13 completed
724 scrub_check_flags 14 ""
726 #run_test 10b "non-stopped OI scrub should auto restarts after MDS remount (2)"
734 for n in $(seq $MDSCOUNT); do
735 $LFS mkdir -i $((n - 1)) $DIR/$tdir/mds$n ||
736 error "(1) Fail to mkdir $DIR/$tdir/mds$n"
738 createmany -o $DIR/$tdir/mds$n/f $CREATED ||
739 error "(2) Fail to create under $tdir/mds$n"
742 # reset OI scrub start point by force
744 scrub_check_status 4 completed
749 # OI scrub should skip the new created objects for the first accessing
750 # notice we're creating a new llog for every OST on every startup
751 # new features can make this even less stable, so we only check
752 # that the number of skipped files is less than 2x the number of files
753 local MAXIMUM=$((CREATED * 2))
754 local MINIMUM=$((CREATED + 1)) # files + directory
755 for n in $(seq $MDSCOUNT); do
756 local SKIPPED=$(scrub_status $n | awk '/^noscrub/ { print $2 }')
757 [ $SKIPPED -ge $MAXIMUM -o $SKIPPED -lt $MINIMUM ] &&
758 error "(5) Expect [ $MINIMUM , $MAXIMUM ) objects" \
759 "skipped on mds$n, but got $SKIPPED"
761 checked0[$n]=$(scrub_status $n | awk '/^checked/ { print $2 }')
764 # reset OI scrub start point by force
766 scrub_check_status 7 completed
768 # OI scrub should skip the new created object only once
769 for n in $(seq $MDSCOUNT); do
770 SKIPPED=$(scrub_status $n | awk '/^noscrub/ { print $2 }')
771 checked1[$n]=$(scrub_status $n | awk '/^checked/ { print $2 }')
773 [ ${checked0[$n]} -ne ${checked1[$n]} -o $SKIPPED -eq 0 ] ||
774 error "(8) Expect 0 objects skipped on mds$n, but" \
778 run_test 11 "OI scrub skips the new created objects only once"
782 $SETSTRIPE -c 1 -i 0 $DIR/$tdir
784 local count=$(precreated_ost_obj_count 0 0)
786 #define OBD_FAIL_OSD_COMPAT_INVALID_ENTRY 0x195
787 do_facet ost1 $LCTL set_param fail_loc=0x195
788 createmany -o $DIR/$tdir/f $((count + 32))
790 umount_client $MOUNT || error "(1) Fail to stop client!"
792 stop ost1 || error "(2) Fail to stop ost1"
794 #define OBD_FAIL_OST_NODESTROY 0x233
795 do_facet ost1 $LCTL set_param fail_loc=0x233
797 start ost1 $(ostdevname 1) $MOUNT_OPTS_NOSCRUB ||
798 error "(3) Fail to start ost1"
800 mount_client $MOUNT || error "(4) Fail to start client!"
802 ls -ail $DIR/$tdir > /dev/null 2>&1 && error "(5) ls should fail"
804 $START_SCRUB_ON_OST -r || error "(6) Fail to start OI scrub on OST!"
806 do_facet ost1 $LCTL set_param fail_loc=0
807 wait_update_facet ost1 "$LCTL get_param -n \
808 osd-ldiskfs.$(facet_svc ost1).oi_scrub |
809 awk '/^status/ { print \\\$2 }'" "completed" 6 ||
810 error "(7) Expected '$expected' on ost1"
812 ls -ail $DIR/$tdir > /dev/null || {
814 error "(8) ls should succeed"
817 run_test 12 "OI scrub can rebuild invalid /O entries"
821 $SETSTRIPE -c 1 -i 0 $DIR/$tdir
823 local count=$(precreated_ost_obj_count 0 0)
825 #define OBD_FAIL_OSD_COMPAT_NO_ENTRY 0x196
826 do_facet ost1 $LCTL set_param fail_loc=0x196
827 createmany -o $DIR/$tdir/f $((count + 32))
828 do_facet ost1 $LCTL set_param fail_loc=0
830 umount_client $MOUNT || error "(1) Fail to stop client!"
832 stop ost1 || error "(2) Fail to stop ost1"
834 start ost1 $(ostdevname 1) $MOUNT_OPTS_NOSCRUB ||
835 error "(3) Fail to start ost1"
837 mount_client $MOUNT || error "(4) Fail to start client!"
839 ls -ail $DIR/$tdir > /dev/null 2>&1 && error "(5) ls should fail"
841 $START_SCRUB_ON_OST -r || error "(6) Fail to start OI scrub on OST!"
843 wait_update_facet ost1 "$LCTL get_param -n \
844 osd-ldiskfs.$(facet_svc ost1).oi_scrub |
845 awk '/^status/ { print \\\$2 }'" "completed" 6 ||
846 error "(7) Expected '$expected' on ost1"
848 ls -ail $DIR/$tdir > /dev/null || error "(8) ls should succeed"
850 run_test 13 "OI scrub can rebuild missed /O entries"
854 $SETSTRIPE -c 1 -i 0 $DIR/$tdir
856 local count=$(precreated_ost_obj_count 0 0)
858 #define OBD_FAIL_OSD_COMPAT_NO_ENTRY 0x196
859 do_facet ost1 $LCTL set_param fail_loc=0x196
860 createmany -o $DIR/$tdir/f $((count + 32))
861 do_facet ost1 $LCTL set_param fail_loc=0
863 umount_client $MOUNT || error "(1) Fail to stop client!"
865 stop ost1 || error "(2) Fail to stop ost1"
868 run_e2fsck $(facet_host ost1) $(ostdevname 1) "-y" ||
869 error "(3) Fail to run e2fsck error"
871 start ost1 $(ostdevname 1) $OST_MOUNT_OPTS ||
872 error "(4) Fail to start ost1"
874 mount_client $MOUNT || error "(5) Fail to start client!"
876 local LF_REPAIRED=$($SHOW_SCRUB_ON_OST |
877 awk '/^lf_reparied/ { print $2 }')
878 [ $LF_REPAIRED -gt 0 ] ||
879 error "(6) Some entry under /lost+found should be repaired"
881 ls -ail $DIR/$tdir > /dev/null || error "(7) ls should succeed"
883 run_test 14 "OI scrub can repair objects under lost+found"
886 # skip test_15 for LU-4182
887 [ $MDSCOUNT -ge 2 ] && skip "skip now for >= 2 MDTs" && return
889 scrub_backup_restore 1
890 echo "starting MDTs with OI scrub disabled"
891 scrub_start_mds 2 "$MOUNT_OPTS_NOSCRUB"
892 scrub_check_status 3 init
893 scrub_check_flags 4 inconsistent
895 # run under dryrun mode
896 scrub_start 5 --dryrun
897 scrub_check_status 6 completed
898 scrub_check_flags 7 inconsistent
899 scrub_check_params 8 dryrun
900 scrub_check_repaired 9 20
902 # run under dryrun mode again
903 scrub_start 10 --dryrun
904 scrub_check_status 11 completed
905 scrub_check_flags 12 inconsistent
906 scrub_check_params 13 dryrun
907 scrub_check_repaired 14 20
909 # run under normal mode
911 # Lustre-2.x (x <= 5) used "-n off" to disable dryrun which does not
912 # work under Lustre-2.y (y >=6), the test scripts should be fixed as
913 # "-noff" or "--dryrun=off".
914 scrub_start 15 --dryrun=off
915 scrub_check_status 16 completed
916 scrub_check_flags 17 ""
917 scrub_check_params 18 ""
918 scrub_check_repaired 19 20
920 # run under normal mode again
921 scrub_start 20 --dryrun=off
922 scrub_check_status 21 completed
923 scrub_check_flags 22 ""
924 scrub_check_params 23 ""
925 scrub_check_repaired 24 0
927 run_test 15 "Dryrun mode OI scrub"
929 # restore MDS/OST size
930 MDSSIZE=${SAVED_MDSSIZE}
931 OSTSIZE=${SAVED_OSTSIZE}
932 OSTCOUNT=${SAVED_OSTCOUNT}
934 # cleanup the system at last