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) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300    2)  *  fs/nfs/nfs4xdr.c
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300    3)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300    4)  *  Client-side XDR for NFSv4.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300    5)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300    6)  *  Copyright (c) 2002 The Regents of the University of Michigan.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300    7)  *  All rights reserved.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300    8)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300    9)  *  Kendrick Smith <kmsmith@umich.edu>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   10)  *  Andy Adamson   <andros@umich.edu>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   11)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   12)  *  Redistribution and use in source and binary forms, with or without
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   13)  *  modification, are permitted provided that the following conditions
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   14)  *  are met:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   15)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   16)  *  1. Redistributions of source code must retain the above copyright
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   17)  *     notice, this list of conditions and the following disclaimer.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   18)  *  2. Redistributions in binary form must reproduce the above copyright
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   19)  *     notice, this list of conditions and the following disclaimer in the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   20)  *     documentation and/or other materials provided with the distribution.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   21)  *  3. Neither the name of the University nor the names of its
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   22)  *     contributors may be used to endorse or promote products derived
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   23)  *     from this software without specific prior written permission.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   24)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   25)  *  THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   26)  *  WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   27)  *  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   28)  *  DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   29)  *  FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   30)  *  CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   31)  *  SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   32)  *  BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   33)  *  LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   34)  *  NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   35)  *  SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   36)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   37) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   38) #include <linux/param.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   39) #include <linux/time.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   40) #include <linux/mm.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   41) #include <linux/errno.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   42) #include <linux/string.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   43) #include <linux/in.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   44) #include <linux/pagemap.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   45) #include <linux/proc_fs.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   46) #include <linux/kdev_t.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   47) #include <linux/module.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   48) #include <linux/utsname.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   49) #include <linux/sunrpc/clnt.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   50) #include <linux/sunrpc/msg_prot.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   51) #include <linux/sunrpc/gss_api.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   52) #include <linux/nfs.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   53) #include <linux/nfs4.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   54) #include <linux/nfs_fs.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   55) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   56) #include "nfs4_fs.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   57) #include "nfs4trace.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   58) #include "internal.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   59) #include "nfs4idmap.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   60) #include "nfs4session.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   61) #include "pnfs.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   62) #include "netns.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   63) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   64) #define NFSDBG_FACILITY		NFSDBG_XDR
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   65) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   66) /* Mapping from NFS error code to "errno" error code. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   67) #define errno_NFSERR_IO		EIO
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   68) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   69) struct compound_hdr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   70) static int nfs4_stat_to_errno(int);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   71) static void encode_layoutget(struct xdr_stream *xdr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   72) 			     const struct nfs4_layoutget_args *args,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   73) 			     struct compound_hdr *hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   74) static int decode_layoutget(struct xdr_stream *xdr, struct rpc_rqst *req,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   75) 			     struct nfs4_layoutget_res *res);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   76) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   77) /* NFSv4 COMPOUND tags are only wanted for debugging purposes */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   78) #ifdef DEBUG
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   79) #define NFS4_MAXTAGLEN		20
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   80) #else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   81) #define NFS4_MAXTAGLEN		0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   82) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   83) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   84) /* lock,open owner id:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   85)  * we currently use size 2 (u64) out of (NFS4_OPAQUE_LIMIT  >> 2)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   86)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   87) #define open_owner_id_maxsz	(1 + 2 + 1 + 1 + 2)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   88) #define lock_owner_id_maxsz	(1 + 1 + 4)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   89) #define decode_lockowner_maxsz	(1 + XDR_QUADLEN(IDMAP_NAMESZ))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   90) #define compound_encode_hdr_maxsz	(3 + (NFS4_MAXTAGLEN >> 2))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   91) #define compound_decode_hdr_maxsz	(3 + (NFS4_MAXTAGLEN >> 2))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   92) #define op_encode_hdr_maxsz	(1)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   93) #define op_decode_hdr_maxsz	(2)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   94) #define encode_stateid_maxsz	(XDR_QUADLEN(NFS4_STATEID_SIZE))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   95) #define decode_stateid_maxsz	(XDR_QUADLEN(NFS4_STATEID_SIZE))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   96) #define encode_verifier_maxsz	(XDR_QUADLEN(NFS4_VERIFIER_SIZE))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   97) #define decode_verifier_maxsz	(XDR_QUADLEN(NFS4_VERIFIER_SIZE))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   98) #define encode_putfh_maxsz	(op_encode_hdr_maxsz + 1 + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   99) 				(NFS4_FHSIZE >> 2))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  100) #define decode_putfh_maxsz	(op_decode_hdr_maxsz)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  101) #define encode_putrootfh_maxsz	(op_encode_hdr_maxsz)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  102) #define decode_putrootfh_maxsz	(op_decode_hdr_maxsz)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  103) #define encode_getfh_maxsz      (op_encode_hdr_maxsz)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  104) #define decode_getfh_maxsz      (op_decode_hdr_maxsz + 1 + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  105) 				((3+NFS4_FHSIZE) >> 2))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  106) #define nfs4_fattr_bitmap_maxsz 4
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  107) #define encode_getattr_maxsz    (op_encode_hdr_maxsz + nfs4_fattr_bitmap_maxsz)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  108) #define nfstime4_maxsz		(3)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  109) #define nfs4_name_maxsz		(1 + ((3 + NFS4_MAXNAMLEN) >> 2))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  110) #define nfs4_path_maxsz		(1 + ((3 + NFS4_MAXPATHLEN) >> 2))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  111) #define nfs4_owner_maxsz	(1 + XDR_QUADLEN(IDMAP_NAMESZ))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  112) #define nfs4_group_maxsz	(1 + XDR_QUADLEN(IDMAP_NAMESZ))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  113) #ifdef CONFIG_NFS_V4_SECURITY_LABEL
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  114) /* PI(4 bytes) + LFS(4 bytes) + 1(for null terminator?) + MAXLABELLEN */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  115) #define	nfs4_label_maxsz	(4 + 4 + 1 + XDR_QUADLEN(NFS4_MAXLABELLEN))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  116) #else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  117) #define	nfs4_label_maxsz	0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  118) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  119) /* We support only one layout type per file system */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  120) #define decode_mdsthreshold_maxsz (1 + 1 + nfs4_fattr_bitmap_maxsz + 1 + 8)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  121) /* This is based on getfattr, which uses the most attributes: */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  122) #define nfs4_fattr_value_maxsz	(1 + (1 + 2 + 2 + 4 + 2 + 1 + 1 + 2 + 2 + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  123) 				3*nfstime4_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  124) 				nfs4_owner_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  125) 				nfs4_group_maxsz + nfs4_label_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  126) 				 decode_mdsthreshold_maxsz))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  127) #define nfs4_fattr_maxsz	(nfs4_fattr_bitmap_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  128) 				nfs4_fattr_value_maxsz)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  129) #define decode_getattr_maxsz    (op_decode_hdr_maxsz + nfs4_fattr_maxsz)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  130) #define encode_attrs_maxsz	(nfs4_fattr_bitmap_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  131) 				 1 + 2 + 1 + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  132) 				nfs4_owner_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  133) 				nfs4_group_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  134) 				nfs4_label_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  135) 				1 + nfstime4_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  136) 				1 + nfstime4_maxsz)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  137) #define encode_savefh_maxsz     (op_encode_hdr_maxsz)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  138) #define decode_savefh_maxsz     (op_decode_hdr_maxsz)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  139) #define encode_restorefh_maxsz  (op_encode_hdr_maxsz)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  140) #define decode_restorefh_maxsz  (op_decode_hdr_maxsz)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  141) #define encode_fsinfo_maxsz	(encode_getattr_maxsz)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  142) /* The 5 accounts for the PNFS attributes, and assumes that at most three
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  143)  * layout types will be returned.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  144)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  145) #define decode_fsinfo_maxsz	(op_decode_hdr_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  146) 				 nfs4_fattr_bitmap_maxsz + 4 + 8 + 5)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  147) #define encode_renew_maxsz	(op_encode_hdr_maxsz + 3)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  148) #define decode_renew_maxsz	(op_decode_hdr_maxsz)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  149) #define encode_setclientid_maxsz \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  150) 				(op_encode_hdr_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  151) 				XDR_QUADLEN(NFS4_VERIFIER_SIZE) + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  152) 				/* client name */ \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  153) 				1 + XDR_QUADLEN(NFS4_OPAQUE_LIMIT) + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  154) 				1 /* sc_prog */ + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  155) 				1 + XDR_QUADLEN(RPCBIND_MAXNETIDLEN) + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  156) 				1 + XDR_QUADLEN(RPCBIND_MAXUADDRLEN) + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  157) 				1) /* sc_cb_ident */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  158) #define decode_setclientid_maxsz \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  159) 				(op_decode_hdr_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  160) 				2 /* clientid */ + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  161) 				XDR_QUADLEN(NFS4_VERIFIER_SIZE) + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  162) 				1 + XDR_QUADLEN(RPCBIND_MAXNETIDLEN) + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  163) 				1 + XDR_QUADLEN(RPCBIND_MAXUADDRLEN))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  164) #define encode_setclientid_confirm_maxsz \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  165) 				(op_encode_hdr_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  166) 				3 + (NFS4_VERIFIER_SIZE >> 2))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  167) #define decode_setclientid_confirm_maxsz \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  168) 				(op_decode_hdr_maxsz)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  169) #define encode_lookup_maxsz	(op_encode_hdr_maxsz + nfs4_name_maxsz)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  170) #define decode_lookup_maxsz	(op_decode_hdr_maxsz)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  171) #define encode_lookupp_maxsz	(op_encode_hdr_maxsz)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  172) #define decode_lookupp_maxsz	(op_decode_hdr_maxsz)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  173) #define encode_share_access_maxsz \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  174) 				(2)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  175) #define encode_createmode_maxsz	(1 + encode_attrs_maxsz + encode_verifier_maxsz)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  176) #define encode_opentype_maxsz	(1 + encode_createmode_maxsz)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  177) #define encode_claim_null_maxsz	(1 + nfs4_name_maxsz)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  178) #define encode_open_maxsz	(op_encode_hdr_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  179) 				2 + encode_share_access_maxsz + 2 + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  180) 				open_owner_id_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  181) 				encode_opentype_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  182) 				encode_claim_null_maxsz)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  183) #define decode_space_limit_maxsz	(3)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  184) #define decode_ace_maxsz	(3 + nfs4_owner_maxsz)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  185) #define decode_delegation_maxsz	(1 + decode_stateid_maxsz + 1 + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  186) 				decode_space_limit_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  187) 				decode_ace_maxsz)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  188) #define decode_change_info_maxsz	(5)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  189) #define decode_open_maxsz	(op_decode_hdr_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  190) 				decode_stateid_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  191) 				decode_change_info_maxsz + 1 + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  192) 				nfs4_fattr_bitmap_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  193) 				decode_delegation_maxsz)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  194) #define encode_open_confirm_maxsz \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  195) 				(op_encode_hdr_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  196) 				 encode_stateid_maxsz + 1)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  197) #define decode_open_confirm_maxsz \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  198) 				(op_decode_hdr_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  199) 				 decode_stateid_maxsz)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  200) #define encode_open_downgrade_maxsz \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  201) 				(op_encode_hdr_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  202) 				 encode_stateid_maxsz + 1 + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  203) 				 encode_share_access_maxsz)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  204) #define decode_open_downgrade_maxsz \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  205) 				(op_decode_hdr_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  206) 				 decode_stateid_maxsz)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  207) #define encode_close_maxsz	(op_encode_hdr_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  208) 				 1 + encode_stateid_maxsz)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  209) #define decode_close_maxsz	(op_decode_hdr_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  210) 				 decode_stateid_maxsz)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  211) #define encode_setattr_maxsz	(op_encode_hdr_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  212) 				 encode_stateid_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  213) 				 encode_attrs_maxsz)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  214) #define decode_setattr_maxsz	(op_decode_hdr_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  215) 				 nfs4_fattr_bitmap_maxsz)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  216) #define encode_read_maxsz	(op_encode_hdr_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  217) 				 encode_stateid_maxsz + 3)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  218) #define decode_read_maxsz	(op_decode_hdr_maxsz + 2 + 1)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  219) #define encode_readdir_maxsz	(op_encode_hdr_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  220) 				 2 + encode_verifier_maxsz + 5 + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  221) 				nfs4_label_maxsz)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  222) #define decode_readdir_maxsz	(op_decode_hdr_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  223) 				 decode_verifier_maxsz + 1)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  224) #define encode_readlink_maxsz	(op_encode_hdr_maxsz)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  225) #define decode_readlink_maxsz	(op_decode_hdr_maxsz + 1 + 1)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  226) #define encode_write_maxsz	(op_encode_hdr_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  227) 				 encode_stateid_maxsz + 4)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  228) #define decode_write_maxsz	(op_decode_hdr_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  229) 				 2 + decode_verifier_maxsz)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  230) #define encode_commit_maxsz	(op_encode_hdr_maxsz + 3)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  231) #define decode_commit_maxsz	(op_decode_hdr_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  232) 				 decode_verifier_maxsz)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  233) #define encode_remove_maxsz	(op_encode_hdr_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  234) 				nfs4_name_maxsz)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  235) #define decode_remove_maxsz	(op_decode_hdr_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  236) 				 decode_change_info_maxsz)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  237) #define encode_rename_maxsz	(op_encode_hdr_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  238) 				2 * nfs4_name_maxsz)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  239) #define decode_rename_maxsz	(op_decode_hdr_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  240) 				 decode_change_info_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  241) 				 decode_change_info_maxsz)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  242) #define encode_link_maxsz	(op_encode_hdr_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  243) 				nfs4_name_maxsz)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  244) #define decode_link_maxsz	(op_decode_hdr_maxsz + decode_change_info_maxsz)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  245) #define encode_lockowner_maxsz	(7)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  246) #define encode_lock_maxsz	(op_encode_hdr_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  247) 				 7 + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  248) 				 1 + encode_stateid_maxsz + 1 + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  249) 				 encode_lockowner_maxsz)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  250) #define decode_lock_denied_maxsz \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  251) 				(8 + decode_lockowner_maxsz)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  252) #define decode_lock_maxsz	(op_decode_hdr_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  253) 				 decode_lock_denied_maxsz)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  254) #define encode_lockt_maxsz	(op_encode_hdr_maxsz + 5 + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  255) 				encode_lockowner_maxsz)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  256) #define decode_lockt_maxsz	(op_decode_hdr_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  257) 				 decode_lock_denied_maxsz)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  258) #define encode_locku_maxsz	(op_encode_hdr_maxsz + 3 + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  259) 				 encode_stateid_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  260) 				 4)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  261) #define decode_locku_maxsz	(op_decode_hdr_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  262) 				 decode_stateid_maxsz)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  263) #define encode_release_lockowner_maxsz \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  264) 				(op_encode_hdr_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  265) 				 encode_lockowner_maxsz)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  266) #define decode_release_lockowner_maxsz \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  267) 				(op_decode_hdr_maxsz)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  268) #define encode_access_maxsz	(op_encode_hdr_maxsz + 1)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  269) #define decode_access_maxsz	(op_decode_hdr_maxsz + 2)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  270) #define encode_symlink_maxsz	(op_encode_hdr_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  271) 				1 + nfs4_name_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  272) 				1 + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  273) 				nfs4_fattr_maxsz)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  274) #define decode_symlink_maxsz	(op_decode_hdr_maxsz + 8)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  275) #define encode_create_maxsz	(op_encode_hdr_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  276) 				1 + 2 + nfs4_name_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  277) 				encode_attrs_maxsz)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  278) #define decode_create_maxsz	(op_decode_hdr_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  279) 				decode_change_info_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  280) 				nfs4_fattr_bitmap_maxsz)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  281) #define encode_statfs_maxsz	(encode_getattr_maxsz)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  282) #define decode_statfs_maxsz	(decode_getattr_maxsz)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  283) #define encode_delegreturn_maxsz (op_encode_hdr_maxsz + 4)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  284) #define decode_delegreturn_maxsz (op_decode_hdr_maxsz)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  285) #define encode_getacl_maxsz	(encode_getattr_maxsz)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  286) #define decode_getacl_maxsz	(op_decode_hdr_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  287) 				 nfs4_fattr_bitmap_maxsz + 1 + 1)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  288) #define encode_setacl_maxsz	(op_encode_hdr_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  289) 				 encode_stateid_maxsz + 3)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  290) #define decode_setacl_maxsz	(decode_setattr_maxsz)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  291) #define encode_fs_locations_maxsz \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  292) 				(encode_getattr_maxsz)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  293) #define decode_fs_locations_maxsz \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  294) 				(1)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  295) #define encode_secinfo_maxsz	(op_encode_hdr_maxsz + nfs4_name_maxsz)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  296) #define decode_secinfo_maxsz	(op_decode_hdr_maxsz + 1 + ((NFS_MAX_SECFLAVORS * (16 + GSS_OID_MAX_LEN)) / 4))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  297) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  298) #if defined(CONFIG_NFS_V4_1)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  299) #define NFS4_MAX_MACHINE_NAME_LEN (64)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  300) #define IMPL_NAME_LIMIT (sizeof(utsname()->sysname) + sizeof(utsname()->release) + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  301) 			 sizeof(utsname()->version) + sizeof(utsname()->machine) + 8)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  302) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  303) #define encode_exchange_id_maxsz (op_encode_hdr_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  304) 				encode_verifier_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  305) 				1 /* co_ownerid.len */ + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  306) 				/* eia_clientowner */ \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  307) 				1 + XDR_QUADLEN(NFS4_OPAQUE_LIMIT) + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  308) 				1 /* flags */ + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  309) 				1 /* spa_how */ + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  310) 				/* max is SP4_MACH_CRED (for now) */ + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  311) 				1 + NFS4_OP_MAP_NUM_WORDS + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  312) 				1 + NFS4_OP_MAP_NUM_WORDS + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  313) 				1 /* implementation id array of size 1 */ + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  314) 				1 /* nii_domain */ + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  315) 				XDR_QUADLEN(NFS4_OPAQUE_LIMIT) + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  316) 				1 /* nii_name */ + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  317) 				XDR_QUADLEN(IMPL_NAME_LIMIT) + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  318) 				3 /* nii_date */)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  319) #define decode_exchange_id_maxsz (op_decode_hdr_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  320) 				2 /* eir_clientid */ + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  321) 				1 /* eir_sequenceid */ + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  322) 				1 /* eir_flags */ + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  323) 				1 /* spr_how */ + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  324) 				  /* max is SP4_MACH_CRED (for now) */ + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  325) 				1 + NFS4_OP_MAP_NUM_WORDS + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  326) 				1 + NFS4_OP_MAP_NUM_WORDS + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  327) 				2 /* eir_server_owner.so_minor_id */ + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  328) 				/* eir_server_owner.so_major_id<> */ \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  329) 				XDR_QUADLEN(NFS4_OPAQUE_LIMIT) + 1 + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  330) 				/* eir_server_scope<> */ \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  331) 				XDR_QUADLEN(NFS4_OPAQUE_LIMIT) + 1 + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  332) 				1 /* eir_server_impl_id array length */ + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  333) 				1 /* nii_domain */ + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  334) 				XDR_QUADLEN(NFS4_OPAQUE_LIMIT) + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  335) 				1 /* nii_name */ + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  336) 				XDR_QUADLEN(NFS4_OPAQUE_LIMIT) + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  337) 				3 /* nii_date */)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  338) #define encode_channel_attrs_maxsz  (6 + 1 /* ca_rdma_ird.len (0) */)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  339) #define decode_channel_attrs_maxsz  (6 + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  340) 				     1 /* ca_rdma_ird.len */ + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  341) 				     1 /* ca_rdma_ird */)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  342) #define encode_create_session_maxsz  (op_encode_hdr_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  343) 				     2 /* csa_clientid */ + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  344) 				     1 /* csa_sequence */ + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  345) 				     1 /* csa_flags */ + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  346) 				     encode_channel_attrs_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  347) 				     encode_channel_attrs_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  348) 				     1 /* csa_cb_program */ + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  349) 				     1 /* csa_sec_parms.len (1) */ + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  350) 				     1 /* cb_secflavor (AUTH_SYS) */ + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  351) 				     1 /* stamp */ + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  352) 				     1 /* machinename.len */ + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  353) 				     XDR_QUADLEN(NFS4_MAX_MACHINE_NAME_LEN) + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  354) 				     1 /* uid */ + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  355) 				     1 /* gid */ + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  356) 				     1 /* gids.len (0) */)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  357) #define decode_create_session_maxsz  (op_decode_hdr_maxsz +	\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  358) 				     XDR_QUADLEN(NFS4_MAX_SESSIONID_LEN) + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  359) 				     1 /* csr_sequence */ + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  360) 				     1 /* csr_flags */ + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  361) 				     decode_channel_attrs_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  362) 				     decode_channel_attrs_maxsz)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  363) #define encode_bind_conn_to_session_maxsz  (op_encode_hdr_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  364) 				     /* bctsa_sessid */ \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  365) 				     XDR_QUADLEN(NFS4_MAX_SESSIONID_LEN) + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  366) 				     1 /* bctsa_dir */ + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  367) 				     1 /* bctsa_use_conn_in_rdma_mode */)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  368) #define decode_bind_conn_to_session_maxsz  (op_decode_hdr_maxsz +	\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  369) 				     /* bctsr_sessid */ \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  370) 				     XDR_QUADLEN(NFS4_MAX_SESSIONID_LEN) + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  371) 				     1 /* bctsr_dir */ + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  372) 				     1 /* bctsr_use_conn_in_rdma_mode */)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  373) #define encode_destroy_session_maxsz    (op_encode_hdr_maxsz + 4)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  374) #define decode_destroy_session_maxsz    (op_decode_hdr_maxsz)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  375) #define encode_destroy_clientid_maxsz   (op_encode_hdr_maxsz + 2)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  376) #define decode_destroy_clientid_maxsz   (op_decode_hdr_maxsz)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  377) #define encode_sequence_maxsz	(op_encode_hdr_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  378) 				XDR_QUADLEN(NFS4_MAX_SESSIONID_LEN) + 4)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  379) #define decode_sequence_maxsz	(op_decode_hdr_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  380) 				XDR_QUADLEN(NFS4_MAX_SESSIONID_LEN) + 5)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  381) #define encode_reclaim_complete_maxsz	(op_encode_hdr_maxsz + 4)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  382) #define decode_reclaim_complete_maxsz	(op_decode_hdr_maxsz + 4)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  383) #define encode_getdeviceinfo_maxsz (op_encode_hdr_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  384) 				XDR_QUADLEN(NFS4_DEVICEID4_SIZE) + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  385) 				1 /* layout type */ + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  386) 				1 /* maxcount */ + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  387) 				1 /* bitmap size */ + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  388) 				1 /* notification bitmap length */ + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  389) 				1 /* notification bitmap, word 0 */)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  390) #define decode_getdeviceinfo_maxsz (op_decode_hdr_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  391) 				1 /* layout type */ + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  392) 				1 /* opaque devaddr4 length */ + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  393) 				  /* devaddr4 payload is read into page */ \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  394) 				1 /* notification bitmap length */ + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  395) 				1 /* notification bitmap, word 0 */ + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  396) 				1 /* possible XDR padding */)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  397) #define encode_layoutget_maxsz	(op_encode_hdr_maxsz + 10 + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  398) 				encode_stateid_maxsz)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  399) #define decode_layoutget_maxsz	(op_decode_hdr_maxsz + 8 + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  400) 				decode_stateid_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  401) 				XDR_QUADLEN(PNFS_LAYOUT_MAXSIZE) + 1)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  402) #define encode_layoutcommit_maxsz (op_encode_hdr_maxsz +          \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  403) 				2 /* offset */ + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  404) 				2 /* length */ + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  405) 				1 /* reclaim */ + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  406) 				encode_stateid_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  407) 				1 /* new offset (true) */ + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  408) 				2 /* last byte written */ + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  409) 				1 /* nt_timechanged (false) */ + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  410) 				1 /* layoutupdate4 layout type */ + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  411) 				1 /* layoutupdate4 opaqueue len */)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  412) 				  /* the actual content of layoutupdate4 should
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  413) 				     be allocated by drivers and spliced in
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  414) 				     using xdr_write_pages */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  415) #define decode_layoutcommit_maxsz (op_decode_hdr_maxsz + 3)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  416) #define encode_layoutreturn_maxsz (8 + op_encode_hdr_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  417) 				encode_stateid_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  418) 				1 + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  419) 				XDR_QUADLEN(NFS4_OPAQUE_LIMIT))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  420) #define decode_layoutreturn_maxsz (op_decode_hdr_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  421) 				1 + decode_stateid_maxsz)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  422) #define encode_secinfo_no_name_maxsz (op_encode_hdr_maxsz + 1)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  423) #define decode_secinfo_no_name_maxsz decode_secinfo_maxsz
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  424) #define encode_test_stateid_maxsz	(op_encode_hdr_maxsz + 2 + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  425) 					 XDR_QUADLEN(NFS4_STATEID_SIZE))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  426) #define decode_test_stateid_maxsz	(op_decode_hdr_maxsz + 2 + 1)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  427) #define encode_free_stateid_maxsz	(op_encode_hdr_maxsz + 1 + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  428) 					 XDR_QUADLEN(NFS4_STATEID_SIZE))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  429) #define decode_free_stateid_maxsz	(op_decode_hdr_maxsz)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  430) #else /* CONFIG_NFS_V4_1 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  431) #define encode_sequence_maxsz	0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  432) #define decode_sequence_maxsz	0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  433) #define encode_layoutreturn_maxsz 0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  434) #define decode_layoutreturn_maxsz 0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  435) #define encode_layoutget_maxsz	0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  436) #define decode_layoutget_maxsz	0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  437) #endif /* CONFIG_NFS_V4_1 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  438) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  439) #define NFS4_enc_compound_sz	(1024)  /* XXX: large enough? */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  440) #define NFS4_dec_compound_sz	(1024)  /* XXX: large enough? */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  441) #define NFS4_enc_read_sz	(compound_encode_hdr_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  442) 				encode_sequence_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  443) 				encode_putfh_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  444) 				encode_read_maxsz)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  445) #define NFS4_dec_read_sz	(compound_decode_hdr_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  446) 				decode_sequence_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  447) 				decode_putfh_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  448) 				decode_read_maxsz)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  449) #define NFS4_enc_readlink_sz	(compound_encode_hdr_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  450) 				encode_sequence_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  451) 				encode_putfh_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  452) 				encode_readlink_maxsz)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  453) #define NFS4_dec_readlink_sz	(compound_decode_hdr_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  454) 				decode_sequence_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  455) 				decode_putfh_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  456) 				decode_readlink_maxsz)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  457) #define NFS4_enc_readdir_sz	(compound_encode_hdr_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  458) 				encode_sequence_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  459) 				encode_putfh_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  460) 				encode_readdir_maxsz)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  461) #define NFS4_dec_readdir_sz	(compound_decode_hdr_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  462) 				decode_sequence_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  463) 				decode_putfh_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  464) 				decode_readdir_maxsz)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  465) #define NFS4_enc_write_sz	(compound_encode_hdr_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  466) 				encode_sequence_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  467) 				encode_putfh_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  468) 				encode_write_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  469) 				encode_getattr_maxsz)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  470) #define NFS4_dec_write_sz	(compound_decode_hdr_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  471) 				decode_sequence_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  472) 				decode_putfh_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  473) 				decode_write_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  474) 				decode_getattr_maxsz)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  475) #define NFS4_enc_commit_sz	(compound_encode_hdr_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  476) 				encode_sequence_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  477) 				encode_putfh_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  478) 				encode_commit_maxsz)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  479) #define NFS4_dec_commit_sz	(compound_decode_hdr_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  480) 				decode_sequence_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  481) 				decode_putfh_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  482) 				decode_commit_maxsz)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  483) #define NFS4_enc_open_sz        (compound_encode_hdr_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  484) 				encode_sequence_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  485) 				encode_putfh_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  486) 				encode_open_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  487) 				encode_access_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  488) 				encode_getfh_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  489) 				encode_getattr_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  490) 				encode_layoutget_maxsz)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  491) #define NFS4_dec_open_sz        (compound_decode_hdr_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  492) 				decode_sequence_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  493) 				decode_putfh_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  494) 				decode_open_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  495) 				decode_access_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  496) 				decode_getfh_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  497) 				decode_getattr_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  498) 				decode_layoutget_maxsz)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  499) #define NFS4_enc_open_confirm_sz \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  500) 				(compound_encode_hdr_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  501) 				 encode_putfh_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  502) 				 encode_open_confirm_maxsz)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  503) #define NFS4_dec_open_confirm_sz \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  504) 				(compound_decode_hdr_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  505) 				 decode_putfh_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  506) 				 decode_open_confirm_maxsz)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  507) #define NFS4_enc_open_noattr_sz	(compound_encode_hdr_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  508) 					encode_sequence_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  509) 					encode_putfh_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  510) 					encode_open_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  511) 					encode_access_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  512) 					encode_getattr_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  513) 					encode_layoutget_maxsz)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  514) #define NFS4_dec_open_noattr_sz	(compound_decode_hdr_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  515) 					decode_sequence_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  516) 					decode_putfh_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  517) 					decode_open_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  518) 					decode_access_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  519) 					decode_getattr_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  520) 					decode_layoutget_maxsz)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  521) #define NFS4_enc_open_downgrade_sz \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  522) 				(compound_encode_hdr_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  523) 				 encode_sequence_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  524) 				 encode_putfh_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  525) 				 encode_layoutreturn_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  526) 				 encode_open_downgrade_maxsz)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  527) #define NFS4_dec_open_downgrade_sz \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  528) 				(compound_decode_hdr_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  529) 				 decode_sequence_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  530) 				 decode_putfh_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  531) 				 decode_layoutreturn_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  532) 				 decode_open_downgrade_maxsz)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  533) #define NFS4_enc_close_sz	(compound_encode_hdr_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  534) 				 encode_sequence_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  535) 				 encode_putfh_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  536) 				 encode_layoutreturn_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  537) 				 encode_close_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  538) 				 encode_getattr_maxsz)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  539) #define NFS4_dec_close_sz	(compound_decode_hdr_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  540) 				 decode_sequence_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  541) 				 decode_putfh_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  542) 				 decode_layoutreturn_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  543) 				 decode_close_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  544) 				 decode_getattr_maxsz)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  545) #define NFS4_enc_setattr_sz	(compound_encode_hdr_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  546) 				 encode_sequence_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  547) 				 encode_putfh_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  548) 				 encode_setattr_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  549) 				 encode_getattr_maxsz)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  550) #define NFS4_dec_setattr_sz	(compound_decode_hdr_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  551) 				 decode_sequence_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  552) 				 decode_putfh_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  553) 				 decode_setattr_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  554) 				 decode_getattr_maxsz)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  555) #define NFS4_enc_fsinfo_sz	(compound_encode_hdr_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  556) 				encode_sequence_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  557) 				encode_putfh_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  558) 				encode_fsinfo_maxsz)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  559) #define NFS4_dec_fsinfo_sz	(compound_decode_hdr_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  560) 				decode_sequence_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  561) 				decode_putfh_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  562) 				decode_fsinfo_maxsz)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  563) #define NFS4_enc_renew_sz	(compound_encode_hdr_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  564) 				encode_renew_maxsz)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  565) #define NFS4_dec_renew_sz	(compound_decode_hdr_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  566) 				decode_renew_maxsz)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  567) #define NFS4_enc_setclientid_sz	(compound_encode_hdr_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  568) 				encode_setclientid_maxsz)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  569) #define NFS4_dec_setclientid_sz	(compound_decode_hdr_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  570) 				decode_setclientid_maxsz)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  571) #define NFS4_enc_setclientid_confirm_sz \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  572) 				(compound_encode_hdr_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  573) 				encode_setclientid_confirm_maxsz)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  574) #define NFS4_dec_setclientid_confirm_sz \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  575) 				(compound_decode_hdr_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  576) 				decode_setclientid_confirm_maxsz)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  577) #define NFS4_enc_lock_sz        (compound_encode_hdr_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  578) 				encode_sequence_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  579) 				encode_putfh_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  580) 				encode_lock_maxsz)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  581) #define NFS4_dec_lock_sz        (compound_decode_hdr_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  582) 				decode_sequence_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  583) 				decode_putfh_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  584) 				decode_lock_maxsz)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  585) #define NFS4_enc_lockt_sz       (compound_encode_hdr_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  586) 				encode_sequence_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  587) 				encode_putfh_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  588) 				encode_lockt_maxsz)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  589) #define NFS4_dec_lockt_sz       (compound_decode_hdr_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  590) 				 decode_sequence_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  591) 				 decode_putfh_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  592) 				 decode_lockt_maxsz)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  593) #define NFS4_enc_locku_sz       (compound_encode_hdr_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  594) 				encode_sequence_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  595) 				encode_putfh_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  596) 				encode_locku_maxsz)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  597) #define NFS4_dec_locku_sz       (compound_decode_hdr_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  598) 				decode_sequence_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  599) 				decode_putfh_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  600) 				decode_locku_maxsz)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  601) #define NFS4_enc_release_lockowner_sz \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  602) 				(compound_encode_hdr_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  603) 				 encode_lockowner_maxsz)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  604) #define NFS4_dec_release_lockowner_sz \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  605) 				(compound_decode_hdr_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  606) 				 decode_lockowner_maxsz)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  607) #define NFS4_enc_access_sz	(compound_encode_hdr_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  608) 				encode_sequence_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  609) 				encode_putfh_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  610) 				encode_access_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  611) 				encode_getattr_maxsz)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  612) #define NFS4_dec_access_sz	(compound_decode_hdr_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  613) 				decode_sequence_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  614) 				decode_putfh_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  615) 				decode_access_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  616) 				decode_getattr_maxsz)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  617) #define NFS4_enc_getattr_sz	(compound_encode_hdr_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  618) 				encode_sequence_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  619) 				encode_putfh_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  620) 				encode_getattr_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  621) 				encode_renew_maxsz)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  622) #define NFS4_dec_getattr_sz	(compound_decode_hdr_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  623) 				decode_sequence_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  624) 				decode_putfh_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  625) 				decode_getattr_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  626) 				decode_renew_maxsz)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  627) #define NFS4_enc_lookup_sz	(compound_encode_hdr_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  628) 				encode_sequence_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  629) 				encode_putfh_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  630) 				encode_lookup_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  631) 				encode_getattr_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  632) 				encode_getfh_maxsz)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  633) #define NFS4_dec_lookup_sz	(compound_decode_hdr_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  634) 				decode_sequence_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  635) 				decode_putfh_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  636) 				decode_lookup_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  637) 				decode_getattr_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  638) 				decode_getfh_maxsz)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  639) #define NFS4_enc_lookupp_sz	(compound_encode_hdr_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  640) 				encode_sequence_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  641) 				encode_putfh_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  642) 				encode_lookupp_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  643) 				encode_getattr_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  644) 				encode_getfh_maxsz)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  645) #define NFS4_dec_lookupp_sz	(compound_decode_hdr_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  646) 				decode_sequence_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  647) 				decode_putfh_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  648) 				decode_lookupp_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  649) 				decode_getattr_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  650) 				decode_getfh_maxsz)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  651) #define NFS4_enc_lookup_root_sz (compound_encode_hdr_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  652) 				encode_sequence_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  653) 				encode_putrootfh_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  654) 				encode_getattr_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  655) 				encode_getfh_maxsz)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  656) #define NFS4_dec_lookup_root_sz (compound_decode_hdr_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  657) 				decode_sequence_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  658) 				decode_putrootfh_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  659) 				decode_getattr_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  660) 				decode_getfh_maxsz)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  661) #define NFS4_enc_remove_sz	(compound_encode_hdr_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  662) 				encode_sequence_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  663) 				encode_putfh_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  664) 				encode_remove_maxsz)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  665) #define NFS4_dec_remove_sz	(compound_decode_hdr_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  666) 				decode_sequence_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  667) 				decode_putfh_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  668) 				decode_remove_maxsz)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  669) #define NFS4_enc_rename_sz	(compound_encode_hdr_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  670) 				encode_sequence_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  671) 				encode_putfh_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  672) 				encode_savefh_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  673) 				encode_putfh_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  674) 				encode_rename_maxsz)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  675) #define NFS4_dec_rename_sz	(compound_decode_hdr_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  676) 				decode_sequence_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  677) 				decode_putfh_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  678) 				decode_savefh_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  679) 				decode_putfh_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  680) 				decode_rename_maxsz)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  681) #define NFS4_enc_link_sz	(compound_encode_hdr_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  682) 				encode_sequence_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  683) 				encode_putfh_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  684) 				encode_savefh_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  685) 				encode_putfh_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  686) 				encode_link_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  687) 				encode_restorefh_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  688) 				encode_getattr_maxsz)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  689) #define NFS4_dec_link_sz	(compound_decode_hdr_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  690) 				decode_sequence_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  691) 				decode_putfh_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  692) 				decode_savefh_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  693) 				decode_putfh_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  694) 				decode_link_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  695) 				decode_restorefh_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  696) 				decode_getattr_maxsz)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  697) #define NFS4_enc_symlink_sz	(compound_encode_hdr_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  698) 				encode_sequence_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  699) 				encode_putfh_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  700) 				encode_symlink_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  701) 				encode_getattr_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  702) 				encode_getfh_maxsz)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  703) #define NFS4_dec_symlink_sz	(compound_decode_hdr_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  704) 				decode_sequence_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  705) 				decode_putfh_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  706) 				decode_symlink_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  707) 				decode_getattr_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  708) 				decode_getfh_maxsz)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  709) #define NFS4_enc_create_sz	(compound_encode_hdr_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  710) 				encode_sequence_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  711) 				encode_putfh_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  712) 				encode_create_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  713) 				encode_getfh_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  714) 				encode_getattr_maxsz)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  715) #define NFS4_dec_create_sz	(compound_decode_hdr_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  716) 				decode_sequence_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  717) 				decode_putfh_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  718) 				decode_create_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  719) 				decode_getfh_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  720) 				decode_getattr_maxsz)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  721) #define NFS4_enc_pathconf_sz	(compound_encode_hdr_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  722) 				encode_sequence_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  723) 				encode_putfh_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  724) 				encode_getattr_maxsz)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  725) #define NFS4_dec_pathconf_sz	(compound_decode_hdr_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  726) 				decode_sequence_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  727) 				decode_putfh_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  728) 				decode_getattr_maxsz)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  729) #define NFS4_enc_statfs_sz	(compound_encode_hdr_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  730) 				encode_sequence_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  731) 				encode_putfh_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  732) 				encode_statfs_maxsz)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  733) #define NFS4_dec_statfs_sz	(compound_decode_hdr_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  734) 				decode_sequence_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  735) 				decode_putfh_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  736) 				decode_statfs_maxsz)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  737) #define NFS4_enc_server_caps_sz (compound_encode_hdr_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  738) 				encode_sequence_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  739) 				encode_putfh_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  740) 				encode_getattr_maxsz)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  741) #define NFS4_dec_server_caps_sz (compound_decode_hdr_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  742) 				decode_sequence_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  743) 				decode_putfh_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  744) 				decode_getattr_maxsz)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  745) #define NFS4_enc_delegreturn_sz	(compound_encode_hdr_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  746) 				encode_sequence_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  747) 				encode_putfh_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  748) 				encode_layoutreturn_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  749) 				encode_delegreturn_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  750) 				encode_getattr_maxsz)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  751) #define NFS4_dec_delegreturn_sz (compound_decode_hdr_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  752) 				decode_sequence_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  753) 				decode_putfh_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  754) 				decode_layoutreturn_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  755) 				decode_delegreturn_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  756) 				decode_getattr_maxsz)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  757) #define NFS4_enc_getacl_sz	(compound_encode_hdr_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  758) 				encode_sequence_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  759) 				encode_putfh_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  760) 				encode_getacl_maxsz)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  761) #define NFS4_dec_getacl_sz	(compound_decode_hdr_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  762) 				decode_sequence_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  763) 				decode_putfh_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  764) 				decode_getacl_maxsz)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  765) #define NFS4_enc_setacl_sz	(compound_encode_hdr_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  766) 				encode_sequence_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  767) 				encode_putfh_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  768) 				encode_setacl_maxsz)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  769) #define NFS4_dec_setacl_sz	(compound_decode_hdr_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  770) 				decode_sequence_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  771) 				decode_putfh_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  772) 				decode_setacl_maxsz)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  773) #define NFS4_enc_fs_locations_sz \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  774) 				(compound_encode_hdr_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  775) 				 encode_sequence_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  776) 				 encode_putfh_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  777) 				 encode_lookup_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  778) 				 encode_fs_locations_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  779) 				 encode_renew_maxsz)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  780) #define NFS4_dec_fs_locations_sz \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  781) 				(compound_decode_hdr_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  782) 				 decode_sequence_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  783) 				 decode_putfh_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  784) 				 decode_lookup_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  785) 				 decode_fs_locations_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  786) 				 decode_renew_maxsz)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  787) #define NFS4_enc_secinfo_sz 	(compound_encode_hdr_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  788) 				encode_sequence_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  789) 				encode_putfh_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  790) 				encode_secinfo_maxsz)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  791) #define NFS4_dec_secinfo_sz	(compound_decode_hdr_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  792) 				decode_sequence_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  793) 				decode_putfh_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  794) 				decode_secinfo_maxsz)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  795) #define NFS4_enc_fsid_present_sz \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  796) 				(compound_encode_hdr_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  797) 				 encode_sequence_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  798) 				 encode_putfh_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  799) 				 encode_getfh_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  800) 				 encode_renew_maxsz)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  801) #define NFS4_dec_fsid_present_sz \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  802) 				(compound_decode_hdr_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  803) 				 decode_sequence_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  804) 				 decode_putfh_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  805) 				 decode_getfh_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  806) 				 decode_renew_maxsz)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  807) #if defined(CONFIG_NFS_V4_1)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  808) #define NFS4_enc_bind_conn_to_session_sz \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  809) 				(compound_encode_hdr_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  810) 				 encode_bind_conn_to_session_maxsz)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  811) #define NFS4_dec_bind_conn_to_session_sz \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  812) 				(compound_decode_hdr_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  813) 				 decode_bind_conn_to_session_maxsz)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  814) #define NFS4_enc_exchange_id_sz \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  815) 				(compound_encode_hdr_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  816) 				 encode_exchange_id_maxsz)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  817) #define NFS4_dec_exchange_id_sz \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  818) 				(compound_decode_hdr_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  819) 				 decode_exchange_id_maxsz)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  820) #define NFS4_enc_create_session_sz \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  821) 				(compound_encode_hdr_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  822) 				 encode_create_session_maxsz)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  823) #define NFS4_dec_create_session_sz \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  824) 				(compound_decode_hdr_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  825) 				 decode_create_session_maxsz)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  826) #define NFS4_enc_destroy_session_sz	(compound_encode_hdr_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  827) 					 encode_destroy_session_maxsz)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  828) #define NFS4_dec_destroy_session_sz	(compound_decode_hdr_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  829) 					 decode_destroy_session_maxsz)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  830) #define NFS4_enc_destroy_clientid_sz	(compound_encode_hdr_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  831) 					 encode_destroy_clientid_maxsz)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  832) #define NFS4_dec_destroy_clientid_sz	(compound_decode_hdr_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  833) 					 decode_destroy_clientid_maxsz)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  834) #define NFS4_enc_sequence_sz \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  835) 				(compound_decode_hdr_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  836) 				 encode_sequence_maxsz)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  837) #define NFS4_dec_sequence_sz \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  838) 				(compound_decode_hdr_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  839) 				 decode_sequence_maxsz)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  840) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  841) #define NFS4_enc_get_lease_time_sz	(compound_encode_hdr_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  842) 					 encode_sequence_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  843) 					 encode_putrootfh_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  844) 					 encode_fsinfo_maxsz)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  845) #define NFS4_dec_get_lease_time_sz	(compound_decode_hdr_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  846) 					 decode_sequence_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  847) 					 decode_putrootfh_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  848) 					 decode_fsinfo_maxsz)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  849) #if defined(CONFIG_NFS_V4_1)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  850) #define NFS4_enc_reclaim_complete_sz	(compound_encode_hdr_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  851) 					 encode_sequence_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  852) 					 encode_reclaim_complete_maxsz)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  853) #define NFS4_dec_reclaim_complete_sz	(compound_decode_hdr_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  854) 					 decode_sequence_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  855) 					 decode_reclaim_complete_maxsz)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  856) #define NFS4_enc_getdeviceinfo_sz (compound_encode_hdr_maxsz +    \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  857) 				encode_sequence_maxsz +\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  858) 				encode_getdeviceinfo_maxsz)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  859) #define NFS4_dec_getdeviceinfo_sz (compound_decode_hdr_maxsz +    \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  860) 				decode_sequence_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  861) 				decode_getdeviceinfo_maxsz)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  862) #define NFS4_enc_layoutget_sz	(compound_encode_hdr_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  863) 				encode_sequence_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  864) 				encode_putfh_maxsz +        \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  865) 				encode_layoutget_maxsz)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  866) #define NFS4_dec_layoutget_sz	(compound_decode_hdr_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  867) 				decode_sequence_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  868) 				decode_putfh_maxsz +        \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  869) 				decode_layoutget_maxsz)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  870) #define NFS4_enc_layoutcommit_sz (compound_encode_hdr_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  871) 				encode_sequence_maxsz +\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  872) 				encode_putfh_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  873) 				encode_layoutcommit_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  874) 				encode_getattr_maxsz)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  875) #define NFS4_dec_layoutcommit_sz (compound_decode_hdr_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  876) 				decode_sequence_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  877) 				decode_putfh_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  878) 				decode_layoutcommit_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  879) 				decode_getattr_maxsz)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  880) #define NFS4_enc_layoutreturn_sz (compound_encode_hdr_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  881) 				encode_sequence_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  882) 				encode_putfh_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  883) 				encode_layoutreturn_maxsz)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  884) #define NFS4_dec_layoutreturn_sz (compound_decode_hdr_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  885) 				decode_sequence_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  886) 				decode_putfh_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  887) 				decode_layoutreturn_maxsz)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  888) #define NFS4_enc_secinfo_no_name_sz	(compound_encode_hdr_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  889) 					encode_sequence_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  890) 					encode_putrootfh_maxsz +\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  891) 					encode_secinfo_no_name_maxsz)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  892) #define NFS4_dec_secinfo_no_name_sz	(compound_decode_hdr_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  893) 					decode_sequence_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  894) 					decode_putrootfh_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  895) 					decode_secinfo_no_name_maxsz)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  896) #define NFS4_enc_test_stateid_sz	(compound_encode_hdr_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  897) 					 encode_sequence_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  898) 					 encode_test_stateid_maxsz)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  899) #define NFS4_dec_test_stateid_sz	(compound_decode_hdr_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  900) 					 decode_sequence_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  901) 					 decode_test_stateid_maxsz)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  902) #define NFS4_enc_free_stateid_sz	(compound_encode_hdr_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  903) 					 encode_sequence_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  904) 					 encode_free_stateid_maxsz)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  905) #define NFS4_dec_free_stateid_sz	(compound_decode_hdr_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  906) 					 decode_sequence_maxsz + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  907) 					 decode_free_stateid_maxsz)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  908) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  909) const u32 nfs41_maxwrite_overhead = ((RPC_MAX_HEADER_WITH_AUTH +
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  910) 				      compound_encode_hdr_maxsz +
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  911) 				      encode_sequence_maxsz +
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  912) 				      encode_putfh_maxsz +
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  913) 				      encode_getattr_maxsz) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  914) 				     XDR_UNIT);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  915) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  916) const u32 nfs41_maxread_overhead = ((RPC_MAX_HEADER_WITH_AUTH +
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  917) 				     compound_decode_hdr_maxsz +
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  918) 				     decode_sequence_maxsz +
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  919) 				     decode_putfh_maxsz) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  920) 				    XDR_UNIT);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  921) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  922) const u32 nfs41_maxgetdevinfo_overhead = ((RPC_MAX_REPHEADER_WITH_AUTH +
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  923) 					   compound_decode_hdr_maxsz +
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  924) 					   decode_sequence_maxsz) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  925) 					  XDR_UNIT);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  926) EXPORT_SYMBOL_GPL(nfs41_maxgetdevinfo_overhead);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  927) #endif /* CONFIG_NFS_V4_1 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  928) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  929) static const umode_t nfs_type2fmt[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  930) 	[NF4BAD] = 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  931) 	[NF4REG] = S_IFREG,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  932) 	[NF4DIR] = S_IFDIR,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  933) 	[NF4BLK] = S_IFBLK,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  934) 	[NF4CHR] = S_IFCHR,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  935) 	[NF4LNK] = S_IFLNK,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  936) 	[NF4SOCK] = S_IFSOCK,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  937) 	[NF4FIFO] = S_IFIFO,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  938) 	[NF4ATTRDIR] = 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  939) 	[NF4NAMEDATTR] = 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) struct compound_hdr {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  943) 	int32_t		status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  944) 	uint32_t	nops;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  945) 	__be32 *	nops_p;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  946) 	uint32_t	taglen;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  947) 	char *		tag;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  948) 	uint32_t	replen;		/* expected reply words */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  949) 	u32		minorversion;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  950) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  951) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  952) static __be32 *reserve_space(struct xdr_stream *xdr, size_t nbytes)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  953) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  954) 	__be32 *p = xdr_reserve_space(xdr, nbytes);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  955) 	BUG_ON(!p);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  956) 	return p;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  957) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  958) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  959) static void encode_opaque_fixed(struct xdr_stream *xdr, const void *buf, size_t len)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  960) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  961) 	WARN_ON_ONCE(xdr_stream_encode_opaque_fixed(xdr, buf, len) < 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  962) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  963) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  964) static void encode_string(struct xdr_stream *xdr, unsigned int len, const char *str)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  965) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  966) 	WARN_ON_ONCE(xdr_stream_encode_opaque(xdr, str, len) < 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  967) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  968) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  969) static void encode_uint32(struct xdr_stream *xdr, u32 n)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  970) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  971) 	WARN_ON_ONCE(xdr_stream_encode_u32(xdr, n) < 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  972) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  973) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  974) static void encode_uint64(struct xdr_stream *xdr, u64 n)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  975) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  976) 	WARN_ON_ONCE(xdr_stream_encode_u64(xdr, n) < 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  977) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  978) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  979) static ssize_t xdr_encode_bitmap4(struct xdr_stream *xdr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  980) 		const __u32 *bitmap, size_t len)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  981) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  982) 	ssize_t ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  983) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  984) 	/* Trim empty words */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  985) 	while (len > 0 && bitmap[len-1] == 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  986) 		len--;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  987) 	ret = xdr_stream_encode_uint32_array(xdr, bitmap, len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  988) 	if (WARN_ON_ONCE(ret < 0))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  989) 		return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  990) 	return len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  991) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  992) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  993) static size_t mask_bitmap4(const __u32 *bitmap, const __u32 *mask,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  994) 		__u32 *res, size_t len)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  995) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  996) 	size_t i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  997) 	__u32 tmp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  998) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  999) 	while (len > 0 && (bitmap[len-1] == 0 || mask[len-1] == 0))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1000) 		len--;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1001) 	for (i = len; i-- > 0;) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1002) 		tmp = bitmap[i] & mask[i];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1003) 		res[i] = tmp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1004) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1005) 	return len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1006) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1007) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1008) static void encode_nfs4_seqid(struct xdr_stream *xdr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1009) 		const struct nfs_seqid *seqid)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1010) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1011) 	if (seqid != NULL)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1012) 		encode_uint32(xdr, seqid->sequence->counter);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1013) 	else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1014) 		encode_uint32(xdr, 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 void encode_compound_hdr(struct xdr_stream *xdr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1018) 				struct rpc_rqst *req,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1019) 				struct compound_hdr *hdr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1020) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1021) 	__be32 *p;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1022) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1023) 	/* initialize running count of expected bytes in reply.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1024) 	 * NOTE: the replied tag SHOULD be the same is the one sent,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1025) 	 * but this is not required as a MUST for the server to do so. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1026) 	hdr->replen = 3 + hdr->taglen;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1027) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1028) 	WARN_ON_ONCE(hdr->taglen > NFS4_MAXTAGLEN);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1029) 	encode_string(xdr, hdr->taglen, hdr->tag);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1030) 	p = reserve_space(xdr, 8);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1031) 	*p++ = cpu_to_be32(hdr->minorversion);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1032) 	hdr->nops_p = p;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1033) 	*p = cpu_to_be32(hdr->nops);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1034) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1035) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1036) static void encode_op_hdr(struct xdr_stream *xdr, enum nfs_opnum4 op,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1037) 		uint32_t replen,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1038) 		struct compound_hdr *hdr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1039) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1040) 	encode_uint32(xdr, op);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1041) 	hdr->nops++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1042) 	hdr->replen += replen;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1043) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1044) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1045) static void encode_nops(struct compound_hdr *hdr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1046) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1047) 	WARN_ON_ONCE(hdr->nops > NFS4_MAX_OPS);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1048) 	*hdr->nops_p = htonl(hdr->nops);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1049) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1050) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1051) static void encode_nfs4_stateid(struct xdr_stream *xdr, const nfs4_stateid *stateid)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1052) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1053) 	encode_opaque_fixed(xdr, stateid, NFS4_STATEID_SIZE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1054) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1055) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1056) static void encode_nfs4_verifier(struct xdr_stream *xdr, const nfs4_verifier *verf)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1057) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1058) 	encode_opaque_fixed(xdr, verf->data, NFS4_VERIFIER_SIZE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1059) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1060) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1061) static __be32 *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1062) xdr_encode_nfstime4(__be32 *p, const struct timespec64 *t)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1063) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1064) 	p = xdr_encode_hyper(p, t->tv_sec);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1065) 	*p++ = cpu_to_be32(t->tv_nsec);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1066) 	return p;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1067) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1068) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1069) static void encode_attrs(struct xdr_stream *xdr, const struct iattr *iap,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1070) 				const struct nfs4_label *label,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1071) 				const umode_t *umask,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1072) 				const struct nfs_server *server,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1073) 				const uint32_t attrmask[])
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1074) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1075) 	char owner_name[IDMAP_NAMESZ];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1076) 	char owner_group[IDMAP_NAMESZ];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1077) 	int owner_namelen = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1078) 	int owner_grouplen = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1079) 	__be32 *p;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1080) 	uint32_t len = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1081) 	uint32_t bmval[3] = { 0 };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1082) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1083) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1084) 	 * We reserve enough space to write the entire attribute buffer at once.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1085) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1086) 	if ((iap->ia_valid & ATTR_SIZE) && (attrmask[0] & FATTR4_WORD0_SIZE)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1087) 		bmval[0] |= FATTR4_WORD0_SIZE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1088) 		len += 8;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1089) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1090) 	if (iap->ia_valid & ATTR_MODE) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1091) 		if (umask && (attrmask[2] & FATTR4_WORD2_MODE_UMASK)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1092) 			bmval[2] |= FATTR4_WORD2_MODE_UMASK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1093) 			len += 8;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1094) 		} else if (attrmask[1] & FATTR4_WORD1_MODE) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1095) 			bmval[1] |= FATTR4_WORD1_MODE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1096) 			len += 4;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1097) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1098) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1099) 	if ((iap->ia_valid & ATTR_UID) && (attrmask[1] & FATTR4_WORD1_OWNER)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1100) 		owner_namelen = nfs_map_uid_to_name(server, iap->ia_uid, owner_name, IDMAP_NAMESZ);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1101) 		if (owner_namelen < 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1102) 			dprintk("nfs: couldn't resolve uid %d to string\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1103) 					from_kuid(&init_user_ns, iap->ia_uid));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1104) 			/* XXX */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1105) 			strcpy(owner_name, "nobody");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1106) 			owner_namelen = sizeof("nobody") - 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1107) 			/* goto out; */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1108) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1109) 		bmval[1] |= FATTR4_WORD1_OWNER;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1110) 		len += 4 + (XDR_QUADLEN(owner_namelen) << 2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1111) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1112) 	if ((iap->ia_valid & ATTR_GID) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1113) 	   (attrmask[1] & FATTR4_WORD1_OWNER_GROUP)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1114) 		owner_grouplen = nfs_map_gid_to_group(server, iap->ia_gid, owner_group, IDMAP_NAMESZ);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1115) 		if (owner_grouplen < 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1116) 			dprintk("nfs: couldn't resolve gid %d to string\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1117) 					from_kgid(&init_user_ns, iap->ia_gid));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1118) 			strcpy(owner_group, "nobody");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1119) 			owner_grouplen = sizeof("nobody") - 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1120) 			/* goto out; */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1121) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1122) 		bmval[1] |= FATTR4_WORD1_OWNER_GROUP;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1123) 		len += 4 + (XDR_QUADLEN(owner_grouplen) << 2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1124) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1125) 	if (attrmask[1] & FATTR4_WORD1_TIME_ACCESS_SET) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1126) 		if (iap->ia_valid & ATTR_ATIME_SET) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1127) 			bmval[1] |= FATTR4_WORD1_TIME_ACCESS_SET;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1128) 			len += 4 + (nfstime4_maxsz << 2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1129) 		} else if (iap->ia_valid & ATTR_ATIME) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1130) 			bmval[1] |= FATTR4_WORD1_TIME_ACCESS_SET;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1131) 			len += 4;
^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) 	if (attrmask[1] & FATTR4_WORD1_TIME_MODIFY_SET) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1135) 		if (iap->ia_valid & ATTR_MTIME_SET) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1136) 			bmval[1] |= FATTR4_WORD1_TIME_MODIFY_SET;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1137) 			len += 4 + (nfstime4_maxsz << 2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1138) 		} else if (iap->ia_valid & ATTR_MTIME) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1139) 			bmval[1] |= FATTR4_WORD1_TIME_MODIFY_SET;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1140) 			len += 4;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1141) 		}
^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) 	if (label && (attrmask[2] & FATTR4_WORD2_SECURITY_LABEL)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1145) 		len += 4 + 4 + 4 + (XDR_QUADLEN(label->len) << 2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1146) 		bmval[2] |= FATTR4_WORD2_SECURITY_LABEL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1147) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1148) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1149) 	xdr_encode_bitmap4(xdr, bmval, ARRAY_SIZE(bmval));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1150) 	xdr_stream_encode_opaque_inline(xdr, (void **)&p, len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1151) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1152) 	if (bmval[0] & FATTR4_WORD0_SIZE)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1153) 		p = xdr_encode_hyper(p, iap->ia_size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1154) 	if (bmval[1] & FATTR4_WORD1_MODE)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1155) 		*p++ = cpu_to_be32(iap->ia_mode & S_IALLUGO);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1156) 	if (bmval[1] & FATTR4_WORD1_OWNER)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1157) 		p = xdr_encode_opaque(p, owner_name, owner_namelen);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1158) 	if (bmval[1] & FATTR4_WORD1_OWNER_GROUP)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1159) 		p = xdr_encode_opaque(p, owner_group, owner_grouplen);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1160) 	if (bmval[1] & FATTR4_WORD1_TIME_ACCESS_SET) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1161) 		if (iap->ia_valid & ATTR_ATIME_SET) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1162) 			*p++ = cpu_to_be32(NFS4_SET_TO_CLIENT_TIME);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1163) 			p = xdr_encode_nfstime4(p, &iap->ia_atime);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1164) 		} else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1165) 			*p++ = cpu_to_be32(NFS4_SET_TO_SERVER_TIME);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1166) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1167) 	if (bmval[1] & FATTR4_WORD1_TIME_MODIFY_SET) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1168) 		if (iap->ia_valid & ATTR_MTIME_SET) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1169) 			*p++ = cpu_to_be32(NFS4_SET_TO_CLIENT_TIME);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1170) 			p = xdr_encode_nfstime4(p, &iap->ia_mtime);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1171) 		} else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1172) 			*p++ = cpu_to_be32(NFS4_SET_TO_SERVER_TIME);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1173) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1174) 	if (label && (bmval[2] & FATTR4_WORD2_SECURITY_LABEL)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1175) 		*p++ = cpu_to_be32(label->lfs);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1176) 		*p++ = cpu_to_be32(label->pi);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1177) 		*p++ = cpu_to_be32(label->len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1178) 		p = xdr_encode_opaque_fixed(p, label->label, label->len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1179) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1180) 	if (bmval[2] & FATTR4_WORD2_MODE_UMASK) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1181) 		*p++ = cpu_to_be32(iap->ia_mode & S_IALLUGO);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1182) 		*p++ = cpu_to_be32(*umask);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1183) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1184) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1185) /* out: */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1186) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1187) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1188) static void encode_access(struct xdr_stream *xdr, u32 access, struct compound_hdr *hdr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1189) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1190) 	encode_op_hdr(xdr, OP_ACCESS, decode_access_maxsz, hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1191) 	encode_uint32(xdr, access);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1192) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1193) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1194) static void encode_close(struct xdr_stream *xdr, const struct nfs_closeargs *arg, struct compound_hdr *hdr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1195) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1196) 	encode_op_hdr(xdr, OP_CLOSE, decode_close_maxsz, hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1197) 	encode_nfs4_seqid(xdr, arg->seqid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1198) 	encode_nfs4_stateid(xdr, &arg->stateid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1199) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1200) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1201) static void encode_commit(struct xdr_stream *xdr, const struct nfs_commitargs *args, struct compound_hdr *hdr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1202) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1203) 	__be32 *p;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1204) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1205) 	encode_op_hdr(xdr, OP_COMMIT, decode_commit_maxsz, hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1206) 	p = reserve_space(xdr, 12);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1207) 	p = xdr_encode_hyper(p, args->offset);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1208) 	*p = cpu_to_be32(args->count);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1209) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1210) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1211) static void encode_create(struct xdr_stream *xdr, const struct nfs4_create_arg *create, struct compound_hdr *hdr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1212) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1213) 	__be32 *p;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1214) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1215) 	encode_op_hdr(xdr, OP_CREATE, decode_create_maxsz, hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1216) 	encode_uint32(xdr, create->ftype);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1217) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1218) 	switch (create->ftype) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1219) 	case NF4LNK:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1220) 		p = reserve_space(xdr, 4);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1221) 		*p = cpu_to_be32(create->u.symlink.len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1222) 		xdr_write_pages(xdr, create->u.symlink.pages, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1223) 				create->u.symlink.len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1224) 		xdr->buf->flags |= XDRBUF_WRITE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1225) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1226) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1227) 	case NF4BLK: case NF4CHR:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1228) 		p = reserve_space(xdr, 8);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1229) 		*p++ = cpu_to_be32(create->u.device.specdata1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1230) 		*p = cpu_to_be32(create->u.device.specdata2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1231) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1232) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1233) 	default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1234) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1235) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1236) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1237) 	encode_string(xdr, create->name->len, create->name->name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1238) 	encode_attrs(xdr, create->attrs, create->label, &create->umask,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1239) 			create->server, create->server->attr_bitmask);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1240) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1241) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1242) static void encode_getattr(struct xdr_stream *xdr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1243) 		const __u32 *bitmap, const __u32 *mask, size_t len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1244) 		struct compound_hdr *hdr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1245) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1246) 	__u32 masked_bitmap[nfs4_fattr_bitmap_maxsz];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1247) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1248) 	encode_op_hdr(xdr, OP_GETATTR, decode_getattr_maxsz, hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1249) 	if (mask) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1250) 		if (WARN_ON_ONCE(len > ARRAY_SIZE(masked_bitmap)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1251) 			len = ARRAY_SIZE(masked_bitmap);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1252) 		len = mask_bitmap4(bitmap, mask, masked_bitmap, len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1253) 		bitmap = masked_bitmap;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1254) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1255) 	xdr_encode_bitmap4(xdr, bitmap, len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1256) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1257) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1258) static void encode_getfattr(struct xdr_stream *xdr, const u32* bitmask, struct compound_hdr *hdr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1259) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1260) 	encode_getattr(xdr, nfs4_fattr_bitmap, bitmask,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1261) 			ARRAY_SIZE(nfs4_fattr_bitmap), hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1262) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1263) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1264) static void encode_getfattr_open(struct xdr_stream *xdr, const u32 *bitmask,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1265) 				 const u32 *open_bitmap,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1266) 				 struct compound_hdr *hdr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1267) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1268) 	encode_getattr(xdr, open_bitmap, bitmask, 3, hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1269) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1270) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1271) static void encode_fsinfo(struct xdr_stream *xdr, const u32* bitmask, struct compound_hdr *hdr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1272) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1273) 	encode_getattr(xdr, nfs4_fsinfo_bitmap, bitmask,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1274) 			ARRAY_SIZE(nfs4_fsinfo_bitmap), hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1275) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1276) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1277) static void encode_fs_locations(struct xdr_stream *xdr, const u32* bitmask, struct compound_hdr *hdr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1278) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1279) 	encode_getattr(xdr, nfs4_fs_locations_bitmap, bitmask,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1280) 			ARRAY_SIZE(nfs4_fs_locations_bitmap), hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1281) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1282) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1283) static void encode_getfh(struct xdr_stream *xdr, struct compound_hdr *hdr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1284) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1285) 	encode_op_hdr(xdr, OP_GETFH, decode_getfh_maxsz, hdr);
^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) static void encode_link(struct xdr_stream *xdr, const struct qstr *name, struct compound_hdr *hdr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1289) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1290) 	encode_op_hdr(xdr, OP_LINK, decode_link_maxsz, hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1291) 	encode_string(xdr, name->len, name->name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1292) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1293) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1294) static inline int nfs4_lock_type(struct file_lock *fl, int block)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1295) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1296) 	if (fl->fl_type == F_RDLCK)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1297) 		return block ? NFS4_READW_LT : NFS4_READ_LT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1298) 	return block ? NFS4_WRITEW_LT : NFS4_WRITE_LT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1299) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1300) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1301) static inline uint64_t nfs4_lock_length(struct file_lock *fl)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1302) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1303) 	if (fl->fl_end == OFFSET_MAX)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1304) 		return ~(uint64_t)0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1305) 	return fl->fl_end - fl->fl_start + 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1306) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1307) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1308) static void encode_lockowner(struct xdr_stream *xdr, const struct nfs_lowner *lowner)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1309) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1310) 	__be32 *p;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1311) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1312) 	p = reserve_space(xdr, 32);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1313) 	p = xdr_encode_hyper(p, lowner->clientid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1314) 	*p++ = cpu_to_be32(20);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1315) 	p = xdr_encode_opaque_fixed(p, "lock id:", 8);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1316) 	*p++ = cpu_to_be32(lowner->s_dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1317) 	xdr_encode_hyper(p, lowner->id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1318) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1319) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1320) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1321)  * opcode,type,reclaim,offset,length,new_lock_owner = 32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1322)  * open_seqid,open_stateid,lock_seqid,lock_owner.clientid, lock_owner.id = 40
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1323)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1324) static void encode_lock(struct xdr_stream *xdr, const struct nfs_lock_args *args, struct compound_hdr *hdr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1325) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1326) 	__be32 *p;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1327) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1328) 	encode_op_hdr(xdr, OP_LOCK, decode_lock_maxsz, hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1329) 	p = reserve_space(xdr, 28);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1330) 	*p++ = cpu_to_be32(nfs4_lock_type(args->fl, args->block));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1331) 	*p++ = cpu_to_be32(args->reclaim);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1332) 	p = xdr_encode_hyper(p, args->fl->fl_start);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1333) 	p = xdr_encode_hyper(p, nfs4_lock_length(args->fl));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1334) 	*p = cpu_to_be32(args->new_lock_owner);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1335) 	if (args->new_lock_owner){
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1336) 		encode_nfs4_seqid(xdr, args->open_seqid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1337) 		encode_nfs4_stateid(xdr, &args->open_stateid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1338) 		encode_nfs4_seqid(xdr, args->lock_seqid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1339) 		encode_lockowner(xdr, &args->lock_owner);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1340) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1341) 	else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1342) 		encode_nfs4_stateid(xdr, &args->lock_stateid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1343) 		encode_nfs4_seqid(xdr, args->lock_seqid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1344) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1345) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1346) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1347) static void encode_lockt(struct xdr_stream *xdr, const struct nfs_lockt_args *args, struct compound_hdr *hdr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1348) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1349) 	__be32 *p;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1350) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1351) 	encode_op_hdr(xdr, OP_LOCKT, decode_lockt_maxsz, hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1352) 	p = reserve_space(xdr, 20);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1353) 	*p++ = cpu_to_be32(nfs4_lock_type(args->fl, 0));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1354) 	p = xdr_encode_hyper(p, args->fl->fl_start);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1355) 	p = xdr_encode_hyper(p, nfs4_lock_length(args->fl));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1356) 	encode_lockowner(xdr, &args->lock_owner);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1357) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1358) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1359) static void encode_locku(struct xdr_stream *xdr, const struct nfs_locku_args *args, struct compound_hdr *hdr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1360) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1361) 	__be32 *p;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1362) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1363) 	encode_op_hdr(xdr, OP_LOCKU, decode_locku_maxsz, hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1364) 	encode_uint32(xdr, nfs4_lock_type(args->fl, 0));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1365) 	encode_nfs4_seqid(xdr, args->seqid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1366) 	encode_nfs4_stateid(xdr, &args->stateid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1367) 	p = reserve_space(xdr, 16);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1368) 	p = xdr_encode_hyper(p, args->fl->fl_start);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1369) 	xdr_encode_hyper(p, nfs4_lock_length(args->fl));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1370) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1371) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1372) static void encode_release_lockowner(struct xdr_stream *xdr, const struct nfs_lowner *lowner, struct compound_hdr *hdr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1373) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1374) 	encode_op_hdr(xdr, OP_RELEASE_LOCKOWNER, decode_release_lockowner_maxsz, hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1375) 	encode_lockowner(xdr, lowner);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1376) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1377) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1378) static void encode_lookup(struct xdr_stream *xdr, const struct qstr *name, struct compound_hdr *hdr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1379) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1380) 	encode_op_hdr(xdr, OP_LOOKUP, decode_lookup_maxsz, hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1381) 	encode_string(xdr, name->len, name->name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1382) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1383) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1384) static void encode_lookupp(struct xdr_stream *xdr, struct compound_hdr *hdr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1385) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1386) 	encode_op_hdr(xdr, OP_LOOKUPP, decode_lookupp_maxsz, hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1387) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1388) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1389) static void encode_share_access(struct xdr_stream *xdr, u32 share_access)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1390) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1391) 	__be32 *p;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1392) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1393) 	p = reserve_space(xdr, 8);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1394) 	*p++ = cpu_to_be32(share_access);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1395) 	*p = cpu_to_be32(0);		/* for linux, share_deny = 0 always */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1396) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1397) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1398) static inline void encode_openhdr(struct xdr_stream *xdr, const struct nfs_openargs *arg)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1399) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1400) 	__be32 *p;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1401)  /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1402)  * opcode 4, seqid 4, share_access 4, share_deny 4, clientid 8, ownerlen 4,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1403)  * owner 4 = 32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1404)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1405) 	encode_nfs4_seqid(xdr, arg->seqid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1406) 	encode_share_access(xdr, arg->share_access);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1407) 	p = reserve_space(xdr, 36);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1408) 	p = xdr_encode_hyper(p, arg->clientid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1409) 	*p++ = cpu_to_be32(24);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1410) 	p = xdr_encode_opaque_fixed(p, "open id:", 8);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1411) 	*p++ = cpu_to_be32(arg->server->s_dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1412) 	*p++ = cpu_to_be32(arg->id.uniquifier);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1413) 	xdr_encode_hyper(p, arg->id.create_time);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1414) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1415) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1416) static inline void encode_createmode(struct xdr_stream *xdr, const struct nfs_openargs *arg)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1417) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1418) 	__be32 *p;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1419) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1420) 	p = reserve_space(xdr, 4);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1421) 	switch(arg->createmode) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1422) 	case NFS4_CREATE_UNCHECKED:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1423) 		*p = cpu_to_be32(NFS4_CREATE_UNCHECKED);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1424) 		encode_attrs(xdr, arg->u.attrs, arg->label, &arg->umask,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1425) 				arg->server, arg->server->attr_bitmask);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1426) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1427) 	case NFS4_CREATE_GUARDED:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1428) 		*p = cpu_to_be32(NFS4_CREATE_GUARDED);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1429) 		encode_attrs(xdr, arg->u.attrs, arg->label, &arg->umask,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1430) 				arg->server, arg->server->attr_bitmask);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1431) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1432) 	case NFS4_CREATE_EXCLUSIVE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1433) 		*p = cpu_to_be32(NFS4_CREATE_EXCLUSIVE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1434) 		encode_nfs4_verifier(xdr, &arg->u.verifier);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1435) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1436) 	case NFS4_CREATE_EXCLUSIVE4_1:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1437) 		*p = cpu_to_be32(NFS4_CREATE_EXCLUSIVE4_1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1438) 		encode_nfs4_verifier(xdr, &arg->u.verifier);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1439) 		encode_attrs(xdr, arg->u.attrs, arg->label, &arg->umask,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1440) 				arg->server, arg->server->exclcreat_bitmask);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1441) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1442) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1443) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1444) static void encode_opentype(struct xdr_stream *xdr, const struct nfs_openargs *arg)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1445) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1446) 	__be32 *p;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1447) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1448) 	p = reserve_space(xdr, 4);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1449) 	switch (arg->open_flags & O_CREAT) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1450) 	case 0:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1451) 		*p = cpu_to_be32(NFS4_OPEN_NOCREATE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1452) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1453) 	default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1454) 		*p = cpu_to_be32(NFS4_OPEN_CREATE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1455) 		encode_createmode(xdr, arg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1456) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1457) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1458) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1459) static inline void encode_delegation_type(struct xdr_stream *xdr, fmode_t delegation_type)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1460) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1461) 	__be32 *p;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1462) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1463) 	p = reserve_space(xdr, 4);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1464) 	switch (delegation_type) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1465) 	case 0:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1466) 		*p = cpu_to_be32(NFS4_OPEN_DELEGATE_NONE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1467) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1468) 	case FMODE_READ:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1469) 		*p = cpu_to_be32(NFS4_OPEN_DELEGATE_READ);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1470) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1471) 	case FMODE_WRITE|FMODE_READ:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1472) 		*p = cpu_to_be32(NFS4_OPEN_DELEGATE_WRITE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1473) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1474) 	default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1475) 		BUG();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1476) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1477) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1478) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1479) static inline void encode_claim_null(struct xdr_stream *xdr, const struct qstr *name)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1480) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1481) 	__be32 *p;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1482) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1483) 	p = reserve_space(xdr, 4);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1484) 	*p = cpu_to_be32(NFS4_OPEN_CLAIM_NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1485) 	encode_string(xdr, name->len, name->name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1486) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1487) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1488) static inline void encode_claim_previous(struct xdr_stream *xdr, fmode_t type)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1489) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1490) 	__be32 *p;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1491) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1492) 	p = reserve_space(xdr, 4);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1493) 	*p = cpu_to_be32(NFS4_OPEN_CLAIM_PREVIOUS);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1494) 	encode_delegation_type(xdr, type);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1495) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1496) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1497) static inline void encode_claim_delegate_cur(struct xdr_stream *xdr, const struct qstr *name, const nfs4_stateid *stateid)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1498) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1499) 	__be32 *p;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1500) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1501) 	p = reserve_space(xdr, 4);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1502) 	*p = cpu_to_be32(NFS4_OPEN_CLAIM_DELEGATE_CUR);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1503) 	encode_nfs4_stateid(xdr, stateid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1504) 	encode_string(xdr, name->len, name->name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1505) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1506) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1507) static inline void encode_claim_fh(struct xdr_stream *xdr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1508) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1509) 	__be32 *p;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1510) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1511) 	p = reserve_space(xdr, 4);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1512) 	*p = cpu_to_be32(NFS4_OPEN_CLAIM_FH);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1513) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1514) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1515) static inline void encode_claim_delegate_cur_fh(struct xdr_stream *xdr, const nfs4_stateid *stateid)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1516) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1517) 	__be32 *p;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1518) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1519) 	p = reserve_space(xdr, 4);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1520) 	*p = cpu_to_be32(NFS4_OPEN_CLAIM_DELEG_CUR_FH);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1521) 	encode_nfs4_stateid(xdr, stateid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1522) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1523) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1524) static void encode_open(struct xdr_stream *xdr, const struct nfs_openargs *arg, struct compound_hdr *hdr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1525) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1526) 	encode_op_hdr(xdr, OP_OPEN, decode_open_maxsz, hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1527) 	encode_openhdr(xdr, arg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1528) 	encode_opentype(xdr, arg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1529) 	switch (arg->claim) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1530) 	case NFS4_OPEN_CLAIM_NULL:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1531) 		encode_claim_null(xdr, arg->name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1532) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1533) 	case NFS4_OPEN_CLAIM_PREVIOUS:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1534) 		encode_claim_previous(xdr, arg->u.delegation_type);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1535) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1536) 	case NFS4_OPEN_CLAIM_DELEGATE_CUR:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1537) 		encode_claim_delegate_cur(xdr, arg->name, &arg->u.delegation);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1538) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1539) 	case NFS4_OPEN_CLAIM_FH:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1540) 		encode_claim_fh(xdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1541) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1542) 	case NFS4_OPEN_CLAIM_DELEG_CUR_FH:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1543) 		encode_claim_delegate_cur_fh(xdr, &arg->u.delegation);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1544) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1545) 	default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1546) 		BUG();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1547) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1548) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1549) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1550) static void encode_open_confirm(struct xdr_stream *xdr, const struct nfs_open_confirmargs *arg, struct compound_hdr *hdr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1551) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1552) 	encode_op_hdr(xdr, OP_OPEN_CONFIRM, decode_open_confirm_maxsz, hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1553) 	encode_nfs4_stateid(xdr, arg->stateid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1554) 	encode_nfs4_seqid(xdr, arg->seqid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1555) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1556) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1557) static void encode_open_downgrade(struct xdr_stream *xdr, const struct nfs_closeargs *arg, struct compound_hdr *hdr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1558) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1559) 	encode_op_hdr(xdr, OP_OPEN_DOWNGRADE, decode_open_downgrade_maxsz, hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1560) 	encode_nfs4_stateid(xdr, &arg->stateid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1561) 	encode_nfs4_seqid(xdr, arg->seqid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1562) 	encode_share_access(xdr, arg->share_access);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1563) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1564) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1565) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1566) encode_putfh(struct xdr_stream *xdr, const struct nfs_fh *fh, struct compound_hdr *hdr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1567) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1568) 	encode_op_hdr(xdr, OP_PUTFH, decode_putfh_maxsz, hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1569) 	encode_string(xdr, fh->size, fh->data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1570) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1571) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1572) static void encode_putrootfh(struct xdr_stream *xdr, struct compound_hdr *hdr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1573) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1574) 	encode_op_hdr(xdr, OP_PUTROOTFH, decode_putrootfh_maxsz, hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1575) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1576) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1577) static void encode_read(struct xdr_stream *xdr, const struct nfs_pgio_args *args,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1578) 			struct compound_hdr *hdr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1579) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1580) 	__be32 *p;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1581) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1582) 	encode_op_hdr(xdr, OP_READ, decode_read_maxsz, hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1583) 	encode_nfs4_stateid(xdr, &args->stateid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1584) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1585) 	p = reserve_space(xdr, 12);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1586) 	p = xdr_encode_hyper(p, args->offset);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1587) 	*p = cpu_to_be32(args->count);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1588) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1589) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1590) static void encode_readdir(struct xdr_stream *xdr, const struct nfs4_readdir_arg *readdir, struct rpc_rqst *req, struct compound_hdr *hdr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1591) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1592) 	uint32_t attrs[3] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1593) 		FATTR4_WORD0_RDATTR_ERROR,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1594) 		FATTR4_WORD1_MOUNTED_ON_FILEID,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1595) 	};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1596) 	uint32_t dircount = readdir->count >> 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1597) 	__be32 *p, verf[2];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1598) 	uint32_t attrlen = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1599) 	unsigned int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1600) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1601) 	if (readdir->plus) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1602) 		attrs[0] |= FATTR4_WORD0_TYPE|FATTR4_WORD0_CHANGE|FATTR4_WORD0_SIZE|
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1603) 			FATTR4_WORD0_FSID|FATTR4_WORD0_FILEHANDLE|FATTR4_WORD0_FILEID;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1604) 		attrs[1] |= FATTR4_WORD1_MODE|FATTR4_WORD1_NUMLINKS|FATTR4_WORD1_OWNER|
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1605) 			FATTR4_WORD1_OWNER_GROUP|FATTR4_WORD1_RAWDEV|
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1606) 			FATTR4_WORD1_SPACE_USED|FATTR4_WORD1_TIME_ACCESS|
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1607) 			FATTR4_WORD1_TIME_METADATA|FATTR4_WORD1_TIME_MODIFY;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1608) 		attrs[2] |= FATTR4_WORD2_SECURITY_LABEL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1609) 		dircount >>= 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1610) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1611) 	/* Use mounted_on_fileid only if the server supports it */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1612) 	if (!(readdir->bitmask[1] & FATTR4_WORD1_MOUNTED_ON_FILEID))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1613) 		attrs[0] |= FATTR4_WORD0_FILEID;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1614) 	for (i = 0; i < ARRAY_SIZE(attrs); i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1615) 		attrs[i] &= readdir->bitmask[i];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1616) 		if (attrs[i] != 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1617) 			attrlen = i+1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1618) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1619) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1620) 	encode_op_hdr(xdr, OP_READDIR, decode_readdir_maxsz, hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1621) 	encode_uint64(xdr, readdir->cookie);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1622) 	encode_nfs4_verifier(xdr, &readdir->verifier);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1623) 	p = reserve_space(xdr, 12 + (attrlen << 2));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1624) 	*p++ = cpu_to_be32(dircount);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1625) 	*p++ = cpu_to_be32(readdir->count);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1626) 	*p++ = cpu_to_be32(attrlen);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1627) 	for (i = 0; i < attrlen; i++)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1628) 		*p++ = cpu_to_be32(attrs[i]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1629) 	memcpy(verf, readdir->verifier.data, sizeof(verf));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1630) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1631) 	dprintk("%s: cookie = %llu, verifier = %08x:%08x, bitmap = %08x:%08x:%08x\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1632) 			__func__,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1633) 			(unsigned long long)readdir->cookie,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1634) 			verf[0], verf[1],
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1635) 			attrs[0] & readdir->bitmask[0],
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1636) 			attrs[1] & readdir->bitmask[1],
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1637) 			attrs[2] & readdir->bitmask[2]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1638) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1639) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1640) static void encode_readlink(struct xdr_stream *xdr, const struct nfs4_readlink *readlink, struct rpc_rqst *req, struct compound_hdr *hdr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1641) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1642) 	encode_op_hdr(xdr, OP_READLINK, decode_readlink_maxsz, hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1643) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1644) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1645) static void encode_remove(struct xdr_stream *xdr, const struct qstr *name, struct compound_hdr *hdr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1646) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1647) 	encode_op_hdr(xdr, OP_REMOVE, decode_remove_maxsz, hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1648) 	encode_string(xdr, name->len, name->name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1649) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1650) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1651) static void encode_rename(struct xdr_stream *xdr, const struct qstr *oldname, const struct qstr *newname, struct compound_hdr *hdr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1652) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1653) 	encode_op_hdr(xdr, OP_RENAME, decode_rename_maxsz, hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1654) 	encode_string(xdr, oldname->len, oldname->name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1655) 	encode_string(xdr, newname->len, newname->name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1656) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1657) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1658) static void encode_renew(struct xdr_stream *xdr, clientid4 clid,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1659) 			 struct compound_hdr *hdr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1660) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1661) 	encode_op_hdr(xdr, OP_RENEW, decode_renew_maxsz, hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1662) 	encode_uint64(xdr, clid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1663) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1664) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1665) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1666) encode_restorefh(struct xdr_stream *xdr, struct compound_hdr *hdr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1667) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1668) 	encode_op_hdr(xdr, OP_RESTOREFH, decode_restorefh_maxsz, hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1669) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1670) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1671) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1672) encode_setacl(struct xdr_stream *xdr, const struct nfs_setaclargs *arg,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1673) 		struct compound_hdr *hdr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1674) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1675) 	__be32 *p;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1676) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1677) 	encode_op_hdr(xdr, OP_SETATTR, decode_setacl_maxsz, hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1678) 	encode_nfs4_stateid(xdr, &zero_stateid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1679) 	p = reserve_space(xdr, 2*4);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1680) 	*p++ = cpu_to_be32(1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1681) 	*p = cpu_to_be32(FATTR4_WORD0_ACL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1682) 	p = reserve_space(xdr, 4);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1683) 	*p = cpu_to_be32(arg->acl_len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1684) 	xdr_write_pages(xdr, arg->acl_pages, 0, arg->acl_len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1685) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1686) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1687) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1688) encode_savefh(struct xdr_stream *xdr, struct compound_hdr *hdr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1689) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1690) 	encode_op_hdr(xdr, OP_SAVEFH, decode_savefh_maxsz, hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1691) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1692) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1693) static void encode_setattr(struct xdr_stream *xdr, const struct nfs_setattrargs *arg, const struct nfs_server *server, struct compound_hdr *hdr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1694) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1695) 	encode_op_hdr(xdr, OP_SETATTR, decode_setattr_maxsz, hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1696) 	encode_nfs4_stateid(xdr, &arg->stateid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1697) 	encode_attrs(xdr, arg->iap, arg->label, NULL, server,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1698) 			server->attr_bitmask);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1699) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1700) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1701) static void encode_setclientid(struct xdr_stream *xdr, const struct nfs4_setclientid *setclientid, struct compound_hdr *hdr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1702) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1703) 	__be32 *p;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1704) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1705) 	encode_op_hdr(xdr, OP_SETCLIENTID, decode_setclientid_maxsz, hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1706) 	encode_nfs4_verifier(xdr, setclientid->sc_verifier);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1707) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1708) 	encode_string(xdr, strlen(setclientid->sc_clnt->cl_owner_id),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1709) 			setclientid->sc_clnt->cl_owner_id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1710) 	p = reserve_space(xdr, 4);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1711) 	*p = cpu_to_be32(setclientid->sc_prog);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1712) 	encode_string(xdr, setclientid->sc_netid_len, setclientid->sc_netid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1713) 	encode_string(xdr, setclientid->sc_uaddr_len, setclientid->sc_uaddr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1714) 	p = reserve_space(xdr, 4);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1715) 	*p = cpu_to_be32(setclientid->sc_clnt->cl_cb_ident);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1716) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1717) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1718) static void encode_setclientid_confirm(struct xdr_stream *xdr, const struct nfs4_setclientid_res *arg, struct compound_hdr *hdr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1719) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1720) 	encode_op_hdr(xdr, OP_SETCLIENTID_CONFIRM,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1721) 			decode_setclientid_confirm_maxsz, hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1722) 	encode_uint64(xdr, arg->clientid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1723) 	encode_nfs4_verifier(xdr, &arg->confirm);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1724) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1725) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1726) static void encode_write(struct xdr_stream *xdr, const struct nfs_pgio_args *args,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1727) 			 struct compound_hdr *hdr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1728) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1729) 	__be32 *p;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1730) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1731) 	encode_op_hdr(xdr, OP_WRITE, decode_write_maxsz, hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1732) 	encode_nfs4_stateid(xdr, &args->stateid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1733) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1734) 	p = reserve_space(xdr, 16);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1735) 	p = xdr_encode_hyper(p, args->offset);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1736) 	*p++ = cpu_to_be32(args->stable);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1737) 	*p = cpu_to_be32(args->count);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1738) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1739) 	xdr_write_pages(xdr, args->pages, args->pgbase, args->count);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1740) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1741) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1742) static void encode_delegreturn(struct xdr_stream *xdr, const nfs4_stateid *stateid, struct compound_hdr *hdr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1743) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1744) 	encode_op_hdr(xdr, OP_DELEGRETURN, decode_delegreturn_maxsz, hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1745) 	encode_nfs4_stateid(xdr, stateid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1746) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1747) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1748) static void encode_secinfo(struct xdr_stream *xdr, const struct qstr *name, struct compound_hdr *hdr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1749) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1750) 	encode_op_hdr(xdr, OP_SECINFO, decode_secinfo_maxsz, hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1751) 	encode_string(xdr, name->len, name->name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1752) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1753) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1754) #if defined(CONFIG_NFS_V4_1)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1755) /* NFSv4.1 operations */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1756) static void encode_bind_conn_to_session(struct xdr_stream *xdr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1757) 				   const struct nfs41_bind_conn_to_session_args *args,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1758) 				   struct compound_hdr *hdr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1759) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1760) 	__be32 *p;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1761) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1762) 	encode_op_hdr(xdr, OP_BIND_CONN_TO_SESSION,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1763) 		decode_bind_conn_to_session_maxsz, hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1764) 	encode_opaque_fixed(xdr, args->sessionid.data, NFS4_MAX_SESSIONID_LEN);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1765) 	p = xdr_reserve_space(xdr, 8);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1766) 	*p++ = cpu_to_be32(args->dir);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1767) 	*p = (args->use_conn_in_rdma_mode) ? cpu_to_be32(1) : cpu_to_be32(0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1768) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1769) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1770) static void encode_op_map(struct xdr_stream *xdr, const struct nfs4_op_map *op_map)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1771) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1772) 	unsigned int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1773) 	encode_uint32(xdr, NFS4_OP_MAP_NUM_WORDS);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1774) 	for (i = 0; i < NFS4_OP_MAP_NUM_WORDS; i++)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1775) 		encode_uint32(xdr, op_map->u.words[i]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1776) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1777) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1778) static void encode_exchange_id(struct xdr_stream *xdr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1779) 			       const struct nfs41_exchange_id_args *args,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1780) 			       struct compound_hdr *hdr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1781) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1782) 	__be32 *p;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1783) 	char impl_name[IMPL_NAME_LIMIT];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1784) 	int len = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1785) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1786) 	encode_op_hdr(xdr, OP_EXCHANGE_ID, decode_exchange_id_maxsz, hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1787) 	encode_nfs4_verifier(xdr, &args->verifier);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1788) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1789) 	encode_string(xdr, strlen(args->client->cl_owner_id),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1790) 			args->client->cl_owner_id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1791) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1792) 	encode_uint32(xdr, args->flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1793) 	encode_uint32(xdr, args->state_protect.how);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1794) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1795) 	switch (args->state_protect.how) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1796) 	case SP4_NONE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1797) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1798) 	case SP4_MACH_CRED:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1799) 		encode_op_map(xdr, &args->state_protect.enforce);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1800) 		encode_op_map(xdr, &args->state_protect.allow);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1801) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1802) 	default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1803) 		WARN_ON_ONCE(1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1804) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1805) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1806) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1807) 	if (send_implementation_id &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1808) 	    sizeof(CONFIG_NFS_V4_1_IMPLEMENTATION_ID_DOMAIN) > 1 &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1809) 	    sizeof(CONFIG_NFS_V4_1_IMPLEMENTATION_ID_DOMAIN)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1810) 		<= sizeof(impl_name) + 1)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1811) 		len = snprintf(impl_name, sizeof(impl_name), "%s %s %s %s",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1812) 			       utsname()->sysname, utsname()->release,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1813) 			       utsname()->version, utsname()->machine);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1814) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1815) 	if (len > 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1816) 		encode_uint32(xdr, 1);	/* implementation id array length=1 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1817) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1818) 		encode_string(xdr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1819) 			sizeof(CONFIG_NFS_V4_1_IMPLEMENTATION_ID_DOMAIN) - 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1820) 			CONFIG_NFS_V4_1_IMPLEMENTATION_ID_DOMAIN);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1821) 		encode_string(xdr, len, impl_name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1822) 		/* just send zeros for nii_date - the date is in nii_name */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1823) 		p = reserve_space(xdr, 12);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1824) 		p = xdr_encode_hyper(p, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1825) 		*p = cpu_to_be32(0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1826) 	} else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1827) 		encode_uint32(xdr, 0);	/* implementation id array length=0 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1828) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1829) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1830) static void encode_create_session(struct xdr_stream *xdr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1831) 				  const struct nfs41_create_session_args *args,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1832) 				  struct compound_hdr *hdr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1833) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1834) 	__be32 *p;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1835) 	struct nfs_client *clp = args->client;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1836) 	struct rpc_clnt *clnt = clp->cl_rpcclient;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1837) 	struct nfs_net *nn = net_generic(clp->cl_net, nfs_net_id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1838) 	u32 max_resp_sz_cached;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1839) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1840) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1841) 	 * Assumes OPEN is the biggest non-idempotent compound.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1842) 	 * 2 is the verifier.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1843) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1844) 	max_resp_sz_cached = (NFS4_dec_open_sz + RPC_REPHDRSIZE + 2)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1845) 				* XDR_UNIT + RPC_MAX_AUTH_SIZE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1846) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1847) 	encode_op_hdr(xdr, OP_CREATE_SESSION, decode_create_session_maxsz, hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1848) 	p = reserve_space(xdr, 16 + 2*28 + 20 + clnt->cl_nodelen + 12);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1849) 	p = xdr_encode_hyper(p, args->clientid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1850) 	*p++ = cpu_to_be32(args->seqid);			/*Sequence id */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1851) 	*p++ = cpu_to_be32(args->flags);			/*flags */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1852) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1853) 	/* Fore Channel */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1854) 	*p++ = cpu_to_be32(0);				/* header padding size */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1855) 	*p++ = cpu_to_be32(args->fc_attrs.max_rqst_sz);	/* max req size */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1856) 	*p++ = cpu_to_be32(args->fc_attrs.max_resp_sz);	/* max resp size */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1857) 	*p++ = cpu_to_be32(max_resp_sz_cached);		/* Max resp sz cached */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1858) 	*p++ = cpu_to_be32(args->fc_attrs.max_ops);	/* max operations */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1859) 	*p++ = cpu_to_be32(args->fc_attrs.max_reqs);	/* max requests */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1860) 	*p++ = cpu_to_be32(0);				/* rdmachannel_attrs */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1861) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1862) 	/* Back Channel */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1863) 	*p++ = cpu_to_be32(0);				/* header padding size */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1864) 	*p++ = cpu_to_be32(args->bc_attrs.max_rqst_sz);	/* max req size */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1865) 	*p++ = cpu_to_be32(args->bc_attrs.max_resp_sz);	/* max resp size */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1866) 	*p++ = cpu_to_be32(args->bc_attrs.max_resp_sz_cached);	/* Max resp sz cached */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1867) 	*p++ = cpu_to_be32(args->bc_attrs.max_ops);	/* max operations */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1868) 	*p++ = cpu_to_be32(args->bc_attrs.max_reqs);	/* max requests */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1869) 	*p++ = cpu_to_be32(0);				/* rdmachannel_attrs */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1870) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1871) 	*p++ = cpu_to_be32(args->cb_program);		/* cb_program */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1872) 	*p++ = cpu_to_be32(1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1873) 	*p++ = cpu_to_be32(RPC_AUTH_UNIX);			/* auth_sys */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1874) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1875) 	/* authsys_parms rfc1831 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1876) 	*p++ = cpu_to_be32(ktime_to_ns(nn->boot_time));	/* stamp */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1877) 	p = xdr_encode_array(p, clnt->cl_nodename, clnt->cl_nodelen);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1878) 	*p++ = cpu_to_be32(0);				/* UID */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1879) 	*p++ = cpu_to_be32(0);				/* GID */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1880) 	*p = cpu_to_be32(0);				/* No more gids */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1881) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1882) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1883) static void encode_destroy_session(struct xdr_stream *xdr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1884) 				   const struct nfs4_session *session,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1885) 				   struct compound_hdr *hdr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1886) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1887) 	encode_op_hdr(xdr, OP_DESTROY_SESSION, decode_destroy_session_maxsz, hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1888) 	encode_opaque_fixed(xdr, session->sess_id.data, NFS4_MAX_SESSIONID_LEN);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1889) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1890) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1891) static void encode_destroy_clientid(struct xdr_stream *xdr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1892) 				   uint64_t clientid,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1893) 				   struct compound_hdr *hdr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1894) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1895) 	encode_op_hdr(xdr, OP_DESTROY_CLIENTID, decode_destroy_clientid_maxsz, hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1896) 	encode_uint64(xdr, clientid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1897) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1898) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1899) static void encode_reclaim_complete(struct xdr_stream *xdr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1900) 				    const struct nfs41_reclaim_complete_args *args,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1901) 				    struct compound_hdr *hdr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1902) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1903) 	encode_op_hdr(xdr, OP_RECLAIM_COMPLETE, decode_reclaim_complete_maxsz, hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1904) 	encode_uint32(xdr, args->one_fs);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1905) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1906) #endif /* CONFIG_NFS_V4_1 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1907) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1908) static void encode_sequence(struct xdr_stream *xdr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1909) 			    const struct nfs4_sequence_args *args,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1910) 			    struct compound_hdr *hdr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1911) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1912) #if defined(CONFIG_NFS_V4_1)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1913) 	struct nfs4_session *session;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1914) 	struct nfs4_slot_table *tp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1915) 	struct nfs4_slot *slot = args->sa_slot;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1916) 	__be32 *p;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1917) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1918) 	tp = slot->table;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1919) 	session = tp->session;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1920) 	if (!session)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1921) 		return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1922) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1923) 	encode_op_hdr(xdr, OP_SEQUENCE, decode_sequence_maxsz, hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1924) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1925) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1926) 	 * Sessionid + seqid + slotid + max slotid + cache_this
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1927) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1928) 	dprintk("%s: sessionid=%u:%u:%u:%u seqid=%d slotid=%d "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1929) 		"max_slotid=%d cache_this=%d\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1930) 		__func__,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1931) 		((u32 *)session->sess_id.data)[0],
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1932) 		((u32 *)session->sess_id.data)[1],
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1933) 		((u32 *)session->sess_id.data)[2],
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1934) 		((u32 *)session->sess_id.data)[3],
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1935) 		slot->seq_nr, slot->slot_nr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1936) 		tp->highest_used_slotid, args->sa_cache_this);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1937) 	p = reserve_space(xdr, NFS4_MAX_SESSIONID_LEN + 16);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1938) 	p = xdr_encode_opaque_fixed(p, session->sess_id.data, NFS4_MAX_SESSIONID_LEN);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1939) 	*p++ = cpu_to_be32(slot->seq_nr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1940) 	*p++ = cpu_to_be32(slot->slot_nr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1941) 	*p++ = cpu_to_be32(tp->highest_used_slotid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1942) 	*p = cpu_to_be32(args->sa_cache_this);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1943) #endif /* CONFIG_NFS_V4_1 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1944) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1945) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1946) #ifdef CONFIG_NFS_V4_1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1947) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1948) encode_getdeviceinfo(struct xdr_stream *xdr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1949) 		     const struct nfs4_getdeviceinfo_args *args,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1950) 		     struct compound_hdr *hdr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1951) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1952) 	__be32 *p;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1953) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1954) 	encode_op_hdr(xdr, OP_GETDEVICEINFO, decode_getdeviceinfo_maxsz, hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1955) 	p = reserve_space(xdr, NFS4_DEVICEID4_SIZE + 4 + 4);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1956) 	p = xdr_encode_opaque_fixed(p, args->pdev->dev_id.data,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1957) 				    NFS4_DEVICEID4_SIZE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1958) 	*p++ = cpu_to_be32(args->pdev->layout_type);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1959) 	*p++ = cpu_to_be32(args->pdev->maxcount);	/* gdia_maxcount */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1960) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1961) 	p = reserve_space(xdr, 4 + 4);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1962) 	*p++ = cpu_to_be32(1);			/* bitmap length */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1963) 	*p++ = cpu_to_be32(args->notify_types);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1964) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1965) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1966) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1967) encode_layoutget(struct xdr_stream *xdr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1968) 		      const struct nfs4_layoutget_args *args,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1969) 		      struct compound_hdr *hdr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1970) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1971) 	__be32 *p;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1972) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1973) 	encode_op_hdr(xdr, OP_LAYOUTGET, decode_layoutget_maxsz, hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1974) 	p = reserve_space(xdr, 36);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1975) 	*p++ = cpu_to_be32(0);     /* Signal layout available */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1976) 	*p++ = cpu_to_be32(args->type);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1977) 	*p++ = cpu_to_be32(args->range.iomode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1978) 	p = xdr_encode_hyper(p, args->range.offset);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1979) 	p = xdr_encode_hyper(p, args->range.length);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1980) 	p = xdr_encode_hyper(p, args->minlength);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1981) 	encode_nfs4_stateid(xdr, &args->stateid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1982) 	encode_uint32(xdr, args->maxcount);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1983) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1984) 	dprintk("%s: 1st type:0x%x iomode:%d off:%lu len:%lu mc:%d\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1985) 		__func__,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1986) 		args->type,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1987) 		args->range.iomode,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1988) 		(unsigned long)args->range.offset,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1989) 		(unsigned long)args->range.length,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1990) 		args->maxcount);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1991) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1992) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1993) static int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1994) encode_layoutcommit(struct xdr_stream *xdr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1995) 		    struct inode *inode,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1996) 		    const struct nfs4_layoutcommit_args *args,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1997) 		    struct compound_hdr *hdr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1998) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1999) 	__be32 *p;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2000) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2001) 	dprintk("%s: lbw: %llu type: %d\n", __func__, args->lastbytewritten,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2002) 		NFS_SERVER(args->inode)->pnfs_curr_ld->id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2003) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2004) 	encode_op_hdr(xdr, OP_LAYOUTCOMMIT, decode_layoutcommit_maxsz, hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2005) 	p = reserve_space(xdr, 20);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2006) 	/* Only whole file layouts */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2007) 	p = xdr_encode_hyper(p, 0); /* offset */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2008) 	p = xdr_encode_hyper(p, args->lastbytewritten + 1);	/* length */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2009) 	*p = cpu_to_be32(0); /* reclaim */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2010) 	encode_nfs4_stateid(xdr, &args->stateid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2011) 	if (args->lastbytewritten != U64_MAX) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2012) 		p = reserve_space(xdr, 20);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2013) 		*p++ = cpu_to_be32(1); /* newoffset = TRUE */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2014) 		p = xdr_encode_hyper(p, args->lastbytewritten);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2015) 	} else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2016) 		p = reserve_space(xdr, 12);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2017) 		*p++ = cpu_to_be32(0); /* newoffset = FALSE */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2018) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2019) 	*p++ = cpu_to_be32(0); /* Never send time_modify_changed */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2020) 	*p++ = cpu_to_be32(NFS_SERVER(args->inode)->pnfs_curr_ld->id);/* type */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2021) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2022) 	encode_uint32(xdr, args->layoutupdate_len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2023) 	if (args->layoutupdate_pages)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2024) 		xdr_write_pages(xdr, args->layoutupdate_pages, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2025) 				args->layoutupdate_len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2026) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2027) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2028) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2029) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2030) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2031) encode_layoutreturn(struct xdr_stream *xdr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2032) 		    const struct nfs4_layoutreturn_args *args,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2033) 		    struct compound_hdr *hdr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2034) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2035) 	__be32 *p;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2036) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2037) 	encode_op_hdr(xdr, OP_LAYOUTRETURN, decode_layoutreturn_maxsz, hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2038) 	p = reserve_space(xdr, 16);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2039) 	*p++ = cpu_to_be32(0);		/* reclaim. always 0 for now */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2040) 	*p++ = cpu_to_be32(args->layout_type);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2041) 	*p++ = cpu_to_be32(args->range.iomode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2042) 	*p = cpu_to_be32(RETURN_FILE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2043) 	p = reserve_space(xdr, 16);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2044) 	p = xdr_encode_hyper(p, args->range.offset);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2045) 	p = xdr_encode_hyper(p, args->range.length);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2046) 	spin_lock(&args->inode->i_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2047) 	encode_nfs4_stateid(xdr, &args->stateid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2048) 	spin_unlock(&args->inode->i_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2049) 	if (args->ld_private->ops && args->ld_private->ops->encode)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2050) 		args->ld_private->ops->encode(xdr, args, args->ld_private);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2051) 	else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2052) 		encode_uint32(xdr, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2053) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2054) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2055) static int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2056) encode_secinfo_no_name(struct xdr_stream *xdr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2057) 		       const struct nfs41_secinfo_no_name_args *args,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2058) 		       struct compound_hdr *hdr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2059) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2060) 	encode_op_hdr(xdr, OP_SECINFO_NO_NAME, decode_secinfo_no_name_maxsz, hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2061) 	encode_uint32(xdr, args->style);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2062) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2063) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2064) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2065) static void encode_test_stateid(struct xdr_stream *xdr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2066) 				const struct nfs41_test_stateid_args *args,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2067) 				struct compound_hdr *hdr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2068) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2069) 	encode_op_hdr(xdr, OP_TEST_STATEID, decode_test_stateid_maxsz, hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2070) 	encode_uint32(xdr, 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2071) 	encode_nfs4_stateid(xdr, args->stateid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2072) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2073) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2074) static void encode_free_stateid(struct xdr_stream *xdr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2075) 				const struct nfs41_free_stateid_args *args,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2076) 				struct compound_hdr *hdr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2077) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2078) 	encode_op_hdr(xdr, OP_FREE_STATEID, decode_free_stateid_maxsz, hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2079) 	encode_nfs4_stateid(xdr, &args->stateid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2080) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2081) #else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2082) static inline void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2083) encode_layoutreturn(struct xdr_stream *xdr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2084) 		    const struct nfs4_layoutreturn_args *args,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2085) 		    struct compound_hdr *hdr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2086) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2087) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2088) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2089) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2090) encode_layoutget(struct xdr_stream *xdr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2091) 		      const struct nfs4_layoutget_args *args,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2092) 		      struct compound_hdr *hdr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2093) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2094) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2095) #endif /* CONFIG_NFS_V4_1 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2096) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2097) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2098)  * END OF "GENERIC" ENCODE ROUTINES.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2099)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2100) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2101) static u32 nfs4_xdr_minorversion(const struct nfs4_sequence_args *args)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2102) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2103) #if defined(CONFIG_NFS_V4_1)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2104) 	struct nfs4_session *session = args->sa_slot->table->session;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2105) 	if (session)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2106) 		return session->clp->cl_mvops->minor_version;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2107) #endif /* CONFIG_NFS_V4_1 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2108) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2109) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2110) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2111) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2112)  * Encode an ACCESS request
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2113)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2114) static void nfs4_xdr_enc_access(struct rpc_rqst *req, struct xdr_stream *xdr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2115) 				const void *data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2116) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2117) 	const struct nfs4_accessargs *args = data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2118) 	struct compound_hdr hdr = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2119) 		.minorversion = nfs4_xdr_minorversion(&args->seq_args),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2120) 	};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2121) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2122) 	encode_compound_hdr(xdr, req, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2123) 	encode_sequence(xdr, &args->seq_args, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2124) 	encode_putfh(xdr, args->fh, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2125) 	encode_access(xdr, args->access, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2126) 	if (args->bitmask)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2127) 		encode_getfattr(xdr, args->bitmask, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2128) 	encode_nops(&hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2129) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2130) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2131) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2132)  * Encode LOOKUP request
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2133)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2134) static void nfs4_xdr_enc_lookup(struct rpc_rqst *req, struct xdr_stream *xdr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2135) 				const void *data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2136) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2137) 	const struct nfs4_lookup_arg *args = data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2138) 	struct compound_hdr hdr = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2139) 		.minorversion = nfs4_xdr_minorversion(&args->seq_args),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2140) 	};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2141) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2142) 	encode_compound_hdr(xdr, req, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2143) 	encode_sequence(xdr, &args->seq_args, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2144) 	encode_putfh(xdr, args->dir_fh, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2145) 	encode_lookup(xdr, args->name, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2146) 	encode_getfh(xdr, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2147) 	encode_getfattr(xdr, args->bitmask, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2148) 	encode_nops(&hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2149) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2150) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2151) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2152)  * Encode LOOKUPP request
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2153)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2154) static void nfs4_xdr_enc_lookupp(struct rpc_rqst *req, struct xdr_stream *xdr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2155) 		const void *data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2156) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2157) 	const struct nfs4_lookupp_arg *args = data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2158) 	struct compound_hdr hdr = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2159) 		.minorversion = nfs4_xdr_minorversion(&args->seq_args),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2160) 	};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2161) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2162) 	encode_compound_hdr(xdr, req, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2163) 	encode_sequence(xdr, &args->seq_args, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2164) 	encode_putfh(xdr, args->fh, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2165) 	encode_lookupp(xdr, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2166) 	encode_getfh(xdr, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2167) 	encode_getfattr(xdr, args->bitmask, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2168) 	encode_nops(&hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2169) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2170) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2171) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2172)  * Encode LOOKUP_ROOT request
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2173)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2174) static void nfs4_xdr_enc_lookup_root(struct rpc_rqst *req,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2175) 				     struct xdr_stream *xdr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2176) 				     const void *data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2177) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2178) 	const struct nfs4_lookup_root_arg *args = data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2179) 	struct compound_hdr hdr = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2180) 		.minorversion = nfs4_xdr_minorversion(&args->seq_args),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2181) 	};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2182) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2183) 	encode_compound_hdr(xdr, req, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2184) 	encode_sequence(xdr, &args->seq_args, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2185) 	encode_putrootfh(xdr, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2186) 	encode_getfh(xdr, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2187) 	encode_getfattr(xdr, args->bitmask, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2188) 	encode_nops(&hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2189) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2190) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2191) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2192)  * Encode REMOVE request
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2193)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2194) static void nfs4_xdr_enc_remove(struct rpc_rqst *req, struct xdr_stream *xdr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2195) 				const void *data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2196) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2197) 	const struct nfs_removeargs *args = data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2198) 	struct compound_hdr hdr = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2199) 		.minorversion = nfs4_xdr_minorversion(&args->seq_args),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2200) 	};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2201) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2202) 	encode_compound_hdr(xdr, req, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2203) 	encode_sequence(xdr, &args->seq_args, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2204) 	encode_putfh(xdr, args->fh, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2205) 	encode_remove(xdr, &args->name, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2206) 	encode_nops(&hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2207) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2208) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2209) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2210)  * Encode RENAME request
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2211)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2212) static void nfs4_xdr_enc_rename(struct rpc_rqst *req, struct xdr_stream *xdr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2213) 				const void *data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2214) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2215) 	const struct nfs_renameargs *args = data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2216) 	struct compound_hdr hdr = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2217) 		.minorversion = nfs4_xdr_minorversion(&args->seq_args),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2218) 	};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2219) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2220) 	encode_compound_hdr(xdr, req, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2221) 	encode_sequence(xdr, &args->seq_args, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2222) 	encode_putfh(xdr, args->old_dir, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2223) 	encode_savefh(xdr, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2224) 	encode_putfh(xdr, args->new_dir, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2225) 	encode_rename(xdr, args->old_name, args->new_name, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2226) 	encode_nops(&hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2227) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2228) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2229) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2230)  * Encode LINK request
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2231)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2232) static void nfs4_xdr_enc_link(struct rpc_rqst *req, struct xdr_stream *xdr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2233) 			      const void *data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2234) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2235) 	const struct nfs4_link_arg *args = data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2236) 	struct compound_hdr hdr = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2237) 		.minorversion = nfs4_xdr_minorversion(&args->seq_args),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2238) 	};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2239) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2240) 	encode_compound_hdr(xdr, req, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2241) 	encode_sequence(xdr, &args->seq_args, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2242) 	encode_putfh(xdr, args->fh, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2243) 	encode_savefh(xdr, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2244) 	encode_putfh(xdr, args->dir_fh, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2245) 	encode_link(xdr, args->name, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2246) 	encode_restorefh(xdr, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2247) 	encode_getfattr(xdr, args->bitmask, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2248) 	encode_nops(&hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2249) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2250) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2251) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2252)  * Encode CREATE request
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2253)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2254) static void nfs4_xdr_enc_create(struct rpc_rqst *req, struct xdr_stream *xdr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2255) 				const void *data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2256) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2257) 	const struct nfs4_create_arg *args = data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2258) 	struct compound_hdr hdr = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2259) 		.minorversion = nfs4_xdr_minorversion(&args->seq_args),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2260) 	};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2261) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2262) 	encode_compound_hdr(xdr, req, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2263) 	encode_sequence(xdr, &args->seq_args, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2264) 	encode_putfh(xdr, args->dir_fh, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2265) 	encode_create(xdr, args, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2266) 	encode_getfh(xdr, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2267) 	encode_getfattr(xdr, args->bitmask, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2268) 	encode_nops(&hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2269) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2270) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2271) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2272)  * Encode SYMLINK request
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2273)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2274) static void nfs4_xdr_enc_symlink(struct rpc_rqst *req, struct xdr_stream *xdr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2275) 				 const void *data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2276) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2277) 	const struct nfs4_create_arg *args = data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2278) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2279) 	nfs4_xdr_enc_create(req, xdr, args);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2280) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2281) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2282) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2283)  * Encode GETATTR request
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2284)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2285) static void nfs4_xdr_enc_getattr(struct rpc_rqst *req, struct xdr_stream *xdr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2286) 				 const void *data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2287) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2288) 	const struct nfs4_getattr_arg *args = data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2289) 	struct compound_hdr hdr = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2290) 		.minorversion = nfs4_xdr_minorversion(&args->seq_args),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2291) 	};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2292) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2293) 	encode_compound_hdr(xdr, req, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2294) 	encode_sequence(xdr, &args->seq_args, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2295) 	encode_putfh(xdr, args->fh, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2296) 	encode_getfattr(xdr, args->bitmask, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2297) 	encode_nops(&hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2298) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2299) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2300) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2301)  * Encode a CLOSE request
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2302)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2303) static void nfs4_xdr_enc_close(struct rpc_rqst *req, struct xdr_stream *xdr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2304) 			       const void *data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2305) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2306) 	const struct nfs_closeargs *args = data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2307) 	struct compound_hdr hdr = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2308) 		.minorversion = nfs4_xdr_minorversion(&args->seq_args),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2309) 	};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2310) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2311) 	encode_compound_hdr(xdr, req, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2312) 	encode_sequence(xdr, &args->seq_args, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2313) 	encode_putfh(xdr, args->fh, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2314) 	if (args->lr_args)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2315) 		encode_layoutreturn(xdr, args->lr_args, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2316) 	if (args->bitmask != NULL)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2317) 		encode_getfattr(xdr, args->bitmask, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2318) 	encode_close(xdr, args, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2319) 	encode_nops(&hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2320) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2321) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2322) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2323)  * Encode an OPEN request
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2324)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2325) static void nfs4_xdr_enc_open(struct rpc_rqst *req, struct xdr_stream *xdr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2326) 			      const void *data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2327) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2328) 	const struct nfs_openargs *args = data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2329) 	struct compound_hdr hdr = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2330) 		.minorversion = nfs4_xdr_minorversion(&args->seq_args),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2331) 	};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2332) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2333) 	encode_compound_hdr(xdr, req, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2334) 	encode_sequence(xdr, &args->seq_args, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2335) 	encode_putfh(xdr, args->fh, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2336) 	encode_open(xdr, args, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2337) 	encode_getfh(xdr, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2338) 	if (args->access)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2339) 		encode_access(xdr, args->access, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2340) 	encode_getfattr_open(xdr, args->bitmask, args->open_bitmap, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2341) 	if (args->lg_args) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2342) 		encode_layoutget(xdr, args->lg_args, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2343) 		rpc_prepare_reply_pages(req, args->lg_args->layout.pages, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2344) 					args->lg_args->layout.pglen,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2345) 					hdr.replen);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2346) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2347) 	encode_nops(&hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2348) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2349) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2350) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2351)  * Encode an OPEN_CONFIRM request
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2352)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2353) static void nfs4_xdr_enc_open_confirm(struct rpc_rqst *req,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2354) 				      struct xdr_stream *xdr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2355) 				      const void *data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2356) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2357) 	const struct nfs_open_confirmargs *args = data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2358) 	struct compound_hdr hdr = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2359) 		.nops   = 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2360) 	};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2361) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2362) 	encode_compound_hdr(xdr, req, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2363) 	encode_putfh(xdr, args->fh, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2364) 	encode_open_confirm(xdr, args, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2365) 	encode_nops(&hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2366) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2367) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2368) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2369)  * Encode an OPEN request with no attributes.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2370)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2371) static void nfs4_xdr_enc_open_noattr(struct rpc_rqst *req,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2372) 				     struct xdr_stream *xdr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2373) 				     const void *data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2374) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2375) 	const struct nfs_openargs *args = data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2376) 	struct compound_hdr hdr = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2377) 		.minorversion = nfs4_xdr_minorversion(&args->seq_args),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2378) 	};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2379) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2380) 	encode_compound_hdr(xdr, req, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2381) 	encode_sequence(xdr, &args->seq_args, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2382) 	encode_putfh(xdr, args->fh, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2383) 	encode_open(xdr, args, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2384) 	if (args->access)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2385) 		encode_access(xdr, args->access, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2386) 	encode_getfattr_open(xdr, args->bitmask, args->open_bitmap, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2387) 	if (args->lg_args) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2388) 		encode_layoutget(xdr, args->lg_args, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2389) 		rpc_prepare_reply_pages(req, args->lg_args->layout.pages, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2390) 					args->lg_args->layout.pglen,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2391) 					hdr.replen);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2392) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2393) 	encode_nops(&hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2394) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2395) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2396) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2397)  * Encode an OPEN_DOWNGRADE request
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2398)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2399) static void nfs4_xdr_enc_open_downgrade(struct rpc_rqst *req,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2400) 					struct xdr_stream *xdr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2401) 					const void *data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2402) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2403) 	const struct nfs_closeargs *args = data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2404) 	struct compound_hdr hdr = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2405) 		.minorversion = nfs4_xdr_minorversion(&args->seq_args),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2406) 	};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2407) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2408) 	encode_compound_hdr(xdr, req, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2409) 	encode_sequence(xdr, &args->seq_args, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2410) 	encode_putfh(xdr, args->fh, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2411) 	if (args->lr_args)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2412) 		encode_layoutreturn(xdr, args->lr_args, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2413) 	encode_open_downgrade(xdr, args, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2414) 	encode_nops(&hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2415) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2416) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2417) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2418)  * Encode a LOCK request
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2419)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2420) static void nfs4_xdr_enc_lock(struct rpc_rqst *req, struct xdr_stream *xdr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2421) 			      const void *data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2422) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2423) 	const struct nfs_lock_args *args = data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2424) 	struct compound_hdr hdr = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2425) 		.minorversion = nfs4_xdr_minorversion(&args->seq_args),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2426) 	};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2427) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2428) 	encode_compound_hdr(xdr, req, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2429) 	encode_sequence(xdr, &args->seq_args, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2430) 	encode_putfh(xdr, args->fh, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2431) 	encode_lock(xdr, args, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2432) 	encode_nops(&hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2433) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2434) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2435) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2436)  * Encode a LOCKT request
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2437)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2438) static void nfs4_xdr_enc_lockt(struct rpc_rqst *req, struct xdr_stream *xdr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2439) 			       const void *data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2440) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2441) 	const struct nfs_lockt_args *args = data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2442) 	struct compound_hdr hdr = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2443) 		.minorversion = nfs4_xdr_minorversion(&args->seq_args),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2444) 	};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2445) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2446) 	encode_compound_hdr(xdr, req, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2447) 	encode_sequence(xdr, &args->seq_args, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2448) 	encode_putfh(xdr, args->fh, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2449) 	encode_lockt(xdr, args, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2450) 	encode_nops(&hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2451) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2452) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2453) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2454)  * Encode a LOCKU request
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2455)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2456) static void nfs4_xdr_enc_locku(struct rpc_rqst *req, struct xdr_stream *xdr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2457) 			       const void *data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2458) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2459) 	const struct nfs_locku_args *args = data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2460) 	struct compound_hdr hdr = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2461) 		.minorversion = nfs4_xdr_minorversion(&args->seq_args),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2462) 	};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2463) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2464) 	encode_compound_hdr(xdr, req, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2465) 	encode_sequence(xdr, &args->seq_args, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2466) 	encode_putfh(xdr, args->fh, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2467) 	encode_locku(xdr, args, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2468) 	encode_nops(&hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2469) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2470) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2471) static void nfs4_xdr_enc_release_lockowner(struct rpc_rqst *req,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2472) 					   struct xdr_stream *xdr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2473) 					   const void *data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2474) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2475) 	const struct nfs_release_lockowner_args *args = data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2476) 	struct compound_hdr hdr = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2477) 		.minorversion = 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2478) 	};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2479) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2480) 	encode_compound_hdr(xdr, req, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2481) 	encode_release_lockowner(xdr, &args->lock_owner, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2482) 	encode_nops(&hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2483) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2484) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2485) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2486)  * Encode a READLINK request
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2487)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2488) static void nfs4_xdr_enc_readlink(struct rpc_rqst *req, struct xdr_stream *xdr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2489) 				  const void *data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2490) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2491) 	const struct nfs4_readlink *args = data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2492) 	struct compound_hdr hdr = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2493) 		.minorversion = nfs4_xdr_minorversion(&args->seq_args),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2494) 	};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2495) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2496) 	encode_compound_hdr(xdr, req, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2497) 	encode_sequence(xdr, &args->seq_args, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2498) 	encode_putfh(xdr, args->fh, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2499) 	encode_readlink(xdr, args, req, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2500) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2501) 	rpc_prepare_reply_pages(req, args->pages, args->pgbase,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2502) 				args->pglen, hdr.replen);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2503) 	encode_nops(&hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2504) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2505) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2506) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2507)  * Encode a READDIR request
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2508)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2509) static void nfs4_xdr_enc_readdir(struct rpc_rqst *req, struct xdr_stream *xdr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2510) 				 const void *data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2511) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2512) 	const struct nfs4_readdir_arg *args = data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2513) 	struct compound_hdr hdr = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2514) 		.minorversion = nfs4_xdr_minorversion(&args->seq_args),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2515) 	};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2516) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2517) 	encode_compound_hdr(xdr, req, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2518) 	encode_sequence(xdr, &args->seq_args, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2519) 	encode_putfh(xdr, args->fh, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2520) 	encode_readdir(xdr, args, req, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2521) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2522) 	rpc_prepare_reply_pages(req, args->pages, args->pgbase,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2523) 				args->count, hdr.replen);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2524) 	encode_nops(&hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2525) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2526) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2527) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2528)  * Encode a READ request
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2529)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2530) static void nfs4_xdr_enc_read(struct rpc_rqst *req, struct xdr_stream *xdr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2531) 			      const void *data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2532) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2533) 	const struct nfs_pgio_args *args = data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2534) 	struct compound_hdr hdr = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2535) 		.minorversion = nfs4_xdr_minorversion(&args->seq_args),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2536) 	};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2537) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2538) 	encode_compound_hdr(xdr, req, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2539) 	encode_sequence(xdr, &args->seq_args, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2540) 	encode_putfh(xdr, args->fh, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2541) 	encode_read(xdr, args, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2542) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2543) 	rpc_prepare_reply_pages(req, args->pages, args->pgbase,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2544) 				args->count, hdr.replen);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2545) 	req->rq_rcv_buf.flags |= XDRBUF_READ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2546) 	encode_nops(&hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2547) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2548) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2549) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2550)  * Encode an SETATTR request
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2551)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2552) static void nfs4_xdr_enc_setattr(struct rpc_rqst *req, struct xdr_stream *xdr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2553) 				 const void *data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2554) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2555) 	const struct nfs_setattrargs *args = data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2556) 	struct compound_hdr hdr = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2557) 		.minorversion = nfs4_xdr_minorversion(&args->seq_args),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2558) 	};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2559) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2560) 	encode_compound_hdr(xdr, req, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2561) 	encode_sequence(xdr, &args->seq_args, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2562) 	encode_putfh(xdr, args->fh, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2563) 	encode_setattr(xdr, args, args->server, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2564) 	encode_getfattr(xdr, args->bitmask, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2565) 	encode_nops(&hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2566) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2567) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2568) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2569)  * Encode a GETACL request
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2570)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2571) static void nfs4_xdr_enc_getacl(struct rpc_rqst *req, struct xdr_stream *xdr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2572) 				const void *data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2573) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2574) 	const struct nfs_getaclargs *args = data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2575) 	struct compound_hdr hdr = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2576) 		.minorversion = nfs4_xdr_minorversion(&args->seq_args),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2577) 	};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2578) 	const __u32 nfs4_acl_bitmap[1] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2579) 		[0] = FATTR4_WORD0_ACL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2580) 	};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2581) 	uint32_t replen;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2582) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2583) 	encode_compound_hdr(xdr, req, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2584) 	encode_sequence(xdr, &args->seq_args, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2585) 	encode_putfh(xdr, args->fh, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2586) 	replen = hdr.replen + op_decode_hdr_maxsz;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2587) 	encode_getattr(xdr, nfs4_acl_bitmap, NULL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2588) 			ARRAY_SIZE(nfs4_acl_bitmap), &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2589) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2590) 	rpc_prepare_reply_pages(req, args->acl_pages, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2591) 				args->acl_len, replen + 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2592) 	encode_nops(&hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2593) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2594) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2595) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2596)  * Encode a WRITE request
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2597)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2598) static void nfs4_xdr_enc_write(struct rpc_rqst *req, struct xdr_stream *xdr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2599) 			       const void *data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2600) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2601) 	const struct nfs_pgio_args *args = data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2602) 	struct compound_hdr hdr = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2603) 		.minorversion = nfs4_xdr_minorversion(&args->seq_args),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2604) 	};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2605) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2606) 	encode_compound_hdr(xdr, req, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2607) 	encode_sequence(xdr, &args->seq_args, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2608) 	encode_putfh(xdr, args->fh, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2609) 	encode_write(xdr, args, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2610) 	req->rq_snd_buf.flags |= XDRBUF_WRITE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2611) 	if (args->bitmask)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2612) 		encode_getfattr(xdr, args->bitmask, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2613) 	encode_nops(&hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2614) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2615) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2616) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2617)  *  a COMMIT request
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2618)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2619) static void nfs4_xdr_enc_commit(struct rpc_rqst *req, struct xdr_stream *xdr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2620) 				const void *data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2621) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2622) 	const struct nfs_commitargs *args = data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2623) 	struct compound_hdr hdr = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2624) 		.minorversion = nfs4_xdr_minorversion(&args->seq_args),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2625) 	};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2626) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2627) 	encode_compound_hdr(xdr, req, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2628) 	encode_sequence(xdr, &args->seq_args, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2629) 	encode_putfh(xdr, args->fh, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2630) 	encode_commit(xdr, args, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2631) 	encode_nops(&hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2632) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2633) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2634) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2635)  * FSINFO request
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2636)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2637) static void nfs4_xdr_enc_fsinfo(struct rpc_rqst *req, struct xdr_stream *xdr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2638) 				const void *data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2639) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2640) 	const struct nfs4_fsinfo_arg *args = data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2641) 	struct compound_hdr hdr = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2642) 		.minorversion = nfs4_xdr_minorversion(&args->seq_args),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2643) 	};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2644) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2645) 	encode_compound_hdr(xdr, req, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2646) 	encode_sequence(xdr, &args->seq_args, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2647) 	encode_putfh(xdr, args->fh, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2648) 	encode_fsinfo(xdr, args->bitmask, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2649) 	encode_nops(&hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2650) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2651) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2652) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2653)  * a PATHCONF request
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2654)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2655) static void nfs4_xdr_enc_pathconf(struct rpc_rqst *req, struct xdr_stream *xdr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2656) 				  const void *data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2657) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2658) 	const struct nfs4_pathconf_arg *args = data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2659) 	struct compound_hdr hdr = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2660) 		.minorversion = nfs4_xdr_minorversion(&args->seq_args),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2661) 	};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2662) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2663) 	encode_compound_hdr(xdr, req, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2664) 	encode_sequence(xdr, &args->seq_args, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2665) 	encode_putfh(xdr, args->fh, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2666) 	encode_getattr(xdr, nfs4_pathconf_bitmap, args->bitmask,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2667) 			ARRAY_SIZE(nfs4_pathconf_bitmap), &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2668) 	encode_nops(&hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2669) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2670) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2671) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2672)  * a STATFS request
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2673)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2674) static void nfs4_xdr_enc_statfs(struct rpc_rqst *req, struct xdr_stream *xdr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2675) 				const void *data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2676) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2677) 	const struct nfs4_statfs_arg *args = data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2678) 	struct compound_hdr hdr = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2679) 		.minorversion = nfs4_xdr_minorversion(&args->seq_args),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2680) 	};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2681) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2682) 	encode_compound_hdr(xdr, req, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2683) 	encode_sequence(xdr, &args->seq_args, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2684) 	encode_putfh(xdr, args->fh, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2685) 	encode_getattr(xdr, nfs4_statfs_bitmap, args->bitmask,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2686) 			ARRAY_SIZE(nfs4_statfs_bitmap), &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2687) 	encode_nops(&hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2688) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2689) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2690) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2691)  * GETATTR_BITMAP request
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2692)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2693) static void nfs4_xdr_enc_server_caps(struct rpc_rqst *req,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2694) 				     struct xdr_stream *xdr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2695) 				     const void *data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2696) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2697) 	const struct nfs4_server_caps_arg *args = data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2698) 	const u32 *bitmask = args->bitmask;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2699) 	struct compound_hdr hdr = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2700) 		.minorversion = nfs4_xdr_minorversion(&args->seq_args),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2701) 	};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2702) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2703) 	encode_compound_hdr(xdr, req, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2704) 	encode_sequence(xdr, &args->seq_args, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2705) 	encode_putfh(xdr, args->fhandle, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2706) 	encode_getattr(xdr, bitmask, NULL, 3, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2707) 	encode_nops(&hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2708) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2709) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2710) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2711)  * a RENEW request
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2712)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2713) static void nfs4_xdr_enc_renew(struct rpc_rqst *req, struct xdr_stream *xdr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2714) 			       const void *data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2715) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2716) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2717) 	const struct nfs_client *clp = data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2718) 	struct compound_hdr hdr = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2719) 		.nops	= 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2720) 	};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2721) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2722) 	encode_compound_hdr(xdr, req, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2723) 	encode_renew(xdr, clp->cl_clientid, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2724) 	encode_nops(&hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2725) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2726) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2727) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2728)  * a SETCLIENTID request
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2729)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2730) static void nfs4_xdr_enc_setclientid(struct rpc_rqst *req,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2731) 				     struct xdr_stream *xdr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2732) 				     const void *data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2733) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2734) 	const struct nfs4_setclientid *sc = data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2735) 	struct compound_hdr hdr = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2736) 		.nops	= 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2737) 	};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2738) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2739) 	encode_compound_hdr(xdr, req, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2740) 	encode_setclientid(xdr, sc, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2741) 	encode_nops(&hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2742) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2743) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2744) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2745)  * a SETCLIENTID_CONFIRM request
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2746)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2747) static void nfs4_xdr_enc_setclientid_confirm(struct rpc_rqst *req,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2748) 					     struct xdr_stream *xdr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2749) 					     const void *data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2750) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2751) 	const struct nfs4_setclientid_res *arg = data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2752) 	struct compound_hdr hdr = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2753) 		.nops	= 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2754) 	};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2755) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2756) 	encode_compound_hdr(xdr, req, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2757) 	encode_setclientid_confirm(xdr, arg, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2758) 	encode_nops(&hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2759) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2760) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2761) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2762)  * DELEGRETURN request
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2763)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2764) static void nfs4_xdr_enc_delegreturn(struct rpc_rqst *req,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2765) 				     struct xdr_stream *xdr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2766) 				     const void *data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2767) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2768) 	const struct nfs4_delegreturnargs *args = data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2769) 	struct compound_hdr hdr = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2770) 		.minorversion = nfs4_xdr_minorversion(&args->seq_args),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2771) 	};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2772) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2773) 	encode_compound_hdr(xdr, req, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2774) 	encode_sequence(xdr, &args->seq_args, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2775) 	encode_putfh(xdr, args->fhandle, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2776) 	if (args->lr_args)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2777) 		encode_layoutreturn(xdr, args->lr_args, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2778) 	if (args->bitmask)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2779) 		encode_getfattr(xdr, args->bitmask, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2780) 	encode_delegreturn(xdr, args->stateid, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2781) 	encode_nops(&hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2782) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2783) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2784) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2785)  * Encode FS_LOCATIONS request
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2786)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2787) static void nfs4_xdr_enc_fs_locations(struct rpc_rqst *req,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2788) 				      struct xdr_stream *xdr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2789) 				      const void *data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2790) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2791) 	const struct nfs4_fs_locations_arg *args = data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2792) 	struct compound_hdr hdr = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2793) 		.minorversion = nfs4_xdr_minorversion(&args->seq_args),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2794) 	};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2795) 	uint32_t replen;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2796) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2797) 	encode_compound_hdr(xdr, req, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2798) 	encode_sequence(xdr, &args->seq_args, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2799) 	if (args->migration) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2800) 		encode_putfh(xdr, args->fh, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2801) 		replen = hdr.replen;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2802) 		encode_fs_locations(xdr, args->bitmask, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2803) 		if (args->renew)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2804) 			encode_renew(xdr, args->clientid, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2805) 	} else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2806) 		encode_putfh(xdr, args->dir_fh, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2807) 		encode_lookup(xdr, args->name, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2808) 		replen = hdr.replen;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2809) 		encode_fs_locations(xdr, args->bitmask, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2810) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2811) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2812) 	rpc_prepare_reply_pages(req, (struct page **)&args->page, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2813) 				PAGE_SIZE, replen + 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2814) 	encode_nops(&hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2815) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2816) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2817) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2818)  * Encode SECINFO request
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2819)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2820) static void nfs4_xdr_enc_secinfo(struct rpc_rqst *req,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2821) 				struct xdr_stream *xdr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2822) 				const void *data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2823) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2824) 	const struct nfs4_secinfo_arg *args = data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2825) 	struct compound_hdr hdr = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2826) 		.minorversion = nfs4_xdr_minorversion(&args->seq_args),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2827) 	};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2828) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2829) 	encode_compound_hdr(xdr, req, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2830) 	encode_sequence(xdr, &args->seq_args, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2831) 	encode_putfh(xdr, args->dir_fh, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2832) 	encode_secinfo(xdr, args->name, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2833) 	encode_nops(&hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2834) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2835) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2836) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2837)  * Encode FSID_PRESENT request
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2838)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2839) static void nfs4_xdr_enc_fsid_present(struct rpc_rqst *req,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2840) 				      struct xdr_stream *xdr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2841) 				      const void *data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2842) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2843) 	const struct nfs4_fsid_present_arg *args = data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2844) 	struct compound_hdr hdr = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2845) 		.minorversion = nfs4_xdr_minorversion(&args->seq_args),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2846) 	};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2847) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2848) 	encode_compound_hdr(xdr, req, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2849) 	encode_sequence(xdr, &args->seq_args, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2850) 	encode_putfh(xdr, args->fh, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2851) 	encode_getfh(xdr, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2852) 	if (args->renew)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2853) 		encode_renew(xdr, args->clientid, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2854) 	encode_nops(&hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2855) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2856) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2857) #if defined(CONFIG_NFS_V4_1)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2858) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2859)  * BIND_CONN_TO_SESSION request
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2860)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2861) static void nfs4_xdr_enc_bind_conn_to_session(struct rpc_rqst *req,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2862) 				struct xdr_stream *xdr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2863) 				const void *data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2864) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2865) 	const struct nfs41_bind_conn_to_session_args *args = data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2866) 	struct compound_hdr hdr = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2867) 		.minorversion = args->client->cl_mvops->minor_version,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2868) 	};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2869) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2870) 	encode_compound_hdr(xdr, req, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2871) 	encode_bind_conn_to_session(xdr, args, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2872) 	encode_nops(&hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2873) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2874) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2875) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2876)  * EXCHANGE_ID request
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2877)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2878) static void nfs4_xdr_enc_exchange_id(struct rpc_rqst *req,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2879) 				     struct xdr_stream *xdr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2880) 				     const void *data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2881) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2882) 	const struct nfs41_exchange_id_args *args = data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2883) 	struct compound_hdr hdr = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2884) 		.minorversion = args->client->cl_mvops->minor_version,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2885) 	};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2886) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2887) 	encode_compound_hdr(xdr, req, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2888) 	encode_exchange_id(xdr, args, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2889) 	encode_nops(&hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2890) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2891) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2892) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2893)  * a CREATE_SESSION request
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2894)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2895) static void nfs4_xdr_enc_create_session(struct rpc_rqst *req,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2896) 					struct xdr_stream *xdr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2897) 					const void *data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2898) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2899) 	const struct nfs41_create_session_args *args = data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2900) 	struct compound_hdr hdr = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2901) 		.minorversion = args->client->cl_mvops->minor_version,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2902) 	};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2903) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2904) 	encode_compound_hdr(xdr, req, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2905) 	encode_create_session(xdr, args, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2906) 	encode_nops(&hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2907) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2908) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2909) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2910)  * a DESTROY_SESSION request
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2911)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2912) static void nfs4_xdr_enc_destroy_session(struct rpc_rqst *req,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2913) 					 struct xdr_stream *xdr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2914) 					 const void *data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2915) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2916) 	const struct nfs4_session *session = data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2917) 	struct compound_hdr hdr = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2918) 		.minorversion = session->clp->cl_mvops->minor_version,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2919) 	};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2920) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2921) 	encode_compound_hdr(xdr, req, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2922) 	encode_destroy_session(xdr, session, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2923) 	encode_nops(&hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2924) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2925) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2926) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2927)  * a DESTROY_CLIENTID request
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2928)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2929) static void nfs4_xdr_enc_destroy_clientid(struct rpc_rqst *req,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2930) 					 struct xdr_stream *xdr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2931) 					 const void *data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2932) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2933) 	const struct nfs_client *clp = data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2934) 	struct compound_hdr hdr = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2935) 		.minorversion = clp->cl_mvops->minor_version,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2936) 	};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2937) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2938) 	encode_compound_hdr(xdr, req, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2939) 	encode_destroy_clientid(xdr, clp->cl_clientid, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2940) 	encode_nops(&hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2941) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2942) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2943) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2944)  * a SEQUENCE request
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2945)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2946) static void nfs4_xdr_enc_sequence(struct rpc_rqst *req, struct xdr_stream *xdr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2947) 				  const void *data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2948) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2949) 	const struct nfs4_sequence_args *args = data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2950) 	struct compound_hdr hdr = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2951) 		.minorversion = nfs4_xdr_minorversion(args),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2952) 	};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2953) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2954) 	encode_compound_hdr(xdr, req, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2955) 	encode_sequence(xdr, args, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2956) 	encode_nops(&hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2957) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2958) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2959) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2960) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2961) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2962)  * a GET_LEASE_TIME request
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2963)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2964) static void nfs4_xdr_enc_get_lease_time(struct rpc_rqst *req,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2965) 					struct xdr_stream *xdr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2966) 					const void *data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2967) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2968) 	const struct nfs4_get_lease_time_args *args = data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2969) 	struct compound_hdr hdr = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2970) 		.minorversion = nfs4_xdr_minorversion(&args->la_seq_args),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2971) 	};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2972) 	const u32 lease_bitmap[3] = { FATTR4_WORD0_LEASE_TIME };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2973) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2974) 	encode_compound_hdr(xdr, req, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2975) 	encode_sequence(xdr, &args->la_seq_args, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2976) 	encode_putrootfh(xdr, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2977) 	encode_fsinfo(xdr, lease_bitmap, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2978) 	encode_nops(&hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2979) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2980) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2981) #ifdef CONFIG_NFS_V4_1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2982) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2983) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2984)  * a RECLAIM_COMPLETE request
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2985)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2986) static void nfs4_xdr_enc_reclaim_complete(struct rpc_rqst *req,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2987) 					  struct xdr_stream *xdr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2988) 					  const void *data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2989) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2990) 	const struct nfs41_reclaim_complete_args *args = data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2991) 	struct compound_hdr hdr = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2992) 		.minorversion = nfs4_xdr_minorversion(&args->seq_args)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2993) 	};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2994) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2995) 	encode_compound_hdr(xdr, req, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2996) 	encode_sequence(xdr, &args->seq_args, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2997) 	encode_reclaim_complete(xdr, args, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2998) 	encode_nops(&hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2999) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3000) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3001) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3002)  * Encode GETDEVICEINFO request
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3003)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3004) static void nfs4_xdr_enc_getdeviceinfo(struct rpc_rqst *req,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3005) 				       struct xdr_stream *xdr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3006) 				       const void *data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3007) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3008) 	const struct nfs4_getdeviceinfo_args *args = data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3009) 	struct compound_hdr hdr = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3010) 		.minorversion = nfs4_xdr_minorversion(&args->seq_args),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3011) 	};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3012) 	uint32_t replen;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3013) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3014) 	encode_compound_hdr(xdr, req, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3015) 	encode_sequence(xdr, &args->seq_args, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3016) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3017) 	replen = hdr.replen + op_decode_hdr_maxsz;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3018) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3019) 	encode_getdeviceinfo(xdr, args, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3020) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3021) 	/* set up reply kvec. device_addr4 opaque data is read into the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3022) 	 * pages */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3023) 	rpc_prepare_reply_pages(req, args->pdev->pages, args->pdev->pgbase,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3024) 				args->pdev->pglen, replen + 2 + 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3025) 	encode_nops(&hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3026) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3027) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3028) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3029)  *  Encode LAYOUTGET request
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3030)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3031) static void nfs4_xdr_enc_layoutget(struct rpc_rqst *req,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3032) 				   struct xdr_stream *xdr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3033) 				   const void *data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3034) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3035) 	const struct nfs4_layoutget_args *args = data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3036) 	struct compound_hdr hdr = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3037) 		.minorversion = nfs4_xdr_minorversion(&args->seq_args),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3038) 	};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3039) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3040) 	encode_compound_hdr(xdr, req, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3041) 	encode_sequence(xdr, &args->seq_args, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3042) 	encode_putfh(xdr, NFS_FH(args->inode), &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3043) 	encode_layoutget(xdr, args, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3044) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3045) 	rpc_prepare_reply_pages(req, args->layout.pages, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3046) 				args->layout.pglen, hdr.replen);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3047) 	encode_nops(&hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3048) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3049) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3050) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3051)  *  Encode LAYOUTCOMMIT request
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3052)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3053) static void nfs4_xdr_enc_layoutcommit(struct rpc_rqst *req,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3054) 				      struct xdr_stream *xdr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3055) 				      const void *priv)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3056) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3057) 	const struct nfs4_layoutcommit_args *args = priv;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3058) 	struct nfs4_layoutcommit_data *data =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3059) 		container_of(args, struct nfs4_layoutcommit_data, args);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3060) 	struct compound_hdr hdr = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3061) 		.minorversion = nfs4_xdr_minorversion(&args->seq_args),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3062) 	};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3063) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3064) 	encode_compound_hdr(xdr, req, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3065) 	encode_sequence(xdr, &args->seq_args, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3066) 	encode_putfh(xdr, NFS_FH(args->inode), &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3067) 	encode_layoutcommit(xdr, data->args.inode, args, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3068) 	encode_getfattr(xdr, args->bitmask, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3069) 	encode_nops(&hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3070) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3071) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3072) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3073)  * Encode LAYOUTRETURN request
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3074)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3075) static void nfs4_xdr_enc_layoutreturn(struct rpc_rqst *req,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3076) 				      struct xdr_stream *xdr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3077) 				      const void *data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3078) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3079) 	const struct nfs4_layoutreturn_args *args = data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3080) 	struct compound_hdr hdr = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3081) 		.minorversion = nfs4_xdr_minorversion(&args->seq_args),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3082) 	};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3083) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3084) 	encode_compound_hdr(xdr, req, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3085) 	encode_sequence(xdr, &args->seq_args, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3086) 	encode_putfh(xdr, NFS_FH(args->inode), &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3087) 	encode_layoutreturn(xdr, args, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3088) 	encode_nops(&hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3089) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3090) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3091) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3092)  * Encode SECINFO_NO_NAME request
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3093)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3094) static void nfs4_xdr_enc_secinfo_no_name(struct rpc_rqst *req,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3095) 					struct xdr_stream *xdr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3096) 					const void *data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3097) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3098) 	const struct nfs41_secinfo_no_name_args *args = data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3099) 	struct compound_hdr hdr = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3100) 		.minorversion = nfs4_xdr_minorversion(&args->seq_args),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3101) 	};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3102) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3103) 	encode_compound_hdr(xdr, req, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3104) 	encode_sequence(xdr, &args->seq_args, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3105) 	encode_putrootfh(xdr, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3106) 	encode_secinfo_no_name(xdr, args, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3107) 	encode_nops(&hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3108) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3109) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3110) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3111)  *  Encode TEST_STATEID request
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3112)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3113) static void nfs4_xdr_enc_test_stateid(struct rpc_rqst *req,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3114) 				      struct xdr_stream *xdr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3115) 				      const void *data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3116) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3117) 	const struct nfs41_test_stateid_args *args = data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3118) 	struct compound_hdr hdr = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3119) 		.minorversion = nfs4_xdr_minorversion(&args->seq_args),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3120) 	};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3121) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3122) 	encode_compound_hdr(xdr, req, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3123) 	encode_sequence(xdr, &args->seq_args, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3124) 	encode_test_stateid(xdr, args, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3125) 	encode_nops(&hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3126) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3127) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3128) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3129)  *  Encode FREE_STATEID request
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3130)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3131) static void nfs4_xdr_enc_free_stateid(struct rpc_rqst *req,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3132) 				     struct xdr_stream *xdr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3133) 				     const void *data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3134) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3135) 	const struct nfs41_free_stateid_args *args = data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3136) 	struct compound_hdr hdr = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3137) 		.minorversion = nfs4_xdr_minorversion(&args->seq_args),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3138) 	};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3139) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3140) 	encode_compound_hdr(xdr, req, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3141) 	encode_sequence(xdr, &args->seq_args, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3142) 	encode_free_stateid(xdr, args, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3143) 	encode_nops(&hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3144) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3145) #endif /* CONFIG_NFS_V4_1 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3146) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3147) static int decode_opaque_inline(struct xdr_stream *xdr, unsigned int *len, char **string)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3148) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3149) 	ssize_t ret = xdr_stream_decode_opaque_inline(xdr, (void **)string,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3150) 			NFS4_OPAQUE_LIMIT);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3151) 	if (unlikely(ret < 0))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3152) 		return -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3153) 	*len = ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3154) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3155) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3156) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3157) static int decode_compound_hdr(struct xdr_stream *xdr, struct compound_hdr *hdr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3158) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3159) 	__be32 *p;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3160) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3161) 	p = xdr_inline_decode(xdr, 8);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3162) 	if (unlikely(!p))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3163) 		return -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3164) 	hdr->status = be32_to_cpup(p++);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3165) 	hdr->taglen = be32_to_cpup(p);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3166) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3167) 	p = xdr_inline_decode(xdr, hdr->taglen + 4);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3168) 	if (unlikely(!p))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3169) 		return -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3170) 	hdr->tag = (char *)p;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3171) 	p += XDR_QUADLEN(hdr->taglen);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3172) 	hdr->nops = be32_to_cpup(p);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3173) 	if (unlikely(hdr->nops < 1))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3174) 		return nfs4_stat_to_errno(hdr->status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3175) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3176) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3177) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3178) static bool __decode_op_hdr(struct xdr_stream *xdr, enum nfs_opnum4 expected,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3179) 		int *nfs_retval)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3180) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3181) 	__be32 *p;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3182) 	uint32_t opnum;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3183) 	int32_t nfserr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3184) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3185) 	p = xdr_inline_decode(xdr, 8);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3186) 	if (unlikely(!p))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3187) 		goto out_overflow;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3188) 	opnum = be32_to_cpup(p++);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3189) 	if (unlikely(opnum != expected))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3190) 		goto out_bad_operation;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3191) 	if (unlikely(*p != cpu_to_be32(NFS_OK)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3192) 		goto out_status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3193) 	*nfs_retval = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3194) 	return true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3195) out_status:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3196) 	nfserr = be32_to_cpup(p);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3197) 	trace_nfs4_xdr_status(xdr, opnum, nfserr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3198) 	*nfs_retval = nfs4_stat_to_errno(nfserr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3199) 	return true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3200) out_bad_operation:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3201) 	dprintk("nfs: Server returned operation"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3202) 		" %d but we issued a request for %d\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3203) 			opnum, expected);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3204) 	*nfs_retval = -EREMOTEIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3205) 	return false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3206) out_overflow:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3207) 	*nfs_retval = -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3208) 	return false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3209) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3210) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3211) static int decode_op_hdr(struct xdr_stream *xdr, enum nfs_opnum4 expected)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3212) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3213) 	int retval;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3214) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3215) 	__decode_op_hdr(xdr, expected, &retval);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3216) 	return retval;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3217) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3218) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3219) /* Dummy routine */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3220) static int decode_ace(struct xdr_stream *xdr, void *ace)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3221) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3222) 	__be32 *p;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3223) 	unsigned int strlen;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3224) 	char *str;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3225) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3226) 	p = xdr_inline_decode(xdr, 12);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3227) 	if (unlikely(!p))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3228) 		return -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3229) 	return decode_opaque_inline(xdr, &strlen, &str);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3230) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3231) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3232) static ssize_t
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3233) decode_bitmap4(struct xdr_stream *xdr, uint32_t *bitmap, size_t sz)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3234) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3235) 	ssize_t ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3236) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3237) 	ret = xdr_stream_decode_uint32_array(xdr, bitmap, sz);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3238) 	if (likely(ret >= 0))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3239) 		return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3240) 	if (ret != -EMSGSIZE)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3241) 		return -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3242) 	return sz;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3243) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3244) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3245) static int decode_attr_bitmap(struct xdr_stream *xdr, uint32_t *bitmap)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3246) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3247) 	ssize_t ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3248) 	ret = decode_bitmap4(xdr, bitmap, 3);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3249) 	return ret < 0 ? ret : 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3250) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3251) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3252) static int decode_attr_length(struct xdr_stream *xdr, uint32_t *attrlen, unsigned int *savep)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3253) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3254) 	__be32 *p;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3255) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3256) 	p = xdr_inline_decode(xdr, 4);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3257) 	if (unlikely(!p))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3258) 		return -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3259) 	*attrlen = be32_to_cpup(p);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3260) 	*savep = xdr_stream_pos(xdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3261) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3262) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3263) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3264) static int decode_attr_supported(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t *bitmask)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3265) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3266) 	if (likely(bitmap[0] & FATTR4_WORD0_SUPPORTED_ATTRS)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3267) 		int ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3268) 		ret = decode_attr_bitmap(xdr, bitmask);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3269) 		if (unlikely(ret < 0))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3270) 			return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3271) 		bitmap[0] &= ~FATTR4_WORD0_SUPPORTED_ATTRS;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3272) 	} else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3273) 		bitmask[0] = bitmask[1] = bitmask[2] = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3274) 	dprintk("%s: bitmask=%08x:%08x:%08x\n", __func__,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3275) 		bitmask[0], bitmask[1], bitmask[2]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3276) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3277) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3278) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3279) static int decode_attr_type(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t *type)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3280) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3281) 	__be32 *p;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3282) 	int ret = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3283) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3284) 	*type = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3285) 	if (unlikely(bitmap[0] & (FATTR4_WORD0_TYPE - 1U)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3286) 		return -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3287) 	if (likely(bitmap[0] & FATTR4_WORD0_TYPE)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3288) 		p = xdr_inline_decode(xdr, 4);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3289) 		if (unlikely(!p))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3290) 			return -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3291) 		*type = be32_to_cpup(p);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3292) 		if (*type < NF4REG || *type > NF4NAMEDATTR) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3293) 			dprintk("%s: bad type %d\n", __func__, *type);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3294) 			return -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3295) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3296) 		bitmap[0] &= ~FATTR4_WORD0_TYPE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3297) 		ret = NFS_ATTR_FATTR_TYPE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3298) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3299) 	dprintk("%s: type=0%o\n", __func__, nfs_type2fmt[*type]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3300) 	return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3301) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3302) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3303) static int decode_attr_fh_expire_type(struct xdr_stream *xdr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3304) 				      uint32_t *bitmap, uint32_t *type)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3305) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3306) 	__be32 *p;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3307) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3308) 	*type = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3309) 	if (unlikely(bitmap[0] & (FATTR4_WORD0_FH_EXPIRE_TYPE - 1U)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3310) 		return -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3311) 	if (likely(bitmap[0] & FATTR4_WORD0_FH_EXPIRE_TYPE)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3312) 		p = xdr_inline_decode(xdr, 4);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3313) 		if (unlikely(!p))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3314) 			return -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3315) 		*type = be32_to_cpup(p);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3316) 		bitmap[0] &= ~FATTR4_WORD0_FH_EXPIRE_TYPE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3317) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3318) 	dprintk("%s: expire type=0x%x\n", __func__, *type);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3319) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3320) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3321) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3322) static int decode_attr_change(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *change)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3323) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3324) 	__be32 *p;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3325) 	int ret = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3326) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3327) 	*change = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3328) 	if (unlikely(bitmap[0] & (FATTR4_WORD0_CHANGE - 1U)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3329) 		return -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3330) 	if (likely(bitmap[0] & FATTR4_WORD0_CHANGE)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3331) 		p = xdr_inline_decode(xdr, 8);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3332) 		if (unlikely(!p))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3333) 			return -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3334) 		xdr_decode_hyper(p, change);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3335) 		bitmap[0] &= ~FATTR4_WORD0_CHANGE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3336) 		ret = NFS_ATTR_FATTR_CHANGE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3337) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3338) 	dprintk("%s: change attribute=%Lu\n", __func__,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3339) 			(unsigned long long)*change);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3340) 	return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3341) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3342) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3343) static int decode_attr_size(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *size)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3344) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3345) 	__be32 *p;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3346) 	int ret = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3347) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3348) 	*size = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3349) 	if (unlikely(bitmap[0] & (FATTR4_WORD0_SIZE - 1U)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3350) 		return -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3351) 	if (likely(bitmap[0] & FATTR4_WORD0_SIZE)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3352) 		p = xdr_inline_decode(xdr, 8);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3353) 		if (unlikely(!p))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3354) 			return -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3355) 		xdr_decode_hyper(p, size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3356) 		bitmap[0] &= ~FATTR4_WORD0_SIZE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3357) 		ret = NFS_ATTR_FATTR_SIZE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3358) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3359) 	dprintk("%s: file size=%Lu\n", __func__, (unsigned long long)*size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3360) 	return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3361) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3362) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3363) static int decode_attr_link_support(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t *res)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3364) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3365) 	__be32 *p;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3366) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3367) 	*res = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3368) 	if (unlikely(bitmap[0] & (FATTR4_WORD0_LINK_SUPPORT - 1U)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3369) 		return -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3370) 	if (likely(bitmap[0] & FATTR4_WORD0_LINK_SUPPORT)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3371) 		p = xdr_inline_decode(xdr, 4);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3372) 		if (unlikely(!p))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3373) 			return -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3374) 		*res = be32_to_cpup(p);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3375) 		bitmap[0] &= ~FATTR4_WORD0_LINK_SUPPORT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3376) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3377) 	dprintk("%s: link support=%s\n", __func__, *res == 0 ? "false" : "true");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3378) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3379) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3380) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3381) static int decode_attr_symlink_support(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t *res)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3382) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3383) 	__be32 *p;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3384) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3385) 	*res = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3386) 	if (unlikely(bitmap[0] & (FATTR4_WORD0_SYMLINK_SUPPORT - 1U)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3387) 		return -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3388) 	if (likely(bitmap[0] & FATTR4_WORD0_SYMLINK_SUPPORT)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3389) 		p = xdr_inline_decode(xdr, 4);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3390) 		if (unlikely(!p))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3391) 			return -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3392) 		*res = be32_to_cpup(p);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3393) 		bitmap[0] &= ~FATTR4_WORD0_SYMLINK_SUPPORT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3394) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3395) 	dprintk("%s: symlink support=%s\n", __func__, *res == 0 ? "false" : "true");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3396) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3397) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3398) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3399) static int decode_attr_fsid(struct xdr_stream *xdr, uint32_t *bitmap, struct nfs_fsid *fsid)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3400) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3401) 	__be32 *p;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3402) 	int ret = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3403) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3404) 	fsid->major = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3405) 	fsid->minor = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3406) 	if (unlikely(bitmap[0] & (FATTR4_WORD0_FSID - 1U)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3407) 		return -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3408) 	if (likely(bitmap[0] & FATTR4_WORD0_FSID)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3409) 		p = xdr_inline_decode(xdr, 16);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3410) 		if (unlikely(!p))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3411) 			return -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3412) 		p = xdr_decode_hyper(p, &fsid->major);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3413) 		xdr_decode_hyper(p, &fsid->minor);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3414) 		bitmap[0] &= ~FATTR4_WORD0_FSID;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3415) 		ret = NFS_ATTR_FATTR_FSID;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3416) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3417) 	dprintk("%s: fsid=(0x%Lx/0x%Lx)\n", __func__,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3418) 			(unsigned long long)fsid->major,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3419) 			(unsigned long long)fsid->minor);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3420) 	return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3421) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3422) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3423) static int decode_attr_lease_time(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t *res)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3424) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3425) 	__be32 *p;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3426) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3427) 	*res = 60;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3428) 	if (unlikely(bitmap[0] & (FATTR4_WORD0_LEASE_TIME - 1U)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3429) 		return -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3430) 	if (likely(bitmap[0] & FATTR4_WORD0_LEASE_TIME)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3431) 		p = xdr_inline_decode(xdr, 4);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3432) 		if (unlikely(!p))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3433) 			return -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3434) 		*res = be32_to_cpup(p);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3435) 		bitmap[0] &= ~FATTR4_WORD0_LEASE_TIME;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3436) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3437) 	dprintk("%s: lease time=%u\n", __func__, (unsigned int)*res);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3438) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3439) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3440) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3441) static int decode_attr_error(struct xdr_stream *xdr, uint32_t *bitmap, int32_t *res)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3442) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3443) 	__be32 *p;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3444) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3445) 	if (unlikely(bitmap[0] & (FATTR4_WORD0_RDATTR_ERROR - 1U)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3446) 		return -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3447) 	if (likely(bitmap[0] & FATTR4_WORD0_RDATTR_ERROR)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3448) 		p = xdr_inline_decode(xdr, 4);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3449) 		if (unlikely(!p))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3450) 			return -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3451) 		bitmap[0] &= ~FATTR4_WORD0_RDATTR_ERROR;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3452) 		*res = -be32_to_cpup(p);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3453) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3454) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3455) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3456) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3457) static int decode_attr_exclcreat_supported(struct xdr_stream *xdr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3458) 				 uint32_t *bitmap, uint32_t *bitmask)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3459) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3460) 	if (likely(bitmap[2] & FATTR4_WORD2_SUPPATTR_EXCLCREAT)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3461) 		int ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3462) 		ret = decode_attr_bitmap(xdr, bitmask);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3463) 		if (unlikely(ret < 0))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3464) 			return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3465) 		bitmap[2] &= ~FATTR4_WORD2_SUPPATTR_EXCLCREAT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3466) 	} else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3467) 		bitmask[0] = bitmask[1] = bitmask[2] = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3468) 	dprintk("%s: bitmask=%08x:%08x:%08x\n", __func__,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3469) 		bitmask[0], bitmask[1], bitmask[2]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3470) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3471) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3472) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3473) static int decode_attr_filehandle(struct xdr_stream *xdr, uint32_t *bitmap, struct nfs_fh *fh)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3474) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3475) 	__be32 *p;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3476) 	u32 len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3477) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3478) 	if (fh != NULL)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3479) 		memset(fh, 0, sizeof(*fh));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3480) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3481) 	if (unlikely(bitmap[0] & (FATTR4_WORD0_FILEHANDLE - 1U)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3482) 		return -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3483) 	if (likely(bitmap[0] & FATTR4_WORD0_FILEHANDLE)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3484) 		p = xdr_inline_decode(xdr, 4);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3485) 		if (unlikely(!p))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3486) 			return -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3487) 		len = be32_to_cpup(p);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3488) 		if (len > NFS4_FHSIZE)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3489) 			return -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3490) 		p = xdr_inline_decode(xdr, len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3491) 		if (unlikely(!p))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3492) 			return -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3493) 		if (fh != NULL) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3494) 			memcpy(fh->data, p, len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3495) 			fh->size = len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3496) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3497) 		bitmap[0] &= ~FATTR4_WORD0_FILEHANDLE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3498) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3499) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3500) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3501) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3502) static int decode_attr_aclsupport(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t *res)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3503) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3504) 	__be32 *p;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3505) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3506) 	*res = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3507) 	if (unlikely(bitmap[0] & (FATTR4_WORD0_ACLSUPPORT - 1U)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3508) 		return -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3509) 	if (likely(bitmap[0] & FATTR4_WORD0_ACLSUPPORT)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3510) 		p = xdr_inline_decode(xdr, 4);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3511) 		if (unlikely(!p))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3512) 			return -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3513) 		*res = be32_to_cpup(p);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3514) 		bitmap[0] &= ~FATTR4_WORD0_ACLSUPPORT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3515) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3516) 	dprintk("%s: ACLs supported=%u\n", __func__, (unsigned int)*res);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3517) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3518) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3519) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3520) static int decode_attr_fileid(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *fileid)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3521) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3522) 	__be32 *p;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3523) 	int ret = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3524) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3525) 	*fileid = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3526) 	if (unlikely(bitmap[0] & (FATTR4_WORD0_FILEID - 1U)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3527) 		return -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3528) 	if (likely(bitmap[0] & FATTR4_WORD0_FILEID)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3529) 		p = xdr_inline_decode(xdr, 8);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3530) 		if (unlikely(!p))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3531) 			return -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3532) 		xdr_decode_hyper(p, fileid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3533) 		bitmap[0] &= ~FATTR4_WORD0_FILEID;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3534) 		ret = NFS_ATTR_FATTR_FILEID;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3535) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3536) 	dprintk("%s: fileid=%Lu\n", __func__, (unsigned long long)*fileid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3537) 	return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3538) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3539) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3540) static int decode_attr_mounted_on_fileid(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *fileid)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3541) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3542) 	__be32 *p;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3543) 	int ret = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3544) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3545) 	*fileid = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3546) 	if (unlikely(bitmap[1] & (FATTR4_WORD1_MOUNTED_ON_FILEID - 1U)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3547) 		return -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3548) 	if (likely(bitmap[1] & FATTR4_WORD1_MOUNTED_ON_FILEID)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3549) 		p = xdr_inline_decode(xdr, 8);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3550) 		if (unlikely(!p))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3551) 			return -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3552) 		xdr_decode_hyper(p, fileid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3553) 		bitmap[1] &= ~FATTR4_WORD1_MOUNTED_ON_FILEID;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3554) 		ret = NFS_ATTR_FATTR_MOUNTED_ON_FILEID;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3555) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3556) 	dprintk("%s: fileid=%Lu\n", __func__, (unsigned long long)*fileid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3557) 	return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3558) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3559) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3560) static int decode_attr_files_avail(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *res)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3561) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3562) 	__be32 *p;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3563) 	int status = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3564) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3565) 	*res = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3566) 	if (unlikely(bitmap[0] & (FATTR4_WORD0_FILES_AVAIL - 1U)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3567) 		return -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3568) 	if (likely(bitmap[0] & FATTR4_WORD0_FILES_AVAIL)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3569) 		p = xdr_inline_decode(xdr, 8);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3570) 		if (unlikely(!p))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3571) 			return -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3572) 		xdr_decode_hyper(p, res);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3573) 		bitmap[0] &= ~FATTR4_WORD0_FILES_AVAIL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3574) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3575) 	dprintk("%s: files avail=%Lu\n", __func__, (unsigned long long)*res);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3576) 	return status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3577) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3578) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3579) static int decode_attr_files_free(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *res)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3580) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3581) 	__be32 *p;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3582) 	int status = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3583) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3584) 	*res = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3585) 	if (unlikely(bitmap[0] & (FATTR4_WORD0_FILES_FREE - 1U)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3586) 		return -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3587) 	if (likely(bitmap[0] & FATTR4_WORD0_FILES_FREE)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3588) 		p = xdr_inline_decode(xdr, 8);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3589) 		if (unlikely(!p))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3590) 			return -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3591) 		xdr_decode_hyper(p, res);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3592) 		bitmap[0] &= ~FATTR4_WORD0_FILES_FREE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3593) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3594) 	dprintk("%s: files free=%Lu\n", __func__, (unsigned long long)*res);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3595) 	return status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3596) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3597) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3598) static int decode_attr_files_total(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *res)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3599) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3600) 	__be32 *p;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3601) 	int status = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3602) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3603) 	*res = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3604) 	if (unlikely(bitmap[0] & (FATTR4_WORD0_FILES_TOTAL - 1U)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3605) 		return -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3606) 	if (likely(bitmap[0] & FATTR4_WORD0_FILES_TOTAL)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3607) 		p = xdr_inline_decode(xdr, 8);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3608) 		if (unlikely(!p))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3609) 			return -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3610) 		xdr_decode_hyper(p, res);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3611) 		bitmap[0] &= ~FATTR4_WORD0_FILES_TOTAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3612) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3613) 	dprintk("%s: files total=%Lu\n", __func__, (unsigned long long)*res);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3614) 	return status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3615) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3616) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3617) static int decode_pathname(struct xdr_stream *xdr, struct nfs4_pathname *path)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3618) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3619) 	u32 n;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3620) 	__be32 *p;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3621) 	int status = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3622) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3623) 	p = xdr_inline_decode(xdr, 4);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3624) 	if (unlikely(!p))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3625) 		return -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3626) 	n = be32_to_cpup(p);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3627) 	if (n == 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3628) 		goto root_path;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3629) 	dprintk("pathname4: ");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3630) 	if (n > NFS4_PATHNAME_MAXCOMPONENTS) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3631) 		dprintk("cannot parse %d components in path\n", n);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3632) 		goto out_eio;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3633) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3634) 	for (path->ncomponents = 0; path->ncomponents < n; path->ncomponents++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3635) 		struct nfs4_string *component = &path->components[path->ncomponents];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3636) 		status = decode_opaque_inline(xdr, &component->len, &component->data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3637) 		if (unlikely(status != 0))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3638) 			goto out_eio;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3639) 		ifdebug (XDR)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3640) 			pr_cont("%s%.*s ",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3641) 				(path->ncomponents != n ? "/ " : ""),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3642) 				component->len, component->data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3643) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3644) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3645) 	return status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3646) root_path:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3647) /* a root pathname is sent as a zero component4 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3648) 	path->ncomponents = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3649) 	path->components[0].len=0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3650) 	path->components[0].data=NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3651) 	dprintk("pathname4: /\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3652) 	goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3653) out_eio:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3654) 	dprintk(" status %d", status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3655) 	status = -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3656) 	goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3657) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3658) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3659) static int decode_attr_fs_locations(struct xdr_stream *xdr, uint32_t *bitmap, struct nfs4_fs_locations *res)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3660) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3661) 	int n;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3662) 	__be32 *p;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3663) 	int status = -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3664) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3665) 	if (unlikely(bitmap[0] & (FATTR4_WORD0_FS_LOCATIONS -1U)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3666) 		goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3667) 	status = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3668) 	if (unlikely(!(bitmap[0] & FATTR4_WORD0_FS_LOCATIONS)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3669) 		goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3670) 	bitmap[0] &= ~FATTR4_WORD0_FS_LOCATIONS;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3671) 	status = -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3672) 	/* Ignore borken servers that return unrequested attrs */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3673) 	if (unlikely(res == NULL))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3674) 		goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3675) 	dprintk("%s: fsroot:\n", __func__);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3676) 	status = decode_pathname(xdr, &res->fs_path);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3677) 	if (unlikely(status != 0))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3678) 		goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3679) 	p = xdr_inline_decode(xdr, 4);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3680) 	if (unlikely(!p))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3681) 		goto out_eio;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3682) 	n = be32_to_cpup(p);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3683) 	for (res->nlocations = 0; res->nlocations < n; res->nlocations++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3684) 		u32 m;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3685) 		struct nfs4_fs_location *loc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3686) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3687) 		if (res->nlocations == NFS4_FS_LOCATIONS_MAXENTRIES)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3688) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3689) 		loc = &res->locations[res->nlocations];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3690) 		p = xdr_inline_decode(xdr, 4);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3691) 		if (unlikely(!p))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3692) 			goto out_eio;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3693) 		m = be32_to_cpup(p);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3694) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3695) 		dprintk("%s: servers:\n", __func__);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3696) 		for (loc->nservers = 0; loc->nservers < m; loc->nservers++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3697) 			struct nfs4_string *server;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3698) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3699) 			if (loc->nservers == NFS4_FS_LOCATION_MAXSERVERS) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3700) 				unsigned int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3701) 				dprintk("%s: using first %u of %u servers "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3702) 					"returned for location %u\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3703) 						__func__,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3704) 						NFS4_FS_LOCATION_MAXSERVERS,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3705) 						m, res->nlocations);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3706) 				for (i = loc->nservers; i < m; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3707) 					unsigned int len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3708) 					char *data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3709) 					status = decode_opaque_inline(xdr, &len, &data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3710) 					if (unlikely(status != 0))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3711) 						goto out_eio;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3712) 				}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3713) 				break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3714) 			}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3715) 			server = &loc->servers[loc->nservers];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3716) 			status = decode_opaque_inline(xdr, &server->len, &server->data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3717) 			if (unlikely(status != 0))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3718) 				goto out_eio;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3719) 			dprintk("%s ", server->data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3720) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3721) 		status = decode_pathname(xdr, &loc->rootpath);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3722) 		if (unlikely(status != 0))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3723) 			goto out_eio;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3724) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3725) 	if (res->nlocations != 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3726) 		status = NFS_ATTR_FATTR_V4_LOCATIONS;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3727) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3728) 	dprintk("%s: fs_locations done, error = %d\n", __func__, status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3729) 	return status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3730) out_eio:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3731) 	status = -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3732) 	goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3733) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3734) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3735) static int decode_attr_maxfilesize(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *res)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3736) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3737) 	__be32 *p;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3738) 	int status = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3739) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3740) 	*res = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3741) 	if (unlikely(bitmap[0] & (FATTR4_WORD0_MAXFILESIZE - 1U)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3742) 		return -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3743) 	if (likely(bitmap[0] & FATTR4_WORD0_MAXFILESIZE)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3744) 		p = xdr_inline_decode(xdr, 8);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3745) 		if (unlikely(!p))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3746) 			return -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3747) 		xdr_decode_hyper(p, res);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3748) 		bitmap[0] &= ~FATTR4_WORD0_MAXFILESIZE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3749) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3750) 	dprintk("%s: maxfilesize=%Lu\n", __func__, (unsigned long long)*res);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3751) 	return status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3752) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3753) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3754) static int decode_attr_maxlink(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t *maxlink)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3755) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3756) 	__be32 *p;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3757) 	int status = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3758) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3759) 	*maxlink = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3760) 	if (unlikely(bitmap[0] & (FATTR4_WORD0_MAXLINK - 1U)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3761) 		return -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3762) 	if (likely(bitmap[0] & FATTR4_WORD0_MAXLINK)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3763) 		p = xdr_inline_decode(xdr, 4);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3764) 		if (unlikely(!p))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3765) 			return -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3766) 		*maxlink = be32_to_cpup(p);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3767) 		bitmap[0] &= ~FATTR4_WORD0_MAXLINK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3768) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3769) 	dprintk("%s: maxlink=%u\n", __func__, *maxlink);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3770) 	return status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3771) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3772) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3773) static int decode_attr_maxname(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t *maxname)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3774) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3775) 	__be32 *p;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3776) 	int status = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3777) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3778) 	*maxname = 1024;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3779) 	if (unlikely(bitmap[0] & (FATTR4_WORD0_MAXNAME - 1U)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3780) 		return -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3781) 	if (likely(bitmap[0] & FATTR4_WORD0_MAXNAME)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3782) 		p = xdr_inline_decode(xdr, 4);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3783) 		if (unlikely(!p))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3784) 			return -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3785) 		*maxname = be32_to_cpup(p);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3786) 		bitmap[0] &= ~FATTR4_WORD0_MAXNAME;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3787) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3788) 	dprintk("%s: maxname=%u\n", __func__, *maxname);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3789) 	return status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3790) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3791) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3792) static int decode_attr_maxread(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t *res)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3793) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3794) 	__be32 *p;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3795) 	int status = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3796) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3797) 	*res = 1024;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3798) 	if (unlikely(bitmap[0] & (FATTR4_WORD0_MAXREAD - 1U)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3799) 		return -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3800) 	if (likely(bitmap[0] & FATTR4_WORD0_MAXREAD)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3801) 		uint64_t maxread;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3802) 		p = xdr_inline_decode(xdr, 8);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3803) 		if (unlikely(!p))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3804) 			return -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3805) 		xdr_decode_hyper(p, &maxread);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3806) 		if (maxread > 0x7FFFFFFF)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3807) 			maxread = 0x7FFFFFFF;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3808) 		*res = (uint32_t)maxread;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3809) 		bitmap[0] &= ~FATTR4_WORD0_MAXREAD;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3810) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3811) 	dprintk("%s: maxread=%lu\n", __func__, (unsigned long)*res);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3812) 	return status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3813) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3814) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3815) static int decode_attr_maxwrite(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t *res)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3816) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3817) 	__be32 *p;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3818) 	int status = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3819) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3820) 	*res = 1024;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3821) 	if (unlikely(bitmap[0] & (FATTR4_WORD0_MAXWRITE - 1U)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3822) 		return -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3823) 	if (likely(bitmap[0] & FATTR4_WORD0_MAXWRITE)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3824) 		uint64_t maxwrite;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3825) 		p = xdr_inline_decode(xdr, 8);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3826) 		if (unlikely(!p))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3827) 			return -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3828) 		xdr_decode_hyper(p, &maxwrite);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3829) 		if (maxwrite > 0x7FFFFFFF)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3830) 			maxwrite = 0x7FFFFFFF;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3831) 		*res = (uint32_t)maxwrite;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3832) 		bitmap[0] &= ~FATTR4_WORD0_MAXWRITE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3833) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3834) 	dprintk("%s: maxwrite=%lu\n", __func__, (unsigned long)*res);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3835) 	return status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3836) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3837) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3838) static int decode_attr_mode(struct xdr_stream *xdr, uint32_t *bitmap, umode_t *mode)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3839) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3840) 	uint32_t tmp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3841) 	__be32 *p;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3842) 	int ret = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3843) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3844) 	*mode = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3845) 	if (unlikely(bitmap[1] & (FATTR4_WORD1_MODE - 1U)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3846) 		return -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3847) 	if (likely(bitmap[1] & FATTR4_WORD1_MODE)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3848) 		p = xdr_inline_decode(xdr, 4);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3849) 		if (unlikely(!p))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3850) 			return -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3851) 		tmp = be32_to_cpup(p);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3852) 		*mode = tmp & ~S_IFMT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3853) 		bitmap[1] &= ~FATTR4_WORD1_MODE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3854) 		ret = NFS_ATTR_FATTR_MODE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3855) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3856) 	dprintk("%s: file mode=0%o\n", __func__, (unsigned int)*mode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3857) 	return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3858) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3859) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3860) static int decode_attr_nlink(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t *nlink)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3861) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3862) 	__be32 *p;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3863) 	int ret = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3864) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3865) 	*nlink = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3866) 	if (unlikely(bitmap[1] & (FATTR4_WORD1_NUMLINKS - 1U)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3867) 		return -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3868) 	if (likely(bitmap[1] & FATTR4_WORD1_NUMLINKS)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3869) 		p = xdr_inline_decode(xdr, 4);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3870) 		if (unlikely(!p))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3871) 			return -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3872) 		*nlink = be32_to_cpup(p);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3873) 		bitmap[1] &= ~FATTR4_WORD1_NUMLINKS;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3874) 		ret = NFS_ATTR_FATTR_NLINK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3875) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3876) 	dprintk("%s: nlink=%u\n", __func__, (unsigned int)*nlink);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3877) 	return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3878) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3879) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3880) static ssize_t decode_nfs4_string(struct xdr_stream *xdr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3881) 		struct nfs4_string *name, gfp_t gfp_flags)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3882) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3883) 	ssize_t ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3884) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3885) 	ret = xdr_stream_decode_string_dup(xdr, &name->data,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3886) 			XDR_MAX_NETOBJ, gfp_flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3887) 	name->len = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3888) 	if (ret > 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3889) 		name->len = ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3890) 	return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3891) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3892) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3893) static int decode_attr_owner(struct xdr_stream *xdr, uint32_t *bitmap,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3894) 		const struct nfs_server *server, kuid_t *uid,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3895) 		struct nfs4_string *owner_name)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3896) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3897) 	ssize_t len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3898) 	char *p;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3899) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3900) 	*uid = make_kuid(&init_user_ns, -2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3901) 	if (unlikely(bitmap[1] & (FATTR4_WORD1_OWNER - 1U)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3902) 		return -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3903) 	if (!(bitmap[1] & FATTR4_WORD1_OWNER))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3904) 		return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3905) 	bitmap[1] &= ~FATTR4_WORD1_OWNER;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3906) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3907) 	if (owner_name != NULL) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3908) 		len = decode_nfs4_string(xdr, owner_name, GFP_NOIO);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3909) 		if (len <= 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3910) 			goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3911) 		dprintk("%s: name=%s\n", __func__, owner_name->data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3912) 		return NFS_ATTR_FATTR_OWNER_NAME;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3913) 	} else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3914) 		len = xdr_stream_decode_opaque_inline(xdr, (void **)&p,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3915) 				XDR_MAX_NETOBJ);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3916) 		if (len <= 0 || nfs_map_name_to_uid(server, p, len, uid) != 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3917) 			goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3918) 		dprintk("%s: uid=%d\n", __func__, (int)from_kuid(&init_user_ns, *uid));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3919) 		return NFS_ATTR_FATTR_OWNER;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3920) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3921) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3922) 	if (len == -EBADMSG)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3923) 		return -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3924) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3925) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3926) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3927) static int decode_attr_group(struct xdr_stream *xdr, uint32_t *bitmap,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3928) 		const struct nfs_server *server, kgid_t *gid,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3929) 		struct nfs4_string *group_name)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3930) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3931) 	ssize_t len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3932) 	char *p;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3933) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3934) 	*gid = make_kgid(&init_user_ns, -2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3935) 	if (unlikely(bitmap[1] & (FATTR4_WORD1_OWNER_GROUP - 1U)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3936) 		return -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3937) 	if (!(bitmap[1] & FATTR4_WORD1_OWNER_GROUP))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3938) 		return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3939) 	bitmap[1] &= ~FATTR4_WORD1_OWNER_GROUP;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3940) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3941) 	if (group_name != NULL) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3942) 		len = decode_nfs4_string(xdr, group_name, GFP_NOIO);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3943) 		if (len <= 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3944) 			goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3945) 		dprintk("%s: name=%s\n", __func__, group_name->data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3946) 		return NFS_ATTR_FATTR_GROUP_NAME;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3947) 	} else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3948) 		len = xdr_stream_decode_opaque_inline(xdr, (void **)&p,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3949) 				XDR_MAX_NETOBJ);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3950) 		if (len <= 0 || nfs_map_group_to_gid(server, p, len, gid) != 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3951) 			goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3952) 		dprintk("%s: gid=%d\n", __func__, (int)from_kgid(&init_user_ns, *gid));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3953) 		return NFS_ATTR_FATTR_GROUP;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3954) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3955) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3956) 	if (len == -EBADMSG)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3957) 		return -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3958) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3959) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3960) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3961) static int decode_attr_rdev(struct xdr_stream *xdr, uint32_t *bitmap, dev_t *rdev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3962) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3963) 	uint32_t major = 0, minor = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3964) 	__be32 *p;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3965) 	int ret = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3966) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3967) 	*rdev = MKDEV(0,0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3968) 	if (unlikely(bitmap[1] & (FATTR4_WORD1_RAWDEV - 1U)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3969) 		return -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3970) 	if (likely(bitmap[1] & FATTR4_WORD1_RAWDEV)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3971) 		dev_t tmp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3972) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3973) 		p = xdr_inline_decode(xdr, 8);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3974) 		if (unlikely(!p))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3975) 			return -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3976) 		major = be32_to_cpup(p++);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3977) 		minor = be32_to_cpup(p);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3978) 		tmp = MKDEV(major, minor);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3979) 		if (MAJOR(tmp) == major && MINOR(tmp) == minor)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3980) 			*rdev = tmp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3981) 		bitmap[1] &= ~ FATTR4_WORD1_RAWDEV;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3982) 		ret = NFS_ATTR_FATTR_RDEV;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3983) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3984) 	dprintk("%s: rdev=(0x%x:0x%x)\n", __func__, major, minor);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3985) 	return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3986) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3987) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3988) static int decode_attr_space_avail(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *res)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3989) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3990) 	__be32 *p;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3991) 	int status = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3992) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3993) 	*res = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3994) 	if (unlikely(bitmap[1] & (FATTR4_WORD1_SPACE_AVAIL - 1U)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3995) 		return -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3996) 	if (likely(bitmap[1] & FATTR4_WORD1_SPACE_AVAIL)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3997) 		p = xdr_inline_decode(xdr, 8);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3998) 		if (unlikely(!p))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3999) 			return -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4000) 		xdr_decode_hyper(p, res);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4001) 		bitmap[1] &= ~FATTR4_WORD1_SPACE_AVAIL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4002) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4003) 	dprintk("%s: space avail=%Lu\n", __func__, (unsigned long long)*res);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4004) 	return status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4005) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4006) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4007) static int decode_attr_space_free(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *res)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4008) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4009) 	__be32 *p;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4010) 	int status = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4011) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4012) 	*res = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4013) 	if (unlikely(bitmap[1] & (FATTR4_WORD1_SPACE_FREE - 1U)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4014) 		return -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4015) 	if (likely(bitmap[1] & FATTR4_WORD1_SPACE_FREE)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4016) 		p = xdr_inline_decode(xdr, 8);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4017) 		if (unlikely(!p))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4018) 			return -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4019) 		xdr_decode_hyper(p, res);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4020) 		bitmap[1] &= ~FATTR4_WORD1_SPACE_FREE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4021) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4022) 	dprintk("%s: space free=%Lu\n", __func__, (unsigned long long)*res);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4023) 	return status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4024) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4025) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4026) static int decode_attr_space_total(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *res)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4027) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4028) 	__be32 *p;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4029) 	int status = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4030) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4031) 	*res = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4032) 	if (unlikely(bitmap[1] & (FATTR4_WORD1_SPACE_TOTAL - 1U)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4033) 		return -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4034) 	if (likely(bitmap[1] & FATTR4_WORD1_SPACE_TOTAL)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4035) 		p = xdr_inline_decode(xdr, 8);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4036) 		if (unlikely(!p))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4037) 			return -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4038) 		xdr_decode_hyper(p, res);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4039) 		bitmap[1] &= ~FATTR4_WORD1_SPACE_TOTAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4040) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4041) 	dprintk("%s: space total=%Lu\n", __func__, (unsigned long long)*res);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4042) 	return status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4043) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4044) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4045) static int decode_attr_space_used(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *used)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4046) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4047) 	__be32 *p;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4048) 	int ret = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4049) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4050) 	*used = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4051) 	if (unlikely(bitmap[1] & (FATTR4_WORD1_SPACE_USED - 1U)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4052) 		return -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4053) 	if (likely(bitmap[1] & FATTR4_WORD1_SPACE_USED)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4054) 		p = xdr_inline_decode(xdr, 8);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4055) 		if (unlikely(!p))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4056) 			return -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4057) 		xdr_decode_hyper(p, used);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4058) 		bitmap[1] &= ~FATTR4_WORD1_SPACE_USED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4059) 		ret = NFS_ATTR_FATTR_SPACE_USED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4060) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4061) 	dprintk("%s: space used=%Lu\n", __func__,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4062) 			(unsigned long long)*used);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4063) 	return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4064) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4065) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4066) static __be32 *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4067) xdr_decode_nfstime4(__be32 *p, struct timespec64 *t)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4068) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4069) 	__u64 sec;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4070) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4071) 	p = xdr_decode_hyper(p, &sec);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4072) 	t-> tv_sec = sec;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4073) 	t->tv_nsec = be32_to_cpup(p++);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4074) 	return p;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4075) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4076) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4077) static int decode_attr_time(struct xdr_stream *xdr, struct timespec64 *time)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4078) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4079) 	__be32 *p;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4080) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4081) 	p = xdr_inline_decode(xdr, nfstime4_maxsz << 2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4082) 	if (unlikely(!p))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4083) 		return -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4084) 	xdr_decode_nfstime4(p, time);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4085) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4086) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4087) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4088) static int decode_attr_time_access(struct xdr_stream *xdr, uint32_t *bitmap, struct timespec64 *time)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4089) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4090) 	int status = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4091) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4092) 	time->tv_sec = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4093) 	time->tv_nsec = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4094) 	if (unlikely(bitmap[1] & (FATTR4_WORD1_TIME_ACCESS - 1U)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4095) 		return -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4096) 	if (likely(bitmap[1] & FATTR4_WORD1_TIME_ACCESS)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4097) 		status = decode_attr_time(xdr, time);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4098) 		if (status == 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4099) 			status = NFS_ATTR_FATTR_ATIME;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4100) 		bitmap[1] &= ~FATTR4_WORD1_TIME_ACCESS;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4101) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4102) 	dprintk("%s: atime=%lld\n", __func__, time->tv_sec);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4103) 	return status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4104) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4105) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4106) static int decode_attr_time_metadata(struct xdr_stream *xdr, uint32_t *bitmap, struct timespec64 *time)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4107) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4108) 	int status = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4109) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4110) 	time->tv_sec = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4111) 	time->tv_nsec = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4112) 	if (unlikely(bitmap[1] & (FATTR4_WORD1_TIME_METADATA - 1U)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4113) 		return -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4114) 	if (likely(bitmap[1] & FATTR4_WORD1_TIME_METADATA)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4115) 		status = decode_attr_time(xdr, time);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4116) 		if (status == 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4117) 			status = NFS_ATTR_FATTR_CTIME;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4118) 		bitmap[1] &= ~FATTR4_WORD1_TIME_METADATA;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4119) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4120) 	dprintk("%s: ctime=%lld\n", __func__, time->tv_sec);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4121) 	return status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4122) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4123) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4124) static int decode_attr_time_delta(struct xdr_stream *xdr, uint32_t *bitmap,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4125) 				  struct timespec64 *time)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4126) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4127) 	int status = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4128) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4129) 	time->tv_sec = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4130) 	time->tv_nsec = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4131) 	if (unlikely(bitmap[1] & (FATTR4_WORD1_TIME_DELTA - 1U)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4132) 		return -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4133) 	if (likely(bitmap[1] & FATTR4_WORD1_TIME_DELTA)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4134) 		status = decode_attr_time(xdr, time);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4135) 		bitmap[1] &= ~FATTR4_WORD1_TIME_DELTA;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4136) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4137) 	dprintk("%s: time_delta=%lld %ld\n", __func__, time->tv_sec,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4138) 		time->tv_nsec);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4139) 	return status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4140) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4141) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4142) static int decode_attr_security_label(struct xdr_stream *xdr, uint32_t *bitmap,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4143) 					struct nfs4_label *label)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4144) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4145) 	uint32_t pi = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4146) 	uint32_t lfs = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4147) 	__u32 len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4148) 	__be32 *p;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4149) 	int status = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4150) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4151) 	if (unlikely(bitmap[2] & (FATTR4_WORD2_SECURITY_LABEL - 1U)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4152) 		return -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4153) 	if (likely(bitmap[2] & FATTR4_WORD2_SECURITY_LABEL)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4154) 		p = xdr_inline_decode(xdr, 4);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4155) 		if (unlikely(!p))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4156) 			return -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4157) 		lfs = be32_to_cpup(p++);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4158) 		p = xdr_inline_decode(xdr, 4);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4159) 		if (unlikely(!p))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4160) 			return -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4161) 		pi = be32_to_cpup(p++);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4162) 		p = xdr_inline_decode(xdr, 4);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4163) 		if (unlikely(!p))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4164) 			return -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4165) 		len = be32_to_cpup(p++);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4166) 		p = xdr_inline_decode(xdr, len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4167) 		if (unlikely(!p))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4168) 			return -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4169) 		if (len < NFS4_MAXLABELLEN) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4170) 			if (label) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4171) 				if (label->len) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4172) 					if (label->len < len)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4173) 						return -ERANGE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4174) 					memcpy(label->label, p, len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4175) 				}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4176) 				label->len = len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4177) 				label->pi = pi;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4178) 				label->lfs = lfs;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4179) 				status = NFS_ATTR_FATTR_V4_SECURITY_LABEL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4180) 			}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4181) 			bitmap[2] &= ~FATTR4_WORD2_SECURITY_LABEL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4182) 		} else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4183) 			printk(KERN_WARNING "%s: label too long (%u)!\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4184) 					__func__, len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4185) 		if (label && label->label)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4186) 			dprintk("%s: label=%.*s, len=%d, PI=%d, LFS=%d\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4187) 				__func__, label->len, (char *)label->label,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4188) 				label->len, label->pi, label->lfs);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4189) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4190) 	return status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4191) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4192) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4193) static int decode_attr_time_modify(struct xdr_stream *xdr, uint32_t *bitmap, struct timespec64 *time)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4194) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4195) 	int status = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4196) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4197) 	time->tv_sec = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4198) 	time->tv_nsec = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4199) 	if (unlikely(bitmap[1] & (FATTR4_WORD1_TIME_MODIFY - 1U)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4200) 		return -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4201) 	if (likely(bitmap[1] & FATTR4_WORD1_TIME_MODIFY)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4202) 		status = decode_attr_time(xdr, time);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4203) 		if (status == 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4204) 			status = NFS_ATTR_FATTR_MTIME;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4205) 		bitmap[1] &= ~FATTR4_WORD1_TIME_MODIFY;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4206) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4207) 	dprintk("%s: mtime=%lld\n", __func__, time->tv_sec);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4208) 	return status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4209) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4210) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4211) static int decode_attr_xattrsupport(struct xdr_stream *xdr, uint32_t *bitmap,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4212) 				    uint32_t *res)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4213) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4214) 	__be32 *p;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4215) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4216) 	*res = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4217) 	if (unlikely(bitmap[2] & (FATTR4_WORD2_XATTR_SUPPORT - 1U)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4218) 		return -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4219) 	if (likely(bitmap[2] & FATTR4_WORD2_XATTR_SUPPORT)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4220) 		p = xdr_inline_decode(xdr, 4);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4221) 		if (unlikely(!p))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4222) 			return -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4223) 		*res = be32_to_cpup(p);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4224) 		bitmap[2] &= ~FATTR4_WORD2_XATTR_SUPPORT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4225) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4226) 	dprintk("%s: XATTR support=%s\n", __func__,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4227) 		*res == 0 ? "false" : "true");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4228) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4229) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4230) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4231) static int verify_attr_len(struct xdr_stream *xdr, unsigned int savep, uint32_t attrlen)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4232) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4233) 	unsigned int attrwords = XDR_QUADLEN(attrlen);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4234) 	unsigned int nwords = (xdr_stream_pos(xdr) - savep) >> 2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4235) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4236) 	if (unlikely(attrwords != nwords)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4237) 		dprintk("%s: server returned incorrect attribute length: "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4238) 			"%u %c %u\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4239) 				__func__,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4240) 				attrwords << 2,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4241) 				(attrwords < nwords) ? '<' : '>',
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4242) 				nwords << 2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4243) 		return -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4244) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4245) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4246) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4247) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4248) static int decode_change_info(struct xdr_stream *xdr, struct nfs4_change_info *cinfo)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4249) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4250) 	__be32 *p;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4251) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4252) 	p = xdr_inline_decode(xdr, 20);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4253) 	if (unlikely(!p))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4254) 		return -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4255) 	cinfo->atomic = be32_to_cpup(p++);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4256) 	p = xdr_decode_hyper(p, &cinfo->before);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4257) 	xdr_decode_hyper(p, &cinfo->after);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4258) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4259) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4260) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4261) static int decode_access(struct xdr_stream *xdr, u32 *supported, u32 *access)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4262) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4263) 	__be32 *p;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4264) 	uint32_t supp, acc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4265) 	int status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4266) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4267) 	status = decode_op_hdr(xdr, OP_ACCESS);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4268) 	if (status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4269) 		return status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4270) 	p = xdr_inline_decode(xdr, 8);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4271) 	if (unlikely(!p))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4272) 		return -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4273) 	supp = be32_to_cpup(p++);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4274) 	acc = be32_to_cpup(p);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4275) 	*supported = supp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4276) 	*access = acc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4277) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4278) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4279) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4280) static int decode_opaque_fixed(struct xdr_stream *xdr, void *buf, size_t len)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4281) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4282) 	ssize_t ret = xdr_stream_decode_opaque_fixed(xdr, buf, len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4283) 	if (unlikely(ret < 0))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4284) 		return -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4285) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4286) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4287) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4288) static int decode_stateid(struct xdr_stream *xdr, nfs4_stateid *stateid)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4289) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4290) 	return decode_opaque_fixed(xdr, stateid, NFS4_STATEID_SIZE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4291) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4292) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4293) static int decode_open_stateid(struct xdr_stream *xdr, nfs4_stateid *stateid)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4294) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4295) 	stateid->type = NFS4_OPEN_STATEID_TYPE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4296) 	return decode_stateid(xdr, stateid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4297) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4298) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4299) static int decode_lock_stateid(struct xdr_stream *xdr, nfs4_stateid *stateid)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4300) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4301) 	stateid->type = NFS4_LOCK_STATEID_TYPE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4302) 	return decode_stateid(xdr, stateid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4303) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4304) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4305) static int decode_delegation_stateid(struct xdr_stream *xdr, nfs4_stateid *stateid)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4306) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4307) 	stateid->type = NFS4_DELEGATION_STATEID_TYPE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4308) 	return decode_stateid(xdr, stateid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4309) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4310) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4311) static int decode_invalid_stateid(struct xdr_stream *xdr, nfs4_stateid *stateid)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4312) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4313) 	nfs4_stateid dummy;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4314) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4315) 	nfs4_stateid_copy(stateid, &invalid_stateid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4316) 	return decode_stateid(xdr, &dummy);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4317) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4318) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4319) static int decode_close(struct xdr_stream *xdr, struct nfs_closeres *res)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4320) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4321) 	int status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4322) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4323) 	status = decode_op_hdr(xdr, OP_CLOSE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4324) 	if (status != -EIO)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4325) 		nfs_increment_open_seqid(status, res->seqid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4326) 	if (!status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4327) 		status = decode_invalid_stateid(xdr, &res->stateid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4328) 	return status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4329) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4330) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4331) static int decode_verifier(struct xdr_stream *xdr, void *verifier)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4332) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4333) 	return decode_opaque_fixed(xdr, verifier, NFS4_VERIFIER_SIZE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4334) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4335) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4336) static int decode_write_verifier(struct xdr_stream *xdr, struct nfs_write_verifier *verifier)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4337) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4338) 	return decode_opaque_fixed(xdr, verifier->data, NFS4_VERIFIER_SIZE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4339) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4340) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4341) static int decode_commit(struct xdr_stream *xdr, struct nfs_commitres *res)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4342) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4343) 	struct nfs_writeverf *verf = res->verf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4344) 	int status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4345) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4346) 	status = decode_op_hdr(xdr, OP_COMMIT);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4347) 	if (!status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4348) 		status = decode_write_verifier(xdr, &verf->verifier);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4349) 	if (!status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4350) 		verf->committed = NFS_FILE_SYNC;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4351) 	return status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4352) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4353) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4354) static int decode_create(struct xdr_stream *xdr, struct nfs4_change_info *cinfo)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4355) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4356) 	__be32 *p;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4357) 	uint32_t bmlen;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4358) 	int status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4359) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4360) 	status = decode_op_hdr(xdr, OP_CREATE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4361) 	if (status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4362) 		return status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4363) 	if ((status = decode_change_info(xdr, cinfo)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4364) 		return status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4365) 	p = xdr_inline_decode(xdr, 4);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4366) 	if (unlikely(!p))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4367) 		return -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4368) 	bmlen = be32_to_cpup(p);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4369) 	p = xdr_inline_decode(xdr, bmlen << 2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4370) 	if (likely(p))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4371) 		return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4372) 	return -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4373) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4374) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4375) static int decode_server_caps(struct xdr_stream *xdr, struct nfs4_server_caps_res *res)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4376) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4377) 	unsigned int savep;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4378) 	uint32_t attrlen, bitmap[3] = {0};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4379) 	int status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4380) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4381) 	if ((status = decode_op_hdr(xdr, OP_GETATTR)) != 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4382) 		goto xdr_error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4383) 	if ((status = decode_attr_bitmap(xdr, bitmap)) != 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4384) 		goto xdr_error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4385) 	if ((status = decode_attr_length(xdr, &attrlen, &savep)) != 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4386) 		goto xdr_error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4387) 	if ((status = decode_attr_supported(xdr, bitmap, res->attr_bitmask)) != 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4388) 		goto xdr_error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4389) 	if ((status = decode_attr_fh_expire_type(xdr, bitmap,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4390) 						 &res->fh_expire_type)) != 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4391) 		goto xdr_error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4392) 	if ((status = decode_attr_link_support(xdr, bitmap, &res->has_links)) != 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4393) 		goto xdr_error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4394) 	if ((status = decode_attr_symlink_support(xdr, bitmap, &res->has_symlinks)) != 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4395) 		goto xdr_error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4396) 	if ((status = decode_attr_aclsupport(xdr, bitmap, &res->acl_bitmask)) != 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4397) 		goto xdr_error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4398) 	if ((status = decode_attr_exclcreat_supported(xdr, bitmap,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4399) 				res->exclcreat_bitmask)) != 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4400) 		goto xdr_error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4401) 	status = verify_attr_len(xdr, savep, attrlen);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4402) xdr_error:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4403) 	dprintk("%s: xdr returned %d!\n", __func__, -status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4404) 	return status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4405) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4406) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4407) static int decode_statfs(struct xdr_stream *xdr, struct nfs_fsstat *fsstat)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4408) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4409) 	unsigned int savep;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4410) 	uint32_t attrlen, bitmap[3] = {0};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4411) 	int status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4412) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4413) 	if ((status = decode_op_hdr(xdr, OP_GETATTR)) != 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4414) 		goto xdr_error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4415) 	if ((status = decode_attr_bitmap(xdr, bitmap)) != 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4416) 		goto xdr_error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4417) 	if ((status = decode_attr_length(xdr, &attrlen, &savep)) != 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4418) 		goto xdr_error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4419) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4420) 	if ((status = decode_attr_files_avail(xdr, bitmap, &fsstat->afiles)) != 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4421) 		goto xdr_error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4422) 	if ((status = decode_attr_files_free(xdr, bitmap, &fsstat->ffiles)) != 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4423) 		goto xdr_error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4424) 	if ((status = decode_attr_files_total(xdr, bitmap, &fsstat->tfiles)) != 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4425) 		goto xdr_error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4426) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4427) 	status = -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4428) 	if (unlikely(bitmap[0]))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4429) 		goto xdr_error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4430) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4431) 	if ((status = decode_attr_space_avail(xdr, bitmap, &fsstat->abytes)) != 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4432) 		goto xdr_error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4433) 	if ((status = decode_attr_space_free(xdr, bitmap, &fsstat->fbytes)) != 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4434) 		goto xdr_error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4435) 	if ((status = decode_attr_space_total(xdr, bitmap, &fsstat->tbytes)) != 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4436) 		goto xdr_error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4437) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4438) 	status = verify_attr_len(xdr, savep, attrlen);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4439) xdr_error:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4440) 	dprintk("%s: xdr returned %d!\n", __func__, -status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4441) 	return status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4442) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4443) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4444) static int decode_pathconf(struct xdr_stream *xdr, struct nfs_pathconf *pathconf)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4445) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4446) 	unsigned int savep;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4447) 	uint32_t attrlen, bitmap[3] = {0};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4448) 	int status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4449) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4450) 	if ((status = decode_op_hdr(xdr, OP_GETATTR)) != 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4451) 		goto xdr_error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4452) 	if ((status = decode_attr_bitmap(xdr, bitmap)) != 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4453) 		goto xdr_error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4454) 	if ((status = decode_attr_length(xdr, &attrlen, &savep)) != 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4455) 		goto xdr_error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4456) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4457) 	if ((status = decode_attr_maxlink(xdr, bitmap, &pathconf->max_link)) != 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4458) 		goto xdr_error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4459) 	if ((status = decode_attr_maxname(xdr, bitmap, &pathconf->max_namelen)) != 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4460) 		goto xdr_error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4461) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4462) 	status = verify_attr_len(xdr, savep, attrlen);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4463) xdr_error:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4464) 	dprintk("%s: xdr returned %d!\n", __func__, -status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4465) 	return status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4466) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4467) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4468) static int decode_threshold_hint(struct xdr_stream *xdr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4469) 				  uint32_t *bitmap,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4470) 				  uint64_t *res,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4471) 				  uint32_t hint_bit)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4472) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4473) 	__be32 *p;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4474) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4475) 	*res = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4476) 	if (likely(bitmap[0] & hint_bit)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4477) 		p = xdr_inline_decode(xdr, 8);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4478) 		if (unlikely(!p))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4479) 			return -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4480) 		xdr_decode_hyper(p, res);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4481) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4482) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4483) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4484) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4485) static int decode_first_threshold_item4(struct xdr_stream *xdr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4486) 					struct nfs4_threshold *res)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4487) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4488) 	__be32 *p;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4489) 	unsigned int savep;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4490) 	uint32_t bitmap[3] = {0,}, attrlen;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4491) 	int status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4492) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4493) 	/* layout type */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4494) 	p = xdr_inline_decode(xdr, 4);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4495) 	if (unlikely(!p))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4496) 		return -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4497) 	res->l_type = be32_to_cpup(p);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4498) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4499) 	/* thi_hintset bitmap */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4500) 	status = decode_attr_bitmap(xdr, bitmap);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4501) 	if (status < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4502) 		goto xdr_error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4503) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4504) 	/* thi_hintlist length */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4505) 	status = decode_attr_length(xdr, &attrlen, &savep);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4506) 	if (status < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4507) 		goto xdr_error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4508) 	/* thi_hintlist */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4509) 	status = decode_threshold_hint(xdr, bitmap, &res->rd_sz, THRESHOLD_RD);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4510) 	if (status < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4511) 		goto xdr_error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4512) 	status = decode_threshold_hint(xdr, bitmap, &res->wr_sz, THRESHOLD_WR);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4513) 	if (status < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4514) 		goto xdr_error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4515) 	status = decode_threshold_hint(xdr, bitmap, &res->rd_io_sz,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4516) 				       THRESHOLD_RD_IO);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4517) 	if (status < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4518) 		goto xdr_error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4519) 	status = decode_threshold_hint(xdr, bitmap, &res->wr_io_sz,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4520) 				       THRESHOLD_WR_IO);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4521) 	if (status < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4522) 		goto xdr_error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4523) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4524) 	status = verify_attr_len(xdr, savep, attrlen);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4525) 	res->bm = bitmap[0];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4526) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4527) 	dprintk("%s bm=0x%x rd_sz=%llu wr_sz=%llu rd_io=%llu wr_io=%llu\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4528) 		 __func__, res->bm, res->rd_sz, res->wr_sz, res->rd_io_sz,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4529) 		res->wr_io_sz);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4530) xdr_error:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4531) 	dprintk("%s ret=%d!\n", __func__, status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4532) 	return status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4533) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4534) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4535) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4536)  * Thresholds on pNFS direct I/O vrs MDS I/O
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4537)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4538) static int decode_attr_mdsthreshold(struct xdr_stream *xdr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4539) 				    uint32_t *bitmap,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4540) 				    struct nfs4_threshold *res)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4541) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4542) 	__be32 *p;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4543) 	int status = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4544) 	uint32_t num;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4545) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4546) 	if (unlikely(bitmap[2] & (FATTR4_WORD2_MDSTHRESHOLD - 1U)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4547) 		return -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4548) 	if (bitmap[2] & FATTR4_WORD2_MDSTHRESHOLD) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4549) 		/* Did the server return an unrequested attribute? */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4550) 		if (unlikely(res == NULL))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4551) 			return -EREMOTEIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4552) 		p = xdr_inline_decode(xdr, 4);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4553) 		if (unlikely(!p))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4554) 			return -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4555) 		num = be32_to_cpup(p);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4556) 		if (num == 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4557) 			return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4558) 		if (num > 1)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4559) 			printk(KERN_INFO "%s: Warning: Multiple pNFS layout "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4560) 				"drivers per filesystem not supported\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4561) 				__func__);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4562) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4563) 		status = decode_first_threshold_item4(xdr, res);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4564) 		bitmap[2] &= ~FATTR4_WORD2_MDSTHRESHOLD;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4565) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4566) 	return status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4567) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4568) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4569) static int decode_getfattr_attrs(struct xdr_stream *xdr, uint32_t *bitmap,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4570) 		struct nfs_fattr *fattr, struct nfs_fh *fh,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4571) 		struct nfs4_fs_locations *fs_loc, struct nfs4_label *label,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4572) 		const struct nfs_server *server)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4573) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4574) 	int status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4575) 	umode_t fmode = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4576) 	uint32_t type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4577) 	int32_t err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4578) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4579) 	status = decode_attr_type(xdr, bitmap, &type);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4580) 	if (status < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4581) 		goto xdr_error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4582) 	fattr->mode = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4583) 	if (status != 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4584) 		fattr->mode |= nfs_type2fmt[type];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4585) 		fattr->valid |= status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4586) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4587) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4588) 	status = decode_attr_change(xdr, bitmap, &fattr->change_attr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4589) 	if (status < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4590) 		goto xdr_error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4591) 	fattr->valid |= status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4592) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4593) 	status = decode_attr_size(xdr, bitmap, &fattr->size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4594) 	if (status < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4595) 		goto xdr_error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4596) 	fattr->valid |= status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4597) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4598) 	status = decode_attr_fsid(xdr, bitmap, &fattr->fsid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4599) 	if (status < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4600) 		goto xdr_error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4601) 	fattr->valid |= status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4602) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4603) 	err = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4604) 	status = decode_attr_error(xdr, bitmap, &err);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4605) 	if (status < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4606) 		goto xdr_error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4607) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4608) 	status = decode_attr_filehandle(xdr, bitmap, fh);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4609) 	if (status < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4610) 		goto xdr_error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4611) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4612) 	status = decode_attr_fileid(xdr, bitmap, &fattr->fileid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4613) 	if (status < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4614) 		goto xdr_error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4615) 	fattr->valid |= status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4616) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4617) 	status = decode_attr_fs_locations(xdr, bitmap, fs_loc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4618) 	if (status < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4619) 		goto xdr_error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4620) 	fattr->valid |= status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4621) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4622) 	status = -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4623) 	if (unlikely(bitmap[0]))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4624) 		goto xdr_error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4625) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4626) 	status = decode_attr_mode(xdr, bitmap, &fmode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4627) 	if (status < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4628) 		goto xdr_error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4629) 	if (status != 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4630) 		fattr->mode |= fmode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4631) 		fattr->valid |= status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4632) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4633) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4634) 	status = decode_attr_nlink(xdr, bitmap, &fattr->nlink);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4635) 	if (status < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4636) 		goto xdr_error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4637) 	fattr->valid |= status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4638) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4639) 	status = decode_attr_owner(xdr, bitmap, server, &fattr->uid, fattr->owner_name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4640) 	if (status < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4641) 		goto xdr_error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4642) 	fattr->valid |= status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4643) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4644) 	status = decode_attr_group(xdr, bitmap, server, &fattr->gid, fattr->group_name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4645) 	if (status < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4646) 		goto xdr_error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4647) 	fattr->valid |= status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4648) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4649) 	status = decode_attr_rdev(xdr, bitmap, &fattr->rdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4650) 	if (status < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4651) 		goto xdr_error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4652) 	fattr->valid |= status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4653) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4654) 	status = decode_attr_space_used(xdr, bitmap, &fattr->du.nfs3.used);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4655) 	if (status < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4656) 		goto xdr_error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4657) 	fattr->valid |= status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4658) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4659) 	status = decode_attr_time_access(xdr, bitmap, &fattr->atime);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4660) 	if (status < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4661) 		goto xdr_error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4662) 	fattr->valid |= status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4663) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4664) 	status = decode_attr_time_metadata(xdr, bitmap, &fattr->ctime);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4665) 	if (status < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4666) 		goto xdr_error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4667) 	fattr->valid |= status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4668) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4669) 	status = decode_attr_time_modify(xdr, bitmap, &fattr->mtime);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4670) 	if (status < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4671) 		goto xdr_error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4672) 	fattr->valid |= status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4673) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4674) 	status = decode_attr_mounted_on_fileid(xdr, bitmap, &fattr->mounted_on_fileid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4675) 	if (status < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4676) 		goto xdr_error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4677) 	fattr->valid |= status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4678) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4679) 	status = -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4680) 	if (unlikely(bitmap[1]))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4681) 		goto xdr_error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4682) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4683) 	status = decode_attr_mdsthreshold(xdr, bitmap, fattr->mdsthreshold);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4684) 	if (status < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4685) 		goto xdr_error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4686) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4687) 	if (label) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4688) 		status = decode_attr_security_label(xdr, bitmap, label);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4689) 		if (status < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4690) 			goto xdr_error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4691) 		fattr->valid |= status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4692) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4693) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4694) xdr_error:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4695) 	dprintk("%s: xdr returned %d\n", __func__, -status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4696) 	return status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4697) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4698) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4699) static int decode_getfattr_generic(struct xdr_stream *xdr, struct nfs_fattr *fattr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4700) 		struct nfs_fh *fh, struct nfs4_fs_locations *fs_loc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4701) 		struct nfs4_label *label, const struct nfs_server *server)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4702) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4703) 	unsigned int savep;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4704) 	uint32_t attrlen,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4705) 		 bitmap[3] = {0};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4706) 	int status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4707) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4708) 	status = decode_op_hdr(xdr, OP_GETATTR);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4709) 	if (status < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4710) 		goto xdr_error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4711) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4712) 	status = decode_attr_bitmap(xdr, bitmap);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4713) 	if (status < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4714) 		goto xdr_error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4715) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4716) 	status = decode_attr_length(xdr, &attrlen, &savep);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4717) 	if (status < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4718) 		goto xdr_error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4719) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4720) 	status = decode_getfattr_attrs(xdr, bitmap, fattr, fh, fs_loc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4721) 					label, server);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4722) 	if (status < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4723) 		goto xdr_error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4724) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4725) 	status = verify_attr_len(xdr, savep, attrlen);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4726) xdr_error:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4727) 	dprintk("%s: xdr returned %d\n", __func__, -status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4728) 	return status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4729) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4730) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4731) static int decode_getfattr_label(struct xdr_stream *xdr, struct nfs_fattr *fattr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4732) 		struct nfs4_label *label, const struct nfs_server *server)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4733) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4734) 	return decode_getfattr_generic(xdr, fattr, NULL, NULL, label, server);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4735) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4736) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4737) static int decode_getfattr(struct xdr_stream *xdr, struct nfs_fattr *fattr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4738) 		const struct nfs_server *server)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4739) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4740) 	return decode_getfattr_generic(xdr, fattr, NULL, NULL, NULL, server);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4741) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4742) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4743) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4744)  * Decode potentially multiple layout types.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4745)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4746) static int decode_pnfs_layout_types(struct xdr_stream *xdr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4747) 				    struct nfs_fsinfo *fsinfo)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4748) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4749) 	__be32 *p;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4750) 	uint32_t i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4751) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4752) 	p = xdr_inline_decode(xdr, 4);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4753) 	if (unlikely(!p))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4754) 		return -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4755) 	fsinfo->nlayouttypes = be32_to_cpup(p);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4756) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4757) 	/* pNFS is not supported by the underlying file system */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4758) 	if (fsinfo->nlayouttypes == 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4759) 		return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4760) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4761) 	/* Decode and set first layout type, move xdr->p past unused types */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4762) 	p = xdr_inline_decode(xdr, fsinfo->nlayouttypes * 4);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4763) 	if (unlikely(!p))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4764) 		return -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4765) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4766) 	/* If we get too many, then just cap it at the max */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4767) 	if (fsinfo->nlayouttypes > NFS_MAX_LAYOUT_TYPES) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4768) 		printk(KERN_INFO "NFS: %s: Warning: Too many (%u) pNFS layout types\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4769) 			__func__, fsinfo->nlayouttypes);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4770) 		fsinfo->nlayouttypes = NFS_MAX_LAYOUT_TYPES;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4771) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4772) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4773) 	for(i = 0; i < fsinfo->nlayouttypes; ++i)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4774) 		fsinfo->layouttype[i] = be32_to_cpup(p++);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4775) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4776) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4777) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4778) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4779)  * The type of file system exported.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4780)  * Note we must ensure that layouttype is set in any non-error case.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4781)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4782) static int decode_attr_pnfstype(struct xdr_stream *xdr, uint32_t *bitmap,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4783) 				struct nfs_fsinfo *fsinfo)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4784) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4785) 	int status = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4786) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4787) 	dprintk("%s: bitmap is %x\n", __func__, bitmap[1]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4788) 	if (unlikely(bitmap[1] & (FATTR4_WORD1_FS_LAYOUT_TYPES - 1U)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4789) 		return -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4790) 	if (bitmap[1] & FATTR4_WORD1_FS_LAYOUT_TYPES) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4791) 		status = decode_pnfs_layout_types(xdr, fsinfo);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4792) 		bitmap[1] &= ~FATTR4_WORD1_FS_LAYOUT_TYPES;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4793) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4794) 	return status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4795) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4796) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4797) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4798)  * The prefered block size for layout directed io
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4799)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4800) static int decode_attr_layout_blksize(struct xdr_stream *xdr, uint32_t *bitmap,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4801) 				      uint32_t *res)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4802) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4803) 	__be32 *p;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4804) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4805) 	dprintk("%s: bitmap is %x\n", __func__, bitmap[2]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4806) 	*res = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4807) 	if (bitmap[2] & FATTR4_WORD2_LAYOUT_BLKSIZE) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4808) 		p = xdr_inline_decode(xdr, 4);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4809) 		if (unlikely(!p))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4810) 			return -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4811) 		*res = be32_to_cpup(p);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4812) 		bitmap[2] &= ~FATTR4_WORD2_LAYOUT_BLKSIZE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4813) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4814) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4815) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4816) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4817) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4818)  * The granularity of a CLONE operation.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4819)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4820) static int decode_attr_clone_blksize(struct xdr_stream *xdr, uint32_t *bitmap,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4821) 				     uint32_t *res)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4822) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4823) 	__be32 *p;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4824) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4825) 	dprintk("%s: bitmap is %x\n", __func__, bitmap[2]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4826) 	*res = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4827) 	if (bitmap[2] & FATTR4_WORD2_CLONE_BLKSIZE) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4828) 		p = xdr_inline_decode(xdr, 4);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4829) 		if (unlikely(!p))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4830) 			return -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4831) 		*res = be32_to_cpup(p);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4832) 		bitmap[2] &= ~FATTR4_WORD2_CLONE_BLKSIZE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4833) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4834) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4835) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4836) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4837) static int decode_fsinfo(struct xdr_stream *xdr, struct nfs_fsinfo *fsinfo)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4838) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4839) 	unsigned int savep;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4840) 	uint32_t attrlen, bitmap[3];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4841) 	int status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4842) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4843) 	if ((status = decode_op_hdr(xdr, OP_GETATTR)) != 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4844) 		goto xdr_error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4845) 	if ((status = decode_attr_bitmap(xdr, bitmap)) != 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4846) 		goto xdr_error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4847) 	if ((status = decode_attr_length(xdr, &attrlen, &savep)) != 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4848) 		goto xdr_error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4849) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4850) 	fsinfo->rtmult = fsinfo->wtmult = 512;	/* ??? */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4851) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4852) 	if ((status = decode_attr_lease_time(xdr, bitmap, &fsinfo->lease_time)) != 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4853) 		goto xdr_error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4854) 	if ((status = decode_attr_maxfilesize(xdr, bitmap, &fsinfo->maxfilesize)) != 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4855) 		goto xdr_error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4856) 	if ((status = decode_attr_maxread(xdr, bitmap, &fsinfo->rtmax)) != 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4857) 		goto xdr_error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4858) 	fsinfo->rtpref = fsinfo->dtpref = fsinfo->rtmax;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4859) 	if ((status = decode_attr_maxwrite(xdr, bitmap, &fsinfo->wtmax)) != 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4860) 		goto xdr_error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4861) 	fsinfo->wtpref = fsinfo->wtmax;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4862) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4863) 	status = -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4864) 	if (unlikely(bitmap[0]))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4865) 		goto xdr_error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4866) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4867) 	status = decode_attr_time_delta(xdr, bitmap, &fsinfo->time_delta);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4868) 	if (status != 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4869) 		goto xdr_error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4870) 	status = decode_attr_pnfstype(xdr, bitmap, fsinfo);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4871) 	if (status != 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4872) 		goto xdr_error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4873) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4874) 	status = -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4875) 	if (unlikely(bitmap[1]))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4876) 		goto xdr_error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4877) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4878) 	status = decode_attr_layout_blksize(xdr, bitmap, &fsinfo->blksize);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4879) 	if (status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4880) 		goto xdr_error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4881) 	status = decode_attr_clone_blksize(xdr, bitmap, &fsinfo->clone_blksize);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4882) 	if (status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4883) 		goto xdr_error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4884) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4885) 	status = decode_attr_xattrsupport(xdr, bitmap,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4886) 					  &fsinfo->xattr_support);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4887) 	if (status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4888) 		goto xdr_error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4889) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4890) 	status = verify_attr_len(xdr, savep, attrlen);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4891) xdr_error:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4892) 	dprintk("%s: xdr returned %d!\n", __func__, -status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4893) 	return status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4894) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4895) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4896) static int decode_getfh(struct xdr_stream *xdr, struct nfs_fh *fh)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4897) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4898) 	__be32 *p;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4899) 	uint32_t len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4900) 	int status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4901) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4902) 	/* Zero handle first to allow comparisons */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4903) 	memset(fh, 0, sizeof(*fh));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4904) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4905) 	status = decode_op_hdr(xdr, OP_GETFH);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4906) 	if (status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4907) 		return status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4908) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4909) 	p = xdr_inline_decode(xdr, 4);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4910) 	if (unlikely(!p))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4911) 		return -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4912) 	len = be32_to_cpup(p);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4913) 	if (len > NFS4_FHSIZE)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4914) 		return -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4915) 	fh->size = len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4916) 	p = xdr_inline_decode(xdr, len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4917) 	if (unlikely(!p))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4918) 		return -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4919) 	memcpy(fh->data, p, len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4920) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4921) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4922) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4923) static int decode_link(struct xdr_stream *xdr, struct nfs4_change_info *cinfo)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4924) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4925) 	int status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4926) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4927) 	status = decode_op_hdr(xdr, OP_LINK);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4928) 	if (status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4929) 		return status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4930) 	return decode_change_info(xdr, cinfo);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4931) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4932) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4933) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4934)  * We create the owner, so we know a proper owner.id length is 4.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4935)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4936) static int decode_lock_denied (struct xdr_stream *xdr, struct file_lock *fl)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4937) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4938) 	uint64_t offset, length, clientid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4939) 	__be32 *p;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4940) 	uint32_t namelen, type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4941) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4942) 	p = xdr_inline_decode(xdr, 32); /* read 32 bytes */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4943) 	if (unlikely(!p))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4944) 		return -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4945) 	p = xdr_decode_hyper(p, &offset); /* read 2 8-byte long words */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4946) 	p = xdr_decode_hyper(p, &length);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4947) 	type = be32_to_cpup(p++); /* 4 byte read */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4948) 	if (fl != NULL) { /* manipulate file lock */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4949) 		fl->fl_start = (loff_t)offset;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4950) 		fl->fl_end = fl->fl_start + (loff_t)length - 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4951) 		if (length == ~(uint64_t)0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4952) 			fl->fl_end = OFFSET_MAX;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4953) 		fl->fl_type = F_WRLCK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4954) 		if (type & 1)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4955) 			fl->fl_type = F_RDLCK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4956) 		fl->fl_pid = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4957) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4958) 	p = xdr_decode_hyper(p, &clientid); /* read 8 bytes */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4959) 	namelen = be32_to_cpup(p); /* read 4 bytes */  /* have read all 32 bytes now */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4960) 	p = xdr_inline_decode(xdr, namelen); /* variable size field */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4961) 	if (likely(!p))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4962) 		return -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4963) 	return -NFS4ERR_DENIED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4964) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4965) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4966) static int decode_lock(struct xdr_stream *xdr, struct nfs_lock_res *res)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4967) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4968) 	int status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4969) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4970) 	status = decode_op_hdr(xdr, OP_LOCK);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4971) 	if (status == -EIO)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4972) 		goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4973) 	if (status == 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4974) 		status = decode_lock_stateid(xdr, &res->stateid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4975) 		if (unlikely(status))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4976) 			goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4977) 	} else if (status == -NFS4ERR_DENIED)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4978) 		status = decode_lock_denied(xdr, NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4979) 	if (res->open_seqid != NULL)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4980) 		nfs_increment_open_seqid(status, res->open_seqid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4981) 	nfs_increment_lock_seqid(status, res->lock_seqid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4982) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4983) 	return status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4984) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4985) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4986) static int decode_lockt(struct xdr_stream *xdr, struct nfs_lockt_res *res)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4987) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4988) 	int status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4989) 	status = decode_op_hdr(xdr, OP_LOCKT);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4990) 	if (status == -NFS4ERR_DENIED)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4991) 		return decode_lock_denied(xdr, res->denied);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4992) 	return status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4993) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4994) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4995) static int decode_locku(struct xdr_stream *xdr, struct nfs_locku_res *res)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4996) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4997) 	int status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4998) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4999) 	status = decode_op_hdr(xdr, OP_LOCKU);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5000) 	if (status != -EIO)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5001) 		nfs_increment_lock_seqid(status, res->seqid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5002) 	if (status == 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5003) 		status = decode_lock_stateid(xdr, &res->stateid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5004) 	return status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5005) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5006) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5007) static int decode_release_lockowner(struct xdr_stream *xdr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5008) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5009) 	return decode_op_hdr(xdr, OP_RELEASE_LOCKOWNER);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5010) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5011) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5012) static int decode_lookup(struct xdr_stream *xdr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5013) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5014) 	return decode_op_hdr(xdr, OP_LOOKUP);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5015) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5016) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5017) static int decode_lookupp(struct xdr_stream *xdr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5018) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5019) 	return decode_op_hdr(xdr, OP_LOOKUPP);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5020) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5021) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5022) /* This is too sick! */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5023) static int decode_space_limit(struct xdr_stream *xdr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5024) 		unsigned long *pagemod_limit)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5025) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5026) 	__be32 *p;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5027) 	uint32_t limit_type, nblocks, blocksize;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5028) 	u64 maxsize = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5029) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5030) 	p = xdr_inline_decode(xdr, 12);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5031) 	if (unlikely(!p))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5032) 		return -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5033) 	limit_type = be32_to_cpup(p++);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5034) 	switch (limit_type) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5035) 	case NFS4_LIMIT_SIZE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5036) 		xdr_decode_hyper(p, &maxsize);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5037) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5038) 	case NFS4_LIMIT_BLOCKS:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5039) 		nblocks = be32_to_cpup(p++);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5040) 		blocksize = be32_to_cpup(p);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5041) 		maxsize = (uint64_t)nblocks * (uint64_t)blocksize;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5042) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5043) 	maxsize >>= PAGE_SHIFT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5044) 	*pagemod_limit = min_t(u64, maxsize, ULONG_MAX);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5045) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5046) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5047) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5048) static int decode_rw_delegation(struct xdr_stream *xdr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5049) 		uint32_t delegation_type,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5050) 		struct nfs_openres *res)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5051) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5052) 	__be32 *p;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5053) 	int status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5054) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5055) 	status = decode_delegation_stateid(xdr, &res->delegation);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5056) 	if (unlikely(status))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5057) 		return status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5058) 	p = xdr_inline_decode(xdr, 4);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5059) 	if (unlikely(!p))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5060) 		return -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5061) 	res->do_recall = be32_to_cpup(p);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5062) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5063) 	switch (delegation_type) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5064) 	case NFS4_OPEN_DELEGATE_READ:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5065) 		res->delegation_type = FMODE_READ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5066) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5067) 	case NFS4_OPEN_DELEGATE_WRITE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5068) 		res->delegation_type = FMODE_WRITE|FMODE_READ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5069) 		if (decode_space_limit(xdr, &res->pagemod_limit) < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5070) 				return -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5071) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5072) 	return decode_ace(xdr, NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5073) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5074) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5075) static int decode_no_delegation(struct xdr_stream *xdr, struct nfs_openres *res)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5076) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5077) 	__be32 *p;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5078) 	uint32_t why_no_delegation;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5079) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5080) 	p = xdr_inline_decode(xdr, 4);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5081) 	if (unlikely(!p))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5082) 		return -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5083) 	why_no_delegation = be32_to_cpup(p);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5084) 	switch (why_no_delegation) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5085) 		case WND4_CONTENTION:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5086) 		case WND4_RESOURCE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5087) 			xdr_inline_decode(xdr, 4);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5088) 			/* Ignore for now */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5089) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5090) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5091) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5092) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5093) static int decode_delegation(struct xdr_stream *xdr, struct nfs_openres *res)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5094) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5095) 	__be32 *p;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5096) 	uint32_t delegation_type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5097) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5098) 	p = xdr_inline_decode(xdr, 4);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5099) 	if (unlikely(!p))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5100) 		return -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5101) 	delegation_type = be32_to_cpup(p);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5102) 	res->delegation_type = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5103) 	switch (delegation_type) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5104) 	case NFS4_OPEN_DELEGATE_NONE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5105) 		return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5106) 	case NFS4_OPEN_DELEGATE_READ:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5107) 	case NFS4_OPEN_DELEGATE_WRITE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5108) 		return decode_rw_delegation(xdr, delegation_type, res);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5109) 	case NFS4_OPEN_DELEGATE_NONE_EXT:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5110) 		return decode_no_delegation(xdr, res);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5111) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5112) 	return -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5113) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5114) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5115) static int decode_open(struct xdr_stream *xdr, struct nfs_openres *res)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5116) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5117) 	__be32 *p;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5118) 	uint32_t savewords, bmlen, i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5119) 	int status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5120) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5121) 	if (!__decode_op_hdr(xdr, OP_OPEN, &status))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5122) 		return status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5123) 	nfs_increment_open_seqid(status, res->seqid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5124) 	if (status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5125) 		return status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5126) 	status = decode_open_stateid(xdr, &res->stateid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5127) 	if (unlikely(status))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5128) 		return status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5129) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5130) 	decode_change_info(xdr, &res->cinfo);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5131) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5132) 	p = xdr_inline_decode(xdr, 8);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5133) 	if (unlikely(!p))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5134) 		return -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5135) 	res->rflags = be32_to_cpup(p++);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5136) 	bmlen = be32_to_cpup(p);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5137) 	if (bmlen > 10)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5138) 		goto xdr_error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5139) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5140) 	p = xdr_inline_decode(xdr, bmlen << 2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5141) 	if (unlikely(!p))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5142) 		return -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5143) 	savewords = min_t(uint32_t, bmlen, NFS4_BITMAP_SIZE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5144) 	for (i = 0; i < savewords; ++i)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5145) 		res->attrset[i] = be32_to_cpup(p++);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5146) 	for (; i < NFS4_BITMAP_SIZE; i++)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5147) 		res->attrset[i] = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5148) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5149) 	return decode_delegation(xdr, res);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5150) xdr_error:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5151) 	dprintk("%s: Bitmap too large! Length = %u\n", __func__, bmlen);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5152) 	return -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5153) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5154) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5155) static int decode_open_confirm(struct xdr_stream *xdr, struct nfs_open_confirmres *res)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5156) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5157) 	int status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5158) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5159) 	status = decode_op_hdr(xdr, OP_OPEN_CONFIRM);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5160) 	if (status != -EIO)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5161) 		nfs_increment_open_seqid(status, res->seqid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5162) 	if (!status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5163) 		status = decode_open_stateid(xdr, &res->stateid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5164) 	return status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5165) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5166) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5167) static int decode_open_downgrade(struct xdr_stream *xdr, struct nfs_closeres *res)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5168) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5169) 	int status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5170) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5171) 	status = decode_op_hdr(xdr, OP_OPEN_DOWNGRADE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5172) 	if (status != -EIO)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5173) 		nfs_increment_open_seqid(status, res->seqid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5174) 	if (!status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5175) 		status = decode_open_stateid(xdr, &res->stateid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5176) 	return status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5177) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5178) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5179) static int decode_putfh(struct xdr_stream *xdr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5180) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5181) 	return decode_op_hdr(xdr, OP_PUTFH);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5182) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5183) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5184) static int decode_putrootfh(struct xdr_stream *xdr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5185) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5186) 	return decode_op_hdr(xdr, OP_PUTROOTFH);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5187) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5188) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5189) static int decode_read(struct xdr_stream *xdr, struct rpc_rqst *req,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5190) 		       struct nfs_pgio_res *res)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5191) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5192) 	__be32 *p;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5193) 	uint32_t count, eof, recvd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5194) 	int status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5195) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5196) 	status = decode_op_hdr(xdr, OP_READ);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5197) 	if (status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5198) 		return status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5199) 	p = xdr_inline_decode(xdr, 8);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5200) 	if (unlikely(!p))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5201) 		return -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5202) 	eof = be32_to_cpup(p++);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5203) 	count = be32_to_cpup(p);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5204) 	recvd = xdr_read_pages(xdr, count);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5205) 	if (count > recvd) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5206) 		dprintk("NFS: server cheating in read reply: "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5207) 				"count %u > recvd %u\n", count, recvd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5208) 		count = recvd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5209) 		eof = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5210) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5211) 	res->eof = eof;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5212) 	res->count = count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5213) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5214) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5215) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5216) static int decode_readdir(struct xdr_stream *xdr, struct rpc_rqst *req, struct nfs4_readdir_res *readdir)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5217) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5218) 	int		status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5219) 	__be32		verf[2];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5220) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5221) 	status = decode_op_hdr(xdr, OP_READDIR);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5222) 	if (!status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5223) 		status = decode_verifier(xdr, readdir->verifier.data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5224) 	if (unlikely(status))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5225) 		return status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5226) 	memcpy(verf, readdir->verifier.data, sizeof(verf));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5227) 	dprintk("%s: verifier = %08x:%08x\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5228) 			__func__, verf[0], verf[1]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5229) 	return xdr_read_pages(xdr, xdr->buf->page_len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5230) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5231) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5232) static int decode_readlink(struct xdr_stream *xdr, struct rpc_rqst *req)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5233) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5234) 	struct xdr_buf *rcvbuf = &req->rq_rcv_buf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5235) 	u32 len, recvd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5236) 	__be32 *p;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5237) 	int status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5238) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5239) 	status = decode_op_hdr(xdr, OP_READLINK);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5240) 	if (status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5241) 		return status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5242) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5243) 	/* Convert length of symlink */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5244) 	p = xdr_inline_decode(xdr, 4);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5245) 	if (unlikely(!p))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5246) 		return -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5247) 	len = be32_to_cpup(p);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5248) 	if (len >= rcvbuf->page_len || len <= 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5249) 		dprintk("nfs: server returned giant symlink!\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5250) 		return -ENAMETOOLONG;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5251) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5252) 	recvd = xdr_read_pages(xdr, len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5253) 	if (recvd < len) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5254) 		dprintk("NFS: server cheating in readlink reply: "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5255) 				"count %u > recvd %u\n", len, recvd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5256) 		return -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5257) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5258) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5259) 	 * The XDR encode routine has set things up so that
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5260) 	 * the link text will be copied directly into the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5261) 	 * buffer.  We just have to do overflow-checking,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5262) 	 * and null-terminate the text (the VFS expects
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5263) 	 * null-termination).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5264) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5265) 	xdr_terminate_string(rcvbuf, len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5266) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5267) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5268) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5269) static int decode_remove(struct xdr_stream *xdr, struct nfs4_change_info *cinfo)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5270) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5271) 	int status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5272) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5273) 	status = decode_op_hdr(xdr, OP_REMOVE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5274) 	if (status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5275) 		goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5276) 	status = decode_change_info(xdr, cinfo);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5277) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5278) 	return status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5279) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5280) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5281) static int decode_rename(struct xdr_stream *xdr, struct nfs4_change_info *old_cinfo,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5282) 	      struct nfs4_change_info *new_cinfo)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5283) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5284) 	int status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5285) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5286) 	status = decode_op_hdr(xdr, OP_RENAME);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5287) 	if (status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5288) 		goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5289) 	if ((status = decode_change_info(xdr, old_cinfo)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5290) 		goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5291) 	status = decode_change_info(xdr, new_cinfo);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5292) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5293) 	return status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5294) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5295) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5296) static int decode_renew(struct xdr_stream *xdr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5297) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5298) 	return decode_op_hdr(xdr, OP_RENEW);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5299) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5300) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5301) static int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5302) decode_restorefh(struct xdr_stream *xdr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5303) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5304) 	return decode_op_hdr(xdr, OP_RESTOREFH);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5305) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5306) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5307) static int decode_getacl(struct xdr_stream *xdr, struct rpc_rqst *req,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5308) 			 struct nfs_getaclres *res)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5309) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5310) 	unsigned int savep;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5311) 	uint32_t attrlen,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5312) 		 bitmap[3] = {0};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5313) 	int status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5314) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5315) 	res->acl_len = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5316) 	if ((status = decode_op_hdr(xdr, OP_GETATTR)) != 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5317) 		goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5318) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5319) 	xdr_enter_page(xdr, xdr->buf->page_len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5320) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5321) 	if ((status = decode_attr_bitmap(xdr, bitmap)) != 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5322) 		goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5323) 	if ((status = decode_attr_length(xdr, &attrlen, &savep)) != 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5324) 		goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5325) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5326) 	if (unlikely(bitmap[0] & (FATTR4_WORD0_ACL - 1U)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5327) 		return -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5328) 	if (likely(bitmap[0] & FATTR4_WORD0_ACL)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5329) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5330) 		/* The bitmap (xdr len + bitmaps) and the attr xdr len words
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5331) 		 * are stored with the acl data to handle the problem of
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5332) 		 * variable length bitmaps.*/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5333) 		res->acl_data_offset = xdr_page_pos(xdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5334) 		res->acl_len = attrlen;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5335) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5336) 		/* Check for receive buffer overflow */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5337) 		if (res->acl_len > (xdr->nwords << 2) ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5338) 		    res->acl_len + res->acl_data_offset > xdr->buf->page_len) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5339) 			res->acl_flags |= NFS4_ACL_TRUNC;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5340) 			dprintk("NFS: acl reply: attrlen %u > page_len %u\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5341) 					attrlen, xdr->nwords << 2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5342) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5343) 	} else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5344) 		status = -EOPNOTSUPP;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5345) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5346) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5347) 	return status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5348) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5349) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5350) static int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5351) decode_savefh(struct xdr_stream *xdr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5352) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5353) 	return decode_op_hdr(xdr, OP_SAVEFH);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5354) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5355) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5356) static int decode_setattr(struct xdr_stream *xdr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5357) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5358) 	int status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5359) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5360) 	status = decode_op_hdr(xdr, OP_SETATTR);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5361) 	if (status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5362) 		return status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5363) 	if (decode_bitmap4(xdr, NULL, 0) >= 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5364) 		return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5365) 	return -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5366) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5367) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5368) static int decode_setclientid(struct xdr_stream *xdr, struct nfs4_setclientid_res *res)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5369) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5370) 	__be32 *p;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5371) 	uint32_t opnum;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5372) 	int32_t nfserr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5373) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5374) 	p = xdr_inline_decode(xdr, 8);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5375) 	if (unlikely(!p))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5376) 		return -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5377) 	opnum = be32_to_cpup(p++);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5378) 	if (opnum != OP_SETCLIENTID) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5379) 		dprintk("nfs: decode_setclientid: Server returned operation"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5380) 			" %d\n", opnum);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5381) 		return -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5382) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5383) 	nfserr = be32_to_cpup(p);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5384) 	if (nfserr == NFS_OK) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5385) 		p = xdr_inline_decode(xdr, 8 + NFS4_VERIFIER_SIZE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5386) 		if (unlikely(!p))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5387) 			return -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5388) 		p = xdr_decode_hyper(p, &res->clientid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5389) 		memcpy(res->confirm.data, p, NFS4_VERIFIER_SIZE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5390) 	} else if (nfserr == NFSERR_CLID_INUSE) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5391) 		uint32_t len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5392) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5393) 		/* skip netid string */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5394) 		p = xdr_inline_decode(xdr, 4);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5395) 		if (unlikely(!p))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5396) 			return -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5397) 		len = be32_to_cpup(p);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5398) 		p = xdr_inline_decode(xdr, len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5399) 		if (unlikely(!p))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5400) 			return -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5401) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5402) 		/* skip uaddr string */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5403) 		p = xdr_inline_decode(xdr, 4);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5404) 		if (unlikely(!p))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5405) 			return -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5406) 		len = be32_to_cpup(p);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5407) 		p = xdr_inline_decode(xdr, len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5408) 		if (unlikely(!p))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5409) 			return -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5410) 		return -NFSERR_CLID_INUSE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5411) 	} else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5412) 		return nfs4_stat_to_errno(nfserr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5413) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5414) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5415) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5416) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5417) static int decode_setclientid_confirm(struct xdr_stream *xdr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5418) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5419) 	return decode_op_hdr(xdr, OP_SETCLIENTID_CONFIRM);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5420) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5421) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5422) static int decode_write(struct xdr_stream *xdr, struct nfs_pgio_res *res)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5423) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5424) 	__be32 *p;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5425) 	int status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5426) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5427) 	status = decode_op_hdr(xdr, OP_WRITE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5428) 	if (status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5429) 		return status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5430) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5431) 	p = xdr_inline_decode(xdr, 8);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5432) 	if (unlikely(!p))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5433) 		return -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5434) 	res->count = be32_to_cpup(p++);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5435) 	res->verf->committed = be32_to_cpup(p++);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5436) 	return decode_write_verifier(xdr, &res->verf->verifier);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5437) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5438) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5439) static int decode_delegreturn(struct xdr_stream *xdr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5440) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5441) 	return decode_op_hdr(xdr, OP_DELEGRETURN);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5442) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5443) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5444) static int decode_secinfo_gss(struct xdr_stream *xdr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5445) 			      struct nfs4_secinfo4 *flavor)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5446) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5447) 	u32 oid_len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5448) 	__be32 *p;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5449) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5450) 	p = xdr_inline_decode(xdr, 4);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5451) 	if (unlikely(!p))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5452) 		return -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5453) 	oid_len = be32_to_cpup(p);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5454) 	if (oid_len > GSS_OID_MAX_LEN)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5455) 		return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5456) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5457) 	p = xdr_inline_decode(xdr, oid_len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5458) 	if (unlikely(!p))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5459) 		return -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5460) 	memcpy(flavor->flavor_info.oid.data, p, oid_len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5461) 	flavor->flavor_info.oid.len = oid_len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5462) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5463) 	p = xdr_inline_decode(xdr, 8);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5464) 	if (unlikely(!p))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5465) 		return -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5466) 	flavor->flavor_info.qop = be32_to_cpup(p++);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5467) 	flavor->flavor_info.service = be32_to_cpup(p);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5468) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5469) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5470) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5471) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5472) static int decode_secinfo_common(struct xdr_stream *xdr, struct nfs4_secinfo_res *res)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5473) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5474) 	struct nfs4_secinfo4 *sec_flavor;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5475) 	unsigned int i, num_flavors;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5476) 	int status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5477) 	__be32 *p;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5478) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5479) 	p = xdr_inline_decode(xdr, 4);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5480) 	if (unlikely(!p))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5481) 		return -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5482) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5483) 	res->flavors->num_flavors = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5484) 	num_flavors = be32_to_cpup(p);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5485) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5486) 	for (i = 0; i < num_flavors; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5487) 		sec_flavor = &res->flavors->flavors[i];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5488) 		if ((char *)&sec_flavor[1] - (char *)res->flavors > PAGE_SIZE)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5489) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5490) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5491) 		p = xdr_inline_decode(xdr, 4);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5492) 		if (unlikely(!p))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5493) 			return -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5494) 		sec_flavor->flavor = be32_to_cpup(p);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5495) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5496) 		if (sec_flavor->flavor == RPC_AUTH_GSS) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5497) 			status = decode_secinfo_gss(xdr, sec_flavor);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5498) 			if (status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5499) 				goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5500) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5501) 		res->flavors->num_flavors++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5502) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5503) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5504) 	status = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5505) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5506) 	return status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5507) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5508) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5509) static int decode_secinfo(struct xdr_stream *xdr, struct nfs4_secinfo_res *res)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5510) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5511) 	int status = decode_op_hdr(xdr, OP_SECINFO);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5512) 	if (status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5513) 		return status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5514) 	return decode_secinfo_common(xdr, res);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5515) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5516) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5517) #if defined(CONFIG_NFS_V4_1)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5518) static int decode_secinfo_no_name(struct xdr_stream *xdr, struct nfs4_secinfo_res *res)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5519) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5520) 	int status = decode_op_hdr(xdr, OP_SECINFO_NO_NAME);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5521) 	if (status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5522) 		return status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5523) 	return decode_secinfo_common(xdr, res);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5524) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5525) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5526) static int decode_op_map(struct xdr_stream *xdr, struct nfs4_op_map *op_map)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5527) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5528) 	__be32 *p;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5529) 	uint32_t bitmap_words;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5530) 	unsigned int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5531) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5532) 	p = xdr_inline_decode(xdr, 4);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5533) 	if (!p)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5534) 		return -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5535) 	bitmap_words = be32_to_cpup(p++);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5536) 	if (bitmap_words > NFS4_OP_MAP_NUM_WORDS)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5537) 		return -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5538) 	p = xdr_inline_decode(xdr, 4 * bitmap_words);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5539) 	for (i = 0; i < bitmap_words; i++)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5540) 		op_map->u.words[i] = be32_to_cpup(p++);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5541) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5542) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5543) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5544) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5545) static int decode_exchange_id(struct xdr_stream *xdr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5546) 			      struct nfs41_exchange_id_res *res)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5547) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5548) 	__be32 *p;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5549) 	uint32_t dummy;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5550) 	char *dummy_str;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5551) 	int status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5552) 	uint32_t impl_id_count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5553) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5554) 	status = decode_op_hdr(xdr, OP_EXCHANGE_ID);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5555) 	if (status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5556) 		return status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5557) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5558) 	p = xdr_inline_decode(xdr, 8);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5559) 	if (unlikely(!p))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5560) 		return -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5561) 	xdr_decode_hyper(p, &res->clientid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5562) 	p = xdr_inline_decode(xdr, 12);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5563) 	if (unlikely(!p))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5564) 		return -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5565) 	res->seqid = be32_to_cpup(p++);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5566) 	res->flags = be32_to_cpup(p++);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5567) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5568) 	res->state_protect.how = be32_to_cpup(p);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5569) 	switch (res->state_protect.how) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5570) 	case SP4_NONE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5571) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5572) 	case SP4_MACH_CRED:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5573) 		status = decode_op_map(xdr, &res->state_protect.enforce);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5574) 		if (status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5575) 			return status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5576) 		status = decode_op_map(xdr, &res->state_protect.allow);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5577) 		if (status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5578) 			return status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5579) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5580) 	default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5581) 		WARN_ON_ONCE(1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5582) 		return -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5583) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5584) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5585) 	/* server_owner4.so_minor_id */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5586) 	p = xdr_inline_decode(xdr, 8);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5587) 	if (unlikely(!p))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5588) 		return -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5589) 	p = xdr_decode_hyper(p, &res->server_owner->minor_id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5590) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5591) 	/* server_owner4.so_major_id */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5592) 	status = decode_opaque_inline(xdr, &dummy, &dummy_str);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5593) 	if (unlikely(status))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5594) 		return status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5595) 	memcpy(res->server_owner->major_id, dummy_str, dummy);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5596) 	res->server_owner->major_id_sz = dummy;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5597) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5598) 	/* server_scope4 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5599) 	status = decode_opaque_inline(xdr, &dummy, &dummy_str);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5600) 	if (unlikely(status))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5601) 		return status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5602) 	memcpy(res->server_scope->server_scope, dummy_str, dummy);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5603) 	res->server_scope->server_scope_sz = dummy;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5604) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5605) 	/* Implementation Id */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5606) 	p = xdr_inline_decode(xdr, 4);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5607) 	if (unlikely(!p))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5608) 		return -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5609) 	impl_id_count = be32_to_cpup(p++);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5610) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5611) 	if (impl_id_count) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5612) 		/* nii_domain */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5613) 		status = decode_opaque_inline(xdr, &dummy, &dummy_str);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5614) 		if (unlikely(status))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5615) 			return status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5616) 		memcpy(res->impl_id->domain, dummy_str, dummy);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5617) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5618) 		/* nii_name */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5619) 		status = decode_opaque_inline(xdr, &dummy, &dummy_str);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5620) 		if (unlikely(status))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5621) 			return status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5622) 		memcpy(res->impl_id->name, dummy_str, dummy);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5623) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5624) 		/* nii_date */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5625) 		p = xdr_inline_decode(xdr, 12);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5626) 		if (unlikely(!p))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5627) 			return -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5628) 		p = xdr_decode_hyper(p, &res->impl_id->date.seconds);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5629) 		res->impl_id->date.nseconds = be32_to_cpup(p);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5630) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5631) 		/* if there's more than one entry, ignore the rest */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5632) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5633) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5634) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5635) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5636) static int decode_chan_attrs(struct xdr_stream *xdr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5637) 			     struct nfs4_channel_attrs *attrs)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5638) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5639) 	__be32 *p;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5640) 	u32 nr_attrs, val;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5641) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5642) 	p = xdr_inline_decode(xdr, 28);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5643) 	if (unlikely(!p))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5644) 		return -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5645) 	val = be32_to_cpup(p++);	/* headerpadsz */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5646) 	if (val)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5647) 		return -EINVAL;		/* no support for header padding yet */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5648) 	attrs->max_rqst_sz = be32_to_cpup(p++);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5649) 	attrs->max_resp_sz = be32_to_cpup(p++);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5650) 	attrs->max_resp_sz_cached = be32_to_cpup(p++);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5651) 	attrs->max_ops = be32_to_cpup(p++);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5652) 	attrs->max_reqs = be32_to_cpup(p++);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5653) 	nr_attrs = be32_to_cpup(p);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5654) 	if (unlikely(nr_attrs > 1)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5655) 		printk(KERN_WARNING "NFS: %s: Invalid rdma channel attrs "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5656) 			"count %u\n", __func__, nr_attrs);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5657) 		return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5658) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5659) 	if (nr_attrs == 1) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5660) 		p = xdr_inline_decode(xdr, 4); /* skip rdma_attrs */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5661) 		if (unlikely(!p))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5662) 			return -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5663) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5664) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5665) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5666) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5667) static int decode_sessionid(struct xdr_stream *xdr, struct nfs4_sessionid *sid)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5668) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5669) 	return decode_opaque_fixed(xdr, sid->data, NFS4_MAX_SESSIONID_LEN);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5670) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5671) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5672) static int decode_bind_conn_to_session(struct xdr_stream *xdr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5673) 				struct nfs41_bind_conn_to_session_res *res)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5674) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5675) 	__be32 *p;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5676) 	int status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5677) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5678) 	status = decode_op_hdr(xdr, OP_BIND_CONN_TO_SESSION);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5679) 	if (!status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5680) 		status = decode_sessionid(xdr, &res->sessionid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5681) 	if (unlikely(status))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5682) 		return status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5683) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5684) 	/* dir flags, rdma mode bool */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5685) 	p = xdr_inline_decode(xdr, 8);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5686) 	if (unlikely(!p))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5687) 		return -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5688) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5689) 	res->dir = be32_to_cpup(p++);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5690) 	if (res->dir == 0 || res->dir > NFS4_CDFS4_BOTH)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5691) 		return -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5692) 	if (be32_to_cpup(p) == 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5693) 		res->use_conn_in_rdma_mode = false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5694) 	else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5695) 		res->use_conn_in_rdma_mode = true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5696) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5697) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5698) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5699) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5700) static int decode_create_session(struct xdr_stream *xdr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5701) 				 struct nfs41_create_session_res *res)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5702) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5703) 	__be32 *p;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5704) 	int status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5705) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5706) 	status = decode_op_hdr(xdr, OP_CREATE_SESSION);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5707) 	if (!status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5708) 		status = decode_sessionid(xdr, &res->sessionid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5709) 	if (unlikely(status))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5710) 		return status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5711) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5712) 	/* seqid, flags */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5713) 	p = xdr_inline_decode(xdr, 8);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5714) 	if (unlikely(!p))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5715) 		return -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5716) 	res->seqid = be32_to_cpup(p++);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5717) 	res->flags = be32_to_cpup(p);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5718) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5719) 	/* Channel attributes */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5720) 	status = decode_chan_attrs(xdr, &res->fc_attrs);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5721) 	if (!status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5722) 		status = decode_chan_attrs(xdr, &res->bc_attrs);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5723) 	return status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5724) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5725) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5726) static int decode_destroy_session(struct xdr_stream *xdr, void *dummy)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5727) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5728) 	return decode_op_hdr(xdr, OP_DESTROY_SESSION);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5729) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5730) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5731) static int decode_destroy_clientid(struct xdr_stream *xdr, void *dummy)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5732) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5733) 	return decode_op_hdr(xdr, OP_DESTROY_CLIENTID);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5734) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5735) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5736) static int decode_reclaim_complete(struct xdr_stream *xdr, void *dummy)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5737) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5738) 	return decode_op_hdr(xdr, OP_RECLAIM_COMPLETE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5739) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5740) #endif /* CONFIG_NFS_V4_1 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5741) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5742) static int decode_sequence(struct xdr_stream *xdr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5743) 			   struct nfs4_sequence_res *res,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5744) 			   struct rpc_rqst *rqstp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5745) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5746) #if defined(CONFIG_NFS_V4_1)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5747) 	struct nfs4_session *session;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5748) 	struct nfs4_sessionid id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5749) 	u32 dummy;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5750) 	int status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5751) 	__be32 *p;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5752) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5753) 	if (res->sr_slot == NULL)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5754) 		return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5755) 	if (!res->sr_slot->table->session)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5756) 		return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5757) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5758) 	status = decode_op_hdr(xdr, OP_SEQUENCE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5759) 	if (!status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5760) 		status = decode_sessionid(xdr, &id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5761) 	if (unlikely(status))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5762) 		goto out_err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5763) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5764) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5765) 	 * If the server returns different values for sessionID, slotID or
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5766) 	 * sequence number, the server is looney tunes.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5767) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5768) 	status = -EREMOTEIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5769) 	session = res->sr_slot->table->session;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5770) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5771) 	if (memcmp(id.data, session->sess_id.data,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5772) 		   NFS4_MAX_SESSIONID_LEN)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5773) 		dprintk("%s Invalid session id\n", __func__);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5774) 		goto out_err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5775) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5776) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5777) 	p = xdr_inline_decode(xdr, 20);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5778) 	if (unlikely(!p))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5779) 		goto out_overflow;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5780) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5781) 	/* seqid */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5782) 	dummy = be32_to_cpup(p++);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5783) 	if (dummy != res->sr_slot->seq_nr) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5784) 		dprintk("%s Invalid sequence number\n", __func__);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5785) 		goto out_err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5786) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5787) 	/* slot id */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5788) 	dummy = be32_to_cpup(p++);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5789) 	if (dummy != res->sr_slot->slot_nr) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5790) 		dprintk("%s Invalid slot id\n", __func__);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5791) 		goto out_err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5792) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5793) 	/* highest slot id */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5794) 	res->sr_highest_slotid = be32_to_cpup(p++);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5795) 	/* target highest slot id */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5796) 	res->sr_target_highest_slotid = be32_to_cpup(p++);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5797) 	/* result flags */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5798) 	res->sr_status_flags = be32_to_cpup(p);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5799) 	status = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5800) out_err:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5801) 	res->sr_status = status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5802) 	return status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5803) out_overflow:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5804) 	status = -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5805) 	goto out_err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5806) #else  /* CONFIG_NFS_V4_1 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5807) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5808) #endif /* CONFIG_NFS_V4_1 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5809) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5810) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5811) #if defined(CONFIG_NFS_V4_1)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5812) static int decode_layout_stateid(struct xdr_stream *xdr, nfs4_stateid *stateid)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5813) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5814) 	stateid->type = NFS4_LAYOUT_STATEID_TYPE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5815) 	return decode_stateid(xdr, stateid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5816) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5817) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5818) static int decode_getdeviceinfo(struct xdr_stream *xdr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5819) 				struct nfs4_getdeviceinfo_res *res)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5820) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5821) 	struct pnfs_device *pdev = res->pdev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5822) 	__be32 *p;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5823) 	uint32_t len, type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5824) 	int status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5825) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5826) 	status = decode_op_hdr(xdr, OP_GETDEVICEINFO);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5827) 	if (status) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5828) 		if (status == -ETOOSMALL) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5829) 			p = xdr_inline_decode(xdr, 4);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5830) 			if (unlikely(!p))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5831) 				return -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5832) 			pdev->mincount = be32_to_cpup(p);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5833) 			dprintk("%s: Min count too small. mincnt = %u\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5834) 				__func__, pdev->mincount);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5835) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5836) 		return status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5837) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5838) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5839) 	p = xdr_inline_decode(xdr, 8);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5840) 	if (unlikely(!p))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5841) 		return -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5842) 	type = be32_to_cpup(p++);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5843) 	if (type != pdev->layout_type) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5844) 		dprintk("%s: layout mismatch req: %u pdev: %u\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5845) 			__func__, pdev->layout_type, type);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5846) 		return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5847) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5848) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5849) 	 * Get the length of the opaque device_addr4. xdr_read_pages places
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5850) 	 * the opaque device_addr4 in the xdr_buf->pages (pnfs_device->pages)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5851) 	 * and places the remaining xdr data in xdr_buf->tail
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5852) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5853) 	pdev->mincount = be32_to_cpup(p);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5854) 	if (xdr_read_pages(xdr, pdev->mincount) != pdev->mincount)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5855) 		return -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5856) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5857) 	/* Parse notification bitmap, verifying that it is zero. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5858) 	p = xdr_inline_decode(xdr, 4);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5859) 	if (unlikely(!p))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5860) 		return -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5861) 	len = be32_to_cpup(p);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5862) 	if (len) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5863) 		uint32_t i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5864) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5865) 		p = xdr_inline_decode(xdr, 4 * len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5866) 		if (unlikely(!p))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5867) 			return -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5868) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5869) 		res->notification = be32_to_cpup(p++);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5870) 		for (i = 1; i < len; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5871) 			if (be32_to_cpup(p++)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5872) 				dprintk("%s: unsupported notification\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5873) 					__func__);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5874) 				return -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5875) 			}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5876) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5877) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5878) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5879) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5880) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5881) static int decode_layoutget(struct xdr_stream *xdr, struct rpc_rqst *req,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5882) 			    struct nfs4_layoutget_res *res)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5883) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5884) 	__be32 *p;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5885) 	int status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5886) 	u32 layout_count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5887) 	u32 recvd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5888) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5889) 	status = decode_op_hdr(xdr, OP_LAYOUTGET);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5890) 	if (status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5891) 		goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5892) 	p = xdr_inline_decode(xdr, 4);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5893) 	if (unlikely(!p))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5894) 		goto out_overflow;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5895) 	res->return_on_close = be32_to_cpup(p);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5896) 	decode_layout_stateid(xdr, &res->stateid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5897) 	p = xdr_inline_decode(xdr, 4);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5898) 	if (unlikely(!p))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5899) 		goto out_overflow;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5900) 	layout_count = be32_to_cpup(p);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5901) 	if (!layout_count) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5902) 		dprintk("%s: server responded with empty layout array\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5903) 			__func__);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5904) 		status = -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5905) 		goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5906) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5907) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5908) 	p = xdr_inline_decode(xdr, 28);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5909) 	if (unlikely(!p))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5910) 		goto out_overflow;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5911) 	p = xdr_decode_hyper(p, &res->range.offset);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5912) 	p = xdr_decode_hyper(p, &res->range.length);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5913) 	res->range.iomode = be32_to_cpup(p++);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5914) 	res->type = be32_to_cpup(p++);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5915) 	res->layoutp->len = be32_to_cpup(p);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5916) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5917) 	dprintk("%s roff:%lu rlen:%lu riomode:%d, lo_type:0x%x, lo.len:%d\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5918) 		__func__,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5919) 		(unsigned long)res->range.offset,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5920) 		(unsigned long)res->range.length,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5921) 		res->range.iomode,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5922) 		res->type,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5923) 		res->layoutp->len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5924) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5925) 	recvd = xdr_read_pages(xdr, res->layoutp->len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5926) 	if (res->layoutp->len > recvd) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5927) 		dprintk("NFS: server cheating in layoutget reply: "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5928) 				"layout len %u > recvd %u\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5929) 				res->layoutp->len, recvd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5930) 		status = -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5931) 		goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5932) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5933) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5934) 	if (layout_count > 1) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5935) 		/* We only handle a length one array at the moment.  Any
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5936) 		 * further entries are just ignored.  Note that this means
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5937) 		 * the client may see a response that is less than the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5938) 		 * minimum it requested.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5939) 		 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5940) 		dprintk("%s: server responded with %d layouts, dropping tail\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5941) 			__func__, layout_count);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5942) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5943) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5944) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5945) 	res->status = status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5946) 	return status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5947) out_overflow:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5948) 	status = -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5949) 	goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5950) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5951) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5952) static int decode_layoutreturn(struct xdr_stream *xdr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5953) 			       struct nfs4_layoutreturn_res *res)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5954) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5955) 	__be32 *p;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5956) 	int status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5957) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5958) 	status = decode_op_hdr(xdr, OP_LAYOUTRETURN);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5959) 	if (status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5960) 		return status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5961) 	p = xdr_inline_decode(xdr, 4);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5962) 	if (unlikely(!p))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5963) 		return -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5964) 	res->lrs_present = be32_to_cpup(p);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5965) 	if (res->lrs_present)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5966) 		status = decode_layout_stateid(xdr, &res->stateid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5967) 	else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5968) 		nfs4_stateid_copy(&res->stateid, &invalid_stateid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5969) 	return status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5970) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5971) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5972) static int decode_layoutcommit(struct xdr_stream *xdr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5973) 			       struct rpc_rqst *req,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5974) 			       struct nfs4_layoutcommit_res *res)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5975) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5976) 	__be32 *p;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5977) 	__u32 sizechanged;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5978) 	int status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5979) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5980) 	status = decode_op_hdr(xdr, OP_LAYOUTCOMMIT);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5981) 	res->status = status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5982) 	if (status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5983) 		return status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5984) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5985) 	p = xdr_inline_decode(xdr, 4);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5986) 	if (unlikely(!p))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5987) 		return -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5988) 	sizechanged = be32_to_cpup(p);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5989) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5990) 	if (sizechanged) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5991) 		/* throw away new size */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5992) 		p = xdr_inline_decode(xdr, 8);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5993) 		if (unlikely(!p))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5994) 			return -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5995) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5996) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5997) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5998) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5999) static int decode_test_stateid(struct xdr_stream *xdr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6000) 			       struct nfs41_test_stateid_res *res)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6001) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6002) 	__be32 *p;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6003) 	int status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6004) 	int num_res;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6005) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6006) 	status = decode_op_hdr(xdr, OP_TEST_STATEID);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6007) 	if (status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6008) 		return status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6009) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6010) 	p = xdr_inline_decode(xdr, 4);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6011) 	if (unlikely(!p))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6012) 		return -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6013) 	num_res = be32_to_cpup(p++);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6014) 	if (num_res != 1)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6015) 		return -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6016) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6017) 	p = xdr_inline_decode(xdr, 4);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6018) 	if (unlikely(!p))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6019) 		return -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6020) 	res->status = be32_to_cpup(p++);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6021) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6022) 	return status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6023) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6024) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6025) static int decode_free_stateid(struct xdr_stream *xdr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6026) 			       struct nfs41_free_stateid_res *res)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6027) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6028) 	res->status = decode_op_hdr(xdr, OP_FREE_STATEID);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6029) 	return res->status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6030) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6031) #else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6032) static inline
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6033) int decode_layoutreturn(struct xdr_stream *xdr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6034) 			       struct nfs4_layoutreturn_res *res)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6035) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6036) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6037) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6038) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6039) static int decode_layoutget(struct xdr_stream *xdr, struct rpc_rqst *req,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6040) 			    struct nfs4_layoutget_res *res)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6041) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6042) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6043) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6044) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6045) #endif /* CONFIG_NFS_V4_1 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6046) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6047) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6048)  * END OF "GENERIC" DECODE ROUTINES.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6049)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6050) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6051) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6052)  * Decode OPEN_DOWNGRADE response
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6053)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6054) static int nfs4_xdr_dec_open_downgrade(struct rpc_rqst *rqstp,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6055) 				       struct xdr_stream *xdr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6056) 				       void *data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6057) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6058) 	struct nfs_closeres *res = data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6059) 	struct compound_hdr hdr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6060) 	int status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6061) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6062) 	status = decode_compound_hdr(xdr, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6063) 	if (status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6064) 		goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6065) 	status = decode_sequence(xdr, &res->seq_res, rqstp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6066) 	if (status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6067) 		goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6068) 	status = decode_putfh(xdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6069) 	if (status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6070) 		goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6071) 	if (res->lr_res) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6072) 		status = decode_layoutreturn(xdr, res->lr_res);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6073) 		res->lr_ret = status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6074) 		if (status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6075) 			goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6076) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6077) 	status = decode_open_downgrade(xdr, res);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6078) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6079) 	return status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6080) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6081) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6082) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6083)  * Decode ACCESS response
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6084)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6085) static int nfs4_xdr_dec_access(struct rpc_rqst *rqstp, struct xdr_stream *xdr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6086) 			       void *data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6087) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6088) 	struct nfs4_accessres *res = data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6089) 	struct compound_hdr hdr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6090) 	int status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6091) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6092) 	status = decode_compound_hdr(xdr, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6093) 	if (status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6094) 		goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6095) 	status = decode_sequence(xdr, &res->seq_res, rqstp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6096) 	if (status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6097) 		goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6098) 	status = decode_putfh(xdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6099) 	if (status != 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6100) 		goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6101) 	status = decode_access(xdr, &res->supported, &res->access);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6102) 	if (status != 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6103) 		goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6104) 	if (res->fattr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6105) 		decode_getfattr(xdr, res->fattr, res->server);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6106) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6107) 	return status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6108) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6109) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6110) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6111)  * Decode LOOKUP response
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6112)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6113) static int nfs4_xdr_dec_lookup(struct rpc_rqst *rqstp, struct xdr_stream *xdr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6114) 			       void *data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6115) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6116) 	struct nfs4_lookup_res *res = data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6117) 	struct compound_hdr hdr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6118) 	int status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6119) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6120) 	status = decode_compound_hdr(xdr, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6121) 	if (status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6122) 		goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6123) 	status = decode_sequence(xdr, &res->seq_res, rqstp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6124) 	if (status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6125) 		goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6126) 	status = decode_putfh(xdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6127) 	if (status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6128) 		goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6129) 	status = decode_lookup(xdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6130) 	if (status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6131) 		goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6132) 	status = decode_getfh(xdr, res->fh);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6133) 	if (status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6134) 		goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6135) 	status = decode_getfattr_label(xdr, res->fattr, res->label, res->server);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6136) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6137) 	return status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6138) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6139) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6140) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6141)  * Decode LOOKUPP response
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6142)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6143) static int nfs4_xdr_dec_lookupp(struct rpc_rqst *rqstp, struct xdr_stream *xdr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6144) 		void *data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6145) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6146) 	struct nfs4_lookupp_res *res = data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6147) 	struct compound_hdr hdr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6148) 	int status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6149) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6150) 	status = decode_compound_hdr(xdr, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6151) 	if (status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6152) 		goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6153) 	status = decode_sequence(xdr, &res->seq_res, rqstp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6154) 	if (status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6155) 		goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6156) 	status = decode_putfh(xdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6157) 	if (status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6158) 		goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6159) 	status = decode_lookupp(xdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6160) 	if (status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6161) 		goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6162) 	status = decode_getfh(xdr, res->fh);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6163) 	if (status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6164) 		goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6165) 	status = decode_getfattr_label(xdr, res->fattr, res->label, res->server);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6166) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6167) 	return status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6168) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6169) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6170) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6171)  * Decode LOOKUP_ROOT response
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6172)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6173) static int nfs4_xdr_dec_lookup_root(struct rpc_rqst *rqstp,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6174) 				    struct xdr_stream *xdr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6175) 				    void *data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6176) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6177) 	struct nfs4_lookup_res *res = data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6178) 	struct compound_hdr hdr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6179) 	int status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6180) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6181) 	status = decode_compound_hdr(xdr, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6182) 	if (status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6183) 		goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6184) 	status = decode_sequence(xdr, &res->seq_res, rqstp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6185) 	if (status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6186) 		goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6187) 	status = decode_putrootfh(xdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6188) 	if (status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6189) 		goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6190) 	status = decode_getfh(xdr, res->fh);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6191) 	if (status == 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6192) 		status = decode_getfattr_label(xdr, res->fattr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6193) 						res->label, res->server);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6194) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6195) 	return status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6196) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6197) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6198) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6199)  * Decode REMOVE response
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6200)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6201) static int nfs4_xdr_dec_remove(struct rpc_rqst *rqstp, struct xdr_stream *xdr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6202) 			       void *data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6203) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6204) 	struct nfs_removeres *res = data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6205) 	struct compound_hdr hdr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6206) 	int status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6207) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6208) 	status = decode_compound_hdr(xdr, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6209) 	if (status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6210) 		goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6211) 	status = decode_sequence(xdr, &res->seq_res, rqstp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6212) 	if (status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6213) 		goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6214) 	status = decode_putfh(xdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6215) 	if (status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6216) 		goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6217) 	status = decode_remove(xdr, &res->cinfo);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6218) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6219) 	return status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6220) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6221) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6222) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6223)  * Decode RENAME response
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6224)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6225) static int nfs4_xdr_dec_rename(struct rpc_rqst *rqstp, struct xdr_stream *xdr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6226) 			       void *data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6227) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6228) 	struct nfs_renameres *res = data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6229) 	struct compound_hdr hdr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6230) 	int status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6231) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6232) 	status = decode_compound_hdr(xdr, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6233) 	if (status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6234) 		goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6235) 	status = decode_sequence(xdr, &res->seq_res, rqstp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6236) 	if (status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6237) 		goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6238) 	status = decode_putfh(xdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6239) 	if (status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6240) 		goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6241) 	status = decode_savefh(xdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6242) 	if (status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6243) 		goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6244) 	status = decode_putfh(xdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6245) 	if (status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6246) 		goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6247) 	status = decode_rename(xdr, &res->old_cinfo, &res->new_cinfo);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6248) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6249) 	return status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6250) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6251) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6252) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6253)  * Decode LINK response
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6254)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6255) static int nfs4_xdr_dec_link(struct rpc_rqst *rqstp, struct xdr_stream *xdr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6256) 			     void *data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6257) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6258) 	struct nfs4_link_res *res = data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6259) 	struct compound_hdr hdr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6260) 	int status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6261) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6262) 	status = decode_compound_hdr(xdr, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6263) 	if (status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6264) 		goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6265) 	status = decode_sequence(xdr, &res->seq_res, rqstp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6266) 	if (status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6267) 		goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6268) 	status = decode_putfh(xdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6269) 	if (status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6270) 		goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6271) 	status = decode_savefh(xdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6272) 	if (status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6273) 		goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6274) 	status = decode_putfh(xdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6275) 	if (status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6276) 		goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6277) 	status = decode_link(xdr, &res->cinfo);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6278) 	if (status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6279) 		goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6280) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6281) 	 * Note order: OP_LINK leaves the directory as the current
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6282) 	 *             filehandle.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6283) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6284) 	status = decode_restorefh(xdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6285) 	if (status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6286) 		goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6287) 	decode_getfattr_label(xdr, res->fattr, res->label, res->server);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6288) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6289) 	return status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6290) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6291) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6292) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6293)  * Decode CREATE response
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6294)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6295) static int nfs4_xdr_dec_create(struct rpc_rqst *rqstp, struct xdr_stream *xdr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6296) 			       void *data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6297) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6298) 	struct nfs4_create_res *res = data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6299) 	struct compound_hdr hdr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6300) 	int status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6301) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6302) 	status = decode_compound_hdr(xdr, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6303) 	if (status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6304) 		goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6305) 	status = decode_sequence(xdr, &res->seq_res, rqstp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6306) 	if (status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6307) 		goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6308) 	status = decode_putfh(xdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6309) 	if (status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6310) 		goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6311) 	status = decode_create(xdr, &res->dir_cinfo);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6312) 	if (status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6313) 		goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6314) 	status = decode_getfh(xdr, res->fh);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6315) 	if (status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6316) 		goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6317) 	decode_getfattr_label(xdr, res->fattr, res->label, res->server);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6318) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6319) 	return status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6320) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6321) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6322) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6323)  * Decode SYMLINK response
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6324)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6325) static int nfs4_xdr_dec_symlink(struct rpc_rqst *rqstp, struct xdr_stream *xdr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6326) 				void *res)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6327) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6328) 	return nfs4_xdr_dec_create(rqstp, xdr, res);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6329) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6330) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6331) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6332)  * Decode GETATTR response
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6333)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6334) static int nfs4_xdr_dec_getattr(struct rpc_rqst *rqstp, struct xdr_stream *xdr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6335) 				void *data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6336) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6337) 	struct nfs4_getattr_res *res = data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6338) 	struct compound_hdr hdr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6339) 	int status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6340) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6341) 	status = decode_compound_hdr(xdr, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6342) 	if (status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6343) 		goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6344) 	status = decode_sequence(xdr, &res->seq_res, rqstp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6345) 	if (status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6346) 		goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6347) 	status = decode_putfh(xdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6348) 	if (status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6349) 		goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6350) 	status = decode_getfattr_label(xdr, res->fattr, res->label, res->server);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6351) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6352) 	return status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6353) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6354) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6355) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6356)  * Encode an SETACL request
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6357)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6358) static void nfs4_xdr_enc_setacl(struct rpc_rqst *req, struct xdr_stream *xdr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6359) 				const void *data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6360) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6361) 	const struct nfs_setaclargs *args = data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6362) 	struct compound_hdr hdr = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6363) 		.minorversion = nfs4_xdr_minorversion(&args->seq_args),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6364) 	};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6365) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6366) 	encode_compound_hdr(xdr, req, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6367) 	encode_sequence(xdr, &args->seq_args, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6368) 	encode_putfh(xdr, args->fh, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6369) 	encode_setacl(xdr, args, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6370) 	encode_nops(&hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6371) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6372) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6373) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6374)  * Decode SETACL response
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6375)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6376) static int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6377) nfs4_xdr_dec_setacl(struct rpc_rqst *rqstp, struct xdr_stream *xdr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6378) 		    void *data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6379) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6380) 	struct nfs_setaclres *res = data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6381) 	struct compound_hdr hdr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6382) 	int status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6383) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6384) 	status = decode_compound_hdr(xdr, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6385) 	if (status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6386) 		goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6387) 	status = decode_sequence(xdr, &res->seq_res, rqstp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6388) 	if (status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6389) 		goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6390) 	status = decode_putfh(xdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6391) 	if (status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6392) 		goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6393) 	status = decode_setattr(xdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6394) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6395) 	return status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6396) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6397) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6398) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6399)  * Decode GETACL response
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6400)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6401) static int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6402) nfs4_xdr_dec_getacl(struct rpc_rqst *rqstp, struct xdr_stream *xdr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6403) 		    void *data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6404) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6405) 	struct nfs_getaclres *res = data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6406) 	struct compound_hdr hdr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6407) 	int status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6408) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6409) 	if (res->acl_scratch != NULL) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6410) 		void *p = page_address(res->acl_scratch);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6411) 		xdr_set_scratch_buffer(xdr, p, PAGE_SIZE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6412) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6413) 	status = decode_compound_hdr(xdr, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6414) 	if (status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6415) 		goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6416) 	status = decode_sequence(xdr, &res->seq_res, rqstp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6417) 	if (status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6418) 		goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6419) 	status = decode_putfh(xdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6420) 	if (status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6421) 		goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6422) 	status = decode_getacl(xdr, rqstp, res);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6423) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6424) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6425) 	return status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6426) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6427) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6428) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6429)  * Decode CLOSE response
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6430)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6431) static int nfs4_xdr_dec_close(struct rpc_rqst *rqstp, struct xdr_stream *xdr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6432) 			      void *data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6433) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6434) 	struct nfs_closeres *res = data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6435) 	struct compound_hdr hdr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6436) 	int status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6437) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6438) 	status = decode_compound_hdr(xdr, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6439) 	if (status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6440) 		goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6441) 	status = decode_sequence(xdr, &res->seq_res, rqstp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6442) 	if (status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6443) 		goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6444) 	status = decode_putfh(xdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6445) 	if (status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6446) 		goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6447) 	if (res->lr_res) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6448) 		status = decode_layoutreturn(xdr, res->lr_res);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6449) 		res->lr_ret = status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6450) 		if (status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6451) 			goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6452) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6453) 	if (res->fattr != NULL) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6454) 		status = decode_getfattr(xdr, res->fattr, res->server);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6455) 		if (status != 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6456) 			goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6457) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6458) 	status = decode_close(xdr, res);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6459) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6460) 	return status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6461) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6462) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6463) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6464)  * Decode OPEN response
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6465)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6466) static int nfs4_xdr_dec_open(struct rpc_rqst *rqstp, struct xdr_stream *xdr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6467) 			     void *data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6468) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6469) 	struct nfs_openres *res = data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6470) 	struct compound_hdr hdr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6471) 	int status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6472) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6473) 	status = decode_compound_hdr(xdr, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6474) 	if (status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6475) 		goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6476) 	status = decode_sequence(xdr, &res->seq_res, rqstp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6477) 	if (status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6478) 		goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6479) 	status = decode_putfh(xdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6480) 	if (status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6481) 		goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6482) 	status = decode_open(xdr, res);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6483) 	if (status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6484) 		goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6485) 	status = decode_getfh(xdr, &res->fh);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6486) 	if (status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6487) 		goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6488) 	if (res->access_request)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6489) 		decode_access(xdr, &res->access_supported, &res->access_result);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6490) 	decode_getfattr_label(xdr, res->f_attr, res->f_label, res->server);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6491) 	if (res->lg_res)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6492) 		decode_layoutget(xdr, rqstp, res->lg_res);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6493) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6494) 	return status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6495) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6496) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6497) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6498)  * Decode OPEN_CONFIRM response
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6499)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6500) static int nfs4_xdr_dec_open_confirm(struct rpc_rqst *rqstp,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6501) 				     struct xdr_stream *xdr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6502) 				     void *data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6503) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6504) 	struct nfs_open_confirmres *res = data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6505) 	struct compound_hdr hdr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6506) 	int status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6507) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6508) 	status = decode_compound_hdr(xdr, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6509) 	if (status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6510) 		goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6511) 	status = decode_putfh(xdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6512) 	if (status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6513) 		goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6514) 	status = decode_open_confirm(xdr, res);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6515) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6516) 	return status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6517) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6518) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6519) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6520)  * Decode OPEN response
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6521)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6522) static int nfs4_xdr_dec_open_noattr(struct rpc_rqst *rqstp,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6523) 				    struct xdr_stream *xdr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6524) 				    void *data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6525) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6526) 	struct nfs_openres *res = data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6527) 	struct compound_hdr hdr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6528) 	int status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6529) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6530) 	status = decode_compound_hdr(xdr, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6531) 	if (status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6532) 		goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6533) 	status = decode_sequence(xdr, &res->seq_res, rqstp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6534) 	if (status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6535) 		goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6536) 	status = decode_putfh(xdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6537) 	if (status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6538) 		goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6539) 	status = decode_open(xdr, res);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6540) 	if (status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6541) 		goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6542) 	if (res->access_request)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6543) 		decode_access(xdr, &res->access_supported, &res->access_result);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6544) 	decode_getfattr(xdr, res->f_attr, res->server);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6545) 	if (res->lg_res)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6546) 		decode_layoutget(xdr, rqstp, res->lg_res);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6547) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6548) 	return status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6549) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6550) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6551) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6552)  * Decode SETATTR response
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6553)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6554) static int nfs4_xdr_dec_setattr(struct rpc_rqst *rqstp,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6555) 				struct xdr_stream *xdr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6556) 				void *data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6557) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6558) 	struct nfs_setattrres *res = data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6559) 	struct compound_hdr hdr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6560) 	int status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6561) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6562) 	status = decode_compound_hdr(xdr, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6563) 	if (status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6564) 		goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6565) 	status = decode_sequence(xdr, &res->seq_res, rqstp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6566) 	if (status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6567) 		goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6568) 	status = decode_putfh(xdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6569) 	if (status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6570) 		goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6571) 	status = decode_setattr(xdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6572) 	if (status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6573) 		goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6574) 	decode_getfattr_label(xdr, res->fattr, res->label, res->server);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6575) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6576) 	return status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6577) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6578) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6579) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6580)  * Decode LOCK response
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6581)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6582) static int nfs4_xdr_dec_lock(struct rpc_rqst *rqstp, struct xdr_stream *xdr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6583) 			     void *data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6584) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6585) 	struct nfs_lock_res *res = data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6586) 	struct compound_hdr hdr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6587) 	int status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6588) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6589) 	status = decode_compound_hdr(xdr, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6590) 	if (status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6591) 		goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6592) 	status = decode_sequence(xdr, &res->seq_res, rqstp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6593) 	if (status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6594) 		goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6595) 	status = decode_putfh(xdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6596) 	if (status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6597) 		goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6598) 	status = decode_lock(xdr, res);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6599) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6600) 	return status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6601) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6602) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6603) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6604)  * Decode LOCKT response
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6605)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6606) static int nfs4_xdr_dec_lockt(struct rpc_rqst *rqstp, struct xdr_stream *xdr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6607) 			      void *data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6608) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6609) 	struct nfs_lockt_res *res = data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6610) 	struct compound_hdr hdr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6611) 	int status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6612) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6613) 	status = decode_compound_hdr(xdr, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6614) 	if (status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6615) 		goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6616) 	status = decode_sequence(xdr, &res->seq_res, rqstp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6617) 	if (status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6618) 		goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6619) 	status = decode_putfh(xdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6620) 	if (status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6621) 		goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6622) 	status = decode_lockt(xdr, res);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6623) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6624) 	return status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6625) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6626) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6627) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6628)  * Decode LOCKU response
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6629)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6630) static int nfs4_xdr_dec_locku(struct rpc_rqst *rqstp, struct xdr_stream *xdr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6631) 			      void *data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6632) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6633) 	struct nfs_locku_res *res = data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6634) 	struct compound_hdr hdr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6635) 	int status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6636) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6637) 	status = decode_compound_hdr(xdr, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6638) 	if (status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6639) 		goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6640) 	status = decode_sequence(xdr, &res->seq_res, rqstp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6641) 	if (status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6642) 		goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6643) 	status = decode_putfh(xdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6644) 	if (status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6645) 		goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6646) 	status = decode_locku(xdr, res);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6647) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6648) 	return status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6649) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6650) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6651) static int nfs4_xdr_dec_release_lockowner(struct rpc_rqst *rqstp,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6652) 					  struct xdr_stream *xdr, void *dummy)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6653) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6654) 	struct compound_hdr hdr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6655) 	int status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6656) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6657) 	status = decode_compound_hdr(xdr, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6658) 	if (!status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6659) 		status = decode_release_lockowner(xdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6660) 	return status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6661) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6662) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6663) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6664)  * Decode READLINK response
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6665)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6666) static int nfs4_xdr_dec_readlink(struct rpc_rqst *rqstp,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6667) 				 struct xdr_stream *xdr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6668) 				 void *data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6669) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6670) 	struct nfs4_readlink_res *res = data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6671) 	struct compound_hdr hdr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6672) 	int status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6673) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6674) 	status = decode_compound_hdr(xdr, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6675) 	if (status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6676) 		goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6677) 	status = decode_sequence(xdr, &res->seq_res, rqstp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6678) 	if (status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6679) 		goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6680) 	status = decode_putfh(xdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6681) 	if (status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6682) 		goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6683) 	status = decode_readlink(xdr, rqstp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6684) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6685) 	return status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6686) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6687) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6688) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6689)  * Decode READDIR response
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6690)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6691) static int nfs4_xdr_dec_readdir(struct rpc_rqst *rqstp, struct xdr_stream *xdr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6692) 				void *data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6693) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6694) 	struct nfs4_readdir_res *res = data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6695) 	struct compound_hdr hdr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6696) 	int status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6697) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6698) 	status = decode_compound_hdr(xdr, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6699) 	if (status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6700) 		goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6701) 	status = decode_sequence(xdr, &res->seq_res, rqstp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6702) 	if (status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6703) 		goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6704) 	status = decode_putfh(xdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6705) 	if (status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6706) 		goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6707) 	status = decode_readdir(xdr, rqstp, res);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6708) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6709) 	return status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6710) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6711) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6712) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6713)  * Decode Read response
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6714)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6715) static int nfs4_xdr_dec_read(struct rpc_rqst *rqstp, struct xdr_stream *xdr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6716) 			     void *data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6717) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6718) 	struct nfs_pgio_res *res = data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6719) 	struct compound_hdr hdr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6720) 	int status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6721) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6722) 	status = decode_compound_hdr(xdr, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6723) 	res->op_status = hdr.status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6724) 	if (status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6725) 		goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6726) 	status = decode_sequence(xdr, &res->seq_res, rqstp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6727) 	if (status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6728) 		goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6729) 	status = decode_putfh(xdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6730) 	if (status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6731) 		goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6732) 	status = decode_read(xdr, rqstp, res);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6733) 	if (!status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6734) 		status = res->count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6735) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6736) 	return status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6737) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6738) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6739) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6740)  * Decode WRITE response
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6741)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6742) static int nfs4_xdr_dec_write(struct rpc_rqst *rqstp, struct xdr_stream *xdr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6743) 			      void *data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6744) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6745) 	struct nfs_pgio_res *res = data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6746) 	struct compound_hdr hdr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6747) 	int status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6748) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6749) 	status = decode_compound_hdr(xdr, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6750) 	res->op_status = hdr.status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6751) 	if (status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6752) 		goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6753) 	status = decode_sequence(xdr, &res->seq_res, rqstp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6754) 	if (status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6755) 		goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6756) 	status = decode_putfh(xdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6757) 	if (status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6758) 		goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6759) 	status = decode_write(xdr, res);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6760) 	if (status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6761) 		goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6762) 	if (res->fattr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6763) 		decode_getfattr(xdr, res->fattr, res->server);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6764) 	if (!status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6765) 		status = res->count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6766) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6767) 	return status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6768) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6769) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6770) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6771)  * Decode COMMIT response
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6772)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6773) static int nfs4_xdr_dec_commit(struct rpc_rqst *rqstp, struct xdr_stream *xdr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6774) 			       void *data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6775) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6776) 	struct nfs_commitres *res = data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6777) 	struct compound_hdr hdr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6778) 	int status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6779) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6780) 	status = decode_compound_hdr(xdr, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6781) 	res->op_status = hdr.status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6782) 	if (status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6783) 		goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6784) 	status = decode_sequence(xdr, &res->seq_res, rqstp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6785) 	if (status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6786) 		goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6787) 	status = decode_putfh(xdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6788) 	if (status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6789) 		goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6790) 	status = decode_commit(xdr, res);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6791) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6792) 	return status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6793) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6794) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6795) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6796)  * Decode FSINFO response
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6797)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6798) static int nfs4_xdr_dec_fsinfo(struct rpc_rqst *req, struct xdr_stream *xdr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6799) 			       void *data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6800) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6801) 	struct nfs4_fsinfo_res *res = data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6802) 	struct compound_hdr hdr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6803) 	int status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6804) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6805) 	status = decode_compound_hdr(xdr, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6806) 	if (!status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6807) 		status = decode_sequence(xdr, &res->seq_res, req);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6808) 	if (!status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6809) 		status = decode_putfh(xdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6810) 	if (!status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6811) 		status = decode_fsinfo(xdr, res->fsinfo);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6812) 	return status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6813) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6814) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6815) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6816)  * Decode PATHCONF response
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6817)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6818) static int nfs4_xdr_dec_pathconf(struct rpc_rqst *req, struct xdr_stream *xdr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6819) 				 void *data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6820) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6821) 	struct nfs4_pathconf_res *res = data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6822) 	struct compound_hdr hdr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6823) 	int status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6824) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6825) 	status = decode_compound_hdr(xdr, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6826) 	if (!status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6827) 		status = decode_sequence(xdr, &res->seq_res, req);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6828) 	if (!status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6829) 		status = decode_putfh(xdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6830) 	if (!status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6831) 		status = decode_pathconf(xdr, res->pathconf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6832) 	return status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6833) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6834) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6835) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6836)  * Decode STATFS response
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6837)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6838) static int nfs4_xdr_dec_statfs(struct rpc_rqst *req, struct xdr_stream *xdr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6839) 			       void *data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6840) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6841) 	struct nfs4_statfs_res *res = data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6842) 	struct compound_hdr hdr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6843) 	int status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6844) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6845) 	status = decode_compound_hdr(xdr, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6846) 	if (!status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6847) 		status = decode_sequence(xdr, &res->seq_res, req);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6848) 	if (!status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6849) 		status = decode_putfh(xdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6850) 	if (!status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6851) 		status = decode_statfs(xdr, res->fsstat);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6852) 	return status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6853) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6854) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6855) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6856)  * Decode GETATTR_BITMAP response
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6857)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6858) static int nfs4_xdr_dec_server_caps(struct rpc_rqst *req,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6859) 				    struct xdr_stream *xdr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6860) 				    void *data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6861) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6862) 	struct nfs4_server_caps_res *res = data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6863) 	struct compound_hdr hdr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6864) 	int status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6865) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6866) 	status = decode_compound_hdr(xdr, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6867) 	if (status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6868) 		goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6869) 	status = decode_sequence(xdr, &res->seq_res, req);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6870) 	if (status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6871) 		goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6872) 	status = decode_putfh(xdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6873) 	if (status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6874) 		goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6875) 	status = decode_server_caps(xdr, res);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6876) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6877) 	return status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6878) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6879) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6880) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6881)  * Decode RENEW response
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6882)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6883) static int nfs4_xdr_dec_renew(struct rpc_rqst *rqstp, struct xdr_stream *xdr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6884) 			      void *__unused)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6885) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6886) 	struct compound_hdr hdr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6887) 	int status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6888) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6889) 	status = decode_compound_hdr(xdr, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6890) 	if (!status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6891) 		status = decode_renew(xdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6892) 	return status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6893) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6894) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6895) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6896)  * Decode SETCLIENTID response
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6897)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6898) static int nfs4_xdr_dec_setclientid(struct rpc_rqst *req,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6899) 				    struct xdr_stream *xdr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6900) 				    void *data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6901) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6902) 	struct nfs4_setclientid_res *res = data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6903) 	struct compound_hdr hdr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6904) 	int status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6905) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6906) 	status = decode_compound_hdr(xdr, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6907) 	if (!status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6908) 		status = decode_setclientid(xdr, res);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6909) 	return status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6910) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6911) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6912) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6913)  * Decode SETCLIENTID_CONFIRM response
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6914)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6915) static int nfs4_xdr_dec_setclientid_confirm(struct rpc_rqst *req,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6916) 					    struct xdr_stream *xdr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6917) 					    void *data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6918) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6919) 	struct compound_hdr hdr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6920) 	int status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6921) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6922) 	status = decode_compound_hdr(xdr, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6923) 	if (!status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6924) 		status = decode_setclientid_confirm(xdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6925) 	return status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6926) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6927) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6928) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6929)  * Decode DELEGRETURN response
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6930)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6931) static int nfs4_xdr_dec_delegreturn(struct rpc_rqst *rqstp,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6932) 				    struct xdr_stream *xdr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6933) 				    void *data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6934) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6935) 	struct nfs4_delegreturnres *res = data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6936) 	struct compound_hdr hdr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6937) 	int status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6938) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6939) 	status = decode_compound_hdr(xdr, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6940) 	if (status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6941) 		goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6942) 	status = decode_sequence(xdr, &res->seq_res, rqstp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6943) 	if (status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6944) 		goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6945) 	status = decode_putfh(xdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6946) 	if (status != 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6947) 		goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6948) 	if (res->lr_res) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6949) 		status = decode_layoutreturn(xdr, res->lr_res);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6950) 		res->lr_ret = status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6951) 		if (status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6952) 			goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6953) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6954) 	if (res->fattr) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6955) 		status = decode_getfattr(xdr, res->fattr, res->server);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6956) 		if (status != 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6957) 			goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6958) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6959) 	status = decode_delegreturn(xdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6960) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6961) 	return status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6962) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6963) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6964) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6965)  * Decode FS_LOCATIONS response
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6966)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6967) static int nfs4_xdr_dec_fs_locations(struct rpc_rqst *req,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6968) 				     struct xdr_stream *xdr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6969) 				     void *data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6970) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6971) 	struct nfs4_fs_locations_res *res = data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6972) 	struct compound_hdr hdr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6973) 	int status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6974) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6975) 	status = decode_compound_hdr(xdr, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6976) 	if (status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6977) 		goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6978) 	status = decode_sequence(xdr, &res->seq_res, req);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6979) 	if (status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6980) 		goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6981) 	status = decode_putfh(xdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6982) 	if (status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6983) 		goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6984) 	if (res->migration) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6985) 		xdr_enter_page(xdr, PAGE_SIZE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6986) 		status = decode_getfattr_generic(xdr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6987) 					&res->fs_locations->fattr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6988) 					 NULL, res->fs_locations,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6989) 					 NULL, res->fs_locations->server);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6990) 		if (status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6991) 			goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6992) 		if (res->renew)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6993) 			status = decode_renew(xdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6994) 	} else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6995) 		status = decode_lookup(xdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6996) 		if (status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6997) 			goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6998) 		xdr_enter_page(xdr, PAGE_SIZE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6999) 		status = decode_getfattr_generic(xdr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7000) 					&res->fs_locations->fattr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7001) 					 NULL, res->fs_locations,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7002) 					 NULL, res->fs_locations->server);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7003) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7004) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7005) 	return status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7006) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7007) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7008) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7009)  * Decode SECINFO response
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7010)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7011) static int nfs4_xdr_dec_secinfo(struct rpc_rqst *rqstp,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7012) 				struct xdr_stream *xdr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7013) 				void *data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7014) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7015) 	struct nfs4_secinfo_res *res = data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7016) 	struct compound_hdr hdr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7017) 	int status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7018) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7019) 	status = decode_compound_hdr(xdr, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7020) 	if (status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7021) 		goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7022) 	status = decode_sequence(xdr, &res->seq_res, rqstp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7023) 	if (status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7024) 		goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7025) 	status = decode_putfh(xdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7026) 	if (status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7027) 		goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7028) 	status = decode_secinfo(xdr, res);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7029) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7030) 	return status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7031) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7032) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7033) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7034)  * Decode FSID_PRESENT response
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7035)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7036) static int nfs4_xdr_dec_fsid_present(struct rpc_rqst *rqstp,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7037) 				     struct xdr_stream *xdr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7038) 				     void *data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7039) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7040) 	struct nfs4_fsid_present_res *res = data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7041) 	struct compound_hdr hdr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7042) 	int status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7043) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7044) 	status = decode_compound_hdr(xdr, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7045) 	if (status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7046) 		goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7047) 	status = decode_sequence(xdr, &res->seq_res, rqstp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7048) 	if (status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7049) 		goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7050) 	status = decode_putfh(xdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7051) 	if (status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7052) 		goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7053) 	status = decode_getfh(xdr, res->fh);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7054) 	if (status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7055) 		goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7056) 	if (res->renew)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7057) 		status = decode_renew(xdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7058) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7059) 	return status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7060) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7061) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7062) #if defined(CONFIG_NFS_V4_1)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7063) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7064)  * Decode BIND_CONN_TO_SESSION response
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7065)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7066) static int nfs4_xdr_dec_bind_conn_to_session(struct rpc_rqst *rqstp,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7067) 					struct xdr_stream *xdr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7068) 					void *res)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7069) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7070) 	struct compound_hdr hdr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7071) 	int status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7072) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7073) 	status = decode_compound_hdr(xdr, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7074) 	if (!status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7075) 		status = decode_bind_conn_to_session(xdr, res);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7076) 	return status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7077) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7078) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7079) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7080)  * Decode EXCHANGE_ID response
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7081)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7082) static int nfs4_xdr_dec_exchange_id(struct rpc_rqst *rqstp,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7083) 				    struct xdr_stream *xdr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7084) 				    void *res)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7085) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7086) 	struct compound_hdr hdr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7087) 	int status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7088) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7089) 	status = decode_compound_hdr(xdr, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7090) 	if (!status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7091) 		status = decode_exchange_id(xdr, res);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7092) 	return status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7093) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7094) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7095) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7096)  * Decode CREATE_SESSION response
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7097)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7098) static int nfs4_xdr_dec_create_session(struct rpc_rqst *rqstp,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7099) 				       struct xdr_stream *xdr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7100) 				       void *res)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7101) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7102) 	struct compound_hdr hdr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7103) 	int status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7104) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7105) 	status = decode_compound_hdr(xdr, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7106) 	if (!status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7107) 		status = decode_create_session(xdr, res);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7108) 	return status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7109) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7110) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7111) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7112)  * Decode DESTROY_SESSION response
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7113)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7114) static int nfs4_xdr_dec_destroy_session(struct rpc_rqst *rqstp,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7115) 					struct xdr_stream *xdr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7116) 					void *res)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7117) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7118) 	struct compound_hdr hdr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7119) 	int status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7120) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7121) 	status = decode_compound_hdr(xdr, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7122) 	if (!status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7123) 		status = decode_destroy_session(xdr, res);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7124) 	return status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7125) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7126) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7127) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7128)  * Decode DESTROY_CLIENTID response
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7129)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7130) static int nfs4_xdr_dec_destroy_clientid(struct rpc_rqst *rqstp,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7131) 					struct xdr_stream *xdr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7132) 					void *res)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7133) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7134) 	struct compound_hdr hdr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7135) 	int status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7136) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7137) 	status = decode_compound_hdr(xdr, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7138) 	if (!status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7139) 		status = decode_destroy_clientid(xdr, res);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7140) 	return status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7141) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7142) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7143) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7144)  * Decode SEQUENCE response
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7145)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7146) static int nfs4_xdr_dec_sequence(struct rpc_rqst *rqstp,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7147) 				 struct xdr_stream *xdr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7148) 				 void *res)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7149) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7150) 	struct compound_hdr hdr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7151) 	int status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7152) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7153) 	status = decode_compound_hdr(xdr, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7154) 	if (!status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7155) 		status = decode_sequence(xdr, res, rqstp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7156) 	return status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7157) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7158) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7159) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7160) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7161) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7162)  * Decode GET_LEASE_TIME response
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7163)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7164) static int nfs4_xdr_dec_get_lease_time(struct rpc_rqst *rqstp,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7165) 				       struct xdr_stream *xdr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7166) 				       void *data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7167) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7168) 	struct nfs4_get_lease_time_res *res = data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7169) 	struct compound_hdr hdr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7170) 	int status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7171) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7172) 	status = decode_compound_hdr(xdr, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7173) 	if (!status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7174) 		status = decode_sequence(xdr, &res->lr_seq_res, rqstp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7175) 	if (!status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7176) 		status = decode_putrootfh(xdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7177) 	if (!status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7178) 		status = decode_fsinfo(xdr, res->lr_fsinfo);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7179) 	return status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7180) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7181) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7182) #ifdef CONFIG_NFS_V4_1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7183) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7184) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7185)  * Decode RECLAIM_COMPLETE response
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7186)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7187) static int nfs4_xdr_dec_reclaim_complete(struct rpc_rqst *rqstp,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7188) 					 struct xdr_stream *xdr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7189) 					 void *data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7190) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7191) 	struct nfs41_reclaim_complete_res *res = data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7192) 	struct compound_hdr hdr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7193) 	int status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7194) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7195) 	status = decode_compound_hdr(xdr, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7196) 	if (!status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7197) 		status = decode_sequence(xdr, &res->seq_res, rqstp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7198) 	if (!status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7199) 		status = decode_reclaim_complete(xdr, NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7200) 	return status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7201) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7202) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7203) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7204)  * Decode GETDEVINFO response
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7205)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7206) static int nfs4_xdr_dec_getdeviceinfo(struct rpc_rqst *rqstp,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7207) 				      struct xdr_stream *xdr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7208) 				      void *data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7209) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7210) 	struct nfs4_getdeviceinfo_res *res = data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7211) 	struct compound_hdr hdr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7212) 	int status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7213) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7214) 	status = decode_compound_hdr(xdr, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7215) 	if (status != 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7216) 		goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7217) 	status = decode_sequence(xdr, &res->seq_res, rqstp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7218) 	if (status != 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7219) 		goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7220) 	status = decode_getdeviceinfo(xdr, res);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7221) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7222) 	return status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7223) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7224) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7225) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7226)  * Decode LAYOUTGET response
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7227)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7228) static int nfs4_xdr_dec_layoutget(struct rpc_rqst *rqstp,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7229) 				  struct xdr_stream *xdr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7230) 				  void *data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7231) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7232) 	struct nfs4_layoutget_res *res = data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7233) 	struct compound_hdr hdr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7234) 	int status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7235) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7236) 	status = decode_compound_hdr(xdr, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7237) 	if (status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7238) 		goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7239) 	status = decode_sequence(xdr, &res->seq_res, rqstp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7240) 	if (status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7241) 		goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7242) 	status = decode_putfh(xdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7243) 	if (status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7244) 		goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7245) 	status = decode_layoutget(xdr, rqstp, res);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7246) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7247) 	return status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7248) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7249) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7250) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7251)  * Decode LAYOUTRETURN response
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7252)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7253) static int nfs4_xdr_dec_layoutreturn(struct rpc_rqst *rqstp,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7254) 				     struct xdr_stream *xdr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7255) 				     void *data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7256) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7257) 	struct nfs4_layoutreturn_res *res = data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7258) 	struct compound_hdr hdr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7259) 	int status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7260) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7261) 	status = decode_compound_hdr(xdr, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7262) 	if (status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7263) 		goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7264) 	status = decode_sequence(xdr, &res->seq_res, rqstp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7265) 	if (status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7266) 		goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7267) 	status = decode_putfh(xdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7268) 	if (status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7269) 		goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7270) 	status = decode_layoutreturn(xdr, res);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7271) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7272) 	return status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7273) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7274) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7275) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7276)  * Decode LAYOUTCOMMIT response
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7277)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7278) static int nfs4_xdr_dec_layoutcommit(struct rpc_rqst *rqstp,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7279) 				     struct xdr_stream *xdr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7280) 				     void *data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7281) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7282) 	struct nfs4_layoutcommit_res *res = data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7283) 	struct compound_hdr hdr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7284) 	int status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7285) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7286) 	status = decode_compound_hdr(xdr, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7287) 	if (status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7288) 		goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7289) 	status = decode_sequence(xdr, &res->seq_res, rqstp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7290) 	if (status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7291) 		goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7292) 	status = decode_putfh(xdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7293) 	if (status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7294) 		goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7295) 	status = decode_layoutcommit(xdr, rqstp, res);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7296) 	if (status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7297) 		goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7298) 	decode_getfattr(xdr, res->fattr, res->server);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7299) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7300) 	return status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7301) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7302) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7303) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7304)  * Decode SECINFO_NO_NAME response
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7305)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7306) static int nfs4_xdr_dec_secinfo_no_name(struct rpc_rqst *rqstp,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7307) 					struct xdr_stream *xdr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7308) 					void *data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7309) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7310) 	struct nfs4_secinfo_res *res = data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7311) 	struct compound_hdr hdr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7312) 	int status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7313) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7314) 	status = decode_compound_hdr(xdr, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7315) 	if (status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7316) 		goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7317) 	status = decode_sequence(xdr, &res->seq_res, rqstp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7318) 	if (status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7319) 		goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7320) 	status = decode_putrootfh(xdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7321) 	if (status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7322) 		goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7323) 	status = decode_secinfo_no_name(xdr, res);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7324) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7325) 	return status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7326) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7327) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7328) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7329)  * Decode TEST_STATEID response
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7330)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7331) static int nfs4_xdr_dec_test_stateid(struct rpc_rqst *rqstp,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7332) 				     struct xdr_stream *xdr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7333) 				     void *data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7334) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7335) 	struct nfs41_test_stateid_res *res = data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7336) 	struct compound_hdr hdr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7337) 	int status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7338) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7339) 	status = decode_compound_hdr(xdr, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7340) 	if (status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7341) 		goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7342) 	status = decode_sequence(xdr, &res->seq_res, rqstp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7343) 	if (status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7344) 		goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7345) 	status = decode_test_stateid(xdr, res);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7346) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7347) 	return status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7348) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7349) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7350) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7351)  * Decode FREE_STATEID response
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7352)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7353) static int nfs4_xdr_dec_free_stateid(struct rpc_rqst *rqstp,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7354) 				     struct xdr_stream *xdr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7355) 				     void *data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7356) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7357) 	struct nfs41_free_stateid_res *res = data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7358) 	struct compound_hdr hdr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7359) 	int status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7360) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7361) 	status = decode_compound_hdr(xdr, &hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7362) 	if (status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7363) 		goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7364) 	status = decode_sequence(xdr, &res->seq_res, rqstp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7365) 	if (status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7366) 		goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7367) 	status = decode_free_stateid(xdr, res);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7368) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7369) 	return status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7370) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7371) #endif /* CONFIG_NFS_V4_1 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7372) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7373) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7374)  * nfs4_decode_dirent - Decode a single NFSv4 directory entry stored in
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7375)  *                      the local page cache.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7376)  * @xdr: XDR stream where entry resides
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7377)  * @entry: buffer to fill in with entry data
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7378)  * @plus: boolean indicating whether this should be a readdirplus entry
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7379)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7380)  * Returns zero if successful, otherwise a negative errno value is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7381)  * returned.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7382)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7383)  * This function is not invoked during READDIR reply decoding, but
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7384)  * rather whenever an application invokes the getdents(2) system call
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7385)  * on a directory already in our cache.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7386)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7387) int nfs4_decode_dirent(struct xdr_stream *xdr, struct nfs_entry *entry,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7388) 		       bool plus)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7389) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7390) 	unsigned int savep;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7391) 	uint32_t bitmap[3] = {0};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7392) 	uint32_t len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7393) 	uint64_t new_cookie;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7394) 	__be32 *p = xdr_inline_decode(xdr, 4);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7395) 	if (unlikely(!p))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7396) 		return -EAGAIN;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7397) 	if (*p == xdr_zero) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7398) 		p = xdr_inline_decode(xdr, 4);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7399) 		if (unlikely(!p))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7400) 			return -EAGAIN;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7401) 		if (*p == xdr_zero)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7402) 			return -EAGAIN;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7403) 		entry->eof = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7404) 		return -EBADCOOKIE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7405) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7406) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7407) 	p = xdr_inline_decode(xdr, 12);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7408) 	if (unlikely(!p))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7409) 		return -EAGAIN;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7410) 	p = xdr_decode_hyper(p, &new_cookie);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7411) 	entry->len = be32_to_cpup(p);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7412) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7413) 	p = xdr_inline_decode(xdr, entry->len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7414) 	if (unlikely(!p))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7415) 		return -EAGAIN;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7416) 	entry->name = (const char *) p;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7417) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7418) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7419) 	 * In case the server doesn't return an inode number,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7420) 	 * we fake one here.  (We don't use inode number 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7421) 	 * since glibc seems to choke on it...)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7422) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7423) 	entry->ino = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7424) 	entry->fattr->valid = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7425) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7426) 	if (decode_attr_bitmap(xdr, bitmap) < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7427) 		return -EAGAIN;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7428) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7429) 	if (decode_attr_length(xdr, &len, &savep) < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7430) 		return -EAGAIN;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7431) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7432) 	if (decode_getfattr_attrs(xdr, bitmap, entry->fattr, entry->fh,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7433) 			NULL, entry->label, entry->server) < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7434) 		return -EAGAIN;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7435) 	if (entry->fattr->valid & NFS_ATTR_FATTR_MOUNTED_ON_FILEID)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7436) 		entry->ino = entry->fattr->mounted_on_fileid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7437) 	else if (entry->fattr->valid & NFS_ATTR_FATTR_FILEID)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7438) 		entry->ino = entry->fattr->fileid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7439) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7440) 	entry->d_type = DT_UNKNOWN;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7441) 	if (entry->fattr->valid & NFS_ATTR_FATTR_TYPE)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7442) 		entry->d_type = nfs_umode_to_dtype(entry->fattr->mode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7443) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7444) 	entry->prev_cookie = entry->cookie;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7445) 	entry->cookie = new_cookie;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7446) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7447) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7448) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7449) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7450) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7451)  * We need to translate between nfs status return values and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7452)  * the local errno values which may not be the same.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7453)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7454) static struct {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7455) 	int stat;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7456) 	int errno;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7457) } nfs_errtbl[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7458) 	{ NFS4_OK,		0		},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7459) 	{ NFS4ERR_PERM,		-EPERM		},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7460) 	{ NFS4ERR_NOENT,	-ENOENT		},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7461) 	{ NFS4ERR_IO,		-errno_NFSERR_IO},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7462) 	{ NFS4ERR_NXIO,		-ENXIO		},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7463) 	{ NFS4ERR_ACCESS,	-EACCES		},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7464) 	{ NFS4ERR_EXIST,	-EEXIST		},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7465) 	{ NFS4ERR_XDEV,		-EXDEV		},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7466) 	{ NFS4ERR_NOTDIR,	-ENOTDIR	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7467) 	{ NFS4ERR_ISDIR,	-EISDIR		},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7468) 	{ NFS4ERR_INVAL,	-EINVAL		},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7469) 	{ NFS4ERR_FBIG,		-EFBIG		},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7470) 	{ NFS4ERR_NOSPC,	-ENOSPC		},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7471) 	{ NFS4ERR_ROFS,		-EROFS		},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7472) 	{ NFS4ERR_MLINK,	-EMLINK		},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7473) 	{ NFS4ERR_NAMETOOLONG,	-ENAMETOOLONG	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7474) 	{ NFS4ERR_NOTEMPTY,	-ENOTEMPTY	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7475) 	{ NFS4ERR_DQUOT,	-EDQUOT		},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7476) 	{ NFS4ERR_STALE,	-ESTALE		},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7477) 	{ NFS4ERR_BADHANDLE,	-EBADHANDLE	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7478) 	{ NFS4ERR_BAD_COOKIE,	-EBADCOOKIE	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7479) 	{ NFS4ERR_NOTSUPP,	-ENOTSUPP	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7480) 	{ NFS4ERR_TOOSMALL,	-ETOOSMALL	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7481) 	{ NFS4ERR_SERVERFAULT,	-EREMOTEIO	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7482) 	{ NFS4ERR_BADTYPE,	-EBADTYPE	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7483) 	{ NFS4ERR_LOCKED,	-EAGAIN		},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7484) 	{ NFS4ERR_SYMLINK,	-ELOOP		},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7485) 	{ NFS4ERR_OP_ILLEGAL,	-EOPNOTSUPP	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7486) 	{ NFS4ERR_DEADLOCK,	-EDEADLK	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7487) 	{ NFS4ERR_NOXATTR,	-ENODATA	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7488) 	{ NFS4ERR_XATTR2BIG,	-E2BIG		},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7489) 	{ -1,			-EIO		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7490) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7491) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7492) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7493)  * Convert an NFS error code to a local one.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7494)  * This one is used jointly by NFSv2 and NFSv3.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7495)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7496) static int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7497) nfs4_stat_to_errno(int stat)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7498) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7499) 	int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7500) 	for (i = 0; nfs_errtbl[i].stat != -1; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7501) 		if (nfs_errtbl[i].stat == stat)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7502) 			return nfs_errtbl[i].errno;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7503) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7504) 	if (stat <= 10000 || stat > 10100) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7505) 		/* The server is looney tunes. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7506) 		return -EREMOTEIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7507) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7508) 	/* If we cannot translate the error, the recovery routines should
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7509) 	 * handle it.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7510) 	 * Note: remaining NFSv4 error codes have values > 10000, so should
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7511) 	 * not conflict with native Linux error codes.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7512) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7513) 	return -stat;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7514) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7515) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7516) #ifdef CONFIG_NFS_V4_2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7517) #include "nfs42xdr.c"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7518) #endif /* CONFIG_NFS_V4_2 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7519) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7520) #define PROC(proc, argtype, restype)				\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7521) [NFSPROC4_CLNT_##proc] = {					\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7522) 	.p_proc   = NFSPROC4_COMPOUND,				\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7523) 	.p_encode = nfs4_xdr_##argtype,				\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7524) 	.p_decode = nfs4_xdr_##restype,				\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7525) 	.p_arglen = NFS4_##argtype##_sz,			\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7526) 	.p_replen = NFS4_##restype##_sz,			\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7527) 	.p_statidx = NFSPROC4_CLNT_##proc,			\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7528) 	.p_name   = #proc,					\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7529) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7530) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7531) #define STUB(proc)		\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7532) [NFSPROC4_CLNT_##proc] = {	\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7533) 	.p_name = #proc,	\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7534) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7535) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7536) #if defined(CONFIG_NFS_V4_1)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7537) #define PROC41(proc, argtype, restype)				\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7538) 	PROC(proc, argtype, restype)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7539) #else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7540) #define PROC41(proc, argtype, restype)				\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7541) 	STUB(proc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7542) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7543) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7544) #if defined(CONFIG_NFS_V4_2)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7545) #define PROC42(proc, argtype, restype)				\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7546) 	PROC(proc, argtype, restype)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7547) #else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7548) #define PROC42(proc, argtype, restype)				\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7549) 	STUB(proc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7550) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7551) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7552) const struct rpc_procinfo nfs4_procedures[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7553) 	PROC(READ,		enc_read,		dec_read),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7554) 	PROC(WRITE,		enc_write,		dec_write),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7555) 	PROC(COMMIT,		enc_commit,		dec_commit),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7556) 	PROC(OPEN,		enc_open,		dec_open),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7557) 	PROC(OPEN_CONFIRM,	enc_open_confirm,	dec_open_confirm),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7558) 	PROC(OPEN_NOATTR,	enc_open_noattr,	dec_open_noattr),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7559) 	PROC(OPEN_DOWNGRADE,	enc_open_downgrade,	dec_open_downgrade),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7560) 	PROC(CLOSE,		enc_close,		dec_close),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7561) 	PROC(SETATTR,		enc_setattr,		dec_setattr),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7562) 	PROC(FSINFO,		enc_fsinfo,		dec_fsinfo),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7563) 	PROC(RENEW,		enc_renew,		dec_renew),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7564) 	PROC(SETCLIENTID,	enc_setclientid,	dec_setclientid),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7565) 	PROC(SETCLIENTID_CONFIRM, enc_setclientid_confirm, dec_setclientid_confirm),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7566) 	PROC(LOCK,		enc_lock,		dec_lock),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7567) 	PROC(LOCKT,		enc_lockt,		dec_lockt),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7568) 	PROC(LOCKU,		enc_locku,		dec_locku),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7569) 	PROC(ACCESS,		enc_access,		dec_access),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7570) 	PROC(GETATTR,		enc_getattr,		dec_getattr),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7571) 	PROC(LOOKUP,		enc_lookup,		dec_lookup),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7572) 	PROC(LOOKUP_ROOT,	enc_lookup_root,	dec_lookup_root),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7573) 	PROC(REMOVE,		enc_remove,		dec_remove),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7574) 	PROC(RENAME,		enc_rename,		dec_rename),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7575) 	PROC(LINK,		enc_link,		dec_link),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7576) 	PROC(SYMLINK,		enc_symlink,		dec_symlink),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7577) 	PROC(CREATE,		enc_create,		dec_create),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7578) 	PROC(PATHCONF,		enc_pathconf,		dec_pathconf),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7579) 	PROC(STATFS,		enc_statfs,		dec_statfs),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7580) 	PROC(READLINK,		enc_readlink,		dec_readlink),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7581) 	PROC(READDIR,		enc_readdir,		dec_readdir),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7582) 	PROC(SERVER_CAPS,	enc_server_caps,	dec_server_caps),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7583) 	PROC(DELEGRETURN,	enc_delegreturn,	dec_delegreturn),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7584) 	PROC(GETACL,		enc_getacl,		dec_getacl),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7585) 	PROC(SETACL,		enc_setacl,		dec_setacl),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7586) 	PROC(FS_LOCATIONS,	enc_fs_locations,	dec_fs_locations),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7587) 	PROC(RELEASE_LOCKOWNER,	enc_release_lockowner,	dec_release_lockowner),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7588) 	PROC(SECINFO,		enc_secinfo,		dec_secinfo),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7589) 	PROC(FSID_PRESENT,	enc_fsid_present,	dec_fsid_present),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7590) 	PROC41(EXCHANGE_ID,	enc_exchange_id,	dec_exchange_id),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7591) 	PROC41(CREATE_SESSION,	enc_create_session,	dec_create_session),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7592) 	PROC41(DESTROY_SESSION,	enc_destroy_session,	dec_destroy_session),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7593) 	PROC41(SEQUENCE,	enc_sequence,		dec_sequence),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7594) 	PROC(GET_LEASE_TIME,	enc_get_lease_time,	dec_get_lease_time),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7595) 	PROC41(RECLAIM_COMPLETE,enc_reclaim_complete,	dec_reclaim_complete),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7596) 	PROC41(GETDEVICEINFO,	enc_getdeviceinfo,	dec_getdeviceinfo),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7597) 	PROC41(LAYOUTGET,	enc_layoutget,		dec_layoutget),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7598) 	PROC41(LAYOUTCOMMIT,	enc_layoutcommit,	dec_layoutcommit),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7599) 	PROC41(LAYOUTRETURN,	enc_layoutreturn,	dec_layoutreturn),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7600) 	PROC41(SECINFO_NO_NAME,	enc_secinfo_no_name,	dec_secinfo_no_name),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7601) 	PROC41(TEST_STATEID,	enc_test_stateid,	dec_test_stateid),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7602) 	PROC41(FREE_STATEID,	enc_free_stateid,	dec_free_stateid),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7603) 	STUB(GETDEVICELIST),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7604) 	PROC41(BIND_CONN_TO_SESSION,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7605) 			enc_bind_conn_to_session, dec_bind_conn_to_session),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7606) 	PROC41(DESTROY_CLIENTID,enc_destroy_clientid,	dec_destroy_clientid),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7607) 	PROC42(SEEK,		enc_seek,		dec_seek),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7608) 	PROC42(ALLOCATE,	enc_allocate,		dec_allocate),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7609) 	PROC42(DEALLOCATE,	enc_deallocate,		dec_deallocate),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7610) 	PROC42(LAYOUTSTATS,	enc_layoutstats,	dec_layoutstats),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7611) 	PROC42(CLONE,		enc_clone,		dec_clone),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7612) 	PROC42(COPY,		enc_copy,		dec_copy),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7613) 	PROC42(OFFLOAD_CANCEL,	enc_offload_cancel,	dec_offload_cancel),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7614) 	PROC42(COPY_NOTIFY,	enc_copy_notify,	dec_copy_notify),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7615) 	PROC(LOOKUPP,		enc_lookupp,		dec_lookupp),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7616) 	PROC42(LAYOUTERROR,	enc_layouterror,	dec_layouterror),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7617) 	PROC42(GETXATTR,	enc_getxattr,		dec_getxattr),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7618) 	PROC42(SETXATTR,	enc_setxattr,		dec_setxattr),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7619) 	PROC42(LISTXATTRS,	enc_listxattrs,		dec_listxattrs),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7620) 	PROC42(REMOVEXATTR,	enc_removexattr,	dec_removexattr),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7621) 	PROC42(READ_PLUS,	enc_read_plus,		dec_read_plus),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7622) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7623) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7624) static unsigned int nfs_version4_counts[ARRAY_SIZE(nfs4_procedures)];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7625) const struct rpc_version nfs_version4 = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7626) 	.number			= 4,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7627) 	.nrprocs		= ARRAY_SIZE(nfs4_procedures),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7628) 	.procs			= nfs4_procedures,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7629) 	.counts			= nfs_version4_counts,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7630) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7631) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7632) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7633)  * Local variables:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7634)  *  c-basic-offset: 8
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7635)  * End:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7636)  */