Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
nfs4.h
Go to the documentation of this file.
1 /*
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 <[email protected]>
10  * Andy Adamson <[email protected]>
11  */
12 #ifndef _LINUX_NFS4_H
13 #define _LINUX_NFS4_H
14 
15 #include <linux/list.h>
16 #include <uapi/linux/nfs4.h>
17 
18 struct nfs4_ace {
22  int whotype;
24 };
25 
26 struct nfs4_acl {
28  struct nfs4_ace aces[0];
29 };
30 
31 typedef struct { char data[NFS4_VERIFIER_SIZE]; } nfs4_verifier;
32 
33 struct nfs_stateid4 {
36 } __attribute__ ((packed));
37 
38 typedef struct nfs_stateid4 nfs4_stateid;
39 
40 enum nfs_opnum4 {
41  OP_ACCESS = 3,
42  OP_CLOSE = 4,
43  OP_COMMIT = 5,
44  OP_CREATE = 6,
48  OP_GETFH = 10,
49  OP_LINK = 11,
50  OP_LOCK = 12,
51  OP_LOCKT = 13,
52  OP_LOCKU = 14,
53  OP_LOOKUP = 15,
54  OP_LOOKUPP = 16,
55  OP_NVERIFY = 17,
56  OP_OPEN = 18,
60  OP_PUTFH = 22,
63  OP_READ = 25,
64  OP_READDIR = 26,
66  OP_REMOVE = 28,
67  OP_RENAME = 29,
68  OP_RENEW = 30,
70  OP_SAVEFH = 32,
71  OP_SECINFO = 33,
72  OP_SETATTR = 34,
75  OP_VERIFY = 37,
76  OP_WRITE = 38,
78 
79  /* nfs41 */
94  OP_SET_SSV = 54,
99 
100  OP_ILLEGAL = 10044,
101 };
102 
103 /*Defining first and last NFS4 operations implemented.
104 Needs to be updated if more operations are defined in future.*/
105 
106 #define FIRST_NFS4_OP OP_ACCESS
107 #define LAST_NFS4_OP OP_RECLAIM_COMPLETE
108 
109 enum nfsstat4 {
110  NFS4_OK = 0,
118  /* Unused/reserved 19 */
136  NFS4ERR_DELAY = 10008,
137  NFS4ERR_SAME = 10009,
138  NFS4ERR_DENIED = 10010,
140  NFS4ERR_LOCKED = 10012,
141  NFS4ERR_GRACE = 10013,
147  NFS4ERR_MOVED = 10019,
164  NFS4ERR_BADXDR = 10036,
177 
178  /* nfs41 */
187  NFS4ERR_BACK_CHAN_BUSY = 10057, /* backchan reqs outstanding */
193  NFS4ERR_SEQ_MISORDERED = 10063, /* unexpected seq.id in req */
194  NFS4ERR_SEQUENCE_POS = 10064, /* [CB_]SEQ. op not 1st op */
195  NFS4ERR_REQ_TOO_BIG = 10065, /* request too big */
196  NFS4ERR_REP_TOO_BIG = 10066, /* reply too big */
197  NFS4ERR_REP_TOO_BIG_TO_CACHE = 10067, /* rep. not all cached */
198  NFS4ERR_RETRY_UNCACHED_REP = 10068, /* retry & rep. uncached */
199  NFS4ERR_UNSAFE_COMPOUND = 10069, /* retry/recovery too hard */
200  NFS4ERR_TOO_MANY_OPS = 10070, /* too many ops in [CB_]COMP */
201  NFS4ERR_OP_NOT_IN_SESSION = 10071, /* op needs [CB_]SEQ. op */
202  NFS4ERR_HASH_ALG_UNSUPP = 10072, /* hash alg. not supp. */
203  /* Error 10073 is unused. */
204  NFS4ERR_CLIENTID_BUSY = 10074, /* clientid has state */
205  NFS4ERR_PNFS_IO_HOLE = 10075, /* IO to _SPARSE file hole */
206  NFS4ERR_SEQ_FALSE_RETRY = 10076, /* retry not original */
207  NFS4ERR_BAD_HIGH_SLOT = 10077, /* sequence arg bad */
208  NFS4ERR_DEADSESSION = 10078, /* persistent session dead */
209  NFS4ERR_ENCR_ALG_UNSUPP = 10079, /* SSV alg mismatch */
210  NFS4ERR_PNFS_NO_LAYOUT = 10080, /* direct I/O with no layout */
211  NFS4ERR_NOT_ONLY_OP = 10081, /* bad compound */
212  NFS4ERR_WRONG_CRED = 10082, /* permissions:state change */
213  NFS4ERR_WRONG_TYPE = 10083, /* current operation mismatch */
214  NFS4ERR_DIRDELEG_UNAVAIL = 10084, /* no directory delegation */
215  NFS4ERR_REJECT_DELEG = 10085, /* on callback */
216  NFS4ERR_RETURNCONFLICT = 10086, /* outstanding layoutreturn */
217  NFS4ERR_DELEG_REVOKED = 10087, /* deleg./layout revoked */
218 };
219 
220 static inline bool seqid_mutating_err(u32 err)
221 {
222  /* rfc 3530 section 8.1.5: */
223  switch (err) {
226  case NFS4ERR_BAD_STATEID:
227  case NFS4ERR_BAD_SEQID:
228  case NFS4ERR_BADXDR:
229  case NFS4ERR_RESOURCE:
231  return false;
232  };
233  return true;
234 }
235 
236 /*
237  * Note: NF4BAD is not actually part of the protocol; it is just used
238  * internally by nfsd.
239  */
241  NF4BAD = 0,
242  NF4REG = 1, /* Regular File */
243  NF4DIR = 2, /* Directory */
244  NF4BLK = 3, /* Special File - block device */
245  NF4CHR = 4, /* Special File - character device */
246  NF4LNK = 5, /* Symbolic Link */
247  NF4SOCK = 6, /* Special File - socket */
248  NF4FIFO = 7, /* Special File - fifo */
249  NF4ATTRDIR = 8, /* Attribute Directory */
250  NF4NAMEDATTR = 9 /* Named Attribute */
251 };
252 
258  NFS4_OPEN_CLAIM_FH = 4, /* 4.1 */
261 };
262 
263 enum opentype4 {
266 };
267 
272  /*
273  * New to NFSv4.1. If session is persistent,
274  * GUARDED4 MUST be used. Otherwise, use
275  * EXCLUSIVE4_1 instead of EXCLUSIVE4.
276  */
278 };
279 
280 enum limit_by4 {
283 };
284 
290 };
291 
292 enum why_no_delegation4 { /* new to v4.1 */
302 };
303 
310 };
311 
312 
313 /* Mandatory Attributes */
314 #define FATTR4_WORD0_SUPPORTED_ATTRS (1UL << 0)
315 #define FATTR4_WORD0_TYPE (1UL << 1)
316 #define FATTR4_WORD0_FH_EXPIRE_TYPE (1UL << 2)
317 #define FATTR4_WORD0_CHANGE (1UL << 3)
318 #define FATTR4_WORD0_SIZE (1UL << 4)
319 #define FATTR4_WORD0_LINK_SUPPORT (1UL << 5)
320 #define FATTR4_WORD0_SYMLINK_SUPPORT (1UL << 6)
321 #define FATTR4_WORD0_NAMED_ATTR (1UL << 7)
322 #define FATTR4_WORD0_FSID (1UL << 8)
323 #define FATTR4_WORD0_UNIQUE_HANDLES (1UL << 9)
324 #define FATTR4_WORD0_LEASE_TIME (1UL << 10)
325 #define FATTR4_WORD0_RDATTR_ERROR (1UL << 11)
326 /* Mandatory in NFSv4.1 */
327 #define FATTR4_WORD2_SUPPATTR_EXCLCREAT (1UL << 11)
328 
329 /* Recommended Attributes */
330 #define FATTR4_WORD0_ACL (1UL << 12)
331 #define FATTR4_WORD0_ACLSUPPORT (1UL << 13)
332 #define FATTR4_WORD0_ARCHIVE (1UL << 14)
333 #define FATTR4_WORD0_CANSETTIME (1UL << 15)
334 #define FATTR4_WORD0_CASE_INSENSITIVE (1UL << 16)
335 #define FATTR4_WORD0_CASE_PRESERVING (1UL << 17)
336 #define FATTR4_WORD0_CHOWN_RESTRICTED (1UL << 18)
337 #define FATTR4_WORD0_FILEHANDLE (1UL << 19)
338 #define FATTR4_WORD0_FILEID (1UL << 20)
339 #define FATTR4_WORD0_FILES_AVAIL (1UL << 21)
340 #define FATTR4_WORD0_FILES_FREE (1UL << 22)
341 #define FATTR4_WORD0_FILES_TOTAL (1UL << 23)
342 #define FATTR4_WORD0_FS_LOCATIONS (1UL << 24)
343 #define FATTR4_WORD0_HIDDEN (1UL << 25)
344 #define FATTR4_WORD0_HOMOGENEOUS (1UL << 26)
345 #define FATTR4_WORD0_MAXFILESIZE (1UL << 27)
346 #define FATTR4_WORD0_MAXLINK (1UL << 28)
347 #define FATTR4_WORD0_MAXNAME (1UL << 29)
348 #define FATTR4_WORD0_MAXREAD (1UL << 30)
349 #define FATTR4_WORD0_MAXWRITE (1UL << 31)
350 #define FATTR4_WORD1_MIMETYPE (1UL << 0)
351 #define FATTR4_WORD1_MODE (1UL << 1)
352 #define FATTR4_WORD1_NO_TRUNC (1UL << 2)
353 #define FATTR4_WORD1_NUMLINKS (1UL << 3)
354 #define FATTR4_WORD1_OWNER (1UL << 4)
355 #define FATTR4_WORD1_OWNER_GROUP (1UL << 5)
356 #define FATTR4_WORD1_QUOTA_HARD (1UL << 6)
357 #define FATTR4_WORD1_QUOTA_SOFT (1UL << 7)
358 #define FATTR4_WORD1_QUOTA_USED (1UL << 8)
359 #define FATTR4_WORD1_RAWDEV (1UL << 9)
360 #define FATTR4_WORD1_SPACE_AVAIL (1UL << 10)
361 #define FATTR4_WORD1_SPACE_FREE (1UL << 11)
362 #define FATTR4_WORD1_SPACE_TOTAL (1UL << 12)
363 #define FATTR4_WORD1_SPACE_USED (1UL << 13)
364 #define FATTR4_WORD1_SYSTEM (1UL << 14)
365 #define FATTR4_WORD1_TIME_ACCESS (1UL << 15)
366 #define FATTR4_WORD1_TIME_ACCESS_SET (1UL << 16)
367 #define FATTR4_WORD1_TIME_BACKUP (1UL << 17)
368 #define FATTR4_WORD1_TIME_CREATE (1UL << 18)
369 #define FATTR4_WORD1_TIME_DELTA (1UL << 19)
370 #define FATTR4_WORD1_TIME_METADATA (1UL << 20)
371 #define FATTR4_WORD1_TIME_MODIFY (1UL << 21)
372 #define FATTR4_WORD1_TIME_MODIFY_SET (1UL << 22)
373 #define FATTR4_WORD1_MOUNTED_ON_FILEID (1UL << 23)
374 #define FATTR4_WORD1_FS_LAYOUT_TYPES (1UL << 30)
375 #define FATTR4_WORD2_LAYOUT_BLKSIZE (1UL << 1)
376 #define FATTR4_WORD2_MDSTHRESHOLD (1UL << 4)
377 
378 /* MDS threshold bitmap bits */
379 #define THRESHOLD_RD (1UL << 0)
380 #define THRESHOLD_WR (1UL << 1)
381 #define THRESHOLD_RD_IO (1UL << 2)
382 #define THRESHOLD_WR_IO (1UL << 3)
383 
384 #define NFSPROC4_NULL 0
385 #define NFSPROC4_COMPOUND 1
386 #define NFS4_VERSION 4
387 #define NFS4_MINOR_VERSION 0
388 
389 #if defined(CONFIG_NFS_V4_1)
390 #define NFS4_MAX_MINOR_VERSION 1
391 #else
392 #define NFS4_MAX_MINOR_VERSION 0
393 #endif /* CONFIG_NFS_V4_1 */
394 
395 #define NFS4_DEBUG 1
396 
397 /* Index of predefined Linux client operations */
398 
399 enum {
400  NFSPROC4_CLNT_NULL = 0, /* Unused */
437 
438  /* nfs41 */
455 };
456 
457 /* nfs41 types */
459  unsigned char data[NFS4_MAX_SESSIONID_LEN];
460 };
461 
462 /* Create Session Flags */
463 #define SESSION4_PERSIST 0x001
464 #define SESSION4_BACK_CHAN 0x002
465 #define SESSION4_RDMA 0x004
466 
467 #define SESSION4_FLAG_MASK_A 0x007
468 
470  SP4_NONE = 0,
473 };
474 
479 };
480 
481 /* used for both layout return and recall */
486 };
487 
492 };
493 
497 };
498 
499 #define NFL4_UFLG_MASK 0x0000003F
500 #define NFL4_UFLG_DENSE 0x00000001
501 #define NFL4_UFLG_COMMIT_THRU_MDS 0x00000002
502 #define NFL4_UFLG_STRIPE_UNIT_SIZE_MASK 0xFFFFFFC0
503 
504 /* Encoded in the loh_body field of type layouthint4 */
510 };
511 
512 #define NFS4_DEVICEID4_SIZE 16
513 
516 };
517 
518 #endif