aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlex Elder <elder@inktank.com>2012-05-24 12:55:03 -0400
committerSage Weil <sage@inktank.com>2012-07-06 00:14:30 -0400
commit7593af920baac37752190a0db703d2732bed4a3b (patch)
treef660bc222db9b74305b8a2b8cc25d508bd0596a5
parentab166d5aa3bc036fba7efaca6e4e43a7e9510acf (diff)
libceph: distinguish two phases of connect sequence
Currently a ceph connection enters a "CONNECTING" state when it begins the process of (re-)connecting with its peer. Once the two ends have successfully exchanged their banner and addresses, an additional NEGOTIATING bit is set in the ceph connection's state to indicate the connection information exhange has begun. The CONNECTING bit/state continues to be set during this phase. Rather than have the CONNECTING state continue while the NEGOTIATING bit is set, interpret these two phases as distinct states. In other words, when NEGOTIATING is set, clear CONNECTING. That way only one of them will be active at a time. Signed-off-by: Alex Elder <elder@inktank.com> Reviewed-by: Sage Weil <sage@inktank.com>
-rw-r--r--net/ceph/messenger.c52
1 files changed, 28 insertions, 24 deletions
diff --git a/net/ceph/messenger.c b/net/ceph/messenger.c
index 5e67be3fa29..32a3a2a7258 100644
--- a/net/ceph/messenger.c
+++ b/net/ceph/messenger.c
@@ -1559,7 +1559,6 @@ static int process_connect(struct ceph_connection *con)
1559 return -1; 1559 return -1;
1560 } 1560 }
1561 clear_bit(NEGOTIATING, &con->state); 1561 clear_bit(NEGOTIATING, &con->state);
1562 clear_bit(CONNECTING, &con->state);
1563 set_bit(CONNECTED, &con->state); 1562 set_bit(CONNECTED, &con->state);
1564 con->peer_global_seq = le32_to_cpu(con->in_reply.global_seq); 1563 con->peer_global_seq = le32_to_cpu(con->in_reply.global_seq);
1565 con->connect_seq++; 1564 con->connect_seq++;
@@ -2000,7 +1999,8 @@ more_kvec:
2000 } 1999 }
2001 2000
2002do_next: 2001do_next:
2003 if (!test_bit(CONNECTING, &con->state)) { 2002 if (!test_bit(CONNECTING, &con->state) &&
2003 !test_bit(NEGOTIATING, &con->state)) {
2004 /* is anything else pending? */ 2004 /* is anything else pending? */
2005 if (!list_empty(&con->out_queue)) { 2005 if (!list_empty(&con->out_queue)) {
2006 prepare_write_message(con); 2006 prepare_write_message(con);
@@ -2057,25 +2057,29 @@ more:
2057 } 2057 }
2058 2058
2059 if (test_bit(CONNECTING, &con->state)) { 2059 if (test_bit(CONNECTING, &con->state)) {
2060 if (!test_bit(NEGOTIATING, &con->state)) { 2060 dout("try_read connecting\n");
2061 dout("try_read connecting\n"); 2061 ret = read_partial_banner(con);
2062 ret = read_partial_banner(con); 2062 if (ret <= 0)
2063 if (ret <= 0)
2064 goto out;
2065 ret = process_banner(con);
2066 if (ret < 0)
2067 goto out;
2068
2069 /* Banner is good, exchange connection info */
2070 ret = prepare_write_connect(con);
2071 if (ret < 0)
2072 goto out;
2073 prepare_read_connect(con);
2074 set_bit(NEGOTIATING, &con->state);
2075
2076 /* Send connection info before awaiting response */
2077 goto out; 2063 goto out;
2078 } 2064 ret = process_banner(con);
2065 if (ret < 0)
2066 goto out;
2067
2068 clear_bit(CONNECTING, &con->state);
2069 set_bit(NEGOTIATING, &con->state);
2070
2071 /* Banner is good, exchange connection info */
2072 ret = prepare_write_connect(con);
2073 if (ret < 0)
2074 goto out;
2075 prepare_read_connect(con);
2076
2077 /* Send connection info before awaiting response */
2078 goto out;
2079 }
2080
2081 if (test_bit(NEGOTIATING, &con->state)) {
2082 dout("try_read negotiating\n");
2079 ret = read_partial_connect(con); 2083 ret = read_partial_connect(con);
2080 if (ret <= 0) 2084 if (ret <= 0)
2081 goto out; 2085 goto out;
@@ -2197,12 +2201,12 @@ restart:
2197 if (test_and_clear_bit(SOCK_CLOSED, &con->flags)) { 2201 if (test_and_clear_bit(SOCK_CLOSED, &con->flags)) {
2198 if (test_and_clear_bit(CONNECTED, &con->state)) 2202 if (test_and_clear_bit(CONNECTED, &con->state))
2199 con->error_msg = "socket closed"; 2203 con->error_msg = "socket closed";
2200 else if (test_and_clear_bit(CONNECTING, &con->state)) { 2204 else if (test_and_clear_bit(NEGOTIATING, &con->state))
2201 clear_bit(NEGOTIATING, &con->state); 2205 con->error_msg = "negotiation failed";
2206 else if (test_and_clear_bit(CONNECTING, &con->state))
2202 con->error_msg = "connection failed"; 2207 con->error_msg = "connection failed";
2203 } else { 2208 else
2204 con->error_msg = "unrecognized con state"; 2209 con->error_msg = "unrecognized con state";
2205 }
2206 goto fault; 2210 goto fault;
2207 } 2211 }
2208 2212