diff --git a/mk/spdk.lib_deps.mk b/mk/spdk.lib_deps.mk index d6cf411c7..4a5c971ec 100644 --- a/mk/spdk.lib_deps.mk +++ b/mk/spdk.lib_deps.mk @@ -130,22 +130,22 @@ DEPDIRS-bdev_split := $(BDEV_DEPS) DEPDIRS-bdev_aio := $(BDEV_DEPS_THREAD) DEPDIRS-bdev_compress := $(BDEV_DEPS_THREAD) reduce +DEPDIRS-bdev_crypto := $(BDEV_DEPS_THREAD) DEPDIRS-bdev_delay := $(BDEV_DEPS_THREAD) +DEPDIRS-bdev_iscsi := $(BDEV_DEPS_THREAD) DEPDIRS-bdev_null := $(BDEV_DEPS_THREAD) +DEPDIRS-bdev_nvme = $(BDEV_DEPS_THREAD) nvme +DEPDIRS-bdev_ocf := $(BDEV_DEPS_THREAD) DEPDIRS-bdev_passthru := $(BDEV_DEPS_THREAD) +DEPDIRS-bdev_pmem := $(BDEV_DEPS_THREAD) +DEPDIRS-bdev_raid := $(BDEV_DEPS_THREAD) +DEPDIRS-bdev_rbd := $(BDEV_DEPS_THREAD) DEPDIRS-bdev_uring := $(BDEV_DEPS_THREAD) DEPDIRS-bdev_zone_block := $(BDEV_DEPS_THREAD) ifeq ($(OS),Linux) DEPDIRS-bdev_ftl := $(BDEV_DEPS_THREAD) ftl endif -DEPDIRS-bdev_crypto := $(BDEV_DEPS_CONF_THREAD) -DEPDIRS-bdev_iscsi := $(BDEV_DEPS_CONF_THREAD) -DEPDIRS-bdev_nvme = $(BDEV_DEPS_CONF_THREAD) nvme -DEPDIRS-bdev_ocf := $(BDEV_DEPS_CONF_THREAD) -DEPDIRS-bdev_pmem := $(BDEV_DEPS_CONF_THREAD) -DEPDIRS-bdev_raid := $(BDEV_DEPS_CONF_THREAD) -DEPDIRS-bdev_rbd := $(BDEV_DEPS_CONF_THREAD) DEPDIRS-bdev_virtio := $(BDEV_DEPS_CONF_THREAD) virtio # module/event diff --git a/module/bdev/crypto/vbdev_crypto.c b/module/bdev/crypto/vbdev_crypto.c index cdb293927..42f455701 100644 --- a/module/bdev/crypto/vbdev_crypto.c +++ b/module/bdev/crypto/vbdev_crypto.c @@ -34,7 +34,6 @@ #include "vbdev_crypto.h" #include "spdk/env.h" -#include "spdk/conf.h" #include "spdk/endian.h" #include "spdk/thread.h" #include "spdk/bdev_module.h" @@ -1550,72 +1549,12 @@ create_crypto_disk(const char *bdev_name, const char *vbdev_name, static int vbdev_crypto_init(void) { - struct spdk_conf_section *sp = NULL; - const char *conf_bdev_name = NULL; - const char *conf_vbdev_name = NULL; - const char *crypto_pmd = NULL; - int i; int rc = 0; - const char *key = NULL; - const char *cipher = NULL; - const char *key2 = NULL; /* Fully configure both SW and HW drivers. */ rc = vbdev_crypto_init_crypto_drivers(); if (rc) { SPDK_ERRLOG("Error setting up crypto devices\n"); - return rc; - } - - sp = spdk_conf_find_section(NULL, "crypto"); - if (sp == NULL) { - return 0; - } - - for (i = 0; ; i++) { - - if (!spdk_conf_section_get_nval(sp, "CRY", i)) { - break; - } - - conf_bdev_name = spdk_conf_section_get_nmval(sp, "CRY", i, 0); - if (!conf_bdev_name) { - SPDK_ERRLOG("crypto configuration missing bdev name\n"); - return -EINVAL; - } - - conf_vbdev_name = spdk_conf_section_get_nmval(sp, "CRY", i, 1); - if (!conf_vbdev_name) { - SPDK_ERRLOG("crypto configuration missing crypto_bdev name\n"); - return -EINVAL; - } - - key = spdk_conf_section_get_nmval(sp, "CRY", i, 2); - if (!key) { - SPDK_ERRLOG("crypto configuration missing crypto_bdev key\n"); - return -EINVAL; - } - SPDK_NOTICELOG("WARNING: You are storing your key in a plain text file!!\n"); - - crypto_pmd = spdk_conf_section_get_nmval(sp, "CRY", i, 3); - if (!crypto_pmd) { - SPDK_ERRLOG("crypto configuration missing driver type\n"); - return -EINVAL; - } - - /* These are optional. */ - cipher = spdk_conf_section_get_nmval(sp, "CRY", i, 4); - if (cipher == NULL) { - cipher = AES_CBC; - } - key2 = spdk_conf_section_get_nmval(sp, "CRY", i, 5); - - /* Note: config file options do not support QAT AES_XTS, use RPC */ - rc = vbdev_crypto_insert_name(conf_bdev_name, conf_vbdev_name, - crypto_pmd, key, cipher, key2); - if (rc != 0) { - return rc; - } } return rc; @@ -1690,22 +1629,6 @@ vbdev_crypto_get_ctx_size(void) return sizeof(struct crypto_bdev_io); } -/* Called when SPDK wants to save the current config of this vbdev module to - * a file. - */ -static void -vbdev_crypto_get_spdk_running_config(FILE *fp) -{ - struct bdev_names *names = NULL; - fprintf(fp, "\n[crypto]\n"); - TAILQ_FOREACH(names, &g_bdev_names, link) { - fprintf(fp, " crypto %s %s ", names->bdev_name, names->vbdev_name); - fprintf(fp, "\n"); - } - - fprintf(fp, "\n"); -} - static void vbdev_crypto_base_bdev_hotremove_cb(struct spdk_bdev *bdev_find) { @@ -1752,7 +1675,6 @@ static const struct spdk_bdev_fn_table vbdev_crypto_fn_table = { static struct spdk_bdev_module crypto_if = { .name = "crypto", .module_init = vbdev_crypto_init, - .config_text = vbdev_crypto_get_spdk_running_config, .get_ctx_size = vbdev_crypto_get_ctx_size, .examine_config = vbdev_crypto_examine, .module_fini = vbdev_crypto_finish, diff --git a/module/bdev/iscsi/bdev_iscsi.c b/module/bdev/iscsi/bdev_iscsi.c index b61b0209c..8ef640837 100644 --- a/module/bdev/iscsi/bdev_iscsi.c +++ b/module/bdev/iscsi/bdev_iscsi.c @@ -34,7 +34,6 @@ #include "spdk/stdinc.h" #include "spdk/bdev.h" -#include "spdk/conf.h" #include "spdk/env.h" #include "spdk/fd.h" #include "spdk/thread.h" @@ -175,7 +174,6 @@ static struct spdk_bdev_module g_iscsi_bdev_module = { .module_init = bdev_iscsi_initialize, .module_fini = bdev_iscsi_finish, .get_ctx_size = bdev_iscsi_get_ctx_size, - .async_init = true, }; SPDK_BDEV_MODULE_REGISTER(iscsi, &g_iscsi_bdev_module); @@ -884,53 +882,10 @@ delete_iscsi_disk(struct spdk_bdev *bdev, spdk_delete_iscsi_complete cb_fn, void spdk_bdev_unregister(bdev, cb_fn, cb_arg); } -static void -bdev_iscsi_initialize_cb(void *cb_arg, struct spdk_bdev *bdev, int status) -{ - if (TAILQ_EMPTY(&g_iscsi_conn_req)) { - spdk_bdev_module_init_done(&g_iscsi_bdev_module); - } -} - static int bdev_iscsi_initialize(void) { - struct spdk_conf_section *sp; - - const char *url, *bdev_name, *initiator_iqn; - int i, rc; - - sp = spdk_conf_find_section(NULL, "iSCSI_Initiator"); - if (sp == NULL) { - spdk_bdev_module_init_done(&g_iscsi_bdev_module); - return 0; - } - - initiator_iqn = spdk_conf_section_get_val(sp, "initiator_name"); - if (!initiator_iqn) { - initiator_iqn = DEFAULT_INITIATOR_NAME; - } - - rc = 0; - for (i = 0; (url = spdk_conf_section_get_nmval(sp, "URL", i, 0)) != NULL; i++) { - bdev_name = spdk_conf_section_get_nmval(sp, "URL", i, 1); - if (bdev_name == NULL) { - SPDK_ERRLOG("no bdev name specified for URL %s\n", url); - rc = -EINVAL; - break; - } - - rc = create_iscsi_disk(bdev_name, url, initiator_iqn, bdev_iscsi_initialize_cb, NULL); - if (rc) { - break; - } - } - - if (i == 0) { - spdk_bdev_module_init_done(&g_iscsi_bdev_module); - } - - return rc; + return 0; } SPDK_LOG_REGISTER_COMPONENT(iscsi_init) diff --git a/module/bdev/nvme/bdev_nvme.c b/module/bdev/nvme/bdev_nvme.c index 6790bc63a..837a325e0 100644 --- a/module/bdev/nvme/bdev_nvme.c +++ b/module/bdev/nvme/bdev_nvme.c @@ -37,7 +37,6 @@ #include "bdev_ocssd.h" #include "spdk/config.h" -#include "spdk/conf.h" #include "spdk/endian.h" #include "spdk/bdev.h" #include "spdk/json.h" @@ -53,7 +52,6 @@ #define SPDK_BDEV_NVME_DEFAULT_DELAY_CMD_SUBMIT true -static void bdev_nvme_get_spdk_running_config(FILE *fp); static int bdev_nvme_config_json(struct spdk_json_write_ctx *w); struct nvme_bdev_io { @@ -131,7 +129,6 @@ static bool g_nvme_hotplug_enabled = false; static struct spdk_thread *g_bdev_nvme_init_thread; static struct spdk_poller *g_hotplug_poller; static struct spdk_nvme_probe_ctx *g_hotplug_probe_ctx; -static char *g_nvme_hostnqn = NULL; static void nvme_ctrlr_populate_namespaces(struct nvme_bdev_ctrlr *nvme_bdev_ctrlr, struct nvme_async_probe_ctx *ctx); @@ -223,7 +220,6 @@ static struct spdk_bdev_module nvme_if = { .async_fini = true, .module_init = bdev_nvme_library_init, .module_fini = bdev_nvme_library_fini, - .config_text = bdev_nvme_get_spdk_running_config, .config_json = bdev_nvme_config_json, .get_ctx_size = bdev_nvme_get_ctx_size, @@ -1128,49 +1124,6 @@ hotplug_probe_cb(void *cb_ctx, const struct spdk_nvme_transport_id *trid, return true; } -static bool -probe_cb(void *cb_ctx, const struct spdk_nvme_transport_id *trid, - struct spdk_nvme_ctrlr_opts *opts) -{ - struct nvme_probe_ctx *ctx = cb_ctx; - - SPDK_DEBUGLOG(bdev_nvme, "Probing device %s\n", trid->traddr); - - if (nvme_bdev_ctrlr_get(trid)) { - SPDK_ERRLOG("A controller with the provided trid (traddr: %s) already exists.\n", - trid->traddr); - return false; - } - - if (trid->trtype == SPDK_NVME_TRANSPORT_PCIE) { - bool claim_device = false; - size_t i; - - for (i = 0; i < ctx->count; i++) { - if (spdk_nvme_transport_id_compare(trid, &ctx->trids[i]) == 0) { - claim_device = true; - break; - } - } - - if (!claim_device) { - SPDK_DEBUGLOG(bdev_nvme, "Not claiming device at %s\n", trid->traddr); - return false; - } - } - - if (ctx->hostnqn) { - snprintf(opts->hostnqn, sizeof(opts->hostnqn), "%s", ctx->hostnqn); - } - - opts->arbitration_burst = (uint8_t)g_opts.arbitration_burst; - opts->low_priority_weight = (uint8_t)g_opts.low_priority_weight; - opts->medium_priority_weight = (uint8_t)g_opts.medium_priority_weight; - opts->high_priority_weight = (uint8_t)g_opts.high_priority_weight; - - return true; -} - static void nvme_abort_cpl(void *ctx, const struct spdk_nvme_cpl *cpl) { @@ -2020,215 +1973,13 @@ bdev_nvme_delete(const char *name) static int bdev_nvme_library_init(void) { - struct nvme_bdev_ctrlr *nvme_bdev_ctrlr; - struct spdk_conf_section *sp; - const char *val; - int rc = 0; - int64_t intval = 0; - size_t i; - struct nvme_probe_ctx *probe_ctx = NULL; - int retry_count; - uint32_t local_nvme_num = 0; - int64_t hotplug_period; - bool hotplug_enabled = g_nvme_hotplug_enabled; - g_bdev_nvme_init_thread = spdk_get_thread(); spdk_io_device_register(&g_nvme_bdev_ctrlrs, bdev_nvme_poll_group_create_cb, bdev_nvme_poll_group_destroy_cb, sizeof(struct nvme_bdev_poll_group), "bdev_nvme_poll_groups"); - sp = spdk_conf_find_section(NULL, "Nvme"); - if (sp == NULL) { - goto end; - } - - probe_ctx = calloc(1, sizeof(*probe_ctx)); - if (probe_ctx == NULL) { - SPDK_ERRLOG("Failed to allocate probe_ctx\n"); - rc = -1; - goto end; - } - - retry_count = spdk_conf_section_get_intval(sp, "RetryCount"); - if (retry_count >= 0) { - g_opts.retry_count = retry_count; - } - - val = spdk_conf_section_get_val(sp, "TimeoutUsec"); - if (val != NULL) { - intval = spdk_strtoll(val, 10); - if (intval < 0) { - SPDK_ERRLOG("Invalid TimeoutUsec value\n"); - rc = -1; - goto end; - } - } - - g_opts.timeout_us = intval; - - if (g_opts.timeout_us > 0) { - val = spdk_conf_section_get_val(sp, "ActionOnTimeout"); - if (val != NULL) { - if (!strcasecmp(val, "Reset")) { - g_opts.action_on_timeout = SPDK_BDEV_NVME_TIMEOUT_ACTION_RESET; - } else if (!strcasecmp(val, "Abort")) { - g_opts.action_on_timeout = SPDK_BDEV_NVME_TIMEOUT_ACTION_ABORT; - } - } - } - - intval = spdk_conf_section_get_intval(sp, "AdminPollRate"); - if (intval > 0) { - g_opts.nvme_adminq_poll_period_us = intval; - } - - intval = spdk_conf_section_get_intval(sp, "IOPollRate"); - if (intval > 0) { - g_opts.nvme_ioq_poll_period_us = intval; - } - - if (spdk_process_is_primary()) { - hotplug_enabled = spdk_conf_section_get_boolval(sp, "HotplugEnable", false); - } - - hotplug_period = spdk_conf_section_get_intval(sp, "HotplugPollRate"); - if (hotplug_period < 0) { - hotplug_period = 0; - } - - g_nvme_hostnqn = spdk_conf_section_get_val(sp, "HostNQN"); - probe_ctx->hostnqn = g_nvme_hostnqn; - - g_opts.delay_cmd_submit = spdk_conf_section_get_boolval(sp, "DelayCmdSubmit", - SPDK_BDEV_NVME_DEFAULT_DELAY_CMD_SUBMIT); - - for (i = 0; i < NVME_MAX_CONTROLLERS; i++) { - val = spdk_conf_section_get_nmval(sp, "TransportID", i, 0); - if (val == NULL) { - break; - } - - rc = spdk_nvme_transport_id_parse(&probe_ctx->trids[i], val); - if (rc < 0) { - SPDK_ERRLOG("Unable to parse TransportID: %s\n", val); - rc = -1; - goto end; - } - - rc = spdk_nvme_host_id_parse(&probe_ctx->hostids[i], val); - if (rc < 0) { - SPDK_ERRLOG("Unable to parse HostID: %s\n", val); - rc = -1; - goto end; - } - - val = spdk_conf_section_get_nmval(sp, "TransportID", i, 1); - if (val == NULL) { - SPDK_ERRLOG("No name provided for TransportID\n"); - rc = -1; - goto end; - } - - probe_ctx->names[i] = val; - - val = spdk_conf_section_get_nmval(sp, "TransportID", i, 2); - if (val != NULL) { - rc = spdk_nvme_prchk_flags_parse(&probe_ctx->prchk_flags[i], val); - if (rc < 0) { - SPDK_ERRLOG("Unable to parse prchk: %s\n", val); - rc = -1; - goto end; - } - } - - probe_ctx->count++; - - if (probe_ctx->trids[i].trtype != SPDK_NVME_TRANSPORT_PCIE) { - struct spdk_nvme_ctrlr *ctrlr; - struct spdk_nvme_ctrlr_opts opts; - - if (nvme_bdev_ctrlr_get(&probe_ctx->trids[i])) { - SPDK_ERRLOG("A controller with the provided trid (traddr: %s) already exists.\n", - probe_ctx->trids[i].traddr); - rc = -1; - goto end; - } - - if (probe_ctx->trids[i].subnqn[0] == '\0') { - SPDK_ERRLOG("Need to provide subsystem nqn\n"); - rc = -1; - goto end; - } - - spdk_nvme_ctrlr_get_default_ctrlr_opts(&opts, sizeof(opts)); - opts.transport_retry_count = g_opts.retry_count; - - if (probe_ctx->hostnqn != NULL) { - snprintf(opts.hostnqn, sizeof(opts.hostnqn), "%s", probe_ctx->hostnqn); - } - - if (probe_ctx->hostids[i].hostaddr[0] != '\0') { - snprintf(opts.src_addr, sizeof(opts.src_addr), "%s", probe_ctx->hostids[i].hostaddr); - } - - if (probe_ctx->hostids[i].hostsvcid[0] != '\0') { - snprintf(opts.src_svcid, sizeof(opts.src_svcid), "%s", probe_ctx->hostids[i].hostsvcid); - } - - ctrlr = spdk_nvme_connect(&probe_ctx->trids[i], &opts, sizeof(opts)); - if (ctrlr == NULL) { - SPDK_ERRLOG("Unable to connect to provided trid (traddr: %s)\n", - probe_ctx->trids[i].traddr); - rc = -1; - goto end; - } - - rc = nvme_bdev_ctrlr_create(ctrlr, probe_ctx->names[i], &probe_ctx->trids[i], 0); - if (rc) { - goto end; - } - - nvme_bdev_ctrlr = nvme_bdev_ctrlr_get(&probe_ctx->trids[i]); - if (!nvme_bdev_ctrlr) { - SPDK_ERRLOG("Failed to find new NVMe controller\n"); - rc = -ENODEV; - goto end; - } - - nvme_ctrlr_populate_namespaces(nvme_bdev_ctrlr, NULL); - } else { - local_nvme_num++; - } - } - - if (local_nvme_num > 0) { - /* used to probe local NVMe device */ - if (spdk_nvme_probe(NULL, probe_ctx, probe_cb, attach_cb, remove_cb)) { - rc = -1; - goto end; - } - - for (i = 0; i < probe_ctx->count; i++) { - if (probe_ctx->trids[i].trtype != SPDK_NVME_TRANSPORT_PCIE) { - continue; - } - - if (!nvme_bdev_ctrlr_get(&probe_ctx->trids[i])) { - SPDK_ERRLOG("NVMe SSD \"%s\" could not be found.\n", probe_ctx->trids[i].traddr); - SPDK_ERRLOG("Check PCIe BDF and that it is attached to UIO/VFIO driver.\n"); - } - } - } - - rc = bdev_nvme_set_hotplug(hotplug_enabled, hotplug_period, NULL, NULL); - if (rc) { - SPDK_ERRLOG("Failed to setup hotplug (%d): %s", rc, spdk_strerror(rc)); - rc = -1; - } -end: - free(probe_ctx); - return rc; + return 0; } static void @@ -2913,107 +2664,6 @@ bdev_nvme_abort(struct nvme_bdev_ns *nvme_ns, struct nvme_io_channel *nvme_ch, return rc; } -static void -bdev_nvme_get_spdk_running_config(FILE *fp) -{ - struct nvme_bdev_ctrlr *nvme_bdev_ctrlr; - - fprintf(fp, "\n[Nvme]"); - fprintf(fp, "\n" - "# NVMe Device Whitelist\n" - "# Users may specify which NVMe devices to claim by their transport id.\n" - "# See spdk_nvme_transport_id_parse() in spdk/nvme.h for the correct format.\n" - "# The second argument is the assigned name, which can be referenced from\n" - "# other sections in the configuration file. For NVMe devices, a namespace\n" - "# is automatically appended to each name in the format nY, where\n" - "# Y is the NSID (starts at 1).\n"); - - TAILQ_FOREACH(nvme_bdev_ctrlr, &g_nvme_bdev_ctrlrs, tailq) { - const char *trtype; - const char *prchk_flags; - - trtype = spdk_nvme_transport_id_trtype_str(nvme_bdev_ctrlr->connected_trid->trtype); - if (!trtype) { - continue; - } - - if (nvme_bdev_ctrlr->connected_trid->trtype == SPDK_NVME_TRANSPORT_PCIE) { - fprintf(fp, "TransportID \"trtype:%s traddr:%s\" %s\n", - trtype, - nvme_bdev_ctrlr->connected_trid->traddr, nvme_bdev_ctrlr->name); - } else { - const char *adrfam; - - adrfam = spdk_nvme_transport_id_adrfam_str(nvme_bdev_ctrlr->connected_trid->adrfam); - prchk_flags = spdk_nvme_prchk_flags_str(nvme_bdev_ctrlr->prchk_flags); - - if (adrfam) { - fprintf(fp, "TransportID \"trtype:%s adrfam:%s traddr:%s trsvcid:%s subnqn:%s\" %s", - trtype, adrfam, - nvme_bdev_ctrlr->connected_trid->traddr, nvme_bdev_ctrlr->connected_trid->trsvcid, - nvme_bdev_ctrlr->connected_trid->subnqn, nvme_bdev_ctrlr->name); - } else { - fprintf(fp, "TransportID \"trtype:%s traddr:%s trsvcid:%s subnqn:%s\" %s", - trtype, - nvme_bdev_ctrlr->connected_trid->traddr, nvme_bdev_ctrlr->connected_trid->trsvcid, - nvme_bdev_ctrlr->connected_trid->subnqn, nvme_bdev_ctrlr->name); - } - - if (prchk_flags) { - fprintf(fp, " \"%s\"\n", prchk_flags); - } else { - fprintf(fp, "\n"); - } - } - } - - fprintf(fp, "\n" - "# The number of attempts per I/O when an I/O fails. Do not include\n" - "# this key to get the default behavior.\n"); - fprintf(fp, "RetryCount %d\n", g_opts.retry_count); - fprintf(fp, "\n" - "# Timeout for each command, in microseconds. If 0, don't track timeouts.\n"); - fprintf(fp, "TimeoutUsec %"PRIu64"\n", g_opts.timeout_us); - - fprintf(fp, "\n" - "# Action to take on command time out. Only valid when Timeout is greater\n" - "# than 0. This may be 'Reset' to reset the controller, 'Abort' to abort\n" - "# the command, or 'None' to just print a message but do nothing.\n" - "# Admin command timeouts will always result in a reset.\n"); - switch (g_opts.action_on_timeout) { - case SPDK_BDEV_NVME_TIMEOUT_ACTION_NONE: - fprintf(fp, "ActionOnTimeout None\n"); - break; - case SPDK_BDEV_NVME_TIMEOUT_ACTION_RESET: - fprintf(fp, "ActionOnTimeout Reset\n"); - break; - case SPDK_BDEV_NVME_TIMEOUT_ACTION_ABORT: - fprintf(fp, "ActionOnTimeout Abort\n"); - break; - } - - fprintf(fp, "\n" - "# Set how often the admin queue is polled for asynchronous events.\n" - "# Units in microseconds.\n"); - fprintf(fp, "AdminPollRate %"PRIu64"\n", g_opts.nvme_adminq_poll_period_us); - fprintf(fp, "IOPollRate %" PRIu64"\n", g_opts.nvme_ioq_poll_period_us); - fprintf(fp, "\n" - "# Disable handling of hotplug (runtime insert and remove) events,\n" - "# users can set to Yes if want to enable it.\n" - "# Default: No\n"); - fprintf(fp, "HotplugEnable %s\n", g_nvme_hotplug_enabled ? "Yes" : "No"); - fprintf(fp, "\n" - "# Set how often the hotplug is processed for insert and remove events." - "# Units in microseconds.\n"); - fprintf(fp, "HotplugPollRate %"PRIu64"\n", g_nvme_hotplug_poll_period_us); - if (g_nvme_hostnqn) { - fprintf(fp, "HostNQN %s\n", g_nvme_hostnqn); - } - fprintf(fp, "DelayCmdSubmit %s\n", g_opts.delay_cmd_submit ? "True" : "False"); - - fprintf(fp, "\n"); -} - static void nvme_ctrlr_config_json_standard_namespace(struct spdk_json_write_ctx *w, struct nvme_bdev_ns *ns) { diff --git a/module/bdev/ocf/vbdev_ocf.c b/module/bdev/ocf/vbdev_ocf.c index 825a50d5e..d8a106e37 100644 --- a/module/bdev/ocf/vbdev_ocf.c +++ b/module/bdev/ocf/vbdev_ocf.c @@ -42,7 +42,6 @@ #include "vbdev_ocf.h" #include "spdk/bdev_module.h" -#include "spdk/conf.h" #include "spdk/thread.h" #include "spdk/string.h" #include "spdk/log.h" @@ -1260,10 +1259,7 @@ error_free: static int vbdev_ocf_init(void) { - const char *vbdev_name, *modename, *cache_line_size, *cache_name, *core_name; - struct spdk_conf_section *sp; int status; - uint64_t cache_line_size_uint64; status = vbdev_ocf_ctx_init(); if (status) { @@ -1278,53 +1274,6 @@ vbdev_ocf_init(void) return status; } - sp = spdk_conf_find_section(NULL, "OCF"); - if (sp == NULL) { - return 0; - } - - for (int i = 0; ; i++) { - if (!spdk_conf_section_get_nval(sp, "OCF", i)) { - break; - } - - vbdev_name = spdk_conf_section_get_nmval(sp, "OCF", i, 0); - if (!vbdev_name) { - SPDK_ERRLOG("No vbdev name specified\n"); - continue; - } - - modename = spdk_conf_section_get_nmval(sp, "OCF", i, 1); - if (!modename) { - SPDK_ERRLOG("No modename specified for OCF vbdev '%s'\n", vbdev_name); - continue; - } - - cache_line_size = spdk_conf_section_get_nmval(sp, "OCF", i, 2); - if (!cache_line_size) { - SPDK_ERRLOG("No cache line size specified for OCF vbdev '%s'\n", vbdev_name); - continue; - } - cache_line_size_uint64 = strtoull(cache_line_size, NULL, 10); - - cache_name = spdk_conf_section_get_nmval(sp, "OCF", i, 3); - if (!cache_name) { - SPDK_ERRLOG("No cache device specified for OCF vbdev '%s'\n", vbdev_name); - continue; - } - - core_name = spdk_conf_section_get_nmval(sp, "OCF", i, 4); - if (!core_name) { - SPDK_ERRLOG("No core devices specified for OCF vbdev '%s'\n", vbdev_name); - continue; - } - - status = init_vbdev(vbdev_name, modename, cache_line_size_uint64, cache_name, core_name, false); - if (status) { - SPDK_ERRLOG("Config initialization failed with code: %d\n", status); - } - } - return status; } @@ -1797,7 +1746,6 @@ static struct spdk_bdev_module ocf_if = { .module_init = vbdev_ocf_init, .fini_start = fini_start, .module_fini = vbdev_ocf_module_fini, - .config_text = NULL, .get_ctx_size = vbdev_ocf_get_ctx_size, .examine_config = vbdev_ocf_examine, .examine_disk = vbdev_ocf_examine_disk, diff --git a/module/bdev/pmem/bdev_pmem.c b/module/bdev/pmem/bdev_pmem.c index 253c9c99c..8e7b6c914 100644 --- a/module/bdev/pmem/bdev_pmem.c +++ b/module/bdev/pmem/bdev_pmem.c @@ -31,7 +31,6 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include "spdk/conf.h" #include "spdk/string.h" #include "spdk/likely.h" #include "spdk/util.h" @@ -401,41 +400,6 @@ delete_pmem_disk(struct spdk_bdev *bdev, spdk_delete_pmem_complete cb_fn, void * spdk_bdev_unregister(bdev, cb_fn, cb_arg); } -static void -bdev_pmem_read_conf(void) -{ - struct spdk_conf_section *sp; - struct spdk_bdev *bdev; - const char *pmem_file; - const char *bdev_name; - int i; - - sp = spdk_conf_find_section(NULL, "Pmem"); - if (sp == NULL) { - return; - } - - for (i = 0; ; i++) { - if (!spdk_conf_section_get_nval(sp, "Blk", i)) { - break; - } - - pmem_file = spdk_conf_section_get_nmval(sp, "Blk", i, 0); - if (pmem_file == NULL) { - SPDK_ERRLOG("Pmem: missing filename\n"); - continue; - } - - bdev_name = spdk_conf_section_get_nmval(sp, "Blk", i, 1); - if (bdev_name == NULL) { - SPDK_ERRLOG("Pmem: missing bdev name\n"); - continue; - } - - create_pmem_disk(pmem_file, bdev_name, &bdev); - } -} - static int bdev_pmem_initialize(void) { @@ -452,8 +416,6 @@ bdev_pmem_initialize(void) #endif spdk_io_device_register(&g_pmem_disks, bdev_pmem_create_cb, bdev_pmem_destroy_cb, 0, "pmem_bdev"); - bdev_pmem_read_conf(); - return 0; } diff --git a/module/bdev/raid/bdev_raid.c b/module/bdev/raid/bdev_raid.c index 1784f3bc3..b1b314852 100644 --- a/module/bdev/raid/bdev_raid.c +++ b/module/bdev/raid/bdev_raid.c @@ -34,7 +34,6 @@ #include "bdev_raid.h" #include "spdk/env.h" #include "spdk/thread.h" -#include "spdk/conf.h" #include "spdk/log.h" #include "spdk/string.h" #include "spdk/util.h" @@ -904,154 +903,6 @@ raid_bdev_level_to_str(enum raid_level level) return ""; } -/* - * brief: - * raid_bdev_parse_raid is used to parse the raid bdev from config file based on - * pre-defined raid bdev format in config file. - * Format of config file: - * [RAID1] - * Name raid1 - * StripSize 64 - * NumDevices 2 - * RaidLevel 0 - * Devices Nvme0n1 Nvme1n1 - * - * [RAID2] - * Name raid2 - * StripSize 64 - * NumDevices 3 - * RaidLevel 0 - * Devices Nvme2n1 Nvme3n1 Nvme4n1 - * - * params: - * conf_section - pointer to config section - * returns: - * 0 - success - * non zero - failure - */ -static int -raid_bdev_parse_raid(struct spdk_conf_section *conf_section) -{ - const char *raid_name; - uint32_t strip_size; - uint8_t num_base_bdevs; - const char *raid_level_str; - enum raid_level level; - const char *base_bdev_name; - struct raid_bdev_config *raid_cfg; - int rc, i, val; - - raid_name = spdk_conf_section_get_val(conf_section, "Name"); - if (raid_name == NULL) { - SPDK_ERRLOG("raid_name is null\n"); - return -EINVAL; - } - - val = spdk_conf_section_get_intval(conf_section, "StripSize"); - if (val < 0) { - return -EINVAL; - } - strip_size = val; - - val = spdk_conf_section_get_intval(conf_section, "NumDevices"); - if (val < 0) { - return -EINVAL; - } - num_base_bdevs = val; - - raid_level_str = spdk_conf_section_get_val(conf_section, "RaidLevel"); - if (raid_level_str == NULL) { - SPDK_ERRLOG("Missing RaidLevel\n"); - return -EINVAL; - } - level = raid_bdev_parse_raid_level(raid_level_str); - if (level == INVALID_RAID_LEVEL) { - SPDK_ERRLOG("Invalid RaidLevel\n"); - return -EINVAL; - } - - SPDK_DEBUGLOG(bdev_raid, "%s %" PRIu32 " %u %u\n", - raid_name, strip_size, num_base_bdevs, level); - - rc = raid_bdev_config_add(raid_name, strip_size, num_base_bdevs, level, - &raid_cfg); - if (rc != 0) { - SPDK_ERRLOG("Failed to add raid bdev config\n"); - return rc; - } - - for (i = 0; true; i++) { - base_bdev_name = spdk_conf_section_get_nmval(conf_section, "Devices", 0, i); - if (base_bdev_name == NULL) { - break; - } - if (i >= num_base_bdevs) { - raid_bdev_config_cleanup(raid_cfg); - SPDK_ERRLOG("Number of devices mentioned is more than count\n"); - return -EINVAL; - } - - rc = raid_bdev_config_add_base_bdev(raid_cfg, base_bdev_name, i); - if (rc != 0) { - raid_bdev_config_cleanup(raid_cfg); - SPDK_ERRLOG("Failed to add base bdev to raid bdev config\n"); - return rc; - } - } - - if (i != raid_cfg->num_base_bdevs) { - raid_bdev_config_cleanup(raid_cfg); - SPDK_ERRLOG("Number of devices mentioned is less than count\n"); - return -EINVAL; - } - - rc = raid_bdev_create(raid_cfg); - if (rc != 0) { - raid_bdev_config_cleanup(raid_cfg); - SPDK_ERRLOG("Failed to create raid bdev\n"); - return rc; - } - - rc = raid_bdev_add_base_devices(raid_cfg); - if (rc != 0) { - SPDK_ERRLOG("Failed to add any base bdev to raid bdev\n"); - /* Config is not removed in this case. */ - } - - return 0; -} - -/* - * brief: - * raid_bdev_parse_config is used to find the raid bdev config section and parse it - * Format of config file: - * params: - * none - * returns: - * 0 - success - * non zero - failure - */ -static int -raid_bdev_parse_config(void) -{ - int ret; - struct spdk_conf_section *conf_section; - - conf_section = spdk_conf_first_section(NULL); - while (conf_section != NULL) { - if (spdk_conf_section_match_prefix(conf_section, "RAID")) { - ret = raid_bdev_parse_raid(conf_section); - if (ret < 0) { - SPDK_ERRLOG("Unable to parse raid bdev section\n"); - return ret; - } - } - conf_section = spdk_conf_next_section(conf_section); - } - - return 0; -} - /* * brief: * raid_bdev_fini_start is called when bdev layer is starting the @@ -1099,48 +950,6 @@ raid_bdev_get_ctx_size(void) return sizeof(struct raid_bdev_io); } -/* - * brief: - * raid_bdev_get_running_config is used to get the configuration options. - * - * params: - * fp - The pointer to a file that will be written to the configuration options. - * returns: - * none - */ -static void -raid_bdev_get_running_config(FILE *fp) -{ - struct raid_bdev *raid_bdev; - struct raid_base_bdev_info *base_info; - int index = 1; - - TAILQ_FOREACH(raid_bdev, &g_raid_bdev_configured_list, state_link) { - fprintf(fp, - "\n" - "[RAID%d]\n" - " Name %s\n" - " StripSize %" PRIu32 "\n" - " NumDevices %u\n" - " RaidLevel %s\n", - index, raid_bdev->bdev.name, raid_bdev->strip_size_kb, - raid_bdev->num_base_bdevs, - raid_bdev_level_to_str(raid_bdev->level)); - fprintf(fp, - " Devices "); - RAID_FOR_EACH_BASE_BDEV(raid_bdev, base_info) { - if (base_info->bdev) { - fprintf(fp, - "%s ", - base_info->bdev->name); - } - } - fprintf(fp, - "\n"); - index++; - } -} - /* * brief: * raid_bdev_can_claim_bdev is the function to check if this base_bdev can be @@ -1187,7 +996,6 @@ static struct spdk_bdev_module g_raid_if = { .module_fini = raid_bdev_exit, .get_ctx_size = raid_bdev_get_ctx_size, .examine_config = raid_bdev_examine, - .config_text = raid_bdev_get_running_config, .async_init = false, .async_fini = false, }; @@ -1205,18 +1013,6 @@ SPDK_BDEV_MODULE_REGISTER(raid, &g_raid_if) static int raid_bdev_init(void) { - int ret; - - /* Parse config file for raids */ - ret = raid_bdev_parse_config(); - if (ret < 0) { - SPDK_ERRLOG("raid bdev init failed parsing\n"); - raid_bdev_free(); - return ret; - } - - SPDK_DEBUGLOG(bdev_raid, "raid_bdev_init completed successfully\n"); - return 0; } diff --git a/module/bdev/rbd/bdev_rbd.c b/module/bdev/rbd/bdev_rbd.c index a886ad269..21536f4dc 100644 --- a/module/bdev/rbd/bdev_rbd.c +++ b/module/bdev/rbd/bdev_rbd.c @@ -40,7 +40,6 @@ #include #include -#include "spdk/conf.h" #include "spdk/env.h" #include "spdk/bdev.h" #include "spdk/thread.h" @@ -835,77 +834,10 @@ bdev_rbd_group_destroy_cb(void *io_device, void *ctx_buf) static int bdev_rbd_library_init(void) { - int i, rc = 0; - const char *val; - const char *pool_name; - const char *rbd_name; - struct spdk_bdev *bdev; - uint32_t block_size; - long int tmp; - struct spdk_conf_section *sp; - spdk_io_device_register(&rbd_if, bdev_rbd_group_create_cb, bdev_rbd_group_destroy_cb, - sizeof(struct bdev_rbd_group_channel), - "bdev_rbd_poll_groups"); + sizeof(struct bdev_rbd_group_channel), "bdev_rbd_poll_groups"); - sp = spdk_conf_find_section(NULL, "Ceph"); - if (sp == NULL) { - /* - * Ceph section not found. Do not initialize any rbd LUNS. - */ - goto end; - } - - /* Init rbd block devices */ - for (i = 0; ; i++) { - val = spdk_conf_section_get_nval(sp, "Ceph", i); - if (val == NULL) { - break; - } - - /* get the Rbd_pool name */ - pool_name = spdk_conf_section_get_nmval(sp, "Ceph", i, 0); - if (pool_name == NULL) { - SPDK_ERRLOG("Ceph%d: rbd pool name needs to be provided\n", i); - rc = -1; - goto end; - } - - rbd_name = spdk_conf_section_get_nmval(sp, "Ceph", i, 1); - if (rbd_name == NULL) { - SPDK_ERRLOG("Ceph%d: format error\n", i); - rc = -1; - goto end; - } - - val = spdk_conf_section_get_nmval(sp, "Ceph", i, 2); - - if (val == NULL) { - block_size = 512; /* default value */ - } else { - tmp = spdk_strtol(val, 10); - if (tmp <= 0) { - SPDK_ERRLOG("Invalid block size\n"); - rc = -1; - goto end; - } else if (tmp & 0x1ff) { - SPDK_ERRLOG("current block_size = %ld, it should be multiple of 512\n", - tmp); - rc = -1; - goto end; - } - block_size = (uint32_t)tmp; - } - - /* TODO(?): user_id and rbd config values */ - rc = bdev_rbd_create(&bdev, NULL, NULL, pool_name, NULL, rbd_name, block_size); - if (rc) { - goto end; - } - } - -end: - return rc; + return 0; } static void diff --git a/test/unit/lib/bdev/crypto.c/crypto_ut.c b/test/unit/lib/bdev/crypto.c/crypto_ut.c index b48ab34ca..cba1fe020 100644 --- a/test/unit/lib/bdev/crypto.c/crypto_ut.c +++ b/test/unit/lib/bdev/crypto.c/crypto_ut.c @@ -142,12 +142,6 @@ mock_rte_lcore_count(void) /* SPDK stubs */ DEFINE_STUB(spdk_bdev_queue_io_wait, int, (struct spdk_bdev *bdev, struct spdk_io_channel *ch, struct spdk_bdev_io_wait_entry *entry), 0); -DEFINE_STUB(spdk_conf_find_section, struct spdk_conf_section *, - (struct spdk_conf *cp, const char *name), NULL); -DEFINE_STUB(spdk_conf_section_get_nval, char *, - (struct spdk_conf_section *sp, const char *key, int idx), NULL); -DEFINE_STUB(spdk_conf_section_get_nmval, char *, - (struct spdk_conf_section *sp, const char *key, int idx1, int idx2), NULL); DEFINE_STUB_V(spdk_bdev_module_list_add, (struct spdk_bdev_module *bdev_module)); DEFINE_STUB_V(spdk_bdev_free_io, (struct spdk_bdev_io *g_bdev_io)); DEFINE_STUB_V(spdk_bdev_io_put_aux_buf, (struct spdk_bdev_io *bdev_io, void *aux_buf)); diff --git a/test/unit/lib/bdev/pmem/bdev_pmem_ut.c b/test/unit/lib/bdev/pmem/bdev_pmem_ut.c index 8cd51e9f7..46115474d 100644 --- a/test/unit/lib/bdev/pmem/bdev_pmem_ut.c +++ b/test/unit/lib/bdev/pmem/bdev_pmem_ut.c @@ -40,13 +40,6 @@ #include "bdev/pmem/bdev_pmem.c" -DEFINE_STUB(spdk_conf_find_section, struct spdk_conf_section *, - (struct spdk_conf *cp, const char *name), NULL); -DEFINE_STUB(spdk_conf_section_get_nval, char *, - (struct spdk_conf_section *sp, const char *key, int idx), NULL); -DEFINE_STUB(spdk_conf_section_get_nmval, char *, - (struct spdk_conf_section *sp, const char *key, int idx1, int idx2), NULL); - static struct spdk_bdev_module *g_bdev_pmem_module; static int g_bdev_module_cnt; diff --git a/test/unit/lib/bdev/raid/bdev_raid.c/bdev_raid_ut.c b/test/unit/lib/bdev/raid/bdev_raid.c/bdev_raid_ut.c index 6cc2eac80..e5472a756 100644 --- a/test/unit/lib/bdev/raid/bdev_raid.c/bdev_raid_ut.c +++ b/test/unit/lib/bdev/raid/bdev_raid.c/bdev_raid_ut.c @@ -464,75 +464,6 @@ spdk_bdev_module_release_bdev(struct spdk_bdev *bdev) bdev->internal.claim_module = NULL; } -struct spdk_conf_section * -spdk_conf_first_section(struct spdk_conf *cp) -{ - if (g_config_level_create) { - return (void *) 0x1; - } - - return NULL; -} - -bool -spdk_conf_section_match_prefix(const struct spdk_conf_section *sp, const char *name_prefix) -{ - if (g_config_level_create) { - return true; - } - - return false; -} - -char * -spdk_conf_section_get_val(struct spdk_conf_section *sp, const char *key) -{ - struct rpc_bdev_raid_create *req = g_rpc_req; - - if (g_config_level_create) { - if (strcmp(key, "Name") == 0) { - return req->name; - } else if (strcmp(key, "RaidLevel") == 0) { - return (char *)raid_bdev_level_to_str(req->level); - } - } - - return NULL; -} - -int -spdk_conf_section_get_intval(struct spdk_conf_section *sp, const char *key) -{ - struct rpc_bdev_raid_create *req = g_rpc_req; - - if (g_config_level_create) { - if (strcmp(key, "StripSize") == 0) { - return req->strip_size_kb; - } else if (strcmp(key, "NumDevices") == 0) { - return req->base_bdevs.num_base_bdevs; - } - } - - return 0; -} - -char * -spdk_conf_section_get_nmval(struct spdk_conf_section *sp, const char *key, int idx1, int idx2) -{ - struct rpc_bdev_raid_create *req = g_rpc_req; - - if (g_config_level_create) { - if (strcmp(key, "Devices") == 0) { - if (idx2 >= g_max_base_drives) { - return NULL; - } - return req->base_bdevs.base_bdevs[idx2]; - } - } - - return NULL; -} - int spdk_bdev_module_claim_bdev(struct spdk_bdev *bdev, struct spdk_bdev_desc *desc, struct spdk_bdev_module *module) @@ -1101,16 +1032,6 @@ create_raid_bdev_create_req(struct rpc_bdev_raid_create *r, const char *raid_nam g_test_multi_raids = 0; } -static void -create_raid_bdev_create_config(struct rpc_bdev_raid_create *r, const char *raid_name, - uint8_t bbdev_start_idx, bool create_base_bdev) -{ - create_test_req(r, raid_name, bbdev_start_idx, create_base_bdev); - - g_config_level_create = 1; - g_test_multi_raids = 0; -} - static void free_test_req(struct rpc_bdev_raid_create *r) { @@ -2063,111 +1984,6 @@ test_io_type_supported(void) CU_ASSERT(raid_bdev_io_type_supported(NULL, SPDK_BDEV_IO_TYPE_INVALID) == false); } -static void -test_create_raid_from_config(void) -{ - struct rpc_bdev_raid_create req; - struct spdk_bdev *bdev; - struct rpc_bdev_raid_delete destroy_req; - bool can_claim; - struct raid_bdev_config *raid_cfg; - uint8_t base_bdev_slot; - - set_globals(); - create_raid_bdev_create_config(&req, "raid1", 0, true); - CU_ASSERT(raid_bdev_init() == 0); - - verify_raid_config_present("raid1", true); - verify_raid_bdev_present("raid1", true); - - TAILQ_FOREACH(bdev, &g_bdev_list, internal.link) { - raid_bdev_examine(bdev); - } - - can_claim = raid_bdev_can_claim_bdev("Invalid", &raid_cfg, &base_bdev_slot); - CU_ASSERT(can_claim == false); - - verify_raid_config(&req, true); - verify_raid_bdev(&req, true, RAID_BDEV_STATE_ONLINE); - - create_raid_bdev_delete_req(&destroy_req, "raid1", 0); - rpc_bdev_raid_delete(NULL, NULL); - CU_ASSERT(g_rpc_err == 0); - verify_raid_config_present("raid1", false); - verify_raid_bdev_present("raid1", false); - - raid_bdev_exit(); - free_test_req(&req); - base_bdevs_cleanup(); - reset_globals(); -} - -static void -test_create_raid_from_config_invalid_params(void) -{ - struct rpc_bdev_raid_create req; - - set_globals(); - - create_raid_bdev_create_config(&req, "raid1", 0, true); - free(req.name); - req.name = NULL; - CU_ASSERT(raid_bdev_init() != 0); - free_test_req(&req); - verify_raid_config_present("raid1", false); - verify_raid_bdev_present("raid1", false); - - create_raid_bdev_create_config(&req, "raid1", 0, false); - req.strip_size_kb = 1234; - CU_ASSERT(raid_bdev_init() != 0); - free_test_req(&req); - verify_raid_config_present("raid1", false); - verify_raid_bdev_present("raid1", false); - - create_raid_bdev_create_config(&req, "raid1", 0, false); - req.level = INVALID_RAID_LEVEL; - CU_ASSERT(raid_bdev_init() != 0); - free_test_req(&req); - verify_raid_config_present("raid1", false); - verify_raid_bdev_present("raid1", false); - - create_raid_bdev_create_config(&req, "raid1", 0, false); - req.level = INVALID_RAID_LEVEL; - CU_ASSERT(raid_bdev_init() != 0); - free_test_req(&req); - verify_raid_config_present("raid1", false); - verify_raid_bdev_present("raid1", false); - - create_raid_bdev_create_config(&req, "raid1", 0, false); - req.base_bdevs.num_base_bdevs++; - CU_ASSERT(raid_bdev_init() != 0); - req.base_bdevs.num_base_bdevs--; - free_test_req(&req); - verify_raid_config_present("raid1", false); - verify_raid_bdev_present("raid1", false); - - create_raid_bdev_create_config(&req, "raid1", 0, false); - req.base_bdevs.num_base_bdevs--; - CU_ASSERT(raid_bdev_init() != 0); - req.base_bdevs.num_base_bdevs++; - free_test_req(&req); - verify_raid_config_present("raid1", false); - verify_raid_bdev_present("raid1", false); - - if (g_max_base_drives > 1) { - create_raid_bdev_create_config(&req, "raid1", 0, false); - snprintf(req.base_bdevs.base_bdevs[g_max_base_drives - 1], 15, "%s", "Nvme0n1"); - CU_ASSERT(raid_bdev_init() != 0); - free_test_req(&req); - verify_raid_config_present("raid1", false); - verify_raid_bdev_present("raid1", false); - } - - raid_bdev_exit(); - base_bdevs_cleanup(); - reset_globals(); -} - static void test_raid_json_dump_info(void) { @@ -2254,8 +2070,6 @@ int main(int argc, char **argv) CU_ADD_TEST(suite, test_multi_raid_no_io); CU_ADD_TEST(suite, test_multi_raid_with_io); CU_ADD_TEST(suite, test_io_type_supported); - CU_ADD_TEST(suite, test_create_raid_from_config); - CU_ADD_TEST(suite, test_create_raid_from_config_invalid_params); CU_ADD_TEST(suite, test_raid_json_dump_info); CU_ADD_TEST(suite, test_context_size); CU_ADD_TEST(suite, test_raid_level_conversions);