From patchwork Mon Aug 13 02:19:57 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Max Reitz X-Patchwork-Id: 10563837 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id B92261815 for ; Mon, 13 Aug 2018 02:25:33 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AA21128CF4 for ; Mon, 13 Aug 2018 02:25:33 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9E05B28CF9; Mon, 13 Aug 2018 02:25:33 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 4EAC428CF4 for ; Mon, 13 Aug 2018 02:25:33 +0000 (UTC) Received: from localhost ([::1]:37188 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fp2Y0-0008DD-Jf for patchwork-qemu-devel@patchwork.kernel.org; Sun, 12 Aug 2018 22:25:32 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53189) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fp2TC-0003XV-6q for qemu-devel@nongnu.org; Sun, 12 Aug 2018 22:20:35 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fp2TB-0008CP-8v for qemu-devel@nongnu.org; Sun, 12 Aug 2018 22:20:34 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:53886 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1fp2T9-00088n-19; Sun, 12 Aug 2018 22:20:31 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 7FAB240216FC; Mon, 13 Aug 2018 02:20:30 +0000 (UTC) Received: from localhost (ovpn-204-21.brq.redhat.com [10.40.204.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 0EC1F2026D6D; Mon, 13 Aug 2018 02:20:29 +0000 (UTC) From: Max Reitz To: qemu-block@nongnu.org Date: Mon, 13 Aug 2018 04:19:57 +0200 Message-Id: <20180813022006.7216-9-mreitz@redhat.com> In-Reply-To: <20180813022006.7216-1-mreitz@redhat.com> References: <20180813022006.7216-1-mreitz@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.5]); Mon, 13 Aug 2018 02:20:30 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.5]); Mon, 13 Aug 2018 02:20:30 +0000 (UTC) for IP:'10.11.54.4' DOMAIN:'int-mx04.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'mreitz@redhat.com' RCPT:'' X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [PATCH 08/17] mirror: Make mirror_co_discard() nicer X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , Jeff Cody , Fam Zheng , qemu-devel@nongnu.org, Max Reitz Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP Signed-off-by: Max Reitz --- block/mirror.c | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/block/mirror.c b/block/mirror.c index df8e0242dc..85b08086cc 100644 --- a/block/mirror.c +++ b/block/mirror.c @@ -374,16 +374,13 @@ static int coroutine_fn mirror_co_zero(MirrorBlockJob *s, s->unmap ? BDRV_REQ_MAY_UNMAP : 0); } -static void coroutine_fn mirror_co_discard(void *opaque) +static int coroutine_fn mirror_co_discard(MirrorBlockJob *s, + int64_t offset, int64_t bytes) { - MirrorOp *op = opaque; - int ret; - - op->s->in_flight++; - op->s->bytes_in_flight += op->bytes; + s->in_flight++; + s->bytes_in_flight += bytes; - ret = blk_co_pdiscard(op->s->target, op->offset, op->bytes); - mirror_write_complete(op, ret); + return blk_co_pdiscard(s->target, offset, bytes); } static void coroutine_fn mirror_co_perform(void *opaque) @@ -400,8 +397,8 @@ static void coroutine_fn mirror_co_perform(void *opaque) ret = mirror_co_zero(s, op->offset, op->bytes); break; case MIRROR_METHOD_DISCARD: - mirror_co_discard(opaque); - return; + ret = mirror_co_discard(s, op->offset, op->bytes); + break; default: abort(); }