callback.h 4.9 KB

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