nfs_fs_sb.h 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206
  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. struct nfs4_session *cl_session; /* sharred session */
  67. #endif /* CONFIG_NFS_V4_1 */
  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 * 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. 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. #endif
  125. void (*destroy)(struct nfs_server *);
  126. atomic_t active; /* Keep trace of any activity to this server */
  127. /* mountd-related mount options */
  128. struct sockaddr_storage mountd_address;
  129. size_t mountd_addrlen;
  130. u32 mountd_version;
  131. unsigned short mountd_port;
  132. unsigned short mountd_protocol;
  133. };
  134. /* Server capabilities */
  135. #define NFS_CAP_READDIRPLUS (1U << 0)
  136. #define NFS_CAP_HARDLINKS (1U << 1)
  137. #define NFS_CAP_SYMLINKS (1U << 2)
  138. #define NFS_CAP_ACLS (1U << 3)
  139. #define NFS_CAP_ATOMIC_OPEN (1U << 4)
  140. /* maximum number of slots to use */
  141. #define NFS4_MAX_SLOT_TABLE RPC_MAX_SLOT_TABLE
  142. #if defined(CONFIG_NFS_V4_1)
  143. /* Sessions */
  144. #define SLOT_TABLE_SZ (NFS4_MAX_SLOT_TABLE/(8*sizeof(long)))
  145. struct nfs4_slot_table {
  146. struct nfs4_slot *slots; /* seqid per slot */
  147. unsigned long used_slots[SLOT_TABLE_SZ]; /* used/unused bitmap */
  148. spinlock_t slot_tbl_lock;
  149. struct rpc_wait_queue slot_tbl_waitq; /* allocators may wait here */
  150. int max_slots; /* # slots in table */
  151. int highest_used_slotid; /* sent to server on each SEQ.
  152. * op for dynamic resizing */
  153. };
  154. static inline int slot_idx(struct nfs4_slot_table *tbl, struct nfs4_slot *sp)
  155. {
  156. return sp - tbl->slots;
  157. }
  158. /*
  159. * Session related parameters
  160. */
  161. struct nfs4_session {
  162. struct nfs4_sessionid sess_id;
  163. u32 flags;
  164. unsigned long session_state;
  165. u32 hash_alg;
  166. u32 ssv_len;
  167. /* The fore and back channel */
  168. struct nfs4_channel_attrs fc_attrs;
  169. struct nfs4_slot_table fc_slot_table;
  170. struct nfs4_channel_attrs bc_attrs;
  171. /* back channel has one slot */
  172. struct nfs_client *clp;
  173. };
  174. #endif /* CONFIG_NFS_V4_1 */
  175. #endif