Blame view

fs/nfs/nfs4_fs.h 22.5 KB
b24413180   Greg Kroah-Hartman   License cleanup: ...
1
  /* SPDX-License-Identifier: GPL-2.0 */
4ce79717c   Trond Myklebust   [PATCH] NFS: Head...
2
3
4
5
6
7
8
9
10
11
  /*
   * linux/fs/nfs/nfs4_fs.h
   *
   * Copyright (C) 2005 Trond Myklebust
   *
   * NFSv4-specific filesystem definitions and declarations
   */
  
  #ifndef __LINUX_FS_NFS_NFS4_FS_H
  #define __LINUX_FS_NFS_NFS4_FS_H
694e096fd   Anna Schumaker   NFS: Enabling v4....
12
13
14
15
16
17
18
  #if defined(CONFIG_NFS_V4_2)
  #define NFS4_MAX_MINOR_VERSION 2
  #elif defined(CONFIG_NFS_V4_1)
  #define NFS4_MAX_MINOR_VERSION 1
  #else
  #define NFS4_MAX_MINOR_VERSION 0
  #endif
89d77c8fa   Bryan Schumaker   NFS: Convert v4 i...
19
  #if IS_ENABLED(CONFIG_NFS_V4)
4ce79717c   Trond Myklebust   [PATCH] NFS: Head...
20

330212796   Trond Myklebust   NFSv4: Move nfs4_...
21
  #define NFS4_MAX_LOOP_ON_RECOVER (10)
c137afabe   Trond Myklebust   NFSv4: Allow the ...
22
  #include <linux/seqlock.h>
4ce79717c   Trond Myklebust   [PATCH] NFS: Head...
23
  struct idmap;
4ce79717c   Trond Myklebust   [PATCH] NFS: Head...
24
  enum nfs4_client_state {
e005e8041   Trond Myklebust   NFSv4: Rename the...
25
  	NFS4CLNT_MANAGER_RUNNING  = 0,
e598d843c   Trond Myklebust   NFSv4: Remove red...
26
  	NFS4CLNT_CHECK_LEASE,
58d9714a4   Trond Myklebust   NFSv4: Send RENEW...
27
  	NFS4CLNT_LEASE_EXPIRED,
b79a4a1b4   Trond Myklebust   NFSv4: Fix state ...
28
29
  	NFS4CLNT_RECLAIM_REBOOT,
  	NFS4CLNT_RECLAIM_NOGRACE,
707fb4b32   Trond Myklebust   NFSv4: Clean up N...
30
  	NFS4CLNT_DELEGRETURN,
6df08189f   Andy Adamson   nfs41: rename cl_...
31
  	NFS4CLNT_SESSION_RESET,
fd954ae12   Trond Myklebust   NFSv4.1: Don't lo...
32
  	NFS4CLNT_LEASE_CONFIRM,
78fe0f41d   Weston Andros Adamson   NFS: use scope fr...
33
  	NFS4CLNT_SERVER_SCOPE_MISMATCH,
2c820d9a9   Chuck Lever   NFS: Force server...
34
  	NFS4CLNT_PURGE_STATE,
a9e64442f   Weston Andros Adamson   nfs41: Use BIND_C...
35
  	NFS4CLNT_BIND_CONN_TO_SESSION,
c9fdeb280   Chuck Lever   NFS: Add basic mi...
36
  	NFS4CLNT_MOVED,
b7f7a66e4   Chuck Lever   NFS: Support NFS4...
37
  	NFS4CLNT_LEASE_MOVED,
45870d690   Trond Myklebust   NFSv4.1: Test del...
38
  	NFS4CLNT_DELEGATION_EXPIRED,
aeabb3c96   Trond Myklebust   NFSv4: Fix a NFSv...
39
  	NFS4CLNT_RUN_MANAGER,
b5fdf8418   Trond Myklebust   NFSv4: Add suppor...
40
41
42
  	NFS4CLNT_RECALL_RUNNING,
  	NFS4CLNT_RECALL_ANY_LAYOUT_READ,
  	NFS4CLNT_RECALL_ANY_LAYOUT_RW,
4ce79717c   Trond Myklebust   [PATCH] NFS: Head...
43
  };
2f60ea6b8   Trond Myklebust   NFSv4: The NFSv4....
44
45
  #define NFS4_RENEW_TIMEOUT		0x01
  #define NFS4_RENEW_DELEGATION_CB	0x02
63f5f796a   Trond Myklebust   NFSv4.1: Allow pa...
46
  struct nfs_seqid_counter;
97dc13594   Trond Myklebust   NFSv41: Clean up ...
47
48
  struct nfs4_minor_version_ops {
  	u32	minor_version;
39c6daae7   Trond Myklebust   NFSv4: Prepare fo...
49
  	unsigned init_caps;
97dc13594   Trond Myklebust   NFSv41: Clean up ...
50

abf79bb34   Chuck Lever   NFS: Add a slot t...
51
52
  	int	(*init_client)(struct nfs_client *);
  	void	(*shutdown_client)(struct nfs_client *);
36281caa8   Trond Myklebust   NFSv4: Further cl...
53
  	bool	(*match_stateid)(const nfs4_stateid *,
e047a10c1   Trond Myklebust   NFSv41: Fix nfs_a...
54
  			const nfs4_stateid *);
fca78d6d2   Bryan Schumaker   NFS: Add SECINFO_...
55
56
  	int	(*find_root_sec)(struct nfs_server *, struct nfs_fh *,
  			struct nfs_fsinfo *);
f1cdae87f   Jeff Layton   nfs4: turn free_l...
57
  	void	(*free_lock_state)(struct nfs_server *,
c8b2d0bfd   Trond Myklebust   NFSv4.1: Ensure t...
58
  			struct nfs4_lock_state *);
45870d690   Trond Myklebust   NFSv4.1: Test del...
59
  	int	(*test_and_free_expired)(struct nfs_server *,
a52458b48   NeilBrown   NFS/NFSD/SUNRPC: ...
60
  			nfs4_stateid *, const struct cred *);
63f5f796a   Trond Myklebust   NFSv4.1: Allow pa...
61
62
  	struct nfs_seqid *
  		(*alloc_seqid)(struct nfs_seqid_counter *, gfp_t);
10e037d1e   Santosh kumar pradhan   sunrpc: Add xprt ...
63
64
  	void	(*session_trunk)(struct rpc_clnt *clnt,
  			struct rpc_xprt *xprt, void *data);
9915ea7e0   Chuck Lever   NFS: Add RPC call...
65
  	const struct rpc_call_ops *call_sync_ops;
c48f4f354   Trond Myklebust   NFSv41: Convert t...
66
67
68
  	const struct nfs4_state_recovery_ops *reboot_recovery_ops;
  	const struct nfs4_state_recovery_ops *nograce_recovery_ops;
  	const struct nfs4_state_maintenance_ops *state_renewal_ops;
ec011fe84   Chuck Lever   NFS: Introduce a ...
69
  	const struct nfs4_mig_recovery_ops *mig_recovery_ops;
97dc13594   Trond Myklebust   NFSv41: Clean up ...
70
  };
