From patchwork Wed Feb 20 00:56:48 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 2165831 Return-Path: X-Original-To: patchwork-ceph-devel@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork1.kernel.org (Postfix) with ESMTP id 866423FDF1 for ; Wed, 20 Feb 2013 00:56:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1759045Ab3BTA4w (ORCPT ); Tue, 19 Feb 2013 19:56:52 -0500 Received: from mail-qa0-f50.google.com ([209.85.216.50]:34893 "EHLO mail-qa0-f50.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1759039Ab3BTA4v (ORCPT ); Tue, 19 Feb 2013 19:56:51 -0500 Received: by mail-qa0-f50.google.com with SMTP id dx4so2162389qab.2 for ; Tue, 19 Feb 2013 16:56:50 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-received:message-id:date:from:user-agent:mime-version:to:subject :references:in-reply-to:content-type:content-transfer-encoding :x-gm-message-state; bh=YItbqOYH0H8nCZeoKirlXPCFGg+9seAJbMRbQQnHVbI=; b=U7YkHHeZCtZIxkll8/Zmh7+cVC3wweq43+0PS+6xoT0+VsD6TF8HaNc+Xv0DtYCEop f1G/tbBOAuMON4IO8pFpaxIM7EcKNxGnsn2YO1ma8JbZwHRua6Ev1HBysb3YzNWJetve Kg7IGkptq04g6YKeM8AUSAMAcGomUK/J0vAoiMfjW1cd60EB0Q++pmICdWguhnhIFycv 07mKrCw4rFkkK4Jj3r38sqbZJURf4+zw1ojtiih4D9ifius+IuC6bODBD98TWryExLEW ta1/z2fzf/y2KM55CuM2aui9TSpLvBUP//7Bz5Vwqq5ME84WE3/ciUmH56HWfqKN0DzX 5LmQ== X-Received: by 10.49.72.136 with SMTP id d8mr8710123qev.62.1361321810398; Tue, 19 Feb 2013 16:56:50 -0800 (PST) Received: from [172.22.22.4] (c-71-195-31-37.hsd1.mn.comcast.net. [71.195.31.37]) by mx.google.com with ESMTPS id no8sm16493323qeb.0.2013.02.19.16.56.48 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 19 Feb 2013 16:56:49 -0800 (PST) Message-ID: <51241F50.6010708@inktank.com> Date: Tue, 19 Feb 2013 18:56:48 -0600 From: Alex Elder User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130106 Thunderbird/17.0.2 MIME-Version: 1.0 To: ceph-devel Subject: [PATCH 4/5] libceph: use a do..while loop in con_work() References: <51241E15.80903@inktank.com> In-Reply-To: <51241E15.80903@inktank.com> X-Gm-Message-State: ALoCoQm+AiqntmGeg0o9/YGI1nDdNtRSP/wn18zr9VX6vRqIItlSiy2LuMYhiUPOo+MgZgXpmjbu Sender: ceph-devel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: ceph-devel@vger.kernel.org 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. NOTE: This was done in two steps in order to facilitate review. The This patch will be squashed into the next one before commit. next patch simply indents the loop properly. Signed-off-by: Alex Elder --- net/ceph/messenger.c | 32 +++++++++++++++++--------------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/net/ceph/messenger.c b/net/ceph/messenger.c index 1cf0e53..609f2eb 100644 --- a/net/ceph/messenger.c +++ b/net/ceph/messenger.c @@ -2338,28 +2338,28 @@ 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)) { +while (true) { + int ret; + + if ((fault = con_sock_closed(con))) { dout("con_work %p SOCK_CLOSED\n", con); - fault = true; - goto done; + break; } if (con_backoff(con)) { dout("con_work %p BACKOFF\n", con); - goto done; + break; } if (con->state == CON_STATE_STANDBY) { dout("con_work %p STANDBY\n", con); - goto done; + break; } if (con->state == CON_STATE_CLOSED) { dout("con_work %p CLOSED\n", con); BUG_ON(con->sock); - goto done; + break; } if (con->state == CON_STATE_PREOPEN) { dout("con_work %p OPENING\n", con); @@ -2367,22 +2367,24 @@ restart: } ret = try_read(con); - if (ret == -EAGAIN) - goto restart; if (ret < 0) { + if (ret == -EAGAIN) + continue; con->error_msg = "socket error on read"; fault = true; - goto done; + break; } ret = try_write(con); - if (ret == -EAGAIN) - goto restart; if (ret < 0) { + if (ret == -EAGAIN) + continue; con->error_msg = "socket error on write"; fault = true; } -done: + + break; /* If we make it to here, we're done */ +} if (fault) con_fault(con); mutex_unlock(&con->mutex);