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