ONLY=${ONLY:-"$*"}
-#Bug number for excepting test
-ALWAYS_EXCEPT="$SANITY_LFSCK_EXCEPT"
-
-[ "$SLOW" = "no" ] && EXCEPT_SLOW=""
-# UPDATE THE COMMENT ABOVE WITH BUG NUMBERS WHEN CHANGING ALWAYS_EXCEPT!
-
-LUSTRE=${LUSTRE:-$(cd $(dirname $0)/..; echo $PWD)}
+LUSTRE=${LUSTRE:-$(dirname $0)/..}
. $LUSTRE/tests/test-framework.sh
init_test_env $@
-. ${CONFIG:=$LUSTRE/tests/cfg/$NAME.sh}
init_logging
+ALWAYS_EXCEPT="$SANITY_LFSCK_EXCEPT "
+
+# DNE does not support striped directory on zfs-based backend yet.
+[ $(facet_fstype $SINGLEMDS) != ldiskfs ] &&
+#Bug number for excepting test
+ ALWAYS_EXCEPT+=" 31"
+# UPDATE THE COMMENT ABOVE WITH BUG NUMBERS WHEN CHANGING ALWAYS_EXCEPT!
+
+[[ $(lustre_version_code $SINGLEMDS) -le $(version_code 2.4.90) ]] &&
+ ALWAYS_EXCEPT="$ALWAYS_EXCEPT 2c"
+
+[[ $(lustre_version_code ost1) -lt $(version_code 2.5.55) ]] &&
+ ALWAYS_EXCEPT="$ALWAYS_EXCEPT 11 12 13 14 15 16 17 18 19 20 21"
+
+[[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.6.50) ]] &&
+ ALWAYS_EXCEPT="$ALWAYS_EXCEPT 2d 2e 3 22 23 24 25 26 27 28 29 30 31"
+
+[ "$SLOW" = "no" ] && EXCEPT_SLOW=""
+build_test_filter
+
require_dsh_mds || exit 0
load_modules
# build up a clean test environment.
REFORMAT="yes" check_and_setup_lustre
-[[ $(lustre_version_code $SINGLEMDS) -le $(version_code 2.4.90) ]] &&
- ALWAYS_EXCEPT="$ALWAYS_EXCEPT 2c"
-
-[[ $(lustre_version_code ost1) -lt $(version_code 2.5.55) ]] &&
- ALWAYS_EXCEPT="$ALWAYS_EXCEPT 11 12 13 14 15 16 17 18 19 20 21"
-
-[[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.6.50) ]] &&
- ALWAYS_EXCEPT="$ALWAYS_EXCEPT 2d 2e 3 22 23 24 25 26 27 28 29 30 31"
-
-# DNE does not support striped directory on zfs-based backend yet.
-[ $(facet_fstype $SINGLEMDS) != ldiskfs ] &&
- ALWAYS_EXCEPT="$ALWAYS_EXCEPT 31"
-
-build_test_filter
-
MDT_DEV="${FSNAME}-MDT0000"
OST_DEV="${FSNAME}-OST0000"
MDT_DEVNAME=$(mdsdevname ${SINGLEMDS//mds/})
$LCTL get_param -n mdd.${MDT_DEV}.lfsck_layout"
SHOW_LAYOUT_ON_OST="do_facet ost1 \
$LCTL get_param -n obdfilter.${OST_DEV}.lfsck_layout"
-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"
MOUNT_OPTS_SKIP_LFSCK="-o user_xattr,skip_lfsck"
lfsck_prep() {
test_11a() {
check_mount_and_prep
- $SETSTRIPE -c 1 -i 0 $DIR/$tdir
+ $LFS setstripe -c 1 -i 0 $DIR/$tdir
createmany -o $DIR/$tdir/f 64 || error "(0) Fail to create 64 files."
echo "stopall"
test_11b() {
check_mount_and_prep
- $SETSTRIPE -c 1 -i 0 $DIR/$tdir
+ $LFS setstripe -c 1 -i 0 $DIR/$tdir
echo "set fail_loc=0x160d to skip the updating LAST_ID on-disk"
#define OBD_FAIL_LFSCK_SKIP_LASTID 0x160d
cancel_lru_locks mdc
cancel_lru_locks osc
+ # dryrun mode only check orphans, not repaie
+ echo "Trigger layout LFSCK --dryrun to find out orphan OST-object"
+ $START_LAYOUT --dryrun -o -r ||
+ error "Fail to start layout LFSCK in dryrun mode"
+ wait_all_targets_blocked layout completed 2
+
+ local PARAMS=$($SHOW_LAYOUT | awk '/^param/ { print $2 }')
+ [ "$PARAMS" == "dryrun,all_targets,orphan" ] ||
+ error "Expect 'dryrun,all_targets,orphan', got '$PARAMS'"
+
+ local orphans=$(do_facet mds1 $LCTL get_param -n \
+ mdd.$(facet_svc mds1).lfsck_layout |
+ awk '/^inconsistent_orphan/ { print $2 }')
+ [ $orphans -eq 3 ] ||
+ error "Expect 3 found on mds1, but got: $orphans"
+
+ # orphan parents should not be created
+ local subdir
+ for subdir in $MOUNT/.lustre/lost+found/*; do
+ [ ! "$(ls -A $subdir)" ] || error "$subdir not empty"
+ done
+
echo "Trigger layout LFSCK on all devices to find out orphan OST-object"
$START_LAYOUT -r -o || error "(1) Fail to start LFSCK for layout!"
#define OBD_FAIL_LFSCK_BAD_NAME_HASH 0x1628
$LCTL set_param fail_loc=0x1628 fail_val=1
- createmany -d $DIR/$tdir/striped_dir/d $MDSCOUNT ||
+ createmany -d $DIR/$tdir/striped_dir/d $((MDSCOUNT * 5)) ||
error "(2) Fail to create file under striped directory"
$LCTL set_param fail_loc=0 fail_val=0
local repaired=$(do_facet mds2 $LCTL get_param -n \
mdd.$(facet_svc mds2).lfsck_namespace |
awk '/^name_hash_repaired/ { print $2 }')
+ echo "repaired $repaired name entries with bad hash"
[ $repaired -ge 1 ] ||
error "(5) Fail to repair bad name hash: $repaired"
umount_client $MOUNT || error "(6) umount failed"
mount_client $MOUNT || error "(7) mount failed"
- for ((i = 0; i < $MDSCOUNT; i++)); do
+ for ((i = 0; i < $((MDSCOUNT * 5)); i++)); do
stat $DIR/$tdir/striped_dir/d$i ||
error "(8) Fail to stat d$i after LFSCK"
rmdir $DIR/$tdir/striped_dir/d$i ||
check_mount_and_prep
+ lfs df $DIR
+ lfs df -i $DIR
+ lctl get_param osc.*.*grant*
+ stack_trap "lfs df $DIR; lfs df -i $DIR; lctl get_param osc.*.*grant*"
+
$LFS setstripe -N -E 1M -o 0,1 -E -1 -o 2 -N -E 2M -o 1,2 -E -1 -o 0 \
-N -E 3M -o 2,0 -E -1 -o 1 $DIR/$tdir/f0 ||
error "(0) Fail to create mirror file $DIR/$tdir/f0"
}
run_test 39 "LFSCK does not break foreign dir and reverse is also true"
+test_40a() {
+ [[ $MDSCOUNT -ge 2 ]] || skip "needs >= 2 MDTs"
+
+ check_mount_and_prep
+ $LFS mkdir -i 1 $DIR/$tdir/dir1
+ $LFS setstripe -E 1M -c1 -S 1M -E 128M -c2 -S 4M -E eof $DIR/$tdir/dir1
+
+ touch $DIR/$tdir/dir1/f1
+ local layout1=$(get_layout_param $DIR/$tdir/dir1/f1)
+
+ echo "Migrate $DIR/$tdir/dir1 from MDT1 to MDT0"
+ $LFS migrate -m 0 $DIR/$tdir/dir1
+
+ echo "trigger LFSCK for layout"
+ do_facet $SINGLEMDS $LCTL lfsck_start -M ${MDT_DEV} -t layout -r
+
+ wait_update_facet $SINGLEMDS "$LCTL get_param -n \
+ mdd.${MDT_DEV}.lfsck_layout |
+ awk '/^status/ { print \\\$2 }'" "completed" 32 || {
+ $SHOW_LAYOUT
+ error "(2) unexpected status"
+ }
+
+ local layout2=$(get_layout_param $DIR/$tdir/dir1/f1)
+
+ [[ "$layout1" == "$layout2" ]] || error "layout lost after lfsck"
+}
+run_test 40a "LFSCK correctly fixes lmm_oi in composite layout"
+
# restore MDS/OST size
MDSSIZE=${SAVED_MDSSIZE}
OSTSIZE=${SAVED_OSTSIZE}