]> www.infradead.org Git - users/sagi/nvme-cli.git/commitdiff
netapp-nvme: fix nvme ns desc uuid handling for ontapdevices
authorMartin George <marting@netapp.com>
Wed, 16 Feb 2022 18:33:20 +0000 (00:03 +0530)
committerMartin George <marting@netapp.com>
Wed, 16 Feb 2022 18:33:20 +0000 (00:03 +0530)
The nvme ns desc uuid handling in the NetApp plugin for
ontapdevices is broken after the recent upgrade to libnvme. The
uuid hanlding logic here was flawed to begin with, so rework this
code to ensure the respective uuid descriptor itself is stored in
the ontapdevice_info structure and processed appropriately.

Signed-off-by: Martin George <marting@netapp.com>
plugins/netapp/netapp-nvme.c

index e14a970b2922db964a0ff5c27ebe7fec356ab74a..d5c6d6cddd0ea033825935e89a2043e99a850e60 100644 (file)
@@ -67,7 +67,7 @@ struct ontapdevice_info {
        unsigned                nsid;
        struct nvme_id_ctrl     ctrl;
        struct nvme_id_ns       ns;
-       struct nvme_ns_id_desc  nsdesc;
+       uuid_t                  uuid;
        unsigned char           log_data[ONTAP_C2_LOG_SIZE];
        char                    dev[265];
 };
@@ -115,15 +115,6 @@ static void netapp_get_ns_size(char *size, long long *lba,
        sprintf(size, "%.2f%sB", nsze, s_suffix);
 }
 
-static void netapp_uuid_to_str(char *str, void *data)
-{
-       uuid_t uuid;
-       struct nvme_ns_id_desc *desc = data;
-
-       memcpy(uuid, data + sizeof(*desc), 16);
-       uuid_unparse_lower(uuid, str);
-}
-
 static void ontap_labels_to_str(char *dst, char *src, int count)
 {
        int i;
@@ -340,7 +331,7 @@ static void netapp_ontapdevices_print(struct ontapdevice_info *devices,
        for (i = 0; i < count; i++) {
 
                netapp_get_ns_size(size, &lba, &devices[i].ns);
-               netapp_uuid_to_str(uuid_str, &devices[i].nsdesc);
+               uuid_unparse_lower(devices[i].uuid, uuid_str);
                netapp_get_ontap_labels(vsname, nspath, devices[i].log_data);
 
                if (format == NJSON) {
@@ -423,6 +414,7 @@ static int netapp_ontapdevices_get_info(int fd, struct ontapdevice_info *item,
                const char *dev)
 {
        int err;
+       void *nsdescs;
 
        err = nvme_identify_ctrl(fd, &item->ctrl);
        if (err) {
@@ -444,13 +436,20 @@ static int netapp_ontapdevices_get_info(int fd, struct ontapdevice_info *item,
                return 0;
        }
 
-       err = nvme_identify_ns_descs(fd, item->nsid, &item->nsdesc);
+       if (posix_memalign(&nsdescs, getpagesize(), 0x1000)) {
+               fprintf(stderr, "Cannot allocate controller list payload\n");
+               return 0;
+       }
+
+       err = nvme_identify_ns_descs(fd, item->nsid, nsdescs);
        if (err) {
                fprintf(stderr, "Unable to identify namespace descriptor for %s (%s)\n",
                                dev, strerror(err));
                return 0;
        }
 
+       memcpy(item->uuid, nsdescs + sizeof(struct nvme_ns_id_desc), sizeof(item->uuid));
+
        err = nvme_get_ontap_c2_log(fd, item->nsid, item->log_data, ONTAP_C2_LOG_SIZE);
        if (err) {
                fprintf(stderr, "Unable to get log page data for %s (%s)\n",