aboutsummaryrefslogtreecommitdiffstats
path: root/net/sunrpc/cache.c
diff options
context:
space:
mode:
authorNeilBrown <neilb@suse.de>2009-09-09 02:32:54 -0400
committerJ. Bruce Fields <bfields@citi.umich.edu>2009-09-11 17:08:54 -0400
commit908329f2c08b8b5af7b394f709b0ee9c43b93041 (patch)
tree2a1940cebcde4659b6eccd0f054511d2d5f28d59 /net/sunrpc/cache.c
parent9e4c6379a62d94d3362b12c7a00f2105df6d7eeb (diff)
sunrpc/cache: simplify cache_fresh_locked and cache_fresh_unlocked.
The extra call to cache_revisit_request in cache_fresh_unlocked is not needed, as should have been fairly clear at the time of commit 4013edea9a0b6cdcb1fdf5d4011e47e068fd6efb If there are requests to be revisited, then we can be sure that CACHE_PENDING is set, so the second call is sufficient. So remove the first call. Then remove the 'new' parameter, then remove the return value for cache_fresh_locked which is only used to provide the value for 'new'. Signed-off-by: NeilBrown <neilb@suse.de> Signed-off-by: J. Bruce Fields <bfields@citi.umich.edu>
Diffstat (limited to 'net/sunrpc/cache.c')
-rw-r--r--net/sunrpc/cache.c23
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
106static void cache_dequeue(struct cache_detail *detail, struct cache_head *ch); 106static void cache_dequeue(struct cache_detail *detail, struct cache_head *ch);
107 107
108static int cache_fresh_locked(struct cache_head *head, time_t expiry) 108static 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
115static void cache_fresh_unlocked(struct cache_head *head, 115static 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;