X-Git-Url: http://git.osdn.net/view?a=blobdiff_plain;f=include%2Flinux%2Fsunrpc%2Fcache.h;h=ece432b7f87f9fa6b46beb2dc860ae88b0f776d9;hb=c5b29f885afe;hp=7bf3e84b92f43c1e331040b735bf3faff67fd697;hpb=16bb85bc12e7d0b066b1471185f3889cb1ceb382;p=sagit-ice-cold%2Fkernel_xiaomi_msm8998.git diff --git a/include/linux/sunrpc/cache.h b/include/linux/sunrpc/cache.h index 7bf3e84b92f4..ece432b7f87f 100644 --- a/include/linux/sunrpc/cache.h +++ b/include/linux/sunrpc/cache.h @@ -218,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_ */