]> git.neil.brown.name Git - mdadm.git/commit
mdadm: Fix hang race condition in wait_for_zero_forks()
authorLogan Gunthorpe <logang@deltatee.com>
Tue, 4 Jun 2024 16:38:36 +0000 (10:38 -0600)
committerMariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com>
Thu, 13 Jun 2024 13:19:34 +0000 (15:19 +0200)
commit1a5c0e60308651a20d25ff52511230a20d830330
tree571e67b8dd22062f749a8da9afcc0ddd35674ed0
parent4f3efc34644d06f55fc650e4aa6b5a6ec22cea5f
mdadm: Fix hang race condition in wait_for_zero_forks()

Running a create operation with --write-zeros can randomly hang
forever waiting for child processes. This happens roughly on in
ten runs with when running with small (20MB) loop devices.

The bug is caused by the fact that signals can be coallesced into
one if they are not read by signalfd quick enough. So if two children
finish at exactly the same time, only one SIGCHLD will be received
by the parent.

To fix this, wait on all processes with WNOHANG every time a SIGCHLD
is received and exit when all processes have been waited on.

Reported-by: Xiao Ni <xni@redhat.com>
Signed-off-by: Logan Gunthorpe <logang@deltatee.com>
Signed-off-by: Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com>
Create.c