public inbox for linux-nfs@vger.kernel.org
 help / color / mirror / Atom feed
From: "J. Bruce Fields" <bfields@redhat.com>
To: Chuck Lever <chuck.lever@oracle.com>
Cc: Trond Myklebust <trondmy@hammerspace.com>,
	"bfields@fieldses.org" <bfields@fieldses.org>,
	"kinglongmee@gmail.com" <kinglongmee@gmail.com>,
	"linux-nfs@vger.kernel.org" <linux-nfs@vger.kernel.org>
Subject: [PATCH] SUNRPC/cache: don't allow invalid entries to be flushed
Date: Fri, 27 Mar 2020 11:53:09 -0400	[thread overview]
Message-ID: <20200327155309.GA135601@pick.fieldses.org> (raw)
In-Reply-To: <80c83f5543d7d758a165be167d3bf0b2175e57f8.camel@hammerspace.com>

From: "J. Bruce Fields" <bfields@redhat.com>

Trond points out in 277f27e2f277 that we allow invalid cache entries to
persist indefinitely.  That fix, however, reintroduces the problem fixed
by Kinglong Mee's d6fc8821c2d2 "SUNRPC/Cache: Always treat the invalid
cache as unexpired", where an invalid cache entry is immediately removed
by a flush before mountd responds to it.  The result is that the server
thread that should be waiting for mountd to fill in that entry instead
gets an -ETIMEDOUT return from cache_check().  Symptoms are the server
becoming unresponsive after a restart, reproduceable by running pynfs
4.1 test REBT5.

Instead, take a compromise approach: allow invalid cache entries to be
removed after they expire, but not to be removed by a cache flush.

Fixes: 277f27e2f277 "SUNRPC/cache: Allow garbage collection..."
Signed-off-by: J. Bruce Fields <bfields@redhat.com>
---
 include/linux/sunrpc/cache.h | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/include/linux/sunrpc/cache.h b/include/linux/sunrpc/cache.h
index 532cdbda43da..10891b70fc7b 100644
--- a/include/linux/sunrpc/cache.h
+++ b/include/linux/sunrpc/cache.h
@@ -209,8 +209,11 @@ 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)
 {
-	return  (h->expiry_time < seconds_since_boot()) ||
-		(detail->flush_time >= h->last_refresh);
+	if (h->expiry_time < seconds_since_boot())
+		return true;
+	if (!test_bit(CACHE_VALID, &h->flags))
+		return false;
+	return detail->flush_time >= h->last_refresh;
 }
 
 extern int cache_check(struct cache_detail *detail,
-- 
2.25.1


  reply	other threads:[~2020-03-27 15:53 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
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               ` J. Bruce Fields [this message]
2020-03-27 16:15                 ` [PATCH] SUNRPC/cache: don't allow invalid entries to be flushed 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=20200327155309.GA135601@pick.fieldses.org \
    --to=bfields@redhat.com \
    --cc=bfields@fieldses.org \
    --cc=chuck.lever@oracle.com \
    --cc=kinglongmee@gmail.com \
    --cc=linux-nfs@vger.kernel.org \
    --cc=trondmy@hammerspace.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