|
@@ -149,6 +149,24 @@ struct cache_deferred_req {
|
|
|
int too_many);
|
|
|
};
|
|
|
|
|
|
+/*
|
|
|
+ * timestamps kept in the cache are expressed in seconds
|
|
|
+ * since boot. This is the best for measuring differences in
|
|
|
+ * real time.
|
|
|
+ */
|
|
|
+static inline time_t seconds_since_boot(void)
|
|
|
+{
|
|
|
+ struct timespec boot;
|
|
|
+ getboottime(&boot);
|
|
|
+ return get_seconds() - boot.tv_sec;
|
|
|
+}
|
|
|
+
|
|
|
+static inline time_t convert_to_wallclock(time_t sinceboot)
|
|
|
+{
|
|
|
+ struct timespec boot;
|
|
|
+ getboottime(&boot);
|
|
|
+ return boot.tv_sec + sinceboot;
|
|
|
+}
|
|
|
|
|
|
extern const struct file_operations cache_file_operations_pipefs;
|
|
|
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)
|
|
|
kref_put(&h->ref, cd->cache_put);
|
|
|
}
|
|
|
|
|
|
-static inline int cache_valid(struct cache_head *h)
|
|
|
+static inline int cache_is_expired(struct cache_detail *detail, struct cache_head *h)
|
|
|
{
|
|
|
- /* If an item has been unhashed pending removal when
|
|
|
- * the refcount drops to 0, the expiry_time will be
|
|
|
- * set to 0. We don't want to consider such items
|
|
|
- * valid in this context even though CACHE_VALID is
|
|
|
- * set.
|
|
|
- */
|
|
|
- return (h->expiry_time != 0 && test_bit(CACHE_VALID, &h->flags));
|
|
|
+ return (h->expiry_time < seconds_since_boot()) ||
|
|
|
+ (detail->flush_time > h->last_refresh);
|
|
|
}
|
|
|
|
|
|
extern int cache_check(struct cache_detail *detail,
|
|
@@ -251,25 +264,6 @@ static inline int get_uint(char **bpp, unsigned int *anint)
|
|
|
return 0;
|
|
|
}
|
|
|
|
|
|
-/*
|
|
|
- * timestamps kept in the cache are expressed in seconds
|
|
|
- * since boot. This is the best for measuring differences in
|
|
|
- * real time.
|
|
|
- */
|
|
|
-static inline time_t seconds_since_boot(void)
|
|
|
-{
|
|
|
- struct timespec boot;
|
|
|
- getboottime(&boot);
|
|
|
- return get_seconds() - boot.tv_sec;
|
|
|
-}
|
|
|
-
|
|
|
-static inline time_t convert_to_wallclock(time_t sinceboot)
|
|
|
-{
|
|
|
- struct timespec boot;
|
|
|
- getboottime(&boot);
|
|
|
- return boot.tv_sec + sinceboot;
|
|
|
-}
|
|
|
-
|
|
|
static inline time_t get_expiry(char **bpp)
|
|
|
{
|
|
|
int rv;
|