summaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorAlex Elder <elder@inktank.com>2013-02-19 12:25:57 -0600
committerAlex Elder <elder@inktank.com>2013-02-25 15:37:37 -0600
commit49659416ba4fa8308bd29e453f54c3bcf8a0fbf1 (patch)
tree45ef273049a461489baf3de188f57a544fef2be9 /net
parentb6e7b6a11923bda6102b4e3e196693567944869c (diff)
downloadop-kernel-dev-49659416ba4fa8308bd29e453f54c3bcf8a0fbf1.zip
op-kernel-dev-49659416ba4fa8308bd29e453f54c3bcf8a0fbf1.tar.gz
libceph: use a do..while loop in con_work()
This just converts a manually-implemented loop into a do..while loop in con_work(). It also moves handling of EAGAIN inside the blocks where it's already been determined an error code was returned. Also update a few dout() calls near the affected code for consistency. Signed-off-by: Alex Elder <elder@inktank.com> Reviewed-by: Josh Durgin <josh.durgin@inktank.com>
Diffstat (limited to 'net')
-rw-r--r--net/ceph/messenger.c83
1 files changed, 42 insertions, 41 deletions
diff --git a/net/ceph/messenger.c b/net/ceph/messenger.c
index 18eb788..2c0669f 100644
--- a/net/ceph/messenger.c
+++ b/net/ceph/messenger.c
@@ -2387,51 +2387,53 @@ static void con_work(struct work_struct *work)
{
struct ceph_connection *con = container_of(work, struct ceph_connection,
work.work);
- bool fault = false;
- int ret;
+ bool fault;
mutex_lock(&con->mutex);
-restart:
- if (con_sock_closed(con)) {
- dout("%s: con %p SOCK_CLOSED\n", __func__, con);
- fault = true;
- goto done;
- }
- if (con_backoff(con)) {
- dout("%s: con %p BACKOFF\n", __func__, con);
- goto done;
- }
- if (con->state == CON_STATE_STANDBY) {
- dout("con_work %p STANDBY\n", con);
- goto done;
- }
- if (con->state == CON_STATE_CLOSED) {
- dout("con_work %p CLOSED\n", con);
- BUG_ON(con->sock);
- goto done;
- }
- if (con->state == CON_STATE_PREOPEN) {
- dout("%s: con %p OPENING\n", __func__, con);
- BUG_ON(con->sock);
- }
+ while (true) {
+ int ret;
- ret = try_read(con);
- if (ret == -EAGAIN)
- goto restart;
- if (ret < 0) {
- con->error_msg = "socket error on read";
- fault = true;
- goto done;
- }
+ if ((fault = con_sock_closed(con))) {
+ dout("%s: con %p SOCK_CLOSED\n", __func__, con);
+ break;
+ }
+ if (con_backoff(con)) {
+ dout("%s: con %p BACKOFF\n", __func__, con);
+ break;
+ }
+ if (con->state == CON_STATE_STANDBY) {
+ dout("%s: con %p STANDBY\n", __func__, con);
+ break;
+ }
+ if (con->state == CON_STATE_CLOSED) {
+ dout("%s: con %p CLOSED\n", __func__, con);
+ BUG_ON(con->sock);
+ break;
+ }
+ if (con->state == CON_STATE_PREOPEN) {
+ dout("%s: con %p PREOPEN\n", __func__, con);
+ BUG_ON(con->sock);
+ }
- ret = try_write(con);
- if (ret == -EAGAIN)
- goto restart;
- if (ret < 0) {
- con->error_msg = "socket error on write";
- fault = true;
+ ret = try_read(con);
+ if (ret < 0) {
+ if (ret == -EAGAIN)
+ continue;
+ con->error_msg = "socket error on read";
+ fault = true;
+ break;
+ }
+
+ ret = try_write(con);
+ if (ret < 0) {
+ if (ret == -EAGAIN)
+ continue;
+ con->error_msg = "socket error on write";
+ fault = true;
+ }
+
+ break; /* If we make it to here, we're done */
}
-done:
if (fault)
con_fault(con);
mutex_unlock(&con->mutex);
@@ -2442,7 +2444,6 @@ done:
con->ops->put(con);
}
-
/*
* Generic error/fault handler. A retry mechanism is used with
* exponential backoff
OpenPOWER on IntegriCloud