Commit b1ecb314 authored by Seth Howell's avatar Seth Howell Committed by Jim Harris
Browse files

bdev_nvme: use spdk_nvme_connect in spdk_bdev_nvme_create



This makes it possible to configure the host address information over
RPC.

Change-Id: Icf0de200fbb8cb869c1408f12564e832d58fe00d
Signed-off-by: default avatarSeth Howell <seth.howell@intel.com>
Reviewed-on: https://review.gerrithub.io/437571


Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avatarJim Harris <james.r.harris@intel.com>
Reviewed-by: default avatarBen Walker <benjamin.walker@intel.com>
Reviewed-by: default avatarShuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Chandler-Test-Pool: SPDK Automated Test System <sys_sgsw@intel.com>
parent 675c5592
Loading
Loading
Loading
Loading
+17 −18
Original line number Diff line number Diff line
@@ -1196,7 +1196,8 @@ spdk_bdev_nvme_create(struct spdk_nvme_transport_id *trid,
		      const char **names, size_t *count,
		      const char *hostnqn)
{
	struct nvme_probe_ctx	*probe_ctx;
	struct spdk_nvme_ctrlr_opts	opts;
	struct spdk_nvme_ctrlr		*ctrlr;
	struct nvme_ctrlr		*nvme_ctrlr;
	struct nvme_bdev		*nvme_bdev;
	uint32_t			i, nsid;
@@ -1212,26 +1213,26 @@ spdk_bdev_nvme_create(struct spdk_nvme_transport_id *trid,
		return -1;
	}

	probe_ctx = calloc(1, sizeof(*probe_ctx));
	if (probe_ctx == NULL) {
		SPDK_ERRLOG("Failed to allocate probe_ctx\n");
	spdk_nvme_ctrlr_get_default_ctrlr_opts(&opts, sizeof(opts));

	if (hostnqn) {
		snprintf(opts.hostnqn, sizeof(opts.hostnqn), "%s", hostnqn);
	}

	ctrlr = spdk_nvme_connect(trid, &opts, sizeof(opts));
	if (!ctrlr) {
		SPDK_ERRLOG("Failed to create new device\n");
		return -1;
	}

	probe_ctx->count = 1;
	probe_ctx->trids[0] = *trid;
	probe_ctx->names[0] = base_name;
	probe_ctx->hostnqn = hostnqn;
	if (spdk_nvme_probe(trid, probe_ctx, probe_cb, attach_cb, NULL)) {
		SPDK_ERRLOG("Failed to probe for new devices\n");
		free(probe_ctx);
	if (create_ctrlr(ctrlr, base_name, trid)) {
		SPDK_ERRLOG("Failed to create new device\n");
		return -1;
	}

	nvme_ctrlr = nvme_ctrlr_get(trid);
	if (!nvme_ctrlr) {
		SPDK_ERRLOG("Failed to find new NVMe controller\n");
		free(probe_ctx);
		return -1;
	}

@@ -1253,14 +1254,12 @@ spdk_bdev_nvme_create(struct spdk_nvme_transport_id *trid,
		} else {
			SPDK_ERRLOG("Maximum number of namespaces supported per NVMe controller is %zu. Unable to return all names of created bdevs\n",
				    *count);
			free(probe_ctx);
			return -1;
		}
	}

	*count = j;

	free(probe_ctx);
	return 0;
}