From nobody Mon Feb 9 09:32:35 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1615370893; cv=none; d=zohomail.com; s=zohoarc; b=SuwPH9+aHIAdsnbekQBkHW/CK2uwfD1t+Pwnbq/ZOawoBCJTZD4J2sIXrKC4rQM62odzs9RQy8Ax5+iBG2r8E4EE35/LADsIZ3hZ88qPY927WJhUCbpx/Didqf+c+GK/HmJM4D0alD1TDOPEo5FBgVHxItuKHxGRem45DXsI/m0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1615370893; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=FYrnxZCRUqxvXhWp4PVvzcwcxMk+kEx5KKxZbiqJ6bQ=; b=GzmYbbpyT5TB5HSy/pXzFbWo0il4txOA67BicxnpV5hDm47J58qyX/XjvG0OMaZ2cP18z1BX7aSW7ZEjIBPM3dEWi7+bO30/VBU30K3xIgWOjGYmVVoEO8MnPtyDJN+XNg79/8SyDSpfjs6Fdks0rPBj8CPvw1Qggm2J7lQf7fg= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1615370893531321.55115188828745; Wed, 10 Mar 2021 02:08:13 -0800 (PST) Received: from localhost ([::1]:38558 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lJvlE-0005f1-6d for importer@patchew.org; Wed, 10 Mar 2021 05:08:12 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:57978) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lJvXR-0007Vl-R7; Wed, 10 Mar 2021 04:53:57 -0500 Received: from new3-smtp.messagingengine.com ([66.111.4.229]:48937) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lJvXO-00052o-N3; Wed, 10 Mar 2021 04:53:57 -0500 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailnew.nyi.internal (Postfix) with ESMTP id 5DD735806C9; Wed, 10 Mar 2021 04:53:52 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute4.internal (MEProxy); Wed, 10 Mar 2021 04:53:52 -0500 Received: from apples.local (80-167-98-190-cable.dk.customer.tdc.net [80.167.98.190]) by mail.messagingengine.com (Postfix) with ESMTPA id C524024005E; Wed, 10 Mar 2021 04:53:50 -0500 (EST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=irrelevant.dk; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; s=fm2; bh=FYrnxZCRUqxvX hWp4PVvzcwcxMk+kEx5KKxZbiqJ6bQ=; b=fW708OreVNi21n/3UaRYEiH+hn8ZF 3m81xBHlnVdBCJCx2xdoRoj5z4/JD7hA9IBsZHNtPL9kDWR6x7pUWd4T5jKc3Qav vXhpR5UFe4xCsZ8wnwFZJApqMtjwQgqghFUpeE5lMPGfyTPXxhsOpJavww0xFQ/F g3utkEKoe0n0lAJfgGbT+GVI+jmrABoDw/VUaAHR5RGnyNhegf9jImoYHmuIwl+i ARhGU4cfqLrYDynEWWV+BdJkUhdWtP8T+bipKL7RXVSyoiBS1r9pO9gUMXbujrFP UOD2lZL4OSeVqkMFwyFPDmTo36cWH7X6epf0mwDUepd7SEpYAfYqZwGvg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:date:from :in-reply-to:message-id:mime-version:references:subject:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm2; bh=FYrnxZCRUqxvXhWp4PVvzcwcxMk+kEx5KKxZbiqJ6bQ=; b=pZe3yeeM GoTCPH5sIklHJENonZ5Yw5Qa/8Rc4Irtb0tOSPFcpYPz30x62xHM8hEPX5kw3Q1m XDCSI4GPoXfA3GowXuVIkzEA23sCf/7G48qXX2Eky49sRgBbBue0aFBCNM/Z3Uy/ GcwnX/u4DiMBtUBS+EiUbDxpxbR7rqe67/sN3HEY4qH0V8kDgGjEu+tq/KaohL5R 6626C6es36FgSaFAAqsGB4AOjncJqbiK5Z89UbuS+Lp8/h81QzDIN+qwL3hSmMbZ +5AszACaMHA/n+5ErecWQYWdNAgFBbTCLx8VupQ8zqobsbWIO0L7xlitOJC5fg9r PRKPW6I5vYa/Tw== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduledruddukedgtdelucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephffvufffkffojghfggfgsedtkeertdertddtnecuhfhrohhmpefmlhgruhhs ucflvghnshgvnhcuoehithhssehirhhrvghlvghvrghnthdrughkqeenucggtffrrghtth gvrhhnpeeuleetgeeiuefhgfekfefgveejiefgteekiedtgfdtieefhfdthfefueffvefg keenucfkphepkedtrdduieejrdelkedrudeltdenucevlhhushhtvghrufhiiigvpedtne curfgrrhgrmhepmhgrihhlfhhrohhmpehithhssehirhhrvghlvghvrghnthdrughk X-ME-Proxy: From: Klaus Jensen To: qemu-devel@nongnu.org Subject: [PATCH v5 01/13] hw/block/nvme: fix zone management receive reporting too many zones Date: Wed, 10 Mar 2021 10:53:35 +0100 Message-Id: <20210310095347.682395-2-its@irrelevant.dk> X-Mailer: git-send-email 2.30.1 In-Reply-To: <20210310095347.682395-1-its@irrelevant.dk> References: <20210310095347.682395-1-its@irrelevant.dk> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=66.111.4.229; envelope-from=its@irrelevant.dk; helo=new3-smtp.messagingengine.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Fam Zheng , Kevin Wolf , qemu-block@nongnu.org, Dmitry Fomichev , Klaus Jensen , Gollu Appalanaidu , Max Reitz , Keith Busch , Stefan Hajnoczi , Klaus Jensen Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" From: Klaus Jensen nvme_zone_mgmt_recv uses nvme_ns_nlbas() to get the number of LBAs in the namespace and then calculates the number of zones to report by incrementing slba with ZSZE until exceeding the number of LBAs as returned by nvme_ns_nlbas(). This is bad because the namespace might be of such as size that some LBAs are valid, but are not part of any zone, causing zone management receive to report one additional (but non-existing) zone. Fix this with a conventional loop on i < ns->num_zones instead. Fixes: a479335bfaf3 ("hw/block/nvme: Support Zoned Namespace Command Set") Cc: Dmitry Fomichev Signed-off-by: Klaus Jensen Reviewed-by: Dmitry Fomichev --- hw/block/nvme.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/hw/block/nvme.c b/hw/block/nvme.c index d439e44db839..c7b9a1663dd7 100644 --- a/hw/block/nvme.c +++ b/hw/block/nvme.c @@ -2619,12 +2619,13 @@ static uint16_t nvme_zone_mgmt_recv(NvmeCtrl *n, Nv= meRequest *req) uint32_t zone_idx, zra, zrasf, partial; uint64_t max_zones, nr_zones =3D 0; uint16_t status; - uint64_t slba, capacity =3D nvme_ns_nlbas(ns); + uint64_t slba; NvmeZoneDescr *z; NvmeZone *zone; NvmeZoneReportHeader *header; void *buf, *buf_p; size_t zone_entry_sz; + int i; =20 req->status =3D NVME_SUCCESS; =20 @@ -2666,7 +2667,7 @@ static uint16_t nvme_zone_mgmt_recv(NvmeCtrl *n, Nvme= Request *req) buf =3D g_malloc0(data_size); =20 zone =3D &ns->zone_array[zone_idx]; - for (; slba < capacity; slba +=3D ns->zone_size) { + for (i =3D zone_idx; i < ns->num_zones; i++) { if (partial && nr_zones >=3D max_zones) { break; } --=20 2.30.1