cee54fc94   Trond Myklebust   NFSv4: Add functi...
71
72
  #define NFS_SEQID_CONFIRMED 1
  struct nfs_seqid_counter {
95b72eb0b   Trond Myklebust   NFSv4: Ensure we ...
73
  	ktime_t create_time;
48c22eb21   Trond Myklebust   NFS: Move struct ...
74
  	int owner_id;
cee54fc94   Trond Myklebust   NFSv4: Add functi...
75
76
  	int flags;
  	u32 counter;
7ba127ab9   Trond Myklebust   NFSv4: Move conte...
77
78
79
  	spinlock_t lock;		/* Protects the list */
  	struct list_head list;		/* Defines sequence of RPC calls */
  	struct rpc_wait_queue	wait;	/* RPC call delay queue */
cee54fc94   Trond Myklebust   NFSv4: Add functi...
80
81
82
  };
  
  struct nfs_seqid {
cee54fc94   Trond Myklebust   NFSv4: Add functi...
83
  	struct nfs_seqid_counter *sequence;
4e51336a0   Trond Myklebust   NFSv4: Final twea...
84
  	struct list_head list;
4601df20f   Trond Myklebust   NFSv4: Avoid thun...
85
  	struct rpc_task *task;
cee54fc94   Trond Myklebust   NFSv4: Add functi...
86
87
88
89
90
91
92
93
94
  };
  
  static inline void nfs_confirm_seqid(struct nfs_seqid_counter *seqid, int status)
  {
  	if (seqid_mutating_err(-status))
  		seqid->flags |= NFS_SEQID_CONFIRMED;
  }
  
  /*
4ce79717c   Trond Myklebust   [PATCH] NFS: Head...
95
96
97
   * NFS4 state_owners and lock_owners are simply labels for ordered
   * sequences of RPC calls. Their sole purpose is to provide once-only
   * semantics by allowing the server to identify replayed requests.
4ce79717c   Trond Myklebust   [PATCH] NFS: Head...
98
99
   */
  struct nfs4_state_owner {
6f2e64d3e   Trond Myklebust   NFSv4: Make the N...
100
  	struct nfs_server    *so_server;
0aaaf5c42   Chuck Lever   NFS: Cache state ...
101
102
  	struct list_head     so_lru;
  	unsigned long        so_expires;
24d292b89   Chuck Lever   NFS: Move cl_stat...
103
  	struct rb_node	     so_server_node;
4ce79717c   Trond Myklebust   [PATCH] NFS: Head...
104

a52458b48   NeilBrown   NFS/NFSD/SUNRPC: ...
105
  	const struct cred    *so_cred;	 /* Associated cred */
9f958ab88   Trond Myklebust   NFSv4: Reduce the...
106
107
108
  
  	spinlock_t	     so_lock;
  	atomic_t	     so_count;
7eff03aec   Trond Myklebust   NFSv4: Add a reco...
109
  	unsigned long	     so_flags;
4ce79717c   Trond Myklebust   [PATCH] NFS: Head...
110
  	struct list_head     so_states;
cee54fc94   Trond Myklebust   NFSv4: Add functi...
111
  	struct nfs_seqid_counter so_seqid;
76246c921   Ahmed S. Darwish   NFSv4: Use sequen...
112
  	seqcount_spinlock_t  so_reclaim_seqcount;
65b62a29f   Trond Myklebust   NFSv4: Ensure del...
113
  	struct mutex	     so_delegreturn_mutex;
4ce79717c   Trond Myklebust   [PATCH] NFS: Head...
114
  };
7eff03aec   Trond Myklebust   NFSv4: Add a reco...
115
116
117
118
  enum {
  	NFS_OWNER_RECLAIM_REBOOT,
  	NFS_OWNER_RECLAIM_NOGRACE
  };
afe6c27cc   Alexandros Batsakis   nfs: change nfs4_...
119
120
121
  #define NFS_LOCK_NEW		0
  #define NFS_LOCK_RECLAIM	1
  #define NFS_LOCK_EXPIRED	2
