bdev/nvme: Allocate context at the head of bdev_nvme_create()
Signed-off-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com> Change-Id: Id4f8703dbfdd0f12263eef82e51b7df3d8e15d81 Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/4386 Tested-by: SPDK CI Jenkins <sys_sgci@intel.com> Reviewed-by: Aleksey Marchuk <alexeymar@mellanox.com> Reviewed-by: Jim Harris <james.r.harris@intel.com> Reviewed-by: Ben Walker <benjamin.walker@intel.com>
This commit is contained in:
parent
66f74eb9f7
commit
cced29b595
@ -1922,15 +1922,29 @@ bdev_nvme_create(struct spdk_nvme_transport_id *trid,
|
|||||||
return -EEXIST;
|
return -EEXIST;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ctx = calloc(1, sizeof(*ctx));
|
||||||
|
if (!ctx) {
|
||||||
|
return -ENOMEM;
|
||||||
|
}
|
||||||
|
ctx->base_name = base_name;
|
||||||
|
ctx->names = names;
|
||||||
|
ctx->count = count;
|
||||||
|
ctx->cb_fn = cb_fn;
|
||||||
|
ctx->cb_ctx = cb_ctx;
|
||||||
|
ctx->prchk_flags = prchk_flags;
|
||||||
|
ctx->trid = *trid;
|
||||||
|
|
||||||
existing_ctrlr = nvme_bdev_ctrlr_get_by_name(base_name);
|
existing_ctrlr = nvme_bdev_ctrlr_get_by_name(base_name);
|
||||||
if (existing_ctrlr) {
|
if (existing_ctrlr) {
|
||||||
if (trid->trtype == SPDK_NVME_TRANSPORT_PCIE) {
|
if (trid->trtype == SPDK_NVME_TRANSPORT_PCIE) {
|
||||||
SPDK_ERRLOG("A controller with the provided name (name: %s) already exists with transport type PCIe. PCIe multipath is not supported.\n",
|
SPDK_ERRLOG("A controller with the provided name (name: %s) already exists with transport type PCIe. PCIe multipath is not supported.\n",
|
||||||
base_name);
|
base_name);
|
||||||
|
free(ctx);
|
||||||
return -EEXIST;
|
return -EEXIST;
|
||||||
}
|
}
|
||||||
rc = bdev_nvme_add_trid(existing_ctrlr->name, trid);
|
rc = bdev_nvme_add_trid(existing_ctrlr->name, trid);
|
||||||
if (rc) {
|
if (rc) {
|
||||||
|
free(ctx);
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1945,18 +1959,6 @@ bdev_nvme_create(struct spdk_nvme_transport_id *trid,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx = calloc(1, sizeof(*ctx));
|
|
||||||
if (!ctx) {
|
|
||||||
return -ENOMEM;
|
|
||||||
}
|
|
||||||
ctx->base_name = base_name;
|
|
||||||
ctx->names = names;
|
|
||||||
ctx->count = count;
|
|
||||||
ctx->cb_fn = cb_fn;
|
|
||||||
ctx->cb_ctx = cb_ctx;
|
|
||||||
ctx->prchk_flags = prchk_flags;
|
|
||||||
ctx->trid = *trid;
|
|
||||||
|
|
||||||
if (existing_ctrlr) {
|
if (existing_ctrlr) {
|
||||||
nvme_ctrlr_populate_namespaces_done(ctx);
|
nvme_ctrlr_populate_namespaces_done(ctx);
|
||||||
return 0;
|
return 0;
|
||||||
|
Loading…
Reference in New Issue
Block a user