aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/sunrpc/cache.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/linux/sunrpc/cache.h')
-rw-r--r--include/linux/sunrpc/cache.h45
1 files changed, 41 insertions, 4 deletions
diff --git a/include/linux/sunrpc/cache.h b/include/linux/sunrpc/cache.h
index 7bf3e84b92f4..8d2eef1a8582 100644
--- a/include/linux/sunrpc/cache.h
+++ b/include/linux/sunrpc/cache.h
@@ -13,6 +13,7 @@
13#ifndef _LINUX_SUNRPC_CACHE_H_ 13#ifndef _LINUX_SUNRPC_CACHE_H_
14#define _LINUX_SUNRPC_CACHE_H_ 14#define _LINUX_SUNRPC_CACHE_H_
15 15
16#include <linux/kref.h>
16#include <linux/slab.h> 17#include <linux/slab.h>
17#include <asm/atomic.h> 18#include <asm/atomic.h>
18#include <linux/proc_fs.h> 19#include <linux/proc_fs.h>
@@ -34,10 +35,10 @@
34 * Each cache must be registered so that it can be cleaned regularly. 35 * Each cache must be registered so that it can be cleaned regularly.
35 * When the cache is unregistered, it is flushed completely. 36 * When the cache is unregistered, it is flushed completely.
36 * 37 *
37 * Entries have a ref count and a 'hashed' flag which counts the existance 38 * Entries have a ref count and a 'hashed' flag which counts the existence
38 * in the hash table. 39 * in the hash table.
39 * We only expire entries when refcount is zero. 40 * We only expire entries when refcount is zero.
40 * Existance in the cache is counted the refcount. 41 * Existence in the cache is counted the refcount.
41 */ 42 */
42 43
43/* Every cache item has a common header that is used 44/* Every cache item has a common header that is used
@@ -125,12 +126,15 @@ struct cache_detail {
125 */ 126 */
126struct cache_req { 127struct cache_req {
127 struct cache_deferred_req *(*defer)(struct cache_req *req); 128 struct cache_deferred_req *(*defer)(struct cache_req *req);
129 int thread_wait; /* How long (jiffies) we can block the
130 * current thread to wait for updates.
131 */
128}; 132};
129/* this must be embedded in a deferred_request that is being 133/* this must be embedded in a deferred_request that is being
130 * delayed awaiting cache-fill 134 * delayed awaiting cache-fill
131 */ 135 */
132struct cache_deferred_req { 136struct cache_deferred_req {
133 struct list_head hash; /* on hash chain */ 137 struct hlist_node hash; /* on hash chain */
134 struct list_head recent; /* on fifo */ 138 struct list_head recent; /* on fifo */
135 struct cache_head *item; /* cache item we wait on */ 139 struct cache_head *item; /* cache item we wait on */
136 void *owner; /* we might need to discard all defered requests 140 void *owner; /* we might need to discard all defered requests
@@ -194,7 +198,9 @@ extern void cache_purge(struct cache_detail *detail);
194#define NEVER (0x7FFFFFFF) 198#define NEVER (0x7FFFFFFF)
195extern void __init cache_initialize(void); 199extern void __init cache_initialize(void);
196extern int cache_register(struct cache_detail *cd); 200extern int cache_register(struct cache_detail *cd);
201extern int cache_register_net(struct cache_detail *cd, struct net *net);
197extern void cache_unregister(struct cache_detail *cd); 202extern void cache_unregister(struct cache_detail *cd);
203extern void cache_unregister_net(struct cache_detail *cd, struct net *net);
198 204
199extern int sunrpc_cache_register_pipefs(struct dentry *parent, const char *, 205extern int sunrpc_cache_register_pipefs(struct dentry *parent, const char *,
200 mode_t, struct cache_detail *); 206 mode_t, struct cache_detail *);
@@ -218,14 +224,45 @@ static inline int get_int(char **bpp, int *anint)
218 return 0; 224 return 0;
219} 225}
220 226
227/*
228 * timestamps kept in the cache are expressed in seconds
229 * since boot. This is the best for measuring differences in
230 * real time.
231 */
232static inline time_t seconds_since_boot(void)
233{
234 struct timespec boot;
235 getboottime(&boot);
236 return get_seconds() - boot.tv_sec;
237}
238
239static inline time_t convert_to_wallclock(time_t sinceboot)
240{
241 struct timespec boot;
242 getboottime(&boot);
243 return boot.tv_sec + sinceboot;
244}
245
221static inline time_t get_expiry(char **bpp) 246static inline time_t get_expiry(char **bpp)
222{ 247{
223 int rv; 248 int rv;
249 struct timespec boot;
250
224 if (get_int(bpp, &rv)) 251 if (get_int(bpp, &rv))
225 return 0; 252 return 0;
226 if (rv < 0) 253 if (rv < 0)
227 return 0; 254 return 0;
228 return rv; 255 getboottime(&boot);
256 return rv - boot.tv_sec;
257}
258
259#ifdef CONFIG_NFSD_DEPRECATED
260static inline void sunrpc_invalidate(struct cache_head *h,
261 struct cache_detail *detail)
262{
263 h->expiry_time = seconds_since_boot() - 1;
264 detail->nextcheck = seconds_since_boot();
229} 265}
266#endif /* CONFIG_NFSD_DEPRECATED */
230 267
231#endif /* _LINUX_SUNRPC_CACHE_H_ */ 268#endif /* _LINUX_SUNRPC_CACHE_H_ */