All of lore.kernel.org
 help / color / mirror / Atom feed
From: Alex Elder <elder@inktank.com>
To: ceph-devel <ceph-devel@vger.kernel.org>
Subject: [PATCH 5/9] libceph: change TAG_CLOSE handling
Date: Fri, 22 Jun 2012 17:48:35 -0500	[thread overview]
Message-ID: <4FE4F643.6010705@inktank.com> (raw)
In-Reply-To: <4FE4F534.1000009@inktank.com>

Currently, if a connection is READY in try_read(), and a CLOSE tag
is the what is received next, the connection's state changes from
CONNECTED to CLOSED and try_read() returns.

If this happens, control returns to con_work(), and try_write()
is called.  If there was queued data to send, try_write() appears
to attempt to send it despite the receipt of the CLOSE tag.

Eventually, try_write() will return either:
  - A non-negative value, in which case con_work() will end, and
    will at some point get triggered to run by an event.
  - -EAGAIN, in which case control returns to the top of con_work()
  - Some other error, which will cause con_work() to call
    ceph_fault(), which will close the socket and force a new
    connection sequence to be initiated on the next write.

At the top of con_work(), if the connection is in CLOSED state,
the same fault handling will be done as would happen for any
other error.

Instead of messing with the connection state deep inside try_read(),
just have try_read() return a negative value (an errno), and let
the fault handling code in con_work() take care of resetting the
connection right away.  This will also close the connection before
needlessly sending any queued data to the other end.

Signed-off-by: Alex Elder <elder@inktank.com>
---
 net/ceph/messenger.c |    3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

Index: b/net/ceph/messenger.c
===================================================================
--- a/net/ceph/messenger.c
+++ b/net/ceph/messenger.c
@@ -2273,8 +2273,7 @@ more:
 			prepare_read_ack(con);
 			break;
 		case CEPH_MSGR_TAG_CLOSE:
-			clear_bit(CONNECTED, &con->state);
-			set_bit(CLOSED, &con->state);   /* fixme */
+			ret = -EIO;
 			goto out;
 		default:
 			goto bad_tag;

  parent reply	other threads:[~2012-06-22 22:48 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-06-22 22:44 [PATCH 0/9] another batch of messenger patches Alex Elder
2012-06-22 22:48 ` [PATCH 1/9] libceph: encapsulate and document connect sequence Alex Elder
2012-06-22 22:48 ` [PATCH 2/9] libceph: encapsulate and document negotiation phase Alex Elder
2012-06-22 22:48 ` [PATCH 3/9] libceph: close the connection's socket on reset Alex Elder
2012-06-22 22:48 ` [PATCH 4/9] libceph: don't close socket in OPENING state Alex Elder
2012-06-22 22:48 ` Alex Elder [this message]
2012-06-22 22:48 ` [PATCH 6/9] libceph: kill fail_protocol() Alex Elder
2012-06-22 22:48 ` [PATCH 7/9] libceph: close connection on reset tag Alex Elder
2012-06-22 22:48 ` [PATCH 8/9] libceph: close connection on connect failure Alex Elder
2012-06-22 22:49 ` [PATCH 9/9] libceph: set CONNECTING state even earlier Alex Elder

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=4FE4F643.6010705@inktank.com \
    --to=elder@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.