nfs4_fs.h 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. /*
  3. * linux/fs/nfs/nfs4_fs.h
  4. *
  5. * Copyright (C) 2005 Trond Myklebust
  6. *
  7. * NFSv4-specific filesystem definitions and declarations
  8. */
  9. #ifndef __LINUX_FS_NFS_NFS4_FS_H
  10. #define __LINUX_FS_NFS_NFS4_FS_H
  11. #if defined(CONFIG_NFS_V4_2)
  12. #define NFS4_MAX_MINOR_VERSION 2
  13. #elif defined(CONFIG_NFS_V4_1)
  14. #define NFS4_MAX_MINOR_VERSION 1
  15. #else
  16. #define NFS4_MAX_MINOR_VERSION 0
  17. #endif
  18. #if IS_ENABLED(CONFIG_NFS_V4)
  19. #define NFS4_MAX_LOOP_ON_RECOVER (10)
  20. #include <linux/seqlock.h>
  21. struct idmap;
  22. enum nfs4_client_state {
  23. NFS4CLNT_MANAGER_RUNNING = 0,
  24. NFS4CLNT_CHECK_LEASE,
  25. NFS4CLNT_LEASE_EXPIRED,
  26. NFS4CLNT_RECLAIM_REBOOT,
  27. NFS4CLNT_RECLAIM_NOGRACE,
  28. NFS4CLNT_DELEGRETURN,
  29. NFS4CLNT_SESSION_RESET,
  30. NFS4CLNT_LEASE_CONFIRM,
  31. NFS4CLNT_SERVER_SCOPE_MISMATCH,
  32. NFS4CLNT_PURGE_STATE,
  33. NFS4CLNT_BIND_CONN_TO_SESSION,
  34. NFS4CLNT_MOVED,
  35. NFS4CLNT_LEASE_MOVED,
  36. NFS4CLNT_DELEGATION_EXPIRED,
  37. NFS4CLNT_RUN_MANAGER,
  38. NFS4CLNT_DELEGRETURN_RUNNING,
  39. };
  40. #define NFS4_RENEW_TIMEOUT 0x01
  41. #define NFS4_RENEW_DELEGATION_CB 0x02
  42. struct nfs_seqid_counter;
  43. struct nfs4_minor_version_ops {
  44. u32 minor_version;
  45. unsigned init_caps;
  46. int (*init_client)(struct nfs_client *);
  47. void (*shutdown_client)(struct nfs_client *);
  48. bool (*match_stateid)(const nfs4_stateid *,
  49. const nfs4_stateid *);
  50. int (*find_root_sec)(struct nfs_server *, struct nfs_fh *,
  51. struct nfs_fsinfo *);
  52. void (*free_lock_state)(struct nfs_server *,
  53. struct nfs4_lock_state *);
  54. int (*test_and_free_expired)(struct nfs_server *,
  55. nfs4_stateid *, struct rpc_cred *);
  56. struct nfs_seqid *
  57. (*alloc_seqid)(struct nfs_seqid_counter *, gfp_t);
  58. int (*session_trunk)(struct rpc_clnt *, struct rpc_xprt *, void *);
  59. const struct rpc_call_ops *call_sync_ops;
  60. const struct nfs4_state_recovery_ops *reboot_recovery_ops;
  61. const struct nfs4_state_recovery_ops *nograce_recovery_ops;
  62. const struct nfs4_state_maintenance_ops *state_renewal_ops;
  63. const struct nfs4_mig_recovery_ops *mig_recovery_ops;
  64. };
  65. #define NFS_SEQID_CONFIRMED 1
  66. struct nfs_seqid_counter {
  67. ktime_t create_time;
  68. int owner_id;
  69. int flags;
  70. u32 counter;
  71. spinlock_t lock; /* Protects the list */
  72. struct list_head list; /* Defines sequence of RPC calls */
  73. struct rpc_wait_queue wait; /* RPC call delay queue */
  74. };
  75. struct nfs_seqid {
  76. struct nfs_seqid_counter *sequence;
  77. struct list_head list;
  78. struct rpc_task *task;
  79. };
  80. static inline void nfs_confirm_seqid(struct nfs_seqid_counter *seqid, int status)
  81. {
  82. if (seqid_mutating_err(-status))
  83. seqid->flags |= NFS_SEQID_CONFIRMED;
  84. }
  85. /*
  86. * NFS4 state_owners and lock_owners are simply labels for ordered
  87. * sequences of RPC calls. Their sole purpose is to provide once-only
  88. * semantics by allowing the server to identify replayed requests.
  89. */
  90. struct nfs4_state_owner {
  91. struct nfs_server *so_server;
  92. struct list_head so_lru;
  93. unsigned long so_expires;
  94. struct rb_node so_server_node;
  95. struct rpc_cred *so_cred; /* Associated cred */
  96. spinlock_t so_lock;
  97. atomic_t so_count;
  98. unsigned long so_flags;
  99. struct list_head so_states;
  100. struct nfs_seqid_counter so_seqid;
  101. seqcount_t so_reclaim_seqcount;
  102. struct mutex so_delegreturn_mutex;
  103. };
  104. enum {
  105. NFS_OWNER_RECLAIM_REBOOT,
  106. NFS_OWNER_RECLAIM_NOGRACE
  107. };
  108. #define NFS_LOCK_NEW 0
  109. #define NFS_LOCK_RECLAIM 1
  110. #define NFS_LOCK_EXPIRED 2
  111. /*
  112. * struct nfs4_state maintains the client-side state for a given
  113. * (state_owner,inode) tuple (OPEN) or state_owner (LOCK).
  114. *
  115. * OPEN:
  116. * In order to know when to OPEN_DOWNGRADE or CLOSE the state on the server,
  117. * we need to know how many files are open for reading or writing on a
  118. * given inode. This information too is stored here.
  119. *
  120. * LOCK: one nfs4_state (LOCK) to hold the lock stateid nfs4_state(OPEN)
  121. */
  122. struct nfs4_lock_state {
  123. struct list_head ls_locks; /* Other lock stateids */
  124. struct nfs4_state * ls_state; /* Pointer to open state */
  125. #define NFS_LOCK_INITIALIZED 0
  126. #define NFS_LOCK_LOST 1
  127. unsigned long ls_flags;
  128. struct nfs_seqid_counter ls_seqid;
  129. nfs4_stateid ls_stateid;
  130. refcount_t ls_count;
  131. fl_owner_t ls_owner;
  132. };
  133. /* bits for nfs4_state->flags */
  134. enum {
  135. LK_STATE_IN_USE,
  136. NFS_DELEGATED_STATE, /* Current stateid is delegation */
  137. NFS_OPEN_STATE, /* OPEN stateid is set */
  138. NFS_O_RDONLY_STATE, /* OPEN stateid has read-only state */
  139. NFS_O_WRONLY_STATE, /* OPEN stateid has write-only state */
  140. NFS_O_RDWR_STATE, /* OPEN stateid has read/write state */
  141. NFS_STATE_RECLAIM_REBOOT, /* OPEN stateid server rebooted */
  142. NFS_STATE_RECLAIM_NOGRACE, /* OPEN stateid needs to recover state */
  143. NFS_STATE_POSIX_LOCKS, /* Posix locks are supported */
  144. NFS_STATE_RECOVERY_FAILED, /* OPEN stateid state recovery failed */
  145. NFS_STATE_MAY_NOTIFY_LOCK, /* server may CB_NOTIFY_LOCK */
  146. NFS_STATE_CHANGE_WAIT, /* A state changing operation is outstanding */
  147. #ifdef CONFIG_NFS_V4_2
  148. NFS_CLNT_DST_SSC_COPY_STATE, /* dst server open state on client*/
  149. #endif /* CONFIG_NFS_V4_2 */
  150. };
  151. struct nfs4_state {
  152. struct list_head open_states; /* List of states for the same state_owner */
  153. struct list_head inode_states; /* List of states for the same inode */
  154. struct list_head lock_states; /* List of subservient lock stateids */
  155. struct nfs4_state_owner *owner; /* Pointer to the open owner */
  156. struct inode *inode; /* Pointer to the inode */
  157. unsigned long flags; /* Do we hold any locks? */
  158. spinlock_t state_lock; /* Protects the lock_states list */
  159. seqlock_t seqlock; /* Protects the stateid/open_stateid */
  160. nfs4_stateid stateid; /* Current stateid: may be delegation */
  161. nfs4_stateid open_stateid; /* OPEN stateid */
  162. /* The following 3 fields are protected by owner->so_lock */
  163. unsigned int n_rdonly; /* Number of read-only references */
  164. unsigned int n_wronly; /* Number of write-only references */
  165. unsigned int n_rdwr; /* Number of read/write references */
  166. fmode_t state; /* State on the server (R,W, or RW) */
  167. refcount_t count;
  168. wait_queue_head_t waitq;
  169. struct rcu_head rcu_head;
  170. };
  171. struct nfs4_exception {
  172. struct nfs4_state *state;
  173. struct inode *inode;
  174. nfs4_stateid *stateid;
  175. long timeout;
  176. unsigned char delay : 1,
  177. recovering : 1,
  178. retry : 1;
  179. };
  180. struct nfs4_state_recovery_ops {
  181. int owner_flag_bit;
  182. int state_flag_bit;
  183. int (*recover_open)(struct nfs4_state_owner *, struct nfs4_state *);
  184. int (*recover_lock)(struct nfs4_state *, struct file_lock *);
  185. int (*establish_clid)(struct nfs_client *, struct rpc_cred *);
  186. int (*reclaim_complete)(struct nfs_client *, struct rpc_cred *);
  187. int (*detect_trunking)(struct nfs_client *, struct nfs_client **,
  188. struct rpc_cred *);
  189. };
  190. struct nfs4_opendata {
  191. struct kref kref;
  192. struct nfs_openargs o_arg;
  193. struct nfs_openres o_res;
  194. struct nfs_open_confirmargs c_arg;
  195. struct nfs_open_confirmres c_res;
  196. struct nfs4_string owner_name;
  197. struct nfs4_string group_name;
  198. struct nfs4_label *a_label;
  199. struct nfs_fattr f_attr;
  200. struct nfs4_label *f_label;
  201. struct dentry *dir;
  202. struct dentry *dentry;
  203. struct nfs4_state_owner *owner;
  204. struct nfs4_state *state;
  205. struct iattr attrs;
  206. struct nfs4_layoutget *lgp;
  207. unsigned long timestamp;
  208. bool rpc_done;
  209. bool file_created;
  210. bool is_recover;
  211. bool cancelled;
  212. int rpc_status;
  213. };
  214. struct nfs4_add_xprt_data {
  215. struct nfs_client *clp;
  216. struct rpc_cred *cred;
  217. };
  218. struct nfs4_state_maintenance_ops {
  219. int (*sched_state_renewal)(struct nfs_client *, struct rpc_cred *, unsigned);
  220. struct rpc_cred * (*get_state_renewal_cred_locked)(struct nfs_client *);
  221. int (*renew_lease)(struct nfs_client *, struct rpc_cred *);
  222. };
  223. struct nfs4_mig_recovery_ops {
  224. int (*get_locations)(struct inode *, struct nfs4_fs_locations *,
  225. struct page *, struct rpc_cred *);
  226. int (*fsid_present)(struct inode *, struct rpc_cred *);
  227. };
  228. extern const struct dentry_operations nfs4_dentry_operations;
  229. /* dir.c */
  230. int nfs_atomic_open(struct inode *, struct dentry *, struct file *,
  231. unsigned, umode_t);
  232. /* super.c */
  233. extern struct file_system_type nfs4_fs_type;
  234. /* nfs4namespace.c */
  235. struct rpc_clnt *nfs4_negotiate_security(struct rpc_clnt *, struct inode *,
  236. const struct qstr *);
  237. struct vfsmount *nfs4_submount(struct nfs_server *, struct dentry *,
  238. struct nfs_fh *, struct nfs_fattr *);
  239. int nfs4_replace_transport(struct nfs_server *server,
  240. const struct nfs4_fs_locations *locations);
  241. /* nfs4proc.c */
  242. extern int nfs4_handle_exception(struct nfs_server *, int, struct nfs4_exception *);
  243. extern int nfs4_async_handle_error(struct rpc_task *task,
  244. struct nfs_server *server,
  245. struct nfs4_state *state, long *timeout);
  246. extern int nfs4_call_sync(struct rpc_clnt *, struct nfs_server *,
  247. struct rpc_message *, struct nfs4_sequence_args *,
  248. struct nfs4_sequence_res *, int);
  249. extern void nfs4_init_sequence(struct nfs4_sequence_args *, struct nfs4_sequence_res *, int, int);
  250. extern int nfs4_proc_setclientid(struct nfs_client *, u32, unsigned short, struct rpc_cred *, struct nfs4_setclientid_res *);
  251. extern int nfs4_proc_setclientid_confirm(struct nfs_client *, struct nfs4_setclientid_res *arg, struct rpc_cred *);
  252. extern int nfs4_proc_get_rootfh(struct nfs_server *, struct nfs_fh *, struct nfs_fsinfo *, bool);
  253. extern int nfs4_proc_bind_conn_to_session(struct nfs_client *, struct rpc_cred *cred);
  254. extern int nfs4_proc_exchange_id(struct nfs_client *clp, struct rpc_cred *cred);
  255. extern int nfs4_destroy_clientid(struct nfs_client *clp);
  256. extern int nfs4_init_clientid(struct nfs_client *, struct rpc_cred *);
  257. extern int nfs41_init_clientid(struct nfs_client *, struct rpc_cred *);
  258. extern int nfs4_do_close(struct nfs4_state *state, gfp_t gfp_mask, int wait);
  259. extern int nfs4_server_capabilities(struct nfs_server *server, struct nfs_fh *fhandle);
  260. extern int nfs4_proc_fs_locations(struct rpc_clnt *, struct inode *, const struct qstr *,
  261. struct nfs4_fs_locations *, struct page *);
  262. extern int nfs4_proc_get_locations(struct inode *, struct nfs4_fs_locations *,
  263. struct page *page, struct rpc_cred *);
  264. extern int nfs4_proc_fsid_present(struct inode *, struct rpc_cred *);
  265. extern struct rpc_clnt *nfs4_proc_lookup_mountpoint(struct inode *, const struct qstr *,
  266. struct nfs_fh *, struct nfs_fattr *);
  267. extern int nfs4_proc_secinfo(struct inode *, const struct qstr *, struct nfs4_secinfo_flavors *);
  268. extern const struct xattr_handler *nfs4_xattr_handlers[];
  269. extern int nfs4_set_rw_stateid(nfs4_stateid *stateid,
  270. const struct nfs_open_context *ctx,
  271. const struct nfs_lock_context *l_ctx,
  272. fmode_t fmode);
  273. #if defined(CONFIG_NFS_V4_1)
  274. extern int nfs41_sequence_done(struct rpc_task *, struct nfs4_sequence_res *);
  275. extern int nfs4_proc_create_session(struct nfs_client *, struct rpc_cred *);
  276. extern int nfs4_proc_destroy_session(struct nfs4_session *, struct rpc_cred *);
  277. extern int nfs4_proc_get_lease_time(struct nfs_client *clp,
  278. struct nfs_fsinfo *fsinfo);
  279. extern int nfs4_proc_layoutcommit(struct nfs4_layoutcommit_data *data,
  280. bool sync);
  281. extern int nfs4_detect_session_trunking(struct nfs_client *clp,
  282. struct nfs41_exchange_id_res *res, struct rpc_xprt *xprt);
  283. static inline bool
  284. is_ds_only_client(struct nfs_client *clp)
  285. {
  286. return (clp->cl_exchange_flags & EXCHGID4_FLAG_MASK_PNFS) ==
  287. EXCHGID4_FLAG_USE_PNFS_DS;
  288. }
  289. static inline bool
  290. is_ds_client(struct nfs_client *clp)
  291. {
  292. return clp->cl_exchange_flags & EXCHGID4_FLAG_USE_PNFS_DS;
  293. }
  294. static inline bool
  295. _nfs4_state_protect(struct nfs_client *clp, unsigned long sp4_mode,
  296. struct rpc_clnt **clntp, struct rpc_message *msg)
  297. {
  298. struct rpc_cred *newcred = NULL;
  299. rpc_authflavor_t flavor;
  300. if (sp4_mode == NFS_SP4_MACH_CRED_CLEANUP ||
  301. sp4_mode == NFS_SP4_MACH_CRED_PNFS_CLEANUP) {
  302. /* Using machine creds for cleanup operations
  303. * is only relevent if the client credentials
  304. * might expire. So don't bother for
  305. * RPC_AUTH_UNIX. If file was only exported to
  306. * sec=sys, the PUTFH would fail anyway.
  307. */
  308. if ((*clntp)->cl_auth->au_flavor == RPC_AUTH_UNIX)
  309. return false;
  310. }
  311. if (test_bit(sp4_mode, &clp->cl_sp4_flags)) {
  312. spin_lock(&clp->cl_lock);
  313. if (clp->cl_machine_cred != NULL)
  314. /* don't call get_rpccred on the machine cred -
  315. * a reference will be held for life of clp */
  316. newcred = clp->cl_machine_cred;
  317. spin_unlock(&clp->cl_lock);
  318. msg->rpc_cred = newcred;
  319. flavor = clp->cl_rpcclient->cl_auth->au_flavor;
  320. WARN_ON_ONCE(flavor != RPC_AUTH_GSS_KRB5I &&
  321. flavor != RPC_AUTH_GSS_KRB5P);
  322. *clntp = clp->cl_rpcclient;
  323. return true;
  324. }
  325. return false;
  326. }
  327. /*
  328. * Function responsible for determining if an rpc_message should use the
  329. * machine cred under SP4_MACH_CRED and if so switching the credential and
  330. * authflavor (using the nfs_client's rpc_clnt which will be krb5i/p).
  331. * Should be called before rpc_call_sync/rpc_call_async.
  332. */
  333. static inline void
  334. nfs4_state_protect(struct nfs_client *clp, unsigned long sp4_mode,
  335. struct rpc_clnt **clntp, struct rpc_message *msg)
  336. {
  337. _nfs4_state_protect(clp, sp4_mode, clntp, msg);
  338. }
  339. /*
  340. * Special wrapper to nfs4_state_protect for write.
  341. * If WRITE can use machine cred but COMMIT cannot, make sure all writes
  342. * that use machine cred use NFS_FILE_SYNC.
  343. */
  344. static inline void
  345. nfs4_state_protect_write(struct nfs_client *clp, struct rpc_clnt **clntp,
  346. struct rpc_message *msg, struct nfs_pgio_header *hdr)
  347. {
  348. if (_nfs4_state_protect(clp, NFS_SP4_MACH_CRED_WRITE, clntp, msg) &&
  349. !test_bit(NFS_SP4_MACH_CRED_COMMIT, &clp->cl_sp4_flags))
  350. hdr->args.stable = NFS_FILE_SYNC;
  351. }
  352. #else /* CONFIG_NFS_v4_1 */
  353. static inline bool
  354. is_ds_only_client(struct nfs_client *clp)
  355. {
  356. return false;
  357. }
  358. static inline bool
  359. is_ds_client(struct nfs_client *clp)
  360. {
  361. return false;
  362. }
  363. static inline void
  364. nfs4_state_protect(struct nfs_client *clp, unsigned long sp4_flags,
  365. struct rpc_clnt **clntp, struct rpc_message *msg)
  366. {
  367. }
  368. static inline void
  369. nfs4_state_protect_write(struct nfs_client *clp, struct rpc_clnt **clntp,
  370. struct rpc_message *msg, struct nfs_pgio_header *hdr)
  371. {
  372. }
  373. #endif /* CONFIG_NFS_V4_1 */
  374. extern const struct nfs4_minor_version_ops *nfs_v4_minor_ops[];
  375. extern const u32 nfs4_fattr_bitmap[3];
  376. extern const u32 nfs4_statfs_bitmap[3];
  377. extern const u32 nfs4_pathconf_bitmap[3];
  378. extern const u32 nfs4_fsinfo_bitmap[3];
  379. extern const u32 nfs4_fs_locations_bitmap[3];
  380. void nfs40_shutdown_client(struct nfs_client *);
  381. void nfs41_shutdown_client(struct nfs_client *);
  382. int nfs40_init_client(struct nfs_client *);
  383. int nfs41_init_client(struct nfs_client *);
  384. void nfs4_free_client(struct nfs_client *);
  385. struct nfs_client *nfs4_alloc_client(const struct nfs_client_initdata *);
  386. /* nfs4renewd.c */
  387. extern void nfs4_schedule_state_renewal(struct nfs_client *);
  388. extern void nfs4_renewd_prepare_shutdown(struct nfs_server *);
  389. extern void nfs4_kill_renewd(struct nfs_client *);
  390. extern void nfs4_renew_state(struct work_struct *);
  391. extern void nfs4_set_lease_period(struct nfs_client *clp,
  392. unsigned long lease,
  393. unsigned long lastrenewed);
  394. /* nfs4state.c */
  395. struct rpc_cred *nfs4_get_clid_cred(struct nfs_client *clp);
  396. struct rpc_cred *nfs4_get_machine_cred_locked(struct nfs_client *clp);
  397. struct rpc_cred *nfs4_get_renew_cred_locked(struct nfs_client *clp);
  398. int nfs4_discover_server_trunking(struct nfs_client *clp,
  399. struct nfs_client **);
  400. int nfs40_discover_server_trunking(struct nfs_client *clp,
  401. struct nfs_client **, struct rpc_cred *);
  402. #if defined(CONFIG_NFS_V4_1)
  403. int nfs41_discover_server_trunking(struct nfs_client *clp,
  404. struct nfs_client **, struct rpc_cred *);
  405. extern void nfs4_schedule_session_recovery(struct nfs4_session *, int);
  406. extern void nfs41_notify_server(struct nfs_client *);
  407. #else
  408. static inline void nfs4_schedule_session_recovery(struct nfs4_session *session, int err)
  409. {
  410. }
  411. #endif /* CONFIG_NFS_V4_1 */
  412. extern struct nfs4_state_owner *nfs4_get_state_owner(struct nfs_server *, struct rpc_cred *, gfp_t);
  413. extern void nfs4_put_state_owner(struct nfs4_state_owner *);
  414. extern void nfs4_purge_state_owners(struct nfs_server *);
  415. extern struct nfs4_state * nfs4_get_open_state(struct inode *, struct nfs4_state_owner *);
  416. extern void nfs4_put_open_state(struct nfs4_state *);
  417. extern void nfs4_close_state(struct nfs4_state *, fmode_t);
  418. extern void nfs4_close_sync(struct nfs4_state *, fmode_t);
  419. extern void nfs4_state_set_mode_locked(struct nfs4_state *, fmode_t);
  420. extern void nfs_inode_find_state_and_recover(struct inode *inode,
  421. const nfs4_stateid *stateid);
  422. extern int nfs4_state_mark_reclaim_nograce(struct nfs_client *, struct nfs4_state *);
  423. extern void nfs4_schedule_lease_recovery(struct nfs_client *);
  424. extern int nfs4_wait_clnt_recover(struct nfs_client *clp);
  425. extern int nfs4_client_recover_expired_lease(struct nfs_client *clp);
  426. extern void nfs4_schedule_state_manager(struct nfs_client *);
  427. extern void nfs4_schedule_path_down_recovery(struct nfs_client *clp);
  428. extern int nfs4_schedule_stateid_recovery(const struct nfs_server *, struct nfs4_state *);
  429. extern int nfs4_schedule_migration_recovery(const struct nfs_server *);
  430. extern void nfs4_schedule_lease_moved_recovery(struct nfs_client *);
  431. extern void nfs41_handle_sequence_flag_errors(struct nfs_client *clp, u32 flags, bool);
  432. extern void nfs41_handle_server_scope(struct nfs_client *,
  433. struct nfs41_server_scope **);
  434. extern void nfs4_put_lock_state(struct nfs4_lock_state *lsp);
  435. extern int nfs4_set_lock_state(struct nfs4_state *state, struct file_lock *fl);
  436. extern int nfs4_select_rw_stateid(struct nfs4_state *, fmode_t,
  437. const struct nfs_lock_context *, nfs4_stateid *,
  438. struct rpc_cred **);
  439. extern bool nfs4_refresh_open_stateid(nfs4_stateid *dst,
  440. struct nfs4_state *state);
  441. extern bool nfs4_copy_open_stateid(nfs4_stateid *dst,
  442. struct nfs4_state *state);
  443. extern struct nfs_seqid *nfs_alloc_seqid(struct nfs_seqid_counter *counter, gfp_t gfp_mask);
  444. extern int nfs_wait_on_sequence(struct nfs_seqid *seqid, struct rpc_task *task);
  445. extern void nfs_increment_open_seqid(int status, struct nfs_seqid *seqid);
  446. extern void nfs_increment_lock_seqid(int status, struct nfs_seqid *seqid);
  447. extern void nfs_release_seqid(struct nfs_seqid *seqid);
  448. extern void nfs_free_seqid(struct nfs_seqid *seqid);
  449. extern int nfs4_setup_sequence(struct nfs_client *client,
  450. struct nfs4_sequence_args *args,
  451. struct nfs4_sequence_res *res,
  452. struct rpc_task *task);
  453. extern int nfs4_sequence_done(struct rpc_task *task,
  454. struct nfs4_sequence_res *res);
  455. extern void nfs4_free_lock_state(struct nfs_server *server, struct nfs4_lock_state *lsp);
  456. extern int nfs4_proc_commit(struct file *dst, __u64 offset, __u32 count, struct nfs_commitres *res);
  457. extern const nfs4_stateid zero_stateid;
  458. extern const nfs4_stateid invalid_stateid;
  459. /* nfs4super.c */
  460. struct nfs_mount_info;
  461. extern struct nfs_subversion nfs_v4;
  462. struct dentry *nfs4_try_mount(int, const char *, struct nfs_mount_info *, struct nfs_subversion *);
  463. extern bool nfs4_disable_idmapping;
  464. extern unsigned short max_session_slots;
  465. extern unsigned short max_session_cb_slots;
  466. extern unsigned short send_implementation_id;
  467. extern bool recover_lost_locks;
  468. #define NFS4_CLIENT_ID_UNIQ_LEN (64)
  469. extern char nfs4_client_id_uniquifier[NFS4_CLIENT_ID_UNIQ_LEN];
  470. /* nfs4sysctl.c */
  471. #ifdef CONFIG_SYSCTL
  472. int nfs4_register_sysctl(void);
  473. void nfs4_unregister_sysctl(void);
  474. #else
  475. static inline int nfs4_register_sysctl(void)
  476. {
  477. return 0;
  478. }
  479. static inline void nfs4_unregister_sysctl(void)
  480. {
  481. }
  482. #endif
  483. /* nfs4xdr.c */
  484. extern const struct rpc_procinfo nfs4_procedures[];
  485. struct nfs4_mount_data;
  486. /* callback_xdr.c */
  487. extern const struct svc_version nfs4_callback_version1;
  488. extern const struct svc_version nfs4_callback_version4;
  489. static inline void nfs4_stateid_copy(nfs4_stateid *dst, const nfs4_stateid *src)
  490. {
  491. memcpy(dst->data, src->data, sizeof(dst->data));
  492. dst->type = src->type;
  493. }
  494. static inline bool nfs4_stateid_match(const nfs4_stateid *dst, const nfs4_stateid *src)
  495. {
  496. if (dst->type != src->type)
  497. return false;
  498. return memcmp(dst->data, src->data, sizeof(dst->data)) == 0;
  499. }
  500. static inline bool nfs4_stateid_match_other(const nfs4_stateid *dst, const nfs4_stateid *src)
  501. {
  502. return memcmp(dst->other, src->other, NFS4_STATEID_OTHER_SIZE) == 0;
  503. }
  504. static inline bool nfs4_stateid_is_newer(const nfs4_stateid *s1, const nfs4_stateid *s2)
  505. {
  506. return (s32)(be32_to_cpu(s1->seqid) - be32_to_cpu(s2->seqid)) > 0;
  507. }
  508. static inline bool nfs4_valid_open_stateid(const struct nfs4_state *state)
  509. {
  510. return test_bit(NFS_STATE_RECOVERY_FAILED, &state->flags) == 0;
  511. }
  512. static inline bool nfs4_state_match_open_stateid_other(const struct nfs4_state *state,
  513. const nfs4_stateid *stateid)
  514. {
  515. return test_bit(NFS_OPEN_STATE, &state->flags) &&
  516. nfs4_stateid_match_other(&state->open_stateid, stateid);
  517. }
  518. #else
  519. #define nfs4_close_state(a, b) do { } while (0)
  520. #define nfs4_close_sync(a, b) do { } while (0)
  521. #define nfs4_state_protect(a, b, c, d) do { } while (0)
  522. #define nfs4_state_protect_write(a, b, c, d) do { } while (0)
  523. #endif /* CONFIG_NFS_V4 */
  524. #endif /* __LINUX_FS_NFS_NFS4_FS.H */