From f0ed3e2ec105637d0a0391ac3c35a2c577e0b273 Mon Sep 17 00:00:00 2001 From: Kinga Stefaniuk Date: Thu, 24 Oct 2024 15:09:47 +0200 Subject: func.sh: do not hang when grow-continue can't finish When grow-continue process is ongoing, sync_action indicates that recovery is in progress. If grow-continue does not finish, even if sync_action is not "reshape" anymore, the test should fail. Signed-off-by: Kinga Stefaniuk --- tests/func.sh | 45 ++++++++++++++++++++++++++++++++++++++------- tests/imsm-grow-template | 2 -- 2 files changed, 38 insertions(+), 9 deletions(-) diff --git a/tests/func.sh b/tests/func.sh index 567d91d9..214773bb 100644 --- a/tests/func.sh +++ b/tests/func.sh @@ -202,6 +202,24 @@ restore_selinux() { setenforce $sys_selinux } +wait_for_reshape_end() { + # wait for grow-continue to finish but break if sync_action does not + # contain any reshape value + while true + do + sync_action=$(grep -Ec '(resync|recovery|reshape|check|repair) *=' /proc/mdstat) + if (( "$sync_action" != 0 )); then + sleep 1 + continue + elif [[ $(pgrep -f "mdadm --grow --continue" > /dev/null) != "" ]]; then + echo "Grow continue did not finish but reshape is done" >&2 + exit 1 + else + break + fi + done +} + setup_systemd_env() { warn "Warning! Test suite will set up systemd environment!\n" echo "Use \"systemctl show-environment\" to show systemd environment variables" @@ -357,15 +375,28 @@ check() { max=`cat /proc/sys/dev/raid/speed_limit_max` echo 200000 > /proc/sys/dev/raid/speed_limit_max sleep 0.1 - while grep -Eq '(resync|recovery|reshape|check|repair) *=' /proc/mdstat || - grep -v idle > /dev/null /sys/block/md*/md/sync_action + iterations=0 + # Wait 10 seconds for one of the actions appears in sync_action. + while [ $iterations -le 10 ] do - sleep 0.5 - done - while ps auxf | grep "mdadm --grow --continue" | grep -v grep - do - sleep 1 + sync_action=$(grep -Ec '(resync|recovery|reshape|check|repair) *=' /proc/mdstat) + if (( "$sync_action" == 0 )); then + sleep 1 + iterations=$(( $iterations + 1 )) + continue + else + break + fi done + echo "Reshape has not started after 10 seconds" + + # Now let's wait for reshape to finish. + echo "Waiting for grow-continue to finish" + wait_for_reshape_end + # If we have matrix-raid there's a second process ongoing + sleep 5 + wait_for_reshape_end + echo $min > /proc/sys/dev/raid/speed_limit_min echo $max > /proc/sys/dev/raid/speed_limit_max ;; diff --git a/tests/imsm-grow-template b/tests/imsm-grow-template index f69e0257..c3279fcc 100644 --- a/tests/imsm-grow-template +++ b/tests/imsm-grow-template @@ -103,9 +103,7 @@ else exit 1 fi else - sleep 5 check wait - sleep 5 check wait imsm_check member $member0 $num_disks $vol0_level $vol0_comp_size $((vol0_comp_size * vol0_new_num_comps)) $vol0_offset $vol0_chunk testdev $member0 $vol0_new_num_comps $vol0_comp_size $vol0_chunk -- cgit v1.2.3