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