From 90c28166c09a9c5fdc941195b2e4f908eb02c4f2 Mon Sep 17 00:00:00 2001 From: Daniel Verkamp Date: Thu, 23 Jun 2016 11:54:54 -0700 Subject: [PATCH] nvmf: use cm_id context to store conn pointer Instead of searching the global list of connections to find a matching cm_id, we can just store the pointer back to the spdk_nvmf_conn in the rdma_cm_id context field. Change-Id: I39ea16be6a633a1136d65743747b63b600f20e63 Signed-off-by: Daniel Verkamp --- lib/nvmf/conn.c | 15 --------------- lib/nvmf/conn.h | 3 --- lib/nvmf/rdma.c | 3 ++- 3 files changed, 2 insertions(+), 19 deletions(-) diff --git a/lib/nvmf/conn.c b/lib/nvmf/conn.c index c5f42f68f7..1e32e390c8 100644 --- a/lib/nvmf/conn.c +++ b/lib/nvmf/conn.c @@ -128,21 +128,6 @@ free_conn(struct spdk_nvmf_conn *conn) conn->is_valid = 0; } -struct spdk_nvmf_conn * -spdk_find_nvmf_conn_by_cm_id(struct rdma_cm_id *cm_id) -{ - int i; - - for (i = 0; i < g_max_conns; i++) { - if ((g_conns_array[i].is_valid == 1) && - (g_conns_array[i].cm_id == cm_id)) { - return &g_conns_array[i]; - } - } - - return NULL; -} - static struct spdk_nvmf_conn * spdk_find_nvmf_conn_by_cntlid(int cntlid) { diff --git a/lib/nvmf/conn.h b/lib/nvmf/conn.h index ed53a9cc9d..1f67ea6e5f 100644 --- a/lib/nvmf/conn.h +++ b/lib/nvmf/conn.h @@ -102,7 +102,4 @@ spdk_nvmf_allocate_conn(void); int spdk_nvmf_startup_conn(struct spdk_nvmf_conn *conn); -struct spdk_nvmf_conn * -spdk_find_nvmf_conn_by_cm_id(struct rdma_cm_id *cm_id); - #endif /* NVMF_CONN_H */ diff --git a/lib/nvmf/rdma.c b/lib/nvmf/rdma.c index 948c6dd178..dd52569d41 100644 --- a/lib/nvmf/rdma.c +++ b/lib/nvmf/rdma.c @@ -475,6 +475,7 @@ nvmf_rdma_cm_connect(struct rdma_cm_event *event) * and also to ibv_device (cm_id->verbs->device) */ conn->cm_id = conn_id; + conn_id->context = conn; /* check for private data */ if (event->param.conn.private_data_len < sizeof(union spdk_nvmf_rdma_private_data)) { @@ -655,7 +656,7 @@ nvmf_rdma_cm_disconnect(struct rdma_cm_event *event) } conn_id = event->id; - conn = spdk_find_nvmf_conn_by_cm_id(conn_id); + conn = conn_id->context; if (conn == NULL) { SPDK_ERRLOG("disconnect request: no active connection\n"); goto err0;