1
2
3
4
5
6
7
8
9
10
11
12#ifndef _LINUX_NFS4_H
13#define _LINUX_NFS4_H
14
15#include <linux/list.h>
16#include <linux/uidgid.h>
17#include <uapi/linux/nfs4.h>
18
19struct nfs4_ace {
20 uint32_t type;
21 uint32_t flag;
22 uint32_t access_mask;
23 int whotype;
24 union {
25 kuid_t who_uid;
26 kgid_t who_gid;
27 };
28};
29
30struct nfs4_acl {
31 uint32_t naces;
32 struct nfs4_ace aces[0];
33};
34
35#define NFS4_MAXLABELLEN 2048
36
37struct nfs4_label {
38 uint32_t lfs;
39 uint32_t pi;
40 u32 len;
41 char *label;
42};
43
44typedef struct { char data[NFS4_VERIFIER_SIZE]; } nfs4_verifier;
45
46struct nfs_stateid4 {
47 __be32 seqid;
48 char other[NFS4_STATEID_OTHER_SIZE];
49} __attribute__ ((packed));
50
51typedef struct nfs_stateid4 nfs4_stateid;
52
53enum nfs_opnum4 {
54 OP_ACCESS = 3,
55 OP_CLOSE = 4,
56 OP_COMMIT = 5,
57 OP_CREATE = 6,
58 OP_DELEGPURGE = 7,
59 OP_DELEGRETURN = 8,
60 OP_GETATTR = 9,
61 OP_GETFH = 10,
62 OP_LINK = 11,
63 OP_LOCK = 12,
64 OP_LOCKT = 13,
65 OP_LOCKU = 14,
66 OP_LOOKUP = 15,
67 OP_LOOKUPP = 16,
68 OP_NVERIFY = 17,
69 OP_OPEN = 18,
70 OP_OPENATTR = 19,
71 OP_OPEN_CONFIRM = 20,
72 OP_OPEN_DOWNGRADE = 21,
73 OP_PUTFH = 22,
74 OP_PUTPUBFH = 23,
75 OP_PUTROOTFH = 24,
76 OP_READ = 25,
77 OP_READDIR = 26,
78 OP_READLINK = 27,
79 OP_REMOVE = 28,
80 OP_RENAME = 29,
81 OP_RENEW = 30,
82 OP_RESTOREFH = 31,
83 OP_SAVEFH = 32,
84 OP_SECINFO = 33,
85 OP_SETATTR = 34,
86 OP_SETCLIENTID = 35,
87 OP_SETCLIENTID_CONFIRM = 36,
88 OP_VERIFY = 37,
89 OP_WRITE = 38,
90 OP_RELEASE_LOCKOWNER = 39,
91
92
93 OP_BACKCHANNEL_CTL = 40,
94 OP_BIND_CONN_TO_SESSION = 41,
95 OP_EXCHANGE_ID = 42,
96 OP_CREATE_SESSION = 43,
97 OP_DESTROY_SESSION = 44,
98 OP_FREE_STATEID = 45,
99 OP_GET_DIR_DELEGATION = 46,
100 OP_GETDEVICEINFO = 47,
101 OP_GETDEVICELIST = 48,
102 OP_LAYOUTCOMMIT = 49,
103 OP_LAYOUTGET = 50,
104 OP_LAYOUTRETURN = 51,
105 OP_SECINFO_NO_NAME = 52,
106 OP_SEQUENCE = 53,
107 OP_SET_SSV = 54,
108 OP_TEST_STATEID = 55,
109 OP_WANT_DELEGATION = 56,
110 OP_DESTROY_CLIENTID = 57,
111 OP_RECLAIM_COMPLETE = 58,
112
113 OP_ILLEGAL = 10044,
114};
115
116
117
118
119#define FIRST_NFS4_OP OP_ACCESS
120#define LAST_NFS4_OP OP_RECLAIM_COMPLETE
121#define LAST_NFS40_OP OP_RELEASE_LOCKOWNER
122#define LAST_NFS41_OP OP_RECLAIM_COMPLETE
123#define LAST_NFS42_OP OP_RECLAIM_COMPLETE
124
125enum nfsstat4 {
126 NFS4_OK = 0,
127 NFS4ERR_PERM = 1,
128 NFS4ERR_NOENT = 2,
129 NFS4ERR_IO = 5,
130 NFS4ERR_NXIO = 6,
131 NFS4ERR_ACCESS = 13,
132 NFS4ERR_EXIST = 17,
133 NFS4ERR_XDEV = 18,
134
135 NFS4ERR_NOTDIR = 20,
136 NFS4ERR_ISDIR = 21,
137 NFS4ERR_INVAL = 22,
138 NFS4ERR_FBIG = 27,
139 NFS4ERR_NOSPC = 28,
140 NFS4ERR_ROFS = 30,
141 NFS4ERR_MLINK = 31,
142 NFS4ERR_NAMETOOLONG = 63,
143 NFS4ERR_NOTEMPTY = 66,
144 NFS4ERR_DQUOT = 69,
145 NFS4ERR_STALE = 70,
146 NFS4ERR_BADHANDLE = 10001,
147 NFS4ERR_BAD_COOKIE = 10003,
148 NFS4ERR_NOTSUPP = 10004,
149 NFS4ERR_TOOSMALL = 10005,
150 NFS4ERR_SERVERFAULT = 10006,
151 NFS4ERR_BADTYPE = 10007,
152 NFS4ERR_DELAY = 10008,
153 NFS4ERR_SAME = 10009,
154 NFS4ERR_DENIED = 10010,
155 NFS4ERR_EXPIRED = 10011,
156 NFS4ERR_LOCKED = 10012,
157 NFS4ERR_GRACE = 10013,
158 NFS4ERR_FHEXPIRED = 10014,
159 NFS4ERR_SHARE_DENIED = 10015,
160 NFS4ERR_WRONGSEC = 10016,
161 NFS4ERR_CLID_INUSE = 10017,
162 NFS4ERR_RESOURCE = 10018,
163 NFS4ERR_MOVED = 10019,
164 NFS4ERR_NOFILEHANDLE = 10020,
165 NFS4ERR_MINOR_VERS_MISMATCH = 10021,
166 NFS4ERR_STALE_CLIENTID = 10022,
167 NFS4ERR_STALE_STATEID = 10023,
168 NFS4ERR_OLD_STATEID = 10024,
169 NFS4ERR_BAD_STATEID = 10025,
170 NFS4ERR_BAD_SEQID = 10026,
171 NFS4ERR_NOT_SAME = 10027,
172 NFS4ERR_LOCK_RANGE = 10028,
173 NFS4ERR_SYMLINK = 10029,
174 NFS4ERR_RESTOREFH = 10030,
175 NFS4ERR_LEASE_MOVED = 10031,
176 NFS4ERR_ATTRNOTSUPP = 10032,
177 NFS4ERR_NO_GRACE = 10033,
178 NFS4ERR_RECLAIM_BAD = 10034,
179 NFS4ERR_RECLAIM_CONFLICT = 10035,
180 NFS4ERR_BADXDR = 10036,
181 NFS4ERR_LOCKS_HELD = 10037,
182 NFS4ERR_OPENMODE = 10038,
183 NFS4ERR_BADOWNER = 10039,
184 NFS4ERR_BADCHAR = 10040,
185 NFS4ERR_BADNAME = 10041,
186 NFS4ERR_BAD_RANGE = 10042,
187 NFS4ERR_LOCK_NOTSUPP = 10043,
188 NFS4ERR_OP_ILLEGAL = 10044,
189 NFS4ERR_DEADLOCK = 10045,
190 NFS4ERR_FILE_OPEN = 10046,
191 NFS4ERR_ADMIN_REVOKED = 10047,
192 NFS4ERR_CB_PATH_DOWN = 10048,
193
194
195 NFS4ERR_BADIOMODE = 10049,
196 NFS4ERR_BADLAYOUT = 10050,
197 NFS4ERR_BAD_SESSION_DIGEST = 10051,
198 NFS4ERR_BADSESSION = 10052,
199 NFS4ERR_BADSLOT = 10053,
200 NFS4ERR_COMPLETE_ALREADY = 10054,
201 NFS4ERR_CONN_NOT_BOUND_TO_SESSION = 10055,
202 NFS4ERR_DELEG_ALREADY_WANTED = 10056,
203 NFS4ERR_BACK_CHAN_BUSY = 10057,
204 NFS4ERR_LAYOUTTRYLATER = 10058,
205 NFS4ERR_LAYOUTUNAVAILABLE = 10059,
206 NFS4ERR_NOMATCHING_LAYOUT = 10060,
207 NFS4ERR_RECALLCONFLICT = 10061,
208 NFS4ERR_UNKNOWN_LAYOUTTYPE = 10062,
209 NFS4ERR_SEQ_MISORDERED = 10063,
210 NFS4ERR_SEQUENCE_POS = 10064,
211 NFS4ERR_REQ_TOO_BIG = 10065,
212 NFS4ERR_REP_TOO_BIG = 10066,
213 NFS4ERR_REP_TOO_BIG_TO_CACHE = 10067,
214 NFS4ERR_RETRY_UNCACHED_REP = 10068,
215 NFS4ERR_UNSAFE_COMPOUND = 10069,
216 NFS4ERR_TOO_MANY_OPS = 10070,
217 NFS4ERR_OP_NOT_IN_SESSION = 10071,
218 NFS4ERR_HASH_ALG_UNSUPP = 10072,
219
220 NFS4ERR_CLIENTID_BUSY = 10074,
221 NFS4ERR_PNFS_IO_HOLE = 10075,
222 NFS4ERR_SEQ_FALSE_RETRY = 10076,
223 NFS4ERR_BAD_HIGH_SLOT = 10077,
224 NFS4ERR_DEADSESSION = 10078,
225 NFS4ERR_ENCR_ALG_UNSUPP = 10079,
226 NFS4ERR_PNFS_NO_LAYOUT = 10080,
227 NFS4ERR_NOT_ONLY_OP = 10081,
228 NFS4ERR_WRONG_CRED = 10082,
229 NFS4ERR_WRONG_TYPE = 10083,
230 NFS4ERR_DIRDELEG_UNAVAIL = 10084,
231 NFS4ERR_REJECT_DELEG = 10085,
232 NFS4ERR_RETURNCONFLICT = 10086,
233 NFS4ERR_DELEG_REVOKED = 10087,
234
235
236 NFS4ERR_PARTNER_NOTSUPP = 10088,
237 NFS4ERR_PARTNER_NO_AUTH = 10089,
238 NFS4ERR_METADATA_NOTSUPP = 10090,
239 NFS4ERR_OFFLOAD_DENIED = 10091,
240 NFS4ERR_WRONG_LFS = 10092,
241 NFS4ERR_BADLABEL = 10093,
242};
243
244static inline bool seqid_mutating_err(u32 err)
245{
246
247 switch (err) {
248 case NFS4ERR_STALE_CLIENTID:
249 case NFS4ERR_STALE_STATEID:
250 case NFS4ERR_BAD_STATEID:
251 case NFS4ERR_BAD_SEQID:
252 case NFS4ERR_BADXDR:
253 case NFS4ERR_RESOURCE:
254 case NFS4ERR_NOFILEHANDLE:
255 return false;
256 };
257 return true;
258}
259
260
261
262
263
264enum nfs_ftype4 {
265 NF4BAD = 0,
266 NF4REG = 1,
267 NF4DIR = 2,
268 NF4BLK = 3,
269 NF4CHR = 4,
270 NF4LNK = 5,
271 NF4SOCK = 6,
272 NF4FIFO = 7,
273 NF4ATTRDIR = 8,
274 NF4NAMEDATTR = 9
275};
276
277enum open_claim_type4 {
278 NFS4_OPEN_CLAIM_NULL = 0,
279 NFS4_OPEN_CLAIM_PREVIOUS = 1,
280 NFS4_OPEN_CLAIM_DELEGATE_CUR = 2,
281 NFS4_OPEN_CLAIM_DELEGATE_PREV = 3,
282 NFS4_OPEN_CLAIM_FH = 4,
283 NFS4_OPEN_CLAIM_DELEG_CUR_FH = 5,
284 NFS4_OPEN_CLAIM_DELEG_PREV_FH = 6,
285};
286
287enum opentype4 {
288 NFS4_OPEN_NOCREATE = 0,
289 NFS4_OPEN_CREATE = 1
290};
291
292enum createmode4 {
293 NFS4_CREATE_UNCHECKED = 0,
294 NFS4_CREATE_GUARDED = 1,
295 NFS4_CREATE_EXCLUSIVE = 2,
296
297
298
299
300
301 NFS4_CREATE_EXCLUSIVE4_1 = 3
302};
303
304enum limit_by4 {
305 NFS4_LIMIT_SIZE = 1,
306 NFS4_LIMIT_BLOCKS = 2
307};
308
309enum open_delegation_type4 {
310 NFS4_OPEN_DELEGATE_NONE = 0,
311 NFS4_OPEN_DELEGATE_READ = 1,
312 NFS4_OPEN_DELEGATE_WRITE = 2,
313 NFS4_OPEN_DELEGATE_NONE_EXT = 3,
314};
315
316enum why_no_delegation4 {
317 WND4_NOT_WANTED = 0,
318 WND4_CONTENTION = 1,
319 WND4_RESOURCE = 2,
320 WND4_NOT_SUPP_FTYPE = 3,
321 WND4_WRITE_DELEG_NOT_SUPP_FTYPE = 4,
322 WND4_NOT_SUPP_UPGRADE = 5,
323 WND4_NOT_SUPP_DOWNGRADE = 6,
324 WND4_CANCELLED = 7,
325 WND4_IS_DIR = 8,
326};
327
328enum lock_type4 {
329 NFS4_UNLOCK_LT = 0,
330 NFS4_READ_LT = 1,
331 NFS4_WRITE_LT = 2,
332 NFS4_READW_LT = 3,
333 NFS4_WRITEW_LT = 4
334};
335
336
337
338#define FATTR4_WORD0_SUPPORTED_ATTRS (1UL << 0)
339#define FATTR4_WORD0_TYPE (1UL << 1)
340#define FATTR4_WORD0_FH_EXPIRE_TYPE (1UL << 2)
341#define FATTR4_WORD0_CHANGE (1UL << 3)
342#define FATTR4_WORD0_SIZE (1UL << 4)
343#define FATTR4_WORD0_LINK_SUPPORT (1UL << 5)
344#define FATTR4_WORD0_SYMLINK_SUPPORT (1UL << 6)
345#define FATTR4_WORD0_NAMED_ATTR (1UL << 7)
346#define FATTR4_WORD0_FSID (1UL << 8)
347#define FATTR4_WORD0_UNIQUE_HANDLES (1UL << 9)
348#define FATTR4_WORD0_LEASE_TIME (1UL << 10)
349#define FATTR4_WORD0_RDATTR_ERROR (1UL << 11)
350
351#define FATTR4_WORD2_SUPPATTR_EXCLCREAT (1UL << 11)
352
353
354#define FATTR4_WORD0_ACL (1UL << 12)
355#define FATTR4_WORD0_ACLSUPPORT (1UL << 13)
356#define FATTR4_WORD0_ARCHIVE (1UL << 14)
357#define FATTR4_WORD0_CANSETTIME (1UL << 15)
358#define FATTR4_WORD0_CASE_INSENSITIVE (1UL << 16)
359#define FATTR4_WORD0_CASE_PRESERVING (1UL << 17)
360#define FATTR4_WORD0_CHOWN_RESTRICTED (1UL << 18)
361#define FATTR4_WORD0_FILEHANDLE (1UL << 19)
362#define FATTR4_WORD0_FILEID (1UL << 20)
363#define FATTR4_WORD0_FILES_AVAIL (1UL << 21)
364#define FATTR4_WORD0_FILES_FREE (1UL << 22)
365#define FATTR4_WORD0_FILES_TOTAL (1UL << 23)
366#define FATTR4_WORD0_FS_LOCATIONS (1UL << 24)
367#define FATTR4_WORD0_HIDDEN (1UL << 25)
368#define FATTR4_WORD0_HOMOGENEOUS (1UL << 26)
369#define FATTR4_WORD0_MAXFILESIZE (1UL << 27)
370#define FATTR4_WORD0_MAXLINK (1UL << 28)
371#define FATTR4_WORD0_MAXNAME (1UL << 29)
372#define FATTR4_WORD0_MAXREAD (1UL << 30)
373#define FATTR4_WORD0_MAXWRITE (1UL << 31)
374#define FATTR4_WORD1_MIMETYPE (1UL << 0)
375#define FATTR4_WORD1_MODE (1UL << 1)
376#define FATTR4_WORD1_NO_TRUNC (1UL << 2)
377#define FATTR4_WORD1_NUMLINKS (1UL << 3)
378#define FATTR4_WORD1_OWNER (1UL << 4)
379#define FATTR4_WORD1_OWNER_GROUP (1UL << 5)
380#define FATTR4_WORD1_QUOTA_HARD (1UL << 6)
381#define FATTR4_WORD1_QUOTA_SOFT (1UL << 7)
382#define FATTR4_WORD1_QUOTA_USED (1UL << 8)
383#define FATTR4_WORD1_RAWDEV (1UL << 9)
384#define FATTR4_WORD1_SPACE_AVAIL (1UL << 10)
385#define FATTR4_WORD1_SPACE_FREE (1UL << 11)
386#define FATTR4_WORD1_SPACE_TOTAL (1UL << 12)
387#define FATTR4_WORD1_SPACE_USED (1UL << 13)
388#define FATTR4_WORD1_SYSTEM (1UL << 14)
389#define FATTR4_WORD1_TIME_ACCESS (1UL << 15)
390#define FATTR4_WORD1_TIME_ACCESS_SET (1UL << 16)
391#define FATTR4_WORD1_TIME_BACKUP (1UL << 17)
392#define FATTR4_WORD1_TIME_CREATE (1UL << 18)
393#define FATTR4_WORD1_TIME_DELTA (1UL << 19)
394#define FATTR4_WORD1_TIME_METADATA (1UL << 20)
395#define FATTR4_WORD1_TIME_MODIFY (1UL << 21)
396#define FATTR4_WORD1_TIME_MODIFY_SET (1UL << 22)
397#define FATTR4_WORD1_MOUNTED_ON_FILEID (1UL << 23)
398#define FATTR4_WORD1_FS_LAYOUT_TYPES (1UL << 30)
399#define FATTR4_WORD2_LAYOUT_BLKSIZE (1UL << 1)
400#define FATTR4_WORD2_MDSTHRESHOLD (1UL << 4)
401#define FATTR4_WORD2_SECURITY_LABEL (1UL << 16)
402#define FATTR4_WORD2_CHANGE_SECURITY_LABEL \
403 (1UL << 17)
404
405
406#define THRESHOLD_RD (1UL << 0)
407#define THRESHOLD_WR (1UL << 1)
408#define THRESHOLD_RD_IO (1UL << 2)
409#define THRESHOLD_WR_IO (1UL << 3)
410
411#define NFSPROC4_NULL 0
412#define NFSPROC4_COMPOUND 1
413#define NFS4_VERSION 4
414#define NFS4_MINOR_VERSION 0
415
416#define NFS4_DEBUG 1
417
418
419
420enum {
421 NFSPROC4_CLNT_NULL = 0,
422 NFSPROC4_CLNT_READ,
423 NFSPROC4_CLNT_WRITE,
424 NFSPROC4_CLNT_COMMIT,
425 NFSPROC4_CLNT_OPEN,
426 NFSPROC4_CLNT_OPEN_CONFIRM,
427 NFSPROC4_CLNT_OPEN_NOATTR,
428 NFSPROC4_CLNT_OPEN_DOWNGRADE,
429 NFSPROC4_CLNT_CLOSE,
430 NFSPROC4_CLNT_SETATTR,
431 NFSPROC4_CLNT_FSINFO,
432 NFSPROC4_CLNT_RENEW,
433 NFSPROC4_CLNT_SETCLIENTID,
434 NFSPROC4_CLNT_SETCLIENTID_CONFIRM,
435 NFSPROC4_CLNT_LOCK,
436 NFSPROC4_CLNT_LOCKT,
437 NFSPROC4_CLNT_LOCKU,
438 NFSPROC4_CLNT_ACCESS,
439 NFSPROC4_CLNT_GETATTR,
440 NFSPROC4_CLNT_LOOKUP,
441 NFSPROC4_CLNT_LOOKUP_ROOT,
442 NFSPROC4_CLNT_REMOVE,
443 NFSPROC4_CLNT_RENAME,
444 NFSPROC4_CLNT_LINK,
445 NFSPROC4_CLNT_SYMLINK,
446 NFSPROC4_CLNT_CREATE,
447 NFSPROC4_CLNT_PATHCONF,
448 NFSPROC4_CLNT_STATFS,
449 NFSPROC4_CLNT_READLINK,
450 NFSPROC4_CLNT_READDIR,
451 NFSPROC4_CLNT_SERVER_CAPS,
452 NFSPROC4_CLNT_DELEGRETURN,
453 NFSPROC4_CLNT_GETACL,
454 NFSPROC4_CLNT_SETACL,
455 NFSPROC4_CLNT_FS_LOCATIONS,
456 NFSPROC4_CLNT_RELEASE_LOCKOWNER,
457 NFSPROC4_CLNT_SECINFO,
458 NFSPROC4_CLNT_FSID_PRESENT,
459
460
461 NFSPROC4_CLNT_EXCHANGE_ID,
462 NFSPROC4_CLNT_CREATE_SESSION,
463 NFSPROC4_CLNT_DESTROY_SESSION,
464 NFSPROC4_CLNT_SEQUENCE,
465 NFSPROC4_CLNT_GET_LEASE_TIME,
466 NFSPROC4_CLNT_RECLAIM_COMPLETE,
467 NFSPROC4_CLNT_LAYOUTGET,
468 NFSPROC4_CLNT_GETDEVICEINFO,
469 NFSPROC4_CLNT_LAYOUTCOMMIT,
470 NFSPROC4_CLNT_LAYOUTRETURN,
471 NFSPROC4_CLNT_SECINFO_NO_NAME,
472 NFSPROC4_CLNT_TEST_STATEID,
473 NFSPROC4_CLNT_FREE_STATEID,
474 NFSPROC4_CLNT_GETDEVICELIST,
475 NFSPROC4_CLNT_BIND_CONN_TO_SESSION,
476 NFSPROC4_CLNT_DESTROY_CLIENTID,
477};
478
479
480struct nfs4_sessionid {
481 unsigned char data[NFS4_MAX_SESSIONID_LEN];
482};
483
484
485#define SESSION4_PERSIST 0x001
486#define SESSION4_BACK_CHAN 0x002
487#define SESSION4_RDMA 0x004
488
489#define SESSION4_FLAG_MASK_A 0x007
490
491enum state_protect_how4 {
492 SP4_NONE = 0,
493 SP4_MACH_CRED = 1,
494 SP4_SSV = 2
495};
496
497enum pnfs_layouttype {
498 LAYOUT_NFSV4_1_FILES = 1,
499 LAYOUT_OSD2_OBJECTS = 2,
500 LAYOUT_BLOCK_VOLUME = 3,
501};
502
503
504enum pnfs_layoutreturn_type {
505 RETURN_FILE = 1,
506 RETURN_FSID = 2,
507 RETURN_ALL = 3
508};
509
510enum pnfs_iomode {
511 IOMODE_READ = 1,
512 IOMODE_RW = 2,
513 IOMODE_ANY = 3,
514};
515
516enum pnfs_notify_deviceid_type4 {
517 NOTIFY_DEVICEID4_CHANGE = 1 << 1,
518 NOTIFY_DEVICEID4_DELETE = 1 << 2,
519};
520
521#define NFL4_UFLG_MASK 0x0000003F
522#define NFL4_UFLG_DENSE 0x00000001
523#define NFL4_UFLG_COMMIT_THRU_MDS 0x00000002
524#define NFL4_UFLG_STRIPE_UNIT_SIZE_MASK 0xFFFFFFC0
525
526
527enum filelayout_hint_care4 {
528 NFLH4_CARE_DENSE = NFL4_UFLG_DENSE,
529 NFLH4_CARE_COMMIT_THRU_MDS = NFL4_UFLG_COMMIT_THRU_MDS,
530 NFLH4_CARE_STRIPE_UNIT_SIZE = 0x00000040,
531 NFLH4_CARE_STRIPE_COUNT = 0x00000080
532};
533
534#define NFS4_DEVICEID4_SIZE 16
535
536struct nfs4_deviceid {
537 char data[NFS4_DEVICEID4_SIZE];
538};
539
540#endif
541