diff options
Diffstat (limited to 'include/linux/sunrpc/cache.h')
-rw-r--r-- | include/linux/sunrpc/cache.h | 28 |
1 files changed, 25 insertions, 3 deletions
diff --git a/include/linux/sunrpc/cache.h b/include/linux/sunrpc/cache.h index 0e1febf4e5bc..ece432b7f87f 100644 --- a/include/linux/sunrpc/cache.h +++ b/include/linux/sunrpc/cache.h | |||
@@ -218,20 +218,42 @@ static inline int get_int(char **bpp, int *anint) | |||
218 | return 0; | 218 | return 0; |
219 | } | 219 | } |
220 | 220 | ||
221 | /* | ||
222 | * timestamps kept in the cache are expressed in seconds | ||
223 | * since boot. This is the best for measuring differences in | ||
224 | * real time. | ||
225 | */ | ||
226 | static inline time_t seconds_since_boot(void) | ||
227 | { | ||
228 | struct timespec boot; | ||
229 | getboottime(&boot); | ||
230 | return get_seconds() - boot.tv_sec; | ||
231 | } | ||
232 | |||
233 | static inline time_t convert_to_wallclock(time_t sinceboot) | ||
234 | { | ||
235 | struct timespec boot; | ||
236 | getboottime(&boot); | ||
237 | return boot.tv_sec + sinceboot; | ||
238 | } | ||
239 | |||
221 | static inline time_t get_expiry(char **bpp) | 240 | static inline time_t get_expiry(char **bpp) |
222 | { | 241 | { |
223 | int rv; | 242 | int rv; |
243 | struct timespec boot; | ||
244 | |||
224 | if (get_int(bpp, &rv)) | 245 | if (get_int(bpp, &rv)) |
225 | return 0; | 246 | return 0; |
226 | if (rv < 0) | 247 | if (rv < 0) |
227 | return 0; | 248 | return 0; |
228 | return rv; | 249 | getboottime(&boot); |
250 | return rv - boot.tv_sec; | ||
229 | } | 251 | } |
230 | 252 | ||
231 | static inline void sunrpc_invalidate(struct cache_head *h, | 253 | static inline void sunrpc_invalidate(struct cache_head *h, |
232 | struct cache_detail *detail) | 254 | struct cache_detail *detail) |
233 | { | 255 | { |
234 | h->expiry_time = get_seconds() - 1; | 256 | h->expiry_time = seconds_since_boot() - 1; |
235 | detail->nextcheck = get_seconds(); | 257 | detail->nextcheck = seconds_since_boot(); |
236 | } | 258 | } |
237 | #endif /* _LINUX_SUNRPC_CACHE_H_ */ | 259 | #endif /* _LINUX_SUNRPC_CACHE_H_ */ |