cache.h 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. /*
  2. * Request reply cache. This was heavily inspired by the
  3. * implementation in 4.3BSD/4.4BSD.
  4. *
  5. * Copyright (C) 1995, 1996 Olaf Kirch <okir@monad.swb.de>
  6. */
  7. #ifndef NFSCACHE_H
  8. #define NFSCACHE_H
  9. #include <linux/sunrpc/svc.h>
  10. /*
  11. * Representation of a reply cache entry.
  12. *
  13. * Note that we use a sockaddr_in6 to hold the address instead of the more
  14. * typical sockaddr_storage. This is for space reasons, since sockaddr_storage
  15. * is much larger than a sockaddr_in6.
  16. */
  17. struct svc_cacherep {
  18. struct hlist_node c_hash;
  19. struct list_head c_lru;
  20. unsigned char c_state, /* unused, inprog, done */
  21. c_type, /* status, buffer */
  22. c_secure : 1; /* req came from port < 1024 */
  23. struct sockaddr_in6 c_addr;
  24. __be32 c_xid;
  25. u32 c_prot;
  26. u32 c_proc;
  27. u32 c_vers;
  28. unsigned int c_len;
  29. __wsum c_csum;
  30. unsigned long c_timestamp;
  31. union {
  32. struct kvec u_vec;
  33. __be32 u_status;
  34. } c_u;
  35. };
  36. #define c_replvec c_u.u_vec
  37. #define c_replstat c_u.u_status
  38. /* cache entry states */
  39. enum {
  40. RC_UNUSED,
  41. RC_INPROG,
  42. RC_DONE
  43. };
  44. /* return values */
  45. enum {
  46. RC_DROPIT,
  47. RC_REPLY,
  48. RC_DOIT
  49. };
  50. /*
  51. * Cache types.
  52. * We may want to add more types one day, e.g. for diropres and
  53. * attrstat replies. Using cache entries with fixed length instead
  54. * of buffer pointers may be more efficient.
  55. */
  56. enum {
  57. RC_NOCACHE,
  58. RC_REPLSTAT,
  59. RC_REPLBUFF,
  60. };
  61. /*
  62. * If requests are retransmitted within this interval, they're dropped.
  63. */
  64. #define RC_DELAY (HZ/5)
  65. /* Cache entries expire after this time period */
  66. #define RC_EXPIRE (120 * HZ)
  67. /* Checksum this amount of the request */
  68. #define RC_CSUMLEN (256U)
  69. int nfsd_reply_cache_init(void);
  70. void nfsd_reply_cache_shutdown(void);
  71. int nfsd_cache_lookup(struct svc_rqst *);
  72. void nfsd_cache_update(struct svc_rqst *, int, __be32 *);
  73. int nfsd_reply_cache_stats_open(struct inode *, struct file *);
  74. #endif /* NFSCACHE_H */