aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDarrick J. Wong <djwong@kernel.org>2023-12-13 14:34:33 -0800
committerZorro Lang <zlang@kernel.org>2023-12-16 02:00:41 +0800
commite9b26f8c1649ff512e11c8dc0c27196ea9422167 (patch)
treee62bf7741eca1e677942ec1d5b328207e0983764
parent409db1b2972bc674f9ed2e2719966018694a9cb5 (diff)
downloadxfstests-dev-e9b26f8c1649ff512e11c8dc0c27196ea9422167.tar.gz
generic/615: fix loop termination failures
On 6.7-rc2, I've noticed that this test hangs unpredictably because the stat loop fails to exit. While the kill $loop_pid command /should/ take care of it, it clearly isn't. Set up an additional safety factor by checking for the existence of a sentinel flag before starting the loop body. In bash, "[" is a builtin so the loop should run almost as tightly as it did before. Signed-off-by: "Darrick J. Wong" <djwong@kernel.org> Reviewed-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Zorro Lang <zlang@redhat.com> Signed-off-by: Zorro Lang <zlang@kernel.org>
-rwxr-xr-xtests/generic/6156
1 files changed, 4 insertions, 2 deletions
diff --git a/tests/generic/615 b/tests/generic/615
index 4979306d56..9411229874 100755
--- a/tests/generic/615
+++ b/tests/generic/615
@@ -21,11 +21,10 @@ _require_odirect
stat_loop()
{
- trap "wait; exit" SIGTERM
local filepath=$1
local blocks
- while :; do
+ while [ -e "$loop_file" ]; do
blocks=$(stat -c %b $filepath)
if [ $blocks -eq 0 ]; then
echo "error: stat(2) reported zero blocks"
@@ -39,6 +38,8 @@ _scratch_mount
$XFS_IO_PROG -f -s -c "pwrite -b 64K 0 64K" $SCRATCH_MNT/foo > /dev/null
+loop_file=$tmp.loopfile
+touch $loop_file
stat_loop $SCRATCH_MNT/foo &
loop_pid=$!
@@ -64,6 +65,7 @@ for ((i = 0; i < 2000; i++)); do
$XFS_IO_PROG -d -c "pwrite -b 64K 0 64K" $SCRATCH_MNT/foo > /dev/null
done
+rm -f $loop_file
kill $loop_pid &> /dev/null
wait