4ce79717c   Trond Myklebust   [PATCH] NFS: Head...
122
123
124
125
126
127
128
129
130
131
132
133
134
  /*
   * struct nfs4_state maintains the client-side state for a given
   * (state_owner,inode) tuple (OPEN) or state_owner (LOCK).
   *
   * OPEN:
   * In order to know when to OPEN_DOWNGRADE or CLOSE the state on the server,
   * we need to know how many files are open for reading or writing on a
   * given inode. This information too is stored here.
   *
   * LOCK: one nfs4_state (LOCK) to hold the lock stateid nfs4_state(OPEN)
   */
  
  struct nfs4_lock_state {
0c0e0d3c0   Jeff Layton   nfs: revert "nfs4...
135
136
  	struct list_head	ls_locks;	/* Other lock stateids */
  	struct nfs4_state *	ls_state;	/* Pointer to open state */
795a88c96   Trond Myklebust   NFSv4: Convert th...
137
  #define NFS_LOCK_INITIALIZED 0
ef1820f9b   NeilBrown   NFSv4: Don't try ...
138
  #define NFS_LOCK_LOST        1
0c0e0d3c0   Jeff Layton   nfs: revert "nfs4...
139
  	unsigned long		ls_flags;
cee54fc94   Trond Myklebust   NFSv4: Add functi...
140
  	struct nfs_seqid_counter	ls_seqid;
0c0e0d3c0   Jeff Layton   nfs: revert "nfs4...
141
  	nfs4_stateid		ls_stateid;
194bc1f48   Elena Reshetova   fs, nfs: convert ...
142
  	refcount_t		ls_count;
0c0e0d3c0   Jeff Layton   nfs: revert "nfs4...
143
  	fl_owner_t		ls_owner;
4ce79717c   Trond Myklebust   [PATCH] NFS: Head...
144
145
146
147
148
  };
  
  /* bits for nfs4_state->flags */
  enum {
  	LK_STATE_IN_USE,
003707c72   Trond Myklebust   NFSv4: Always use...
149
  	NFS_DELEGATED_STATE,		/* Current stateid is delegation */
92b40e938   Trond Myklebust   NFSv4: Use the op...
150
  	NFS_OPEN_STATE,			/* OPEN stateid is set */
003707c72   Trond Myklebust   NFSv4: Always use...
151
152
153
  	NFS_O_RDONLY_STATE,		/* OPEN stateid has read-only state */
  	NFS_O_WRONLY_STATE,		/* OPEN stateid has write-only state */
  	NFS_O_RDWR_STATE,		/* OPEN stateid has read/write state */
b79a4a1b4   Trond Myklebust   NFSv4: Fix state ...
154
155
  	NFS_STATE_RECLAIM_REBOOT,	/* OPEN stateid server rebooted */
  	NFS_STATE_RECLAIM_NOGRACE,	/* OPEN stateid needs to recover state */
8e469ebd6   Trond Myklebust   NFSv4: Don't allo...
156
  	NFS_STATE_POSIX_LOCKS,		/* Posix locks are supported */
5d422301f   Trond Myklebust   NFSv4: Fail I/O i...
157
  	NFS_STATE_RECOVERY_FAILED,	/* OPEN stateid state recovery failed */
a8ce377a5   Jeff Layton   nfs: track whethe...
158
  	NFS_STATE_MAY_NOTIFY_LOCK,	/* server may CB_NOTIFY_LOCK */
c9399f21c   Trond Myklebust   NFSv4: Fix OPEN /...
159
  	NFS_STATE_CHANGE_WAIT,		/* A state changing operation is outstanding */
e4648aa4f   Olga Kornievskaia   NFS recover from ...
160
  	NFS_CLNT_DST_SSC_COPY_STATE,    /* dst server open state on client*/
0e65a32c8   Olga Kornievskaia   NFS: handle sourc...
161
  	NFS_CLNT_SRC_SSC_COPY_STATE,    /* src server open state on client*/
0b9018b9c   Olga Kornievskaia   NFS: skip recover...
162
  	NFS_SRV_SSC_COPY_STATE,		/* ssc state on the dst server */
4ce79717c   Trond Myklebust   [PATCH] NFS: Head...
163
164
165
166
167
168
169
170
171
172
173
  };
  
  struct nfs4_state {
  	struct list_head open_states;	/* List of states for the same state_owner */
  	struct list_head inode_states;	/* List of states for the same inode */
  	struct list_head lock_states;	/* List of subservient lock stateids */
  
  	struct nfs4_state_owner *owner;	/* Pointer to the open owner */
  	struct inode *inode;		/* Pointer to the inode */
  
  	unsigned long flags;		/* Do we hold any locks? */
8d0a8a9d0   Trond Myklebust   [PATCH] NFSv4: Cl...
174
  	spinlock_t state_lock;		/* Protects the lock_states list */
4ce79717c   Trond Myklebust   [PATCH] NFS: Head...
175

8bda4e4c9   Trond Myklebust   NFSv4: Fix up sta...
176
  	seqlock_t seqlock;		/* Protects the stateid/open_stateid */
003707c72   Trond Myklebust   NFSv4: Always use...
177
178
  	nfs4_stateid stateid;		/* Current stateid: may be delegation */
  	nfs4_stateid open_stateid;	/* OPEN stateid */
4ce79717c   Trond Myklebust   [PATCH] NFS: Head...
179

8bda4e4c9   Trond Myklebust   NFSv4: Fix up sta...
180
  	/* The following 3 fields are protected by owner->so_lock */
003707c72   Trond Myklebust   NFSv4: Always use...
181
182
183
  	unsigned int n_rdonly;		/* Number of read-only references */
  	unsigned int n_wronly;		/* Number of write-only references */
  	unsigned int n_rdwr;		/* Number of read/write references */
dc0b027df   Trond Myklebust   NFSv4: Convert th...
184
  	fmode_t state;			/* State on the server (R,W, or RW) */
ace9fad43   Trond Myklebust   NFSv4: Convert st...
185
  	refcount_t count;
c9399f21c   Trond Myklebust   NFSv4: Fix OPEN /...
186
187
  
  	wait_queue_head_t waitq;
9ae075fdd   Trond Myklebust   NFSv4: Convert op...
188
  	struct rcu_head rcu_head;
4ce79717c   Trond Myklebust   [PATCH] NFS: Head...
189
190
191
192
  };
  
  
  struct nfs4_exception {
9e33bed55   Trond Myklebust   NFSv4: Add recove...
193
  	struct nfs4_state *state;
3114ea7a2   Trond Myklebust   NFSv4: Return the...
194
  	struct inode *inode;
8487c479e   Trond Myklebust   NFSv4: Allow retr...
195
  	nfs4_stateid *stateid;
b3c2aa074   Trond Myklebust   NFSv4: Refactor N...
196
197
198
199
  	long timeout;
  	unsigned char delay : 1,
  		      recovering : 1,
  		      retry : 1;
0688e64bc   Trond Myklebust   NFS: Allow signal...
200
  	bool interruptible;
4ce79717c   Trond Myklebust   [PATCH] NFS: Head...
201
202
203
  };
  
  struct nfs4_state_recovery_ops {
7eff03aec   Trond Myklebust   NFSv4: Add a reco...
204
  	int owner_flag_bit;
b79a4a1b4   Trond Myklebust   NFSv4: Fix state ...
205
  	int state_flag_bit;
4ce79717c   Trond Myklebust   [PATCH] NFS: Head...
206
207
  	int (*recover_open)(struct nfs4_state_owner *, struct nfs4_state *);
  	int (*recover_lock)(struct nfs4_state *, struct file_lock *);
a52458b48   NeilBrown   NFS/NFSD/SUNRPC: ...
208
209
  	int (*establish_clid)(struct nfs_client *, const struct cred *);
  	int (*reclaim_complete)(struct nfs_client *, const struct cred *);
05f4c350e   Chuck Lever   NFS: Discover NFS...
210
  	int (*detect_trunking)(struct nfs_client *, struct nfs_client **,
a52458b48   NeilBrown   NFS/NFSD/SUNRPC: ...
211
  		const struct cred *);
4ce79717c   Trond Myklebust   [PATCH] NFS: Head...
212
  };
1b146fcff   Fred Isaman   pnfs: Move nfs4_o...
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
  struct nfs4_opendata {
  	struct kref kref;
  	struct nfs_openargs o_arg;
  	struct nfs_openres o_res;
  	struct nfs_open_confirmargs c_arg;
  	struct nfs_open_confirmres c_res;
  	struct nfs4_string owner_name;
  	struct nfs4_string group_name;
  	struct nfs4_label *a_label;
  	struct nfs_fattr f_attr;
  	struct nfs4_label *f_label;
  	struct dentry *dir;
  	struct dentry *dentry;
  	struct nfs4_state_owner *owner;
  	struct nfs4_state *state;
  	struct iattr attrs;
  	struct nfs4_layoutget *lgp;
  	unsigned long timestamp;
  	bool rpc_done;
  	bool file_created;
  	bool is_recover;
  	bool cancelled;
  	int rpc_status;
  };
04fa2c6bb   Andy Adamson   NFS pnfs data ser...
237
238
  struct nfs4_add_xprt_data {
  	struct nfs_client	*clp;
a52458b48   NeilBrown   NFS/NFSD/SUNRPC: ...
239
  	const struct cred	*cred;
04fa2c6bb   Andy Adamson   NFS pnfs data ser...
240
  };
29fba38b7   Benny Halevy   nfs41: lease renewal
241
  struct nfs4_state_maintenance_ops {
a52458b48   NeilBrown   NFS/NFSD/SUNRPC: ...
242
243
244
  	int (*sched_state_renewal)(struct nfs_client *, const struct cred *, unsigned);
  	const struct cred * (*get_state_renewal_cred)(struct nfs_client *);
  	int (*renew_lease)(struct nfs_client *, const struct cred *);
29fba38b7   Benny Halevy   nfs41: lease renewal
245
  };
