Skip to content

Commit 9a81ef4

Browse files
J. Bruce Fieldschucklever
authored andcommitted
SUNRPC/cache: don't allow invalid entries to be flushed
Trond points out in commit 277f27e ("SUNRPC/cache: Allow garbage collection of invalid cache entries") that we allow invalid cache entries to persist indefinitely. That fix, however, reintroduces the problem fixed by Kinglong Mee's commit d6fc882 ("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: 277f27e ("SUNRPC/cache: Allow garbage collection ... ") Signed-off-by: J. Bruce Fields <[email protected]> Signed-off-by: Chuck Lever <[email protected]>
1 parent 69afd26 commit 9a81ef4

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

include/linux/sunrpc/cache.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -209,8 +209,11 @@ static inline void cache_put(struct cache_head *h, struct cache_detail *cd)
209209

210210
static inline bool cache_is_expired(struct cache_detail *detail, struct cache_head *h)
211211
{
212-
return (h->expiry_time < seconds_since_boot()) ||
213-
(detail->flush_time >= h->last_refresh);
212+
if (h->expiry_time < seconds_since_boot())
213+
return true;
214+
if (!test_bit(CACHE_VALID, &h->flags))
215+
return false;
216+
return detail->flush_time >= h->last_refresh;
214217
}
215218

216219
extern int cache_check(struct cache_detail *detail,

0 commit comments

Comments
 (0)