]> www.infradead.org Git - users/sagi/libnvme.git/commitdiff
fabrics: have nvmf_get_discovery_log() call nvmf_get_discovery_wargs()
authorCaleb Sander <csander@purestorage.com>
Tue, 8 Aug 2023 00:59:10 +0000 (18:59 -0600)
committerDaniel Wagner <wagi@monom.org>
Tue, 7 Nov 2023 07:06:49 +0000 (08:06 +0100)
There is a lot of duplicated code between nvmf_get_discovery_log()
and nvmf_get_discovery_wargs().
Since nvmf_get_discovery_wargs() is more general,
use it to implement nvmf_get_discovery_log().

Signed-off-by: Caleb Sander <csander@purestorage.com>
src/nvme/fabrics.c

index 6617f7b615a5eb29edb57312581fc6ef703b515c..2ecf1b001b07add62167b56281b62bdaae8e887c 100644 (file)
@@ -1170,34 +1170,15 @@ static void sanitize_discovery_log_entry(struct nvmf_disc_log_entry *e)
 int nvmf_get_discovery_log(nvme_ctrl_t c, struct nvmf_discovery_log **logp,
                           int max_retries)
 {
-       struct nvmf_discovery_log *log;
-
-       struct nvme_get_log_args args = {
-               .args_size = sizeof(args),
-               .fd = nvme_ctrl_get_fd(c),
-               .nsid = NVME_NSID_NONE,
-               .lsp = NVMF_LOG_DISC_LSP_NONE,
-               .lsi = NVME_LOG_LSI_NONE,
-               .uuidx = NVME_UUID_NONE,
+       struct nvme_get_discovery_args args = {
+               .c = c,
+               .max_retries = max_retries,
                .timeout = NVME_DEFAULT_IOCTL_TIMEOUT,
-               .result = NULL,
-               .lid = NVME_LOG_LID_DISCOVER,
-               .log = NULL,
-               .len = 0,
-               .csi = NVME_CSI_NVM,
-               .rae = false,
-               .ot = false,
+               .lsp = NVMF_LOG_DISC_LSP_NONE,
        };
 
-       log = nvme_discovery_log(c, &args, max_retries);
-       if (!log)
-               return -1;
-
-       for (int i = 0; i < le64_to_cpu(log->numrec); i++)
-               sanitize_discovery_log_entry(&log->entries[i]);
-
-       *logp = log;
-       return 0;
+       *logp = nvmf_get_discovery_wargs(&args);
+       return *logp ? 0 : -1;
 }
 
 struct nvmf_discovery_log *nvmf_get_discovery_wargs(struct nvme_get_discovery_args *args)