bdev/nvme: Extract create_ctrlr from bdev_nvme_create_and_get_bdev_names
This change will make possible to use connect_attach_cb function with other NVMe bdev types. Changing bdev_nvme_create_and_get_bdev_names function name to more suitable. Signed-off-by: Maciej Szwed <maciej.szwed@intel.com> Change-Id: I0bf79aba65914b4ac1826200f7d049e1c26276f4 Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/468594 Tested-by: SPDK CI Jenkins <sys_sgci@intel.com> Reviewed-by: Jim Harris <james.r.harris@intel.com> Reviewed-by: Ben Walker <benjamin.walker@intel.com> Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
This commit is contained in:
parent
d7d03bd36a
commit
cfaa742841
@ -1191,27 +1191,16 @@ spdk_bdev_nvme_set_hotplug(bool enabled, uint64_t period_us, spdk_msg_fn cb, voi
|
||||
}
|
||||
|
||||
static int
|
||||
bdev_nvme_create_and_get_bdev_names(struct spdk_nvme_ctrlr *ctrlr,
|
||||
const char *base_name,
|
||||
const char **names, size_t *count,
|
||||
const struct spdk_nvme_transport_id *trid,
|
||||
uint32_t prchk_flags)
|
||||
bdev_nvme_create_bdevs(const char **names, size_t *count,
|
||||
const struct spdk_nvme_transport_id *trid)
|
||||
{
|
||||
struct nvme_bdev_ctrlr *nvme_bdev_ctrlr;
|
||||
struct nvme_bdev *nvme_bdev;
|
||||
uint32_t i, nsid;
|
||||
size_t j;
|
||||
|
||||
if (create_ctrlr(ctrlr, base_name, trid, prchk_flags)) {
|
||||
SPDK_ERRLOG("Failed to create new device\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
nvme_bdev_ctrlr = nvme_bdev_ctrlr_get(trid);
|
||||
if (!nvme_bdev_ctrlr) {
|
||||
SPDK_ERRLOG("Failed to find new NVMe controller\n");
|
||||
return -1;
|
||||
}
|
||||
assert(nvme_bdev_ctrlr != NULL);
|
||||
|
||||
nvme_ctrlr_create_bdevs(nvme_bdev_ctrlr);
|
||||
|
||||
@ -1264,12 +1253,19 @@ connect_attach_cb(void *cb_ctx, const struct spdk_nvme_transport_id *trid,
|
||||
int rc;
|
||||
|
||||
ctx = SPDK_CONTAINEROF(user_opts, struct nvme_async_probe_ctx, opts);
|
||||
rc = bdev_nvme_create_and_get_bdev_names(ctrlr,
|
||||
ctx->base_name,
|
||||
ctx->names, ctx->count,
|
||||
&ctx->trid,
|
||||
ctx->prchk_flags);
|
||||
|
||||
rc = create_ctrlr(ctrlr, ctx->base_name, &ctx->trid, ctx->prchk_flags);
|
||||
if (rc) {
|
||||
SPDK_ERRLOG("Failed to create new device\n");
|
||||
goto end;
|
||||
}
|
||||
|
||||
rc = bdev_nvme_create_bdevs(ctx->names, ctx->count, &ctx->trid);
|
||||
if (rc) {
|
||||
SPDK_ERRLOG("Failed to create bdevs\n");
|
||||
}
|
||||
|
||||
end:
|
||||
if (ctx->cb_fn) {
|
||||
ctx->cb_fn(ctx->cb_ctx, rc);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user