diff options
| -rw-r--r-- | net/sunrpc/cache.c | 23 |
1 files changed, 10 insertions, 13 deletions
diff --git a/net/sunrpc/cache.c b/net/sunrpc/cache.c index 1a50dfe6dc6e..f2895d0a5f81 100644 --- a/net/sunrpc/cache.c +++ b/net/sunrpc/cache.c | |||
| @@ -105,18 +105,16 @@ EXPORT_SYMBOL_GPL(sunrpc_cache_lookup); | |||
| 105 | 105 | ||
| 106 | static void cache_dequeue(struct cache_detail *detail, struct cache_head *ch); | 106 | static void cache_dequeue(struct cache_detail *detail, struct cache_head *ch); |
| 107 | 107 | ||
| 108 | static int cache_fresh_locked(struct cache_head *head, time_t expiry) | 108 | static void cache_fresh_locked(struct cache_head *head, time_t expiry) |
| 109 | { | 109 | { |
| 110 | head->expiry_time = expiry; | 110 | head->expiry_time = expiry; |
| 111 | head->last_refresh = get_seconds(); | 111 | head->last_refresh = get_seconds(); |
| 112 | return !test_and_set_bit(CACHE_VALID, &head->flags); | 112 | set_bit(CACHE_VALID, &head->flags); |
| 113 | } | 113 | } |
| 114 | 114 | ||
| 115 | static void cache_fresh_unlocked(struct cache_head *head, | 115 | static void cache_fresh_unlocked(struct cache_head *head, |
| 116 | struct cache_detail *detail, int new) | 116 | struct cache_detail *detail) |
| 117 | { | 117 | { |
| 118 | if (new) | ||
| 119 | cache_revisit_request(head); | ||
| 120 | if (test_and_clear_bit(CACHE_PENDING, &head->flags)) { | 118 | if (test_and_clear_bit(CACHE_PENDING, &head->flags)) { |
| 121 | cache_revisit_request(head); | 119 | cache_revisit_request(head); |
| 122 | cache_dequeue(detail, head); | 120 | cache_dequeue(detail, head); |
| @@ -132,7 +130,6 @@ struct cache_head *sunrpc_cache_update(struct cache_detail *detail, | |||
| 132 | */ | 130 | */ |
| 133 | struct cache_head **head; | 131 | struct cache_head **head; |
| 134 | struct cache_head *tmp; | 132 | struct cache_head *tmp; |
| 135 | int is_new; | ||
| 136 | 133 | ||
| 137 | if (!test_bit(CACHE_VALID, &old->flags)) { | 134 | if (!test_bit(CACHE_VALID, &old->flags)) { |
| 138 | write_lock(&detail->hash_lock); | 135 | write_lock(&detail->hash_lock); |
| @@ -141,9 +138,9 @@ struct cache_head *sunrpc_cache_update(struct cache_detail *detail, | |||
| 141 | set_bit(CACHE_NEGATIVE, &old->flags); | 138 | set_bit(CACHE_NEGATIVE, &old->flags); |
| 142 | else | 139 | else |
| 143 | detail->update(old, new); | 140 | detail->update(old, new); |
| 144 | is_new = cache_fresh_locked(old, new->expiry_time); | 141 | cache_fresh_locked(old, new->expiry_time); |
| 145 | write_unlock(&detail->hash_lock); | 142 | write_unlock(&detail->hash_lock); |
| 146 | cache_fresh_unlocked(old, detail, is_new); | 143 | cache_fresh_unlocked(old, detail); |
| 147 | return old; | 144 | return old; |
| 148 | } | 145 | } |
| 149 | write_unlock(&detail->hash_lock); | 146 | write_unlock(&detail->hash_lock); |
| @@ -167,11 +164,11 @@ struct cache_head *sunrpc_cache_update(struct cache_detail *detail, | |||
| 167 | *head = tmp; | 164 | *head = tmp; |
| 168 | detail->entries++; | 165 | detail->entries++; |
| 169 | cache_get(tmp); | 166 | cache_get(tmp); |
| 170 | is_new = cache_fresh_locked(tmp, new->expiry_time); | 167 | cache_fresh_locked(tmp, new->expiry_time); |
| 171 | cache_fresh_locked(old, 0); | 168 | cache_fresh_locked(old, 0); |
| 172 | write_unlock(&detail->hash_lock); | 169 | write_unlock(&detail->hash_lock); |
| 173 | cache_fresh_unlocked(tmp, detail, is_new); | 170 | cache_fresh_unlocked(tmp, detail); |
| 174 | cache_fresh_unlocked(old, detail, 0); | 171 | cache_fresh_unlocked(old, detail); |
| 175 | cache_put(old, detail); | 172 | cache_put(old, detail); |
| 176 | return tmp; | 173 | return tmp; |
| 177 | } | 174 | } |
| @@ -240,8 +237,8 @@ int cache_check(struct cache_detail *detail, | |||
| 240 | cache_revisit_request(h); | 237 | cache_revisit_request(h); |
| 241 | if (rv == -EAGAIN) { | 238 | if (rv == -EAGAIN) { |
| 242 | set_bit(CACHE_NEGATIVE, &h->flags); | 239 | set_bit(CACHE_NEGATIVE, &h->flags); |
| 243 | cache_fresh_unlocked(h, detail, | 240 | cache_fresh_locked(h, get_seconds()+CACHE_NEW_EXPIRY); |
| 244 | cache_fresh_locked(h, get_seconds()+CACHE_NEW_EXPIRY)); | 241 | cache_fresh_unlocked(h, detail); |
| 245 | rv = -ENOENT; | 242 | rv = -ENOENT; |
| 246 | } | 243 | } |
| 247 | break; | 244 | break; |
