[rds-devel] [PATCH future/20090207 1/2] RDS/IB+IW: Grab the CM lock when processing connect requests.

Steve Wise swise at opengridcomputing.com
Wed Feb 11 13:06:50 PST 2009


Signed-off-by: Steve Wise <swise at opengridcomputing.com>
---

 net/rds/ib_cm.c |   22 +++++++++++++---------
 net/rds/iw_cm.c |   22 +++++++++++++---------
 2 files changed, 26 insertions(+), 18 deletions(-)

diff --git a/net/rds/ib_cm.c b/net/rds/ib_cm.c
index 870070d..3bc7851 100644
--- a/net/rds/ib_cm.c
+++ b/net/rds/ib_cm.c
@@ -423,15 +423,6 @@ static int rds_ib_cm_handle_connect(struct rdma_cm_id *cm_id,
 		conn = NULL;
 		goto out;
 	}
-	ic = conn->c_transport_data;
-
-	rds_ib_set_protocol(conn, version);
-	rds_ib_set_flow_control(conn, be32_to_cpu(dp->dp_credit));
-
-	/* If the peer gave us the last packet it saw, process this as if
-	 * we had received a regular ACK. */
-	if (dp->dp_ack_seq)
-		rds_send_drop_acked(conn, be64_to_cpu(dp->dp_ack_seq), NULL);
 
 	/*
 	 * The connection request may occur while the
@@ -440,6 +431,7 @@ static int rds_ib_cm_handle_connect(struct rdma_cm_id *cm_id,
 	 * by both hosts, we have a random backoff mechanism -
 	 * see the comment above rds_queue_reconnect()
 	 */
+	mutex_lock(&conn->c_cm_lock);
 	if (!rds_conn_transition(conn, RDS_CONN_DOWN, RDS_CONN_CONNECTING)) {
 		if (rds_conn_state(conn) == RDS_CONN_UP) {
 			rdsdebug("incoming connect while connecting\n");
@@ -450,9 +442,20 @@ static int rds_ib_cm_handle_connect(struct rdma_cm_id *cm_id,
 			/* Wait and see - our connect may still be succeeding */
 			rds_ib_stats_inc(s_ib_connect_raced);
 		}
+		mutex_unlock(&conn->c_cm_lock);
 		goto out;
 	}
 
+	ic = conn->c_transport_data;
+
+	rds_ib_set_protocol(conn, version);
+	rds_ib_set_flow_control(conn, be32_to_cpu(dp->dp_credit));
+
+	/* If the peer gave us the last packet it saw, process this as if
+	 * we had received a regular ACK. */
+	if (dp->dp_ack_seq)
+		rds_send_drop_acked(conn, be64_to_cpu(dp->dp_ack_seq), NULL);
+
 	BUG_ON(cm_id->context);
 	BUG_ON(ic->i_cm_id);
 
@@ -473,6 +476,7 @@ static int rds_ib_cm_handle_connect(struct rdma_cm_id *cm_id,
 
 	/* rdma_accept() calls rdma_reject() internally if it fails */
 	err = rdma_accept(cm_id, &conn_param);
+	mutex_unlock(&conn->c_cm_lock);
 	if (err) {
 		rds_ib_conn_error(conn, "rdma_accept failed (%d)\n", err);
 		goto out;
diff --git a/net/rds/iw_cm.c b/net/rds/iw_cm.c
index 2f03072..9090eb9 100644
--- a/net/rds/iw_cm.c
+++ b/net/rds/iw_cm.c
@@ -408,15 +408,6 @@ static int rds_iw_cm_handle_connect(struct rdma_cm_id *cm_id,
 		conn = NULL;
 		goto out;
 	}
-	ic = conn->c_transport_data;
-
-	rds_iw_set_protocol(conn, version);
-	rds_iw_set_flow_control(conn, be32_to_cpu(dp->dp_credit));
-
-	/* If the peer gave us the last packet it saw, process this as if
-	 * we had received a regular ACK. */
-	if (dp->dp_ack_seq)
-		rds_send_drop_acked(conn, be64_to_cpu(dp->dp_ack_seq), NULL);
 
 	/*
 	 * The connection request may occur while the
@@ -425,6 +416,7 @@ static int rds_iw_cm_handle_connect(struct rdma_cm_id *cm_id,
 	 * by both hosts, we have a random backoff mechanism -
 	 * see the comment above rds_queue_reconnect()
 	 */
+	mutex_lock(&conn->c_cm_lock);
 	if (!rds_conn_transition(conn, RDS_CONN_DOWN, RDS_CONN_CONNECTING)) {
 		if (rds_conn_state(conn) == RDS_CONN_UP) {
 			rdsdebug("incoming connect while connecting\n");
@@ -435,9 +427,20 @@ static int rds_iw_cm_handle_connect(struct rdma_cm_id *cm_id,
 			/* Wait and see - our connect may still be succeeding */
 			rds_iw_stats_inc(s_iw_connect_raced);
 		}
+		mutex_unlock(&conn->c_cm_lock);
 		goto out;
 	}
 
+	ic = conn->c_transport_data;
+
+	rds_iw_set_protocol(conn, version);
+	rds_iw_set_flow_control(conn, be32_to_cpu(dp->dp_credit));
+
+	/* If the peer gave us the last packet it saw, process this as if
+	 * we had received a regular ACK. */
+	if (dp->dp_ack_seq)
+		rds_send_drop_acked(conn, be64_to_cpu(dp->dp_ack_seq), NULL);
+
 	BUG_ON(cm_id->context);
 	BUG_ON(ic->i_cm_id);
 
@@ -464,6 +467,7 @@ static int rds_iw_cm_handle_connect(struct rdma_cm_id *cm_id,
 
 	/* rdma_accept() calls rdma_reject() internally if it fails */
 	err = rdma_accept(cm_id, &conn_param);
+	mutex_unlock(&conn->c_cm_lock);
 	if (err) {
 		rds_iw_conn_error(conn, "rdma_accept failed (%d)\n", err);
 		goto out;




More information about the rds-devel mailing list