bdev/nvme: Move bdev_nvme_ctrlr_destruct function to common.c
This is a part of changes required by upcoming patch. This will also require moving bdev_nvme_unregister_cb function to common.c. Signed-off-by: Maciej Szwed <maciej.szwed@intel.com> Change-Id: Icc14534db4aec903542a94588d22b0ea9d43f47a Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/470439 Reviewed-by: Changpeng Liu <changpeng.liu@intel.com> Reviewed-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com> Reviewed-by: Konrad Sztyber <konrad.sztyber@intel.com> Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com> Reviewed-by: Ben Walker <benjamin.walker@intel.com> Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
This commit is contained in:
parent
6a13d85778
commit
b56d8100b6
@ -247,42 +247,6 @@ bdev_nvme_poll_adminq(void *arg)
|
|||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
|
||||||
bdev_nvme_unregister_cb(void *io_device)
|
|
||||||
{
|
|
||||||
struct nvme_bdev_ctrlr *nvme_bdev_ctrlr = io_device;
|
|
||||||
uint32_t i;
|
|
||||||
|
|
||||||
pthread_mutex_lock(&g_bdev_nvme_mutex);
|
|
||||||
TAILQ_REMOVE(&g_nvme_bdev_ctrlrs, nvme_bdev_ctrlr, tailq);
|
|
||||||
pthread_mutex_unlock(&g_bdev_nvme_mutex);
|
|
||||||
spdk_nvme_detach(nvme_bdev_ctrlr->ctrlr);
|
|
||||||
spdk_poller_unregister(&nvme_bdev_ctrlr->adminq_timer_poller);
|
|
||||||
free(nvme_bdev_ctrlr->name);
|
|
||||||
for (i = 0; i < nvme_bdev_ctrlr->num_ns; i++) {
|
|
||||||
free(nvme_bdev_ctrlr->namespaces[i]);
|
|
||||||
}
|
|
||||||
free(nvme_bdev_ctrlr->namespaces);
|
|
||||||
free(nvme_bdev_ctrlr);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
bdev_nvme_ctrlr_destruct(struct nvme_bdev_ctrlr *nvme_bdev_ctrlr)
|
|
||||||
{
|
|
||||||
assert(nvme_bdev_ctrlr->destruct);
|
|
||||||
if (nvme_bdev_ctrlr->opal_dev) {
|
|
||||||
if (nvme_bdev_ctrlr->opal_poller != NULL) {
|
|
||||||
spdk_poller_unregister(&nvme_bdev_ctrlr->opal_poller);
|
|
||||||
/* wait until we get the result */
|
|
||||||
while (spdk_opal_revert_poll(nvme_bdev_ctrlr->opal_dev) == -EAGAIN);
|
|
||||||
}
|
|
||||||
spdk_opal_close(nvme_bdev_ctrlr->opal_dev);
|
|
||||||
nvme_bdev_ctrlr->opal_dev = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
spdk_io_device_unregister(nvme_bdev_ctrlr, bdev_nvme_unregister_cb);
|
|
||||||
}
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
bdev_nvme_destruct(void *ctx)
|
bdev_nvme_destruct(void *ctx)
|
||||||
{
|
{
|
||||||
|
@ -109,3 +109,39 @@ nvme_bdev_dump_trid_json(struct spdk_nvme_transport_id *trid, struct spdk_json_w
|
|||||||
spdk_json_write_named_string(w, "subnqn", trid->subnqn);
|
spdk_json_write_named_string(w, "subnqn", trid->subnqn);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
bdev_nvme_unregister_cb(void *io_device)
|
||||||
|
{
|
||||||
|
struct nvme_bdev_ctrlr *nvme_bdev_ctrlr = io_device;
|
||||||
|
uint32_t i;
|
||||||
|
|
||||||
|
pthread_mutex_lock(&g_bdev_nvme_mutex);
|
||||||
|
TAILQ_REMOVE(&g_nvme_bdev_ctrlrs, nvme_bdev_ctrlr, tailq);
|
||||||
|
pthread_mutex_unlock(&g_bdev_nvme_mutex);
|
||||||
|
spdk_nvme_detach(nvme_bdev_ctrlr->ctrlr);
|
||||||
|
spdk_poller_unregister(&nvme_bdev_ctrlr->adminq_timer_poller);
|
||||||
|
free(nvme_bdev_ctrlr->name);
|
||||||
|
for (i = 0; i < nvme_bdev_ctrlr->num_ns; i++) {
|
||||||
|
free(nvme_bdev_ctrlr->namespaces[i]);
|
||||||
|
}
|
||||||
|
free(nvme_bdev_ctrlr->namespaces);
|
||||||
|
free(nvme_bdev_ctrlr);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
bdev_nvme_ctrlr_destruct(struct nvme_bdev_ctrlr *nvme_bdev_ctrlr)
|
||||||
|
{
|
||||||
|
assert(nvme_bdev_ctrlr->destruct);
|
||||||
|
if (nvme_bdev_ctrlr->opal_dev) {
|
||||||
|
if (nvme_bdev_ctrlr->opal_poller != NULL) {
|
||||||
|
spdk_poller_unregister(&nvme_bdev_ctrlr->opal_poller);
|
||||||
|
/* wait until we get the result */
|
||||||
|
while (spdk_opal_revert_poll(nvme_bdev_ctrlr->opal_dev) == -EAGAIN);
|
||||||
|
}
|
||||||
|
spdk_opal_close(nvme_bdev_ctrlr->opal_dev);
|
||||||
|
nvme_bdev_ctrlr->opal_dev = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
spdk_io_device_unregister(nvme_bdev_ctrlr, bdev_nvme_unregister_cb);
|
||||||
|
}
|
||||||
|
@ -120,4 +120,6 @@ struct nvme_bdev_ctrlr *nvme_bdev_next_ctrlr(struct nvme_bdev_ctrlr *prev);
|
|||||||
void nvme_bdev_dump_trid_json(struct spdk_nvme_transport_id *trid,
|
void nvme_bdev_dump_trid_json(struct spdk_nvme_transport_id *trid,
|
||||||
struct spdk_json_write_ctx *w);
|
struct spdk_json_write_ctx *w);
|
||||||
|
|
||||||
|
void bdev_nvme_ctrlr_destruct(struct nvme_bdev_ctrlr *nvme_bdev_ctrlr);
|
||||||
|
|
||||||
#endif /* SPDK_COMMON_BDEV_NVME_H */
|
#endif /* SPDK_COMMON_BDEV_NVME_H */
|
||||||
|
Loading…
Reference in New Issue
Block a user