aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTrond Myklebust <trond.myklebust@primarydata.com>2014-08-06 13:44:25 -0400
committerJ. Bruce Fields <bfields@redhat.com>2014-08-17 12:00:13 -0400
commitef9b16dc6de692865e898a35e750119b5b9c82c5 (patch)
treebc051d9207bc8a6b5547dbb1232ccf92c5127b3e
parent89a26b3d295d35fefcc994cb0cf3817d0ff432d5 (diff)
nfsd: Reorder nfsd_cache_match to check more powerful discriminators first
We would normally expect the xid and the checksum to be the best discriminators. Check them before looking at the procedure number, etc. Signed-off-by: Trond Myklebust <trond.myklebust@primarydata.com> Signed-off-by: J. Bruce Fields <bfields@redhat.com>
-rw-r--r--fs/nfsd/nfscache.c18
1 files changed, 11 insertions, 7 deletions
diff --git a/fs/nfsd/nfscache.c b/fs/nfsd/nfscache.c
index 74603654b7f9..122f69185ef5 100644
--- a/fs/nfsd/nfscache.c
+++ b/fs/nfsd/nfscache.c
@@ -338,20 +338,24 @@ nfsd_cache_csum(struct svc_rqst *rqstp)
338static bool 338static bool
339nfsd_cache_match(struct svc_rqst *rqstp, __wsum csum, struct svc_cacherep *rp) 339nfsd_cache_match(struct svc_rqst *rqstp, __wsum csum, struct svc_cacherep *rp)
340{ 340{
341 /* Check RPC header info first */ 341 /* Check RPC XID first */
342 if (rqstp->rq_xid != rp->c_xid || rqstp->rq_proc != rp->c_proc || 342 if (rqstp->rq_xid != rp->c_xid)
343 rqstp->rq_prot != rp->c_prot || rqstp->rq_vers != rp->c_vers ||
344 rqstp->rq_arg.len != rp->c_len ||
345 !rpc_cmp_addr(svc_addr(rqstp), (struct sockaddr *)&rp->c_addr) ||
346 rpc_get_port(svc_addr(rqstp)) != rpc_get_port((struct sockaddr *)&rp->c_addr))
347 return false; 343 return false;
348
349 /* compare checksum of NFS data */ 344 /* compare checksum of NFS data */
350 if (csum != rp->c_csum) { 345 if (csum != rp->c_csum) {
351 ++payload_misses; 346 ++payload_misses;
352 return false; 347 return false;
353 } 348 }
354 349
350 /* Other discriminators */
351 if (rqstp->rq_proc != rp->c_proc ||
352 rqstp->rq_prot != rp->c_prot ||
353 rqstp->rq_vers != rp->c_vers ||
354 rqstp->rq_arg.len != rp->c_len ||
355 !rpc_cmp_addr(svc_addr(rqstp), (struct sockaddr *)&rp->c_addr) ||
356 rpc_get_port(svc_addr(rqstp)) != rpc_get_port((struct sockaddr *)&rp->c_addr))
357 return false;
358
355 return true; 359 return true;
356} 360}
357 361