From patchwork Wed Feb 20 00:55:52 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 2165851 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 BEDEADF24C for ; Wed, 20 Feb 2013 01:03:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933782Ab3BTBDT (ORCPT ); Tue, 19 Feb 2013 20:03:19 -0500 Received: from mail-qa0-f45.google.com ([209.85.216.45]:43996 "EHLO mail-qa0-f45.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933774Ab3BTBDT (ORCPT ); Tue, 19 Feb 2013 20:03:19 -0500 Received: by mail-qa0-f45.google.com with SMTP id g10so2184440qah.11 for ; Tue, 19 Feb 2013 17:03:18 -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=5oF/fwnEvoiJbyqAhU8gCHK/wvIxa3g3D5bzPlR+UWQ=; b=GapdKwHgVP4F9MC3XHmoNOAUayFPrZW5Sy2E8GYC1CRe1ns7aMD3/R1wV0VhYUsYCI NhU4jndSw+Zo3yd/b+0bmLY8Tz3co6bXCibi0YCjrhG6IMeQwWVbHyXdcSGEkaM7pwI9 hhXPAaspMns9Q4hwRpidu8AQtEIXVecIsOyDpwDiWMYYea1CjaRjF3OWIvlB2U/3sxo1 R9uMKTk+GCMeSd5IQPJ224qawCjXqlMOhWmE7t5sFW2gPdNu60ecsutD/6knoq5KrnD7 JHqHJFgMSjZCGGhB0oO5QRWGkTd0ZXJUIFLVudZW7gUA5eKyMYUJ64rDALC8F76Iq7c9 ZH+w== X-Received: by 10.49.48.113 with SMTP id k17mr8775534qen.51.1361321754931; Tue, 19 Feb 2013 16:55:54 -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 o5sm29431312qao.12.2013.02.19.16.55.53 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 19 Feb 2013 16:55:54 -0800 (PST) Message-ID: <51241F18.3030709@inktank.com> Date: Tue, 19 Feb 2013 18:55:52 -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 2/5] libceph: separate non-locked fault handling References: <51241E15.80903@inktank.com> In-Reply-To: <51241E15.80903@inktank.com> X-Gm-Message-State: ALoCoQmv2eEr6A6tnDPk6yGa4lRtDjYFFxlhIb9Dba7yGAGtv/CiBfO3uUjm+Us/gADLibgnJLaS Sender: ceph-devel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: ceph-devel@vger.kernel.org An error occurring on a ceph connection is treated as a fault, causing the connection to be reset. The initial part of this fault handling has to be done while holding the connection mutex, but it must then be dropped for the last part. Separate the part of this fault handling that executes without the lock into its own function, con_fault_finish(). Move the call to this new function, as well as call that drops the connection mutex, into ceph_fault(). Rename that function con_fault() to reflect that it's only handling the connection part of the fault handling. The motivation for this was a warning from sparse about the locking being done here. Rearranging things this way keeps all the mutex manipulation within ceph_fault(), and this stops sparse from complaining. This partially resolves: http://tracker.ceph.com/issues/4184 Reported-by: Fengguang Wu Signed-off-by: Alex Elder --- net/ceph/messenger.c | 42 +++++++++++++++++++++++------------------- 1 file changed, 23 insertions(+), 19 deletions(-) diff --git a/net/ceph/messenger.c b/net/ceph/messenger.c index 686973c..0fe9cbd 100644 --- a/net/ceph/messenger.c +++ b/net/ceph/messenger.c @@ -115,7 +115,7 @@ static struct lock_class_key socket_class; static void queue_con(struct ceph_connection *con); static void con_work(struct work_struct *); -static void ceph_fault(struct ceph_connection *con); +static void con_fault(struct ceph_connection *con); /* * Nicely render a sockaddr as a string. An array of formatted @@ -2314,6 +2314,23 @@ static bool con_backoff(struct ceph_connection *con) return true; } +/* Finish fault handling; con->mutex must *not* be held here */ + +static void con_fault_finish(struct ceph_connection *con) +{ + /* + * in case we faulted due to authentication, invalidate our + * current tickets so that we can get new ones. + */ + if (con->auth_retry && con->ops->invalidate_authorizer) { + dout("calling invalidate_authorizer()\n"); + con->ops->invalidate_authorizer(con); + } + + if (con->ops->fault) + con->ops->fault(con); +} + /* * Do some work on a connection. Drop a connection ref when we're done. */ @@ -2370,7 +2387,9 @@ done_unlocked: return; fault: - ceph_fault(con); /* error/fault path */ + con_fault(con); + mutex_unlock(&con->mutex); + con_fault_finish(con); goto done_unlocked; } @@ -2379,8 +2398,7 @@ fault: * Generic error/fault handler. A retry mechanism is used with * exponential backoff */ -static void ceph_fault(struct ceph_connection *con) - __releases(con->mutex) +static void con_fault(struct ceph_connection *con) { pr_warning("%s%lld %s %s\n", ENTITY_NAME(con->peer_name), ceph_pr_addr(&con->peer_addr.in_addr), con->error_msg); @@ -2396,7 +2414,7 @@ static void ceph_fault(struct ceph_connection *con) if (test_bit(CON_FLAG_LOSSYTX, &con->flags)) { dout("fault on LOSSYTX channel, marking CLOSED\n"); con->state = CON_STATE_CLOSED; - goto out_unlock; + return; } if (con->in_msg) { @@ -2427,20 +2445,6 @@ static void ceph_fault(struct ceph_connection *con) set_bit(CON_FLAG_BACKOFF, &con->flags); queue_con(con); } - -out_unlock: - mutex_unlock(&con->mutex); - /* - * in case we faulted due to authentication, invalidate our - * current tickets so that we can get new ones. - */ - if (con->auth_retry && con->ops->invalidate_authorizer) { - dout("calling invalidate_authorizer()\n"); - con->ops->invalidate_authorizer(con); - } - - if (con->ops->fault) - con->ops->fault(con); }