In con_work(), a while(true) loop is used to contain a block of code. The normal path through that code does *not* actually loop. The only time it loops is if a socket read or write operation returns -EAGAIN. So the use of the loop control structure is a little misleading. Restructure that block so it's *not* a loop, and use "goto" calls rather than a loop to implement the control flow. Signed-off-by: Alex Elder <elder@xxxxxxxxxx> --- net/ceph/messenger.c | 84 +++++++++++++++++++++++++--------------------------- 1 file changed, 41 insertions(+), 43 deletions(-) diff --git a/net/ceph/messenger.c b/net/ceph/messenger.c index ec60c23..053c5f3 100644 --- a/net/ceph/messenger.c +++ b/net/ceph/messenger.c @@ -2845,54 +2845,52 @@ static void con_work(struct work_struct *work) struct ceph_connection *con = container_of(work, struct ceph_connection, work.work); bool fault; + int ret; mutex_lock(&con->mutex); - while (true) { - int ret; - - 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_read(con); - if (ret < 0) { - if (ret == -EAGAIN) - continue; - if (!con->error_msg) - con->error_msg = "socket error on read"; - fault = true; - break; - } +again: + fault = con_sock_closed(con); + if (fault) { + dout("%s: con %p SOCK_CLOSED\n", __func__, con); + goto done; + } + if (con_backoff(con)) { + dout("%s: con %p BACKOFF\n", __func__, con); + goto done; + } + if (con->state == CON_STATE_STANDBY) { + dout("%s: con %p STANDBY\n", __func__, con); + goto done; + } + if (con->state == CON_STATE_CLOSED) { + dout("%s: con %p CLOSED\n", __func__, con); + BUG_ON(con->sock); + goto done; + } + if (con->state == CON_STATE_PREOPEN) { + dout("%s: con %p PREOPEN\n", __func__, con); + BUG_ON(con->sock); + } - ret = try_write(con); - if (ret < 0) { - if (ret == -EAGAIN) - continue; - if (!con->error_msg) - con->error_msg = "socket error on write"; - fault = true; - } + ret = try_read(con); + if (ret < 0) { + if (ret == -EAGAIN) + goto again; + if (!con->error_msg) + con->error_msg = "socket error on read"; + fault = true; + goto done; + } - break; /* If we make it to here, we're done */ + ret = try_write(con); + if (ret < 0) { + if (ret == -EAGAIN) + goto again; + if (!con->error_msg) + con->error_msg = "socket error on write"; + fault = true; } +done: if (fault) con_fault(con); mutex_unlock(&con->mutex); -- 2.1.0 -- To unsubscribe from this list: send the line "unsubscribe ceph-devel" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html