From: Alex Elder <elder@inktank.com>
To: Sage Weil <sage@inktank.com>
Cc: ceph-devel@vger.kernel.org
Subject: Re: [PATCH 3/8] libceph: fix handling of immediate socket connect failure
Date: Mon, 30 Jul 2012 19:08:23 -0500 [thread overview]
Message-ID: <501721F7.8080301@inktank.com> (raw)
In-Reply-To: <1343663971-3221-4-git-send-email-sage@inktank.com>
On 07/30/2012 10:59 AM, Sage Weil wrote:
> If the connect() call immediately fails such that sock == NULL, we
> still need con_close_socket() to reset our socket state to CLOSED.
>
> Signed-off-by: Sage Weil <sage@inktank.com>
Looks good.
I'm glad you're adding in dout() calls... I hadn't been doing
that as I was working on the messenger code.
Reviewed-by: Alex Elder <elder@inktank.com>
> ---
> net/ceph/messenger.c | 26 +++++++++++++++++++-------
> 1 file changed, 19 insertions(+), 7 deletions(-)
>
> diff --git a/net/ceph/messenger.c b/net/ceph/messenger.c
> index fa16f2c..a6a0c7a 100644
> --- a/net/ceph/messenger.c
> +++ b/net/ceph/messenger.c
> @@ -224,6 +224,8 @@ static void con_sock_state_init(struct ceph_connection *con)
> old_state = atomic_xchg(&con->sock_state, CON_SOCK_STATE_CLOSED);
> if (WARN_ON(old_state != CON_SOCK_STATE_NEW))
> printk("%s: unexpected old state %d\n", __func__, old_state);
> + dout("%s con %p sock %d -> %d\n", __func__, con, old_state,
> + CON_SOCK_STATE_CLOSED);
> }
>
> static void con_sock_state_connecting(struct ceph_connection *con)
> @@ -233,6 +235,8 @@ static void con_sock_state_connecting(struct ceph_connection *con)
> old_state = atomic_xchg(&con->sock_state, CON_SOCK_STATE_CONNECTING);
> if (WARN_ON(old_state != CON_SOCK_STATE_CLOSED))
> printk("%s: unexpected old state %d\n", __func__, old_state);
> + dout("%s con %p sock %d -> %d\n", __func__, con, old_state,
> + CON_SOCK_STATE_CONNECTING);
> }
>
> static void con_sock_state_connected(struct ceph_connection *con)
> @@ -242,6 +246,8 @@ static void con_sock_state_connected(struct ceph_connection *con)
> old_state = atomic_xchg(&con->sock_state, CON_SOCK_STATE_CONNECTED);
> if (WARN_ON(old_state != CON_SOCK_STATE_CONNECTING))
> printk("%s: unexpected old state %d\n", __func__, old_state);
> + dout("%s con %p sock %d -> %d\n", __func__, con, old_state,
> + CON_SOCK_STATE_CONNECTED);
> }
>
> static void con_sock_state_closing(struct ceph_connection *con)
> @@ -253,6 +259,8 @@ static void con_sock_state_closing(struct ceph_connection *con)
> old_state != CON_SOCK_STATE_CONNECTED &&
> old_state != CON_SOCK_STATE_CLOSING))
> printk("%s: unexpected old state %d\n", __func__, old_state);
> + dout("%s con %p sock %d -> %d\n", __func__, con, old_state,
> + CON_SOCK_STATE_CLOSING);
> }
>
> static void con_sock_state_closed(struct ceph_connection *con)
> @@ -262,8 +270,11 @@ static void con_sock_state_closed(struct ceph_connection *con)
> old_state = atomic_xchg(&con->sock_state, CON_SOCK_STATE_CLOSED);
> if (WARN_ON(old_state != CON_SOCK_STATE_CONNECTED &&
> old_state != CON_SOCK_STATE_CLOSING &&
> - old_state != CON_SOCK_STATE_CONNECTING))
> + old_state != CON_SOCK_STATE_CONNECTING &&
> + old_state != CON_SOCK_STATE_CLOSED))
> printk("%s: unexpected old state %d\n", __func__, old_state);
> + dout("%s con %p sock %d -> %d\n", __func__, con, old_state,
> + CON_SOCK_STATE_CLOSED);
> }
>
> /*
> @@ -448,14 +459,14 @@ static int ceph_tcp_sendpage(struct socket *sock, struct page *page,
> */
> static int con_close_socket(struct ceph_connection *con)
> {
> - int rc;
> + int rc = 0;
>
> dout("con_close_socket on %p sock %p\n", con, con->sock);
> - if (!con->sock)
> - return 0;
> - rc = con->sock->ops->shutdown(con->sock, SHUT_RDWR);
> - sock_release(con->sock);
> - con->sock = NULL;
> + if (con->sock) {
> + rc = con->sock->ops->shutdown(con->sock, SHUT_RDWR);
> + sock_release(con->sock);
> + con->sock = NULL;
> + }
>
> /*
> * Forcibly clear the SOCK_CLOSED flag. It gets set
> @@ -464,6 +475,7 @@ static int con_close_socket(struct ceph_connection *con)
> * shut the socket down.
> */
> clear_bit(CON_FLAG_SOCK_CLOSED, &con->flags);
> +
> con_sock_state_closed(con);
> return rc;
> }
>
next prev parent reply other threads:[~2012-07-31 0:08 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-07-30 15:59 [PATCH 0/8] Last batch of messenger fixes, misc Sage Weil
2012-07-30 15:59 ` [PATCH 1/8] libceph: be less chatty about stray replies Sage Weil
2012-07-30 23:00 ` Alex Elder
2012-07-30 15:59 ` [PATCH 2/8] ceph: update MAINTAINERS file Sage Weil
2012-07-30 23:09 ` Alex Elder
2012-07-30 15:59 ` [PATCH 3/8] libceph: fix handling of immediate socket connect failure Sage Weil
2012-07-31 0:08 ` Alex Elder [this message]
2012-07-30 15:59 ` [PATCH 4/8] libceph: revoke mon_client messages on session restart Sage Weil
2012-07-31 0:09 ` Alex Elder
2012-07-30 15:59 ` [PATCH 5/8] libceph: verify state after retaking con lock after dispatch Sage Weil
2012-07-31 0:11 ` Alex Elder
2012-07-30 15:59 ` [PATCH 6/8] libceph: avoid dropping con mutex before fault Sage Weil
2012-07-31 0:12 ` Alex Elder
2012-07-30 15:59 ` [PATCH 7/8] libceph: change ceph_con_in_msg_alloc convention to be less weird Sage Weil
2012-07-31 0:25 ` Alex Elder
2012-07-31 1:09 ` Sage Weil
2012-07-30 15:59 ` [PATCH 8/8] libceph: recheck con state after allocating incoming message Sage Weil
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=501721F7.8080301@inktank.com \
--to=elder@inktank.com \
--cc=ceph-devel@vger.kernel.org \
--cc=sage@inktank.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.