Received: by 10.223.176.46 with SMTP id f43csp93344wra; Tue, 23 Jan 2018 16:49:54 -0800 (PST) X-Google-Smtp-Source: AH8x225jOxdAVqCO97aNBkRz9qvzp8qkGPJalkrsMn5O5TnVyas2BSE2N+nyBQviPwrugwXAOl83 X-Received: by 10.99.160.88 with SMTP id u24mr9528427pgn.122.1516754994024; Tue, 23 Jan 2018 16:49:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516754993; cv=none; d=google.com; s=arc-20160816; b=VbTFV1OsckdekPHVcuN5baQKTFe/3WBvi9QS7hAe+P64aCGEej1qyTM7RusWfTC1E5 RZNo318szgH8loykf+GtS2HhFRwVfoKlO0gAyusGXUDH2UdG1wdO4Q1r6UjAcbpk04li Y5+e+ZXJZZ5WUlKEan4CQ34LkC/9dcVPr2uegYzCizpZSFk5Jo9Q4tfGTArXA1duJD5s nELoqpenCAYWv0f+ECSfTi3SzEJQNa/GjLl90uANjtBuv/aAHrAkdl7a9Azn0tXfhV9m 17lyX6r0qQYpYrHx3cqr6PGn+oqXnv7ielnEKd0LNPHNli0AYn7S/xC4JV/tz6pHl6KS HOaQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:date:cc:to:from:subject:message-id :dkim-signature:arc-authentication-results; bh=aLiveIl7BTBG4toevbK3fdZkjFIhu1flH3Z7HL9pEt8=; b=dtcGkbdcX3R95jfTqCdL9UxsWyRw6DWMnJLmxDwHmhm067rTd0AqXOY6OcX3ecm57F Yl45bXeRF2b3cAq0uSckKnsXE7pFU/mitsazpeXTv/AbLDZnWJdsQApFNw24+lt4nG3g GA9DwVPcYCPsZ6a4V8Rf5aK19fQswl18pHkVlA12dNrKYm/FND5bK3mEj7c50mcf4ceo VLD5/EU0v5ElvaR1skuOfGrlaYogGUv2iDLC2y2DOvbdS0BWt4uZdxeqcpSL0vDgqjvR MSaGXFKjMe3rD3JhvuY8T0HPAbb5Q2ItzgxpTy6xFY8ljSiGm4lQFCMOPB2hUcIphUFl OlLQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=FggIZTgZ; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b91-v6si2989048plb.819.2018.01.23.16.49.39; Tue, 23 Jan 2018 16:49:53 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=FggIZTgZ; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932434AbeAXArg (ORCPT + 99 others); Tue, 23 Jan 2018 19:47:36 -0500 Received: from mail-io0-f195.google.com ([209.85.223.195]:34892 "EHLO mail-io0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932083AbeAXAre (ORCPT ); Tue, 23 Jan 2018 19:47:34 -0500 Received: by mail-io0-f195.google.com with SMTP id m11so2997913iob.2; Tue, 23 Jan 2018 16:47:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=message-id:subject:from:to:cc:date:in-reply-to:references :mime-version:content-transfer-encoding; bh=aLiveIl7BTBG4toevbK3fdZkjFIhu1flH3Z7HL9pEt8=; b=FggIZTgZTwgGW/mOcJb/oKBdl2EXANiC2h4DlrPzMZc6MIRUGfBcEhBlhpwO5iAwhY lro9pdahOMwsenxBDZOSVpuH6J+7Bc/P5nxNx+plcKmO05OWfluFVN51MPdFbCTTqwdf l9fLOmcT66QoBl5fAYUqaThNIBRTblWBZ1/+6bgi5Dsz0GtbO2cdN4gKe/DZ0YG9qlo7 MieHqF+HPaEOtiyZgGYUpbcvPdR1kgk83gV5P9EsZF1a/UQrVabsCHrY7eogJopP0el+ e5uvATdvpu39zRDmW2Qsp7pXEq/ZzcJ3C6W7pOTSQww2ce1kXt5fUj1QioDlW0xIqAmG QdzA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:subject:from:to:cc:date:in-reply-to :references:mime-version:content-transfer-encoding; bh=aLiveIl7BTBG4toevbK3fdZkjFIhu1flH3Z7HL9pEt8=; b=nOlXCAEagdfNMoQ05w4TZTjed3Axt6DpZkfgoCRSBIjvoEgSpXCJFU7KN5okRBhKU5 9ZaCCwECmdvOGypbvZ6Ufo4s6QhwWq063ts1jkTkzSPugiJ/XYux7FbdT7PoXACK/3/L xfJsHVhNlHtH7nJaXyQoVIxZo3xNKc9iCE5ms276OEt/ocjQMEI3YerUwY7ildX+hkx9 gPWIvG2YU889m6Iqhbl/aLCpE86dmSBozc0MJ0gIPsqv/hhUKEvcFSAP1ePoDstJMjZ0 uHTQtjc4i+v3t1+lcA1A6p3gvCQ6Avh7tmi2bUoLzM/fxjkwsJJE1RbHtfgakfdLriDH eVVg== X-Gm-Message-State: AKwxyteIl2yAjGIclQZ7f9e21KNg306w+Ayv+XVE7qoe/WUe1grK440N tvLK3ZFKDLSz2sBSHpR0UQ== X-Received: by 10.107.170.142 with SMTP id g14mr6250874ioj.22.1516754853654; Tue, 23 Jan 2018 16:47:33 -0800 (PST) Received: from leira (c-68-49-162-121.hsd1.mi.comcast.net. [68.49.162.121]) by smtp.gmail.com with ESMTPSA id m26sm10274395ioi.50.2018.01.23.16.47.32 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 23 Jan 2018 16:47:33 -0800 (PST) Message-ID: <1516754851.18068.3.camel@gmail.com> Subject: Re: [PATCH 1/4] lockd: convert nlm_host.h_count from atomic_t to refcount_t From: Trond Myklebust To: "J. Bruce Fields" , "Reshetova, Elena" Cc: "linux-nfs@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "jlayton@kernel.org" , "anna.schumaker@netapp.com" , "peterz@infradead.org" , "keescook@chromium.org" Date: Tue, 23 Jan 2018 19:47:31 -0500 In-Reply-To: <20180123220950.GA5632@fieldses.org> References: <1511954146-11793-1-git-send-email-elena.reshetova@intel.com> <1511954146-11793-2-git-send-email-elena.reshetova@intel.com> <20171221202350.GE31467@fieldses.org> <2236FBA76BA1254E88B949DDB74E612B802CFB57@IRSMSX102.ger.corp.intel.com> <20171222142553.GA9630@fieldses.org> <20171222154250.GB9630@fieldses.org> <2236FBA76BA1254E88B949DDB74E612B802D08DA@IRSMSX102.ger.corp.intel.com> <20180123220950.GA5632@fieldses.org> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.26.4 (3.26.4-1.fc27) Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 2018-01-23 at 17:09 -0500, J. Bruce Fields wrote: > > The object still has useful information in it so we can't just > reinitalize it completely. I guess we could make nlm_get_host do > > if (refcount_read(&host->h_count)) > refcount_inc(&host->h_count); > else > refcount_set(&host->h_count, 1); > > Or we could just change the code so the refcount is always 1 higher > in > the NFS server case, so "1" instead of "0" is used to mean "nobody's > using this, you can garbage collect this", and then it won't go to 0 > until the garbage collector actually destroys it. > > This isn't an unusual pattern, what have other subsystems been doing? > Hi Bruce, Sorry I forgot about the issues with the server garbage collector, and I applied these patches to my linux-next a couple of weeks ago. What say we fix the issue with something like the following? 8<------------------------------------------------------------ From 83ce0f55ca54337a573f1d70038714815a9cd645 Mon Sep 17 00:00:00 2001 From: Trond Myklebust Date: Tue, 23 Jan 2018 19:39:04 -0500 Subject: [PATCH] lockd: Fix server refcounting The server shouldn't actually delete the struct nlm_host until it hits the garbage collector. In order to make that work correctly with the refcount API, we can bump the refcount by one, and then use refcount_dec_if_one() in the garbage collector. Signed-off-by: Trond Myklebust --- fs/lockd/host.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/fs/lockd/host.c b/fs/lockd/host.c index 7d6ab72bbe65..d35cd6be0675 100644 --- a/fs/lockd/host.c +++ b/fs/lockd/host.c @@ -388,6 +388,8 @@ struct nlm_host *nlmsvc_lookup_host(const struct svc_rqst *rqstp, ln->nrhosts++; nrhosts++; + refcount_inc(&host->h_count); + dprintk("lockd: %s created host %s (%s)\n", __func__, host->h_name, host->h_addrbuf); @@ -662,8 +664,7 @@ nlm_gc_hosts(struct net *net) for_each_host_safe(host, next, chain, nlm_server_hosts) { if (net && host->net != net) continue; - if (refcount_read(&host->h_count) || host->h_inuse - || time_before(jiffies, host->h_expires)) { + if (host->h_inuse || time_before(jiffies, host->h_expires)) { dprintk("nlm_gc_hosts skipping %s " "(cnt %d use %d exp %ld net %x)\n", host->h_name, refcount_read(&host->h_count), @@ -671,7 +672,8 @@ nlm_gc_hosts(struct net *net) host->net->ns.inum); continue; } - nlm_destroy_host_locked(host); + if (refcount_dec_if_one(&host->h_count)) + nlm_destroy_host_locked(host); } if (net) { -- 2.14.3 -- Trond Myklebust Linux NFS client maintainer, PrimaryData trond.myklebust@primarydata.com