All of lore.kernel.org
 help / color / mirror / Atom feed
From: Sage Weil <sage@inktank.com>
To: ceph-devel@vger.kernel.org
Cc: Sage Weil <sage@inktank.com>
Subject: [PATCH 5/8] libceph: verify state after retaking con lock after dispatch
Date: Mon, 30 Jul 2012 08:59:28 -0700	[thread overview]
Message-ID: <1343663971-3221-6-git-send-email-sage@inktank.com> (raw)
In-Reply-To: <1343663971-3221-1-git-send-email-sage@inktank.com>

We drop the con mutex when delivering a message.  When we retake the
lock, we need to verify we are still in the OPEN state before
preparing to read the next tag, or else we risk stepping on a
connection that has been closed.

Signed-off-by: Sage Weil <sage@inktank.com>
---
 net/ceph/messenger.c |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/net/ceph/messenger.c b/net/ceph/messenger.c
index a6a0c7a..feb5a2a 100644
--- a/net/ceph/messenger.c
+++ b/net/ceph/messenger.c
@@ -2003,7 +2003,6 @@ static void process_message(struct ceph_connection *con)
 	con->ops->dispatch(con, msg);
 
 	mutex_lock(&con->mutex);
-	prepare_read_tag(con);
 }
 
 
@@ -2213,6 +2212,8 @@ more:
 		if (con->in_tag == CEPH_MSGR_TAG_READY)
 			goto more;
 		process_message(con);
+		if (con->state == CON_STATE_OPEN)
+			prepare_read_tag(con);
 		goto more;
 	}
 	if (con->in_tag == CEPH_MSGR_TAG_ACK) {
-- 
1.7.9.5


  parent reply	other threads:[~2012-07-30 15:59 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
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 ` Sage Weil [this message]
2012-07-31  0:11   ` [PATCH 5/8] libceph: verify state after retaking con lock after dispatch 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=1343663971-3221-6-git-send-email-sage@inktank.com \
    --to=sage@inktank.com \
    --cc=ceph-devel@vger.kernel.org \
    /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.