block: Let bdrv_drain_all() to call aio_poll() for each AioContext
authorAlexander Yarygin <yarygin@linux.vnet.ibm.com>
Wed, 10 Jun 2015 11:38:17 +0000 (14:38 +0300)
committerStefan Hajnoczi <stefanha@redhat.com>
Tue, 23 Jun 2015 14:06:16 +0000 (15:06 +0100)
commitf406c03c093f1451ac0ba7fde31eeb78e5e5e417
tree52b1a39551c0db3c413c42e49ec3e9f01f800dc6
parenta3206972a9eab65ec8e8f9ae320ad628ba4b58f1
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 <borntraeger@de.ibm.com>
Cc: Cornelia Huck <cornelia.huck@de.ibm.com>
Cc: Kevin Wolf <kwolf@redhat.com>
Cc: Paolo Bonzini <pbonzini@redhat.com>
Cc: Stefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: Alexander Yarygin <yarygin@linux.vnet.ibm.com>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Tested-by: Christian Borntraeger <borntraeger@de.ibm.com>
Message-id: 1433936297-7098-4-git-send-email-yarygin@linux.vnet.ibm.com
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
block/io.c