From patchwork Tue Oct 9 21:33:00 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 1571671 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 3BDE73FE80 for ; Tue, 9 Oct 2012 21:33:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756825Ab2JIVdF (ORCPT ); Tue, 9 Oct 2012 17:33:05 -0400 Received: from mail-pb0-f46.google.com ([209.85.160.46]:53550 "EHLO mail-pb0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754075Ab2JIVdD (ORCPT ); Tue, 9 Oct 2012 17:33:03 -0400 Received: by mail-pb0-f46.google.com with SMTP id rr4so5691963pbb.19 for ; Tue, 09 Oct 2012 14:33:03 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=message-id:date:from:user-agent:mime-version:to:subject:references :in-reply-to:content-type:content-transfer-encoding :x-gm-message-state; bh=019RFVYrbexZnkCzzVnBQlviA5v0TC/2uZlcb6iyp0Y=; b=CKszLPqWg70e1hqFMF2sw21ANMO19IOaRrT+Kjyq3BTHERHuiV8ZwvKi3yurojISF1 RcnIwdUwcfSXyKGbeemNMvCFGRYIhoTetJAvskLqlVs8H6xrrAw8vJN68PbtlnrllGXl l3jb+8zQmoeQkwXVUDbLUjn01Zt3T6VDC5j2MlquRWTtGxmGfMjF96RJAtI+d0rfMFIl tlPWcBRLo85IMOSMhMKspNaXkwcgY2DPWzVzSCXktVYrOcBuMsJvkj6CoCzUI0APaFS8 4SYtwYK8xQCn1ISrQow6cE8Bv3M058jFz1j+YZwuvta7uufYAZfCUMxbialsQUI5FtSA Thhg== Received: by 10.68.225.34 with SMTP id rh2mr67332551pbc.78.1349818383414; Tue, 09 Oct 2012 14:33:03 -0700 (PDT) Received: from ?IPv6:2607:f298:a:607:4823:f93f:93c7:61da? ([2607:f298:a:607:4823:f93f:93c7:61da]) by mx.google.com with ESMTPS id o1sm1962021paz.34.2012.10.09.14.33.01 (version=SSLv3 cipher=OTHER); Tue, 09 Oct 2012 14:33:02 -0700 (PDT) Message-ID: <5074980C.6090104@inktank.com> Date: Tue, 09 Oct 2012 14:33:00 -0700 From: Alex Elder User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:15.0) Gecko/20120912 Thunderbird/15.0.1 MIME-Version: 1.0 To: ceph-devel@vger.kernel.org Subject: [PATCH 1/3] libceph: reset BACKOFF if unable to re-queue References: <507497AC.5030609@inktank.com> In-Reply-To: <507497AC.5030609@inktank.com> X-Gm-Message-State: ALoCoQkTatYPvKvNM7ztpDXzq/YNSIDlr8a7QmQ7PWLq4eEGCbIvJcPgPyD1B9A3nTUQAnAmPWor Sender: ceph-devel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: ceph-devel@vger.kernel.org If ceph_fault() is unable to queue work after a delay, it sets the BACKOFF connection flag so con_work() will attempt to do so. In con_work(), when BACKOFF is set, if queue_delayed_work() doesn't result in newly-queued work, it simply ignores this condition and proceeds as if no backoff delay were desired. There are two problems with this--one of which is a bug. The first problem is simply that the intended behavior is to back off, and if we aren't able queue the work item to run after a delay we're not doing that. The only reason queue_delayed_work() won't queue work is if the provided work item is already queued. In the messenger, this means that con_work() is already scheduled to be run again. So if we simply set the BACKOFF flag again when this occurs, we know the next con_work() call will again attempt to hold off activity on the connection until after the delay. The second problem--the bug--is a leak of a reference count. If queue_delayed_work() returns 0 in con_work(), con->ops->put() drops the connection reference held on entry to con_work(). However, processing is (was) allowed to continue, and at the end of the function a second con->ops->put() is called. This patch fixes both problems. Signed-off-by: Alex Elder Reviewed-by: Sage Weil --- net/ceph/messenger.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/net/ceph/messenger.c b/net/ceph/messenger.c index f9f65fe..ece06bc 100644 --- a/net/ceph/messenger.c +++ b/net/ceph/messenger.c @@ -2300,10 +2300,11 @@ restart: mutex_unlock(&con->mutex); return; } else { - con->ops->put(con); dout("con_work %p FAILED to back off %lu\n", con, con->delay); + set_bit(CON_FLAG_BACKOFF, &con->flags); } + goto done; } if (con->state == CON_STATE_STANDBY) {