[ofa-general] [PATCH 1/4] sdp: Use sdp_set_state()

Amir Vadai amirv at mellanox.co.il
Thu Jun 19 07:57:54 PDT 2008


Fix all places that change sk_state directly to use sdp_set_state()

Signed-off-by: Amir Vadai <amirv at mellanox.co.il>
---
 drivers/infiniband/ulp/sdp/sdp.h       |   12 ++++++------
 drivers/infiniband/ulp/sdp/sdp_bcopy.c |    4 ++--
 drivers/infiniband/ulp/sdp/sdp_cma.c   |    6 +++---
 drivers/infiniband/ulp/sdp/sdp_main.c  |   18 +++++++++---------
 4 files changed, 20 insertions(+), 20 deletions(-)

diff --git a/drivers/infiniband/ulp/sdp/sdp.h b/drivers/infiniband/ulp/sdp/sdp.h
index bb2434a..5bd4041 100644
--- a/drivers/infiniband/ulp/sdp/sdp.h
+++ b/drivers/infiniband/ulp/sdp/sdp.h
@@ -218,13 +218,18 @@ static inline struct sdp_sock *sdp_sk(const struct sock *sk)
 	        return (struct sdp_sock *)sk;
 }
 
+static inline void sdp_set_state(struct sock *sk, int state)
+{
+	sk->sk_state = state;
+}
+
 static inline void sdp_set_error(struct sock *sk, int err)
 {
 	sk->sk_err = -err;
 	if (sk->sk_socket)
 		sk->sk_socket->state = SS_UNCONNECTED;
 
-	sk->sk_state = TCP_CLOSE;
+	sdp_set_state(sk, TCP_CLOSE);
 
 	if (sdp_sk(sk)->time_wait) {
 		sdp_dbg(sk, "%s: destroy in time wait state\n", __func__);
@@ -235,11 +240,6 @@ static inline void sdp_set_error(struct sock *sk, int err)
 	sk->sk_error_report(sk);
 }
 
-static inline void sdp_set_state(struct sock *sk, int state)
-{
-	sk->sk_state = state;
-}
-
 extern struct workqueue_struct *sdp_workqueue;
 
 int sdp_cma_handler(struct rdma_cm_id *, struct rdma_cm_event *);
diff --git a/drivers/infiniband/ulp/sdp/sdp_bcopy.c b/drivers/infiniband/ulp/sdp/sdp_bcopy.c
index be7c598..05825bf 100644
--- a/drivers/infiniband/ulp/sdp/sdp_bcopy.c
+++ b/drivers/infiniband/ulp/sdp/sdp_bcopy.c
@@ -544,9 +544,9 @@ void sdp_post_sends(struct sdp_sock *ssk, int nonagle)
 		BUG_ON(!skb);
 		sdp_post_send(ssk, skb, SDP_MID_DISCONN);
 		if (ssk->isk.sk.sk_state == TCP_FIN_WAIT1)
-			ssk->isk.sk.sk_state = TCP_FIN_WAIT2;
+			sdp_set_state(&ssk->isk.sk, TCP_FIN_WAIT2);
 		else
-			ssk->isk.sk.sk_state = TCP_CLOSING;
+			sdp_set_state(&ssk->isk.sk, TCP_CLOSING);
 	}
 }
 
