From f6be2427d04e70dafe9d224bda6fa18fe5109816 Mon Sep 17 00:00:00 2001 From: Caleb Sander Date: Mon, 7 Aug 2023 18:59:10 -0600 Subject: [PATCH] fabrics: have nvmf_get_discovery_log() call nvmf_get_discovery_wargs() 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 --- src/nvme/fabrics.c | 31 ++++++------------------------- 1 file changed, 6 insertions(+), 25 deletions(-) diff --git a/src/nvme/fabrics.c b/src/nvme/fabrics.c index 6617f7b6..2ecf1b00 100644 --- a/src/nvme/fabrics.c +++ b/src/nvme/fabrics.c @@ -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) -- 2.50.1