Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
openSUSE:Leap:15.5:Update
libnvme.26472
0015-fabrics-restructrure-nvmf_get_discovery_lo...
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File 0015-fabrics-restructrure-nvmf_get_discovery_log.patch of Package libnvme.26472
From: Daniel Wagner <dwagner@suse.de> Date: Mon, 13 Jun 2022 11:27:45 +0200 Subject: fabrics: restructrure nvmf_get_discovery_log Git-commit: ed7982650df6f26227968bf55e5d26145e2d1fdb References: bsc#1201717 Move the initial header read into the do while loop. This simplifies the loop flow into first read header if there are records fetch them too. With this we keep the genctr and numrec in sync for both get log invocation. Signed-off-by: Daniel Wagner <dwagner@suse.de> --- src/nvme/fabrics.c | 67 ++++++++++++++++++++++------------------------------- 1 file changed, 29 insertions(+), 38 deletions(-) --- a/src/nvme/fabrics.c +++ b/src/nvme/fabrics.c @@ -786,54 +786,27 @@ int nvmf_get_discovery_log(nvme_ctrl_t c int max_retries) { nvme_root_t r = c->s && c->s->h ? c->s->h->r : NULL; - struct nvmf_discovery_log *log; - int hdr, ret, retries = 0; + struct nvmf_discovery_log *log = NULL; + int ret, retries = 0; const char *name = nvme_ctrl_get_name(c); uint64_t genctr, numrec; unsigned int size; - hdr = sizeof(struct nvmf_discovery_log); - log = malloc(hdr); - if (!log) { - nvme_msg(r, LOG_ERR, - "could not allocate memory for discovery log header\n"); - errno = ENOMEM; - return -1; - } - memset(log, 0, hdr); - - nvme_msg(r, LOG_DEBUG, "%s: discover length %d\n", name, 0x100); - ret = nvme_discovery_log(nvme_ctrl_get_fd(c), 0x100, log, true); - if (ret) { - nvme_msg(r, LOG_INFO, "%s: discover failed, error %d\n", - name, errno); - goto out_free_log; - } - do { - numrec = le64_to_cpu(log->numrec); - genctr = le64_to_cpu(log->genctr); - - if (numrec == 0) { - *logp = log; - return 0; - } - - size = sizeof(struct nvmf_discovery_log) + - sizeof(struct nvmf_disc_log_entry) * (numrec); + size = sizeof(struct nvmf_discovery_log); free(log); - log = malloc(size); + log = calloc(1, size); if (!log) { nvme_msg(r, LOG_ERR, - "could not alloc memory for discovery log page\n"); + "could not allocate memory for discovery log header\n"); errno = ENOMEM; return -1; } - memset(log, 0, size); - nvme_msg(r, LOG_DEBUG, "%s: discover length %d\n", name, size); - ret = nvme_discovery_log(nvme_ctrl_get_fd(c), size, log, false); + nvme_msg(r, LOG_DEBUG, "%s: get header (try %d/%d)\n", + name, retries, max_retries); + ret = nvme_discovery_log(nvme_ctrl_get_fd(c), size, log, true); if (ret) { nvme_msg(r, LOG_INFO, "%s: discover try %d/%d failed, error %d\n", @@ -841,11 +814,29 @@ int nvmf_get_discovery_log(nvme_ctrl_t c goto out_free_log; } + numrec = le64_to_cpu(log->numrec); genctr = le64_to_cpu(log->genctr); + + if (numrec == 0) + break; + + size = sizeof(struct nvmf_discovery_log) + + sizeof(struct nvmf_disc_log_entry) * numrec; + + free(log); + log = calloc(1, size); + if (!log) { + nvme_msg(r, LOG_ERR, + "could not alloc memory for discovery log page\n"); + errno = ENOMEM; + return -1; + } + nvme_msg(r, LOG_DEBUG, - "%s: discover genctr %" PRIu64 ", retry\n", - name, genctr); - ret = nvme_discovery_log(nvme_ctrl_get_fd(c), hdr, log, true); + "%s: get header and %" PRIu64 + " records (length %d genctr %" PRIu64 ")\n", + name, numrec, size, genctr); + ret = nvme_discovery_log(nvme_ctrl_get_fd(c), size, log, false); if (ret) { nvme_msg(r, LOG_INFO, "%s: discover try %d/%d failed, error %d\n",
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor