Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp1714213ybv; Thu, 6 Feb 2020 08:33:53 -0800 (PST) X-Google-Smtp-Source: APXvYqxJjtMo++xdbBghWgxNwMhsrs6Oy1e5UKSJ8bDP/Vhuv/YGIqYEQMEaaHRQY6T+6zem1Qyp X-Received: by 2002:a05:6830:15d2:: with SMTP id j18mr166960otr.216.1581006833693; Thu, 06 Feb 2020 08:33:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1581006833; cv=none; d=google.com; s=arc-20160816; b=EVTgYvI1WNjbGRB193CXARxTuVHldTCpnMYujNgmyx9dg8Uvjt1GRgSCesrgsW1UGP yX9vrpY9NfMu/7FO/p+sCb3tj7H6sdyXtoI/iElfIYZs29kdrKldA22Bpr38jZzy9EkH 8nnkncyxR9JheXcyA6jRK5sDwH2OMtE+C+iqgkC4lFlfkawke/4BtfsRfsGEpeC3JHKe R/obnFpRdtilPl6XRHiOqLBISjPGSxSUPbqtjt6OxRARkt+GKiQaT5e8ZMrbwo7t/HVb Ai0730V8mW6DzSl1rBXxQ6TnE1czTBZ30pmZfH3I/On2G0U/e+umtSyA+ZE90P64Noy6 IUOg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:from:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:date; bh=aNe5u9+hZyDGvsMZby4KXWi12rUFlhIiEtTySE8j/vw=; b=MrxG25zujaLOzUGjr1BN8bPmR7y9zpj+ZFFZkVI8usITtSkDUHw6j08K48AqwfkshL maytwZHXIfkupAP5TTCN8JfRcz8cU3Zm2ry0X5NfaN7PXQy8yUKCjIHLhDjtXS2stjur 37Bv6XK9hFEMfJN/7B1pM8ke9ZnyWxcdXw6f/4uPzXycl94RiMBWGFS6FaqiTVxLrKt0 2lWOgF3RUcdUDCA3qllnj0sbZq9rz0ouGyjWPX/iK44nUoQJ6mLX4e+Mr6gF+6aEQmTN CUR5kGIAU3rRZNFf5bpchIzN1gp8u/t9LMpcOQ+t53BIdbyuhkrNJh/TXfbgxyEqirBJ vNEg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-nfs-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i6si58946otj.24.2020.02.06.08.33.28; Thu, 06 Feb 2020 08:33:53 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-nfs-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-nfs-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727514AbgBFQdX (ORCPT + 99 others); Thu, 6 Feb 2020 11:33:23 -0500 Received: from fieldses.org ([173.255.197.46]:55356 "EHLO fieldses.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727390AbgBFQdX (ORCPT ); Thu, 6 Feb 2020 11:33:23 -0500 Received: by fieldses.org (Postfix, from userid 2815) id E030C709; Thu, 6 Feb 2020 11:33:22 -0500 (EST) Date: Thu, 6 Feb 2020 11:33:22 -0500 To: Trond Myklebust Cc: "J. Bruce Fields" , linux-nfs@vger.kernel.org Subject: Re: [PATCH] SUNRPC/cache: Allow garbage collection of invalid cache entries Message-ID: <20200206163322.GB2244@fieldses.org> References: <20200114165738.922961-1-trond.myklebust@hammerspace.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200114165738.922961-1-trond.myklebust@hammerspace.com> User-Agent: Mutt/1.5.21 (2010-09-15) From: bfields@fieldses.org (J. Bruce Fields) Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org On Tue, Jan 14, 2020 at 11:57:38AM -0500, Trond Myklebust wrote: > If the cache entry never gets initialised, we want the garbage > collector to be able to evict it. Otherwise if the upcall daemon > fails to initialise the entry, we end up never expiring it. Could you tell us more about what motivated this? It's causing failures on pynfs server-reboot tests. I haven't pinned down the cause yet, but it looks like it could be a regression to the behavior Kinglong Mee describes in detail in his original patch. Dropping for the time being. --b. > > Fixes: d6fc8821c2d2 ("SUNRPC/Cache: Always treat the invalid cache as unexpired") > Signed-off-by: Trond Myklebust > --- > include/linux/sunrpc/cache.h | 3 --- > net/sunrpc/cache.c | 36 +++++++++++++++++++----------------- > 2 files changed, 19 insertions(+), 20 deletions(-) > > diff --git a/include/linux/sunrpc/cache.h b/include/linux/sunrpc/cache.h > index f8603724fbee..0428dd23fd79 100644 > --- a/include/linux/sunrpc/cache.h > +++ b/include/linux/sunrpc/cache.h > @@ -202,9 +202,6 @@ static inline void cache_put(struct cache_head *h, struct cache_detail *cd) > > static inline bool cache_is_expired(struct cache_detail *detail, struct cache_head *h) > { > - if (!test_bit(CACHE_VALID, &h->flags)) > - return false; > - > return (h->expiry_time < seconds_since_boot()) || > (detail->flush_time >= h->last_refresh); > } > diff --git a/net/sunrpc/cache.c b/net/sunrpc/cache.c > index 52d927210d32..99d630150af6 100644 > --- a/net/sunrpc/cache.c > +++ b/net/sunrpc/cache.c > @@ -65,13 +65,14 @@ static struct cache_head *sunrpc_cache_find_rcu(struct cache_detail *detail, > > rcu_read_lock(); > hlist_for_each_entry_rcu(tmp, head, cache_list) { > - if (detail->match(tmp, key)) { > - if (cache_is_expired(detail, tmp)) > - continue; > - tmp = cache_get_rcu(tmp); > - rcu_read_unlock(); > - return tmp; > - } > + if (!detail->match(tmp, key)) > + continue; > + if (test_bit(CACHE_VALID, &tmp->flags) && > + cache_is_expired(detail, tmp)) > + continue; > + tmp = cache_get_rcu(tmp); > + rcu_read_unlock(); > + return tmp; > } > rcu_read_unlock(); > return NULL; > @@ -114,17 +115,18 @@ static struct cache_head *sunrpc_cache_add_entry(struct cache_detail *detail, > > /* check if entry appeared while we slept */ > hlist_for_each_entry_rcu(tmp, head, cache_list) { > - if (detail->match(tmp, key)) { > - if (cache_is_expired(detail, tmp)) { > - sunrpc_begin_cache_remove_entry(tmp, detail); > - freeme = tmp; > - break; > - } > - cache_get(tmp); > - spin_unlock(&detail->hash_lock); > - cache_put(new, detail); > - return tmp; > + if (!detail->match(tmp, key)) > + continue; > + if (test_bit(CACHE_VALID, &tmp->flags) && > + cache_is_expired(detail, tmp)) { > + sunrpc_begin_cache_remove_entry(tmp, detail); > + freeme = tmp; > + break; > } > + cache_get(tmp); > + spin_unlock(&detail->hash_lock); > + cache_put(new, detail); > + return tmp; > } > > hlist_add_head_rcu(&new->cache_list, head); > -- > 2.24.1