From 43a7b667d0fdb138faa44862fc6b92eb23188341 Mon Sep 17 00:00:00 2001 From: Jeff Layton Date: Mon, 28 Jan 2013 14:41:13 -0500 Subject: [PATCH] --- yaml --- r: 359715 b: refs/heads/master c: d1a0774de6cb908f5ba7806d09aaf86bb03fa182 h: refs/heads/master i: 359713: bd75750b536e2ab1a6c7159180694cf2da6aa67a 359711: c66a324517520026b15ce34980639b27618fb677 v: v3 --- [refs] | 2 +- trunk/fs/nfsd/cache.h | 3 +++ trunk/fs/nfsd/nfscache.c | 9 ++++++++- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/[refs] b/[refs] index 56ab8b6ee750..b26daa8f91c6 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: 25e6b8b0e1a247747db5275b1b6b362f5acf2245 +refs/heads/master: d1a0774de6cb908f5ba7806d09aaf86bb03fa182 diff --git a/trunk/fs/nfsd/cache.h b/trunk/fs/nfsd/cache.h index f8c6df8649dc..9c7232b45103 100644 --- a/trunk/fs/nfsd/cache.h +++ b/trunk/fs/nfsd/cache.h @@ -70,6 +70,9 @@ enum { */ #define RC_DELAY (HZ/5) +/* Cache entries expire after this time period */ +#define RC_EXPIRE (120 * HZ) + int nfsd_reply_cache_init(void); void nfsd_reply_cache_shutdown(void); int nfsd_cache_lookup(struct svc_rqst *); diff --git a/trunk/fs/nfsd/nfscache.c b/trunk/fs/nfsd/nfscache.c index 2cdc4be84553..634b8566aaef 100644 --- a/trunk/fs/nfsd/nfscache.c +++ b/trunk/fs/nfsd/nfscache.c @@ -142,6 +142,13 @@ hash_refile(struct svc_cacherep *rp) hlist_add_head(&rp->c_hash, cache_hash + request_hash(rp->c_xid)); } +static inline bool +nfsd_cache_entry_expired(struct svc_cacherep *rp) +{ + return rp->c_state != RC_INPROG && + time_after(jiffies, rp->c_timestamp + RC_EXPIRE); +} + /* * Try to find an entry matching the current call in the cache. When none * is found, we grab the oldest unlocked entry off the LRU list. @@ -175,7 +182,7 @@ nfsd_cache_lookup(struct svc_rqst *rqstp) if (rp->c_state != RC_UNUSED && xid == rp->c_xid && proc == rp->c_proc && proto == rp->c_prot && vers == rp->c_vers && - time_before(jiffies, rp->c_timestamp + 120*HZ) && + !nfsd_cache_entry_expired(rp) && rpc_cmp_addr(svc_addr(rqstp), (struct sockaddr *)&rp->c_addr) && rpc_get_port(svc_addr(rqstp)) == rpc_get_port((struct sockaddr *)&rp->c_addr)) { nfsdstats.rchits++;