ec011fe84   Chuck Lever   NFS: Introduce a ...
246
  struct nfs4_mig_recovery_ops {
b03d735b4   Chuck Lever   NFS: Add method t...
247
  	int (*get_locations)(struct inode *, struct nfs4_fs_locations *,
a52458b48   NeilBrown   NFS/NFSD/SUNRPC: ...
248
249
  		struct page *, const struct cred *);
  	int (*fsid_present)(struct inode *, const struct cred *);
ec011fe84   Chuck Lever   NFS: Introduce a ...
250
  };
f786aa90e   Al Viro   constify dentry_o...
251
  extern const struct dentry_operations nfs4_dentry_operations;
73a79706d   Bryan Schumaker   NFS: Split out NF...
252
253
254
  
  /* dir.c */
  int nfs_atomic_open(struct inode *, struct dentry *, struct file *,
44907d790   Al Viro   get rid of 'opene...
255
  		    unsigned, umode_t);
6b3b5496d   J. Bruce Fields   [PATCH] NFSv4: Ad...
256

f2aedb713   David Howells   NFS: Add fs_conte...
257
  /* fs_context.c */
1ae811ee2   bjschuma@gmail.com   NFS: Fix a regres...
258
  extern struct file_system_type nfs4_fs_type;
72de53ec4   Bryan Schumaker   NFS: Do secinfo a...
259
  /* nfs4namespace.c */
beffb8feb   Al Viro   qstr: constify in...
260
261
  struct rpc_clnt *nfs4_negotiate_security(struct rpc_clnt *, struct inode *,
  					 const struct qstr *);
f2aedb713   David Howells   NFS: Add fs_conte...
262
  int nfs4_submount(struct fs_context *, struct nfs_server *);
800c06a5b   Chuck Lever   NFS: Add function...
263
264
  int nfs4_replace_transport(struct nfs_server *server,
  				const struct nfs4_fs_locations *locations);
72de53ec4   Bryan Schumaker   NFS: Do secinfo a...
265

4ce79717c   Trond Myklebust   [PATCH] NFS: Head...
266
  /* nfs4proc.c */
f4ac1674f   Anna Schumaker   nfs: Add ALLOCATE...
267
  extern int nfs4_handle_exception(struct nfs_server *, int, struct nfs4_exception *);
0f913a57d   Olga Kornievskaia   NFS export nfs4_a...
268
269
270
  extern int nfs4_async_handle_error(struct rpc_task *task,
  				   struct nfs_server *server,
  				   struct nfs4_state *state, long *timeout);
1c6dcbe5c   Anna Schumaker   NFS: Implement SEEK
271
272
273
  extern int nfs4_call_sync(struct rpc_clnt *, struct nfs_server *,
  			  struct rpc_message *, struct nfs4_sequence_args *,
  			  struct nfs4_sequence_res *, int);
fba83f341   Anna Schumaker   NFS: Pass "privil...
274
  extern void nfs4_init_sequence(struct nfs4_sequence_args *, struct nfs4_sequence_res *, int, int);
a52458b48   NeilBrown   NFS/NFSD/SUNRPC: ...
275
276
  extern int nfs4_proc_setclientid(struct nfs_client *, u32, unsigned short, const struct cred *, struct nfs4_setclientid_res *);
  extern int nfs4_proc_setclientid_confirm(struct nfs_client *, struct nfs4_setclientid_res *arg, const struct cred *);
5e6b19901   Trond Myklebust   NFSv4: Fix securi...
277
  extern int nfs4_proc_get_rootfh(struct nfs_server *, struct nfs_fh *, struct nfs_fsinfo *, bool);
a52458b48   NeilBrown   NFS/NFSD/SUNRPC: ...
278
279
  extern int nfs4_proc_bind_conn_to_session(struct nfs_client *, const struct cred *cred);
  extern int nfs4_proc_exchange_id(struct nfs_client *clp, const struct cred *cred);
662455391   Trond Myklebust   NFSv4.1: Add DEST...
280
  extern int nfs4_destroy_clientid(struct nfs_client *clp);
a52458b48   NeilBrown   NFS/NFSD/SUNRPC: ...
281
282
  extern int nfs4_init_clientid(struct nfs_client *, const struct cred *);
  extern int nfs41_init_clientid(struct nfs_client *, const struct cred *);
1f7977c13   Trond Myklebust   NFSv4.1: Simplify...
283
  extern int nfs4_do_close(struct nfs4_state *state, gfp_t gfp_mask, int wait);
55a975937   Trond Myklebust   NFS: Ensure the c...
284
  extern int nfs4_server_capabilities(struct nfs_server *server, struct nfs_fh *fhandle);
f05d147f7   Bryan Schumaker   NFS: Fix followin...
285
286
  extern int nfs4_proc_fs_locations(struct rpc_clnt *, struct inode *, const struct qstr *,
  				  struct nfs4_fs_locations *, struct page *);
b03d735b4   Chuck Lever   NFS: Add method t...
287
  extern int nfs4_proc_get_locations(struct inode *, struct nfs4_fs_locations *,
a52458b48   NeilBrown   NFS/NFSD/SUNRPC: ...
288
289
  		struct page *page, const struct cred *);
  extern int nfs4_proc_fsid_present(struct inode *, const struct cred *);
f7b37b8b1   Trond Myklebust   NFS: Add softreva...
290
291
292
293
  extern struct rpc_clnt *nfs4_proc_lookup_mountpoint(struct inode *,
  						    struct dentry *,
  						    struct nfs_fh *,
  						    struct nfs_fattr *);
72de53ec4   Bryan Schumaker   NFS: Do secinfo a...
294
  extern int nfs4_proc_secinfo(struct inode *, const struct qstr *, struct nfs4_secinfo_flavors *);
64c2ce8b7   Aneesh Kumar K.V   nfsv4: Switch to ...
295
  extern const struct xattr_handler *nfs4_xattr_handlers[];
5521abfdc   Trond Myklebust   NFSv4: Resend the...
296
  extern int nfs4_set_rw_stateid(nfs4_stateid *stateid,
9b2061498   Trond Myklebust   NFSv4: The statei...
297
298
299
  		const struct nfs_open_context *ctx,
  		const struct nfs_lock_context *l_ctx,
  		fmode_t fmode);
ec4b09250   Olga Kornievskaia   NFS: inter ssc open
300
301
302
303
304
305
306
  extern int nfs4_proc_getattr(struct nfs_server *server, struct nfs_fh *fhandle,
  			     struct nfs_fattr *fattr, struct nfs4_label *label,
  			     struct inode *inode);
  extern int update_open_stateid(struct nfs4_state *state,
  				const nfs4_stateid *open_stateid,
  				const nfs4_stateid *deleg_stateid,
  				fmode_t fmode);
4ce79717c   Trond Myklebust   [PATCH] NFS: Head...
307

0efb01b2a   Donald Buczek   nfs4: Make nfs4_p...
308
309
  extern int nfs4_proc_get_lease_time(struct nfs_client *clp,
  		struct nfs_fsinfo *fsinfo);
