Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

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