nfs_fs_sb.h 7.1 KB

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