Whamcloud - gitweb
LU-9295 test: skip sanity-lfsck 9 less than 2.8
[fs/lustre-release.git] / lustre / tests / sanity-lfsck.sh
index d1dcc90..99b1c4e 100644 (file)
@@ -454,8 +454,7 @@ run_test 2d "LFSCK can recover the missing linkEA entry"
 
 test_2e()
 {
-       [ $MDSCOUNT -lt 2 ] &&
-               skip "We need at least 2 MDSes for this test" && return
+       [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
 
        check_mount_and_prep
 
@@ -1022,7 +1021,7 @@ test_9a() {
                return 0
        fi
 
-       [[ $server_version -ge $(version_code 2.7.50) ]] ||
+       [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.7.50) ]] ||
                { skip "Need MDS version >= 2.7.50"; return; }
 
        check_mount_and_prep
@@ -1096,7 +1095,7 @@ test_9b() {
                return 0
        fi
 
-       [[ $server_version -ge $(version_code 2.7.50) ]] ||
+       [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.7.50) ]] ||
                { skip "Need MDS version >= 2.7.50"; return; }
 
        lfsck_prep 0 0
@@ -1335,14 +1334,6 @@ test_11b() {
        umount_client $MOUNT
        stop ost1 || error "(1) Fail to stop ost1"
 
-       # stop MDS to forget last precreated object
-       echo "stop $SINGLEMDS"
-       stop $SINGLEMDS > /dev/null || error "(11) Fail to stop MDS!"
-       do_facet $SINGLEMDS $LCTL set_param fail_loc=0 fail_val=0
-       echo "start $SINGLEMDS"
-       start $SINGLEMDS $MDT_DEVNAME $MOUNT_OPTS_SCRUB > /dev/null ||
-               error "(12) Fail to start MDS!"
-
        #define OBD_FAIL_OST_ENOSPC              0x215
        do_facet ost1 $LCTL set_param fail_loc=0x215
 
@@ -1391,8 +1382,7 @@ test_11b() {
 run_test 11b "LFSCK can rebuild crashed last_id"
 
 test_12a() {
-       [ $MDSCOUNT -lt 2 ] &&
-               skip "We need at least 2 MDSes for test_12a" && return
+       [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
 
        check_mount_and_prep
        for k in $(seq $MDSCOUNT); do
@@ -1779,8 +1769,7 @@ test_15b() {
 run_test 15b "LFSCK can repair unmatched MDT-object/OST-object pairs (2)"
 
 test_15c() {
-       [ $MDSCOUNT -lt 2 ] &&
-               skip "We need at least 2 MDSes for this test" && return
+       [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
 
        [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.7.55) ] &&
                skip "Skip the test after 2.7.55 see LU-6437" && return
@@ -2516,8 +2505,8 @@ test_18e() {
        sleep 2
 
        echo "Write new data to f2/f4 to modify the new created OST-object."
-       echo "dummy" >> $DIR/$tdir/a1/f2
-       echo "dummy" >> $DIR/$tdir/a1/f4
+       echo "dummy" >> $DIR/$tdir/a1/f2 || error "write a1/f2 failed"
+       echo "dummy" >> $DIR/$tdir/a1/f4 || error "write a1/f4 failed"
 
        do_facet $SINGLEMDS $LCTL set_param fail_val=0 fail_loc=0
 
@@ -2587,8 +2576,7 @@ test_18e() {
 run_test 18e "Find out orphan OST-object and repair it (5)"
 
 test_18f() {
-       [ $OSTCOUNT -lt 2 ] &&
-               skip "The test needs at least 2 OSTs" && return
+       [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs" && return
 
        echo "#####"
        echo "The target MDT-object is lost. The LFSCK should re-create the"
@@ -2943,8 +2931,7 @@ PATTERN_WITH_HOLE="40000001"
 PATTERN_WITHOUT_HOLE="1"
 
 test_20a() {
-       [ $OSTCOUNT -lt 2 ] &&
-               skip "The test needs at least 2 OSTs" && return
+       [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs" && return
 
        echo "#####"
        echo "The target MDT-object and some of its OST-object are lost."
@@ -3283,8 +3270,7 @@ test_20a() {
 run_test 20a "Handle the orphan with dummy LOV EA slot properly"
 
 test_20b() {
-       [ $OSTCOUNT -lt 2 ] &&
-               skip "The test needs at least 2 OSTs" && return
+       [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs" && return
 
        echo "#####"
        echo "The target MDT-object and some of its OST-object are lost."
@@ -3381,38 +3367,38 @@ test_20b() {
 
        $LFS getstripe -v $name || error "(7.1) cannot getstripe on $name"
 
-       local pattern=$($LFS getstripe -L -I 1 $name)
+       local pattern=$($LFS getstripe -L -I1 $name)
        [[ "$pattern" = "$PATTERN_WITHOUT_HOLE" ]] ||
                error "(7.2.1) NOT expect pattern flag hole, but got $pattern"
 
-       pattern=$($LFS getstripe -L -I 2 $name)
+       pattern=$($LFS getstripe -L -I2 $name)
        [[ "$pattern" = "$PATTERN_WITHOUT_HOLE" ]] ||
                error "(7.2.2) NOT expect pattern flag hole, but got $pattern"
 
-       local stripes=$($LFS getstripe -c -I 1 $name)
+       local stripes=$($LFS getstripe -c -I1 $name)
        [ $stripes -eq 2 ] ||
                error "(7.3.1) expect 2 stripes, but got $stripes"
 
-       stripes=$($LFS getstripe -c -I 2 $name)
+       stripes=$($LFS getstripe -c -I2 $name)
        [ $stripes -eq 2 ] ||
                error "(7.3.2) expect 2 stripes, but got $stripes"
 
-       local e_start=$($LFS getstripe -I 1 $name |
+       local e_start=$($LFS getstripe -I1 $name |
                        awk '/lcme_extent.e_start:/ { print $2 }')
        [ $e_start -eq 0 ] ||
                error "(7.4.1) expect the COMP1 start at 0, got $e_start"
 
-       local e_end=$($LFS getstripe -I 1 $name |
+       local e_end=$($LFS getstripe -I1 $name |
                      awk '/lcme_extent.e_end:/ { print $2 }')
        [ $e_end -eq 2097152 ] ||
                error "(7.4.2) expect the COMP1 end at 2097152, got $e_end"
 
-       e_start=$($LFS getstripe -I 2 $name |
+       e_start=$($LFS getstripe -I2 $name |
                  awk '/lcme_extent.e_start:/ { print $2 }')
        [ $e_start -eq 2097152 ] ||
                error "(7.5.1) expect the COMP2 start at 2097152, got $e_start"
 
-       e_end=$($LFS getstripe -I 2 $name |
+       e_end=$($LFS getstripe -I2 $name |
                awk '/lcme_extent.e_end:/ { print $2 }')
        [ "$e_end" = "EOF" ] ||
                error "(7.5.2) expect the COMP2 end at (EOF), got $e_end"
@@ -3439,38 +3425,38 @@ test_20b() {
 
        $LFS getstripe -v $name || error "(8.1) cannot getstripe on $name"
 
-       pattern=$($LFS getstripe -L -I 1 $name)
+       pattern=$($LFS getstripe -L -I1 $name)
        [[ "$pattern" = "$PATTERN_WITH_HOLE" ]] ||
                error "(8.2.1) expect pattern flag hole, but got $pattern"
 
-       pattern=$($LFS getstripe -L -I 2 $name)
+       pattern=$($LFS getstripe -L -I2 $name)
        [[ "$pattern" = "$PATTERN_WITH_HOLE" ]] ||
                error "(8.2.2) expect pattern flag hole, but got $pattern"
 
-       stripes=$($LFS getstripe -c -I 1 $name)
+       stripes=$($LFS getstripe -c -I1 $name)
        [ $stripes -eq 2 ] ||
                error "(8.3.2) expect 2 stripes, but got $stripes"
 
-       stripes=$($LFS getstripe -c -I 2 $name)
+       stripes=$($LFS getstripe -c -I2 $name)
        [ $stripes -eq 2 ] ||
                error "(8.3.2) expect 2 stripes, but got $stripes"
 
-       e_start=$($LFS getstripe -I 1 $name |
+       e_start=$($LFS getstripe -I1 $name |
                  awk '/lcme_extent.e_start:/ { print $2 }')
        [ $e_start -eq 0 ] ||
                error "(8.4.1) expect the COMP1 start at 0, got $e_start"
 
-       e_end=$($LFS getstripe -I 1 $name |
+       e_end=$($LFS getstripe -I1 $name |
                awk '/lcme_extent.e_end:/ { print $2 }')
        [ $e_end -eq 2097152 ] ||
                error "(8.4.2) expect the COMP1 end at 2097152, got $e_end"
 
-       e_start=$($LFS getstripe -I 2 $name |
+       e_start=$($LFS getstripe -I2 $name |
                  awk '/lcme_extent.e_start:/ { print $2 }')
        [ $e_start -eq 2097152 ] ||
                error "(8.5.1) expect the COMP2 start at 2097152, got $e_start"
 
-       e_end=$($LFS getstripe -I 2 $name |
+       e_end=$($LFS getstripe -I2 $name |
                awk '/lcme_extent.e_end:/ { print $2 }')
        [ "$e_end" = "EOF" ] ||
                error "(8.5.2) expect the COMP2 end at (EOF), got $e_end"
@@ -3514,38 +3500,38 @@ test_20b() {
 
        $LFS getstripe -v $name || error "(9.1) cannot getstripe on $name"
 
-       pattern=$($LFS getstripe -L -I 1 $name)
+       pattern=$($LFS getstripe -L -I1 $name)
        [[ "$pattern" = "$PATTERN_WITH_HOLE" ]] ||
                error "(9.2.1) expect pattern flag hole, but got $pattern"
 
-       pattern=$($LFS getstripe -L -I 2 $name)
+       pattern=$($LFS getstripe -L -I2 $name)
        [[ "$pattern" = "$PATTERN_WITH_HOLE" ]] ||
                error "(9.2.2) expect pattern flag hole, but got $pattern"
 
-       stripes=$($LFS getstripe -c -I 1 $name)
+       stripes=$($LFS getstripe -c -I1 $name)
        [ $stripes -eq 2 ] ||
                error "(9.3.2) expect 2 stripes, but got $stripes"
 
-       stripes=$($LFS getstripe -c -I 2 $name)
+       stripes=$($LFS getstripe -c -I2 $name)
        [ $stripes -eq 2 ] ||
                error "(9.3.2) expect 2 stripes, but got $stripes"
 
-       e_start=$($LFS getstripe -I 1 $name |
+       e_start=$($LFS getstripe -I1 $name |
                  awk '/lcme_extent.e_start:/ { print $2 }')
        [ $e_start -eq 0 ] ||
                error "(9.4.1) expect the COMP1 start at 0, got $e_start"
 
-       e_end=$($LFS getstripe -I 1 $name |
+       e_end=$($LFS getstripe -I1 $name |
                awk '/lcme_extent.e_end:/ { print $2 }')
        [ $e_end -eq 2097152 ] ||
                error "(9.4.2) expect the COMP1 end at 2097152, got $e_end"
 
-       e_start=$($LFS getstripe -I 2 $name |
+       e_start=$($LFS getstripe -I2 $name |
                  awk '/lcme_extent.e_start:/ { print $2 }')
        [ $e_start -eq 2097152 ] ||
                error "(9.5.1) expect the COMP2 start at 2097152, got $e_start"
 
-       e_end=$($LFS getstripe -I 2 $name |
+       e_end=$($LFS getstripe -I2 $name |
                awk '/lcme_extent.e_end:/ { print $2 }')
        [ "$e_end" = "EOF" ] ||
                error "(9.5.2) expect the COMP2 end at (EOF), got $e_end"
@@ -3620,8 +3606,7 @@ test_21() {
 run_test 21 "run all LFSCK components by default"
 
 test_22a() {
-       [ $MDSCOUNT -lt 2 ] &&
-               skip "We need at least 2 MDSes for this test" && return
+       [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
 
        echo "#####"
        echo "The parent_A references the child directory via some name entry,"
@@ -3663,8 +3648,7 @@ test_22a() {
 run_test 22a "LFSCK can repair unmatched pairs (1)"
 
 test_22b() {
-       [ $MDSCOUNT -lt 2 ] &&
-               skip "We need at least 2 MDSes for this test" && return
+       [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
 
        echo "#####"
        echo "The parent_A references the child directory via the name entry_B,"
@@ -3713,8 +3697,7 @@ test_22b() {
 run_test 22b "LFSCK can repair unmatched pairs (2)"
 
 test_23a() {
-       [ $MDSCOUNT -lt 2 ] &&
-               skip "We need at least 2 MDSes for this test" && return
+       [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
 
        echo "#####"
        echo "The name entry is there, but the MDT-object for such name "
@@ -3956,8 +3939,7 @@ test_23c() {
 run_test 23c "LFSCK can repair dangling name entry (3)"
 
 test_24() {
-       [ $MDSCOUNT -lt 2 ] &&
-               skip "We need at least 2 MDSes for this test" && return
+       [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
 
        echo "#####"
        echo "Two MDT-objects back reference the same name entry via their"
@@ -4033,7 +4015,7 @@ run_test 24 "LFSCK can repair multiple-referenced name entry"
 
 test_25() {
        [ $(facet_fstype $SINGLEMDS) != ldiskfs ] &&
-               skip "Only support to inject failure on ldiskfs" && return
+               skip "ldiskfs only test" && return
 
        echo "#####"
        echo "The file type in the name entry does not match the file type"
@@ -4121,8 +4103,7 @@ test_26a() {
 run_test 26a "LFSCK can add the missing local name entry back to the namespace"
 
 test_26b() {
-       [ $MDSCOUNT -lt 2 ] &&
-               skip "We need at least 2 MDSes for this test" && return
+       [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
 
        echo "#####"
        echo "The remote name entry back referenced by the MDT-object is lost."
@@ -4221,8 +4202,7 @@ test_27a() {
 run_test 27a "LFSCK can recreate the lost local parent directory as orphan"
 
 test_27b() {
-       [ $MDSCOUNT -lt 2 ] &&
-               skip "We need at least 2 MDSes for this test" && return
+       [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
 
        echo "#####"
        echo "The remote parent referenced by the MDT-object linkEA is lost."
@@ -4275,8 +4255,7 @@ test_27b() {
 run_test 27b "LFSCK can recreate the lost remote parent directory as orphan"
 
 test_28() {
-       [ $MDSCOUNT -lt 2 ] &&
-               skip "The test needs at least 2 MDTs" && return
+       [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
 
        echo "#####"
        echo "The target name entry is lost. The LFSCK should insert the"
@@ -4553,7 +4532,7 @@ run_test 29c "verify linkEA size limitation"
 
 test_30() {
        [ $(facet_fstype $SINGLEMDS) != ldiskfs ] &&
-               skip "Only support backend /lost+found for ldiskfs" && return
+               skip "ldiskfs only test" && return
 
        echo "#####"
        echo "The namespace LFSCK will move the orphans from backend"
@@ -4634,8 +4613,7 @@ test_30() {
 run_test 30 "LFSCK can recover the orphans from backend /lost+found"
 
 test_31a() {
-       [ $MDSCOUNT -lt 2 ] &&
-               skip "The test needs at least 2 MDTs" && return
+       [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
 
        echo "#####"
        echo "For the name entry under a striped directory, if the name"
@@ -4685,8 +4663,7 @@ test_31a() {
 run_test 31a "The LFSCK can find/repair the name entry with bad name hash (1)"
 
 test_31b() {
-       [ $MDSCOUNT -lt 2 ] &&
-               skip "The test needs at least 2 MDTs" && return
+       [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
 
        echo "#####"
        echo "For the name entry under a striped directory, if the name"
@@ -4737,8 +4714,7 @@ test_31b() {
 run_test 31b "The LFSCK can find/repair the name entry with bad name hash (2)"
 
 test_31c() {
-       [ $MDSCOUNT -lt 2 ] &&
-               skip "The test needs at least 2 MDTs" && return
+       [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
 
        echo "#####"
        echo "For some reason, the master MDT-object of the striped directory"
@@ -4781,8 +4757,7 @@ test_31c() {
 run_test 31c "Re-generate the lost master LMV EA for striped directory"
 
 test_31d() {
-       [ $MDSCOUNT -lt 2 ] &&
-               skip "The test needs at least 2 MDTs" && return
+       [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
 
        echo "#####"
        echo "For some reason, the master MDT-object of the striped directory"
@@ -4836,8 +4811,7 @@ test_31d() {
 run_test 31d "Set broken striped directory (modified after broken) as read-only"
 
 test_31e() {
-       [ $MDSCOUNT -lt 2 ] &&
-               skip "The test needs at least 2 MDTs" && return
+       [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
 
        echo "#####"
        echo "For some reason, the slave MDT-object of the striped directory"
@@ -4874,8 +4848,7 @@ test_31e() {
 run_test 31e "Re-generate the lost slave LMV EA for striped directory (1)"
 
 test_31f() {
-       [ $MDSCOUNT -lt 2 ] &&
-               skip "The test needs at least 2 MDTs" && return
+       [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
 
        echo "#####"
        echo "For some reason, the slave MDT-object of the striped directory"
@@ -4913,8 +4886,7 @@ test_31f() {
 run_test 31f "Re-generate the lost slave LMV EA for striped directory (2)"
 
 test_31g() {
-       [ $MDSCOUNT -lt 2 ] &&
-               skip "The test needs at least 2 MDTs" && return
+       [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
 
        echo "#####"
        echo "For some reason, the stripe index in the slave LMV EA is"
@@ -4959,8 +4931,7 @@ test_31g() {
 run_test 31g "Repair the corrupted slave LMV EA"
 
 test_31h() {
-       [ $MDSCOUNT -lt 2 ] &&
-               skip "The test needs at least 2 MDTs" && return
+       [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
 
        echo "#####"
        echo "For some reason, the shard's name entry in the striped"
@@ -5029,6 +5000,28 @@ test_32()
 }
 run_test 32 "stop LFSCK when some OST failed"
 
+test_33()
+{
+       lfsck_prep 5 5
+
+       $START_LAYOUT --dryrun -o -r ||
+               error "(1) Fail to start layout LFSCK"
+       wait_all_targets_blocked layout completed 2
+
+       local PARAMS=$($SHOW_LAYOUT | awk '/^param/ { print $2 }')
+       [ "$PARAMS" == "dryrun,all_targets,orphan" ] ||
+               error "(3) Expect 'dryrun,all_targets,orphan', got '$PARAMS'"
+
+       $START_NAMESPACE -e abort -A -r ||
+               error "(4) Fail to start namespace LFSCK"
+       wait_all_targets_blocked namespace completed 5
+
+       PARAMS=$($SHOW_NAMESPACE | awk '/^param/ { print $2 }')
+       [ "$PARAMS" == "failout,all_targets" ] ||
+               error "(6) Expect 'failout,all_targets', got '$PARAMS'"
+}
+run_test 33 "check LFSCK paramters"
+
 # restore MDS/OST size
 MDSSIZE=${SAVED_MDSSIZE}
 OSTSIZE=${SAVED_OSTSIZE}