bdev/nvme: Use spdk_nvme_connect for non-PCI devices
Change-Id: Ibd472e0deda621c4a103b4ddf988e4994181b3c8 Signed-off-by: Ben Walker <benjamin.walker@intel.com> Reviewed-on: https://review.gerrithub.io/415542 Reviewed-by: Daniel Verkamp <daniel.verkamp@intel.com> Reviewed-by: Jim Harris <james.r.harris@intel.com> Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
This commit is contained in:
parent
7d87273f60
commit
b99dd2af4a
@ -852,7 +852,7 @@ timeout_cb(void *cb_arg, struct spdk_nvme_ctrlr *ctrlr,
|
||||
|
||||
static int
|
||||
create_ctrlr(struct spdk_nvme_ctrlr *ctrlr,
|
||||
char *name,
|
||||
const char *name,
|
||||
const struct spdk_nvme_transport_id *trid)
|
||||
{
|
||||
struct nvme_ctrlr *nvme_ctrlr;
|
||||
@ -874,7 +874,7 @@ create_ctrlr(struct spdk_nvme_ctrlr *ctrlr,
|
||||
nvme_ctrlr->ctrlr = ctrlr;
|
||||
nvme_ctrlr->ref = 0;
|
||||
nvme_ctrlr->trid = *trid;
|
||||
nvme_ctrlr->name = name;
|
||||
nvme_ctrlr->name = strdup(name);
|
||||
|
||||
spdk_io_device_register(ctrlr, bdev_nvme_create_cb, bdev_nvme_destroy_cb,
|
||||
sizeof(struct nvme_io_channel));
|
||||
@ -905,7 +905,6 @@ attach_cb(void *cb_ctx, const struct spdk_nvme_transport_id *trid,
|
||||
struct nvme_probe_ctx *ctx = cb_ctx;
|
||||
char *name = NULL;
|
||||
size_t i;
|
||||
int rc;
|
||||
|
||||
if (ctx) {
|
||||
for (i = 0; i < ctx->count; i++) {
|
||||
@ -924,11 +923,9 @@ attach_cb(void *cb_ctx, const struct spdk_nvme_transport_id *trid,
|
||||
|
||||
SPDK_DEBUGLOG(SPDK_LOG_BDEV_NVME, "Attached to %s (%s)\n", trid->traddr, name);
|
||||
|
||||
rc = create_ctrlr(ctrlr, name, trid);
|
||||
if (rc) {
|
||||
free(name);
|
||||
return;
|
||||
}
|
||||
create_ctrlr(ctrlr, name, trid);
|
||||
|
||||
free(name);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -1138,16 +1135,36 @@ bdev_nvme_library_init(void)
|
||||
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_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;
|
||||
}
|
||||
|
||||
if (spdk_nvme_probe(&probe_ctx->trids[i], probe_ctx, probe_cb, attach_cb, NULL)) {
|
||||
spdk_nvme_ctrlr_get_default_ctrlr_opts(&opts, sizeof(opts));
|
||||
|
||||
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 = create_ctrlr(ctrlr, probe_ctx->names[i], &probe_ctx->trids[i]);
|
||||
if (!rc) {
|
||||
goto end;
|
||||
}
|
||||
} else {
|
||||
local_nvme_num++;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user