From: bfields@fieldses.org (J. Bruce Fields)
To: Trond Myklebust <trondmy@gmail.com>
Cc: "J. Bruce Fields" <bfields@redhat.com>, linux-nfs@vger.kernel.org
Subject: Re: [PATCH] SUNRPC/cache: Allow garbage collection of invalid cache entries
Date: Thu, 6 Feb 2020 11:33:22 -0500 [thread overview]
Message-ID: <20200206163322.GB2244@fieldses.org> (raw)
In-Reply-To: <20200114165738.922961-1-trond.myklebust@hammerspace.com>
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 <trond.myklebust@hammerspace.com>
> ---
> 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
next prev parent reply other threads:[~2020-02-06 16:33 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-01-14 16:57 [PATCH] SUNRPC/cache: Allow garbage collection of invalid cache entries Trond Myklebust
2020-02-06 16:33 ` J. Bruce Fields [this message]
2020-02-07 14:25 ` Trond Myklebust
2020-02-07 18:18 ` bfields
2020-02-10 18:47 ` Trond Myklebust
2020-03-26 20:40 ` bfields
2020-03-26 21:42 ` Trond Myklebust
2020-03-27 1:50 ` J. Bruce Fields
2020-03-27 12:33 ` Trond Myklebust
2020-03-27 15:53 ` [PATCH] SUNRPC/cache: don't allow invalid entries to be flushed J. Bruce Fields
2020-03-27 16:15 ` Chuck Lever
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200206163322.GB2244@fieldses.org \
--to=bfields@fieldses.org \
--cc=bfields@redhat.com \
--cc=linux-nfs@vger.kernel.org \
--cc=trondmy@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).