Another tiny bit from the multiqueue series. This takes care of reimplementing bdrv_drain to process each BDS in the tree in order. A side effect is to separate draining of data writes from draining of metadata writes, which allows us to reinstate QED's .bdrv_drain implementation.
A couple words on the role of this in the multiqueue world. This series is half of what's needed to remove RFifoLock and contention callbacks. In order to do so, aio_poll will only run in the I/O thread; when the main QEMU thread wants to drain a BlockDriverState it will rely on the I/O thread to do the work. in_flight then provides a quick way to detect whether to wake up a thread sitting in bdrv_drain. Compared to previous attempts, the main change is that some tracking has to be done at the BlockBackend level, because throttling has been moved there. This series requires: - "replication: interrupt failover if the main device is closed" - "blockjob: introduce .drain callback for jobs" The next (already written) steps are: - "aio: convert from RFifoLock to QemuRecMutex" - "aio: push aio_context_acquire/release down to dispatching" - "aio: explicitly acquire aiocontext in all callbacks" - "coroutine-lock: make it thread-safe" - "block: make BlockDriverState fields thread-safe" In total these are about 60 patches. I plan to merge the first into 2.8 as a bugfix. Further (planned) steps are: - blockjob: do not protect with AioContext lock This is just using a QemuMutex to protect BlockJob fields - block drivers: make them thread-safe This ensures everything is protected by the CoMutex or, for AIO-based drivers, by a QemuMutex. - block: remove bdrv_set_aio_context Paolo Fam Zheng (1): qed: Implement .bdrv_drain Paolo Bonzini (2): block: add BDS field to count in-flight requests block: change drain to look only at one child at a time block/block-backend.c | 17 ++++++- block/io.c | 127 ++++++++++++++++++++++++++++++++-------------- block/qed.c | 16 +++++- include/block/block_int.h | 10 ++-- 4 files changed, 124 insertions(+), 46 deletions(-) -- 2.7.4