callback.h 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. /*
  3. * linux/fs/nfs/callback.h
  4. *
  5. * Copyright (C) 2004 Trond Myklebust
  6. *
  7. * NFSv4 callback definitions
  8. */
  9. #ifndef __LINUX_FS_NFS_CALLBACK_H
  10. #define __LINUX_FS_NFS_CALLBACK_H
  11. #include <linux/sunrpc/svc.h>
  12. #define NFS4_CALLBACK 0x40000000
  13. #define NFS4_CALLBACK_XDRSIZE 2048
  14. #define NFS4_CALLBACK_BUFSIZE (1024 + NFS4_CALLBACK_XDRSIZE)
  15. enum nfs4_callback_procnum {
  16. CB_NULL = 0,
  17. CB_COMPOUND = 1,
  18. };
  19. enum nfs4_callback_opnum {
  20. OP_CB_GETATTR = 3,
  21. OP_CB_RECALL = 4,
  22. /* Callback operations new to NFSv4.1 */
  23. OP_CB_LAYOUTRECALL = 5,
  24. OP_CB_NOTIFY = 6,
  25. OP_CB_PUSH_DELEG = 7,
  26. OP_CB_RECALL_ANY = 8,
  27. OP_CB_RECALLABLE_OBJ_AVAIL = 9,
  28. OP_CB_RECALL_SLOT = 10,
  29. OP_CB_SEQUENCE = 11,
  30. OP_CB_WANTS_CANCELLED = 12,
  31. OP_CB_NOTIFY_LOCK = 13,
  32. OP_CB_NOTIFY_DEVICEID = 14,
  33. /* Callback operations new to NFSv4.2 */
  34. OP_CB_OFFLOAD = 15,
  35. OP_CB_ILLEGAL = 10044,
  36. };
  37. struct nfs4_slot;
  38. struct cb_process_state {
  39. __be32 drc_status;
  40. struct nfs_client *clp;
  41. struct nfs4_slot *slot;
  42. u32 minorversion;
  43. struct net *net;
  44. };
  45. struct cb_compound_hdr_arg {
  46. unsigned int taglen;
  47. const char *tag;
  48. unsigned int minorversion;
  49. unsigned int cb_ident; /* v4.0 callback identifier */
  50. unsigned nops;
  51. };
  52. struct cb_compound_hdr_res {
  53. __be32 *status;
  54. unsigned int taglen;
  55. const char *tag;
  56. __be32 *nops;
  57. };
  58. struct cb_getattrargs {
  59. struct nfs_fh fh;
  60. uint32_t bitmap[2];
  61. };
  62. struct cb_getattrres {
  63. __be32 status;
  64. uint32_t bitmap[2];
  65. uint64_t size;
  66. uint64_t change_attr;
  67. struct timespec64 ctime;
  68. struct timespec64 mtime;
  69. };
  70. struct cb_recallargs {
  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(void *argp, void *resp,
  104. struct cb_process_state *cps);
  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 PNFS_FF_RCA4_TYPE_MASK_READ 16
  115. #define PNFS_FF_RCA4_TYPE_MASK_RW 17
  116. #define RCA4_TYPE_MASK_ALL 0x3f31f
  117. struct cb_recallanyargs {
  118. uint32_t craa_objs_to_keep;
  119. uint32_t craa_type_mask;
  120. };
  121. extern __be32 nfs4_callback_recallany(void *argp, void *resp,
  122. struct cb_process_state *cps);
  123. struct cb_recallslotargs {
  124. uint32_t crsa_target_highest_slotid;
  125. };
  126. extern __be32 nfs4_callback_recallslot(void *argp, void *resp,
  127. struct cb_process_state *cps);
  128. struct cb_layoutrecallargs {
  129. uint32_t cbl_recall_type;
  130. uint32_t cbl_layout_type;
  131. uint32_t cbl_layoutchanged;
  132. union {
  133. struct {
  134. struct nfs_fh cbl_fh;
  135. struct pnfs_layout_range cbl_range;
  136. nfs4_stateid cbl_stateid;
  137. };
  138. struct nfs_fsid cbl_fsid;
  139. };
  140. };
  141. extern __be32 nfs4_callback_layoutrecall(void *argp, void *resp,
  142. struct cb_process_state *cps);
  143. struct cb_devicenotifyitem {
  144. uint32_t cbd_notify_type;
  145. uint32_t cbd_layout_type;
  146. struct nfs4_deviceid cbd_dev_id;
  147. uint32_t cbd_immediate;
  148. };
  149. struct cb_devicenotifyargs {
  150. uint32_t ndevs;
  151. struct cb_devicenotifyitem *devs;
  152. };
  153. extern __be32 nfs4_callback_devicenotify(void *argp, void *resp,
  154. struct cb_process_state *cps);
  155. struct cb_notify_lock_args {
  156. struct nfs_fh cbnl_fh;
  157. struct nfs_lowner cbnl_owner;
  158. bool cbnl_valid;
  159. };
  160. extern __be32 nfs4_callback_notify_lock(void *argp, void *resp,
  161. struct cb_process_state *cps);
  162. #endif /* CONFIG_NFS_V4_1 */
  163. #ifdef CONFIG_NFS_V4_2
  164. struct cb_offloadargs {
  165. struct nfs_fh coa_fh;
  166. nfs4_stateid coa_stateid;
  167. uint32_t error;
  168. uint64_t wr_count;
  169. struct nfs_writeverf wr_writeverf;
  170. };
  171. extern __be32 nfs4_callback_offload(void *args, void *dummy,
  172. struct cb_process_state *cps);
  173. #endif /* CONFIG_NFS_V4_2 */
  174. extern int check_gss_callback_principal(struct nfs_client *, struct svc_rqst *);
  175. extern __be32 nfs4_callback_getattr(void *argp, void *resp,
  176. struct cb_process_state *cps);
  177. extern __be32 nfs4_callback_recall(void *argp, void *resp,
  178. struct cb_process_state *cps);
  179. #if IS_ENABLED(CONFIG_NFS_V4)
  180. extern int nfs_callback_up(u32 minorversion, struct rpc_xprt *xprt);
  181. extern void nfs_callback_down(int minorversion, struct net *net);
  182. #endif /* CONFIG_NFS_V4 */
  183. /*
  184. * nfs41: Callbacks are expected to not cause substantial latency,
  185. * so we limit their concurrency to 1 by setting up the maximum number
  186. * of slots for the backchannel.
  187. */
  188. #define NFS41_BC_MIN_CALLBACKS 1
  189. #define NFS41_BC_MAX_CALLBACKS 1
  190. #define NFS4_MIN_NR_CALLBACK_THREADS 1
  191. extern unsigned int nfs_callback_set_tcpport;
  192. extern unsigned short nfs_callback_nr_threads;
  193. #endif /* __LINUX_FS_NFS_CALLBACK_H */