summaryrefslogtreecommitdiffstats
path: root/net/sunrpc/cache.c
diff options
context:
space:
mode:
authorNeilBrown <neilb@suse.de>2006-03-27 01:15:09 -0800
committerLinus Torvalds <torvalds@g5.osdl.org>2006-03-27 08:44:43 -0800
commitbaab935ff3bdac20c558809da0d8e8f761840219 (patch)
treea22c3189505fe8e7ab3820c988ffd771c0b64fa6 /net/sunrpc/cache.c
parentebd0cb1af3be2729cc1f574681dfba01fcf458d9 (diff)
downloadlinux-stable-baab935ff3bdac20c558809da0d8e8f761840219.tar.gz
linux-stable-baab935ff3bdac20c558809da0d8e8f761840219.tar.bz2
linux-stable-baab935ff3bdac20c558809da0d8e8f761840219.zip
[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)
time_t now = get_seconds();
h->next = NULL;
h->flags = 0;
- atomic_set(&h->refcnt, 1);
+ kref_init(&h->ref);
h->expiry_time = now + CACHE_NEW_EXPIRY;
h->last_refresh = now;
}
@@ -81,7 +81,7 @@ struct cache_head *sunrpc_cache_lookup(struct cache_detail *detail,
if (detail->match(tmp, key)) {
cache_get(tmp);
write_unlock(&detail->hash_lock);
- detail->cache_put(new, detail);
+ cache_put(new, detail);
return tmp;
}
}
@@ -145,7 +145,7 @@ struct cache_head *sunrpc_cache_update(struct cache_detail *detail,
/* We need to insert a new entry */
tmp = detail->alloc();
if (!tmp) {
- detail->cache_put(old, detail);
+ cache_put(old, detail);
return NULL;
}
cache_init(tmp);
@@ -165,7 +165,7 @@ struct cache_head *sunrpc_cache_update(struct cache_detail *detail,
write_unlock(&detail->hash_lock);
cache_fresh_unlocked(tmp, detail, is_new);
cache_fresh_unlocked(old, detail, 0);
- detail->cache_put(old, detail);
+ cache_put(old, detail);
return tmp;
}
EXPORT_SYMBOL(sunrpc_cache_update);
@@ -234,7 +234,7 @@ int cache_check(struct cache_detail *detail,
cache_defer_req(rqstp, h);
if (rv)
- detail->cache_put(h, detail);
+ cache_put(h, detail);
return rv;
}
@@ -431,7 +431,7 @@ static int cache_clean(void)
if (test_and_clear_bit(CACHE_PENDING, &ch->flags))
queue_loose(current_detail, ch);
- if (atomic_read(&ch->refcnt) == 1)
+ if (atomic_read(&ch->ref.refcount) == 1)
break;
}
if (ch) {
@@ -446,7 +446,7 @@ static int cache_clean(void)
current_index ++;
spin_unlock(&cache_list_lock);
if (ch)
- d->cache_put(ch, d);
+ cache_put(ch, d);
} else
spin_unlock(&cache_list_lock);
@@ -723,7 +723,7 @@ cache_read(struct file *filp, char __user *buf, size_t count, loff_t *ppos)
!test_bit(CACHE_PENDING, &rq->item->flags)) {
list_del(&rq->q.list);
spin_unlock(&queue_lock);
- cd->cache_put(rq->item, cd);
+ cache_put(rq->item, cd);
kfree(rq->buf);
kfree(rq);
} else
@@ -906,7 +906,7 @@ static void queue_loose(struct cache_detail *detail, struct cache_head *ch)
continue;
list_del(&cr->q.list);
spin_unlock(&queue_lock);
- detail->cache_put(cr->item, detail);
+ cache_put(cr->item, detail);
kfree(cr->buf);
kfree(cr);
return;
@@ -1192,7 +1192,7 @@ static int c_show(struct seq_file *m, void *p)
ifdebug(CACHE)
seq_printf(m, "# expiry=%ld refcnt=%d flags=%lx\n",
- cp->expiry_time, atomic_read(&cp->refcnt), cp->flags);
+ cp->expiry_time, atomic_read(&cp->ref.refcount), cp->flags);
cache_get(cp);
if (cache_check(cd, cp, NULL))
/* cache_check does a cache_put on failure */