Whamcloud - gitweb
LU-4970 lfsck: flush async updating before exit
[fs/lustre-release.git] / lustre / tests / sanity-lfsck.sh
index bb11656..18c6bbb 100644 (file)
@@ -19,7 +19,6 @@ init_logging
 
 require_dsh_mds || exit 0
 
-MCREATE=${MCREATE:-mcreate}
 SAVED_MDSSIZE=${MDSSIZE}
 SAVED_OSTSIZE=${OSTSIZE}
 SAVED_OSTCOUNT=${OSTCOUNT}
@@ -42,7 +41,7 @@ setupall
        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"
+       ALWAYS_EXCEPT="$ALWAYS_EXCEPT 11 12 13 14 15 16 17 18 19 20 21"
 
 build_test_filter
 
@@ -510,7 +509,7 @@ test_6a() {
        local POS1=$($SHOW_NAMESPACE |
                     awk '/^latest_start_position/ { print $2 }' |
                     tr -d ',')
-       [ $POS0 -lt $POS1 ] ||
+       [[ $POS0 -lt $POS1 ]] ||
                error "(7) Expect larger than: $POS0, but got $POS1"
 
        do_facet $SINGLEMDS $LCTL set_param fail_loc=0 fail_val=0
@@ -568,10 +567,10 @@ test_6b() {
                       awk '/^latest_start_position/ { print $4 }')
 
        if [ "$D_POS0" == "N/A" -o "$D_POS1" == "N/A" ]; then
-               [ $O_POS0 -lt $O_POS1 ] ||
+               [[ $O_POS0 -lt $O_POS1 ]] ||
                        error "(7.1) $O_POS1 is not larger than $O_POS0"
        else
-               [ $D_POS0 -lt $D_POS1 ] ||
+               [[ $D_POS0 -lt $D_POS1 ]] ||
                        error "(7.2) $D_POS1 is not larger than $D_POS0"
        fi
 
@@ -1269,6 +1268,8 @@ test_14() {
        createmany -o $DIR/$tdir/f $((count + 32))
        do_facet ost1 $LCTL set_param fail_loc=0
 
+       start_full_debug_logging
+
        # exhaust other pre-created dangling cases
        count=$(precreated_ost_obj_count 0 0)
        createmany -o $DIR/$tdir/a $count ||
@@ -1312,6 +1313,7 @@ test_14() {
 
        echo "'ls' should success after layout LFSCK repairing"
        ls -ail $DIR/$tdir > /dev/null || error "(9) ls should success."
+       stop_full_debug_logging
 }
 run_test 14 "LFSCK can repair MDT-object with dangling reference"
 
@@ -1684,11 +1686,11 @@ test_18b() {
        fi
 
        echo "Move the files from ./lustre/lost+found/MDTxxxx to namespace"
-       mv $MOUNT/.lustre/lost+found/MDT0000/R-${fid1} $DIR/$tdir/a1/f1 ||
-       error "(5) Fail to move $MOUNT/.lustre/lost+found/MDT0000/R-${fid1}"
+       mv $MOUNT/.lustre/lost+found/MDT0000/${fid1}-R-0 $DIR/$tdir/a1/f1 ||
+       error "(5) Fail to move $MOUNT/.lustre/lost+found/MDT0000/${fid1}-R-0"
 
        if [ $MDSCOUNT -ge 2 ]; then
-               local name=$MOUNT/.lustre/lost+found/MDT0001/R-${fid2}
+               local name=$MOUNT/.lustre/lost+found/MDT0001/${fid2}-R-0
                mv $name $DIR/$tdir/a2/f2 || error "(6) Fail to move $name"
        fi
 
@@ -1733,8 +1735,7 @@ test_18c() {
 
        if [ $MDSCOUNT -ge 2 ]; then
                $LFS mkdir -i 1 $DIR/$tdir/a2
-               $LFS setstripe -c 2 -i 1 -s 1M $DIR/$tdir/a2
-               do_facet ost2 $LCTL set_param fail_loc=0x1617
+               $LFS setstripe -c 1 -i 0 -s 1M $DIR/$tdir/a2
                dd if=/dev/zero of=$DIR/$tdir/a2/f2 bs=1M count=2
                $LFS getstripe $DIR/$tdir/a2/f2
        fi
@@ -1784,7 +1785,7 @@ test_18c() {
        done
 
        if [ $MDSCOUNT -ge 2 ]; then
-               expected=3
+               expected=2
        else
                expected=1
        fi
@@ -1803,12 +1804,12 @@ test_18c() {
                        error "(5) Expect 0 fixed on mds2, but got: $repaired"
        fi
 
-       echo "There should be some stub under .lustre/lost+found/MDT0001/"
-       ls -ail $MOUNT/.lustre/lost+found/MDT0001/N-* &&
+       echo "There should NOT be some stub under .lustre/lost+found/MDT0001/"
+       ls -ail $MOUNT/.lustre/lost+found/MDT0001/*-N-0 &&
                error "(6) .lustre/lost+found/MDT0001/ should be empty"
 
        echo "There should be some stub under .lustre/lost+found/MDT0000/"
-       ls -ail $MOUNT/.lustre/lost+found/MDT0000/N-* ||
+       ls -ail $MOUNT/.lustre/lost+found/MDT0000/*-N-0 ||
                error "(7) .lustre/lost+found/MDT0000/ should not be empty"
 }
 run_test 18c "Find out orphan OST-object and repair it (3)"
@@ -1997,7 +1998,7 @@ test_18e() {
                error "(6) Expect 1 orphan has been fixed, but got: $repaired"
 
        echo "There should be stub file under .lustre/lost+found/MDT0000/"
-       local cname=$(ls $MOUNT/.lustre/lost+found/MDT0000/C-*)
+       local cname=$(ls $MOUNT/.lustre/lost+found/MDT0000/*-C-0)
        [ ! -z $name ] ||
                error "(7) .lustre/lost+found/MDT0000/ should not be empty"
 
@@ -2197,9 +2198,9 @@ test_20() {
        LOV_PATTERN_F_HOLE=0x40000000
 
        #
-       # R-${fid0} is the old f0
+       # ${fid0}-R-0 is the old f0
        #
-       local name="$MOUNT/.lustre/lost+found/MDT0000/R-${fid0}"
+       local name="$MOUNT/.lustre/lost+found/MDT0000/${fid0}-R-0"
        echo "Check $name, which is the old f0"
 
        $LFS getstripe -v $name || error "(5.1) cannot getstripe on $name"
@@ -2232,9 +2233,9 @@ test_20() {
        rm -f $name || error "(5.9) cannot unlink $name"
 
        #
-       # R-${fid1} contains the old f1's stripe1 (and stripe2 if OSTs > 2)
+       # ${fid1}-R-0 contains the old f1's stripe1 (and stripe2 if OSTs > 2)
        #
-       name="$MOUNT/.lustre/lost+found/MDT0000/R-${fid1}"
+       name="$MOUNT/.lustre/lost+found/MDT0000/${fid1}-R-0"
        if [ $OSTCOUNT -gt 2 ]; then
                echo "Check $name, it contains the old f1's stripe1 and stripe2"
        else
@@ -2288,9 +2289,9 @@ test_20() {
        rm -f $name || error "(6.13) cannot unlink $name"
 
        #
-       # R-${fid2} it contains the old f2's stripe0 (and stripe2 if OSTs > 2)
+       # ${fid2}-R-0 it contains the old f2's stripe0 (and stripe2 if OSTs > 2)
        #
-       name="$MOUNT/.lustre/lost+found/MDT0000/R-${fid2}"
+       name="$MOUNT/.lustre/lost+found/MDT0000/${fid2}-R-0"
        if [ $OSTCOUNT -gt 2 ]; then
                echo "Check $name, it contains the old f2's stripe0 and stripe2"
        else
@@ -2364,9 +2365,9 @@ test_20() {
        [ $OSTCOUNT -le 2 ] && return
 
        #
-       # R-${fid3} should contains the old f3's stripe0 and stripe1
+       # ${fid3}-R-0 should contains the old f3's stripe0 and stripe1
        #
-       name="$MOUNT/.lustre/lost+found/MDT0000/R-${fid3}"
+       name="$MOUNT/.lustre/lost+found/MDT0000/${fid3}-R-0"
        echo "Check $name, which contains the old f3's stripe0 and stripe1"
 
        $LFS getstripe -v $name || error "(8.1) cannot getstripe on $name"
@@ -2400,6 +2401,33 @@ test_20() {
 }
 run_test 20 "Handle the orphan with dummy LOV EA slot properly"
 
+test_21() {
+       [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.5.59) ]] &&
+               skip "ignore the test if MDS is older than 2.5.59" && exit 0
+
+       check_mount_and_prep
+       createmany -o $DIR/$tdir/f 100 || error "(0) Fail to create 100 files"
+
+       echo "Start all LFSCK components by default (-s 1)"
+       do_facet mds1 $LCTL lfsck_start -M ${FSNAME}-MDT0000 -s 1 -r ||
+               error "Fail to start LFSCK"
+
+       echo "namespace LFSCK should be in 'scanning-phase1' status"
+       local STATUS=$($SHOW_NAMESPACE | awk '/^status/ { print $2 }')
+       [ "$STATUS" == "scanning-phase1" ] ||
+               error "Expect namespace 'scanning-phase1', but got '$STATUS'"
+
+       echo "layout LFSCK should be in 'scanning-phase1' status"
+       STATUS=$($SHOW_LAYOUT | awk '/^status/ { print $2 }')
+       [ "$STATUS" == "scanning-phase1" ] ||
+               error "Expect layout 'scanning-phase1', but got '$STATUS'"
+
+       echo "Stop all LFSCK components by default"
+       do_facet mds1 $LCTL lfsck_stop -M ${FSNAME}-MDT0000 ||
+               error "Fail to stop LFSCK"
+}
+run_test 21 "run all LFSCK components by default"
+
 $LCTL set_param debug=-lfsck > /dev/null || true
 
 # restore MDS/OST size