callback.h 5.3 KB

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