Whamcloud - gitweb
LU-11036 test: race in sanity-lfsck test_8 20/51720/3
authorLai Siyao <lai.siyao@whamcloud.com>
Mon, 10 Jul 2023 04:30:28 +0000 (00:30 -0400)
committerOleg Drokin <green@whamcloud.com>
Tue, 1 Aug 2023 06:13:08 +0000 (06:13 +0000)
In sanity-lfsck test_8, "sleep 1" is run after START_NAMESPACE,
but it still has chance that LFSCK status is complete but LFSCK
thread not quit yet, therefore the following START_NAMESPACE may fail
with -EALREADY. Just check the first lfsck started scanning.

And similarly use wait_update to check flags for DELAY3.

Test-Parameters: trivial MDSCOUNT=2 MDTCOUNT=4 testlist=sanity-lfsck env=ONLY=8,ONLY_REPEAT=10
Signed-off-by: Lai Siyao <lai.siyao@whamcloud.com>
Change-Id: Ie1f612bebb52c4755e5b4e13d58ab8bf2aeb2832
Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/51720
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Reviewed-by: Alex Deiter <alex.deiter@gmail.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
lustre/tests/sanity-lfsck.sh [changed mode: 0644->0755]

old mode 100644 (file)
new mode 100755 (executable)
index b54eb80..781443e
@@ -989,16 +989,12 @@ test_8()
        #define OBD_FAIL_LFSCK_DELAY2           0x1601
        do_facet $SINGLEMDS $LCTL set_param fail_loc=0x1601
        $START_NAMESPACE
-       sleep 1
-       [ -n "$($SHOW_NAMESPACE |
-               grep -E "status: init|status: completed")" ] && {
-               $START_NAMESPACE ||
-               namespace_error "(16) Fail to start LFSCK for namespace!"
-       } || echo "lfsck for namespace has been started"
-
-       STATUS=$($SHOW_NAMESPACE | awk '/^status/ { print $2 }')
-       [ "$STATUS" == "scanning-phase1" ] ||
-               namespace_error "(17) Expect 'scanning-phase1', but got '$STATUS'"
+       wait_update_facet $SINGLEMDS "$LCTL get_param -n \
+               mdd.${MDT_DEV}.lfsck_namespace |
+               awk '/^status/ { print \\\$2 }'" "scanning-phase1" 32 || {
+               $SHOW_NAMESPACE
+               namespace_error "(17) unexpected status"
+       }
 
        echo "stop $SINGLEMDS"
        stop $SINGLEMDS > /dev/null || error "(18) Fail to stop $SINGLEMDS!"
@@ -1068,11 +1064,12 @@ test_8()
        }
 
        # wait to process one inode at least (OBD_FAIL_LFSCK_DELAY3)
-       sleep 3
-
-       local FLAGS=$($SHOW_NAMESPACE | awk '/^flags/ { print $2 }')
-       [ "$FLAGS" == "scanned-once,inconsistent" ] ||
-               namespace_error "(23) Expect 'scanned-once,inconsistent',but got '$FLAGS'"
+       wait_update_facet $SINGLEMDS "$LCTL get_param -n \
+               mdd.${MDT_DEV}.lfsck_namespace |
+               awk '/^flags/ { print \\\$2 }'" "scanned-once,inconsistent" 32 || {
+               $SHOW_NAMESPACE
+               namespace_error "(23) Expect 'scanned-once,inconsistent'"
+       }
 
        do_facet $SINGLEMDS $LCTL set_param fail_loc=0 fail_val=0
        wait_update_facet $SINGLEMDS "$LCTL get_param -n \