cache.h 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  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 list_head c_lru;
  19. unsigned char c_state, /* unused, inprog, done */
  20. c_type, /* status, buffer */
  21. c_secure : 1; /* req came from port < 1024 */
  22. struct sockaddr_in6 c_addr;
  23. __be32 c_xid;
  24. u32 c_prot;
  25. u32 c_proc;
  26. u32 c_vers;
  27. unsigned int c_len;
  28. __wsum c_csum;
  29. unsigned long c_timestamp;
  30. union {
  31. struct kvec u_vec;
  32. __be32 u_status;
  33. } c_u;
  34. };
  35. #define c_replvec c_u.u_vec
  36. #define c_replstat c_u.u_status
  37. /* cache entry states */
  38. enum {
  39. RC_UNUSED,
  40. RC_INPROG,
  41. RC_DONE
  42. };
  43. /* return values */
  44. enum {
  45. RC_DROPIT,
  46. RC_REPLY,
  47. RC_DOIT
  48. };
  49. /*
  50. * Cache types.
  51. * We may want to add more types one day, e.g. for diropres and
  52. * attrstat replies. Using cache entries with fixed length instead
  53. * of buffer pointers may be more efficient.
  54. */
  55. enum {
  56. RC_NOCACHE,
  57. RC_REPLSTAT,
  58. RC_REPLBUFF,
  59. };
  60. /*
  61. * If requests are retransmitted within this interval, they're dropped.
  62. */
  63. #define RC_DELAY (HZ/5)
  64. /* Cache entries expire after this time period */
  65. #define RC_EXPIRE (120 * HZ)
  66. /* Checksum this amount of the request */
  67. #define RC_CSUMLEN (256U)
  68. int nfsd_reply_cache_init(void);
  69. void nfsd_reply_cache_shutdown(void);
  70. int nfsd_cache_lookup(struct svc_rqst *);
  71. void nfsd_cache_update(struct svc_rqst *, int, __be32 *);
  72. int nfsd_reply_cache_stats_open(struct inode *, struct file *);
  73. #endif /* NFSCACHE_H */