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>
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"
$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=$!
$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