Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 359715
b: refs/heads/master
c: d1a0774
h: refs/heads/master
i:
  359713: bd75750
  359711: c66a324
v: v3
  • Loading branch information
Jeff Layton authored and J. Bruce Fields committed Feb 4, 2013
1 parent 70e0407 commit 43a7b66
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 25e6b8b0e1a247747db5275b1b6b362f5acf2245
refs/heads/master: d1a0774de6cb908f5ba7806d09aaf86bb03fa182
3 changes: 3 additions & 0 deletions trunk/fs/nfsd/cache.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 *);
Expand Down
9 changes: 8 additions & 1 deletion trunk/fs/nfsd/nfscache.c
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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++;
Expand Down

0 comments on commit 43a7b66

Please sign in to comment.