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. atomic_t count;
  168. wait_queue_head_t waitq;
  169. };
  170. struct nfs4_exception {
  171. struct nfs4_state *state;
  172. struct inode *inode;
  173. nfs4_stateid *stateid;
  174. long timeout;
  175. unsigned char delay : 1,
  176. recovering : 1,
  177. retry : 1;
  178. };
  179. struct nfs4_state_recovery_ops {
  180. int owner_flag_bit;
  181. int state_flag_bit;
  182. int (*recover_open)(struct nfs4_state_owner *, struct nfs4_state *);
  183. int (*recover_lock)(struct nfs4_state *, struct file_lock *);
  184. int (*establish_clid)(struct nfs_client *, struct rpc_cred *);
  185. int (*reclaim_complete)(struct nfs_client *, struct rpc_cred *);
  186. int (*detect_trunking)(struct nfs_client *, struct nfs_client **,
  187. struct rpc_cred *);
  188. };
  189. struct nfs4_opendata {
  190. struct kref kref;
  191. struct nfs_openargs o_arg;
  192. struct nfs_openres o_res;
  193. struct nfs_open_confirmargs c_arg;
  194. struct nfs_open_confirmres c_res;
  195. struct nfs4_string owner_name;
  196. struct nfs4_string group_name;
  197. struct nfs4_label *a_label;
  198. struct nfs_fattr f_attr;
  199. struct nfs4_label *f_label;
  200. struct dentry *dir;
  201. struct dentry *dentry;
  202. struct nfs4_state_owner *owner;
  203. struct nfs4_state *state;
  204. struct iattr attrs;
  205. struct nfs4_layoutget *lgp;
  206. unsigned long timestamp;
  207. bool rpc_done;
  208. bool file_created;
  209. bool is_recover;
  210. bool cancelled;
  211. int rpc_status;
  212. };
  213. struct nfs4_add_xprt_data {
  214. struct nfs_client *clp;
  215. struct rpc_cred *cred;
  216. };
  217. struct nfs4_state_maintenance_ops {
  218. int (*sched_state_renewal)(struct nfs_client *, struct rpc_cred *, unsigned);
  219. struct rpc_cred * (*get_state_renewal_cred_locked)(struct nfs_client *);
  220. int (*renew_lease)(struct nfs_client *, struct rpc_cred *);
  221. };
  222. struct nfs4_mig_recovery_ops {
  223. int (*get_locations)(struct inode *, struct nfs4_fs_locations *,
  224. struct page *, struct rpc_cred *);
  225. int (*fsid_present)(struct inode *, struct rpc_cred *);
  226. };
  227. extern const struct dentry_operations nfs4_dentry_operations;
  228. /* dir.c */
  229. int nfs_atomic_open(struct inode *, struct dentry *, struct file *,
  230. unsigned, umode_t);
  231. /* super.c */
  232. extern struct file_system_type nfs4_fs_type;
  233. /* nfs4namespace.c */
  234. struct rpc_clnt *nfs4_negotiate_security(struct rpc_clnt *, struct inode *,
  235. const struct qstr *);
  236. struct vfsmount *nfs4_submount(struct nfs_server *, struct dentry *,
  237. struct nfs_fh *, struct nfs_fattr *);
  238. int nfs4_replace_transport(struct nfs_server *server,
  239. const struct nfs4_fs_locations *locations);
  240. /* nfs4proc.c */
  241. extern int nfs4_handle_exception(struct nfs_server *, int, struct nfs4_exception *);
  242. extern int nfs4_async_handle_error(struct rpc_task *task,
  243. struct nfs_server *server,
  244. struct nfs4_state *state, long *timeout);
  245. extern int nfs4_call_sync(struct rpc_clnt *, struct nfs_server *,
  246. struct rpc_message *, struct nfs4_sequence_args *,
  247. struct nfs4_sequence_res *, int);
  248. extern void nfs4_init_sequence(struct nfs4_sequence_args *, struct nfs4_sequence_res *, int, int);
  249. extern int nfs4_proc_setclientid(struct nfs_client *, u32, unsigned short, struct rpc_cred *, struct nfs4_setclientid_res *);
  250. extern int nfs4_proc_setclientid_confirm(struct nfs_client *, struct nfs4_setclientid_res *arg, struct rpc_cred *);
  251. extern int nfs4_proc_get_rootfh(struct nfs_server *, struct nfs_fh *, struct nfs_fsinfo *, bool);
  252. extern int nfs4_proc_bind_conn_to_session(struct nfs_client *, struct rpc_cred *cred);
  253. extern int nfs4_proc_exchange_id(struct nfs_client *clp, struct rpc_cred *cred);
  254. extern int nfs4_destroy_clientid(struct nfs_client *clp);
  255. extern int nfs4_init_clientid(struct nfs_client *, struct rpc_cred *);
  256. extern int nfs41_init_clientid(struct nfs_client *, struct rpc_cred *);
  257. extern int nfs4_do_close(struct nfs4_state *state, gfp_t gfp_mask, int wait);
  258. extern int nfs4_server_capabilities(struct nfs_server *server, struct nfs_fh *fhandle);
  259. extern int nfs4_proc_fs_locations(struct rpc_clnt *, struct inode *, const struct qstr *,
  260. struct nfs4_fs_locations *, struct page *);
  261. extern int nfs4_proc_get_locations(struct inode *, struct nfs4_fs_locations *,
  262. struct page *page, struct rpc_cred *);
  263. extern int nfs4_proc_fsid_present(struct inode *, struct rpc_cred *);
  264. extern struct rpc_clnt *nfs4_proc_lookup_mountpoint(struct inode *, const struct qstr *,
  265. struct nfs_fh *, struct nfs_fattr *);
  266. extern int nfs4_proc_secinfo(struct inode *, const struct qstr *, struct nfs4_secinfo_flavors *);
  267. extern const struct xattr_handler *nfs4_xattr_handlers[];
  268. extern int nfs4_set_rw_stateid(nfs4_stateid *stateid,
  269. const struct nfs_open_context *ctx,
  270. const struct nfs_lock_context *l_ctx,
  271. fmode_t fmode);
  272. #if defined(CONFIG_NFS_V4_1)
  273. extern int nfs41_sequence_done(struct rpc_task *, struct nfs4_sequence_res *);
  274. extern int nfs4_proc_create_session(struct nfs_client *, struct rpc_cred *);
  275. extern int nfs4_proc_destroy_session(struct nfs4_session *, struct rpc_cred *);
  276. extern int nfs4_proc_get_lease_time(struct nfs_client *clp,
  277. struct nfs_fsinfo *fsinfo);
  278. extern int nfs4_proc_layoutcommit(struct nfs4_layoutcommit_data *data,
  279. bool sync);
  280. extern int nfs4_detect_session_trunking(struct nfs_client *clp,
  281. struct nfs41_exchange_id_res *res, struct rpc_xprt *xprt);
  282. static inline bool
  283. is_ds_only_client(struct nfs_client *clp)
  284. {
  285. return (clp->cl_exchange_flags & EXCHGID4_FLAG_MASK_PNFS) ==
  286. EXCHGID4_FLAG_USE_PNFS_DS;
  287. }
  288. static inline bool
  289. is_ds_client(struct nfs_client *clp)
  290. {
  291. return clp->cl_exchange_flags & EXCHGID4_FLAG_USE_PNFS_DS;
  292. }
  293. static inline bool
  294. _nfs4_state_protect(struct nfs_client *clp, unsigned long sp4_mode,
  295. struct rpc_clnt **clntp, struct rpc_message *msg)
  296. {
  297. struct rpc_cred *newcred = NULL;
  298. rpc_authflavor_t flavor;
  299. if (sp4_mode == NFS_SP4_MACH_CRED_CLEANUP ||
  300. sp4_mode == NFS_SP4_MACH_CRED_PNFS_CLEANUP) {
  301. /* Using machine creds for cleanup operations
  302. * is only relevent if the client credentials
  303. * might expire. So don't bother for
  304. * RPC_AUTH_UNIX. If file was only exported to
  305. * sec=sys, the PUTFH would fail anyway.
  306. */
  307. if ((*clntp)->cl_auth->au_flavor == RPC_AUTH_UNIX)
  308. return false;
  309. }
  310. if (test_bit(sp4_mode, &clp->cl_sp4_flags)) {
  311. spin_lock(&clp->cl_lock);
  312. if (clp->cl_machine_cred != NULL)
  313. /* don't call get_rpccred on the machine cred -
  314. * a reference will be held for life of clp */
  315. newcred = clp->cl_machine_cred;
  316. spin_unlock(&clp->cl_lock);
  317. msg->rpc_cred = newcred;
  318. flavor = clp->cl_rpcclient->cl_auth->au_flavor;
  319. WARN_ON_ONCE(flavor != RPC_AUTH_GSS_KRB5I &&
  320. flavor != RPC_AUTH_GSS_KRB5P);
  321. *clntp = clp->cl_rpcclient;
  322. return true;
  323. }
  324. return false;
  325. }
  326. /*
  327. * Function responsible for determining if an rpc_message should use the
  328. * machine cred under SP4_MACH_CRED and if so switching the credential and
  329. * authflavor (using the nfs_client's rpc_clnt which will be krb5i/p).
  330. * Should be called before rpc_call_sync/rpc_call_async.
  331. */
  332. static inline void
  333. nfs4_state_protect(struct nfs_client *clp, unsigned long sp4_mode,
  334. struct rpc_clnt **clntp, struct rpc_message *msg)
  335. {
  336. _nfs4_state_protect(clp, sp4_mode, clntp, msg);
  337. }
  338. /*
  339. * Special wrapper to nfs4_state_protect for write.
  340. * If WRITE can use machine cred but COMMIT cannot, make sure all writes
  341. * that use machine cred use NFS_FILE_SYNC.
  342. */
  343. static inline void
  344. nfs4_state_protect_write(struct nfs_client *clp, struct rpc_clnt **clntp,
  345. struct rpc_message *msg, struct nfs_pgio_header *hdr)
  346. {
  347. if (_nfs4_state_protect(clp, NFS_SP4_MACH_CRED_WRITE, clntp, msg) &&
  348. !test_bit(NFS_SP4_MACH_CRED_COMMIT, &clp->cl_sp4_flags))
  349. hdr->args.stable = NFS_FILE_SYNC;
  350. }
  351. #else /* CONFIG_NFS_v4_1 */
  352. static inline bool
  353. is_ds_only_client(struct nfs_client *clp)
  354. {
  355. return false;
  356. }
  357. static inline bool
  358. is_ds_client(struct nfs_client *clp)
  359. {
  360. return false;
  361. }
  362. static inline void
  363. nfs4_state_protect(struct nfs_client *clp, unsigned long sp4_flags,
  364. struct rpc_clnt **clntp, struct rpc_message *msg)
  365. {
  366. }
  367. static inline void
  368. nfs4_state_protect_write(struct nfs_client *clp, struct rpc_clnt **clntp,
  369. struct rpc_message *msg, struct nfs_pgio_header *hdr)
  370. {
  371. }
  372. #endif /* CONFIG_NFS_V4_1 */
  373. extern const struct nfs4_minor_version_ops *nfs_v4_minor_ops[];
  374. extern const u32 nfs4_fattr_bitmap[3];
  375. extern const u32 nfs4_statfs_bitmap[3];
  376. extern const u32 nfs4_pathconf_bitmap[3];
  377. extern const u32 nfs4_fsinfo_bitmap[3];
  378. extern const u32 nfs4_fs_locations_bitmap[3];
  379. void nfs40_shutdown_client(struct nfs_client *);
  380. void nfs41_shutdown_client(struct nfs_client *);
  381. int nfs40_init_client(struct nfs_client *);
  382. int nfs41_init_client(struct nfs_client *);
  383. void nfs4_free_client(struct nfs_client *);
  384. struct nfs_client *nfs4_alloc_client(const struct nfs_client_initdata *);
  385. /* nfs4renewd.c */
  386. extern void nfs4_schedule_state_renewal(struct nfs_client *);
  387. extern void nfs4_renewd_prepare_shutdown(struct nfs_server *);
  388. extern void nfs4_kill_renewd(struct nfs_client *);
  389. extern void nfs4_renew_state(struct work_struct *);
  390. extern void nfs4_set_lease_period(struct nfs_client *clp,
  391. unsigned long lease,
  392. unsigned long lastrenewed);
  393. /* nfs4state.c */
  394. struct rpc_cred *nfs4_get_clid_cred(struct nfs_client *clp);
  395. struct rpc_cred *nfs4_get_machine_cred_locked(struct nfs_client *clp);
  396. struct rpc_cred *nfs4_get_renew_cred_locked(struct nfs_client *clp);
  397. int nfs4_discover_server_trunking(struct nfs_client *clp,
  398. struct nfs_client **);
  399. int nfs40_discover_server_trunking(struct nfs_client *clp,
  400. struct nfs_client **, struct rpc_cred *);
  401. #if defined(CONFIG_NFS_V4_1)
  402. int nfs41_discover_server_trunking(struct nfs_client *clp,
  403. struct nfs_client **, struct rpc_cred *);
  404. extern void nfs4_schedule_session_recovery(struct nfs4_session *, int);
  405. extern void nfs41_notify_server(struct nfs_client *);
  406. #else
  407. static inline void nfs4_schedule_session_recovery(struct nfs4_session *session, int err)
  408. {
  409. }
  410. #endif /* CONFIG_NFS_V4_1 */
  411. extern struct nfs4_state_owner *nfs4_get_state_owner(struct nfs_server *, struct rpc_cred *, gfp_t);
  412. extern void nfs4_put_state_owner(struct nfs4_state_owner *);
  413. extern void nfs4_purge_state_owners(struct nfs_server *, struct list_head *);
  414. extern void nfs4_free_state_owners(struct list_head *head);
  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 */