mirror: Wait only for in-flight operations
commitce8cabbd17cf738ddfc68384440c38e5dd2fdf97
authorKevin Wolf <kwolf@redhat.com>
Thu, 26 Mar 2020 15:36:28 +0000 (26 16:36 +0100)
committerKevin Wolf <kwolf@redhat.com>
Fri, 27 Mar 2020 13:47:23 +0000 (27 14:47 +0100)
tree67b8b26517396b48ba468d471810e32883652402
parent9178f4fe5f083064f5c91f04d98c815ce5a5af1c
mirror: Wait only for in-flight operations

mirror_wait_for_free_in_flight_slot() just picks a random operation to
wait for. However, a MirrorOp is already in s->ops_in_flight when
mirror_co_read() waits for free slots, so if not enough slots are
immediately available, an operation can end up waiting for itself, or
two or more operations can wait for each other to complete, which
results in a hang.

Fix this by adding a flag to MirrorOp that tells us if the request is
already in flight (and therefore occupies slots that it will later
free), and picking only such operations for waiting.

Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=1794692
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Message-Id: <20200326153628.4869-3-kwolf@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
block/mirror.c