]> www.infradead.org Git - users/sagi/nvme-cli.git/commitdiff
nvme: set eds to true if controller supports 128 bit hostid
authorBryan Gurney <bgurney@redhat.com>
Tue, 21 Jan 2025 17:20:34 +0000 (12:20 -0500)
committerDaniel Wagner <wagi@monom.org>
Wed, 22 Jan 2025 15:37:47 +0000 (16:37 +0100)
A controller that uses a 128-bit Host Identifier may result in the
"nvme resv-report" command failing with a "Host Identifier Inconsistent
Format" error that suggests the "simultaneous use of 64-bit and
128-bit Host Identifier values on different controllers".

This error can be avoided if the "--eds" option is used, to request
the extended data structure.  However, the controller's ctratt
value indicates whether the Host Identifier is 64 bits or 128 bits.
Therefore, check the ctratt flag, and set eds to true if the
controller indicates a 128-bit Host Identifier.

Signed-off-by: Bryan Gurney <bgurney@redhat.com>
nvme.c

diff --git a/nvme.c b/nvme.c
index a65873b2416ca469a460737a896436b488d2f244..2ed4ee92623f2a8c4f5978be38847daf41badc96 100644 (file)
--- a/nvme.c
+++ b/nvme.c
@@ -7740,6 +7740,7 @@ static int resv_report(int argc, char **argv, struct command *cmd, struct plugin
        const char *eds = "request extended data structure";
 
        _cleanup_free_ struct nvme_resv_status *status = NULL;
+       _cleanup_free_ struct nvme_id_ctrl *ctrl = NULL;
        _cleanup_nvme_dev_ struct nvme_dev *dev = NULL;
        nvme_print_flags_t flags;
        int err, size;
@@ -7792,6 +7793,19 @@ static int resv_report(int argc, char **argv, struct command *cmd, struct plugin
 
        size = (cfg.numd + 1) << 2;
 
+       ctrl = nvme_alloc(sizeof(*ctrl));
+       if (!ctrl)
+               return -ENOMEM;
+
+       err = nvme_cli_identify_ctrl(dev, ctrl);
+       if (err) {
+               nvme_show_error("identify-ctrl: %s", nvme_strerror(errno));
+               return -errno;
+       }
+
+       if (ctrl->ctratt & NVME_CTRL_CTRATT_128_ID)
+               cfg.eds = true;
+
        status = nvme_alloc(size);
        if (!status)
                return -ENOMEM;