aboutsummaryrefslogtreecommitdiffstats
path: root/net/ceph/messenger.c
diff options
context:
space:
mode:
authorAlex Elder <elder@inktank.com>2012-05-29 12:04:58 -0400
committerAlex Elder <elder@dreamhost.com>2012-06-01 09:37:56 -0400
commita5988c490ef66cb04ea2f610681949b25c773b3c (patch)
treea2bf615fb7df0bf61ea23720a2ffe6337cba254a /net/ceph/messenger.c
parente10006f807ffc4d5b1d861305d18d9e8145891ca (diff)
libceph: set CLOSED state bit in con_init
Once a connection is fully initialized, it is really in a CLOSED state, so make that explicit by setting the bit in its state field. It is possible for a connection in NEGOTIATING state to get a failure, leading to ceph_fault() and ultimately ceph_con_close(). Clear that bits if it is set in that case, to reflect that the connection truly is closed and is no longer participating in a connect sequence. Issue a warning if ceph_con_open() is called on a connection that is not in CLOSED state. Signed-off-by: Alex Elder <elder@inktank.com> Reviewed-by: Sage Weil <sage@inktank.com>
Diffstat (limited to 'net/ceph/messenger.c')
-rw-r--r--net/ceph/messenger.c15
1 files changed, 11 insertions, 4 deletions
diff --git a/net/ceph/messenger.c b/net/ceph/messenger.c
index a4ac3deec161..36b440a00cc2 100644
--- a/net/ceph/messenger.c
+++ b/net/ceph/messenger.c
@@ -454,11 +454,14 @@ void ceph_con_close(struct ceph_connection *con)
454{ 454{
455 dout("con_close %p peer %s\n", con, 455 dout("con_close %p peer %s\n", con,
456 ceph_pr_addr(&con->peer_addr.in_addr)); 456 ceph_pr_addr(&con->peer_addr.in_addr));
457 set_bit(CLOSED, &con->state); /* in case there's queued work */ 457 clear_bit(NEGOTIATING, &con->state);
458 clear_bit(STANDBY, &con->state); /* avoid connect_seq bump */ 458 clear_bit(STANDBY, &con->state); /* avoid connect_seq bump */
459 set_bit(CLOSED, &con->state);
460
459 clear_bit(LOSSYTX, &con->flags); /* so we retry next connect */ 461 clear_bit(LOSSYTX, &con->flags); /* so we retry next connect */
460 clear_bit(KEEPALIVE_PENDING, &con->flags); 462 clear_bit(KEEPALIVE_PENDING, &con->flags);
461 clear_bit(WRITE_PENDING, &con->flags); 463 clear_bit(WRITE_PENDING, &con->flags);
464
462 mutex_lock(&con->mutex); 465 mutex_lock(&con->mutex);
463 reset_connection(con); 466 reset_connection(con);
464 con->peer_global_seq = 0; 467 con->peer_global_seq = 0;
@@ -475,7 +478,8 @@ void ceph_con_open(struct ceph_connection *con, struct ceph_entity_addr *addr)
475{ 478{
476 dout("con_open %p %s\n", con, ceph_pr_addr(&addr->in_addr)); 479 dout("con_open %p %s\n", con, ceph_pr_addr(&addr->in_addr));
477 set_bit(OPENING, &con->state); 480 set_bit(OPENING, &con->state);
478 clear_bit(CLOSED, &con->state); 481 WARN_ON(!test_and_clear_bit(CLOSED, &con->state));
482
479 memcpy(&con->peer_addr, addr, sizeof(*addr)); 483 memcpy(&con->peer_addr, addr, sizeof(*addr));
480 con->delay = 0; /* reset backoff memory */ 484 con->delay = 0; /* reset backoff memory */
481 queue_con(con); 485 queue_con(con);
@@ -530,6 +534,8 @@ void ceph_con_init(struct ceph_messenger *msgr, struct ceph_connection *con)
530 INIT_LIST_HEAD(&con->out_queue); 534 INIT_LIST_HEAD(&con->out_queue);
531 INIT_LIST_HEAD(&con->out_sent); 535 INIT_LIST_HEAD(&con->out_sent);
532 INIT_DELAYED_WORK(&con->work, con_work); 536 INIT_DELAYED_WORK(&con->work, con_work);
537
538 set_bit(CLOSED, &con->state);
533} 539}
534EXPORT_SYMBOL(ceph_con_init); 540EXPORT_SYMBOL(ceph_con_init);
535 541
@@ -1933,14 +1939,15 @@ more:
1933 1939
1934 /* open the socket first? */ 1940 /* open the socket first? */
1935 if (con->sock == NULL) { 1941 if (con->sock == NULL) {
1942 clear_bit(NEGOTIATING, &con->state);
1943 set_bit(CONNECTING, &con->state);
1944
1936 con_out_kvec_reset(con); 1945 con_out_kvec_reset(con);
1937 prepare_write_banner(con); 1946 prepare_write_banner(con);
1938 ret = prepare_write_connect(con); 1947 ret = prepare_write_connect(con);
1939 if (ret < 0) 1948 if (ret < 0)
1940 goto out; 1949 goto out;
1941 prepare_read_banner(con); 1950 prepare_read_banner(con);
1942 set_bit(CONNECTING, &con->state);
1943 clear_bit(NEGOTIATING, &con->state);
1944 1951
1945 BUG_ON(con->in_msg); 1952 BUG_ON(con->in_msg);
1946 con->in_tag = CEPH_MSGR_TAG_READY; 1953 con->in_tag = CEPH_MSGR_TAG_READY;