1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef _LINUX_NFS_XDR_H
3 #define _LINUX_NFS_XDR_H
4
5 #include <linux/nfsacl.h>
6 #include <linux/sunrpc/gss_api.h>
7
8 /*
9 * To change the maximum rsize and wsize supported by the NFS client, adjust
10 * NFS_MAX_FILE_IO_SIZE. 64KB is a typical maximum, but some servers can
11 * support a megabyte or more. The default is left at 4096 bytes, which is
12 * reasonable for NFS over UDP.
13 */
14 #define NFS_MAX_FILE_IO_SIZE (1048576U)
15 #define NFS_DEF_FILE_IO_SIZE (4096U)
16 #define NFS_MIN_FILE_IO_SIZE (1024U)
17
18 #define NFS_BITMASK_SZ 3
19
20 /* aux_flags in nfs_fattr */
21 #define NFS_AUX_UNCACHEABLE_FILE_DATA BIT(0)
22
23 struct nfs4_string {
24 unsigned int len;
25 char *data;
26 };
27
28 struct nfs_fsid {
29 uint64_t major;
30 uint64_t minor;
31 };
32
33 /*
34 * Helper for checking equality between 2 fsids.
35 */
nfs_fsid_equal(const struct nfs_fsid * a,const struct nfs_fsid * b)36 static inline int nfs_fsid_equal(const struct nfs_fsid *a, const struct nfs_fsid *b)
37 {
38 return a->major == b->major && a->minor == b->minor;
39 }
40
41 struct nfs4_threshold {
42 __u32 bm;
43 __u32 l_type;
44 __u64 rd_sz;
45 __u64 wr_sz;
46 __u64 rd_io_sz;
47 __u64 wr_io_sz;
48 };
49
50 struct nfs_fattr {
51 __u64 valid; /* which fields are valid */
52 umode_t mode;
53 __u32 nlink;
54 kuid_t uid;
55 kgid_t gid;
56 dev_t rdev;
57 __u64 size;
58 union {
59 struct {
60 __u32 blocksize;
61 __u32 blocks;
62 } nfs2;
63 struct {
64 __u64 used;
65 } nfs3;
66 } du;
67 struct nfs_fsid fsid;
68 __u64 fileid;
69 __u64 mounted_on_fileid;
70 struct timespec64 atime;
71 struct timespec64 mtime;
72 struct timespec64 ctime;
73 struct timespec64 btime;
74 __u32 aux_flags; /* NFSv4 auxiliary flags bitfield */
75 __u64 change_attr; /* NFSv4 change attribute */
76 __u64 pre_change_attr;/* pre-op NFSv4 change attribute */
77 __u64 pre_size; /* pre_op_attr.size */
78 struct timespec64 pre_mtime; /* pre_op_attr.mtime */
79 struct timespec64 pre_ctime; /* pre_op_attr.ctime */
80 unsigned long time_start;
81 unsigned long gencount;
82 struct nfs4_string *owner_name;
83 struct nfs4_string *group_name;
84 struct nfs4_threshold *mdsthreshold; /* pNFS threshold hints */
85 struct nfs4_label *label;
86 };
87
88 #define NFS_ATTR_FATTR_TYPE BIT_ULL(0)
89 #define NFS_ATTR_FATTR_MODE BIT_ULL(1)
90 #define NFS_ATTR_FATTR_NLINK BIT_ULL(2)
91 #define NFS_ATTR_FATTR_OWNER BIT_ULL(3)
92 #define NFS_ATTR_FATTR_GROUP BIT_ULL(4)
93 #define NFS_ATTR_FATTR_RDEV BIT_ULL(5)
94 #define NFS_ATTR_FATTR_SIZE BIT_ULL(6)
95 #define NFS_ATTR_FATTR_PRESIZE BIT_ULL(7)
96 #define NFS_ATTR_FATTR_BLOCKS_USED BIT_ULL(8)
97 #define NFS_ATTR_FATTR_SPACE_USED BIT_ULL(9)
98 #define NFS_ATTR_FATTR_FSID BIT_ULL(10)
99 #define NFS_ATTR_FATTR_FILEID BIT_ULL(11)
100 #define NFS_ATTR_FATTR_ATIME BIT_ULL(12)
101 #define NFS_ATTR_FATTR_MTIME BIT_ULL(13)
102 #define NFS_ATTR_FATTR_CTIME BIT_ULL(14)
103 #define NFS_ATTR_FATTR_PREMTIME BIT_ULL(15)
104 #define NFS_ATTR_FATTR_PRECTIME BIT_ULL(16)
105 #define NFS_ATTR_FATTR_CHANGE BIT_ULL(17)
106 #define NFS_ATTR_FATTR_PRECHANGE BIT_ULL(18)
107 #define NFS_ATTR_FATTR_V4_LOCATIONS BIT_ULL(19)
108 #define NFS_ATTR_FATTR_V4_REFERRAL BIT_ULL(20)
109 #define NFS_ATTR_FATTR_MOUNTPOINT BIT_ULL(21)
110 #define NFS_ATTR_FATTR_MOUNTED_ON_FILEID BIT_ULL(22)
111 #define NFS_ATTR_FATTR_OWNER_NAME BIT_ULL(23)
112 #define NFS_ATTR_FATTR_GROUP_NAME BIT_ULL(24)
113 #define NFS_ATTR_FATTR_V4_SECURITY_LABEL BIT_ULL(25)
114 #define NFS_ATTR_FATTR_BTIME BIT_ULL(26)
115 #define NFS_ATTR_FATTR_UNCACHEABLE_FILE_DATA BIT_ULL(27)
116
117 #define NFS_ATTR_FATTR (NFS_ATTR_FATTR_TYPE \
118 | NFS_ATTR_FATTR_MODE \
119 | NFS_ATTR_FATTR_NLINK \
120 | NFS_ATTR_FATTR_OWNER \
121 | NFS_ATTR_FATTR_GROUP \
122 | NFS_ATTR_FATTR_RDEV \
123 | NFS_ATTR_FATTR_SIZE \
124 | NFS_ATTR_FATTR_FSID \
125 | NFS_ATTR_FATTR_FILEID \
126 | NFS_ATTR_FATTR_ATIME \
127 | NFS_ATTR_FATTR_MTIME \
128 | NFS_ATTR_FATTR_CTIME \
129 | NFS_ATTR_FATTR_CHANGE)
130 #define NFS_ATTR_FATTR_V2 (NFS_ATTR_FATTR \
131 | NFS_ATTR_FATTR_BLOCKS_USED)
132 #define NFS_ATTR_FATTR_V3 (NFS_ATTR_FATTR \
133 | NFS_ATTR_FATTR_SPACE_USED)
134 #define NFS_ATTR_FATTR_V4 (NFS_ATTR_FATTR \
135 | NFS_ATTR_FATTR_SPACE_USED \
136 | NFS_ATTR_FATTR_BTIME \
137 | NFS_ATTR_FATTR_V4_SECURITY_LABEL \
138 | NFS_ATTR_FATTR_UNCACHEABLE_FILE_DATA)
139
140 /*
141 * Maximal number of supported layout drivers.
142 */
143 #define NFS_MAX_LAYOUT_TYPES 8
144
145 /*
146 * Info on the file system
147 */
148 struct nfs_fsinfo {
149 struct nfs_fattr *fattr; /* Post-op attributes */
150 __u32 rtmax; /* max. read transfer size */
151 __u32 rtpref; /* pref. read transfer size */
152 __u32 rtmult; /* reads should be multiple of this */
153 __u32 wtmax; /* max. write transfer size */
154 __u32 wtpref; /* pref. write transfer size */
155 __u32 wtmult; /* writes should be multiple of this */
156 __u32 dtpref; /* pref. readdir transfer size */
157 __u64 maxfilesize;
158 struct timespec64 time_delta; /* server time granularity */
159 __u32 lease_time; /* in seconds */
160 __u32 nlayouttypes; /* number of layouttypes */
161 __u32 layouttype[NFS_MAX_LAYOUT_TYPES]; /* supported pnfs layout driver */
162 __u32 blksize; /* preferred pnfs io block size */
163 __u32 clone_blksize; /* granularity of a CLONE operation */
164 enum nfs4_change_attr_type
165 change_attr_type; /* Info about change attr */
166 __u32 xattr_support; /* User xattrs supported */
167 };
168
169 struct nfs_fsstat {
170 struct nfs_fattr *fattr; /* Post-op attributes */
171 __u64 tbytes; /* total size in bytes */
172 __u64 fbytes; /* # of free bytes */
173 __u64 abytes; /* # of bytes available to user */
174 __u64 tfiles; /* # of files */
175 __u64 ffiles; /* # of free files */
176 __u64 afiles; /* # of files available to user */
177 };
178
179 struct nfs2_fsstat {
180 __u32 tsize; /* Server transfer size */
181 __u32 bsize; /* Filesystem block size */
182 __u32 blocks; /* No. of "bsize" blocks on filesystem */
183 __u32 bfree; /* No. of free "bsize" blocks */
184 __u32 bavail; /* No. of available "bsize" blocks */
185 };
186
187 struct nfs_pathconf {
188 struct nfs_fattr *fattr; /* Post-op attributes */
189 __u32 max_link; /* max # of hard links */
190 __u32 max_namelen; /* max name length */
191 bool case_insensitive;
192 bool case_preserving;
193 };
194
195 struct nfs4_change_info {
196 u32 atomic;
197 u64 before;
198 u64 after;
199 };
200
201 struct nfs_seqid;
202
203 /* nfs41 sessions channel attributes */
204 struct nfs4_channel_attrs {
205 u32 max_rqst_sz;
206 u32 max_resp_sz;
207 u32 max_resp_sz_cached;
208 u32 max_ops;
209 u32 max_reqs;
210 };
211
212 struct nfs4_slot;
213 struct nfs4_sequence_args {
214 struct nfs4_slot *sa_slot;
215 u8 sa_cache_this : 1,
216 sa_privileged : 1;
217 };
218
219 struct nfs4_sequence_res {
220 const struct nfs4_sequence_slot_ops *sr_slot_ops;
221 struct nfs4_slot *sr_slot; /* slot used to send request */
222 unsigned long sr_timestamp;
223 int sr_status; /* sequence operation status */
224 u32 sr_status_flags;
225 u32 sr_highest_slotid;
226 u32 sr_target_highest_slotid;
227 };
228
229 struct nfs4_get_lease_time_args {
230 struct nfs4_sequence_args la_seq_args;
231 };
232
233 struct nfs4_get_lease_time_res {
234 struct nfs4_sequence_res lr_seq_res;
235 struct nfs_fsinfo *lr_fsinfo;
236 };
237
238 struct xdr_stream;
239 struct nfs4_xdr_opaque_data;
240
241 struct nfs4_xdr_opaque_ops {
242 void (*encode)(struct xdr_stream *, const void *args,
243 const struct nfs4_xdr_opaque_data *);
244 void (*free)(struct nfs4_xdr_opaque_data *);
245 };
246
247 struct nfs4_xdr_opaque_data {
248 const struct nfs4_xdr_opaque_ops *ops;
249 void *data;
250 };
251
252 #define PNFS_LAYOUT_MAXSIZE 4096
253
254 struct nfs4_layoutdriver_data {
255 struct page **pages;
256 __u32 pglen;
257 __u32 len;
258 };
259
260 struct pnfs_layout_range {
261 u32 iomode;
262 u64 offset;
263 u64 length;
264 };
265
266 struct nfs4_layoutget_args {
267 struct nfs4_sequence_args seq_args;
268 __u32 type;
269 struct pnfs_layout_range range;
270 __u64 minlength;
271 __u32 maxcount;
272 struct inode *inode;
273 struct nfs_open_context *ctx;
274 nfs4_stateid stateid;
275 struct nfs4_layoutdriver_data layout;
276 };
277
278 struct nfs4_layoutget_res {
279 struct nfs4_sequence_res seq_res;
280 int status;
281 __u32 return_on_close;
282 struct pnfs_layout_range range;
283 __u32 type;
284 nfs4_stateid stateid;
285 struct nfs4_layoutdriver_data *layoutp;
286 };
287
288 struct nfs4_layoutget {
289 struct nfs4_layoutget_args args;
290 struct nfs4_layoutget_res res;
291 const struct cred *cred;
292 struct pnfs_layout_hdr *lo;
293 gfp_t gfp_flags;
294 };
295
296 struct nfs4_getdeviceinfo_args {
297 struct nfs4_sequence_args seq_args;
298 struct pnfs_device *pdev;
299 __u32 notify_types;
300 };
301
302 struct nfs4_getdeviceinfo_res {
303 struct nfs4_sequence_res seq_res;
304 struct pnfs_device *pdev;
305 __u32 notification;
306 };
307
308 struct nfs4_layoutcommit_args {
309 struct nfs4_sequence_args seq_args;
310 nfs4_stateid stateid;
311 __u64 lastbytewritten;
312 struct inode *inode;
313 const u32 *bitmask;
314 size_t layoutupdate_len;
315 struct page *layoutupdate_page;
316 struct page **layoutupdate_pages;
317 __be32 *start_p;
318 };
319
320 struct nfs4_layoutcommit_res {
321 struct nfs4_sequence_res seq_res;
322 struct nfs_fattr *fattr;
323 const struct nfs_server *server;
324 int status;
325 };
326
327 struct nfs4_layoutcommit_data {
328 struct rpc_task task;
329 struct nfs_fattr fattr;
330 struct list_head lseg_list;
331 const struct cred *cred;
332 struct inode *inode;
333 struct nfs4_layoutcommit_args args;
334 struct nfs4_layoutcommit_res res;
335 };
336
337 struct nfs4_layoutreturn_args {
338 struct nfs4_sequence_args seq_args;
339 struct pnfs_layout_hdr *layout;
340 struct inode *inode;
341 struct pnfs_layout_range range;
342 nfs4_stateid stateid;
343 __u32 layout_type;
344 struct nfs4_xdr_opaque_data *ld_private;
345 };
346
347 struct nfs4_layoutreturn_res {
348 struct nfs4_sequence_res seq_res;
349 u32 lrs_present;
350 nfs4_stateid stateid;
351 };
352
353 struct nfs4_layoutreturn {
354 struct nfs4_layoutreturn_args args;
355 struct nfs4_layoutreturn_res res;
356 const struct cred *cred;
357 struct nfs_client *clp;
358 struct inode *inode;
359 int rpc_status;
360 struct nfs4_xdr_opaque_data ld_private;
361 };
362
363 #define PNFS_LAYOUTSTATS_MAXSIZE 384
364
365 struct nfs42_layoutstat_args;
366 struct nfs42_layoutstat_devinfo;
367 typedef void (*layoutstats_encode_t)(struct xdr_stream *,
368 struct nfs42_layoutstat_args *,
369 struct nfs42_layoutstat_devinfo *);
370
371 /* Per file per deviceid layoutstats */
372 struct nfs42_layoutstat_devinfo {
373 struct nfs4_deviceid dev_id;
374 __u64 offset;
375 __u64 length;
376 __u64 read_count;
377 __u64 read_bytes;
378 __u64 write_count;
379 __u64 write_bytes;
380 __u32 layout_type;
381 struct nfs4_xdr_opaque_data ld_private;
382 };
383
384 struct nfs42_layoutstat_args {
385 struct nfs4_sequence_args seq_args;
386 struct nfs_fh *fh;
387 struct inode *inode;
388 nfs4_stateid stateid;
389 int num_dev;
390 struct nfs42_layoutstat_devinfo *devinfo;
391 };
392
393 struct nfs42_layoutstat_res {
394 struct nfs4_sequence_res seq_res;
395 int num_dev;
396 int rpc_status;
397 };
398
399 struct nfs42_layoutstat_data {
400 struct inode *inode;
401 struct nfs42_layoutstat_args args;
402 struct nfs42_layoutstat_res res;
403 };
404
405 struct nfs42_device_error {
406 struct nfs4_deviceid dev_id;
407 int status;
408 enum nfs_opnum4 opnum;
409 };
410
411 struct nfs42_layout_error {
412 __u64 offset;
413 __u64 length;
414 nfs4_stateid stateid;
415 struct nfs42_device_error errors[1];
416 };
417
418 #define NFS42_LAYOUTERROR_MAX 5
419
420 struct nfs42_layouterror_args {
421 struct nfs4_sequence_args seq_args;
422 struct inode *inode;
423 unsigned int num_errors;
424 struct nfs42_layout_error errors[NFS42_LAYOUTERROR_MAX];
425 };
426
427 struct nfs42_layouterror_res {
428 struct nfs4_sequence_res seq_res;
429 unsigned int num_errors;
430 int rpc_status;
431 };
432
433 struct nfs42_layouterror_data {
434 struct nfs42_layouterror_args args;
435 struct nfs42_layouterror_res res;
436 struct inode *inode;
437 struct pnfs_layout_segment *lseg;
438 };
439
440 struct nfs42_clone_args {
441 struct nfs4_sequence_args seq_args;
442 struct nfs_fh *src_fh;
443 struct nfs_fh *dst_fh;
444 nfs4_stateid src_stateid;
445 nfs4_stateid dst_stateid;
446 __u64 src_offset;
447 __u64 dst_offset;
448 __u64 count;
449 const u32 *dst_bitmask;
450 };
451
452 struct nfs42_clone_res {
453 struct nfs4_sequence_res seq_res;
454 unsigned int rpc_status;
455 struct nfs_fattr *dst_fattr;
456 const struct nfs_server *server;
457 };
458
459 struct stateowner_id {
460 __u64 create_time;
461 __u64 uniquifier;
462 };
463
464 struct nfs4_open_delegation {
465 __u32 open_delegation_type;
466 union {
467 struct {
468 fmode_t type;
469 __u32 do_recall;
470 nfs4_stateid stateid;
471 unsigned long pagemod_limit;
472 };
473 struct {
474 __u32 why_no_delegation;
475 __u32 will_notify;
476 };
477 };
478 };
479
480 /*
481 * Arguments to the open call.
482 */
483 struct nfs_openargs {
484 struct nfs4_sequence_args seq_args;
485 const struct nfs_fh * fh;
486 struct nfs_seqid * seqid;
487 int open_flags;
488 fmode_t fmode;
489 u32 share_access;
490 u32 access;
491 __u64 clientid;
492 struct stateowner_id id;
493 union {
494 struct {
495 struct iattr * attrs; /* UNCHECKED, GUARDED, EXCLUSIVE4_1 */
496 nfs4_verifier verifier; /* EXCLUSIVE */
497 };
498 nfs4_stateid delegation; /* CLAIM_DELEGATE_CUR */
499 __u32 delegation_type; /* CLAIM_PREVIOUS */
500 } u;
501 const struct qstr * name;
502 const struct nfs_server *server; /* Needed for ID mapping */
503 const u32 * bitmask;
504 const u32 * open_bitmap;
505 enum open_claim_type4 claim;
506 enum createmode4 createmode;
507 const struct nfs4_label *label;
508 umode_t umask;
509 struct nfs4_layoutget_args *lg_args;
510 };
511
512 struct nfs_openres {
513 struct nfs4_sequence_res seq_res;
514 nfs4_stateid stateid;
515 struct nfs_fh fh;
516 struct nfs4_change_info cinfo;
517 __u32 rflags;
518 struct nfs_fattr * f_attr;
519 struct nfs_seqid * seqid;
520 const struct nfs_server *server;
521 __u32 attrset[NFS4_BITMAP_SIZE];
522 struct nfs4_string *owner;
523 struct nfs4_string *group_owner;
524 struct nfs4_open_delegation delegation;
525 __u32 access_request;
526 __u32 access_supported;
527 __u32 access_result;
528 struct nfs4_layoutget_res *lg_res;
529 };
530
531 /*
532 * Arguments to the open_confirm call.
533 */
534 struct nfs_open_confirmargs {
535 struct nfs4_sequence_args seq_args;
536 const struct nfs_fh * fh;
537 nfs4_stateid * stateid;
538 struct nfs_seqid * seqid;
539 };
540
541 struct nfs_open_confirmres {
542 struct nfs4_sequence_res seq_res;
543 nfs4_stateid stateid;
544 struct nfs_seqid * seqid;
545 };
546
547 /*
548 * Arguments to the close call.
549 */
550 struct nfs_closeargs {
551 struct nfs4_sequence_args seq_args;
552 struct nfs_fh * fh;
553 nfs4_stateid stateid;
554 struct nfs_seqid * seqid;
555 fmode_t fmode;
556 u32 share_access;
557 const u32 * bitmask;
558 u32 bitmask_store[NFS_BITMASK_SZ];
559 struct nfs4_layoutreturn_args *lr_args;
560 };
561
562 struct nfs_closeres {
563 struct nfs4_sequence_res seq_res;
564 nfs4_stateid stateid;
565 struct nfs_fattr * fattr;
566 struct nfs_seqid * seqid;
567 const struct nfs_server *server;
568 struct nfs4_layoutreturn_res *lr_res;
569 int lr_ret;
570 };
571 /*
572 * * Arguments to the lock,lockt, and locku call.
573 * */
574 struct nfs_lowner {
575 __u64 clientid;
576 __u64 id;
577 dev_t s_dev;
578 };
579
580 struct nfs_lock_args {
581 struct nfs4_sequence_args seq_args;
582 struct nfs_fh * fh;
583 struct file_lock * fl;
584 struct nfs_seqid * lock_seqid;
585 nfs4_stateid lock_stateid;
586 struct nfs_seqid * open_seqid;
587 nfs4_stateid open_stateid;
588 struct nfs_lowner lock_owner;
589 unsigned char block : 1;
590 unsigned char reclaim : 1;
591 unsigned char new_lock_owner : 1;
592 };
593
594 struct nfs_lock_res {
595 struct nfs4_sequence_res seq_res;
596 nfs4_stateid stateid;
597 struct nfs_seqid * lock_seqid;
598 struct nfs_seqid * open_seqid;
599 };
600
601 struct nfs_locku_args {
602 struct nfs4_sequence_args seq_args;
603 struct nfs_fh * fh;
604 struct file_lock * fl;
605 struct nfs_seqid * seqid;
606 nfs4_stateid stateid;
607 };
608
609 struct nfs_locku_res {
610 struct nfs4_sequence_res seq_res;
611 nfs4_stateid stateid;
612 struct nfs_seqid * seqid;
613 };
614
615 struct nfs_lockt_args {
616 struct nfs4_sequence_args seq_args;
617 struct nfs_fh * fh;
618 struct file_lock * fl;
619 struct nfs_lowner lock_owner;
620 };
621
622 struct nfs_lockt_res {
623 struct nfs4_sequence_res seq_res;
624 struct file_lock * denied; /* LOCK, LOCKT failed */
625 };
626
627 struct nfs_release_lockowner_args {
628 struct nfs4_sequence_args seq_args;
629 struct nfs_lowner lock_owner;
630 };
631
632 struct nfs_release_lockowner_res {
633 struct nfs4_sequence_res seq_res;
634 };
635
636 struct nfs4_delegattr {
637 struct timespec64 atime;
638 struct timespec64 mtime;
639 bool atime_set;
640 bool mtime_set;
641 };
642
643 struct nfs4_delegreturnargs {
644 struct nfs4_sequence_args seq_args;
645 const struct nfs_fh *fhandle;
646 const nfs4_stateid *stateid;
647 const u32 *bitmask;
648 u32 bitmask_store[NFS_BITMASK_SZ];
649 struct nfs4_layoutreturn_args *lr_args;
650 struct nfs4_delegattr *sattr_args;
651 };
652
653 struct nfs4_delegreturnres {
654 struct nfs4_sequence_res seq_res;
655 struct nfs_fattr * fattr;
656 struct nfs_server *server;
657 struct nfs4_layoutreturn_res *lr_res;
658 int lr_ret;
659 bool sattr_res;
660 int sattr_ret;
661 };
662
663 /*
664 * Arguments to the write call.
665 */
666 struct nfs_write_verifier {
667 char data[8];
668 };
669
670 struct nfs_writeverf {
671 struct nfs_write_verifier verifier;
672 enum nfs3_stable_how committed;
673 };
674
675 /*
676 * Arguments shared by the read and write call.
677 */
678 struct nfs_pgio_args {
679 struct nfs4_sequence_args seq_args;
680 struct nfs_fh * fh;
681 struct nfs_open_context *context;
682 struct nfs_lock_context *lock_context;
683 nfs4_stateid stateid;
684 __u64 offset;
685 __u32 count;
686 unsigned int pgbase;
687 struct page ** pages;
688 union {
689 unsigned int replen; /* used by read */
690 struct {
691 const u32 * bitmask; /* used by write */
692 u32 bitmask_store[NFS_BITMASK_SZ]; /* used by write */
693 enum nfs3_stable_how stable; /* used by write */
694 };
695 };
696 };
697
698 struct nfs_pgio_res {
699 struct nfs4_sequence_res seq_res;
700 struct nfs_fattr * fattr;
701 __u64 count;
702 __u32 op_status;
703 union {
704 struct {
705 unsigned int replen; /* used by read */
706 int eof; /* used by read */
707 void * scratch; /* used by read */
708 };
709 struct {
710 struct nfs_writeverf * verf; /* used by write */
711 const struct nfs_server *server; /* used by write */
712 };
713 };
714 };
715
716 /*
717 * Arguments to the commit call.
718 */
719 struct nfs_commitargs {
720 struct nfs4_sequence_args seq_args;
721 struct nfs_fh *fh;
722 __u64 offset;
723 __u32 count;
724 const u32 *bitmask;
725 };
726
727 struct nfs_commitres {
728 struct nfs4_sequence_res seq_res;
729 __u32 op_status;
730 struct nfs_fattr *fattr;
731 struct nfs_writeverf *verf;
732 const struct nfs_server *server;
733 };
734
735 /*
736 * Common arguments to the unlink call
737 */
738 struct nfs_removeargs {
739 struct nfs4_sequence_args seq_args;
740 const struct nfs_fh *fh;
741 struct qstr name;
742 };
743
744 struct nfs_removeres {
745 struct nfs4_sequence_res seq_res;
746 struct nfs_server *server;
747 struct nfs_fattr *dir_attr;
748 struct nfs4_change_info cinfo;
749 };
750
751 /*
752 * Common arguments to the rename call
753 */
754 struct nfs_renameargs {
755 struct nfs4_sequence_args seq_args;
756 const struct nfs_fh *old_dir;
757 const struct nfs_fh *new_dir;
758 const struct qstr *old_name;
759 const struct qstr *new_name;
760 };
761
762 struct nfs_renameres {
763 struct nfs4_sequence_res seq_res;
764 struct nfs_server *server;
765 struct nfs4_change_info old_cinfo;
766 struct nfs_fattr *old_fattr;
767 struct nfs4_change_info new_cinfo;
768 struct nfs_fattr *new_fattr;
769 };
770
771 /* parsed sec= options */
772 #define NFS_AUTH_INFO_MAX_FLAVORS 12 /* see fs/nfs/super.c */
773 struct nfs_auth_info {
774 unsigned int flavor_len;
775 rpc_authflavor_t flavors[NFS_AUTH_INFO_MAX_FLAVORS];
776 };
777
778 /*
779 * Argument struct for decode_entry function
780 */
781 struct nfs_entry {
782 __u64 ino;
783 __u64 cookie;
784 const char * name;
785 unsigned int len;
786 int eof;
787 struct nfs_fh * fh;
788 struct nfs_fattr * fattr;
789 unsigned char d_type;
790 struct nfs_server * server;
791 };
792
793 struct nfs_readdir_arg {
794 struct dentry *dentry;
795 const struct cred *cred;
796 __be32 *verf;
797 u64 cookie;
798 struct page **pages;
799 unsigned int page_len;
800 bool plus;
801 };
802
803 struct nfs_readdir_res {
804 __be32 *verf;
805 };
806
807 /*
808 * The following types are for NFSv2 only.
809 */
810 struct nfs_sattrargs {
811 struct nfs_fh * fh;
812 struct iattr * sattr;
813 };
814
815 struct nfs_diropargs {
816 struct nfs_fh * fh;
817 const char * name;
818 unsigned int len;
819 };
820
821 struct nfs_createargs {
822 struct nfs_fh * fh;
823 const char * name;
824 unsigned int len;
825 struct iattr * sattr;
826 };
827
828 struct nfs_setattrargs {
829 struct nfs4_sequence_args seq_args;
830 struct nfs_fh * fh;
831 nfs4_stateid stateid;
832 struct iattr * iap;
833 const struct nfs_server * server; /* Needed for name mapping */
834 const u32 * bitmask;
835 const struct nfs4_label *label;
836 };
837
838 enum nfs4_acl_type {
839 NFS4ACL_NONE = 0,
840 NFS4ACL_ACL,
841 NFS4ACL_DACL,
842 NFS4ACL_SACL,
843 };
844
845 struct nfs_setaclargs {
846 struct nfs4_sequence_args seq_args;
847 struct nfs_fh * fh;
848 enum nfs4_acl_type acl_type;
849 size_t acl_len;
850 struct page ** acl_pages;
851 };
852
853 struct nfs_setaclres {
854 struct nfs4_sequence_res seq_res;
855 };
856
857 struct nfs_getaclargs {
858 struct nfs4_sequence_args seq_args;
859 struct nfs_fh * fh;
860 enum nfs4_acl_type acl_type;
861 size_t acl_len;
862 struct page ** acl_pages;
863 };
864
865 /* getxattr ACL interface flags */
866 #define NFS4_ACL_TRUNC 0x0001 /* ACL was truncated */
867 struct nfs_getaclres {
868 struct nfs4_sequence_res seq_res;
869 enum nfs4_acl_type acl_type;
870 size_t acl_len;
871 size_t acl_data_offset;
872 int acl_flags;
873 struct folio * acl_scratch;
874 };
875
876 struct nfs_setattrres {
877 struct nfs4_sequence_res seq_res;
878 struct nfs_fattr * fattr;
879 const struct nfs_server * server;
880 };
881
882 struct nfs_linkargs {
883 struct nfs_fh * fromfh;
884 struct nfs_fh * tofh;
885 const char * toname;
886 unsigned int tolen;
887 };
888
889 struct nfs_symlinkargs {
890 struct nfs_fh * fromfh;
891 const char * fromname;
892 unsigned int fromlen;
893 struct page ** pages;
894 unsigned int pathlen;
895 struct iattr * sattr;
896 };
897
898 struct nfs_readdirargs {
899 struct nfs_fh * fh;
900 __u32 cookie;
901 unsigned int count;
902 struct page ** pages;
903 };
904
905 struct nfs3_getaclargs {
906 struct nfs_fh * fh;
907 int mask;
908 struct page ** pages;
909 };
910
911 struct nfs3_setaclargs {
912 struct inode * inode;
913 int mask;
914 struct posix_acl * acl_access;
915 struct posix_acl * acl_default;
916 size_t len;
917 unsigned int npages;
918 struct page ** pages;
919 };
920
921 struct nfs_diropok {
922 struct nfs_fh * fh;
923 struct nfs_fattr * fattr;
924 };
925
926 struct nfs_readlinkargs {
927 struct nfs_fh * fh;
928 unsigned int pgbase;
929 unsigned int pglen;
930 struct page ** pages;
931 };
932
933 struct nfs3_sattrargs {
934 struct nfs_fh * fh;
935 struct iattr * sattr;
936 unsigned int guard;
937 struct timespec64 guardtime;
938 };
939
940 struct nfs3_diropargs {
941 struct nfs_fh * fh;
942 const char * name;
943 unsigned int len;
944 };
945
946 struct nfs3_accessargs {
947 struct nfs_fh * fh;
948 __u32 access;
949 };
950
951 struct nfs3_createargs {
952 struct nfs_fh * fh;
953 const char * name;
954 unsigned int len;
955 struct iattr * sattr;
956 enum nfs3_createmode createmode;
957 __be32 verifier[2];
958 };
959
960 struct nfs3_mkdirargs {
961 struct nfs_fh * fh;
962 const char * name;
963 unsigned int len;
964 struct iattr * sattr;
965 };
966
967 struct nfs3_symlinkargs {
968 struct nfs_fh * fromfh;
969 const char * fromname;
970 unsigned int fromlen;
971 struct page ** pages;
972 unsigned int pathlen;
973 struct iattr * sattr;
974 };
975
976 struct nfs3_mknodargs {
977 struct nfs_fh * fh;
978 const char * name;
979 unsigned int len;
980 enum nfs3_ftype type;
981 struct iattr * sattr;
982 dev_t rdev;
983 };
984
985 struct nfs3_linkargs {
986 struct nfs_fh * fromfh;
987 struct nfs_fh * tofh;
988 const char * toname;
989 unsigned int tolen;
990 };
991
992 struct nfs3_readdirargs {
993 struct nfs_fh * fh;
994 __u64 cookie;
995 __be32 verf[2];
996 bool plus;
997 unsigned int count;
998 struct page ** pages;
999 };
1000
1001 struct nfs3_diropres {
1002 struct nfs_fattr * dir_attr;
1003 struct nfs_fh * fh;
1004 struct nfs_fattr * fattr;
1005 };
1006
1007 struct nfs3_accessres {
1008 struct nfs_fattr * fattr;
1009 __u32 access;
1010 };
1011
1012 struct nfs3_readlinkargs {
1013 struct nfs_fh * fh;
1014 unsigned int pgbase;
1015 unsigned int pglen;
1016 struct page ** pages;
1017 };
1018
1019 struct nfs3_linkres {
1020 struct nfs_fattr * dir_attr;
1021 struct nfs_fattr * fattr;
1022 };
1023
1024 struct nfs3_readdirres {
1025 struct nfs_fattr * dir_attr;
1026 __be32 * verf;
1027 bool plus;
1028 };
1029
1030 struct nfs3_getaclres {
1031 struct nfs_fattr * fattr;
1032 int mask;
1033 unsigned int acl_access_count;
1034 unsigned int acl_default_count;
1035 struct posix_acl * acl_access;
1036 struct posix_acl * acl_default;
1037 };
1038
1039 #if IS_ENABLED(CONFIG_NFS_V4)
1040
1041 typedef u64 clientid4;
1042
1043 struct nfs4_accessargs {
1044 struct nfs4_sequence_args seq_args;
1045 const struct nfs_fh * fh;
1046 const u32 * bitmask;
1047 u32 access;
1048 };
1049
1050 struct nfs4_accessres {
1051 struct nfs4_sequence_res seq_res;
1052 const struct nfs_server * server;
1053 struct nfs_fattr * fattr;
1054 u32 supported;
1055 u32 access;
1056 };
1057
1058 struct nfs4_create_arg {
1059 struct nfs4_sequence_args seq_args;
1060 u32 ftype;
1061 union {
1062 struct {
1063 struct page ** pages;
1064 unsigned int len;
1065 } symlink; /* NF4LNK */
1066 struct {
1067 u32 specdata1;
1068 u32 specdata2;
1069 } device; /* NF4BLK, NF4CHR */
1070 } u;
1071 const struct qstr * name;
1072 const struct nfs_server * server;
1073 const struct iattr * attrs;
1074 const struct nfs_fh * dir_fh;
1075 const u32 * bitmask;
1076 const struct nfs4_label *label;
1077 umode_t umask;
1078 };
1079
1080 struct nfs4_create_res {
1081 struct nfs4_sequence_res seq_res;
1082 const struct nfs_server * server;
1083 struct nfs_fh * fh;
1084 struct nfs_fattr * fattr;
1085 struct nfs4_change_info dir_cinfo;
1086 };
1087
1088 struct nfs4_fsinfo_arg {
1089 struct nfs4_sequence_args seq_args;
1090 const struct nfs_fh * fh;
1091 const u32 * bitmask;
1092 };
1093
1094 struct nfs4_fsinfo_res {
1095 struct nfs4_sequence_res seq_res;
1096 struct nfs_fsinfo *fsinfo;
1097 };
1098
1099 struct nfs4_getattr_arg {
1100 struct nfs4_sequence_args seq_args;
1101 const struct nfs_fh * fh;
1102 const u32 * bitmask;
1103 bool get_dir_deleg;
1104 };
1105
1106 struct nfs4_gdd_res {
1107 u32 status;
1108 nfs4_stateid deleg;
1109 };
1110
1111 struct nfs4_getattr_res {
1112 struct nfs4_sequence_res seq_res;
1113 const struct nfs_server * server;
1114 struct nfs_fattr * fattr;
1115 struct nfs4_gdd_res * gdd_res;
1116 };
1117
1118 struct nfs4_link_arg {
1119 struct nfs4_sequence_args seq_args;
1120 const struct nfs_fh * fh;
1121 const struct nfs_fh * dir_fh;
1122 const struct qstr * name;
1123 const u32 * bitmask;
1124 };
1125
1126 struct nfs4_link_res {
1127 struct nfs4_sequence_res seq_res;
1128 const struct nfs_server * server;
1129 struct nfs_fattr * fattr;
1130 struct nfs4_change_info cinfo;
1131 struct nfs_fattr * dir_attr;
1132 };
1133
1134 struct nfs4_lookup_arg {
1135 struct nfs4_sequence_args seq_args;
1136 const struct nfs_fh * dir_fh;
1137 const struct qstr * name;
1138 const u32 * bitmask;
1139 };
1140
1141 struct nfs4_lookup_res {
1142 struct nfs4_sequence_res seq_res;
1143 const struct nfs_server * server;
1144 struct nfs_fattr * fattr;
1145 struct nfs_fh * fh;
1146 };
1147
1148 struct nfs4_lookupp_arg {
1149 struct nfs4_sequence_args seq_args;
1150 const struct nfs_fh *fh;
1151 const u32 *bitmask;
1152 };
1153
1154 struct nfs4_lookupp_res {
1155 struct nfs4_sequence_res seq_res;
1156 const struct nfs_server *server;
1157 struct nfs_fattr *fattr;
1158 struct nfs_fh *fh;
1159 };
1160
1161 struct nfs4_lookup_root_arg {
1162 struct nfs4_sequence_args seq_args;
1163 const u32 * bitmask;
1164 };
1165
1166 struct nfs4_pathconf_arg {
1167 struct nfs4_sequence_args seq_args;
1168 const struct nfs_fh * fh;
1169 const u32 * bitmask;
1170 };
1171
1172 struct nfs4_pathconf_res {
1173 struct nfs4_sequence_res seq_res;
1174 struct nfs_pathconf *pathconf;
1175 };
1176
1177 struct nfs4_readdir_arg {
1178 struct nfs4_sequence_args seq_args;
1179 const struct nfs_fh * fh;
1180 u64 cookie;
1181 nfs4_verifier verifier;
1182 u32 count;
1183 struct page ** pages; /* zero-copy data */
1184 unsigned int pgbase; /* zero-copy data */
1185 const u32 * bitmask;
1186 bool plus;
1187 };
1188
1189 struct nfs4_readdir_res {
1190 struct nfs4_sequence_res seq_res;
1191 nfs4_verifier verifier;
1192 unsigned int pgbase;
1193 };
1194
1195 struct nfs4_readlink {
1196 struct nfs4_sequence_args seq_args;
1197 const struct nfs_fh * fh;
1198 unsigned int pgbase;
1199 unsigned int pglen; /* zero-copy data */
1200 struct page ** pages; /* zero-copy data */
1201 };
1202
1203 struct nfs4_readlink_res {
1204 struct nfs4_sequence_res seq_res;
1205 };
1206
1207 struct nfs4_setclientid {
1208 const nfs4_verifier * sc_verifier;
1209 u32 sc_prog;
1210 unsigned int sc_netid_len;
1211 char sc_netid[RPCBIND_MAXNETIDLEN + 1];
1212 unsigned int sc_uaddr_len;
1213 char sc_uaddr[RPCBIND_MAXUADDRLEN + 1];
1214 struct nfs_client *sc_clnt;
1215 struct rpc_cred *sc_cred;
1216 };
1217
1218 struct nfs4_setclientid_res {
1219 u64 clientid;
1220 nfs4_verifier confirm;
1221 };
1222
1223 struct nfs4_statfs_arg {
1224 struct nfs4_sequence_args seq_args;
1225 const struct nfs_fh * fh;
1226 const u32 * bitmask;
1227 };
1228
1229 struct nfs4_statfs_res {
1230 struct nfs4_sequence_res seq_res;
1231 struct nfs_fsstat *fsstat;
1232 };
1233
1234 struct nfs4_open_caps {
1235 u32 oa_share_access[1];
1236 u32 oa_share_deny[1];
1237 u32 oa_share_access_want[1];
1238 u32 oa_open_claim[1];
1239 u32 oa_createmode[1];
1240 };
1241
1242 struct nfs4_server_caps_arg {
1243 struct nfs4_sequence_args seq_args;
1244 struct nfs_fh *fhandle;
1245 const u32 * bitmask;
1246 };
1247
1248 struct nfs4_server_caps_res {
1249 struct nfs4_sequence_res seq_res;
1250 u32 attr_bitmask[3];
1251 u32 exclcreat_bitmask[3];
1252 u32 acl_bitmask;
1253 u32 has_links;
1254 u32 has_symlinks;
1255 u32 fh_expire_type;
1256 u32 case_insensitive;
1257 u32 case_preserving;
1258 struct nfs4_open_caps open_caps;
1259 };
1260
1261 #define NFS4_PATHNAME_MAXCOMPONENTS 512
1262 struct nfs4_pathname {
1263 unsigned int ncomponents;
1264 struct nfs4_string components[NFS4_PATHNAME_MAXCOMPONENTS];
1265 };
1266
1267 #define NFS4_FS_LOCATION_MAXSERVERS 10
1268 struct nfs4_fs_location {
1269 unsigned int nservers;
1270 struct nfs4_string servers[NFS4_FS_LOCATION_MAXSERVERS];
1271 struct nfs4_pathname rootpath;
1272 };
1273
1274 #define NFS4_FS_LOCATIONS_MAXENTRIES 10
1275 struct nfs4_fs_locations {
1276 struct nfs_fattr *fattr;
1277 const struct nfs_server *server;
1278 struct nfs4_pathname fs_path;
1279 int nlocations;
1280 struct nfs4_fs_location locations[NFS4_FS_LOCATIONS_MAXENTRIES];
1281 };
1282
1283 struct nfs4_fs_locations_arg {
1284 struct nfs4_sequence_args seq_args;
1285 const struct nfs_fh *dir_fh;
1286 const struct nfs_fh *fh;
1287 const struct qstr *name;
1288 struct page *page;
1289 const u32 *bitmask;
1290 clientid4 clientid;
1291 unsigned char migration:1, renew:1;
1292 };
1293
1294 struct nfs4_fs_locations_res {
1295 struct nfs4_sequence_res seq_res;
1296 struct nfs4_fs_locations *fs_locations;
1297 unsigned char migration:1, renew:1;
1298 };
1299
1300 struct nfs4_secinfo4 {
1301 u32 flavor;
1302 struct rpcsec_gss_info flavor_info;
1303 };
1304
1305 struct nfs4_secinfo_flavors {
1306 unsigned int num_flavors;
1307 struct nfs4_secinfo4 flavors[];
1308 };
1309
1310 struct nfs4_secinfo_arg {
1311 struct nfs4_sequence_args seq_args;
1312 const struct nfs_fh *dir_fh;
1313 const struct qstr *name;
1314 };
1315
1316 struct nfs4_secinfo_res {
1317 struct nfs4_sequence_res seq_res;
1318 struct nfs4_secinfo_flavors *flavors;
1319 };
1320
1321 struct nfs4_fsid_present_arg {
1322 struct nfs4_sequence_args seq_args;
1323 const struct nfs_fh *fh;
1324 clientid4 clientid;
1325 unsigned char renew:1;
1326 };
1327
1328 struct nfs4_fsid_present_res {
1329 struct nfs4_sequence_res seq_res;
1330 struct nfs_fh *fh;
1331 unsigned char renew:1;
1332 };
1333
1334 struct pnfs_commit_bucket {
1335 struct list_head written;
1336 struct list_head committing;
1337 struct pnfs_layout_segment *lseg;
1338 struct nfs_writeverf direct_verf;
1339 };
1340
1341 struct pnfs_commit_array {
1342 struct list_head cinfo_list;
1343 struct list_head lseg_list;
1344 struct pnfs_layout_segment *lseg;
1345 struct rcu_head rcu;
1346 refcount_t refcount;
1347 unsigned int nbuckets;
1348 struct pnfs_commit_bucket buckets[] __counted_by(nbuckets);
1349 };
1350
1351 struct pnfs_ds_commit_info {
1352 struct list_head commits;
1353 unsigned int nwritten;
1354 unsigned int ncommitting;
1355 const struct pnfs_commit_ops *ops;
1356 };
1357
1358 struct nfs41_state_protection {
1359 u32 how;
1360 struct nfs4_op_map enforce;
1361 struct nfs4_op_map allow;
1362 };
1363
1364 struct nfs41_exchange_id_args {
1365 struct nfs_client *client;
1366 nfs4_verifier verifier;
1367 u32 flags;
1368 struct nfs41_state_protection state_protect;
1369 };
1370
1371 struct nfs41_server_owner {
1372 uint64_t minor_id;
1373 uint32_t major_id_sz;
1374 char major_id[NFS4_OPAQUE_LIMIT];
1375 };
1376
1377 struct nfs41_server_scope {
1378 uint32_t server_scope_sz;
1379 char server_scope[NFS4_OPAQUE_LIMIT];
1380 };
1381
1382 struct nfs41_impl_id {
1383 char domain[NFS4_OPAQUE_LIMIT + 1];
1384 char name[NFS4_OPAQUE_LIMIT + 1];
1385 struct nfstime4 date;
1386 };
1387
1388 #define MAX_BIND_CONN_TO_SESSION_RETRIES 3
1389 struct nfs41_bind_conn_to_session_args {
1390 struct nfs_client *client;
1391 struct nfs4_sessionid sessionid;
1392 u32 dir;
1393 bool use_conn_in_rdma_mode;
1394 int retries;
1395 };
1396
1397 struct nfs41_bind_conn_to_session_res {
1398 struct nfs4_sessionid sessionid;
1399 u32 dir;
1400 bool use_conn_in_rdma_mode;
1401 };
1402
1403 struct nfs41_exchange_id_res {
1404 u64 clientid;
1405 u32 seqid;
1406 u32 flags;
1407 struct nfs41_server_owner *server_owner;
1408 struct nfs41_server_scope *server_scope;
1409 struct nfs41_impl_id *impl_id;
1410 struct nfs41_state_protection state_protect;
1411 };
1412
1413 struct nfs41_create_session_args {
1414 struct nfs_client *client;
1415 u64 clientid;
1416 uint32_t seqid;
1417 uint32_t flags;
1418 uint32_t cb_program;
1419 struct nfs4_channel_attrs fc_attrs; /* Fore Channel */
1420 struct nfs4_channel_attrs bc_attrs; /* Back Channel */
1421 };
1422
1423 struct nfs41_create_session_res {
1424 struct nfs4_sessionid sessionid;
1425 uint32_t seqid;
1426 uint32_t flags;
1427 struct nfs4_channel_attrs fc_attrs; /* Fore Channel */
1428 struct nfs4_channel_attrs bc_attrs; /* Back Channel */
1429 };
1430
1431 struct nfs41_reclaim_complete_args {
1432 struct nfs4_sequence_args seq_args;
1433 /* In the future extend to include curr_fh for use with migration */
1434 unsigned char one_fs:1;
1435 };
1436
1437 struct nfs41_reclaim_complete_res {
1438 struct nfs4_sequence_res seq_res;
1439 };
1440
1441 #define SECINFO_STYLE_CURRENT_FH 0
1442 #define SECINFO_STYLE_PARENT 1
1443 struct nfs41_secinfo_no_name_args {
1444 struct nfs4_sequence_args seq_args;
1445 int style;
1446 };
1447
1448 struct nfs41_test_stateid_args {
1449 struct nfs4_sequence_args seq_args;
1450 nfs4_stateid stateid;
1451 };
1452
1453 struct nfs41_test_stateid_res {
1454 struct nfs4_sequence_res seq_res;
1455 unsigned int status;
1456 };
1457
1458 struct nfs41_free_stateid_args {
1459 struct nfs4_sequence_args seq_args;
1460 nfs4_stateid stateid;
1461 };
1462
1463 struct nfs41_free_stateid_res {
1464 struct nfs4_sequence_res seq_res;
1465 unsigned int status;
1466 };
1467
1468 #else
1469
1470 struct pnfs_ds_commit_info {
1471 };
1472
1473 #endif /* CONFIG_NFS_V4 */
1474
1475 #ifdef CONFIG_NFS_V4_2
1476 struct nfs42_falloc_args {
1477 struct nfs4_sequence_args seq_args;
1478
1479 struct nfs_fh *falloc_fh;
1480 nfs4_stateid falloc_stateid;
1481 u64 falloc_offset;
1482 u64 falloc_length;
1483 const u32 *falloc_bitmask;
1484 };
1485
1486 struct nfs42_falloc_res {
1487 struct nfs4_sequence_res seq_res;
1488 unsigned int status;
1489
1490 struct nfs_fattr *falloc_fattr;
1491 const struct nfs_server *falloc_server;
1492 };
1493
1494 struct nfs42_copy_args {
1495 struct nfs4_sequence_args seq_args;
1496
1497 struct nfs_fh *src_fh;
1498 nfs4_stateid src_stateid;
1499 u64 src_pos;
1500
1501 struct nfs_fh *dst_fh;
1502 nfs4_stateid dst_stateid;
1503 u64 dst_pos;
1504
1505 u64 count;
1506 bool sync;
1507 struct nl4_server *cp_src;
1508 };
1509
1510 struct nfs42_write_res {
1511 nfs4_stateid stateid;
1512 u64 count;
1513 struct nfs_writeverf verifier;
1514 };
1515
1516 struct nfs42_copy_res {
1517 struct nfs4_sequence_res seq_res;
1518 struct nfs42_write_res write_res;
1519 bool consecutive;
1520 bool synchronous;
1521 struct nfs_commitres commit_res;
1522 };
1523
1524 struct nfs42_offload_status_args {
1525 struct nfs4_sequence_args osa_seq_args;
1526 struct nfs_fh *osa_src_fh;
1527 nfs4_stateid osa_stateid;
1528 };
1529
1530 struct nfs42_offload_status_res {
1531 struct nfs4_sequence_res osr_seq_res;
1532 u64 osr_count;
1533 int complete_count;
1534 u32 osr_complete;
1535 };
1536
1537 struct nfs42_copy_notify_args {
1538 struct nfs4_sequence_args cna_seq_args;
1539
1540 struct nfs_fh *cna_src_fh;
1541 nfs4_stateid cna_src_stateid;
1542 struct nl4_server cna_dst;
1543 };
1544
1545 struct nfs42_copy_notify_res {
1546 struct nfs4_sequence_res cnr_seq_res;
1547
1548 struct nfstime4 cnr_lease_time;
1549 nfs4_stateid cnr_stateid;
1550 struct nl4_server cnr_src;
1551 };
1552
1553 struct nfs42_seek_args {
1554 struct nfs4_sequence_args seq_args;
1555
1556 struct nfs_fh *sa_fh;
1557 nfs4_stateid sa_stateid;
1558 u64 sa_offset;
1559 u32 sa_what;
1560 };
1561
1562 struct nfs42_seek_res {
1563 struct nfs4_sequence_res seq_res;
1564 unsigned int status;
1565
1566 u32 sr_eof;
1567 u64 sr_offset;
1568 };
1569
1570 struct nfs42_setxattrargs {
1571 struct nfs4_sequence_args seq_args;
1572 struct nfs_fh *fh;
1573 const u32 *bitmask;
1574 const char *xattr_name;
1575 u32 xattr_flags;
1576 size_t xattr_len;
1577 struct page **xattr_pages;
1578 };
1579
1580 struct nfs42_setxattrres {
1581 struct nfs4_sequence_res seq_res;
1582 struct nfs4_change_info cinfo;
1583 struct nfs_fattr *fattr;
1584 const struct nfs_server *server;
1585 };
1586
1587 struct nfs42_getxattrargs {
1588 struct nfs4_sequence_args seq_args;
1589 struct nfs_fh *fh;
1590 const char *xattr_name;
1591 size_t xattr_len;
1592 struct page **xattr_pages;
1593 };
1594
1595 struct nfs42_getxattrres {
1596 struct nfs4_sequence_res seq_res;
1597 size_t xattr_len;
1598 };
1599
1600 struct nfs42_listxattrsargs {
1601 struct nfs4_sequence_args seq_args;
1602 struct nfs_fh *fh;
1603 u32 count;
1604 u64 cookie;
1605 struct page **xattr_pages;
1606 };
1607
1608 struct nfs42_listxattrsres {
1609 struct nfs4_sequence_res seq_res;
1610 struct folio *scratch;
1611 void *xattr_buf;
1612 size_t xattr_len;
1613 u64 cookie;
1614 bool eof;
1615 size_t copied;
1616 };
1617
1618 struct nfs42_removexattrargs {
1619 struct nfs4_sequence_args seq_args;
1620 struct nfs_fh *fh;
1621 const u32 *bitmask;
1622 const char *xattr_name;
1623 };
1624
1625 struct nfs42_removexattrres {
1626 struct nfs4_sequence_res seq_res;
1627 struct nfs4_change_info cinfo;
1628 struct nfs_fattr *fattr;
1629 const struct nfs_server *server;
1630 };
1631
1632 #endif /* CONFIG_NFS_V4_2 */
1633
1634 struct nfs_page;
1635
1636 #define NFS_PAGEVEC_SIZE (8U)
1637
1638 struct nfs_page_array {
1639 struct page **pagevec;
1640 unsigned int npages; /* Max length of pagevec */
1641 struct page *page_array[NFS_PAGEVEC_SIZE];
1642 };
1643
1644 /* used as flag bits in nfs_pgio_header */
1645 enum {
1646 NFS_IOHDR_ERROR = 0,
1647 NFS_IOHDR_EOF,
1648 NFS_IOHDR_REDO,
1649 NFS_IOHDR_STAT,
1650 NFS_IOHDR_RESEND_PNFS,
1651 NFS_IOHDR_RESEND_MDS,
1652 NFS_IOHDR_UNSTABLE_WRITES,
1653 NFS_IOHDR_ODIRECT,
1654 };
1655
1656 struct nfs_io_completion;
1657 struct nfs_pgio_header {
1658 struct inode *inode;
1659 const struct cred *cred;
1660 struct list_head pages;
1661 struct nfs_page *req;
1662 struct nfs_writeverf verf; /* Used for writes */
1663 fmode_t rw_mode;
1664 struct pnfs_layout_segment *lseg;
1665 loff_t io_start;
1666 const struct rpc_call_ops *mds_ops;
1667 void (*release) (struct nfs_pgio_header *hdr);
1668 const struct nfs_pgio_completion_ops *completion_ops;
1669 const struct nfs_rw_ops *rw_ops;
1670 struct nfs_io_completion *io_completion;
1671 struct nfs_direct_req *dreq;
1672 #ifdef CONFIG_NFS_FSCACHE
1673 void *netfs;
1674 #endif
1675
1676 unsigned short retrans;
1677 int pnfs_error;
1678 int error; /* merge with pnfs_error */
1679 unsigned int good_bytes; /* boundary of good data */
1680 unsigned long flags;
1681
1682 /*
1683 * rpc data
1684 */
1685 struct rpc_task task;
1686 struct nfs_fattr fattr;
1687 struct nfs_pgio_args args; /* argument struct */
1688 struct nfs_pgio_res res; /* result struct */
1689 unsigned long timestamp; /* For lease renewal */
1690 int (*pgio_done_cb)(struct rpc_task *, struct nfs_pgio_header *);
1691 __u64 mds_offset; /* Filelayout dense stripe */
1692 struct nfs_page_array page_array;
1693 struct nfs_client *ds_clp; /* pNFS data server */
1694 u32 ds_commit_idx; /* ds index if ds_clp is set */
1695 u32 pgio_mirror_idx;/* mirror index in pgio layer */
1696 };
1697
1698 struct nfs_mds_commit_info {
1699 atomic_t rpcs_out;
1700 atomic_long_t ncommit;
1701 struct list_head list;
1702 };
1703
1704 struct nfs_commit_info;
1705 struct nfs_commit_data;
1706 struct nfs_inode;
1707 struct nfs_commit_completion_ops {
1708 void (*completion) (struct nfs_commit_data *data);
1709 void (*resched_write) (struct nfs_commit_info *, struct nfs_page *);
1710 };
1711
1712 struct nfs_commit_info {
1713 struct inode *inode; /* Needed for inode->i_lock */
1714 struct nfs_mds_commit_info *mds;
1715 struct pnfs_ds_commit_info *ds;
1716 struct nfs_direct_req *dreq; /* O_DIRECT request */
1717 const struct nfs_commit_completion_ops *completion_ops;
1718 };
1719
1720 struct nfs_commit_data {
1721 struct rpc_task task;
1722 struct inode *inode;
1723 const struct cred *cred;
1724 struct nfs_fattr fattr;
1725 struct nfs_writeverf verf;
1726 struct list_head pages; /* Coalesced requests we wish to flush */
1727 struct list_head list; /* lists of struct nfs_write_data */
1728 struct nfs_direct_req *dreq; /* O_DIRECT request */
1729 struct nfs_commitargs args; /* argument struct */
1730 struct nfs_commitres res; /* result struct */
1731 struct nfs_open_context *context;
1732 struct pnfs_layout_segment *lseg;
1733 struct nfs_client *ds_clp; /* pNFS data server */
1734 int ds_commit_index;
1735 loff_t lwb;
1736 const struct rpc_call_ops *mds_ops;
1737 const struct nfs_commit_completion_ops *completion_ops;
1738 int (*commit_done_cb) (struct rpc_task *task, struct nfs_commit_data *data);
1739 unsigned long flags;
1740 };
1741
1742 struct nfs_pgio_completion_ops {
1743 void (*error_cleanup)(struct list_head *head, int);
1744 void (*init_hdr)(struct nfs_pgio_header *hdr);
1745 void (*completion)(struct nfs_pgio_header *hdr);
1746 void (*reschedule_io)(struct nfs_pgio_header *hdr);
1747 };
1748
1749 struct nfs_unlinkdata {
1750 struct nfs_removeargs args;
1751 struct nfs_removeres res;
1752 struct dentry *dentry;
1753 const struct cred *cred;
1754 struct nfs_fattr dir_attr;
1755 long timeout;
1756 };
1757
1758 struct nfs_renamedata {
1759 struct nfs_renameargs args;
1760 struct nfs_renameres res;
1761 struct rpc_task task;
1762 const struct cred *cred;
1763 struct inode *old_dir;
1764 struct dentry *old_dentry;
1765 struct nfs_fattr old_fattr;
1766 struct inode *new_dir;
1767 struct dentry *new_dentry;
1768 struct nfs_fattr new_fattr;
1769 void (*complete)(struct rpc_task *, struct nfs_renamedata *);
1770 long timeout;
1771 bool cancelled;
1772 };
1773
1774 struct nfs_access_entry;
1775 struct nfs_client;
1776 struct rpc_timeout;
1777 struct nfs_subversion;
1778 struct nfs_mount_info;
1779 struct nfs_client_initdata;
1780 struct nfs_pageio_descriptor;
1781 struct fs_context;
1782
1783 /*
1784 * RPC procedure vector for NFSv2/NFSv3 demuxing
1785 */
1786 struct nfs_rpc_ops {
1787 u32 version; /* Protocol version */
1788 const struct dentry_operations *dentry_ops;
1789 const struct inode_operations *dir_inode_ops;
1790 const struct inode_operations *file_inode_ops;
1791 const struct file_operations *file_ops;
1792 const struct nlmclnt_operations *nlmclnt_ops;
1793
1794 int (*getroot) (struct nfs_server *, struct nfs_fh *,
1795 struct nfs_fsinfo *);
1796 int (*submount) (struct fs_context *, struct nfs_server *);
1797 int (*try_get_tree) (struct fs_context *);
1798 int (*getattr) (struct nfs_server *, struct nfs_fh *,
1799 struct nfs_fattr *, struct inode *);
1800 int (*setattr) (struct dentry *, struct nfs_fattr *,
1801 struct iattr *);
1802 int (*lookup) (struct inode *, struct dentry *, const struct qstr *,
1803 struct nfs_fh *, struct nfs_fattr *);
1804 int (*lookupp) (struct inode *, struct nfs_fh *,
1805 struct nfs_fattr *);
1806 int (*access) (struct inode *, struct nfs_access_entry *, const struct cred *);
1807 int (*readlink)(struct inode *, struct page *, unsigned int,
1808 unsigned int);
1809 int (*create) (struct inode *, struct dentry *,
1810 struct iattr *, int);
1811 int (*remove) (struct inode *, struct dentry *);
1812 void (*unlink_setup) (struct rpc_message *, struct dentry *, struct inode *);
1813 void (*unlink_rpc_prepare) (struct rpc_task *, struct nfs_unlinkdata *);
1814 int (*unlink_done) (struct rpc_task *, struct inode *);
1815 void (*rename_setup) (struct rpc_message *msg,
1816 struct dentry *old_dentry,
1817 struct dentry *new_dentry,
1818 struct inode *same_parent);
1819 void (*rename_rpc_prepare)(struct rpc_task *task, struct nfs_renamedata *);
1820 int (*rename_done) (struct rpc_task *task, struct inode *old_dir, struct inode *new_dir);
1821 int (*link) (struct inode *, struct inode *, const struct qstr *);
1822 int (*symlink) (struct inode *, struct dentry *, struct folio *,
1823 unsigned int, struct iattr *);
1824 struct dentry *(*mkdir) (struct inode *, struct dentry *, struct iattr *);
1825 int (*rmdir) (struct inode *, const struct qstr *);
1826 int (*readdir) (struct nfs_readdir_arg *, struct nfs_readdir_res *);
1827 int (*mknod) (struct inode *, struct dentry *, struct iattr *,
1828 dev_t);
1829 int (*statfs) (struct nfs_server *, struct nfs_fh *,
1830 struct nfs_fsstat *);
1831 int (*fsinfo) (struct nfs_server *, struct nfs_fh *,
1832 struct nfs_fsinfo *);
1833 int (*pathconf) (struct nfs_server *, struct nfs_fh *,
1834 struct nfs_pathconf *);
1835 int (*set_capabilities)(struct nfs_server *, struct nfs_fh *);
1836 int (*decode_dirent)(struct xdr_stream *, struct nfs_entry *, bool);
1837 int (*pgio_rpc_prepare)(struct rpc_task *,
1838 struct nfs_pgio_header *);
1839 void (*read_setup)(struct nfs_pgio_header *, struct rpc_message *);
1840 int (*read_done)(struct rpc_task *, struct nfs_pgio_header *);
1841 void (*write_setup)(struct nfs_pgio_header *, struct rpc_message *,
1842 struct rpc_clnt **);
1843 int (*write_done)(struct rpc_task *, struct nfs_pgio_header *);
1844 void (*commit_setup) (struct nfs_commit_data *, struct rpc_message *,
1845 struct rpc_clnt **);
1846 void (*commit_rpc_prepare)(struct rpc_task *, struct nfs_commit_data *);
1847 int (*commit_done) (struct rpc_task *, struct nfs_commit_data *);
1848 int (*lock)(struct file *, int, struct file_lock *);
1849 int (*lock_check_bounds)(const struct file_lock *);
1850 void (*clear_acl_cache)(struct inode *);
1851 void (*close_context)(struct nfs_open_context *ctx, int);
1852 struct inode * (*open_context) (struct inode *dir,
1853 struct nfs_open_context *ctx,
1854 int open_flags,
1855 struct iattr *iattr,
1856 int *);
1857 int (*have_delegation)(struct inode *, fmode_t, int);
1858 void (*return_delegation)(struct inode *);
1859 struct nfs_client *(*alloc_client) (const struct nfs_client_initdata *);
1860 struct nfs_client *(*init_client) (struct nfs_client *,
1861 const struct nfs_client_initdata *);
1862 void (*free_client) (struct nfs_client *);
1863 struct nfs_server *(*create_server)(struct fs_context *);
1864 struct nfs_server *(*clone_server)(struct nfs_server *, struct nfs_fh *,
1865 struct nfs_fattr *, rpc_authflavor_t);
1866 int (*discover_trunking)(struct nfs_server *, struct nfs_fh *);
1867 void (*enable_swap)(struct inode *inode);
1868 void (*disable_swap)(struct inode *inode);
1869 };
1870
1871 /*
1872 * Helper functions used by NFS client and/or server
1873 */
encode_opaque_fixed(struct xdr_stream * xdr,const void * buf,size_t len)1874 static inline void encode_opaque_fixed(struct xdr_stream *xdr,
1875 const void *buf, size_t len)
1876 {
1877 WARN_ON_ONCE(xdr_stream_encode_opaque_fixed(xdr, buf, len) < 0);
1878 }
1879
decode_opaque_fixed(struct xdr_stream * xdr,void * buf,size_t len)1880 static inline int decode_opaque_fixed(struct xdr_stream *xdr,
1881 void *buf, size_t len)
1882 {
1883 ssize_t ret = xdr_stream_decode_opaque_fixed(xdr, buf, len);
1884 if (unlikely(ret < 0))
1885 return -EIO;
1886 return 0;
1887 }
1888
1889 /*
1890 * Function vectors etc. for the NFS client
1891 */
1892 extern const struct nfs_rpc_ops nfs_v2_clientops;
1893 extern const struct nfs_rpc_ops nfs_v3_clientops;
1894 extern const struct nfs_rpc_ops nfs_v4_clientops;
1895 extern const struct rpc_version nfs_version2;
1896 extern const struct rpc_version nfs_version3;
1897 extern const struct rpc_version nfs_version4;
1898
1899 extern const struct rpc_version nfsacl_version3;
1900 extern const struct rpc_program nfsacl_program;
1901
1902 #endif /* _LINUX_NFS_XDR_H */
1903