From: Klaus Jensen <its@irrelevant.dk>
To: qemu-devel@nongnu.org
Cc: Fam Zheng <fam@euphon.net>, Kevin Wolf <kwolf@redhat.com>,
qemu-block@nongnu.org, Dmitry Fomichev <dmitry.fomichev@wdc.com>,
Klaus Jensen <k.jensen@samsung.com>,
Gollu Appalanaidu <anaidu.gollu@samsung.com>,
Max Reitz <mreitz@redhat.com>, Keith Busch <kbusch@kernel.org>,
Stefan Hajnoczi <stefanha@redhat.com>,
Klaus Jensen <its@irrelevant.dk>
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 [thread overview]
Message-ID: <20210310095347.682395-2-its@irrelevant.dk> (raw)
In-Reply-To: <20210310095347.682395-1-its@irrelevant.dk>
From: Klaus Jensen <k.jensen@samsung.com>
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 <dmitry.fomichev@wdc.com>
Signed-off-by: Klaus Jensen <k.jensen@samsung.com>
---
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, NvmeRequest *req)
uint32_t zone_idx, zra, zrasf, partial;
uint64_t max_zones, nr_zones = 0;
uint16_t status;
- uint64_t slba, capacity = nvme_ns_nlbas(ns);
+ uint64_t slba;
NvmeZoneDescr *z;
NvmeZone *zone;
NvmeZoneReportHeader *header;
void *buf, *buf_p;
size_t zone_entry_sz;
+ int i;
req->status = NVME_SUCCESS;
@@ -2666,7 +2667,7 @@ static uint16_t nvme_zone_mgmt_recv(NvmeCtrl *n, NvmeRequest *req)
buf = g_malloc0(data_size);
zone = &ns->zone_array[zone_idx];
- for (; slba < capacity; slba += ns->zone_size) {
+ for (i = zone_idx; i < ns->num_zones; i++) {
if (partial && nr_zones >= max_zones) {
break;
}
--
2.30.1
next prev parent reply other threads:[~2021-03-10 10:07 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-03-10 9:53 [PATCH v5 00/13] hw/block/nvme: metadata and end-to-end data protection support Klaus Jensen
2021-03-10 9:53 ` Klaus Jensen [this message]
2021-03-14 19:31 ` [PATCH v5 01/13] hw/block/nvme: fix zone management receive reporting too many zones Dmitry Fomichev
2021-03-15 18:59 ` Klaus Jensen
2021-03-10 9:53 ` [PATCH v5 02/13] hw/block/nvme: add metadata support Klaus Jensen
2021-03-10 9:53 ` [PATCH v5 03/13] hw/block/nvme: end-to-end data protection Klaus Jensen
2021-03-10 9:53 ` [PATCH v5 04/13] hw/block/nvme: add verify command Klaus Jensen
2021-03-10 9:53 ` [PATCH v5 05/13] hw/block/nvme: add non-mdts command size limit for verify Klaus Jensen
2021-03-10 9:53 ` [PATCH v5 06/13] hw/block/nvme: support multiple lba formats Klaus Jensen
2021-03-10 9:53 ` [PATCH v5 07/13] hw/block/nvme: prefer runtime helpers instead of device parameters Klaus Jensen
2021-03-16 6:47 ` Minwoo Im
2021-03-10 9:53 ` [PATCH v5 08/13] hw/block/nvme: pull lba format initialization Klaus Jensen
2021-03-16 6:49 ` Minwoo Im
2021-03-10 9:53 ` [PATCH v5 09/13] hw/block/nvme: parameterize nvme_ns_nlbas Klaus Jensen
2021-03-16 6:53 ` Minwoo Im
2021-03-16 7:19 ` Klaus Jensen
2021-03-16 7:34 ` Minwoo Im
2021-03-10 9:53 ` [PATCH v5 10/13] hw/block/nvme: remove invalid zone resource checks Klaus Jensen
2021-03-10 9:53 ` [PATCH v5 11/13] hw/block/nvme: move zoned constraints checks Klaus Jensen
2021-03-10 9:53 ` [PATCH v5 12/13] hw/block/nvme: split zone check/set geometry Klaus Jensen
2021-03-10 9:53 ` [PATCH v5 13/13] hw/block/nvme: add support for the format nvm command Klaus Jensen
2021-03-15 22:23 ` [PATCH v5 00/13] hw/block/nvme: metadata and end-to-end data protection support Klaus Jensen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210310095347.682395-2-its@irrelevant.dk \
--to=its@irrelevant.dk \
--cc=anaidu.gollu@samsung.com \
--cc=dmitry.fomichev@wdc.com \
--cc=fam@euphon.net \
--cc=k.jensen@samsung.com \
--cc=kbusch@kernel.org \
--cc=kwolf@redhat.com \
--cc=mreitz@redhat.com \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=stefanha@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).