1b523ca97   Frank van der Linden   nfs: modify updat...
310
311
312
313
  extern void nfs4_update_changeattr(struct inode *dir,
  				   struct nfs4_change_info *cinfo,
  				   unsigned long timestamp,
  				   unsigned long cache_validity);
ccde1e9c0   Frank van der Linden   nfs: make the buf...
314
315
  extern int nfs4_buf_to_pages_noslab(const void *buf, size_t buflen,
  				    struct page **pages);
1b523ca97   Frank van der Linden   nfs: modify updat...
316

557134a39   Andy Adamson   nfs41: sessions c...
317
  #if defined(CONFIG_NFS_V4_1)
f9c96fcc5   Andy Adamson   NFSv4.1 free slot...
318
  extern int nfs41_sequence_done(struct rpc_task *, struct nfs4_sequence_res *);
a52458b48   NeilBrown   NFS/NFSD/SUNRPC: ...
319
320
  extern int nfs4_proc_create_session(struct nfs_client *, const struct cred *);
  extern int nfs4_proc_destroy_session(struct nfs4_session *, const struct cred *);
863a3c6c6   Andy Adamson   NFSv4.1: layoutco...
321
  extern int nfs4_proc_layoutcommit(struct nfs4_layoutcommit_data *data,
ef3115378   Andy Adamson   NFSv4.1 convert l...
322
  				  bool sync);
ba84db96a   Andy Adamson   NFS detect sessio...
323
324
  extern int nfs4_detect_session_trunking(struct nfs_client *clp,
  		struct nfs41_exchange_id_res *res, struct rpc_xprt *xprt);
94de8b27d   Andy Adamson   NFSv4.1: add MDS ...
325
326
327
328
329
330
331
  
  static inline bool
  is_ds_only_client(struct nfs_client *clp)
  {
  	return (clp->cl_exchange_flags & EXCHGID4_FLAG_MASK_PNFS) ==
  		EXCHGID4_FLAG_USE_PNFS_DS;
  }
d83217c13   Andy Adamson   NFSv4.1: data ser...
332
333
334
335
336
337
  
  static inline bool
  is_ds_client(struct nfs_client *clp)
  {
  	return clp->cl_exchange_flags & EXCHGID4_FLAG_USE_PNFS_DS;
  }
ab4c23613   Weston Andros Adamson   nfs4.1: Add state...
338

8c21c62c4   Weston Andros Adamson   nfs4.1: Add SP4_M...
339
340
341
  static inline bool
  _nfs4_state_protect(struct nfs_client *clp, unsigned long sp4_mode,
  		    struct rpc_clnt **clntp, struct rpc_message *msg)
ab4c23613   Weston Andros Adamson   nfs4.1: Add state...
342
  {
ab4c23613   Weston Andros Adamson   nfs4.1: Add state...
343
  	rpc_authflavor_t flavor;
b79e87e07   NeilBrown   NFSv4.1: don't us...
344
345
346
347
348
349
350
351
352
353
354
  	if (sp4_mode == NFS_SP4_MACH_CRED_CLEANUP ||
  	    sp4_mode == NFS_SP4_MACH_CRED_PNFS_CLEANUP) {
  		/* Using machine creds for cleanup operations
  		 * is only relevent if the client credentials
  		 * might expire. So don't bother for
  		 * RPC_AUTH_UNIX.  If file was only exported to
  		 * sec=sys, the PUTFH would fail anyway.
  		 */
  		if ((*clntp)->cl_auth->au_flavor == RPC_AUTH_UNIX)
  			return false;
  	}
ab4c23613   Weston Andros Adamson   nfs4.1: Add state...
355
  	if (test_bit(sp4_mode, &clp->cl_sp4_flags)) {
5e16923b4   NeilBrown   NFS/SUNRPC: don't...
356
  		msg->rpc_cred = rpc_machine_cred();
ab4c23613   Weston Andros Adamson   nfs4.1: Add state...
357
358
  
  		flavor = clp->cl_rpcclient->cl_auth->au_flavor;
312cd958a   Weston Andros Adamson   NFSv4.1: sp4_mach...
359
360
  		WARN_ON_ONCE(flavor != RPC_AUTH_GSS_KRB5I &&
  			     flavor != RPC_AUTH_GSS_KRB5P);
ab4c23613   Weston Andros Adamson   nfs4.1: Add state...
361
  		*clntp = clp->cl_rpcclient;
8c21c62c4   Weston Andros Adamson   nfs4.1: Add SP4_M...
362
363
  
  		return true;
ab4c23613   Weston Andros Adamson   nfs4.1: Add state...
364
  	}
8c21c62c4   Weston Andros Adamson   nfs4.1: Add SP4_M...
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
  	return false;
  }
  
  /*
   * Function responsible for determining if an rpc_message should use the
   * machine cred under SP4_MACH_CRED and if so switching the credential and
   * authflavor (using the nfs_client's rpc_clnt which will be krb5i/p).
   * Should be called before rpc_call_sync/rpc_call_async.
   */
  static inline void
  nfs4_state_protect(struct nfs_client *clp, unsigned long sp4_mode,
  		   struct rpc_clnt **clntp, struct rpc_message *msg)
  {
  	_nfs4_state_protect(clp, sp4_mode, clntp, msg);
  }
  
  /*
   * Special wrapper to nfs4_state_protect for write.
   * If WRITE can use machine cred but COMMIT cannot, make sure all writes
   * that use machine cred use NFS_FILE_SYNC.
   */
  static inline void
  nfs4_state_protect_write(struct nfs_client *clp, struct rpc_clnt **clntp,
d45f60c67   Weston Andros Adamson   nfs: merge nfs_pg...
388
  			 struct rpc_message *msg, struct nfs_pgio_header *hdr)
8c21c62c4   Weston Andros Adamson   nfs4.1: Add SP4_M...
389
390
391
  {
  	if (_nfs4_state_protect(clp, NFS_SP4_MACH_CRED_WRITE, clntp, msg) &&
  	    !test_bit(NFS_SP4_MACH_CRED_COMMIT, &clp->cl_sp4_flags))
d45f60c67   Weston Andros Adamson   nfs: merge nfs_pg...
392
  		hdr->args.stable = NFS_FILE_SYNC;
ab4c23613   Weston Andros Adamson   nfs4.1: Add state...
393
  }
fbcd4abcb   Andy Adamson   nfs41: setup_sequ...
394
  #else /* CONFIG_NFS_v4_1 */
94de8b27d   Andy Adamson   NFSv4.1: add MDS ...
395
396
  static inline bool
  is_ds_only_client(struct nfs_client *clp)
d83217c13   Andy Adamson   NFSv4.1: data ser...
397
398
399
400
401
402
  {
  	return false;
  }
  
  static inline bool
  is_ds_client(struct nfs_client *clp)
94de8b27d   Andy Adamson   NFSv4.1: add MDS ...
403
404
405
  {
  	return false;
  }
