9 #ifndef __LINUX_FS_NFS_NFS4_FS_H
10 #define __LINUX_FS_NFS_NFS4_FS_H
12 #if IS_ENABLED(CONFIG_NFS_V4)
16 enum nfs4_client_state {
17 NFS4CLNT_MANAGER_RUNNING = 0,
19 NFS4CLNT_LEASE_EXPIRED,
20 NFS4CLNT_RECLAIM_REBOOT,
21 NFS4CLNT_RECLAIM_NOGRACE,
23 NFS4CLNT_SESSION_RESET,
25 NFS4CLNT_LEASE_CONFIRM,
26 NFS4CLNT_SERVER_SCOPE_MISMATCH,
28 NFS4CLNT_BIND_CONN_TO_SESSION,
31 enum nfs4_session_state {
33 NFS4_SESSION_DRAINING,
36 #define NFS4_RENEW_TIMEOUT 0x01
37 #define NFS4_RENEW_DELEGATION_CB 0x02
39 struct nfs4_minor_version_ops {
52 const struct nfs4_state_recovery_ops *reboot_recovery_ops;
53 const struct nfs4_state_recovery_ops *nograce_recovery_ops;
54 const struct nfs4_state_maintenance_ops *state_renewal_ops;
57 #define NFS_SEQID_CONFIRMED 1
58 struct nfs_seqid_counter {
74 static inline void nfs_confirm_seqid(
struct nfs_seqid_counter *
seqid,
int status)
76 if (seqid_mutating_err(-status))
77 seqid->flags |= NFS_SEQID_CONFIRMED;
85 struct nfs4_state_owner {
88 unsigned long so_expires;
91 struct rpc_cred *so_cred;
95 unsigned long so_flags;
97 struct nfs_seqid_counter so_seqid;
101 NFS_OWNER_RECLAIM_REBOOT,
102 NFS_OWNER_RECLAIM_NOGRACE
105 #define NFS_LOCK_NEW 0
106 #define NFS_LOCK_RECLAIM 1
107 #define NFS_LOCK_EXPIRED 2
121 struct nfs4_lock_owner {
122 unsigned int lo_type;
123 #define NFS4_ANY_LOCK_TYPE (0U)
124 #define NFS4_FLOCK_LOCK_TYPE (1U << 0)
125 #define NFS4_POSIX_LOCK_TYPE (1U << 1)
134 struct nfs4_state * ls_state;
135 #define NFS_LOCK_INITIALIZED 0
136 unsigned long ls_flags;
137 struct nfs_seqid_counter ls_seqid;
140 struct nfs4_lock_owner ls_owner;
150 NFS_STATE_RECLAIM_REBOOT,
151 NFS_STATE_RECLAIM_NOGRACE,
152 NFS_STATE_POSIX_LOCKS,
160 struct nfs4_state_owner *
owner;
171 unsigned int n_rdonly;
172 unsigned int n_wronly;
179 struct nfs4_exception {
182 struct nfs4_state *
state;
186 struct nfs4_state_recovery_ops {
189 int (*recover_open)(
struct nfs4_state_owner *,
struct nfs4_state *);
190 int (*recover_lock)(
struct nfs4_state *,
struct file_lock *);
191 int (*establish_clid)(
struct nfs_client *,
struct rpc_cred *);
192 struct rpc_cred * (*get_clid_cred)(
struct nfs_client *);
198 struct nfs4_state_maintenance_ops {
199 int (*sched_state_renewal)(
struct nfs_client *,
struct rpc_cred *, unsigned);
200 struct rpc_cred * (*get_state_renewal_cred_locked)(
struct nfs_client *);
223 extern int nfs4_proc_bind_conn_to_session(
struct nfs_client *,
struct rpc_cred *
cred);
224 extern int nfs4_proc_exchange_id(
struct nfs_client *clp,
struct rpc_cred *
cred);
225 extern int nfs4_destroy_clientid(
struct nfs_client *clp);
227 extern int nfs41_init_clientid(
struct nfs_client *,
struct rpc_cred *);
231 struct nfs4_fs_locations *,
struct page *);
238 #if defined(CONFIG_NFS_V4_1)
239 static inline struct nfs4_session *nfs4_get_session(
const struct nfs_server *server)
245 extern int nfs4_setup_sequence(
const struct nfs_server *server,
248 extern int nfs41_setup_sequence(
struct nfs4_session *session,
251 extern void nfs4_destroy_session(
struct nfs4_session *session);
252 extern struct nfs4_session *nfs4_alloc_session(
struct nfs_client *clp);
253 extern int nfs4_proc_create_session(
struct nfs_client *,
struct rpc_cred *);
254 extern int nfs4_proc_destroy_session(
struct nfs4_session *,
struct rpc_cred *);
255 extern int nfs4_init_session(
struct nfs_server *server);
256 extern int nfs4_proc_get_lease_time(
struct nfs_client *clp,
274 static inline struct nfs4_session *nfs4_get_session(
const struct nfs_server *server)
279 static inline int nfs4_setup_sequence(
const struct nfs_server *server,
286 static inline int nfs4_init_session(
struct nfs_server *server)
318 extern void nfs4_renewd_prepare_shutdown(
struct nfs_server *);
329 #if defined(CONFIG_NFS_V4_1)
331 struct rpc_cred *nfs4_get_exchange_id_cred(
struct nfs_client *clp);
332 int nfs41_discover_server_trunking(
struct nfs_client *clp,
334 extern void nfs4_schedule_session_recovery(
struct nfs4_session *,
int);
336 static inline void nfs4_schedule_session_recovery(
struct nfs4_session *session,
int err)
356 extern void nfs41_handle_recall_slot(
struct nfs_client *clp);
357 extern void nfs41_handle_server_scope(
struct nfs_client *,
358 struct nfs41_server_scope **);
379 extern bool nfs4_disable_idmapping;
380 extern unsigned short max_session_slots;
381 extern unsigned short send_implementation_id;
383 #define NFS4_CLIENT_ID_UNIQ_LEN (64)
384 extern char nfs4_client_id_uniquifier[NFS4_CLIENT_ID_UNIQ_LEN];
412 memcpy(dst, src,
sizeof(*dst));
417 return memcmp(dst, src,
sizeof(*dst)) == 0;
422 #define nfs4_close_state(a, b) do { } while (0)
423 #define nfs4_close_sync(a, b) do { } while (0)