diff options
Diffstat (limited to 'include/linux/sunrpc/cache.h')
-rw-r--r-- | include/linux/sunrpc/cache.h | 49 |
1 files changed, 22 insertions, 27 deletions
diff --git a/include/linux/sunrpc/cache.h b/include/linux/sunrpc/cache.h index 303399b1ba59..6ce690de447f 100644 --- a/include/linux/sunrpc/cache.h +++ b/include/linux/sunrpc/cache.h | |||
@@ -57,6 +57,7 @@ struct cache_head { | |||
57 | #define CACHE_VALID 0 /* Entry contains valid data */ | 57 | #define CACHE_VALID 0 /* Entry contains valid data */ |
58 | #define CACHE_NEGATIVE 1 /* Negative entry - there is no match for the key */ | 58 | #define CACHE_NEGATIVE 1 /* Negative entry - there is no match for the key */ |
59 | #define CACHE_PENDING 2 /* An upcall has been sent but no reply received yet*/ | 59 | #define CACHE_PENDING 2 /* An upcall has been sent but no reply received yet*/ |
60 | #define CACHE_CLEANED 3 /* Entry has been cleaned from cache */ | ||
60 | 61 | ||
61 | #define CACHE_NEW_EXPIRY 120 /* keep new things pending confirmation for 120 seconds */ | 62 | #define CACHE_NEW_EXPIRY 120 /* keep new things pending confirmation for 120 seconds */ |
62 | 63 | ||
@@ -148,6 +149,24 @@ struct cache_deferred_req { | |||
148 | int too_many); | 149 | int too_many); |
149 | }; | 150 | }; |
150 | 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 | } | ||
151 | 170 | ||
152 | extern const struct file_operations cache_file_operations_pipefs; | 171 | extern const struct file_operations cache_file_operations_pipefs; |
153 | extern const struct file_operations content_file_operations_pipefs; | 172 | extern const struct file_operations content_file_operations_pipefs; |
@@ -181,15 +200,10 @@ static inline void cache_put(struct cache_head *h, struct cache_detail *cd) | |||
181 | kref_put(&h->ref, cd->cache_put); | 200 | kref_put(&h->ref, cd->cache_put); |
182 | } | 201 | } |
183 | 202 | ||
184 | static inline int cache_valid(struct cache_head *h) | 203 | static inline int cache_is_expired(struct cache_detail *detail, struct cache_head *h) |
185 | { | 204 | { |
186 | /* If an item has been unhashed pending removal when | 205 | return (h->expiry_time < seconds_since_boot()) || |
187 | * the refcount drops to 0, the expiry_time will be | 206 | (detail->flush_time > h->last_refresh); |
188 | * set to 0. We don't want to consider such items | ||
189 | * valid in this context even though CACHE_VALID is | ||
190 | * set. | ||
191 | */ | ||
192 | return (h->expiry_time != 0 && test_bit(CACHE_VALID, &h->flags)); | ||
193 | } | 207 | } |
194 | 208 | ||
195 | extern int cache_check(struct cache_detail *detail, | 209 | extern int cache_check(struct cache_detail *detail, |
@@ -250,25 +264,6 @@ static inline int get_uint(char **bpp, unsigned int *anint) | |||
250 | return 0; | 264 | return 0; |
251 | } | 265 | } |
252 | 266 | ||
253 | /* | ||
254 | * timestamps kept in the cache are expressed in seconds | ||
255 | * since boot. This is the best for measuring differences in | ||
256 | * real time. | ||
257 | */ | ||
258 | static inline time_t seconds_since_boot(void) | ||
259 | { | ||
260 | struct timespec boot; | ||
261 | getboottime(&boot); | ||
262 | return get_seconds() - boot.tv_sec; | ||
263 | } | ||
264 | |||
265 | static inline time_t convert_to_wallclock(time_t sinceboot) | ||
266 | { | ||
267 | struct timespec boot; | ||
268 | getboottime(&boot); | ||
269 | return boot.tv_sec + sinceboot; | ||
270 | } | ||
271 | |||
272 | static inline time_t get_expiry(char **bpp) | 267 | static inline time_t get_expiry(char **bpp) |
273 | { | 268 | { |
274 | int rv; | 269 | int rv; |