nfs_fs_sb.h 7.1 KB

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