diff options
Diffstat (limited to 'include/linux/sunrpc/cache.h')
-rw-r--r-- | include/linux/sunrpc/cache.h | 13 |
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 | ||
152 | static inline struct cache_head *cache_get(struct cache_head *h) | 151 | static 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 | ||
159 | static inline int cache_put(struct cache_head *h, struct cache_detail *cd) | 158 | static 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 | ||
167 | extern void cache_init(struct cache_head *h); | 166 | extern void cache_init(struct cache_head *h); |