From patchwork Mon Jul 1 11:29:44 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Hajnoczi X-Patchwork-Id: 256094 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 9A8C52C008C for ; Mon, 1 Jul 2013 21:30:16 +1000 (EST) Received: from localhost ([::1]:47957 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UtcJC-0001ZZ-NQ for incoming@patchwork.ozlabs.org; Mon, 01 Jul 2013 07:30:14 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43054) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UtcIp-0001Rd-8F for qemu-devel@nongnu.org; Mon, 01 Jul 2013 07:29:55 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UtcIm-0001N9-Lb for qemu-devel@nongnu.org; Mon, 01 Jul 2013 07:29:51 -0400 Received: from mx1.redhat.com ([209.132.183.28]:20438) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UtcIm-0001N4-EX; Mon, 01 Jul 2013 07:29:48 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r61BTl6m001690 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Mon, 1 Jul 2013 07:29:47 -0400 Received: from localhost (ovpn-112-23.ams2.redhat.com [10.36.112.23]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id r61BTkrp000838; Mon, 1 Jul 2013 07:29:47 -0400 From: Stefan Hajnoczi To: Date: Mon, 1 Jul 2013 13:29:44 +0200 Message-Id: <1372678184-5008-1-git-send-email-stefanha@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Kevin Wolf , qemu-stable@nongnu.org, Stefan Hajnoczi Subject: [Qemu-devel] [PATCH] block: fix bdrv_flush() ordering in bdrv_close() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Since 80ccf93b we flush the block device during close. The bdrv_drain_all() call should come before bdrv_flush() to ensure guest write requests have completed. Otherwise we may miss pending writes when flushing. However, there is still a slight change that cancelling a blockjob or doing bdrv_flush() might leave an I/O request running, so call bdrv_drain_all() again for safety as the final step. Cc: qemu-stable@nongnu.org Signed-off-by: Stefan Hajnoczi --- block.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/block.c b/block.c index 6c493ad..fca55b1 100644 --- a/block.c +++ b/block.c @@ -1358,11 +1358,12 @@ void bdrv_reopen_abort(BDRVReopenState *reopen_state) void bdrv_close(BlockDriverState *bs) { - bdrv_flush(bs); + bdrv_drain_all(); /* complete guest I/O */ if (bs->job) { block_job_cancel_sync(bs->job); } - bdrv_drain_all(); + bdrv_flush(bs); + bdrv_drain_all(); /* in case blockjob or flush started I/O */ notifier_list_notify(&bs->close_notifiers, bs); if (bs->drv) {