19a74af21SBoaz Harrosh /* 29a74af21SBoaz Harrosh * Request reply cache. This was heavily inspired by the 39a74af21SBoaz Harrosh * implementation in 4.3BSD/4.4BSD. 49a74af21SBoaz Harrosh * 59a74af21SBoaz Harrosh * Copyright (C) 1995, 1996 Olaf Kirch <okir@monad.swb.de> 69a74af21SBoaz Harrosh */ 79a74af21SBoaz Harrosh 89a74af21SBoaz Harrosh #ifndef NFSCACHE_H 99a74af21SBoaz Harrosh #define NFSCACHE_H 109a74af21SBoaz Harrosh 119a74af21SBoaz Harrosh #include <linux/sunrpc/svc.h> 129a74af21SBoaz Harrosh 139a74af21SBoaz Harrosh /* 149a74af21SBoaz Harrosh * Representation of a reply cache entry. 157b9e8522SJeff Layton * 167b9e8522SJeff Layton * Note that we use a sockaddr_in6 to hold the address instead of the more 177b9e8522SJeff Layton * typical sockaddr_storage. This is for space reasons, since sockaddr_storage 187b9e8522SJeff Layton * is much larger than a sockaddr_in6. 199a74af21SBoaz Harrosh */ 209a74af21SBoaz Harrosh struct svc_cacherep { 219a74af21SBoaz Harrosh struct hlist_node c_hash; 229a74af21SBoaz Harrosh struct list_head c_lru; 239a74af21SBoaz Harrosh 249a74af21SBoaz Harrosh unsigned char c_state, /* unused, inprog, done */ 259a74af21SBoaz Harrosh c_type, /* status, buffer */ 269a74af21SBoaz Harrosh c_secure : 1; /* req came from port < 1024 */ 277b9e8522SJeff Layton struct sockaddr_in6 c_addr; 289a74af21SBoaz Harrosh __be32 c_xid; 299a74af21SBoaz Harrosh u32 c_prot; 309a74af21SBoaz Harrosh u32 c_proc; 319a74af21SBoaz Harrosh u32 c_vers; 329a74af21SBoaz Harrosh unsigned long c_timestamp; 339a74af21SBoaz Harrosh union { 349a74af21SBoaz Harrosh struct kvec u_vec; 359a74af21SBoaz Harrosh __be32 u_status; 369a74af21SBoaz Harrosh } c_u; 379a74af21SBoaz Harrosh }; 389a74af21SBoaz Harrosh 399a74af21SBoaz Harrosh #define c_replvec c_u.u_vec 409a74af21SBoaz Harrosh #define c_replstat c_u.u_status 419a74af21SBoaz Harrosh 429a74af21SBoaz Harrosh /* cache entry states */ 439a74af21SBoaz Harrosh enum { 449a74af21SBoaz Harrosh RC_UNUSED, 459a74af21SBoaz Harrosh RC_INPROG, 469a74af21SBoaz Harrosh RC_DONE 479a74af21SBoaz Harrosh }; 489a74af21SBoaz Harrosh 499a74af21SBoaz Harrosh /* return values */ 509a74af21SBoaz Harrosh enum { 519a74af21SBoaz Harrosh RC_DROPIT, 529a74af21SBoaz Harrosh RC_REPLY, 5309662d58SJeff Layton RC_DOIT 549a74af21SBoaz Harrosh }; 559a74af21SBoaz Harrosh 569a74af21SBoaz Harrosh /* 579a74af21SBoaz Harrosh * Cache types. 589a74af21SBoaz Harrosh * We may want to add more types one day, e.g. for diropres and 599a74af21SBoaz Harrosh * attrstat replies. Using cache entries with fixed length instead 609a74af21SBoaz Harrosh * of buffer pointers may be more efficient. 619a74af21SBoaz Harrosh */ 629a74af21SBoaz Harrosh enum { 639a74af21SBoaz Harrosh RC_NOCACHE, 649a74af21SBoaz Harrosh RC_REPLSTAT, 659a74af21SBoaz Harrosh RC_REPLBUFF, 669a74af21SBoaz Harrosh }; 679a74af21SBoaz Harrosh 689a74af21SBoaz Harrosh /* 699a74af21SBoaz Harrosh * If requests are retransmitted within this interval, they're dropped. 709a74af21SBoaz Harrosh */ 719a74af21SBoaz Harrosh #define RC_DELAY (HZ/5) 729a74af21SBoaz Harrosh 73d1a0774dSJeff Layton /* Cache entries expire after this time period */ 74d1a0774dSJeff Layton #define RC_EXPIRE (120 * HZ) 75d1a0774dSJeff Layton 769a74af21SBoaz Harrosh int nfsd_reply_cache_init(void); 779a74af21SBoaz Harrosh void nfsd_reply_cache_shutdown(void); 781091006cSJ. Bruce Fields int nfsd_cache_lookup(struct svc_rqst *); 799a74af21SBoaz Harrosh void nfsd_cache_update(struct svc_rqst *, int, __be32 *); 809a74af21SBoaz Harrosh 819a74af21SBoaz Harrosh #ifdef CONFIG_NFSD_V4 829a74af21SBoaz Harrosh void nfsd4_set_statp(struct svc_rqst *rqstp, __be32 *statp); 839a74af21SBoaz Harrosh #else /* CONFIG_NFSD_V4 */ 849a74af21SBoaz Harrosh static inline void nfsd4_set_statp(struct svc_rqst *rqstp, __be32 *statp) 859a74af21SBoaz Harrosh { 869a74af21SBoaz Harrosh } 879a74af21SBoaz Harrosh #endif /* CONFIG_NFSD_V4 */ 889a74af21SBoaz Harrosh 899a74af21SBoaz Harrosh #endif /* NFSCACHE_H */ 90