nfs_fs_sb.h 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223
  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. /*
  16. * The nfs_client identifies our client state to the server.
  17. */
  18. struct nfs_client {
  19. atomic_t cl_count;
  20. int cl_cons_state; /* current construction state (-ve: init error) */
  21. #define NFS_CS_READY 0 /* ready to be used */
  22. #define NFS_CS_INITING 1 /* busy initialising */
  23. #define NFS_CS_SESSION_INITING 2 /* busy initialising session */
  24. unsigned long cl_res_state; /* NFS resources state */
  25. #define NFS_CS_CALLBACK 1 /* - callback started */
  26. #define NFS_CS_IDMAP 2 /* - idmap started */
  27. #define NFS_CS_RENEWD 3 /* - renewd started */
  28. struct sockaddr_storage cl_addr; /* server identifier */
  29. size_t cl_addrlen;
  30. char * cl_hostname; /* hostname of server */
  31. struct list_head cl_share_link; /* link in global client list */
  32. struct list_head cl_superblocks; /* List of nfs_server structs */
  33. struct rpc_clnt * cl_rpcclient;
  34. const struct nfs_rpc_ops *rpc_ops; /* NFS protocol vector */
  35. int cl_proto; /* Network transport protocol */
  36. u32 cl_minorversion;/* NFSv4 minorversion */
  37. struct rpc_cred *cl_machine_cred;
  38. #ifdef CONFIG_NFS_V4
  39. u64 cl_clientid; /* constant */
  40. nfs4_verifier cl_confirm;
  41. unsigned long cl_state;
  42. struct rb_root cl_openowner_id;
  43. struct rb_root cl_lockowner_id;
  44. struct list_head cl_delegations;
  45. struct rb_root cl_state_owners;
  46. spinlock_t cl_lock;
  47. unsigned long cl_lease_time;
  48. unsigned long cl_last_renewal;
  49. struct delayed_work cl_renewd;
  50. struct rpc_wait_queue cl_rpcwaitq;
  51. /* used for the setclientid verifier */
  52. struct timespec cl_boot_time;
  53. /* idmapper */
  54. struct idmap * cl_idmap;
  55. /* Our own IP address, as a null-terminated string.
  56. * This is used to generate the clientid, and the callback address.
  57. */
  58. char cl_ipaddr[48];
  59. unsigned char cl_id_uniquifier;
  60. int (* cl_call_sync)(struct nfs_server *server,
  61. struct rpc_message *msg,
  62. struct nfs4_sequence_args *args,
  63. struct nfs4_sequence_res *res,
  64. int cache_reply);
  65. #endif /* CONFIG_NFS_V4 */
  66. #ifdef CONFIG_NFS_V4_1
  67. /* clientid returned from EXCHANGE_ID, used by session operations */
  68. u64 cl_ex_clid;
  69. /* The sequence id to use for the next CREATE_SESSION */
  70. u32 cl_seqid;
  71. /* The flags used for obtaining the clientid during EXCHANGE_ID */
  72. u32 cl_exchange_flags;
  73. struct nfs4_session *cl_session; /* sharred session */
  74. #endif /* CONFIG_NFS_V4_1 */
  75. #ifdef CONFIG_NFS_FSCACHE
  76. struct fscache_cookie *fscache; /* client index cache cookie */
  77. #endif
  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. unsigned long mount_time; /* when this fs was mounted */
  114. dev_t s_dev; /* superblock dev numbers */
  115. #ifdef CONFIG_NFS_FSCACHE
  116. struct nfs_fscache_key *fscache_key; /* unique key for superblock */
  117. struct fscache_cookie *fscache; /* superblock cookie */
  118. #endif
  119. #ifdef CONFIG_NFS_V4
  120. u32 attr_bitmask[2];/* 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. #endif
  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. /* maximum number of slots to use */
  157. #define NFS4_MAX_SLOT_TABLE RPC_MAX_SLOT_TABLE
  158. #if defined(CONFIG_NFS_V4_1)
  159. /* Sessions */
  160. #define SLOT_TABLE_SZ (NFS4_MAX_SLOT_TABLE/(8*sizeof(long)))
  161. struct nfs4_slot_table {
  162. struct nfs4_slot *slots; /* seqid per slot */
  163. unsigned long used_slots[SLOT_TABLE_SZ]; /* used/unused bitmap */
  164. spinlock_t slot_tbl_lock;
  165. struct rpc_wait_queue slot_tbl_waitq; /* allocators may wait here */
  166. int max_slots; /* # slots in table */
  167. int highest_used_slotid; /* sent to server on each SEQ.
  168. * op for dynamic resizing */
  169. };
  170. static inline int slot_idx(struct nfs4_slot_table *tbl, struct nfs4_slot *sp)
  171. {
  172. return sp - tbl->slots;
  173. }
  174. /*
  175. * Session related parameters
  176. */
  177. struct nfs4_session {
  178. struct nfs4_sessionid sess_id;
  179. u32 flags;
  180. unsigned long session_state;
  181. u32 hash_alg;
  182. u32 ssv_len;
  183. struct completion complete;
  184. /* The fore and back channel */
  185. struct nfs4_channel_attrs fc_attrs;
  186. struct nfs4_slot_table fc_slot_table;
  187. struct nfs4_channel_attrs bc_attrs;
  188. struct nfs4_slot_table bc_slot_table;
  189. struct nfs_client *clp;
  190. };
  191. #endif /* CONFIG_NFS_V4_1 */
  192. #endif