Skip to content

Commit cb02ee8

Browse files
committed
func.sh: do not hang when grow-continue can't finish
When grow-continue process is on, the sync_action represents value which means that recovery is in progress. When grow-continue does not finish, even if sync_action is not reshape anymore, test should fail. Signed-off-by: Kinga Stefaniuk <kinga.stefaniuk@intel.com>
1 parent b278b2f commit cb02ee8

File tree

1 file changed

+24
-5
lines changed

1 file changed

+24
-5
lines changed

tests/func.sh

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -357,14 +357,33 @@ check() {
357357
max=`cat /proc/sys/dev/raid/speed_limit_max`
358358
echo 200000 > /proc/sys/dev/raid/speed_limit_max
359359
sleep 0.1
360-
while grep -Eq '(resync|recovery|reshape|check|repair) *=' /proc/mdstat ||
361-
grep -v idle > /dev/null /sys/block/md*/md/sync_action
362-
do
363-
sleep 0.5
360+
max_iterations=5
361+
# wait up to 5 seconds for one of action appeared in sync_action,
362+
# which will trigger grow-continue process
363+
for ((i = 0 ; i < max_iterations ; i++ )); do
364+
sync_action=`grep -Eq '(resync|recovery|reshape|check|repair) *=' /proc/mdstat || grep -v idle > /dev/null /sys/block/md*/md/sync_action`
365+
if [ "$sync_action" ]; then
366+
break
367+
fi
368+
sleep 1
364369
done
370+
371+
if [[ i == max_iterations ]]; then
372+
echo >&2 "Timeout waiting for reshape operation appeared in sync_action"
373+
exit 1
374+
fi
375+
376+
# wait for grow-continue to finish but break if sync_action does not
377+
# contain any reshape value
365378
while ps auxf | grep "mdadm --grow --continue" | grep -v grep
366379
do
367-
sleep 1
380+
sync_action=`grep -Eq '(resync|recovery|reshape|check|repair) *=' /proc/mdstat || grep -v idle > /dev/null /sys/block/md*/md/sync_action`
381+
if [ "$sync_action" ]; then
382+
sleep 1
383+
continue
384+
fi
385+
echo >&2 "Grow continue does not finish but reshape is done"
386+
exit 1
368387
done
369388
echo $min > /proc/sys/dev/raid/speed_limit_min
370389
echo $max > /proc/sys/dev/raid/speed_limit_max

0 commit comments

Comments
 (0)