diff --git a/module/bdev/nvme/bdev_nvme.c b/module/bdev/nvme/bdev_nvme.c index ba9824a890..9cdc1e83fe 100644 --- a/module/bdev/nvme/bdev_nvme.c +++ b/module/bdev/nvme/bdev_nvme.c @@ -1702,31 +1702,8 @@ nvme_ctrlr_populate_namespace(struct nvme_ctrlr *nvme_ctrlr, struct nvme_ns *nvm } rc = nvme_bdev_create(nvme_ctrlr, nvme_ns); + done: - nvme_ctrlr_populate_namespace_done(ctx, nvme_ns, rc); -} - -static void -nvme_ctrlr_depopulate_namespace(struct nvme_ctrlr *ctrlr, struct nvme_ns *nvme_ns) -{ - struct nvme_bdev *bdev; - - bdev = nvme_ns->bdev; - if (bdev != NULL) { - spdk_bdev_unregister(&bdev->disk, NULL, NULL); - } - - nvme_ctrlr_depopulate_namespace_done(nvme_ns); -} - -void -nvme_ctrlr_populate_namespace_done(struct nvme_async_probe_ctx *ctx, - struct nvme_ns *nvme_ns, int rc) -{ - struct nvme_ctrlr *nvme_ctrlr = nvme_ns->ctrlr; - - assert(nvme_ctrlr != NULL); - if (rc == 0) { pthread_mutex_lock(&nvme_ctrlr->mutex); nvme_ctrlr->ref++; @@ -1743,6 +1720,29 @@ nvme_ctrlr_populate_namespace_done(struct nvme_async_probe_ctx *ctx, } } +static void +nvme_ctrlr_depopulate_namespace(struct nvme_ctrlr *nvme_ctrlr, struct nvme_ns *nvme_ns) +{ + struct nvme_bdev *bdev; + + bdev = nvme_ns->bdev; + if (bdev != NULL) { + spdk_bdev_unregister(&bdev->disk, NULL, NULL); + } + + pthread_mutex_lock(&nvme_ctrlr->mutex); + + nvme_ns->populated = false; + + if (nvme_ns->bdev != NULL) { + pthread_mutex_unlock(&nvme_ctrlr->mutex); + return; + } + pthread_mutex_unlock(&nvme_ctrlr->mutex); + + nvme_ctrlr_release(nvme_ctrlr); +} + static void nvme_ctrlr_populate_namespaces(struct nvme_ctrlr *nvme_ctrlr, struct nvme_async_probe_ctx *ctx) diff --git a/module/bdev/nvme/common.c b/module/bdev/nvme/common.c index 033dacb3c6..29f60fc481 100644 --- a/module/bdev/nvme/common.c +++ b/module/bdev/nvme/common.c @@ -195,26 +195,6 @@ nvme_ctrlr_release(struct nvme_ctrlr *nvme_ctrlr) nvme_ctrlr_unregister(nvme_ctrlr); } -void -nvme_ctrlr_depopulate_namespace_done(struct nvme_ns *nvme_ns) -{ - struct nvme_ctrlr *nvme_ctrlr = nvme_ns->ctrlr; - - assert(nvme_ctrlr != NULL); - - pthread_mutex_lock(&nvme_ctrlr->mutex); - - nvme_ns->populated = false; - - if (nvme_ns->bdev != NULL) { - pthread_mutex_unlock(&nvme_ctrlr->mutex); - return; - } - pthread_mutex_unlock(&nvme_ctrlr->mutex); - - nvme_ctrlr_release(nvme_ctrlr); -} - int bdev_nvme_create_bdev_channel_cb(void *io_device, void *ctx_buf) { diff --git a/module/bdev/nvme/common.h b/module/bdev/nvme/common.h index 1585a6a3cd..129de3e8bb 100644 --- a/module/bdev/nvme/common.h +++ b/module/bdev/nvme/common.h @@ -174,10 +174,6 @@ struct nvme_bdev_channel { struct nvme_ctrlr_channel *ctrlr_ch; }; -void nvme_ctrlr_populate_namespace_done(struct nvme_async_probe_ctx *ctx, - struct nvme_ns *nvme_ns, int rc); -void nvme_ctrlr_depopulate_namespace_done(struct nvme_ns *nvme_ns); - struct nvme_ctrlr *nvme_ctrlr_get(const struct spdk_nvme_transport_id *trid); struct nvme_ctrlr *nvme_ctrlr_get_by_name(const char *name);