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: 956771 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com 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 41pfh20VRfz9s89 for ; Mon, 13 Aug 2018 12:24:49 +1000 (AEST) Received: from localhost ([::1]:37177 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fp2XH-000663-DU for incoming@patchwork.ozlabs.org; Sun, 12 Aug 2018 22:24:47 -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+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" 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(); }