ab4c23613   Weston Andros Adamson   nfs4.1: Add state...
406
407
408
409
410
411
  
  static inline void
  nfs4_state_protect(struct nfs_client *clp, unsigned long sp4_flags,
  		   struct rpc_clnt **clntp, struct rpc_message *msg)
  {
  }
8c21c62c4   Weston Andros Adamson   nfs4.1: Add SP4_M...
412
413
414
  
  static inline void
  nfs4_state_protect_write(struct nfs_client *clp, struct rpc_clnt **clntp,
d45f60c67   Weston Andros Adamson   nfs: merge nfs_pg...
415
  			 struct rpc_message *msg, struct nfs_pgio_header *hdr)
8c21c62c4   Weston Andros Adamson   nfs4.1: Add SP4_M...
416
417
  {
  }
557134a39   Andy Adamson   nfs41: sessions c...
418
  #endif /* CONFIG_NFS_V4_1 */
4ce79717c   Trond Myklebust   [PATCH] NFS: Head...
419

97dc13594   Trond Myklebust   NFSv41: Clean up ...
420
  extern const struct nfs4_minor_version_ops *nfs_v4_minor_ops[];
29fba38b7   Benny Halevy   nfs41: lease renewal
421

1549210fc   Trond Myklebust   NFSv4: Fix an Oop...
422
  extern const u32 nfs4_fattr_bitmap[3];
a09df2ca2   David Quigley   NFSv4: Extend fat...
423
424
  extern const u32 nfs4_statfs_bitmap[3];
  extern const u32 nfs4_pathconf_bitmap[3];
dae100c2b   Fred Isaman   pnfs: ask for lay...
425
  extern const u32 nfs4_fsinfo_bitmap[3];
a09df2ca2   David Quigley   NFSv4: Extend fat...
426
  extern const u32 nfs4_fs_locations_bitmap[3];
4ce79717c   Trond Myklebust   [PATCH] NFS: Head...
427

abf79bb34   Chuck Lever   NFS: Add a slot t...
428
429
430
431
  void nfs40_shutdown_client(struct nfs_client *);
  void nfs41_shutdown_client(struct nfs_client *);
  int nfs40_init_client(struct nfs_client *);
  int nfs41_init_client(struct nfs_client *);
cdb7ecede   Bryan Schumaker   NFS: Create a fre...
432
  void nfs4_free_client(struct nfs_client *);
6663ee7f8   Bryan Schumaker   NFS: Create an al...
433
  struct nfs_client *nfs4_alloc_client(const struct nfs_client_initdata *);
4ce79717c   Trond Myklebust   [PATCH] NFS: Head...
434
  /* nfs4renewd.c */
adfa6f980   David Howells   NFS: Rename struc...
435
  extern void nfs4_schedule_state_renewal(struct nfs_client *);
4ce79717c   Trond Myklebust   [PATCH] NFS: Head...
436
  extern void nfs4_renewd_prepare_shutdown(struct nfs_server *);
adfa6f980   David Howells   NFS: Rename struc...
437
  extern void nfs4_kill_renewd(struct nfs_client *);
65f27f384   David Howells   WorkStruct: Pass ...
438
  extern void nfs4_renew_state(struct work_struct *);
7dc2993a9   Robert Milkowski   NFSv4.0: nfs4_do_...
439
  extern void nfs4_set_lease_period(struct nfs_client *clp, unsigned long lease);
fb10fb67a   Trond Myklebust   NFSv4: Cleanup th...
440

4ce79717c   Trond Myklebust   [PATCH] NFS: Head...
441
442
  
  /* nfs4state.c */
d49dd1175   Ben Dooks   NFSv4: add declar...
443
  extern const nfs4_stateid current_stateid;
a52458b48   NeilBrown   NFS/NFSD/SUNRPC: ...
444
445
446
  const struct cred *nfs4_get_clid_cred(struct nfs_client *clp);
  const struct cred *nfs4_get_machine_cred(struct nfs_client *clp);
  const struct cred *nfs4_get_renew_cred(struct nfs_client *clp);
05f4c350e   Chuck Lever   NFS: Discover NFS...
447
448
449
  int nfs4_discover_server_trunking(struct nfs_client *clp,
  			struct nfs_client **);
  int nfs40_discover_server_trunking(struct nfs_client *clp,
a52458b48   NeilBrown   NFS/NFSD/SUNRPC: ...
450
  			struct nfs_client **, const struct cred *);
a7b721037   Andy Adamson   nfs41: introduce ...
451
  #if defined(CONFIG_NFS_V4_1)
05f4c350e   Chuck Lever   NFS: Discover NFS...
452
  int nfs41_discover_server_trunking(struct nfs_client *clp,
a52458b48   NeilBrown   NFS/NFSD/SUNRPC: ...
453
  			struct nfs_client **, const struct cred *);
9f594791d   Trond Myklebust   NFSv4.1: Handle o...
454
  extern void nfs4_schedule_session_recovery(struct nfs4_session *, int);
3f10a6af4   Anna Schumaker   NFS: Remove nfs41...
455
  extern void nfs41_notify_server(struct nfs_client *);
0491567b5   Olga Kornievskaia   NFS: add COPY_NOT...
456
457
  bool nfs4_check_serverowner_major_id(struct nfs41_server_owner *o1,
  			struct nfs41_server_owner *o2);
0400a6b0c   Trond Myklebust   NFSv4/4.1: Fix nf...
458
  #else
9f594791d   Trond Myklebust   NFSv4.1: Handle o...
459
  static inline void nfs4_schedule_session_recovery(struct nfs4_session *session, int err)
0400a6b0c   Trond Myklebust   NFSv4/4.1: Fix nf...
460
461
  {
  }
a7b721037   Andy Adamson   nfs41: introduce ...
462
  #endif /* CONFIG_NFS_V4_1 */
4ce79717c   Trond Myklebust   [PATCH] NFS: Head...
463

a52458b48   NeilBrown   NFS/NFSD/SUNRPC: ...
464
  extern struct nfs4_state_owner *nfs4_get_state_owner(struct nfs_server *, const struct cred *, gfp_t);
4ce79717c   Trond Myklebust   [PATCH] NFS: Head...
465
  extern void nfs4_put_state_owner(struct nfs4_state_owner *);
c77e22834   Trond Myklebust   NFSv4: Fix a pote...
466
467
  extern void nfs4_purge_state_owners(struct nfs_server *, struct list_head *);
  extern void nfs4_free_state_owners(struct list_head *head);
4ce79717c   Trond Myklebust   [PATCH] NFS: Head...
468
469
  extern struct nfs4_state * nfs4_get_open_state(struct inode *, struct nfs4_state_owner *);
  extern void nfs4_put_open_state(struct nfs4_state *);
643168c2d   Al Viro   nfs4_closedata do...
470
471
  extern void nfs4_close_state(struct nfs4_state *, fmode_t);
  extern void nfs4_close_sync(struct nfs4_state *, fmode_t);
dc0b027df   Trond Myklebust   NFSv4: Convert th...
472
  extern void nfs4_state_set_mode_locked(struct nfs4_state *, fmode_t);
