public inbox for git-commits@fedoraproject.org
help / color / mirror / Atom feed
* [rpms/nvme-cli] f45: nvme-cli: Fix resv report missing registrations
@ 2026-10-06 11:53 Jesse Taube
0 siblings, 0 replies; only message in thread
From: Jesse Taube @ 2026-10-06 11:53 UTC (permalink / raw)
To: git-commits
A new commit has been pushed.
Repo : rpms/nvme-cli
Branch : f45
Commit : cffc352645aebd2c1e021ea010764976b788c857
Author : Jesse Taube <jtaubepe@redhat.com>
Date : 2026-10-06T13:52:44+02:00
Stats : +185/-1 in 2 file(s)
URL : https://src.fedoraproject.org/rpms/nvme-cli/c/cffc352645aebd2c1e021ea010764976b788c857?branch=f45
Log:
nvme-cli: Fix resv report missing registrations
Resolves: RHEL-262354
Signed-off-by: Jesse Taube <jtaubepe@redhat.com>
---
diff --git a/0001-Backport-resv-plugin-size-the-resv-report-from-the-r.patch b/0001-Backport-resv-plugin-size-the-resv-report-from-the-r.patch
new file mode 100644
index 0000000..e419b74
--- /dev/null
+++ b/0001-Backport-resv-plugin-size-the-resv-report-from-the-r.patch
@@ -0,0 +1,180 @@
+From 531b8a886f42510af4b498029ef4494d6cb2801f Mon Sep 17 00:00:00 2001
+From: Jesse Taube <jtaubepe@redhat.com>
+Date: Thu, 24 Sep 2026 11:38:27 -0400
+Subject: [PATCH] Backport: ("resv-plugin: size the resv report from the
+ registrant count")
+
+resv_report() clamped the transfer to one page and asked for that much
+up front. A namespace with many registered controllers reports more
+than fits: 4096 bytes holds 169 registrant descriptors, or only 63 when
+the extended data structure is in use, which is forced on whenever the
+controller supports 128-bit host identifiers. The excess registrants
+were dropped with no indication to the user, and an explicit --numd
+larger than 1023 dwords was silently rewritten to 1023 itself.
+
+Read the fixed-size header first, then repeat the command with a buffer
+sized for the registrant count it carries. --numd now overrides the
+automatic sizing rather than capping it, bounded only by the largest
+report a 16-bit registrant count can describe.
+
+Signed-off-by: Martin George <marting@netapp.com>
+
+Commit: f7dbddc51d00 ("src: rework nvme_resv_report commands:")
+Replaced `nvme_resv_report` with `nvme_init_resv_report` and
+`libnvme_exec_io_passthru`. Replacing those two functions with
+`nvme_resv_report` was necessary for the backport.
+
+Commit: 636c94d1daac ("libnvme: update definitions with ECN122 changes")
+Renamed `regctl` to `regstrnt`, `regctl_eds` to `registrant_eds`, and
+`regctl_ds` to `registrant_ds`, so reverse those changs.
+
+Signed-off-by: Jesse Taube <jtaubepe@redhat.com>
+---
+ nvme.c | 101 ++++++++++++++++++++++++++++++++++++++++++++++++++-------
+ 1 file changed, 89 insertions(+), 12 deletions(-)
+
+diff --git a/nvme.c b/nvme.c
+index 2e2035814..6c35a10ca 100644
+--- a/nvme.c
++++ b/nvme.c
+@@ -8058,6 +8058,30 @@ static int resv_release(int argc, char **argv, struct command *cmd, struct plugi
+ return err;
+ }
+
++/* The Number of Registrants field is 16 bits wide. */
++#define RESV_MAX_REGCTL 0xffff
++
++/*
++ * Bytes needed to hold a reservation status with @regctl registrant
++ * descriptors. Pass 0 for the fixed header alone, which is all it takes
++ * to learn how many registrants are there.
++ *
++ * The extended data structure changes both halves of the layout:
++ * a 64-byte header rather than 24, and 64-byte descriptors rather than 24.
++ * All four are multiples of 4, so the result is always a whole number of
++ * dwords, which nvme_resv_report() relies on when it turns the byte
++ * count into the 0's-based dword count the command carries.
++ */
++static int resv_report_size(bool eds, unsigned int regctl)
++{
++ if (eds)
++ return offsetof(struct nvme_resv_status, regctl_eds) +
++ regctl * sizeof(struct nvme_registered_ctrl_ext);
++
++ return offsetof(struct nvme_resv_status, regctl_ds) +
++ regctl * sizeof(struct nvme_registered_ctrl);
++}
++
+ static int resv_report(int argc, char **argv, struct command *cmd, struct plugin *plugin)
+ {
+ const char *desc = "Returns Reservation Status data\n"
+@@ -8071,7 +8095,7 @@ static int resv_report(int argc, char **argv, struct command *cmd, struct plugin
+ _cleanup_free_ struct nvme_id_ctrl *ctrl = NULL;
+ _cleanup_nvme_dev_ struct nvme_dev *dev = NULL;
+ nvme_print_flags_t flags;
+- int err, size;
++ int err, size, regctl;
+
+ struct config {
+ __u32 namespace_id;
+@@ -8114,13 +8138,6 @@ static int resv_report(int argc, char **argv, struct command *cmd, struct plugin
+ }
+ }
+
+- if (!cfg.numd || cfg.numd >= (0x1000 >> 2))
+- cfg.numd = (0x1000 >> 2) - 1;
+- if (cfg.numd < 3)
+- cfg.numd = 3;
+-
+- size = (cfg.numd + 1) << 2;
+-
+ ctrl = nvme_alloc(sizeof(*ctrl));
+ if (!ctrl)
+ return -ENOMEM;
+@@ -8134,6 +8151,24 @@ static int resv_report(int argc, char **argv, struct command *cmd, struct plugin
+ if (ctrl->ctratt & NVME_CTRL_CTRATT_128_ID)
+ cfg.eds = true;
+
++ /*
++ * The registrant count is only known once the report header has
++ * been read, so fetch the header first and repeat the command with
++ * a buffer sized for the count it reports. Sizing the transfer up
++ * front instead would truncate the report on a namespace with many
++ * registered controllers: one page holds only 63 registrants when
++ * the extended data structure is in use. An explicit --numd is
++ * honoured as given and skips the second pass.
++ */
++ if (cfg.numd) {
++ size = resv_report_size(cfg.eds, RESV_MAX_REGCTL);
++ if (cfg.numd < 3)
++ cfg.numd = 3;
++ if (cfg.numd < (__u32)size / 4 - 1)
++ size = (cfg.numd + 1) << 2;
++ } else
++ size = resv_report_size(cfg.eds, 0);
++
+ status = nvme_alloc(size);
+ if (!status)
+ return -ENOMEM;
+@@ -8149,12 +8184,54 @@ static int resv_report(int argc, char **argv, struct command *cmd, struct plugin
+ .result = NULL,
+ };
+ err = nvme_resv_report(&args);
+- if (!err)
+- nvme_show_resv_report(status, size, cfg.eds, flags);
+- else if (err > 0)
++ if (err > 0) {
+ nvme_show_status(err);
+- else
++ return err;
++ } else if (err) {
+ nvme_show_error("reservation report: %s", nvme_strerror(errno));
++ return err;
++ }
++
++ /* Two separate bytes, not a __le16: the field sits at odd offset 5. */
++ regctl = status->regctl[0] | (status->regctl[1] << 8);
++
++ if (!cfg.numd && regctl) {
++ struct nvme_resv_status *p;
++
++ size = resv_report_size(cfg.eds, regctl);
++
++ /*
++ * On failure, libnvme_realloc() returns NULL and leaves the
++ * original allocation valid, so assigning straight to status
++ * would drop the only reference to it.
++ */
++ p = nvme_alloc(size);
++ if (!p)
++ return -ENOMEM;
++ status = p;
++
++ /* Re-init, not just repoint: cdw10 encodes the new length. */
++ struct nvme_resv_report_args args = {
++ .args_size = sizeof(args),
++ .fd = dev_fd(dev),
++ .nsid = cfg.namespace_id,
++ .eds = cfg.eds,
++ .len = size,
++ .report = status,
++ .timeout = nvme_cfg.timeout,
++ .result = NULL,
++ };
++ err = nvme_resv_report(&args);
++ if (err > 0) {
++ nvme_show_status(err);
++ return err;
++ } else if (err) {
++ nvme_show_error("reservation report: %s", nvme_strerror(errno));
++ return err;
++ }
++ }
++
++ nvme_show_resv_report(status, size, cfg.eds, flags);
+
+ return err;
+ }
+--
+2.55.0
+
diff --git a/nvme-cli.spec b/nvme-cli.spec
index 2f69b68..222f55c 100644
--- a/nvme-cli.spec
+++ b/nvme-cli.spec
@@ -5,7 +5,7 @@
Name: nvme-cli
Version: 2.16
-Release: 5%{?dist}
+Release: 6%{?dist}
Summary: NVMe management command line interface
License: GPL-2.0-only
@@ -16,6 +16,7 @@ Source2: 99-nvme-nbft-no-ignore-carrier.conf
# https://bugzilla.redhat.com/show_bug.cgi?id=2501829
Patch0: format-sigint.patch
+Patch1: 0001-Backport-resv-plugin-size-the-resv-report-from-the-r.patch
BuildRequires: meson >= 0.53
BuildRequires: gcc gcc-c++
@@ -122,6 +123,9 @@ fi
%changelog
+* Tue Sep 28 2026 Jesse Taube <jtaubepe@redhat.com> - 2.16-6
+- Fix nvme resv report missing registrations
+
* Tue Aug 18 2026 Tomas Bzatek <tbzatek@redhat.com> - 2.16-5
- Fix ignored interruption in format command (#2501829)
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2026-10-06 11:53 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-10-06 11:53 [rpms/nvme-cli] f45: nvme-cli: Fix resv report missing registrations Jesse Taube
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox