nfs_fs_sb.h 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244
  1. #ifndef _NFS_FS_SB
  2. #define _NFS_FS_SB
  3. #include <linux/list.h>
  4. #include <linux/backing-dev.h>
  5. #include <linux/idr.h>
  6. #include <linux/wait.h>
  7. #include <linux/nfs_xdr.h>
  8. #include <linux/sunrpc/xprt.h>
  9. #include <linux/atomic.h>
  10. struct nfs4_session;
  11. struct nfs_iostats;
  12. struct nlm_host;
  13. struct nfs4_sequence_args;
  14. struct nfs4_sequence_res;
  15. struct nfs_server;
  16. struct nfs4_minor_version_ops;
  17. struct nfs41_server_scope;
  18. struct nfs41_impl_id;
  19. /*
  20. * The nfs_client identifies our client state to the server.
  21. */
  22. struct nfs_client {
  23. atomic_t cl_count;
  24. int cl_cons_state; /* current construction state (-ve: init error) */
  25. #define NFS_CS_READY 0 /* ready to be used */
  26. #define NFS_CS_INITING 1 /* busy initialising */
  27. #define NFS_CS_SESSION_INITING 2 /* busy initialising session */
  28. unsigned long cl_res_state; /* NFS resources state */
  29. #define NFS_CS_CALLBACK 1 /* - callback started */
  30. #define NFS_CS_IDMAP 2 /* - idmap started */
  31. #define NFS_CS_RENEWD 3 /* - renewd started */
  32. #define NFS_CS_STOP_RENEW 4 /* no more state to renew */
  33. #define NFS_CS_CHECK_LEASE_TIME 5 /* need to check lease time */
  34. unsigned long cl_flags; /* behavior switches */
  35. #define NFS_CS_NORESVPORT 0 /* - use ephemeral src port */
  36. #define NFS_CS_DISCRTRY 1 /* - disconnect on RPC retry */
  37. struct sockaddr_storage cl_addr; /* server identifier */
  38. size_t cl_addrlen;
  39. char * cl_hostname; /* hostname of server */
  40. struct list_head cl_share_link; /* link in global client list */
  41. struct list_head cl_superblocks; /* List of nfs_server structs */
  42. struct rpc_clnt * cl_rpcclient;
  43. const struct nfs_rpc_ops *rpc_ops; /* NFS protocol vector */
  44. int cl_proto; /* Network transport protocol */
  45. u32 cl_minorversion;/* NFSv4 minorversion */
  46. struct rpc_cred *cl_machine_cred;
  47. #ifdef CONFIG_NFS_V4
  48. u64 cl_clientid; /* constant */
  49. nfs4_verifier cl_confirm; /* Clientid verifier */
  50. unsigned long cl_state;
  51. spinlock_t cl_lock;
  52. unsigned long cl_lease_time;
  53. unsigned long cl_last_renewal;
  54. struct delayed_work cl_renewd;
  55. struct rpc_wait_queue cl_rpcwaitq;
  56. /* idmapper */
  57. struct idmap * cl_idmap;
  58. /* Our own IP address, as a null-terminated string.
  59. * This is used to generate the clientid, and the callback address.
  60. */
  61. char cl_ipaddr[48];
  62. unsigned char cl_id_uniquifier;
  63. u32 cl_cb_ident; /* v4.0 callback identifier */
  64. const struct nfs4_minor_version_ops *cl_mvops;
  65. /* The sequence id to use for the next CREATE_SESSION */
  66. u32 cl_seqid;
  67. /* The flags used for obtaining the clientid during EXCHANGE_ID */
  68. u32 cl_exchange_flags;
  69. struct nfs4_session *cl_session; /* shared session */
  70. struct nfs41_server_owner *cl_serverowner;
  71. struct nfs41_server_scope *cl_serverscope;
  72. struct nfs41_impl_id *cl_implid;
  73. #endif /* CONFIG_NFS_V4 */
  74. #ifdef CONFIG_NFS_FSCACHE
  75. struct fscache_cookie *fscache; /* client index cache cookie */
  76. #endif
  77. struct net *cl_net;
  78. };
  79. /*
  80. * NFS client parameters stored in the superblock.
  81. */
  82. struct nfs_server {
  83. struct nfs_client * nfs_client; /* shared client and NFS4 state */
  84. struct list_head client_link; /* List of other nfs_server structs
  85. * that share the same client
  86. */
  87. struct list_head master_link; /* link in master servers list */
  88. struct rpc_clnt * client; /* RPC client handle */
  89. struct rpc_clnt * client_acl; /* ACL RPC client handle */
  90. struct nlm_host *nlm_host; /* NLM client handle */
  91. struct nfs_iostats __percpu *io_stats; /* I/O statistics */
  92. struct backing_dev_info backing_dev_info;
  93. atomic_long_t writeback; /* number of writeback pages */
  94. int flags; /* various flags */
  95. unsigned int caps; /* server capabilities */
  96. unsigned int rsize; /* read size */
  97. unsigned int rpages; /* read size (in pages) */
  98. unsigned int wsize; /* write size */
  99. unsigned int wpages; /* write size (in pages) */
  100. unsigned int wtmult; /* server disk block size */
  101. unsigned int dtsize; /* readdir size */
  102. unsigned short port; /* "port=" setting */
  103. unsigned int bsize; /* server block size */
  104. unsigned int acregmin; /* attr cache timeouts */
  105. unsigned int acregmax;
  106. unsigned int acdirmin;
  107. unsigned int acdirmax;
  108. unsigned int namelen;
  109. unsigned int options; /* extra options enabled by mount */
  110. #define NFS_OPTION_FSCACHE 0x00000001 /* - local caching enabled */
  111. struct nfs_fsid fsid;
  112. __u64 maxfilesize; /* maximum file size */
  113. struct timespec time_delta; /* smallest time granularity */
  114. unsigned long mount_time; /* when this fs was mounted */
  115. dev_t s_dev; /* superblock dev numbers */
  116. #ifdef CONFIG_NFS_FSCACHE
  117. struct nfs_fscache_key *fscache_key; /* unique key for superblock */
  118. struct fscache_cookie *fscache; /* superblock cookie */
  119. #endif
  120. u32 pnfs_blksize; /* layout_blksize attr */
  121. #ifdef CONFIG_NFS_V4
  122. u32 attr_bitmask[3];/* V4 bitmask representing the set
  123. of attributes supported on this
  124. filesystem */
  125. u32 cache_consistency_bitmask[2];
  126. /* V4 bitmask representing the subset
  127. of change attribute, size, ctime
  128. and mtime attributes supported by
  129. the server */
  130. u32 acl_bitmask; /* V4 bitmask representing the ACEs
  131. that are supported on this
  132. filesystem */
  133. u32 fh_expire_type; /* V4 bitmask representing file
  134. handle volatility type for
  135. this filesystem */
  136. struct pnfs_layoutdriver_type *pnfs_curr_ld; /* Active layout driver */
  137. struct rpc_wait_queue roc_rpcwaitq;
  138. void *pnfs_ld_data; /* per mount point data */
  139. /* the following fields are protected by nfs_client->cl_lock */
  140. struct rb_root state_owners;
  141. #endif
  142. struct ida openowner_id;
  143. struct ida lockowner_id;
  144. struct list_head state_owners_lru;
  145. struct list_head layouts;
  146. struct list_head delegations;
  147. void (*destroy)(struct nfs_server *);
  148. atomic_t active; /* Keep trace of any activity to this server */
  149. /* mountd-related mount options */
  150. struct sockaddr_storage mountd_address;
  151. size_t mountd_addrlen;
  152. u32 mountd_version;
  153. unsigned short mountd_port;
  154. unsigned short mountd_protocol;
  155. };
  156. /* Server capabilities */
  157. #define NFS_CAP_READDIRPLUS (1U << 0)
  158. #define NFS_CAP_HARDLINKS (1U << 1)
  159. #define NFS_CAP_SYMLINKS (1U << 2)
  160. #define NFS_CAP_ACLS (1U << 3)
  161. #define NFS_CAP_ATOMIC_OPEN (1U << 4)
  162. #define NFS_CAP_CHANGE_ATTR (1U << 5)
  163. #define NFS_CAP_FILEID (1U << 6)
  164. #define NFS_CAP_MODE (1U << 7)
  165. #define NFS_CAP_NLINK (1U << 8)
  166. #define NFS_CAP_OWNER (1U << 9)
  167. #define NFS_CAP_OWNER_GROUP (1U << 10)
  168. #define NFS_CAP_ATIME (1U << 11)
  169. #define NFS_CAP_CTIME (1U << 12)
  170. #define NFS_CAP_MTIME (1U << 13)
  171. #define NFS_CAP_POSIX_LOCK (1U << 14)
  172. #define NFS_CAP_UIDGID_NOMAP (1U << 15)
  173. /* maximum number of slots to use */
  174. #define NFS4_DEF_SLOT_TABLE_SIZE (16U)
  175. #define NFS4_MAX_SLOT_TABLE (256U)
  176. #define NFS4_NO_SLOT ((u32)-1)
  177. #if defined(CONFIG_NFS_V4)
  178. /* Sessions */
  179. #define SLOT_TABLE_SZ DIV_ROUND_UP(NFS4_MAX_SLOT_TABLE, 8*sizeof(long))
  180. struct nfs4_slot_table {
  181. struct nfs4_slot *slots; /* seqid per slot */
  182. unsigned long used_slots[SLOT_TABLE_SZ]; /* used/unused bitmap */
  183. spinlock_t slot_tbl_lock;
  184. struct rpc_wait_queue slot_tbl_waitq; /* allocators may wait here */
  185. u32 max_slots; /* # slots in table */
  186. u32 highest_used_slotid; /* sent to server on each SEQ.
  187. * op for dynamic resizing */
  188. u32 target_max_slots; /* Set by CB_RECALL_SLOT as
  189. * the new max_slots */
  190. struct completion complete;
  191. };
  192. static inline int slot_idx(struct nfs4_slot_table *tbl, struct nfs4_slot *sp)
  193. {
  194. return sp - tbl->slots;
  195. }
  196. /*
  197. * Session related parameters
  198. */
  199. struct nfs4_session {
  200. struct nfs4_sessionid sess_id;
  201. u32 flags;
  202. unsigned long session_state;
  203. u32 hash_alg;
  204. u32 ssv_len;
  205. /* The fore and back channel */
  206. struct nfs4_channel_attrs fc_attrs;
  207. struct nfs4_slot_table fc_slot_table;
  208. struct nfs4_channel_attrs bc_attrs;
  209. struct nfs4_slot_table bc_slot_table;
  210. struct nfs_client *clp;
  211. };
  212. #endif /* CONFIG_NFS_V4 */
  213. #endif