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