From patchwork Thu Oct 29 02:14:26 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fam Zheng X-Patchwork-Id: 537651 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)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id EA61F140B0F for ; Thu, 29 Oct 2015 13:17:25 +1100 (AEDT) Received: from localhost ([::1]:41602 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZrcmJ-0007n3-UZ for incoming@patchwork.ozlabs.org; Wed, 28 Oct 2015 22:17:23 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60255) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZrckI-0004S6-RZ for qemu-devel@nongnu.org; Wed, 28 Oct 2015 22:15:19 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZrckH-0008HC-TO for qemu-devel@nongnu.org; Wed, 28 Oct 2015 22:15:18 -0400 Received: from mx1.redhat.com ([209.132.183.28]:39352) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZrckF-0008Gk-Md; Wed, 28 Oct 2015 22:15:15 -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 (Postfix) with ESMTPS id 40502C18F6BF; Thu, 29 Oct 2015 02:15:15 +0000 (UTC) Received: from fam-t430.redhat.com (vpn1-5-102.pek2.redhat.com [10.72.5.102]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t9T2ERWl022871; Wed, 28 Oct 2015 22:15:11 -0400 From: Fam Zheng To: qemu-devel@nongnu.org Date: Thu, 29 Oct 2015 10:14:26 +0800 Message-Id: <1446084866-12451-10-git-send-email-famz@redhat.com> In-Reply-To: <1446084866-12451-1-git-send-email-famz@redhat.com> References: <1446084866-12451-1-git-send-email-famz@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 , Stefan Hajnoczi , qemu-block@nongnu.org, Peter Lieven , Ronnie Sahlberg , Paolo Bonzini Subject: [Qemu-devel] [PATCH v2 9/9] qed: Implement .bdrv_drain 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 The "need_check_timer" is used to clear the "NEED_CHECK" flag in the image header after a grace period once metadata update has finished. In compliance to the bdrv_drain semantics we should make sure it remains deleted once .bdrv_drain is called. We cannot reuse qed_need_check_timer_cb because here it doesn't satisfy the assertion. Do the "plug" and "flush" calls manually. Signed-off-by: Fam Zheng Reviewed-by: Kevin Wolf --- block/qed.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/block/qed.c b/block/qed.c index 5ea05d4..9b88895 100644 --- a/block/qed.c +++ b/block/qed.c @@ -375,6 +375,18 @@ static void bdrv_qed_attach_aio_context(BlockDriverState *bs, } } +static void bdrv_qed_drain(BlockDriverState *bs) +{ + BDRVQEDState *s = bs->opaque; + + /* Cancel timer and start doing I/O that were meant to happen as if it + * fired, that way we get bdrv_drain() taking care of the ongoing requests + * correctly. */ + qed_cancel_need_check_timer(s); + qed_plug_allocating_write_reqs(s); + bdrv_aio_flush(s->bs, qed_clear_need_check, s); +} + static int bdrv_qed_open(BlockDriverState *bs, QDict *options, int flags, Error **errp) { @@ -1676,6 +1688,7 @@ static BlockDriver bdrv_qed = { .bdrv_check = bdrv_qed_check, .bdrv_detach_aio_context = bdrv_qed_detach_aio_context, .bdrv_attach_aio_context = bdrv_qed_attach_aio_context, + .bdrv_drain = bdrv_qed_drain, }; static void bdrv_qed_init(void)