callback.h 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215
  1. /*
  2. * linux/fs/nfs/callback.h
  3. *
  4. * Copyright (C) 2004 Trond Myklebust
  5. *
  6. * NFSv4 callback definitions
  7. */
  8. #ifndef __LINUX_FS_NFS_CALLBACK_H
  9. #define __LINUX_FS_NFS_CALLBACK_H
  10. #include <linux/sunrpc/svc.h>
  11. #define NFS4_CALLBACK 0x40000000
  12. #define NFS4_CALLBACK_XDRSIZE 2048
  13. #define NFS4_CALLBACK_BUFSIZE (1024 + NFS4_CALLBACK_XDRSIZE)
  14. enum nfs4_callback_procnum {
  15. CB_NULL = 0,
  16. CB_COMPOUND = 1,
  17. };
  18. enum nfs4_callback_opnum {
  19. OP_CB_GETATTR = 3,
  20. OP_CB_RECALL = 4,
  21. /* Callback operations new to NFSv4.1 */
  22. OP_CB_LAYOUTRECALL = 5,
  23. OP_CB_NOTIFY = 6,
  24. OP_CB_PUSH_DELEG = 7,
  25. OP_CB_RECALL_ANY = 8,
  26. OP_CB_RECALLABLE_OBJ_AVAIL = 9,
  27. OP_CB_RECALL_SLOT = 10,
  28. OP_CB_SEQUENCE = 11,
  29. OP_CB_WANTS_CANCELLED = 12,
  30. OP_CB_NOTIFY_LOCK = 13,
  31. OP_CB_NOTIFY_DEVICEID = 14,
  32. OP_CB_ILLEGAL = 10044,
  33. };
  34. struct cb_process_state {
  35. __be32 drc_status;
  36. struct nfs_client *clp;
  37. u32 slotid;
  38. struct net *net;
  39. };
  40. struct cb_compound_hdr_arg {
  41. unsigned int taglen;
  42. const char *tag;
  43. unsigned int minorversion;
  44. unsigned int cb_ident; /* v4.0 callback identifier */
  45. unsigned nops;
  46. };
  47. struct cb_compound_hdr_res {
  48. __be32 *status;
  49. unsigned int taglen;
  50. const char *tag;
  51. __be32 *nops;
  52. };
  53. struct cb_getattrargs {
  54. struct sockaddr *addr;
  55. struct nfs_fh fh;
  56. uint32_t bitmap[2];
  57. };
  58. struct cb_getattrres {
  59. __be32 status;
  60. uint32_t bitmap[2];
  61. uint64_t size;
  62. uint64_t change_attr;
  63. struct timespec ctime;
  64. struct timespec mtime;
  65. };
  66. struct cb_recallargs {
  67. struct sockaddr *addr;
  68. struct nfs_fh fh;
  69. nfs4_stateid stateid;
  70. uint32_t truncate;
  71. };
  72. #if defined(CONFIG_NFS_V4_1)
  73. struct referring_call {
  74. uint32_t rc_sequenceid;
  75. uint32_t rc_slotid;
  76. };
  77. struct referring_call_list {
  78. struct nfs4_sessionid rcl_sessionid;
  79. uint32_t rcl_nrefcalls;
  80. struct referring_call *rcl_refcalls;
  81. };
  82. struct cb_sequenceargs {
  83. struct sockaddr *csa_addr;
  84. struct nfs4_sessionid csa_sessionid;
  85. uint32_t csa_sequenceid;
  86. uint32_t csa_slotid;
  87. uint32_t csa_highestslotid;
  88. uint32_t csa_cachethis;
  89. uint32_t csa_nrclists;
  90. struct referring_call_list *csa_rclists;
  91. };
  92. struct cb_sequenceres {
  93. __be32 csr_status;
  94. struct nfs4_sessionid csr_sessionid;
  95. uint32_t csr_sequenceid;
  96. uint32_t csr_slotid;
  97. uint32_t csr_highestslotid;
  98. uint32_t csr_target_highestslotid;
  99. };
  100. extern __be32 nfs4_callback_sequence(struct cb_sequenceargs *args,
  101. struct cb_sequenceres *res,
  102. struct cb_process_state *cps);
  103. extern int nfs41_validate_delegation_stateid(struct nfs_delegation *delegation,
  104. const nfs4_stateid *stateid);
  105. #define RCA4_TYPE_MASK_RDATA_DLG 0
  106. #define RCA4_TYPE_MASK_WDATA_DLG 1
  107. #define RCA4_TYPE_MASK_DIR_DLG 2
  108. #define RCA4_TYPE_MASK_FILE_LAYOUT 3
  109. #define RCA4_TYPE_MASK_BLK_LAYOUT 4
  110. #define RCA4_TYPE_MASK_OBJ_LAYOUT_MIN 8
  111. #define RCA4_TYPE_MASK_OBJ_LAYOUT_MAX 9
  112. #define RCA4_TYPE_MASK_OTHER_LAYOUT_MIN 12
  113. #define RCA4_TYPE_MASK_OTHER_LAYOUT_MAX 15
  114. #define RCA4_TYPE_MASK_ALL 0xf31f
  115. struct cb_recallanyargs {
  116. struct sockaddr *craa_addr;
  117. uint32_t craa_objs_to_keep;
  118. uint32_t craa_type_mask;
  119. };
  120. extern __be32 nfs4_callback_recallany(struct cb_recallanyargs *args,
  121. void *dummy,
  122. struct cb_process_state *cps);
  123. struct cb_recallslotargs {
  124. struct sockaddr *crsa_addr;
  125. uint32_t crsa_target_max_slots;
  126. };
  127. extern __be32 nfs4_callback_recallslot(struct cb_recallslotargs *args,
  128. void *dummy,
  129. struct cb_process_state *cps);
  130. struct cb_layoutrecallargs {
  131. struct sockaddr *cbl_addr;
  132. uint32_t cbl_recall_type;
  133. uint32_t cbl_layout_type;
  134. uint32_t cbl_layoutchanged;
  135. union {
  136. struct {
  137. struct nfs_fh cbl_fh;
  138. struct pnfs_layout_range cbl_range;
  139. nfs4_stateid cbl_stateid;
  140. };
  141. struct nfs_fsid cbl_fsid;
  142. };
  143. };
  144. extern __be32 nfs4_callback_layoutrecall(
  145. struct cb_layoutrecallargs *args,
  146. void *dummy, struct cb_process_state *cps);
  147. extern void nfs4_check_drain_bc_complete(struct nfs4_session *ses);
  148. struct cb_devicenotifyitem {
  149. uint32_t cbd_notify_type;
  150. uint32_t cbd_layout_type;
  151. struct nfs4_deviceid cbd_dev_id;
  152. uint32_t cbd_immediate;
  153. };
  154. struct cb_devicenotifyargs {
  155. int ndevs;
  156. struct cb_devicenotifyitem *devs;
  157. };
  158. extern __be32 nfs4_callback_devicenotify(
  159. struct cb_devicenotifyargs *args,
  160. void *dummy, struct cb_process_state *cps);
  161. #endif /* CONFIG_NFS_V4_1 */
  162. extern int check_gss_callback_principal(struct nfs_client *, struct svc_rqst *);
  163. extern __be32 nfs4_callback_getattr(struct cb_getattrargs *args,
  164. struct cb_getattrres *res,
  165. struct cb_process_state *cps);
  166. extern __be32 nfs4_callback_recall(struct cb_recallargs *args, void *dummy,
  167. struct cb_process_state *cps);
  168. #ifdef CONFIG_NFS_V4
  169. extern int nfs_callback_up(u32 minorversion, struct rpc_xprt *xprt);
  170. extern void nfs_callback_down(int minorversion);
  171. extern int nfs4_validate_delegation_stateid(struct nfs_delegation *delegation,
  172. const nfs4_stateid *stateid);
  173. extern int nfs4_set_callback_sessionid(struct nfs_client *clp);
  174. #endif /* CONFIG_NFS_V4 */
  175. /*
  176. * nfs41: Callbacks are expected to not cause substantial latency,
  177. * so we limit their concurrency to 1 by setting up the maximum number
  178. * of slots for the backchannel.
  179. */
  180. #define NFS41_BC_MIN_CALLBACKS 1
  181. #define NFS41_BC_MAX_CALLBACKS 1
  182. extern unsigned int nfs_callback_set_tcpport;
  183. extern unsigned short nfs_callback_tcpport;
  184. extern unsigned short nfs_callback_tcpport6;
  185. #endif /* __LINUX_FS_NFS_CALLBACK_H */