Skip to content

Commit

Permalink
fabrics: retry discovery log page when DNR is not set
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
hreinecke committed Apr 4, 2024
1 parent 3df618d commit dc86b59
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/nvme/fabrics.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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;

Expand Down Expand Up @@ -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;
}

Expand All @@ -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) &&
Expand Down

0 comments on commit dc86b59

Please sign in to comment.