nfs_fs_sb.h 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. #ifndef _NFS_FS_SB
  3. #define _NFS_FS_SB
  4. #include <linux/list.h>
  5. #include <linux/backing-dev.h>
  6. #include <linux/idr.h>
  7. #include <linux/wait.h>
  8. #include <linux/nfs_xdr.h>
  9. #include <linux/sunrpc/xprt.h>
  10. #include <linux/atomic.h>
  11. #include <linux/refcount.h>
  12. struct nfs4_session;
  13. struct nfs_iostats;
  14. struct nlm_host;
  15. struct nfs4_sequence_args;
  16. struct nfs4_sequence_res;
  17. struct nfs_server;
  18. struct nfs4_minor_version_ops;
  19. struct nfs41_server_scope;
  20. struct nfs41_impl_id;
  21. /*
  22. * The nfs_client identifies our client state to the server.
  23. */
  24. struct nfs_client {
  25. refcount_t cl_count;
  26. atomic_t cl_mds_count;
  27. int cl_cons_state; /* current construction state (-ve: init error) */
  28. #define NFS_CS_READY 0 /* ready to be used */
  29. #define NFS_CS_INITING 1 /* busy initialising */
  30. #define NFS_CS_SESSION_INITING 2 /* busy initialising session */
  31. unsigned long cl_res_state; /* NFS resources state */
  32. #define NFS_CS_CALLBACK 1 /* - callback started */
  33. #define NFS_CS_IDMAP 2 /* - idmap started */
  34. #define NFS_CS_RENEWD 3 /* - renewd started */
  35. #define NFS_CS_STOP_RENEW 4 /* no more state to renew */
  36. #define NFS_CS_CHECK_LEASE_TIME 5 /* need to check lease time */
  37. unsigned long cl_flags; /* behavior switches */
  38. #define NFS_CS_NORESVPORT 0 /* - use ephemeral src port */
  39. #define NFS_CS_DISCRTRY 1 /* - disconnect on RPC retry */
  40. #define NFS_CS_MIGRATION 2 /* - transparent state migr */
  41. #define NFS_CS_INFINITE_SLOTS 3 /* - don't limit TCP slots */
  42. #define NFS_CS_NO_RETRANS_TIMEOUT 4 /* - Disable retransmit timeouts */
  43. #define NFS_CS_TSM_POSSIBLE 5 /* - Maybe state migration */
  44. #define NFS_CS_NOPING 6 /* - don't ping on connect */
  45. #define NFS_CS_DS 7 /* - Server is a DS */
  46. #define NFS_CS_REUSEPORT 8 /* - reuse src port on reconnect */
  47. #define NFS_CS_PNFS 9 /* - Server used for pnfs */
  48. struct sockaddr_storage cl_addr; /* server identifier */
  49. size_t cl_addrlen;
  50. char * cl_hostname; /* hostname of server */
  51. char * cl_acceptor; /* GSSAPI acceptor name */
  52. struct list_head cl_share_link; /* link in global client list */
  53. struct list_head cl_superblocks; /* List of nfs_server structs */
  54. struct rpc_clnt * cl_rpcclient;
  55. const struct nfs_rpc_ops *rpc_ops; /* NFS protocol vector */
  56. int cl_proto; /* Network transport protocol */
  57. struct nfs_subversion * cl_nfs_mod; /* pointer to nfs version module */
  58. u32 cl_minorversion;/* NFSv4 minorversion */
  59. unsigned int cl_nconnect; /* Number of connections */
  60. unsigned int cl_max_connect; /* max number of xprts allowed */
  61. const char * cl_principal; /* used for machine cred */
  62. #if IS_ENABLED(CONFIG_NFS_V4)
  63. struct list_head cl_ds_clients; /* auth flavor data servers */
  64. u64 cl_clientid; /* constant */
  65. nfs4_verifier cl_confirm; /* Clientid verifier */
  66. unsigned long cl_state;
  67. spinlock_t cl_lock;
  68. unsigned long cl_lease_time;
  69. unsigned long cl_last_renewal;
  70. struct delayed_work cl_renewd;
  71. struct rpc_wait_queue cl_rpcwaitq;
  72. /* idmapper */
  73. struct idmap * cl_idmap;
  74. /* Client owner identifier */
  75. const char * cl_owner_id;
  76. u32 cl_cb_ident; /* v4.0 callback identifier */
  77. const struct nfs4_minor_version_ops *cl_mvops;
  78. unsigned long cl_mig_gen;
  79. /* NFSv4.0 transport blocking */
  80. struct nfs4_slot_table *cl_slot_tbl;
  81. /* The sequence id to use for the next CREATE_SESSION */
  82. u32 cl_seqid;
  83. /* The flags used for obtaining the clientid during EXCHANGE_ID */
  84. u32 cl_exchange_flags;
  85. struct nfs4_session *cl_session; /* shared session */
  86. bool cl_preserve_clid;
  87. struct nfs41_server_owner *cl_serverowner;
  88. struct nfs41_server_scope *cl_serverscope;
  89. struct nfs41_impl_id *cl_implid;
  90. /* nfs 4.1+ state protection modes: */
  91. unsigned long cl_sp4_flags;
  92. #define NFS_SP4_MACH_CRED_MINIMAL 1 /* Minimal sp4_mach_cred - state ops
  93. * must use machine cred */
  94. #define NFS_SP4_MACH_CRED_CLEANUP 2 /* CLOSE and LOCKU */
  95. #define NFS_SP4_MACH_CRED_SECINFO 3 /* SECINFO and SECINFO_NO_NAME */
  96. #define NFS_SP4_MACH_CRED_STATEID 4 /* TEST_STATEID and FREE_STATEID */
  97. #define NFS_SP4_MACH_CRED_WRITE 5 /* WRITE */
  98. #define NFS_SP4_MACH_CRED_COMMIT 6 /* COMMIT */
  99. #define NFS_SP4_MACH_CRED_PNFS_CLEANUP 7 /* LAYOUTRETURN */
  100. #if IS_ENABLED(CONFIG_NFS_V4_1)
  101. wait_queue_head_t cl_lock_waitq;
  102. #endif /* CONFIG_NFS_V4_1 */
  103. #endif /* CONFIG_NFS_V4 */
  104. /* Our own IP address, as a null-terminated string.
  105. * This is used to generate the mv0 callback address.
  106. */
  107. char cl_ipaddr[48];
  108. struct net *cl_net;
  109. struct list_head pending_cb_stateids;
  110. };
  111. /*
  112. * NFS client parameters stored in the superblock.
  113. */
  114. struct nfs_server {
  115. struct nfs_client * nfs_client; /* shared client and NFS4 state */
  116. struct list_head client_link; /* List of other nfs_server structs
  117. * that share the same client
  118. */
  119. struct list_head master_link; /* link in master servers list */
  120. struct rpc_clnt * client; /* RPC client handle */
  121. struct rpc_clnt * client_acl; /* ACL RPC client handle */
  122. struct nlm_host *nlm_host; /* NLM client handle */
  123. struct nfs_iostats __percpu *io_stats; /* I/O statistics */
  124. atomic_long_t writeback; /* number of writeback pages */
  125. unsigned int write_congested;/* flag set when writeback gets too high */
  126. unsigned int flags; /* various flags */
  127. /* The following are for internal use only. Also see uapi/linux/nfs_mount.h */
  128. #define NFS_MOUNT_LOOKUP_CACHE_NONEG 0x10000
  129. #define NFS_MOUNT_LOOKUP_CACHE_NONE 0x20000
  130. #define NFS_MOUNT_NORESVPORT 0x40000
  131. #define NFS_MOUNT_LEGACY_INTERFACE 0x80000
  132. #define NFS_MOUNT_LOCAL_FLOCK 0x100000
  133. #define NFS_MOUNT_LOCAL_FCNTL 0x200000
  134. #define NFS_MOUNT_SOFTERR 0x400000
  135. #define NFS_MOUNT_SOFTREVAL 0x800000
  136. #define NFS_MOUNT_WRITE_EAGER 0x01000000
  137. #define NFS_MOUNT_WRITE_WAIT 0x02000000
  138. #define NFS_MOUNT_TRUNK_DISCOVERY 0x04000000
  139. unsigned int fattr_valid; /* Valid attributes */
  140. unsigned int caps; /* server capabilities */
  141. unsigned int rsize; /* read size */
  142. unsigned int rpages; /* read size (in pages) */
  143. unsigned int wsize; /* write size */
  144. unsigned int wpages; /* write size (in pages) */
  145. unsigned int wtmult; /* server disk block size */
  146. unsigned int dtsize; /* readdir size */
  147. unsigned short port; /* "port=" setting */
  148. unsigned int bsize; /* server block size */
  149. #ifdef CONFIG_NFS_V4_2
  150. unsigned int gxasize; /* getxattr size */
  151. unsigned int sxasize; /* setxattr size */
  152. unsigned int lxasize; /* listxattr size */
  153. #endif
  154. unsigned int acregmin; /* attr cache timeouts */
  155. unsigned int acregmax;
  156. unsigned int acdirmin;
  157. unsigned int acdirmax;
  158. unsigned int namelen;
  159. unsigned int options; /* extra options enabled by mount */
  160. unsigned int clone_blksize; /* granularity of a CLONE operation */
  161. #define NFS_OPTION_FSCACHE 0x00000001 /* - local caching enabled */
  162. #define NFS_OPTION_MIGRATION 0x00000002 /* - NFSv4 migration enabled */
  163. enum nfs4_change_attr_type
  164. change_attr_type;/* Description of change attribute */
  165. struct nfs_fsid fsid;
  166. __u64 maxfilesize; /* maximum file size */
  167. struct timespec64 time_delta; /* smallest time granularity */
  168. unsigned long mount_time; /* when this fs was mounted */
  169. struct super_block *super; /* VFS super block */
  170. dev_t s_dev; /* superblock dev numbers */
  171. struct nfs_auth_info auth_info; /* parsed auth flavors */
  172. #ifdef CONFIG_NFS_FSCACHE
  173. struct fscache_volume *fscache; /* superblock cookie */
  174. char *fscache_uniq; /* Uniquifier (or NULL) */
  175. #endif
  176. u32 pnfs_blksize; /* layout_blksize attr */
  177. #if IS_ENABLED(CONFIG_NFS_V4)
  178. u32 attr_bitmask[3];/* V4 bitmask representing the set
  179. of attributes supported on this
  180. filesystem */
  181. u32 attr_bitmask_nl[3];
  182. /* V4 bitmask representing the
  183. set of attributes supported
  184. on this filesystem excluding
  185. the label support bit. */
  186. u32 exclcreat_bitmask[3];
  187. /* V4 bitmask representing the
  188. set of attributes supported
  189. on this filesystem for the
  190. exclusive create. */
  191. u32 cache_consistency_bitmask[3];
  192. /* V4 bitmask representing the subset
  193. of change attribute, size, ctime
  194. and mtime attributes supported by
  195. the server */
  196. u32 acl_bitmask; /* V4 bitmask representing the ACEs
  197. that are supported on this
  198. filesystem */
  199. u32 fh_expire_type; /* V4 bitmask representing file
  200. handle volatility type for
  201. this filesystem */
  202. struct pnfs_layoutdriver_type *pnfs_curr_ld; /* Active layout driver */
  203. struct rpc_wait_queue roc_rpcwaitq;
  204. void *pnfs_ld_data; /* per mount point data */
  205. /* the following fields are protected by nfs_client->cl_lock */
  206. struct rb_root state_owners;
  207. #endif
  208. struct ida openowner_id;
  209. struct ida lockowner_id;
  210. struct list_head state_owners_lru;
  211. struct list_head layouts;
  212. struct list_head delegations;
  213. struct list_head ss_copies;
  214. unsigned long mig_gen;
  215. unsigned long mig_status;
  216. #define NFS_MIG_IN_TRANSITION (1)
  217. #define NFS_MIG_FAILED (2)
  218. #define NFS_MIG_TSM_POSSIBLE (3)
  219. void (*destroy)(struct nfs_server *);
  220. atomic_t active; /* Keep trace of any activity to this server */
  221. /* mountd-related mount options */
  222. struct sockaddr_storage mountd_address;
  223. size_t mountd_addrlen;
  224. u32 mountd_version;
  225. unsigned short mountd_port;
  226. unsigned short mountd_protocol;
  227. struct rpc_wait_queue uoc_rpcwaitq;
  228. /* XDR related information */
  229. unsigned int read_hdrsize;
  230. /* User namespace info */
  231. const struct cred *cred;
  232. bool has_sec_mnt_opts;
  233. };
  234. /* Server capabilities */
  235. #define NFS_CAP_READDIRPLUS (1U << 0)
  236. #define NFS_CAP_HARDLINKS (1U << 1)
  237. #define NFS_CAP_SYMLINKS (1U << 2)
  238. #define NFS_CAP_ACLS (1U << 3)
  239. #define NFS_CAP_ATOMIC_OPEN (1U << 4)
  240. #define NFS_CAP_LGOPEN (1U << 5)
  241. #define NFS_CAP_CASE_INSENSITIVE (1U << 6)
  242. #define NFS_CAP_CASE_PRESERVING (1U << 7)
  243. #define NFS_CAP_POSIX_LOCK (1U << 14)
  244. #define NFS_CAP_UIDGID_NOMAP (1U << 15)
  245. #define NFS_CAP_STATEID_NFSV41 (1U << 16)
  246. #define NFS_CAP_ATOMIC_OPEN_V1 (1U << 17)
  247. #define NFS_CAP_SECURITY_LABEL (1U << 18)
  248. #define NFS_CAP_SEEK (1U << 19)
  249. #define NFS_CAP_ALLOCATE (1U << 20)
  250. #define NFS_CAP_DEALLOCATE (1U << 21)
  251. #define NFS_CAP_LAYOUTSTATS (1U << 22)
  252. #define NFS_CAP_CLONE (1U << 23)
  253. #define NFS_CAP_COPY (1U << 24)
  254. #define NFS_CAP_OFFLOAD_CANCEL (1U << 25)
  255. #define NFS_CAP_LAYOUTERROR (1U << 26)
  256. #define NFS_CAP_COPY_NOTIFY (1U << 27)
  257. #define NFS_CAP_XATTR (1U << 28)
  258. #define NFS_CAP_READ_PLUS (1U << 29)
  259. #define NFS_CAP_FS_LOCATIONS (1U << 30)
  260. #define NFS_CAP_MOVEABLE (1U << 31)
  261. #endif