blob: 00121f298269590cabc12ce7924f61d8e8742e07 [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 Myklebust2d2f24a2012-03-04 18:13:57 -050053struct nfs_stateid4 {
Alexandros Batsakis94499252010-10-20 00:17:56 -040054 __be32 seqid;
55 char other[NFS4_STATEID_OTHER_SIZE];
56} __attribute__ ((packed));
57
Trond Myklebust2d2f24a2012-03-04 18:13:57 -050058typedef struct nfs_stateid4 nfs4_stateid;
Linus Torvalds1da177e2005-04-16 15:20:36 -070059
60enum nfs_opnum4 {
61 OP_ACCESS = 3,
62 OP_CLOSE = 4,
63 OP_COMMIT = 5,
64 OP_CREATE = 6,
65 OP_DELEGPURGE = 7,
66 OP_DELEGRETURN = 8,
67 OP_GETATTR = 9,
68 OP_GETFH = 10,
69 OP_LINK = 11,
70 OP_LOCK = 12,
71 OP_LOCKT = 13,
72 OP_LOCKU = 14,
73 OP_LOOKUP = 15,
74 OP_LOOKUPP = 16,
75 OP_NVERIFY = 17,
76 OP_OPEN = 18,
77 OP_OPENATTR = 19,
78 OP_OPEN_CONFIRM = 20,
79 OP_OPEN_DOWNGRADE = 21,
80 OP_PUTFH = 22,
81 OP_PUTPUBFH = 23,
82 OP_PUTROOTFH = 24,
83 OP_READ = 25,
84 OP_READDIR = 26,
85 OP_READLINK = 27,
86 OP_REMOVE = 28,
87 OP_RENAME = 29,
88 OP_RENEW = 30,
89 OP_RESTOREFH = 31,
90 OP_SAVEFH = 32,
91 OP_SECINFO = 33,
92 OP_SETATTR = 34,
93 OP_SETCLIENTID = 35,
94 OP_SETCLIENTID_CONFIRM = 36,
95 OP_VERIFY = 37,
96 OP_WRITE = 38,
97 OP_RELEASE_LOCKOWNER = 39,
Benny Halevy18df1882009-04-03 08:27:36 +030098
99 /* nfs41 */
100 OP_BACKCHANNEL_CTL = 40,
101 OP_BIND_CONN_TO_SESSION = 41,
102 OP_EXCHANGE_ID = 42,
103 OP_CREATE_SESSION = 43,
104 OP_DESTROY_SESSION = 44,
105 OP_FREE_STATEID = 45,
106 OP_GET_DIR_DELEGATION = 46,
107 OP_GETDEVICEINFO = 47,
108 OP_GETDEVICELIST = 48,
109 OP_LAYOUTCOMMIT = 49,
110 OP_LAYOUTGET = 50,
111 OP_LAYOUTRETURN = 51,
112 OP_SECINFO_NO_NAME = 52,
113 OP_SEQUENCE = 53,
114 OP_SET_SSV = 54,
115 OP_TEST_STATEID = 55,
116 OP_WANT_DELEGATION = 56,
117 OP_DESTROY_CLIENTID = 57,
118 OP_RECLAIM_COMPLETE = 58,
119
Anna Schumaker87a15a82014-09-26 13:58:26 -0400120 /* nfs42 */
121 OP_ALLOCATE = 59,
122 OP_COPY = 60,
123 OP_COPY_NOTIFY = 61,
124 OP_DEALLOCATE = 62,
125 OP_IO_ADVISE = 63,
126 OP_LAYOUTERROR = 64,
127 OP_LAYOUTSTATS = 65,
128 OP_OFFLOAD_CANCEL = 66,
129 OP_OFFLOAD_STATUS = 67,
130 OP_READ_PLUS = 68,
131 OP_SEEK = 69,
132 OP_WRITE_SAME = 70,
133
Linus Torvalds1da177e2005-04-16 15:20:36 -0700134 OP_ILLEGAL = 10044,
135};
136
Shankar Anande2b20952006-07-10 04:45:44 -0700137/*Defining first and last NFS4 operations implemented.
138Needs to be updated if more operations are defined in future.*/
139
140#define FIRST_NFS4_OP OP_ACCESS
Anna Schumaker87a15a82014-09-26 13:58:26 -0400141#define LAST_NFS4_OP OP_WRITE_SAME
Anna Schumaker8217d142013-10-30 13:38:13 -0400142#define LAST_NFS40_OP OP_RELEASE_LOCKOWNER
143#define LAST_NFS41_OP OP_RECLAIM_COMPLETE
Anna Schumaker87a15a82014-09-26 13:58:26 -0400144#define LAST_NFS42_OP OP_WRITE_SAME
Shankar Anande2b20952006-07-10 04:45:44 -0700145
Linus Torvalds1da177e2005-04-16 15:20:36 -0700146enum nfsstat4 {
147 NFS4_OK = 0,
148 NFS4ERR_PERM = 1,
149 NFS4ERR_NOENT = 2,
150 NFS4ERR_IO = 5,
151 NFS4ERR_NXIO = 6,
152 NFS4ERR_ACCESS = 13,
153 NFS4ERR_EXIST = 17,
154 NFS4ERR_XDEV = 18,
155 /* Unused/reserved 19 */
156 NFS4ERR_NOTDIR = 20,
157 NFS4ERR_ISDIR = 21,
158 NFS4ERR_INVAL = 22,
159 NFS4ERR_FBIG = 27,
160 NFS4ERR_NOSPC = 28,
161 NFS4ERR_ROFS = 30,
162 NFS4ERR_MLINK = 31,
163 NFS4ERR_NAMETOOLONG = 63,
164 NFS4ERR_NOTEMPTY = 66,
165 NFS4ERR_DQUOT = 69,
166 NFS4ERR_STALE = 70,
167 NFS4ERR_BADHANDLE = 10001,
168 NFS4ERR_BAD_COOKIE = 10003,
169 NFS4ERR_NOTSUPP = 10004,
170 NFS4ERR_TOOSMALL = 10005,
171 NFS4ERR_SERVERFAULT = 10006,
172 NFS4ERR_BADTYPE = 10007,
173 NFS4ERR_DELAY = 10008,
174 NFS4ERR_SAME = 10009,
175 NFS4ERR_DENIED = 10010,
176 NFS4ERR_EXPIRED = 10011,
177 NFS4ERR_LOCKED = 10012,
178 NFS4ERR_GRACE = 10013,
179 NFS4ERR_FHEXPIRED = 10014,
180 NFS4ERR_SHARE_DENIED = 10015,
181 NFS4ERR_WRONGSEC = 10016,
182 NFS4ERR_CLID_INUSE = 10017,
183 NFS4ERR_RESOURCE = 10018,
184 NFS4ERR_MOVED = 10019,
185 NFS4ERR_NOFILEHANDLE = 10020,
186 NFS4ERR_MINOR_VERS_MISMATCH = 10021,
187 NFS4ERR_STALE_CLIENTID = 10022,
188 NFS4ERR_STALE_STATEID = 10023,
189 NFS4ERR_OLD_STATEID = 10024,
190 NFS4ERR_BAD_STATEID = 10025,
191 NFS4ERR_BAD_SEQID = 10026,
192 NFS4ERR_NOT_SAME = 10027,
193 NFS4ERR_LOCK_RANGE = 10028,
194 NFS4ERR_SYMLINK = 10029,
195 NFS4ERR_RESTOREFH = 10030,
196 NFS4ERR_LEASE_MOVED = 10031,
197 NFS4ERR_ATTRNOTSUPP = 10032,
198 NFS4ERR_NO_GRACE = 10033,
199 NFS4ERR_RECLAIM_BAD = 10034,
200 NFS4ERR_RECLAIM_CONFLICT = 10035,
201 NFS4ERR_BADXDR = 10036,
202 NFS4ERR_LOCKS_HELD = 10037,
203 NFS4ERR_OPENMODE = 10038,
204 NFS4ERR_BADOWNER = 10039,
205 NFS4ERR_BADCHAR = 10040,
206 NFS4ERR_BADNAME = 10041,
207 NFS4ERR_BAD_RANGE = 10042,
208 NFS4ERR_LOCK_NOTSUPP = 10043,
209 NFS4ERR_OP_ILLEGAL = 10044,
210 NFS4ERR_DEADLOCK = 10045,
211 NFS4ERR_FILE_OPEN = 10046,
212 NFS4ERR_ADMIN_REVOKED = 10047,
Benny Halevy18df1882009-04-03 08:27:36 +0300213 NFS4ERR_CB_PATH_DOWN = 10048,
214
215 /* nfs41 */
216 NFS4ERR_BADIOMODE = 10049,
217 NFS4ERR_BADLAYOUT = 10050,
218 NFS4ERR_BAD_SESSION_DIGEST = 10051,
219 NFS4ERR_BADSESSION = 10052,
220 NFS4ERR_BADSLOT = 10053,
221 NFS4ERR_COMPLETE_ALREADY = 10054,
222 NFS4ERR_CONN_NOT_BOUND_TO_SESSION = 10055,
223 NFS4ERR_DELEG_ALREADY_WANTED = 10056,
224 NFS4ERR_BACK_CHAN_BUSY = 10057, /* backchan reqs outstanding */
225 NFS4ERR_LAYOUTTRYLATER = 10058,
226 NFS4ERR_LAYOUTUNAVAILABLE = 10059,
227 NFS4ERR_NOMATCHING_LAYOUT = 10060,
228 NFS4ERR_RECALLCONFLICT = 10061,
229 NFS4ERR_UNKNOWN_LAYOUTTYPE = 10062,
230 NFS4ERR_SEQ_MISORDERED = 10063, /* unexpected seq.id in req */
231 NFS4ERR_SEQUENCE_POS = 10064, /* [CB_]SEQ. op not 1st op */
232 NFS4ERR_REQ_TOO_BIG = 10065, /* request too big */
233 NFS4ERR_REP_TOO_BIG = 10066, /* reply too big */
234 NFS4ERR_REP_TOO_BIG_TO_CACHE = 10067, /* rep. not all cached */
235 NFS4ERR_RETRY_UNCACHED_REP = 10068, /* retry & rep. uncached */
236 NFS4ERR_UNSAFE_COMPOUND = 10069, /* retry/recovery too hard */
237 NFS4ERR_TOO_MANY_OPS = 10070, /* too many ops in [CB_]COMP */
238 NFS4ERR_OP_NOT_IN_SESSION = 10071, /* op needs [CB_]SEQ. op */
239 NFS4ERR_HASH_ALG_UNSUPP = 10072, /* hash alg. not supp. */
240 /* Error 10073 is unused. */
241 NFS4ERR_CLIENTID_BUSY = 10074, /* clientid has state */
242 NFS4ERR_PNFS_IO_HOLE = 10075, /* IO to _SPARSE file hole */
Lucas De Marchi25985ed2011-03-30 22:57:33 -0300243 NFS4ERR_SEQ_FALSE_RETRY = 10076, /* retry not original */
Benny Halevy18df1882009-04-03 08:27:36 +0300244 NFS4ERR_BAD_HIGH_SLOT = 10077, /* sequence arg bad */
245 NFS4ERR_DEADSESSION = 10078, /* persistent session dead */
246 NFS4ERR_ENCR_ALG_UNSUPP = 10079, /* SSV alg mismatch */
247 NFS4ERR_PNFS_NO_LAYOUT = 10080, /* direct I/O with no layout */
248 NFS4ERR_NOT_ONLY_OP = 10081, /* bad compound */
249 NFS4ERR_WRONG_CRED = 10082, /* permissions:state change */
250 NFS4ERR_WRONG_TYPE = 10083, /* current operation mismatch */
251 NFS4ERR_DIRDELEG_UNAVAIL = 10084, /* no directory delegation */
252 NFS4ERR_REJECT_DELEG = 10085, /* on callback */
253 NFS4ERR_RETURNCONFLICT = 10086, /* outstanding layoutreturn */
254 NFS4ERR_DELEG_REVOKED = 10087, /* deleg./layout revoked */
Steve Dickson4488cc92013-05-02 13:18:55 -0400255
256 /* nfs42 */
257 NFS4ERR_PARTNER_NOTSUPP = 10088,
258 NFS4ERR_PARTNER_NO_AUTH = 10089,
Anna Schumaker2b8941b2014-08-27 11:17:56 -0400259 NFS4ERR_UNION_NOTSUPP = 10090,
Steve Dickson4488cc92013-05-02 13:18:55 -0400260 NFS4ERR_OFFLOAD_DENIED = 10091,
261 NFS4ERR_WRONG_LFS = 10092,
262 NFS4ERR_BADLABEL = 10093,
Anna Schumaker2b8941b2014-08-27 11:17:56 -0400263 NFS4ERR_OFFLOAD_NO_REQS = 10094,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700264};
265
J. Bruce Fieldsa9004ab2011-08-23 15:43:04 -0400266static inline bool seqid_mutating_err(u32 err)
267{
268 /* rfc 3530 section 8.1.5: */
269 switch (err) {
270 case NFS4ERR_STALE_CLIENTID:
271 case NFS4ERR_STALE_STATEID:
272 case NFS4ERR_BAD_STATEID:
273 case NFS4ERR_BAD_SEQID:
274 case NFS4ERR_BADXDR:
275 case NFS4ERR_RESOURCE:
276 case NFS4ERR_NOFILEHANDLE:
277 return false;
278 };
279 return true;
280}
281
Linus Torvalds1da177e2005-04-16 15:20:36 -0700282/*
283 * Note: NF4BAD is not actually part of the protocol; it is just used
284 * internally by nfsd.
285 */
286enum nfs_ftype4 {
287 NF4BAD = 0,
288 NF4REG = 1, /* Regular File */
289 NF4DIR = 2, /* Directory */
290 NF4BLK = 3, /* Special File - block device */
291 NF4CHR = 4, /* Special File - character device */
292 NF4LNK = 5, /* Symbolic Link */
293 NF4SOCK = 6, /* Special File - socket */
294 NF4FIFO = 7, /* Special File - fifo */
295 NF4ATTRDIR = 8, /* Attribute Directory */
296 NF4NAMEDATTR = 9 /* Named Attribute */
297};
298
299enum open_claim_type4 {
300 NFS4_OPEN_CLAIM_NULL = 0,
301 NFS4_OPEN_CLAIM_PREVIOUS = 1,
302 NFS4_OPEN_CLAIM_DELEGATE_CUR = 2,
J. Bruce Fields8b289b22011-10-19 11:52:12 -0400303 NFS4_OPEN_CLAIM_DELEGATE_PREV = 3,
304 NFS4_OPEN_CLAIM_FH = 4, /* 4.1 */
305 NFS4_OPEN_CLAIM_DELEG_CUR_FH = 5, /* 4.1 */
306 NFS4_OPEN_CLAIM_DELEG_PREV_FH = 6, /* 4.1 */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700307};
308
309enum opentype4 {
310 NFS4_OPEN_NOCREATE = 0,
311 NFS4_OPEN_CREATE = 1
312};
313
314enum createmode4 {
315 NFS4_CREATE_UNCHECKED = 0,
316 NFS4_CREATE_GUARDED = 1,
Benny Halevy79fb54a2009-04-03 08:29:17 +0300317 NFS4_CREATE_EXCLUSIVE = 2,
318 /*
319 * New to NFSv4.1. If session is persistent,
320 * GUARDED4 MUST be used. Otherwise, use
321 * EXCLUSIVE4_1 instead of EXCLUSIVE4.
322 */
323 NFS4_CREATE_EXCLUSIVE4_1 = 3
Linus Torvalds1da177e2005-04-16 15:20:36 -0700324};
325
326enum limit_by4 {
327 NFS4_LIMIT_SIZE = 1,
328 NFS4_LIMIT_BLOCKS = 2
329};
330
331enum open_delegation_type4 {
332 NFS4_OPEN_DELEGATE_NONE = 0,
333 NFS4_OPEN_DELEGATE_READ = 1,
Benny Halevyd24433c2012-02-16 20:57:17 +0200334 NFS4_OPEN_DELEGATE_WRITE = 2,
335 NFS4_OPEN_DELEGATE_NONE_EXT = 3, /* 4.1 */
336};
337
338enum why_no_delegation4 { /* new to v4.1 */
339 WND4_NOT_WANTED = 0,
340 WND4_CONTENTION = 1,
341 WND4_RESOURCE = 2,
342 WND4_NOT_SUPP_FTYPE = 3,
343 WND4_WRITE_DELEG_NOT_SUPP_FTYPE = 4,
344 WND4_NOT_SUPP_UPGRADE = 5,
345 WND4_NOT_SUPP_DOWNGRADE = 6,
346 WND4_CANCELLED = 7,
347 WND4_IS_DIR = 8,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700348};
349
350enum lock_type4 {
351 NFS4_UNLOCK_LT = 0,
352 NFS4_READ_LT = 1,
353 NFS4_WRITE_LT = 2,
354 NFS4_READW_LT = 3,
355 NFS4_WRITEW_LT = 4
356};
357
358
359/* Mandatory Attributes */
360#define FATTR4_WORD0_SUPPORTED_ATTRS (1UL << 0)
361#define FATTR4_WORD0_TYPE (1UL << 1)
362#define FATTR4_WORD0_FH_EXPIRE_TYPE (1UL << 2)
363#define FATTR4_WORD0_CHANGE (1UL << 3)
364#define FATTR4_WORD0_SIZE (1UL << 4)
365#define FATTR4_WORD0_LINK_SUPPORT (1UL << 5)
366#define FATTR4_WORD0_SYMLINK_SUPPORT (1UL << 6)
367#define FATTR4_WORD0_NAMED_ATTR (1UL << 7)
368#define FATTR4_WORD0_FSID (1UL << 8)
369#define FATTR4_WORD0_UNIQUE_HANDLES (1UL << 9)
370#define FATTR4_WORD0_LEASE_TIME (1UL << 10)
371#define FATTR4_WORD0_RDATTR_ERROR (1UL << 11)
Benny Halevy8c18f202009-04-03 08:29:14 +0300372/* Mandatory in NFSv4.1 */
373#define FATTR4_WORD2_SUPPATTR_EXCLCREAT (1UL << 11)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700374
375/* Recommended Attributes */
376#define FATTR4_WORD0_ACL (1UL << 12)
377#define FATTR4_WORD0_ACLSUPPORT (1UL << 13)
378#define FATTR4_WORD0_ARCHIVE (1UL << 14)
379#define FATTR4_WORD0_CANSETTIME (1UL << 15)
380#define FATTR4_WORD0_CASE_INSENSITIVE (1UL << 16)
381#define FATTR4_WORD0_CASE_PRESERVING (1UL << 17)
382#define FATTR4_WORD0_CHOWN_RESTRICTED (1UL << 18)
383#define FATTR4_WORD0_FILEHANDLE (1UL << 19)
384#define FATTR4_WORD0_FILEID (1UL << 20)
385#define FATTR4_WORD0_FILES_AVAIL (1UL << 21)
386#define FATTR4_WORD0_FILES_FREE (1UL << 22)
387#define FATTR4_WORD0_FILES_TOTAL (1UL << 23)
388#define FATTR4_WORD0_FS_LOCATIONS (1UL << 24)
389#define FATTR4_WORD0_HIDDEN (1UL << 25)
390#define FATTR4_WORD0_HOMOGENEOUS (1UL << 26)
391#define FATTR4_WORD0_MAXFILESIZE (1UL << 27)
392#define FATTR4_WORD0_MAXLINK (1UL << 28)
393#define FATTR4_WORD0_MAXNAME (1UL << 29)
394#define FATTR4_WORD0_MAXREAD (1UL << 30)
395#define FATTR4_WORD0_MAXWRITE (1UL << 31)
396#define FATTR4_WORD1_MIMETYPE (1UL << 0)
397#define FATTR4_WORD1_MODE (1UL << 1)
398#define FATTR4_WORD1_NO_TRUNC (1UL << 2)
399#define FATTR4_WORD1_NUMLINKS (1UL << 3)
400#define FATTR4_WORD1_OWNER (1UL << 4)
401#define FATTR4_WORD1_OWNER_GROUP (1UL << 5)
402#define FATTR4_WORD1_QUOTA_HARD (1UL << 6)
403#define FATTR4_WORD1_QUOTA_SOFT (1UL << 7)
404#define FATTR4_WORD1_QUOTA_USED (1UL << 8)
405#define FATTR4_WORD1_RAWDEV (1UL << 9)
406#define FATTR4_WORD1_SPACE_AVAIL (1UL << 10)
407#define FATTR4_WORD1_SPACE_FREE (1UL << 11)
408#define FATTR4_WORD1_SPACE_TOTAL (1UL << 12)
409#define FATTR4_WORD1_SPACE_USED (1UL << 13)
410#define FATTR4_WORD1_SYSTEM (1UL << 14)
411#define FATTR4_WORD1_TIME_ACCESS (1UL << 15)
412#define FATTR4_WORD1_TIME_ACCESS_SET (1UL << 16)
413#define FATTR4_WORD1_TIME_BACKUP (1UL << 17)
414#define FATTR4_WORD1_TIME_CREATE (1UL << 18)
415#define FATTR4_WORD1_TIME_DELTA (1UL << 19)
416#define FATTR4_WORD1_TIME_METADATA (1UL << 20)
417#define FATTR4_WORD1_TIME_MODIFY (1UL << 21)
418#define FATTR4_WORD1_TIME_MODIFY_SET (1UL << 22)
419#define FATTR4_WORD1_MOUNTED_ON_FILEID (1UL << 23)
Dean Hildebrandc772567d2010-10-20 00:17:55 -0400420#define FATTR4_WORD1_FS_LAYOUT_TYPES (1UL << 30)
Christoph Hellwig9cf514c2014-05-05 13:11:59 +0200421#define FATTR4_WORD2_LAYOUT_TYPES (1UL << 0)
Dean Hildebrandc772567d2010-10-20 00:17:55 -0400422#define FATTR4_WORD2_LAYOUT_BLKSIZE (1UL << 1)
Andy Adamson88034c32012-05-23 05:02:34 -0400423#define FATTR4_WORD2_MDSTHRESHOLD (1UL << 4)
Trond Myklebustf3f5a0f2013-11-04 14:38:05 -0500424#define FATTR4_WORD2_SECURITY_LABEL (1UL << 16)
Andy Adamson88034c32012-05-23 05:02:34 -0400425
426/* MDS threshold bitmap bits */
427#define THRESHOLD_RD (1UL << 0)
428#define THRESHOLD_WR (1UL << 1)
429#define THRESHOLD_RD_IO (1UL << 2)
430#define THRESHOLD_WR_IO (1UL << 3)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700431
432#define NFSPROC4_NULL 0
433#define NFSPROC4_COMPOUND 1
Chuck Lever764302c2009-09-08 19:50:03 -0400434#define NFS4_VERSION 4
Linus Torvalds1da177e2005-04-16 15:20:36 -0700435#define NFS4_MINOR_VERSION 0
Mike Sager44549df2009-04-01 09:21:47 -0400436
Linus Torvalds1da177e2005-04-16 15:20:36 -0700437#define NFS4_DEBUG 1
438
Linus Torvalds1da177e2005-04-16 15:20:36 -0700439/* Index of predefined Linux client operations */
440
441enum {
442 NFSPROC4_CLNT_NULL = 0, /* Unused */
443 NFSPROC4_CLNT_READ,
444 NFSPROC4_CLNT_WRITE,
445 NFSPROC4_CLNT_COMMIT,
446 NFSPROC4_CLNT_OPEN,
447 NFSPROC4_CLNT_OPEN_CONFIRM,
448 NFSPROC4_CLNT_OPEN_NOATTR,
449 NFSPROC4_CLNT_OPEN_DOWNGRADE,
450 NFSPROC4_CLNT_CLOSE,
451 NFSPROC4_CLNT_SETATTR,
452 NFSPROC4_CLNT_FSINFO,
453 NFSPROC4_CLNT_RENEW,
454 NFSPROC4_CLNT_SETCLIENTID,
455 NFSPROC4_CLNT_SETCLIENTID_CONFIRM,
456 NFSPROC4_CLNT_LOCK,
457 NFSPROC4_CLNT_LOCKT,
458 NFSPROC4_CLNT_LOCKU,
459 NFSPROC4_CLNT_ACCESS,
460 NFSPROC4_CLNT_GETATTR,
461 NFSPROC4_CLNT_LOOKUP,
462 NFSPROC4_CLNT_LOOKUP_ROOT,
463 NFSPROC4_CLNT_REMOVE,
464 NFSPROC4_CLNT_RENAME,
465 NFSPROC4_CLNT_LINK,
466 NFSPROC4_CLNT_SYMLINK,
467 NFSPROC4_CLNT_CREATE,
468 NFSPROC4_CLNT_PATHCONF,
469 NFSPROC4_CLNT_STATFS,
470 NFSPROC4_CLNT_READLINK,
471 NFSPROC4_CLNT_READDIR,
472 NFSPROC4_CLNT_SERVER_CAPS,
473 NFSPROC4_CLNT_DELEGRETURN,
J. Bruce Fields029d1052005-06-22 17:16:22 +0000474 NFSPROC4_CLNT_GETACL,
J. Bruce Fields23ec6962005-06-22 17:16:22 +0000475 NFSPROC4_CLNT_SETACL,
Trond Myklebust683b57b2006-06-09 09:34:22 -0400476 NFSPROC4_CLNT_FS_LOCATIONS,
Trond Myklebustd3c7b7c2010-07-01 12:49:01 -0400477 NFSPROC4_CLNT_RELEASE_LOCKOWNER,
Bryan Schumaker5a5ea0d2011-03-24 17:12:29 +0000478 NFSPROC4_CLNT_SECINFO,
Chuck Lever44c99932013-10-17 14:13:30 -0400479 NFSPROC4_CLNT_FSID_PRESENT,
Benny Halevy18df1882009-04-03 08:27:36 +0300480
481 /* nfs41 */
482 NFSPROC4_CLNT_EXCHANGE_ID,
483 NFSPROC4_CLNT_CREATE_SESSION,
484 NFSPROC4_CLNT_DESTROY_SESSION,
485 NFSPROC4_CLNT_SEQUENCE,
486 NFSPROC4_CLNT_GET_LEASE_TIME,
Ricardo Labiaga180197532009-12-05 16:08:40 -0500487 NFSPROC4_CLNT_RECLAIM_COMPLETE,
Andy Adamsonb1f69b72010-10-20 00:18:03 -0400488 NFSPROC4_CLNT_LAYOUTGET,
489 NFSPROC4_CLNT_GETDEVICEINFO,
Andy Adamson863a3c62011-03-23 13:27:54 +0000490 NFSPROC4_CLNT_LAYOUTCOMMIT,
Benny Halevycbe82602011-05-22 19:52:37 +0300491 NFSPROC4_CLNT_LAYOUTRETURN,
Bryan Schumakerfca78d62011-06-02 14:59:07 -0400492 NFSPROC4_CLNT_SECINFO_NO_NAME,
Bryan Schumaker7d974792011-06-02 14:59:08 -0400493 NFSPROC4_CLNT_TEST_STATEID,
Bryan Schumaker9aeda352011-06-02 14:59:09 -0400494 NFSPROC4_CLNT_FREE_STATEID,
Andy Adamson7f11d8d2011-07-30 20:52:35 -0400495 NFSPROC4_CLNT_GETDEVICELIST,
Trond Myklebustad24ecf2012-05-25 17:11:42 -0400496 NFSPROC4_CLNT_BIND_CONN_TO_SESSION,
Trond Myklebust66245532012-05-25 17:18:09 -0400497 NFSPROC4_CLNT_DESTROY_CLIENTID,
Anna Schumaker1c6dcbe2014-09-26 13:58:48 -0400498
499 /* nfs42 */
500 NFSPROC4_CLNT_SEEK,
Anna Schumakerf4ac1672014-11-25 13:18:15 -0500501 NFSPROC4_CLNT_ALLOCATE,
Anna Schumaker624bd5b2014-11-25 13:18:16 -0500502 NFSPROC4_CLNT_DEALLOCATE,
Trond Myklebustbe3a5d22015-06-23 19:51:55 +0800503 NFSPROC4_CLNT_LAYOUTSTATS,
Benny Halevy18df1882009-04-03 08:27:36 +0300504};
505
506/* nfs41 types */
507struct nfs4_sessionid {
508 unsigned char data[NFS4_MAX_SESSIONID_LEN];
509};
510
511/* Create Session Flags */
Mi Jinlonga62573d2011-03-23 17:57:07 +0800512#define SESSION4_PERSIST 0x001
513#define SESSION4_BACK_CHAN 0x002
514#define SESSION4_RDMA 0x004
515
516#define SESSION4_FLAG_MASK_A 0x007
Benny Halevy18df1882009-04-03 08:27:36 +0300517
518enum state_protect_how4 {
519 SP4_NONE = 0,
520 SP4_MACH_CRED = 1,
521 SP4_SSV = 2
Linus Torvalds1da177e2005-04-16 15:20:36 -0700522};
523
Dean Hildebrandc772567d2010-10-20 00:17:55 -0400524enum pnfs_layouttype {
525 LAYOUT_NFSV4_1_FILES = 1,
526 LAYOUT_OSD2_OBJECTS = 2,
527 LAYOUT_BLOCK_VOLUME = 3,
Tom Haynesd67ae822014-12-11 17:02:04 -0500528 LAYOUT_FLEX_FILES = 4,
Christoph Hellwig6cae0a42014-08-16 13:31:51 +0200529 LAYOUT_TYPE_MAX
Dean Hildebrandc772567d2010-10-20 00:17:55 -0400530};
531
532/* used for both layout return and recall */
533enum pnfs_layoutreturn_type {
534 RETURN_FILE = 1,
535 RETURN_FSID = 2,
536 RETURN_ALL = 3
537};
538
539enum pnfs_iomode {
540 IOMODE_READ = 1,
541 IOMODE_RW = 2,
542 IOMODE_ANY = 3,
543};
544
545enum pnfs_notify_deviceid_type4 {
546 NOTIFY_DEVICEID4_CHANGE = 1 << 1,
547 NOTIFY_DEVICEID4_DELETE = 1 << 2,
548};
549
Christoph Hellwig8bb28972015-08-17 18:41:01 +0200550enum pnfs_block_volume_type {
551 PNFS_BLOCK_VOLUME_SIMPLE = 0,
552 PNFS_BLOCK_VOLUME_SLICE = 1,
553 PNFS_BLOCK_VOLUME_CONCAT = 2,
554 PNFS_BLOCK_VOLUME_STRIPE = 3,
555};
556
557enum pnfs_block_extent_state {
558 PNFS_BLOCK_READWRITE_DATA = 0,
559 PNFS_BLOCK_READ_DATA = 1,
560 PNFS_BLOCK_INVALID_DATA = 2,
561 PNFS_BLOCK_NONE_DATA = 3,
562};
563
564/* on the wire size of a block layout extent */
565#define PNFS_BLOCK_EXTENT_SIZE \
566 (7 * sizeof(__be32) + NFS4_DEVICEID4_SIZE)
567
Dean Hildebrandc772567d2010-10-20 00:17:55 -0400568#define NFL4_UFLG_MASK 0x0000003F
569#define NFL4_UFLG_DENSE 0x00000001
570#define NFL4_UFLG_COMMIT_THRU_MDS 0x00000002
571#define NFL4_UFLG_STRIPE_UNIT_SIZE_MASK 0xFFFFFFC0
572
573/* Encoded in the loh_body field of type layouthint4 */
574enum filelayout_hint_care4 {
575 NFLH4_CARE_DENSE = NFL4_UFLG_DENSE,
576 NFLH4_CARE_COMMIT_THRU_MDS = NFL4_UFLG_COMMIT_THRU_MDS,
577 NFLH4_CARE_STRIPE_UNIT_SIZE = 0x00000040,
578 NFLH4_CARE_STRIPE_COUNT = 0x00000080
579};
580
581#define NFS4_DEVICEID4_SIZE 16
582
583struct nfs4_deviceid {
584 char data[NFS4_DEVICEID4_SIZE];
585};
586
Anna Schumaker24bab492014-09-26 13:58:27 -0400587enum data_content4 {
588 NFS4_CONTENT_DATA = 0,
589 NFS4_CONTENT_HOLE = 1,
590};
591
Linus Torvalds1da177e2005-04-16 15:20:36 -0700592#endif