Commit d3726b6e authored by Jim Harris's avatar Jim Harris Committed by Tomasz Zawadzki
Browse files

bdev/nvme: pass probe_ctx to populate_namespace functions



This is in preparation for making the per-ns-type
populate_namespace functions asynchronous.

Signed-off-by: default avatarJim Harris <james.r.harris@intel.com>
Change-Id: I63176e0d117eb91de82b3f8b68a18de592e0a980

Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/475921


Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avatarChangpeng Liu <changpeng.liu@intel.com>
Reviewed-by: default avatarTomasz Zawadzki <tomasz.zawadzki@intel.com>
Reviewed-by: default avatarKonrad Sztyber <konrad.sztyber@intel.com>
Reviewed-by: default avatarBen Walker <benjamin.walker@intel.com>
Reviewed-by: default avatarShuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
parent de76e810
Loading
Loading
Loading
Loading
+17 −14
Original line number Diff line number Diff line
@@ -125,7 +125,8 @@ static struct spdk_poller *g_hotplug_poller;
static struct spdk_nvme_probe_ctx *g_hotplug_probe_ctx;
static char *g_nvme_hostnqn = NULL;

static void nvme_ctrlr_populate_namespaces(struct nvme_bdev_ctrlr *nvme_bdev_ctrlr);
static void nvme_ctrlr_populate_namespaces(struct nvme_bdev_ctrlr *nvme_bdev_ctrlr,
		struct nvme_async_probe_ctx *ctx);
static int bdev_nvme_library_init(void);
static void bdev_nvme_library_fini(void);
static int bdev_nvme_readv(struct nvme_bdev *nbdev, struct spdk_io_channel *ch,
@@ -149,11 +150,11 @@ static int bdev_nvme_io_passthru_md(struct nvme_bdev *nbdev, struct spdk_io_chan
static int bdev_nvme_reset(struct nvme_bdev_ctrlr *nvme_bdev_ctrlr, struct nvme_bdev_io *bio);

typedef int (*populate_namespace_fn)(struct nvme_bdev_ctrlr *nvme_bdev_ctrlr,
				     struct nvme_bdev_ns *nvme_ns);
				     struct nvme_bdev_ns *nvme_ns, struct nvme_async_probe_ctx *ctx);
static int nvme_ctrlr_populate_standard_namespace(struct nvme_bdev_ctrlr *nvme_bdev_ctrlr,
		struct nvme_bdev_ns *nvme_ns);
		struct nvme_bdev_ns *nvme_ns, struct nvme_async_probe_ctx *ctx);
static int nvme_ctrlr_populate_ocssd_namespace(struct nvme_bdev_ctrlr *nvme_bdev_ctrlr,
		struct nvme_bdev_ns *nvme_ns);
		struct nvme_bdev_ns *nvme_ns, struct nvme_async_probe_ctx *ctx);

