$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() {
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}