cache.h 1.6 KB

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