nfs_fs_sb.h 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212
  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. unsigned long cl_res_state; /* NFS resources state */
  24. #define NFS_CS_CALLBACK 1 /* - callback started */
  25. #define NFS_CS_IDMAP 2 /* - idmap started */
  26. #define NFS_CS_RENEWD 3 /* - renewd started */
  27. struct sockaddr_storage cl_addr; /* server identifier */
  28. size_t cl_addrlen;
  29. char * cl_hostname; /* hostname of server */
  30. struct list_head cl_share_link; /* link in global client list */
  31. struct list_head cl_superblocks; /* List of nfs_server structs */
  32. struct rpc_clnt * cl_rpcclient;
  33. const struct nfs_rpc_ops *rpc_ops; /* NFS protocol vector */
  34. int cl_proto; /* Network transport protocol */
  35. u32 cl_minorversion;/* NFSv4 minorversion */
  36. struct rpc_cred *cl_machine_cred;
  37. #ifdef CONFIG_NFS_V4
  38. u64 cl_clientid; /* constant */
  39. nfs4_verifier cl_confirm;
  40. unsigned long cl_state;
  41. struct rb_root cl_openowner_id;
  42. struct rb_root cl_lockowner_id;
  43. struct list_head cl_delegations;
  44. struct rb_root cl_state_owners;
  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. int (* cl_call_sync)(struct nfs_server *server,
  60. struct rpc_message *msg,
  61. struct nfs4_sequence_args *args,
  62. struct nfs4_sequence_res *res,
  63. int cache_reply);
  64. #endif /* CONFIG_NFS_V4 */
  65. #ifdef CONFIG_NFS_V4_1
  66. /* clientid returned from EXCHANGE_ID, used by session operations */
  67. u64 cl_ex_clid;
  68. /* The sequence id to use for the next CREATE_SESSION */
  69. u32 cl_seqid;
  70. /* The flags used for obtaining the clientid during EXCHANGE_ID */
  71. u32 cl_exchange_flags;
  72. struct nfs4_session *cl_session; /* sharred session */
  73. #endif /* CONFIG_NFS_V4_1 */
  74. #ifdef CONFIG_NFS_FSCACHE
  75. struct fscache_cookie *fscache; /* client index cache cookie */
  76. #endif
  77. };
  78. /*
  79. * NFS client parameters stored in the superblock.
  80. */
  81. struct nfs_server {
  82. struct nfs_client * nfs_client; /* shared client and NFS4 state */
  83. struct list_head client_link; /* List of other nfs_server structs
  84. * that share the same client
  85. */
  86. struct list_head master_link; /* link in master servers list */
  87. struct rpc_clnt * client; /* RPC client handle */
  88. struct rpc_clnt * client_acl; /* ACL RPC client handle */
  89. struct nlm_host *nlm_host; /* NLM client handle */
  90. struct nfs_iostats * io_stats; /* I/O statistics */
  91. struct backing_dev_info backing_dev_info;
  92. atomic_long_t writeback; /* number of writeback pages */
  93. int flags; /* various flags */
  94. unsigned int caps; /* server capabilities */
  95. unsigned int rsize; /* read size */
  96. unsigned int rpages; /* read size (in pages) */
  97. unsigned int wsize; /* write size */
  98. unsigned int wpages; /* write size (in pages) */
  99. unsigned int wtmult; /* server disk block size */
  100. unsigned int dtsize; /* readdir size */
  101. unsigned short port; /* "port=" setting */
  102. unsigned int bsize; /* server block size */
  103. unsigned int acregmin; /* attr cache timeouts */
  104. unsigned int acregmax;
  105. unsigned int acdirmin;
  106. unsigned int acdirmax;
  107. unsigned int namelen;
  108. unsigned int options; /* extra options enabled by mount */
  109. #define NFS_OPTION_FSCACHE 0x00000001 /* - local caching enabled */
  110. struct nfs_fsid fsid;
  111. __u64 maxfilesize; /* maximum file size */
  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. #ifdef CONFIG_NFS_V4
  119. u32 attr_bitmask[2];/* V4 bitmask representing the set
  120. of attributes supported on this
  121. filesystem */
  122. u32 cache_consistency_bitmask[2];
  123. /* V4 bitmask representing the subset
  124. of change attribute, size, ctime
  125. and mtime attributes supported by
  126. the server */
  127. u32 acl_bitmask; /* V4 bitmask representing the ACEs
  128. that are supported on this
  129. filesystem */
  130. #endif
  131. void (*destroy)(struct nfs_server *);
  132. atomic_t active; /* Keep trace of any activity to this server */
  133. /* mountd-related mount options */
  134. struct sockaddr_storage mountd_address;
  135. size_t mountd_addrlen;
  136. u32 mountd_version;
  137. unsigned short mountd_port;
  138. unsigned short mountd_protocol;
  139. };
  140. /* Server capabilities */
  141. #define NFS_CAP_READDIRPLUS (1U << 0)
  142. #define NFS_CAP_HARDLINKS (1U << 1)
  143. #define NFS_CAP_SYMLINKS (1U << 2)
  144. #define NFS_CAP_ACLS (1U << 3)
  145. #define NFS_CAP_ATOMIC_OPEN (1U << 4)
  146. /* maximum number of slots to use */
  147. #define NFS4_MAX_SLOT_TABLE RPC_MAX_SLOT_TABLE
  148. #if defined(CONFIG_NFS_V4_1)
  149. /* Sessions */
  150. #define SLOT_TABLE_SZ (NFS4_MAX_SLOT_TABLE/(8*sizeof(long)))
  151. struct nfs4_slot_table {
  152. struct nfs4_slot *slots; /* seqid per slot */
  153. unsigned long used_slots[SLOT_TABLE_SZ]; /* used/unused bitmap */
  154. spinlock_t slot_tbl_lock;
  155. struct rpc_wait_queue slot_tbl_waitq; /* allocators may wait here */
  156. int max_slots; /* # slots in table */
  157. int highest_used_slotid; /* sent to server on each SEQ.
  158. * op for dynamic resizing */
  159. };
  160. static inline int slot_idx(struct nfs4_slot_table *tbl, struct nfs4_slot *sp)
  161. {
  162. return sp - tbl->slots;
  163. }
  164. /*
  165. * Session related parameters
  166. */
  167. struct nfs4_session {
  168. struct nfs4_sessionid sess_id;
  169. u32 flags;
  170. unsigned long session_state;
  171. u32 hash_alg;
  172. u32 ssv_len;
  173. /* The fore and back channel */
  174. struct nfs4_channel_attrs fc_attrs;
  175. struct nfs4_slot_table fc_slot_table;
  176. struct nfs4_channel_attrs bc_attrs;
  177. /* back channel has one slot */
  178. struct nfs_client *clp;
  179. };
  180. #endif /* CONFIG_NFS_V4_1 */
  181. #endif