Commit 88c4015f authored by Sagi Grimberg's avatar Sagi Grimberg Committed by Nicholas Bellinger

Target/iser: Improve cm events handling

There are 4 RDMA_CM events that all basically mean that
the user should teardown the IB connection:
- DISCONNECTED
- ADDR_CHANGE
- DEVICE_REMOVAL
- TIMEWAIT_EXIT

Only in DISCONNECTED/ADDR_CHANGE it makes sense to
call rdma_disconnect (send DREQ/DREP to our initiator).
So we keep the same teardown handler for all of them
but only indicate calling rdma_disconnect for the relevant
events.

This patch also removes redundant debug prints for each single
event.

v2 changes:
 - Call isert_disconnected_handler() for DEVICE_REMOVAL (Or + Sag)
Signed-off-by: default avatarSagi Grimberg <sagig@mellanox.com>
Cc: stable@vger.kernel.org # 3.10+
Signed-off-by: default avatarNicholas Bellinger <nab@linux-iscsi.org>
parent 9d49f5e2
...@@ -788,8 +788,10 @@ isert_disconnect_work(struct work_struct *work) ...@@ -788,8 +788,10 @@ isert_disconnect_work(struct work_struct *work)
return; return;
} }
/* Send DREQ/DREP towards our initiator */ if (isert_conn->disconnect) {
rdma_disconnect(isert_conn->conn_cm_id); /* Send DREQ/DREP towards our initiator */
rdma_disconnect(isert_conn->conn_cm_id);
}
mutex_unlock(&isert_conn->conn_mutex); mutex_unlock(&isert_conn->conn_mutex);
...@@ -799,10 +801,11 @@ isert_disconnect_work(struct work_struct *work) ...@@ -799,10 +801,11 @@ isert_disconnect_work(struct work_struct *work)
} }
static void static void
isert_disconnected_handler(struct rdma_cm_id *cma_id) isert_disconnected_handler(struct rdma_cm_id *cma_id, bool disconnect)
{ {
struct isert_conn *isert_conn = (struct isert_conn *)cma_id->context; struct isert_conn *isert_conn = (struct isert_conn *)cma_id->context;
isert_conn->disconnect = disconnect;
INIT_WORK(&isert_conn->conn_logout_work, isert_disconnect_work); INIT_WORK(&isert_conn->conn_logout_work, isert_disconnect_work);
schedule_work(&isert_conn->conn_logout_work); schedule_work(&isert_conn->conn_logout_work);
} }
...@@ -811,29 +814,28 @@ static int ...@@ -811,29 +814,28 @@ static int
isert_cma_handler(struct rdma_cm_id *cma_id, struct rdma_cm_event *event) isert_cma_handler(struct rdma_cm_id *cma_id, struct rdma_cm_event *event)
{ {
int ret = 0; int ret = 0;
bool disconnect = false;
pr_debug("isert_cma_handler: event %d status %d conn %p id %p\n", pr_debug("isert_cma_handler: event %d status %d conn %p id %p\n",
event->event, event->status, cma_id->context, cma_id); event->event, event->status, cma_id->context, cma_id);
switch (event->event) { switch (event->event) {
case RDMA_CM_EVENT_CONNECT_REQUEST: case RDMA_CM_EVENT_CONNECT_REQUEST:
pr_debug("RDMA_CM_EVENT_CONNECT_REQUEST: >>>>>>>>>>>>>>>\n");
ret = isert_connect_request(cma_id, event); ret = isert_connect_request(cma_id, event);
break; break;
case RDMA_CM_EVENT_ESTABLISHED: case RDMA_CM_EVENT_ESTABLISHED:
pr_debug("RDMA_CM_EVENT_ESTABLISHED >>>>>>>>>>>>>>\n");
isert_connected_handler(cma_id); isert_connected_handler(cma_id);
break; break;
case RDMA_CM_EVENT_DISCONNECTED: case RDMA_CM_EVENT_ADDR_CHANGE: /* FALLTHRU */
pr_debug("RDMA_CM_EVENT_DISCONNECTED: >>>>>>>>>>>>>>\n"); case RDMA_CM_EVENT_DISCONNECTED: /* FALLTHRU */
isert_disconnected_handler(cma_id); case RDMA_CM_EVENT_DEVICE_REMOVAL: /* FALLTHRU */
break; disconnect = true;
case RDMA_CM_EVENT_DEVICE_REMOVAL: case RDMA_CM_EVENT_TIMEWAIT_EXIT: /* FALLTHRU */
case RDMA_CM_EVENT_ADDR_CHANGE: isert_disconnected_handler(cma_id, disconnect);
break; break;
case RDMA_CM_EVENT_CONNECT_ERROR: case RDMA_CM_EVENT_CONNECT_ERROR:
default: default:
pr_err("Unknown RDMA CMA event: %d\n", event->event); pr_err("Unhandled RDMA CMA event: %d\n", event->event);
break; break;
} }
......
...@@ -150,6 +150,7 @@ struct isert_conn { ...@@ -150,6 +150,7 @@ struct isert_conn {
#define ISERT_COMP_BATCH_COUNT 8 #define ISERT_COMP_BATCH_COUNT 8
int conn_comp_batch; int conn_comp_batch;
struct llist_head conn_comp_llist; struct llist_head conn_comp_llist;
bool disconnect;
}; };
#define ISERT_MAX_CQ 64 #define ISERT_MAX_CQ 64
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment