diff options
Diffstat (limited to 'include/linux/sunrpc/cache.h')
-rw-r--r-- | include/linux/sunrpc/cache.h | 48 |
1 files changed, 21 insertions, 27 deletions
diff --git a/include/linux/sunrpc/cache.h b/include/linux/sunrpc/cache.h index 8419f7dbdab2..6ce690de447f 100644 --- a/include/linux/sunrpc/cache.h +++ b/include/linux/sunrpc/cache.h | |||
@@ -149,6 +149,24 @@ struct cache_deferred_req { | |||
149 | int too_many); | 149 | int too_many); |
150 | }; | 150 | }; |
151 | 151 | ||
152 | /* | ||
153 | * timestamps kept in the cache are expressed in seconds | ||
154 | * since boot. This is the best for measuring differences in | ||
155 | * real time. | ||
156 | */ | ||
157 | static inline time_t seconds_since_boot(void) | ||
158 | { | ||
159 | struct timespec boot; | ||
160 | getboottime(&boot); | ||
161 | return get_seconds() - boot.tv_sec; | ||
162 | } | ||
163 | |||
164 | static inline time_t convert_to_wallclock(time_t sinceboot) | ||
165 | { | ||
166 | struct timespec boot; | ||
167 | getboottime(&boot); | ||
168 | return boot.tv_sec + sinceboot; | ||
169 | } | ||
152 | 170 | ||
153 | extern const struct file_operations cache_file_operations_pipefs; | 171 | extern const struct file_operations cache_file_operations_pipefs; |
154 | extern const struct file_operations content_file_operations_pipefs; | 172 | extern const struct file_operations content_file_operations_pipefs; |
@@ -182,15 +200,10 @@ static inline void cache_put(struct cache_head *h, struct cache_detail *cd) | |||
182 | kref_put(&h->ref, cd->cache_put); | 200 | kref_put(&h->ref, cd->cache_put); |
183 | } | 201 | } |
184 | 202 | ||
185 | static inline int cache_valid(struct cache_head *h) | 203 | static inline int cache_is_expired(struct cache_detail *detail, struct cache_head *h) |
186 | { | 204 | { |
187 | /* If an item has been unhashed pending removal when | 205 | return (h->expiry_time < seconds_since_boot()) || |
188 | * the refcount drops to 0, the expiry_time will be | 206 | (detail->flush_time > h->last_refresh); |
189 | * set to 0. We don't want to consider such items | ||
190 | * valid in this context even though CACHE_VALID is | ||
191 | * set. | ||
192 | */ | ||
193 | return (h->expiry_time != 0 && test_bit(CACHE_VALID, &h->flags)); | ||
194 | } | 207 | } |
195 | 208 | ||
196 | extern int cache_check(struct cache_detail *detail, | 209 | extern int cache_check(struct cache_detail *detail, |
@@ -251,25 +264,6 @@ static inline int get_uint(char **bpp, unsigned int *anint) | |||
251 | return 0; | 264 | return 0; |
252 | } | 265 | } |
253 | 266 | ||
254 | /* | ||
255 | * timestamps kept in the cache are expressed in seconds | ||
256 | * since boot. This is the best for measuring differences in | ||
257 | * real time. | ||
258 | */ | ||
259 | static inline time_t seconds_since_boot(void) | ||
260 | { | ||
261 | struct timespec boot; | ||
262 | getboottime(&boot); | ||
263 | return get_seconds() - boot.tv_sec; | ||
264 | } | ||
265 | |||
266 | static inline time_t convert_to_wallclock(time_t sinceboot) | ||
267 | { | ||
268 | struct timespec boot; | ||
269 | getboottime(&boot); | ||
270 | return boot.tv_sec + sinceboot; | ||
271 | } | ||
272 | |||
273 | static inline time_t get_expiry(char **bpp) | 267 | static inline time_t get_expiry(char **bpp) |
274 | { | 268 | { |
275 | int rv; | 269 | int rv; |