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