]> www.infradead.org Git - users/sagi/libnvme.git/commitdiff
fabrics: retry discovery log page when DNR is not set
authorHannes Reinecke <hare@suse.de>
Thu, 4 Apr 2024 07:35:13 +0000 (09:35 +0200)
committerDaniel Wagner <wagi@monom.org>
Tue, 9 Apr 2024 12:47:59 +0000 (14:47 +0200)
Reading the discovery log page might result in an NVMe status,
so we should evaluate the DNR bit to check if it's safe to retry
the command.

Signed-off-by: Hannes Reinecke <hare@suse.de>
src/nvme/fabrics.c

index 6738e9dc42ec2d5ef58aa1974a3188fa8a42ff06..96ba9d4b89ab510d8175bef02fb1d3a69ecf83d7 100644 (file)
@@ -1051,6 +1051,7 @@ static struct nvmf_discovery_log *nvme_discovery_log(
        int retries = 0;
        const char *name = nvme_ctrl_get_name(args->c);
        uint64_t genctr, numrec;
+       __u32 result;
        int fd = nvme_ctrl_get_fd(args->c);
        struct nvme_get_log_args log_args = {
                .result = args->result,
@@ -1076,13 +1077,21 @@ static struct nvmf_discovery_log *nvme_discovery_log(
                 name, retries, args->max_retries);
        log_args.log = log;
        log_args.len = DISCOVERY_HEADER_LEN;
+       if (!args->result)
+               log_args.result = &result;
+retry_header:
        if (nvme_get_log_page(fd, NVME_LOG_PAGE_PDU_SIZE, &log_args)) {
                nvme_msg(r, LOG_INFO,
                         "%s: discover try %d/%d failed, error %d\n",
                         name, retries, args->max_retries, errno);
+               if (*log_args.result &&
+                   !(*log_args.result & NVME_SC_DNR) &&
+                   (++retries < args->max_retries))
+                       goto retry_header;
                goto out_free_log;
        }
 
+       retries = 0;
        do {
                size_t entries_size;
 
@@ -1113,6 +1122,9 @@ static struct nvmf_discovery_log *nvme_discovery_log(
                        nvme_msg(r, LOG_INFO,
                                 "%s: discover try %d/%d failed, error %d\n",
                                 name, retries, args->max_retries, errno);
+                       if (*log_args.result &&
+                           !(*log_args.result & NVME_SC_DNR))
+                               continue;
                        goto out_free_log;
                }
 
@@ -1129,6 +1141,9 @@ static struct nvmf_discovery_log *nvme_discovery_log(
                        nvme_msg(r, LOG_INFO,
                                 "%s: discover try %d/%d failed, error %d\n",
                                 name, retries, args->max_retries, errno);
+                       if (*log_args.result &&
+                           !(*log_args.result & NVME_SC_DNR))
+                               continue;
                        goto out_free_log;
                }
        } while (genctr != le64_to_cpu(log->genctr) &&