Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300    1) // SPDX-License-Identifier: GPL-2.0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300    2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300    3)  * Copyright (c) 2014 Anna Schumaker <Anna.Schumaker@Netapp.com>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300    4)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300    5) #ifndef __LINUX_FS_NFS_NFS4_2XDR_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300    6) #define __LINUX_FS_NFS_NFS4_2XDR_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300    7) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300    8) #include "nfs42.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300    9) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   10) #define encode_fallocate_maxsz		(encode_stateid_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   11) 					 2 /* offset */ + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   12) 					 2 /* length */)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   13) #define NFS42_WRITE_RES_SIZE		(1 /* wr_callback_id size */ +\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   14) 					 XDR_QUADLEN(NFS4_STATEID_SIZE) + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   15) 					 2 /* wr_count */ + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   16) 					 1 /* wr_committed */ + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   17) 					 XDR_QUADLEN(NFS4_VERIFIER_SIZE))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   18) #define encode_allocate_maxsz		(op_encode_hdr_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   19) 					 encode_fallocate_maxsz)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   20) #define decode_allocate_maxsz		(op_decode_hdr_maxsz)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   21) #define encode_copy_maxsz		(op_encode_hdr_maxsz +          \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   22) 					 XDR_QUADLEN(NFS4_STATEID_SIZE) + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   23) 					 XDR_QUADLEN(NFS4_STATEID_SIZE) + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   24) 					 2 + 2 + 2 + 1 + 1 + 1 +\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   25) 					 1 + /* One cnr_source_server */\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   26) 					 1 + /* nl4_type */ \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   27) 					 1 + XDR_QUADLEN(NFS4_OPAQUE_LIMIT))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   28) #define decode_copy_maxsz		(op_decode_hdr_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   29) 					 NFS42_WRITE_RES_SIZE + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   30) 					 1 /* cr_consecutive */ + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   31) 					 1 /* cr_synchronous */)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   32) #define encode_offload_cancel_maxsz	(op_encode_hdr_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   33) 					 XDR_QUADLEN(NFS4_STATEID_SIZE))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   34) #define decode_offload_cancel_maxsz	(op_decode_hdr_maxsz)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   35) #define encode_copy_notify_maxsz	(op_encode_hdr_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   36) 					 XDR_QUADLEN(NFS4_STATEID_SIZE) + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   37) 					 1 + /* nl4_type */ \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   38) 					 1 + XDR_QUADLEN(NFS4_OPAQUE_LIMIT))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   39) #define decode_copy_notify_maxsz	(op_decode_hdr_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   40) 					 3 + /* cnr_lease_time */\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   41) 					 XDR_QUADLEN(NFS4_STATEID_SIZE) + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   42) 					 1 + /* Support 1 cnr_source_server */\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   43) 					 1 + /* nl4_type */ \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   44) 					 1 + XDR_QUADLEN(NFS4_OPAQUE_LIMIT))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   45) #define encode_deallocate_maxsz		(op_encode_hdr_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   46) 					 encode_fallocate_maxsz)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   47) #define decode_deallocate_maxsz		(op_decode_hdr_maxsz)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   48) #define encode_read_plus_maxsz		(op_encode_hdr_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   49) 					 encode_stateid_maxsz + 3)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   50) #define NFS42_READ_PLUS_SEGMENT_SIZE	(1 /* data_content4 */ + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   51) 					 2 /* data_info4.di_offset */ + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   52) 					 2 /* data_info4.di_length */)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   53) #define decode_read_plus_maxsz		(op_decode_hdr_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   54) 					 1 /* rpr_eof */ + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   55) 					 1 /* rpr_contents count */ + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   56) 					 2 * NFS42_READ_PLUS_SEGMENT_SIZE)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   57) #define encode_seek_maxsz		(op_encode_hdr_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   58) 					 encode_stateid_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   59) 					 2 /* offset */ + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   60) 					 1 /* whence */)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   61) #define decode_seek_maxsz		(op_decode_hdr_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   62) 					 1 /* eof */ + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   63) 					 1 /* whence */ + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   64) 					 2 /* offset */ + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   65) 					 2 /* length */)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   66) #define encode_io_info_maxsz		4
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   67) #define encode_layoutstats_maxsz	(op_decode_hdr_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   68) 					2 /* offset */ + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   69) 					2 /* length */ + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   70) 					encode_stateid_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   71) 					encode_io_info_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   72) 					encode_io_info_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   73) 					1 /* opaque devaddr4 length */ + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   74) 					XDR_QUADLEN(PNFS_LAYOUTSTATS_MAXSIZE))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   75) #define decode_layoutstats_maxsz	(op_decode_hdr_maxsz)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   76) #define encode_device_error_maxsz	(XDR_QUADLEN(NFS4_DEVICEID4_SIZE) + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   77) 					1 /* status */ + 1 /* opnum */)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   78) #define encode_layouterror_maxsz	(op_decode_hdr_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   79) 					2 /* offset */ + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   80) 					2 /* length */ + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   81) 					encode_stateid_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   82) 					1 /* Array size */ + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   83) 					encode_device_error_maxsz)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   84) #define decode_layouterror_maxsz	(op_decode_hdr_maxsz)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   85) #define encode_clone_maxsz		(encode_stateid_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   86) 					encode_stateid_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   87) 					2 /* src offset */ + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   88) 					2 /* dst offset */ + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   89) 					2 /* count */)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   90) #define decode_clone_maxsz		(op_decode_hdr_maxsz)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   91) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   92) #define NFS4_enc_allocate_sz		(compound_encode_hdr_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   93) 					 encode_sequence_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   94) 					 encode_putfh_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   95) 					 encode_allocate_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   96) 					 encode_getattr_maxsz)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   97) #define NFS4_dec_allocate_sz		(compound_decode_hdr_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   98) 					 decode_sequence_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   99) 					 decode_putfh_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  100) 					 decode_allocate_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  101) 					 decode_getattr_maxsz)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  102) #define NFS4_enc_copy_sz		(compound_encode_hdr_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  103) 					 encode_sequence_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  104) 					 encode_putfh_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  105) 					 encode_savefh_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  106) 					 encode_putfh_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  107) 					 encode_copy_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  108) 					 encode_commit_maxsz)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  109) #define NFS4_dec_copy_sz		(compound_decode_hdr_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  110) 					 decode_sequence_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  111) 					 decode_putfh_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  112) 					 decode_savefh_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  113) 					 decode_putfh_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  114) 					 decode_copy_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  115) 					 decode_commit_maxsz)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  116) #define NFS4_enc_offload_cancel_sz	(compound_encode_hdr_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  117) 					 encode_sequence_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  118) 					 encode_putfh_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  119) 					 encode_offload_cancel_maxsz)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  120) #define NFS4_dec_offload_cancel_sz	(compound_decode_hdr_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  121) 					 decode_sequence_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  122) 					 decode_putfh_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  123) 					 decode_offload_cancel_maxsz)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  124) #define NFS4_enc_copy_notify_sz		(compound_encode_hdr_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  125) 					 encode_putfh_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  126) 					 encode_copy_notify_maxsz)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  127) #define NFS4_dec_copy_notify_sz		(compound_decode_hdr_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  128) 					 decode_putfh_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  129) 					 decode_copy_notify_maxsz)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  130) #define NFS4_enc_deallocate_sz		(compound_encode_hdr_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  131) 					 encode_sequence_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  132) 					 encode_putfh_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  133) 					 encode_deallocate_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  134) 					 encode_getattr_maxsz)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  135) #define NFS4_dec_deallocate_sz		(compound_decode_hdr_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  136) 					 decode_sequence_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  137) 					 decode_putfh_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  138) 					 decode_deallocate_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  139) 					 decode_getattr_maxsz)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  140) #define NFS4_enc_read_plus_sz		(compound_encode_hdr_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  141) 					 encode_sequence_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  142) 					 encode_putfh_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  143) 					 encode_read_plus_maxsz)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  144) #define NFS4_dec_read_plus_sz		(compound_decode_hdr_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  145) 					 decode_sequence_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  146) 					 decode_putfh_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  147) 					 decode_read_plus_maxsz)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  148) #define NFS4_enc_seek_sz		(compound_encode_hdr_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  149) 					 encode_sequence_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  150) 					 encode_putfh_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  151) 					 encode_seek_maxsz)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  152) #define NFS4_dec_seek_sz		(compound_decode_hdr_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  153) 					 decode_sequence_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  154) 					 decode_putfh_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  155) 					 decode_seek_maxsz)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  156) #define NFS4_enc_layoutstats_sz		(compound_encode_hdr_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  157) 					 encode_sequence_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  158) 					 encode_putfh_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  159) 					 PNFS_LAYOUTSTATS_MAXDEV * encode_layoutstats_maxsz)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  160) #define NFS4_dec_layoutstats_sz		(compound_decode_hdr_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  161) 					 decode_sequence_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  162) 					 decode_putfh_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  163) 					 PNFS_LAYOUTSTATS_MAXDEV * decode_layoutstats_maxsz)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  164) #define NFS4_enc_layouterror_sz		(compound_encode_hdr_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  165) 					 encode_sequence_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  166) 					 encode_putfh_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  167) 					 NFS42_LAYOUTERROR_MAX * \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  168) 					 encode_layouterror_maxsz)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  169) #define NFS4_dec_layouterror_sz		(compound_decode_hdr_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  170) 					 decode_sequence_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  171) 					 decode_putfh_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  172) 					 NFS42_LAYOUTERROR_MAX * \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  173) 					 decode_layouterror_maxsz)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  174) #define NFS4_enc_clone_sz		(compound_encode_hdr_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  175) 					 encode_sequence_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  176) 					 encode_putfh_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  177) 					 encode_savefh_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  178) 					 encode_putfh_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  179) 					 encode_clone_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  180) 					 encode_getattr_maxsz)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  181) #define NFS4_dec_clone_sz		(compound_decode_hdr_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  182) 					 decode_sequence_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  183) 					 decode_putfh_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  184) 					 decode_savefh_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  185) 					 decode_putfh_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  186) 					 decode_clone_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  187) 					 decode_getattr_maxsz)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  188) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  189) /* Not limited by NFS itself, limited by the generic xattr code */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  190) #define nfs4_xattr_name_maxsz   XDR_QUADLEN(XATTR_NAME_MAX)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  191) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  192) #define encode_getxattr_maxsz   (op_encode_hdr_maxsz + 1 + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  193) 				 nfs4_xattr_name_maxsz)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  194) #define decode_getxattr_maxsz   (op_decode_hdr_maxsz + 1 + 1)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  195) #define encode_setxattr_maxsz   (op_encode_hdr_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  196) 				 1 + nfs4_xattr_name_maxsz + 1)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  197) #define decode_setxattr_maxsz   (op_decode_hdr_maxsz + decode_change_info_maxsz)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  198) #define encode_listxattrs_maxsz  (op_encode_hdr_maxsz + 2 + 1)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  199) #define decode_listxattrs_maxsz  (op_decode_hdr_maxsz + 2 + 1 + 1 + 1)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  200) #define encode_removexattr_maxsz (op_encode_hdr_maxsz + 1 + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  201) 				  nfs4_xattr_name_maxsz)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  202) #define decode_removexattr_maxsz (op_decode_hdr_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  203) 				  decode_change_info_maxsz)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  204) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  205) #define NFS4_enc_getxattr_sz	(compound_encode_hdr_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  206) 				encode_sequence_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  207) 				encode_putfh_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  208) 				encode_getxattr_maxsz)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  209) #define NFS4_dec_getxattr_sz	(compound_decode_hdr_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  210) 				decode_sequence_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  211) 				decode_putfh_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  212) 				decode_getxattr_maxsz)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  213) #define NFS4_enc_setxattr_sz	(compound_encode_hdr_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  214) 				encode_sequence_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  215) 				encode_putfh_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  216) 				encode_setxattr_maxsz)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  217) #define NFS4_dec_setxattr_sz	(compound_decode_hdr_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  218) 				decode_sequence_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  219) 				decode_putfh_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  220) 				decode_setxattr_maxsz)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  221) #define NFS4_enc_listxattrs_sz	(compound_encode_hdr_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  222) 				encode_sequence_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  223) 				encode_putfh_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  224) 				encode_listxattrs_maxsz)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  225) #define NFS4_dec_listxattrs_sz	(compound_decode_hdr_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  226) 				decode_sequence_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  227) 				decode_putfh_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  228) 				decode_listxattrs_maxsz)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  229) #define NFS4_enc_removexattr_sz	(compound_encode_hdr_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  230) 				encode_sequence_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  231) 				encode_putfh_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  232) 				encode_removexattr_maxsz)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  233) #define NFS4_dec_removexattr_sz	(compound_decode_hdr_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  234) 				decode_sequence_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  235) 				decode_putfh_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  236) 				decode_removexattr_maxsz)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  237) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  238) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  239)  * These values specify the maximum amount of data that is not
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  240)  * associated with the extended attribute name or extended
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  241)  * attribute list in the SETXATTR, GETXATTR and LISTXATTR
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  242)  * respectively.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  243)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  244) const u32 nfs42_maxsetxattr_overhead = ((RPC_MAX_HEADER_WITH_AUTH +
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  245) 					compound_encode_hdr_maxsz +
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  246) 					encode_sequence_maxsz +
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  247) 					encode_putfh_maxsz + 1 +
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  248) 					nfs4_xattr_name_maxsz)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  249) 					* XDR_UNIT);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  250) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  251) const u32 nfs42_maxgetxattr_overhead = ((RPC_MAX_HEADER_WITH_AUTH +
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  252) 					compound_decode_hdr_maxsz +
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  253) 					decode_sequence_maxsz +
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  254) 					decode_putfh_maxsz + 1) * XDR_UNIT);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  255) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  256) const u32 nfs42_maxlistxattrs_overhead = ((RPC_MAX_HEADER_WITH_AUTH +
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  257) 					compound_decode_hdr_maxsz +
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  258) 					decode_sequence_maxsz +
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  259) 					decode_putfh_maxsz + 3) * XDR_UNIT);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  260) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  261) static void encode_fallocate(struct xdr_stream *xdr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  262) 			     const struct nfs42_falloc_args *args)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  263) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  264) 	encode_nfs4_stateid(xdr, &args->falloc_stateid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  265) 	encode_uint64(xdr, args->falloc_offset);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  266) 	encode_uint64(xdr, args->falloc_length);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  267) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  268) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  269) static void encode_allocate(struct xdr_stream *xdr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  270) 			    const struct nfs42_falloc_args *args,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  271) 			    struct compound_hdr *hdr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  272) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  273) 	encode_op_hdr(xdr, OP_ALLOCATE, decode_allocate_maxsz, hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  274) 	encode_fallocate(xdr, args);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  275) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  276) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  277) static void encode_nl4_server(struct xdr_stream *xdr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  278) 			      const struct nl4_server *ns)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  279) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  280) 	encode_uint32(xdr, ns->nl4_type);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  281) 	switch (ns->nl4_type) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  282) 	case NL4_NAME:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  283) 	case NL4_URL:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  284) 		encode_string(xdr, ns->u.nl4_str_sz, ns->u.nl4_str);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  285) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  286) 	case NL4_NETADDR:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  287) 		encode_string(xdr, ns->u.nl4_addr.netid_len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  288) 			      ns->u.nl4_addr.netid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  289) 		encode_string(xdr, ns->u.nl4_addr.addr_len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  290) 			      ns->u.nl4_addr.addr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  291) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  292) 	default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  293) 		WARN_ON_ONCE(1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  294) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  295) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  296) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  297) static void encode_copy(struct xdr_stream *xdr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  298) 			const struct nfs42_copy_args *args,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  299) 			struct compound_hdr *hdr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  300) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  301) 	encode_op_hdr(xdr, OP_COPY, decode_copy_maxsz, hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  302) 	encode_nfs4_stateid(xdr, &args->src_stateid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  303) 	encode_nfs4_stateid(xdr, &args->dst_stateid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  304) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  305) 	encode_uint64(xdr, args->src_pos);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  306) 	encode_uint64(xdr, args->dst_pos);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  307) 	encode_uint64(xdr, args->count);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  308) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  309) 	encode_uint32(xdr, 1); /* consecutive = true */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  310) 	encode_uint32(xdr, args->sync);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  311) 	if (args->cp_src == NULL) { /* intra-ssc */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  312) 		encode_uint32(xdr, 0); /* no src server list */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  313) 		return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  314) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  315) 	encode_uint32(xdr, 1); /* supporting 1 server */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  316) 	encode_nl4_server(xdr, args->cp_src);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  317) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  318) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  319) static void encode_offload_cancel(struct xdr_stream *xdr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  320) 				  const struct nfs42_offload_status_args *args,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  321) 				  struct compound_hdr *hdr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  322) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  323) 	encode_op_hdr(xdr, OP_OFFLOAD_CANCEL, decode_offload_cancel_maxsz, hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  324) 	encode_nfs4_stateid(xdr, &args->osa_stateid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  325) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  326) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  327) static void encode_copy_notify(struct xdr_stream *xdr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  328) 			       const struct nfs42_copy_notify_args *args,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  329) 			       struct compound_hdr *hdr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  330) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  331) 	encode_op_hdr(xdr, OP_COPY_NOTIFY, decode_copy_notify_maxsz, hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  332) 	encode_nfs4_stateid(xdr, &args->cna_src_stateid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  333) 	encode_nl4_server(xdr, &args->cna_dst);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  334) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  335) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  336) static void encode_deallocate(struct xdr_stream *xdr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  337) 			      const struct nfs42_falloc_args *args,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  338) 			      struct compound_hdr *hdr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  339) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  340) 	encode_op_hdr(xdr, OP_DEALLOCATE, decode_deallocate_maxsz, hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  341) 	encode_fallocate(xdr, args);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  342) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  343) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  344) static void encode_read_plus(struct xdr_stream *xdr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  345) 			     const struct nfs_pgio_args *args,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  346) 			     struct compound_hdr *hdr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  347) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  348) 	encode_op_hdr(xdr, OP_READ_PLUS, decode_read_plus_maxsz, hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  349) 	encode_nfs4_stateid(xdr, &args->stateid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  350) 	encode_uint64(xdr, args->offset);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  351) 	encode_uint32(xdr, args->count);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  352) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  353) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  354) static void encode_seek(struct xdr_stream *xdr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  355) 			const struct nfs42_seek_args *args,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  356) 			struct compound_hdr *hdr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  357) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  358) 	encode_op_hdr(xdr, OP_SEEK, decode_seek_maxsz, hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  359) 	encode_nfs4_stateid(xdr, &args->sa_stateid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  360) 	encode_uint64(xdr, args->sa_offset);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  361) 	encode_uint32(xdr, args->sa_what);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  362) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  363) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  364) static void encode_layoutstats(struct xdr_stream *xdr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  365) 			       const struct nfs42_layoutstat_args *args,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  366) 			       struct nfs42_layoutstat_devinfo *devinfo,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  367) 			       struct compound_hdr *hdr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  368) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  369) 	__be32 *p;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  370) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  371) 	encode_op_hdr(xdr, OP_LAYOUTSTATS, decode_layoutstats_maxsz, hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  372) 	p = reserve_space(xdr, 8 + 8);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  373) 	p = xdr_encode_hyper(p, devinfo->offset);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  374) 	p = xdr_encode_hyper(p, devinfo->length);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  375) 	encode_nfs4_stateid(xdr, &args->stateid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  376) 	p = reserve_space(xdr, 4*8 + NFS4_DEVICEID4_SIZE + 4);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  377) 	p = xdr_encode_hyper(p, devinfo->read_count);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  378) 	p = xdr_encode_hyper(p, devinfo->read_bytes);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  379) 	p = xdr_encode_hyper(p, devinfo->write_count);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  380) 	p = xdr_encode_hyper(p, devinfo->write_bytes);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  381) 	p = xdr_encode_opaque_fixed(p, devinfo->dev_id.data,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  382) 			NFS4_DEVICEID4_SIZE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  383) 	/* Encode layoutupdate4 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  384) 	*p++ = cpu_to_be32(devinfo->layout_type);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  385) 	if (devinfo->ld_private.ops)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  386) 		devinfo->ld_private.ops->encode(xdr, args,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  387) 				&devinfo->ld_private);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  388) 	else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  389) 		encode_uint32(xdr, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  390) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  391) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  392) static void encode_clone(struct xdr_stream *xdr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  393) 			 const struct nfs42_clone_args *args,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  394) 			 struct compound_hdr *hdr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  395) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  396) 	__be32 *p;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  397) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  398) 	encode_op_hdr(xdr, OP_CLONE, decode_clone_maxsz, hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  399) 	encode_nfs4_stateid(xdr, &args->src_stateid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  400) 	encode_nfs4_stateid(xdr, &args->dst_stateid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  401) 	p = reserve_space(xdr, 3*8);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  402) 	p = xdr_encode_hyper(p, args->src_offset);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  403) 	p = xdr_encode_hyper(p, args->dst_offset);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  404) 	xdr_encode_hyper(p, args->count);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  405) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  406) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  407) static void encode_device_error(struct xdr_stream *xdr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  408) 				const struct nfs42_device_error *error)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  409) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  410) 	__be32 *p;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  411) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  412) 	p = reserve_space(xdr, NFS4_DEVICEID4_SIZE + 2*4);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  413) 	p = xdr_encode_opaque_fixed(p, error->dev_id.data,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  414) 			NFS4_DEVICEID4_SIZE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  415) 	*p++ = cpu_to_be32(error->status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  416) 	*p = cpu_to_be32(error->opnum);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  417) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  418) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  419) static void encode_layouterror(struct xdr_stream *xdr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  420) 			       const struct nfs42_layout_error *args,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  421) 			       struct compound_hdr *hdr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  422) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  423) 	__be32 *p;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  424) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  425) 	encode_op_hdr(xdr, OP_LAYOUTERROR, decode_layouterror_maxsz, hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  426) 	p = reserve_space(xdr, 8 + 8);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  427) 	p = xdr_encode_hyper(p, args->offset);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  428) 	p = xdr_encode_hyper(p, args->length);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  429) 	encode_nfs4_stateid(xdr, &args->stateid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  430) 	p = reserve_space(xdr, 4);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  431) 	*p = cpu_to_be32(1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  432) 	encode_device_error(xdr, &args->errors[0]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  433) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  434) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  435) static void encode_setxattr(struct xdr_stream *xdr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  436) 			    const struct nfs42_setxattrargs *arg,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  437) 			    struct compound_hdr *hdr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  438) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  439) 	__be32 *p;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  440) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  441) 	BUILD_BUG_ON(XATTR_CREATE != SETXATTR4_CREATE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  442) 	BUILD_BUG_ON(XATTR_REPLACE != SETXATTR4_REPLACE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  443) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  444) 	encode_op_hdr(xdr, OP_SETXATTR, decode_setxattr_maxsz, hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  445) 	p = reserve_space(xdr, 4);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  446) 	*p = cpu_to_be32(arg->xattr_flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  447) 	encode_string(xdr, strlen(arg->xattr_name), arg->xattr_name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  448) 	p = reserve_space(xdr, 4);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  449) 	*p = cpu_to_be32(arg->xattr_len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  450) 	if (arg->xattr_len)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  451) 		xdr_write_pages(xdr, arg->xattr_pages, 0, arg->xattr_len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  452) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  453) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  454) static int decode_setxattr(struct xdr_stream *xdr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  455) 			   struct nfs4_change_info *cinfo)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  456) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  457) 	int status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  458) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  459) 	status = decode_op_hdr(xdr, OP_SETXATTR);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  460) 	if (status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  461) 		goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  462) 	status = decode_change_info(xdr, cinfo);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  463) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  464) 	return status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  465) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  466) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  467) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  468) static void encode_getxattr(struct xdr_stream *xdr, const char *name,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  469) 			    struct compound_hdr *hdr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  470) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  471) 	encode_op_hdr(xdr, OP_GETXATTR, decode_getxattr_maxsz, hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  472) 	encode_string(xdr, strlen(name), name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  473) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  474) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  475) static int decode_getxattr(struct xdr_stream *xdr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  476) 			   struct nfs42_getxattrres *res,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  477) 			   struct rpc_rqst *req)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  478) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  479) 	int status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  480) 	__be32 *p;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  481) 	u32 len, rdlen;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  482) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  483) 	status = decode_op_hdr(xdr, OP_GETXATTR);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  484) 	if (status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  485) 		return status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  486) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  487) 	p = xdr_inline_decode(xdr, 4);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  488) 	if (unlikely(!p))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  489) 		return -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  490) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  491) 	len = be32_to_cpup(p);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  492) 	if (len > req->rq_rcv_buf.page_len)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  493) 		return -ERANGE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  494) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  495) 	res->xattr_len = len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  496) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  497) 	if (len > 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  498) 		rdlen = xdr_read_pages(xdr, len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  499) 		if (rdlen < len)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  500) 			return -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  501) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  502) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  503) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  504) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  505) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  506) static void encode_removexattr(struct xdr_stream *xdr, const char *name,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  507) 			       struct compound_hdr *hdr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  508) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  509) 	encode_op_hdr(xdr, OP_REMOVEXATTR, decode_removexattr_maxsz, hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  510) 	encode_string(xdr, strlen(name), name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  511) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  512) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  513) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  514) static int decode_removexattr(struct xdr_stream *xdr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  515) 			   struct nfs4_change_info *cinfo)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  516) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  517) 	int status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  518) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  519) 	status = decode_op_hdr(xdr, OP_REMOVEXATTR);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  520) 	if (status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  521) 		goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  522) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  523) 	status = decode_change_info(xdr, cinfo);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  524) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  525) 	return status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  526) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  527) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  528) static void encode_listxattrs(struct xdr_stream *xdr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  529) 			     const struct nfs42_listxattrsargs *arg,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  530) 			     struct compound_hdr *hdr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  531) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  532) 	__be32 *p;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  533) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  534) 	encode_op_hdr(xdr, OP_LISTXATTRS, decode_listxattrs_maxsz, hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  535) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  536) 	p = reserve_space(xdr, 12);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  537) 	if (unlikely(!p))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  538) 		return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  539) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  540) 	p = xdr_encode_hyper(p, arg->cookie);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  541) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  542) 	 * RFC 8276 says to specify the full max length of the LISTXATTRS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  543) 	 * XDR reply. Count is set to the XDR length of the names array
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  544) 	 * plus the EOF marker. So, add the cookie and the names count.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  545) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  546) 	*p = cpu_to_be32(arg->count + 8 + 4);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  547) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  548) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  549) static int decode_listxattrs(struct xdr_stream *xdr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  550) 			    struct nfs42_listxattrsres *res)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  551) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  552) 	int status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  553) 	__be32 *p;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  554) 	u32 count, len, ulen;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  555) 	size_t left, copied;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  556) 	char *buf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  557) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  558) 	status = decode_op_hdr(xdr, OP_LISTXATTRS);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  559) 	if (status) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  560) 		/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  561) 		 * Special case: for LISTXATTRS, NFS4ERR_TOOSMALL
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  562) 		 * should be translated to ERANGE.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  563) 		 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  564) 		if (status == -ETOOSMALL)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  565) 			status = -ERANGE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  566) 		goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  567) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  568) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  569) 	p = xdr_inline_decode(xdr, 8);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  570) 	if (unlikely(!p))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  571) 		return -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  572) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  573) 	xdr_decode_hyper(p, &res->cookie);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  574) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  575) 	p = xdr_inline_decode(xdr, 4);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  576) 	if (unlikely(!p))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  577) 		return -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  578) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  579) 	left = res->xattr_len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  580) 	buf = res->xattr_buf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  581) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  582) 	count = be32_to_cpup(p);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  583) 	copied = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  584) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  585) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  586) 	 * We have asked for enough room to encode the maximum number
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  587) 	 * of possible attribute names, so everything should fit.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  588) 	 *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  589) 	 * But, don't rely on that assumption. Just decode entries
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  590) 	 * until they don't fit anymore, just in case the server did
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  591) 	 * something odd.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  592) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  593) 	while (count--) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  594) 		p = xdr_inline_decode(xdr, 4);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  595) 		if (unlikely(!p))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  596) 			return -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  597) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  598) 		len = be32_to_cpup(p);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  599) 		if (len > (XATTR_NAME_MAX - XATTR_USER_PREFIX_LEN)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  600) 			status = -ERANGE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  601) 			goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  602) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  603) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  604) 		p = xdr_inline_decode(xdr, len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  605) 		if (unlikely(!p))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  606) 			return -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  607) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  608) 		ulen = len + XATTR_USER_PREFIX_LEN + 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  609) 		if (buf) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  610) 			if (ulen > left) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  611) 				status = -ERANGE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  612) 				goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  613) 			}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  614) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  615) 			memcpy(buf, XATTR_USER_PREFIX, XATTR_USER_PREFIX_LEN);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  616) 			memcpy(buf + XATTR_USER_PREFIX_LEN, p, len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  617) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  618) 			buf[ulen - 1] = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  619) 			buf += ulen;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  620) 			left -= ulen;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  621) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  622) 		copied += ulen;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  623) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  624) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  625) 	p = xdr_inline_decode(xdr, 4);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  626) 	if (unlikely(!p))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  627) 		return -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  628) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  629) 	res->eof = be32_to_cpup(p);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  630) 	res->copied = copied;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  631) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  632) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  633) 	if (status == -ERANGE && res->xattr_len == XATTR_LIST_MAX)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  634) 		status = -E2BIG;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  635) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  636) 	return status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  637) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  638) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  639) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  640)  * Encode ALLOCATE request
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  641)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  642) static void nfs4_xdr_enc_allocate(struct rpc_rqst *req,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  643) 				  struct xdr_stream *xdr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  644) 				  const void *data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  645) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  646) 	const struct nfs42_falloc_args *args = data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  647) 	struct compound_hdr hdr = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  648) 		.minorversion = nfs4_xdr_minorversion(&args->seq_args),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  649) 	};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  650) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  651) 	encode_compound_hdr(xdr, req, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  652) 	encode_sequence(xdr, &args->seq_args, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  653) 	encode_putfh(xdr, args->falloc_fh, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  654) 	encode_allocate(xdr, args, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  655) 	encode_getfattr(xdr, args->falloc_bitmask, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  656) 	encode_nops(&hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  657) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  658) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  659) static void encode_copy_commit(struct xdr_stream *xdr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  660) 			  const struct nfs42_copy_args *args,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  661) 			  struct compound_hdr *hdr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  662) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  663) 	__be32 *p;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  664) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  665) 	encode_op_hdr(xdr, OP_COMMIT, decode_commit_maxsz, hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  666) 	p = reserve_space(xdr, 12);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  667) 	p = xdr_encode_hyper(p, args->dst_pos);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  668) 	*p = cpu_to_be32(args->count);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  669) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  670) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  671) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  672)  * Encode COPY request
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  673)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  674) static void nfs4_xdr_enc_copy(struct rpc_rqst *req,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  675) 			      struct xdr_stream *xdr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  676) 			      const void *data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  677) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  678) 	const struct nfs42_copy_args *args = data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  679) 	struct compound_hdr hdr = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  680) 		.minorversion = nfs4_xdr_minorversion(&args->seq_args),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  681) 	};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  682) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  683) 	encode_compound_hdr(xdr, req, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  684) 	encode_sequence(xdr, &args->seq_args, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  685) 	encode_putfh(xdr, args->src_fh, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  686) 	encode_savefh(xdr, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  687) 	encode_putfh(xdr, args->dst_fh, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  688) 	encode_copy(xdr, args, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  689) 	if (args->sync)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  690) 		encode_copy_commit(xdr, args, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  691) 	encode_nops(&hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  692) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  693) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  694) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  695)  * Encode OFFLOAD_CANEL request
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  696)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  697) static void nfs4_xdr_enc_offload_cancel(struct rpc_rqst *req,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  698) 					struct xdr_stream *xdr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  699) 					const void *data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  700) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  701) 	const struct nfs42_offload_status_args *args = data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  702) 	struct compound_hdr hdr = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  703) 		.minorversion = nfs4_xdr_minorversion(&args->osa_seq_args),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  704) 	};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  705) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  706) 	encode_compound_hdr(xdr, req, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  707) 	encode_sequence(xdr, &args->osa_seq_args, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  708) 	encode_putfh(xdr, args->osa_src_fh, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  709) 	encode_offload_cancel(xdr, args, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  710) 	encode_nops(&hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  711) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  712) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  713) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  714)  * Encode COPY_NOTIFY request
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  715)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  716) static void nfs4_xdr_enc_copy_notify(struct rpc_rqst *req,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  717) 				     struct xdr_stream *xdr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  718) 				     const void *data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  719) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  720) 	const struct nfs42_copy_notify_args *args = data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  721) 	struct compound_hdr hdr = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  722) 		.minorversion = nfs4_xdr_minorversion(&args->cna_seq_args),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  723) 	};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  724) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  725) 	encode_compound_hdr(xdr, req, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  726) 	encode_sequence(xdr, &args->cna_seq_args, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  727) 	encode_putfh(xdr, args->cna_src_fh, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  728) 	encode_copy_notify(xdr, args, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  729) 	encode_nops(&hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  730) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  731) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  732) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  733)  * Encode DEALLOCATE request
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  734)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  735) static void nfs4_xdr_enc_deallocate(struct rpc_rqst *req,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  736) 				    struct xdr_stream *xdr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  737) 				    const void *data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  738) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  739) 	const struct nfs42_falloc_args *args = data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  740) 	struct compound_hdr hdr = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  741) 		.minorversion = nfs4_xdr_minorversion(&args->seq_args),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  742) 	};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  743) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  744) 	encode_compound_hdr(xdr, req, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  745) 	encode_sequence(xdr, &args->seq_args, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  746) 	encode_putfh(xdr, args->falloc_fh, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  747) 	encode_deallocate(xdr, args, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  748) 	encode_getfattr(xdr, args->falloc_bitmask, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  749) 	encode_nops(&hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  750) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  751) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  752) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  753)  * Encode READ_PLUS request
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  754)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  755) static void nfs4_xdr_enc_read_plus(struct rpc_rqst *req,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  756) 				   struct xdr_stream *xdr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  757) 				   const void *data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  758) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  759) 	const struct nfs_pgio_args *args = data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  760) 	struct compound_hdr hdr = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  761) 		.minorversion = nfs4_xdr_minorversion(&args->seq_args),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  762) 	};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  763) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  764) 	encode_compound_hdr(xdr, req, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  765) 	encode_sequence(xdr, &args->seq_args, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  766) 	encode_putfh(xdr, args->fh, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  767) 	encode_read_plus(xdr, args, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  768) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  769) 	rpc_prepare_reply_pages(req, args->pages, args->pgbase,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  770) 				args->count, hdr.replen);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  771) 	encode_nops(&hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  772) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  773) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  774) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  775)  * Encode SEEK request
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  776)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  777) static void nfs4_xdr_enc_seek(struct rpc_rqst *req,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  778) 			      struct xdr_stream *xdr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  779) 			      const void *data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  780) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  781) 	const struct nfs42_seek_args *args = data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  782) 	struct compound_hdr hdr = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  783) 		.minorversion = nfs4_xdr_minorversion(&args->seq_args),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  784) 	};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  785) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  786) 	encode_compound_hdr(xdr, req, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  787) 	encode_sequence(xdr, &args->seq_args, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  788) 	encode_putfh(xdr, args->sa_fh, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  789) 	encode_seek(xdr, args, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  790) 	encode_nops(&hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  791) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  792) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  793) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  794)  * Encode LAYOUTSTATS request
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  795)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  796) static void nfs4_xdr_enc_layoutstats(struct rpc_rqst *req,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  797) 				     struct xdr_stream *xdr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  798) 				     const void *data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  799) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  800) 	const struct nfs42_layoutstat_args *args = data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  801) 	int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  802) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  803) 	struct compound_hdr hdr = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  804) 		.minorversion = nfs4_xdr_minorversion(&args->seq_args),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  805) 	};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  806) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  807) 	encode_compound_hdr(xdr, req, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  808) 	encode_sequence(xdr, &args->seq_args, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  809) 	encode_putfh(xdr, args->fh, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  810) 	WARN_ON(args->num_dev > PNFS_LAYOUTSTATS_MAXDEV);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  811) 	for (i = 0; i < args->num_dev; i++)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  812) 		encode_layoutstats(xdr, args, &args->devinfo[i], &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  813) 	encode_nops(&hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  814) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  815) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  816) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  817)  * Encode CLONE request
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  818)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  819) static void nfs4_xdr_enc_clone(struct rpc_rqst *req,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  820) 			       struct xdr_stream *xdr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  821) 			       const void *data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  822) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  823) 	const struct nfs42_clone_args *args = data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  824) 	struct compound_hdr hdr = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  825) 		.minorversion = nfs4_xdr_minorversion(&args->seq_args),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  826) 	};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  827) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  828) 	encode_compound_hdr(xdr, req, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  829) 	encode_sequence(xdr, &args->seq_args, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  830) 	encode_putfh(xdr, args->src_fh, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  831) 	encode_savefh(xdr, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  832) 	encode_putfh(xdr, args->dst_fh, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  833) 	encode_clone(xdr, args, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  834) 	encode_getfattr(xdr, args->dst_bitmask, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  835) 	encode_nops(&hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  836) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  837) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  838) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  839)  * Encode LAYOUTERROR request
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  840)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  841) static void nfs4_xdr_enc_layouterror(struct rpc_rqst *req,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  842) 				     struct xdr_stream *xdr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  843) 				     const void *data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  844) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  845) 	const struct nfs42_layouterror_args *args = data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  846) 	struct compound_hdr hdr = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  847) 		.minorversion = nfs4_xdr_minorversion(&args->seq_args),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  848) 	};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  849) 	int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  850) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  851) 	encode_compound_hdr(xdr, req, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  852) 	encode_sequence(xdr, &args->seq_args, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  853) 	encode_putfh(xdr, NFS_FH(args->inode), &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  854) 	for (i = 0; i < args->num_errors; i++)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  855) 		encode_layouterror(xdr, &args->errors[i], &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  856) 	encode_nops(&hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  857) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  858) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  859) static int decode_allocate(struct xdr_stream *xdr, struct nfs42_falloc_res *res)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  860) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  861) 	return decode_op_hdr(xdr, OP_ALLOCATE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  862) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  863) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  864) static int decode_write_response(struct xdr_stream *xdr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  865) 				 struct nfs42_write_res *res)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  866) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  867) 	__be32 *p;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  868) 	int status, count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  869) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  870) 	p = xdr_inline_decode(xdr, 4);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  871) 	if (unlikely(!p))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  872) 		return -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  873) 	count = be32_to_cpup(p);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  874) 	if (count > 1)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  875) 		return -EREMOTEIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  876) 	else if (count == 1) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  877) 		status = decode_opaque_fixed(xdr, &res->stateid,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  878) 				NFS4_STATEID_SIZE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  879) 		if (unlikely(status))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  880) 			return -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  881) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  882) 	p = xdr_inline_decode(xdr, 8 + 4);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  883) 	if (unlikely(!p))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  884) 		return -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  885) 	p = xdr_decode_hyper(p, &res->count);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  886) 	res->verifier.committed = be32_to_cpup(p);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  887) 	return decode_verifier(xdr, &res->verifier.verifier);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  888) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  889) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  890) static int decode_nl4_server(struct xdr_stream *xdr, struct nl4_server *ns)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  891) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  892) 	struct nfs42_netaddr *naddr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  893) 	uint32_t dummy;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  894) 	char *dummy_str;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  895) 	__be32 *p;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  896) 	int status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  897) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  898) 	/* nl_type */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  899) 	p = xdr_inline_decode(xdr, 4);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  900) 	if (unlikely(!p))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  901) 		return -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  902) 	ns->nl4_type = be32_to_cpup(p);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  903) 	switch (ns->nl4_type) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  904) 	case NL4_NAME:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  905) 	case NL4_URL:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  906) 		status = decode_opaque_inline(xdr, &dummy, &dummy_str);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  907) 		if (unlikely(status))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  908) 			return status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  909) 		if (unlikely(dummy > NFS4_OPAQUE_LIMIT))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  910) 			return -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  911) 		memcpy(&ns->u.nl4_str, dummy_str, dummy);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  912) 		ns->u.nl4_str_sz = dummy;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  913) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  914) 	case NL4_NETADDR:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  915) 		naddr = &ns->u.nl4_addr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  916) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  917) 		/* netid string */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  918) 		status = decode_opaque_inline(xdr, &dummy, &dummy_str);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  919) 		if (unlikely(status))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  920) 			return status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  921) 		if (unlikely(dummy > RPCBIND_MAXNETIDLEN))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  922) 			return -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  923) 		naddr->netid_len = dummy;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  924) 		memcpy(naddr->netid, dummy_str, naddr->netid_len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  925) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  926) 		/* uaddr string */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  927) 		status = decode_opaque_inline(xdr, &dummy, &dummy_str);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  928) 		if (unlikely(status))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  929) 			return status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  930) 		if (unlikely(dummy > RPCBIND_MAXUADDRLEN))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  931) 			return -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  932) 		naddr->addr_len = dummy;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  933) 		memcpy(naddr->addr, dummy_str, naddr->addr_len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  934) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  935) 	default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  936) 		WARN_ON_ONCE(1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  937) 		return -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  938) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  939) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  940) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  941) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  942) static int decode_copy_requirements(struct xdr_stream *xdr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  943) 				    struct nfs42_copy_res *res) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  944) 	__be32 *p;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  945) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  946) 	p = xdr_inline_decode(xdr, 4 + 4);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  947) 	if (unlikely(!p))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  948) 		return -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  949) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  950) 	res->consecutive = be32_to_cpup(p++);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  951) 	res->synchronous = be32_to_cpup(p++);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  952) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  953) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  954) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  955) static int decode_copy(struct xdr_stream *xdr, struct nfs42_copy_res *res)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  956) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  957) 	int status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  958) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  959) 	status = decode_op_hdr(xdr, OP_COPY);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  960) 	if (status == NFS4ERR_OFFLOAD_NO_REQS) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  961) 		status = decode_copy_requirements(xdr, res);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  962) 		if (status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  963) 			return status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  964) 		return NFS4ERR_OFFLOAD_NO_REQS;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  965) 	} else if (status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  966) 		return status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  967) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  968) 	status = decode_write_response(xdr, &res->write_res);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  969) 	if (status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  970) 		return status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  971) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  972) 	return decode_copy_requirements(xdr, res);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  973) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  974) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  975) static int decode_offload_cancel(struct xdr_stream *xdr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  976) 				 struct nfs42_offload_status_res *res)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  977) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  978) 	return decode_op_hdr(xdr, OP_OFFLOAD_CANCEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  979) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  980) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  981) static int decode_copy_notify(struct xdr_stream *xdr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  982) 			      struct nfs42_copy_notify_res *res)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  983) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  984) 	__be32 *p;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  985) 	int status, count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  986) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  987) 	status = decode_op_hdr(xdr, OP_COPY_NOTIFY);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  988) 	if (status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  989) 		return status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  990) 	/* cnr_lease_time */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  991) 	p = xdr_inline_decode(xdr, 12);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  992) 	if (unlikely(!p))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  993) 		return -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  994) 	p = xdr_decode_hyper(p, &res->cnr_lease_time.seconds);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  995) 	res->cnr_lease_time.nseconds = be32_to_cpup(p);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  996) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  997) 	status = decode_opaque_fixed(xdr, &res->cnr_stateid, NFS4_STATEID_SIZE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  998) 	if (unlikely(status))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  999) 		return -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1000) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1001) 	/* number of source addresses */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1002) 	p = xdr_inline_decode(xdr, 4);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1003) 	if (unlikely(!p))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1004) 		return -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1005) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1006) 	count = be32_to_cpup(p);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1007) 	if (count > 1)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1008) 		pr_warn("NFS: %s: nsvr %d > Supported. Use first servers\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1009) 			 __func__, count);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1010) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1011) 	status = decode_nl4_server(xdr, &res->cnr_src);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1012) 	if (unlikely(status))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1013) 		return -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1014) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1015) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1016) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1017) static int decode_deallocate(struct xdr_stream *xdr, struct nfs42_falloc_res *res)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1018) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1019) 	return decode_op_hdr(xdr, OP_DEALLOCATE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1020) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1021) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1022) static int decode_read_plus_data(struct xdr_stream *xdr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1023) 				 struct nfs_pgio_res *res)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1024) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1025) 	uint32_t count, recvd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1026) 	uint64_t offset;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1027) 	__be32 *p;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1028) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1029) 	p = xdr_inline_decode(xdr, 8 + 4);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1030) 	if (!p)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1031) 		return 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1032) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1033) 	p = xdr_decode_hyper(p, &offset);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1034) 	count = be32_to_cpup(p);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1035) 	recvd = xdr_align_data(xdr, res->count, count);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1036) 	res->count += recvd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1037) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1038) 	if (count > recvd)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1039) 		return 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1040) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1041) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1042) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1043) static int decode_read_plus_hole(struct xdr_stream *xdr, struct nfs_pgio_res *res,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1044) 				 uint32_t *eof)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1045) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1046) 	uint64_t offset, length, recvd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1047) 	__be32 *p;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1048) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1049) 	p = xdr_inline_decode(xdr, 8 + 8);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1050) 	if (!p)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1051) 		return 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1052) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1053) 	p = xdr_decode_hyper(p, &offset);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1054) 	p = xdr_decode_hyper(p, &length);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1055) 	recvd = xdr_expand_hole(xdr, res->count, length);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1056) 	res->count += recvd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1057) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1058) 	if (recvd < length)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1059) 		return 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1060) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1061) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1062) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1063) static int decode_read_plus(struct xdr_stream *xdr, struct nfs_pgio_res *res)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1064) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1065) 	uint32_t eof, segments, type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1066) 	int status, i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1067) 	__be32 *p;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1068) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1069) 	status = decode_op_hdr(xdr, OP_READ_PLUS);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1070) 	if (status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1071) 		return status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1072) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1073) 	p = xdr_inline_decode(xdr, 4 + 4);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1074) 	if (unlikely(!p))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1075) 		return -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1076) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1077) 	eof = be32_to_cpup(p++);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1078) 	segments = be32_to_cpup(p++);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1079) 	if (segments == 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1080) 		goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1081) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1082) 	for (i = 0; i < segments; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1083) 		p = xdr_inline_decode(xdr, 4);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1084) 		if (!p)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1085) 			goto early_out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1086) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1087) 		type = be32_to_cpup(p++);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1088) 		if (type == NFS4_CONTENT_DATA)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1089) 			status = decode_read_plus_data(xdr, res);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1090) 		else if (type == NFS4_CONTENT_HOLE)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1091) 			status = decode_read_plus_hole(xdr, res, &eof);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1092) 		else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1093) 			return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1094) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1095) 		if (status < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1096) 			return status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1097) 		if (status > 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1098) 			goto early_out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1099) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1100) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1101) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1102) 	res->eof = eof;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1103) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1104) early_out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1105) 	if (unlikely(!i))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1106) 		return -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1107) 	res->eof = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1108) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1109) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1110) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1111) static int decode_seek(struct xdr_stream *xdr, struct nfs42_seek_res *res)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1112) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1113) 	int status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1114) 	__be32 *p;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1115) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1116) 	status = decode_op_hdr(xdr, OP_SEEK);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1117) 	if (status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1118) 		return status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1119) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1120) 	p = xdr_inline_decode(xdr, 4 + 8);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1121) 	if (unlikely(!p))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1122) 		return -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1123) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1124) 	res->sr_eof = be32_to_cpup(p++);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1125) 	p = xdr_decode_hyper(p, &res->sr_offset);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1126) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1127) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1128) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1129) static int decode_layoutstats(struct xdr_stream *xdr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1130) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1131) 	return decode_op_hdr(xdr, OP_LAYOUTSTATS);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1132) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1133) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1134) static int decode_clone(struct xdr_stream *xdr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1135) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1136) 	return decode_op_hdr(xdr, OP_CLONE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1137) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1138) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1139) static int decode_layouterror(struct xdr_stream *xdr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1140) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1141) 	return decode_op_hdr(xdr, OP_LAYOUTERROR);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1142) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1143) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1144) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1145)  * Decode ALLOCATE request
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1146)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1147) static int nfs4_xdr_dec_allocate(struct rpc_rqst *rqstp,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1148) 				 struct xdr_stream *xdr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1149) 				 void *data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1150) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1151) 	struct nfs42_falloc_res *res = data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1152) 	struct compound_hdr hdr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1153) 	int status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1154) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1155) 	status = decode_compound_hdr(xdr, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1156) 	if (status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1157) 		goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1158) 	status = decode_sequence(xdr, &res->seq_res, rqstp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1159) 	if (status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1160) 		goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1161) 	status = decode_putfh(xdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1162) 	if (status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1163) 		goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1164) 	status = decode_allocate(xdr, res);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1165) 	if (status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1166) 		goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1167) 	decode_getfattr(xdr, res->falloc_fattr, res->falloc_server);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1168) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1169) 	return status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1170) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1171) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1172) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1173)  * Decode COPY response
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1174)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1175) static int nfs4_xdr_dec_copy(struct rpc_rqst *rqstp,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1176) 			     struct xdr_stream *xdr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1177) 			     void *data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1178) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1179) 	struct nfs42_copy_res *res = data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1180) 	struct compound_hdr hdr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1181) 	int status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1182) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1183) 	status = decode_compound_hdr(xdr, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1184) 	if (status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1185) 		goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1186) 	status = decode_sequence(xdr, &res->seq_res, rqstp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1187) 	if (status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1188) 		goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1189) 	status = decode_putfh(xdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1190) 	if (status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1191) 		goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1192) 	status = decode_savefh(xdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1193) 	if (status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1194) 		goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1195) 	status = decode_putfh(xdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1196) 	if (status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1197) 		goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1198) 	status = decode_copy(xdr, res);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1199) 	if (status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1200) 		goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1201) 	if (res->commit_res.verf)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1202) 		status = decode_commit(xdr, &res->commit_res);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1203) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1204) 	return status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1205) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1206) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1207) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1208)  * Decode OFFLOAD_CANCEL response
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1209)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1210) static int nfs4_xdr_dec_offload_cancel(struct rpc_rqst *rqstp,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1211) 				       struct xdr_stream *xdr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1212) 				       void *data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1213) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1214) 	struct nfs42_offload_status_res *res = data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1215) 	struct compound_hdr hdr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1216) 	int status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1217) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1218) 	status = decode_compound_hdr(xdr, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1219) 	if (status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1220) 		goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1221) 	status = decode_sequence(xdr, &res->osr_seq_res, rqstp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1222) 	if (status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1223) 		goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1224) 	status = decode_putfh(xdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1225) 	if (status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1226) 		goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1227) 	status = decode_offload_cancel(xdr, res);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1228) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1229) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1230) 	return status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1231) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1232) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1233) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1234)  * Decode COPY_NOTIFY response
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1235)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1236) static int nfs4_xdr_dec_copy_notify(struct rpc_rqst *rqstp,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1237) 				    struct xdr_stream *xdr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1238) 				    void *data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1239) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1240) 	struct nfs42_copy_notify_res *res = data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1241) 	struct compound_hdr hdr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1242) 	int status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1243) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1244) 	status = decode_compound_hdr(xdr, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1245) 	if (status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1246) 		goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1247) 	status = decode_sequence(xdr, &res->cnr_seq_res, rqstp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1248) 	if (status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1249) 		goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1250) 	status = decode_putfh(xdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1251) 	if (status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1252) 		goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1253) 	status = decode_copy_notify(xdr, res);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1254) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1255) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1256) 	return status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1257) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1258) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1259) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1260)  * Decode DEALLOCATE request
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1261)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1262) static int nfs4_xdr_dec_deallocate(struct rpc_rqst *rqstp,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1263) 				   struct xdr_stream *xdr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1264) 				   void *data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1265) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1266) 	struct nfs42_falloc_res *res = data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1267) 	struct compound_hdr hdr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1268) 	int status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1269) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1270) 	status = decode_compound_hdr(xdr, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1271) 	if (status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1272) 		goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1273) 	status = decode_sequence(xdr, &res->seq_res, rqstp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1274) 	if (status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1275) 		goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1276) 	status = decode_putfh(xdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1277) 	if (status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1278) 		goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1279) 	status = decode_deallocate(xdr, res);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1280) 	if (status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1281) 		goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1282) 	decode_getfattr(xdr, res->falloc_fattr, res->falloc_server);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1283) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1284) 	return status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1285) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1286) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1287) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1288)  * Decode READ_PLUS request
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1289)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1290) static int nfs4_xdr_dec_read_plus(struct rpc_rqst *rqstp,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1291) 				  struct xdr_stream *xdr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1292) 				  void *data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1293) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1294) 	struct nfs_pgio_res *res = data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1295) 	struct compound_hdr hdr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1296) 	int status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1297) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1298) 	status = decode_compound_hdr(xdr, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1299) 	if (status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1300) 		goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1301) 	status = decode_sequence(xdr, &res->seq_res, rqstp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1302) 	if (status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1303) 		goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1304) 	status = decode_putfh(xdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1305) 	if (status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1306) 		goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1307) 	status = decode_read_plus(xdr, res);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1308) 	if (!status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1309) 		status = res->count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1310) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1311) 	return status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1312) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1313) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1314) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1315)  * Decode SEEK request
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1316)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1317) static int nfs4_xdr_dec_seek(struct rpc_rqst *rqstp,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1318) 			     struct xdr_stream *xdr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1319) 			     void *data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1320) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1321) 	struct nfs42_seek_res *res = data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1322) 	struct compound_hdr hdr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1323) 	int status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1324) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1325) 	status = decode_compound_hdr(xdr, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1326) 	if (status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1327) 		goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1328) 	status = decode_sequence(xdr, &res->seq_res, rqstp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1329) 	if (status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1330) 		goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1331) 	status = decode_putfh(xdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1332) 	if (status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1333) 		goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1334) 	status = decode_seek(xdr, res);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1335) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1336) 	return status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1337) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1338) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1339) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1340)  * Decode LAYOUTSTATS request
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1341)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1342) static int nfs4_xdr_dec_layoutstats(struct rpc_rqst *rqstp,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1343) 				    struct xdr_stream *xdr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1344) 				    void *data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1345) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1346) 	struct nfs42_layoutstat_res *res = data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1347) 	struct compound_hdr hdr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1348) 	int status, i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1349) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1350) 	status = decode_compound_hdr(xdr, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1351) 	if (status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1352) 		goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1353) 	status = decode_sequence(xdr, &res->seq_res, rqstp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1354) 	if (status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1355) 		goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1356) 	status = decode_putfh(xdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1357) 	if (status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1358) 		goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1359) 	WARN_ON(res->num_dev > PNFS_LAYOUTSTATS_MAXDEV);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1360) 	for (i = 0; i < res->num_dev; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1361) 		status = decode_layoutstats(xdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1362) 		if (status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1363) 			goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1364) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1365) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1366) 	res->rpc_status = status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1367) 	return status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1368) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1369) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1370) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1371)  * Decode CLONE request
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1372)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1373) static int nfs4_xdr_dec_clone(struct rpc_rqst *rqstp,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1374) 			      struct xdr_stream *xdr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1375) 			      void *data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1376) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1377) 	struct nfs42_clone_res *res = data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1378) 	struct compound_hdr hdr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1379) 	int status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1380) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1381) 	status = decode_compound_hdr(xdr, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1382) 	if (status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1383) 		goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1384) 	status = decode_sequence(xdr, &res->seq_res, rqstp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1385) 	if (status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1386) 		goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1387) 	status = decode_putfh(xdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1388) 	if (status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1389) 		goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1390) 	status = decode_savefh(xdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1391) 	if (status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1392) 		goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1393) 	status = decode_putfh(xdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1394) 	if (status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1395) 		goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1396) 	status = decode_clone(xdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1397) 	if (status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1398) 		goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1399) 	decode_getfattr(xdr, res->dst_fattr, res->server);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1400) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1401) 	res->rpc_status = status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1402) 	return status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1403) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1404) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1405) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1406)  * Decode LAYOUTERROR request
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1407)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1408) static int nfs4_xdr_dec_layouterror(struct rpc_rqst *rqstp,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1409) 				    struct xdr_stream *xdr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1410) 				    void *data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1411) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1412) 	struct nfs42_layouterror_res *res = data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1413) 	struct compound_hdr hdr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1414) 	int status, i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1415) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1416) 	status = decode_compound_hdr(xdr, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1417) 	if (status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1418) 		goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1419) 	status = decode_sequence(xdr, &res->seq_res, rqstp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1420) 	if (status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1421) 		goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1422) 	status = decode_putfh(xdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1423) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1424) 	for (i = 0; i < res->num_errors && status == 0; i++)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1425) 		status = decode_layouterror(xdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1426) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1427) 	res->rpc_status = status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1428) 	return status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1429) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1430) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1431) #ifdef CONFIG_NFS_V4_2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1432) static void nfs4_xdr_enc_setxattr(struct rpc_rqst *req, struct xdr_stream *xdr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1433) 				  const void *data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1434) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1435) 	const struct nfs42_setxattrargs *args = data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1436) 	struct compound_hdr hdr = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1437) 		.minorversion = nfs4_xdr_minorversion(&args->seq_args),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1438) 	};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1439) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1440) 	encode_compound_hdr(xdr, req, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1441) 	encode_sequence(xdr, &args->seq_args, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1442) 	encode_putfh(xdr, args->fh, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1443) 	encode_setxattr(xdr, args, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1444) 	encode_nops(&hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1445) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1446) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1447) static int nfs4_xdr_dec_setxattr(struct rpc_rqst *req, struct xdr_stream *xdr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1448) 				 void *data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1449) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1450) 	struct nfs42_setxattrres *res = data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1451) 	struct compound_hdr hdr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1452) 	int status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1453) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1454) 	status = decode_compound_hdr(xdr, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1455) 	if (status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1456) 		goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1457) 	status = decode_sequence(xdr, &res->seq_res, req);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1458) 	if (status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1459) 		goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1460) 	status = decode_putfh(xdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1461) 	if (status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1462) 		goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1463) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1464) 	status = decode_setxattr(xdr, &res->cinfo);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1465) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1466) 	return status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1467) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1468) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1469) static void nfs4_xdr_enc_getxattr(struct rpc_rqst *req, struct xdr_stream *xdr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1470) 				  const void *data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1471) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1472) 	const struct nfs42_getxattrargs *args = data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1473) 	struct compound_hdr hdr = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1474) 		.minorversion = nfs4_xdr_minorversion(&args->seq_args),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1475) 	};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1476) 	size_t plen;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1477) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1478) 	encode_compound_hdr(xdr, req, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1479) 	encode_sequence(xdr, &args->seq_args, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1480) 	encode_putfh(xdr, args->fh, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1481) 	encode_getxattr(xdr, args->xattr_name, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1482) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1483) 	plen = args->xattr_len ? args->xattr_len : XATTR_SIZE_MAX;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1484) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1485) 	rpc_prepare_reply_pages(req, args->xattr_pages, 0, plen,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1486) 	    hdr.replen);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1487) 	req->rq_rcv_buf.flags |= XDRBUF_SPARSE_PAGES;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1488) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1489) 	encode_nops(&hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1490) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1491) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1492) static int nfs4_xdr_dec_getxattr(struct rpc_rqst *rqstp,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1493) 				 struct xdr_stream *xdr, void *data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1494) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1495) 	struct nfs42_getxattrres *res = data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1496) 	struct compound_hdr hdr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1497) 	int status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1498) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1499) 	status = decode_compound_hdr(xdr, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1500) 	if (status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1501) 		goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1502) 	status = decode_sequence(xdr, &res->seq_res, rqstp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1503) 	if (status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1504) 		goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1505) 	status = decode_putfh(xdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1506) 	if (status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1507) 		goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1508) 	status = decode_getxattr(xdr, res, rqstp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1509) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1510) 	return status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1511) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1512) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1513) static void nfs4_xdr_enc_listxattrs(struct rpc_rqst *req,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1514) 				    struct xdr_stream *xdr, const void *data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1515) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1516) 	const struct nfs42_listxattrsargs *args = data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1517) 	struct compound_hdr hdr = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1518) 		.minorversion = nfs4_xdr_minorversion(&args->seq_args),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1519) 	};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1520) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1521) 	encode_compound_hdr(xdr, req, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1522) 	encode_sequence(xdr, &args->seq_args, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1523) 	encode_putfh(xdr, args->fh, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1524) 	encode_listxattrs(xdr, args, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1525) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1526) 	rpc_prepare_reply_pages(req, args->xattr_pages, 0, args->count,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1527) 	    hdr.replen);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1528) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1529) 	encode_nops(&hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1530) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1531) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1532) static int nfs4_xdr_dec_listxattrs(struct rpc_rqst *rqstp,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1533) 				   struct xdr_stream *xdr, void *data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1534) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1535) 	struct nfs42_listxattrsres *res = data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1536) 	struct compound_hdr hdr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1537) 	int status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1538) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1539) 	xdr_set_scratch_buffer(xdr, page_address(res->scratch), PAGE_SIZE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1540) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1541) 	status = decode_compound_hdr(xdr, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1542) 	if (status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1543) 		goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1544) 	status = decode_sequence(xdr, &res->seq_res, rqstp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1545) 	if (status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1546) 		goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1547) 	status = decode_putfh(xdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1548) 	if (status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1549) 		goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1550) 	status = decode_listxattrs(xdr, res);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1551) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1552) 	return status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1553) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1554) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1555) static void nfs4_xdr_enc_removexattr(struct rpc_rqst *req,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1556) 				     struct xdr_stream *xdr, const void *data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1557) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1558) 	const struct nfs42_removexattrargs *args = data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1559) 	struct compound_hdr hdr = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1560) 		.minorversion = nfs4_xdr_minorversion(&args->seq_args),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1561) 	};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1562) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1563) 	encode_compound_hdr(xdr, req, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1564) 	encode_sequence(xdr, &args->seq_args, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1565) 	encode_putfh(xdr, args->fh, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1566) 	encode_removexattr(xdr, args->xattr_name, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1567) 	encode_nops(&hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1568) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1569) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1570) static int nfs4_xdr_dec_removexattr(struct rpc_rqst *req,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1571) 				    struct xdr_stream *xdr, void *data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1572) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1573) 	struct nfs42_removexattrres *res = data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1574) 	struct compound_hdr hdr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1575) 	int status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1576) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1577) 	status = decode_compound_hdr(xdr, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1578) 	if (status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1579) 		goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1580) 	status = decode_sequence(xdr, &res->seq_res, req);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1581) 	if (status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1582) 		goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1583) 	status = decode_putfh(xdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1584) 	if (status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1585) 		goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1586) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1587) 	status = decode_removexattr(xdr, &res->cinfo);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1588) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1589) 	return status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1590) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1591) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1592) #endif /* __LINUX_FS_NFS_NFS4_2XDR_H */