aboutsummaryrefslogtreecommitdiffstats
path: root/net/ceph
diff options
context:
space:
mode:
authorAlex Elder <elder@inktank.com>2013-02-19 13:25:57 -0500
committerAlex Elder <elder@inktank.com>2013-02-25 16:37:37 -0500
commit49659416ba4fa8308bd29e453f54c3bcf8a0fbf1 (patch)
tree45ef273049a461489baf3de188f57a544fef2be9 /net/ceph
parentb6e7b6a11923bda6102b4e3e196693567944869c (diff)
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/ceph')
-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 18eb788bbb9d..2c0669fb54e3 100644
--- a/net/ceph/messenger.c
+++ b/net/ceph/messenger.c
@@ -2387,51 +2387,53 @@ static void con_work(struct work_struct *work)
2387{ 2387{
2388 struct ceph_connection *con = container_of(work, struct ceph_connection, 2388 struct ceph_connection *con = container_of(work, struct ceph_connection,
2389 work.work); 2389 work.work);
2390 bool fault = false; 2390 bool fault;
2391 int ret;
2392 2391
2393 mutex_lock(&con->mutex); 2392 mutex_lock(&con->mutex);
2394restart: 2393 while (true) {
2395 if (con_sock_closed(con)) { 2394 int ret;
2396 dout("%s: con %p SOCK_CLOSED\n", __func__, con);
2397 fault = true;
2398 goto done;
2399 }
2400 if (con_backoff(con)) {
2401 dout("%s: con %p BACKOFF\n", __func__, con);
2402 goto done;
2403 }
2404 if (con->state == CON_STATE_STANDBY) {
2405 dout("con_work %p STANDBY\n", con);
2406 goto done;
2407 }
2408 if (con->state == CON_STATE_CLOSED) {
2409 dout("con_work %p CLOSED\n", con);
2410 BUG_ON(con->sock);
2411 goto done;
2412 }
2413 if (con->state == CON_STATE_PREOPEN) {
2414 dout("%s: con %p OPENING\n", __func__, con);
2415 BUG_ON(con->sock);
2416 }
2417 2395
2418 ret = try_read(con); 2396 if ((fault = con_sock_closed(con))) {
2419 if (ret == -EAGAIN) 2397 dout("%s: con %p SOCK_CLOSED\n", __func__, con);
2420 goto restart; 2398 break;
2421 if (ret < 0) { 2399 }
2422 con->error_msg = "socket error on read"; 2400 if (con_backoff(con)) {
2423 fault = true; 2401 dout("%s: con %p BACKOFF\n", __func__, con);
2424 goto done; 2402 break;
2425 } 2403 }
2404 if (con->state == CON_STATE_STANDBY) {
2405 dout("%s: con %p STANDBY\n", __func__, con);
2406 break;
2407 }
2408 if (con->state == CON_STATE_CLOSED) {
2409 dout("%s: con %p CLOSED\n", __func__, con);
2410 BUG_ON(con->sock);
2411 break;
2412 }
2413 if (con->state == CON_STATE_PREOPEN) {
2414 dout("%s: con %p PREOPEN\n", __func__, con);
2415 BUG_ON(con->sock);
2416 }
2426 2417
2427 ret = try_write(con); 2418 ret = try_read(con);
2428 if (ret == -EAGAIN) 2419 if (ret < 0) {
2429 goto restart; 2420 if (ret == -EAGAIN)
2430 if (ret < 0) { 2421 continue;
2431 con->error_msg = "socket error on write"; 2422 con->error_msg = "socket error on read";
2432 fault = true; 2423 fault = true;
2424 break;
2425 }
2426
2427 ret = try_write(con);
2428 if (ret < 0) {
2429 if (ret == -EAGAIN)
2430 continue;
2431 con->error_msg = "socket error on write";
2432 fault = true;
2433 }
2434
2435 break; /* If we make it to here, we're done */
2433 } 2436 }
2434done:
2435 if (fault) 2437 if (fault)
2436 con_fault(con); 2438 con_fault(con);
2437 mutex_unlock(&con->mutex); 2439 mutex_unlock(&con->mutex);
@@ -2442,7 +2444,6 @@ done:
2442 con->ops->put(con); 2444 con->ops->put(con);
2443} 2445}
2444 2446
2445
2446/* 2447/*
2447 * Generic error/fault handler. A retry mechanism is used with 2448 * Generic error/fault handler. A retry mechanism is used with
2448 * exponential backoff 2449 * exponential backoff