aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--net/sunrpc/cache.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/net/sunrpc/cache.c b/net/sunrpc/cache.c
index 83592e012585..9826c5ceb995 100644
--- a/net/sunrpc/cache.c
+++ b/net/sunrpc/cache.c
@@ -49,6 +49,12 @@ static void cache_init(struct cache_head *h)
49 h->last_refresh = now; 49 h->last_refresh = now;
50} 50}
51 51
52static inline int cache_is_expired(struct cache_detail *detail, struct cache_head *h)
53{
54 return (h->expiry_time < get_seconds()) ||
55 (detail->flush_time > h->last_refresh);
56}
57
52struct cache_head *sunrpc_cache_lookup(struct cache_detail *detail, 58struct cache_head *sunrpc_cache_lookup(struct cache_detail *detail,
53 struct cache_head *key, int hash) 59 struct cache_head *key, int hash)
54{ 60{
@@ -184,9 +190,7 @@ static int cache_make_upcall(struct cache_detail *cd, struct cache_head *h)
184static inline int cache_is_valid(struct cache_detail *detail, struct cache_head *h) 190static inline int cache_is_valid(struct cache_detail *detail, struct cache_head *h)
185{ 191{
186 if (!test_bit(CACHE_VALID, &h->flags) || 192 if (!test_bit(CACHE_VALID, &h->flags) ||
187 h->expiry_time < get_seconds()) 193 cache_is_expired(detail, h))
188 return -EAGAIN;
189 else if (detail->flush_time > h->last_refresh)
190 return -EAGAIN; 194 return -EAGAIN;
191 else { 195 else {
192 /* entry is valid */ 196 /* entry is valid */
@@ -400,8 +404,7 @@ static int cache_clean(void)
400 for (ch = *cp ; ch ; cp = & ch->next, ch = *cp) { 404 for (ch = *cp ; ch ; cp = & ch->next, ch = *cp) {
401 if (current_detail->nextcheck > ch->expiry_time) 405 if (current_detail->nextcheck > ch->expiry_time)
402 current_detail->nextcheck = ch->expiry_time+1; 406 current_detail->nextcheck = ch->expiry_time+1;
403 if (ch->expiry_time >= get_seconds() && 407 if (!cache_is_expired(current_detail, ch))
404 ch->last_refresh >= current_detail->flush_time)
405 continue; 408 continue;
406 409
407 *cp = ch->next; 410 *cp = ch->next;