nvme: remove transport qpair_destroy() function

Each transport should handle its own qpair cleanup internally.

Change-Id: I7dd737be820ea6bad686f4aad7d74044fad58a47
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
This commit is contained in:
Daniel Verkamp 2016-11-28 15:25:05 -07:00
parent ba16e46349
commit a9e436911f
7 changed files with 23 additions and 55 deletions

View File

@ -506,7 +506,6 @@ int nvme_qpair_construct(struct spdk_nvme_qpair *qpair, uint16_t id,
uint16_t num_entries,
struct spdk_nvme_ctrlr *ctrlr,
enum spdk_nvme_qprio qprio);
void nvme_qpair_destroy(struct spdk_nvme_qpair *qpair);
void nvme_qpair_enable(struct spdk_nvme_qpair *qpair);
void nvme_qpair_disable(struct spdk_nvme_qpair *qpair);
int nvme_qpair_submit_request(struct spdk_nvme_qpair *qpair,
@ -558,7 +557,6 @@ struct spdk_nvme_ctrlr *nvme_attach(enum spdk_nvme_transport transport,
int nvme_ ## name ## _ctrlr_delete_io_qpair(struct spdk_nvme_ctrlr *ctrlr, struct spdk_nvme_qpair *qpair); \
int nvme_ ## name ## _ctrlr_reinit_io_qpair(struct spdk_nvme_ctrlr *ctrlr, struct spdk_nvme_qpair *qpair); \
int nvme_ ## name ## _qpair_construct(struct spdk_nvme_qpair *qpair); \
int nvme_ ## name ## _qpair_destroy(struct spdk_nvme_qpair *qpair); \
int nvme_ ## name ## _qpair_enable(struct spdk_nvme_qpair *qpair); \
int nvme_ ## name ## _qpair_disable(struct spdk_nvme_qpair *qpair); \
int nvme_ ## name ## _qpair_reset(struct spdk_nvme_qpair *qpair); \

View File

@ -181,6 +181,8 @@ struct nvme_pcie_qpair {
uint64_t cpl_bus_addr;
};
static int nvme_pcie_qpair_destroy(struct spdk_nvme_qpair *qpair);
__thread struct nvme_pcie_ctrlr *g_thread_mmio_ctrlr = NULL;
static volatile uint16_t g_signal_lock;
static bool g_sigset = false;
@ -660,13 +662,9 @@ int
nvme_pcie_ctrlr_destruct(struct spdk_nvme_ctrlr *ctrlr)
{
struct nvme_pcie_ctrlr *pctrlr = nvme_pcie_ctrlr(ctrlr);
struct nvme_pcie_qpair *pqpair;
if (ctrlr->adminq) {
pqpair = nvme_pcie_qpair(ctrlr->adminq);
nvme_qpair_destroy(ctrlr->adminq);
spdk_free(pqpair);
nvme_pcie_qpair_destroy(ctrlr->adminq);
}
nvme_pcie_ctrlr_free_bars(pctrlr);
@ -1043,7 +1041,7 @@ nvme_pcie_admin_qpair_destroy(struct spdk_nvme_qpair *qpair)
nvme_pcie_admin_qpair_abort_aers(qpair);
}
int
static int
nvme_pcie_qpair_destroy(struct spdk_nvme_qpair *qpair)
{
struct nvme_pcie_qpair *pqpair = nvme_pcie_qpair(qpair);
@ -1053,17 +1051,16 @@ nvme_pcie_qpair_destroy(struct spdk_nvme_qpair *qpair)
}
if (pqpair->cmd && !pqpair->sq_in_cmb) {
spdk_free(pqpair->cmd);
pqpair->cmd = NULL;
}
if (pqpair->cpl) {
spdk_free(pqpair->cpl);
pqpair->cpl = NULL;
}
if (pqpair->tr) {
spdk_free(pqpair->tr);
pqpair->tr = NULL;
}
spdk_free(pqpair);
return 0;
}
@ -1313,7 +1310,7 @@ nvme_pcie_ctrlr_create_io_qpair(struct spdk_nvme_ctrlr *ctrlr, uint16_t qid,
rc = nvme_qpair_construct(qpair, qid, num_entries, ctrlr, qprio);
if (rc != 0) {
spdk_free(pqpair);
nvme_pcie_qpair_destroy(qpair);
return NULL;
}
@ -1321,8 +1318,7 @@ nvme_pcie_ctrlr_create_io_qpair(struct spdk_nvme_ctrlr *ctrlr, uint16_t qid,
if (rc != 0) {
SPDK_ERRLOG("I/O queue creation failed\n");
nvme_qpair_destroy(qpair);
spdk_free(pqpair);
nvme_pcie_qpair_destroy(qpair);
return NULL;
}
@ -1338,7 +1334,6 @@ nvme_pcie_ctrlr_reinit_io_qpair(struct spdk_nvme_ctrlr *ctrlr, struct spdk_nvme_
int
nvme_pcie_ctrlr_delete_io_qpair(struct spdk_nvme_ctrlr *ctrlr, struct spdk_nvme_qpair *qpair)
{
struct nvme_pcie_qpair *pqpair = nvme_pcie_qpair(qpair);
struct nvme_completion_poll_status status;
int rc;
@ -1370,8 +1365,7 @@ nvme_pcie_ctrlr_delete_io_qpair(struct spdk_nvme_ctrlr *ctrlr, struct spdk_nvme_
return -1;
}
nvme_qpair_destroy(qpair);
spdk_free(pqpair);
nvme_pcie_qpair_destroy(qpair);
return 0;
}

View File

@ -358,19 +358,12 @@ nvme_qpair_construct(struct spdk_nvme_qpair *qpair, uint16_t id,
if (nvme_transport_qpair_construct(qpair)) {
SPDK_ERRLOG("qpair_construct() failed\n");
nvme_qpair_destroy(qpair);
return -1;
}
return 0;
}
void
nvme_qpair_destroy(struct spdk_nvme_qpair *qpair)
{
nvme_transport_qpair_destroy(qpair);
}
int
nvme_qpair_submit_request(struct spdk_nvme_qpair *qpair, struct nvme_request *req)
{

View File

@ -127,6 +127,8 @@ struct spdk_nvme_rdma_rsp {
struct ibv_sge recv_sgl;
};
static int nvme_rdma_qpair_destroy(struct spdk_nvme_qpair *qpair);
static inline struct nvme_rdma_qpair *
nvme_rdma_qpair(struct spdk_nvme_qpair *qpair)
{
@ -649,7 +651,7 @@ nvme_rdma_qpair_connect(struct nvme_rdma_qpair *rqpair)
rc = nvmf_cm_construct(rqpair);
if (rc < 0) {
return nvme_transport_qpair_destroy(&rqpair->qpair);
return nvme_rdma_qpair_destroy(&rqpair->qpair);
}
ctrlr = rqpair->qpair.ctrlr;
@ -699,7 +701,7 @@ nvme_rdma_qpair_connect(struct nvme_rdma_qpair *rqpair)
return 0;
err:
return nvme_transport_qpair_destroy(&rqpair->qpair);;
return nvme_rdma_qpair_destroy(&rqpair->qpair);
}
static struct spdk_nvme_rdma_req *
@ -914,21 +916,16 @@ _nvme_rdma_ctrlr_create_qpair(struct spdk_nvme_ctrlr *ctrlr,
rc = nvme_rdma_qpair_connect(rqpair);
if (rc < 0) {
SPDK_ERRLOG("Failed to connect through rdma qpair\n");
goto err;
return rc;
}
rc = nvme_rdma_qpair_fabric_connect(rqpair);
if (rc < 0) {
SPDK_ERRLOG("Failed to send/receive the qpair fabric request\n");
goto err;
return rc;
}
return 0;
err:
nvme_transport_qpair_destroy(&rqpair->qpair);
return rc;
}
@ -968,15 +965,15 @@ nvme_rdma_ctrlr_create_qpair(struct spdk_nvme_ctrlr *ctrlr, uint16_t qid,
}
rc = _nvme_rdma_ctrlr_create_qpair(ctrlr, qpair);
if (rc < 0) {
nvme_rdma_qpair_destroy(qpair);
return NULL;
}
return qpair;
}
int
static int
nvme_rdma_qpair_destroy(struct spdk_nvme_qpair *qpair)
{
struct nvme_rdma_qpair *rqpair;
@ -1213,6 +1210,10 @@ nvme_rdma_ctrlr_destruct(struct spdk_nvme_ctrlr *ctrlr)
{
struct nvme_rdma_ctrlr *rctrlr = nvme_rdma_ctrlr(ctrlr);
if (ctrlr->adminq) {
nvme_rdma_qpair_destroy(ctrlr->adminq);
}
free(rctrlr);
return 0;
@ -1299,8 +1300,7 @@ nvme_rdma_qpair_submit_request(struct spdk_nvme_qpair *qpair,
int
nvme_rdma_ctrlr_delete_io_qpair(struct spdk_nvme_ctrlr *ctrlr, struct spdk_nvme_qpair *qpair)
{
return nvme_transport_qpair_destroy(qpair);
return nvme_rdma_qpair_destroy(qpair);
}
int
@ -1318,6 +1318,7 @@ nvme_rdma_qpair_construct(struct spdk_nvme_qpair *qpair)
rqpair = nvme_rdma_qpair(qpair);
rqpair->rdma_reqs = calloc(qpair->num_entries, sizeof(struct spdk_nvme_rdma_req));
if (rqpair->rdma_reqs == NULL) {
nvme_rdma_qpair_destroy(qpair);
return -1;
}

View File

@ -172,12 +172,6 @@ nvme_transport_qpair_construct(struct spdk_nvme_qpair *qpair)
NVME_TRANSPORT_CALL(qpair->transport, qpair_construct, (qpair));
}
int
nvme_transport_qpair_destroy(struct spdk_nvme_qpair *qpair)
{
NVME_TRANSPORT_CALL(qpair->transport, qpair_destroy, (qpair));
}
int
nvme_transport_qpair_enable(struct spdk_nvme_qpair *qpair)
{

View File

@ -248,11 +248,6 @@ nvme_qpair_disable(struct spdk_nvme_qpair *qpair)
{
}
void
nvme_qpair_destroy(struct spdk_nvme_qpair *qpair)
{
}
void
nvme_qpair_enable(struct spdk_nvme_qpair *qpair)
{

View File

@ -189,12 +189,6 @@ nvme_transport_qpair_construct(struct spdk_nvme_qpair *qpair)
return 0;
}
int
nvme_transport_qpair_destroy(struct spdk_nvme_qpair *qpair)
{
return 0;
}
int
nvme_transport_qpair_enable(struct spdk_nvme_qpair *qpair)
{
@ -243,7 +237,6 @@ prepare_submit_request_test(struct spdk_nvme_qpair *qpair,
static void
cleanup_submit_request_test(struct spdk_nvme_qpair *qpair)
{
nvme_qpair_destroy(qpair);
}
#if 0 /* TODO: move to PCIe-specific unit test */