diff options
author | NeilBrown <neilb@suse.de> | 2010-02-03 01:31:31 -0500 |
---|---|---|
committer | J. Bruce Fields <bfields@citi.umich.edu> | 2010-03-14 18:08:37 -0400 |
commit | 2f50d8b63dd6e5320a9d223298df19df3502da29 (patch) | |
tree | c1b9aa6c882151bcdadd994233d7b8f33a43b9fb /net/sunrpc | |
parent | 3af4974eb2c7867d6e160977195dfde586d0e564 (diff) |
sunrpc/cache: factor out cache_is_expired
This removes a tiny bit of code duplication, but more important
prepares for following patch which will perform the expiry check in
cache_lookup and the rest of the validity check in cache_check.
Signed-off-by: NeilBrown <neilb@suse.de>
Signed-off-by: J. Bruce Fields <bfields@citi.umich.edu>
Diffstat (limited to 'net/sunrpc')
-rw-r--r-- | net/sunrpc/cache.c | 13 |
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 | ||
52 | static 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 | |||
52 | struct cache_head *sunrpc_cache_lookup(struct cache_detail *detail, | 58 | struct 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) | |||
184 | static inline int cache_is_valid(struct cache_detail *detail, struct cache_head *h) | 190 | static 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; |