From patchwork Fri Feb 22 17:30:23 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 2176731 Return-Path: X-Original-To: patchwork-ceph-devel@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork2.kernel.org (Postfix) with ESMTP id 44021DFABD for ; Fri, 22 Feb 2013 17:30:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758134Ab3BVRa1 (ORCPT ); Fri, 22 Feb 2013 12:30:27 -0500 Received: from mail-ia0-f179.google.com ([209.85.210.179]:59841 "EHLO mail-ia0-f179.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757971Ab3BVRa0 (ORCPT ); Fri, 22 Feb 2013 12:30:26 -0500 Received: by mail-ia0-f179.google.com with SMTP id x24so739264iak.24 for ; Fri, 22 Feb 2013 09:30:26 -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=3ZBJ38u4mfKPxO9/BCGJpeDEE5IEB7t+/NUOrZGRTWM=; b=O/8Am0nHk/pZPHdcYThnHkkUG0qyQnjhgrotaUtmADyqyOjSJezjpToOWQvnJ8x3+g Ry7zjrhFhBmMnqT0hxCVqvi3xwidVtAxVJjizcl4vKNgNMWOJBPg1xfUrkv/Ckrd44tx NYMZwSBRjJXHBpu81dSEPbK8DnU3sHRgyd6zA0Vv0FeHz8DSR+Tb4U0Eg8u3SHUV7THa Njib+/E5q/6uaPsC2R6O8eL07qML0B+sunzXn90B9I4YrE/6NPT70cu/k+q1ZTm4MQ22 dPw4kmw9xyogGiivEY0Ss2+4GtWG/txtuxVIAt3WSpXV54EgcREIk0aUfZbr23YQ5bzH 3O1Q== X-Received: by 10.50.178.73 with SMTP id cw9mr19467igc.22.1361554226343; Fri, 22 Feb 2013 09:30:26 -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 3sm2244803igp.9.2013.02.22.09.30.24 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 22 Feb 2013 09:30:25 -0800 (PST) Message-ID: <5127AB2F.7070204@inktank.com> Date: Fri, 22 Feb 2013 11:30:23 -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@vger.kernel.org >> ceph-devel" Subject: [PATCH 4/5, v2] libceph: use a do..while loop in con_work() References: <5127A85D.1070000@inktank.com> <5127A935.8020605@inktank.com> In-Reply-To: <5127A935.8020605@inktank.com> X-Gm-Message-State: ALoCoQmOgKZ/Oeprr1SV/h9KmUw80eoYPyhbmWQ/yfiG7Iy+nH/IQjD1Os3I+N9djOvCK5av+DWS 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. Also update a few dout() calls near the affected code for consistency. 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 --- v2: rebased net/ceph/messenger.c | 39 ++++++++++++++++++++------------------- 1 file changed, 20 insertions(+), 19 deletions(-) diff --git a/net/ceph/messenger.c b/net/ceph/messenger.c index 18eb788..223406f 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)) { +while (true) { + int ret; + + if ((fault = con_sock_closed(con))) { dout("%s: con %p SOCK_CLOSED\n", __func__, con); - fault = true; - goto done; + break; } if (con_backoff(con)) { dout("%s: con %p BACKOFF\n", __func__, con); - goto done; + break; } if (con->state == CON_STATE_STANDBY) { - dout("con_work %p STANDBY\n", con); - goto done; + dout("%s: con %p STANDBY\n", __func__, con); + break; } if (con->state == CON_STATE_CLOSED) { - dout("con_work %p CLOSED\n", con); + dout("%s: con %p CLOSED\n", __func__, con); BUG_ON(con->sock); - goto done; + break; } if (con->state == CON_STATE_PREOPEN) { - dout("%s: con %p OPENING\n", __func__, con); + dout("%s: con %p PREOPEN\n", __func__, con); BUG_ON(con->sock); } 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); @@ -2442,7 +2444,6 @@ done: con->ops->put(con); } - /* * Generic error/fault handler. A retry mechanism is used with * exponential backoff