cache.h 1.7 KB

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