From: Alex Elder <elder@inktank.com>
To: Sage Weil <sage@inktank.com>
Cc: ceph-devel@vger.kernel.org
Subject: Re: [PATCH 4/9] libceph: fix mutex coverage for ceph_con_close
Date: Mon, 30 Jul 2012 13:43:29 -0500 [thread overview]
Message-ID: <5016D5D1.7060108@inktank.com> (raw)
In-Reply-To: <1342831308-18815-5-git-send-email-sage@inktank.com>
On 07/20/2012 07:41 PM, Sage Weil wrote:
> Hold the mutex while twiddling all of the state bits to avoid possible
> races. While we're here, make not of why we cannot close the socket
> directly.
>
> Signed-off-by: Sage Weil <sage@inktank.com>
Looks OK to me. A quick scan seems to show that the
state and flag bits are *almost* always set while the
mutex is held. The one counterexample I found was for
the STANDBY state bit in clear_standby() (but I really
didn't look very closely).
Anyway, I think this looks fine--it makes things safer
even if there could be another imperfection somewhere.
Reviewed-by: Alex Elder <elder@inktank.com>
> ---
> net/ceph/messenger.c | 8 +++++++-
> 1 files changed, 7 insertions(+), 1 deletions(-)
>
> diff --git a/net/ceph/messenger.c b/net/ceph/messenger.c
> index 7105908..e24310e 100644
> --- a/net/ceph/messenger.c
> +++ b/net/ceph/messenger.c
> @@ -503,6 +503,7 @@ static void reset_connection(struct ceph_connection *con)
> */
> void ceph_con_close(struct ceph_connection *con)
> {
> + mutex_lock(&con->mutex);
> dout("con_close %p peer %s\n", con,
> ceph_pr_addr(&con->peer_addr.in_addr));
> clear_bit(NEGOTIATING, &con->state);
> @@ -515,11 +516,16 @@ void ceph_con_close(struct ceph_connection *con)
> clear_bit(KEEPALIVE_PENDING, &con->flags);
> clear_bit(WRITE_PENDING, &con->flags);
>
> - mutex_lock(&con->mutex);
> reset_connection(con);
> con->peer_global_seq = 0;
> cancel_delayed_work(&con->work);
> mutex_unlock(&con->mutex);
> +
> + /*
> + * We cannot close the socket directly from here because the
> + * work threads use it without holding the mutex. Instead, let
> + * con_work() do it.
> + */
> queue_con(con);
> }
> EXPORT_SYMBOL(ceph_con_close);
>
next prev parent reply other threads:[~2012-07-30 18:43 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-07-21 0:41 [PATCH 0/9] messenger fixups, batch #1 Sage Weil
2012-07-21 0:41 ` [PATCH 1/9] libceph: move feature bits to separate header Sage Weil
2012-07-24 22:14 ` Yehuda Sadeh
2012-07-30 18:29 ` Alex Elder
2012-07-21 0:41 ` [PATCH 2/9] libceph: support crush tunables Sage Weil
2012-07-24 22:24 ` Yehuda Sadeh
2012-07-30 23:14 ` Sage Weil
2012-07-30 23:45 ` Yehuda Sadeh
2012-07-30 18:36 ` Alex Elder
2012-07-21 0:41 ` [PATCH 3/9] libceph: report socket read/write error message Sage Weil
2012-07-24 22:26 ` Yehuda Sadeh
2012-07-30 18:37 ` Alex Elder
2012-07-21 0:41 ` [PATCH 4/9] libceph: fix mutex coverage for ceph_con_close Sage Weil
2012-07-24 22:29 ` Yehuda Sadeh
2012-07-30 18:43 ` Alex Elder [this message]
2012-07-21 0:41 ` [PATCH 5/9] libceph: resubmit linger ops when pg mapping changes Sage Weil
2012-07-24 22:51 ` Yehuda Sadeh
2012-07-30 22:40 ` Alex Elder
2012-07-30 23:03 ` Sage Weil
2012-07-21 0:41 ` [PATCH 6/9] libceph: (re)initialize bio_iter on start of message receive Sage Weil
2012-07-24 22:55 ` Yehuda Sadeh
2012-07-30 19:04 ` Alex Elder
2012-07-21 0:41 ` [PATCH 7/9] ceph: close old con before reopening on mds reconnect Sage Weil
2012-07-24 22:56 ` Yehuda Sadeh
2012-07-30 23:11 ` Sage Weil
2012-07-21 0:41 ` [PATCH 8/9] libceph: protect ceph_con_open() with mutex Sage Weil
2012-07-24 22:58 ` Yehuda Sadeh
2012-07-30 19:06 ` Alex Elder
2012-07-21 0:41 ` [PATCH 9/9] libceph: reset connection retry on successfully negotiation Sage Weil
2012-07-24 23:00 ` Yehuda Sadeh
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=5016D5D1.7060108@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox