]> git.ipfire.org Git - thirdparty/qemu.git/commit - block.c
block: stop relying on io_flush() in bdrv_drain_all()
authorStefan Hajnoczi <stefanha@redhat.com>
Thu, 11 Apr 2013 13:41:13 +0000 (15:41 +0200)
committerStefan Hajnoczi <stefanha@redhat.com>
Mon, 19 Aug 2013 13:45:34 +0000 (15:45 +0200)
commit88266f5aa70fa71fd5cc20aa4dbeb7a7bd8d2e92
tree59a8cc958f76256abfa69357edc131b69c566d8d
parente1b5c52e04d04bb93546c6e37e8884889d047cb1
block: stop relying on io_flush() in bdrv_drain_all()

If a block driver has no file descriptors to monitor but there are still
active requests, it can return 1 from .io_flush().  This is used to spin
during synchronous I/O.

Stop relying on .io_flush() and instead check
QLIST_EMPTY(&bs->tracked_requests) to decide whether there are active
requests.

This is the first step in removing .io_flush() so that event loops no
longer need to have the concept of synchronous I/O.  Eventually we may
be able to kill synchronous I/O completely by running everything in a
coroutine, but that is future work.

Note this patch moves bs->throttled_reqs initialization to bdrv_new() so
that bdrv_requests_pending(bs) can safely access it.  In practice bs is
g_malloc0() so the memory is already zeroed but it's safer to initialize
the queue properly.

We also need to fix up block/stream.c:close_unused_images() to prevent
traversing a dangling pointer while it rearranges the backing file
chain.  This is necessary since the new bdrv_drain_all() traverses the
backing file chain.

Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
block.c
block/stream.c