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