]> git.apps.os.sepia.ceph.com Git - xfstests-dev.git/commit
generic/251: fix infinite looping if fstrim_loop configuration fails
authorDarrick J. Wong <djwong@kernel.org>
Wed, 21 May 2025 22:42:07 +0000 (15:42 -0700)
committerZorro Lang <zlang@kernel.org>
Fri, 23 May 2025 13:43:29 +0000 (21:43 +0800)
commitc0de6df761000445ddd6134cec29015fef39310d
tree857715f8b8c90978415a101b9ee23db05159d7e1
parentaac2e9fee68b6e998de86655046f7c26613a6532
generic/251: fix infinite looping if fstrim_loop configuration fails

In generic/251, the topmost scope of the test creates a run file
($tmp.fstrim_loop), starts fstrim_loop as a background shell, and then
waits for the file to disappear.  Unfortunately, the set_*_constraints
helpers called by fstrim_loop can abort the subshell by invoking
_notrun, in which case the loop never deletes the runfile and the upper
scope waits forever.

Fix this by amending _destroy_fstrim to delete the runfile always, and
move the trap call to the top of the function with a note about why it
must always be called.

Oh but wait, there's a second runfile related bug in run_process -- if
the fstrim loop exits while run_process is looping, it'll keep looping
even though there isn't anything else going on.  Break out of the loopin
this case.

Oh but wait, there's a /third/ runfile bug -- if the fstrim_loop exits
before the run_process children, it will delete the runfile.  Then the
top level scope, in trying to empty out the runfile to get the
fstrim_loop to exit, recreates the runfile and waits forever for nobody
to delete the run file.

I hate process management in bash.

Cc: fstests@vger.kernel.org # v2024.12.01
Fixes: 2d6e7681acff1e ("generic/251: use sentinel files to kill the fstrim loop")
Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Zorro Lang <zlang@kernel.org>
tests/generic/251