OSDN Git Service

sunrpc: use seconds since boot in expiry cache
[sagit-ice-cold/kernel_xiaomi_msm8998.git] / include / linux / sunrpc / cache.h
index 6f52b4d..ece432b 100644 (file)
@@ -192,6 +192,7 @@ extern int cache_check(struct cache_detail *detail,
 extern void cache_flush(void);
 extern void cache_purge(struct cache_detail *detail);
 #define NEVER (0x7FFFFFFF)
+extern void __init cache_initialize(void);
 extern int cache_register(struct cache_detail *cd);
 extern void cache_unregister(struct cache_detail *cd);
 
@@ -217,14 +218,42 @@ static inline int get_int(char **bpp, 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;
+       struct timespec boot;
+
        if (get_int(bpp, &rv))
                return 0;
        if (rv < 0)
                return 0;
-       return rv;
+       getboottime(&boot);
+       return rv - boot.tv_sec;
 }
 
+static inline void sunrpc_invalidate(struct cache_head *h,
+                                    struct cache_detail *detail)
+{
+       h->expiry_time = seconds_since_boot() - 1;
+       detail->nextcheck = seconds_since_boot();
+}
 #endif /*  _LINUX_SUNRPC_CACHE_H_ */