diff --git a/module/bdev/nvme/bdev_nvme.c b/module/bdev/nvme/bdev_nvme.c index 2240b96ef..90e7953e1 100644 --- a/module/bdev/nvme/bdev_nvme.c +++ b/module/bdev/nvme/bdev_nvme.c @@ -2863,7 +2863,6 @@ bdev_nvme_async_poll(void *arg) int bdev_nvme_create(struct spdk_nvme_transport_id *trid, - struct spdk_nvme_host_id *hostid, const char *base_name, const char **names, uint32_t count, @@ -2916,14 +2915,6 @@ bdev_nvme_create(struct spdk_nvme_transport_id *trid, ctx->opts.keep_alive_timeout_ms = g_opts.keep_alive_timeout_ms; ctx->opts.disable_read_ana_log_page = true; - if (hostid->hostaddr[0] != '\0') { - snprintf(ctx->opts.src_addr, sizeof(ctx->opts.src_addr), "%s", hostid->hostaddr); - } - - if (hostid->hostsvcid[0] != '\0') { - snprintf(ctx->opts.src_svcid, sizeof(ctx->opts.src_svcid), "%s", hostid->hostsvcid); - } - if (nvme_ctrlr_get_by_name(base_name) == NULL) { attach_cb = connect_attach_cb; } else { diff --git a/module/bdev/nvme/bdev_nvme.h b/module/bdev/nvme/bdev_nvme.h index d1ee3e065..450155863 100644 --- a/module/bdev/nvme/bdev_nvme.h +++ b/module/bdev/nvme/bdev_nvme.h @@ -203,7 +203,6 @@ int bdev_nvme_set_opts(const struct spdk_bdev_nvme_opts *opts); int bdev_nvme_set_hotplug(bool enabled, uint64_t period_us, spdk_msg_fn cb, void *cb_ctx); int bdev_nvme_create(struct spdk_nvme_transport_id *trid, - struct spdk_nvme_host_id *hostid, const char *base_name, const char **names, uint32_t count, diff --git a/module/bdev/nvme/bdev_nvme_rpc.c b/module/bdev/nvme/bdev_nvme_rpc.c index 704971e53..79e0a09f7 100644 --- a/module/bdev/nvme/bdev_nvme_rpc.c +++ b/module/bdev/nvme/bdev_nvme_rpc.c @@ -271,7 +271,6 @@ rpc_bdev_nvme_attach_controller(struct spdk_jsonrpc_request *request, { struct rpc_bdev_nvme_attach_controller_ctx *ctx; struct spdk_nvme_transport_id trid = {}; - struct spdk_nvme_host_id hostid = {}; uint32_t prchk_flags = 0; struct nvme_ctrlr *ctrlr = NULL; size_t len, maxlen; @@ -363,25 +362,25 @@ rpc_bdev_nvme_attach_controller(struct spdk_jsonrpc_request *request, } if (ctx->req.hostaddr) { - maxlen = sizeof(hostid.hostaddr); + maxlen = sizeof(ctx->req.opts.src_addr); len = strnlen(ctx->req.hostaddr, maxlen); if (len == maxlen) { spdk_jsonrpc_send_error_response_fmt(request, -EINVAL, "hostaddr too long: %s", ctx->req.hostaddr); goto cleanup; } - memcpy(hostid.hostaddr, ctx->req.hostaddr, len + 1); + snprintf(ctx->req.opts.src_addr, maxlen, "%s", ctx->req.hostaddr); } if (ctx->req.hostsvcid) { - maxlen = sizeof(hostid.hostsvcid); + maxlen = sizeof(ctx->req.opts.src_svcid); len = strnlen(ctx->req.hostsvcid, maxlen); if (len == maxlen) { spdk_jsonrpc_send_error_response_fmt(request, -EINVAL, "hostsvcid too long: %s", ctx->req.hostsvcid); goto cleanup; } - memcpy(hostid.hostsvcid, ctx->req.hostsvcid, len + 1); + snprintf(ctx->req.opts.src_svcid, maxlen, "%s", ctx->req.hostsvcid); } ctrlr = nvme_ctrlr_get_by_name(ctx->req.name); @@ -401,8 +400,8 @@ rpc_bdev_nvme_attach_controller(struct spdk_jsonrpc_request *request, ctx->request = request; ctx->count = NVME_MAX_BDEVS_PER_RPC; - rc = bdev_nvme_create(&trid, &hostid, ctx->req.name, ctx->names, ctx->count, - prchk_flags, rpc_bdev_nvme_attach_controller_done, ctx, &ctx->req.opts); + rc = bdev_nvme_create(&trid, ctx->req.name, ctx->names, ctx->count, prchk_flags, + rpc_bdev_nvme_attach_controller_done, ctx, &ctx->req.opts); if (rc) { spdk_jsonrpc_send_error_response(request, rc, spdk_strerror(-rc)); goto cleanup; diff --git a/test/unit/lib/bdev/nvme/bdev_nvme.c/bdev_nvme_ut.c b/test/unit/lib/bdev/nvme/bdev_nvme.c/bdev_nvme_ut.c index 01a0e5187..c583f57e6 100644 --- a/test/unit/lib/bdev/nvme/bdev_nvme.c/bdev_nvme_ut.c +++ b/test/unit/lib/bdev/nvme/bdev_nvme.c/bdev_nvme_ut.c @@ -1508,7 +1508,6 @@ static void test_pending_reset(void) { struct spdk_nvme_transport_id trid = {}; - struct spdk_nvme_host_id hostid = {}; struct spdk_nvme_ctrlr *ctrlr; struct nvme_ctrlr *nvme_ctrlr = NULL; const int STRING_SIZE = 32; @@ -1531,7 +1530,7 @@ test_pending_reset(void) g_ut_attach_ctrlr_status = 0; g_ut_attach_bdev_count = 1; - rc = bdev_nvme_create(&trid, &hostid, "nvme0", attached_names, STRING_SIZE, 0, + rc = bdev_nvme_create(&trid, "nvme0", attached_names, STRING_SIZE, 0, attach_ctrlr_done, NULL, NULL); CU_ASSERT(rc == 0); @@ -1634,7 +1633,6 @@ static void test_attach_ctrlr(void) { struct spdk_nvme_transport_id trid = {}; - struct spdk_nvme_host_id hostid = {}; struct spdk_nvme_ctrlr *ctrlr; struct nvme_ctrlr *nvme_ctrlr; const int STRING_SIZE = 32; @@ -1657,7 +1655,7 @@ test_attach_ctrlr(void) g_ut_attach_ctrlr_status = -EIO; g_ut_attach_bdev_count = 0; - rc = bdev_nvme_create(&trid, &hostid, "nvme0", attached_names, STRING_SIZE, 0, + rc = bdev_nvme_create(&trid, "nvme0", attached_names, STRING_SIZE, 0, attach_ctrlr_done, NULL, NULL); CU_ASSERT(rc == 0); @@ -1672,7 +1670,7 @@ test_attach_ctrlr(void) g_ut_attach_ctrlr_status = 0; - rc = bdev_nvme_create(&trid, &hostid, "nvme0", attached_names, STRING_SIZE, 0, + rc = bdev_nvme_create(&trid, "nvme0", attached_names, STRING_SIZE, 0, attach_ctrlr_done, NULL, NULL); CU_ASSERT(rc == 0); @@ -1699,7 +1697,7 @@ test_attach_ctrlr(void) g_ut_attach_bdev_count = 1; - rc = bdev_nvme_create(&trid, &hostid, "nvme0", attached_names, STRING_SIZE, 0, + rc = bdev_nvme_create(&trid, "nvme0", attached_names, STRING_SIZE, 0, attach_ctrlr_done, NULL, NULL); CU_ASSERT(rc == 0); @@ -1734,7 +1732,7 @@ test_attach_ctrlr(void) g_ut_register_bdev_status = -EINVAL; g_ut_attach_bdev_count = 0; - rc = bdev_nvme_create(&trid, &hostid, "nvme0", attached_names, STRING_SIZE, 0, + rc = bdev_nvme_create(&trid, "nvme0", attached_names, STRING_SIZE, 0, attach_ctrlr_done, NULL, NULL); CU_ASSERT(rc == 0); @@ -1819,7 +1817,6 @@ static void test_aer_cb(void) { struct spdk_nvme_transport_id trid = {}; - struct spdk_nvme_host_id hostid = {}; struct spdk_nvme_ctrlr *ctrlr; struct nvme_ctrlr *nvme_ctrlr; struct nvme_bdev *bdev; @@ -1845,7 +1842,7 @@ test_aer_cb(void) g_ut_attach_ctrlr_status = 0; g_ut_attach_bdev_count = 3; - rc = bdev_nvme_create(&trid, &hostid, "nvme0", attached_names, STRING_SIZE, 0, + rc = bdev_nvme_create(&trid, "nvme0", attached_names, STRING_SIZE, 0, attach_ctrlr_done, NULL, NULL); CU_ASSERT(rc == 0); @@ -2020,7 +2017,6 @@ static void test_submit_nvme_cmd(void) { struct spdk_nvme_transport_id trid = {}; - struct spdk_nvme_host_id hostid = {}; struct spdk_nvme_ctrlr *ctrlr; struct nvme_ctrlr *nvme_ctrlr; const int STRING_SIZE = 32; @@ -2042,7 +2038,7 @@ test_submit_nvme_cmd(void) g_ut_attach_ctrlr_status = 0; g_ut_attach_bdev_count = 1; - rc = bdev_nvme_create(&trid, &hostid, "nvme0", attached_names, STRING_SIZE, 0, + rc = bdev_nvme_create(&trid, "nvme0", attached_names, STRING_SIZE, 0, attach_ctrlr_done, NULL, NULL); CU_ASSERT(rc == 0); @@ -2112,7 +2108,6 @@ static void test_add_remove_trid(void) { struct spdk_nvme_transport_id trid1 = {}, trid2 = {}, trid3 = {}; - struct spdk_nvme_host_id hostid = {}; struct spdk_nvme_ctrlr *ctrlr1, *ctrlr2, *ctrlr3; struct nvme_ctrlr *nvme_ctrlr = NULL; const int STRING_SIZE = 32; @@ -2133,7 +2128,7 @@ test_add_remove_trid(void) ctrlr1 = ut_attach_ctrlr(&trid1, 0, false); SPDK_CU_ASSERT_FATAL(ctrlr1 != NULL); - rc = bdev_nvme_create(&trid1, &hostid, "nvme0", attached_names, STRING_SIZE, 0, + rc = bdev_nvme_create(&trid1, "nvme0", attached_names, STRING_SIZE, 0, attach_ctrlr_done, NULL, NULL); CU_ASSERT(rc == 0); @@ -2148,7 +2143,7 @@ test_add_remove_trid(void) ctrlr2 = ut_attach_ctrlr(&trid2, 0, false); SPDK_CU_ASSERT_FATAL(ctrlr2 != NULL); - rc = bdev_nvme_create(&trid2, &hostid, "nvme0", attached_names, STRING_SIZE, 0, + rc = bdev_nvme_create(&trid2, "nvme0", attached_names, STRING_SIZE, 0, attach_ctrlr_done, NULL, NULL); CU_ASSERT(rc == 0); @@ -2178,7 +2173,7 @@ test_add_remove_trid(void) ctrlr3 = ut_attach_ctrlr(&trid3, 0, false); SPDK_CU_ASSERT_FATAL(ctrlr3 != NULL); - rc = bdev_nvme_create(&trid3, &hostid, "nvme0", attached_names, STRING_SIZE, 0, + rc = bdev_nvme_create(&trid3, "nvme0", attached_names, STRING_SIZE, 0, attach_ctrlr_done, NULL, NULL); CU_ASSERT(rc == 0); @@ -2223,7 +2218,7 @@ test_add_remove_trid(void) ctrlr1 = ut_attach_ctrlr(&trid1, 0, false); SPDK_CU_ASSERT_FATAL(ctrlr1 != NULL); - rc = bdev_nvme_create(&trid1, &hostid, "nvme0", attached_names, STRING_SIZE, 0, + rc = bdev_nvme_create(&trid1, "nvme0", attached_names, STRING_SIZE, 0, attach_ctrlr_done, NULL, NULL); CU_ASSERT(rc == 0); @@ -2238,7 +2233,7 @@ test_add_remove_trid(void) ctrlr2 = ut_attach_ctrlr(&trid2, 0, false); SPDK_CU_ASSERT_FATAL(ctrlr2 != NULL); - rc = bdev_nvme_create(&trid2, &hostid, "nvme0", attached_names, STRING_SIZE, 0, + rc = bdev_nvme_create(&trid2, "nvme0", attached_names, STRING_SIZE, 0, attach_ctrlr_done, NULL, NULL); CU_ASSERT(rc == 0); @@ -2267,7 +2262,6 @@ static void test_abort(void) { struct spdk_nvme_transport_id trid = {}; - struct spdk_nvme_host_id hostid = {}; struct spdk_nvme_ctrlr *ctrlr; struct nvme_ctrlr *nvme_ctrlr; const int STRING_SIZE = 32; @@ -2294,7 +2288,7 @@ test_abort(void) set_thread(1); - rc = bdev_nvme_create(&trid, &hostid, "nvme0", attached_names, STRING_SIZE, 0, + rc = bdev_nvme_create(&trid, "nvme0", attached_names, STRING_SIZE, 0, attach_ctrlr_done, NULL, NULL); CU_ASSERT(rc == 0); @@ -2489,7 +2483,6 @@ static void test_bdev_unregister(void) { struct spdk_nvme_transport_id trid = {}; - struct spdk_nvme_host_id hostid = {}; struct spdk_nvme_ctrlr *ctrlr; struct nvme_ctrlr *nvme_ctrlr; struct nvme_ns *nvme_ns1, *nvme_ns2; @@ -2507,7 +2500,7 @@ test_bdev_unregister(void) g_ut_attach_ctrlr_status = 0; g_ut_attach_bdev_count = 2; - rc = bdev_nvme_create(&trid, &hostid, "nvme0", attached_names, STRING_SIZE, 0, + rc = bdev_nvme_create(&trid, "nvme0", attached_names, STRING_SIZE, 0, attach_ctrlr_done, NULL, NULL); CU_ASSERT(rc == 0); @@ -2598,7 +2591,6 @@ static void test_init_ana_log_page(void) { struct spdk_nvme_transport_id trid = {}; - struct spdk_nvme_host_id hostid = {}; struct spdk_nvme_ctrlr *ctrlr; struct nvme_ctrlr *nvme_ctrlr; const int STRING_SIZE = 32; @@ -2622,7 +2614,7 @@ test_init_ana_log_page(void) g_ut_attach_ctrlr_status = 0; g_ut_attach_bdev_count = 5; - rc = bdev_nvme_create(&trid, &hostid, "nvme0", attached_names, STRING_SIZE, 0, + rc = bdev_nvme_create(&trid, "nvme0", attached_names, STRING_SIZE, 0, attach_ctrlr_done, NULL, NULL); CU_ASSERT(rc == 0);