block: Let bdrv_drain_all() to call aio_poll() for each AioContext
After the commit
9b536adc ("block: acquire AioContext in
bdrv_drain_all()") the aio_poll() function got called for every
BlockDriverState, in assumption that every device may have its own
AioContext. If we have thousands of disks attached, there are a lot of
BlockDriverStates but only a few AioContexts, leading to tons of
unnecessary aio_poll() calls.
This patch changes the bdrv_drain_all() function allowing it find shared
AioContexts and to call aio_poll() only for unique ones.
Cc: Christian Borntraeger <[email protected]>
Cc: Cornelia Huck <[email protected]>
Cc: Kevin Wolf <[email protected]>
Cc: Paolo Bonzini <[email protected]>
Cc: Stefan Hajnoczi <[email protected]>
Signed-off-by: Alexander Yarygin <[email protected]>
Reviewed-by: Stefan Hajnoczi <[email protected]>
Tested-by: Christian Borntraeger <[email protected]>
Message-id:
1433936297[email protected]
Signed-off-by: Stefan Hajnoczi <[email protected]>