aboutsummaryrefslogtreecommitdiffstats
path: root/net/sunrpc/cache.c
diff options
context:
space:
mode:
authorNeilBrown <neilb@suse.de>2006-03-27 04:15:09 -0500
committerLinus Torvalds <torvalds@g5.osdl.org>2006-03-27 11:44:43 -0500
commitbaab935ff3bdac20c558809da0d8e8f761840219 (patch)
treea22c3189505fe8e7ab3820c988ffd771c0b64fa6 /net/sunrpc/cache.c
parentebd0cb1af3be2729cc1f574681dfba01fcf458d9 (diff)
[PATCH] knfsd: Convert sunrpc_cache to use krefs
.. it makes some of the code nicer. Signed-off-by: Neil Brown <neilb@suse.de> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'net/sunrpc/cache.c')
-rw-r--r--net/sunrpc/cache.c20
1 files changed, 10 insertions, 10 deletions
diff --git a/net/sunrpc/cache.c b/net/sunrpc/cache.c
index edcda4fd88e8..dd81e5928172 100644
--- a/net/sunrpc/cache.c
+++ b/net/sunrpc/cache.c
@@ -42,7 +42,7 @@ void cache_init(struct cache_head *h)
42 time_t now = get_seconds(); 42 time_t now = get_seconds();
43 h->next = NULL; 43 h->next = NULL;
44 h->flags = 0; 44 h->flags = 0;
45 atomic_set(&h->refcnt, 1); 45 kref_init(&h->ref);
46 h->expiry_time = now + CACHE_NEW_EXPIRY; 46 h->expiry_time = now + CACHE_NEW_EXPIRY;
47 h->last_refresh = now; 47 h->last_refresh = now;
48} 48}
@@ -81,7 +81,7 @@ struct cache_head *sunrpc_cache_lookup(struct cache_detail *detail,
81 if (detail->match(tmp, key)) { 81 if (detail->match(tmp, key)) {
82 cache_get(tmp); 82 cache_get(tmp);
83 write_unlock(&detail->hash_lock); 83 write_unlock(&detail->hash_lock);
84 detail->cache_put(new, detail); 84 cache_put(new, detail);
85 return tmp; 85 return tmp;
86 } 86 }
87 } 87 }
@@ -145,7 +145,7 @@ struct cache_head *sunrpc_cache_update(struct cache_detail *detail,
145 /* We need to insert a new entry */ 145 /* We need to insert a new entry */
146 tmp = detail->alloc(); 146 tmp = detail->alloc();
147 if (!tmp) { 147 if (!tmp) {
148 detail->cache_put(old, detail); 148 cache_put(old, detail);
149 return NULL; 149 return NULL;
150 } 150 }
151 cache_init(tmp); 151 cache_init(tmp);
@@ -165,7 +165,7 @@ struct cache_head *sunrpc_cache_update(struct cache_detail *detail,
165 write_unlock(&detail->hash_lock); 165 write_unlock(&detail->hash_lock);
166 cache_fresh_unlocked(tmp, detail, is_new); 166 cache_fresh_unlocked(tmp, detail, is_new);
167 cache_fresh_unlocked(old, detail, 0); 167 cache_fresh_unlocked(old, detail, 0);
168 detail->cache_put(old, detail); 168 cache_put(old, detail);
169 return tmp; 169 return tmp;
170} 170}
171EXPORT_SYMBOL(sunrpc_cache_update); 171EXPORT_SYMBOL(sunrpc_cache_update);
@@ -234,7 +234,7 @@ int cache_check(struct cache_detail *detail,
234 cache_defer_req(rqstp, h); 234 cache_defer_req(rqstp, h);
235 235
236 if (rv) 236 if (rv)
237 detail->cache_put(h, detail); 237 cache_put(h, detail);
238 return rv; 238 return rv;
239} 239}
240 240
@@ -431,7 +431,7 @@ static int cache_clean(void)
431 if (test_and_clear_bit(CACHE_PENDING, &ch->flags)) 431 if (test_and_clear_bit(CACHE_PENDING, &ch->flags))
432 queue_loose(current_detail, ch); 432 queue_loose(current_detail, ch);
433 433
434 if (atomic_read(&ch->refcnt) == 1) 434 if (atomic_read(&ch->ref.refcount) == 1)
435 break; 435 break;
436 } 436 }
437 if (ch) { 437 if (ch) {
@@ -446,7 +446,7 @@ static int cache_clean(void)
446 current_index ++; 446 current_index ++;
447 spin_unlock(&cache_list_lock); 447 spin_unlock(&cache_list_lock);
448 if (ch) 448 if (ch)
449 d->cache_put(ch, d); 449 cache_put(ch, d);
450 } else 450 } else
451 spin_unlock(&cache_list_lock); 451 spin_unlock(&cache_list_lock);
452 452
@@ -723,7 +723,7 @@ cache_read(struct file *filp, char __user *buf, size_t count, loff_t *ppos)
723 !test_bit(CACHE_PENDING, &rq->item->flags)) { 723 !test_bit(CACHE_PENDING, &rq->item->flags)) {
724 list_del(&rq->q.list); 724 list_del(&rq->q.list);
725 spin_unlock(&queue_lock); 725 spin_unlock(&queue_lock);
726 cd->cache_put(rq->item, cd); 726 cache_put(rq->item, cd);
727 kfree(rq->buf); 727 kfree(rq->buf);
728 kfree(rq); 728 kfree(rq);
729 } else 729 } else
@@ -906,7 +906,7 @@ static void queue_loose(struct cache_detail *detail, struct cache_head *ch)
906 continue; 906 continue;
907 list_del(&cr->q.list); 907 list_del(&cr->q.list);
908 spin_unlock(&queue_lock); 908 spin_unlock(&queue_lock);
909 detail->cache_put(cr->item, detail); 909 cache_put(cr->item, detail);
910 kfree(cr->buf); 910 kfree(cr->buf);
911 kfree(cr); 911 kfree(cr);
912 return; 912 return;
@@ -1192,7 +1192,7 @@ static int c_show(struct seq_file *m, void *p)
1192 1192
1193 ifdebug(CACHE) 1193 ifdebug(CACHE)
1194 seq_printf(m, "# expiry=%ld refcnt=%d flags=%lx\n", 1194 seq_printf(m, "# expiry=%ld refcnt=%d flags=%lx\n",
1195 cp->expiry_time, atomic_read(&cp->refcnt), cp->flags); 1195 cp->expiry_time, atomic_read(&cp->ref.refcount), cp->flags);
1196 cache_get(cp); 1196 cache_get(cp);
1197 if (cache_check(cd, cp, NULL)) 1197 if (cache_check(cd, cp, NULL))
1198 /* cache_check does a cache_put on failure */ 1198 /* cache_check does a cache_put on failure */