bdev/nvme: Include hostnqn into ctrlr_opts when calling bdev_nvme_create()

bdev_nvme_create() is called only by a single caller and hostnqn is
just copied to ctrlr_opts even if it is passed separately.

Hence include hostnqn into ctrlr_opts rather than passing it as a
parameter for bdev_nvme_create().

Signed-off-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Change-Id: I75b640bcecefa94950b0c19936fab0571c428125
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/9332
Community-CI: Mellanox Build Bot
Community-CI: Broadcom CI <spdk-ci.pdl@broadcom.com>
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Konrad Sztyber <konrad.sztyber@gmail.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
This commit is contained in:
Shuhei Matsumoto 2021-08-26 18:20:54 +09:00 committed by Tomasz Zawadzki
parent efbab14933
commit 9a3939bfb7
4 changed files with 21 additions and 22 deletions

View File

@ -2669,7 +2669,6 @@ bdev_nvme_create(struct spdk_nvme_transport_id *trid,
const char *base_name,
const char **names,
uint32_t count,
const char *hostnqn,
uint32_t prchk_flags,
spdk_bdev_create_nvme_fn cb_fn,
void *cb_ctx,
@ -2719,10 +2718,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 (hostnqn) {
snprintf(ctx->opts.hostnqn, sizeof(ctx->opts.hostnqn), "%s", hostnqn);
}
if (hostid->hostaddr[0] != '\0') {
snprintf(ctx->opts.src_addr, sizeof(ctx->opts.src_addr), "%s", hostid->hostaddr);
}

View File

@ -75,7 +75,6 @@ int bdev_nvme_create(struct spdk_nvme_transport_id *trid,
const char *base_name,
const char **names,
uint32_t count,
const char *hostnqn,
uint32_t prchk_flags,
spdk_bdev_create_nvme_fn cb_fn,
void *cb_ctx,

View File

@ -365,6 +365,11 @@ rpc_bdev_nvme_attach_controller(struct spdk_jsonrpc_request *request,
goto conflicting_arguments;
}
if (ctx->req.hostnqn) {
snprintf(ctx->req.opts.hostnqn, sizeof(ctx->req.opts.hostnqn), "%s",
ctx->req.hostnqn);
}
if (ctx->req.hostaddr) {
maxlen = sizeof(hostid.hostaddr);
len = strnlen(ctx->req.hostaddr, maxlen);
@ -397,7 +402,7 @@ 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, ctx->req.hostnqn,
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);
if (rc) {
spdk_jsonrpc_send_error_response(request, rc, spdk_strerror(-rc));

View File

@ -1519,7 +1519,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, NULL, 0,
rc = bdev_nvme_create(&trid, &hostid, "nvme0", attached_names, STRING_SIZE, 0,
attach_ctrlr_done, NULL, NULL);
CU_ASSERT(rc == 0);
@ -1645,7 +1645,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, NULL, 0,
rc = bdev_nvme_create(&trid, &hostid, "nvme0", attached_names, STRING_SIZE, 0,
attach_ctrlr_done, NULL, NULL);
CU_ASSERT(rc == 0);
@ -1660,7 +1660,7 @@ test_attach_ctrlr(void)
g_ut_attach_ctrlr_status = 0;
rc = bdev_nvme_create(&trid, &hostid, "nvme0", attached_names, STRING_SIZE, NULL, 0,
rc = bdev_nvme_create(&trid, &hostid, "nvme0", attached_names, STRING_SIZE, 0,
attach_ctrlr_done, NULL, NULL);
CU_ASSERT(rc == 0);
@ -1687,7 +1687,7 @@ test_attach_ctrlr(void)
g_ut_attach_bdev_count = 1;
rc = bdev_nvme_create(&trid, &hostid, "nvme0", attached_names, STRING_SIZE, NULL, 0,
rc = bdev_nvme_create(&trid, &hostid, "nvme0", attached_names, STRING_SIZE, 0,
attach_ctrlr_done, NULL, NULL);
CU_ASSERT(rc == 0);
@ -1722,7 +1722,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, NULL, 0,
rc = bdev_nvme_create(&trid, &hostid, "nvme0", attached_names, STRING_SIZE, 0,
attach_ctrlr_done, NULL, NULL);
CU_ASSERT(rc == 0);
@ -1833,7 +1833,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, NULL, 0,
rc = bdev_nvme_create(&trid, &hostid, "nvme0", attached_names, STRING_SIZE, 0,
attach_ctrlr_done, NULL, NULL);
CU_ASSERT(rc == 0);
@ -2030,7 +2030,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, NULL, 0,
rc = bdev_nvme_create(&trid, &hostid, "nvme0", attached_names, STRING_SIZE, 0,
attach_ctrlr_done, NULL, NULL);
CU_ASSERT(rc == 0);
@ -2121,7 +2121,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, NULL, 0,
rc = bdev_nvme_create(&trid1, &hostid, "nvme0", attached_names, STRING_SIZE, 0,
attach_ctrlr_done, NULL, NULL);
CU_ASSERT(rc == 0);
@ -2136,7 +2136,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, NULL, 0,
rc = bdev_nvme_create(&trid2, &hostid, "nvme0", attached_names, STRING_SIZE, 0,
attach_ctrlr_done, NULL, NULL);
CU_ASSERT(rc == 0);
@ -2166,7 +2166,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, NULL, 0,
rc = bdev_nvme_create(&trid3, &hostid, "nvme0", attached_names, STRING_SIZE, 0,
attach_ctrlr_done, NULL, NULL);
CU_ASSERT(rc == 0);
@ -2211,7 +2211,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, NULL, 0,
rc = bdev_nvme_create(&trid1, &hostid, "nvme0", attached_names, STRING_SIZE, 0,
attach_ctrlr_done, NULL, NULL);
CU_ASSERT(rc == 0);
@ -2226,7 +2226,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, NULL, 0,
rc = bdev_nvme_create(&trid2, &hostid, "nvme0", attached_names, STRING_SIZE, 0,
attach_ctrlr_done, NULL, NULL);
CU_ASSERT(rc == 0);
@ -2282,7 +2282,7 @@ test_abort(void)
set_thread(1);
rc = bdev_nvme_create(&trid, &hostid, "nvme0", attached_names, STRING_SIZE, NULL, 0,
rc = bdev_nvme_create(&trid, &hostid, "nvme0", attached_names, STRING_SIZE, 0,
attach_ctrlr_done, NULL, NULL);
CU_ASSERT(rc == 0);
@ -2495,7 +2495,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, NULL, 0,
rc = bdev_nvme_create(&trid, &hostid, "nvme0", attached_names, STRING_SIZE, 0,
attach_ctrlr_done, NULL, NULL);
CU_ASSERT(rc == 0);
@ -2610,7 +2610,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, NULL, 0,
rc = bdev_nvme_create(&trid, &hostid, "nvme0", attached_names, STRING_SIZE, 0,
attach_ctrlr_done, NULL, NULL);
CU_ASSERT(rc == 0);