Patchwork [3.5.yuz,extended,stable] Patch "libceph: set CLOSED state bit in con_init" has been added to staging queue

mail settings
Submitter Herton Ronaldo Krzesinski
Date Nov. 20, 2012, 5:15 p.m.
Message ID <>
Download mbox | patch
Permalink /patch/200416/
State New
Headers show


Herton Ronaldo Krzesinski - Nov. 20, 2012, 5:15 p.m.
This is a note to let you know that I have just added a patch titled

    libceph: set CLOSED state bit in con_init

to the linux-3.5.y-queue branch of the 3.5.yuz extended stable tree 
which can be found at:;a=shortlog;h=refs/heads/linux-3.5.y-queue

If you, or anyone else, feels it should not be added to this tree, please 
reply to this email.

For more information about the 3.5.yuz tree, see



From c87d5dcc64e89009a18a32cd4f8f8bfa4293f4c8 Mon Sep 17 00:00:00 2001
From: Alex Elder <>
Date: Tue, 29 May 2012 11:04:58 -0500
Subject: [PATCH 09/78] libceph: set CLOSED state bit in con_init

commit a5988c490ef66cb04ea2f610681949b25c773b3c upstream.

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 <>
Reviewed-by: Sage Weil <>
Signed-off-by: Herton Ronaldo Krzesinski <>
 net/ceph/messenger.c |   15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)



diff --git a/net/ceph/messenger.c b/net/ceph/messenger.c
index 3239d3d..603d8b5 100644
--- a/net/ceph/messenger.c
+++ b/net/ceph/messenger.c
@@ -454,11 +454,14 @@  void ceph_con_close(struct ceph_connection *con)
 	dout("con_close %p peer %s\n", con,
-	set_bit(CLOSED, &con->state);  /* in case there's queued work */
+	clear_bit(NEGOTIATING, &con->state);
 	clear_bit(STANDBY, &con->state);  /* avoid connect_seq bump */
+	set_bit(CLOSED, &con->state);
 	clear_bit(LOSSYTX, &con->flags);  /* so we retry next connect */
 	clear_bit(KEEPALIVE_PENDING, &con->flags);
 	clear_bit(WRITE_PENDING, &con->flags);
 	con->peer_global_seq = 0;
@@ -475,7 +478,8 @@  void ceph_con_open(struct ceph_connection *con, struct ceph_entity_addr *addr)
 	dout("con_open %p %s\n", con, ceph_pr_addr(&addr->in_addr));
 	set_bit(OPENING, &con->state);
-	clear_bit(CLOSED, &con->state);
+	WARN_ON(!test_and_clear_bit(CLOSED, &con->state));
 	memcpy(&con->peer_addr, addr, sizeof(*addr));
 	con->delay = 0;      /* reset backoff memory */
@@ -530,6 +534,8 @@  void ceph_con_init(struct ceph_messenger *msgr, struct ceph_connection *con)
 	INIT_DELAYED_WORK(&con->work, con_work);
+	set_bit(CLOSED, &con->state);

@@ -1937,14 +1943,15 @@  more:

 	/* open the socket first? */
 	if (con->sock == NULL) {
+		clear_bit(NEGOTIATING, &con->state);
+		set_bit(CONNECTING, &con->state);
 		ret = prepare_write_connect(con);
 		if (ret < 0)
 			goto out;
-		set_bit(CONNECTING, &con->state);
-		clear_bit(NEGOTIATING, &con->state);

 		con->in_tag = CEPH_MSGR_TAG_READY;