From f1ddb4093ed623c1382f75e47807e4081962cc3d Mon Sep 17 00:00:00 2001 From: Lai Siyao Date: Mon, 10 Jul 2023 00:30:28 -0400 Subject: [PATCH] LU-11036 test: race in sanity-lfsck test_8 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 Change-Id: Ie1f612bebb52c4755e5b4e13d58ab8bf2aeb2832 Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/51720 Tested-by: jenkins Tested-by: Maloo Reviewed-by: Andreas Dilger Reviewed-by: Alex Deiter Reviewed-by: Oleg Drokin --- lustre/tests/sanity-lfsck.sh | 27 ++++++++++++--------------- 1 file changed, 12 insertions(+), 15 deletions(-) mode change 100644 => 100755 lustre/tests/sanity-lfsck.sh diff --git a/lustre/tests/sanity-lfsck.sh b/lustre/tests/sanity-lfsck.sh old mode 100644 new mode 100755 index b54eb80..781443e --- a/lustre/tests/sanity-lfsck.sh +++ b/lustre/tests/sanity-lfsck.sh @@ -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 \ -- 1.8.3.1