Skip to content

Commit 2f50d8b

Browse files
neilbrownJ. Bruce Fields
authored andcommitted
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>
1 parent 3af4974 commit 2f50d8b

1 file changed

Lines changed: 8 additions & 5 deletions

File tree

‎net/sunrpc/cache.c‎

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,12 @@ static void cache_init(struct cache_head *h)
4949
h->last_refresh = now;
5050
}
5151

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+
5258
struct cache_head *sunrpc_cache_lookup(struct cache_detail *detail,
5359
struct cache_head *key, int hash)
5460
{
@@ -184,9 +190,7 @@ static int cache_make_upcall(struct cache_detail *cd, struct cache_head *h)
184190
static inline int cache_is_valid(struct cache_detail *detail, struct cache_head *h)
185191
{
186192
if (!test_bit(CACHE_VALID, &h->flags) ||
187-
h->expiry_time < get_seconds())
188-
return -EAGAIN;
189-
else if (detail->flush_time > h->last_refresh)
193+
cache_is_expired(detail, h))
190194
return -EAGAIN;
191195
else {
192196
/* entry is valid */
@@ -400,8 +404,7 @@ static int cache_clean(void)
400404
for (ch = *cp ; ch ; cp = & ch->next, ch = *cp) {
401405
if (current_detail->nextcheck > ch->expiry_time)
402406
current_detail->nextcheck = ch->expiry_time+1;
403-
if (ch->expiry_time >= get_seconds() &&
404-
ch->last_refresh >= current_detail->flush_time)
407+
if (!cache_is_expired(current_detail, ch))
405408
continue;
406409

407410
*cp = ch->next;

0 commit comments

Comments
 (0)