]> git.proxmox.com Git - mirror_ubuntu-zesty-kernel.git/blame - include/linux/nfs_xdr.h
NFS: Convert cache_change_attribute into a jiffy-based value
[mirror_ubuntu-zesty-kernel.git] / include / linux / nfs_xdr.h
CommitLineData
1da177e4
LT
1#ifndef _LINUX_NFS_XDR_H
2#define _LINUX_NFS_XDR_H
3
4#include <linux/sunrpc/xprt.h>
b7fa0554 5#include <linux/nfsacl.h>
1da177e4
LT
6
7struct nfs4_fsid {
8 __u64 major;
9 __u64 minor;
10};
11
12struct nfs_fattr {
13 unsigned short valid; /* which fields are valid */
14 __u64 pre_size; /* pre_op_attr.size */
15 struct timespec pre_mtime; /* pre_op_attr.mtime */
16 struct timespec pre_ctime; /* pre_op_attr.ctime */
17 enum nfs_ftype type; /* always use NFSv2 types */
18 __u32 mode;
19 __u32 nlink;
20 __u32 uid;
21 __u32 gid;
22 __u64 size;
23 union {
24 struct {
25 __u32 blocksize;
26 __u32 blocks;
27 } nfs2;
28 struct {
29 __u64 used;
30 } nfs3;
31 } du;
32 dev_t rdev;
33 union {
34 __u64 nfs3; /* also nfs2 */
35 struct nfs4_fsid nfs4;
36 } fsid_u;
37 __u64 fileid;
38 struct timespec atime;
39 struct timespec mtime;
40 struct timespec ctime;
41 __u32 bitmap[2]; /* NFSv4 returned attribute bitmap */
42 __u64 change_attr; /* NFSv4 change attribute */
43 __u64 pre_change_attr;/* pre-op NFSv4 change attribute */
44 unsigned long timestamp;
45};
46
47#define NFS_ATTR_WCC 0x0001 /* pre-op WCC data */
48#define NFS_ATTR_FATTR 0x0002 /* post-op attributes */
49#define NFS_ATTR_FATTR_V3 0x0004 /* NFSv3 attributes */
50#define NFS_ATTR_FATTR_V4 0x0008
51#define NFS_ATTR_PRE_CHANGE 0x0010
52
53/*
54 * Info on the file system
55 */
56struct nfs_fsinfo {
57 struct nfs_fattr *fattr; /* Post-op attributes */
58 __u32 rtmax; /* max. read transfer size */
59 __u32 rtpref; /* pref. read transfer size */
60 __u32 rtmult; /* reads should be multiple of this */
61 __u32 wtmax; /* max. write transfer size */
62 __u32 wtpref; /* pref. write transfer size */
63 __u32 wtmult; /* writes should be multiple of this */
64 __u32 dtpref; /* pref. readdir transfer size */
65 __u64 maxfilesize;
66 __u32 lease_time; /* in seconds */
67};
68
69struct nfs_fsstat {
70 struct nfs_fattr *fattr; /* Post-op attributes */
71 __u64 tbytes; /* total size in bytes */
72 __u64 fbytes; /* # of free bytes */
73 __u64 abytes; /* # of bytes available to user */
74 __u64 tfiles; /* # of files */
75 __u64 ffiles; /* # of free files */
76 __u64 afiles; /* # of files available to user */
77};
78
79struct nfs2_fsstat {
80 __u32 tsize; /* Server transfer size */
81 __u32 bsize; /* Filesystem block size */
82 __u32 blocks; /* No. of "bsize" blocks on filesystem */
83 __u32 bfree; /* No. of free "bsize" blocks */
84 __u32 bavail; /* No. of available "bsize" blocks */
85};
86
87struct nfs_pathconf {
88 struct nfs_fattr *fattr; /* Post-op attributes */
89 __u32 max_link; /* max # of hard links */
90 __u32 max_namelen; /* max name length */
91};
92
93struct nfs4_change_info {
94 u32 atomic;
95 u64 before;
96 u64 after;
97};
98
cee54fc9 99struct nfs_seqid;
1da177e4
LT
100/*
101 * Arguments to the open call.
102 */
103struct nfs_openargs {
104 const struct nfs_fh * fh;
cee54fc9 105 struct nfs_seqid * seqid;
1da177e4
LT
106 int open_flags;
107 __u64 clientid;
108 __u32 id;
109 union {
110 struct iattr * attrs; /* UNCHECKED, GUARDED */
111 nfs4_verifier verifier; /* EXCLUSIVE */
112 nfs4_stateid delegation; /* CLAIM_DELEGATE_CUR */
113 int delegation_type; /* CLAIM_PREVIOUS */
114 } u;
115 const struct qstr * name;
116 const struct nfs_server *server; /* Needed for ID mapping */
117 const u32 * bitmask;
118 __u32 claim;
119};
120
121struct nfs_openres {
122 nfs4_stateid stateid;
123 struct nfs_fh fh;
124 struct nfs4_change_info cinfo;
125 __u32 rflags;
126 struct nfs_fattr * f_attr;
127 const struct nfs_server *server;
128 int delegation_type;
129 nfs4_stateid delegation;
130 __u32 do_recall;
131 __u64 maxsize;
132};
133
134/*
135 * Arguments to the open_confirm call.
136 */
137struct nfs_open_confirmargs {
138 const struct nfs_fh * fh;
139 nfs4_stateid stateid;
cee54fc9 140 struct nfs_seqid * seqid;
1da177e4
LT
141};
142
143struct nfs_open_confirmres {
144 nfs4_stateid stateid;
145};
146
147/*
148 * Arguments to the close call.
149 */
150struct nfs_closeargs {
151 struct nfs_fh * fh;
9512135d 152 nfs4_stateid * stateid;
cee54fc9 153 struct nfs_seqid * seqid;
1da177e4
LT
154 int open_flags;
155};
156
157struct nfs_closeres {
158 nfs4_stateid stateid;
159};
160/*
161 * * Arguments to the lock,lockt, and locku call.
162 * */
163struct nfs_lowner {
164 __u64 clientid;
165 u32 id;
166};
167
06735b34 168struct nfs_lock_opargs {
cee54fc9 169 struct nfs_seqid * lock_seqid;
06735b34
TM
170 nfs4_stateid * lock_stateid;
171 struct nfs_seqid * open_seqid;
172 nfs4_stateid * open_stateid;
1da177e4 173 struct nfs_lowner lock_owner;
1da177e4
LT
174 __u32 reclaim;
175 __u32 new_lock_owner;
1da177e4
LT
176};
177
178struct nfs_locku_opargs {
cee54fc9 179 struct nfs_seqid * seqid;
faf5f49c 180 nfs4_stateid * stateid;
1da177e4
LT
181};
182
183struct nfs_lockargs {
184 struct nfs_fh * fh;
185 __u32 type;
186 __u64 offset;
187 __u64 length;
188 union {
189 struct nfs_lock_opargs *lock; /* LOCK */
190 struct nfs_lowner *lockt; /* LOCKT */
191 struct nfs_locku_opargs *locku; /* LOCKU */
192 } u;
193};
194
195struct nfs_lock_denied {
196 __u64 offset;
197 __u64 length;
198 __u32 type;
199 struct nfs_lowner owner;
200};
201
202struct nfs_lockres {
203 union {
204 nfs4_stateid stateid;/* LOCK success, LOCKU */
205 struct nfs_lock_denied denied; /* LOCK failed, LOCKT success */
206 } u;
207 const struct nfs_server * server;
208};
209
210struct nfs4_delegreturnargs {
211 const struct nfs_fh *fhandle;
212 const nfs4_stateid *stateid;
213};
214
215/*
216 * Arguments to the read call.
217 */
218
219#define NFS_READ_MAXIOV (9U)
220#if (NFS_READ_MAXIOV > (MAX_IOVEC -2))
221#error "NFS_READ_MAXIOV is too large"
222#endif
223
224struct nfs_readargs {
225 struct nfs_fh * fh;
226 struct nfs_open_context *context;
227 __u64 offset;
228 __u32 count;
229 unsigned int pgbase;
230 struct page ** pages;
231};
232
233struct nfs_readres {
234 struct nfs_fattr * fattr;
235 __u32 count;
236 int eof;
237};
238
239/*
240 * Arguments to the write call.
241 */
242#define NFS_WRITE_MAXIOV (9U)
243#if (NFS_WRITE_MAXIOV > (MAX_IOVEC -2))
244#error "NFS_WRITE_MAXIOV is too large"
245#endif
246
247struct nfs_writeargs {
248 struct nfs_fh * fh;
249 struct nfs_open_context *context;
250 __u64 offset;
251 __u32 count;
252 enum nfs3_stable_how stable;
253 unsigned int pgbase;
254 struct page ** pages;
255};
256
257struct nfs_writeverf {
258 enum nfs3_stable_how committed;
259 __u32 verifier[2];
260};
261
262struct nfs_writeres {
263 struct nfs_fattr * fattr;
264 struct nfs_writeverf * verf;
265 __u32 count;
266};
267
268/*
269 * Argument struct for decode_entry function
270 */
271struct nfs_entry {
272 __u64 ino;
273 __u64 cookie,
274 prev_cookie;
275 const char * name;
276 unsigned int len;
277 int eof;
278 struct nfs_fh * fh;
279 struct nfs_fattr * fattr;
280};
281
282/*
283 * The following types are for NFSv2 only.
284 */
285struct nfs_sattrargs {
286 struct nfs_fh * fh;
287 struct iattr * sattr;
288};
289
290struct nfs_diropargs {
291 struct nfs_fh * fh;
292 const char * name;
293 unsigned int len;
294};
295
296struct nfs_createargs {
297 struct nfs_fh * fh;
298 const char * name;
299 unsigned int len;
300 struct iattr * sattr;
301};
302
303struct nfs_renameargs {
304 struct nfs_fh * fromfh;
305 const char * fromname;
306 unsigned int fromlen;
307 struct nfs_fh * tofh;
308 const char * toname;
309 unsigned int tolen;
310};
311
312struct nfs_setattrargs {
313 struct nfs_fh * fh;
314 nfs4_stateid stateid;
315 struct iattr * iap;
316 const struct nfs_server * server; /* Needed for name mapping */
317 const u32 * bitmask;
318};
319
23ec6965
BF
320struct nfs_setaclargs {
321 struct nfs_fh * fh;
322 size_t acl_len;
323 unsigned int acl_pgbase;
324 struct page ** acl_pages;
325};
326
029d105e
BF
327struct nfs_getaclargs {
328 struct nfs_fh * fh;
329 size_t acl_len;
330 unsigned int acl_pgbase;
331 struct page ** acl_pages;
332};
333
1da177e4
LT
334struct nfs_setattrres {
335 struct nfs_fattr * fattr;
336 const struct nfs_server * server;
337};
338
339struct nfs_linkargs {
340 struct nfs_fh * fromfh;
341 struct nfs_fh * tofh;
342 const char * toname;
343 unsigned int tolen;
344};
345
346struct nfs_symlinkargs {
347 struct nfs_fh * fromfh;
348 const char * fromname;
349 unsigned int fromlen;
350 const char * topath;
351 unsigned int tolen;
352 struct iattr * sattr;
353};
354
355struct nfs_readdirargs {
356 struct nfs_fh * fh;
357 __u32 cookie;
358 unsigned int count;
359 struct page ** pages;
360};
361
b7fa0554
AG
362struct nfs3_getaclargs {
363 struct nfs_fh * fh;
364 int mask;
365 struct page ** pages;
366};
367
368struct nfs3_setaclargs {
369 struct inode * inode;
370 int mask;
371 struct posix_acl * acl_access;
372 struct posix_acl * acl_default;
373 struct page ** pages;
374};
375
1da177e4
LT
376struct nfs_diropok {
377 struct nfs_fh * fh;
378 struct nfs_fattr * fattr;
379};
380
381struct nfs_readlinkargs {
382 struct nfs_fh * fh;
383 unsigned int pgbase;
384 unsigned int pglen;
385 struct page ** pages;
386};
387
388struct nfs3_sattrargs {
389 struct nfs_fh * fh;
390 struct iattr * sattr;
391 unsigned int guard;
392 struct timespec guardtime;
393};
394
395struct nfs3_diropargs {
396 struct nfs_fh * fh;
397 const char * name;
398 unsigned int len;
399};
400
401struct nfs3_accessargs {
402 struct nfs_fh * fh;
403 __u32 access;
404};
405
406struct nfs3_createargs {
407 struct nfs_fh * fh;
408 const char * name;
409 unsigned int len;
410 struct iattr * sattr;
411 enum nfs3_createmode createmode;
412 __u32 verifier[2];
413};
414
415struct nfs3_mkdirargs {
416 struct nfs_fh * fh;
417 const char * name;
418 unsigned int len;
419 struct iattr * sattr;
420};
421
422struct nfs3_symlinkargs {
423 struct nfs_fh * fromfh;
424 const char * fromname;
425 unsigned int fromlen;
426 const char * topath;
427 unsigned int tolen;
428 struct iattr * sattr;
429};
430
431struct nfs3_mknodargs {
432 struct nfs_fh * fh;
433 const char * name;
434 unsigned int len;
435 enum nfs3_ftype type;
436 struct iattr * sattr;
437 dev_t rdev;
438};
439
440struct nfs3_renameargs {
441 struct nfs_fh * fromfh;
442 const char * fromname;
443 unsigned int fromlen;
444 struct nfs_fh * tofh;
445 const char * toname;
446 unsigned int tolen;
447};
448
449struct nfs3_linkargs {
450 struct nfs_fh * fromfh;
451 struct nfs_fh * tofh;
452 const char * toname;
453 unsigned int tolen;
454};
455
456struct nfs3_readdirargs {
457 struct nfs_fh * fh;
458 __u64 cookie;
459 __u32 verf[2];
460 int plus;
461 unsigned int count;
462 struct page ** pages;
463};
464
465struct nfs3_diropres {
466 struct nfs_fattr * dir_attr;
467 struct nfs_fh * fh;
468 struct nfs_fattr * fattr;
469};
470
471struct nfs3_accessres {
472 struct nfs_fattr * fattr;
473 __u32 access;
474};
475
476struct nfs3_readlinkargs {
477 struct nfs_fh * fh;
478 unsigned int pgbase;
479 unsigned int pglen;
480 struct page ** pages;
481};
482
483struct nfs3_renameres {
484 struct nfs_fattr * fromattr;
485 struct nfs_fattr * toattr;
486};
487
488struct nfs3_linkres {
489 struct nfs_fattr * dir_attr;
490 struct nfs_fattr * fattr;
491};
492
493struct nfs3_readdirres {
494 struct nfs_fattr * dir_attr;
495 __u32 * verf;
496 int plus;
497};
498
b7fa0554
AG
499struct nfs3_getaclres {
500 struct nfs_fattr * fattr;
501 int mask;
502 unsigned int acl_access_count;
503 unsigned int acl_default_count;
504 struct posix_acl * acl_access;
505 struct posix_acl * acl_default;
506};
507
1da177e4
LT
508#ifdef CONFIG_NFS_V4
509
510typedef u64 clientid4;
511
512struct nfs4_accessargs {
513 const struct nfs_fh * fh;
514 u32 access;
515};
516
517struct nfs4_accessres {
518 u32 supported;
519 u32 access;
520};
521
522struct nfs4_create_arg {
523 u32 ftype;
524 union {
525 struct qstr * symlink; /* NF4LNK */
526 struct {
527 u32 specdata1;
528 u32 specdata2;
529 } device; /* NF4BLK, NF4CHR */
530 } u;
531 const struct qstr * name;
532 const struct nfs_server * server;
533 const struct iattr * attrs;
534 const struct nfs_fh * dir_fh;
535 const u32 * bitmask;
536};
537
538struct nfs4_create_res {
539 const struct nfs_server * server;
540 struct nfs_fh * fh;
541 struct nfs_fattr * fattr;
542 struct nfs4_change_info dir_cinfo;
543};
544
545struct nfs4_fsinfo_arg {
546 const struct nfs_fh * fh;
547 const u32 * bitmask;
548};
549
550struct nfs4_getattr_arg {
551 const struct nfs_fh * fh;
552 const u32 * bitmask;
553};
554
555struct nfs4_getattr_res {
556 const struct nfs_server * server;
557 struct nfs_fattr * fattr;
558};
559
560struct nfs4_link_arg {
561 const struct nfs_fh * fh;
562 const struct nfs_fh * dir_fh;
563 const struct qstr * name;
564};
565
566struct nfs4_lookup_arg {
567 const struct nfs_fh * dir_fh;
568 const struct qstr * name;
569 const u32 * bitmask;
570};
571
572struct nfs4_lookup_res {
573 const struct nfs_server * server;
574 struct nfs_fattr * fattr;
575 struct nfs_fh * fh;
576};
577
578struct nfs4_lookup_root_arg {
579 const u32 * bitmask;
580};
581
582struct nfs4_pathconf_arg {
583 const struct nfs_fh * fh;
584 const u32 * bitmask;
585};
586
587struct nfs4_readdir_arg {
588 const struct nfs_fh * fh;
589 u64 cookie;
590 nfs4_verifier verifier;
591 u32 count;
592 struct page ** pages; /* zero-copy data */
593 unsigned int pgbase; /* zero-copy data */
594 const u32 * bitmask;
595};
596
597struct nfs4_readdir_res {
598 nfs4_verifier verifier;
599 unsigned int pgbase;
600};
601
602struct nfs4_readlink {
603 const struct nfs_fh * fh;
604 unsigned int pgbase;
605 unsigned int pglen; /* zero-copy data */
606 struct page ** pages; /* zero-copy data */
607};
608
609struct nfs4_remove_arg {
610 const struct nfs_fh * fh;
611 const struct qstr * name;
612};
613
614struct nfs4_rename_arg {
615 const struct nfs_fh * old_dir;
616 const struct nfs_fh * new_dir;
617 const struct qstr * old_name;
618 const struct qstr * new_name;
619};
620
621struct nfs4_rename_res {
622 struct nfs4_change_info old_cinfo;
623 struct nfs4_change_info new_cinfo;
624};
625
626struct nfs4_setclientid {
627 const nfs4_verifier * sc_verifier; /* request */
628 unsigned int sc_name_len;
629 char sc_name[32]; /* request */
630 u32 sc_prog; /* request */
631 unsigned int sc_netid_len;
632 char sc_netid[4]; /* request */
633 unsigned int sc_uaddr_len;
634 char sc_uaddr[24]; /* request */
635 u32 sc_cb_ident; /* request */
636};
637
638struct nfs4_statfs_arg {
639 const struct nfs_fh * fh;
640 const u32 * bitmask;
641};
642
643struct nfs4_server_caps_res {
644 u32 attr_bitmask[2];
645 u32 acl_bitmask;
646 u32 has_links;
647 u32 has_symlinks;
648};
649
650#endif /* CONFIG_NFS_V4 */
651
652struct nfs_page;
653
654struct nfs_read_data {
655 int flags;
656 struct rpc_task task;
657 struct inode *inode;
658 struct rpc_cred *cred;
659 struct nfs_fattr fattr; /* fattr storage */
660 struct list_head pages; /* Coalesced read requests */
661 struct nfs_page *req; /* multi ops per nfs_page */
662 struct page *pagevec[NFS_READ_MAXIOV];
663 struct nfs_readargs args;
664 struct nfs_readres res;
665#ifdef CONFIG_NFS_V4
666 unsigned long timestamp; /* For lease renewal */
667#endif
668 void (*complete) (struct nfs_read_data *, int);
669};
670
671struct nfs_write_data {
672 int flags;
673 struct rpc_task task;
674 struct inode *inode;
675 struct rpc_cred *cred;
676 struct nfs_fattr fattr;
677 struct nfs_writeverf verf;
678 struct list_head pages; /* Coalesced requests we wish to flush */
679 struct nfs_page *req; /* multi ops per nfs_page */
680 struct page *pagevec[NFS_WRITE_MAXIOV];
681 struct nfs_writeargs args; /* argument struct */
682 struct nfs_writeres res; /* result struct */
683#ifdef CONFIG_NFS_V4
684 unsigned long timestamp; /* For lease renewal */
685#endif
686 void (*complete) (struct nfs_write_data *, int);
687};
688
689struct nfs_access_entry;
690
691/*
692 * RPC procedure vector for NFSv2/NFSv3 demuxing
693 */
694struct nfs_rpc_ops {
695 int version; /* Protocol version */
696 struct dentry_operations *dentry_ops;
697 struct inode_operations *dir_inode_ops;
92cfc62c 698 struct inode_operations *file_inode_ops;
1da177e4
LT
699
700 int (*getroot) (struct nfs_server *, struct nfs_fh *,
701 struct nfs_fsinfo *);
702 int (*getattr) (struct nfs_server *, struct nfs_fh *,
703 struct nfs_fattr *);
704 int (*setattr) (struct dentry *, struct nfs_fattr *,
705 struct iattr *);
706 int (*lookup) (struct inode *, struct qstr *,
707 struct nfs_fh *, struct nfs_fattr *);
708 int (*access) (struct inode *, struct nfs_access_entry *);
709 int (*readlink)(struct inode *, struct page *, unsigned int,
710 unsigned int);
711 int (*read) (struct nfs_read_data *);
712 int (*write) (struct nfs_write_data *);
713 int (*commit) (struct nfs_write_data *);
714 int (*create) (struct inode *, struct dentry *,
02a913a7 715 struct iattr *, int, struct nameidata *);
1da177e4
LT
716 int (*remove) (struct inode *, struct qstr *);
717 int (*unlink_setup) (struct rpc_message *,
718 struct dentry *, struct qstr *);
719 int (*unlink_done) (struct dentry *, struct rpc_task *);
720 int (*rename) (struct inode *, struct qstr *,
721 struct inode *, struct qstr *);
722 int (*link) (struct inode *, struct inode *, struct qstr *);
723 int (*symlink) (struct inode *, struct qstr *, struct qstr *,
724 struct iattr *, struct nfs_fh *,
725 struct nfs_fattr *);
726 int (*mkdir) (struct inode *, struct dentry *, struct iattr *);
727 int (*rmdir) (struct inode *, struct qstr *);
728 int (*readdir) (struct dentry *, struct rpc_cred *,
729 u64, struct page *, unsigned int, int);
730 int (*mknod) (struct inode *, struct dentry *, struct iattr *,
731 dev_t);
732 int (*statfs) (struct nfs_server *, struct nfs_fh *,
733 struct nfs_fsstat *);
734 int (*fsinfo) (struct nfs_server *, struct nfs_fh *,
735 struct nfs_fsinfo *);
736 int (*pathconf) (struct nfs_server *, struct nfs_fh *,
737 struct nfs_pathconf *);
738 u32 * (*decode_dirent)(u32 *, struct nfs_entry *, int plus);
739 void (*read_setup) (struct nfs_read_data *);
740 void (*write_setup) (struct nfs_write_data *, int how);
741 void (*commit_setup) (struct nfs_write_data *, int how);
742 int (*file_open) (struct inode *, struct file *);
743 int (*file_release) (struct inode *, struct file *);
744 int (*lock)(struct file *, int, struct file_lock *);
ada70d94 745 void (*clear_acl_cache)(struct inode *);
1da177e4
LT
746};
747
748/*
749 * NFS_CALL(getattr, inode, (fattr));
750 * into
751 * NFS_PROTO(inode)->getattr(fattr);
752 */
753#define NFS_CALL(op, inode, args) NFS_PROTO(inode)->op args
754
755/*
756 * Function vectors etc. for the NFS client
757 */
758extern struct nfs_rpc_ops nfs_v2_clientops;
759extern struct nfs_rpc_ops nfs_v3_clientops;
760extern struct nfs_rpc_ops nfs_v4_clientops;
761extern struct rpc_version nfs_version2;
762extern struct rpc_version nfs_version3;
763extern struct rpc_version nfs_version4;
764
b7fa0554
AG
765extern struct rpc_version nfsacl_version3;
766extern struct rpc_program nfsacl_program;
767
1da177e4 768#endif