diff options
Diffstat (limited to 'include/linux/sunrpc/cache.h')
-rw-r--r-- | include/linux/sunrpc/cache.h | 37 |
1 files changed, 35 insertions, 2 deletions
diff --git a/include/linux/sunrpc/cache.h b/include/linux/sunrpc/cache.h index 7bf3e84b92f4..6950c981882d 100644 --- a/include/linux/sunrpc/cache.h +++ b/include/linux/sunrpc/cache.h | |||
@@ -125,12 +125,15 @@ struct cache_detail { | |||
125 | */ | 125 | */ |
126 | struct cache_req { | 126 | struct cache_req { |
127 | struct cache_deferred_req *(*defer)(struct cache_req *req); | 127 | struct cache_deferred_req *(*defer)(struct cache_req *req); |
128 | int thread_wait; /* How long (jiffies) we can block the | ||
129 | * current thread to wait for updates. | ||
130 | */ | ||
128 | }; | 131 | }; |
129 | /* this must be embedded in a deferred_request that is being | 132 | /* this must be embedded in a deferred_request that is being |
130 | * delayed awaiting cache-fill | 133 | * delayed awaiting cache-fill |
131 | */ | 134 | */ |
132 | struct cache_deferred_req { | 135 | struct cache_deferred_req { |
133 | struct list_head hash; /* on hash chain */ | 136 | struct hlist_node hash; /* on hash chain */ |
134 | struct list_head recent; /* on fifo */ | 137 | struct list_head recent; /* on fifo */ |
135 | struct cache_head *item; /* cache item we wait on */ | 138 | struct cache_head *item; /* cache item we wait on */ |
136 | void *owner; /* we might need to discard all defered requests | 139 | void *owner; /* we might need to discard all defered requests |
@@ -194,7 +197,9 @@ extern void cache_purge(struct cache_detail *detail); | |||
194 | #define NEVER (0x7FFFFFFF) | 197 | #define NEVER (0x7FFFFFFF) |
195 | extern void __init cache_initialize(void); | 198 | extern void __init cache_initialize(void); |
196 | extern int cache_register(struct cache_detail *cd); | 199 | extern int cache_register(struct cache_detail *cd); |
200 | extern int cache_register_net(struct cache_detail *cd, struct net *net); | ||
197 | extern void cache_unregister(struct cache_detail *cd); | 201 | extern void cache_unregister(struct cache_detail *cd); |
202 | extern void cache_unregister_net(struct cache_detail *cd, struct net *net); | ||
198 | 203 | ||
199 | extern int sunrpc_cache_register_pipefs(struct dentry *parent, const char *, | 204 | extern int sunrpc_cache_register_pipefs(struct dentry *parent, const char *, |
200 | mode_t, struct cache_detail *); | 205 | mode_t, struct cache_detail *); |
@@ -218,14 +223,42 @@ static inline int get_int(char **bpp, int *anint) | |||
218 | return 0; | 223 | return 0; |
219 | } | 224 | } |
220 | 225 | ||
226 | /* | ||
227 | * timestamps kept in the cache are expressed in seconds | ||
228 | * since boot. This is the best for measuring differences in | ||
229 | * real time. | ||
230 | */ | ||
231 | static inline time_t seconds_since_boot(void) | ||
232 | { | ||
233 | struct timespec boot; | ||
234 | getboottime(&boot); | ||
235 | return get_seconds() - boot.tv_sec; | ||
236 | } | ||
237 | |||
238 | static inline time_t convert_to_wallclock(time_t sinceboot) | ||
239 | { | ||
240 | struct timespec boot; | ||
241 | getboottime(&boot); | ||
242 | return boot.tv_sec + sinceboot; | ||
243 | } | ||
244 | |||
221 | static inline time_t get_expiry(char **bpp) | 245 | static inline time_t get_expiry(char **bpp) |
222 | { | 246 | { |
223 | int rv; | 247 | int rv; |
248 | struct timespec boot; | ||
249 | |||
224 | if (get_int(bpp, &rv)) | 250 | if (get_int(bpp, &rv)) |
225 | return 0; | 251 | return 0; |
226 | if (rv < 0) | 252 | if (rv < 0) |
227 | return 0; | 253 | return 0; |
228 | return rv; | 254 | getboottime(&boot); |
255 | return rv - boot.tv_sec; | ||
229 | } | 256 | } |
230 | 257 | ||
258 | static inline void sunrpc_invalidate(struct cache_head *h, | ||
259 | struct cache_detail *detail) | ||
260 | { | ||
261 | h->expiry_time = seconds_since_boot() - 1; | ||
262 | detail->nextcheck = seconds_since_boot(); | ||
263 | } | ||
231 | #endif /* _LINUX_SUNRPC_CACHE_H_ */ | 264 | #endif /* _LINUX_SUNRPC_CACHE_H_ */ |