From nobody Wed Nov 5 07:34:31 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1534171554219313.57548860151803; Mon, 13 Aug 2018 07:45:54 -0700 (PDT) Received: from localhost ([::1]:39886 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fpE6L-0007KR-Js for importer@patchew.org; Mon, 13 Aug 2018 10:45:45 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43270) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fpE48-0005ya-Nl for qemu-devel@nongnu.org; Mon, 13 Aug 2018 10:43:31 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fpE47-0007md-Vp for qemu-devel@nongnu.org; Mon, 13 Aug 2018 10:43:28 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:52210 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 1fpE44-0007lF-O9; Mon, 13 Aug 2018 10:43:24 -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 4CECE7C809; Mon, 13 Aug 2018 14:43:24 +0000 (UTC) Received: from donizetti.redhat.com (ovpn-112-29.ams2.redhat.com [10.36.112.29]) by smtp.corp.redhat.com (Postfix) with ESMTP id 35E042026D7E; Mon, 13 Aug 2018 14:43:22 +0000 (UTC) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Mon, 13 Aug 2018 16:43:20 +0200 Message-Id: <20180813144320.12382-2-pbonzini@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.2]); Mon, 13 Aug 2018 14:43:24 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.2]); Mon, 13 Aug 2018 14:43:24 +0000 (UTC) for IP:'10.11.54.4' DOMAIN:'int-mx04.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'pbonzini@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] nvme: simplify plug/unplug 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: famz@redhat.com, qemu-block@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RDMRC_1 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" bdrv_io_plug/bdrv_io_unplug take care of keeping a nesting count, so change s->plugged to just a bool. Signed-off-by: Paolo Bonzini --- block/nvme.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/block/nvme.c b/block/nvme.c index df2e16fabe..973db3decd 100644 --- a/block/nvme.c +++ b/block/nvme.c @@ -104,7 +104,7 @@ typedef struct { uint64_t nsze; /* Namespace size reported by identify command */ int nsid; /* The namespace id to read/write data. */ uint64_t max_transfer; - int plugged; + bool plugged; =20 CoMutex dma_map_lock; CoQueue dma_flush_queue; @@ -1110,7 +1110,8 @@ static void nvme_attach_aio_context(BlockDriverState = *bs, static void nvme_aio_plug(BlockDriverState *bs) { BDRVNVMeState *s =3D bs->opaque; - s->plugged++; + assert(!s->plugged); + s->plugged =3D true; } =20 static void nvme_aio_unplug(BlockDriverState *bs) @@ -1118,14 +1119,13 @@ static void nvme_aio_unplug(BlockDriverState *bs) int i; BDRVNVMeState *s =3D bs->opaque; assert(s->plugged); - if (!--s->plugged) { - for (i =3D 1; i < s->nr_queues; i++) { - NVMeQueuePair *q =3D s->queues[i]; - qemu_mutex_lock(&q->lock); - nvme_kick(s, q); - nvme_process_completion(s, q); - qemu_mutex_unlock(&q->lock); - } + s->plugged =3D false; + for (i =3D 1; i < s->nr_queues; i++) { + NVMeQueuePair *q =3D s->queues[i]; + qemu_mutex_lock(&q->lock); + nvme_kick(s, q); + nvme_process_completion(s, q); + qemu_mutex_unlock(&q->lock); } } =20 --=20 2.17.1