a1d0b5eeb   Trond Myklebust   NFS: Properly han...
473
474
  extern void nfs_inode_find_state_and_recover(struct inode *inode,
  		const nfs4_stateid *stateid);
4f14c194a   Trond Myklebust   NFSv4: Clear the ...
475
  extern int nfs4_state_mark_reclaim_nograce(struct nfs_client *, struct nfs4_state *);
0400a6b0c   Trond Myklebust   NFSv4/4.1: Fix nf...
476
  extern void nfs4_schedule_lease_recovery(struct nfs_client *);
330212796   Trond Myklebust   NFSv4: Move nfs4_...
477
478
  extern int nfs4_wait_clnt_recover(struct nfs_client *clp);
  extern int nfs4_client_recover_expired_lease(struct nfs_client *clp);
b0d3ded1a   Trond Myklebust   NFSv4: Clean up n...
479
  extern void nfs4_schedule_state_manager(struct nfs_client *);
042b60beb   Trond Myklebust   NFSv4: renewd nee...
480
  extern void nfs4_schedule_path_down_recovery(struct nfs_client *clp);
5d422301f   Trond Myklebust   NFSv4: Fail I/O i...
481
  extern int nfs4_schedule_stateid_recovery(const struct nfs_server *, struct nfs4_state *);
c9fdeb280   Chuck Lever   NFS: Add basic mi...
482
  extern int nfs4_schedule_migration_recovery(const struct nfs_server *);
b7f7a66e4   Chuck Lever   NFS: Support NFS4...
483
  extern void nfs4_schedule_lease_moved_recovery(struct nfs_client *);
0a014a44a   Trond Myklebust   NFSv4.1: Don't de...
484
  extern void nfs41_handle_sequence_flag_errors(struct nfs_client *clp, u32 flags, bool);
78fe0f41d   Weston Andros Adamson   NFS: use scope fr...
485
  extern void nfs41_handle_server_scope(struct nfs_client *,
79d4e1f0d   Chuck Lever   NFS: Use proper n...
486
  				      struct nfs41_server_scope **);
faf5f49c2   Trond Myklebust   NFSv4: Make NFS c...
487
  extern void nfs4_put_lock_state(struct nfs4_lock_state *lsp);
8d0a8a9d0   Trond Myklebust   [PATCH] NFSv4: Cl...
488
  extern int nfs4_set_lock_state(struct nfs4_state *state, struct file_lock *fl);
abf4e13cc   Trond Myklebust   NFSv4: Use the ri...
489
  extern int nfs4_select_rw_stateid(struct nfs4_state *, fmode_t,
173934754   NeilBrown   NFSv4: change nfs...
490
  		const struct nfs_lock_context *, nfs4_stateid *,
a52458b48   NeilBrown   NFS/NFSD/SUNRPC: ...
491
  		const struct cred **);
c82bac6f4   Trond Myklebust   NFSv4: Don't try ...
492
493
  extern bool nfs4_copy_open_stateid(nfs4_stateid *dst,
  		struct nfs4_state *state);
4ce79717c   Trond Myklebust   [PATCH] NFS: Head...
494

8535b2be5   Trond Myklebust   NFSv4: Don't use ...
495
  extern struct nfs_seqid *nfs_alloc_seqid(struct nfs_seqid_counter *counter, gfp_t gfp_mask);
cee54fc94   Trond Myklebust   NFSv4: Add functi...
496
497
498
  extern int nfs_wait_on_sequence(struct nfs_seqid *seqid, struct rpc_task *task);
  extern void nfs_increment_open_seqid(int status, struct nfs_seqid *seqid);
  extern void nfs_increment_lock_seqid(int status, struct nfs_seqid *seqid);
72211dbe7   Trond Myklebust   NFSv4: Release th...
499
  extern void nfs_release_seqid(struct nfs_seqid *seqid);
cee54fc94   Trond Myklebust   NFSv4: Add functi...
500
  extern void nfs_free_seqid(struct nfs_seqid *seqid);
3be0f80b5   Trond Myklebust   NFSv4.1: Fix up r...
501
  extern int nfs4_setup_sequence(struct nfs_client *client,
cb04ad2a2   Peng Tao   nfs4: pass slot t...
502
503
504
  				struct nfs4_sequence_args *args,
  				struct nfs4_sequence_res *res,
  				struct rpc_task *task);
2c4b131de   Peng Tao   nfs4: export nfs4...
505
506
  extern int nfs4_sequence_done(struct rpc_task *task,
  			      struct nfs4_sequence_res *res);
cee54fc94   Trond Myklebust   NFSv4: Add functi...
507

5ae67c4fe   Trond Myklebust   NFSv4: It is not ...
508
  extern void nfs4_free_lock_state(struct nfs_server *server, struct nfs4_lock_state *lsp);
6b8d84e2f   Olga Kornievskaia   NFS add a simple ...
509
  extern int nfs4_proc_commit(struct file *dst, __u64 offset, __u32 count, struct nfs_commitres *res);
4ce79717c   Trond Myklebust   [PATCH] NFS: Head...
510
  extern const nfs4_stateid zero_stateid;
fcd8843c4   Trond Myklebust   NFSv4: Replace cl...
511
  extern const nfs4_stateid invalid_stateid;
4ce79717c   Trond Myklebust   [PATCH] NFS: Head...
512

129d1977e   Bryan Schumaker   NFS: Create an in...
513
  /* nfs4super.c */
fbdefd644   Bryan Schumaker   NFS: Split out th...
514
  struct nfs_mount_info;
ab7017a3a   Bryan Schumaker   NFS: Add version ...
515
  extern struct nfs_subversion nfs_v4;
fac1e8e4e   Bryan Schumaker   NFS: Keep module ...
516
517
  extern bool nfs4_disable_idmapping;
  extern unsigned short max_session_slots;
5405fc44c   Trond Myklebust   NFSv4.x: Add kern...
518
  extern unsigned short max_session_cb_slots;
fac1e8e4e   Bryan Schumaker   NFS: Keep module ...
519
  extern unsigned short send_implementation_id;
f6de7a39c   Trond Myklebust   NFSv4: Document t...
520
  extern bool recover_lost_locks;
89d77c8fa   Bryan Schumaker   NFS: Convert v4 i...
521

6f2ea7f2a   Chuck Lever   NFS: Add nfs4_uni...
522
523
  #define NFS4_CLIENT_ID_UNIQ_LEN		(64)
  extern char nfs4_client_id_uniquifier[NFS4_CLIENT_ID_UNIQ_LEN];
f2aedb713   David Howells   NFS: Add fs_conte...
524
525
  extern int nfs4_try_get_tree(struct fs_context *);
  extern int nfs4_get_referral_tree(struct fs_context *);
466bfe7f4   Bryan Schumaker   NFS: Initialize v...
526
527
528
529
530
531
532
533
534
  /* nfs4sysctl.c */
  #ifdef CONFIG_SYSCTL
  int nfs4_register_sysctl(void);
  void nfs4_unregister_sysctl(void);
  #else
  static inline int nfs4_register_sysctl(void)
  {
  	return 0;
  }
