1 Patch-mainline: submitted 04aug2009
3 From: NeilBrown <neilb@suse.de>
4 Date: Tue, 4 Aug 2009 15:06:37 +1000
5 Subject: [PATCH 04/12] sunrpc/cache: recheck cache validity after cache_defer_req
7 If cache_defer_req did not leave the request on a queue, then it could
8 possibly have waited long enough that the cache became valid. So check the
11 Signed-off-by: NeilBrown <neilb@suse.de>
14 net/sunrpc/cache.c | 53 +++++++++++++++++++++++++++++++++--------------------
15 1 file changed, 33 insertions(+), 20 deletions(-)
17 --- linux-2.6.27-SLE11_BRANCH.orig/net/sunrpc/cache.c
18 +++ linux-2.6.27-SLE11_BRANCH/net/sunrpc/cache.c
19 @@ -173,6 +173,22 @@ struct cache_head *sunrpc_cache_update(s
20 EXPORT_SYMBOL(sunrpc_cache_update);
22 static int cache_make_upcall(struct cache_detail *detail, struct cache_head *h);
24 +static inline int cache_is_valid(struct cache_detail *detail, struct cache_head *h)
26 + if (!test_bit(CACHE_VALID, &h->flags) ||
27 + h->expiry_time < get_seconds())
29 + else if (detail->flush_time > h->last_refresh)
32 + /* entry is valid */
33 + if (test_bit(CACHE_NEGATIVE, &h->flags))
40 * This is the generic cache management routine for all
41 * the authentication caches.
42 @@ -181,8 +197,10 @@ static int cache_make_upcall(struct cach
45 * Returns 0 if the cache_head can be used, or cache_puts it and returns
46 - * -EAGAIN if upcall is pending,
47 - * -ETIMEDOUT if upcall failed and should be retried,
48 + * -EAGAIN if upcall is pending and request has been queued
49 + * -ETIMEDOUT if upcall failed or request could not be queue or
50 + * upcall completed but item is still invalid (implying that
51 + * the cache item has been replaced with a newer one).
52 * -ENOENT if cache entry was negative
54 int cache_check(struct cache_detail *detail,
55 @@ -192,17 +210,7 @@ int cache_check(struct cache_detail *det
56 long refresh_age, age;
58 /* First decide return status as best we can */
59 - if (!test_bit(CACHE_VALID, &h->flags) ||
60 - h->expiry_time < get_seconds())
62 - else if (detail->flush_time > h->last_refresh)
65 - /* entry is valid */
66 - if (test_bit(CACHE_NEGATIVE, &h->flags))
70 + rv = cache_is_valid(detail, h);
72 /* now see if we want to start an upcall */
73 refresh_age = (h->expiry_time - h->last_refresh);
74 @@ -234,10 +242,14 @@ int cache_check(struct cache_detail *det
79 - if (cache_defer_req(rqstp, h) != 0)
82 + if (rv == -EAGAIN) {
83 + if (cache_defer_req(rqstp, h) == 0) {
84 + /* Request is not deferred */
85 + rv = cache_is_valid(detail, h);
93 @@ -558,11 +570,11 @@ static int cache_defer_req(struct cache_
94 * or continue and drop the oldest below
100 dreq = req->defer(req);
107 @@ -592,8 +604,9 @@ static int cache_defer_req(struct cache_
108 if (!test_bit(CACHE_PENDING, &item->flags)) {
109 /* must have just been validated... */
110 cache_revisit_request(item);
117 static void cache_revisit_request(struct cache_head *item)