$LCTL get_param -n osd-*.${MDT_DEV}.oi_scrub"
SHOW_SCRUB_ON_OST="do_facet ost1 \
$LCTL get_param -n osd-*.${OST_DEV}.oi_scrub"
-MOUNT_OPTS_SCRUB="-o user_xattr"
-MOUNT_OPTS_NOSCRUB="-o user_xattr,noscrub"
+MOUNT_OPTS_SCRUB="$MDS_MOUNT_OPTS -o user_xattr"
+MOUNT_OPTS_NOSCRUB="$MDS_MOUNT_OPTS -o user_xattr,noscrub"
scrub_prep() {
local nfiles=$1
[ -n "$FILESET" ] && skip "Not functional for FILESET set"
scrub_prep 0
- echo "start $SINGLEMDS without disabling OI scrub"
+ echo "start $SINGLEMDS without disabling OI scrub: $MOUNT_OPTS_SCRUB"
scrub_start_mds 1 "$MOUNT_OPTS_SCRUB"
local FLAGS=$($SHOW_SCRUB | awk '/^flags/ { print $2 }')
echo "stop $SINGLEMDS"
stop $SINGLEMDS > /dev/null || error "(6) Fail to stop MDS!"
- echo "start $SINGLEMDS with disabling OI scrub"
+ echo "start $SINGLEMDS with disabling OI scrub: $MOUNT_OPTS_NOSCRUB"
start $SINGLEMDS $(mdsdevname 1) $MOUNT_OPTS_NOSCRUB > /dev/null ||
error "(7) Fail to start MDS!"
sleep $RUN_TIME1
scrub_check_status 6 completed
scrub_check_flags 7 ""
+
# OI scrub should run with limited speed under non-inconsistent case
scrub_start 8 -s $BASE_SPEED1 -r
done
sleep $RUN_TIME2
- # MIN_MARGIN = 0.8 = 8 / 10
+ # 30% margin
+ local MARGIN=3
local MIN_SPEED=$(((PRE_FETCHED + \
BASE_SPEED1 * (RUN_TIME1 - TIME_DIFF) + \
BASE_SPEED2 * (RUN_TIME2 - TIME_DIFF)) / \
- (RUN_TIME1 + RUN_TIME2) * 8 / 10))
+ (RUN_TIME1 + RUN_TIME2) * (10 - MARGIN) / 10))
# MAX_MARGIN = 1.2 = 12 / 10
MAX_SPEED=$(((PRE_FETCHED + \
BASE_SPEED1 * (RUN_TIME1 + TIME_DIFF) + \
BASE_SPEED2 * (RUN_TIME2 + TIME_DIFF)) / \
- (RUN_TIME1 + RUN_TIME2) * 12 / 10))
+ (RUN_TIME1 + RUN_TIME2) * (10 + MARGIN) / 10))
for n in $(seq $MDSCOUNT); do
SPEED=$(scrub_status $n | awk '/^average_speed/ { print $2 }')
[ $SPEED -gt $MIN_SPEED ] ||
}
run_test 16 "Initial OI scrub can rebuild crashed index objects"
+test_17a() {
+ [ "$mds1_FSTYPE" != "ldiskfs" ] && skip_env "ldiskfs only test"
+
+#define OBD_FAIL_OSD_OI_ENOSPC 0x19d
+ do_facet mds1 $LCTL set_param fail_loc=0x8000019d
+ mkdir $DIR/$tdir && error "mkdir should fail"
+ stop mds1
+ local devname=$(mdsdevname 1)
+
+ stack_trap "start mds1 $devname $MDS_MOUNT_OPTS" EXIT
+ FSCK_MAX_ERR=0 run_e2fsck $(facet_active_host mds1) $devname -n ||
+ error "e2fsck returned $?"
+}
+run_test 17a "ENOSPC on OI insert shouldn't leak inodes"
+
+test_17b() {
+ [ "$mds1_FSTYPE" != "ldiskfs" ] && skip_env "ldiskfs only test"
+
+#define OBD_FAIL_OSD_DOTDOT_ENOSPC 0x19e
+ do_facet mds1 $LCTL set_param fail_loc=0x8000019e
+ mkdir $DIR/$tdir && error "mkdir should fail"
+ stop mds1
+ local devname=$(mdsdevname 1)
+
+ stack_trap "start mds1 $devname $MDS_MOUNT_OPTS" EXIT
+ FSCK_MAX_ERR=0 run_e2fsck $(facet_active_host mds1) $devname -n ||
+ error "e2fsck returned $?"
+}
+run_test 17b "ENOSPC on .. insertion shouldn't leak inodes"
+
+test_18() {
+ local n
+ local fids=()
+ local opts=$(csa_add "$MOUNT_OPTS_SCRUB" -o resetoi)
+
+ scrub_prep 10
+ scrub_start_mds 1 "$MOUNT_OPTS_SCRUB"
+ mount_client $MOUNT || error "(2) Fail to start client!"
+ for n in $(seq $MDSCOUNT); do
+ fids+=($($LFS path2fid $DIR/$tdir/mds$n/test-framework.sh))
+ done
+ cleanup_mount $MOUNT > /dev/null || error "(3) Fail to stop client!"
+ for n in $(seq $MDSCOUNT); do
+ stop mds$n > /dev/null || error "(4) Fail to stop MDS$n!"
+ done
+ scrub_start_mds 5 "$opts"
+ do_facet mds1 dmesg | grep "reset Object Index" ||
+ error "(6) reset log not found"
+ mount_client $MOUNT || error "(7) Fail to start client!"
+ scrub_check_data 7
+
+ local fid
+ local path
+ for n in $(seq $MDSCOUNT); do
+ path=$($LFS fid2path $DIR ${fids[$((n - 1))]})
+ [ "$path" == "$DIR/$tdir/mds$n/test-framework.sh" ] ||
+ error "path mismatch $path != $DIR/$tdir/mds$n/test-framework.sh"
+ fid=$($LFS path2fid $DIR/$tdir/mds$n/test-framework.sh)
+ [ "${fids[$((n - 1))]}" == "$fid" ] ||
+ error "$DIR/$tdir/mds$n/test-framework.sh FID mismatch ${fids[$((n - 1))]} != $fid"
+ done
+}
+run_test 18 "test mount -o resetoi to recreate OI files"
+
+test_19() {
+ local rcmd="do_facet ost${ost}"
+
+ check_mount_and_prep
+ $LFS setstripe -c 1 -i 0 $DIR/$tdir
+ createmany -o $DIR/$tdir/f 64 || error "(0) Fail to create 32 files."
+
+ echo "stopall"
+ stopall > /dev/null
+
+ # create mulitple link file
+ mount_fstype ost1 || error "(1) Fail to mount ost1"
+ mntpt=$(facet_mntpt ost1)
+
+ local path=$mntpt/O/0/d2
+ local file=$(${rcmd} ls $path | awk '{print $0; exit}')
+
+ # create link to the first file
+ echo "link $path/1 to $path/$file"
+ ${rcmd} ln $path/$file $path/1
+ unmount_fstype ost1 || error "(2) Fail to umount ost1"
+
+ start ost1 $(ostdevname 1) $MOUNT_OPTS_NOSCRUB > /dev/null ||
+ error "(2) Fail to start ost1"
+
+ $START_SCRUB_ON_OST -r || error "(3) Fail to start OI scrub on OST!"
+
+ wait_update_facet ost1 "$LCTL get_param -n \
+ osd-*.$(facet_svc ost1).oi_scrub |
+ awk '/^status/ { print \\\$2 }'" "completed" 6 ||
+ error "(4) Expected '$expected' on ost1"
+
+ stop ost1
+ mount_fstype ost1 || error "(5) Fail to mount ost1"
+ links=$(do_facet ost1 "stat $path/$file" | awk '/Links:/ { print $6 }')
+ unmount_fstype ost1 || error "(6) Fail to umount ost1"
+
+ start ost1 $(ostdevname 1) $MOUNT_OPTS_NOSCRUB > /dev/null ||
+ error "(7) Fail to start ost1"
+
+ (( links == 1)) || error "(8) object links $links != 1 after scrub"
+}
+run_test 19 "LFSCK can fix multiple linked files on OST"
+
# restore MDS/OST size
MDSSIZE=${SAVED_MDSSIZE}
OSTSIZE=${SAVED_OSTSIZE}