From: Alex Elder <elder@inktank.com>
To: "ceph-devel@vger.kernel.org >> ceph-devel" <ceph-devel@vger.kernel.org>
Subject: [PATCH 2/5] libceph: separate non-locked fault handling
Date: Fri, 22 Feb 2013 11:26:04 -0600 [thread overview]
Message-ID: <5127AA2C.7090709@inktank.com> (raw)
In-Reply-To: <5127A935.8020605@inktank.com>
An error occurring on a ceph connection is treated as a fault,
causing the connection to be reset. The initial part of this fault
handling has to be done while holding the connection mutex, but
it must then be dropped for the last part.
Separate the part of this fault handling that executes without the
lock into its own function, con_fault_finish(). Move the call to
this new function, as well as call that drops the connection mutex,
into ceph_fault(). Rename that function con_fault() to reflect that
it's only handling the connection part of the fault handling.
The motivation for this was a warning from sparse about the locking
being done here. Rearranging things this way keeps all the mutex
manipulation within ceph_fault(), and this stops sparse from
complaining.
This partially resolves:
http://tracker.ceph.com/issues/4184
Reported-by: Fengguang Wu <fengguang.wu@intel.com>
Signed-off-by: Alex Elder <elder@inktank.com>
---
v2: rebased
net/ceph/messenger.c | 42 +++++++++++++++++++++++-------------------
1 file changed, 23 insertions(+), 19 deletions(-)
diff --git a/net/ceph/messenger.c b/net/ceph/messenger.c
index 9a29d8a..c3b9060 100644
--- a/net/ceph/messenger.c
+++ b/net/ceph/messenger.c
@@ -166,7 +166,7 @@ static struct lock_class_key socket_class;
static void queue_con(struct ceph_connection *con);
static void con_work(struct work_struct *);
-static void ceph_fault(struct ceph_connection *con);
+static void con_fault(struct ceph_connection *con);
/*
* Nicely render a sockaddr as a string. An array of formatted
@@ -2363,6 +2363,23 @@ static bool con_backoff(struct ceph_connection *con)
return true;
}
+/* Finish fault handling; con->mutex must *not* be held here */
+
+static void con_fault_finish(struct ceph_connection *con)
+{
+ /*
+ * in case we faulted due to authentication, invalidate our
+ * current tickets so that we can get new ones.
+ */
+ if (con->auth_retry && con->ops->invalidate_authorizer) {
+ dout("calling invalidate_authorizer()\n");
+ con->ops->invalidate_authorizer(con);
+ }
+
+ if (con->ops->fault)
+ con->ops->fault(con);
+}
+
/*
* Do some work on a connection. Drop a connection ref when we're done.
*/
@@ -2419,7 +2436,9 @@ done_unlocked:
return;
fault:
- ceph_fault(con); /* error/fault path */
+ con_fault(con);
+ mutex_unlock(&con->mutex);
+ con_fault_finish(con);
goto done_unlocked;
}
@@ -2428,8 +2447,7 @@ fault:
* Generic error/fault handler. A retry mechanism is used with
* exponential backoff
*/
-static void ceph_fault(struct ceph_connection *con)
- __releases(con->mutex)
+static void con_fault(struct ceph_connection *con)
{
pr_warning("%s%lld %s %s\n", ENTITY_NAME(con->peer_name),
ceph_pr_addr(&con->peer_addr.in_addr), con->error_msg);
@@ -2445,7 +2463,7 @@ static void ceph_fault(struct ceph_connection *con)
if (con_flag_test(con, CON_FLAG_LOSSYTX)) {
dout("fault on LOSSYTX channel, marking CLOSED\n");
con->state = CON_STATE_CLOSED;
- goto out_unlock;
+ return;
}
if (con->in_msg) {
@@ -2476,20 +2494,6 @@ static void ceph_fault(struct ceph_connection *con)
con_flag_set(con, CON_FLAG_BACKOFF);
queue_con(con);
}
-
-out_unlock:
- mutex_unlock(&con->mutex);
- /*
- * in case we faulted due to authentication, invalidate our
- * current tickets so that we can get new ones.
- */
- if (con->auth_retry && con->ops->invalidate_authorizer) {
- dout("calling invalidate_authorizer()\n");
- con->ops->invalidate_authorizer(con);
- }
-
- if (con->ops->fault)
- con->ops->fault(con);
}
--
1.7.9.5
next prev parent reply other threads:[~2013-02-22 17:26 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-02-22 17:18 Updated sparse warning message patches Alex Elder
2013-02-22 17:21 ` [PATCH, v2] rbd: eliminate sparse warnings Alex Elder
2013-02-22 17:21 ` [PATCH, v2] ceph: eliminate sparse warnings in fs code Alex Elder
2013-02-22 17:21 ` [PATCH, v2] libceph: eliminate sparse warnings Alex Elder
2013-02-22 17:21 ` [PATCH 0/5, v2] libceph clean up con_work() Alex Elder
2013-02-22 17:23 ` [PATCH 1/5] libceph: encapsulate connection backoff Alex Elder
2013-02-22 17:23 ` [PATCH 2/5] libceph: separate non-locked fault handling Alex Elder
2013-02-22 17:26 ` Alex Elder [this message]
2013-02-22 17:32 ` Alex Elder
2013-02-22 17:26 ` [PATCH 3/5, v2] libceph: use a flag to indicate a fault has occurred Alex Elder
2013-02-22 17:30 ` [PATCH 4/5, v2] libceph: use a do..while loop in con_work() Alex Elder
2013-02-22 17:30 ` [PATCH 5/5, v2] libceph: indent properly Alex Elder
2013-02-25 19:15 ` Updated sparse warning message patches Josh Durgin
-- strict thread matches above, loose matches on Subject: below --
2013-02-20 0:51 [PATCH 0/5] libceph clean up con_work() Alex Elder
2013-02-20 0:55 ` [PATCH 2/5] libceph: separate non-locked fault handling 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=5127AA2C.7090709@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.