bdev/nvme: Make bdev_nvm_create_bdevs asynchronous like
With this change the new callback create_bdevs_cb is introduced. This callback may be used by future NVMe controllers which require asynchronous creation of bdevs. This will make future implementation easier because we will only have to call callback function. Signed-off-by: Maciej Szwed <maciej.szwed@intel.com> Change-Id: Ib46a38cf71bc783db58be9021efd06fcd547c4d9 Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/469699 Community-CI: Broadcom SPDK FC-NVMe CI <spdk-ci.pdl@broadcom.com> Tested-by: SPDK CI Jenkins <sys_sgci@intel.com> Reviewed-by: Ben Walker <benjamin.walker@intel.com> Reviewed-by: Jim Harris <james.r.harris@intel.com>
This commit is contained in:
parent
b577d89297
commit
81d6bcd02c
@ -1205,8 +1205,19 @@ spdk_bdev_nvme_set_hotplug(bool enabled, uint64_t period_us, spdk_msg_fn cb, voi
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
bdev_nvme_create_bdevs(struct nvme_async_probe_ctx *ctx)
|
||||
static void
|
||||
create_bdevs_cb(void *cb_arg, size_t count, int rc)
|
||||
{
|
||||
struct nvme_async_probe_ctx *ctx = cb_arg;
|
||||
|
||||
if (ctx->cb_fn) {
|
||||
ctx->cb_fn(ctx->cb_ctx, count, rc);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
bdev_nvme_create_bdevs(struct nvme_async_probe_ctx *ctx, spdk_bdev_create_nvme_fn cb_fn,
|
||||
void *cb_arg)
|
||||
{
|
||||
struct nvme_bdev_ctrlr *nvme_bdev_ctrlr;
|
||||
struct nvme_bdev *nvme_bdev;
|
||||
@ -1236,13 +1247,12 @@ bdev_nvme_create_bdevs(struct nvme_async_probe_ctx *ctx)
|
||||
} else {
|
||||
SPDK_ERRLOG("Maximum number of namespaces supported per NVMe controller is %du. Unable to return all names of created bdevs\n",
|
||||
ctx->count);
|
||||
return -1;
|
||||
cb_fn(cb_arg, 0, -ERANGE);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
ctx->count = j;
|
||||
|
||||
return 0;
|
||||
cb_fn(cb_arg, j, 0);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -1258,19 +1268,14 @@ connect_attach_cb(void *cb_ctx, const struct spdk_nvme_transport_id *trid,
|
||||
rc = create_ctrlr(ctrlr, ctx->base_name, &ctx->trid, ctx->prchk_flags);
|
||||
if (rc) {
|
||||
SPDK_ERRLOG("Failed to create new device\n");
|
||||
goto end;
|
||||
create_bdevs_cb(ctx, 0, rc);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!spdk_nvme_ctrlr_is_ocssd_supported(ctrlr)) {
|
||||
rc = bdev_nvme_create_bdevs(ctx);
|
||||
if (rc) {
|
||||
SPDK_ERRLOG("Failed to create bdevs\n");
|
||||
}
|
||||
}
|
||||
|
||||
end:
|
||||
if (ctx->cb_fn) {
|
||||
ctx->cb_fn(ctx->cb_ctx, ctx->count, rc);
|
||||
if (spdk_nvme_ctrlr_is_ocssd_supported(ctrlr)) {
|
||||
create_bdevs_cb(ctx, 0, 0);
|
||||
} else {
|
||||
bdev_nvme_create_bdevs(ctx, create_bdevs_cb, ctx);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user