static populate_namespace_fn g_populate_namespace_fn[] = {
	NULL,
@@ -794,7 +795,7 @@ static const struct spdk_bdev_fn_table nvmelib_fn_table = {

static int
nvme_ctrlr_populate_standard_namespace(struct nvme_bdev_ctrlr *nvme_bdev_ctrlr,
				       struct nvme_bdev_ns *nvme_ns)
				       struct nvme_bdev_ns *nvme_ns, struct nvme_async_probe_ctx *ctx)
{
	struct spdk_nvme_ctrlr	*ctrlr = nvme_bdev_ctrlr->ctrlr;
	struct nvme_bdev	*bdev;
@@ -871,7 +872,7 @@ nvme_ctrlr_populate_standard_namespace(struct nvme_bdev_ctrlr *nvme_bdev_ctrlr,

static int
nvme_ctrlr_populate_ocssd_namespace(struct nvme_bdev_ctrlr *nvme_bdev_ctrlr,
				    struct nvme_bdev_ns *nvme_ns)
				    struct nvme_bdev_ns *nvme_ns, struct nvme_async_probe_ctx *ctx)
{
	return 0;
}
@@ -1018,9 +1019,10 @@ nvme_ctrlr_depopulate_ocssd_namespace(struct nvme_bdev_ns *ns)
{
}

static int nvme_ctrlr_populate_namespace(struct nvme_bdev_ctrlr *ctrlr, struct nvme_bdev_ns *ns)
static int nvme_ctrlr_populate_namespace(struct nvme_bdev_ctrlr *ctrlr, struct nvme_bdev_ns *ns,
		struct nvme_async_probe_ctx *ctx)
{
	return g_populate_namespace_fn[ns->type](ctrlr, ns);
	return g_populate_namespace_fn[ns->type](ctrlr, ns, ctx);
}

static void nvme_ctrlr_depopulate_namespace(struct nvme_bdev_ctrlr *ctrlr, struct nvme_bdev_ns *ns)
@@ -1029,7 +1031,8 @@ static void nvme_ctrlr_depopulate_namespace(struct nvme_bdev_ctrlr *ctrlr, struc
}

static void
nvme_ctrlr_populate_namespaces(struct nvme_bdev_ctrlr *nvme_bdev_ctrlr)
nvme_ctrlr_populate_namespaces(struct nvme_bdev_ctrlr *nvme_bdev_ctrlr,
			       struct nvme_async_probe_ctx *ctx)
{
	struct spdk_nvme_ctrlr	*ctrlr = nvme_bdev_ctrlr->ctrlr;
	struct nvme_bdev_ns	*ns;
@@ -1051,7 +1054,7 @@ nvme_ctrlr_populate_namespaces(struct nvme_bdev_ctrlr *nvme_bdev_ctrlr)

			TAILQ_INIT(&ns->bdevs);

			rc = nvme_ctrlr_populate_namespace(nvme_bdev_ctrlr, ns);
			rc = nvme_ctrlr_populate_namespace(nvme_bdev_ctrlr, ns, ctx);
			if (rc == 0) {
				ns->populated = true;
			} else {
@@ -1080,7 +1083,7 @@ aer_cb(void *arg, const struct spdk_nvme_cpl *cpl)
	event.raw = cpl->cdw0;
	if ((event.bits.async_event_type == SPDK_NVME_ASYNC_EVENT_TYPE_NOTICE) &&
	    (event.bits.async_event_info == SPDK_NVME_ASYNC_EVENT_NS_ATTR_CHANGED)) {
		nvme_ctrlr_populate_namespaces(nvme_bdev_ctrlr);
		nvme_ctrlr_populate_namespaces(nvme_bdev_ctrlr, NULL);
	}
}

@@ -1195,7 +1198,7 @@ attach_cb(void *cb_ctx, const struct spdk_nvme_transport_id *trid,
		return;
	}

	nvme_ctrlr_populate_namespaces(nvme_bdev_ctrlr);
	nvme_ctrlr_populate_namespaces(nvme_bdev_ctrlr, NULL);

	free(name);
}
@@ -1357,7 +1360,7 @@ bdev_nvme_populate_namespaces(struct nvme_async_probe_ctx *ctx)
	nvme_bdev_ctrlr = nvme_bdev_ctrlr_get(&ctx->trid);
	assert(nvme_bdev_ctrlr != NULL);

	nvme_ctrlr_populate_namespaces(nvme_bdev_ctrlr);
	nvme_ctrlr_populate_namespaces(nvme_bdev_ctrlr, ctx);

	/*
	 * Report the new bdevs that were created in this call.
@@ -1692,7 +1695,7 @@ bdev_nvme_library_init(void)
				goto end;
			}

			nvme_ctrlr_populate_namespaces(nvme_bdev_ctrlr);
			nvme_ctrlr_populate_namespaces(nvme_bdev_ctrlr, NULL);
		} else {
			local_nvme_num++;
		}