cache.h 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. /*
  2. * include/linux/nfsd/cache.h
  3. *
  4. * Request reply cache. This was heavily inspired by the
  5. * implementation in 4.3BSD/4.4BSD.
  6. *
  7. * Copyright (C) 1995, 1996 Olaf Kirch <okir@monad.swb.de>
  8. */
  9. #ifndef NFSCACHE_H
  10. #define NFSCACHE_H
  11. #include <linux/in.h>
  12. #include <linux/uio.h>
  13. /*
  14. * Representation of a reply cache entry. The first two members *must*
  15. * be hash_next and hash_prev.
  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_in c_addr;
  24. __be32 c_xid;
  25. u32 c_prot;
  26. u32 c_proc;
  27. u32 c_vers;
  28. unsigned long c_timestamp;
  29. union {
  30. struct kvec u_vec;
  31. __be32 u_status;
  32. } c_u;
  33. };
  34. #define c_replvec c_u.u_vec
  35. #define c_replstat c_u.u_status
  36. /* cache entry states */
  37. enum {
  38. RC_UNUSED,
  39. RC_INPROG,
  40. RC_DONE
  41. };
  42. /* return values */
  43. enum {
  44. RC_DROPIT,
  45. RC_REPLY,
  46. RC_DOIT,
  47. RC_INTR
  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. int nfsd_reply_cache_init(void);
  65. void nfsd_reply_cache_shutdown(void);
  66. int nfsd_cache_lookup(struct svc_rqst *, int);
  67. void nfsd_cache_update(struct svc_rqst *, int, __be32 *);
  68. #endif /* NFSCACHE_H */