diff --git a/drivers/infiniband/ulp/sdp/sdp_cma.c b/drivers/infiniband/ulp/sdp/sdp_cma.c
index 2e4ceb5..f2fb083 100644
--- a/drivers/infiniband/ulp/sdp/sdp_cma.c
+++ b/drivers/infiniband/ulp/sdp/sdp_cma.c
@@ -256,7 +256,7 @@ int sdp_connect_handler(struct sock *sk, struct rdma_cm_id *id,
 	list_add_tail(&sdp_sk(child)->backlog_queue, &sdp_sk(sk)->backlog_queue);
 	sdp_sk(child)->parent = sk;
 
-	child->sk_state = TCP_SYN_RECV;
+	sdp_set_state(child, TCP_SYN_RECV);
 
 	/* child->sk_write_space(child); */
 	/* child->sk_data_ready(child, 0); */
@@ -272,7 +272,7 @@ static int sdp_response_handler(struct sock *sk, struct rdma_cm_id *id,
 	struct sockaddr_in *dst_addr;
 	sdp_dbg(sk, "%s\n", __func__);
 
-	sk->sk_state = TCP_ESTABLISHED;
+	sdp_set_state(sk, TCP_ESTABLISHED);
 
 	if (sock_flag(sk, SOCK_KEEPOPEN))
 		sdp_start_keepalive_timer(sk);
@@ -316,7 +316,7 @@ int sdp_connected_handler(struct sock *sk, struct rdma_cm_event *event)
 	parent = sdp_sk(sk)->parent;
 	BUG_ON(!parent);
 
-	sk->sk_state = TCP_ESTABLISHED;
+	sdp_set_state(sk, TCP_ESTABLISHED);
 
 	if (sock_flag(sk, SOCK_KEEPOPEN))
 		sdp_start_keepalive_timer(sk);
diff --git a/drivers/infiniband/ulp/sdp/sdp_main.c b/drivers/infiniband/ulp/sdp/sdp_main.c
index 8f1e8b0..acd3aab 100644
--- a/drivers/infiniband/ulp/sdp/sdp_main.c
+++ b/drivers/infiniband/ulp/sdp/sdp_main.c
@@ -452,9 +452,9 @@ static int sdp_close_state(struct sock *sk)
 		return 0;
 
 	if (sk->sk_state == TCP_ESTABLISHED)
-		sk->sk_state = TCP_FIN_WAIT1;
+		sdp_set_state(sk, TCP_FIN_WAIT1);
 	else if (sk->sk_state == TCP_CLOSE_WAIT)
-		sk->sk_state = TCP_LAST_ACK;
+		sdp_set_state(sk, TCP_LAST_ACK);
 	else
 		return 0;
 	return 1;
@@ -553,7 +553,7 @@ adjudge_to_death:
 	if (sk->sk_state == TCP_FIN_WAIT2 &&
 		!sk->sk_send_head &&
 		sdp_sk(sk)->tx_head == sdp_sk(sk)->tx_tail) {
-		sk->sk_state = TCP_CLOSE;
+		sdp_set_state(sk, TCP_CLOSE);
 	}
 
 	if ((1 << sk->sk_state) & (TCPF_FIN_WAIT1 | TCPF_FIN_WAIT2)) {
@@ -622,7 +622,7 @@ static int sdp_connect(struct sock *sk, struct sockaddr *uaddr, int addr_len)
 		return rc;
 	}
 
-	sk->sk_state = TCP_SYN_SENT;
+	sdp_set_state(sk, TCP_SYN_SENT);
 	return 0;
 }
 
@@ -853,7 +853,7 @@ void sdp_time_wait_work(struct work_struct *work)
 
 	sdp_dbg(sk, "%s: refcnt %d\n", __func__, atomic_read(&sk->sk_refcnt));
 
-	sk->sk_state = TCP_CLOSE;
+	sdp_set_state(sk, TCP_CLOSE);
 	sdp_sk(sk)->time_wait = 0;
 	release_sock(sk);
 
@@ -864,7 +864,7 @@ void sdp_time_wait_work(struct work_struct *work)
 void sdp_time_wait_destroy_sk(struct sdp_sock *ssk)
 {
 	ssk->time_wait = 0;
-	ssk->isk.sk.sk_state = TCP_CLOSE;
+	sdp_set_state(&ssk->isk.sk, TCP_CLOSE);
 	queue_work(sdp_workqueue, &ssk->destroy_work);
 }
 
@@ -895,9 +895,9 @@ static void sdp_shutdown(struct sock *sk, int how)
 		return;
 
 	if (sk->sk_state == TCP_ESTABLISHED)
-		sk->sk_state = TCP_FIN_WAIT1;
+		sdp_set_state(sk, TCP_FIN_WAIT1);
 	else if (sk->sk_state == TCP_CLOSE_WAIT)
-		sk->sk_state = TCP_LAST_ACK;
+		sdp_set_state(sk, TCP_LAST_ACK);
 	else
 		return;
 
@@ -1991,7 +1991,7 @@ static int sdp_listen(struct sock *sk, int backlog)
 		sdp_warn(sk, "rdma_listen failed: %d\n", rc);
 		sdp_set_error(sk, rc);
 	} else
-		sk->sk_state = TCP_LISTEN;
+		sdp_set_state(sk, TCP_LISTEN);
 	return rc;
 }
 
-- 
1.5.2




More information about the general mailing list