lib/nvme: change api for io message
API changes in this patch:
1) nvme_io_msg_ctrlr_start => nvme_io_msg_ctrlr_register
2) nvme_io_msg_ctrlr_stop with (shutdown == false) => nvme_io_msg_ctrlr_unregister
3) nvme_io_msg_ctrlr_stop with (shutdown == true) => nvme_io_msg_ctrlr_detach
Signed-off-by: Tomasz Kulasek <tomaszx.kulasek@intel.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/474096 (master)
(cherry picked from commit 9eb0ffa90c
)
Change-Id: I60153ebbfb0d0b22575128d106f9333c3887213d
Signed-off-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/478346
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-by: Tomasz Kulasek <tomaszx.kulasek@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
This commit is contained in:
parent
44e398469d
commit
277cb377d9
@ -69,7 +69,7 @@ spdk_nvme_detach(struct spdk_nvme_ctrlr *ctrlr)
|
||||
nvme_ctrlr_proc_put_ref(ctrlr);
|
||||
|
||||
if (nvme_ctrlr_get_ref_count(ctrlr) == 0) {
|
||||
nvme_io_msg_ctrlr_stop(ctrlr, NULL, true);
|
||||
nvme_io_msg_ctrlr_detach(ctrlr);
|
||||
if (nvme_ctrlr_shared(ctrlr)) {
|
||||
TAILQ_REMOVE(&g_spdk_nvme_driver->shared_attached_ctrlrs, ctrlr, tailq);
|
||||
} else {
|
||||
|
@ -778,14 +778,14 @@ spdk_nvme_cuse_register(struct spdk_nvme_ctrlr *ctrlr, const char *dev_path)
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
rc = nvme_io_msg_ctrlr_start(ctrlr, &cuse_nvme_io_msg_producer);
|
||||
rc = nvme_io_msg_ctrlr_register(ctrlr, &cuse_nvme_io_msg_producer);
|
||||
if (rc) {
|
||||
return rc;
|
||||
}
|
||||
|
||||
rc = nvme_cuse_start(ctrlr, dev_path);
|
||||
if (rc) {
|
||||
nvme_io_msg_ctrlr_stop(ctrlr, &cuse_nvme_io_msg_producer, false);
|
||||
nvme_io_msg_ctrlr_unregister(ctrlr, &cuse_nvme_io_msg_producer);
|
||||
}
|
||||
|
||||
return rc;
|
||||
@ -796,7 +796,7 @@ spdk_nvme_cuse_unregister(struct spdk_nvme_ctrlr *ctrlr)
|
||||
{
|
||||
nvme_cuse_stop(ctrlr);
|
||||
|
||||
nvme_io_msg_ctrlr_stop(ctrlr, &cuse_nvme_io_msg_producer, false);
|
||||
nvme_io_msg_ctrlr_unregister(ctrlr, &cuse_nvme_io_msg_producer);
|
||||
}
|
||||
|
||||
char *
|
||||
|
@ -107,7 +107,8 @@ spdk_nvme_io_msg_process(struct spdk_nvme_ctrlr *ctrlr)
|
||||
}
|
||||
|
||||
int
|
||||
nvme_io_msg_ctrlr_start(struct spdk_nvme_ctrlr *ctrlr, struct nvme_io_msg_producer *io_msg_producer)
|
||||
nvme_io_msg_ctrlr_register(struct spdk_nvme_ctrlr *ctrlr,
|
||||
struct nvme_io_msg_producer *io_msg_producer)
|
||||
{
|
||||
if (io_msg_producer == NULL) {
|
||||
SPDK_ERRLOG("io_msg_producer cannot be NULL\n");
|
||||
@ -144,26 +145,12 @@ nvme_io_msg_ctrlr_start(struct spdk_nvme_ctrlr *ctrlr, struct nvme_io_msg_produc
|
||||
}
|
||||
|
||||
void
|
||||
nvme_io_msg_ctrlr_stop(struct spdk_nvme_ctrlr *ctrlr, struct nvme_io_msg_producer *io_msg_producer,
|
||||
bool shutdown)
|
||||
nvme_io_msg_ctrlr_detach(struct spdk_nvme_ctrlr *ctrlr)
|
||||
{
|
||||
if (STAILQ_EMPTY(&ctrlr->io_producers) && shutdown) {
|
||||
/* Shutdown path with no producers registered = io msg ctrlr not started */
|
||||
return;
|
||||
if (ctrlr->external_io_msgs) {
|
||||
spdk_ring_free(ctrlr->external_io_msgs);
|
||||
}
|
||||
|
||||
if (io_msg_producer != NULL) {
|
||||
STAILQ_REMOVE(&ctrlr->io_producers, io_msg_producer, nvme_io_msg_producer, link);
|
||||
}
|
||||
|
||||
if (!STAILQ_EMPTY(&ctrlr->io_producers) && !shutdown) {
|
||||
/* There are still some registered producers */
|
||||
return;
|
||||
}
|
||||
|
||||
assert(ctrlr->external_io_msgs);
|
||||
spdk_ring_free(ctrlr->external_io_msgs);
|
||||
|
||||
if (ctrlr->external_io_msgs_qpair) {
|
||||
spdk_nvme_ctrlr_free_io_qpair(ctrlr->external_io_msgs_qpair);
|
||||
ctrlr->external_io_msgs_qpair = NULL;
|
||||
@ -171,3 +158,16 @@ nvme_io_msg_ctrlr_stop(struct spdk_nvme_ctrlr *ctrlr, struct nvme_io_msg_produce
|
||||
|
||||
pthread_mutex_destroy(&ctrlr->external_io_msgs_lock);
|
||||
}
|
||||
|
||||
void
|
||||
nvme_io_msg_ctrlr_unregister(struct spdk_nvme_ctrlr *ctrlr,
|
||||
struct nvme_io_msg_producer *io_msg_producer)
|
||||
{
|
||||
if (io_msg_producer != NULL) {
|
||||
STAILQ_REMOVE(&ctrlr->io_producers, io_msg_producer, nvme_io_msg_producer, link);
|
||||
}
|
||||
|
||||
if (STAILQ_EMPTY(&ctrlr->io_producers)) {
|
||||
nvme_io_msg_ctrlr_detach(ctrlr);
|
||||
}
|
||||
}
|
||||
|
@ -78,9 +78,10 @@ int nvme_io_msg_send(struct spdk_nvme_ctrlr *ctrlr, uint32_t nsid, spdk_nvme_io_
|
||||
*/
|
||||
int spdk_nvme_io_msg_process(struct spdk_nvme_ctrlr *ctrlr);
|
||||
|
||||
int nvme_io_msg_ctrlr_start(struct spdk_nvme_ctrlr *ctrlr,
|
||||
struct nvme_io_msg_producer *io_msg_producer);
|
||||
void nvme_io_msg_ctrlr_stop(struct spdk_nvme_ctrlr *ctrlr,
|
||||
struct nvme_io_msg_producer *io_msg_producer, bool shutdown);
|
||||
int nvme_io_msg_ctrlr_register(struct spdk_nvme_ctrlr *ctrlr,
|
||||
struct nvme_io_msg_producer *io_msg_producer);
|
||||
void nvme_io_msg_ctrlr_unregister(struct spdk_nvme_ctrlr *ctrlr,
|
||||
struct nvme_io_msg_producer *io_msg_producer);
|
||||
void nvme_io_msg_ctrlr_detach(struct spdk_nvme_ctrlr *ctrlr);
|
||||
|
||||
#endif /* SPDK_NVME_IO_MSG_H_ */
|
||||
|
@ -60,8 +60,7 @@ DEFINE_STUB(nvme_transport_ctrlr_construct, struct spdk_nvme_ctrlr *,
|
||||
(const struct spdk_nvme_transport_id *trid,
|
||||
const struct spdk_nvme_ctrlr_opts *opts,
|
||||
void *devhandle), NULL);
|
||||
DEFINE_STUB_V(nvme_io_msg_ctrlr_stop, (struct spdk_nvme_ctrlr *ctrlr,
|
||||
struct nvme_io_msg_producer *io_msg_producer, bool shutdown));
|
||||
DEFINE_STUB_V(nvme_io_msg_ctrlr_detach, (struct spdk_nvme_ctrlr *ctrlr));
|
||||
|
||||
static bool ut_destruct_called = false;
|
||||
void
|
||||
|
Loading…
Reference in New Issue
Block a user