]> git.ipfire.org Git - thirdparty/mdadm.git/commitdiff
func.sh: do not hang when grow-continue can't finish
authorKinga Stefaniuk <kinga.stefaniuk@intel.com>
Thu, 24 Oct 2024 13:09:47 +0000 (15:09 +0200)
committerMariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com>
Wed, 13 Nov 2024 13:17:35 +0000 (14:17 +0100)
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 <kinga.stefaniuk@intel.com>
tests/func.sh
tests/imsm-grow-template

index 567d91d9173ee38a53ba16a3b521aa2776bde48b..214773bbd70c221f48f8565114a58886c11883e6 100644 (file)
@@ -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
        ;;
index f69e025701efc6ed1e0e387f782981f9008897a8..c3279fccd879525f6de888a08c35c09c8511b4a3 100644 (file)
@@ -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