summaryrefslogtreecommitdiff
path: root/fs/nfsd/cache.h
diff options
context:
space:
mode:
authorJeff Layton <jlayton@redhat.com>2013-02-04 11:57:27 -0500
committerJ. Bruce Fields <bfields@redhat.com>2013-02-08 16:02:26 -0500
commit01a7decf75930925322c5efc87af0b5e58eb8650 (patch)
treecdd3420f451edc0568f4318b1d2338d491679068 /fs/nfsd/cache.h
parent4c190e2f913f038c9c91ee63b59cd037260ba353 (diff)
nfsd: keep a checksum of the first 256 bytes of request
Now that we're allowing more DRC entries, it becomes a lot easier to hit problems with XID collisions. In order to mitigate those, calculate a checksum of up to the first 256 bytes of each request coming in and store that in the cache entry, along with the total length of the request. This initially used crc32, but Chuck Lever and Jim Rees pointed out that crc32 is probably more heavyweight than we really need for generating these checksums, and recommended looking at using the same routines that are used to generate checksums for IP packets. On an x86_64 KVM guest measurements with ftrace showed ~800ns to use csum_partial vs ~1750ns for crc32. The difference probably isn't terribly significant, but for now we may as well use csum_partial. Signed-off-by: Jeff Layton <jlayton@redhat.com> Stones-thrown-by: Chuck Lever <chuck.lever@oracle.com> Signed-off-by: J. Bruce Fields <bfields@redhat.com>
Diffstat (limited to 'fs/nfsd/cache.h')
-rw-r--r--fs/nfsd/cache.h5
1 files changed, 5 insertions, 0 deletions
diff --git a/fs/nfsd/cache.h b/fs/nfsd/cache.h
index 9c7232b45103..87fd1410b737 100644
--- a/fs/nfsd/cache.h
+++ b/fs/nfsd/cache.h
@@ -29,6 +29,8 @@ struct svc_cacherep {
u32 c_prot;
u32 c_proc;
u32 c_vers;
+ unsigned int c_len;
+ __wsum c_csum;
unsigned long c_timestamp;
union {
struct kvec u_vec;
@@ -73,6 +75,9 @@ enum {
/* Cache entries expire after this time period */
#define RC_EXPIRE (120 * HZ)
+/* Checksum this amount of the request */
+#define RC_CSUMLEN (256U)
+
int nfsd_reply_cache_init(void);
void nfsd_reply_cache_shutdown(void);
int nfsd_cache_lookup(struct svc_rqst *);