0add3e856   Randy Dunlap   nfs: fix stub ret...
535
  static inline void nfs4_unregister_sysctl(void)
466bfe7f4   Bryan Schumaker   NFS: Initialize v...
536
537
538
  {
  }
  #endif
4ce79717c   Trond Myklebust   [PATCH] NFS: Head...
539
  /* nfs4xdr.c */
499b49881   Christoph Hellwig   sunrpc: mark all ...
540
  extern const struct rpc_procinfo nfs4_procedures[];
4ce79717c   Trond Myklebust   [PATCH] NFS: Head...
541

04a5da690   Frank van der Linden   NFSv4.2: define l...
542
543
544
545
546
  #ifdef CONFIG_NFS_V4_2
  extern const u32 nfs42_maxsetxattr_overhead;
  extern const u32 nfs42_maxgetxattr_overhead;
  extern const u32 nfs42_maxlistxattrs_overhead;
  #endif
4ce79717c   Trond Myklebust   [PATCH] NFS: Head...
547
548
549
  struct nfs4_mount_data;
  
  /* callback_xdr.c */
e9679189e   Christoph Hellwig   sunrpc: mark all ...
550
551
  extern const struct svc_version nfs4_callback_version1;
  extern const struct svc_version nfs4_callback_version4;
4ce79717c   Trond Myklebust   [PATCH] NFS: Head...
552

f597c5379   Trond Myklebust   NFSv4: Add helper...
553
554
  static inline void nfs4_stateid_copy(nfs4_stateid *dst, const nfs4_stateid *src)
  {
93b717fd8   Trond Myklebust   NFSv4: Label stat...
555
556
  	memcpy(dst->data, src->data, sizeof(dst->data));
  	dst->type = src->type;
f597c5379   Trond Myklebust   NFSv4: Add helper...
557
558
559
560
  }
  
  static inline bool nfs4_stateid_match(const nfs4_stateid *dst, const nfs4_stateid *src)
  {
93b717fd8   Trond Myklebust   NFSv4: Label stat...
561
562
563
  	if (dst->type != src->type)
  		return false;
  	return memcmp(dst->data, src->data, sizeof(dst->data)) == 0;
f597c5379   Trond Myklebust   NFSv4: Add helper...
564
  }
e999e80ee   Trond Myklebust   NFSv4: Don't upda...
565
566
567
568
569
570
571
572
573
  static inline bool nfs4_stateid_match_other(const nfs4_stateid *dst, const nfs4_stateid *src)
  {
  	return memcmp(dst->other, src->other, NFS4_STATEID_OTHER_SIZE) == 0;
  }
  
  static inline bool nfs4_stateid_is_newer(const nfs4_stateid *s1, const nfs4_stateid *s2)
  {
  	return (s32)(be32_to_cpu(s1->seqid) - be32_to_cpu(s2->seqid)) > 0;
  }
b4868b44c   Benjamin Coddington   NFSv4: Wait for s...
574
575
576
577
578
579
580
  static inline bool nfs4_stateid_is_next(const nfs4_stateid *s1, const nfs4_stateid *s2)
  {
  	u32 seq1 = be32_to_cpu(s1->seqid);
  	u32 seq2 = be32_to_cpu(s2->seqid);
  
  	return seq2 == seq1 + 1U || (seq2 == 1U && seq1 == 0xffffffffU);
  }
42c304c34   Trond Myklebust   NFS: nfs_inode_fi...
581
582
583
584
585
  static inline bool nfs4_stateid_match_or_older(const nfs4_stateid *dst, const nfs4_stateid *src)
  {
  	return nfs4_stateid_match_other(dst, src) &&
  		!(src->seqid && nfs4_stateid_is_newer(dst, src));
  }
922839570   Trond Myklebust   NFSv4: Add a help...
586
587
588
589
590
591
592
593
  static inline void nfs4_stateid_seqid_inc(nfs4_stateid *s1)
  {
  	u32 seqid = be32_to_cpu(s1->seqid);
  
  	if (++seqid == 0)
  		++seqid;
  	s1->seqid = cpu_to_be32(seqid);
  }
5d422301f   Trond Myklebust   NFSv4: Fail I/O i...
594
595
596
597
  static inline bool nfs4_valid_open_stateid(const struct nfs4_state *state)
  {
  	return test_bit(NFS_STATE_RECOVERY_FAILED, &state->flags) == 0;
  }
3e7dfb165   Trond Myklebust   NFSv4: Fix CLOSE ...
598
599
600
601
602
603
  static inline bool nfs4_state_match_open_stateid_other(const struct nfs4_state *state,
  		const nfs4_stateid *stateid)
  {
  	return test_bit(NFS_OPEN_STATE, &state->flags) &&
  		nfs4_stateid_match_other(&state->open_stateid, stateid);
  }
95ad37f90   Frank van der Linden   NFSv4.2: add clie...
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
  /* nfs42xattr.c */
  #ifdef CONFIG_NFS_V4_2
  extern int __init nfs4_xattr_cache_init(void);
  extern void nfs4_xattr_cache_exit(void);
  extern void nfs4_xattr_cache_add(struct inode *inode, const char *name,
  				 const char *buf, struct page **pages,
  				 ssize_t buflen);
  extern void nfs4_xattr_cache_remove(struct inode *inode, const char *name);
  extern ssize_t nfs4_xattr_cache_get(struct inode *inode, const char *name,
  				char *buf, ssize_t buflen);
  extern void nfs4_xattr_cache_set_list(struct inode *inode, const char *buf,
  				      ssize_t buflen);
  extern ssize_t nfs4_xattr_cache_list(struct inode *inode, char *buf,
  				     ssize_t buflen);
  extern void nfs4_xattr_cache_zap(struct inode *inode);
4ce79717c   Trond Myklebust   [PATCH] NFS: Head...
619
  #else
95ad37f90   Frank van der Linden   NFSv4.2: add clie...
620
621
622
623
624
625
  static inline void nfs4_xattr_cache_zap(struct inode *inode)
  {
  }
  #endif /* CONFIG_NFS_V4_2 */
  
  #else /* CONFIG_NFS_V4 */
4ce79717c   Trond Myklebust   [PATCH] NFS: Head...
626

643168c2d   Al Viro   nfs4_closedata do...
627
628
  #define nfs4_close_state(a, b) do { } while (0)
  #define nfs4_close_sync(a, b) do { } while (0)
8c21c62c4   Weston Andros Adamson   nfs4.1: Add SP4_M...
629
630
  #define nfs4_state_protect(a, b, c, d) do { } while (0)
  #define nfs4_state_protect_write(a, b, c, d) do { } while (0)
4ce79717c   Trond Myklebust   [PATCH] NFS: Head...
631

95ad37f90   Frank van der Linden   NFSv4.2: add clie...
632

4ce79717c   Trond Myklebust   [PATCH] NFS: Head...
633
634
  #endif /* CONFIG_NFS_V4 */
  #endif /* __LINUX_FS_NFS_NFS4_FS.H */