aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/sunrpc/cache.h
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 /include/linux/sunrpc/cache.h
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 'include/linux/sunrpc/cache.h')
-rw-r--r--include/linux/sunrpc/cache.h13
1 files changed, 6 insertions, 7 deletions
diff --git a/include/linux/sunrpc/cache.h b/include/linux/sunrpc/cache.h
index a37fead1873b..ad3f5cbdb770 100644
--- a/include/linux/sunrpc/cache.h
+++ b/include/linux/sunrpc/cache.h
@@ -50,7 +50,7 @@ struct cache_head {
50 time_t last_refresh; /* If CACHE_PENDING, this is when upcall 50 time_t last_refresh; /* If CACHE_PENDING, this is when upcall
51 * was sent, else this is when update was received 51 * was sent, else this is when update was received
52 */ 52 */
53 atomic_t refcnt; 53 struct kref ref;
54 unsigned long flags; 54 unsigned long flags;
55}; 55};
56#define CACHE_VALID 0 /* Entry contains valid data */ 56#define CACHE_VALID 0 /* Entry contains valid data */
@@ -68,8 +68,7 @@ struct cache_detail {
68 atomic_t inuse; /* active user-space update or lookup */ 68 atomic_t inuse; /* active user-space update or lookup */
69 69
70 char *name; 70 char *name;
71 void (*cache_put)(struct cache_head *, 71 void (*cache_put)(struct kref *);
72 struct cache_detail*);
73 72
74 void (*cache_request)(struct cache_detail *cd, 73 void (*cache_request)(struct cache_detail *cd,
75 struct cache_head *h, 74 struct cache_head *h,
@@ -151,17 +150,17 @@ extern void cache_clean_deferred(void *owner);
151 150
152static inline struct cache_head *cache_get(struct cache_head *h) 151static inline struct cache_head *cache_get(struct cache_head *h)
153{ 152{
154 atomic_inc(&h->refcnt); 153 kref_get(&h->ref);
155 return h; 154 return h;
156} 155}
157 156
158 157
159static inline int cache_put(struct cache_head *h, struct cache_detail *cd) 158static inline void cache_put(struct cache_head *h, struct cache_detail *cd)
160{ 159{
161 if (atomic_read(&h->refcnt) <= 2 && 160 if (atomic_read(&h->ref.refcount) <= 2 &&
162 h->expiry_time < cd->nextcheck) 161 h->expiry_time < cd->nextcheck)
163 cd->nextcheck = h->expiry_time; 162 cd->nextcheck = h->expiry_time;
164 return atomic_dec_and_test(&h->refcnt); 163 kref_put(&h->ref, cd->cache_put);
165} 164}
166 165
167extern void cache_init(struct cache_head *h); 166extern void cache_init(struct cache_head *h);