From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33968) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aBgyB-0007LF-Mo for qemu-devel@nongnu.org; Wed, 23 Dec 2015 05:48:36 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aBgyA-0007yn-Qt for qemu-devel@nongnu.org; Wed, 23 Dec 2015 05:48:35 -0500 From: Paolo Bonzini Date: Wed, 23 Dec 2015 11:48:24 +0100 Message-Id: <1450867706-19860-2-git-send-email-pbonzini@redhat.com> Subject: [Qemu-devel] [PATCH] block: use drained section in bdrv_close List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org bdrv_close is used when ejecting a medium. Use a drained section to ensure that all I/O goes to either the old medium or the bitbucket. Signed-off-by: Paolo Bonzini --- block.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/block.c b/block.c index 411edbf..01655de 100644 --- a/block.c +++ b/block.c @@ -2154,9 +2154,10 @@ void bdrv_close(BlockDriverState *bs) bdrv_io_limits_disable(bs); } - bdrv_drain(bs); /* complete I/O */ + bdrv_drained_begin(bs); /* complete I/O */ bdrv_flush(bs); bdrv_drain(bs); /* in case flush left pending I/O */ + notifier_list_notify(&bs->close_notifiers, bs); if (bs->blk) { @@ -2206,6 +2207,7 @@ void bdrv_close(BlockDriverState *bs) g_free(ban); } QLIST_INIT(&bs->aio_notifiers); + bdrv_drained_end(bs); } void bdrv_close_all(void) -- 2.5.0