bdev/nvme: Include hostid into ctrlr_opts when calling bdev_nvme_create()
Following the last patch, include hostid 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: I0d04db1c5767ec76a9a7cd255c3a8d56b0b8f583 Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/9344 Reviewed-by: Jim Harris <james.r.harris@intel.com> Reviewed-by: Aleksey Marchuk <alexeymar@mellanox.com> Reviewed-by: Konrad Sztyber <konrad.sztyber@gmail.com> Community-CI: Broadcom CI <spdk-ci.pdl@broadcom.com> Community-CI: Mellanox Build Bot Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
This commit is contained in:
parent
b0a6496a7b
commit
6d2caa652b
@ -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 {
|
||||
|
@ -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,
|
||||
|
@ -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;
|
||||
|
@ -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);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user