From patchwork Wed Feb 20 00:56:06 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 2165821 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 E05933FDF1 for ; Wed, 20 Feb 2013 00:56:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1759036Ab3BTA4K (ORCPT ); Tue, 19 Feb 2013 19:56:10 -0500 Received: from mail-qc0-f182.google.com ([209.85.216.182]:33827 "EHLO mail-qc0-f182.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1759033Ab3BTA4J (ORCPT ); Tue, 19 Feb 2013 19:56:09 -0500 Received: by mail-qc0-f182.google.com with SMTP id k19so2862025qcs.13 for ; Tue, 19 Feb 2013 16:56:09 -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=mtBdW8DhC84lVzLAbl4FkaF79E52QBr45PC88qW3P70=; b=oe5X78cdyzUhFRrkW/3I9a2WcGHBHQFJWLbnaRgrxb9q0i2LR8WcaQPNB4fn7bpMm0 UwT4vtsIU1vB/W141miiAS/5GZLmWHoeQEUt8dGw8e4LGayjyoqMJJ7To/laTyEvhP0U oMfgbeQWEIKppREYRItlqAB2bGO5oX1ajQPvXYSG/+arFd+o7NzWEdghV5ETaiC2wrKx JeiXoBbrRqi0tf11XrkidVUV2sIfzOwzv4raAYX7lb/+pwW23eCxCyp9GCHsvWdBVvg1 ED708QvN7aJQNQ/EJKyqzPPbEsgPewbOBFtbk/2ASQE6eNhHfz07YWuwXUkcTW5ndo/3 jIaw== X-Received: by 10.224.96.4 with SMTP id f4mr8504024qan.79.1361321768976; Tue, 19 Feb 2013 16:56:08 -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 ec9sm6577271qab.9.2013.02.19.16.56.07 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 19 Feb 2013 16:56:08 -0800 (PST) Message-ID: <51241F26.60902@inktank.com> Date: Tue, 19 Feb 2013 18:56:06 -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 3/5] libceph: use a flag to indicate a fault has occurred References: <51241E15.80903@inktank.com> In-Reply-To: <51241E15.80903@inktank.com> X-Gm-Message-State: ALoCoQkIc4YUjvqn2dxPgVDcP17gRx18ro7vePGm5uY+mnPrINNW0KjPPSJlq0dh39Pg6sEb8GZ1 Sender: ceph-devel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: ceph-devel@vger.kernel.org This just rearranges the logic in con_work() a little bit so that a flag is used to indicate a fault has occurred. This allows both the fault and non-fault case to be handled the same way and avoids a couple of nearly consecutive gotos. Signed-off-by: Alex Elder --- net/ceph/messenger.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/net/ceph/messenger.c b/net/ceph/messenger.c index 0fe9cbd..1cf0e53 100644 --- a/net/ceph/messenger.c +++ b/net/ceph/messenger.c @@ -2338,13 +2338,15 @@ 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; mutex_lock(&con->mutex); restart: if (con_sock_closed(con)) { dout("con_work %p SOCK_CLOSED\n", con); - goto fault; + fault = true; + goto done; } if (con_backoff(con)) { dout("con_work %p BACKOFF\n", con); @@ -2369,7 +2371,8 @@ restart: goto restart; if (ret < 0) { con->error_msg = "socket error on read"; - goto fault; + fault = true; + goto done; } ret = try_write(con); @@ -2377,20 +2380,17 @@ restart: goto restart; if (ret < 0) { con->error_msg = "socket error on write"; - goto fault; + fault = true; } - done: + if (fault) + con_fault(con); mutex_unlock(&con->mutex); -done_unlocked: - con->ops->put(con); - return; -fault: - con_fault(con); - mutex_unlock(&con->mutex); - con_fault_finish(con); - goto done_unlocked; + if (fault) + con_fault_finish(con); + + con->ops->put(con); }