From: NeilBrown <neilb@suse.de>
To: "J. Bruce Fields" <bfields@fieldses.org>
Cc: linux-nfs@vger.kernel.org
Subject: [PATCH 2/9] sunrpc/cache: factor out cache_is_expired
Date: Wed, 03 Feb 2010 17:31:31 +1100 [thread overview]
Message-ID: <20100203063131.12945.65321.stgit@notabene.brown> (raw)
In-Reply-To: <20100203060657.12945.27293.stgit-wvvUuzkyo1EYVZTmpyfIwg@public.gmane.org>
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>
---
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 83592e0..9826c5c 100644
--- a/net/sunrpc/cache.c
+++ b/net/sunrpc/cache.c
@@ -49,6 +49,12 @@ static void cache_init(struct cache_head *h)
h->last_refresh = now;
}
+static inline int cache_is_expired(struct cache_detail *detail, struct cache_head *h)
+{
+ return (h->expiry_time < get_seconds()) ||
+ (detail->flush_time > h->last_refresh);
+}
+
struct cache_head *sunrpc_cache_lookup(struct cache_detail *detail,
struct cache_head *key, int hash)
{
@@ -184,9 +190,7 @@ static int cache_make_upcall(struct cache_detail *cd, struct cache_head *h)
static inline int cache_is_valid(struct cache_detail *detail, struct cache_head *h)
{
if (!test_bit(CACHE_VALID, &h->flags) ||
- h->expiry_time < get_seconds())
- return -EAGAIN;
- else if (detail->flush_time > h->last_refresh)
+ cache_is_expired(detail, h))
return -EAGAIN;
else {
/* entry is valid */
@@ -400,8 +404,7 @@ static int cache_clean(void)
for (ch = *cp ; ch ; cp = & ch->next, ch = *cp) {
if (current_detail->nextcheck > ch->expiry_time)
current_detail->nextcheck = ch->expiry_time+1;
- if (ch->expiry_time >= get_seconds() &&
- ch->last_refresh >= current_detail->flush_time)
+ if (!cache_is_expired(current_detail, ch))
continue;
*cp = ch->next;
next prev parent reply other threads:[~2010-02-03 6:39 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-02-03 6:31 [PATCH 0/9] Cache deferal improvements - try++ NeilBrown
[not found] ` <20100203060657.12945.27293.stgit-wvvUuzkyo1EYVZTmpyfIwg@public.gmane.org>
2010-02-03 6:31 ` [PATCH 5/9] nfsd/idmap: drop special request deferal in favour of improved default NeilBrown
2010-02-03 6:31 ` NeilBrown [this message]
[not found] ` <20100203063131.12945.65321.stgit-wvvUuzkyo1EYVZTmpyfIwg@public.gmane.org>
2010-03-15 0:58 ` [PATCH 2/9] sunrpc/cache: factor out cache_is_expired J. Bruce Fields
2010-02-03 6:31 ` [PATCH 6/9] sunrpc: close connection when a request is irretrievably lost NeilBrown
2010-02-03 15:43 ` Chuck Lever
2010-02-03 21:23 ` Neil Brown
2010-02-03 22:20 ` Trond Myklebust
2010-02-03 22:34 ` J. Bruce Fields
2010-02-03 22:40 ` Chuck Lever
2010-02-03 23:13 ` Trond Myklebust
2010-02-04 0:06 ` Chuck Lever
2010-02-04 0:24 ` Trond Myklebust
2010-02-03 22:34 ` Chuck Lever
2010-02-03 6:31 ` [PATCH 3/9] sunrpc: never return expired entries in sunrpc_cache_lookup NeilBrown
[not found] ` <20100203063131.12945.97779.stgit-wvvUuzkyo1EYVZTmpyfIwg@public.gmane.org>
2010-03-17 21:33 ` J. Bruce Fields
2010-03-24 1:22 ` Neil Brown
2010-03-30 15:11 ` J. Bruce Fields
2010-02-03 6:31 ` [PATCH 1/9] sunrpc: don't keep expired entries in the auth caches NeilBrown
[not found] ` <20100203063130.12945.29226.stgit-wvvUuzkyo1EYVZTmpyfIwg@public.gmane.org>
2010-03-15 0:58 ` J. Bruce Fields
2010-02-03 6:31 ` [PATCH 8/9] svcauth_gss: replace a trivial 'switch' with an 'if' NeilBrown
2010-02-03 6:31 ` [PATCH 7/9] nfsd: factor out hash functions for export caches NeilBrown
[not found] ` <20100203063131.12945.38791.stgit-wvvUuzkyo1EYVZTmpyfIwg@public.gmane.org>
2010-03-17 19:35 ` J. Bruce Fields
2010-02-03 6:31 ` [PATCH 4/9] sunrpc/cache: allow threads to block while waiting for cache update NeilBrown
2010-04-15 15:55 ` J. Bruce Fields
2010-02-03 6:31 ` [PATCH 9/9] sunrpc/cache: change deferred-request hash table to use hlist NeilBrown
2010-02-03 19:43 ` [PATCH 0/9] Cache deferal improvements - try++ J. Bruce Fields
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=20100203063131.12945.65321.stgit@notabene.brown \
--to=neilb@suse.de \
--cc=bfields@fieldses.org \
--cc=linux-nfs@vger.kernel.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.