From patchwork Wed Feb 20 00:55:24 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 2165811 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 D67473FDF1 for ; Wed, 20 Feb 2013 00:55:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758997Ab3BTAz3 (ORCPT ); Tue, 19 Feb 2013 19:55:29 -0500 Received: from mail-qa0-f47.google.com ([209.85.216.47]:46041 "EHLO mail-qa0-f47.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1758948Ab3BTAz2 (ORCPT ); Tue, 19 Feb 2013 19:55:28 -0500 Received: by mail-qa0-f47.google.com with SMTP id j8so2167015qah.20 for ; Tue, 19 Feb 2013 16:55:27 -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=wmhNMqPutyNllSMN7qiQdOs0rIJZ8cAGXBk+qs75iPE=; b=jdlaRERUlRyysxLtUIobSfqLXC1YDIwwlRajONIgGs0tmDVBuDno81wnM6jd9eFnAI IYWRuCNtDGkWosiYH6IDzJUzL+3eQWbobdUVmskUYsXa4XHKLWlMdmPR/u3U9vB/4wuf ZIlHRITOoEoCIW3lchRAq3ajgwMuvaU0sLyNdmLBeFlsI6eCp0/AZGDwKZg34ZtrVcov n2BHGHeezse/EM/ahdFZlLjgAwEccH7Xu55f2AB0gv2cDUwrwk4X3HAdCYJMji/deaeu WS6b1l+Yt8BfSkKDpGZSlQhPY750MSyIoSRRpIHtjlgWzH4x77YO8Xnex/Y9uC9GogT/ 4JgA== X-Received: by 10.49.74.73 with SMTP id r9mr8501987qev.44.1361321727576; Tue, 19 Feb 2013 16:55:27 -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 hr1sm28673335qeb.3.2013.02.19.16.55.26 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 19 Feb 2013 16:55:26 -0800 (PST) Message-ID: <51241EFC.2080104@inktank.com> Date: Tue, 19 Feb 2013 18:55:24 -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 1/5] libceph: encapsulate connection backoff References: <51241E15.80903@inktank.com> In-Reply-To: <51241E15.80903@inktank.com> X-Gm-Message-State: ALoCoQmJSdYfYeDSYLJr8Sml+iq/XIBII/uOlmN5JVMgH3OwB/0OBLDOyDwLRo1Xvnb2NapRGkFl Sender: ceph-devel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: ceph-devel@vger.kernel.org Collect the code that tests for and implements a backoff delay for a ceph connection into a new function, ceph_backoff(). Make the debug output messages in that part of the code report things consistently by reporting a message in the socket closed case, and by making the one for PREOPEN state report the connection pointer like the rest. Signed-off-by: Alex Elder --- net/ceph/messenger.c | 37 ++++++++++++++++++++++++------------- 1 file changed, 24 insertions(+), 13 deletions(-) */ @@ -2307,21 +2325,14 @@ static void con_work(struct work_struct *work) mutex_lock(&con->mutex); restart: - if (con_sock_closed(con)) + if (con_sock_closed(con)) { + dout("con_work %p SOCK_CLOSED\n", con); goto fault; - - if (test_and_clear_bit(CON_FLAG_BACKOFF, &con->flags)) { - dout("con_work %p backing off\n", con); - ret = queue_con_delay(con, round_jiffies_relative(con->delay)); - if (ret) { - dout("con_work %p FAILED to back off %lu\n", con, - con->delay); - BUG_ON(ret == -ENOENT); - set_bit(CON_FLAG_BACKOFF, &con->flags); - } + } + if (con_backoff(con)) { + dout("con_work %p BACKOFF\n", con); goto done; } - if (con->state == CON_STATE_STANDBY) { dout("con_work %p STANDBY\n", con); goto done; @@ -2332,7 +2343,7 @@ restart: goto done; } if (con->state == CON_STATE_PREOPEN) { - dout("con_work OPENING\n"); + dout("con_work %p OPENING\n", con); BUG_ON(con->sock); } diff --git a/net/ceph/messenger.c b/net/ceph/messenger.c index ab702cd..686973c 100644 --- a/net/ceph/messenger.c +++ b/net/ceph/messenger.c @@ -2296,6 +2296,24 @@ static bool con_sock_closed(struct ceph_connection *con) return true; } +static bool con_backoff(struct ceph_connection *con) +{ + int ret; + + if (!test_and_clear_bit(CON_FLAG_BACKOFF, &con->flags)) + return false; + + ret = queue_con_delay(con, round_jiffies_relative(con->delay)); + if (ret) { + dout("%s %p FAILED to back off %lu\n", + __func__, con, con->delay); + BUG_ON(ret == -ENOENT); + set_bit(CON_FLAG_BACKOFF, &con->flags); + } + + return true; +} + /* * Do some work on a connection. Drop a connection ref when we're done.