blob: c6564ada9bebb8ea0787e60fc8cea3b46d09433c [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 * include/linux/nfs4.h
3 *
4 * NFSv4 protocol definitions.
5 *
6 * Copyright (c) 2002 The Regents of the University of Michigan.
7 * All rights reserved.
8 *
9 * Kendrick Smith <kmsmith@umich.edu>
10 * Andy Adamson <andros@umich.edu>
11 */
Linus Torvalds1da177e2005-04-16 15:20:36 -070012#ifndef _LINUX_NFS4_H
13#define _LINUX_NFS4_H
14
David Woodhouse997b7af2006-04-25 14:51:45 +010015#include <linux/list.h>
Eric W. Biedermanab8e4ae2013-02-02 05:18:08 -080016#include <linux/uidgid.h>
David Howells607ca462012-10-13 10:46:48 +010017#include <uapi/linux/nfs4.h>
David Woodhouse997b7af2006-04-25 14:51:45 +010018
Andreas Gruenbacherbff17522015-03-27 17:50:00 +010019enum nfs4_acl_whotype {
20 NFS4_ACL_WHO_NAMED = 0,
21 NFS4_ACL_WHO_OWNER,
22 NFS4_ACL_WHO_GROUP,
23 NFS4_ACL_WHO_EVERYONE,
24};
25
Linus Torvalds1da177e2005-04-16 15:20:36 -070026struct nfs4_ace {
27 uint32_t type;
28 uint32_t flag;
29 uint32_t access_mask;
30 int whotype;
Eric W. Biedermanab8e4ae2013-02-02 05:18:08 -080031 union {
32 kuid_t who_uid;
33 kgid_t who_gid;
34 };
Linus Torvalds1da177e2005-04-16 15:20:36 -070035};
36
37struct nfs4_acl {
38 uint32_t naces;
J. Bruce Fields28e05dd2007-02-16 01:28:30 -080039 struct nfs4_ace aces[0];
Linus Torvalds1da177e2005-04-16 15:20:36 -070040};
41
Steve Dicksone058f702013-05-22 12:50:40 -040042#define NFS4_MAXLABELLEN 2048
43
44struct nfs4_label {
45 uint32_t lfs;
46 uint32_t pi;
47 u32 len;
48 char *label;
49};
50
Linus Torvalds1da177e2005-04-16 15:20:36 -070051typedef struct { char data[NFS4_VERIFIER_SIZE]; } nfs4_verifier;
Alexandros Batsakis94499252010-10-20 00:17:56 -040052
Trond Myklebust93b717f2016-05-16 17:42:43 -040053struct nfs4_stateid_struct {
54 union {
55 char data[NFS4_STATEID_SIZE];
56 struct {
57 __be32 seqid;
58 char other[NFS4_STATEID_OTHER_SIZE];
59 } __attribute__ ((packed));
60 };
Alexandros Batsakis94499252010-10-20 00:17:56 -040061
Trond Myklebust93b717f2016-05-16 17:42:43 -040062 enum {
63 NFS4_INVALID_STATEID_TYPE = 0,
64 NFS4_SPECIAL_STATEID_TYPE,
65 NFS4_OPEN_STATEID_TYPE,
66 NFS4_LOCK_STATEID_TYPE,
67 NFS4_DELEGATION_STATEID_TYPE,
68 NFS4_LAYOUT_STATEID_TYPE,
69 NFS4_PNFS_DS_STATEID_TYPE,
70 } type;
71};
72
73typedef struct nfs4_stateid_struct nfs4_stateid;
Linus Torvalds1da177e2005-04-16 15:20:36 -070074
75enum nfs_opnum4 {
76 OP_ACCESS = 3,
77 OP_CLOSE = 4,
78 OP_COMMIT = 5,
79 OP_CREATE = 6,
80 OP_DELEGPURGE = 7,
81 OP_DELEGRETURN = 8,
82 OP_GETATTR = 9,
83 OP_GETFH = 10,
84 OP_LINK = 11,
85 OP_LOCK = 12,
86 OP_LOCKT = 13,
87 OP_LOCKU = 14,
88 OP_LOOKUP = 15,
89 OP_LOOKUPP = 16,
90 OP_NVERIFY = 17,
91 OP_OPEN = 18,
92 OP_OPENATTR = 19,
93 OP_OPEN_CONFIRM = 20,
94 OP_OPEN_DOWNGRADE = 21,
95 OP_PUTFH = 22,
96 OP_PUTPUBFH = 23,
97 OP_PUTROOTFH = 24,
98 OP_READ = 25,
99 OP_READDIR = 26,
100 OP_READLINK = 27,
101 OP_REMOVE = 28,
102 OP_RENAME = 29,
103 OP_RENEW = 30,
104 OP_RESTOREFH = 31,
105 OP_SAVEFH = 32,
106 OP_SECINFO = 33,
107 OP_SETATTR = 34,
108 OP_SETCLIENTID = 35,
109 OP_SETCLIENTID_CONFIRM = 36,
110 OP_VERIFY = 37,
111 OP_WRITE = 38,
112 OP_RELEASE_LOCKOWNER = 39,
Benny Halevy18df1882009-04-03 08:27:36 +0300113
114 /* nfs41 */
115 OP_BACKCHANNEL_CTL = 40,
116 OP_BIND_CONN_TO_SESSION = 41,
117 OP_EXCHANGE_ID = 42,
118 OP_CREATE_SESSION = 43,
119 OP_DESTROY_SESSION = 44,
120 OP_FREE_STATEID = 45,
121 OP_GET_DIR_DELEGATION = 46,
122 OP_GETDEVICEINFO = 47,
123 OP_GETDEVICELIST = 48,
124 OP_LAYOUTCOMMIT = 49,
125 OP_LAYOUTGET = 50,
126 OP_LAYOUTRETURN = 51,
127 OP_SECINFO_NO_NAME = 52,
128 OP_SEQUENCE = 53,
129 OP_SET_SSV = 54,
130 OP_TEST_STATEID = 55,
131 OP_WANT_DELEGATION = 56,
132 OP_DESTROY_CLIENTID = 57,
133 OP_RECLAIM_COMPLETE = 58,
134
Anna Schumaker87a15a82014-09-26 13:58:26 -0400135 /* nfs42 */
136 OP_ALLOCATE = 59,
137 OP_COPY = 60,
138 OP_COPY_NOTIFY = 61,
139 OP_DEALLOCATE = 62,
140 OP_IO_ADVISE = 63,
141 OP_LAYOUTERROR = 64,
142 OP_LAYOUTSTATS = 65,
143 OP_OFFLOAD_CANCEL = 66,
144 OP_OFFLOAD_STATUS = 67,
145 OP_READ_PLUS = 68,
146 OP_SEEK = 69,
147 OP_WRITE_SAME = 70,
Peng Tao36022772015-09-26 02:24:34 +0800148 OP_CLONE = 71,
Anna Schumaker87a15a82014-09-26 13:58:26 -0400149
Linus Torvalds1da177e2005-04-16 15:20:36 -0700150 OP_ILLEGAL = 10044,
151};
152
Shankar Anande2b20952006-07-10 04:45:44 -0700153/*Defining first and last NFS4 operations implemented.
154Needs to be updated if more operations are defined in future.*/
155
156#define FIRST_NFS4_OP OP_ACCESS
Anna Schumaker8217d142013-10-30 13:38:13 -0400157#define LAST_NFS40_OP OP_RELEASE_LOCKOWNER
158#define LAST_NFS41_OP OP_RECLAIM_COMPLETE
Christoph Hellwigffa01602015-12-03 12:59:52 +0100159#define LAST_NFS42_OP OP_CLONE
160#define LAST_NFS4_OP LAST_NFS42_OP
Shankar Anande2b20952006-07-10 04:45:44 -0700161
Linus Torvalds1da177e2005-04-16 15:20:36 -0700162enum nfsstat4 {
163 NFS4_OK = 0,
164 NFS4ERR_PERM = 1,
165 NFS4ERR_NOENT = 2,
166 NFS4ERR_IO = 5,
167 NFS4ERR_NXIO = 6,
168 NFS4ERR_ACCESS = 13,
169 NFS4ERR_EXIST = 17,
170 NFS4ERR_XDEV = 18,
171 /* Unused/reserved 19 */
172 NFS4ERR_NOTDIR = 20,
173 NFS4ERR_ISDIR = 21,
174 NFS4ERR_INVAL = 22,
175 NFS4ERR_FBIG = 27,
176 NFS4ERR_NOSPC = 28,
177 NFS4ERR_ROFS = 30,
178 NFS4ERR_MLINK = 31,
179 NFS4ERR_NAMETOOLONG = 63,
180 NFS4ERR_NOTEMPTY = 66,
181 NFS4ERR_DQUOT = 69,
182 NFS4ERR_STALE = 70,
183 NFS4ERR_BADHANDLE = 10001,
184 NFS4ERR_BAD_COOKIE = 10003,
185 NFS4ERR_NOTSUPP = 10004,
186 NFS4ERR_TOOSMALL = 10005,
187 NFS4ERR_SERVERFAULT = 10006,
188 NFS4ERR_BADTYPE = 10007,
189 NFS4ERR_DELAY = 10008,
190 NFS4ERR_SAME = 10009,
191 NFS4ERR_DENIED = 10010,
192 NFS4ERR_EXPIRED = 10011,
193 NFS4ERR_LOCKED = 10012,
194 NFS4ERR_GRACE = 10013,
195 NFS4ERR_FHEXPIRED = 10014,
196 NFS4ERR_SHARE_DENIED = 10015,
197 NFS4ERR_WRONGSEC = 10016,
198 NFS4ERR_CLID_INUSE = 10017,
199 NFS4ERR_RESOURCE = 10018,
200 NFS4ERR_MOVED = 10019,
201 NFS4ERR_NOFILEHANDLE = 10020,
202 NFS4ERR_MINOR_VERS_MISMATCH = 10021,
203 NFS4ERR_STALE_CLIENTID = 10022,
204 NFS4ERR_STALE_STATEID = 10023,
205 NFS4ERR_OLD_STATEID = 10024,
206 NFS4ERR_BAD_STATEID = 10025,
207 NFS4ERR_BAD_SEQID = 10026,
208 NFS4ERR_NOT_SAME = 10027,
209 NFS4ERR_LOCK_RANGE = 10028,
210 NFS4ERR_SYMLINK = 10029,
211 NFS4ERR_RESTOREFH = 10030,
212 NFS4ERR_LEASE_MOVED = 10031,
213 NFS4ERR_ATTRNOTSUPP = 10032,
214 NFS4ERR_NO_GRACE = 10033,
215 NFS4ERR_RECLAIM_BAD = 10034,
216 NFS4ERR_RECLAIM_CONFLICT = 10035,
217 NFS4ERR_BADXDR = 10036,
218 NFS4ERR_LOCKS_HELD = 10037,
219 NFS4ERR_OPENMODE = 10038,
220 NFS4ERR_BADOWNER = 10039,
221 NFS4ERR_BADCHAR = 10040,
222 NFS4ERR_BADNAME = 10041,
223 NFS4ERR_BAD_RANGE = 10042,
224 NFS4ERR_LOCK_NOTSUPP = 10043,
225 NFS4ERR_OP_ILLEGAL = 10044,
226 NFS4ERR_DEADLOCK = 10045,
227 NFS4ERR_FILE_OPEN = 10046,
228 NFS4ERR_ADMIN_REVOKED = 10047,
Benny Halevy18df1882009-04-03 08:27:36 +0300229 NFS4ERR_CB_PATH_DOWN = 10048,
230
231 /* nfs41 */
232 NFS4ERR_BADIOMODE = 10049,
233 NFS4ERR_BADLAYOUT = 10050,
234 NFS4ERR_BAD_SESSION_DIGEST = 10051,
235 NFS4ERR_BADSESSION = 10052,
236 NFS4ERR_BADSLOT = 10053,
237 NFS4ERR_COMPLETE_ALREADY = 10054,
238 NFS4ERR_CONN_NOT_BOUND_TO_SESSION = 10055,
239 NFS4ERR_DELEG_ALREADY_WANTED = 10056,
240 NFS4ERR_BACK_CHAN_BUSY = 10057, /* backchan reqs outstanding */
241 NFS4ERR_LAYOUTTRYLATER = 10058,
242 NFS4ERR_LAYOUTUNAVAILABLE = 10059,
243 NFS4ERR_NOMATCHING_LAYOUT = 10060,
244 NFS4ERR_RECALLCONFLICT = 10061,
245 NFS4ERR_UNKNOWN_LAYOUTTYPE = 10062,
246 NFS4ERR_SEQ_MISORDERED = 10063, /* unexpected seq.id in req */
247 NFS4ERR_SEQUENCE_POS = 10064, /* [CB_]SEQ. op not 1st op */
248 NFS4ERR_REQ_TOO_BIG = 10065, /* request too big */
249 NFS4ERR_REP_TOO_BIG = 10066, /* reply too big */
250 NFS4ERR_REP_TOO_BIG_TO_CACHE = 10067, /* rep. not all cached */
251 NFS4ERR_RETRY_UNCACHED_REP = 10068, /* retry & rep. uncached */
252 NFS4ERR_UNSAFE_COMPOUND = 10069, /* retry/recovery too hard */
253 NFS4ERR_TOO_MANY_OPS = 10070, /* too many ops in [CB_]COMP */
254 NFS4ERR_OP_NOT_IN_SESSION = 10071, /* op needs [CB_]SEQ. op */
255 NFS4ERR_HASH_ALG_UNSUPP = 10072, /* hash alg. not supp. */
256 /* Error 10073 is unused. */
257 NFS4ERR_CLIENTID_BUSY = 10074, /* clientid has state */
258 NFS4ERR_PNFS_IO_HOLE = 10075, /* IO to _SPARSE file hole */
Lucas De Marchi25985ed2011-03-30 22:57:33 -0300259 NFS4ERR_SEQ_FALSE_RETRY = 10076, /* retry not original */
Benny Halevy18df1882009-04-03 08:27:36 +0300260 NFS4ERR_BAD_HIGH_SLOT = 10077, /* sequence arg bad */
261 NFS4ERR_DEADSESSION = 10078, /* persistent session dead */
262 NFS4ERR_ENCR_ALG_UNSUPP = 10079, /* SSV alg mismatch */
263 NFS4ERR_PNFS_NO_LAYOUT = 10080, /* direct I/O with no layout */
264 NFS4ERR_NOT_ONLY_OP = 10081, /* bad compound */
265 NFS4ERR_WRONG_CRED = 10082, /* permissions:state change */
266 NFS4ERR_WRONG_TYPE = 10083, /* current operation mismatch */
267 NFS4ERR_DIRDELEG_UNAVAIL = 10084, /* no directory delegation */
268 NFS4ERR_REJECT_DELEG = 10085, /* on callback */
269 NFS4ERR_RETURNCONFLICT = 10086, /* outstanding layoutreturn */
270 NFS4ERR_DELEG_REVOKED = 10087, /* deleg./layout revoked */
Steve Dickson4488cc92013-05-02 13:18:55 -0400271
272 /* nfs42 */
273 NFS4ERR_PARTNER_NOTSUPP = 10088,
274 NFS4ERR_PARTNER_NO_AUTH = 10089,
Anna Schumaker2b8941b2014-08-27 11:17:56 -0400275 NFS4ERR_UNION_NOTSUPP = 10090,
Steve Dickson4488cc92013-05-02 13:18:55 -0400276 NFS4ERR_OFFLOAD_DENIED = 10091,
277 NFS4ERR_WRONG_LFS = 10092,
278 NFS4ERR_BADLABEL = 10093,
Anna Schumaker2b8941b2014-08-27 11:17:56 -0400279 NFS4ERR_OFFLOAD_NO_REQS = 10094,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700280};
281
J. Bruce Fieldsa9004ab2011-08-23 15:43:04 -0400282static inline bool seqid_mutating_err(u32 err)
283{
284 /* rfc 3530 section 8.1.5: */
285 switch (err) {
286 case NFS4ERR_STALE_CLIENTID:
287 case NFS4ERR_STALE_STATEID:
288 case NFS4ERR_BAD_STATEID:
289 case NFS4ERR_BAD_SEQID:
290 case NFS4ERR_BADXDR:
291 case NFS4ERR_RESOURCE:
292 case NFS4ERR_NOFILEHANDLE:
293 return false;
294 };
295 return true;
296}
297
Linus Torvalds1da177e2005-04-16 15:20:36 -0700298/*
299 * Note: NF4BAD is not actually part of the protocol; it is just used
300 * internally by nfsd.
301 */
302enum nfs_ftype4 {
303 NF4BAD = 0,
304 NF4REG = 1, /* Regular File */
305 NF4DIR = 2, /* Directory */
306 NF4BLK = 3, /* Special File - block device */
307 NF4CHR = 4, /* Special File - character device */
308 NF4LNK = 5, /* Symbolic Link */
309 NF4SOCK = 6, /* Special File - socket */
310 NF4FIFO = 7, /* Special File - fifo */
311 NF4ATTRDIR = 8, /* Attribute Directory */
312 NF4NAMEDATTR = 9 /* Named Attribute */
313};
314
315enum open_claim_type4 {
316 NFS4_OPEN_CLAIM_NULL = 0,
317 NFS4_OPEN_CLAIM_PREVIOUS = 1,
318 NFS4_OPEN_CLAIM_DELEGATE_CUR = 2,
J. Bruce Fields8b289b22011-10-19 11:52:12 -0400319 NFS4_OPEN_CLAIM_DELEGATE_PREV = 3,
320 NFS4_OPEN_CLAIM_FH = 4, /* 4.1 */
321 NFS4_OPEN_CLAIM_DELEG_CUR_FH = 5, /* 4.1 */
322 NFS4_OPEN_CLAIM_DELEG_PREV_FH = 6, /* 4.1 */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700323};
324
325enum opentype4 {
326 NFS4_OPEN_NOCREATE = 0,
327 NFS4_OPEN_CREATE = 1
328};
329
330enum createmode4 {
331 NFS4_CREATE_UNCHECKED = 0,
332 NFS4_CREATE_GUARDED = 1,
Benny Halevy79fb54a2009-04-03 08:29:17 +0300333 NFS4_CREATE_EXCLUSIVE = 2,
334 /*
335 * New to NFSv4.1. If session is persistent,
336 * GUARDED4 MUST be used. Otherwise, use
337 * EXCLUSIVE4_1 instead of EXCLUSIVE4.
338 */
339 NFS4_CREATE_EXCLUSIVE4_1 = 3
Linus Torvalds1da177e2005-04-16 15:20:36 -0700340};
341
342enum limit_by4 {
343 NFS4_LIMIT_SIZE = 1,
344 NFS4_LIMIT_BLOCKS = 2
345};
346
347enum open_delegation_type4 {
348 NFS4_OPEN_DELEGATE_NONE = 0,
349 NFS4_OPEN_DELEGATE_READ = 1,
Benny Halevyd24433c2012-02-16 20:57:17 +0200350 NFS4_OPEN_DELEGATE_WRITE = 2,
351 NFS4_OPEN_DELEGATE_NONE_EXT = 3, /* 4.1 */
352};
353
354enum why_no_delegation4 { /* new to v4.1 */
355 WND4_NOT_WANTED = 0,
356 WND4_CONTENTION = 1,
357 WND4_RESOURCE = 2,
358 WND4_NOT_SUPP_FTYPE = 3,
359 WND4_WRITE_DELEG_NOT_SUPP_FTYPE = 4,
360 WND4_NOT_SUPP_UPGRADE = 5,
361 WND4_NOT_SUPP_DOWNGRADE = 6,
362 WND4_CANCELLED = 7,
363 WND4_IS_DIR = 8,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700364};
365
366enum lock_type4 {
367 NFS4_UNLOCK_LT = 0,
368 NFS4_READ_LT = 1,
369 NFS4_WRITE_LT = 2,
370 NFS4_READW_LT = 3,
371 NFS4_WRITEW_LT = 4
372};
373
374
375/* Mandatory Attributes */
376#define FATTR4_WORD0_SUPPORTED_ATTRS (1UL << 0)
377#define FATTR4_WORD0_TYPE (1UL << 1)
378#define FATTR4_WORD0_FH_EXPIRE_TYPE (1UL << 2)
379#define FATTR4_WORD0_CHANGE (1UL << 3)
380#define FATTR4_WORD0_SIZE (1UL << 4)
381#define FATTR4_WORD0_LINK_SUPPORT (1UL << 5)
382#define FATTR4_WORD0_SYMLINK_SUPPORT (1UL << 6)
383#define FATTR4_WORD0_NAMED_ATTR (1UL << 7)
384#define FATTR4_WORD0_FSID (1UL << 8)
385#define FATTR4_WORD0_UNIQUE_HANDLES (1UL << 9)
386#define FATTR4_WORD0_LEASE_TIME (1UL << 10)
387#define FATTR4_WORD0_RDATTR_ERROR (1UL << 11)
Benny Halevy8c18f202009-04-03 08:29:14 +0300388/* Mandatory in NFSv4.1 */
389#define FATTR4_WORD2_SUPPATTR_EXCLCREAT (1UL << 11)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700390
391/* Recommended Attributes */
392#define FATTR4_WORD0_ACL (1UL << 12)
393#define FATTR4_WORD0_ACLSUPPORT (1UL << 13)
394#define FATTR4_WORD0_ARCHIVE (1UL << 14)
395#define FATTR4_WORD0_CANSETTIME (1UL << 15)
396#define FATTR4_WORD0_CASE_INSENSITIVE (1UL << 16)
397#define FATTR4_WORD0_CASE_PRESERVING (1UL << 17)
398#define FATTR4_WORD0_CHOWN_RESTRICTED (1UL << 18)
399#define FATTR4_WORD0_FILEHANDLE (1UL << 19)
400#define FATTR4_WORD0_FILEID (1UL << 20)
401#define FATTR4_WORD0_FILES_AVAIL (1UL << 21)
402#define FATTR4_WORD0_FILES_FREE (1UL << 22)
403#define FATTR4_WORD0_FILES_TOTAL (1UL << 23)
404#define FATTR4_WORD0_FS_LOCATIONS (1UL << 24)
405#define FATTR4_WORD0_HIDDEN (1UL << 25)
406#define FATTR4_WORD0_HOMOGENEOUS (1UL << 26)
407#define FATTR4_WORD0_MAXFILESIZE (1UL << 27)
408#define FATTR4_WORD0_MAXLINK (1UL << 28)
409#define FATTR4_WORD0_MAXNAME (1UL << 29)
410#define FATTR4_WORD0_MAXREAD (1UL << 30)
411#define FATTR4_WORD0_MAXWRITE (1UL << 31)
412#define FATTR4_WORD1_MIMETYPE (1UL << 0)
413#define FATTR4_WORD1_MODE (1UL << 1)
414#define FATTR4_WORD1_NO_TRUNC (1UL << 2)
415#define FATTR4_WORD1_NUMLINKS (1UL << 3)
416#define FATTR4_WORD1_OWNER (1UL << 4)
417#define FATTR4_WORD1_OWNER_GROUP (1UL << 5)
418#define FATTR4_WORD1_QUOTA_HARD (1UL << 6)
419#define FATTR4_WORD1_QUOTA_SOFT (1UL << 7)
420#define FATTR4_WORD1_QUOTA_USED (1UL << 8)
421#define FATTR4_WORD1_RAWDEV (1UL << 9)
422#define FATTR4_WORD1_SPACE_AVAIL (1UL << 10)
423#define FATTR4_WORD1_SPACE_FREE (1UL << 11)
424#define FATTR4_WORD1_SPACE_TOTAL (1UL << 12)
425#define FATTR4_WORD1_SPACE_USED (1UL << 13)
426#define FATTR4_WORD1_SYSTEM (1UL << 14)
427#define FATTR4_WORD1_TIME_ACCESS (1UL << 15)
428#define FATTR4_WORD1_TIME_ACCESS_SET (1UL << 16)
429#define FATTR4_WORD1_TIME_BACKUP (1UL << 17)
430#define FATTR4_WORD1_TIME_CREATE (1UL << 18)
431#define FATTR4_WORD1_TIME_DELTA (1UL << 19)
432#define FATTR4_WORD1_TIME_METADATA (1UL << 20)
433#define FATTR4_WORD1_TIME_MODIFY (1UL << 21)
434#define FATTR4_WORD1_TIME_MODIFY_SET (1UL << 22)
435#define FATTR4_WORD1_MOUNTED_ON_FILEID (1UL << 23)
Dean Hildebrandc772567d2010-10-20 00:17:55 -0400436#define FATTR4_WORD1_FS_LAYOUT_TYPES (1UL << 30)
Christoph Hellwig9cf514c2014-05-05 13:11:59 +0200437#define FATTR4_WORD2_LAYOUT_TYPES (1UL << 0)
Dean Hildebrandc772567d2010-10-20 00:17:55 -0400438#define FATTR4_WORD2_LAYOUT_BLKSIZE (1UL << 1)
Andy Adamson88034c32012-05-23 05:02:34 -0400439#define FATTR4_WORD2_MDSTHRESHOLD (1UL << 4)
Peng Tao2a92ee92015-09-26 02:24:37 +0800440#define FATTR4_WORD2_CLONE_BLKSIZE (1UL << 13)
Trond Myklebustf3f5a0f2013-11-04 14:38:05 -0500441#define FATTR4_WORD2_SECURITY_LABEL (1UL << 16)
Andy Adamson88034c32012-05-23 05:02:34 -0400442
443/* MDS threshold bitmap bits */
444#define THRESHOLD_RD (1UL << 0)
445#define THRESHOLD_WR (1UL << 1)
446#define THRESHOLD_RD_IO (1UL << 2)
447#define THRESHOLD_WR_IO (1UL << 3)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700448
449#define NFSPROC4_NULL 0
450#define NFSPROC4_COMPOUND 1
Chuck Lever764302c2009-09-08 19:50:03 -0400451#define NFS4_VERSION 4
Linus Torvalds1da177e2005-04-16 15:20:36 -0700452#define NFS4_MINOR_VERSION 0
Mike Sager44549df2009-04-01 09:21:47 -0400453
Linus Torvalds1da177e2005-04-16 15:20:36 -0700454#define NFS4_DEBUG 1
455
Linus Torvalds1da177e2005-04-16 15:20:36 -0700456/* Index of predefined Linux client operations */
457
458enum {
459 NFSPROC4_CLNT_NULL = 0, /* Unused */
460 NFSPROC4_CLNT_READ,
461 NFSPROC4_CLNT_WRITE,
462 NFSPROC4_CLNT_COMMIT,
463 NFSPROC4_CLNT_OPEN,
464 NFSPROC4_CLNT_OPEN_CONFIRM,
465 NFSPROC4_CLNT_OPEN_NOATTR,
466 NFSPROC4_CLNT_OPEN_DOWNGRADE,
467 NFSPROC4_CLNT_CLOSE,
468 NFSPROC4_CLNT_SETATTR,
469 NFSPROC4_CLNT_FSINFO,
470 NFSPROC4_CLNT_RENEW,
471 NFSPROC4_CLNT_SETCLIENTID,
472 NFSPROC4_CLNT_SETCLIENTID_CONFIRM,
473 NFSPROC4_CLNT_LOCK,
474 NFSPROC4_CLNT_LOCKT,
475 NFSPROC4_CLNT_LOCKU,
476 NFSPROC4_CLNT_ACCESS,
477 NFSPROC4_CLNT_GETATTR,
478 NFSPROC4_CLNT_LOOKUP,
479 NFSPROC4_CLNT_LOOKUP_ROOT,
480 NFSPROC4_CLNT_REMOVE,
481 NFSPROC4_CLNT_RENAME,
482 NFSPROC4_CLNT_LINK,
483 NFSPROC4_CLNT_SYMLINK,
484 NFSPROC4_CLNT_CREATE,
485 NFSPROC4_CLNT_PATHCONF,
486 NFSPROC4_CLNT_STATFS,
487 NFSPROC4_CLNT_READLINK,
488 NFSPROC4_CLNT_READDIR,
489 NFSPROC4_CLNT_SERVER_CAPS,
490 NFSPROC4_CLNT_DELEGRETURN,
J. Bruce Fields029d1052005-06-22 17:16:22 +0000491 NFSPROC4_CLNT_GETACL,
J. Bruce Fields23ec6962005-06-22 17:16:22 +0000492 NFSPROC4_CLNT_SETACL,
Trond Myklebust683b57b2006-06-09 09:34:22 -0400493 NFSPROC4_CLNT_FS_LOCATIONS,
Trond Myklebustd3c7b7c2010-07-01 12:49:01 -0400494 NFSPROC4_CLNT_RELEASE_LOCKOWNER,
Bryan Schumaker5a5ea0d2011-03-24 17:12:29 +0000495 NFSPROC4_CLNT_SECINFO,
Chuck Lever44c99932013-10-17 14:13:30 -0400496 NFSPROC4_CLNT_FSID_PRESENT,
Benny Halevy18df1882009-04-03 08:27:36 +0300497
498 /* nfs41 */
499 NFSPROC4_CLNT_EXCHANGE_ID,
500 NFSPROC4_CLNT_CREATE_SESSION,
501 NFSPROC4_CLNT_DESTROY_SESSION,
502 NFSPROC4_CLNT_SEQUENCE,
503 NFSPROC4_CLNT_GET_LEASE_TIME,
Ricardo Labiaga180197532009-12-05 16:08:40 -0500504 NFSPROC4_CLNT_RECLAIM_COMPLETE,
Andy Adamsonb1f69b72010-10-20 00:18:03 -0400505 NFSPROC4_CLNT_LAYOUTGET,
506 NFSPROC4_CLNT_GETDEVICEINFO,
Andy Adamson863a3c62011-03-23 13:27:54 +0000507 NFSPROC4_CLNT_LAYOUTCOMMIT,
Benny Halevycbe82602011-05-22 19:52:37 +0300508 NFSPROC4_CLNT_LAYOUTRETURN,
Bryan Schumakerfca78d62011-06-02 14:59:07 -0400509 NFSPROC4_CLNT_SECINFO_NO_NAME,
Bryan Schumaker7d974792011-06-02 14:59:08 -0400510 NFSPROC4_CLNT_TEST_STATEID,
Bryan Schumaker9aeda352011-06-02 14:59:09 -0400511 NFSPROC4_CLNT_FREE_STATEID,
Andy Adamson7f11d8d2011-07-30 20:52:35 -0400512 NFSPROC4_CLNT_GETDEVICELIST,
Trond Myklebustad24ecf2012-05-25 17:11:42 -0400513 NFSPROC4_CLNT_BIND_CONN_TO_SESSION,
Trond Myklebust66245532012-05-25 17:18:09 -0400514 NFSPROC4_CLNT_DESTROY_CLIENTID,
Anna Schumaker1c6dcbe2014-09-26 13:58:48 -0400515
516 /* nfs42 */
517 NFSPROC4_CLNT_SEEK,
Anna Schumakerf4ac1672014-11-25 13:18:15 -0500518 NFSPROC4_CLNT_ALLOCATE,
Anna Schumaker624bd5b2014-11-25 13:18:16 -0500519 NFSPROC4_CLNT_DEALLOCATE,
Trond Myklebustbe3a5d22015-06-23 19:51:55 +0800520 NFSPROC4_CLNT_LAYOUTSTATS,
Peng Tao36022772015-09-26 02:24:34 +0800521 NFSPROC4_CLNT_CLONE,
Anna Schumaker2e724482013-05-21 16:53:03 -0400522 NFSPROC4_CLNT_COPY,
Benny Halevy18df1882009-04-03 08:27:36 +0300523};
524
525/* nfs41 types */
526struct nfs4_sessionid {
527 unsigned char data[NFS4_MAX_SESSIONID_LEN];
528};
529
530/* Create Session Flags */
Mi Jinlonga62573d2011-03-23 17:57:07 +0800531#define SESSION4_PERSIST 0x001
532#define SESSION4_BACK_CHAN 0x002
533#define SESSION4_RDMA 0x004
534
535#define SESSION4_FLAG_MASK_A 0x007
Benny Halevy18df1882009-04-03 08:27:36 +0300536
537enum state_protect_how4 {
538 SP4_NONE = 0,
539 SP4_MACH_CRED = 1,
540 SP4_SSV = 2
Linus Torvalds1da177e2005-04-16 15:20:36 -0700541};
542
Dean Hildebrandc772567d2010-10-20 00:17:55 -0400543enum pnfs_layouttype {
544 LAYOUT_NFSV4_1_FILES = 1,
545 LAYOUT_OSD2_OBJECTS = 2,
546 LAYOUT_BLOCK_VOLUME = 3,
Tom Haynesd67ae822014-12-11 17:02:04 -0500547 LAYOUT_FLEX_FILES = 4,
Christoph Hellwig40cf4462016-03-04 20:46:14 +0100548 LAYOUT_SCSI = 5,
Christoph Hellwig6cae0a42014-08-16 13:31:51 +0200549 LAYOUT_TYPE_MAX
Dean Hildebrandc772567d2010-10-20 00:17:55 -0400550};
551
552/* used for both layout return and recall */
553enum pnfs_layoutreturn_type {
554 RETURN_FILE = 1,
555 RETURN_FSID = 2,
556 RETURN_ALL = 3
557};
558
559enum pnfs_iomode {
560 IOMODE_READ = 1,
561 IOMODE_RW = 2,
562 IOMODE_ANY = 3,
563};
564
565enum pnfs_notify_deviceid_type4 {
566 NOTIFY_DEVICEID4_CHANGE = 1 << 1,
567 NOTIFY_DEVICEID4_DELETE = 1 << 2,
568};
569
Christoph Hellwig8bb28972015-08-17 18:41:01 +0200570enum pnfs_block_volume_type {
571 PNFS_BLOCK_VOLUME_SIMPLE = 0,
572 PNFS_BLOCK_VOLUME_SLICE = 1,
573 PNFS_BLOCK_VOLUME_CONCAT = 2,
574 PNFS_BLOCK_VOLUME_STRIPE = 3,
Christoph Hellwig40cf4462016-03-04 20:46:14 +0100575 PNFS_BLOCK_VOLUME_SCSI = 4,
Christoph Hellwig8bb28972015-08-17 18:41:01 +0200576};
577
578enum pnfs_block_extent_state {
579 PNFS_BLOCK_READWRITE_DATA = 0,
580 PNFS_BLOCK_READ_DATA = 1,
581 PNFS_BLOCK_INVALID_DATA = 2,
582 PNFS_BLOCK_NONE_DATA = 3,
583};
584
585/* on the wire size of a block layout extent */
586#define PNFS_BLOCK_EXTENT_SIZE \
587 (7 * sizeof(__be32) + NFS4_DEVICEID4_SIZE)
588
Christoph Hellwig40cf4462016-03-04 20:46:14 +0100589/* on the wire size of a scsi commit range */
590#define PNFS_SCSI_RANGE_SIZE \
591 (4 * sizeof(__be32))
592
593enum scsi_code_set {
594 PS_CODE_SET_BINARY = 1,
595 PS_CODE_SET_ASCII = 2,
596 PS_CODE_SET_UTF8 = 3
597};
598
599enum scsi_designator_type {
600 PS_DESIGNATOR_T10 = 1,
601 PS_DESIGNATOR_EUI64 = 2,
602 PS_DESIGNATOR_NAA = 3,
603 PS_DESIGNATOR_NAME = 8
604};
605
Dean Hildebrandc772567d2010-10-20 00:17:55 -0400606#define NFL4_UFLG_MASK 0x0000003F
607#define NFL4_UFLG_DENSE 0x00000001
608#define NFL4_UFLG_COMMIT_THRU_MDS 0x00000002
609#define NFL4_UFLG_STRIPE_UNIT_SIZE_MASK 0xFFFFFFC0
610
611/* Encoded in the loh_body field of type layouthint4 */
612enum filelayout_hint_care4 {
613 NFLH4_CARE_DENSE = NFL4_UFLG_DENSE,
614 NFLH4_CARE_COMMIT_THRU_MDS = NFL4_UFLG_COMMIT_THRU_MDS,
615 NFLH4_CARE_STRIPE_UNIT_SIZE = 0x00000040,
616 NFLH4_CARE_STRIPE_COUNT = 0x00000080
617};
618
619#define NFS4_DEVICEID4_SIZE 16
620
621struct nfs4_deviceid {
622 char data[NFS4_DEVICEID4_SIZE];
623};
624
Anna Schumaker24bab492014-09-26 13:58:27 -0400625enum data_content4 {
626 NFS4_CONTENT_DATA = 0,
627 NFS4_CONTENT_HOLE = 1,
628};
629
Jeff Layton9a4bf312015-12-10 10:41:58 -0500630enum pnfs_update_layout_reason {
631 PNFS_UPDATE_LAYOUT_UNKNOWN = 0,
632 PNFS_UPDATE_LAYOUT_NO_PNFS,
633 PNFS_UPDATE_LAYOUT_RD_ZEROLEN,
634 PNFS_UPDATE_LAYOUT_MDSTHRESH,
635 PNFS_UPDATE_LAYOUT_NOMEM,
636 PNFS_UPDATE_LAYOUT_BULK_RECALL,
637 PNFS_UPDATE_LAYOUT_IO_TEST_FAIL,
638 PNFS_UPDATE_LAYOUT_FOUND_CACHED,
639 PNFS_UPDATE_LAYOUT_RETURN,
Jeff Layton183d9e72016-05-17 12:28:47 -0400640 PNFS_UPDATE_LAYOUT_RETRY,
Jeff Layton9a4bf312015-12-10 10:41:58 -0500641 PNFS_UPDATE_LAYOUT_BLOCKED,
Jeff Layton183d9e72016-05-17 12:28:47 -0400642 PNFS_UPDATE_LAYOUT_INVALID_OPEN,
Jeff Layton9a4bf312015-12-10 10:41:58 -0500643 PNFS_UPDATE_LAYOUT_SEND_LAYOUTGET,
644};
645
Andrew Elble1adf0c52016-06-15 12:52:07 -0400646#define NFS4_OP_MAP_NUM_LONGS \
647 DIV_ROUND_UP(LAST_NFS4_OP, 8 * sizeof(unsigned long))
648#define NFS4_OP_MAP_NUM_WORDS \
649 (NFS4_OP_MAP_NUM_LONGS * sizeof(unsigned long) / sizeof(u32))
650struct nfs4_op_map {
651 union {
652 unsigned long longs[NFS4_OP_MAP_NUM_LONGS];
653 u32 words[NFS4_OP_MAP_NUM_WORDS];
654 } u;
655};
656
Linus Torvalds1da177e2005-04-16 15:20:36 -0700657#endif