]> git-server-git.apps.pok.os.sepia.ceph.com Git - xfstests-dev.git/commitdiff
generic/032: fix failure due to attempt to wait for non-child process
authorFilipe Manana <fdmanana@suse.com>
Wed, 28 May 2025 11:42:20 +0000 (12:42 +0100)
committerZorro Lang <zlang@kernel.org>
Fri, 20 Jun 2025 16:46:47 +0000 (00:46 +0800)
Running generic/032 can sporadically fail like this:

  generic/032 11s ... - output mismatch (see /home/fdmanana/git/hub/xfstests/results//generic/032.out.bad)
      --- tests/generic/032.out   2023-03-02 21:47:53.884609618 +0000
      +++ /home/fdmanana/git/hub/xfstests/results//generic/032.out.bad    2025-05-28 10:39:34.549499493 +0100
      @@ -1,5 +1,6 @@
       QA output created by 032
       100 iterations
      +/home/fdmanana/git/hub/xfstests/tests/generic/032: line 90: wait: pid 3708239 is not a child of this shell
       000000 cd cd cd cd cd cd cd cd cd cd cd cd cd cd cd cd  >................<
       *
       100000
      ...
      (Run 'diff -u /home/fdmanana/git/hub/xfstests/tests/generic/032.out /home/fdmanana/git/h

This is because we are attempting to wait for a process that is not a
child process of the test process and it's instead a child of a process
spawned by the test.

To make sure that after we kill the process running _syncloop() there
isn't any xfs_io process still running syncfs, add instead a trap to
to _syncloop() that waits for xfs_io to finish before the process running
that function exits.

Signed-off-by: Filipe Manana <fdmanana@suse.com>
Reviewed-by: Zorro Lang <zlang@redhat.com>
Signed-off-by: Zorro Lang <zlang@kernel.org>
tests/generic/032

index 48d594fe9315b8b5f56dad3d49dcddacea3b724c..b04b84decff7f5bf0e3bfff4e633e8a71090dcb5 100755 (executable)
@@ -28,6 +28,10 @@ _cleanup()
 
 _syncloop()
 {
+       # Wait for any running xfs_io command running syncfs before we exit so
+       # that unmount will not fail due to the mount being pinned by xfs_io.
+       trap "wait; exit" SIGTERM
+
        while [ true ]; do
                _scratch_sync
        done
@@ -81,15 +85,6 @@ echo $iters iterations
 kill $syncpid
 wait
 
-# The xfs_io instance started by _scratch_sync could be stuck in D state when
-# the subshell running _syncloop & is killed.  That xfs_io process pins the
-# mount so we must kill it and wait for it to die before cycling the mount.
-dead_syncfs_pid=$(_pgrep xfs_io)
-if [ -n "$dead_syncfs_pid" ]; then
-       _pkill xfs_io
-       wait $dead_syncfs_pid
-fi
-
 # clear page cache and dump the file
 _scratch_cycle_mount
 _hexdump $SCRATCH_MNT/file