nfs_fs_sb.h 7.0 KB

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