ONLY=${ONLY:-"$*"}
-#Bug number for excepting test LU-4684 LU-10406
-ALWAYS_EXCEPT="$SANITY_LFSCK_EXCEPT 15c 29c 31c"
+#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!
dd if=/dev/zero of=$DIR/$tdir/f0 bs=1M count=1
cancel_lru_locks osc
+ # created but no setattr or write to the file.
+ mkdir $DIR/$tdir/d1
+ chown $RUNAS_ID:$RUNAS_GID $DIR/$tdir/d1
+ $RUNAS createmany -o $DIR/$tdir/d1/o 100 || error "create failed"
+
echo "Inject failure stub to skip OST-object owner changing"
#define OBD_FAIL_LFSCK_BAD_OWNER 0x1613
do_facet $SINGLEMDS $LCTL set_param fail_loc=0x1613
}
run_test 23b "LFSCK can repair dangling name entry (2)"
+cleanup_23c() {
+ do_facet $SINGLEMDS $LCTL set_param fail_val=0 fail_loc=0
+ wait_update_facet $SINGLEMDS "$LCTL get_param -n \
+ mdd.${MDT_DEV}.lfsck_namespace |
+ awk '/^status/ { print \\\$2 }'" "completed" 32 || {
+ $SHOW_NAMESPACE
+ error "(10) unexpected status"
+ }
+
+ stop_full_debug_logging
+}
+
test_23c() {
echo "#####"
echo "The objectA has multiple hard links, one of them corresponding"
check_mount_and_prep
$LFS mkdir -i 0 $DIR/$tdir/d0 || error "(1) Fail to mkdir d0 on MDT0"
- $LFS path2fid $DIR/$tdir/d0
+ parent_fid="$($LFS path2fid $DIR/$tdir/d0)"
+ echo "parent_fid=$parent_fid"
createmany -o $DIR/$tdir/d0/t 10 || error "(1.5) Fail to creatmany"
echo "dummy" > $DIR/$tdir/d0/f0 || error "(2) Fail to touch on MDT0"
- $LFS path2fid $DIR/$tdir/d0/f0
+ f0_fid="$($LFS path2fid $DIR/$tdir/d0/f0)"
+ echo "f0_fid=$f0_fid"
echo "dead" > $DIR/$tdir/d0/f1 || error "(3) Fail to touch on MDT0"
- $LFS path2fid $DIR/$tdir/d0/f1
-
- local SEQ0=$($LFS path2fid $DIR/$tdir/d0/f0 | awk -F':' '{print $1}')
- local SEQ1=$($LFS path2fid $DIR/$tdir/d0/f1 | awk -F':' '{print $1}')
+ f1_fid="$($LFS path2fid $DIR/$tdir/d0/f1)"
+ echo "f1_fid=$f1_fid"
- if [ "$SEQ0" != "$SEQ1" ]; then
+ if [ "${fid_f0/:.*/}" != "${fid_f1/:.*/}" ]; then
# To guarantee that the f0 and f1 are in the same FID seq
rm -f $DIR/$tdir/d0/f0 ||
error "(3.1) Fail to unlink $DIR/$tdir/d0/f0"
echo "dummy" > $DIR/$tdir/d0/f0 ||
error "(3.2) Fail to touch on MDT0"
- $LFS path2fid $DIR/$tdir/d0/f0
+ f0_fid="$($LFS path2fid $DIR/$tdir/d0/f0)"
+ echo "f0_fid=$f0_fid (replaced)"
fi
- local OID=$($LFS path2fid $DIR/$tdir/d0/f1 | awk -F':' '{print $2}')
- OID=$(printf %d $OID)
+ local oid=$(awk -F':' '{ printf $2 }' <<< $f1_fid)
echo "Inject failure stub on MDT0 to simulate dangling name entry"
#define OBD_FAIL_LFSCK_DANGLING3 0x1621
- do_facet $SINGLEMDS $LCTL set_param fail_val=$OID fail_loc=0x1621
+ do_facet $SINGLEMDS $LCTL set_param fail_val=$oid fail_loc=0x1621
ln $DIR/$tdir/d0/f0 $DIR/$tdir/d0/foo || error "(4) Fail to hard link"
do_facet $SINGLEMDS $LCTL set_param fail_val=0 fail_loc=0
$START_NAMESPACE -r -C ||
error "(7) Fail to start LFSCK for namespace"
- wait_update_facet client "stat $DIR/$tdir/d0/foo |
- awk '/Size/ { print \\\$2 }'" "0" $LTIME || {
+ wait_update_facet client "stat -c%s $DIR/$tdir/d0/foo" "0" $LTIME || {
+ # While unexpected by the test, it is valid for LFSCK to repair
+ # the link to the original object before any data is written.
+ local size=$(stat -c %s $DIR/$tdir/d0/foo)
+
+ if [ "$size" = "6" -a "$(<$DIR/$tdir/d0/foo)" = "dummy" ]; then
+ log "LFSCK repaired file prematurely"
+ cleanup_23c
+ return 0
+ fi
+
stat $DIR/$tdir/d0/foo
$SHOW_NAMESPACE
error "(8) unexpected size"
echo "data" >> $DIR/$tdir/d0/foo || error "(9) Fail to write"
cancel_lru_locks osc
- do_facet $SINGLEMDS $LCTL set_param fail_val=0 fail_loc=0
- wait_update_facet $SINGLEMDS "$LCTL get_param -n \
- mdd.${MDT_DEV}.lfsck_namespace |
- awk '/^status/ { print \\\$2 }'" "completed" 32 || {
- $SHOW_NAMESPACE
- error "(10) unexpected status"
- }
-
- stop_full_debug_logging
+ cleanup_23c
local repaired=$($SHOW_NAMESPACE |
awk '/^dangling_repaired/ { print $2 }')
cancel_lru_locks mdc
if [ $MDSCOUNT -ge 2 ]; then
- $LFS migrate -m 1 $DIR/$tdir/guard 2>/dev/null ||
- error "(3.1) Migrate failure"
+ $LFS migrate -m 1 $DIR/$tdir/guard 2>/dev/null &&
+ error "(3.1) Migrate should fail"
echo "The object with linkEA overflow should NOT be migrated"
local newfid=$($LFS path2fid $DIR/$tdir/guard/f0)
unlinkmany $DIR/$tdir/foo/ttttttttttt 100 || error "(4) Fail to unlink"
if [ $MDSCOUNT -ge 2 ]; then
- $LFS migrate -m 1 $DIR/$tdir/guard 2>/dev/null ||
- error "(5.1) Migrate failure"
+ $LFS migrate -m 1 $DIR/$tdir/guard 2>/dev/null &&
+ error "(5.1) Migrate should fail"
# The overflow timestamp is still there, so migration will fail.
local newfid=$($LFS path2fid $DIR/$tdir/guard/f0)
}
run_test 35 "LFSCK can rebuild the lost agent entry"
-# It will be replaced by "lfs getstripe -N" via LU-11124.
-get_mirrors_count() {
- local mirrors=$($LFS getstripe $1 |
- awk '/lcm_mirror_count/ { print $2 }')
- echo $mirrors
-}
-
test_36a() {
[ $OSTCOUNT -lt 3 ] && skip "needs >= 3 OSTs" && return
local mirrors
- mirrors=$(get_mirrors_count $DIR/$tdir/f0)
+ mirrors=$($LFS getstripe -N $DIR/$tdir/f0)
[ $mirrors -eq 2 ] || error "(18) $DIR/$tdir/f0 has $mirrors mirrors"
- mirrors=$(get_mirrors_count $DIR/$tdir/f1)
+ mirrors=$($LFS getstripe -N $DIR/$tdir/f1)
[ $mirrors -eq 2 ] || error "(19) $DIR/$tdir/f1 has $mirrors mirrors"
- mirrors=$(get_mirrors_count $DIR/$tdir/f2)
+ mirrors=$($LFS getstripe -N $DIR/$tdir/f2)
[ $mirrors -eq 2 ] || error "(20) $DIR/$tdir/f2 has $mirrors mirrors"
echo "Trigger layout LFSCK on all devices to find out orphan OST-object"
[ $repaired -eq 9 ] ||
error "(24) Expect 9 fixed on mds1, but got: $repaired"
- mirrors=$(get_mirrors_count $DIR/$tdir/f0)
+ mirrors=$($LFS getstripe -N $DIR/$tdir/f0)
[ $mirrors -eq 3 ] || error "(25) $DIR/$tdir/f0 has $mirrors mirrors"
- mirrors=$(get_mirrors_count $DIR/$tdir/f1)
+ mirrors=$($LFS getstripe -N $DIR/$tdir/f1)
[ $mirrors -eq 3 ] || error "(26) $DIR/$tdir/f1 has $mirrors mirrors"
- mirrors=$(get_mirrors_count $DIR/$tdir/f2)
+ mirrors=$($LFS getstripe -N $DIR/$tdir/f2)
[ $mirrors -eq 3 ] || error "(27) $DIR/$tdir/f2 has $mirrors mirrors"
$LFS getstripe $DIR/$tdir/f0 | grep "lcme_mirror_id:.*1" || {
[ $count -eq 9 ] || error "(8) Expect 9 fixed on mds1, but got: $count"
local name=$MOUNT/.lustre/lost+found/MDT0000/${fid}-R-0
- count=$($LFS getstripe $name | awk '/lcm_mirror_count/ { print $2 }')
+ count=$($LFS getstripe --mirror-count $name)
[ $count -eq 3 ] || error "(9) $DIR/$tdir/f0 has $count mirrors"
- count=$($LFS getstripe $name | awk '/lcm_entry_count/ { print $2 }')
- [ $count -eq 6 ] || error "(10) $DIR/$tdir/f0 has $count entries"
+ count=$($LFS getstripe --component-count $name)
+ [ $count -eq 6 ] || error "(10) $DIR/$tdir/f0 has $count components"
$LFS getstripe $name | grep "lcme_mirror_id:.*1" || {
$LFS getstripe $name
[ $count -eq 6 ] || error "(7) Expect 9 fixed on mds1, but got: $count"
local name=$MOUNT/.lustre/lost+found/MDT0000/${fid}-R-0
- count=$($LFS getstripe $name | awk '/lcm_mirror_count/ { print $2 }')
+ count=$($LFS getstripe --mirror-count $name)
[ $count -eq 2 ] || error "(8) $DIR/$tdir/f0 has $count mirrors"
- count=$($LFS getstripe $name | awk '/lcm_entry_count/ { print $2 }')
- [ $count -eq 4 ] || error "(9) $DIR/$tdir/f0 has $count entries"
+ count=$($LFS getstripe --component-count $name)
+ [ $count -eq 4 ] || error "(9) $DIR/$tdir/f0 has $count components"
local flags=$($LFS getstripe $name | head -n 10 |
awk '/lcme_flags/ { print $2 }')
}
run_test 36c "rebuild LOV EA for mirrored file (3)"
+test_37()
+{
+ local PID
+ local rc
+ local t_dir="$DIR/$tdir/d0"
+ check_mount_and_prep
+
+ $LFS mkdir -i 0 $t_dir || error "(2) Fail to mkdir $t_dir on MDT0"
+ multiop_bg_pause $t_dir D_c || { error "multiop failed: $?"; return 1; }
+ PID=$!
+ rmdir $t_dir
+
+ $START_NAMESPACE -r -A || {
+ error "(3) Fail to start LFSCK for namespace!"; kill -USR1 $PID; }
+
+ wait_all_targets_blocked namespace completed 4
+ stat $t_dir && rc=1
+ kill -USR1 $PID
+ return $rc
+}
+run_test 37 "LFSCK must skip a ORPHAN"
+
+
# restore MDS/OST size
MDSSIZE=${SAVED_MDSSIZE}
OSTSIZE=${SAVED_OSTSIZE}