| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* | 
|  | 2 | *  fs/nfs/nfs4xdr.c | 
|  | 3 | * | 
|  | 4 | *  Client-side XDR for NFSv4. | 
|  | 5 | * | 
|  | 6 | *  Copyright (c) 2002 The Regents of the University of Michigan. | 
|  | 7 | *  All rights reserved. | 
|  | 8 | * | 
|  | 9 | *  Kendrick Smith <kmsmith@umich.edu> | 
|  | 10 | *  Andy Adamson   <andros@umich.edu> | 
| Andy Adamson | 6c0195a | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 11 | * | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 12 | *  Redistribution and use in source and binary forms, with or without | 
|  | 13 | *  modification, are permitted provided that the following conditions | 
|  | 14 | *  are met: | 
|  | 15 | * | 
|  | 16 | *  1. Redistributions of source code must retain the above copyright | 
|  | 17 | *     notice, this list of conditions and the following disclaimer. | 
|  | 18 | *  2. Redistributions in binary form must reproduce the above copyright | 
|  | 19 | *     notice, this list of conditions and the following disclaimer in the | 
|  | 20 | *     documentation and/or other materials provided with the distribution. | 
|  | 21 | *  3. Neither the name of the University nor the names of its | 
|  | 22 | *     contributors may be used to endorse or promote products derived | 
|  | 23 | *     from this software without specific prior written permission. | 
|  | 24 | * | 
|  | 25 | *  THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED | 
|  | 26 | *  WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF | 
|  | 27 | *  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | 
|  | 28 | *  DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | 
|  | 29 | *  FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | 
|  | 30 | *  CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | 
|  | 31 | *  SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR | 
|  | 32 | *  BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF | 
|  | 33 | *  LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING | 
|  | 34 | *  NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | 
|  | 35 | *  SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 
|  | 36 | */ | 
|  | 37 |  | 
|  | 38 | #include <linux/param.h> | 
|  | 39 | #include <linux/time.h> | 
|  | 40 | #include <linux/mm.h> | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 41 | #include <linux/errno.h> | 
|  | 42 | #include <linux/string.h> | 
|  | 43 | #include <linux/in.h> | 
|  | 44 | #include <linux/pagemap.h> | 
|  | 45 | #include <linux/proc_fs.h> | 
|  | 46 | #include <linux/kdev_t.h> | 
| Weston Andros Adamson | db8ac8b | 2012-02-17 15:20:24 -0500 | [diff] [blame] | 47 | #include <linux/module.h> | 
|  | 48 | #include <linux/utsname.h> | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 49 | #include <linux/sunrpc/clnt.h> | 
| Alexandros Batsakis | 2449ea2 | 2009-12-05 13:36:55 -0500 | [diff] [blame] | 50 | #include <linux/sunrpc/msg_prot.h> | 
| Bryan Schumaker | 5a5ea0d | 2011-03-24 17:12:29 +0000 | [diff] [blame] | 51 | #include <linux/sunrpc/gss_api.h> | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 52 | #include <linux/nfs.h> | 
|  | 53 | #include <linux/nfs4.h> | 
|  | 54 | #include <linux/nfs_fs.h> | 
| Chuck Lever | f092075 | 2012-05-21 22:45:41 -0400 | [diff] [blame] | 55 |  | 
| Trond Myklebust | 4ce7971 | 2005-06-22 17:16:21 +0000 | [diff] [blame] | 56 | #include "nfs4_fs.h" | 
| Alexandros Batsakis | 4882ef7 | 2009-12-05 13:30:21 -0500 | [diff] [blame] | 57 | #include "internal.h" | 
| Anna Schumaker | 40c64c2 | 2015-04-15 13:00:05 -0400 | [diff] [blame] | 58 | #include "nfs4idmap.h" | 
| Trond Myklebust | 76e697b | 2012-11-26 14:20:49 -0500 | [diff] [blame] | 59 | #include "nfs4session.h" | 
| Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 60 | #include "pnfs.h" | 
| Chuck Lever | f092075 | 2012-05-21 22:45:41 -0400 | [diff] [blame] | 61 | #include "netns.h" | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 62 |  | 
|  | 63 | #define NFSDBG_FACILITY		NFSDBG_XDR | 
|  | 64 |  | 
|  | 65 | /* Mapping from NFS error code to "errno" error code. */ | 
|  | 66 | #define errno_NFSERR_IO		EIO | 
|  | 67 |  | 
| David Howells | 0a8ea43 | 2006-08-22 20:06:08 -0400 | [diff] [blame] | 68 | static int nfs4_stat_to_errno(int); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 69 |  | 
|  | 70 | /* NFSv4 COMPOUND tags are only wanted for debugging purposes */ | 
|  | 71 | #ifdef DEBUG | 
|  | 72 | #define NFS4_MAXTAGLEN		20 | 
|  | 73 | #else | 
|  | 74 | #define NFS4_MAXTAGLEN		0 | 
|  | 75 | #endif | 
|  | 76 |  | 
| Andy Adamson | 6c0195a | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 77 | /* lock,open owner id: | 
| Trond Myklebust | 9f958ab | 2007-07-02 13:58:33 -0400 | [diff] [blame] | 78 | * we currently use size 2 (u64) out of (NFS4_OPAQUE_LIMIT  >> 2) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 79 | */ | 
| Trond Myklebust | 95b72eb | 2012-04-20 19:24:51 -0400 | [diff] [blame] | 80 | #define open_owner_id_maxsz	(1 + 2 + 1 + 1 + 2) | 
| Trond Myklebust | d035c36 | 2010-12-21 10:45:27 -0500 | [diff] [blame] | 81 | #define lock_owner_id_maxsz	(1 + 1 + 4) | 
| Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 82 | #define decode_lockowner_maxsz	(1 + XDR_QUADLEN(IDMAP_NAMESZ)) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 83 | #define compound_encode_hdr_maxsz	(3 + (NFS4_MAXTAGLEN >> 2)) | 
|  | 84 | #define compound_decode_hdr_maxsz	(3 + (NFS4_MAXTAGLEN >> 2)) | 
|  | 85 | #define op_encode_hdr_maxsz	(1) | 
|  | 86 | #define op_decode_hdr_maxsz	(2) | 
| Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 87 | #define encode_stateid_maxsz	(XDR_QUADLEN(NFS4_STATEID_SIZE)) | 
|  | 88 | #define decode_stateid_maxsz	(XDR_QUADLEN(NFS4_STATEID_SIZE)) | 
|  | 89 | #define encode_verifier_maxsz	(XDR_QUADLEN(NFS4_VERIFIER_SIZE)) | 
|  | 90 | #define decode_verifier_maxsz	(XDR_QUADLEN(NFS4_VERIFIER_SIZE)) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 91 | #define encode_putfh_maxsz	(op_encode_hdr_maxsz + 1 + \ | 
|  | 92 | (NFS4_FHSIZE >> 2)) | 
|  | 93 | #define decode_putfh_maxsz	(op_decode_hdr_maxsz) | 
|  | 94 | #define encode_putrootfh_maxsz	(op_encode_hdr_maxsz) | 
|  | 95 | #define decode_putrootfh_maxsz	(op_decode_hdr_maxsz) | 
|  | 96 | #define encode_getfh_maxsz      (op_encode_hdr_maxsz) | 
|  | 97 | #define decode_getfh_maxsz      (op_decode_hdr_maxsz + 1 + \ | 
|  | 98 | ((3+NFS4_FHSIZE) >> 2)) | 
| Andy Adamson | e5012d1 | 2011-07-11 17:17:42 -0400 | [diff] [blame] | 99 | #define nfs4_fattr_bitmap_maxsz 4 | 
| J. Bruce Fields | 9692820 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 100 | #define encode_getattr_maxsz    (op_encode_hdr_maxsz + nfs4_fattr_bitmap_maxsz) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 101 | #define nfs4_name_maxsz		(1 + ((3 + NFS4_MAXNAMLEN) >> 2)) | 
|  | 102 | #define nfs4_path_maxsz		(1 + ((3 + NFS4_MAXPATHLEN) >> 2)) | 
| Trond Myklebust | bd625ba | 2007-07-08 18:38:23 -0400 | [diff] [blame] | 103 | #define nfs4_owner_maxsz	(1 + XDR_QUADLEN(IDMAP_NAMESZ)) | 
|  | 104 | #define nfs4_group_maxsz	(1 + XDR_QUADLEN(IDMAP_NAMESZ)) | 
| David Quigley | aa9c266 | 2013-05-22 12:50:44 -0400 | [diff] [blame] | 105 | #ifdef CONFIG_NFS_V4_SECURITY_LABEL | 
|  | 106 | /* PI(4 bytes) + LFS(4 bytes) + 1(for null terminator?) + MAXLABELLEN */ | 
|  | 107 | #define	nfs4_label_maxsz	(4 + 4 + 1 + XDR_QUADLEN(NFS4_MAXLABELLEN)) | 
| David Quigley | aa9c266 | 2013-05-22 12:50:44 -0400 | [diff] [blame] | 108 | #else | 
|  | 109 | #define	nfs4_label_maxsz	0 | 
| David Quigley | aa9c266 | 2013-05-22 12:50:44 -0400 | [diff] [blame] | 110 | #endif | 
| Andy Adamson | 88034c3 | 2012-05-23 05:02:34 -0400 | [diff] [blame] | 111 | /* We support only one layout type per file system */ | 
|  | 112 | #define decode_mdsthreshold_maxsz (1 + 1 + nfs4_fattr_bitmap_maxsz + 1 + 8) | 
| J. Bruce Fields | 9692820 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 113 | /* This is based on getfattr, which uses the most attributes: */ | 
|  | 114 | #define nfs4_fattr_value_maxsz	(1 + (1 + 2 + 2 + 4 + 2 + 1 + 1 + 2 + 2 + \ | 
| Andy Adamson | 88034c3 | 2012-05-23 05:02:34 -0400 | [diff] [blame] | 115 | 3 + 3 + 3 + nfs4_owner_maxsz + \ | 
| David Quigley | aa9c266 | 2013-05-22 12:50:44 -0400 | [diff] [blame] | 116 | nfs4_group_maxsz + nfs4_label_maxsz + \ | 
|  | 117 | decode_mdsthreshold_maxsz)) | 
| J. Bruce Fields | 9692820 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 118 | #define nfs4_fattr_maxsz	(nfs4_fattr_bitmap_maxsz + \ | 
|  | 119 | nfs4_fattr_value_maxsz) | 
|  | 120 | #define decode_getattr_maxsz    (op_decode_hdr_maxsz + nfs4_fattr_maxsz) | 
| Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 121 | #define encode_attrs_maxsz	(nfs4_fattr_bitmap_maxsz + \ | 
|  | 122 | 1 + 2 + 1 + \ | 
|  | 123 | nfs4_owner_maxsz + \ | 
|  | 124 | nfs4_group_maxsz + \ | 
| David Quigley | aa9c266 | 2013-05-22 12:50:44 -0400 | [diff] [blame] | 125 | nfs4_label_maxsz + \ | 
| Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 126 | 4 + 4) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 127 | #define encode_savefh_maxsz     (op_encode_hdr_maxsz) | 
|  | 128 | #define decode_savefh_maxsz     (op_decode_hdr_maxsz) | 
| Trond Myklebust | 56ae19f | 2005-10-27 22:12:40 -0400 | [diff] [blame] | 129 | #define encode_restorefh_maxsz  (op_encode_hdr_maxsz) | 
|  | 130 | #define decode_restorefh_maxsz  (op_decode_hdr_maxsz) | 
| Fred Isaman | 2f42b5d | 2008-03-13 15:26:30 +0200 | [diff] [blame] | 131 | #define encode_fsinfo_maxsz	(encode_getattr_maxsz) | 
| Fred Isaman | dae100c | 2011-07-30 20:52:37 -0400 | [diff] [blame] | 132 | /* The 5 accounts for the PNFS attributes, and assumes that at most three | 
|  | 133 | * layout types will be returned. | 
|  | 134 | */ | 
|  | 135 | #define decode_fsinfo_maxsz	(op_decode_hdr_maxsz + \ | 
|  | 136 | nfs4_fattr_bitmap_maxsz + 4 + 8 + 5) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 137 | #define encode_renew_maxsz	(op_encode_hdr_maxsz + 3) | 
|  | 138 | #define decode_renew_maxsz	(op_decode_hdr_maxsz) | 
|  | 139 | #define encode_setclientid_maxsz \ | 
|  | 140 | (op_encode_hdr_maxsz + \ | 
| Chuck Lever | cc38bac | 2007-12-10 14:56:54 -0500 | [diff] [blame] | 141 | XDR_QUADLEN(NFS4_VERIFIER_SIZE) + \ | 
| Jeff Layton | b8fb2f5 | 2015-06-09 19:43:58 -0400 | [diff] [blame] | 142 | /* client name */ \ | 
|  | 143 | 1 + XDR_QUADLEN(NFS4_OPAQUE_LIMIT) + \ | 
| Chuck Lever | cc38bac | 2007-12-10 14:56:54 -0500 | [diff] [blame] | 144 | 1 /* sc_prog */ + \ | 
| Chuck Lever | 6dd3436 | 2014-11-08 20:15:18 -0500 | [diff] [blame] | 145 | 1 + XDR_QUADLEN(RPCBIND_MAXNETIDLEN) + \ | 
|  | 146 | 1 + XDR_QUADLEN(RPCBIND_MAXUADDRLEN) + \ | 
| Chuck Lever | cc38bac | 2007-12-10 14:56:54 -0500 | [diff] [blame] | 147 | 1) /* sc_cb_ident */ | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 148 | #define decode_setclientid_maxsz \ | 
|  | 149 | (op_decode_hdr_maxsz + \ | 
| Chuck Lever | 6dd3436 | 2014-11-08 20:15:18 -0500 | [diff] [blame] | 150 | 2 /* clientid */ + \ | 
|  | 151 | XDR_QUADLEN(NFS4_VERIFIER_SIZE) + \ | 
|  | 152 | 1 + XDR_QUADLEN(RPCBIND_MAXNETIDLEN) + \ | 
|  | 153 | 1 + XDR_QUADLEN(RPCBIND_MAXUADDRLEN)) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 154 | #define encode_setclientid_confirm_maxsz \ | 
|  | 155 | (op_encode_hdr_maxsz + \ | 
|  | 156 | 3 + (NFS4_VERIFIER_SIZE >> 2)) | 
|  | 157 | #define decode_setclientid_confirm_maxsz \ | 
|  | 158 | (op_decode_hdr_maxsz) | 
| Trond Myklebust | e688962 | 2007-07-02 13:58:30 -0400 | [diff] [blame] | 159 | #define encode_lookup_maxsz	(op_encode_hdr_maxsz + nfs4_name_maxsz) | 
|  | 160 | #define decode_lookup_maxsz	(op_decode_hdr_maxsz) | 
| Trond Myklebust | 2cebf82 | 2007-07-02 13:57:28 -0400 | [diff] [blame] | 161 | #define encode_share_access_maxsz \ | 
|  | 162 | (2) | 
| Alexandros Batsakis | 4882ef7 | 2009-12-05 13:30:21 -0500 | [diff] [blame] | 163 | #define encode_createmode_maxsz	(1 + encode_attrs_maxsz + encode_verifier_maxsz) | 
| Trond Myklebust | 2cebf82 | 2007-07-02 13:57:28 -0400 | [diff] [blame] | 164 | #define encode_opentype_maxsz	(1 + encode_createmode_maxsz) | 
|  | 165 | #define encode_claim_null_maxsz	(1 + nfs4_name_maxsz) | 
|  | 166 | #define encode_open_maxsz	(op_encode_hdr_maxsz + \ | 
|  | 167 | 2 + encode_share_access_maxsz + 2 + \ | 
|  | 168 | open_owner_id_maxsz + \ | 
|  | 169 | encode_opentype_maxsz + \ | 
|  | 170 | encode_claim_null_maxsz) | 
|  | 171 | #define decode_ace_maxsz	(3 + nfs4_owner_maxsz) | 
| Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 172 | #define decode_delegation_maxsz	(1 + decode_stateid_maxsz + 1 + \ | 
| Trond Myklebust | 2cebf82 | 2007-07-02 13:57:28 -0400 | [diff] [blame] | 173 | decode_ace_maxsz) | 
|  | 174 | #define decode_change_info_maxsz	(5) | 
|  | 175 | #define decode_open_maxsz	(op_decode_hdr_maxsz + \ | 
| Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 176 | decode_stateid_maxsz + \ | 
| Trond Myklebust | 2cebf82 | 2007-07-02 13:57:28 -0400 | [diff] [blame] | 177 | decode_change_info_maxsz + 1 + \ | 
|  | 178 | nfs4_fattr_bitmap_maxsz + \ | 
|  | 179 | decode_delegation_maxsz) | 
| Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 180 | #define encode_open_confirm_maxsz \ | 
|  | 181 | (op_encode_hdr_maxsz + \ | 
|  | 182 | encode_stateid_maxsz + 1) | 
|  | 183 | #define decode_open_confirm_maxsz \ | 
|  | 184 | (op_decode_hdr_maxsz + \ | 
|  | 185 | decode_stateid_maxsz) | 
|  | 186 | #define encode_open_downgrade_maxsz \ | 
|  | 187 | (op_encode_hdr_maxsz + \ | 
|  | 188 | encode_stateid_maxsz + 1 + \ | 
|  | 189 | encode_share_access_maxsz) | 
|  | 190 | #define decode_open_downgrade_maxsz \ | 
|  | 191 | (op_decode_hdr_maxsz + \ | 
|  | 192 | decode_stateid_maxsz) | 
|  | 193 | #define encode_close_maxsz	(op_encode_hdr_maxsz + \ | 
|  | 194 | 1 + encode_stateid_maxsz) | 
|  | 195 | #define decode_close_maxsz	(op_decode_hdr_maxsz + \ | 
|  | 196 | decode_stateid_maxsz) | 
|  | 197 | #define encode_setattr_maxsz	(op_encode_hdr_maxsz + \ | 
|  | 198 | encode_stateid_maxsz + \ | 
|  | 199 | encode_attrs_maxsz) | 
|  | 200 | #define decode_setattr_maxsz	(op_decode_hdr_maxsz + \ | 
|  | 201 | nfs4_fattr_bitmap_maxsz) | 
|  | 202 | #define encode_read_maxsz	(op_encode_hdr_maxsz + \ | 
|  | 203 | encode_stateid_maxsz + 3) | 
|  | 204 | #define decode_read_maxsz	(op_decode_hdr_maxsz + 2) | 
|  | 205 | #define encode_readdir_maxsz	(op_encode_hdr_maxsz + \ | 
| David Quigley | aa9c266 | 2013-05-22 12:50:44 -0400 | [diff] [blame] | 206 | 2 + encode_verifier_maxsz + 5 + \ | 
|  | 207 | nfs4_label_maxsz) | 
| Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 208 | #define decode_readdir_maxsz	(op_decode_hdr_maxsz + \ | 
| Chuck Lever | a7697f6 | 2014-03-12 12:51:17 -0400 | [diff] [blame] | 209 | decode_verifier_maxsz) | 
| Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 210 | #define encode_readlink_maxsz	(op_encode_hdr_maxsz) | 
|  | 211 | #define decode_readlink_maxsz	(op_decode_hdr_maxsz + 1) | 
|  | 212 | #define encode_write_maxsz	(op_encode_hdr_maxsz + \ | 
|  | 213 | encode_stateid_maxsz + 4) | 
|  | 214 | #define decode_write_maxsz	(op_decode_hdr_maxsz + \ | 
|  | 215 | 2 + decode_verifier_maxsz) | 
|  | 216 | #define encode_commit_maxsz	(op_encode_hdr_maxsz + 3) | 
|  | 217 | #define decode_commit_maxsz	(op_decode_hdr_maxsz + \ | 
|  | 218 | decode_verifier_maxsz) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 219 | #define encode_remove_maxsz	(op_encode_hdr_maxsz + \ | 
|  | 220 | nfs4_name_maxsz) | 
| Benny Halevy | 6ce1839 | 2009-04-01 09:22:06 -0400 | [diff] [blame] | 221 | #define decode_remove_maxsz	(op_decode_hdr_maxsz + \ | 
|  | 222 | decode_change_info_maxsz) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 223 | #define encode_rename_maxsz	(op_encode_hdr_maxsz + \ | 
|  | 224 | 2 * nfs4_name_maxsz) | 
| Benny Halevy | 6ce1839 | 2009-04-01 09:22:06 -0400 | [diff] [blame] | 225 | #define decode_rename_maxsz	(op_decode_hdr_maxsz + \ | 
|  | 226 | decode_change_info_maxsz + \ | 
|  | 227 | decode_change_info_maxsz) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 228 | #define encode_link_maxsz	(op_encode_hdr_maxsz + \ | 
|  | 229 | nfs4_name_maxsz) | 
| Benny Halevy | 6ce1839 | 2009-04-01 09:22:06 -0400 | [diff] [blame] | 230 | #define decode_link_maxsz	(op_decode_hdr_maxsz + decode_change_info_maxsz) | 
| Trond Myklebust | daccbde | 2010-06-25 18:11:43 -0400 | [diff] [blame] | 231 | #define encode_lockowner_maxsz	(7) | 
| Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 232 | #define encode_lock_maxsz	(op_encode_hdr_maxsz + \ | 
|  | 233 | 7 + \ | 
| Trond Myklebust | daccbde | 2010-06-25 18:11:43 -0400 | [diff] [blame] | 234 | 1 + encode_stateid_maxsz + 1 + \ | 
|  | 235 | encode_lockowner_maxsz) | 
| Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 236 | #define decode_lock_denied_maxsz \ | 
|  | 237 | (8 + decode_lockowner_maxsz) | 
|  | 238 | #define decode_lock_maxsz	(op_decode_hdr_maxsz + \ | 
|  | 239 | decode_lock_denied_maxsz) | 
| Trond Myklebust | daccbde | 2010-06-25 18:11:43 -0400 | [diff] [blame] | 240 | #define encode_lockt_maxsz	(op_encode_hdr_maxsz + 5 + \ | 
|  | 241 | encode_lockowner_maxsz) | 
| Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 242 | #define decode_lockt_maxsz	(op_decode_hdr_maxsz + \ | 
|  | 243 | decode_lock_denied_maxsz) | 
|  | 244 | #define encode_locku_maxsz	(op_encode_hdr_maxsz + 3 + \ | 
|  | 245 | encode_stateid_maxsz + \ | 
|  | 246 | 4) | 
|  | 247 | #define decode_locku_maxsz	(op_decode_hdr_maxsz + \ | 
|  | 248 | decode_stateid_maxsz) | 
| Trond Myklebust | d3c7b7c | 2010-07-01 12:49:01 -0400 | [diff] [blame] | 249 | #define encode_release_lockowner_maxsz \ | 
|  | 250 | (op_encode_hdr_maxsz + \ | 
|  | 251 | encode_lockowner_maxsz) | 
|  | 252 | #define decode_release_lockowner_maxsz \ | 
|  | 253 | (op_decode_hdr_maxsz) | 
| Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 254 | #define encode_access_maxsz	(op_encode_hdr_maxsz + 1) | 
|  | 255 | #define decode_access_maxsz	(op_decode_hdr_maxsz + 2) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 256 | #define encode_symlink_maxsz	(op_encode_hdr_maxsz + \ | 
|  | 257 | 1 + nfs4_name_maxsz + \ | 
| Chuck Lever | 94a6d75 | 2006-08-22 20:06:23 -0400 | [diff] [blame] | 258 | 1 + \ | 
| J. Bruce Fields | 9692820 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 259 | nfs4_fattr_maxsz) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 260 | #define decode_symlink_maxsz	(op_decode_hdr_maxsz + 8) | 
|  | 261 | #define encode_create_maxsz	(op_encode_hdr_maxsz + \ | 
| Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 262 | 1 + 2 + nfs4_name_maxsz + \ | 
|  | 263 | encode_attrs_maxsz) | 
| Trond Myklebust | 2cebf82 | 2007-07-02 13:57:28 -0400 | [diff] [blame] | 264 | #define decode_create_maxsz	(op_decode_hdr_maxsz + \ | 
|  | 265 | decode_change_info_maxsz + \ | 
|  | 266 | nfs4_fattr_bitmap_maxsz) | 
| Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 267 | #define encode_statfs_maxsz	(encode_getattr_maxsz) | 
|  | 268 | #define decode_statfs_maxsz	(decode_getattr_maxsz) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 269 | #define encode_delegreturn_maxsz (op_encode_hdr_maxsz + 4) | 
|  | 270 | #define decode_delegreturn_maxsz (op_decode_hdr_maxsz) | 
| Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 271 | #define encode_getacl_maxsz	(encode_getattr_maxsz) | 
|  | 272 | #define decode_getacl_maxsz	(op_decode_hdr_maxsz + \ | 
|  | 273 | nfs4_fattr_bitmap_maxsz + 1) | 
|  | 274 | #define encode_setacl_maxsz	(op_encode_hdr_maxsz + \ | 
|  | 275 | encode_stateid_maxsz + 3) | 
|  | 276 | #define decode_setacl_maxsz	(decode_setattr_maxsz) | 
| Trond Myklebust | e688962 | 2007-07-02 13:58:30 -0400 | [diff] [blame] | 277 | #define encode_fs_locations_maxsz \ | 
|  | 278 | (encode_getattr_maxsz) | 
|  | 279 | #define decode_fs_locations_maxsz \ | 
|  | 280 | (0) | 
| Bryan Schumaker | 5a5ea0d | 2011-03-24 17:12:29 +0000 | [diff] [blame] | 281 | #define encode_secinfo_maxsz	(op_encode_hdr_maxsz + nfs4_name_maxsz) | 
| Bryan Schumaker | 1650add | 2011-06-02 15:07:35 -0400 | [diff] [blame] | 282 | #define decode_secinfo_maxsz	(op_decode_hdr_maxsz + 1 + ((NFS_MAX_SECFLAVORS * (16 + GSS_OID_MAX_LEN)) / 4)) | 
| Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 283 |  | 
|  | 284 | #if defined(CONFIG_NFS_V4_1) | 
| Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 285 | #define NFS4_MAX_MACHINE_NAME_LEN (64) | 
| Jim Rees | d751f74 | 2012-11-16 18:12:06 -0500 | [diff] [blame] | 286 | #define IMPL_NAME_LIMIT (sizeof(utsname()->sysname) + sizeof(utsname()->release) + \ | 
|  | 287 | sizeof(utsname()->version) + sizeof(utsname()->machine) + 8) | 
| Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 288 |  | 
| Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 289 | #define encode_exchange_id_maxsz (op_encode_hdr_maxsz + \ | 
|  | 290 | encode_verifier_maxsz + \ | 
|  | 291 | 1 /* co_ownerid.len */ + \ | 
| Jeff Layton | b8fb2f5 | 2015-06-09 19:43:58 -0400 | [diff] [blame] | 292 | /* eia_clientowner */ \ | 
|  | 293 | 1 + XDR_QUADLEN(NFS4_OPAQUE_LIMIT) + \ | 
| Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 294 | 1 /* flags */ + \ | 
|  | 295 | 1 /* spa_how */ + \ | 
| Weston Andros Adamson | 2031cd1 | 2013-08-13 16:37:32 -0400 | [diff] [blame] | 296 | /* max is SP4_MACH_CRED (for now) */ + \ | 
|  | 297 | 1 + NFS4_OP_MAP_NUM_WORDS + \ | 
|  | 298 | 1 + NFS4_OP_MAP_NUM_WORDS + \ | 
| Weston Andros Adamson | db8ac8b | 2012-02-17 15:20:24 -0500 | [diff] [blame] | 299 | 1 /* implementation id array of size 1 */ + \ | 
|  | 300 | 1 /* nii_domain */ + \ | 
|  | 301 | XDR_QUADLEN(NFS4_OPAQUE_LIMIT) + \ | 
|  | 302 | 1 /* nii_name */ + \ | 
| Jim Rees | d751f74 | 2012-11-16 18:12:06 -0500 | [diff] [blame] | 303 | XDR_QUADLEN(IMPL_NAME_LIMIT) + \ | 
| Weston Andros Adamson | db8ac8b | 2012-02-17 15:20:24 -0500 | [diff] [blame] | 304 | 3 /* nii_date */) | 
| Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 305 | #define decode_exchange_id_maxsz (op_decode_hdr_maxsz + \ | 
|  | 306 | 2 /* eir_clientid */ + \ | 
|  | 307 | 1 /* eir_sequenceid */ + \ | 
|  | 308 | 1 /* eir_flags */ + \ | 
|  | 309 | 1 /* spr_how */ + \ | 
| Weston Andros Adamson | 2031cd1 | 2013-08-13 16:37:32 -0400 | [diff] [blame] | 310 | /* max is SP4_MACH_CRED (for now) */ + \ | 
|  | 311 | 1 + NFS4_OP_MAP_NUM_WORDS + \ | 
|  | 312 | 1 + NFS4_OP_MAP_NUM_WORDS + \ | 
| Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 313 | 2 /* eir_server_owner.so_minor_id */ + \ | 
|  | 314 | /* eir_server_owner.so_major_id<> */ \ | 
|  | 315 | XDR_QUADLEN(NFS4_OPAQUE_LIMIT) + 1 + \ | 
|  | 316 | /* eir_server_scope<> */ \ | 
|  | 317 | XDR_QUADLEN(NFS4_OPAQUE_LIMIT) + 1 + \ | 
|  | 318 | 1 /* eir_server_impl_id array length */ + \ | 
| Weston Andros Adamson | 7d2ed9a | 2012-02-17 15:20:26 -0500 | [diff] [blame] | 319 | 1 /* nii_domain */ + \ | 
|  | 320 | XDR_QUADLEN(NFS4_OPAQUE_LIMIT) + \ | 
|  | 321 | 1 /* nii_name */ + \ | 
|  | 322 | XDR_QUADLEN(NFS4_OPAQUE_LIMIT) + \ | 
|  | 323 | 3 /* nii_date */) | 
| Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 324 | #define encode_channel_attrs_maxsz  (6 + 1 /* ca_rdma_ird.len (0) */) | 
|  | 325 | #define decode_channel_attrs_maxsz  (6 + \ | 
|  | 326 | 1 /* ca_rdma_ird.len */ + \ | 
|  | 327 | 1 /* ca_rdma_ird */) | 
|  | 328 | #define encode_create_session_maxsz  (op_encode_hdr_maxsz + \ | 
|  | 329 | 2 /* csa_clientid */ + \ | 
|  | 330 | 1 /* csa_sequence */ + \ | 
|  | 331 | 1 /* csa_flags */ + \ | 
|  | 332 | encode_channel_attrs_maxsz + \ | 
|  | 333 | encode_channel_attrs_maxsz + \ | 
|  | 334 | 1 /* csa_cb_program */ + \ | 
|  | 335 | 1 /* csa_sec_parms.len (1) */ + \ | 
|  | 336 | 1 /* cb_secflavor (AUTH_SYS) */ + \ | 
|  | 337 | 1 /* stamp */ + \ | 
|  | 338 | 1 /* machinename.len */ + \ | 
|  | 339 | XDR_QUADLEN(NFS4_MAX_MACHINE_NAME_LEN) + \ | 
|  | 340 | 1 /* uid */ + \ | 
|  | 341 | 1 /* gid */ + \ | 
|  | 342 | 1 /* gids.len (0) */) | 
|  | 343 | #define decode_create_session_maxsz  (op_decode_hdr_maxsz +	\ | 
|  | 344 | XDR_QUADLEN(NFS4_MAX_SESSIONID_LEN) + \ | 
|  | 345 | 1 /* csr_sequence */ + \ | 
|  | 346 | 1 /* csr_flags */ + \ | 
|  | 347 | decode_channel_attrs_maxsz + \ | 
|  | 348 | decode_channel_attrs_maxsz) | 
| Weston Andros Adamson | 7c44f1ae | 2012-05-24 13:22:50 -0400 | [diff] [blame] | 349 | #define encode_bind_conn_to_session_maxsz  (op_encode_hdr_maxsz + \ | 
|  | 350 | /* bctsa_sessid */ \ | 
|  | 351 | XDR_QUADLEN(NFS4_MAX_SESSIONID_LEN) + \ | 
|  | 352 | 1 /* bctsa_dir */ + \ | 
|  | 353 | 1 /* bctsa_use_conn_in_rdma_mode */) | 
|  | 354 | #define decode_bind_conn_to_session_maxsz  (op_decode_hdr_maxsz +	\ | 
|  | 355 | /* bctsr_sessid */ \ | 
|  | 356 | XDR_QUADLEN(NFS4_MAX_SESSIONID_LEN) + \ | 
|  | 357 | 1 /* bctsr_dir */ + \ | 
|  | 358 | 1 /* bctsr_use_conn_in_rdma_mode */) | 
| Andy Adamson | 0f3e66c | 2009-04-01 09:22:34 -0400 | [diff] [blame] | 359 | #define encode_destroy_session_maxsz    (op_encode_hdr_maxsz + 4) | 
|  | 360 | #define decode_destroy_session_maxsz    (op_decode_hdr_maxsz) | 
| Trond Myklebust | 6624553 | 2012-05-25 17:18:09 -0400 | [diff] [blame] | 361 | #define encode_destroy_clientid_maxsz   (op_encode_hdr_maxsz + 2) | 
|  | 362 | #define decode_destroy_clientid_maxsz   (op_decode_hdr_maxsz) | 
| Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 363 | #define encode_sequence_maxsz	(op_encode_hdr_maxsz + \ | 
|  | 364 | XDR_QUADLEN(NFS4_MAX_SESSIONID_LEN) + 4) | 
|  | 365 | #define decode_sequence_maxsz	(op_decode_hdr_maxsz + \ | 
|  | 366 | XDR_QUADLEN(NFS4_MAX_SESSIONID_LEN) + 5) | 
| Ricardo Labiaga | 18019753 | 2009-12-05 16:08:40 -0500 | [diff] [blame] | 367 | #define encode_reclaim_complete_maxsz	(op_encode_hdr_maxsz + 4) | 
|  | 368 | #define decode_reclaim_complete_maxsz	(op_decode_hdr_maxsz + 4) | 
| Christoph Hellwig | 84c9dee | 2014-09-10 17:37:28 -0700 | [diff] [blame] | 369 | #define encode_getdeviceinfo_maxsz (op_encode_hdr_maxsz + \ | 
|  | 370 | XDR_QUADLEN(NFS4_DEVICEID4_SIZE) + \ | 
|  | 371 | 1 /* layout type */ + \ | 
|  | 372 | 1 /* maxcount */ + \ | 
|  | 373 | 1 /* bitmap size */ + \ | 
|  | 374 | 1 /* notification bitmap length */ + \ | 
|  | 375 | 1 /* notification bitmap, word 0 */) | 
| Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 376 | #define decode_getdeviceinfo_maxsz (op_decode_hdr_maxsz + \ | 
|  | 377 | 1 /* layout type */ + \ | 
|  | 378 | 1 /* opaque devaddr4 length */ + \ | 
|  | 379 | /* devaddr4 payload is read into page */ \ | 
|  | 380 | 1 /* notification bitmap length */ + \ | 
| Christoph Hellwig | 84c9dee | 2014-09-10 17:37:28 -0700 | [diff] [blame] | 381 | 1 /* notification bitmap, word 0 */) | 
| Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 382 | #define encode_layoutget_maxsz	(op_encode_hdr_maxsz + 10 + \ | 
|  | 383 | encode_stateid_maxsz) | 
|  | 384 | #define decode_layoutget_maxsz	(op_decode_hdr_maxsz + 8 + \ | 
|  | 385 | decode_stateid_maxsz + \ | 
|  | 386 | XDR_QUADLEN(PNFS_LAYOUT_MAXSIZE)) | 
| Andy Adamson | 863a3c6 | 2011-03-23 13:27:54 +0000 | [diff] [blame] | 387 | #define encode_layoutcommit_maxsz (op_encode_hdr_maxsz +          \ | 
|  | 388 | 2 /* offset */ + \ | 
|  | 389 | 2 /* length */ + \ | 
|  | 390 | 1 /* reclaim */ + \ | 
|  | 391 | encode_stateid_maxsz + \ | 
|  | 392 | 1 /* new offset (true) */ + \ | 
|  | 393 | 2 /* last byte written */ + \ | 
|  | 394 | 1 /* nt_timechanged (false) */ + \ | 
|  | 395 | 1 /* layoutupdate4 layout type */ + \ | 
| Christoph Hellwig | 5f919c9 | 2014-08-21 11:09:25 -0500 | [diff] [blame] | 396 | 1 /* layoutupdate4 opaqueue len */) | 
|  | 397 | /* the actual content of layoutupdate4 should | 
|  | 398 | be allocated by drivers and spliced in | 
|  | 399 | using xdr_write_pages */ | 
| Andy Adamson | 863a3c6 | 2011-03-23 13:27:54 +0000 | [diff] [blame] | 400 | #define decode_layoutcommit_maxsz (op_decode_hdr_maxsz + 3) | 
| Benny Halevy | cbe8260 | 2011-05-22 19:52:37 +0300 | [diff] [blame] | 401 | #define encode_layoutreturn_maxsz (8 + op_encode_hdr_maxsz + \ | 
|  | 402 | encode_stateid_maxsz + \ | 
| Trond Myklebust | 6669cb8 | 2015-08-27 20:43:20 -0400 | [diff] [blame] | 403 | 1 + \ | 
|  | 404 | XDR_QUADLEN(NFS4_OPAQUE_LIMIT)) | 
| Benny Halevy | cbe8260 | 2011-05-22 19:52:37 +0300 | [diff] [blame] | 405 | #define decode_layoutreturn_maxsz (op_decode_hdr_maxsz + \ | 
|  | 406 | 1 + decode_stateid_maxsz) | 
| Bryan Schumaker | fca78d6 | 2011-06-02 14:59:07 -0400 | [diff] [blame] | 407 | #define encode_secinfo_no_name_maxsz (op_encode_hdr_maxsz + 1) | 
|  | 408 | #define decode_secinfo_no_name_maxsz decode_secinfo_maxsz | 
| Bryan Schumaker | 7d97479 | 2011-06-02 14:59:08 -0400 | [diff] [blame] | 409 | #define encode_test_stateid_maxsz	(op_encode_hdr_maxsz + 2 + \ | 
|  | 410 | XDR_QUADLEN(NFS4_STATEID_SIZE)) | 
|  | 411 | #define decode_test_stateid_maxsz	(op_decode_hdr_maxsz + 2 + 1) | 
| Bryan Schumaker | 9aeda35 | 2011-06-02 14:59:09 -0400 | [diff] [blame] | 412 | #define encode_free_stateid_maxsz	(op_encode_hdr_maxsz + 1 + \ | 
|  | 413 | XDR_QUADLEN(NFS4_STATEID_SIZE)) | 
| Andy Adamson | 9f79fb4 | 2013-09-10 12:56:29 -0400 | [diff] [blame] | 414 | #define decode_free_stateid_maxsz	(op_decode_hdr_maxsz) | 
| Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 415 | #else /* CONFIG_NFS_V4_1 */ | 
|  | 416 | #define encode_sequence_maxsz	0 | 
|  | 417 | #define decode_sequence_maxsz	0 | 
|  | 418 | #endif /* CONFIG_NFS_V4_1 */ | 
|  | 419 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 420 | #define NFS4_enc_compound_sz	(1024)  /* XXX: large enough? */ | 
|  | 421 | #define NFS4_dec_compound_sz	(1024)  /* XXX: large enough? */ | 
|  | 422 | #define NFS4_enc_read_sz	(compound_encode_hdr_maxsz + \ | 
| Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 423 | encode_sequence_maxsz + \ | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 424 | encode_putfh_maxsz + \ | 
| Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 425 | encode_read_maxsz) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 426 | #define NFS4_dec_read_sz	(compound_decode_hdr_maxsz + \ | 
| Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 427 | decode_sequence_maxsz + \ | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 428 | decode_putfh_maxsz + \ | 
| Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 429 | decode_read_maxsz) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 430 | #define NFS4_enc_readlink_sz	(compound_encode_hdr_maxsz + \ | 
| Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 431 | encode_sequence_maxsz + \ | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 432 | encode_putfh_maxsz + \ | 
| Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 433 | encode_readlink_maxsz) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 434 | #define NFS4_dec_readlink_sz	(compound_decode_hdr_maxsz + \ | 
| Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 435 | decode_sequence_maxsz + \ | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 436 | decode_putfh_maxsz + \ | 
| Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 437 | decode_readlink_maxsz) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 438 | #define NFS4_enc_readdir_sz	(compound_encode_hdr_maxsz + \ | 
| Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 439 | encode_sequence_maxsz + \ | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 440 | encode_putfh_maxsz + \ | 
| Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 441 | encode_readdir_maxsz) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 442 | #define NFS4_dec_readdir_sz	(compound_decode_hdr_maxsz + \ | 
| Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 443 | decode_sequence_maxsz + \ | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 444 | decode_putfh_maxsz + \ | 
| Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 445 | decode_readdir_maxsz) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 446 | #define NFS4_enc_write_sz	(compound_encode_hdr_maxsz + \ | 
| Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 447 | encode_sequence_maxsz + \ | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 448 | encode_putfh_maxsz + \ | 
| Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 449 | encode_write_maxsz + \ | 
| Trond Myklebust | 4f9838c | 2005-10-27 22:12:44 -0400 | [diff] [blame] | 450 | encode_getattr_maxsz) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 451 | #define NFS4_dec_write_sz	(compound_decode_hdr_maxsz + \ | 
| Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 452 | decode_sequence_maxsz + \ | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 453 | decode_putfh_maxsz + \ | 
| Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 454 | decode_write_maxsz + \ | 
| Trond Myklebust | 4f9838c | 2005-10-27 22:12:44 -0400 | [diff] [blame] | 455 | decode_getattr_maxsz) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 456 | #define NFS4_enc_commit_sz	(compound_encode_hdr_maxsz + \ | 
| Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 457 | encode_sequence_maxsz + \ | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 458 | encode_putfh_maxsz + \ | 
| Trond Myklebust | 8582715 | 2012-04-29 10:44:42 -0400 | [diff] [blame] | 459 | encode_commit_maxsz) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 460 | #define NFS4_dec_commit_sz	(compound_decode_hdr_maxsz + \ | 
| Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 461 | decode_sequence_maxsz + \ | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 462 | decode_putfh_maxsz + \ | 
| Trond Myklebust | 8582715 | 2012-04-29 10:44:42 -0400 | [diff] [blame] | 463 | decode_commit_maxsz) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 464 | #define NFS4_enc_open_sz        (compound_encode_hdr_maxsz + \ | 
| Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 465 | encode_sequence_maxsz + \ | 
| Trond Myklebust | 2cebf82 | 2007-07-02 13:57:28 -0400 | [diff] [blame] | 466 | encode_putfh_maxsz + \ | 
| Trond Myklebust | 2cebf82 | 2007-07-02 13:57:28 -0400 | [diff] [blame] | 467 | encode_open_maxsz + \ | 
| Weston Andros Adamson | 6168f62 | 2012-09-10 14:00:46 -0400 | [diff] [blame] | 468 | encode_access_maxsz + \ | 
| Trond Myklebust | 2cebf82 | 2007-07-02 13:57:28 -0400 | [diff] [blame] | 469 | encode_getfh_maxsz + \ | 
| Trond Myklebust | 2cebf82 | 2007-07-02 13:57:28 -0400 | [diff] [blame] | 470 | encode_getattr_maxsz) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 471 | #define NFS4_dec_open_sz        (compound_decode_hdr_maxsz + \ | 
| Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 472 | decode_sequence_maxsz + \ | 
| Trond Myklebust | 2cebf82 | 2007-07-02 13:57:28 -0400 | [diff] [blame] | 473 | decode_putfh_maxsz + \ | 
| Trond Myklebust | 2cebf82 | 2007-07-02 13:57:28 -0400 | [diff] [blame] | 474 | decode_open_maxsz + \ | 
| Weston Andros Adamson | 6168f62 | 2012-09-10 14:00:46 -0400 | [diff] [blame] | 475 | decode_access_maxsz + \ | 
| Trond Myklebust | 2cebf82 | 2007-07-02 13:57:28 -0400 | [diff] [blame] | 476 | decode_getfh_maxsz + \ | 
| Trond Myklebust | 2cebf82 | 2007-07-02 13:57:28 -0400 | [diff] [blame] | 477 | decode_getattr_maxsz) | 
| Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 478 | #define NFS4_enc_open_confirm_sz \ | 
|  | 479 | (compound_encode_hdr_maxsz + \ | 
|  | 480 | encode_putfh_maxsz + \ | 
|  | 481 | encode_open_confirm_maxsz) | 
|  | 482 | #define NFS4_dec_open_confirm_sz \ | 
|  | 483 | (compound_decode_hdr_maxsz + \ | 
|  | 484 | decode_putfh_maxsz + \ | 
|  | 485 | decode_open_confirm_maxsz) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 486 | #define NFS4_enc_open_noattr_sz	(compound_encode_hdr_maxsz + \ | 
| Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 487 | encode_sequence_maxsz + \ | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 488 | encode_putfh_maxsz + \ | 
| Trond Myklebust | 2cebf82 | 2007-07-02 13:57:28 -0400 | [diff] [blame] | 489 | encode_open_maxsz + \ | 
| Weston Andros Adamson | 6168f62 | 2012-09-10 14:00:46 -0400 | [diff] [blame] | 490 | encode_access_maxsz + \ | 
| Trond Myklebust | 2cebf82 | 2007-07-02 13:57:28 -0400 | [diff] [blame] | 491 | encode_getattr_maxsz) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 492 | #define NFS4_dec_open_noattr_sz	(compound_decode_hdr_maxsz + \ | 
| Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 493 | decode_sequence_maxsz + \ | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 494 | decode_putfh_maxsz + \ | 
| Trond Myklebust | 2cebf82 | 2007-07-02 13:57:28 -0400 | [diff] [blame] | 495 | decode_open_maxsz + \ | 
| Weston Andros Adamson | 6168f62 | 2012-09-10 14:00:46 -0400 | [diff] [blame] | 496 | decode_access_maxsz + \ | 
| Trond Myklebust | 2cebf82 | 2007-07-02 13:57:28 -0400 | [diff] [blame] | 497 | decode_getattr_maxsz) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 498 | #define NFS4_enc_open_downgrade_sz \ | 
|  | 499 | (compound_encode_hdr_maxsz + \ | 
| Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 500 | encode_sequence_maxsz + \ | 
| Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 501 | encode_putfh_maxsz + \ | 
| Trond Myklebust | 3947b74 | 2016-10-27 18:27:02 -0400 | [diff] [blame^] | 502 | encode_open_downgrade_maxsz) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 503 | #define NFS4_dec_open_downgrade_sz \ | 
|  | 504 | (compound_decode_hdr_maxsz + \ | 
| Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 505 | decode_sequence_maxsz + \ | 
| Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 506 | decode_putfh_maxsz + \ | 
| Trond Myklebust | 3947b74 | 2016-10-27 18:27:02 -0400 | [diff] [blame^] | 507 | decode_open_downgrade_maxsz) | 
| Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 508 | #define NFS4_enc_close_sz	(compound_encode_hdr_maxsz + \ | 
| Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 509 | encode_sequence_maxsz + \ | 
| Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 510 | encode_putfh_maxsz + \ | 
|  | 511 | encode_close_maxsz + \ | 
|  | 512 | encode_getattr_maxsz) | 
|  | 513 | #define NFS4_dec_close_sz	(compound_decode_hdr_maxsz + \ | 
| Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 514 | decode_sequence_maxsz + \ | 
| Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 515 | decode_putfh_maxsz + \ | 
|  | 516 | decode_close_maxsz + \ | 
|  | 517 | decode_getattr_maxsz) | 
|  | 518 | #define NFS4_enc_setattr_sz	(compound_encode_hdr_maxsz + \ | 
| Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 519 | encode_sequence_maxsz + \ | 
| Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 520 | encode_putfh_maxsz + \ | 
|  | 521 | encode_setattr_maxsz + \ | 
|  | 522 | encode_getattr_maxsz) | 
|  | 523 | #define NFS4_dec_setattr_sz	(compound_decode_hdr_maxsz + \ | 
| Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 524 | decode_sequence_maxsz + \ | 
| Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 525 | decode_putfh_maxsz + \ | 
|  | 526 | decode_setattr_maxsz + \ | 
|  | 527 | decode_getattr_maxsz) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 528 | #define NFS4_enc_fsinfo_sz	(compound_encode_hdr_maxsz + \ | 
| Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 529 | encode_sequence_maxsz + \ | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 530 | encode_putfh_maxsz + \ | 
|  | 531 | encode_fsinfo_maxsz) | 
|  | 532 | #define NFS4_dec_fsinfo_sz	(compound_decode_hdr_maxsz + \ | 
| Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 533 | decode_sequence_maxsz + \ | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 534 | decode_putfh_maxsz + \ | 
|  | 535 | decode_fsinfo_maxsz) | 
|  | 536 | #define NFS4_enc_renew_sz	(compound_encode_hdr_maxsz + \ | 
|  | 537 | encode_renew_maxsz) | 
|  | 538 | #define NFS4_dec_renew_sz	(compound_decode_hdr_maxsz + \ | 
|  | 539 | decode_renew_maxsz) | 
|  | 540 | #define NFS4_enc_setclientid_sz	(compound_encode_hdr_maxsz + \ | 
|  | 541 | encode_setclientid_maxsz) | 
|  | 542 | #define NFS4_dec_setclientid_sz	(compound_decode_hdr_maxsz + \ | 
|  | 543 | decode_setclientid_maxsz) | 
|  | 544 | #define NFS4_enc_setclientid_confirm_sz \ | 
|  | 545 | (compound_encode_hdr_maxsz + \ | 
| Chuck Lever | 83ca7f5 | 2013-03-16 15:55:53 -0400 | [diff] [blame] | 546 | encode_setclientid_confirm_maxsz) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 547 | #define NFS4_dec_setclientid_confirm_sz \ | 
|  | 548 | (compound_decode_hdr_maxsz + \ | 
| Chuck Lever | 83ca7f5 | 2013-03-16 15:55:53 -0400 | [diff] [blame] | 549 | decode_setclientid_confirm_maxsz) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 550 | #define NFS4_enc_lock_sz        (compound_encode_hdr_maxsz + \ | 
| Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 551 | encode_sequence_maxsz + \ | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 552 | encode_putfh_maxsz + \ | 
| Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 553 | encode_lock_maxsz) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 554 | #define NFS4_dec_lock_sz        (compound_decode_hdr_maxsz + \ | 
| Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 555 | decode_sequence_maxsz + \ | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 556 | decode_putfh_maxsz + \ | 
| Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 557 | decode_lock_maxsz) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 558 | #define NFS4_enc_lockt_sz       (compound_encode_hdr_maxsz + \ | 
| Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 559 | encode_sequence_maxsz + \ | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 560 | encode_putfh_maxsz + \ | 
| Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 561 | encode_lockt_maxsz) | 
|  | 562 | #define NFS4_dec_lockt_sz       (compound_decode_hdr_maxsz + \ | 
| Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 563 | decode_sequence_maxsz + \ | 
| Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 564 | decode_putfh_maxsz + \ | 
|  | 565 | decode_lockt_maxsz) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 566 | #define NFS4_enc_locku_sz       (compound_encode_hdr_maxsz + \ | 
| Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 567 | encode_sequence_maxsz + \ | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 568 | encode_putfh_maxsz + \ | 
| Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 569 | encode_locku_maxsz) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 570 | #define NFS4_dec_locku_sz       (compound_decode_hdr_maxsz + \ | 
| Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 571 | decode_sequence_maxsz + \ | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 572 | decode_putfh_maxsz + \ | 
| Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 573 | decode_locku_maxsz) | 
| Trond Myklebust | d3c7b7c | 2010-07-01 12:49:01 -0400 | [diff] [blame] | 574 | #define NFS4_enc_release_lockowner_sz \ | 
|  | 575 | (compound_encode_hdr_maxsz + \ | 
|  | 576 | encode_lockowner_maxsz) | 
|  | 577 | #define NFS4_dec_release_lockowner_sz \ | 
|  | 578 | (compound_decode_hdr_maxsz + \ | 
|  | 579 | decode_lockowner_maxsz) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 580 | #define NFS4_enc_access_sz	(compound_encode_hdr_maxsz + \ | 
| Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 581 | encode_sequence_maxsz + \ | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 582 | encode_putfh_maxsz + \ | 
| Trond Myklebust | 76b3299 | 2007-08-10 17:45:11 -0400 | [diff] [blame] | 583 | encode_access_maxsz + \ | 
|  | 584 | encode_getattr_maxsz) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 585 | #define NFS4_dec_access_sz	(compound_decode_hdr_maxsz + \ | 
| Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 586 | decode_sequence_maxsz + \ | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 587 | decode_putfh_maxsz + \ | 
| Trond Myklebust | 76b3299 | 2007-08-10 17:45:11 -0400 | [diff] [blame] | 588 | decode_access_maxsz + \ | 
|  | 589 | decode_getattr_maxsz) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 590 | #define NFS4_enc_getattr_sz	(compound_encode_hdr_maxsz + \ | 
| Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 591 | encode_sequence_maxsz + \ | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 592 | encode_putfh_maxsz + \ | 
| Chuck Lever | 44c9993 | 2013-10-17 14:13:30 -0400 | [diff] [blame] | 593 | encode_getattr_maxsz + \ | 
|  | 594 | encode_renew_maxsz) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 595 | #define NFS4_dec_getattr_sz	(compound_decode_hdr_maxsz + \ | 
| Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 596 | decode_sequence_maxsz + \ | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 597 | decode_putfh_maxsz + \ | 
| Chuck Lever | 44c9993 | 2013-10-17 14:13:30 -0400 | [diff] [blame] | 598 | decode_getattr_maxsz + \ | 
|  | 599 | decode_renew_maxsz) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 600 | #define NFS4_enc_lookup_sz	(compound_encode_hdr_maxsz + \ | 
| Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 601 | encode_sequence_maxsz + \ | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 602 | encode_putfh_maxsz + \ | 
|  | 603 | encode_lookup_maxsz + \ | 
|  | 604 | encode_getattr_maxsz + \ | 
|  | 605 | encode_getfh_maxsz) | 
|  | 606 | #define NFS4_dec_lookup_sz	(compound_decode_hdr_maxsz + \ | 
| Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 607 | decode_sequence_maxsz + \ | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 608 | decode_putfh_maxsz + \ | 
| Trond Myklebust | e688962 | 2007-07-02 13:58:30 -0400 | [diff] [blame] | 609 | decode_lookup_maxsz + \ | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 610 | decode_getattr_maxsz + \ | 
|  | 611 | decode_getfh_maxsz) | 
|  | 612 | #define NFS4_enc_lookup_root_sz (compound_encode_hdr_maxsz + \ | 
| Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 613 | encode_sequence_maxsz + \ | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 614 | encode_putrootfh_maxsz + \ | 
|  | 615 | encode_getattr_maxsz + \ | 
|  | 616 | encode_getfh_maxsz) | 
|  | 617 | #define NFS4_dec_lookup_root_sz (compound_decode_hdr_maxsz + \ | 
| Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 618 | decode_sequence_maxsz + \ | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 619 | decode_putrootfh_maxsz + \ | 
|  | 620 | decode_getattr_maxsz + \ | 
|  | 621 | decode_getfh_maxsz) | 
|  | 622 | #define NFS4_enc_remove_sz	(compound_encode_hdr_maxsz + \ | 
| Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 623 | encode_sequence_maxsz + \ | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 624 | encode_putfh_maxsz + \ | 
| Trond Myklebust | 778d281 | 2012-04-27 13:48:19 -0400 | [diff] [blame] | 625 | encode_remove_maxsz) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 626 | #define NFS4_dec_remove_sz	(compound_decode_hdr_maxsz + \ | 
| Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 627 | decode_sequence_maxsz + \ | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 628 | decode_putfh_maxsz + \ | 
| Trond Myklebust | 778d281 | 2012-04-27 13:48:19 -0400 | [diff] [blame] | 629 | decode_remove_maxsz) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 630 | #define NFS4_enc_rename_sz	(compound_encode_hdr_maxsz + \ | 
| Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 631 | encode_sequence_maxsz + \ | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 632 | encode_putfh_maxsz + \ | 
|  | 633 | encode_savefh_maxsz + \ | 
|  | 634 | encode_putfh_maxsz + \ | 
| Trond Myklebust | 778d281 | 2012-04-27 13:48:19 -0400 | [diff] [blame] | 635 | encode_rename_maxsz) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 636 | #define NFS4_dec_rename_sz	(compound_decode_hdr_maxsz + \ | 
| Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 637 | decode_sequence_maxsz + \ | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 638 | decode_putfh_maxsz + \ | 
|  | 639 | decode_savefh_maxsz + \ | 
|  | 640 | decode_putfh_maxsz + \ | 
| Trond Myklebust | 778d281 | 2012-04-27 13:48:19 -0400 | [diff] [blame] | 641 | decode_rename_maxsz) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 642 | #define NFS4_enc_link_sz	(compound_encode_hdr_maxsz + \ | 
| Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 643 | encode_sequence_maxsz + \ | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 644 | encode_putfh_maxsz + \ | 
|  | 645 | encode_savefh_maxsz + \ | 
|  | 646 | encode_putfh_maxsz + \ | 
| Trond Myklebust | 91ba2ee | 2005-10-27 22:12:42 -0400 | [diff] [blame] | 647 | encode_link_maxsz + \ | 
| Trond Myklebust | 91ba2ee | 2005-10-27 22:12:42 -0400 | [diff] [blame] | 648 | encode_restorefh_maxsz + \ | 
| Trond Myklebust | a9f6991 | 2012-04-27 13:48:17 -0400 | [diff] [blame] | 649 | encode_getattr_maxsz) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 650 | #define NFS4_dec_link_sz	(compound_decode_hdr_maxsz + \ | 
| Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 651 | decode_sequence_maxsz + \ | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 652 | decode_putfh_maxsz + \ | 
|  | 653 | decode_savefh_maxsz + \ | 
|  | 654 | decode_putfh_maxsz + \ | 
| Trond Myklebust | 91ba2ee | 2005-10-27 22:12:42 -0400 | [diff] [blame] | 655 | decode_link_maxsz + \ | 
| Trond Myklebust | 91ba2ee | 2005-10-27 22:12:42 -0400 | [diff] [blame] | 656 | decode_restorefh_maxsz + \ | 
|  | 657 | decode_getattr_maxsz) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 658 | #define NFS4_enc_symlink_sz	(compound_encode_hdr_maxsz + \ | 
| Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 659 | encode_sequence_maxsz + \ | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 660 | encode_putfh_maxsz + \ | 
|  | 661 | encode_symlink_maxsz + \ | 
|  | 662 | encode_getattr_maxsz + \ | 
|  | 663 | encode_getfh_maxsz) | 
|  | 664 | #define NFS4_dec_symlink_sz	(compound_decode_hdr_maxsz + \ | 
| Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 665 | decode_sequence_maxsz + \ | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 666 | decode_putfh_maxsz + \ | 
|  | 667 | decode_symlink_maxsz + \ | 
|  | 668 | decode_getattr_maxsz + \ | 
|  | 669 | decode_getfh_maxsz) | 
|  | 670 | #define NFS4_enc_create_sz	(compound_encode_hdr_maxsz + \ | 
| Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 671 | encode_sequence_maxsz + \ | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 672 | encode_putfh_maxsz + \ | 
|  | 673 | encode_create_maxsz + \ | 
| Trond Myklebust | 56ae19f | 2005-10-27 22:12:40 -0400 | [diff] [blame] | 674 | encode_getfh_maxsz + \ | 
| Trond Myklebust | 56ae19f | 2005-10-27 22:12:40 -0400 | [diff] [blame] | 675 | encode_getattr_maxsz) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 676 | #define NFS4_dec_create_sz	(compound_decode_hdr_maxsz + \ | 
| Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 677 | decode_sequence_maxsz + \ | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 678 | decode_putfh_maxsz + \ | 
|  | 679 | decode_create_maxsz + \ | 
| Trond Myklebust | 56ae19f | 2005-10-27 22:12:40 -0400 | [diff] [blame] | 680 | decode_getfh_maxsz + \ | 
| Trond Myklebust | 56ae19f | 2005-10-27 22:12:40 -0400 | [diff] [blame] | 681 | decode_getattr_maxsz) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 682 | #define NFS4_enc_pathconf_sz	(compound_encode_hdr_maxsz + \ | 
| Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 683 | encode_sequence_maxsz + \ | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 684 | encode_putfh_maxsz + \ | 
|  | 685 | encode_getattr_maxsz) | 
|  | 686 | #define NFS4_dec_pathconf_sz	(compound_decode_hdr_maxsz + \ | 
| Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 687 | decode_sequence_maxsz + \ | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 688 | decode_putfh_maxsz + \ | 
|  | 689 | decode_getattr_maxsz) | 
|  | 690 | #define NFS4_enc_statfs_sz	(compound_encode_hdr_maxsz + \ | 
| Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 691 | encode_sequence_maxsz + \ | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 692 | encode_putfh_maxsz + \ | 
| Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 693 | encode_statfs_maxsz) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 694 | #define NFS4_dec_statfs_sz	(compound_decode_hdr_maxsz + \ | 
| Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 695 | decode_sequence_maxsz + \ | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 696 | decode_putfh_maxsz + \ | 
| Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 697 | decode_statfs_maxsz) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 698 | #define NFS4_enc_server_caps_sz (compound_encode_hdr_maxsz + \ | 
| Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 699 | encode_sequence_maxsz + \ | 
| Trond Myklebust | ab91f26 | 2007-02-02 14:47:17 -0800 | [diff] [blame] | 700 | encode_putfh_maxsz + \ | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 701 | encode_getattr_maxsz) | 
|  | 702 | #define NFS4_dec_server_caps_sz (compound_decode_hdr_maxsz + \ | 
| Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 703 | decode_sequence_maxsz + \ | 
| Trond Myklebust | ab91f26 | 2007-02-02 14:47:17 -0800 | [diff] [blame] | 704 | decode_putfh_maxsz + \ | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 705 | decode_getattr_maxsz) | 
|  | 706 | #define NFS4_enc_delegreturn_sz	(compound_encode_hdr_maxsz + \ | 
| Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 707 | encode_sequence_maxsz + \ | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 708 | encode_putfh_maxsz + \ | 
| Trond Myklebust | fa178f2 | 2006-01-03 09:55:38 +0100 | [diff] [blame] | 709 | encode_delegreturn_maxsz + \ | 
|  | 710 | encode_getattr_maxsz) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 711 | #define NFS4_dec_delegreturn_sz (compound_decode_hdr_maxsz + \ | 
| Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 712 | decode_sequence_maxsz + \ | 
| Trond Myklebust | fa178f2 | 2006-01-03 09:55:38 +0100 | [diff] [blame] | 713 | decode_delegreturn_maxsz + \ | 
|  | 714 | decode_getattr_maxsz) | 
| J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 715 | #define NFS4_enc_getacl_sz	(compound_encode_hdr_maxsz + \ | 
| Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 716 | encode_sequence_maxsz + \ | 
| J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 717 | encode_putfh_maxsz + \ | 
| Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 718 | encode_getacl_maxsz) | 
| J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 719 | #define NFS4_dec_getacl_sz	(compound_decode_hdr_maxsz + \ | 
| Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 720 | decode_sequence_maxsz + \ | 
| J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 721 | decode_putfh_maxsz + \ | 
| Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 722 | decode_getacl_maxsz) | 
| J. Bruce Fields | 23ec696 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 723 | #define NFS4_enc_setacl_sz	(compound_encode_hdr_maxsz + \ | 
| Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 724 | encode_sequence_maxsz + \ | 
| J. Bruce Fields | 23ec696 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 725 | encode_putfh_maxsz + \ | 
| Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 726 | encode_setacl_maxsz) | 
| J. Bruce Fields | 23ec696 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 727 | #define NFS4_dec_setacl_sz	(compound_decode_hdr_maxsz + \ | 
| Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 728 | decode_sequence_maxsz + \ | 
| J. Bruce Fields | 23ec696 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 729 | decode_putfh_maxsz + \ | 
| Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 730 | decode_setacl_maxsz) | 
| Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 731 | #define NFS4_enc_fs_locations_sz \ | 
|  | 732 | (compound_encode_hdr_maxsz + \ | 
| Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 733 | encode_sequence_maxsz + \ | 
| Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 734 | encode_putfh_maxsz + \ | 
| Trond Myklebust | e688962 | 2007-07-02 13:58:30 -0400 | [diff] [blame] | 735 | encode_lookup_maxsz + \ | 
| Chuck Lever | b03d735 | 2013-10-17 14:12:50 -0400 | [diff] [blame] | 736 | encode_fs_locations_maxsz + \ | 
|  | 737 | encode_renew_maxsz) | 
| Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 738 | #define NFS4_dec_fs_locations_sz \ | 
|  | 739 | (compound_decode_hdr_maxsz + \ | 
| Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 740 | decode_sequence_maxsz + \ | 
| Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 741 | decode_putfh_maxsz + \ | 
| Trond Myklebust | e688962 | 2007-07-02 13:58:30 -0400 | [diff] [blame] | 742 | decode_lookup_maxsz + \ | 
| Chuck Lever | b03d735 | 2013-10-17 14:12:50 -0400 | [diff] [blame] | 743 | decode_fs_locations_maxsz + \ | 
|  | 744 | decode_renew_maxsz) | 
| Bryan Schumaker | 5a5ea0d | 2011-03-24 17:12:29 +0000 | [diff] [blame] | 745 | #define NFS4_enc_secinfo_sz 	(compound_encode_hdr_maxsz + \ | 
|  | 746 | encode_sequence_maxsz + \ | 
|  | 747 | encode_putfh_maxsz + \ | 
|  | 748 | encode_secinfo_maxsz) | 
|  | 749 | #define NFS4_dec_secinfo_sz	(compound_decode_hdr_maxsz + \ | 
|  | 750 | decode_sequence_maxsz + \ | 
|  | 751 | decode_putfh_maxsz + \ | 
|  | 752 | decode_secinfo_maxsz) | 
| Chuck Lever | 44c9993 | 2013-10-17 14:13:30 -0400 | [diff] [blame] | 753 | #define NFS4_enc_fsid_present_sz \ | 
|  | 754 | (compound_encode_hdr_maxsz + \ | 
|  | 755 | encode_sequence_maxsz + \ | 
|  | 756 | encode_putfh_maxsz + \ | 
|  | 757 | encode_getfh_maxsz + \ | 
|  | 758 | encode_renew_maxsz) | 
|  | 759 | #define NFS4_dec_fsid_present_sz \ | 
|  | 760 | (compound_decode_hdr_maxsz + \ | 
|  | 761 | decode_sequence_maxsz + \ | 
|  | 762 | decode_putfh_maxsz + \ | 
|  | 763 | decode_getfh_maxsz + \ | 
|  | 764 | decode_renew_maxsz) | 
| Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 765 | #if defined(CONFIG_NFS_V4_1) | 
| Weston Andros Adamson | 7c44f1ae | 2012-05-24 13:22:50 -0400 | [diff] [blame] | 766 | #define NFS4_enc_bind_conn_to_session_sz \ | 
|  | 767 | (compound_encode_hdr_maxsz + \ | 
|  | 768 | encode_bind_conn_to_session_maxsz) | 
|  | 769 | #define NFS4_dec_bind_conn_to_session_sz \ | 
|  | 770 | (compound_decode_hdr_maxsz + \ | 
|  | 771 | decode_bind_conn_to_session_maxsz) | 
| Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 772 | #define NFS4_enc_exchange_id_sz \ | 
|  | 773 | (compound_encode_hdr_maxsz + \ | 
|  | 774 | encode_exchange_id_maxsz) | 
|  | 775 | #define NFS4_dec_exchange_id_sz \ | 
|  | 776 | (compound_decode_hdr_maxsz + \ | 
|  | 777 | decode_exchange_id_maxsz) | 
| Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 778 | #define NFS4_enc_create_session_sz \ | 
|  | 779 | (compound_encode_hdr_maxsz + \ | 
|  | 780 | encode_create_session_maxsz) | 
|  | 781 | #define NFS4_dec_create_session_sz \ | 
|  | 782 | (compound_decode_hdr_maxsz + \ | 
|  | 783 | decode_create_session_maxsz) | 
| Andy Adamson | 0f3e66c | 2009-04-01 09:22:34 -0400 | [diff] [blame] | 784 | #define NFS4_enc_destroy_session_sz	(compound_encode_hdr_maxsz + \ | 
|  | 785 | encode_destroy_session_maxsz) | 
|  | 786 | #define NFS4_dec_destroy_session_sz	(compound_decode_hdr_maxsz + \ | 
|  | 787 | decode_destroy_session_maxsz) | 
| Trond Myklebust | 6624553 | 2012-05-25 17:18:09 -0400 | [diff] [blame] | 788 | #define NFS4_enc_destroy_clientid_sz	(compound_encode_hdr_maxsz + \ | 
|  | 789 | encode_destroy_clientid_maxsz) | 
|  | 790 | #define NFS4_dec_destroy_clientid_sz	(compound_decode_hdr_maxsz + \ | 
|  | 791 | decode_destroy_clientid_maxsz) | 
| Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 792 | #define NFS4_enc_sequence_sz \ | 
|  | 793 | (compound_decode_hdr_maxsz + \ | 
|  | 794 | encode_sequence_maxsz) | 
|  | 795 | #define NFS4_dec_sequence_sz \ | 
|  | 796 | (compound_decode_hdr_maxsz + \ | 
|  | 797 | decode_sequence_maxsz) | 
| Andy Adamson | 2050f0c | 2009-04-01 09:22:30 -0400 | [diff] [blame] | 798 | #define NFS4_enc_get_lease_time_sz	(compound_encode_hdr_maxsz + \ | 
|  | 799 | encode_sequence_maxsz + \ | 
|  | 800 | encode_putrootfh_maxsz + \ | 
|  | 801 | encode_fsinfo_maxsz) | 
|  | 802 | #define NFS4_dec_get_lease_time_sz	(compound_decode_hdr_maxsz + \ | 
|  | 803 | decode_sequence_maxsz + \ | 
|  | 804 | decode_putrootfh_maxsz + \ | 
|  | 805 | decode_fsinfo_maxsz) | 
| Ricardo Labiaga | 18019753 | 2009-12-05 16:08:40 -0500 | [diff] [blame] | 806 | #define NFS4_enc_reclaim_complete_sz	(compound_encode_hdr_maxsz + \ | 
|  | 807 | encode_sequence_maxsz + \ | 
|  | 808 | encode_reclaim_complete_maxsz) | 
|  | 809 | #define NFS4_dec_reclaim_complete_sz	(compound_decode_hdr_maxsz + \ | 
|  | 810 | decode_sequence_maxsz + \ | 
|  | 811 | decode_reclaim_complete_maxsz) | 
| Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 812 | #define NFS4_enc_getdeviceinfo_sz (compound_encode_hdr_maxsz +    \ | 
|  | 813 | encode_sequence_maxsz +\ | 
|  | 814 | encode_getdeviceinfo_maxsz) | 
|  | 815 | #define NFS4_dec_getdeviceinfo_sz (compound_decode_hdr_maxsz +    \ | 
|  | 816 | decode_sequence_maxsz + \ | 
|  | 817 | decode_getdeviceinfo_maxsz) | 
|  | 818 | #define NFS4_enc_layoutget_sz	(compound_encode_hdr_maxsz + \ | 
|  | 819 | encode_sequence_maxsz + \ | 
|  | 820 | encode_putfh_maxsz +        \ | 
|  | 821 | encode_layoutget_maxsz) | 
|  | 822 | #define NFS4_dec_layoutget_sz	(compound_decode_hdr_maxsz + \ | 
|  | 823 | decode_sequence_maxsz + \ | 
|  | 824 | decode_putfh_maxsz +        \ | 
|  | 825 | decode_layoutget_maxsz) | 
| Andy Adamson | 863a3c6 | 2011-03-23 13:27:54 +0000 | [diff] [blame] | 826 | #define NFS4_enc_layoutcommit_sz (compound_encode_hdr_maxsz + \ | 
|  | 827 | encode_sequence_maxsz +\ | 
|  | 828 | encode_putfh_maxsz + \ | 
|  | 829 | encode_layoutcommit_maxsz + \ | 
|  | 830 | encode_getattr_maxsz) | 
|  | 831 | #define NFS4_dec_layoutcommit_sz (compound_decode_hdr_maxsz + \ | 
|  | 832 | decode_sequence_maxsz + \ | 
|  | 833 | decode_putfh_maxsz + \ | 
|  | 834 | decode_layoutcommit_maxsz + \ | 
|  | 835 | decode_getattr_maxsz) | 
| Benny Halevy | cbe8260 | 2011-05-22 19:52:37 +0300 | [diff] [blame] | 836 | #define NFS4_enc_layoutreturn_sz (compound_encode_hdr_maxsz + \ | 
|  | 837 | encode_sequence_maxsz + \ | 
|  | 838 | encode_putfh_maxsz + \ | 
|  | 839 | encode_layoutreturn_maxsz) | 
|  | 840 | #define NFS4_dec_layoutreturn_sz (compound_decode_hdr_maxsz + \ | 
|  | 841 | decode_sequence_maxsz + \ | 
|  | 842 | decode_putfh_maxsz + \ | 
|  | 843 | decode_layoutreturn_maxsz) | 
| Bryan Schumaker | fca78d6 | 2011-06-02 14:59:07 -0400 | [diff] [blame] | 844 | #define NFS4_enc_secinfo_no_name_sz	(compound_encode_hdr_maxsz + \ | 
|  | 845 | encode_sequence_maxsz + \ | 
|  | 846 | encode_putrootfh_maxsz +\ | 
|  | 847 | encode_secinfo_no_name_maxsz) | 
|  | 848 | #define NFS4_dec_secinfo_no_name_sz	(compound_decode_hdr_maxsz + \ | 
|  | 849 | decode_sequence_maxsz + \ | 
|  | 850 | decode_putrootfh_maxsz + \ | 
|  | 851 | decode_secinfo_no_name_maxsz) | 
| Bryan Schumaker | 7d97479 | 2011-06-02 14:59:08 -0400 | [diff] [blame] | 852 | #define NFS4_enc_test_stateid_sz	(compound_encode_hdr_maxsz + \ | 
|  | 853 | encode_sequence_maxsz + \ | 
|  | 854 | encode_test_stateid_maxsz) | 
|  | 855 | #define NFS4_dec_test_stateid_sz	(compound_decode_hdr_maxsz + \ | 
|  | 856 | decode_sequence_maxsz + \ | 
|  | 857 | decode_test_stateid_maxsz) | 
| Bryan Schumaker | 9aeda35 | 2011-06-02 14:59:09 -0400 | [diff] [blame] | 858 | #define NFS4_enc_free_stateid_sz	(compound_encode_hdr_maxsz + \ | 
|  | 859 | encode_sequence_maxsz + \ | 
|  | 860 | encode_free_stateid_maxsz) | 
|  | 861 | #define NFS4_dec_free_stateid_sz	(compound_decode_hdr_maxsz + \ | 
|  | 862 | decode_sequence_maxsz + \ | 
|  | 863 | decode_free_stateid_maxsz) | 
| Alexandros Batsakis | 2449ea2 | 2009-12-05 13:36:55 -0500 | [diff] [blame] | 864 |  | 
|  | 865 | const u32 nfs41_maxwrite_overhead = ((RPC_MAX_HEADER_WITH_AUTH + | 
|  | 866 | compound_encode_hdr_maxsz + | 
|  | 867 | encode_sequence_maxsz + | 
|  | 868 | encode_putfh_maxsz + | 
|  | 869 | encode_getattr_maxsz) * | 
|  | 870 | XDR_UNIT); | 
|  | 871 |  | 
|  | 872 | const u32 nfs41_maxread_overhead = ((RPC_MAX_HEADER_WITH_AUTH + | 
|  | 873 | compound_decode_hdr_maxsz + | 
|  | 874 | decode_sequence_maxsz + | 
|  | 875 | decode_putfh_maxsz) * | 
|  | 876 | XDR_UNIT); | 
| Andy Adamson | f1c097b | 2013-06-25 19:02:53 -0400 | [diff] [blame] | 877 |  | 
|  | 878 | const u32 nfs41_maxgetdevinfo_overhead = ((RPC_MAX_REPHEADER_WITH_AUTH + | 
|  | 879 | compound_decode_hdr_maxsz + | 
|  | 880 | decode_sequence_maxsz) * | 
|  | 881 | XDR_UNIT); | 
|  | 882 | EXPORT_SYMBOL_GPL(nfs41_maxgetdevinfo_overhead); | 
| Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 883 | #endif /* CONFIG_NFS_V4_1 */ | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 884 |  | 
| Trond Myklebust | bca7947 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 885 | static const umode_t nfs_type2fmt[] = { | 
|  | 886 | [NF4BAD] = 0, | 
|  | 887 | [NF4REG] = S_IFREG, | 
|  | 888 | [NF4DIR] = S_IFDIR, | 
|  | 889 | [NF4BLK] = S_IFBLK, | 
|  | 890 | [NF4CHR] = S_IFCHR, | 
|  | 891 | [NF4LNK] = S_IFLNK, | 
|  | 892 | [NF4SOCK] = S_IFSOCK, | 
|  | 893 | [NF4FIFO] = S_IFIFO, | 
|  | 894 | [NF4ATTRDIR] = 0, | 
|  | 895 | [NF4NAMEDATTR] = 0, | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 896 | }; | 
|  | 897 |  | 
|  | 898 | struct compound_hdr { | 
|  | 899 | int32_t		status; | 
|  | 900 | uint32_t	nops; | 
| Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 901 | __be32 *	nops_p; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 902 | uint32_t	taglen; | 
|  | 903 | char *		tag; | 
| Benny Halevy | 0c4e8c1 | 2009-04-01 09:22:07 -0400 | [diff] [blame] | 904 | uint32_t	replen;		/* expected reply words */ | 
| Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 905 | u32		minorversion; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 906 | }; | 
|  | 907 |  | 
| Benny Halevy | 13c65ce | 2009-08-14 17:19:25 +0300 | [diff] [blame] | 908 | static __be32 *reserve_space(struct xdr_stream *xdr, size_t nbytes) | 
|  | 909 | { | 
|  | 910 | __be32 *p = xdr_reserve_space(xdr, nbytes); | 
|  | 911 | BUG_ON(!p); | 
|  | 912 | return p; | 
|  | 913 | } | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 914 |  | 
| Trond Myklebust | cb17e55 | 2012-03-04 18:13:56 -0500 | [diff] [blame] | 915 | static void encode_opaque_fixed(struct xdr_stream *xdr, const void *buf, size_t len) | 
|  | 916 | { | 
|  | 917 | __be32 *p; | 
|  | 918 |  | 
|  | 919 | p = xdr_reserve_space(xdr, len); | 
|  | 920 | xdr_encode_opaque_fixed(p, buf, len); | 
|  | 921 | } | 
|  | 922 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 923 | static void encode_string(struct xdr_stream *xdr, unsigned int len, const char *str) | 
|  | 924 | { | 
| Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 925 | __be32 *p; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 926 |  | 
| Trond Myklebust | 6fdfb0bc | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 927 | p = reserve_space(xdr, 4 + len); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 928 | xdr_encode_opaque(p, str, len); | 
|  | 929 | } | 
|  | 930 |  | 
| Trond Myklebust | 4ade982 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 931 | static void encode_uint32(struct xdr_stream *xdr, u32 n) | 
|  | 932 | { | 
|  | 933 | __be32 *p; | 
|  | 934 |  | 
|  | 935 | p = reserve_space(xdr, 4); | 
|  | 936 | *p = cpu_to_be32(n); | 
|  | 937 | } | 
|  | 938 |  | 
| Trond Myklebust | ff2eb68 | 2012-03-05 11:40:12 -0500 | [diff] [blame] | 939 | static void encode_uint64(struct xdr_stream *xdr, u64 n) | 
|  | 940 | { | 
|  | 941 | __be32 *p; | 
|  | 942 |  | 
|  | 943 | p = reserve_space(xdr, 8); | 
|  | 944 | xdr_encode_hyper(p, n); | 
|  | 945 | } | 
|  | 946 |  | 
| Trond Myklebust | 4ade982 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 947 | static void encode_nfs4_seqid(struct xdr_stream *xdr, | 
|  | 948 | const struct nfs_seqid *seqid) | 
|  | 949 | { | 
| Trond Myklebust | a679641 | 2015-01-23 19:04:44 -0500 | [diff] [blame] | 950 | if (seqid != NULL) | 
|  | 951 | encode_uint32(xdr, seqid->sequence->counter); | 
|  | 952 | else | 
|  | 953 | encode_uint32(xdr, 0); | 
| Trond Myklebust | 4ade982 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 954 | } | 
|  | 955 |  | 
| Benny Halevy | 0c4e8c1 | 2009-04-01 09:22:07 -0400 | [diff] [blame] | 956 | static void encode_compound_hdr(struct xdr_stream *xdr, | 
|  | 957 | struct rpc_rqst *req, | 
|  | 958 | struct compound_hdr *hdr) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 959 | { | 
| Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 960 | __be32 *p; | 
| Trond Myklebust | a17c215 | 2010-07-31 14:29:08 -0400 | [diff] [blame] | 961 | struct rpc_auth *auth = req->rq_cred->cr_auth; | 
| Benny Halevy | 0c4e8c1 | 2009-04-01 09:22:07 -0400 | [diff] [blame] | 962 |  | 
|  | 963 | /* initialize running count of expected bytes in reply. | 
|  | 964 | * NOTE: the replied tag SHOULD be the same is the one sent, | 
|  | 965 | * but this is not required as a MUST for the server to do so. */ | 
|  | 966 | hdr->replen = RPC_REPHDRSIZE + auth->au_rslack + 3 + hdr->taglen; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 967 |  | 
| Trond Myklebust | 7fc3884 | 2012-10-15 11:51:21 -0400 | [diff] [blame] | 968 | WARN_ON_ONCE(hdr->taglen > NFS4_MAXTAGLEN); | 
| Trond Myklebust | 6fdfb0bc | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 969 | encode_string(xdr, hdr->taglen, hdr->tag); | 
|  | 970 | p = reserve_space(xdr, 8); | 
| Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 971 | *p++ = cpu_to_be32(hdr->minorversion); | 
| Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 972 | hdr->nops_p = p; | 
| Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 973 | *p = cpu_to_be32(hdr->nops); | 
| Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 974 | } | 
|  | 975 |  | 
| Trond Myklebust | ab19b48 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 976 | static void encode_op_hdr(struct xdr_stream *xdr, enum nfs_opnum4 op, | 
|  | 977 | uint32_t replen, | 
|  | 978 | struct compound_hdr *hdr) | 
|  | 979 | { | 
|  | 980 | encode_uint32(xdr, op); | 
|  | 981 | hdr->nops++; | 
|  | 982 | hdr->replen += replen; | 
|  | 983 | } | 
|  | 984 |  | 
| Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 985 | static void encode_nops(struct compound_hdr *hdr) | 
|  | 986 | { | 
| Trond Myklebust | 7fc3884 | 2012-10-15 11:51:21 -0400 | [diff] [blame] | 987 | WARN_ON_ONCE(hdr->nops > NFS4_MAX_OPS); | 
| Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 988 | *hdr->nops_p = htonl(hdr->nops); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 989 | } | 
|  | 990 |  | 
| Trond Myklebust | ea9d23f | 2012-03-04 18:13:56 -0500 | [diff] [blame] | 991 | static void encode_nfs4_stateid(struct xdr_stream *xdr, const nfs4_stateid *stateid) | 
|  | 992 | { | 
| Trond Myklebust | 2d2f24a | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 993 | encode_opaque_fixed(xdr, stateid, NFS4_STATEID_SIZE); | 
| Trond Myklebust | ea9d23f | 2012-03-04 18:13:56 -0500 | [diff] [blame] | 994 | } | 
|  | 995 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 996 | static void encode_nfs4_verifier(struct xdr_stream *xdr, const nfs4_verifier *verf) | 
|  | 997 | { | 
| Trond Myklebust | cb17e55 | 2012-03-04 18:13:56 -0500 | [diff] [blame] | 998 | encode_opaque_fixed(xdr, verf->data, NFS4_VERIFIER_SIZE); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 999 | } | 
|  | 1000 |  | 
| David Quigley | aa9c266 | 2013-05-22 12:50:44 -0400 | [diff] [blame] | 1001 | static void encode_attrs(struct xdr_stream *xdr, const struct iattr *iap, | 
|  | 1002 | const struct nfs4_label *label, | 
| Kinglong Mee | 5334c5b | 2015-08-26 21:13:37 +0800 | [diff] [blame] | 1003 | const struct nfs_server *server, | 
|  | 1004 | bool excl_check) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1005 | { | 
|  | 1006 | char owner_name[IDMAP_NAMESZ]; | 
|  | 1007 | char owner_group[IDMAP_NAMESZ]; | 
|  | 1008 | int owner_namelen = 0; | 
|  | 1009 | int owner_grouplen = 0; | 
| Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 1010 | __be32 *p; | 
| Trond Myklebust | d7067b2 | 2013-07-17 17:09:01 -0400 | [diff] [blame] | 1011 | unsigned i; | 
|  | 1012 | uint32_t len = 0; | 
|  | 1013 | uint32_t bmval_len; | 
|  | 1014 | uint32_t bmval[3] = { 0 }; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1015 |  | 
|  | 1016 | /* | 
|  | 1017 | * We reserve enough space to write the entire attribute buffer at once. | 
|  | 1018 | * In the worst-case, this would be | 
| David Quigley | a09df2c | 2013-05-22 12:50:41 -0400 | [diff] [blame] | 1019 | * 16(bitmap) + 4(attrlen) + 8(size) + 4(mode) + 4(atime) + 4(mtime) | 
|  | 1020 | * = 40 bytes, plus any contribution from variable-length fields | 
| J. Bruce Fields | 23ec696 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 1021 | *            such as owner/group. | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1022 | */ | 
| Trond Myklebust | d7067b2 | 2013-07-17 17:09:01 -0400 | [diff] [blame] | 1023 | if (iap->ia_valid & ATTR_SIZE) { | 
|  | 1024 | bmval[0] |= FATTR4_WORD0_SIZE; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1025 | len += 8; | 
| Trond Myklebust | d7067b2 | 2013-07-17 17:09:01 -0400 | [diff] [blame] | 1026 | } | 
|  | 1027 | if (iap->ia_valid & ATTR_MODE) { | 
|  | 1028 | bmval[1] |= FATTR4_WORD1_MODE; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1029 | len += 4; | 
| Trond Myklebust | d7067b2 | 2013-07-17 17:09:01 -0400 | [diff] [blame] | 1030 | } | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1031 | if (iap->ia_valid & ATTR_UID) { | 
| Trond Myklebust | e4fd72a | 2011-02-22 15:44:31 -0800 | [diff] [blame] | 1032 | owner_namelen = nfs_map_uid_to_name(server, iap->ia_uid, owner_name, IDMAP_NAMESZ); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1033 | if (owner_namelen < 0) { | 
| Chuck Lever | fe82a18 | 2007-09-11 18:01:10 -0400 | [diff] [blame] | 1034 | dprintk("nfs: couldn't resolve uid %d to string\n", | 
| Eric W. Biederman | e578207 | 2013-02-01 14:22:02 -0800 | [diff] [blame] | 1035 | from_kuid(&init_user_ns, iap->ia_uid)); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1036 | /* XXX */ | 
|  | 1037 | strcpy(owner_name, "nobody"); | 
|  | 1038 | owner_namelen = sizeof("nobody") - 1; | 
|  | 1039 | /* goto out; */ | 
|  | 1040 | } | 
| Trond Myklebust | d7067b2 | 2013-07-17 17:09:01 -0400 | [diff] [blame] | 1041 | bmval[1] |= FATTR4_WORD1_OWNER; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1042 | len += 4 + (XDR_QUADLEN(owner_namelen) << 2); | 
|  | 1043 | } | 
|  | 1044 | if (iap->ia_valid & ATTR_GID) { | 
| Trond Myklebust | e4fd72a | 2011-02-22 15:44:31 -0800 | [diff] [blame] | 1045 | owner_grouplen = nfs_map_gid_to_group(server, iap->ia_gid, owner_group, IDMAP_NAMESZ); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1046 | if (owner_grouplen < 0) { | 
| Chuck Lever | fe82a18 | 2007-09-11 18:01:10 -0400 | [diff] [blame] | 1047 | dprintk("nfs: couldn't resolve gid %d to string\n", | 
| Eric W. Biederman | e578207 | 2013-02-01 14:22:02 -0800 | [diff] [blame] | 1048 | from_kgid(&init_user_ns, iap->ia_gid)); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1049 | strcpy(owner_group, "nobody"); | 
|  | 1050 | owner_grouplen = sizeof("nobody") - 1; | 
|  | 1051 | /* goto out; */ | 
|  | 1052 | } | 
| Trond Myklebust | d7067b2 | 2013-07-17 17:09:01 -0400 | [diff] [blame] | 1053 | bmval[1] |= FATTR4_WORD1_OWNER_GROUP; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1054 | len += 4 + (XDR_QUADLEN(owner_grouplen) << 2); | 
|  | 1055 | } | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1056 | if (iap->ia_valid & ATTR_ATIME_SET) { | 
| Trond Myklebust | d7067b2 | 2013-07-17 17:09:01 -0400 | [diff] [blame] | 1057 | bmval[1] |= FATTR4_WORD1_TIME_ACCESS_SET; | 
|  | 1058 | len += 16; | 
|  | 1059 | } else if (iap->ia_valid & ATTR_ATIME) { | 
|  | 1060 | bmval[1] |= FATTR4_WORD1_TIME_ACCESS_SET; | 
|  | 1061 | len += 4; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1062 | } | 
|  | 1063 | if (iap->ia_valid & ATTR_MTIME_SET) { | 
| Trond Myklebust | d7067b2 | 2013-07-17 17:09:01 -0400 | [diff] [blame] | 1064 | bmval[1] |= FATTR4_WORD1_TIME_MODIFY_SET; | 
|  | 1065 | len += 16; | 
|  | 1066 | } else if (iap->ia_valid & ATTR_MTIME) { | 
|  | 1067 | bmval[1] |= FATTR4_WORD1_TIME_MODIFY_SET; | 
|  | 1068 | len += 4; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1069 | } | 
| Kinglong Mee | 5334c5b | 2015-08-26 21:13:37 +0800 | [diff] [blame] | 1070 |  | 
|  | 1071 | if (excl_check) { | 
|  | 1072 | const u32 *excl_bmval = server->exclcreat_bitmask; | 
|  | 1073 | bmval[0] &= excl_bmval[0]; | 
|  | 1074 | bmval[1] &= excl_bmval[1]; | 
|  | 1075 | bmval[2] &= excl_bmval[2]; | 
|  | 1076 |  | 
|  | 1077 | if (!(excl_bmval[2] & FATTR4_WORD2_SECURITY_LABEL)) | 
|  | 1078 | label = NULL; | 
|  | 1079 | } | 
|  | 1080 |  | 
| David Quigley | aa9c266 | 2013-05-22 12:50:44 -0400 | [diff] [blame] | 1081 | if (label) { | 
| Trond Myklebust | d7067b2 | 2013-07-17 17:09:01 -0400 | [diff] [blame] | 1082 | len += 4 + 4 + 4 + (XDR_QUADLEN(label->len) << 2); | 
|  | 1083 | bmval[2] |= FATTR4_WORD2_SECURITY_LABEL; | 
|  | 1084 | } | 
|  | 1085 |  | 
|  | 1086 | if (bmval[2] != 0) | 
|  | 1087 | bmval_len = 3; | 
|  | 1088 | else if (bmval[1] != 0) | 
|  | 1089 | bmval_len = 2; | 
|  | 1090 | else | 
|  | 1091 | bmval_len = 1; | 
|  | 1092 |  | 
|  | 1093 | p = reserve_space(xdr, 4 + (bmval_len << 2) + 4 + len); | 
|  | 1094 |  | 
|  | 1095 | *p++ = cpu_to_be32(bmval_len); | 
|  | 1096 | for (i = 0; i < bmval_len; i++) | 
|  | 1097 | *p++ = cpu_to_be32(bmval[i]); | 
|  | 1098 | *p++ = cpu_to_be32(len); | 
|  | 1099 |  | 
|  | 1100 | if (bmval[0] & FATTR4_WORD0_SIZE) | 
|  | 1101 | p = xdr_encode_hyper(p, iap->ia_size); | 
|  | 1102 | if (bmval[1] & FATTR4_WORD1_MODE) | 
|  | 1103 | *p++ = cpu_to_be32(iap->ia_mode & S_IALLUGO); | 
|  | 1104 | if (bmval[1] & FATTR4_WORD1_OWNER) | 
|  | 1105 | p = xdr_encode_opaque(p, owner_name, owner_namelen); | 
|  | 1106 | if (bmval[1] & FATTR4_WORD1_OWNER_GROUP) | 
|  | 1107 | p = xdr_encode_opaque(p, owner_group, owner_grouplen); | 
|  | 1108 | if (bmval[1] & FATTR4_WORD1_TIME_ACCESS_SET) { | 
|  | 1109 | if (iap->ia_valid & ATTR_ATIME_SET) { | 
|  | 1110 | *p++ = cpu_to_be32(NFS4_SET_TO_CLIENT_TIME); | 
|  | 1111 | p = xdr_encode_hyper(p, (s64)iap->ia_atime.tv_sec); | 
|  | 1112 | *p++ = cpu_to_be32(iap->ia_atime.tv_nsec); | 
|  | 1113 | } else | 
|  | 1114 | *p++ = cpu_to_be32(NFS4_SET_TO_SERVER_TIME); | 
|  | 1115 | } | 
|  | 1116 | if (bmval[1] & FATTR4_WORD1_TIME_MODIFY_SET) { | 
|  | 1117 | if (iap->ia_valid & ATTR_MTIME_SET) { | 
|  | 1118 | *p++ = cpu_to_be32(NFS4_SET_TO_CLIENT_TIME); | 
|  | 1119 | p = xdr_encode_hyper(p, (s64)iap->ia_mtime.tv_sec); | 
|  | 1120 | *p++ = cpu_to_be32(iap->ia_mtime.tv_nsec); | 
|  | 1121 | } else | 
|  | 1122 | *p++ = cpu_to_be32(NFS4_SET_TO_SERVER_TIME); | 
|  | 1123 | } | 
|  | 1124 | if (bmval[2] & FATTR4_WORD2_SECURITY_LABEL) { | 
| David Quigley | aa9c266 | 2013-05-22 12:50:44 -0400 | [diff] [blame] | 1125 | *p++ = cpu_to_be32(label->lfs); | 
|  | 1126 | *p++ = cpu_to_be32(label->pi); | 
|  | 1127 | *p++ = cpu_to_be32(label->len); | 
|  | 1128 | p = xdr_encode_opaque_fixed(p, label->label, label->len); | 
|  | 1129 | } | 
| Andy Adamson | 6c0195a | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 1130 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1131 | /* out: */ | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1132 | } | 
|  | 1133 |  | 
| Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1134 | static void encode_access(struct xdr_stream *xdr, u32 access, struct compound_hdr *hdr) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1135 | { | 
| Trond Myklebust | 475d4ba | 2012-03-05 11:27:16 -0500 | [diff] [blame] | 1136 | encode_op_hdr(xdr, OP_ACCESS, decode_access_maxsz, hdr); | 
|  | 1137 | encode_uint32(xdr, access); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1138 | } | 
|  | 1139 |  | 
| Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1140 | static void encode_close(struct xdr_stream *xdr, const struct nfs_closeargs *arg, struct compound_hdr *hdr) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1141 | { | 
| Trond Myklebust | ab19b48 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1142 | encode_op_hdr(xdr, OP_CLOSE, decode_close_maxsz, hdr); | 
| Trond Myklebust | 4ade982 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1143 | encode_nfs4_seqid(xdr, arg->seqid); | 
| Trond Myklebust | 566fcec | 2015-01-23 15:32:46 -0500 | [diff] [blame] | 1144 | encode_nfs4_stateid(xdr, &arg->stateid); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1145 | } | 
|  | 1146 |  | 
| Fred Isaman | 0b7c015 | 2012-04-20 14:47:39 -0400 | [diff] [blame] | 1147 | static void encode_commit(struct xdr_stream *xdr, const struct nfs_commitargs *args, struct compound_hdr *hdr) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1148 | { | 
| Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 1149 | __be32 *p; | 
| Andy Adamson | 6c0195a | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 1150 |  | 
| Trond Myklebust | 475d4ba | 2012-03-05 11:27:16 -0500 | [diff] [blame] | 1151 | encode_op_hdr(xdr, OP_COMMIT, decode_commit_maxsz, hdr); | 
|  | 1152 | p = reserve_space(xdr, 12); | 
| Benny Halevy | b95be5a | 2009-08-14 17:19:01 +0300 | [diff] [blame] | 1153 | p = xdr_encode_hyper(p, args->offset); | 
| Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1154 | *p = cpu_to_be32(args->count); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1155 | } | 
|  | 1156 |  | 
| Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1157 | static void encode_create(struct xdr_stream *xdr, const struct nfs4_create_arg *create, struct compound_hdr *hdr) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1158 | { | 
| Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 1159 | __be32 *p; | 
| Andy Adamson | 6c0195a | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 1160 |  | 
| Trond Myklebust | 475d4ba | 2012-03-05 11:27:16 -0500 | [diff] [blame] | 1161 | encode_op_hdr(xdr, OP_CREATE, decode_create_maxsz, hdr); | 
|  | 1162 | encode_uint32(xdr, create->ftype); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1163 |  | 
|  | 1164 | switch (create->ftype) { | 
|  | 1165 | case NF4LNK: | 
| Benny Halevy | 13c65ce | 2009-08-14 17:19:25 +0300 | [diff] [blame] | 1166 | p = reserve_space(xdr, 4); | 
| Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1167 | *p = cpu_to_be32(create->u.symlink.len); | 
| Chuck Lever | 2fcc213 | 2015-08-03 13:04:26 -0400 | [diff] [blame] | 1168 | xdr_write_pages(xdr, create->u.symlink.pages, 0, | 
|  | 1169 | create->u.symlink.len); | 
|  | 1170 | xdr->buf->flags |= XDRBUF_WRITE; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1171 | break; | 
|  | 1172 |  | 
|  | 1173 | case NF4BLK: case NF4CHR: | 
| Benny Halevy | 13c65ce | 2009-08-14 17:19:25 +0300 | [diff] [blame] | 1174 | p = reserve_space(xdr, 8); | 
| Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1175 | *p++ = cpu_to_be32(create->u.device.specdata1); | 
| Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1176 | *p = cpu_to_be32(create->u.device.specdata2); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1177 | break; | 
|  | 1178 |  | 
|  | 1179 | default: | 
|  | 1180 | break; | 
|  | 1181 | } | 
|  | 1182 |  | 
| Benny Halevy | 811652b | 2009-08-14 17:19:34 +0300 | [diff] [blame] | 1183 | encode_string(xdr, create->name->len, create->name->name); | 
| Kinglong Mee | 5334c5b | 2015-08-26 21:13:37 +0800 | [diff] [blame] | 1184 | encode_attrs(xdr, create->attrs, create->label, create->server, false); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1185 | } | 
|  | 1186 |  | 
| Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1187 | static void encode_getattr_one(struct xdr_stream *xdr, uint32_t bitmap, struct compound_hdr *hdr) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1188 | { | 
| Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 1189 | __be32 *p; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1190 |  | 
| Trond Myklebust | 475d4ba | 2012-03-05 11:27:16 -0500 | [diff] [blame] | 1191 | encode_op_hdr(xdr, OP_GETATTR, decode_getattr_maxsz, hdr); | 
|  | 1192 | p = reserve_space(xdr, 8); | 
| Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1193 | *p++ = cpu_to_be32(1); | 
| Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1194 | *p = cpu_to_be32(bitmap); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1195 | } | 
|  | 1196 |  | 
| Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1197 | static void encode_getattr_two(struct xdr_stream *xdr, uint32_t bm0, uint32_t bm1, struct compound_hdr *hdr) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1198 | { | 
| Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 1199 | __be32 *p; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1200 |  | 
| Trond Myklebust | 475d4ba | 2012-03-05 11:27:16 -0500 | [diff] [blame] | 1201 | encode_op_hdr(xdr, OP_GETATTR, decode_getattr_maxsz, hdr); | 
|  | 1202 | p = reserve_space(xdr, 12); | 
| Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1203 | *p++ = cpu_to_be32(2); | 
|  | 1204 | *p++ = cpu_to_be32(bm0); | 
| Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1205 | *p = cpu_to_be32(bm1); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1206 | } | 
|  | 1207 |  | 
| Fred Isaman | dae100c | 2011-07-30 20:52:37 -0400 | [diff] [blame] | 1208 | static void | 
|  | 1209 | encode_getattr_three(struct xdr_stream *xdr, | 
|  | 1210 | uint32_t bm0, uint32_t bm1, uint32_t bm2, | 
|  | 1211 | struct compound_hdr *hdr) | 
|  | 1212 | { | 
|  | 1213 | __be32 *p; | 
|  | 1214 |  | 
| Trond Myklebust | ab19b48 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1215 | encode_op_hdr(xdr, OP_GETATTR, decode_getattr_maxsz, hdr); | 
| Fred Isaman | dae100c | 2011-07-30 20:52:37 -0400 | [diff] [blame] | 1216 | if (bm2) { | 
|  | 1217 | p = reserve_space(xdr, 16); | 
|  | 1218 | *p++ = cpu_to_be32(3); | 
|  | 1219 | *p++ = cpu_to_be32(bm0); | 
|  | 1220 | *p++ = cpu_to_be32(bm1); | 
|  | 1221 | *p = cpu_to_be32(bm2); | 
|  | 1222 | } else if (bm1) { | 
|  | 1223 | p = reserve_space(xdr, 12); | 
|  | 1224 | *p++ = cpu_to_be32(2); | 
|  | 1225 | *p++ = cpu_to_be32(bm0); | 
|  | 1226 | *p = cpu_to_be32(bm1); | 
|  | 1227 | } else { | 
|  | 1228 | p = reserve_space(xdr, 8); | 
|  | 1229 | *p++ = cpu_to_be32(1); | 
|  | 1230 | *p = cpu_to_be32(bm0); | 
|  | 1231 | } | 
| Fred Isaman | dae100c | 2011-07-30 20:52:37 -0400 | [diff] [blame] | 1232 | } | 
|  | 1233 |  | 
| Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1234 | static void encode_getfattr(struct xdr_stream *xdr, const u32* bitmask, struct compound_hdr *hdr) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1235 | { | 
| David Quigley | a09df2c | 2013-05-22 12:50:41 -0400 | [diff] [blame] | 1236 | encode_getattr_three(xdr, bitmask[0] & nfs4_fattr_bitmap[0], | 
|  | 1237 | bitmask[1] & nfs4_fattr_bitmap[1], | 
|  | 1238 | bitmask[2] & nfs4_fattr_bitmap[2], | 
|  | 1239 | hdr); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1240 | } | 
|  | 1241 |  | 
| Andy Adamson | 88034c3 | 2012-05-23 05:02:34 -0400 | [diff] [blame] | 1242 | static void encode_getfattr_open(struct xdr_stream *xdr, const u32 *bitmask, | 
| Trond Myklebust | 1549210f | 2012-06-05 09:16:47 -0400 | [diff] [blame] | 1243 | const u32 *open_bitmap, | 
| Andy Adamson | 88034c3 | 2012-05-23 05:02:34 -0400 | [diff] [blame] | 1244 | struct compound_hdr *hdr) | 
|  | 1245 | { | 
|  | 1246 | encode_getattr_three(xdr, | 
| Trond Myklebust | 1549210f | 2012-06-05 09:16:47 -0400 | [diff] [blame] | 1247 | bitmask[0] & open_bitmap[0], | 
|  | 1248 | bitmask[1] & open_bitmap[1], | 
|  | 1249 | bitmask[2] & open_bitmap[2], | 
| Andy Adamson | 88034c3 | 2012-05-23 05:02:34 -0400 | [diff] [blame] | 1250 | hdr); | 
|  | 1251 | } | 
|  | 1252 |  | 
| Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1253 | static void encode_fsinfo(struct xdr_stream *xdr, const u32* bitmask, struct compound_hdr *hdr) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1254 | { | 
| Fred Isaman | dae100c | 2011-07-30 20:52:37 -0400 | [diff] [blame] | 1255 | encode_getattr_three(xdr, | 
|  | 1256 | bitmask[0] & nfs4_fsinfo_bitmap[0], | 
|  | 1257 | bitmask[1] & nfs4_fsinfo_bitmap[1], | 
|  | 1258 | bitmask[2] & nfs4_fsinfo_bitmap[2], | 
|  | 1259 | hdr); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1260 | } | 
|  | 1261 |  | 
| Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1262 | static void encode_fs_locations(struct xdr_stream *xdr, const u32* bitmask, struct compound_hdr *hdr) | 
| Manoj Naik | 830b8e3 | 2006-06-09 09:34:25 -0400 | [diff] [blame] | 1263 | { | 
| Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1264 | encode_getattr_two(xdr, bitmask[0] & nfs4_fs_locations_bitmap[0], | 
|  | 1265 | bitmask[1] & nfs4_fs_locations_bitmap[1], hdr); | 
| Manoj Naik | 830b8e3 | 2006-06-09 09:34:25 -0400 | [diff] [blame] | 1266 | } | 
|  | 1267 |  | 
| Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1268 | static void encode_getfh(struct xdr_stream *xdr, struct compound_hdr *hdr) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1269 | { | 
| Trond Myklebust | ab19b48 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1270 | encode_op_hdr(xdr, OP_GETFH, decode_getfh_maxsz, hdr); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1271 | } | 
|  | 1272 |  | 
| Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1273 | static void encode_link(struct xdr_stream *xdr, const struct qstr *name, struct compound_hdr *hdr) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1274 | { | 
| Trond Myklebust | ab19b48 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1275 | encode_op_hdr(xdr, OP_LINK, decode_link_maxsz, hdr); | 
| Trond Myklebust | 6fdfb0bc | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1276 | encode_string(xdr, name->len, name->name); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1277 | } | 
|  | 1278 |  | 
| Trond Myklebust | 911d1aa | 2006-01-03 09:55:16 +0100 | [diff] [blame] | 1279 | static inline int nfs4_lock_type(struct file_lock *fl, int block) | 
|  | 1280 | { | 
| Jeff Layton | f44106e | 2012-07-23 15:49:56 -0400 | [diff] [blame] | 1281 | if (fl->fl_type == F_RDLCK) | 
| Trond Myklebust | 911d1aa | 2006-01-03 09:55:16 +0100 | [diff] [blame] | 1282 | return block ? NFS4_READW_LT : NFS4_READ_LT; | 
|  | 1283 | return block ? NFS4_WRITEW_LT : NFS4_WRITE_LT; | 
|  | 1284 | } | 
|  | 1285 |  | 
|  | 1286 | static inline uint64_t nfs4_lock_length(struct file_lock *fl) | 
|  | 1287 | { | 
|  | 1288 | if (fl->fl_end == OFFSET_MAX) | 
|  | 1289 | return ~(uint64_t)0; | 
|  | 1290 | return fl->fl_end - fl->fl_start + 1; | 
|  | 1291 | } | 
|  | 1292 |  | 
| Trond Myklebust | daccbde | 2010-06-25 18:11:43 -0400 | [diff] [blame] | 1293 | static void encode_lockowner(struct xdr_stream *xdr, const struct nfs_lowner *lowner) | 
|  | 1294 | { | 
|  | 1295 | __be32 *p; | 
|  | 1296 |  | 
| Trond Myklebust | d035c36 | 2010-12-21 10:45:27 -0500 | [diff] [blame] | 1297 | p = reserve_space(xdr, 32); | 
| Trond Myklebust | daccbde | 2010-06-25 18:11:43 -0400 | [diff] [blame] | 1298 | p = xdr_encode_hyper(p, lowner->clientid); | 
| Trond Myklebust | d035c36 | 2010-12-21 10:45:27 -0500 | [diff] [blame] | 1299 | *p++ = cpu_to_be32(20); | 
| Trond Myklebust | daccbde | 2010-06-25 18:11:43 -0400 | [diff] [blame] | 1300 | p = xdr_encode_opaque_fixed(p, "lock id:", 8); | 
| Trond Myklebust | d035c36 | 2010-12-21 10:45:27 -0500 | [diff] [blame] | 1301 | *p++ = cpu_to_be32(lowner->s_dev); | 
| Trond Myklebust | daccbde | 2010-06-25 18:11:43 -0400 | [diff] [blame] | 1302 | xdr_encode_hyper(p, lowner->id); | 
|  | 1303 | } | 
|  | 1304 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1305 | /* | 
|  | 1306 | * opcode,type,reclaim,offset,length,new_lock_owner = 32 | 
|  | 1307 | * open_seqid,open_stateid,lock_seqid,lock_owner.clientid, lock_owner.id = 40 | 
|  | 1308 | */ | 
| Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1309 | static void encode_lock(struct xdr_stream *xdr, const struct nfs_lock_args *args, struct compound_hdr *hdr) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1310 | { | 
| Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 1311 | __be32 *p; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1312 |  | 
| Trond Myklebust | 475d4ba | 2012-03-05 11:27:16 -0500 | [diff] [blame] | 1313 | encode_op_hdr(xdr, OP_LOCK, decode_lock_maxsz, hdr); | 
|  | 1314 | p = reserve_space(xdr, 28); | 
| Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1315 | *p++ = cpu_to_be32(nfs4_lock_type(args->fl, args->block)); | 
|  | 1316 | *p++ = cpu_to_be32(args->reclaim); | 
| Benny Halevy | b95be5a | 2009-08-14 17:19:01 +0300 | [diff] [blame] | 1317 | p = xdr_encode_hyper(p, args->fl->fl_start); | 
|  | 1318 | p = xdr_encode_hyper(p, nfs4_lock_length(args->fl)); | 
| Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1319 | *p = cpu_to_be32(args->new_lock_owner); | 
| Trond Myklebust | 911d1aa | 2006-01-03 09:55:16 +0100 | [diff] [blame] | 1320 | if (args->new_lock_owner){ | 
| Trond Myklebust | 4ade982 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1321 | encode_nfs4_seqid(xdr, args->open_seqid); | 
| Trond Myklebust | 425c1d4 | 2015-01-24 14:57:53 -0500 | [diff] [blame] | 1322 | encode_nfs4_stateid(xdr, &args->open_stateid); | 
| Trond Myklebust | 4ade982 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1323 | encode_nfs4_seqid(xdr, args->lock_seqid); | 
| Trond Myklebust | daccbde | 2010-06-25 18:11:43 -0400 | [diff] [blame] | 1324 | encode_lockowner(xdr, &args->lock_owner); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1325 | } | 
|  | 1326 | else { | 
| Trond Myklebust | 425c1d4 | 2015-01-24 14:57:53 -0500 | [diff] [blame] | 1327 | encode_nfs4_stateid(xdr, &args->lock_stateid); | 
| Trond Myklebust | 4ade982 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1328 | encode_nfs4_seqid(xdr, args->lock_seqid); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1329 | } | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1330 | } | 
|  | 1331 |  | 
| Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1332 | static void encode_lockt(struct xdr_stream *xdr, const struct nfs_lockt_args *args, struct compound_hdr *hdr) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1333 | { | 
| Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 1334 | __be32 *p; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1335 |  | 
| Trond Myklebust | 475d4ba | 2012-03-05 11:27:16 -0500 | [diff] [blame] | 1336 | encode_op_hdr(xdr, OP_LOCKT, decode_lockt_maxsz, hdr); | 
|  | 1337 | p = reserve_space(xdr, 20); | 
| Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1338 | *p++ = cpu_to_be32(nfs4_lock_type(args->fl, 0)); | 
| Benny Halevy | b95be5a | 2009-08-14 17:19:01 +0300 | [diff] [blame] | 1339 | p = xdr_encode_hyper(p, args->fl->fl_start); | 
|  | 1340 | p = xdr_encode_hyper(p, nfs4_lock_length(args->fl)); | 
| Trond Myklebust | daccbde | 2010-06-25 18:11:43 -0400 | [diff] [blame] | 1341 | encode_lockowner(xdr, &args->lock_owner); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1342 | } | 
|  | 1343 |  | 
| Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1344 | static void encode_locku(struct xdr_stream *xdr, const struct nfs_locku_args *args, struct compound_hdr *hdr) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1345 | { | 
| Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 1346 | __be32 *p; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1347 |  | 
| Trond Myklebust | 475d4ba | 2012-03-05 11:27:16 -0500 | [diff] [blame] | 1348 | encode_op_hdr(xdr, OP_LOCKU, decode_locku_maxsz, hdr); | 
|  | 1349 | encode_uint32(xdr, nfs4_lock_type(args->fl, 0)); | 
| Trond Myklebust | 4ade982 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1350 | encode_nfs4_seqid(xdr, args->seqid); | 
| Trond Myklebust | 425c1d4 | 2015-01-24 14:57:53 -0500 | [diff] [blame] | 1351 | encode_nfs4_stateid(xdr, &args->stateid); | 
| Trond Myklebust | ea9d23f | 2012-03-04 18:13:56 -0500 | [diff] [blame] | 1352 | p = reserve_space(xdr, 16); | 
| Benny Halevy | b95be5a | 2009-08-14 17:19:01 +0300 | [diff] [blame] | 1353 | p = xdr_encode_hyper(p, args->fl->fl_start); | 
| Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1354 | xdr_encode_hyper(p, nfs4_lock_length(args->fl)); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1355 | } | 
|  | 1356 |  | 
| Trond Myklebust | d3c7b7c | 2010-07-01 12:49:01 -0400 | [diff] [blame] | 1357 | static void encode_release_lockowner(struct xdr_stream *xdr, const struct nfs_lowner *lowner, struct compound_hdr *hdr) | 
|  | 1358 | { | 
| Trond Myklebust | ab19b48 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1359 | encode_op_hdr(xdr, OP_RELEASE_LOCKOWNER, decode_release_lockowner_maxsz, hdr); | 
| Trond Myklebust | d3c7b7c | 2010-07-01 12:49:01 -0400 | [diff] [blame] | 1360 | encode_lockowner(xdr, lowner); | 
| Trond Myklebust | d3c7b7c | 2010-07-01 12:49:01 -0400 | [diff] [blame] | 1361 | } | 
|  | 1362 |  | 
| Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1363 | static void encode_lookup(struct xdr_stream *xdr, const struct qstr *name, struct compound_hdr *hdr) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1364 | { | 
| Trond Myklebust | ab19b48 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1365 | encode_op_hdr(xdr, OP_LOOKUP, decode_lookup_maxsz, hdr); | 
| Trond Myklebust | 6fdfb0bc | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1366 | encode_string(xdr, name->len, name->name); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1367 | } | 
|  | 1368 |  | 
| Trond Myklebust | 6ae3733 | 2015-01-30 14:21:14 -0500 | [diff] [blame] | 1369 | static void encode_share_access(struct xdr_stream *xdr, u32 share_access) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1370 | { | 
| Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 1371 | __be32 *p; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1372 |  | 
| Benny Halevy | 13c65ce | 2009-08-14 17:19:25 +0300 | [diff] [blame] | 1373 | p = reserve_space(xdr, 8); | 
| Trond Myklebust | 6ae3733 | 2015-01-30 14:21:14 -0500 | [diff] [blame] | 1374 | *p++ = cpu_to_be32(share_access); | 
| Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1375 | *p = cpu_to_be32(0);		/* for linux, share_deny = 0 always */ | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1376 | } | 
|  | 1377 |  | 
|  | 1378 | static inline void encode_openhdr(struct xdr_stream *xdr, const struct nfs_openargs *arg) | 
|  | 1379 | { | 
| Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 1380 | __be32 *p; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1381 | /* | 
|  | 1382 | * opcode 4, seqid 4, share_access 4, share_deny 4, clientid 8, ownerlen 4, | 
|  | 1383 | * owner 4 = 32 | 
|  | 1384 | */ | 
| Trond Myklebust | 4ade982 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1385 | encode_nfs4_seqid(xdr, arg->seqid); | 
| Trond Myklebust | 6ae3733 | 2015-01-30 14:21:14 -0500 | [diff] [blame] | 1386 | encode_share_access(xdr, arg->share_access); | 
| Trond Myklebust | 95b72eb | 2012-04-20 19:24:51 -0400 | [diff] [blame] | 1387 | p = reserve_space(xdr, 36); | 
| Benny Halevy | b95be5a | 2009-08-14 17:19:01 +0300 | [diff] [blame] | 1388 | p = xdr_encode_hyper(p, arg->clientid); | 
| Trond Myklebust | 95b72eb | 2012-04-20 19:24:51 -0400 | [diff] [blame] | 1389 | *p++ = cpu_to_be32(24); | 
| Benny Halevy | 93f0cf2 | 2009-08-14 17:19:06 +0300 | [diff] [blame] | 1390 | p = xdr_encode_opaque_fixed(p, "open id:", 8); | 
| Trond Myklebust | d035c36 | 2010-12-21 10:45:27 -0500 | [diff] [blame] | 1391 | *p++ = cpu_to_be32(arg->server->s_dev); | 
| Trond Myklebust | 95b72eb | 2012-04-20 19:24:51 -0400 | [diff] [blame] | 1392 | *p++ = cpu_to_be32(arg->id.uniquifier); | 
|  | 1393 | xdr_encode_hyper(p, arg->id.create_time); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1394 | } | 
|  | 1395 |  | 
|  | 1396 | static inline void encode_createmode(struct xdr_stream *xdr, const struct nfs_openargs *arg) | 
|  | 1397 | { | 
| Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 1398 | __be32 *p; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1399 |  | 
| Benny Halevy | 13c65ce | 2009-08-14 17:19:25 +0300 | [diff] [blame] | 1400 | p = reserve_space(xdr, 4); | 
| Trond Myklebust | 549b19c | 2013-04-16 18:42:34 -0400 | [diff] [blame] | 1401 | switch(arg->createmode) { | 
|  | 1402 | case NFS4_CREATE_UNCHECKED: | 
| Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1403 | *p = cpu_to_be32(NFS4_CREATE_UNCHECKED); | 
| Kinglong Mee | 5334c5b | 2015-08-26 21:13:37 +0800 | [diff] [blame] | 1404 | encode_attrs(xdr, arg->u.attrs, arg->label, arg->server, false); | 
| Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 1405 | break; | 
| Trond Myklebust | 549b19c | 2013-04-16 18:42:34 -0400 | [diff] [blame] | 1406 | case NFS4_CREATE_GUARDED: | 
|  | 1407 | *p = cpu_to_be32(NFS4_CREATE_GUARDED); | 
| Kinglong Mee | 5334c5b | 2015-08-26 21:13:37 +0800 | [diff] [blame] | 1408 | encode_attrs(xdr, arg->u.attrs, arg->label, arg->server, false); | 
| Trond Myklebust | 549b19c | 2013-04-16 18:42:34 -0400 | [diff] [blame] | 1409 | break; | 
|  | 1410 | case NFS4_CREATE_EXCLUSIVE: | 
|  | 1411 | *p = cpu_to_be32(NFS4_CREATE_EXCLUSIVE); | 
|  | 1412 | encode_nfs4_verifier(xdr, &arg->u.verifier); | 
|  | 1413 | break; | 
|  | 1414 | case NFS4_CREATE_EXCLUSIVE4_1: | 
|  | 1415 | *p = cpu_to_be32(NFS4_CREATE_EXCLUSIVE4_1); | 
|  | 1416 | encode_nfs4_verifier(xdr, &arg->u.verifier); | 
| Kinglong Mee | 5334c5b | 2015-08-26 21:13:37 +0800 | [diff] [blame] | 1417 | encode_attrs(xdr, arg->u.attrs, arg->label, arg->server, true); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1418 | } | 
|  | 1419 | } | 
|  | 1420 |  | 
|  | 1421 | static void encode_opentype(struct xdr_stream *xdr, const struct nfs_openargs *arg) | 
|  | 1422 | { | 
| Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 1423 | __be32 *p; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1424 |  | 
| Benny Halevy | 13c65ce | 2009-08-14 17:19:25 +0300 | [diff] [blame] | 1425 | p = reserve_space(xdr, 4); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1426 | switch (arg->open_flags & O_CREAT) { | 
| Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 1427 | case 0: | 
| Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1428 | *p = cpu_to_be32(NFS4_OPEN_NOCREATE); | 
| Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 1429 | break; | 
|  | 1430 | default: | 
| Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1431 | *p = cpu_to_be32(NFS4_OPEN_CREATE); | 
| Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 1432 | encode_createmode(xdr, arg); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1433 | } | 
|  | 1434 | } | 
|  | 1435 |  | 
| Trond Myklebust | bd7bf9d | 2008-12-23 15:21:53 -0500 | [diff] [blame] | 1436 | static inline void encode_delegation_type(struct xdr_stream *xdr, fmode_t delegation_type) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1437 | { | 
| Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 1438 | __be32 *p; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1439 |  | 
| Benny Halevy | 13c65ce | 2009-08-14 17:19:25 +0300 | [diff] [blame] | 1440 | p = reserve_space(xdr, 4); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1441 | switch (delegation_type) { | 
| Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 1442 | case 0: | 
| Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1443 | *p = cpu_to_be32(NFS4_OPEN_DELEGATE_NONE); | 
| Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 1444 | break; | 
|  | 1445 | case FMODE_READ: | 
| Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1446 | *p = cpu_to_be32(NFS4_OPEN_DELEGATE_READ); | 
| Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 1447 | break; | 
|  | 1448 | case FMODE_WRITE|FMODE_READ: | 
| Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1449 | *p = cpu_to_be32(NFS4_OPEN_DELEGATE_WRITE); | 
| Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 1450 | break; | 
|  | 1451 | default: | 
|  | 1452 | BUG(); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1453 | } | 
|  | 1454 | } | 
|  | 1455 |  | 
|  | 1456 | static inline void encode_claim_null(struct xdr_stream *xdr, const struct qstr *name) | 
|  | 1457 | { | 
| Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 1458 | __be32 *p; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1459 |  | 
| Benny Halevy | 13c65ce | 2009-08-14 17:19:25 +0300 | [diff] [blame] | 1460 | p = reserve_space(xdr, 4); | 
| Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1461 | *p = cpu_to_be32(NFS4_OPEN_CLAIM_NULL); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1462 | encode_string(xdr, name->len, name->name); | 
|  | 1463 | } | 
|  | 1464 |  | 
| Trond Myklebust | bd7bf9d | 2008-12-23 15:21:53 -0500 | [diff] [blame] | 1465 | static inline void encode_claim_previous(struct xdr_stream *xdr, fmode_t type) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1466 | { | 
| Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 1467 | __be32 *p; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1468 |  | 
| Benny Halevy | 13c65ce | 2009-08-14 17:19:25 +0300 | [diff] [blame] | 1469 | p = reserve_space(xdr, 4); | 
| Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1470 | *p = cpu_to_be32(NFS4_OPEN_CLAIM_PREVIOUS); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1471 | encode_delegation_type(xdr, type); | 
|  | 1472 | } | 
|  | 1473 |  | 
|  | 1474 | static inline void encode_claim_delegate_cur(struct xdr_stream *xdr, const struct qstr *name, const nfs4_stateid *stateid) | 
|  | 1475 | { | 
| Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 1476 | __be32 *p; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1477 |  | 
| Trond Myklebust | ea9d23f | 2012-03-04 18:13:56 -0500 | [diff] [blame] | 1478 | p = reserve_space(xdr, 4); | 
|  | 1479 | *p = cpu_to_be32(NFS4_OPEN_CLAIM_DELEGATE_CUR); | 
|  | 1480 | encode_nfs4_stateid(xdr, stateid); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1481 | encode_string(xdr, name->len, name->name); | 
|  | 1482 | } | 
|  | 1483 |  | 
| Trond Myklebust | d9fc661 | 2013-03-15 15:39:06 -0400 | [diff] [blame] | 1484 | static inline void encode_claim_fh(struct xdr_stream *xdr) | 
|  | 1485 | { | 
|  | 1486 | __be32 *p; | 
|  | 1487 |  | 
|  | 1488 | p = reserve_space(xdr, 4); | 
|  | 1489 | *p = cpu_to_be32(NFS4_OPEN_CLAIM_FH); | 
|  | 1490 | } | 
|  | 1491 |  | 
|  | 1492 | static inline void encode_claim_delegate_cur_fh(struct xdr_stream *xdr, const nfs4_stateid *stateid) | 
|  | 1493 | { | 
|  | 1494 | __be32 *p; | 
|  | 1495 |  | 
|  | 1496 | p = reserve_space(xdr, 4); | 
|  | 1497 | *p = cpu_to_be32(NFS4_OPEN_CLAIM_DELEG_CUR_FH); | 
|  | 1498 | encode_nfs4_stateid(xdr, stateid); | 
|  | 1499 | } | 
|  | 1500 |  | 
| Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1501 | static void encode_open(struct xdr_stream *xdr, const struct nfs_openargs *arg, struct compound_hdr *hdr) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1502 | { | 
| Trond Myklebust | ab19b48 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1503 | encode_op_hdr(xdr, OP_OPEN, decode_open_maxsz, hdr); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1504 | encode_openhdr(xdr, arg); | 
|  | 1505 | encode_opentype(xdr, arg); | 
|  | 1506 | switch (arg->claim) { | 
| Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 1507 | case NFS4_OPEN_CLAIM_NULL: | 
|  | 1508 | encode_claim_null(xdr, arg->name); | 
|  | 1509 | break; | 
|  | 1510 | case NFS4_OPEN_CLAIM_PREVIOUS: | 
|  | 1511 | encode_claim_previous(xdr, arg->u.delegation_type); | 
|  | 1512 | break; | 
|  | 1513 | case NFS4_OPEN_CLAIM_DELEGATE_CUR: | 
|  | 1514 | encode_claim_delegate_cur(xdr, arg->name, &arg->u.delegation); | 
|  | 1515 | break; | 
| Trond Myklebust | d9fc661 | 2013-03-15 15:39:06 -0400 | [diff] [blame] | 1516 | case NFS4_OPEN_CLAIM_FH: | 
|  | 1517 | encode_claim_fh(xdr); | 
|  | 1518 | break; | 
|  | 1519 | case NFS4_OPEN_CLAIM_DELEG_CUR_FH: | 
|  | 1520 | encode_claim_delegate_cur_fh(xdr, &arg->u.delegation); | 
|  | 1521 | break; | 
| Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 1522 | default: | 
|  | 1523 | BUG(); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1524 | } | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1525 | } | 
|  | 1526 |  | 
| Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1527 | static void encode_open_confirm(struct xdr_stream *xdr, const struct nfs_open_confirmargs *arg, struct compound_hdr *hdr) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1528 | { | 
| Trond Myklebust | ab19b48 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1529 | encode_op_hdr(xdr, OP_OPEN_CONFIRM, decode_open_confirm_maxsz, hdr); | 
| Trond Myklebust | ea9d23f | 2012-03-04 18:13:56 -0500 | [diff] [blame] | 1530 | encode_nfs4_stateid(xdr, arg->stateid); | 
| Trond Myklebust | 4ade982 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1531 | encode_nfs4_seqid(xdr, arg->seqid); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1532 | } | 
|  | 1533 |  | 
| Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1534 | static void encode_open_downgrade(struct xdr_stream *xdr, const struct nfs_closeargs *arg, struct compound_hdr *hdr) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1535 | { | 
| Trond Myklebust | ab19b48 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1536 | encode_op_hdr(xdr, OP_OPEN_DOWNGRADE, decode_open_downgrade_maxsz, hdr); | 
| Trond Myklebust | 566fcec | 2015-01-23 15:32:46 -0500 | [diff] [blame] | 1537 | encode_nfs4_stateid(xdr, &arg->stateid); | 
| Trond Myklebust | 4ade982 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1538 | encode_nfs4_seqid(xdr, arg->seqid); | 
| Trond Myklebust | 6ae3733 | 2015-01-30 14:21:14 -0500 | [diff] [blame] | 1539 | encode_share_access(xdr, arg->share_access); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1540 | } | 
|  | 1541 |  | 
| Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1542 | static void | 
| Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 1543 | encode_putfh(struct xdr_stream *xdr, const struct nfs_fh *fh, struct compound_hdr *hdr) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1544 | { | 
| Trond Myklebust | ab19b48 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1545 | encode_op_hdr(xdr, OP_PUTFH, decode_putfh_maxsz, hdr); | 
| Trond Myklebust | 6fdfb0bc | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1546 | encode_string(xdr, fh->size, fh->data); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1547 | } | 
|  | 1548 |  | 
| Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1549 | static void encode_putrootfh(struct xdr_stream *xdr, struct compound_hdr *hdr) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1550 | { | 
| Trond Myklebust | ab19b48 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1551 | encode_op_hdr(xdr, OP_PUTROOTFH, decode_putrootfh_maxsz, hdr); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1552 | } | 
|  | 1553 |  | 
| Anna Schumaker | 3c6b899 | 2014-05-06 09:12:24 -0400 | [diff] [blame] | 1554 | static void encode_read(struct xdr_stream *xdr, const struct nfs_pgio_args *args, | 
|  | 1555 | struct compound_hdr *hdr) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1556 | { | 
| Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 1557 | __be32 *p; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1558 |  | 
| Trond Myklebust | ab19b48 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1559 | encode_op_hdr(xdr, OP_READ, decode_read_maxsz, hdr); | 
| Trond Myklebust | 9b20614 | 2013-03-17 15:52:00 -0400 | [diff] [blame] | 1560 | encode_nfs4_stateid(xdr, &args->stateid); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1561 |  | 
| Benny Halevy | 13c65ce | 2009-08-14 17:19:25 +0300 | [diff] [blame] | 1562 | p = reserve_space(xdr, 12); | 
| Benny Halevy | b95be5a | 2009-08-14 17:19:01 +0300 | [diff] [blame] | 1563 | p = xdr_encode_hyper(p, args->offset); | 
| Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1564 | *p = cpu_to_be32(args->count); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1565 | } | 
|  | 1566 |  | 
| Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1567 | static void encode_readdir(struct xdr_stream *xdr, const struct nfs4_readdir_arg *readdir, struct rpc_rqst *req, struct compound_hdr *hdr) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1568 | { | 
| David Quigley | aa9c266 | 2013-05-22 12:50:44 -0400 | [diff] [blame] | 1569 | uint32_t attrs[3] = { | 
| Trond Myklebust | 28331a4 | 2011-04-27 13:47:52 -0400 | [diff] [blame] | 1570 | FATTR4_WORD0_RDATTR_ERROR, | 
|  | 1571 | FATTR4_WORD1_MOUNTED_ON_FILEID, | 
|  | 1572 | }; | 
| Trond Myklebust | 6f7a35b | 2010-10-24 12:11:42 -0400 | [diff] [blame] | 1573 | uint32_t dircount = readdir->count >> 1; | 
| Chuck Lever | cd93710 | 2012-03-02 17:14:31 -0500 | [diff] [blame] | 1574 | __be32 *p, verf[2]; | 
| Trond Myklebust | d204c5d | 2013-11-04 13:23:59 -0500 | [diff] [blame] | 1575 | uint32_t attrlen = 0; | 
|  | 1576 | unsigned int i; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1577 |  | 
| Bryan Schumaker | 82f2e54 | 2010-10-21 16:33:18 -0400 | [diff] [blame] | 1578 | if (readdir->plus) { | 
|  | 1579 | attrs[0] |= FATTR4_WORD0_TYPE|FATTR4_WORD0_CHANGE|FATTR4_WORD0_SIZE| | 
| Trond Myklebust | 28331a4 | 2011-04-27 13:47:52 -0400 | [diff] [blame] | 1580 | FATTR4_WORD0_FSID|FATTR4_WORD0_FILEHANDLE|FATTR4_WORD0_FILEID; | 
| Bryan Schumaker | 82f2e54 | 2010-10-21 16:33:18 -0400 | [diff] [blame] | 1581 | attrs[1] |= FATTR4_WORD1_MODE|FATTR4_WORD1_NUMLINKS|FATTR4_WORD1_OWNER| | 
|  | 1582 | FATTR4_WORD1_OWNER_GROUP|FATTR4_WORD1_RAWDEV| | 
|  | 1583 | FATTR4_WORD1_SPACE_USED|FATTR4_WORD1_TIME_ACCESS| | 
|  | 1584 | FATTR4_WORD1_TIME_METADATA|FATTR4_WORD1_TIME_MODIFY; | 
| Trond Myklebust | d204c5d | 2013-11-04 13:23:59 -0500 | [diff] [blame] | 1585 | attrs[2] |= FATTR4_WORD2_SECURITY_LABEL; | 
| Trond Myklebust | 6f7a35b | 2010-10-24 12:11:42 -0400 | [diff] [blame] | 1586 | dircount >>= 1; | 
| Bryan Schumaker | 82f2e54 | 2010-10-21 16:33:18 -0400 | [diff] [blame] | 1587 | } | 
| Trond Myklebust | 28331a4 | 2011-04-27 13:47:52 -0400 | [diff] [blame] | 1588 | /* Use mounted_on_fileid only if the server supports it */ | 
|  | 1589 | if (!(readdir->bitmask[1] & FATTR4_WORD1_MOUNTED_ON_FILEID)) | 
|  | 1590 | attrs[0] |= FATTR4_WORD0_FILEID; | 
| Trond Myklebust | d204c5d | 2013-11-04 13:23:59 -0500 | [diff] [blame] | 1591 | for (i = 0; i < ARRAY_SIZE(attrs); i++) { | 
|  | 1592 | attrs[i] &= readdir->bitmask[i]; | 
|  | 1593 | if (attrs[i] != 0) | 
|  | 1594 | attrlen = i+1; | 
|  | 1595 | } | 
| Bryan Schumaker | 82f2e54 | 2010-10-21 16:33:18 -0400 | [diff] [blame] | 1596 |  | 
| Trond Myklebust | 475d4ba | 2012-03-05 11:27:16 -0500 | [diff] [blame] | 1597 | encode_op_hdr(xdr, OP_READDIR, decode_readdir_maxsz, hdr); | 
| Trond Myklebust | ff2eb68 | 2012-03-05 11:40:12 -0500 | [diff] [blame] | 1598 | encode_uint64(xdr, readdir->cookie); | 
| Chuck Lever | cd93710 | 2012-03-02 17:14:31 -0500 | [diff] [blame] | 1599 | encode_nfs4_verifier(xdr, &readdir->verifier); | 
| Trond Myklebust | d204c5d | 2013-11-04 13:23:59 -0500 | [diff] [blame] | 1600 | p = reserve_space(xdr, 12 + (attrlen << 2)); | 
| Trond Myklebust | 6f7a35b | 2010-10-24 12:11:42 -0400 | [diff] [blame] | 1601 | *p++ = cpu_to_be32(dircount); | 
| Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1602 | *p++ = cpu_to_be32(readdir->count); | 
| Trond Myklebust | d204c5d | 2013-11-04 13:23:59 -0500 | [diff] [blame] | 1603 | *p++ = cpu_to_be32(attrlen); | 
|  | 1604 | for (i = 0; i < attrlen; i++) | 
|  | 1605 | *p++ = cpu_to_be32(attrs[i]); | 
| Chuck Lever | cd93710 | 2012-03-02 17:14:31 -0500 | [diff] [blame] | 1606 | memcpy(verf, readdir->verifier.data, sizeof(verf)); | 
| David Quigley | aa9c266 | 2013-05-22 12:50:44 -0400 | [diff] [blame] | 1607 |  | 
|  | 1608 | dprintk("%s: cookie = %llu, verifier = %08x:%08x, bitmap = %08x:%08x:%08x\n", | 
| Fred Isaman | 4410924 | 2008-04-02 15:21:15 +0300 | [diff] [blame] | 1609 | __func__, | 
| Trond Myklebust | eadf459 | 2005-06-22 17:16:39 +0000 | [diff] [blame] | 1610 | (unsigned long long)readdir->cookie, | 
| Chuck Lever | cd93710 | 2012-03-02 17:14:31 -0500 | [diff] [blame] | 1611 | verf[0], verf[1], | 
| Trond Myklebust | eadf459 | 2005-06-22 17:16:39 +0000 | [diff] [blame] | 1612 | attrs[0] & readdir->bitmask[0], | 
| David Quigley | aa9c266 | 2013-05-22 12:50:44 -0400 | [diff] [blame] | 1613 | attrs[1] & readdir->bitmask[1], | 
|  | 1614 | attrs[2] & readdir->bitmask[2]); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1615 | } | 
|  | 1616 |  | 
| Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1617 | static void encode_readlink(struct xdr_stream *xdr, const struct nfs4_readlink *readlink, struct rpc_rqst *req, struct compound_hdr *hdr) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1618 | { | 
| Trond Myklebust | ab19b48 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1619 | encode_op_hdr(xdr, OP_READLINK, decode_readlink_maxsz, hdr); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1620 | } | 
|  | 1621 |  | 
| Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1622 | static void encode_remove(struct xdr_stream *xdr, const struct qstr *name, struct compound_hdr *hdr) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1623 | { | 
| Trond Myklebust | ab19b48 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1624 | encode_op_hdr(xdr, OP_REMOVE, decode_remove_maxsz, hdr); | 
| Trond Myklebust | 6fdfb0bc | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1625 | encode_string(xdr, name->len, name->name); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1626 | } | 
|  | 1627 |  | 
| Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1628 | static void encode_rename(struct xdr_stream *xdr, const struct qstr *oldname, const struct qstr *newname, struct compound_hdr *hdr) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1629 | { | 
| Trond Myklebust | ab19b48 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1630 | encode_op_hdr(xdr, OP_RENAME, decode_rename_maxsz, hdr); | 
| Benny Halevy | 811652b | 2009-08-14 17:19:34 +0300 | [diff] [blame] | 1631 | encode_string(xdr, oldname->len, oldname->name); | 
|  | 1632 | encode_string(xdr, newname->len, newname->name); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1633 | } | 
|  | 1634 |  | 
| Chuck Lever | bb4dae5 | 2012-03-01 17:01:48 -0500 | [diff] [blame] | 1635 | static void encode_renew(struct xdr_stream *xdr, clientid4 clid, | 
|  | 1636 | struct compound_hdr *hdr) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1637 | { | 
| Trond Myklebust | 475d4ba | 2012-03-05 11:27:16 -0500 | [diff] [blame] | 1638 | encode_op_hdr(xdr, OP_RENEW, decode_renew_maxsz, hdr); | 
| Trond Myklebust | ff2eb68 | 2012-03-05 11:40:12 -0500 | [diff] [blame] | 1639 | encode_uint64(xdr, clid); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1640 | } | 
|  | 1641 |  | 
| Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1642 | static void | 
| Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 1643 | encode_restorefh(struct xdr_stream *xdr, struct compound_hdr *hdr) | 
| Trond Myklebust | 56ae19f | 2005-10-27 22:12:40 -0400 | [diff] [blame] | 1644 | { | 
| Trond Myklebust | ab19b48 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1645 | encode_op_hdr(xdr, OP_RESTOREFH, decode_restorefh_maxsz, hdr); | 
| Trond Myklebust | 56ae19f | 2005-10-27 22:12:40 -0400 | [diff] [blame] | 1646 | } | 
|  | 1647 |  | 
| Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 1648 | static void | 
| Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 1649 | encode_setacl(struct xdr_stream *xdr, struct nfs_setaclargs *arg, struct compound_hdr *hdr) | 
| J. Bruce Fields | 23ec696 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 1650 | { | 
| Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 1651 | __be32 *p; | 
| J. Bruce Fields | 23ec696 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 1652 |  | 
| Trond Myklebust | ab19b48 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1653 | encode_op_hdr(xdr, OP_SETATTR, decode_setacl_maxsz, hdr); | 
| Trond Myklebust | ea9d23f | 2012-03-04 18:13:56 -0500 | [diff] [blame] | 1654 | encode_nfs4_stateid(xdr, &zero_stateid); | 
| Benny Halevy | 13c65ce | 2009-08-14 17:19:25 +0300 | [diff] [blame] | 1655 | p = reserve_space(xdr, 2*4); | 
| Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1656 | *p++ = cpu_to_be32(1); | 
| Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1657 | *p = cpu_to_be32(FATTR4_WORD0_ACL); | 
| Benny Halevy | 13c65ce | 2009-08-14 17:19:25 +0300 | [diff] [blame] | 1658 | p = reserve_space(xdr, 4); | 
| Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1659 | *p = cpu_to_be32(arg->acl_len); | 
| Andreas Gruenbacher | 8fbcf23 | 2015-11-03 18:25:34 +0100 | [diff] [blame] | 1660 | xdr_write_pages(xdr, arg->acl_pages, 0, arg->acl_len); | 
| J. Bruce Fields | 23ec696 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 1661 | } | 
|  | 1662 |  | 
| Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1663 | static void | 
| Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 1664 | encode_savefh(struct xdr_stream *xdr, struct compound_hdr *hdr) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1665 | { | 
| Trond Myklebust | ab19b48 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1666 | encode_op_hdr(xdr, OP_SAVEFH, decode_savefh_maxsz, hdr); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1667 | } | 
|  | 1668 |  | 
| Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1669 | static void encode_setattr(struct xdr_stream *xdr, const struct nfs_setattrargs *arg, const struct nfs_server *server, struct compound_hdr *hdr) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1670 | { | 
| Trond Myklebust | ab19b48 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1671 | encode_op_hdr(xdr, OP_SETATTR, decode_setattr_maxsz, hdr); | 
| Trond Myklebust | ea9d23f | 2012-03-04 18:13:56 -0500 | [diff] [blame] | 1672 | encode_nfs4_stateid(xdr, &arg->stateid); | 
| Kinglong Mee | 5334c5b | 2015-08-26 21:13:37 +0800 | [diff] [blame] | 1673 | encode_attrs(xdr, arg->iap, arg->label, server, false); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1674 | } | 
|  | 1675 |  | 
| Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1676 | static void encode_setclientid(struct xdr_stream *xdr, const struct nfs4_setclientid *setclientid, struct compound_hdr *hdr) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1677 | { | 
| Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 1678 | __be32 *p; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1679 |  | 
| Trond Myklebust | 7001951 | 2012-03-04 20:49:32 -0500 | [diff] [blame] | 1680 | encode_op_hdr(xdr, OP_SETCLIENTID, decode_setclientid_maxsz, hdr); | 
| Chuck Lever | cd93710 | 2012-03-02 17:14:31 -0500 | [diff] [blame] | 1681 | encode_nfs4_verifier(xdr, setclientid->sc_verifier); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1682 |  | 
| Jeff Layton | 3a6bb73 | 2015-06-09 19:43:57 -0400 | [diff] [blame] | 1683 | encode_string(xdr, strlen(setclientid->sc_clnt->cl_owner_id), | 
|  | 1684 | setclientid->sc_clnt->cl_owner_id); | 
| Benny Halevy | 13c65ce | 2009-08-14 17:19:25 +0300 | [diff] [blame] | 1685 | p = reserve_space(xdr, 4); | 
| Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1686 | *p = cpu_to_be32(setclientid->sc_prog); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1687 | encode_string(xdr, setclientid->sc_netid_len, setclientid->sc_netid); | 
|  | 1688 | encode_string(xdr, setclientid->sc_uaddr_len, setclientid->sc_uaddr); | 
| Benny Halevy | 13c65ce | 2009-08-14 17:19:25 +0300 | [diff] [blame] | 1689 | p = reserve_space(xdr, 4); | 
| Jeff Layton | 3a6bb73 | 2015-06-09 19:43:57 -0400 | [diff] [blame] | 1690 | *p = cpu_to_be32(setclientid->sc_clnt->cl_cb_ident); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1691 | } | 
|  | 1692 |  | 
| Trond Myklebust | bb8b27e | 2010-04-16 16:43:06 -0400 | [diff] [blame] | 1693 | static void encode_setclientid_confirm(struct xdr_stream *xdr, const struct nfs4_setclientid_res *arg, struct compound_hdr *hdr) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1694 | { | 
| Trond Myklebust | 475d4ba | 2012-03-05 11:27:16 -0500 | [diff] [blame] | 1695 | encode_op_hdr(xdr, OP_SETCLIENTID_CONFIRM, | 
|  | 1696 | decode_setclientid_confirm_maxsz, hdr); | 
| Trond Myklebust | ff2eb68 | 2012-03-05 11:40:12 -0500 | [diff] [blame] | 1697 | encode_uint64(xdr, arg->clientid); | 
| Chuck Lever | cd93710 | 2012-03-02 17:14:31 -0500 | [diff] [blame] | 1698 | encode_nfs4_verifier(xdr, &arg->confirm); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1699 | } | 
|  | 1700 |  | 
| Anna Schumaker | 3c6b899 | 2014-05-06 09:12:24 -0400 | [diff] [blame] | 1701 | static void encode_write(struct xdr_stream *xdr, const struct nfs_pgio_args *args, | 
|  | 1702 | struct compound_hdr *hdr) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1703 | { | 
| Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 1704 | __be32 *p; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1705 |  | 
| Trond Myklebust | ab19b48 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1706 | encode_op_hdr(xdr, OP_WRITE, decode_write_maxsz, hdr); | 
| Trond Myklebust | 9b20614 | 2013-03-17 15:52:00 -0400 | [diff] [blame] | 1707 | encode_nfs4_stateid(xdr, &args->stateid); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1708 |  | 
| Benny Halevy | 13c65ce | 2009-08-14 17:19:25 +0300 | [diff] [blame] | 1709 | p = reserve_space(xdr, 16); | 
| Benny Halevy | b95be5a | 2009-08-14 17:19:01 +0300 | [diff] [blame] | 1710 | p = xdr_encode_hyper(p, args->offset); | 
| Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1711 | *p++ = cpu_to_be32(args->stable); | 
| Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1712 | *p = cpu_to_be32(args->count); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1713 |  | 
|  | 1714 | xdr_write_pages(xdr, args->pages, args->pgbase, args->count); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1715 | } | 
|  | 1716 |  | 
| Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1717 | static void encode_delegreturn(struct xdr_stream *xdr, const nfs4_stateid *stateid, struct compound_hdr *hdr) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1718 | { | 
| Trond Myklebust | ab19b48 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1719 | encode_op_hdr(xdr, OP_DELEGRETURN, decode_delegreturn_maxsz, hdr); | 
| Trond Myklebust | ea9d23f | 2012-03-04 18:13:56 -0500 | [diff] [blame] | 1720 | encode_nfs4_stateid(xdr, stateid); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1721 | } | 
| Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 1722 |  | 
| Bryan Schumaker | 5a5ea0d | 2011-03-24 17:12:29 +0000 | [diff] [blame] | 1723 | static void encode_secinfo(struct xdr_stream *xdr, const struct qstr *name, struct compound_hdr *hdr) | 
|  | 1724 | { | 
| Trond Myklebust | ab19b48 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1725 | encode_op_hdr(xdr, OP_SECINFO, decode_secinfo_maxsz, hdr); | 
| Trond Myklebust | 6fdfb0bc | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1726 | encode_string(xdr, name->len, name->name); | 
| Bryan Schumaker | 5a5ea0d | 2011-03-24 17:12:29 +0000 | [diff] [blame] | 1727 | } | 
|  | 1728 |  | 
| Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 1729 | #if defined(CONFIG_NFS_V4_1) | 
| Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 1730 | /* NFSv4.1 operations */ | 
| Weston Andros Adamson | 7c44f1ae | 2012-05-24 13:22:50 -0400 | [diff] [blame] | 1731 | static void encode_bind_conn_to_session(struct xdr_stream *xdr, | 
| Trond Myklebust | 71a097c | 2015-02-18 09:27:18 -0800 | [diff] [blame] | 1732 | struct nfs41_bind_conn_to_session_args *args, | 
| Weston Andros Adamson | 7c44f1ae | 2012-05-24 13:22:50 -0400 | [diff] [blame] | 1733 | struct compound_hdr *hdr) | 
|  | 1734 | { | 
|  | 1735 | __be32 *p; | 
|  | 1736 |  | 
|  | 1737 | encode_op_hdr(xdr, OP_BIND_CONN_TO_SESSION, | 
|  | 1738 | decode_bind_conn_to_session_maxsz, hdr); | 
| Trond Myklebust | 71a097c | 2015-02-18 09:27:18 -0800 | [diff] [blame] | 1739 | encode_opaque_fixed(xdr, args->sessionid.data, NFS4_MAX_SESSIONID_LEN); | 
| Weston Andros Adamson | 7c44f1ae | 2012-05-24 13:22:50 -0400 | [diff] [blame] | 1740 | p = xdr_reserve_space(xdr, 8); | 
| Trond Myklebust | 71a097c | 2015-02-18 09:27:18 -0800 | [diff] [blame] | 1741 | *p++ = cpu_to_be32(args->dir); | 
|  | 1742 | *p = (args->use_conn_in_rdma_mode) ? cpu_to_be32(1) : cpu_to_be32(0); | 
| Weston Andros Adamson | 7c44f1ae | 2012-05-24 13:22:50 -0400 | [diff] [blame] | 1743 | } | 
|  | 1744 |  | 
| Weston Andros Adamson | 2031cd1 | 2013-08-13 16:37:32 -0400 | [diff] [blame] | 1745 | static void encode_op_map(struct xdr_stream *xdr, struct nfs4_op_map *op_map) | 
|  | 1746 | { | 
|  | 1747 | unsigned int i; | 
|  | 1748 | encode_uint32(xdr, NFS4_OP_MAP_NUM_WORDS); | 
|  | 1749 | for (i = 0; i < NFS4_OP_MAP_NUM_WORDS; i++) | 
|  | 1750 | encode_uint32(xdr, op_map->u.words[i]); | 
|  | 1751 | } | 
|  | 1752 |  | 
| Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 1753 | static void encode_exchange_id(struct xdr_stream *xdr, | 
|  | 1754 | struct nfs41_exchange_id_args *args, | 
|  | 1755 | struct compound_hdr *hdr) | 
|  | 1756 | { | 
|  | 1757 | __be32 *p; | 
| Jim Rees | d751f74 | 2012-11-16 18:12:06 -0500 | [diff] [blame] | 1758 | char impl_name[IMPL_NAME_LIMIT]; | 
| Weston Andros Adamson | db8ac8b | 2012-02-17 15:20:24 -0500 | [diff] [blame] | 1759 | int len = 0; | 
| Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 1760 |  | 
| Trond Myklebust | 7001951 | 2012-03-04 20:49:32 -0500 | [diff] [blame] | 1761 | encode_op_hdr(xdr, OP_EXCHANGE_ID, decode_exchange_id_maxsz, hdr); | 
| Chuck Lever | cd93710 | 2012-03-02 17:14:31 -0500 | [diff] [blame] | 1762 | encode_nfs4_verifier(xdr, args->verifier); | 
| Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 1763 |  | 
| Jeff Layton | 3a6bb73 | 2015-06-09 19:43:57 -0400 | [diff] [blame] | 1764 | encode_string(xdr, strlen(args->client->cl_owner_id), | 
|  | 1765 | args->client->cl_owner_id); | 
| Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 1766 |  | 
| Weston Andros Adamson | 2031cd1 | 2013-08-13 16:37:32 -0400 | [diff] [blame] | 1767 | encode_uint32(xdr, args->flags); | 
|  | 1768 | encode_uint32(xdr, args->state_protect.how); | 
|  | 1769 |  | 
|  | 1770 | switch (args->state_protect.how) { | 
|  | 1771 | case SP4_NONE: | 
|  | 1772 | break; | 
|  | 1773 | case SP4_MACH_CRED: | 
|  | 1774 | encode_op_map(xdr, &args->state_protect.enforce); | 
|  | 1775 | encode_op_map(xdr, &args->state_protect.allow); | 
|  | 1776 | break; | 
|  | 1777 | default: | 
|  | 1778 | WARN_ON_ONCE(1); | 
|  | 1779 | break; | 
|  | 1780 | } | 
| Weston Andros Adamson | db8ac8b | 2012-02-17 15:20:24 -0500 | [diff] [blame] | 1781 |  | 
|  | 1782 | if (send_implementation_id && | 
|  | 1783 | sizeof(CONFIG_NFS_V4_1_IMPLEMENTATION_ID_DOMAIN) > 1 && | 
|  | 1784 | sizeof(CONFIG_NFS_V4_1_IMPLEMENTATION_ID_DOMAIN) | 
| Jim Rees | d751f74 | 2012-11-16 18:12:06 -0500 | [diff] [blame] | 1785 | <= sizeof(impl_name) + 1) | 
| Weston Andros Adamson | db8ac8b | 2012-02-17 15:20:24 -0500 | [diff] [blame] | 1786 | len = snprintf(impl_name, sizeof(impl_name), "%s %s %s %s", | 
|  | 1787 | utsname()->sysname, utsname()->release, | 
|  | 1788 | utsname()->version, utsname()->machine); | 
|  | 1789 |  | 
|  | 1790 | if (len > 0) { | 
| Weston Andros Adamson | 2031cd1 | 2013-08-13 16:37:32 -0400 | [diff] [blame] | 1791 | encode_uint32(xdr, 1);	/* implementation id array length=1 */ | 
| Weston Andros Adamson | db8ac8b | 2012-02-17 15:20:24 -0500 | [diff] [blame] | 1792 |  | 
|  | 1793 | encode_string(xdr, | 
|  | 1794 | sizeof(CONFIG_NFS_V4_1_IMPLEMENTATION_ID_DOMAIN) - 1, | 
|  | 1795 | CONFIG_NFS_V4_1_IMPLEMENTATION_ID_DOMAIN); | 
|  | 1796 | encode_string(xdr, len, impl_name); | 
|  | 1797 | /* just send zeros for nii_date - the date is in nii_name */ | 
|  | 1798 | p = reserve_space(xdr, 12); | 
|  | 1799 | p = xdr_encode_hyper(p, 0); | 
|  | 1800 | *p = cpu_to_be32(0); | 
|  | 1801 | } else | 
| Weston Andros Adamson | 2031cd1 | 2013-08-13 16:37:32 -0400 | [diff] [blame] | 1802 | encode_uint32(xdr, 0);	/* implementation id array length=0 */ | 
| Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 1803 | } | 
| Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 1804 |  | 
|  | 1805 | static void encode_create_session(struct xdr_stream *xdr, | 
|  | 1806 | struct nfs41_create_session_args *args, | 
|  | 1807 | struct compound_hdr *hdr) | 
|  | 1808 | { | 
|  | 1809 | __be32 *p; | 
| Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 1810 | struct nfs_client *clp = args->client; | 
| Trond Myklebust | 89f0ff3 | 2015-01-03 14:47:43 -0500 | [diff] [blame] | 1811 | struct rpc_clnt *clnt = clp->cl_rpcclient; | 
| Chuck Lever | f092075 | 2012-05-21 22:45:41 -0400 | [diff] [blame] | 1812 | struct nfs_net *nn = net_generic(clp->cl_net, nfs_net_id); | 
| Mike Sager | 8e0d46e | 2009-12-17 12:06:26 -0500 | [diff] [blame] | 1813 | u32 max_resp_sz_cached; | 
|  | 1814 |  | 
|  | 1815 | /* | 
|  | 1816 | * Assumes OPEN is the biggest non-idempotent compound. | 
|  | 1817 | * 2 is the verifier. | 
|  | 1818 | */ | 
|  | 1819 | max_resp_sz_cached = (NFS4_dec_open_sz + RPC_REPHDRSIZE + | 
|  | 1820 | RPC_MAX_AUTH_SIZE + 2) * XDR_UNIT; | 
| Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 1821 |  | 
| Trond Myklebust | 475d4ba | 2012-03-05 11:27:16 -0500 | [diff] [blame] | 1822 | encode_op_hdr(xdr, OP_CREATE_SESSION, decode_create_session_maxsz, hdr); | 
| Trond Myklebust | 89f0ff3 | 2015-01-03 14:47:43 -0500 | [diff] [blame] | 1823 | p = reserve_space(xdr, 16 + 2*28 + 20 + clnt->cl_nodelen + 12); | 
| Trond Myklebust | 79969dd | 2015-02-18 11:30:18 -0800 | [diff] [blame] | 1824 | p = xdr_encode_hyper(p, args->clientid); | 
|  | 1825 | *p++ = cpu_to_be32(args->seqid);			/*Sequence id */ | 
| Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1826 | *p++ = cpu_to_be32(args->flags);			/*flags */ | 
| Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 1827 |  | 
| Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 1828 | /* Fore Channel */ | 
| Benny Halevy | c9c30dd | 2011-06-11 17:08:39 -0400 | [diff] [blame] | 1829 | *p++ = cpu_to_be32(0);				/* header padding size */ | 
| Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1830 | *p++ = cpu_to_be32(args->fc_attrs.max_rqst_sz);	/* max req size */ | 
|  | 1831 | *p++ = cpu_to_be32(args->fc_attrs.max_resp_sz);	/* max resp size */ | 
| Mike Sager | 8e0d46e | 2009-12-17 12:06:26 -0500 | [diff] [blame] | 1832 | *p++ = cpu_to_be32(max_resp_sz_cached);		/* Max resp sz cached */ | 
| Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1833 | *p++ = cpu_to_be32(args->fc_attrs.max_ops);	/* max operations */ | 
|  | 1834 | *p++ = cpu_to_be32(args->fc_attrs.max_reqs);	/* max requests */ | 
|  | 1835 | *p++ = cpu_to_be32(0);				/* rdmachannel_attrs */ | 
| Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 1836 |  | 
|  | 1837 | /* Back Channel */ | 
| Benny Halevy | c9c30dd | 2011-06-11 17:08:39 -0400 | [diff] [blame] | 1838 | *p++ = cpu_to_be32(0);				/* header padding size */ | 
| Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1839 | *p++ = cpu_to_be32(args->bc_attrs.max_rqst_sz);	/* max req size */ | 
|  | 1840 | *p++ = cpu_to_be32(args->bc_attrs.max_resp_sz);	/* max resp size */ | 
|  | 1841 | *p++ = cpu_to_be32(args->bc_attrs.max_resp_sz_cached);	/* Max resp sz cached */ | 
|  | 1842 | *p++ = cpu_to_be32(args->bc_attrs.max_ops);	/* max operations */ | 
|  | 1843 | *p++ = cpu_to_be32(args->bc_attrs.max_reqs);	/* max requests */ | 
|  | 1844 | *p++ = cpu_to_be32(0);				/* rdmachannel_attrs */ | 
| Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 1845 |  | 
| Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1846 | *p++ = cpu_to_be32(args->cb_program);		/* cb_program */ | 
| Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1847 | *p++ = cpu_to_be32(1); | 
| Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1848 | *p++ = cpu_to_be32(RPC_AUTH_UNIX);			/* auth_sys */ | 
| Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 1849 |  | 
|  | 1850 | /* authsys_parms rfc1831 */ | 
| Deepa Dinamani | 2f86e09 | 2016-10-01 16:46:26 -0700 | [diff] [blame] | 1851 | *p++ = cpu_to_be32(ktime_to_ns(nn->boot_time));	/* stamp */ | 
| Trond Myklebust | 89f0ff3 | 2015-01-03 14:47:43 -0500 | [diff] [blame] | 1852 | p = xdr_encode_array(p, clnt->cl_nodename, clnt->cl_nodelen); | 
| Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1853 | *p++ = cpu_to_be32(0);				/* UID */ | 
|  | 1854 | *p++ = cpu_to_be32(0);				/* GID */ | 
| Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1855 | *p = cpu_to_be32(0);				/* No more gids */ | 
| Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 1856 | } | 
| Andy Adamson | 0f3e66c | 2009-04-01 09:22:34 -0400 | [diff] [blame] | 1857 |  | 
|  | 1858 | static void encode_destroy_session(struct xdr_stream *xdr, | 
|  | 1859 | struct nfs4_session *session, | 
|  | 1860 | struct compound_hdr *hdr) | 
|  | 1861 | { | 
| Trond Myklebust | 475d4ba | 2012-03-05 11:27:16 -0500 | [diff] [blame] | 1862 | encode_op_hdr(xdr, OP_DESTROY_SESSION, decode_destroy_session_maxsz, hdr); | 
|  | 1863 | encode_opaque_fixed(xdr, session->sess_id.data, NFS4_MAX_SESSIONID_LEN); | 
| Andy Adamson | 0f3e66c | 2009-04-01 09:22:34 -0400 | [diff] [blame] | 1864 | } | 
| Ricardo Labiaga | 18019753 | 2009-12-05 16:08:40 -0500 | [diff] [blame] | 1865 |  | 
| Trond Myklebust | 6624553 | 2012-05-25 17:18:09 -0400 | [diff] [blame] | 1866 | static void encode_destroy_clientid(struct xdr_stream *xdr, | 
|  | 1867 | uint64_t clientid, | 
|  | 1868 | struct compound_hdr *hdr) | 
|  | 1869 | { | 
|  | 1870 | encode_op_hdr(xdr, OP_DESTROY_CLIENTID, decode_destroy_clientid_maxsz, hdr); | 
|  | 1871 | encode_uint64(xdr, clientid); | 
|  | 1872 | } | 
|  | 1873 |  | 
| Ricardo Labiaga | 18019753 | 2009-12-05 16:08:40 -0500 | [diff] [blame] | 1874 | static void encode_reclaim_complete(struct xdr_stream *xdr, | 
|  | 1875 | struct nfs41_reclaim_complete_args *args, | 
|  | 1876 | struct compound_hdr *hdr) | 
|  | 1877 | { | 
| Trond Myklebust | 475d4ba | 2012-03-05 11:27:16 -0500 | [diff] [blame] | 1878 | encode_op_hdr(xdr, OP_RECLAIM_COMPLETE, decode_reclaim_complete_maxsz, hdr); | 
|  | 1879 | encode_uint32(xdr, args->one_fs); | 
| Ricardo Labiaga | 18019753 | 2009-12-05 16:08:40 -0500 | [diff] [blame] | 1880 | } | 
| Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 1881 | #endif /* CONFIG_NFS_V4_1 */ | 
|  | 1882 |  | 
| Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 1883 | static void encode_sequence(struct xdr_stream *xdr, | 
|  | 1884 | const struct nfs4_sequence_args *args, | 
|  | 1885 | struct compound_hdr *hdr) | 
|  | 1886 | { | 
|  | 1887 | #if defined(CONFIG_NFS_V4_1) | 
| Trond Myklebust | 2b2fa71 | 2012-11-16 12:58:36 -0500 | [diff] [blame] | 1888 | struct nfs4_session *session; | 
| Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 1889 | struct nfs4_slot_table *tp; | 
| Trond Myklebust | 2b2fa71 | 2012-11-16 12:58:36 -0500 | [diff] [blame] | 1890 | struct nfs4_slot *slot = args->sa_slot; | 
| Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 1891 | __be32 *p; | 
| Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 1892 |  | 
| Trond Myklebust | 2b2fa71 | 2012-11-16 12:58:36 -0500 | [diff] [blame] | 1893 | tp = slot->table; | 
|  | 1894 | session = tp->session; | 
| Chuck Lever | 3bd2384 | 2013-08-09 12:49:19 -0400 | [diff] [blame] | 1895 | if (!session) | 
|  | 1896 | return; | 
| Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 1897 |  | 
| Trond Myklebust | 475d4ba | 2012-03-05 11:27:16 -0500 | [diff] [blame] | 1898 | encode_op_hdr(xdr, OP_SEQUENCE, decode_sequence_maxsz, hdr); | 
| Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 1899 |  | 
|  | 1900 | /* | 
|  | 1901 | * Sessionid + seqid + slotid + max slotid + cache_this | 
|  | 1902 | */ | 
|  | 1903 | dprintk("%s: sessionid=%u:%u:%u:%u seqid=%d slotid=%d " | 
|  | 1904 | "max_slotid=%d cache_this=%d\n", | 
|  | 1905 | __func__, | 
|  | 1906 | ((u32 *)session->sess_id.data)[0], | 
|  | 1907 | ((u32 *)session->sess_id.data)[1], | 
|  | 1908 | ((u32 *)session->sess_id.data)[2], | 
|  | 1909 | ((u32 *)session->sess_id.data)[3], | 
| Trond Myklebust | 2b2fa71 | 2012-11-16 12:58:36 -0500 | [diff] [blame] | 1910 | slot->seq_nr, slot->slot_nr, | 
| Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 1911 | tp->highest_used_slotid, args->sa_cache_this); | 
| Trond Myklebust | 475d4ba | 2012-03-05 11:27:16 -0500 | [diff] [blame] | 1912 | p = reserve_space(xdr, NFS4_MAX_SESSIONID_LEN + 16); | 
| Benny Halevy | 93f0cf2 | 2009-08-14 17:19:06 +0300 | [diff] [blame] | 1913 | p = xdr_encode_opaque_fixed(p, session->sess_id.data, NFS4_MAX_SESSIONID_LEN); | 
| Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1914 | *p++ = cpu_to_be32(slot->seq_nr); | 
| Trond Myklebust | 2b2fa71 | 2012-11-16 12:58:36 -0500 | [diff] [blame] | 1915 | *p++ = cpu_to_be32(slot->slot_nr); | 
| Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1916 | *p++ = cpu_to_be32(tp->highest_used_slotid); | 
| Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1917 | *p = cpu_to_be32(args->sa_cache_this); | 
| Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 1918 | #endif /* CONFIG_NFS_V4_1 */ | 
|  | 1919 | } | 
|  | 1920 |  | 
| Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 1921 | #ifdef CONFIG_NFS_V4_1 | 
|  | 1922 | static void | 
|  | 1923 | encode_getdeviceinfo(struct xdr_stream *xdr, | 
|  | 1924 | const struct nfs4_getdeviceinfo_args *args, | 
|  | 1925 | struct compound_hdr *hdr) | 
|  | 1926 | { | 
|  | 1927 | __be32 *p; | 
|  | 1928 |  | 
| Trond Myklebust | 475d4ba | 2012-03-05 11:27:16 -0500 | [diff] [blame] | 1929 | encode_op_hdr(xdr, OP_GETDEVICEINFO, decode_getdeviceinfo_maxsz, hdr); | 
| Christoph Hellwig | 84c9dee | 2014-09-10 17:37:28 -0700 | [diff] [blame] | 1930 | p = reserve_space(xdr, NFS4_DEVICEID4_SIZE + 4 + 4); | 
| Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 1931 | p = xdr_encode_opaque_fixed(p, args->pdev->dev_id.data, | 
|  | 1932 | NFS4_DEVICEID4_SIZE); | 
|  | 1933 | *p++ = cpu_to_be32(args->pdev->layout_type); | 
| Andy Adamson | f1c097b | 2013-06-25 19:02:53 -0400 | [diff] [blame] | 1934 | *p++ = cpu_to_be32(args->pdev->maxcount);	/* gdia_maxcount */ | 
| Christoph Hellwig | 84c9dee | 2014-09-10 17:37:28 -0700 | [diff] [blame] | 1935 |  | 
|  | 1936 | p = reserve_space(xdr, 4 + 4); | 
|  | 1937 | *p++ = cpu_to_be32(1);			/* bitmap length */ | 
| Trond Myklebust | 4e59080 | 2015-03-09 14:01:25 -0400 | [diff] [blame] | 1938 | *p++ = cpu_to_be32(args->notify_types); | 
| Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 1939 | } | 
|  | 1940 |  | 
|  | 1941 | static void | 
|  | 1942 | encode_layoutget(struct xdr_stream *xdr, | 
|  | 1943 | const struct nfs4_layoutget_args *args, | 
|  | 1944 | struct compound_hdr *hdr) | 
|  | 1945 | { | 
| Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 1946 | __be32 *p; | 
|  | 1947 |  | 
| Trond Myklebust | 475d4ba | 2012-03-05 11:27:16 -0500 | [diff] [blame] | 1948 | encode_op_hdr(xdr, OP_LAYOUTGET, decode_layoutget_maxsz, hdr); | 
|  | 1949 | p = reserve_space(xdr, 36); | 
| Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 1950 | *p++ = cpu_to_be32(0);     /* Signal layout available */ | 
|  | 1951 | *p++ = cpu_to_be32(args->type); | 
|  | 1952 | *p++ = cpu_to_be32(args->range.iomode); | 
|  | 1953 | p = xdr_encode_hyper(p, args->range.offset); | 
|  | 1954 | p = xdr_encode_hyper(p, args->range.length); | 
|  | 1955 | p = xdr_encode_hyper(p, args->minlength); | 
| Trond Myklebust | ea9d23f | 2012-03-04 18:13:56 -0500 | [diff] [blame] | 1956 | encode_nfs4_stateid(xdr, &args->stateid); | 
| Trond Myklebust | 475d4ba | 2012-03-05 11:27:16 -0500 | [diff] [blame] | 1957 | encode_uint32(xdr, args->maxcount); | 
| Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 1958 |  | 
|  | 1959 | dprintk("%s: 1st type:0x%x iomode:%d off:%lu len:%lu mc:%d\n", | 
|  | 1960 | __func__, | 
|  | 1961 | args->type, | 
|  | 1962 | args->range.iomode, | 
|  | 1963 | (unsigned long)args->range.offset, | 
|  | 1964 | (unsigned long)args->range.length, | 
|  | 1965 | args->maxcount); | 
| Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 1966 | } | 
| Andy Adamson | 863a3c6 | 2011-03-23 13:27:54 +0000 | [diff] [blame] | 1967 |  | 
|  | 1968 | static int | 
|  | 1969 | encode_layoutcommit(struct xdr_stream *xdr, | 
| Benny Halevy | ac7db72 | 2011-05-22 19:53:48 +0300 | [diff] [blame] | 1970 | struct inode *inode, | 
| Christoph Hellwig | 5f919c9 | 2014-08-21 11:09:25 -0500 | [diff] [blame] | 1971 | struct nfs4_layoutcommit_args *args, | 
| Andy Adamson | 863a3c6 | 2011-03-23 13:27:54 +0000 | [diff] [blame] | 1972 | struct compound_hdr *hdr) | 
|  | 1973 | { | 
|  | 1974 | __be32 *p; | 
|  | 1975 |  | 
|  | 1976 | dprintk("%s: lbw: %llu type: %d\n", __func__, args->lastbytewritten, | 
|  | 1977 | NFS_SERVER(args->inode)->pnfs_curr_ld->id); | 
|  | 1978 |  | 
| Trond Myklebust | 475d4ba | 2012-03-05 11:27:16 -0500 | [diff] [blame] | 1979 | encode_op_hdr(xdr, OP_LAYOUTCOMMIT, decode_layoutcommit_maxsz, hdr); | 
|  | 1980 | p = reserve_space(xdr, 20); | 
| Andy Adamson | 863a3c6 | 2011-03-23 13:27:54 +0000 | [diff] [blame] | 1981 | /* Only whole file layouts */ | 
|  | 1982 | p = xdr_encode_hyper(p, 0); /* offset */ | 
| Peng Tao | 3557c6c | 2011-07-30 20:52:34 -0400 | [diff] [blame] | 1983 | p = xdr_encode_hyper(p, args->lastbytewritten + 1);	/* length */ | 
| Trond Myklebust | ea9d23f | 2012-03-04 18:13:56 -0500 | [diff] [blame] | 1984 | *p = cpu_to_be32(0); /* reclaim */ | 
|  | 1985 | encode_nfs4_stateid(xdr, &args->stateid); | 
| Trond Myklebust | 2e18d4d | 2016-06-26 18:54:58 -0400 | [diff] [blame] | 1986 | if (args->lastbytewritten != U64_MAX) { | 
|  | 1987 | p = reserve_space(xdr, 20); | 
|  | 1988 | *p++ = cpu_to_be32(1); /* newoffset = TRUE */ | 
|  | 1989 | p = xdr_encode_hyper(p, args->lastbytewritten); | 
|  | 1990 | } else { | 
|  | 1991 | p = reserve_space(xdr, 12); | 
|  | 1992 | *p++ = cpu_to_be32(0); /* newoffset = FALSE */ | 
|  | 1993 | } | 
| Andy Adamson | 863a3c6 | 2011-03-23 13:27:54 +0000 | [diff] [blame] | 1994 | *p++ = cpu_to_be32(0); /* Never send time_modify_changed */ | 
|  | 1995 | *p++ = cpu_to_be32(NFS_SERVER(args->inode)->pnfs_curr_ld->id);/* type */ | 
| Benny Halevy | ac7db72 | 2011-05-22 19:53:48 +0300 | [diff] [blame] | 1996 |  | 
| Christoph Hellwig | 5f919c9 | 2014-08-21 11:09:25 -0500 | [diff] [blame] | 1997 | if (NFS_SERVER(inode)->pnfs_curr_ld->encode_layoutcommit) { | 
| Benny Halevy | ac7db72 | 2011-05-22 19:53:48 +0300 | [diff] [blame] | 1998 | NFS_SERVER(inode)->pnfs_curr_ld->encode_layoutcommit( | 
|  | 1999 | NFS_I(inode)->layout, xdr, args); | 
| Christoph Hellwig | 5f919c9 | 2014-08-21 11:09:25 -0500 | [diff] [blame] | 2000 | } else { | 
|  | 2001 | encode_uint32(xdr, args->layoutupdate_len); | 
|  | 2002 | if (args->layoutupdate_pages) { | 
|  | 2003 | xdr_write_pages(xdr, args->layoutupdate_pages, 0, | 
|  | 2004 | args->layoutupdate_len); | 
|  | 2005 | } | 
|  | 2006 | } | 
| Andy Adamson | 863a3c6 | 2011-03-23 13:27:54 +0000 | [diff] [blame] | 2007 |  | 
| Andy Adamson | 863a3c6 | 2011-03-23 13:27:54 +0000 | [diff] [blame] | 2008 | return 0; | 
|  | 2009 | } | 
| Benny Halevy | cbe8260 | 2011-05-22 19:52:37 +0300 | [diff] [blame] | 2010 |  | 
|  | 2011 | static void | 
|  | 2012 | encode_layoutreturn(struct xdr_stream *xdr, | 
|  | 2013 | const struct nfs4_layoutreturn_args *args, | 
|  | 2014 | struct compound_hdr *hdr) | 
|  | 2015 | { | 
|  | 2016 | __be32 *p; | 
|  | 2017 |  | 
| Trond Myklebust | 475d4ba | 2012-03-05 11:27:16 -0500 | [diff] [blame] | 2018 | encode_op_hdr(xdr, OP_LAYOUTRETURN, decode_layoutreturn_maxsz, hdr); | 
|  | 2019 | p = reserve_space(xdr, 16); | 
| Benny Halevy | cbe8260 | 2011-05-22 19:52:37 +0300 | [diff] [blame] | 2020 | *p++ = cpu_to_be32(0);		/* reclaim. always 0 for now */ | 
|  | 2021 | *p++ = cpu_to_be32(args->layout_type); | 
| Peng Tao | 15eb67c | 2014-11-17 09:30:36 +0800 | [diff] [blame] | 2022 | *p++ = cpu_to_be32(args->range.iomode); | 
| Benny Halevy | cbe8260 | 2011-05-22 19:52:37 +0300 | [diff] [blame] | 2023 | *p = cpu_to_be32(RETURN_FILE); | 
| Trond Myklebust | ea9d23f | 2012-03-04 18:13:56 -0500 | [diff] [blame] | 2024 | p = reserve_space(xdr, 16); | 
| Peng Tao | 15eb67c | 2014-11-17 09:30:36 +0800 | [diff] [blame] | 2025 | p = xdr_encode_hyper(p, args->range.offset); | 
|  | 2026 | p = xdr_encode_hyper(p, args->range.length); | 
| Benny Halevy | cbe8260 | 2011-05-22 19:52:37 +0300 | [diff] [blame] | 2027 | spin_lock(&args->inode->i_lock); | 
| Trond Myklebust | ea9d23f | 2012-03-04 18:13:56 -0500 | [diff] [blame] | 2028 | encode_nfs4_stateid(xdr, &args->stateid); | 
| Benny Halevy | cbe8260 | 2011-05-22 19:52:37 +0300 | [diff] [blame] | 2029 | spin_unlock(&args->inode->i_lock); | 
| Andy Adamson | 04a5554 | 2011-05-22 19:53:10 +0300 | [diff] [blame] | 2030 | if (NFS_SERVER(args->inode)->pnfs_curr_ld->encode_layoutreturn) { | 
|  | 2031 | NFS_SERVER(args->inode)->pnfs_curr_ld->encode_layoutreturn( | 
|  | 2032 | NFS_I(args->inode)->layout, xdr, args); | 
| Trond Myklebust | 475d4ba | 2012-03-05 11:27:16 -0500 | [diff] [blame] | 2033 | } else | 
|  | 2034 | encode_uint32(xdr, 0); | 
| Benny Halevy | cbe8260 | 2011-05-22 19:52:37 +0300 | [diff] [blame] | 2035 | } | 
| Bryan Schumaker | fca78d6 | 2011-06-02 14:59:07 -0400 | [diff] [blame] | 2036 |  | 
|  | 2037 | static int | 
|  | 2038 | encode_secinfo_no_name(struct xdr_stream *xdr, | 
|  | 2039 | const struct nfs41_secinfo_no_name_args *args, | 
|  | 2040 | struct compound_hdr *hdr) | 
|  | 2041 | { | 
| Trond Myklebust | 475d4ba | 2012-03-05 11:27:16 -0500 | [diff] [blame] | 2042 | encode_op_hdr(xdr, OP_SECINFO_NO_NAME, decode_secinfo_no_name_maxsz, hdr); | 
|  | 2043 | encode_uint32(xdr, args->style); | 
| Bryan Schumaker | fca78d6 | 2011-06-02 14:59:07 -0400 | [diff] [blame] | 2044 | return 0; | 
|  | 2045 | } | 
| Bryan Schumaker | 7d97479 | 2011-06-02 14:59:08 -0400 | [diff] [blame] | 2046 |  | 
|  | 2047 | static void encode_test_stateid(struct xdr_stream *xdr, | 
|  | 2048 | struct nfs41_test_stateid_args *args, | 
|  | 2049 | struct compound_hdr *hdr) | 
|  | 2050 | { | 
| Trond Myklebust | 475d4ba | 2012-03-05 11:27:16 -0500 | [diff] [blame] | 2051 | encode_op_hdr(xdr, OP_TEST_STATEID, decode_test_stateid_maxsz, hdr); | 
|  | 2052 | encode_uint32(xdr, 1); | 
| Trond Myklebust | ea9d23f | 2012-03-04 18:13:56 -0500 | [diff] [blame] | 2053 | encode_nfs4_stateid(xdr, args->stateid); | 
| Bryan Schumaker | 7d97479 | 2011-06-02 14:59:08 -0400 | [diff] [blame] | 2054 | } | 
| Bryan Schumaker | 9aeda35 | 2011-06-02 14:59:09 -0400 | [diff] [blame] | 2055 |  | 
|  | 2056 | static void encode_free_stateid(struct xdr_stream *xdr, | 
|  | 2057 | struct nfs41_free_stateid_args *args, | 
|  | 2058 | struct compound_hdr *hdr) | 
|  | 2059 | { | 
| Trond Myklebust | ab19b48 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 2060 | encode_op_hdr(xdr, OP_FREE_STATEID, decode_free_stateid_maxsz, hdr); | 
| Trond Myklebust | 7c1d5fa | 2013-05-03 14:40:01 -0400 | [diff] [blame] | 2061 | encode_nfs4_stateid(xdr, &args->stateid); | 
| Bryan Schumaker | 9aeda35 | 2011-06-02 14:59:09 -0400 | [diff] [blame] | 2062 | } | 
| Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 2063 | #endif /* CONFIG_NFS_V4_1 */ | 
|  | 2064 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2065 | /* | 
|  | 2066 | * END OF "GENERIC" ENCODE ROUTINES. | 
|  | 2067 | */ | 
|  | 2068 |  | 
| Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2069 | static u32 nfs4_xdr_minorversion(const struct nfs4_sequence_args *args) | 
|  | 2070 | { | 
|  | 2071 | #if defined(CONFIG_NFS_V4_1) | 
| Chuck Lever | 3bd2384 | 2013-08-09 12:49:19 -0400 | [diff] [blame] | 2072 | struct nfs4_session *session = args->sa_slot->table->session; | 
|  | 2073 | if (session) | 
|  | 2074 | return session->clp->cl_mvops->minor_version; | 
| Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2075 | #endif /* CONFIG_NFS_V4_1 */ | 
|  | 2076 | return 0; | 
|  | 2077 | } | 
|  | 2078 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2079 | /* | 
|  | 2080 | * Encode an ACCESS request | 
|  | 2081 | */ | 
| Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2082 | static void nfs4_xdr_enc_access(struct rpc_rqst *req, struct xdr_stream *xdr, | 
|  | 2083 | const struct nfs4_accessargs *args) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2084 | { | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2085 | struct compound_hdr hdr = { | 
| Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2086 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2087 | }; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2088 |  | 
| Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2089 | encode_compound_hdr(xdr, req, &hdr); | 
|  | 2090 | encode_sequence(xdr, &args->seq_args, &hdr); | 
|  | 2091 | encode_putfh(xdr, args->fh, &hdr); | 
|  | 2092 | encode_access(xdr, args->access, &hdr); | 
|  | 2093 | encode_getfattr(xdr, args->bitmask, &hdr); | 
| Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2094 | encode_nops(&hdr); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2095 | } | 
|  | 2096 |  | 
|  | 2097 | /* | 
|  | 2098 | * Encode LOOKUP request | 
|  | 2099 | */ | 
| Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2100 | static void nfs4_xdr_enc_lookup(struct rpc_rqst *req, struct xdr_stream *xdr, | 
|  | 2101 | const struct nfs4_lookup_arg *args) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2102 | { | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2103 | struct compound_hdr hdr = { | 
| Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2104 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2105 | }; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2106 |  | 
| Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2107 | encode_compound_hdr(xdr, req, &hdr); | 
|  | 2108 | encode_sequence(xdr, &args->seq_args, &hdr); | 
|  | 2109 | encode_putfh(xdr, args->dir_fh, &hdr); | 
|  | 2110 | encode_lookup(xdr, args->name, &hdr); | 
|  | 2111 | encode_getfh(xdr, &hdr); | 
|  | 2112 | encode_getfattr(xdr, args->bitmask, &hdr); | 
| Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2113 | encode_nops(&hdr); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2114 | } | 
|  | 2115 |  | 
|  | 2116 | /* | 
|  | 2117 | * Encode LOOKUP_ROOT request | 
|  | 2118 | */ | 
| Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2119 | static void nfs4_xdr_enc_lookup_root(struct rpc_rqst *req, | 
|  | 2120 | struct xdr_stream *xdr, | 
|  | 2121 | const struct nfs4_lookup_root_arg *args) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2122 | { | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2123 | struct compound_hdr hdr = { | 
| Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2124 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2125 | }; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2126 |  | 
| Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2127 | encode_compound_hdr(xdr, req, &hdr); | 
|  | 2128 | encode_sequence(xdr, &args->seq_args, &hdr); | 
|  | 2129 | encode_putrootfh(xdr, &hdr); | 
|  | 2130 | encode_getfh(xdr, &hdr); | 
|  | 2131 | encode_getfattr(xdr, args->bitmask, &hdr); | 
| Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2132 | encode_nops(&hdr); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2133 | } | 
|  | 2134 |  | 
|  | 2135 | /* | 
|  | 2136 | * Encode REMOVE request | 
|  | 2137 | */ | 
| Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2138 | static void nfs4_xdr_enc_remove(struct rpc_rqst *req, struct xdr_stream *xdr, | 
|  | 2139 | const struct nfs_removeargs *args) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2140 | { | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2141 | struct compound_hdr hdr = { | 
| Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2142 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2143 | }; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2144 |  | 
| Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2145 | encode_compound_hdr(xdr, req, &hdr); | 
|  | 2146 | encode_sequence(xdr, &args->seq_args, &hdr); | 
|  | 2147 | encode_putfh(xdr, args->fh, &hdr); | 
|  | 2148 | encode_remove(xdr, &args->name, &hdr); | 
| Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2149 | encode_nops(&hdr); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2150 | } | 
|  | 2151 |  | 
|  | 2152 | /* | 
|  | 2153 | * Encode RENAME request | 
|  | 2154 | */ | 
| Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2155 | static void nfs4_xdr_enc_rename(struct rpc_rqst *req, struct xdr_stream *xdr, | 
|  | 2156 | const struct nfs_renameargs *args) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2157 | { | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2158 | struct compound_hdr hdr = { | 
| Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2159 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2160 | }; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2161 |  | 
| Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2162 | encode_compound_hdr(xdr, req, &hdr); | 
|  | 2163 | encode_sequence(xdr, &args->seq_args, &hdr); | 
|  | 2164 | encode_putfh(xdr, args->old_dir, &hdr); | 
|  | 2165 | encode_savefh(xdr, &hdr); | 
|  | 2166 | encode_putfh(xdr, args->new_dir, &hdr); | 
|  | 2167 | encode_rename(xdr, args->old_name, args->new_name, &hdr); | 
| Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2168 | encode_nops(&hdr); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2169 | } | 
|  | 2170 |  | 
|  | 2171 | /* | 
|  | 2172 | * Encode LINK request | 
|  | 2173 | */ | 
| Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2174 | static void nfs4_xdr_enc_link(struct rpc_rqst *req, struct xdr_stream *xdr, | 
|  | 2175 | const struct nfs4_link_arg *args) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2176 | { | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2177 | struct compound_hdr hdr = { | 
| Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2178 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2179 | }; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2180 |  | 
| Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2181 | encode_compound_hdr(xdr, req, &hdr); | 
|  | 2182 | encode_sequence(xdr, &args->seq_args, &hdr); | 
|  | 2183 | encode_putfh(xdr, args->fh, &hdr); | 
|  | 2184 | encode_savefh(xdr, &hdr); | 
|  | 2185 | encode_putfh(xdr, args->dir_fh, &hdr); | 
|  | 2186 | encode_link(xdr, args->name, &hdr); | 
| Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2187 | encode_restorefh(xdr, &hdr); | 
|  | 2188 | encode_getfattr(xdr, args->bitmask, &hdr); | 
| Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2189 | encode_nops(&hdr); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2190 | } | 
|  | 2191 |  | 
|  | 2192 | /* | 
|  | 2193 | * Encode CREATE request | 
|  | 2194 | */ | 
| Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2195 | static void nfs4_xdr_enc_create(struct rpc_rqst *req, struct xdr_stream *xdr, | 
|  | 2196 | const struct nfs4_create_arg *args) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2197 | { | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2198 | struct compound_hdr hdr = { | 
| Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2199 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2200 | }; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2201 |  | 
| Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2202 | encode_compound_hdr(xdr, req, &hdr); | 
|  | 2203 | encode_sequence(xdr, &args->seq_args, &hdr); | 
|  | 2204 | encode_putfh(xdr, args->dir_fh, &hdr); | 
| Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2205 | encode_create(xdr, args, &hdr); | 
|  | 2206 | encode_getfh(xdr, &hdr); | 
|  | 2207 | encode_getfattr(xdr, args->bitmask, &hdr); | 
| Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2208 | encode_nops(&hdr); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2209 | } | 
|  | 2210 |  | 
|  | 2211 | /* | 
|  | 2212 | * Encode SYMLINK request | 
|  | 2213 | */ | 
| Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2214 | static void nfs4_xdr_enc_symlink(struct rpc_rqst *req, struct xdr_stream *xdr, | 
|  | 2215 | const struct nfs4_create_arg *args) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2216 | { | 
| Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2217 | nfs4_xdr_enc_create(req, xdr, args); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2218 | } | 
|  | 2219 |  | 
|  | 2220 | /* | 
|  | 2221 | * Encode GETATTR request | 
|  | 2222 | */ | 
| Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2223 | static void nfs4_xdr_enc_getattr(struct rpc_rqst *req, struct xdr_stream *xdr, | 
|  | 2224 | const struct nfs4_getattr_arg *args) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2225 | { | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2226 | struct compound_hdr hdr = { | 
| Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2227 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2228 | }; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2229 |  | 
| Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2230 | encode_compound_hdr(xdr, req, &hdr); | 
|  | 2231 | encode_sequence(xdr, &args->seq_args, &hdr); | 
|  | 2232 | encode_putfh(xdr, args->fh, &hdr); | 
|  | 2233 | encode_getfattr(xdr, args->bitmask, &hdr); | 
| Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2234 | encode_nops(&hdr); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2235 | } | 
|  | 2236 |  | 
|  | 2237 | /* | 
|  | 2238 | * Encode a CLOSE request | 
|  | 2239 | */ | 
| Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2240 | static void nfs4_xdr_enc_close(struct rpc_rqst *req, struct xdr_stream *xdr, | 
|  | 2241 | struct nfs_closeargs *args) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2242 | { | 
| Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 2243 | struct compound_hdr hdr = { | 
| Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2244 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), | 
| Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 2245 | }; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2246 |  | 
| Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2247 | encode_compound_hdr(xdr, req, &hdr); | 
|  | 2248 | encode_sequence(xdr, &args->seq_args, &hdr); | 
|  | 2249 | encode_putfh(xdr, args->fh, &hdr); | 
|  | 2250 | encode_close(xdr, args, &hdr); | 
|  | 2251 | encode_getfattr(xdr, args->bitmask, &hdr); | 
| Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2252 | encode_nops(&hdr); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2253 | } | 
|  | 2254 |  | 
|  | 2255 | /* | 
|  | 2256 | * Encode an OPEN request | 
|  | 2257 | */ | 
| Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2258 | static void nfs4_xdr_enc_open(struct rpc_rqst *req, struct xdr_stream *xdr, | 
|  | 2259 | struct nfs_openargs *args) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2260 | { | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2261 | struct compound_hdr hdr = { | 
| Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2262 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2263 | }; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2264 |  | 
| Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2265 | encode_compound_hdr(xdr, req, &hdr); | 
|  | 2266 | encode_sequence(xdr, &args->seq_args, &hdr); | 
|  | 2267 | encode_putfh(xdr, args->fh, &hdr); | 
| Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2268 | encode_open(xdr, args, &hdr); | 
|  | 2269 | encode_getfh(xdr, &hdr); | 
| Weston Andros Adamson | ae2bb03 | 2012-10-02 14:49:52 -0700 | [diff] [blame] | 2270 | if (args->access) | 
|  | 2271 | encode_access(xdr, args->access, &hdr); | 
| Trond Myklebust | 1549210f | 2012-06-05 09:16:47 -0400 | [diff] [blame] | 2272 | encode_getfattr_open(xdr, args->bitmask, args->open_bitmap, &hdr); | 
| Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2273 | encode_nops(&hdr); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2274 | } | 
|  | 2275 |  | 
|  | 2276 | /* | 
|  | 2277 | * Encode an OPEN_CONFIRM request | 
|  | 2278 | */ | 
| Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2279 | static void nfs4_xdr_enc_open_confirm(struct rpc_rqst *req, | 
|  | 2280 | struct xdr_stream *xdr, | 
|  | 2281 | struct nfs_open_confirmargs *args) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2282 | { | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2283 | struct compound_hdr hdr = { | 
| Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2284 | .nops   = 0, | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2285 | }; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2286 |  | 
| Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2287 | encode_compound_hdr(xdr, req, &hdr); | 
|  | 2288 | encode_putfh(xdr, args->fh, &hdr); | 
|  | 2289 | encode_open_confirm(xdr, args, &hdr); | 
| Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2290 | encode_nops(&hdr); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2291 | } | 
|  | 2292 |  | 
|  | 2293 | /* | 
|  | 2294 | * Encode an OPEN request with no attributes. | 
|  | 2295 | */ | 
| Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2296 | static void nfs4_xdr_enc_open_noattr(struct rpc_rqst *req, | 
|  | 2297 | struct xdr_stream *xdr, | 
|  | 2298 | struct nfs_openargs *args) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2299 | { | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2300 | struct compound_hdr hdr = { | 
| Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2301 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2302 | }; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2303 |  | 
| Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2304 | encode_compound_hdr(xdr, req, &hdr); | 
|  | 2305 | encode_sequence(xdr, &args->seq_args, &hdr); | 
|  | 2306 | encode_putfh(xdr, args->fh, &hdr); | 
|  | 2307 | encode_open(xdr, args, &hdr); | 
| Weston Andros Adamson | ae2bb03 | 2012-10-02 14:49:52 -0700 | [diff] [blame] | 2308 | if (args->access) | 
|  | 2309 | encode_access(xdr, args->access, &hdr); | 
| Andy Adamson | e23008e | 2012-10-02 21:07:32 -0400 | [diff] [blame] | 2310 | encode_getfattr_open(xdr, args->bitmask, args->open_bitmap, &hdr); | 
| Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2311 | encode_nops(&hdr); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2312 | } | 
|  | 2313 |  | 
|  | 2314 | /* | 
|  | 2315 | * Encode an OPEN_DOWNGRADE request | 
|  | 2316 | */ | 
| Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2317 | static void nfs4_xdr_enc_open_downgrade(struct rpc_rqst *req, | 
|  | 2318 | struct xdr_stream *xdr, | 
|  | 2319 | struct nfs_closeargs *args) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2320 | { | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2321 | struct compound_hdr hdr = { | 
| Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2322 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2323 | }; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2324 |  | 
| Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2325 | encode_compound_hdr(xdr, req, &hdr); | 
|  | 2326 | encode_sequence(xdr, &args->seq_args, &hdr); | 
|  | 2327 | encode_putfh(xdr, args->fh, &hdr); | 
|  | 2328 | encode_open_downgrade(xdr, args, &hdr); | 
| Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2329 | encode_nops(&hdr); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2330 | } | 
|  | 2331 |  | 
|  | 2332 | /* | 
|  | 2333 | * Encode a LOCK request | 
|  | 2334 | */ | 
| Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2335 | static void nfs4_xdr_enc_lock(struct rpc_rqst *req, struct xdr_stream *xdr, | 
|  | 2336 | struct nfs_lock_args *args) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2337 | { | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2338 | struct compound_hdr hdr = { | 
| Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2339 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2340 | }; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2341 |  | 
| Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2342 | encode_compound_hdr(xdr, req, &hdr); | 
|  | 2343 | encode_sequence(xdr, &args->seq_args, &hdr); | 
|  | 2344 | encode_putfh(xdr, args->fh, &hdr); | 
|  | 2345 | encode_lock(xdr, args, &hdr); | 
| Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2346 | encode_nops(&hdr); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2347 | } | 
|  | 2348 |  | 
|  | 2349 | /* | 
|  | 2350 | * Encode a LOCKT request | 
|  | 2351 | */ | 
| Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2352 | static void nfs4_xdr_enc_lockt(struct rpc_rqst *req, struct xdr_stream *xdr, | 
|  | 2353 | struct nfs_lockt_args *args) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2354 | { | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2355 | struct compound_hdr hdr = { | 
| Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2356 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2357 | }; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2358 |  | 
| Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2359 | encode_compound_hdr(xdr, req, &hdr); | 
|  | 2360 | encode_sequence(xdr, &args->seq_args, &hdr); | 
|  | 2361 | encode_putfh(xdr, args->fh, &hdr); | 
|  | 2362 | encode_lockt(xdr, args, &hdr); | 
| Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2363 | encode_nops(&hdr); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2364 | } | 
|  | 2365 |  | 
|  | 2366 | /* | 
|  | 2367 | * Encode a LOCKU request | 
|  | 2368 | */ | 
| Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2369 | static void nfs4_xdr_enc_locku(struct rpc_rqst *req, struct xdr_stream *xdr, | 
|  | 2370 | struct nfs_locku_args *args) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2371 | { | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2372 | struct compound_hdr hdr = { | 
| Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2373 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2374 | }; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2375 |  | 
| Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2376 | encode_compound_hdr(xdr, req, &hdr); | 
|  | 2377 | encode_sequence(xdr, &args->seq_args, &hdr); | 
|  | 2378 | encode_putfh(xdr, args->fh, &hdr); | 
|  | 2379 | encode_locku(xdr, args, &hdr); | 
| Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2380 | encode_nops(&hdr); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2381 | } | 
|  | 2382 |  | 
| Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2383 | static void nfs4_xdr_enc_release_lockowner(struct rpc_rqst *req, | 
|  | 2384 | struct xdr_stream *xdr, | 
|  | 2385 | struct nfs_release_lockowner_args *args) | 
| Trond Myklebust | d3c7b7c | 2010-07-01 12:49:01 -0400 | [diff] [blame] | 2386 | { | 
| Trond Myklebust | d3c7b7c | 2010-07-01 12:49:01 -0400 | [diff] [blame] | 2387 | struct compound_hdr hdr = { | 
|  | 2388 | .minorversion = 0, | 
|  | 2389 | }; | 
|  | 2390 |  | 
| Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2391 | encode_compound_hdr(xdr, req, &hdr); | 
|  | 2392 | encode_release_lockowner(xdr, &args->lock_owner, &hdr); | 
| Trond Myklebust | d3c7b7c | 2010-07-01 12:49:01 -0400 | [diff] [blame] | 2393 | encode_nops(&hdr); | 
| Trond Myklebust | d3c7b7c | 2010-07-01 12:49:01 -0400 | [diff] [blame] | 2394 | } | 
|  | 2395 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2396 | /* | 
|  | 2397 | * Encode a READLINK request | 
|  | 2398 | */ | 
| Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2399 | static void nfs4_xdr_enc_readlink(struct rpc_rqst *req, struct xdr_stream *xdr, | 
|  | 2400 | const struct nfs4_readlink *args) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2401 | { | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2402 | struct compound_hdr hdr = { | 
| Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2403 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2404 | }; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2405 |  | 
| Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2406 | encode_compound_hdr(xdr, req, &hdr); | 
|  | 2407 | encode_sequence(xdr, &args->seq_args, &hdr); | 
|  | 2408 | encode_putfh(xdr, args->fh, &hdr); | 
|  | 2409 | encode_readlink(xdr, args, req, &hdr); | 
| Trond Myklebust | e3a535e | 2007-07-19 10:03:38 -0400 | [diff] [blame] | 2410 |  | 
| Benny Halevy | 28f5669 | 2009-04-01 09:22:09 -0400 | [diff] [blame] | 2411 | xdr_inline_pages(&req->rq_rcv_buf, hdr.replen << 2, args->pages, | 
| Trond Myklebust | e3a535e | 2007-07-19 10:03:38 -0400 | [diff] [blame] | 2412 | args->pgbase, args->pglen); | 
| Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2413 | encode_nops(&hdr); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2414 | } | 
|  | 2415 |  | 
|  | 2416 | /* | 
|  | 2417 | * Encode a READDIR request | 
|  | 2418 | */ | 
| Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2419 | static void nfs4_xdr_enc_readdir(struct rpc_rqst *req, struct xdr_stream *xdr, | 
|  | 2420 | const struct nfs4_readdir_arg *args) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2421 | { | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2422 | struct compound_hdr hdr = { | 
| Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2423 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2424 | }; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2425 |  | 
| Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2426 | encode_compound_hdr(xdr, req, &hdr); | 
|  | 2427 | encode_sequence(xdr, &args->seq_args, &hdr); | 
|  | 2428 | encode_putfh(xdr, args->fh, &hdr); | 
|  | 2429 | encode_readdir(xdr, args, req, &hdr); | 
| Trond Myklebust | d6ac02d | 2007-07-19 10:03:37 -0400 | [diff] [blame] | 2430 |  | 
| Benny Halevy | 28f5669 | 2009-04-01 09:22:09 -0400 | [diff] [blame] | 2431 | xdr_inline_pages(&req->rq_rcv_buf, hdr.replen << 2, args->pages, | 
| Trond Myklebust | d6ac02d | 2007-07-19 10:03:37 -0400 | [diff] [blame] | 2432 | args->pgbase, args->count); | 
|  | 2433 | dprintk("%s: inlined page args = (%u, %p, %u, %u)\n", | 
| Benny Halevy | 28f5669 | 2009-04-01 09:22:09 -0400 | [diff] [blame] | 2434 | __func__, hdr.replen << 2, args->pages, | 
| Trond Myklebust | d6ac02d | 2007-07-19 10:03:37 -0400 | [diff] [blame] | 2435 | args->pgbase, args->count); | 
| Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2436 | encode_nops(&hdr); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2437 | } | 
|  | 2438 |  | 
|  | 2439 | /* | 
|  | 2440 | * Encode a READ request | 
|  | 2441 | */ | 
| Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2442 | static void nfs4_xdr_enc_read(struct rpc_rqst *req, struct xdr_stream *xdr, | 
| Anna Schumaker | 3c6b899 | 2014-05-06 09:12:24 -0400 | [diff] [blame] | 2443 | struct nfs_pgio_args *args) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2444 | { | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2445 | struct compound_hdr hdr = { | 
| Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2446 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2447 | }; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2448 |  | 
| Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2449 | encode_compound_hdr(xdr, req, &hdr); | 
|  | 2450 | encode_sequence(xdr, &args->seq_args, &hdr); | 
|  | 2451 | encode_putfh(xdr, args->fh, &hdr); | 
|  | 2452 | encode_read(xdr, args, &hdr); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2453 |  | 
| Benny Halevy | 28f5669 | 2009-04-01 09:22:09 -0400 | [diff] [blame] | 2454 | xdr_inline_pages(&req->rq_rcv_buf, hdr.replen << 2, | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2455 | args->pages, args->pgbase, args->count); | 
| \"Talpey, Thomas\ | 4f22ccc | 2007-09-10 13:44:58 -0400 | [diff] [blame] | 2456 | req->rq_rcv_buf.flags |= XDRBUF_READ; | 
| Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2457 | encode_nops(&hdr); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2458 | } | 
|  | 2459 |  | 
|  | 2460 | /* | 
|  | 2461 | * Encode an SETATTR request | 
|  | 2462 | */ | 
| Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2463 | static void nfs4_xdr_enc_setattr(struct rpc_rqst *req, struct xdr_stream *xdr, | 
|  | 2464 | struct nfs_setattrargs *args) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2465 | { | 
| Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 2466 | struct compound_hdr hdr = { | 
| Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2467 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), | 
| Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 2468 | }; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2469 |  | 
| Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2470 | encode_compound_hdr(xdr, req, &hdr); | 
|  | 2471 | encode_sequence(xdr, &args->seq_args, &hdr); | 
|  | 2472 | encode_putfh(xdr, args->fh, &hdr); | 
|  | 2473 | encode_setattr(xdr, args, args->server, &hdr); | 
|  | 2474 | encode_getfattr(xdr, args->bitmask, &hdr); | 
| Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2475 | encode_nops(&hdr); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2476 | } | 
|  | 2477 |  | 
|  | 2478 | /* | 
| J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 2479 | * Encode a GETACL request | 
|  | 2480 | */ | 
| Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2481 | static void nfs4_xdr_enc_getacl(struct rpc_rqst *req, struct xdr_stream *xdr, | 
|  | 2482 | struct nfs_getaclargs *args) | 
| J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 2483 | { | 
| J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 2484 | struct compound_hdr hdr = { | 
| Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2485 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), | 
| J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 2486 | }; | 
| Benny Halevy | 28f5669 | 2009-04-01 09:22:09 -0400 | [diff] [blame] | 2487 | uint32_t replen; | 
| J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 2488 |  | 
| Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2489 | encode_compound_hdr(xdr, req, &hdr); | 
|  | 2490 | encode_sequence(xdr, &args->seq_args, &hdr); | 
|  | 2491 | encode_putfh(xdr, args->fh, &hdr); | 
| Andy Adamson | bf118a3 | 2011-12-07 11:55:27 -0500 | [diff] [blame] | 2492 | replen = hdr.replen + op_decode_hdr_maxsz + 1; | 
| Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2493 | encode_getattr_two(xdr, FATTR4_WORD0_ACL, 0, &hdr); | 
| Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 2494 |  | 
| Benny Halevy | 28f5669 | 2009-04-01 09:22:09 -0400 | [diff] [blame] | 2495 | xdr_inline_pages(&req->rq_rcv_buf, replen << 2, | 
| Andreas Gruenbacher | 8fbcf23 | 2015-11-03 18:25:34 +0100 | [diff] [blame] | 2496 | args->acl_pages, 0, args->acl_len); | 
| Andy Adamson | bf118a3 | 2011-12-07 11:55:27 -0500 | [diff] [blame] | 2497 |  | 
| Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2498 | encode_nops(&hdr); | 
| J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 2499 | } | 
|  | 2500 |  | 
|  | 2501 | /* | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2502 | * Encode a WRITE request | 
|  | 2503 | */ | 
| Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2504 | static void nfs4_xdr_enc_write(struct rpc_rqst *req, struct xdr_stream *xdr, | 
| Anna Schumaker | 3c6b899 | 2014-05-06 09:12:24 -0400 | [diff] [blame] | 2505 | struct nfs_pgio_args *args) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2506 | { | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2507 | struct compound_hdr hdr = { | 
| Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2508 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2509 | }; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2510 |  | 
| Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2511 | encode_compound_hdr(xdr, req, &hdr); | 
|  | 2512 | encode_sequence(xdr, &args->seq_args, &hdr); | 
|  | 2513 | encode_putfh(xdr, args->fh, &hdr); | 
|  | 2514 | encode_write(xdr, args, &hdr); | 
| \"Talpey, Thomas\ | 4f22ccc | 2007-09-10 13:44:58 -0400 | [diff] [blame] | 2515 | req->rq_snd_buf.flags |= XDRBUF_WRITE; | 
| Fred Isaman | 7ffd106 | 2011-03-03 15:13:46 +0000 | [diff] [blame] | 2516 | if (args->bitmask) | 
|  | 2517 | encode_getfattr(xdr, args->bitmask, &hdr); | 
| Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2518 | encode_nops(&hdr); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2519 | } | 
|  | 2520 |  | 
|  | 2521 | /* | 
|  | 2522 | *  a COMMIT request | 
|  | 2523 | */ | 
| Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2524 | static void nfs4_xdr_enc_commit(struct rpc_rqst *req, struct xdr_stream *xdr, | 
| Fred Isaman | 0b7c015 | 2012-04-20 14:47:39 -0400 | [diff] [blame] | 2525 | struct nfs_commitargs *args) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2526 | { | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2527 | struct compound_hdr hdr = { | 
| Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2528 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2529 | }; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2530 |  | 
| Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2531 | encode_compound_hdr(xdr, req, &hdr); | 
|  | 2532 | encode_sequence(xdr, &args->seq_args, &hdr); | 
|  | 2533 | encode_putfh(xdr, args->fh, &hdr); | 
|  | 2534 | encode_commit(xdr, args, &hdr); | 
| Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2535 | encode_nops(&hdr); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2536 | } | 
|  | 2537 |  | 
|  | 2538 | /* | 
|  | 2539 | * FSINFO request | 
|  | 2540 | */ | 
| Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2541 | static void nfs4_xdr_enc_fsinfo(struct rpc_rqst *req, struct xdr_stream *xdr, | 
|  | 2542 | struct nfs4_fsinfo_arg *args) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2543 | { | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2544 | struct compound_hdr hdr = { | 
| Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2545 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2546 | }; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2547 |  | 
| Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2548 | encode_compound_hdr(xdr, req, &hdr); | 
|  | 2549 | encode_sequence(xdr, &args->seq_args, &hdr); | 
|  | 2550 | encode_putfh(xdr, args->fh, &hdr); | 
|  | 2551 | encode_fsinfo(xdr, args->bitmask, &hdr); | 
| Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2552 | encode_nops(&hdr); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2553 | } | 
|  | 2554 |  | 
|  | 2555 | /* | 
|  | 2556 | * a PATHCONF request | 
|  | 2557 | */ | 
| Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2558 | static void nfs4_xdr_enc_pathconf(struct rpc_rqst *req, struct xdr_stream *xdr, | 
|  | 2559 | const struct nfs4_pathconf_arg *args) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2560 | { | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2561 | struct compound_hdr hdr = { | 
| Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2562 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2563 | }; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2564 |  | 
| Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2565 | encode_compound_hdr(xdr, req, &hdr); | 
|  | 2566 | encode_sequence(xdr, &args->seq_args, &hdr); | 
|  | 2567 | encode_putfh(xdr, args->fh, &hdr); | 
|  | 2568 | encode_getattr_one(xdr, args->bitmask[0] & nfs4_pathconf_bitmap[0], | 
| Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 2569 | &hdr); | 
| Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2570 | encode_nops(&hdr); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2571 | } | 
|  | 2572 |  | 
|  | 2573 | /* | 
|  | 2574 | * a STATFS request | 
|  | 2575 | */ | 
| Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2576 | static void nfs4_xdr_enc_statfs(struct rpc_rqst *req, struct xdr_stream *xdr, | 
|  | 2577 | const struct nfs4_statfs_arg *args) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2578 | { | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2579 | struct compound_hdr hdr = { | 
| Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2580 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2581 | }; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2582 |  | 
| Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2583 | encode_compound_hdr(xdr, req, &hdr); | 
|  | 2584 | encode_sequence(xdr, &args->seq_args, &hdr); | 
|  | 2585 | encode_putfh(xdr, args->fh, &hdr); | 
|  | 2586 | encode_getattr_two(xdr, args->bitmask[0] & nfs4_statfs_bitmap[0], | 
| Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 2587 | args->bitmask[1] & nfs4_statfs_bitmap[1], &hdr); | 
| Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2588 | encode_nops(&hdr); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2589 | } | 
|  | 2590 |  | 
|  | 2591 | /* | 
|  | 2592 | * GETATTR_BITMAP request | 
|  | 2593 | */ | 
| Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2594 | static void nfs4_xdr_enc_server_caps(struct rpc_rqst *req, | 
|  | 2595 | struct xdr_stream *xdr, | 
|  | 2596 | struct nfs4_server_caps_arg *args) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2597 | { | 
| Kinglong Mee | 8c61282 | 2015-08-26 21:12:58 +0800 | [diff] [blame] | 2598 | const u32 *bitmask = args->bitmask; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2599 | struct compound_hdr hdr = { | 
| Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2600 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2601 | }; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2602 |  | 
| Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2603 | encode_compound_hdr(xdr, req, &hdr); | 
|  | 2604 | encode_sequence(xdr, &args->seq_args, &hdr); | 
|  | 2605 | encode_putfh(xdr, args->fhandle, &hdr); | 
| Kinglong Mee | 8c61282 | 2015-08-26 21:12:58 +0800 | [diff] [blame] | 2606 | encode_getattr_three(xdr, bitmask[0], bitmask[1], bitmask[2], &hdr); | 
| Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2607 | encode_nops(&hdr); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2608 | } | 
|  | 2609 |  | 
|  | 2610 | /* | 
|  | 2611 | * a RENEW request | 
|  | 2612 | */ | 
| Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2613 | static void nfs4_xdr_enc_renew(struct rpc_rqst *req, struct xdr_stream *xdr, | 
|  | 2614 | struct nfs_client *clp) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2615 | { | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2616 | struct compound_hdr hdr = { | 
| Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2617 | .nops	= 0, | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2618 | }; | 
|  | 2619 |  | 
| Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2620 | encode_compound_hdr(xdr, req, &hdr); | 
| Chuck Lever | bb4dae5 | 2012-03-01 17:01:48 -0500 | [diff] [blame] | 2621 | encode_renew(xdr, clp->cl_clientid, &hdr); | 
| Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2622 | encode_nops(&hdr); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2623 | } | 
|  | 2624 |  | 
|  | 2625 | /* | 
|  | 2626 | * a SETCLIENTID request | 
|  | 2627 | */ | 
| Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2628 | static void nfs4_xdr_enc_setclientid(struct rpc_rqst *req, | 
|  | 2629 | struct xdr_stream *xdr, | 
|  | 2630 | struct nfs4_setclientid *sc) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2631 | { | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2632 | struct compound_hdr hdr = { | 
| Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2633 | .nops	= 0, | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2634 | }; | 
|  | 2635 |  | 
| Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2636 | encode_compound_hdr(xdr, req, &hdr); | 
|  | 2637 | encode_setclientid(xdr, sc, &hdr); | 
| Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2638 | encode_nops(&hdr); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2639 | } | 
|  | 2640 |  | 
|  | 2641 | /* | 
|  | 2642 | * a SETCLIENTID_CONFIRM request | 
|  | 2643 | */ | 
| Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2644 | static void nfs4_xdr_enc_setclientid_confirm(struct rpc_rqst *req, | 
|  | 2645 | struct xdr_stream *xdr, | 
|  | 2646 | struct nfs4_setclientid_res *arg) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2647 | { | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2648 | struct compound_hdr hdr = { | 
| Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2649 | .nops	= 0, | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2650 | }; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2651 |  | 
| Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2652 | encode_compound_hdr(xdr, req, &hdr); | 
|  | 2653 | encode_setclientid_confirm(xdr, arg, &hdr); | 
| Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2654 | encode_nops(&hdr); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2655 | } | 
|  | 2656 |  | 
|  | 2657 | /* | 
|  | 2658 | * DELEGRETURN request | 
|  | 2659 | */ | 
| Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2660 | static void nfs4_xdr_enc_delegreturn(struct rpc_rqst *req, | 
|  | 2661 | struct xdr_stream *xdr, | 
|  | 2662 | const struct nfs4_delegreturnargs *args) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2663 | { | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2664 | struct compound_hdr hdr = { | 
| Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2665 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2666 | }; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2667 |  | 
| Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2668 | encode_compound_hdr(xdr, req, &hdr); | 
|  | 2669 | encode_sequence(xdr, &args->seq_args, &hdr); | 
|  | 2670 | encode_putfh(xdr, args->fhandle, &hdr); | 
| Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2671 | encode_getfattr(xdr, args->bitmask, &hdr); | 
| Trond Myklebust | e144cbc | 2012-04-28 16:05:03 -0400 | [diff] [blame] | 2672 | encode_delegreturn(xdr, args->stateid, &hdr); | 
| Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2673 | encode_nops(&hdr); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2674 | } | 
|  | 2675 |  | 
|  | 2676 | /* | 
| Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 2677 | * Encode FS_LOCATIONS request | 
|  | 2678 | */ | 
| Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2679 | static void nfs4_xdr_enc_fs_locations(struct rpc_rqst *req, | 
|  | 2680 | struct xdr_stream *xdr, | 
|  | 2681 | struct nfs4_fs_locations_arg *args) | 
| Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 2682 | { | 
| Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 2683 | struct compound_hdr hdr = { | 
| Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2684 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), | 
| Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 2685 | }; | 
| Benny Halevy | 28f5669 | 2009-04-01 09:22:09 -0400 | [diff] [blame] | 2686 | uint32_t replen; | 
| Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 2687 |  | 
| Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2688 | encode_compound_hdr(xdr, req, &hdr); | 
|  | 2689 | encode_sequence(xdr, &args->seq_args, &hdr); | 
| Chuck Lever | b03d735 | 2013-10-17 14:12:50 -0400 | [diff] [blame] | 2690 | if (args->migration) { | 
|  | 2691 | encode_putfh(xdr, args->fh, &hdr); | 
|  | 2692 | replen = hdr.replen; | 
|  | 2693 | encode_fs_locations(xdr, args->bitmask, &hdr); | 
|  | 2694 | if (args->renew) | 
|  | 2695 | encode_renew(xdr, args->clientid, &hdr); | 
|  | 2696 | } else { | 
|  | 2697 | encode_putfh(xdr, args->dir_fh, &hdr); | 
|  | 2698 | encode_lookup(xdr, args->name, &hdr); | 
|  | 2699 | replen = hdr.replen; | 
|  | 2700 | encode_fs_locations(xdr, args->bitmask, &hdr); | 
|  | 2701 | } | 
| Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 2702 |  | 
| Chuck Lever | b03d735 | 2013-10-17 14:12:50 -0400 | [diff] [blame] | 2703 | /* Set up reply kvec to capture returned fs_locations array. */ | 
| Benny Halevy | 28f5669 | 2009-04-01 09:22:09 -0400 | [diff] [blame] | 2704 | xdr_inline_pages(&req->rq_rcv_buf, replen << 2, &args->page, | 
| Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 2705 | 0, PAGE_SIZE); | 
| Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2706 | encode_nops(&hdr); | 
| Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 2707 | } | 
|  | 2708 |  | 
| Bryan Schumaker | 5a5ea0d | 2011-03-24 17:12:29 +0000 | [diff] [blame] | 2709 | /* | 
|  | 2710 | * Encode SECINFO request | 
|  | 2711 | */ | 
|  | 2712 | static void nfs4_xdr_enc_secinfo(struct rpc_rqst *req, | 
|  | 2713 | struct xdr_stream *xdr, | 
|  | 2714 | struct nfs4_secinfo_arg *args) | 
|  | 2715 | { | 
|  | 2716 | struct compound_hdr hdr = { | 
|  | 2717 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), | 
|  | 2718 | }; | 
|  | 2719 |  | 
|  | 2720 | encode_compound_hdr(xdr, req, &hdr); | 
|  | 2721 | encode_sequence(xdr, &args->seq_args, &hdr); | 
|  | 2722 | encode_putfh(xdr, args->dir_fh, &hdr); | 
|  | 2723 | encode_secinfo(xdr, args->name, &hdr); | 
|  | 2724 | encode_nops(&hdr); | 
|  | 2725 | } | 
|  | 2726 |  | 
| Chuck Lever | 44c9993 | 2013-10-17 14:13:30 -0400 | [diff] [blame] | 2727 | /* | 
|  | 2728 | * Encode FSID_PRESENT request | 
|  | 2729 | */ | 
|  | 2730 | static void nfs4_xdr_enc_fsid_present(struct rpc_rqst *req, | 
|  | 2731 | struct xdr_stream *xdr, | 
|  | 2732 | struct nfs4_fsid_present_arg *args) | 
|  | 2733 | { | 
|  | 2734 | struct compound_hdr hdr = { | 
|  | 2735 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), | 
|  | 2736 | }; | 
|  | 2737 |  | 
|  | 2738 | encode_compound_hdr(xdr, req, &hdr); | 
|  | 2739 | encode_sequence(xdr, &args->seq_args, &hdr); | 
|  | 2740 | encode_putfh(xdr, args->fh, &hdr); | 
|  | 2741 | encode_getfh(xdr, &hdr); | 
|  | 2742 | if (args->renew) | 
|  | 2743 | encode_renew(xdr, args->clientid, &hdr); | 
|  | 2744 | encode_nops(&hdr); | 
|  | 2745 | } | 
|  | 2746 |  | 
| Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 2747 | #if defined(CONFIG_NFS_V4_1) | 
|  | 2748 | /* | 
| Weston Andros Adamson | 7c44f1ae | 2012-05-24 13:22:50 -0400 | [diff] [blame] | 2749 | * BIND_CONN_TO_SESSION request | 
|  | 2750 | */ | 
|  | 2751 | static void nfs4_xdr_enc_bind_conn_to_session(struct rpc_rqst *req, | 
|  | 2752 | struct xdr_stream *xdr, | 
| Trond Myklebust | 71a097c | 2015-02-18 09:27:18 -0800 | [diff] [blame] | 2753 | struct nfs41_bind_conn_to_session_args *args) | 
| Weston Andros Adamson | 7c44f1ae | 2012-05-24 13:22:50 -0400 | [diff] [blame] | 2754 | { | 
|  | 2755 | struct compound_hdr hdr = { | 
| Trond Myklebust | 71a097c | 2015-02-18 09:27:18 -0800 | [diff] [blame] | 2756 | .minorversion = args->client->cl_mvops->minor_version, | 
| Weston Andros Adamson | 7c44f1ae | 2012-05-24 13:22:50 -0400 | [diff] [blame] | 2757 | }; | 
|  | 2758 |  | 
|  | 2759 | encode_compound_hdr(xdr, req, &hdr); | 
| Trond Myklebust | 71a097c | 2015-02-18 09:27:18 -0800 | [diff] [blame] | 2760 | encode_bind_conn_to_session(xdr, args, &hdr); | 
| Weston Andros Adamson | 7c44f1ae | 2012-05-24 13:22:50 -0400 | [diff] [blame] | 2761 | encode_nops(&hdr); | 
|  | 2762 | } | 
|  | 2763 |  | 
|  | 2764 | /* | 
| Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 2765 | * EXCHANGE_ID request | 
|  | 2766 | */ | 
| Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2767 | static void nfs4_xdr_enc_exchange_id(struct rpc_rqst *req, | 
|  | 2768 | struct xdr_stream *xdr, | 
|  | 2769 | struct nfs41_exchange_id_args *args) | 
| Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 2770 | { | 
| Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 2771 | struct compound_hdr hdr = { | 
| Trond Myklebust | a443234 | 2010-06-16 09:52:27 -0400 | [diff] [blame] | 2772 | .minorversion = args->client->cl_mvops->minor_version, | 
| Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 2773 | }; | 
|  | 2774 |  | 
| Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2775 | encode_compound_hdr(xdr, req, &hdr); | 
|  | 2776 | encode_exchange_id(xdr, args, &hdr); | 
| Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 2777 | encode_nops(&hdr); | 
| Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 2778 | } | 
| Andy Adamson | 2050f0c | 2009-04-01 09:22:30 -0400 | [diff] [blame] | 2779 |  | 
|  | 2780 | /* | 
| Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 2781 | * a CREATE_SESSION request | 
|  | 2782 | */ | 
| Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2783 | static void nfs4_xdr_enc_create_session(struct rpc_rqst *req, | 
|  | 2784 | struct xdr_stream *xdr, | 
|  | 2785 | struct nfs41_create_session_args *args) | 
| Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 2786 | { | 
| Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 2787 | struct compound_hdr hdr = { | 
| Trond Myklebust | a443234 | 2010-06-16 09:52:27 -0400 | [diff] [blame] | 2788 | .minorversion = args->client->cl_mvops->minor_version, | 
| Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 2789 | }; | 
|  | 2790 |  | 
| Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2791 | encode_compound_hdr(xdr, req, &hdr); | 
|  | 2792 | encode_create_session(xdr, args, &hdr); | 
| Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 2793 | encode_nops(&hdr); | 
| Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 2794 | } | 
|  | 2795 |  | 
|  | 2796 | /* | 
| Andy Adamson | 0f3e66c | 2009-04-01 09:22:34 -0400 | [diff] [blame] | 2797 | * a DESTROY_SESSION request | 
|  | 2798 | */ | 
| Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2799 | static void nfs4_xdr_enc_destroy_session(struct rpc_rqst *req, | 
|  | 2800 | struct xdr_stream *xdr, | 
|  | 2801 | struct nfs4_session *session) | 
| Andy Adamson | 0f3e66c | 2009-04-01 09:22:34 -0400 | [diff] [blame] | 2802 | { | 
| Andy Adamson | 0f3e66c | 2009-04-01 09:22:34 -0400 | [diff] [blame] | 2803 | struct compound_hdr hdr = { | 
| Trond Myklebust | a443234 | 2010-06-16 09:52:27 -0400 | [diff] [blame] | 2804 | .minorversion = session->clp->cl_mvops->minor_version, | 
| Andy Adamson | 0f3e66c | 2009-04-01 09:22:34 -0400 | [diff] [blame] | 2805 | }; | 
|  | 2806 |  | 
| Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2807 | encode_compound_hdr(xdr, req, &hdr); | 
|  | 2808 | encode_destroy_session(xdr, session, &hdr); | 
| Andy Adamson | 0f3e66c | 2009-04-01 09:22:34 -0400 | [diff] [blame] | 2809 | encode_nops(&hdr); | 
| Andy Adamson | 0f3e66c | 2009-04-01 09:22:34 -0400 | [diff] [blame] | 2810 | } | 
|  | 2811 |  | 
|  | 2812 | /* | 
| Trond Myklebust | 6624553 | 2012-05-25 17:18:09 -0400 | [diff] [blame] | 2813 | * a DESTROY_CLIENTID request | 
|  | 2814 | */ | 
|  | 2815 | static void nfs4_xdr_enc_destroy_clientid(struct rpc_rqst *req, | 
|  | 2816 | struct xdr_stream *xdr, | 
|  | 2817 | struct nfs_client *clp) | 
|  | 2818 | { | 
|  | 2819 | struct compound_hdr hdr = { | 
|  | 2820 | .minorversion = clp->cl_mvops->minor_version, | 
|  | 2821 | }; | 
|  | 2822 |  | 
|  | 2823 | encode_compound_hdr(xdr, req, &hdr); | 
|  | 2824 | encode_destroy_clientid(xdr, clp->cl_clientid, &hdr); | 
|  | 2825 | encode_nops(&hdr); | 
|  | 2826 | } | 
|  | 2827 |  | 
|  | 2828 | /* | 
| Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 2829 | * a SEQUENCE request | 
|  | 2830 | */ | 
| Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2831 | static void nfs4_xdr_enc_sequence(struct rpc_rqst *req, struct xdr_stream *xdr, | 
|  | 2832 | struct nfs4_sequence_args *args) | 
| Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 2833 | { | 
| Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 2834 | struct compound_hdr hdr = { | 
|  | 2835 | .minorversion = nfs4_xdr_minorversion(args), | 
|  | 2836 | }; | 
|  | 2837 |  | 
| Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2838 | encode_compound_hdr(xdr, req, &hdr); | 
|  | 2839 | encode_sequence(xdr, args, &hdr); | 
| Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 2840 | encode_nops(&hdr); | 
| Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 2841 | } | 
|  | 2842 |  | 
|  | 2843 | /* | 
| Andy Adamson | 2050f0c | 2009-04-01 09:22:30 -0400 | [diff] [blame] | 2844 | * a GET_LEASE_TIME request | 
|  | 2845 | */ | 
| Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2846 | static void nfs4_xdr_enc_get_lease_time(struct rpc_rqst *req, | 
|  | 2847 | struct xdr_stream *xdr, | 
|  | 2848 | struct nfs4_get_lease_time_args *args) | 
| Andy Adamson | 2050f0c | 2009-04-01 09:22:30 -0400 | [diff] [blame] | 2849 | { | 
| Andy Adamson | 2050f0c | 2009-04-01 09:22:30 -0400 | [diff] [blame] | 2850 | struct compound_hdr hdr = { | 
|  | 2851 | .minorversion = nfs4_xdr_minorversion(&args->la_seq_args), | 
|  | 2852 | }; | 
| Fred Isaman | dae100c | 2011-07-30 20:52:37 -0400 | [diff] [blame] | 2853 | const u32 lease_bitmap[3] = { FATTR4_WORD0_LEASE_TIME }; | 
| Andy Adamson | 2050f0c | 2009-04-01 09:22:30 -0400 | [diff] [blame] | 2854 |  | 
| Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2855 | encode_compound_hdr(xdr, req, &hdr); | 
|  | 2856 | encode_sequence(xdr, &args->la_seq_args, &hdr); | 
|  | 2857 | encode_putrootfh(xdr, &hdr); | 
|  | 2858 | encode_fsinfo(xdr, lease_bitmap, &hdr); | 
| Andy Adamson | 2050f0c | 2009-04-01 09:22:30 -0400 | [diff] [blame] | 2859 | encode_nops(&hdr); | 
| Andy Adamson | 2050f0c | 2009-04-01 09:22:30 -0400 | [diff] [blame] | 2860 | } | 
| Ricardo Labiaga | 18019753 | 2009-12-05 16:08:40 -0500 | [diff] [blame] | 2861 |  | 
|  | 2862 | /* | 
|  | 2863 | * a RECLAIM_COMPLETE request | 
|  | 2864 | */ | 
| Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2865 | static void nfs4_xdr_enc_reclaim_complete(struct rpc_rqst *req, | 
|  | 2866 | struct xdr_stream *xdr, | 
|  | 2867 | struct nfs41_reclaim_complete_args *args) | 
| Ricardo Labiaga | 18019753 | 2009-12-05 16:08:40 -0500 | [diff] [blame] | 2868 | { | 
| Ricardo Labiaga | 18019753 | 2009-12-05 16:08:40 -0500 | [diff] [blame] | 2869 | struct compound_hdr hdr = { | 
|  | 2870 | .minorversion = nfs4_xdr_minorversion(&args->seq_args) | 
|  | 2871 | }; | 
|  | 2872 |  | 
| Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2873 | encode_compound_hdr(xdr, req, &hdr); | 
|  | 2874 | encode_sequence(xdr, &args->seq_args, &hdr); | 
|  | 2875 | encode_reclaim_complete(xdr, args, &hdr); | 
| Ricardo Labiaga | 18019753 | 2009-12-05 16:08:40 -0500 | [diff] [blame] | 2876 | encode_nops(&hdr); | 
| Ricardo Labiaga | 18019753 | 2009-12-05 16:08:40 -0500 | [diff] [blame] | 2877 | } | 
|  | 2878 |  | 
| Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 2879 | /* | 
|  | 2880 | * Encode GETDEVICEINFO request | 
|  | 2881 | */ | 
| Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2882 | static void nfs4_xdr_enc_getdeviceinfo(struct rpc_rqst *req, | 
|  | 2883 | struct xdr_stream *xdr, | 
|  | 2884 | struct nfs4_getdeviceinfo_args *args) | 
| Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 2885 | { | 
| Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 2886 | struct compound_hdr hdr = { | 
|  | 2887 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), | 
|  | 2888 | }; | 
|  | 2889 |  | 
| Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2890 | encode_compound_hdr(xdr, req, &hdr); | 
|  | 2891 | encode_sequence(xdr, &args->seq_args, &hdr); | 
|  | 2892 | encode_getdeviceinfo(xdr, args, &hdr); | 
| Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 2893 |  | 
|  | 2894 | /* set up reply kvec. Subtract notification bitmap max size (2) | 
|  | 2895 | * so that notification bitmap is put in xdr_buf tail */ | 
|  | 2896 | xdr_inline_pages(&req->rq_rcv_buf, (hdr.replen - 2) << 2, | 
|  | 2897 | args->pdev->pages, args->pdev->pgbase, | 
|  | 2898 | args->pdev->pglen); | 
|  | 2899 |  | 
|  | 2900 | encode_nops(&hdr); | 
| Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 2901 | } | 
|  | 2902 |  | 
|  | 2903 | /* | 
|  | 2904 | *  Encode LAYOUTGET request | 
|  | 2905 | */ | 
| Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2906 | static void nfs4_xdr_enc_layoutget(struct rpc_rqst *req, | 
|  | 2907 | struct xdr_stream *xdr, | 
|  | 2908 | struct nfs4_layoutget_args *args) | 
| Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 2909 | { | 
| Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 2910 | struct compound_hdr hdr = { | 
|  | 2911 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), | 
|  | 2912 | }; | 
|  | 2913 |  | 
| Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2914 | encode_compound_hdr(xdr, req, &hdr); | 
|  | 2915 | encode_sequence(xdr, &args->seq_args, &hdr); | 
|  | 2916 | encode_putfh(xdr, NFS_FH(args->inode), &hdr); | 
|  | 2917 | encode_layoutget(xdr, args, &hdr); | 
| Weston Andros Adamson | 35124a0 | 2011-03-24 16:48:21 -0400 | [diff] [blame] | 2918 |  | 
|  | 2919 | xdr_inline_pages(&req->rq_rcv_buf, hdr.replen << 2, | 
|  | 2920 | args->layout.pages, 0, args->layout.pglen); | 
|  | 2921 |  | 
| Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 2922 | encode_nops(&hdr); | 
| Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 2923 | } | 
| Andy Adamson | 863a3c6 | 2011-03-23 13:27:54 +0000 | [diff] [blame] | 2924 |  | 
|  | 2925 | /* | 
|  | 2926 | *  Encode LAYOUTCOMMIT request | 
|  | 2927 | */ | 
| Benny Halevy | cbe8260 | 2011-05-22 19:52:37 +0300 | [diff] [blame] | 2928 | static void nfs4_xdr_enc_layoutcommit(struct rpc_rqst *req, | 
|  | 2929 | struct xdr_stream *xdr, | 
|  | 2930 | struct nfs4_layoutcommit_args *args) | 
| Andy Adamson | 863a3c6 | 2011-03-23 13:27:54 +0000 | [diff] [blame] | 2931 | { | 
| Benny Halevy | ac7db72 | 2011-05-22 19:53:48 +0300 | [diff] [blame] | 2932 | struct nfs4_layoutcommit_data *data = | 
|  | 2933 | container_of(args, struct nfs4_layoutcommit_data, args); | 
| Andy Adamson | 863a3c6 | 2011-03-23 13:27:54 +0000 | [diff] [blame] | 2934 | struct compound_hdr hdr = { | 
|  | 2935 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), | 
|  | 2936 | }; | 
|  | 2937 |  | 
|  | 2938 | encode_compound_hdr(xdr, req, &hdr); | 
|  | 2939 | encode_sequence(xdr, &args->seq_args, &hdr); | 
|  | 2940 | encode_putfh(xdr, NFS_FH(args->inode), &hdr); | 
| Benny Halevy | ac7db72 | 2011-05-22 19:53:48 +0300 | [diff] [blame] | 2941 | encode_layoutcommit(xdr, data->args.inode, args, &hdr); | 
| Andy Adamson | 863a3c6 | 2011-03-23 13:27:54 +0000 | [diff] [blame] | 2942 | encode_getfattr(xdr, args->bitmask, &hdr); | 
|  | 2943 | encode_nops(&hdr); | 
| Benny Halevy | cbe8260 | 2011-05-22 19:52:37 +0300 | [diff] [blame] | 2944 | } | 
|  | 2945 |  | 
|  | 2946 | /* | 
|  | 2947 | * Encode LAYOUTRETURN request | 
|  | 2948 | */ | 
|  | 2949 | static void nfs4_xdr_enc_layoutreturn(struct rpc_rqst *req, | 
|  | 2950 | struct xdr_stream *xdr, | 
|  | 2951 | struct nfs4_layoutreturn_args *args) | 
|  | 2952 | { | 
|  | 2953 | struct compound_hdr hdr = { | 
|  | 2954 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), | 
|  | 2955 | }; | 
|  | 2956 |  | 
|  | 2957 | encode_compound_hdr(xdr, req, &hdr); | 
|  | 2958 | encode_sequence(xdr, &args->seq_args, &hdr); | 
|  | 2959 | encode_putfh(xdr, NFS_FH(args->inode), &hdr); | 
|  | 2960 | encode_layoutreturn(xdr, args, &hdr); | 
|  | 2961 | encode_nops(&hdr); | 
| Andy Adamson | 863a3c6 | 2011-03-23 13:27:54 +0000 | [diff] [blame] | 2962 | } | 
| Bryan Schumaker | fca78d6 | 2011-06-02 14:59:07 -0400 | [diff] [blame] | 2963 |  | 
|  | 2964 | /* | 
|  | 2965 | * Encode SECINFO_NO_NAME request | 
|  | 2966 | */ | 
|  | 2967 | static int nfs4_xdr_enc_secinfo_no_name(struct rpc_rqst *req, | 
|  | 2968 | struct xdr_stream *xdr, | 
|  | 2969 | struct nfs41_secinfo_no_name_args *args) | 
|  | 2970 | { | 
|  | 2971 | struct compound_hdr hdr = { | 
|  | 2972 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), | 
|  | 2973 | }; | 
|  | 2974 |  | 
|  | 2975 | encode_compound_hdr(xdr, req, &hdr); | 
|  | 2976 | encode_sequence(xdr, &args->seq_args, &hdr); | 
|  | 2977 | encode_putrootfh(xdr, &hdr); | 
|  | 2978 | encode_secinfo_no_name(xdr, args, &hdr); | 
|  | 2979 | encode_nops(&hdr); | 
|  | 2980 | return 0; | 
|  | 2981 | } | 
| Bryan Schumaker | 7d97479 | 2011-06-02 14:59:08 -0400 | [diff] [blame] | 2982 |  | 
|  | 2983 | /* | 
|  | 2984 | *  Encode TEST_STATEID request | 
|  | 2985 | */ | 
|  | 2986 | static void nfs4_xdr_enc_test_stateid(struct rpc_rqst *req, | 
|  | 2987 | struct xdr_stream *xdr, | 
|  | 2988 | struct nfs41_test_stateid_args *args) | 
|  | 2989 | { | 
|  | 2990 | struct compound_hdr hdr = { | 
|  | 2991 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), | 
|  | 2992 | }; | 
|  | 2993 |  | 
|  | 2994 | encode_compound_hdr(xdr, req, &hdr); | 
|  | 2995 | encode_sequence(xdr, &args->seq_args, &hdr); | 
|  | 2996 | encode_test_stateid(xdr, args, &hdr); | 
|  | 2997 | encode_nops(&hdr); | 
|  | 2998 | } | 
| Bryan Schumaker | 9aeda35 | 2011-06-02 14:59:09 -0400 | [diff] [blame] | 2999 |  | 
|  | 3000 | /* | 
|  | 3001 | *  Encode FREE_STATEID request | 
|  | 3002 | */ | 
|  | 3003 | static void nfs4_xdr_enc_free_stateid(struct rpc_rqst *req, | 
|  | 3004 | struct xdr_stream *xdr, | 
|  | 3005 | struct nfs41_free_stateid_args *args) | 
|  | 3006 | { | 
|  | 3007 | struct compound_hdr hdr = { | 
|  | 3008 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), | 
|  | 3009 | }; | 
|  | 3010 |  | 
|  | 3011 | encode_compound_hdr(xdr, req, &hdr); | 
|  | 3012 | encode_sequence(xdr, &args->seq_args, &hdr); | 
|  | 3013 | encode_free_stateid(xdr, args, &hdr); | 
|  | 3014 | encode_nops(&hdr); | 
|  | 3015 | } | 
| Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 3016 | #endif /* CONFIG_NFS_V4_1 */ | 
|  | 3017 |  | 
| Benny Halevy | 686841b | 2009-08-14 17:19:48 +0300 | [diff] [blame] | 3018 | static void print_overflow_msg(const char *func, const struct xdr_stream *xdr) | 
|  | 3019 | { | 
|  | 3020 | dprintk("nfs: %s: prematurely hit end of receive buffer. " | 
|  | 3021 | "Remaining buffer length is %tu words.\n", | 
|  | 3022 | func, xdr->end - xdr->p); | 
|  | 3023 | } | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3024 |  | 
| Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 3025 | static int decode_opaque_inline(struct xdr_stream *xdr, unsigned int *len, char **string) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3026 | { | 
| Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3027 | __be32 *p; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3028 |  | 
| Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3029 | p = xdr_inline_decode(xdr, 4); | 
|  | 3030 | if (unlikely(!p)) | 
|  | 3031 | goto out_overflow; | 
| Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3032 | *len = be32_to_cpup(p); | 
| Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3033 | p = xdr_inline_decode(xdr, *len); | 
|  | 3034 | if (unlikely(!p)) | 
|  | 3035 | goto out_overflow; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3036 | *string = (char *)p; | 
|  | 3037 | return 0; | 
| Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3038 | out_overflow: | 
|  | 3039 | print_overflow_msg(__func__, xdr); | 
|  | 3040 | return -EIO; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3041 | } | 
|  | 3042 |  | 
|  | 3043 | static int decode_compound_hdr(struct xdr_stream *xdr, struct compound_hdr *hdr) | 
|  | 3044 | { | 
| Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3045 | __be32 *p; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3046 |  | 
| Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3047 | p = xdr_inline_decode(xdr, 8); | 
|  | 3048 | if (unlikely(!p)) | 
|  | 3049 | goto out_overflow; | 
| Benny Halevy | 6f723f7 | 2009-08-14 17:19:37 +0300 | [diff] [blame] | 3050 | hdr->status = be32_to_cpup(p++); | 
| Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3051 | hdr->taglen = be32_to_cpup(p); | 
| Andy Adamson | 6c0195a | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 3052 |  | 
| Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3053 | p = xdr_inline_decode(xdr, hdr->taglen + 4); | 
|  | 3054 | if (unlikely(!p)) | 
|  | 3055 | goto out_overflow; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3056 | hdr->tag = (char *)p; | 
|  | 3057 | p += XDR_QUADLEN(hdr->taglen); | 
| Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3058 | hdr->nops = be32_to_cpup(p); | 
| Benny Halevy | aadf615 | 2008-12-23 16:06:13 -0500 | [diff] [blame] | 3059 | if (unlikely(hdr->nops < 1)) | 
|  | 3060 | return nfs4_stat_to_errno(hdr->status); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3061 | return 0; | 
| Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3062 | out_overflow: | 
|  | 3063 | print_overflow_msg(__func__, xdr); | 
|  | 3064 | return -EIO; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3065 | } | 
|  | 3066 |  | 
| Trond Myklebust | c7848f6 | 2013-12-04 17:39:23 -0500 | [diff] [blame] | 3067 | static bool __decode_op_hdr(struct xdr_stream *xdr, enum nfs_opnum4 expected, | 
|  | 3068 | int *nfs_retval) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3069 | { | 
| Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3070 | __be32 *p; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3071 | uint32_t opnum; | 
|  | 3072 | int32_t nfserr; | 
|  | 3073 |  | 
| Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3074 | p = xdr_inline_decode(xdr, 8); | 
|  | 3075 | if (unlikely(!p)) | 
|  | 3076 | goto out_overflow; | 
| Benny Halevy | 6f723f7 | 2009-08-14 17:19:37 +0300 | [diff] [blame] | 3077 | opnum = be32_to_cpup(p++); | 
| Trond Myklebust | c7848f6 | 2013-12-04 17:39:23 -0500 | [diff] [blame] | 3078 | if (unlikely(opnum != expected)) | 
|  | 3079 | goto out_bad_operation; | 
| Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3080 | nfserr = be32_to_cpup(p); | 
| Trond Myklebust | c7848f6 | 2013-12-04 17:39:23 -0500 | [diff] [blame] | 3081 | if (nfserr == NFS_OK) | 
|  | 3082 | *nfs_retval = 0; | 
|  | 3083 | else | 
|  | 3084 | *nfs_retval = nfs4_stat_to_errno(nfserr); | 
|  | 3085 | return true; | 
|  | 3086 | out_bad_operation: | 
|  | 3087 | dprintk("nfs: Server returned operation" | 
|  | 3088 | " %d but we issued a request for %d\n", | 
|  | 3089 | opnum, expected); | 
|  | 3090 | *nfs_retval = -EREMOTEIO; | 
|  | 3091 | return false; | 
| Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3092 | out_overflow: | 
|  | 3093 | print_overflow_msg(__func__, xdr); | 
| Trond Myklebust | c7848f6 | 2013-12-04 17:39:23 -0500 | [diff] [blame] | 3094 | *nfs_retval = -EIO; | 
|  | 3095 | return false; | 
|  | 3096 | } | 
|  | 3097 |  | 
|  | 3098 | static int decode_op_hdr(struct xdr_stream *xdr, enum nfs_opnum4 expected) | 
|  | 3099 | { | 
|  | 3100 | int retval; | 
|  | 3101 |  | 
|  | 3102 | __decode_op_hdr(xdr, expected, &retval); | 
|  | 3103 | return retval; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3104 | } | 
|  | 3105 |  | 
|  | 3106 | /* Dummy routine */ | 
| David Howells | adfa6f9 | 2006-08-22 20:06:08 -0400 | [diff] [blame] | 3107 | static int decode_ace(struct xdr_stream *xdr, void *ace, struct nfs_client *clp) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3108 | { | 
| Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3109 | __be32 *p; | 
| Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 3110 | unsigned int strlen; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3111 | char *str; | 
|  | 3112 |  | 
| Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3113 | p = xdr_inline_decode(xdr, 12); | 
|  | 3114 | if (likely(p)) | 
|  | 3115 | return decode_opaque_inline(xdr, &strlen, &str); | 
|  | 3116 | print_overflow_msg(__func__, xdr); | 
|  | 3117 | return -EIO; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3118 | } | 
|  | 3119 |  | 
|  | 3120 | static int decode_attr_bitmap(struct xdr_stream *xdr, uint32_t *bitmap) | 
|  | 3121 | { | 
| Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3122 | uint32_t bmlen; | 
|  | 3123 | __be32 *p; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3124 |  | 
| Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3125 | p = xdr_inline_decode(xdr, 4); | 
|  | 3126 | if (unlikely(!p)) | 
|  | 3127 | goto out_overflow; | 
| Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3128 | bmlen = be32_to_cpup(p); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3129 |  | 
| Fred Isaman | dae100c | 2011-07-30 20:52:37 -0400 | [diff] [blame] | 3130 | bitmap[0] = bitmap[1] = bitmap[2] = 0; | 
| Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3131 | p = xdr_inline_decode(xdr, (bmlen << 2)); | 
|  | 3132 | if (unlikely(!p)) | 
|  | 3133 | goto out_overflow; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3134 | if (bmlen > 0) { | 
| Benny Halevy | 6f723f7 | 2009-08-14 17:19:37 +0300 | [diff] [blame] | 3135 | bitmap[0] = be32_to_cpup(p++); | 
| Fred Isaman | dae100c | 2011-07-30 20:52:37 -0400 | [diff] [blame] | 3136 | if (bmlen > 1) { | 
|  | 3137 | bitmap[1] = be32_to_cpup(p++); | 
|  | 3138 | if (bmlen > 2) | 
|  | 3139 | bitmap[2] = be32_to_cpup(p); | 
|  | 3140 | } | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3141 | } | 
|  | 3142 | return 0; | 
| Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3143 | out_overflow: | 
|  | 3144 | print_overflow_msg(__func__, xdr); | 
|  | 3145 | return -EIO; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3146 | } | 
|  | 3147 |  | 
| Trond Myklebust | 256e48b | 2012-06-21 11:18:13 -0400 | [diff] [blame] | 3148 | static int decode_attr_length(struct xdr_stream *xdr, uint32_t *attrlen, unsigned int *savep) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3149 | { | 
| Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3150 | __be32 *p; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3151 |  | 
| Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3152 | p = xdr_inline_decode(xdr, 4); | 
|  | 3153 | if (unlikely(!p)) | 
|  | 3154 | goto out_overflow; | 
| Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3155 | *attrlen = be32_to_cpup(p); | 
| Trond Myklebust | 256e48b | 2012-06-21 11:18:13 -0400 | [diff] [blame] | 3156 | *savep = xdr_stream_pos(xdr); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3157 | return 0; | 
| Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3158 | out_overflow: | 
|  | 3159 | print_overflow_msg(__func__, xdr); | 
|  | 3160 | return -EIO; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3161 | } | 
|  | 3162 |  | 
|  | 3163 | static int decode_attr_supported(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t *bitmask) | 
|  | 3164 | { | 
|  | 3165 | if (likely(bitmap[0] & FATTR4_WORD0_SUPPORTED_ATTRS)) { | 
| Roman Borisov | 3388bff | 2010-10-13 16:54:51 +0400 | [diff] [blame] | 3166 | int ret; | 
|  | 3167 | ret = decode_attr_bitmap(xdr, bitmask); | 
|  | 3168 | if (unlikely(ret < 0)) | 
|  | 3169 | return ret; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3170 | bitmap[0] &= ~FATTR4_WORD0_SUPPORTED_ATTRS; | 
|  | 3171 | } else | 
| Fred Isaman | dae100c | 2011-07-30 20:52:37 -0400 | [diff] [blame] | 3172 | bitmask[0] = bitmask[1] = bitmask[2] = 0; | 
|  | 3173 | dprintk("%s: bitmask=%08x:%08x:%08x\n", __func__, | 
|  | 3174 | bitmask[0], bitmask[1], bitmask[2]); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3175 | return 0; | 
|  | 3176 | } | 
|  | 3177 |  | 
|  | 3178 | static int decode_attr_type(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t *type) | 
|  | 3179 | { | 
| Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3180 | __be32 *p; | 
| Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3181 | int ret = 0; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3182 |  | 
|  | 3183 | *type = 0; | 
|  | 3184 | if (unlikely(bitmap[0] & (FATTR4_WORD0_TYPE - 1U))) | 
|  | 3185 | return -EIO; | 
|  | 3186 | if (likely(bitmap[0] & FATTR4_WORD0_TYPE)) { | 
| Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3187 | p = xdr_inline_decode(xdr, 4); | 
|  | 3188 | if (unlikely(!p)) | 
|  | 3189 | goto out_overflow; | 
| Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3190 | *type = be32_to_cpup(p); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3191 | if (*type < NF4REG || *type > NF4NAMEDATTR) { | 
| Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3192 | dprintk("%s: bad type %d\n", __func__, *type); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3193 | return -EIO; | 
|  | 3194 | } | 
|  | 3195 | bitmap[0] &= ~FATTR4_WORD0_TYPE; | 
| Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3196 | ret = NFS_ATTR_FATTR_TYPE; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3197 | } | 
| Trond Myklebust | bca7947 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 3198 | dprintk("%s: type=0%o\n", __func__, nfs_type2fmt[*type]); | 
| Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3199 | return ret; | 
| Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3200 | out_overflow: | 
|  | 3201 | print_overflow_msg(__func__, xdr); | 
|  | 3202 | return -EIO; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3203 | } | 
|  | 3204 |  | 
| Chuck Lever | 264e635 | 2012-03-01 17:02:05 -0500 | [diff] [blame] | 3205 | static int decode_attr_fh_expire_type(struct xdr_stream *xdr, | 
|  | 3206 | uint32_t *bitmap, uint32_t *type) | 
|  | 3207 | { | 
|  | 3208 | __be32 *p; | 
|  | 3209 |  | 
|  | 3210 | *type = 0; | 
|  | 3211 | if (unlikely(bitmap[0] & (FATTR4_WORD0_FH_EXPIRE_TYPE - 1U))) | 
|  | 3212 | return -EIO; | 
|  | 3213 | if (likely(bitmap[0] & FATTR4_WORD0_FH_EXPIRE_TYPE)) { | 
|  | 3214 | p = xdr_inline_decode(xdr, 4); | 
|  | 3215 | if (unlikely(!p)) | 
|  | 3216 | goto out_overflow; | 
|  | 3217 | *type = be32_to_cpup(p); | 
|  | 3218 | bitmap[0] &= ~FATTR4_WORD0_FH_EXPIRE_TYPE; | 
|  | 3219 | } | 
|  | 3220 | dprintk("%s: expire type=0x%x\n", __func__, *type); | 
|  | 3221 | return 0; | 
|  | 3222 | out_overflow: | 
|  | 3223 | print_overflow_msg(__func__, xdr); | 
|  | 3224 | return -EIO; | 
|  | 3225 | } | 
|  | 3226 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3227 | static int decode_attr_change(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *change) | 
|  | 3228 | { | 
| Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3229 | __be32 *p; | 
| Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3230 | int ret = 0; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3231 |  | 
|  | 3232 | *change = 0; | 
|  | 3233 | if (unlikely(bitmap[0] & (FATTR4_WORD0_CHANGE - 1U))) | 
|  | 3234 | return -EIO; | 
|  | 3235 | if (likely(bitmap[0] & FATTR4_WORD0_CHANGE)) { | 
| Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3236 | p = xdr_inline_decode(xdr, 8); | 
|  | 3237 | if (unlikely(!p)) | 
|  | 3238 | goto out_overflow; | 
| Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3239 | xdr_decode_hyper(p, change); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3240 | bitmap[0] &= ~FATTR4_WORD0_CHANGE; | 
| Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3241 | ret = NFS_ATTR_FATTR_CHANGE; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3242 | } | 
| Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3243 | dprintk("%s: change attribute=%Lu\n", __func__, | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3244 | (unsigned long long)*change); | 
| Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3245 | return ret; | 
| Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3246 | out_overflow: | 
|  | 3247 | print_overflow_msg(__func__, xdr); | 
|  | 3248 | return -EIO; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3249 | } | 
|  | 3250 |  | 
|  | 3251 | static int decode_attr_size(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *size) | 
|  | 3252 | { | 
| Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3253 | __be32 *p; | 
| Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3254 | int ret = 0; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3255 |  | 
|  | 3256 | *size = 0; | 
|  | 3257 | if (unlikely(bitmap[0] & (FATTR4_WORD0_SIZE - 1U))) | 
|  | 3258 | return -EIO; | 
|  | 3259 | if (likely(bitmap[0] & FATTR4_WORD0_SIZE)) { | 
| Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3260 | p = xdr_inline_decode(xdr, 8); | 
|  | 3261 | if (unlikely(!p)) | 
|  | 3262 | goto out_overflow; | 
| Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3263 | xdr_decode_hyper(p, size); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3264 | bitmap[0] &= ~FATTR4_WORD0_SIZE; | 
| Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3265 | ret = NFS_ATTR_FATTR_SIZE; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3266 | } | 
| Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3267 | dprintk("%s: file size=%Lu\n", __func__, (unsigned long long)*size); | 
| Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3268 | return ret; | 
| Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3269 | out_overflow: | 
|  | 3270 | print_overflow_msg(__func__, xdr); | 
|  | 3271 | return -EIO; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3272 | } | 
|  | 3273 |  | 
|  | 3274 | static int decode_attr_link_support(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t *res) | 
|  | 3275 | { | 
| Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3276 | __be32 *p; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3277 |  | 
|  | 3278 | *res = 0; | 
|  | 3279 | if (unlikely(bitmap[0] & (FATTR4_WORD0_LINK_SUPPORT - 1U))) | 
|  | 3280 | return -EIO; | 
|  | 3281 | if (likely(bitmap[0] & FATTR4_WORD0_LINK_SUPPORT)) { | 
| Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3282 | p = xdr_inline_decode(xdr, 4); | 
|  | 3283 | if (unlikely(!p)) | 
|  | 3284 | goto out_overflow; | 
| Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3285 | *res = be32_to_cpup(p); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3286 | bitmap[0] &= ~FATTR4_WORD0_LINK_SUPPORT; | 
|  | 3287 | } | 
| Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3288 | dprintk("%s: link support=%s\n", __func__, *res == 0 ? "false" : "true"); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3289 | return 0; | 
| Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3290 | out_overflow: | 
|  | 3291 | print_overflow_msg(__func__, xdr); | 
|  | 3292 | return -EIO; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3293 | } | 
|  | 3294 |  | 
|  | 3295 | static int decode_attr_symlink_support(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t *res) | 
|  | 3296 | { | 
| Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3297 | __be32 *p; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3298 |  | 
|  | 3299 | *res = 0; | 
|  | 3300 | if (unlikely(bitmap[0] & (FATTR4_WORD0_SYMLINK_SUPPORT - 1U))) | 
|  | 3301 | return -EIO; | 
|  | 3302 | if (likely(bitmap[0] & FATTR4_WORD0_SYMLINK_SUPPORT)) { | 
| Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3303 | p = xdr_inline_decode(xdr, 4); | 
|  | 3304 | if (unlikely(!p)) | 
|  | 3305 | goto out_overflow; | 
| Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3306 | *res = be32_to_cpup(p); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3307 | bitmap[0] &= ~FATTR4_WORD0_SYMLINK_SUPPORT; | 
|  | 3308 | } | 
| Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3309 | dprintk("%s: symlink support=%s\n", __func__, *res == 0 ? "false" : "true"); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3310 | return 0; | 
| Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3311 | out_overflow: | 
|  | 3312 | print_overflow_msg(__func__, xdr); | 
|  | 3313 | return -EIO; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3314 | } | 
|  | 3315 |  | 
| Trond Myklebust | 8b4bdcf | 2006-06-09 09:34:19 -0400 | [diff] [blame] | 3316 | static int decode_attr_fsid(struct xdr_stream *xdr, uint32_t *bitmap, struct nfs_fsid *fsid) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3317 | { | 
| Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3318 | __be32 *p; | 
| Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3319 | int ret = 0; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3320 |  | 
|  | 3321 | fsid->major = 0; | 
|  | 3322 | fsid->minor = 0; | 
|  | 3323 | if (unlikely(bitmap[0] & (FATTR4_WORD0_FSID - 1U))) | 
|  | 3324 | return -EIO; | 
|  | 3325 | if (likely(bitmap[0] & FATTR4_WORD0_FSID)) { | 
| Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3326 | p = xdr_inline_decode(xdr, 16); | 
|  | 3327 | if (unlikely(!p)) | 
|  | 3328 | goto out_overflow; | 
| Benny Halevy | 3ceb4db | 2009-08-14 17:19:41 +0300 | [diff] [blame] | 3329 | p = xdr_decode_hyper(p, &fsid->major); | 
| Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3330 | xdr_decode_hyper(p, &fsid->minor); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3331 | bitmap[0] &= ~FATTR4_WORD0_FSID; | 
| Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3332 | ret = NFS_ATTR_FATTR_FSID; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3333 | } | 
| Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3334 | dprintk("%s: fsid=(0x%Lx/0x%Lx)\n", __func__, | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3335 | (unsigned long long)fsid->major, | 
|  | 3336 | (unsigned long long)fsid->minor); | 
| Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3337 | return ret; | 
| Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3338 | out_overflow: | 
|  | 3339 | print_overflow_msg(__func__, xdr); | 
|  | 3340 | return -EIO; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3341 | } | 
|  | 3342 |  | 
|  | 3343 | static int decode_attr_lease_time(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t *res) | 
|  | 3344 | { | 
| Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3345 | __be32 *p; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3346 |  | 
|  | 3347 | *res = 60; | 
|  | 3348 | if (unlikely(bitmap[0] & (FATTR4_WORD0_LEASE_TIME - 1U))) | 
|  | 3349 | return -EIO; | 
|  | 3350 | if (likely(bitmap[0] & FATTR4_WORD0_LEASE_TIME)) { | 
| Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3351 | p = xdr_inline_decode(xdr, 4); | 
|  | 3352 | if (unlikely(!p)) | 
|  | 3353 | goto out_overflow; | 
| Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3354 | *res = be32_to_cpup(p); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3355 | bitmap[0] &= ~FATTR4_WORD0_LEASE_TIME; | 
|  | 3356 | } | 
| Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3357 | dprintk("%s: file size=%u\n", __func__, (unsigned int)*res); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3358 | return 0; | 
| Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3359 | out_overflow: | 
|  | 3360 | print_overflow_msg(__func__, xdr); | 
|  | 3361 | return -EIO; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3362 | } | 
|  | 3363 |  | 
| Trond Myklebust | ee7b75f | 2011-06-16 13:15:41 -0400 | [diff] [blame] | 3364 | static int decode_attr_error(struct xdr_stream *xdr, uint32_t *bitmap, int32_t *res) | 
| Bryan Schumaker | ae42c70 | 2010-10-21 16:33:17 -0400 | [diff] [blame] | 3365 | { | 
|  | 3366 | __be32 *p; | 
|  | 3367 |  | 
|  | 3368 | if (unlikely(bitmap[0] & (FATTR4_WORD0_RDATTR_ERROR - 1U))) | 
|  | 3369 | return -EIO; | 
|  | 3370 | if (likely(bitmap[0] & FATTR4_WORD0_RDATTR_ERROR)) { | 
|  | 3371 | p = xdr_inline_decode(xdr, 4); | 
|  | 3372 | if (unlikely(!p)) | 
|  | 3373 | goto out_overflow; | 
|  | 3374 | bitmap[0] &= ~FATTR4_WORD0_RDATTR_ERROR; | 
| Trond Myklebust | ee7b75f | 2011-06-16 13:15:41 -0400 | [diff] [blame] | 3375 | *res = -be32_to_cpup(p); | 
| Bryan Schumaker | ae42c70 | 2010-10-21 16:33:17 -0400 | [diff] [blame] | 3376 | } | 
|  | 3377 | return 0; | 
|  | 3378 | out_overflow: | 
|  | 3379 | print_overflow_msg(__func__, xdr); | 
|  | 3380 | return -EIO; | 
|  | 3381 | } | 
|  | 3382 |  | 
| Kinglong Mee | 8c61282 | 2015-08-26 21:12:58 +0800 | [diff] [blame] | 3383 | static int decode_attr_exclcreat_supported(struct xdr_stream *xdr, | 
|  | 3384 | uint32_t *bitmap, uint32_t *bitmask) | 
|  | 3385 | { | 
|  | 3386 | if (likely(bitmap[2] & FATTR4_WORD2_SUPPATTR_EXCLCREAT)) { | 
|  | 3387 | int ret; | 
|  | 3388 | ret = decode_attr_bitmap(xdr, bitmask); | 
|  | 3389 | if (unlikely(ret < 0)) | 
|  | 3390 | return ret; | 
|  | 3391 | bitmap[2] &= ~FATTR4_WORD2_SUPPATTR_EXCLCREAT; | 
|  | 3392 | } else | 
|  | 3393 | bitmask[0] = bitmask[1] = bitmask[2] = 0; | 
|  | 3394 | dprintk("%s: bitmask=%08x:%08x:%08x\n", __func__, | 
|  | 3395 | bitmask[0], bitmask[1], bitmask[2]); | 
|  | 3396 | return 0; | 
|  | 3397 | } | 
|  | 3398 |  | 
| Bryan Schumaker | ae42c70 | 2010-10-21 16:33:17 -0400 | [diff] [blame] | 3399 | static int decode_attr_filehandle(struct xdr_stream *xdr, uint32_t *bitmap, struct nfs_fh *fh) | 
|  | 3400 | { | 
|  | 3401 | __be32 *p; | 
|  | 3402 | int len; | 
|  | 3403 |  | 
| Trond Myklebust | 7ad0735 | 2010-10-23 15:34:20 -0400 | [diff] [blame] | 3404 | if (fh != NULL) | 
|  | 3405 | memset(fh, 0, sizeof(*fh)); | 
| Bryan Schumaker | ae42c70 | 2010-10-21 16:33:17 -0400 | [diff] [blame] | 3406 |  | 
|  | 3407 | if (unlikely(bitmap[0] & (FATTR4_WORD0_FILEHANDLE - 1U))) | 
|  | 3408 | return -EIO; | 
|  | 3409 | if (likely(bitmap[0] & FATTR4_WORD0_FILEHANDLE)) { | 
|  | 3410 | p = xdr_inline_decode(xdr, 4); | 
|  | 3411 | if (unlikely(!p)) | 
|  | 3412 | goto out_overflow; | 
|  | 3413 | len = be32_to_cpup(p); | 
|  | 3414 | if (len > NFS4_FHSIZE) | 
|  | 3415 | return -EIO; | 
| Bryan Schumaker | ae42c70 | 2010-10-21 16:33:17 -0400 | [diff] [blame] | 3416 | p = xdr_inline_decode(xdr, len); | 
|  | 3417 | if (unlikely(!p)) | 
|  | 3418 | goto out_overflow; | 
| Trond Myklebust | 7ad0735 | 2010-10-23 15:34:20 -0400 | [diff] [blame] | 3419 | if (fh != NULL) { | 
|  | 3420 | memcpy(fh->data, p, len); | 
|  | 3421 | fh->size = len; | 
|  | 3422 | } | 
| Bryan Schumaker | ae42c70 | 2010-10-21 16:33:17 -0400 | [diff] [blame] | 3423 | bitmap[0] &= ~FATTR4_WORD0_FILEHANDLE; | 
|  | 3424 | } | 
|  | 3425 | return 0; | 
|  | 3426 | out_overflow: | 
|  | 3427 | print_overflow_msg(__func__, xdr); | 
|  | 3428 | return -EIO; | 
|  | 3429 | } | 
|  | 3430 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3431 | static int decode_attr_aclsupport(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t *res) | 
|  | 3432 | { | 
| Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3433 | __be32 *p; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3434 |  | 
| Malahal Naineni | a1800ac | 2014-01-27 15:31:09 -0600 | [diff] [blame] | 3435 | *res = 0; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3436 | if (unlikely(bitmap[0] & (FATTR4_WORD0_ACLSUPPORT - 1U))) | 
|  | 3437 | return -EIO; | 
|  | 3438 | if (likely(bitmap[0] & FATTR4_WORD0_ACLSUPPORT)) { | 
| Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3439 | p = xdr_inline_decode(xdr, 4); | 
|  | 3440 | if (unlikely(!p)) | 
|  | 3441 | goto out_overflow; | 
| Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3442 | *res = be32_to_cpup(p); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3443 | bitmap[0] &= ~FATTR4_WORD0_ACLSUPPORT; | 
|  | 3444 | } | 
| Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3445 | dprintk("%s: ACLs supported=%u\n", __func__, (unsigned int)*res); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3446 | return 0; | 
| Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3447 | out_overflow: | 
|  | 3448 | print_overflow_msg(__func__, xdr); | 
|  | 3449 | return -EIO; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3450 | } | 
|  | 3451 |  | 
|  | 3452 | static int decode_attr_fileid(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *fileid) | 
|  | 3453 | { | 
| Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3454 | __be32 *p; | 
| Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3455 | int ret = 0; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3456 |  | 
|  | 3457 | *fileid = 0; | 
|  | 3458 | if (unlikely(bitmap[0] & (FATTR4_WORD0_FILEID - 1U))) | 
|  | 3459 | return -EIO; | 
|  | 3460 | if (likely(bitmap[0] & FATTR4_WORD0_FILEID)) { | 
| Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3461 | p = xdr_inline_decode(xdr, 8); | 
|  | 3462 | if (unlikely(!p)) | 
|  | 3463 | goto out_overflow; | 
| Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3464 | xdr_decode_hyper(p, fileid); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3465 | bitmap[0] &= ~FATTR4_WORD0_FILEID; | 
| Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3466 | ret = NFS_ATTR_FATTR_FILEID; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3467 | } | 
| Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3468 | dprintk("%s: fileid=%Lu\n", __func__, (unsigned long long)*fileid); | 
| Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3469 | return ret; | 
| Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3470 | out_overflow: | 
|  | 3471 | print_overflow_msg(__func__, xdr); | 
|  | 3472 | return -EIO; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3473 | } | 
|  | 3474 |  | 
| Manoj Naik | 99baf62 | 2006-06-09 09:34:24 -0400 | [diff] [blame] | 3475 | static int decode_attr_mounted_on_fileid(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *fileid) | 
|  | 3476 | { | 
| Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3477 | __be32 *p; | 
| Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3478 | int ret = 0; | 
| Manoj Naik | 99baf62 | 2006-06-09 09:34:24 -0400 | [diff] [blame] | 3479 |  | 
|  | 3480 | *fileid = 0; | 
|  | 3481 | if (unlikely(bitmap[1] & (FATTR4_WORD1_MOUNTED_ON_FILEID - 1U))) | 
|  | 3482 | return -EIO; | 
|  | 3483 | if (likely(bitmap[1] & FATTR4_WORD1_MOUNTED_ON_FILEID)) { | 
| Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3484 | p = xdr_inline_decode(xdr, 8); | 
|  | 3485 | if (unlikely(!p)) | 
|  | 3486 | goto out_overflow; | 
| Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3487 | xdr_decode_hyper(p, fileid); | 
| Manoj Naik | 99baf62 | 2006-06-09 09:34:24 -0400 | [diff] [blame] | 3488 | bitmap[1] &= ~FATTR4_WORD1_MOUNTED_ON_FILEID; | 
| Trond Myklebust | 28331a4 | 2011-04-27 13:47:52 -0400 | [diff] [blame] | 3489 | ret = NFS_ATTR_FATTR_MOUNTED_ON_FILEID; | 
| Manoj Naik | 99baf62 | 2006-06-09 09:34:24 -0400 | [diff] [blame] | 3490 | } | 
| Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3491 | dprintk("%s: fileid=%Lu\n", __func__, (unsigned long long)*fileid); | 
| Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3492 | return ret; | 
| Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3493 | out_overflow: | 
|  | 3494 | print_overflow_msg(__func__, xdr); | 
|  | 3495 | return -EIO; | 
| Manoj Naik | 99baf62 | 2006-06-09 09:34:24 -0400 | [diff] [blame] | 3496 | } | 
|  | 3497 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3498 | static int decode_attr_files_avail(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *res) | 
|  | 3499 | { | 
| Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3500 | __be32 *p; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3501 | int status = 0; | 
|  | 3502 |  | 
|  | 3503 | *res = 0; | 
|  | 3504 | if (unlikely(bitmap[0] & (FATTR4_WORD0_FILES_AVAIL - 1U))) | 
|  | 3505 | return -EIO; | 
|  | 3506 | if (likely(bitmap[0] & FATTR4_WORD0_FILES_AVAIL)) { | 
| Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3507 | p = xdr_inline_decode(xdr, 8); | 
|  | 3508 | if (unlikely(!p)) | 
|  | 3509 | goto out_overflow; | 
| Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3510 | xdr_decode_hyper(p, res); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3511 | bitmap[0] &= ~FATTR4_WORD0_FILES_AVAIL; | 
|  | 3512 | } | 
| Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3513 | dprintk("%s: files avail=%Lu\n", __func__, (unsigned long long)*res); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3514 | return status; | 
| Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3515 | out_overflow: | 
|  | 3516 | print_overflow_msg(__func__, xdr); | 
|  | 3517 | return -EIO; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3518 | } | 
|  | 3519 |  | 
|  | 3520 | static int decode_attr_files_free(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *res) | 
|  | 3521 | { | 
| Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3522 | __be32 *p; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3523 | int status = 0; | 
|  | 3524 |  | 
|  | 3525 | *res = 0; | 
|  | 3526 | if (unlikely(bitmap[0] & (FATTR4_WORD0_FILES_FREE - 1U))) | 
|  | 3527 | return -EIO; | 
|  | 3528 | if (likely(bitmap[0] & FATTR4_WORD0_FILES_FREE)) { | 
| Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3529 | p = xdr_inline_decode(xdr, 8); | 
|  | 3530 | if (unlikely(!p)) | 
|  | 3531 | goto out_overflow; | 
| Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3532 | xdr_decode_hyper(p, res); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3533 | bitmap[0] &= ~FATTR4_WORD0_FILES_FREE; | 
|  | 3534 | } | 
| Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3535 | dprintk("%s: files free=%Lu\n", __func__, (unsigned long long)*res); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3536 | return status; | 
| Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3537 | out_overflow: | 
|  | 3538 | print_overflow_msg(__func__, xdr); | 
|  | 3539 | return -EIO; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3540 | } | 
|  | 3541 |  | 
|  | 3542 | static int decode_attr_files_total(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *res) | 
|  | 3543 | { | 
| Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3544 | __be32 *p; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3545 | int status = 0; | 
|  | 3546 |  | 
|  | 3547 | *res = 0; | 
|  | 3548 | if (unlikely(bitmap[0] & (FATTR4_WORD0_FILES_TOTAL - 1U))) | 
|  | 3549 | return -EIO; | 
|  | 3550 | if (likely(bitmap[0] & FATTR4_WORD0_FILES_TOTAL)) { | 
| Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3551 | p = xdr_inline_decode(xdr, 8); | 
|  | 3552 | if (unlikely(!p)) | 
|  | 3553 | goto out_overflow; | 
| Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3554 | xdr_decode_hyper(p, res); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3555 | bitmap[0] &= ~FATTR4_WORD0_FILES_TOTAL; | 
|  | 3556 | } | 
| Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3557 | dprintk("%s: files total=%Lu\n", __func__, (unsigned long long)*res); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3558 | return status; | 
| Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3559 | out_overflow: | 
|  | 3560 | print_overflow_msg(__func__, xdr); | 
|  | 3561 | return -EIO; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3562 | } | 
|  | 3563 |  | 
| Manoj Naik | 7aaa0b3 | 2006-06-09 09:34:23 -0400 | [diff] [blame] | 3564 | static int decode_pathname(struct xdr_stream *xdr, struct nfs4_pathname *path) | 
|  | 3565 | { | 
| Chuck Lever | 464ad6b | 2007-10-26 13:32:08 -0400 | [diff] [blame] | 3566 | u32 n; | 
| Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3567 | __be32 *p; | 
| Manoj Naik | 7aaa0b3 | 2006-06-09 09:34:23 -0400 | [diff] [blame] | 3568 | int status = 0; | 
|  | 3569 |  | 
| Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3570 | p = xdr_inline_decode(xdr, 4); | 
|  | 3571 | if (unlikely(!p)) | 
|  | 3572 | goto out_overflow; | 
| Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3573 | n = be32_to_cpup(p); | 
| Andy Adamson | 33a43f2 | 2006-06-09 09:34:30 -0400 | [diff] [blame] | 3574 | if (n == 0) | 
|  | 3575 | goto root_path; | 
| Chuck Lever | 02a2976 | 2012-03-01 17:00:31 -0500 | [diff] [blame] | 3576 | dprintk("pathname4: "); | 
| Trond Myklebust | 809b426 | 2013-03-27 11:54:45 -0400 | [diff] [blame] | 3577 | if (n > NFS4_PATHNAME_MAXCOMPONENTS) { | 
|  | 3578 | dprintk("cannot parse %d components in path\n", n); | 
|  | 3579 | goto out_eio; | 
|  | 3580 | } | 
|  | 3581 | for (path->ncomponents = 0; path->ncomponents < n; path->ncomponents++) { | 
| Manoj Naik | 7aaa0b3 | 2006-06-09 09:34:23 -0400 | [diff] [blame] | 3582 | struct nfs4_string *component = &path->components[path->ncomponents]; | 
|  | 3583 | status = decode_opaque_inline(xdr, &component->len, &component->data); | 
|  | 3584 | if (unlikely(status != 0)) | 
|  | 3585 | goto out_eio; | 
| Trond Myklebust | 95a13f7 | 2012-03-14 21:55:01 -0400 | [diff] [blame] | 3586 | ifdebug (XDR) | 
| Chuck Lever | 02a2976 | 2012-03-01 17:00:31 -0500 | [diff] [blame] | 3587 | pr_cont("%s%.*s ", | 
|  | 3588 | (path->ncomponents != n ? "/ " : ""), | 
|  | 3589 | component->len, component->data); | 
| Manoj Naik | 7aaa0b3 | 2006-06-09 09:34:23 -0400 | [diff] [blame] | 3590 | } | 
|  | 3591 | out: | 
| Manoj Naik | 7aaa0b3 | 2006-06-09 09:34:23 -0400 | [diff] [blame] | 3592 | return status; | 
| Andy Adamson | 33a43f2 | 2006-06-09 09:34:30 -0400 | [diff] [blame] | 3593 | root_path: | 
|  | 3594 | /* a root pathname is sent as a zero component4 */ | 
|  | 3595 | path->ncomponents = 1; | 
|  | 3596 | path->components[0].len=0; | 
|  | 3597 | path->components[0].data=NULL; | 
| Chuck Lever | 02a2976 | 2012-03-01 17:00:31 -0500 | [diff] [blame] | 3598 | dprintk("pathname4: /\n"); | 
| Andy Adamson | 33a43f2 | 2006-06-09 09:34:30 -0400 | [diff] [blame] | 3599 | goto out; | 
| Manoj Naik | 7aaa0b3 | 2006-06-09 09:34:23 -0400 | [diff] [blame] | 3600 | out_eio: | 
|  | 3601 | dprintk(" status %d", status); | 
|  | 3602 | status = -EIO; | 
|  | 3603 | goto out; | 
| Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3604 | out_overflow: | 
|  | 3605 | print_overflow_msg(__func__, xdr); | 
|  | 3606 | return -EIO; | 
| Manoj Naik | 7aaa0b3 | 2006-06-09 09:34:23 -0400 | [diff] [blame] | 3607 | } | 
|  | 3608 |  | 
|  | 3609 | static int decode_attr_fs_locations(struct xdr_stream *xdr, uint32_t *bitmap, struct nfs4_fs_locations *res) | 
| Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 3610 | { | 
|  | 3611 | int n; | 
| Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3612 | __be32 *p; | 
| Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 3613 | int status = -EIO; | 
|  | 3614 |  | 
|  | 3615 | if (unlikely(bitmap[0] & (FATTR4_WORD0_FS_LOCATIONS -1U))) | 
|  | 3616 | goto out; | 
|  | 3617 | status = 0; | 
|  | 3618 | if (unlikely(!(bitmap[0] & FATTR4_WORD0_FS_LOCATIONS))) | 
|  | 3619 | goto out; | 
| Kinglong Mee | f54423a | 2015-11-18 10:39:26 +0800 | [diff] [blame] | 3620 | bitmap[0] &= ~FATTR4_WORD0_FS_LOCATIONS; | 
| Trond Myklebust | 8b7e3f4 | 2012-01-30 15:43:56 -0500 | [diff] [blame] | 3621 | status = -EIO; | 
|  | 3622 | /* Ignore borken servers that return unrequested attrs */ | 
|  | 3623 | if (unlikely(res == NULL)) | 
|  | 3624 | goto out; | 
| Chuck Lever | 02a2976 | 2012-03-01 17:00:31 -0500 | [diff] [blame] | 3625 | dprintk("%s: fsroot:\n", __func__); | 
| Manoj Naik | 7aaa0b3 | 2006-06-09 09:34:23 -0400 | [diff] [blame] | 3626 | status = decode_pathname(xdr, &res->fs_path); | 
| Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 3627 | if (unlikely(status != 0)) | 
|  | 3628 | goto out; | 
| Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3629 | p = xdr_inline_decode(xdr, 4); | 
|  | 3630 | if (unlikely(!p)) | 
|  | 3631 | goto out_overflow; | 
| Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3632 | n = be32_to_cpup(p); | 
| Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 3633 | if (n <= 0) | 
|  | 3634 | goto out_eio; | 
| Trond Myklebust | 809b426 | 2013-03-27 11:54:45 -0400 | [diff] [blame] | 3635 | for (res->nlocations = 0; res->nlocations < n; res->nlocations++) { | 
| Chuck Lever | 464ad6b | 2007-10-26 13:32:08 -0400 | [diff] [blame] | 3636 | u32 m; | 
| Trond Myklebust | 809b426 | 2013-03-27 11:54:45 -0400 | [diff] [blame] | 3637 | struct nfs4_fs_location *loc; | 
| Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 3638 |  | 
| Trond Myklebust | 809b426 | 2013-03-27 11:54:45 -0400 | [diff] [blame] | 3639 | if (res->nlocations == NFS4_FS_LOCATIONS_MAXENTRIES) | 
|  | 3640 | break; | 
|  | 3641 | loc = &res->locations[res->nlocations]; | 
| Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3642 | p = xdr_inline_decode(xdr, 4); | 
|  | 3643 | if (unlikely(!p)) | 
|  | 3644 | goto out_overflow; | 
| Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3645 | m = be32_to_cpup(p); | 
| Manoj Naik | 7aaa0b3 | 2006-06-09 09:34:23 -0400 | [diff] [blame] | 3646 |  | 
| Chuck Lever | 02a2976 | 2012-03-01 17:00:31 -0500 | [diff] [blame] | 3647 | dprintk("%s: servers:\n", __func__); | 
| Trond Myklebust | 809b426 | 2013-03-27 11:54:45 -0400 | [diff] [blame] | 3648 | for (loc->nservers = 0; loc->nservers < m; loc->nservers++) { | 
|  | 3649 | struct nfs4_string *server; | 
|  | 3650 |  | 
|  | 3651 | if (loc->nservers == NFS4_FS_LOCATION_MAXSERVERS) { | 
| Chuck Lever | 464ad6b | 2007-10-26 13:32:08 -0400 | [diff] [blame] | 3652 | unsigned int i; | 
|  | 3653 | dprintk("%s: using first %u of %u servers " | 
|  | 3654 | "returned for location %u\n", | 
| Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3655 | __func__, | 
| Chuck Lever | 464ad6b | 2007-10-26 13:32:08 -0400 | [diff] [blame] | 3656 | NFS4_FS_LOCATION_MAXSERVERS, | 
|  | 3657 | m, res->nlocations); | 
| Manoj Naik | 7aaa0b3 | 2006-06-09 09:34:23 -0400 | [diff] [blame] | 3658 | for (i = loc->nservers; i < m; i++) { | 
| Trond Myklebust | 2e42c3e | 2007-05-14 17:20:41 -0400 | [diff] [blame] | 3659 | unsigned int len; | 
| Manoj Naik | 7aaa0b3 | 2006-06-09 09:34:23 -0400 | [diff] [blame] | 3660 | char *data; | 
|  | 3661 | status = decode_opaque_inline(xdr, &len, &data); | 
|  | 3662 | if (unlikely(status != 0)) | 
|  | 3663 | goto out_eio; | 
|  | 3664 | } | 
| Trond Myklebust | 809b426 | 2013-03-27 11:54:45 -0400 | [diff] [blame] | 3665 | break; | 
| Manoj Naik | 7aaa0b3 | 2006-06-09 09:34:23 -0400 | [diff] [blame] | 3666 | } | 
| Trond Myklebust | 809b426 | 2013-03-27 11:54:45 -0400 | [diff] [blame] | 3667 | server = &loc->servers[loc->nservers]; | 
|  | 3668 | status = decode_opaque_inline(xdr, &server->len, &server->data); | 
|  | 3669 | if (unlikely(status != 0)) | 
|  | 3670 | goto out_eio; | 
|  | 3671 | dprintk("%s ", server->data); | 
| Manoj Naik | 7aaa0b3 | 2006-06-09 09:34:23 -0400 | [diff] [blame] | 3672 | } | 
|  | 3673 | status = decode_pathname(xdr, &loc->rootpath); | 
| Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 3674 | if (unlikely(status != 0)) | 
|  | 3675 | goto out_eio; | 
| Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 3676 | } | 
| Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3677 | if (res->nlocations != 0) | 
| Chuck Lever | 81934dd | 2012-03-01 17:01:57 -0500 | [diff] [blame] | 3678 | status = NFS_ATTR_FATTR_V4_LOCATIONS; | 
| Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 3679 | out: | 
| Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3680 | dprintk("%s: fs_locations done, error = %d\n", __func__, status); | 
| Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 3681 | return status; | 
| Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3682 | out_overflow: | 
|  | 3683 | print_overflow_msg(__func__, xdr); | 
| Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 3684 | out_eio: | 
|  | 3685 | status = -EIO; | 
|  | 3686 | goto out; | 
|  | 3687 | } | 
|  | 3688 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3689 | static int decode_attr_maxfilesize(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *res) | 
|  | 3690 | { | 
| Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3691 | __be32 *p; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3692 | int status = 0; | 
|  | 3693 |  | 
|  | 3694 | *res = 0; | 
|  | 3695 | if (unlikely(bitmap[0] & (FATTR4_WORD0_MAXFILESIZE - 1U))) | 
|  | 3696 | return -EIO; | 
|  | 3697 | if (likely(bitmap[0] & FATTR4_WORD0_MAXFILESIZE)) { | 
| Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3698 | p = xdr_inline_decode(xdr, 8); | 
|  | 3699 | if (unlikely(!p)) | 
|  | 3700 | goto out_overflow; | 
| Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3701 | xdr_decode_hyper(p, res); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3702 | bitmap[0] &= ~FATTR4_WORD0_MAXFILESIZE; | 
|  | 3703 | } | 
| Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3704 | dprintk("%s: maxfilesize=%Lu\n", __func__, (unsigned long long)*res); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3705 | return status; | 
| Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3706 | out_overflow: | 
|  | 3707 | print_overflow_msg(__func__, xdr); | 
|  | 3708 | return -EIO; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3709 | } | 
|  | 3710 |  | 
|  | 3711 | static int decode_attr_maxlink(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t *maxlink) | 
|  | 3712 | { | 
| Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3713 | __be32 *p; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3714 | int status = 0; | 
|  | 3715 |  | 
|  | 3716 | *maxlink = 1; | 
|  | 3717 | if (unlikely(bitmap[0] & (FATTR4_WORD0_MAXLINK - 1U))) | 
|  | 3718 | return -EIO; | 
|  | 3719 | if (likely(bitmap[0] & FATTR4_WORD0_MAXLINK)) { | 
| Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3720 | p = xdr_inline_decode(xdr, 4); | 
|  | 3721 | if (unlikely(!p)) | 
|  | 3722 | goto out_overflow; | 
| Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3723 | *maxlink = be32_to_cpup(p); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3724 | bitmap[0] &= ~FATTR4_WORD0_MAXLINK; | 
|  | 3725 | } | 
| Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3726 | dprintk("%s: maxlink=%u\n", __func__, *maxlink); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3727 | return status; | 
| Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3728 | out_overflow: | 
|  | 3729 | print_overflow_msg(__func__, xdr); | 
|  | 3730 | return -EIO; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3731 | } | 
|  | 3732 |  | 
|  | 3733 | static int decode_attr_maxname(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t *maxname) | 
|  | 3734 | { | 
| Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3735 | __be32 *p; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3736 | int status = 0; | 
|  | 3737 |  | 
|  | 3738 | *maxname = 1024; | 
|  | 3739 | if (unlikely(bitmap[0] & (FATTR4_WORD0_MAXNAME - 1U))) | 
|  | 3740 | return -EIO; | 
|  | 3741 | if (likely(bitmap[0] & FATTR4_WORD0_MAXNAME)) { | 
| Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3742 | p = xdr_inline_decode(xdr, 4); | 
|  | 3743 | if (unlikely(!p)) | 
|  | 3744 | goto out_overflow; | 
| Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3745 | *maxname = be32_to_cpup(p); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3746 | bitmap[0] &= ~FATTR4_WORD0_MAXNAME; | 
|  | 3747 | } | 
| Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3748 | dprintk("%s: maxname=%u\n", __func__, *maxname); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3749 | return status; | 
| Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3750 | out_overflow: | 
|  | 3751 | print_overflow_msg(__func__, xdr); | 
|  | 3752 | return -EIO; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3753 | } | 
|  | 3754 |  | 
|  | 3755 | static int decode_attr_maxread(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t *res) | 
|  | 3756 | { | 
| Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3757 | __be32 *p; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3758 | int status = 0; | 
|  | 3759 |  | 
|  | 3760 | *res = 1024; | 
|  | 3761 | if (unlikely(bitmap[0] & (FATTR4_WORD0_MAXREAD - 1U))) | 
|  | 3762 | return -EIO; | 
|  | 3763 | if (likely(bitmap[0] & FATTR4_WORD0_MAXREAD)) { | 
|  | 3764 | uint64_t maxread; | 
| Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3765 | p = xdr_inline_decode(xdr, 8); | 
|  | 3766 | if (unlikely(!p)) | 
|  | 3767 | goto out_overflow; | 
| Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3768 | xdr_decode_hyper(p, &maxread); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3769 | if (maxread > 0x7FFFFFFF) | 
|  | 3770 | maxread = 0x7FFFFFFF; | 
|  | 3771 | *res = (uint32_t)maxread; | 
|  | 3772 | bitmap[0] &= ~FATTR4_WORD0_MAXREAD; | 
|  | 3773 | } | 
| Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3774 | dprintk("%s: maxread=%lu\n", __func__, (unsigned long)*res); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3775 | return status; | 
| Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3776 | out_overflow: | 
|  | 3777 | print_overflow_msg(__func__, xdr); | 
|  | 3778 | return -EIO; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3779 | } | 
|  | 3780 |  | 
|  | 3781 | static int decode_attr_maxwrite(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t *res) | 
|  | 3782 | { | 
| Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3783 | __be32 *p; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3784 | int status = 0; | 
|  | 3785 |  | 
|  | 3786 | *res = 1024; | 
|  | 3787 | if (unlikely(bitmap[0] & (FATTR4_WORD0_MAXWRITE - 1U))) | 
|  | 3788 | return -EIO; | 
|  | 3789 | if (likely(bitmap[0] & FATTR4_WORD0_MAXWRITE)) { | 
|  | 3790 | uint64_t maxwrite; | 
| Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3791 | p = xdr_inline_decode(xdr, 8); | 
|  | 3792 | if (unlikely(!p)) | 
|  | 3793 | goto out_overflow; | 
| Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3794 | xdr_decode_hyper(p, &maxwrite); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3795 | if (maxwrite > 0x7FFFFFFF) | 
|  | 3796 | maxwrite = 0x7FFFFFFF; | 
|  | 3797 | *res = (uint32_t)maxwrite; | 
|  | 3798 | bitmap[0] &= ~FATTR4_WORD0_MAXWRITE; | 
|  | 3799 | } | 
| Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3800 | dprintk("%s: maxwrite=%lu\n", __func__, (unsigned long)*res); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3801 | return status; | 
| Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3802 | out_overflow: | 
|  | 3803 | print_overflow_msg(__func__, xdr); | 
|  | 3804 | return -EIO; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3805 | } | 
|  | 3806 |  | 
| Trond Myklebust | bca7947 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 3807 | static int decode_attr_mode(struct xdr_stream *xdr, uint32_t *bitmap, umode_t *mode) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3808 | { | 
| Trond Myklebust | bca7947 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 3809 | uint32_t tmp; | 
| Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3810 | __be32 *p; | 
| Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3811 | int ret = 0; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3812 |  | 
|  | 3813 | *mode = 0; | 
|  | 3814 | if (unlikely(bitmap[1] & (FATTR4_WORD1_MODE - 1U))) | 
|  | 3815 | return -EIO; | 
|  | 3816 | if (likely(bitmap[1] & FATTR4_WORD1_MODE)) { | 
| Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3817 | p = xdr_inline_decode(xdr, 4); | 
|  | 3818 | if (unlikely(!p)) | 
|  | 3819 | goto out_overflow; | 
| Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3820 | tmp = be32_to_cpup(p); | 
| Trond Myklebust | bca7947 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 3821 | *mode = tmp & ~S_IFMT; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3822 | bitmap[1] &= ~FATTR4_WORD1_MODE; | 
| Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3823 | ret = NFS_ATTR_FATTR_MODE; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3824 | } | 
| Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3825 | dprintk("%s: file mode=0%o\n", __func__, (unsigned int)*mode); | 
| Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3826 | return ret; | 
| Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3827 | out_overflow: | 
|  | 3828 | print_overflow_msg(__func__, xdr); | 
|  | 3829 | return -EIO; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3830 | } | 
|  | 3831 |  | 
|  | 3832 | static int decode_attr_nlink(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t *nlink) | 
|  | 3833 | { | 
| Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3834 | __be32 *p; | 
| Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3835 | int ret = 0; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3836 |  | 
|  | 3837 | *nlink = 1; | 
|  | 3838 | if (unlikely(bitmap[1] & (FATTR4_WORD1_NUMLINKS - 1U))) | 
|  | 3839 | return -EIO; | 
|  | 3840 | if (likely(bitmap[1] & FATTR4_WORD1_NUMLINKS)) { | 
| Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3841 | p = xdr_inline_decode(xdr, 4); | 
|  | 3842 | if (unlikely(!p)) | 
|  | 3843 | goto out_overflow; | 
| Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3844 | *nlink = be32_to_cpup(p); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3845 | bitmap[1] &= ~FATTR4_WORD1_NUMLINKS; | 
| Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3846 | ret = NFS_ATTR_FATTR_NLINK; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3847 | } | 
| Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3848 | dprintk("%s: nlink=%u\n", __func__, (unsigned int)*nlink); | 
| Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3849 | return ret; | 
| Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3850 | out_overflow: | 
|  | 3851 | print_overflow_msg(__func__, xdr); | 
|  | 3852 | return -EIO; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3853 | } | 
|  | 3854 |  | 
| Trond Myklebust | 80e52ac | 2009-08-09 15:06:19 -0400 | [diff] [blame] | 3855 | static int decode_attr_owner(struct xdr_stream *xdr, uint32_t *bitmap, | 
| Eric W. Biederman | e578207 | 2013-02-01 14:22:02 -0800 | [diff] [blame] | 3856 | const struct nfs_server *server, kuid_t *uid, | 
| Trond Myklebust | 6926afd | 2012-01-07 13:22:46 -0500 | [diff] [blame] | 3857 | struct nfs4_string *owner_name) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3858 | { | 
| Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3859 | uint32_t len; | 
|  | 3860 | __be32 *p; | 
| Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3861 | int ret = 0; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3862 |  | 
| Eric W. Biederman | e578207 | 2013-02-01 14:22:02 -0800 | [diff] [blame] | 3863 | *uid = make_kuid(&init_user_ns, -2); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3864 | if (unlikely(bitmap[1] & (FATTR4_WORD1_OWNER - 1U))) | 
|  | 3865 | return -EIO; | 
|  | 3866 | if (likely(bitmap[1] & FATTR4_WORD1_OWNER)) { | 
| Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3867 | p = xdr_inline_decode(xdr, 4); | 
|  | 3868 | if (unlikely(!p)) | 
|  | 3869 | goto out_overflow; | 
| Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3870 | len = be32_to_cpup(p); | 
| Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3871 | p = xdr_inline_decode(xdr, len); | 
|  | 3872 | if (unlikely(!p)) | 
|  | 3873 | goto out_overflow; | 
| Trond Myklebust | 6926afd | 2012-01-07 13:22:46 -0500 | [diff] [blame] | 3874 | if (owner_name != NULL) { | 
|  | 3875 | owner_name->data = kmemdup(p, len, GFP_NOWAIT); | 
|  | 3876 | if (owner_name->data != NULL) { | 
|  | 3877 | owner_name->len = len; | 
|  | 3878 | ret = NFS_ATTR_FATTR_OWNER_NAME; | 
|  | 3879 | } | 
| Trond Myklebust | 80e52ac | 2009-08-09 15:06:19 -0400 | [diff] [blame] | 3880 | } else if (len < XDR_MAX_NETOBJ) { | 
| Trond Myklebust | e4fd72a | 2011-02-22 15:44:31 -0800 | [diff] [blame] | 3881 | if (nfs_map_name_to_uid(server, (char *)p, len, uid) == 0) | 
| Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3882 | ret = NFS_ATTR_FATTR_OWNER; | 
|  | 3883 | else | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3884 | dprintk("%s: nfs_map_name_to_uid failed!\n", | 
| Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3885 | __func__); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3886 | } else | 
| Chuck Lever | fe82a18 | 2007-09-11 18:01:10 -0400 | [diff] [blame] | 3887 | dprintk("%s: name too long (%u)!\n", | 
| Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3888 | __func__, len); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3889 | bitmap[1] &= ~FATTR4_WORD1_OWNER; | 
|  | 3890 | } | 
| Eric W. Biederman | e578207 | 2013-02-01 14:22:02 -0800 | [diff] [blame] | 3891 | dprintk("%s: uid=%d\n", __func__, (int)from_kuid(&init_user_ns, *uid)); | 
| Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3892 | return ret; | 
| Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3893 | out_overflow: | 
|  | 3894 | print_overflow_msg(__func__, xdr); | 
|  | 3895 | return -EIO; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3896 | } | 
|  | 3897 |  | 
| Trond Myklebust | 80e52ac | 2009-08-09 15:06:19 -0400 | [diff] [blame] | 3898 | static int decode_attr_group(struct xdr_stream *xdr, uint32_t *bitmap, | 
| Eric W. Biederman | e578207 | 2013-02-01 14:22:02 -0800 | [diff] [blame] | 3899 | const struct nfs_server *server, kgid_t *gid, | 
| Trond Myklebust | 6926afd | 2012-01-07 13:22:46 -0500 | [diff] [blame] | 3900 | struct nfs4_string *group_name) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3901 | { | 
| Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3902 | uint32_t len; | 
|  | 3903 | __be32 *p; | 
| Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3904 | int ret = 0; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3905 |  | 
| Eric W. Biederman | e578207 | 2013-02-01 14:22:02 -0800 | [diff] [blame] | 3906 | *gid = make_kgid(&init_user_ns, -2); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3907 | if (unlikely(bitmap[1] & (FATTR4_WORD1_OWNER_GROUP - 1U))) | 
|  | 3908 | return -EIO; | 
|  | 3909 | if (likely(bitmap[1] & FATTR4_WORD1_OWNER_GROUP)) { | 
| Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3910 | p = xdr_inline_decode(xdr, 4); | 
|  | 3911 | if (unlikely(!p)) | 
|  | 3912 | goto out_overflow; | 
| Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3913 | len = be32_to_cpup(p); | 
| Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3914 | p = xdr_inline_decode(xdr, len); | 
|  | 3915 | if (unlikely(!p)) | 
|  | 3916 | goto out_overflow; | 
| Trond Myklebust | 6926afd | 2012-01-07 13:22:46 -0500 | [diff] [blame] | 3917 | if (group_name != NULL) { | 
|  | 3918 | group_name->data = kmemdup(p, len, GFP_NOWAIT); | 
|  | 3919 | if (group_name->data != NULL) { | 
|  | 3920 | group_name->len = len; | 
|  | 3921 | ret = NFS_ATTR_FATTR_GROUP_NAME; | 
|  | 3922 | } | 
| Trond Myklebust | 80e52ac | 2009-08-09 15:06:19 -0400 | [diff] [blame] | 3923 | } else if (len < XDR_MAX_NETOBJ) { | 
| Trond Myklebust | e4fd72a | 2011-02-22 15:44:31 -0800 | [diff] [blame] | 3924 | if (nfs_map_group_to_gid(server, (char *)p, len, gid) == 0) | 
| Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3925 | ret = NFS_ATTR_FATTR_GROUP; | 
|  | 3926 | else | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3927 | dprintk("%s: nfs_map_group_to_gid failed!\n", | 
| Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3928 | __func__); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3929 | } else | 
| Chuck Lever | fe82a18 | 2007-09-11 18:01:10 -0400 | [diff] [blame] | 3930 | dprintk("%s: name too long (%u)!\n", | 
| Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3931 | __func__, len); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3932 | bitmap[1] &= ~FATTR4_WORD1_OWNER_GROUP; | 
|  | 3933 | } | 
| Eric W. Biederman | e578207 | 2013-02-01 14:22:02 -0800 | [diff] [blame] | 3934 | dprintk("%s: gid=%d\n", __func__, (int)from_kgid(&init_user_ns, *gid)); | 
| Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3935 | return ret; | 
| Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3936 | out_overflow: | 
|  | 3937 | print_overflow_msg(__func__, xdr); | 
|  | 3938 | return -EIO; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3939 | } | 
|  | 3940 |  | 
|  | 3941 | static int decode_attr_rdev(struct xdr_stream *xdr, uint32_t *bitmap, dev_t *rdev) | 
|  | 3942 | { | 
| Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3943 | uint32_t major = 0, minor = 0; | 
|  | 3944 | __be32 *p; | 
| Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3945 | int ret = 0; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3946 |  | 
|  | 3947 | *rdev = MKDEV(0,0); | 
|  | 3948 | if (unlikely(bitmap[1] & (FATTR4_WORD1_RAWDEV - 1U))) | 
|  | 3949 | return -EIO; | 
|  | 3950 | if (likely(bitmap[1] & FATTR4_WORD1_RAWDEV)) { | 
|  | 3951 | dev_t tmp; | 
|  | 3952 |  | 
| Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3953 | p = xdr_inline_decode(xdr, 8); | 
|  | 3954 | if (unlikely(!p)) | 
|  | 3955 | goto out_overflow; | 
| Benny Halevy | 6f723f7 | 2009-08-14 17:19:37 +0300 | [diff] [blame] | 3956 | major = be32_to_cpup(p++); | 
| Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3957 | minor = be32_to_cpup(p); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3958 | tmp = MKDEV(major, minor); | 
|  | 3959 | if (MAJOR(tmp) == major && MINOR(tmp) == minor) | 
|  | 3960 | *rdev = tmp; | 
|  | 3961 | bitmap[1] &= ~ FATTR4_WORD1_RAWDEV; | 
| Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3962 | ret = NFS_ATTR_FATTR_RDEV; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3963 | } | 
| Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3964 | dprintk("%s: rdev=(0x%x:0x%x)\n", __func__, major, minor); | 
| Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3965 | return ret; | 
| Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3966 | out_overflow: | 
|  | 3967 | print_overflow_msg(__func__, xdr); | 
|  | 3968 | return -EIO; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3969 | } | 
|  | 3970 |  | 
|  | 3971 | static int decode_attr_space_avail(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *res) | 
|  | 3972 | { | 
| Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3973 | __be32 *p; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3974 | int status = 0; | 
|  | 3975 |  | 
|  | 3976 | *res = 0; | 
|  | 3977 | if (unlikely(bitmap[1] & (FATTR4_WORD1_SPACE_AVAIL - 1U))) | 
|  | 3978 | return -EIO; | 
|  | 3979 | if (likely(bitmap[1] & FATTR4_WORD1_SPACE_AVAIL)) { | 
| Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3980 | p = xdr_inline_decode(xdr, 8); | 
|  | 3981 | if (unlikely(!p)) | 
|  | 3982 | goto out_overflow; | 
| Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3983 | xdr_decode_hyper(p, res); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3984 | bitmap[1] &= ~FATTR4_WORD1_SPACE_AVAIL; | 
|  | 3985 | } | 
| Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3986 | dprintk("%s: space avail=%Lu\n", __func__, (unsigned long long)*res); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3987 | return status; | 
| Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3988 | out_overflow: | 
|  | 3989 | print_overflow_msg(__func__, xdr); | 
|  | 3990 | return -EIO; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3991 | } | 
|  | 3992 |  | 
|  | 3993 | static int decode_attr_space_free(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *res) | 
|  | 3994 | { | 
| Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3995 | __be32 *p; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3996 | int status = 0; | 
|  | 3997 |  | 
|  | 3998 | *res = 0; | 
|  | 3999 | if (unlikely(bitmap[1] & (FATTR4_WORD1_SPACE_FREE - 1U))) | 
|  | 4000 | return -EIO; | 
|  | 4001 | if (likely(bitmap[1] & FATTR4_WORD1_SPACE_FREE)) { | 
| Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 4002 | p = xdr_inline_decode(xdr, 8); | 
|  | 4003 | if (unlikely(!p)) | 
|  | 4004 | goto out_overflow; | 
| Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 4005 | xdr_decode_hyper(p, res); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4006 | bitmap[1] &= ~FATTR4_WORD1_SPACE_FREE; | 
|  | 4007 | } | 
| Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 4008 | dprintk("%s: space free=%Lu\n", __func__, (unsigned long long)*res); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4009 | return status; | 
| Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 4010 | out_overflow: | 
|  | 4011 | print_overflow_msg(__func__, xdr); | 
|  | 4012 | return -EIO; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4013 | } | 
|  | 4014 |  | 
|  | 4015 | static int decode_attr_space_total(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *res) | 
|  | 4016 | { | 
| Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 4017 | __be32 *p; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4018 | int status = 0; | 
|  | 4019 |  | 
|  | 4020 | *res = 0; | 
|  | 4021 | if (unlikely(bitmap[1] & (FATTR4_WORD1_SPACE_TOTAL - 1U))) | 
|  | 4022 | return -EIO; | 
|  | 4023 | if (likely(bitmap[1] & FATTR4_WORD1_SPACE_TOTAL)) { | 
| Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 4024 | p = xdr_inline_decode(xdr, 8); | 
|  | 4025 | if (unlikely(!p)) | 
|  | 4026 | goto out_overflow; | 
| Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 4027 | xdr_decode_hyper(p, res); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4028 | bitmap[1] &= ~FATTR4_WORD1_SPACE_TOTAL; | 
|  | 4029 | } | 
| Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 4030 | dprintk("%s: space total=%Lu\n", __func__, (unsigned long long)*res); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4031 | return status; | 
| Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 4032 | out_overflow: | 
|  | 4033 | print_overflow_msg(__func__, xdr); | 
|  | 4034 | return -EIO; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4035 | } | 
|  | 4036 |  | 
|  | 4037 | static int decode_attr_space_used(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *used) | 
|  | 4038 | { | 
| Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 4039 | __be32 *p; | 
| Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 4040 | int ret = 0; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4041 |  | 
|  | 4042 | *used = 0; | 
|  | 4043 | if (unlikely(bitmap[1] & (FATTR4_WORD1_SPACE_USED - 1U))) | 
|  | 4044 | return -EIO; | 
|  | 4045 | if (likely(bitmap[1] & FATTR4_WORD1_SPACE_USED)) { | 
| Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 4046 | p = xdr_inline_decode(xdr, 8); | 
|  | 4047 | if (unlikely(!p)) | 
|  | 4048 | goto out_overflow; | 
| Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 4049 | xdr_decode_hyper(p, used); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4050 | bitmap[1] &= ~FATTR4_WORD1_SPACE_USED; | 
| Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 4051 | ret = NFS_ATTR_FATTR_SPACE_USED; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4052 | } | 
| Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 4053 | dprintk("%s: space used=%Lu\n", __func__, | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4054 | (unsigned long long)*used); | 
| Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 4055 | return ret; | 
| Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 4056 | out_overflow: | 
|  | 4057 | print_overflow_msg(__func__, xdr); | 
|  | 4058 | return -EIO; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4059 | } | 
|  | 4060 |  | 
|  | 4061 | static int decode_attr_time(struct xdr_stream *xdr, struct timespec *time) | 
|  | 4062 | { | 
| Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 4063 | __be32 *p; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4064 | uint64_t sec; | 
|  | 4065 | uint32_t nsec; | 
|  | 4066 |  | 
| Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 4067 | p = xdr_inline_decode(xdr, 12); | 
|  | 4068 | if (unlikely(!p)) | 
|  | 4069 | goto out_overflow; | 
| Benny Halevy | 3ceb4db | 2009-08-14 17:19:41 +0300 | [diff] [blame] | 4070 | p = xdr_decode_hyper(p, &sec); | 
| Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 4071 | nsec = be32_to_cpup(p); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4072 | time->tv_sec = (time_t)sec; | 
|  | 4073 | time->tv_nsec = (long)nsec; | 
|  | 4074 | return 0; | 
| Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 4075 | out_overflow: | 
|  | 4076 | print_overflow_msg(__func__, xdr); | 
|  | 4077 | return -EIO; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4078 | } | 
|  | 4079 |  | 
|  | 4080 | static int decode_attr_time_access(struct xdr_stream *xdr, uint32_t *bitmap, struct timespec *time) | 
|  | 4081 | { | 
|  | 4082 | int status = 0; | 
|  | 4083 |  | 
|  | 4084 | time->tv_sec = 0; | 
|  | 4085 | time->tv_nsec = 0; | 
|  | 4086 | if (unlikely(bitmap[1] & (FATTR4_WORD1_TIME_ACCESS - 1U))) | 
|  | 4087 | return -EIO; | 
|  | 4088 | if (likely(bitmap[1] & FATTR4_WORD1_TIME_ACCESS)) { | 
|  | 4089 | status = decode_attr_time(xdr, time); | 
| Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 4090 | if (status == 0) | 
|  | 4091 | status = NFS_ATTR_FATTR_ATIME; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4092 | bitmap[1] &= ~FATTR4_WORD1_TIME_ACCESS; | 
|  | 4093 | } | 
| Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 4094 | dprintk("%s: atime=%ld\n", __func__, (long)time->tv_sec); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4095 | return status; | 
|  | 4096 | } | 
|  | 4097 |  | 
|  | 4098 | static int decode_attr_time_metadata(struct xdr_stream *xdr, uint32_t *bitmap, struct timespec *time) | 
|  | 4099 | { | 
|  | 4100 | int status = 0; | 
|  | 4101 |  | 
|  | 4102 | time->tv_sec = 0; | 
|  | 4103 | time->tv_nsec = 0; | 
|  | 4104 | if (unlikely(bitmap[1] & (FATTR4_WORD1_TIME_METADATA - 1U))) | 
|  | 4105 | return -EIO; | 
|  | 4106 | if (likely(bitmap[1] & FATTR4_WORD1_TIME_METADATA)) { | 
|  | 4107 | status = decode_attr_time(xdr, time); | 
| Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 4108 | if (status == 0) | 
|  | 4109 | status = NFS_ATTR_FATTR_CTIME; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4110 | bitmap[1] &= ~FATTR4_WORD1_TIME_METADATA; | 
|  | 4111 | } | 
| Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 4112 | dprintk("%s: ctime=%ld\n", __func__, (long)time->tv_sec); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4113 | return status; | 
|  | 4114 | } | 
|  | 4115 |  | 
| Ricardo Labiaga | 55b6e77 | 2010-10-12 16:30:06 -0700 | [diff] [blame] | 4116 | static int decode_attr_time_delta(struct xdr_stream *xdr, uint32_t *bitmap, | 
|  | 4117 | struct timespec *time) | 
|  | 4118 | { | 
|  | 4119 | int status = 0; | 
|  | 4120 |  | 
|  | 4121 | time->tv_sec = 0; | 
|  | 4122 | time->tv_nsec = 0; | 
|  | 4123 | if (unlikely(bitmap[1] & (FATTR4_WORD1_TIME_DELTA - 1U))) | 
|  | 4124 | return -EIO; | 
|  | 4125 | if (likely(bitmap[1] & FATTR4_WORD1_TIME_DELTA)) { | 
|  | 4126 | status = decode_attr_time(xdr, time); | 
|  | 4127 | bitmap[1] &= ~FATTR4_WORD1_TIME_DELTA; | 
|  | 4128 | } | 
|  | 4129 | dprintk("%s: time_delta=%ld %ld\n", __func__, (long)time->tv_sec, | 
|  | 4130 | (long)time->tv_nsec); | 
|  | 4131 | return status; | 
|  | 4132 | } | 
|  | 4133 |  | 
| David Quigley | aa9c266 | 2013-05-22 12:50:44 -0400 | [diff] [blame] | 4134 | static int decode_attr_security_label(struct xdr_stream *xdr, uint32_t *bitmap, | 
|  | 4135 | struct nfs4_label *label) | 
|  | 4136 | { | 
|  | 4137 | uint32_t pi = 0; | 
|  | 4138 | uint32_t lfs = 0; | 
|  | 4139 | __u32 len; | 
|  | 4140 | __be32 *p; | 
|  | 4141 | int status = 0; | 
|  | 4142 |  | 
|  | 4143 | if (unlikely(bitmap[2] & (FATTR4_WORD2_SECURITY_LABEL - 1U))) | 
|  | 4144 | return -EIO; | 
|  | 4145 | if (likely(bitmap[2] & FATTR4_WORD2_SECURITY_LABEL)) { | 
|  | 4146 | p = xdr_inline_decode(xdr, 4); | 
|  | 4147 | if (unlikely(!p)) | 
|  | 4148 | goto out_overflow; | 
|  | 4149 | lfs = be32_to_cpup(p++); | 
|  | 4150 | p = xdr_inline_decode(xdr, 4); | 
|  | 4151 | if (unlikely(!p)) | 
|  | 4152 | goto out_overflow; | 
|  | 4153 | pi = be32_to_cpup(p++); | 
|  | 4154 | p = xdr_inline_decode(xdr, 4); | 
|  | 4155 | if (unlikely(!p)) | 
|  | 4156 | goto out_overflow; | 
|  | 4157 | len = be32_to_cpup(p++); | 
|  | 4158 | p = xdr_inline_decode(xdr, len); | 
|  | 4159 | if (unlikely(!p)) | 
|  | 4160 | goto out_overflow; | 
|  | 4161 | if (len < NFS4_MAXLABELLEN) { | 
|  | 4162 | if (label) { | 
|  | 4163 | memcpy(label->label, p, len); | 
|  | 4164 | label->len = len; | 
|  | 4165 | label->pi = pi; | 
|  | 4166 | label->lfs = lfs; | 
|  | 4167 | status = NFS_ATTR_FATTR_V4_SECURITY_LABEL; | 
|  | 4168 | } | 
|  | 4169 | bitmap[2] &= ~FATTR4_WORD2_SECURITY_LABEL; | 
|  | 4170 | } else | 
|  | 4171 | printk(KERN_WARNING "%s: label too long (%u)!\n", | 
|  | 4172 | __func__, len); | 
|  | 4173 | } | 
|  | 4174 | if (label && label->label) | 
|  | 4175 | dprintk("%s: label=%s, len=%d, PI=%d, LFS=%d\n", __func__, | 
|  | 4176 | (char *)label->label, label->len, label->pi, label->lfs); | 
|  | 4177 | return status; | 
|  | 4178 |  | 
|  | 4179 | out_overflow: | 
|  | 4180 | print_overflow_msg(__func__, xdr); | 
|  | 4181 | return -EIO; | 
|  | 4182 | } | 
|  | 4183 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4184 | static int decode_attr_time_modify(struct xdr_stream *xdr, uint32_t *bitmap, struct timespec *time) | 
|  | 4185 | { | 
|  | 4186 | int status = 0; | 
|  | 4187 |  | 
|  | 4188 | time->tv_sec = 0; | 
|  | 4189 | time->tv_nsec = 0; | 
|  | 4190 | if (unlikely(bitmap[1] & (FATTR4_WORD1_TIME_MODIFY - 1U))) | 
|  | 4191 | return -EIO; | 
|  | 4192 | if (likely(bitmap[1] & FATTR4_WORD1_TIME_MODIFY)) { | 
|  | 4193 | status = decode_attr_time(xdr, time); | 
| Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 4194 | if (status == 0) | 
|  | 4195 | status = NFS_ATTR_FATTR_MTIME; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4196 | bitmap[1] &= ~FATTR4_WORD1_TIME_MODIFY; | 
|  | 4197 | } | 
| Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 4198 | dprintk("%s: mtime=%ld\n", __func__, (long)time->tv_sec); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4199 | return status; | 
|  | 4200 | } | 
|  | 4201 |  | 
| Trond Myklebust | 256e48b | 2012-06-21 11:18:13 -0400 | [diff] [blame] | 4202 | static int verify_attr_len(struct xdr_stream *xdr, unsigned int savep, uint32_t attrlen) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4203 | { | 
|  | 4204 | unsigned int attrwords = XDR_QUADLEN(attrlen); | 
| Trond Myklebust | 256e48b | 2012-06-21 11:18:13 -0400 | [diff] [blame] | 4205 | unsigned int nwords = (xdr_stream_pos(xdr) - savep) >> 2; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4206 |  | 
|  | 4207 | if (unlikely(attrwords != nwords)) { | 
| Chuck Lever | fe82a18 | 2007-09-11 18:01:10 -0400 | [diff] [blame] | 4208 | dprintk("%s: server returned incorrect attribute length: " | 
|  | 4209 | "%u %c %u\n", | 
| Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 4210 | __func__, | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4211 | attrwords << 2, | 
|  | 4212 | (attrwords < nwords) ? '<' : '>', | 
|  | 4213 | nwords << 2); | 
|  | 4214 | return -EIO; | 
|  | 4215 | } | 
|  | 4216 | return 0; | 
|  | 4217 | } | 
|  | 4218 |  | 
|  | 4219 | static int decode_change_info(struct xdr_stream *xdr, struct nfs4_change_info *cinfo) | 
|  | 4220 | { | 
| Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 4221 | __be32 *p; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4222 |  | 
| Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 4223 | p = xdr_inline_decode(xdr, 20); | 
|  | 4224 | if (unlikely(!p)) | 
|  | 4225 | goto out_overflow; | 
| Benny Halevy | 6f723f7 | 2009-08-14 17:19:37 +0300 | [diff] [blame] | 4226 | cinfo->atomic = be32_to_cpup(p++); | 
| Benny Halevy | 3ceb4db | 2009-08-14 17:19:41 +0300 | [diff] [blame] | 4227 | p = xdr_decode_hyper(p, &cinfo->before); | 
| Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 4228 | xdr_decode_hyper(p, &cinfo->after); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4229 | return 0; | 
| Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 4230 | out_overflow: | 
|  | 4231 | print_overflow_msg(__func__, xdr); | 
|  | 4232 | return -EIO; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4233 | } | 
|  | 4234 |  | 
| Weston Andros Adamson | 6168f62 | 2012-09-10 14:00:46 -0400 | [diff] [blame] | 4235 | static int decode_access(struct xdr_stream *xdr, u32 *supported, u32 *access) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4236 | { | 
| Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 4237 | __be32 *p; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4238 | uint32_t supp, acc; | 
|  | 4239 | int status; | 
|  | 4240 |  | 
|  | 4241 | status = decode_op_hdr(xdr, OP_ACCESS); | 
|  | 4242 | if (status) | 
|  | 4243 | return status; | 
| Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 4244 | p = xdr_inline_decode(xdr, 8); | 
|  | 4245 | if (unlikely(!p)) | 
|  | 4246 | goto out_overflow; | 
| Benny Halevy | 6f723f7 | 2009-08-14 17:19:37 +0300 | [diff] [blame] | 4247 | supp = be32_to_cpup(p++); | 
| Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 4248 | acc = be32_to_cpup(p); | 
| Weston Andros Adamson | 6168f62 | 2012-09-10 14:00:46 -0400 | [diff] [blame] | 4249 | *supported = supp; | 
|  | 4250 | *access = acc; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4251 | return 0; | 
| Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 4252 | out_overflow: | 
|  | 4253 | print_overflow_msg(__func__, xdr); | 
|  | 4254 | return -EIO; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4255 | } | 
|  | 4256 |  | 
| Benny Halevy | 07d3043 | 2009-08-14 17:19:52 +0300 | [diff] [blame] | 4257 | static int decode_opaque_fixed(struct xdr_stream *xdr, void *buf, size_t len) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4258 | { | 
| Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 4259 | __be32 *p; | 
| Benny Halevy | 07d3043 | 2009-08-14 17:19:52 +0300 | [diff] [blame] | 4260 |  | 
|  | 4261 | p = xdr_inline_decode(xdr, len); | 
|  | 4262 | if (likely(p)) { | 
|  | 4263 | memcpy(buf, p, len); | 
|  | 4264 | return 0; | 
|  | 4265 | } | 
|  | 4266 | print_overflow_msg(__func__, xdr); | 
|  | 4267 | return -EIO; | 
|  | 4268 | } | 
|  | 4269 |  | 
|  | 4270 | static int decode_stateid(struct xdr_stream *xdr, nfs4_stateid *stateid) | 
|  | 4271 | { | 
| Trond Myklebust | 2d2f24a | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 4272 | return decode_opaque_fixed(xdr, stateid, NFS4_STATEID_SIZE); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4273 | } | 
|  | 4274 |  | 
| Trond Myklebust | 93b717f | 2016-05-16 17:42:43 -0400 | [diff] [blame] | 4275 | static int decode_open_stateid(struct xdr_stream *xdr, nfs4_stateid *stateid) | 
|  | 4276 | { | 
|  | 4277 | stateid->type = NFS4_OPEN_STATEID_TYPE; | 
|  | 4278 | return decode_stateid(xdr, stateid); | 
|  | 4279 | } | 
|  | 4280 |  | 
|  | 4281 | static int decode_lock_stateid(struct xdr_stream *xdr, nfs4_stateid *stateid) | 
|  | 4282 | { | 
|  | 4283 | stateid->type = NFS4_LOCK_STATEID_TYPE; | 
|  | 4284 | return decode_stateid(xdr, stateid); | 
|  | 4285 | } | 
|  | 4286 |  | 
|  | 4287 | static int decode_delegation_stateid(struct xdr_stream *xdr, nfs4_stateid *stateid) | 
|  | 4288 | { | 
|  | 4289 | stateid->type = NFS4_DELEGATION_STATEID_TYPE; | 
|  | 4290 | return decode_stateid(xdr, stateid); | 
|  | 4291 | } | 
|  | 4292 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4293 | static int decode_close(struct xdr_stream *xdr, struct nfs_closeres *res) | 
|  | 4294 | { | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4295 | int status; | 
|  | 4296 |  | 
|  | 4297 | status = decode_op_hdr(xdr, OP_CLOSE); | 
| Trond Myklebust | c1d5193 | 2008-04-07 13:20:54 -0400 | [diff] [blame] | 4298 | if (status != -EIO) | 
|  | 4299 | nfs_increment_open_seqid(status, res->seqid); | 
| Benny Halevy | 07d3043 | 2009-08-14 17:19:52 +0300 | [diff] [blame] | 4300 | if (!status) | 
| Trond Myklebust | 93b717f | 2016-05-16 17:42:43 -0400 | [diff] [blame] | 4301 | status = decode_open_stateid(xdr, &res->stateid); | 
| Benny Halevy | 07d3043 | 2009-08-14 17:19:52 +0300 | [diff] [blame] | 4302 | return status; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4303 | } | 
|  | 4304 |  | 
| Benny Halevy | db942bb | 2009-08-14 17:19:56 +0300 | [diff] [blame] | 4305 | static int decode_verifier(struct xdr_stream *xdr, void *verifier) | 
|  | 4306 | { | 
| Chuck Lever | cd93710 | 2012-03-02 17:14:31 -0500 | [diff] [blame] | 4307 | return decode_opaque_fixed(xdr, verifier, NFS4_VERIFIER_SIZE); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4308 | } | 
|  | 4309 |  | 
| Trond Myklebust | 2f2c63b | 2012-06-08 11:56:09 -0400 | [diff] [blame] | 4310 | static int decode_write_verifier(struct xdr_stream *xdr, struct nfs_write_verifier *verifier) | 
|  | 4311 | { | 
|  | 4312 | return decode_opaque_fixed(xdr, verifier->data, NFS4_VERIFIER_SIZE); | 
|  | 4313 | } | 
|  | 4314 |  | 
| Fred Isaman | 0b7c015 | 2012-04-20 14:47:39 -0400 | [diff] [blame] | 4315 | static int decode_commit(struct xdr_stream *xdr, struct nfs_commitres *res) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4316 | { | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4317 | int status; | 
|  | 4318 |  | 
|  | 4319 | status = decode_op_hdr(xdr, OP_COMMIT); | 
| Benny Halevy | db942bb | 2009-08-14 17:19:56 +0300 | [diff] [blame] | 4320 | if (!status) | 
| Trond Myklebust | 2f2c63b | 2012-06-08 11:56:09 -0400 | [diff] [blame] | 4321 | status = decode_write_verifier(xdr, &res->verf->verifier); | 
| Benny Halevy | db942bb | 2009-08-14 17:19:56 +0300 | [diff] [blame] | 4322 | return status; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4323 | } | 
|  | 4324 |  | 
|  | 4325 | static int decode_create(struct xdr_stream *xdr, struct nfs4_change_info *cinfo) | 
|  | 4326 | { | 
| Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 4327 | __be32 *p; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4328 | uint32_t bmlen; | 
|  | 4329 | int status; | 
|  | 4330 |  | 
|  | 4331 | status = decode_op_hdr(xdr, OP_CREATE); | 
|  | 4332 | if (status) | 
|  | 4333 | return status; | 
|  | 4334 | if ((status = decode_change_info(xdr, cinfo))) | 
|  | 4335 | return status; | 
| Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 4336 | p = xdr_inline_decode(xdr, 4); | 
|  | 4337 | if (unlikely(!p)) | 
|  | 4338 | goto out_overflow; | 
| Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 4339 | bmlen = be32_to_cpup(p); | 
| Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 4340 | p = xdr_inline_decode(xdr, bmlen << 2); | 
|  | 4341 | if (likely(p)) | 
|  | 4342 | return 0; | 
|  | 4343 | out_overflow: | 
|  | 4344 | print_overflow_msg(__func__, xdr); | 
|  | 4345 | return -EIO; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4346 | } | 
|  | 4347 |  | 
|  | 4348 | static int decode_server_caps(struct xdr_stream *xdr, struct nfs4_server_caps_res *res) | 
|  | 4349 | { | 
| Trond Myklebust | 256e48b | 2012-06-21 11:18:13 -0400 | [diff] [blame] | 4350 | unsigned int savep; | 
| Fred Isaman | dae100c | 2011-07-30 20:52:37 -0400 | [diff] [blame] | 4351 | uint32_t attrlen, bitmap[3] = {0}; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4352 | int status; | 
|  | 4353 |  | 
|  | 4354 | if ((status = decode_op_hdr(xdr, OP_GETATTR)) != 0) | 
|  | 4355 | goto xdr_error; | 
|  | 4356 | if ((status = decode_attr_bitmap(xdr, bitmap)) != 0) | 
|  | 4357 | goto xdr_error; | 
|  | 4358 | if ((status = decode_attr_length(xdr, &attrlen, &savep)) != 0) | 
|  | 4359 | goto xdr_error; | 
|  | 4360 | if ((status = decode_attr_supported(xdr, bitmap, res->attr_bitmask)) != 0) | 
|  | 4361 | goto xdr_error; | 
| Chuck Lever | 264e635 | 2012-03-01 17:02:05 -0500 | [diff] [blame] | 4362 | if ((status = decode_attr_fh_expire_type(xdr, bitmap, | 
|  | 4363 | &res->fh_expire_type)) != 0) | 
|  | 4364 | goto xdr_error; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4365 | if ((status = decode_attr_link_support(xdr, bitmap, &res->has_links)) != 0) | 
|  | 4366 | goto xdr_error; | 
|  | 4367 | if ((status = decode_attr_symlink_support(xdr, bitmap, &res->has_symlinks)) != 0) | 
|  | 4368 | goto xdr_error; | 
|  | 4369 | if ((status = decode_attr_aclsupport(xdr, bitmap, &res->acl_bitmask)) != 0) | 
|  | 4370 | goto xdr_error; | 
| Kinglong Mee | 8c61282 | 2015-08-26 21:12:58 +0800 | [diff] [blame] | 4371 | if ((status = decode_attr_exclcreat_supported(xdr, bitmap, | 
|  | 4372 | res->exclcreat_bitmask)) != 0) | 
|  | 4373 | goto xdr_error; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4374 | status = verify_attr_len(xdr, savep, attrlen); | 
|  | 4375 | xdr_error: | 
| Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 4376 | dprintk("%s: xdr returned %d!\n", __func__, -status); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4377 | return status; | 
|  | 4378 | } | 
| Andy Adamson | 6c0195a | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 4379 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4380 | static int decode_statfs(struct xdr_stream *xdr, struct nfs_fsstat *fsstat) | 
|  | 4381 | { | 
| Trond Myklebust | 256e48b | 2012-06-21 11:18:13 -0400 | [diff] [blame] | 4382 | unsigned int savep; | 
| Fred Isaman | dae100c | 2011-07-30 20:52:37 -0400 | [diff] [blame] | 4383 | uint32_t attrlen, bitmap[3] = {0}; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4384 | int status; | 
| Andy Adamson | 6c0195a | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 4385 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4386 | if ((status = decode_op_hdr(xdr, OP_GETATTR)) != 0) | 
|  | 4387 | goto xdr_error; | 
|  | 4388 | if ((status = decode_attr_bitmap(xdr, bitmap)) != 0) | 
|  | 4389 | goto xdr_error; | 
|  | 4390 | if ((status = decode_attr_length(xdr, &attrlen, &savep)) != 0) | 
|  | 4391 | goto xdr_error; | 
|  | 4392 |  | 
|  | 4393 | if ((status = decode_attr_files_avail(xdr, bitmap, &fsstat->afiles)) != 0) | 
|  | 4394 | goto xdr_error; | 
|  | 4395 | if ((status = decode_attr_files_free(xdr, bitmap, &fsstat->ffiles)) != 0) | 
|  | 4396 | goto xdr_error; | 
|  | 4397 | if ((status = decode_attr_files_total(xdr, bitmap, &fsstat->tfiles)) != 0) | 
|  | 4398 | goto xdr_error; | 
| Andreas Gruenbacher | 1ca843a | 2015-11-03 18:25:33 +0100 | [diff] [blame] | 4399 |  | 
|  | 4400 | status = -EIO; | 
|  | 4401 | if (unlikely(bitmap[0])) | 
|  | 4402 | goto xdr_error; | 
|  | 4403 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4404 | if ((status = decode_attr_space_avail(xdr, bitmap, &fsstat->abytes)) != 0) | 
|  | 4405 | goto xdr_error; | 
|  | 4406 | if ((status = decode_attr_space_free(xdr, bitmap, &fsstat->fbytes)) != 0) | 
|  | 4407 | goto xdr_error; | 
|  | 4408 | if ((status = decode_attr_space_total(xdr, bitmap, &fsstat->tbytes)) != 0) | 
|  | 4409 | goto xdr_error; | 
|  | 4410 |  | 
|  | 4411 | status = verify_attr_len(xdr, savep, attrlen); | 
|  | 4412 | xdr_error: | 
| Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 4413 | dprintk("%s: xdr returned %d!\n", __func__, -status); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4414 | return status; | 
|  | 4415 | } | 
|  | 4416 |  | 
|  | 4417 | static int decode_pathconf(struct xdr_stream *xdr, struct nfs_pathconf *pathconf) | 
|  | 4418 | { | 
| Trond Myklebust | 256e48b | 2012-06-21 11:18:13 -0400 | [diff] [blame] | 4419 | unsigned int savep; | 
| Fred Isaman | dae100c | 2011-07-30 20:52:37 -0400 | [diff] [blame] | 4420 | uint32_t attrlen, bitmap[3] = {0}; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4421 | int status; | 
| Andy Adamson | 6c0195a | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 4422 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4423 | if ((status = decode_op_hdr(xdr, OP_GETATTR)) != 0) | 
|  | 4424 | goto xdr_error; | 
|  | 4425 | if ((status = decode_attr_bitmap(xdr, bitmap)) != 0) | 
|  | 4426 | goto xdr_error; | 
|  | 4427 | if ((status = decode_attr_length(xdr, &attrlen, &savep)) != 0) | 
|  | 4428 | goto xdr_error; | 
|  | 4429 |  | 
|  | 4430 | if ((status = decode_attr_maxlink(xdr, bitmap, &pathconf->max_link)) != 0) | 
|  | 4431 | goto xdr_error; | 
|  | 4432 | if ((status = decode_attr_maxname(xdr, bitmap, &pathconf->max_namelen)) != 0) | 
|  | 4433 | goto xdr_error; | 
|  | 4434 |  | 
|  | 4435 | status = verify_attr_len(xdr, savep, attrlen); | 
|  | 4436 | xdr_error: | 
| Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 4437 | dprintk("%s: xdr returned %d!\n", __func__, -status); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4438 | return status; | 
|  | 4439 | } | 
|  | 4440 |  | 
| Andy Adamson | 88034c3 | 2012-05-23 05:02:34 -0400 | [diff] [blame] | 4441 | static int decode_threshold_hint(struct xdr_stream *xdr, | 
|  | 4442 | uint32_t *bitmap, | 
|  | 4443 | uint64_t *res, | 
|  | 4444 | uint32_t hint_bit) | 
|  | 4445 | { | 
|  | 4446 | __be32 *p; | 
|  | 4447 |  | 
|  | 4448 | *res = 0; | 
|  | 4449 | if (likely(bitmap[0] & hint_bit)) { | 
|  | 4450 | p = xdr_inline_decode(xdr, 8); | 
|  | 4451 | if (unlikely(!p)) | 
|  | 4452 | goto out_overflow; | 
|  | 4453 | xdr_decode_hyper(p, res); | 
|  | 4454 | } | 
|  | 4455 | return 0; | 
|  | 4456 | out_overflow: | 
|  | 4457 | print_overflow_msg(__func__, xdr); | 
|  | 4458 | return -EIO; | 
|  | 4459 | } | 
|  | 4460 |  | 
|  | 4461 | static int decode_first_threshold_item4(struct xdr_stream *xdr, | 
|  | 4462 | struct nfs4_threshold *res) | 
|  | 4463 | { | 
| Trond Myklebust | 256e48b | 2012-06-21 11:18:13 -0400 | [diff] [blame] | 4464 | __be32 *p; | 
|  | 4465 | unsigned int savep; | 
| Andy Adamson | 88034c3 | 2012-05-23 05:02:34 -0400 | [diff] [blame] | 4466 | uint32_t bitmap[3] = {0,}, attrlen; | 
|  | 4467 | int status; | 
|  | 4468 |  | 
|  | 4469 | /* layout type */ | 
|  | 4470 | p = xdr_inline_decode(xdr, 4); | 
|  | 4471 | if (unlikely(!p)) { | 
|  | 4472 | print_overflow_msg(__func__, xdr); | 
|  | 4473 | return -EIO; | 
|  | 4474 | } | 
|  | 4475 | res->l_type = be32_to_cpup(p); | 
|  | 4476 |  | 
|  | 4477 | /* thi_hintset bitmap */ | 
|  | 4478 | status = decode_attr_bitmap(xdr, bitmap); | 
|  | 4479 | if (status < 0) | 
|  | 4480 | goto xdr_error; | 
|  | 4481 |  | 
|  | 4482 | /* thi_hintlist length */ | 
|  | 4483 | status = decode_attr_length(xdr, &attrlen, &savep); | 
|  | 4484 | if (status < 0) | 
|  | 4485 | goto xdr_error; | 
|  | 4486 | /* thi_hintlist */ | 
|  | 4487 | status = decode_threshold_hint(xdr, bitmap, &res->rd_sz, THRESHOLD_RD); | 
|  | 4488 | if (status < 0) | 
|  | 4489 | goto xdr_error; | 
|  | 4490 | status = decode_threshold_hint(xdr, bitmap, &res->wr_sz, THRESHOLD_WR); | 
|  | 4491 | if (status < 0) | 
|  | 4492 | goto xdr_error; | 
|  | 4493 | status = decode_threshold_hint(xdr, bitmap, &res->rd_io_sz, | 
|  | 4494 | THRESHOLD_RD_IO); | 
|  | 4495 | if (status < 0) | 
|  | 4496 | goto xdr_error; | 
|  | 4497 | status = decode_threshold_hint(xdr, bitmap, &res->wr_io_sz, | 
|  | 4498 | THRESHOLD_WR_IO); | 
|  | 4499 | if (status < 0) | 
|  | 4500 | goto xdr_error; | 
|  | 4501 |  | 
|  | 4502 | status = verify_attr_len(xdr, savep, attrlen); | 
|  | 4503 | res->bm = bitmap[0]; | 
|  | 4504 |  | 
|  | 4505 | dprintk("%s bm=0x%x rd_sz=%llu wr_sz=%llu rd_io=%llu wr_io=%llu\n", | 
|  | 4506 | __func__, res->bm, res->rd_sz, res->wr_sz, res->rd_io_sz, | 
|  | 4507 | res->wr_io_sz); | 
|  | 4508 | xdr_error: | 
|  | 4509 | dprintk("%s ret=%d!\n", __func__, status); | 
|  | 4510 | return status; | 
|  | 4511 | } | 
|  | 4512 |  | 
|  | 4513 | /* | 
|  | 4514 | * Thresholds on pNFS direct I/O vrs MDS I/O | 
|  | 4515 | */ | 
|  | 4516 | static int decode_attr_mdsthreshold(struct xdr_stream *xdr, | 
|  | 4517 | uint32_t *bitmap, | 
|  | 4518 | struct nfs4_threshold *res) | 
|  | 4519 | { | 
|  | 4520 | __be32 *p; | 
|  | 4521 | int status = 0; | 
|  | 4522 | uint32_t num; | 
|  | 4523 |  | 
|  | 4524 | if (unlikely(bitmap[2] & (FATTR4_WORD2_MDSTHRESHOLD - 1U))) | 
|  | 4525 | return -EIO; | 
| Trond Myklebust | 029c534 | 2012-06-05 09:35:44 -0400 | [diff] [blame] | 4526 | if (bitmap[2] & FATTR4_WORD2_MDSTHRESHOLD) { | 
| Trond Myklebust | 1549210f | 2012-06-05 09:16:47 -0400 | [diff] [blame] | 4527 | /* Did the server return an unrequested attribute? */ | 
|  | 4528 | if (unlikely(res == NULL)) | 
|  | 4529 | return -EREMOTEIO; | 
| Andy Adamson | 88034c3 | 2012-05-23 05:02:34 -0400 | [diff] [blame] | 4530 | p = xdr_inline_decode(xdr, 4); | 
|  | 4531 | if (unlikely(!p)) | 
|  | 4532 | goto out_overflow; | 
|  | 4533 | num = be32_to_cpup(p); | 
|  | 4534 | if (num == 0) | 
|  | 4535 | return 0; | 
|  | 4536 | if (num > 1) | 
|  | 4537 | printk(KERN_INFO "%s: Warning: Multiple pNFS layout " | 
|  | 4538 | "drivers per filesystem not supported\n", | 
|  | 4539 | __func__); | 
|  | 4540 |  | 
|  | 4541 | status = decode_first_threshold_item4(xdr, res); | 
| Trond Myklebust | 029c534 | 2012-06-05 09:35:44 -0400 | [diff] [blame] | 4542 | bitmap[2] &= ~FATTR4_WORD2_MDSTHRESHOLD; | 
| Andy Adamson | 88034c3 | 2012-05-23 05:02:34 -0400 | [diff] [blame] | 4543 | } | 
|  | 4544 | return status; | 
|  | 4545 | out_overflow: | 
|  | 4546 | print_overflow_msg(__func__, xdr); | 
|  | 4547 | return -EIO; | 
|  | 4548 | } | 
|  | 4549 |  | 
| Bryan Schumaker | ae42c70 | 2010-10-21 16:33:17 -0400 | [diff] [blame] | 4550 | static int decode_getfattr_attrs(struct xdr_stream *xdr, uint32_t *bitmap, | 
|  | 4551 | struct nfs_fattr *fattr, struct nfs_fh *fh, | 
| David Quigley | aa9c266 | 2013-05-22 12:50:44 -0400 | [diff] [blame] | 4552 | struct nfs4_fs_locations *fs_loc, struct nfs4_label *label, | 
| Trond Myklebust | 6926afd | 2012-01-07 13:22:46 -0500 | [diff] [blame] | 4553 | const struct nfs_server *server) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4554 | { | 
| Trond Myklebust | bca7947 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 4555 | int status; | 
|  | 4556 | umode_t fmode = 0; | 
| Bryan Schumaker | ae42c70 | 2010-10-21 16:33:17 -0400 | [diff] [blame] | 4557 | uint32_t type; | 
| Trond Myklebust | ee7b75f | 2011-06-16 13:15:41 -0400 | [diff] [blame] | 4558 | int32_t err; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4559 |  | 
| Trond Myklebust | f26c7a7 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 4560 | status = decode_attr_type(xdr, bitmap, &type); | 
|  | 4561 | if (status < 0) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4562 | goto xdr_error; | 
| Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 4563 | fattr->mode = 0; | 
|  | 4564 | if (status != 0) { | 
|  | 4565 | fattr->mode |= nfs_type2fmt[type]; | 
|  | 4566 | fattr->valid |= status; | 
|  | 4567 | } | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4568 |  | 
| Trond Myklebust | f26c7a7 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 4569 | status = decode_attr_change(xdr, bitmap, &fattr->change_attr); | 
|  | 4570 | if (status < 0) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4571 | goto xdr_error; | 
| Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 4572 | fattr->valid |= status; | 
| Trond Myklebust | f26c7a7 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 4573 |  | 
|  | 4574 | status = decode_attr_size(xdr, bitmap, &fattr->size); | 
|  | 4575 | if (status < 0) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4576 | goto xdr_error; | 
| Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 4577 | fattr->valid |= status; | 
| Trond Myklebust | f26c7a7 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 4578 |  | 
|  | 4579 | status = decode_attr_fsid(xdr, bitmap, &fattr->fsid); | 
|  | 4580 | if (status < 0) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4581 | goto xdr_error; | 
| Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 4582 | fattr->valid |= status; | 
| Trond Myklebust | f26c7a7 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 4583 |  | 
| Trond Myklebust | ee7b75f | 2011-06-16 13:15:41 -0400 | [diff] [blame] | 4584 | err = 0; | 
|  | 4585 | status = decode_attr_error(xdr, bitmap, &err); | 
| Bryan Schumaker | ae42c70 | 2010-10-21 16:33:17 -0400 | [diff] [blame] | 4586 | if (status < 0) | 
|  | 4587 | goto xdr_error; | 
|  | 4588 |  | 
|  | 4589 | status = decode_attr_filehandle(xdr, bitmap, fh); | 
|  | 4590 | if (status < 0) | 
|  | 4591 | goto xdr_error; | 
|  | 4592 |  | 
| Trond Myklebust | f26c7a7 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 4593 | status = decode_attr_fileid(xdr, bitmap, &fattr->fileid); | 
|  | 4594 | if (status < 0) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4595 | goto xdr_error; | 
| Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 4596 | fattr->valid |= status; | 
| Trond Myklebust | f26c7a7 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 4597 |  | 
| Trond Myklebust | 8b7e3f4 | 2012-01-30 15:43:56 -0500 | [diff] [blame] | 4598 | status = decode_attr_fs_locations(xdr, bitmap, fs_loc); | 
| Trond Myklebust | f26c7a7 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 4599 | if (status < 0) | 
| Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 4600 | goto xdr_error; | 
| Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 4601 | fattr->valid |= status; | 
| Trond Myklebust | f26c7a7 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 4602 |  | 
| Andreas Gruenbacher | 1ca843a | 2015-11-03 18:25:33 +0100 | [diff] [blame] | 4603 | status = -EIO; | 
|  | 4604 | if (unlikely(bitmap[0])) | 
|  | 4605 | goto xdr_error; | 
|  | 4606 |  | 
| Trond Myklebust | f26c7a7 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 4607 | status = decode_attr_mode(xdr, bitmap, &fmode); | 
|  | 4608 | if (status < 0) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4609 | goto xdr_error; | 
| Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 4610 | if (status != 0) { | 
|  | 4611 | fattr->mode |= fmode; | 
|  | 4612 | fattr->valid |= status; | 
|  | 4613 | } | 
| Trond Myklebust | f26c7a7 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 4614 |  | 
|  | 4615 | status = decode_attr_nlink(xdr, bitmap, &fattr->nlink); | 
|  | 4616 | if (status < 0) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4617 | goto xdr_error; | 
| Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 4618 | fattr->valid |= status; | 
| Trond Myklebust | f26c7a7 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 4619 |  | 
| Trond Myklebust | 6926afd | 2012-01-07 13:22:46 -0500 | [diff] [blame] | 4620 | status = decode_attr_owner(xdr, bitmap, server, &fattr->uid, fattr->owner_name); | 
| Trond Myklebust | f26c7a7 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 4621 | if (status < 0) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4622 | goto xdr_error; | 
| Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 4623 | fattr->valid |= status; | 
| Trond Myklebust | f26c7a7 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 4624 |  | 
| Trond Myklebust | 6926afd | 2012-01-07 13:22:46 -0500 | [diff] [blame] | 4625 | status = decode_attr_group(xdr, bitmap, server, &fattr->gid, fattr->group_name); | 
| Trond Myklebust | f26c7a7 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 4626 | if (status < 0) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4627 | goto xdr_error; | 
| Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 4628 | fattr->valid |= status; | 
| Trond Myklebust | f26c7a7 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 4629 |  | 
|  | 4630 | status = decode_attr_rdev(xdr, bitmap, &fattr->rdev); | 
|  | 4631 | if (status < 0) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4632 | goto xdr_error; | 
| Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 4633 | fattr->valid |= status; | 
| Trond Myklebust | f26c7a7 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 4634 |  | 
|  | 4635 | status = decode_attr_space_used(xdr, bitmap, &fattr->du.nfs3.used); | 
|  | 4636 | if (status < 0) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4637 | goto xdr_error; | 
| Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 4638 | fattr->valid |= status; | 
| Trond Myklebust | f26c7a7 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 4639 |  | 
|  | 4640 | status = decode_attr_time_access(xdr, bitmap, &fattr->atime); | 
|  | 4641 | if (status < 0) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4642 | goto xdr_error; | 
| Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 4643 | fattr->valid |= status; | 
| Trond Myklebust | f26c7a7 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 4644 |  | 
|  | 4645 | status = decode_attr_time_metadata(xdr, bitmap, &fattr->ctime); | 
|  | 4646 | if (status < 0) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4647 | goto xdr_error; | 
| Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 4648 | fattr->valid |= status; | 
| Trond Myklebust | f26c7a7 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 4649 |  | 
|  | 4650 | status = decode_attr_time_modify(xdr, bitmap, &fattr->mtime); | 
|  | 4651 | if (status < 0) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4652 | goto xdr_error; | 
| Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 4653 | fattr->valid |= status; | 
| Trond Myklebust | f26c7a7 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 4654 |  | 
| Trond Myklebust | 28331a4 | 2011-04-27 13:47:52 -0400 | [diff] [blame] | 4655 | status = decode_attr_mounted_on_fileid(xdr, bitmap, &fattr->mounted_on_fileid); | 
| Trond Myklebust | f26c7a7 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 4656 | if (status < 0) | 
| Manoj Naik | 99baf62 | 2006-06-09 09:34:24 -0400 | [diff] [blame] | 4657 | goto xdr_error; | 
| Trond Myklebust | 28331a4 | 2011-04-27 13:47:52 -0400 | [diff] [blame] | 4658 | fattr->valid |= status; | 
| Trond Myklebust | f26c7a7 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 4659 |  | 
| Andreas Gruenbacher | 1ca843a | 2015-11-03 18:25:33 +0100 | [diff] [blame] | 4660 | status = -EIO; | 
|  | 4661 | if (unlikely(bitmap[1])) | 
|  | 4662 | goto xdr_error; | 
|  | 4663 |  | 
| Andy Adamson | 88034c3 | 2012-05-23 05:02:34 -0400 | [diff] [blame] | 4664 | status = decode_attr_mdsthreshold(xdr, bitmap, fattr->mdsthreshold); | 
|  | 4665 | if (status < 0) | 
|  | 4666 | goto xdr_error; | 
|  | 4667 |  | 
| David Quigley | aa9c266 | 2013-05-22 12:50:44 -0400 | [diff] [blame] | 4668 | if (label) { | 
|  | 4669 | status = decode_attr_security_label(xdr, bitmap, label); | 
|  | 4670 | if (status < 0) | 
|  | 4671 | goto xdr_error; | 
|  | 4672 | fattr->valid |= status; | 
|  | 4673 | } | 
|  | 4674 |  | 
| Bryan Schumaker | ae42c70 | 2010-10-21 16:33:17 -0400 | [diff] [blame] | 4675 | xdr_error: | 
|  | 4676 | dprintk("%s: xdr returned %d\n", __func__, -status); | 
|  | 4677 | return status; | 
|  | 4678 | } | 
|  | 4679 |  | 
|  | 4680 | static int decode_getfattr_generic(struct xdr_stream *xdr, struct nfs_fattr *fattr, | 
| Trond Myklebust | 8b7e3f4 | 2012-01-30 15:43:56 -0500 | [diff] [blame] | 4681 | struct nfs_fh *fh, struct nfs4_fs_locations *fs_loc, | 
| David Quigley | aa9c266 | 2013-05-22 12:50:44 -0400 | [diff] [blame] | 4682 | struct nfs4_label *label, const struct nfs_server *server) | 
| Bryan Schumaker | ae42c70 | 2010-10-21 16:33:17 -0400 | [diff] [blame] | 4683 | { | 
| Trond Myklebust | 256e48b | 2012-06-21 11:18:13 -0400 | [diff] [blame] | 4684 | unsigned int savep; | 
| Bryan Schumaker | ae42c70 | 2010-10-21 16:33:17 -0400 | [diff] [blame] | 4685 | uint32_t attrlen, | 
| Fred Isaman | dae100c | 2011-07-30 20:52:37 -0400 | [diff] [blame] | 4686 | bitmap[3] = {0}; | 
| Bryan Schumaker | ae42c70 | 2010-10-21 16:33:17 -0400 | [diff] [blame] | 4687 | int status; | 
|  | 4688 |  | 
|  | 4689 | status = decode_op_hdr(xdr, OP_GETATTR); | 
|  | 4690 | if (status < 0) | 
|  | 4691 | goto xdr_error; | 
|  | 4692 |  | 
|  | 4693 | status = decode_attr_bitmap(xdr, bitmap); | 
|  | 4694 | if (status < 0) | 
|  | 4695 | goto xdr_error; | 
|  | 4696 |  | 
|  | 4697 | status = decode_attr_length(xdr, &attrlen, &savep); | 
|  | 4698 | if (status < 0) | 
|  | 4699 | goto xdr_error; | 
|  | 4700 |  | 
| David Quigley | aa9c266 | 2013-05-22 12:50:44 -0400 | [diff] [blame] | 4701 | status = decode_getfattr_attrs(xdr, bitmap, fattr, fh, fs_loc, | 
|  | 4702 | label, server); | 
| Bryan Schumaker | ae42c70 | 2010-10-21 16:33:17 -0400 | [diff] [blame] | 4703 | if (status < 0) | 
|  | 4704 | goto xdr_error; | 
|  | 4705 |  | 
| Trond Myklebust | f26c7a7 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 4706 | status = verify_attr_len(xdr, savep, attrlen); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4707 | xdr_error: | 
| Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 4708 | dprintk("%s: xdr returned %d\n", __func__, -status); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4709 | return status; | 
|  | 4710 | } | 
|  | 4711 |  | 
| David Quigley | aa9c266 | 2013-05-22 12:50:44 -0400 | [diff] [blame] | 4712 | static int decode_getfattr_label(struct xdr_stream *xdr, struct nfs_fattr *fattr, | 
|  | 4713 | struct nfs4_label *label, const struct nfs_server *server) | 
|  | 4714 | { | 
|  | 4715 | return decode_getfattr_generic(xdr, fattr, NULL, NULL, label, server); | 
|  | 4716 | } | 
|  | 4717 |  | 
| Bryan Schumaker | ae42c70 | 2010-10-21 16:33:17 -0400 | [diff] [blame] | 4718 | static int decode_getfattr(struct xdr_stream *xdr, struct nfs_fattr *fattr, | 
| Trond Myklebust | 6926afd | 2012-01-07 13:22:46 -0500 | [diff] [blame] | 4719 | const struct nfs_server *server) | 
| Bryan Schumaker | ae42c70 | 2010-10-21 16:33:17 -0400 | [diff] [blame] | 4720 | { | 
| David Quigley | aa9c266 | 2013-05-22 12:50:44 -0400 | [diff] [blame] | 4721 | return decode_getfattr_generic(xdr, fattr, NULL, NULL, NULL, server); | 
| Bryan Schumaker | ae42c70 | 2010-10-21 16:33:17 -0400 | [diff] [blame] | 4722 | } | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4723 |  | 
| Andy Adamson | 504913f | 2010-10-20 00:17:57 -0400 | [diff] [blame] | 4724 | /* | 
| Jeff Layton | 3132e49 | 2016-08-10 15:58:24 -0400 | [diff] [blame] | 4725 | * Decode potentially multiple layout types. | 
| Andy Adamson | 504913f | 2010-10-20 00:17:57 -0400 | [diff] [blame] | 4726 | */ | 
| Jeff Layton | 3132e49 | 2016-08-10 15:58:24 -0400 | [diff] [blame] | 4727 | static int decode_pnfs_layout_types(struct xdr_stream *xdr, | 
| Jeff Layton | ca440c3 | 2016-09-15 14:40:49 -0400 | [diff] [blame] | 4728 | struct nfs_fsinfo *fsinfo) | 
| Andy Adamson | 504913f | 2010-10-20 00:17:57 -0400 | [diff] [blame] | 4729 | { | 
| Trond Myklebust | b8a8a0d | 2013-08-20 21:08:56 -0400 | [diff] [blame] | 4730 | __be32 *p; | 
| Jeff Layton | ca440c3 | 2016-09-15 14:40:49 -0400 | [diff] [blame] | 4731 | uint32_t i; | 
| Andy Adamson | 504913f | 2010-10-20 00:17:57 -0400 | [diff] [blame] | 4732 |  | 
|  | 4733 | p = xdr_inline_decode(xdr, 4); | 
|  | 4734 | if (unlikely(!p)) | 
|  | 4735 | goto out_overflow; | 
| Jeff Layton | ca440c3 | 2016-09-15 14:40:49 -0400 | [diff] [blame] | 4736 | fsinfo->nlayouttypes = be32_to_cpup(p); | 
| Andy Adamson | 504913f | 2010-10-20 00:17:57 -0400 | [diff] [blame] | 4737 |  | 
|  | 4738 | /* pNFS is not supported by the underlying file system */ | 
| Jeff Layton | ca440c3 | 2016-09-15 14:40:49 -0400 | [diff] [blame] | 4739 | if (fsinfo->nlayouttypes == 0) | 
| Andy Adamson | 504913f | 2010-10-20 00:17:57 -0400 | [diff] [blame] | 4740 | return 0; | 
| Andy Adamson | 504913f | 2010-10-20 00:17:57 -0400 | [diff] [blame] | 4741 |  | 
|  | 4742 | /* Decode and set first layout type, move xdr->p past unused types */ | 
| Jeff Layton | ca440c3 | 2016-09-15 14:40:49 -0400 | [diff] [blame] | 4743 | p = xdr_inline_decode(xdr, fsinfo->nlayouttypes * 4); | 
| Andy Adamson | 504913f | 2010-10-20 00:17:57 -0400 | [diff] [blame] | 4744 | if (unlikely(!p)) | 
|  | 4745 | goto out_overflow; | 
| Jeff Layton | ca440c3 | 2016-09-15 14:40:49 -0400 | [diff] [blame] | 4746 |  | 
|  | 4747 | /* If we get too many, then just cap it at the max */ | 
|  | 4748 | if (fsinfo->nlayouttypes > NFS_MAX_LAYOUT_TYPES) { | 
|  | 4749 | printk(KERN_INFO "NFS: %s: Warning: Too many (%u) pNFS layout types\n", | 
|  | 4750 | __func__, fsinfo->nlayouttypes); | 
|  | 4751 | fsinfo->nlayouttypes = NFS_MAX_LAYOUT_TYPES; | 
|  | 4752 | } | 
|  | 4753 |  | 
|  | 4754 | for(i = 0; i < fsinfo->nlayouttypes; ++i) | 
|  | 4755 | fsinfo->layouttype[i] = be32_to_cpup(p++); | 
| Andy Adamson | 504913f | 2010-10-20 00:17:57 -0400 | [diff] [blame] | 4756 | return 0; | 
|  | 4757 | out_overflow: | 
|  | 4758 | print_overflow_msg(__func__, xdr); | 
|  | 4759 | return -EIO; | 
|  | 4760 | } | 
|  | 4761 |  | 
|  | 4762 | /* | 
|  | 4763 | * The type of file system exported. | 
|  | 4764 | * Note we must ensure that layouttype is set in any non-error case. | 
|  | 4765 | */ | 
|  | 4766 | static int decode_attr_pnfstype(struct xdr_stream *xdr, uint32_t *bitmap, | 
| Jeff Layton | ca440c3 | 2016-09-15 14:40:49 -0400 | [diff] [blame] | 4767 | struct nfs_fsinfo *fsinfo) | 
| Andy Adamson | 504913f | 2010-10-20 00:17:57 -0400 | [diff] [blame] | 4768 | { | 
|  | 4769 | int status = 0; | 
|  | 4770 |  | 
|  | 4771 | dprintk("%s: bitmap is %x\n", __func__, bitmap[1]); | 
|  | 4772 | if (unlikely(bitmap[1] & (FATTR4_WORD1_FS_LAYOUT_TYPES - 1U))) | 
|  | 4773 | return -EIO; | 
|  | 4774 | if (bitmap[1] & FATTR4_WORD1_FS_LAYOUT_TYPES) { | 
| Jeff Layton | ca440c3 | 2016-09-15 14:40:49 -0400 | [diff] [blame] | 4775 | status = decode_pnfs_layout_types(xdr, fsinfo); | 
| Andy Adamson | 504913f | 2010-10-20 00:17:57 -0400 | [diff] [blame] | 4776 | bitmap[1] &= ~FATTR4_WORD1_FS_LAYOUT_TYPES; | 
| Jeff Layton | 3132e49 | 2016-08-10 15:58:24 -0400 | [diff] [blame] | 4777 | } | 
| Andy Adamson | 504913f | 2010-10-20 00:17:57 -0400 | [diff] [blame] | 4778 | return status; | 
|  | 4779 | } | 
|  | 4780 |  | 
| Fred Isaman | dae100c | 2011-07-30 20:52:37 -0400 | [diff] [blame] | 4781 | /* | 
|  | 4782 | * The prefered block size for layout directed io | 
|  | 4783 | */ | 
|  | 4784 | static int decode_attr_layout_blksize(struct xdr_stream *xdr, uint32_t *bitmap, | 
|  | 4785 | uint32_t *res) | 
|  | 4786 | { | 
|  | 4787 | __be32 *p; | 
|  | 4788 |  | 
|  | 4789 | dprintk("%s: bitmap is %x\n", __func__, bitmap[2]); | 
|  | 4790 | *res = 0; | 
|  | 4791 | if (bitmap[2] & FATTR4_WORD2_LAYOUT_BLKSIZE) { | 
|  | 4792 | p = xdr_inline_decode(xdr, 4); | 
|  | 4793 | if (unlikely(!p)) { | 
|  | 4794 | print_overflow_msg(__func__, xdr); | 
|  | 4795 | return -EIO; | 
|  | 4796 | } | 
|  | 4797 | *res = be32_to_cpup(p); | 
|  | 4798 | bitmap[2] &= ~FATTR4_WORD2_LAYOUT_BLKSIZE; | 
|  | 4799 | } | 
|  | 4800 | return 0; | 
|  | 4801 | } | 
|  | 4802 |  | 
| Peng Tao | 2a92ee9 | 2015-09-26 02:24:37 +0800 | [diff] [blame] | 4803 | /* | 
|  | 4804 | * The granularity of a CLONE operation. | 
|  | 4805 | */ | 
|  | 4806 | static int decode_attr_clone_blksize(struct xdr_stream *xdr, uint32_t *bitmap, | 
|  | 4807 | uint32_t *res) | 
|  | 4808 | { | 
|  | 4809 | __be32 *p; | 
|  | 4810 |  | 
|  | 4811 | dprintk("%s: bitmap is %x\n", __func__, bitmap[2]); | 
|  | 4812 | *res = 0; | 
|  | 4813 | if (bitmap[2] & FATTR4_WORD2_CLONE_BLKSIZE) { | 
|  | 4814 | p = xdr_inline_decode(xdr, 4); | 
|  | 4815 | if (unlikely(!p)) { | 
|  | 4816 | print_overflow_msg(__func__, xdr); | 
|  | 4817 | return -EIO; | 
|  | 4818 | } | 
|  | 4819 | *res = be32_to_cpup(p); | 
|  | 4820 | bitmap[2] &= ~FATTR4_WORD2_CLONE_BLKSIZE; | 
|  | 4821 | } | 
|  | 4822 | return 0; | 
|  | 4823 | } | 
|  | 4824 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4825 | static int decode_fsinfo(struct xdr_stream *xdr, struct nfs_fsinfo *fsinfo) | 
|  | 4826 | { | 
| Trond Myklebust | 256e48b | 2012-06-21 11:18:13 -0400 | [diff] [blame] | 4827 | unsigned int savep; | 
| Fred Isaman | dae100c | 2011-07-30 20:52:37 -0400 | [diff] [blame] | 4828 | uint32_t attrlen, bitmap[3]; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4829 | int status; | 
|  | 4830 |  | 
|  | 4831 | if ((status = decode_op_hdr(xdr, OP_GETATTR)) != 0) | 
|  | 4832 | goto xdr_error; | 
|  | 4833 | if ((status = decode_attr_bitmap(xdr, bitmap)) != 0) | 
|  | 4834 | goto xdr_error; | 
|  | 4835 | if ((status = decode_attr_length(xdr, &attrlen, &savep)) != 0) | 
|  | 4836 | goto xdr_error; | 
|  | 4837 |  | 
|  | 4838 | fsinfo->rtmult = fsinfo->wtmult = 512;	/* ??? */ | 
|  | 4839 |  | 
|  | 4840 | if ((status = decode_attr_lease_time(xdr, bitmap, &fsinfo->lease_time)) != 0) | 
|  | 4841 | goto xdr_error; | 
|  | 4842 | if ((status = decode_attr_maxfilesize(xdr, bitmap, &fsinfo->maxfilesize)) != 0) | 
|  | 4843 | goto xdr_error; | 
|  | 4844 | if ((status = decode_attr_maxread(xdr, bitmap, &fsinfo->rtmax)) != 0) | 
|  | 4845 | goto xdr_error; | 
|  | 4846 | fsinfo->rtpref = fsinfo->dtpref = fsinfo->rtmax; | 
|  | 4847 | if ((status = decode_attr_maxwrite(xdr, bitmap, &fsinfo->wtmax)) != 0) | 
|  | 4848 | goto xdr_error; | 
|  | 4849 | fsinfo->wtpref = fsinfo->wtmax; | 
| Andreas Gruenbacher | 1ca843a | 2015-11-03 18:25:33 +0100 | [diff] [blame] | 4850 |  | 
|  | 4851 | status = -EIO; | 
|  | 4852 | if (unlikely(bitmap[0])) | 
|  | 4853 | goto xdr_error; | 
|  | 4854 |  | 
| Ricardo Labiaga | 55b6e77 | 2010-10-12 16:30:06 -0700 | [diff] [blame] | 4855 | status = decode_attr_time_delta(xdr, bitmap, &fsinfo->time_delta); | 
|  | 4856 | if (status != 0) | 
|  | 4857 | goto xdr_error; | 
| Jeff Layton | ca440c3 | 2016-09-15 14:40:49 -0400 | [diff] [blame] | 4858 | status = decode_attr_pnfstype(xdr, bitmap, fsinfo); | 
| Andy Adamson | 504913f | 2010-10-20 00:17:57 -0400 | [diff] [blame] | 4859 | if (status != 0) | 
|  | 4860 | goto xdr_error; | 
| Andreas Gruenbacher | 1ca843a | 2015-11-03 18:25:33 +0100 | [diff] [blame] | 4861 |  | 
|  | 4862 | status = -EIO; | 
|  | 4863 | if (unlikely(bitmap[1])) | 
|  | 4864 | goto xdr_error; | 
|  | 4865 |  | 
| Fred Isaman | dae100c | 2011-07-30 20:52:37 -0400 | [diff] [blame] | 4866 | status = decode_attr_layout_blksize(xdr, bitmap, &fsinfo->blksize); | 
|  | 4867 | if (status) | 
|  | 4868 | goto xdr_error; | 
| Peng Tao | 2a92ee9 | 2015-09-26 02:24:37 +0800 | [diff] [blame] | 4869 | status = decode_attr_clone_blksize(xdr, bitmap, &fsinfo->clone_blksize); | 
|  | 4870 | if (status) | 
|  | 4871 | goto xdr_error; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4872 |  | 
|  | 4873 | status = verify_attr_len(xdr, savep, attrlen); | 
|  | 4874 | xdr_error: | 
| Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 4875 | dprintk("%s: xdr returned %d!\n", __func__, -status); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4876 | return status; | 
|  | 4877 | } | 
|  | 4878 |  | 
|  | 4879 | static int decode_getfh(struct xdr_stream *xdr, struct nfs_fh *fh) | 
|  | 4880 | { | 
| Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 4881 | __be32 *p; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4882 | uint32_t len; | 
|  | 4883 | int status; | 
|  | 4884 |  | 
| Trond Myklebust | 9936781 | 2007-07-17 21:52:41 -0400 | [diff] [blame] | 4885 | /* Zero handle first to allow comparisons */ | 
|  | 4886 | memset(fh, 0, sizeof(*fh)); | 
|  | 4887 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4888 | status = decode_op_hdr(xdr, OP_GETFH); | 
|  | 4889 | if (status) | 
|  | 4890 | return status; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4891 |  | 
| Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 4892 | p = xdr_inline_decode(xdr, 4); | 
|  | 4893 | if (unlikely(!p)) | 
|  | 4894 | goto out_overflow; | 
| Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 4895 | len = be32_to_cpup(p); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4896 | if (len > NFS4_FHSIZE) | 
|  | 4897 | return -EIO; | 
|  | 4898 | fh->size = len; | 
| Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 4899 | p = xdr_inline_decode(xdr, len); | 
|  | 4900 | if (unlikely(!p)) | 
|  | 4901 | goto out_overflow; | 
| Benny Halevy | 99398d0 | 2009-08-14 17:20:05 +0300 | [diff] [blame] | 4902 | memcpy(fh->data, p, len); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4903 | return 0; | 
| Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 4904 | out_overflow: | 
|  | 4905 | print_overflow_msg(__func__, xdr); | 
|  | 4906 | return -EIO; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4907 | } | 
|  | 4908 |  | 
|  | 4909 | static int decode_link(struct xdr_stream *xdr, struct nfs4_change_info *cinfo) | 
|  | 4910 | { | 
|  | 4911 | int status; | 
| Andy Adamson | 6c0195a | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 4912 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4913 | status = decode_op_hdr(xdr, OP_LINK); | 
|  | 4914 | if (status) | 
|  | 4915 | return status; | 
|  | 4916 | return decode_change_info(xdr, cinfo); | 
|  | 4917 | } | 
|  | 4918 |  | 
|  | 4919 | /* | 
|  | 4920 | * We create the owner, so we know a proper owner.id length is 4. | 
|  | 4921 | */ | 
| Trond Myklebust | 911d1aa | 2006-01-03 09:55:16 +0100 | [diff] [blame] | 4922 | static int decode_lock_denied (struct xdr_stream *xdr, struct file_lock *fl) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4923 | { | 
| Trond Myklebust | 911d1aa | 2006-01-03 09:55:16 +0100 | [diff] [blame] | 4924 | uint64_t offset, length, clientid; | 
| Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 4925 | __be32 *p; | 
| Trond Myklebust | 911d1aa | 2006-01-03 09:55:16 +0100 | [diff] [blame] | 4926 | uint32_t namelen, type; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4927 |  | 
| Bryan Schumaker | babddc7 | 2010-10-20 15:44:29 -0400 | [diff] [blame] | 4928 | p = xdr_inline_decode(xdr, 32); /* read 32 bytes */ | 
| Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 4929 | if (unlikely(!p)) | 
|  | 4930 | goto out_overflow; | 
| Bryan Schumaker | babddc7 | 2010-10-20 15:44:29 -0400 | [diff] [blame] | 4931 | p = xdr_decode_hyper(p, &offset); /* read 2 8-byte long words */ | 
| Benny Halevy | 3ceb4db | 2009-08-14 17:19:41 +0300 | [diff] [blame] | 4932 | p = xdr_decode_hyper(p, &length); | 
| Bryan Schumaker | babddc7 | 2010-10-20 15:44:29 -0400 | [diff] [blame] | 4933 | type = be32_to_cpup(p++); /* 4 byte read */ | 
|  | 4934 | if (fl != NULL) { /* manipulate file lock */ | 
| Trond Myklebust | 911d1aa | 2006-01-03 09:55:16 +0100 | [diff] [blame] | 4935 | fl->fl_start = (loff_t)offset; | 
|  | 4936 | fl->fl_end = fl->fl_start + (loff_t)length - 1; | 
|  | 4937 | if (length == ~(uint64_t)0) | 
|  | 4938 | fl->fl_end = OFFSET_MAX; | 
|  | 4939 | fl->fl_type = F_WRLCK; | 
|  | 4940 | if (type & 1) | 
|  | 4941 | fl->fl_type = F_RDLCK; | 
|  | 4942 | fl->fl_pid = 0; | 
|  | 4943 | } | 
| Bryan Schumaker | babddc7 | 2010-10-20 15:44:29 -0400 | [diff] [blame] | 4944 | p = xdr_decode_hyper(p, &clientid); /* read 8 bytes */ | 
|  | 4945 | namelen = be32_to_cpup(p); /* read 4 bytes */  /* have read all 32 bytes now */ | 
|  | 4946 | p = xdr_inline_decode(xdr, namelen); /* variable size field */ | 
| Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 4947 | if (likely(p)) | 
|  | 4948 | return -NFS4ERR_DENIED; | 
|  | 4949 | out_overflow: | 
|  | 4950 | print_overflow_msg(__func__, xdr); | 
|  | 4951 | return -EIO; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4952 | } | 
|  | 4953 |  | 
| Trond Myklebust | 911d1aa | 2006-01-03 09:55:16 +0100 | [diff] [blame] | 4954 | static int decode_lock(struct xdr_stream *xdr, struct nfs_lock_res *res) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4955 | { | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4956 | int status; | 
|  | 4957 |  | 
|  | 4958 | status = decode_op_hdr(xdr, OP_LOCK); | 
| Trond Myklebust | c1d5193 | 2008-04-07 13:20:54 -0400 | [diff] [blame] | 4959 | if (status == -EIO) | 
|  | 4960 | goto out; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4961 | if (status == 0) { | 
| Trond Myklebust | 93b717f | 2016-05-16 17:42:43 -0400 | [diff] [blame] | 4962 | status = decode_lock_stateid(xdr, &res->stateid); | 
| Benny Halevy | 07d3043 | 2009-08-14 17:19:52 +0300 | [diff] [blame] | 4963 | if (unlikely(status)) | 
|  | 4964 | goto out; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4965 | } else if (status == -NFS4ERR_DENIED) | 
| Trond Myklebust | c1d5193 | 2008-04-07 13:20:54 -0400 | [diff] [blame] | 4966 | status = decode_lock_denied(xdr, NULL); | 
|  | 4967 | if (res->open_seqid != NULL) | 
|  | 4968 | nfs_increment_open_seqid(status, res->open_seqid); | 
|  | 4969 | nfs_increment_lock_seqid(status, res->lock_seqid); | 
|  | 4970 | out: | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4971 | return status; | 
|  | 4972 | } | 
|  | 4973 |  | 
| Trond Myklebust | 911d1aa | 2006-01-03 09:55:16 +0100 | [diff] [blame] | 4974 | static int decode_lockt(struct xdr_stream *xdr, struct nfs_lockt_res *res) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4975 | { | 
|  | 4976 | int status; | 
|  | 4977 | status = decode_op_hdr(xdr, OP_LOCKT); | 
|  | 4978 | if (status == -NFS4ERR_DENIED) | 
| Trond Myklebust | 911d1aa | 2006-01-03 09:55:16 +0100 | [diff] [blame] | 4979 | return decode_lock_denied(xdr, res->denied); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4980 | return status; | 
|  | 4981 | } | 
|  | 4982 |  | 
| Trond Myklebust | 911d1aa | 2006-01-03 09:55:16 +0100 | [diff] [blame] | 4983 | static int decode_locku(struct xdr_stream *xdr, struct nfs_locku_res *res) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4984 | { | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4985 | int status; | 
|  | 4986 |  | 
|  | 4987 | status = decode_op_hdr(xdr, OP_LOCKU); | 
| Trond Myklebust | c1d5193 | 2008-04-07 13:20:54 -0400 | [diff] [blame] | 4988 | if (status != -EIO) | 
|  | 4989 | nfs_increment_lock_seqid(status, res->seqid); | 
| Benny Halevy | 07d3043 | 2009-08-14 17:19:52 +0300 | [diff] [blame] | 4990 | if (status == 0) | 
| Trond Myklebust | 93b717f | 2016-05-16 17:42:43 -0400 | [diff] [blame] | 4991 | status = decode_lock_stateid(xdr, &res->stateid); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4992 | return status; | 
|  | 4993 | } | 
|  | 4994 |  | 
| Trond Myklebust | d3c7b7c | 2010-07-01 12:49:01 -0400 | [diff] [blame] | 4995 | static int decode_release_lockowner(struct xdr_stream *xdr) | 
|  | 4996 | { | 
|  | 4997 | return decode_op_hdr(xdr, OP_RELEASE_LOCKOWNER); | 
|  | 4998 | } | 
|  | 4999 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5000 | static int decode_lookup(struct xdr_stream *xdr) | 
|  | 5001 | { | 
|  | 5002 | return decode_op_hdr(xdr, OP_LOOKUP); | 
|  | 5003 | } | 
|  | 5004 |  | 
|  | 5005 | /* This is too sick! */ | 
| Trond Myklebust | 7d160a6 | 2015-09-05 19:06:57 -0400 | [diff] [blame] | 5006 | static int decode_space_limit(struct xdr_stream *xdr, | 
|  | 5007 | unsigned long *pagemod_limit) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5008 | { | 
| Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 5009 | __be32 *p; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5010 | uint32_t limit_type, nblocks, blocksize; | 
| Trond Myklebust | 7d160a6 | 2015-09-05 19:06:57 -0400 | [diff] [blame] | 5011 | u64 maxsize = 0; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5012 |  | 
| Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 5013 | p = xdr_inline_decode(xdr, 12); | 
|  | 5014 | if (unlikely(!p)) | 
|  | 5015 | goto out_overflow; | 
| Benny Halevy | 6f723f7 | 2009-08-14 17:19:37 +0300 | [diff] [blame] | 5016 | limit_type = be32_to_cpup(p++); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5017 | switch (limit_type) { | 
| Trond Myklebust | 7d160a6 | 2015-09-05 19:06:57 -0400 | [diff] [blame] | 5018 | case NFS4_LIMIT_SIZE: | 
|  | 5019 | xdr_decode_hyper(p, &maxsize); | 
| Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 5020 | break; | 
| Trond Myklebust | 7d160a6 | 2015-09-05 19:06:57 -0400 | [diff] [blame] | 5021 | case NFS4_LIMIT_BLOCKS: | 
| Benny Halevy | 6f723f7 | 2009-08-14 17:19:37 +0300 | [diff] [blame] | 5022 | nblocks = be32_to_cpup(p++); | 
| Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 5023 | blocksize = be32_to_cpup(p); | 
| Trond Myklebust | 7d160a6 | 2015-09-05 19:06:57 -0400 | [diff] [blame] | 5024 | maxsize = (uint64_t)nblocks * (uint64_t)blocksize; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5025 | } | 
| Kirill A. Shutemov | 09cbfea | 2016-04-01 15:29:47 +0300 | [diff] [blame] | 5026 | maxsize >>= PAGE_SHIFT; | 
| Trond Myklebust | 7d160a6 | 2015-09-05 19:06:57 -0400 | [diff] [blame] | 5027 | *pagemod_limit = min_t(u64, maxsize, ULONG_MAX); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5028 | return 0; | 
| Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 5029 | out_overflow: | 
|  | 5030 | print_overflow_msg(__func__, xdr); | 
|  | 5031 | return -EIO; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5032 | } | 
|  | 5033 |  | 
| Trond Myklebust | 6ae3733 | 2015-01-30 14:21:14 -0500 | [diff] [blame] | 5034 | static int decode_rw_delegation(struct xdr_stream *xdr, | 
|  | 5035 | uint32_t delegation_type, | 
|  | 5036 | struct nfs_openres *res) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5037 | { | 
| Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 5038 | __be32 *p; | 
| Benny Halevy | 07d3043 | 2009-08-14 17:19:52 +0300 | [diff] [blame] | 5039 | int status; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5040 |  | 
| Trond Myklebust | 93b717f | 2016-05-16 17:42:43 -0400 | [diff] [blame] | 5041 | status = decode_delegation_stateid(xdr, &res->delegation); | 
| Benny Halevy | 07d3043 | 2009-08-14 17:19:52 +0300 | [diff] [blame] | 5042 | if (unlikely(status)) | 
|  | 5043 | return status; | 
| Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 5044 | p = xdr_inline_decode(xdr, 4); | 
|  | 5045 | if (unlikely(!p)) | 
|  | 5046 | goto out_overflow; | 
| Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 5047 | res->do_recall = be32_to_cpup(p); | 
| Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 5048 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5049 | switch (delegation_type) { | 
| Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 5050 | case NFS4_OPEN_DELEGATE_READ: | 
|  | 5051 | res->delegation_type = FMODE_READ; | 
|  | 5052 | break; | 
|  | 5053 | case NFS4_OPEN_DELEGATE_WRITE: | 
|  | 5054 | res->delegation_type = FMODE_WRITE|FMODE_READ; | 
| Trond Myklebust | 7d160a6 | 2015-09-05 19:06:57 -0400 | [diff] [blame] | 5055 | if (decode_space_limit(xdr, &res->pagemod_limit) < 0) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5056 | return -EIO; | 
|  | 5057 | } | 
| David Howells | 7539bba | 2006-08-22 20:06:09 -0400 | [diff] [blame] | 5058 | return decode_ace(xdr, NULL, res->server->nfs_client); | 
| Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 5059 | out_overflow: | 
|  | 5060 | print_overflow_msg(__func__, xdr); | 
|  | 5061 | return -EIO; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5062 | } | 
|  | 5063 |  | 
| Trond Myklebust | 6ae3733 | 2015-01-30 14:21:14 -0500 | [diff] [blame] | 5064 | static int decode_no_delegation(struct xdr_stream *xdr, struct nfs_openres *res) | 
|  | 5065 | { | 
|  | 5066 | __be32 *p; | 
|  | 5067 | uint32_t why_no_delegation; | 
|  | 5068 |  | 
|  | 5069 | p = xdr_inline_decode(xdr, 4); | 
|  | 5070 | if (unlikely(!p)) | 
|  | 5071 | goto out_overflow; | 
|  | 5072 | why_no_delegation = be32_to_cpup(p); | 
|  | 5073 | switch (why_no_delegation) { | 
|  | 5074 | case WND4_CONTENTION: | 
|  | 5075 | case WND4_RESOURCE: | 
|  | 5076 | xdr_inline_decode(xdr, 4); | 
|  | 5077 | /* Ignore for now */ | 
|  | 5078 | } | 
|  | 5079 | return 0; | 
|  | 5080 | out_overflow: | 
|  | 5081 | print_overflow_msg(__func__, xdr); | 
|  | 5082 | return -EIO; | 
|  | 5083 | } | 
|  | 5084 |  | 
|  | 5085 | static int decode_delegation(struct xdr_stream *xdr, struct nfs_openres *res) | 
|  | 5086 | { | 
|  | 5087 | __be32 *p; | 
|  | 5088 | uint32_t delegation_type; | 
|  | 5089 |  | 
|  | 5090 | p = xdr_inline_decode(xdr, 4); | 
|  | 5091 | if (unlikely(!p)) | 
|  | 5092 | goto out_overflow; | 
|  | 5093 | delegation_type = be32_to_cpup(p); | 
|  | 5094 | res->delegation_type = 0; | 
|  | 5095 | switch (delegation_type) { | 
|  | 5096 | case NFS4_OPEN_DELEGATE_NONE: | 
|  | 5097 | return 0; | 
|  | 5098 | case NFS4_OPEN_DELEGATE_READ: | 
|  | 5099 | case NFS4_OPEN_DELEGATE_WRITE: | 
|  | 5100 | return decode_rw_delegation(xdr, delegation_type, res); | 
|  | 5101 | case NFS4_OPEN_DELEGATE_NONE_EXT: | 
|  | 5102 | return decode_no_delegation(xdr, res); | 
|  | 5103 | } | 
|  | 5104 | return -EIO; | 
|  | 5105 | out_overflow: | 
|  | 5106 | print_overflow_msg(__func__, xdr); | 
|  | 5107 | return -EIO; | 
|  | 5108 | } | 
|  | 5109 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5110 | static int decode_open(struct xdr_stream *xdr, struct nfs_openres *res) | 
|  | 5111 | { | 
| Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 5112 | __be32 *p; | 
| Jeff Layton | aa53ed5 | 2007-06-05 14:49:03 -0400 | [diff] [blame] | 5113 | uint32_t savewords, bmlen, i; | 
| Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 5114 | int status; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5115 |  | 
| Trond Myklebust | c7848f6 | 2013-12-04 17:39:23 -0500 | [diff] [blame] | 5116 | if (!__decode_op_hdr(xdr, OP_OPEN, &status)) | 
|  | 5117 | return status; | 
|  | 5118 | nfs_increment_open_seqid(status, res->seqid); | 
|  | 5119 | if (status) | 
|  | 5120 | return status; | 
| Trond Myklebust | 93b717f | 2016-05-16 17:42:43 -0400 | [diff] [blame] | 5121 | status = decode_open_stateid(xdr, &res->stateid); | 
| Benny Halevy | 07d3043 | 2009-08-14 17:19:52 +0300 | [diff] [blame] | 5122 | if (unlikely(status)) | 
| Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 5123 | return status; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5124 |  | 
| Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 5125 | decode_change_info(xdr, &res->cinfo); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5126 |  | 
| Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 5127 | p = xdr_inline_decode(xdr, 8); | 
|  | 5128 | if (unlikely(!p)) | 
|  | 5129 | goto out_overflow; | 
| Benny Halevy | 6f723f7 | 2009-08-14 17:19:37 +0300 | [diff] [blame] | 5130 | res->rflags = be32_to_cpup(p++); | 
| Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 5131 | bmlen = be32_to_cpup(p); | 
| Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 5132 | if (bmlen > 10) | 
|  | 5133 | goto xdr_error; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5134 |  | 
| Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 5135 | p = xdr_inline_decode(xdr, bmlen << 2); | 
|  | 5136 | if (unlikely(!p)) | 
|  | 5137 | goto out_overflow; | 
| Jeff Layton | aa53ed5 | 2007-06-05 14:49:03 -0400 | [diff] [blame] | 5138 | savewords = min_t(uint32_t, bmlen, NFS4_BITMAP_SIZE); | 
|  | 5139 | for (i = 0; i < savewords; ++i) | 
| Benny Halevy | 6f723f7 | 2009-08-14 17:19:37 +0300 | [diff] [blame] | 5140 | res->attrset[i] = be32_to_cpup(p++); | 
| Jeff Layton | aa53ed5 | 2007-06-05 14:49:03 -0400 | [diff] [blame] | 5141 | for (; i < NFS4_BITMAP_SIZE; i++) | 
|  | 5142 | res->attrset[i] = 0; | 
|  | 5143 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5144 | return decode_delegation(xdr, res); | 
|  | 5145 | xdr_error: | 
| Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 5146 | dprintk("%s: Bitmap too large! Length = %u\n", __func__, bmlen); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5147 | return -EIO; | 
| Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 5148 | out_overflow: | 
|  | 5149 | print_overflow_msg(__func__, xdr); | 
|  | 5150 | return -EIO; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5151 | } | 
|  | 5152 |  | 
|  | 5153 | static int decode_open_confirm(struct xdr_stream *xdr, struct nfs_open_confirmres *res) | 
|  | 5154 | { | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5155 | int status; | 
|  | 5156 |  | 
| Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 5157 | status = decode_op_hdr(xdr, OP_OPEN_CONFIRM); | 
| Trond Myklebust | c1d5193 | 2008-04-07 13:20:54 -0400 | [diff] [blame] | 5158 | if (status != -EIO) | 
|  | 5159 | nfs_increment_open_seqid(status, res->seqid); | 
| Benny Halevy | 07d3043 | 2009-08-14 17:19:52 +0300 | [diff] [blame] | 5160 | if (!status) | 
| Trond Myklebust | 93b717f | 2016-05-16 17:42:43 -0400 | [diff] [blame] | 5161 | status = decode_open_stateid(xdr, &res->stateid); | 
| Benny Halevy | 07d3043 | 2009-08-14 17:19:52 +0300 | [diff] [blame] | 5162 | return status; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5163 | } | 
|  | 5164 |  | 
|  | 5165 | static int decode_open_downgrade(struct xdr_stream *xdr, struct nfs_closeres *res) | 
|  | 5166 | { | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5167 | int status; | 
|  | 5168 |  | 
|  | 5169 | status = decode_op_hdr(xdr, OP_OPEN_DOWNGRADE); | 
| Trond Myklebust | c1d5193 | 2008-04-07 13:20:54 -0400 | [diff] [blame] | 5170 | if (status != -EIO) | 
|  | 5171 | nfs_increment_open_seqid(status, res->seqid); | 
| Benny Halevy | 07d3043 | 2009-08-14 17:19:52 +0300 | [diff] [blame] | 5172 | if (!status) | 
| Trond Myklebust | 93b717f | 2016-05-16 17:42:43 -0400 | [diff] [blame] | 5173 | status = decode_open_stateid(xdr, &res->stateid); | 
| Benny Halevy | 07d3043 | 2009-08-14 17:19:52 +0300 | [diff] [blame] | 5174 | return status; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5175 | } | 
|  | 5176 |  | 
|  | 5177 | static int decode_putfh(struct xdr_stream *xdr) | 
|  | 5178 | { | 
|  | 5179 | return decode_op_hdr(xdr, OP_PUTFH); | 
|  | 5180 | } | 
|  | 5181 |  | 
|  | 5182 | static int decode_putrootfh(struct xdr_stream *xdr) | 
|  | 5183 | { | 
|  | 5184 | return decode_op_hdr(xdr, OP_PUTROOTFH); | 
|  | 5185 | } | 
|  | 5186 |  | 
| Anna Schumaker | 9137bdf | 2014-05-06 09:12:25 -0400 | [diff] [blame] | 5187 | static int decode_read(struct xdr_stream *xdr, struct rpc_rqst *req, | 
|  | 5188 | struct nfs_pgio_res *res) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5189 | { | 
| Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 5190 | __be32 *p; | 
| Trond Myklebust | 64bd577 | 2012-06-20 22:35:05 -0400 | [diff] [blame] | 5191 | uint32_t count, eof, recvd; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5192 | int status; | 
|  | 5193 |  | 
|  | 5194 | status = decode_op_hdr(xdr, OP_READ); | 
|  | 5195 | if (status) | 
|  | 5196 | return status; | 
| Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 5197 | p = xdr_inline_decode(xdr, 8); | 
|  | 5198 | if (unlikely(!p)) | 
|  | 5199 | goto out_overflow; | 
| Benny Halevy | 6f723f7 | 2009-08-14 17:19:37 +0300 | [diff] [blame] | 5200 | eof = be32_to_cpup(p++); | 
| Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 5201 | count = be32_to_cpup(p); | 
| Trond Myklebust | 64bd577 | 2012-06-20 22:35:05 -0400 | [diff] [blame] | 5202 | recvd = xdr_read_pages(xdr, count); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5203 | if (count > recvd) { | 
| Chuck Lever | fe82a18 | 2007-09-11 18:01:10 -0400 | [diff] [blame] | 5204 | dprintk("NFS: server cheating in read reply: " | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5205 | "count %u > recvd %u\n", count, recvd); | 
|  | 5206 | count = recvd; | 
|  | 5207 | eof = 0; | 
|  | 5208 | } | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5209 | res->eof = eof; | 
|  | 5210 | res->count = count; | 
|  | 5211 | return 0; | 
| Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 5212 | out_overflow: | 
|  | 5213 | print_overflow_msg(__func__, xdr); | 
|  | 5214 | return -EIO; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5215 | } | 
|  | 5216 |  | 
|  | 5217 | static int decode_readdir(struct xdr_stream *xdr, struct rpc_rqst *req, struct nfs4_readdir_res *readdir) | 
|  | 5218 | { | 
| Chuck Lever | bcecff7 | 2007-10-26 13:32:03 -0400 | [diff] [blame] | 5219 | int		status; | 
| Chuck Lever | cd93710 | 2012-03-02 17:14:31 -0500 | [diff] [blame] | 5220 | __be32		verf[2]; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5221 |  | 
|  | 5222 | status = decode_op_hdr(xdr, OP_READDIR); | 
| Benny Halevy | db942bb | 2009-08-14 17:19:56 +0300 | [diff] [blame] | 5223 | if (!status) | 
|  | 5224 | status = decode_verifier(xdr, readdir->verifier.data); | 
|  | 5225 | if (unlikely(status)) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5226 | return status; | 
| Chuck Lever | cd93710 | 2012-03-02 17:14:31 -0500 | [diff] [blame] | 5227 | memcpy(verf, readdir->verifier.data, sizeof(verf)); | 
| Fred Isaman | 4410924 | 2008-04-02 15:21:15 +0300 | [diff] [blame] | 5228 | dprintk("%s: verifier = %08x:%08x\n", | 
| Chuck Lever | cd93710 | 2012-03-02 17:14:31 -0500 | [diff] [blame] | 5229 | __func__, verf[0], verf[1]); | 
| Trond Myklebust | 64bd577 | 2012-06-20 22:35:05 -0400 | [diff] [blame] | 5230 | return xdr_read_pages(xdr, xdr->buf->page_len); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5231 | } | 
|  | 5232 |  | 
|  | 5233 | static int decode_readlink(struct xdr_stream *xdr, struct rpc_rqst *req) | 
|  | 5234 | { | 
|  | 5235 | struct xdr_buf *rcvbuf = &req->rq_rcv_buf; | 
| Chuck Lever | bcecff7 | 2007-10-26 13:32:03 -0400 | [diff] [blame] | 5236 | u32 len, recvd; | 
| Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 5237 | __be32 *p; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5238 | int status; | 
|  | 5239 |  | 
|  | 5240 | status = decode_op_hdr(xdr, OP_READLINK); | 
|  | 5241 | if (status) | 
|  | 5242 | return status; | 
|  | 5243 |  | 
|  | 5244 | /* Convert length of symlink */ | 
| Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 5245 | p = xdr_inline_decode(xdr, 4); | 
|  | 5246 | if (unlikely(!p)) | 
|  | 5247 | goto out_overflow; | 
| Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 5248 | len = be32_to_cpup(p); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5249 | if (len >= rcvbuf->page_len || len <= 0) { | 
| Chuck Lever | fe82a18 | 2007-09-11 18:01:10 -0400 | [diff] [blame] | 5250 | dprintk("nfs: server returned giant symlink!\n"); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5251 | return -ENAMETOOLONG; | 
|  | 5252 | } | 
| Trond Myklebust | 64bd577 | 2012-06-20 22:35:05 -0400 | [diff] [blame] | 5253 | recvd = xdr_read_pages(xdr, len); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5254 | if (recvd < len) { | 
| Chuck Lever | fe82a18 | 2007-09-11 18:01:10 -0400 | [diff] [blame] | 5255 | dprintk("NFS: server cheating in readlink reply: " | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5256 | "count %u > recvd %u\n", len, recvd); | 
|  | 5257 | return -EIO; | 
|  | 5258 | } | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5259 | /* | 
|  | 5260 | * The XDR encode routine has set things up so that | 
|  | 5261 | * the link text will be copied directly into the | 
|  | 5262 | * buffer.  We just have to do overflow-checking, | 
|  | 5263 | * and and null-terminate the text (the VFS expects | 
|  | 5264 | * null-termination). | 
|  | 5265 | */ | 
| Chuck Lever | b4687da | 2010-09-21 16:55:48 -0400 | [diff] [blame] | 5266 | xdr_terminate_string(rcvbuf, len); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5267 | return 0; | 
| Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 5268 | out_overflow: | 
|  | 5269 | print_overflow_msg(__func__, xdr); | 
|  | 5270 | return -EIO; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5271 | } | 
|  | 5272 |  | 
|  | 5273 | static int decode_remove(struct xdr_stream *xdr, struct nfs4_change_info *cinfo) | 
|  | 5274 | { | 
|  | 5275 | int status; | 
|  | 5276 |  | 
|  | 5277 | status = decode_op_hdr(xdr, OP_REMOVE); | 
|  | 5278 | if (status) | 
|  | 5279 | goto out; | 
|  | 5280 | status = decode_change_info(xdr, cinfo); | 
|  | 5281 | out: | 
|  | 5282 | return status; | 
|  | 5283 | } | 
|  | 5284 |  | 
|  | 5285 | static int decode_rename(struct xdr_stream *xdr, struct nfs4_change_info *old_cinfo, | 
|  | 5286 | struct nfs4_change_info *new_cinfo) | 
|  | 5287 | { | 
|  | 5288 | int status; | 
|  | 5289 |  | 
|  | 5290 | status = decode_op_hdr(xdr, OP_RENAME); | 
|  | 5291 | if (status) | 
|  | 5292 | goto out; | 
|  | 5293 | if ((status = decode_change_info(xdr, old_cinfo))) | 
|  | 5294 | goto out; | 
|  | 5295 | status = decode_change_info(xdr, new_cinfo); | 
|  | 5296 | out: | 
|  | 5297 | return status; | 
|  | 5298 | } | 
|  | 5299 |  | 
|  | 5300 | static int decode_renew(struct xdr_stream *xdr) | 
|  | 5301 | { | 
|  | 5302 | return decode_op_hdr(xdr, OP_RENEW); | 
|  | 5303 | } | 
|  | 5304 |  | 
| Trond Myklebust | 56ae19f | 2005-10-27 22:12:40 -0400 | [diff] [blame] | 5305 | static int | 
|  | 5306 | decode_restorefh(struct xdr_stream *xdr) | 
|  | 5307 | { | 
|  | 5308 | return decode_op_hdr(xdr, OP_RESTOREFH); | 
|  | 5309 | } | 
|  | 5310 |  | 
| J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 5311 | static int decode_getacl(struct xdr_stream *xdr, struct rpc_rqst *req, | 
| Andy Adamson | bf118a3 | 2011-12-07 11:55:27 -0500 | [diff] [blame] | 5312 | struct nfs_getaclres *res) | 
| J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 5313 | { | 
| Trond Myklebust | 256e48b | 2012-06-21 11:18:13 -0400 | [diff] [blame] | 5314 | unsigned int savep; | 
| J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 5315 | uint32_t attrlen, | 
| Fred Isaman | dae100c | 2011-07-30 20:52:37 -0400 | [diff] [blame] | 5316 | bitmap[3] = {0}; | 
| J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 5317 | int status; | 
| Trond Myklebust | cff298c | 2012-08-14 17:14:17 -0400 | [diff] [blame] | 5318 | unsigned int pg_offset; | 
| J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 5319 |  | 
| Andy Adamson | bf118a3 | 2011-12-07 11:55:27 -0500 | [diff] [blame] | 5320 | res->acl_len = 0; | 
| J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 5321 | if ((status = decode_op_hdr(xdr, OP_GETATTR)) != 0) | 
|  | 5322 | goto out; | 
| Sachin Prabhu | 5a00689 | 2012-04-17 14:35:39 +0100 | [diff] [blame] | 5323 |  | 
| Trond Myklebust | 519d395 | 2012-08-14 17:30:10 -0400 | [diff] [blame] | 5324 | xdr_enter_page(xdr, xdr->buf->page_len); | 
|  | 5325 |  | 
| Trond Myklebust | cff298c | 2012-08-14 17:14:17 -0400 | [diff] [blame] | 5326 | /* Calculate the offset of the page data */ | 
|  | 5327 | pg_offset = xdr->buf->head[0].iov_len; | 
| Sachin Prabhu | 5a00689 | 2012-04-17 14:35:39 +0100 | [diff] [blame] | 5328 |  | 
| J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 5329 | if ((status = decode_attr_bitmap(xdr, bitmap)) != 0) | 
|  | 5330 | goto out; | 
|  | 5331 | if ((status = decode_attr_length(xdr, &attrlen, &savep)) != 0) | 
|  | 5332 | goto out; | 
|  | 5333 |  | 
|  | 5334 | if (unlikely(bitmap[0] & (FATTR4_WORD0_ACL - 1U))) | 
|  | 5335 | return -EIO; | 
|  | 5336 | if (likely(bitmap[0] & FATTR4_WORD0_ACL)) { | 
| J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 5337 |  | 
| Andy Adamson | bf118a3 | 2011-12-07 11:55:27 -0500 | [diff] [blame] | 5338 | /* The bitmap (xdr len + bitmaps) and the attr xdr len words | 
|  | 5339 | * are stored with the acl data to handle the problem of | 
|  | 5340 | * variable length bitmaps.*/ | 
| Trond Myklebust | cff298c | 2012-08-14 17:14:17 -0400 | [diff] [blame] | 5341 | res->acl_data_offset = xdr_stream_pos(xdr) - pg_offset; | 
| Trond Myklebust | 519d395 | 2012-08-14 17:30:10 -0400 | [diff] [blame] | 5342 | res->acl_len = attrlen; | 
| Trond Myklebust | 1f1ea6c | 2012-08-26 11:44:43 -0700 | [diff] [blame] | 5343 |  | 
|  | 5344 | /* Check for receive buffer overflow */ | 
|  | 5345 | if (res->acl_len > (xdr->nwords << 2) || | 
|  | 5346 | res->acl_len + res->acl_data_offset > xdr->buf->page_len) { | 
|  | 5347 | res->acl_flags |= NFS4_ACL_TRUNC; | 
| Trond Myklebust | 519d395 | 2012-08-14 17:30:10 -0400 | [diff] [blame] | 5348 | dprintk("NFS: acl reply: attrlen %u > page_len %u\n", | 
| Trond Myklebust | cff298c | 2012-08-14 17:14:17 -0400 | [diff] [blame] | 5349 | attrlen, xdr->nwords << 2); | 
| J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 5350 | } | 
| J. Bruce Fields | 8c233cf | 2005-10-13 16:54:27 -0400 | [diff] [blame] | 5351 | } else | 
|  | 5352 | status = -EOPNOTSUPP; | 
| J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 5353 |  | 
|  | 5354 | out: | 
|  | 5355 | return status; | 
|  | 5356 | } | 
|  | 5357 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5358 | static int | 
|  | 5359 | decode_savefh(struct xdr_stream *xdr) | 
|  | 5360 | { | 
|  | 5361 | return decode_op_hdr(xdr, OP_SAVEFH); | 
|  | 5362 | } | 
|  | 5363 |  | 
| Benny Halevy | 9e9ecc0 | 2009-04-01 09:22:00 -0400 | [diff] [blame] | 5364 | static int decode_setattr(struct xdr_stream *xdr) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5365 | { | 
| Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 5366 | __be32 *p; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5367 | uint32_t bmlen; | 
|  | 5368 | int status; | 
|  | 5369 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5370 | status = decode_op_hdr(xdr, OP_SETATTR); | 
|  | 5371 | if (status) | 
|  | 5372 | return status; | 
| Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 5373 | p = xdr_inline_decode(xdr, 4); | 
|  | 5374 | if (unlikely(!p)) | 
|  | 5375 | goto out_overflow; | 
| Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 5376 | bmlen = be32_to_cpup(p); | 
| Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 5377 | p = xdr_inline_decode(xdr, bmlen << 2); | 
|  | 5378 | if (likely(p)) | 
|  | 5379 | return 0; | 
|  | 5380 | out_overflow: | 
|  | 5381 | print_overflow_msg(__func__, xdr); | 
|  | 5382 | return -EIO; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5383 | } | 
|  | 5384 |  | 
| Trond Myklebust | bb8b27e | 2010-04-16 16:43:06 -0400 | [diff] [blame] | 5385 | static int decode_setclientid(struct xdr_stream *xdr, struct nfs4_setclientid_res *res) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5386 | { | 
| Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 5387 | __be32 *p; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5388 | uint32_t opnum; | 
|  | 5389 | int32_t nfserr; | 
|  | 5390 |  | 
| Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 5391 | p = xdr_inline_decode(xdr, 8); | 
|  | 5392 | if (unlikely(!p)) | 
|  | 5393 | goto out_overflow; | 
| Benny Halevy | 6f723f7 | 2009-08-14 17:19:37 +0300 | [diff] [blame] | 5394 | opnum = be32_to_cpup(p++); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5395 | if (opnum != OP_SETCLIENTID) { | 
| Chuck Lever | fe82a18 | 2007-09-11 18:01:10 -0400 | [diff] [blame] | 5396 | dprintk("nfs: decode_setclientid: Server returned operation" | 
| Andy Adamson | 6c0195a | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 5397 | " %d\n", opnum); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5398 | return -EIO; | 
|  | 5399 | } | 
| Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 5400 | nfserr = be32_to_cpup(p); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5401 | if (nfserr == NFS_OK) { | 
| Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 5402 | p = xdr_inline_decode(xdr, 8 + NFS4_VERIFIER_SIZE); | 
|  | 5403 | if (unlikely(!p)) | 
|  | 5404 | goto out_overflow; | 
| Trond Myklebust | bb8b27e | 2010-04-16 16:43:06 -0400 | [diff] [blame] | 5405 | p = xdr_decode_hyper(p, &res->clientid); | 
|  | 5406 | memcpy(res->confirm.data, p, NFS4_VERIFIER_SIZE); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5407 | } else if (nfserr == NFSERR_CLID_INUSE) { | 
|  | 5408 | uint32_t len; | 
|  | 5409 |  | 
|  | 5410 | /* skip netid string */ | 
| Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 5411 | p = xdr_inline_decode(xdr, 4); | 
|  | 5412 | if (unlikely(!p)) | 
|  | 5413 | goto out_overflow; | 
| Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 5414 | len = be32_to_cpup(p); | 
| Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 5415 | p = xdr_inline_decode(xdr, len); | 
|  | 5416 | if (unlikely(!p)) | 
|  | 5417 | goto out_overflow; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5418 |  | 
|  | 5419 | /* skip uaddr string */ | 
| Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 5420 | p = xdr_inline_decode(xdr, 4); | 
|  | 5421 | if (unlikely(!p)) | 
|  | 5422 | goto out_overflow; | 
| Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 5423 | len = be32_to_cpup(p); | 
| Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 5424 | p = xdr_inline_decode(xdr, len); | 
|  | 5425 | if (unlikely(!p)) | 
|  | 5426 | goto out_overflow; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5427 | return -NFSERR_CLID_INUSE; | 
|  | 5428 | } else | 
| Benny Halevy | 856dff3 | 2008-03-31 17:39:06 +0300 | [diff] [blame] | 5429 | return nfs4_stat_to_errno(nfserr); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5430 |  | 
|  | 5431 | return 0; | 
| Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 5432 | out_overflow: | 
|  | 5433 | print_overflow_msg(__func__, xdr); | 
|  | 5434 | return -EIO; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5435 | } | 
|  | 5436 |  | 
|  | 5437 | static int decode_setclientid_confirm(struct xdr_stream *xdr) | 
|  | 5438 | { | 
|  | 5439 | return decode_op_hdr(xdr, OP_SETCLIENTID_CONFIRM); | 
|  | 5440 | } | 
|  | 5441 |  | 
| Anna Schumaker | 9137bdf | 2014-05-06 09:12:25 -0400 | [diff] [blame] | 5442 | static int decode_write(struct xdr_stream *xdr, struct nfs_pgio_res *res) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5443 | { | 
| Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 5444 | __be32 *p; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5445 | int status; | 
|  | 5446 |  | 
|  | 5447 | status = decode_op_hdr(xdr, OP_WRITE); | 
|  | 5448 | if (status) | 
|  | 5449 | return status; | 
|  | 5450 |  | 
| Trond Myklebust | 2f2c63b | 2012-06-08 11:56:09 -0400 | [diff] [blame] | 5451 | p = xdr_inline_decode(xdr, 8); | 
| Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 5452 | if (unlikely(!p)) | 
|  | 5453 | goto out_overflow; | 
| Benny Halevy | 6f723f7 | 2009-08-14 17:19:37 +0300 | [diff] [blame] | 5454 | res->count = be32_to_cpup(p++); | 
|  | 5455 | res->verf->committed = be32_to_cpup(p++); | 
| Trond Myklebust | 2f2c63b | 2012-06-08 11:56:09 -0400 | [diff] [blame] | 5456 | return decode_write_verifier(xdr, &res->verf->verifier); | 
| Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 5457 | out_overflow: | 
|  | 5458 | print_overflow_msg(__func__, xdr); | 
|  | 5459 | return -EIO; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5460 | } | 
|  | 5461 |  | 
|  | 5462 | static int decode_delegreturn(struct xdr_stream *xdr) | 
|  | 5463 | { | 
|  | 5464 | return decode_op_hdr(xdr, OP_DELEGRETURN); | 
|  | 5465 | } | 
|  | 5466 |  | 
| Chuck Lever | fb15b26 | 2013-03-16 15:54:34 -0400 | [diff] [blame] | 5467 | static int decode_secinfo_gss(struct xdr_stream *xdr, | 
|  | 5468 | struct nfs4_secinfo4 *flavor) | 
| Bryan Schumaker | 5a5ea0d | 2011-03-24 17:12:29 +0000 | [diff] [blame] | 5469 | { | 
| Chuck Lever | fb15b26 | 2013-03-16 15:54:34 -0400 | [diff] [blame] | 5470 | u32 oid_len; | 
| Bryan Schumaker | 5a5ea0d | 2011-03-24 17:12:29 +0000 | [diff] [blame] | 5471 | __be32 *p; | 
|  | 5472 |  | 
|  | 5473 | p = xdr_inline_decode(xdr, 4); | 
|  | 5474 | if (unlikely(!p)) | 
|  | 5475 | goto out_overflow; | 
| Chuck Lever | fb15b26 | 2013-03-16 15:54:34 -0400 | [diff] [blame] | 5476 | oid_len = be32_to_cpup(p); | 
|  | 5477 | if (oid_len > GSS_OID_MAX_LEN) | 
| Bryan Schumaker | 5a5ea0d | 2011-03-24 17:12:29 +0000 | [diff] [blame] | 5478 | goto out_err; | 
|  | 5479 |  | 
| Chuck Lever | fb15b26 | 2013-03-16 15:54:34 -0400 | [diff] [blame] | 5480 | p = xdr_inline_decode(xdr, oid_len); | 
| Bryan Schumaker | 5a5ea0d | 2011-03-24 17:12:29 +0000 | [diff] [blame] | 5481 | if (unlikely(!p)) | 
|  | 5482 | goto out_overflow; | 
| Chuck Lever | fb15b26 | 2013-03-16 15:54:34 -0400 | [diff] [blame] | 5483 | memcpy(flavor->flavor_info.oid.data, p, oid_len); | 
|  | 5484 | flavor->flavor_info.oid.len = oid_len; | 
| Bryan Schumaker | 5a5ea0d | 2011-03-24 17:12:29 +0000 | [diff] [blame] | 5485 |  | 
|  | 5486 | p = xdr_inline_decode(xdr, 8); | 
|  | 5487 | if (unlikely(!p)) | 
|  | 5488 | goto out_overflow; | 
| Chuck Lever | fb15b26 | 2013-03-16 15:54:34 -0400 | [diff] [blame] | 5489 | flavor->flavor_info.qop = be32_to_cpup(p++); | 
|  | 5490 | flavor->flavor_info.service = be32_to_cpup(p); | 
| Bryan Schumaker | 5a5ea0d | 2011-03-24 17:12:29 +0000 | [diff] [blame] | 5491 |  | 
|  | 5492 | return 0; | 
|  | 5493 |  | 
|  | 5494 | out_overflow: | 
|  | 5495 | print_overflow_msg(__func__, xdr); | 
|  | 5496 | return -EIO; | 
|  | 5497 | out_err: | 
|  | 5498 | return -EINVAL; | 
|  | 5499 | } | 
|  | 5500 |  | 
| Bryan Schumaker | 31e4dda | 2012-04-27 13:27:38 -0400 | [diff] [blame] | 5501 | static int decode_secinfo_common(struct xdr_stream *xdr, struct nfs4_secinfo_res *res) | 
| Bryan Schumaker | 5a5ea0d | 2011-03-24 17:12:29 +0000 | [diff] [blame] | 5502 | { | 
| Chuck Lever | fb15b26 | 2013-03-16 15:54:34 -0400 | [diff] [blame] | 5503 | struct nfs4_secinfo4 *sec_flavor; | 
|  | 5504 | unsigned int i, num_flavors; | 
| Bryan Schumaker | 5a5ea0d | 2011-03-24 17:12:29 +0000 | [diff] [blame] | 5505 | int status; | 
|  | 5506 | __be32 *p; | 
| Bryan Schumaker | 5a5ea0d | 2011-03-24 17:12:29 +0000 | [diff] [blame] | 5507 |  | 
| Bryan Schumaker | 5a5ea0d | 2011-03-24 17:12:29 +0000 | [diff] [blame] | 5508 | p = xdr_inline_decode(xdr, 4); | 
|  | 5509 | if (unlikely(!p)) | 
|  | 5510 | goto out_overflow; | 
| Bryan Schumaker | 5a5ea0d | 2011-03-24 17:12:29 +0000 | [diff] [blame] | 5511 |  | 
| Bryan Schumaker | c3dfc28 | 2011-04-13 14:31:31 -0400 | [diff] [blame] | 5512 | res->flavors->num_flavors = 0; | 
|  | 5513 | num_flavors = be32_to_cpup(p); | 
|  | 5514 |  | 
|  | 5515 | for (i = 0; i < num_flavors; i++) { | 
| Bryan Schumaker | 5a5ea0d | 2011-03-24 17:12:29 +0000 | [diff] [blame] | 5516 | sec_flavor = &res->flavors->flavors[i]; | 
| Bryan Schumaker | c3dfc28 | 2011-04-13 14:31:31 -0400 | [diff] [blame] | 5517 | if ((char *)&sec_flavor[1] - (char *)res->flavors > PAGE_SIZE) | 
| Bryan Schumaker | 5a5ea0d | 2011-03-24 17:12:29 +0000 | [diff] [blame] | 5518 | break; | 
|  | 5519 |  | 
|  | 5520 | p = xdr_inline_decode(xdr, 4); | 
|  | 5521 | if (unlikely(!p)) | 
|  | 5522 | goto out_overflow; | 
|  | 5523 | sec_flavor->flavor = be32_to_cpup(p); | 
|  | 5524 |  | 
|  | 5525 | if (sec_flavor->flavor == RPC_AUTH_GSS) { | 
| Bryan Schumaker | 613e901 | 2011-04-27 15:28:44 -0400 | [diff] [blame] | 5526 | status = decode_secinfo_gss(xdr, sec_flavor); | 
|  | 5527 | if (status) | 
|  | 5528 | goto out; | 
| Bryan Schumaker | 5a5ea0d | 2011-03-24 17:12:29 +0000 | [diff] [blame] | 5529 | } | 
| Bryan Schumaker | c3dfc28 | 2011-04-13 14:31:31 -0400 | [diff] [blame] | 5530 | res->flavors->num_flavors++; | 
| Bryan Schumaker | 5a5ea0d | 2011-03-24 17:12:29 +0000 | [diff] [blame] | 5531 | } | 
|  | 5532 |  | 
| Bryan Schumaker | 31e4dda | 2012-04-27 13:27:38 -0400 | [diff] [blame] | 5533 | status = 0; | 
| Bryan Schumaker | 613e901 | 2011-04-27 15:28:44 -0400 | [diff] [blame] | 5534 | out: | 
|  | 5535 | return status; | 
| Bryan Schumaker | 5a5ea0d | 2011-03-24 17:12:29 +0000 | [diff] [blame] | 5536 | out_overflow: | 
|  | 5537 | print_overflow_msg(__func__, xdr); | 
|  | 5538 | return -EIO; | 
|  | 5539 | } | 
|  | 5540 |  | 
| Bryan Schumaker | 31e4dda | 2012-04-27 13:27:38 -0400 | [diff] [blame] | 5541 | static int decode_secinfo(struct xdr_stream *xdr, struct nfs4_secinfo_res *res) | 
|  | 5542 | { | 
|  | 5543 | int status = decode_op_hdr(xdr, OP_SECINFO); | 
|  | 5544 | if (status) | 
|  | 5545 | return status; | 
|  | 5546 | return decode_secinfo_common(xdr, res); | 
|  | 5547 | } | 
|  | 5548 |  | 
| Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 5549 | #if defined(CONFIG_NFS_V4_1) | 
| Bryan Schumaker | 31e4dda | 2012-04-27 13:27:38 -0400 | [diff] [blame] | 5550 | static int decode_secinfo_no_name(struct xdr_stream *xdr, struct nfs4_secinfo_res *res) | 
|  | 5551 | { | 
|  | 5552 | int status = decode_op_hdr(xdr, OP_SECINFO_NO_NAME); | 
|  | 5553 | if (status) | 
|  | 5554 | return status; | 
|  | 5555 | return decode_secinfo_common(xdr, res); | 
|  | 5556 | } | 
|  | 5557 |  | 
| Weston Andros Adamson | 2031cd1 | 2013-08-13 16:37:32 -0400 | [diff] [blame] | 5558 | static int decode_op_map(struct xdr_stream *xdr, struct nfs4_op_map *op_map) | 
|  | 5559 | { | 
|  | 5560 | __be32 *p; | 
|  | 5561 | uint32_t bitmap_words; | 
|  | 5562 | unsigned int i; | 
|  | 5563 |  | 
|  | 5564 | p = xdr_inline_decode(xdr, 4); | 
|  | 5565 | bitmap_words = be32_to_cpup(p++); | 
|  | 5566 | if (bitmap_words > NFS4_OP_MAP_NUM_WORDS) | 
|  | 5567 | return -EIO; | 
|  | 5568 | p = xdr_inline_decode(xdr, 4 * bitmap_words); | 
|  | 5569 | for (i = 0; i < bitmap_words; i++) | 
|  | 5570 | op_map->u.words[i] = be32_to_cpup(p++); | 
|  | 5571 |  | 
|  | 5572 | return 0; | 
|  | 5573 | } | 
|  | 5574 |  | 
| Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 5575 | static int decode_exchange_id(struct xdr_stream *xdr, | 
|  | 5576 | struct nfs41_exchange_id_res *res) | 
|  | 5577 | { | 
|  | 5578 | __be32 *p; | 
|  | 5579 | uint32_t dummy; | 
| Benny Halevy | 2460ba5 | 2009-08-14 17:20:10 +0300 | [diff] [blame] | 5580 | char *dummy_str; | 
| Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 5581 | int status; | 
| Weston Andros Adamson | 7d2ed9a | 2012-02-17 15:20:26 -0500 | [diff] [blame] | 5582 | uint32_t impl_id_count; | 
| Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 5583 |  | 
|  | 5584 | status = decode_op_hdr(xdr, OP_EXCHANGE_ID); | 
|  | 5585 | if (status) | 
|  | 5586 | return status; | 
|  | 5587 |  | 
| Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 5588 | p = xdr_inline_decode(xdr, 8); | 
|  | 5589 | if (unlikely(!p)) | 
|  | 5590 | goto out_overflow; | 
| Trond Myklebust | 32b0131 | 2012-05-26 13:41:04 -0400 | [diff] [blame] | 5591 | xdr_decode_hyper(p, &res->clientid); | 
| Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 5592 | p = xdr_inline_decode(xdr, 12); | 
|  | 5593 | if (unlikely(!p)) | 
|  | 5594 | goto out_overflow; | 
| Trond Myklebust | 32b0131 | 2012-05-26 13:41:04 -0400 | [diff] [blame] | 5595 | res->seqid = be32_to_cpup(p++); | 
|  | 5596 | res->flags = be32_to_cpup(p++); | 
| Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 5597 |  | 
| Weston Andros Adamson | 2031cd1 | 2013-08-13 16:37:32 -0400 | [diff] [blame] | 5598 | res->state_protect.how = be32_to_cpup(p); | 
|  | 5599 | switch (res->state_protect.how) { | 
|  | 5600 | case SP4_NONE: | 
|  | 5601 | break; | 
|  | 5602 | case SP4_MACH_CRED: | 
|  | 5603 | status = decode_op_map(xdr, &res->state_protect.enforce); | 
|  | 5604 | if (status) | 
|  | 5605 | return status; | 
|  | 5606 | status = decode_op_map(xdr, &res->state_protect.allow); | 
|  | 5607 | if (status) | 
|  | 5608 | return status; | 
|  | 5609 | break; | 
|  | 5610 | default: | 
|  | 5611 | WARN_ON_ONCE(1); | 
| Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 5612 | return -EIO; | 
| Weston Andros Adamson | 2031cd1 | 2013-08-13 16:37:32 -0400 | [diff] [blame] | 5613 | } | 
| Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 5614 |  | 
| Chuck Lever | acdeb69 | 2012-05-21 22:46:16 -0400 | [diff] [blame] | 5615 | /* server_owner4.so_minor_id */ | 
| Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 5616 | p = xdr_inline_decode(xdr, 8); | 
|  | 5617 | if (unlikely(!p)) | 
|  | 5618 | goto out_overflow; | 
| Chuck Lever | acdeb69 | 2012-05-21 22:46:16 -0400 | [diff] [blame] | 5619 | p = xdr_decode_hyper(p, &res->server_owner->minor_id); | 
| Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 5620 |  | 
| Chuck Lever | acdeb69 | 2012-05-21 22:46:16 -0400 | [diff] [blame] | 5621 | /* server_owner4.so_major_id */ | 
| Benny Halevy | 2460ba5 | 2009-08-14 17:20:10 +0300 | [diff] [blame] | 5622 | status = decode_opaque_inline(xdr, &dummy, &dummy_str); | 
|  | 5623 | if (unlikely(status)) | 
|  | 5624 | return status; | 
| Weston Andros Adamson | 78fe0f4 | 2011-05-31 19:05:47 -0400 | [diff] [blame] | 5625 | if (unlikely(dummy > NFS4_OPAQUE_LIMIT)) | 
|  | 5626 | return -EIO; | 
| Chuck Lever | acdeb69 | 2012-05-21 22:46:16 -0400 | [diff] [blame] | 5627 | memcpy(res->server_owner->major_id, dummy_str, dummy); | 
|  | 5628 | res->server_owner->major_id_sz = dummy; | 
| Weston Andros Adamson | 78fe0f4 | 2011-05-31 19:05:47 -0400 | [diff] [blame] | 5629 |  | 
| Chuck Lever | acdeb69 | 2012-05-21 22:46:16 -0400 | [diff] [blame] | 5630 | /* server_scope4 */ | 
|  | 5631 | status = decode_opaque_inline(xdr, &dummy, &dummy_str); | 
|  | 5632 | if (unlikely(status)) | 
|  | 5633 | return status; | 
|  | 5634 | if (unlikely(dummy > NFS4_OPAQUE_LIMIT)) | 
|  | 5635 | return -EIO; | 
| Weston Andros Adamson | 78fe0f4 | 2011-05-31 19:05:47 -0400 | [diff] [blame] | 5636 | memcpy(res->server_scope->server_scope, dummy_str, dummy); | 
|  | 5637 | res->server_scope->server_scope_sz = dummy; | 
|  | 5638 |  | 
| Weston Andros Adamson | 7d2ed9a | 2012-02-17 15:20:26 -0500 | [diff] [blame] | 5639 | /* Implementation Id */ | 
|  | 5640 | p = xdr_inline_decode(xdr, 4); | 
|  | 5641 | if (unlikely(!p)) | 
|  | 5642 | goto out_overflow; | 
|  | 5643 | impl_id_count = be32_to_cpup(p++); | 
| Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 5644 |  | 
| Weston Andros Adamson | 7d2ed9a | 2012-02-17 15:20:26 -0500 | [diff] [blame] | 5645 | if (impl_id_count) { | 
|  | 5646 | /* nii_domain */ | 
|  | 5647 | status = decode_opaque_inline(xdr, &dummy, &dummy_str); | 
|  | 5648 | if (unlikely(status)) | 
|  | 5649 | return status; | 
|  | 5650 | if (unlikely(dummy > NFS4_OPAQUE_LIMIT)) | 
|  | 5651 | return -EIO; | 
|  | 5652 | memcpy(res->impl_id->domain, dummy_str, dummy); | 
|  | 5653 |  | 
|  | 5654 | /* nii_name */ | 
|  | 5655 | status = decode_opaque_inline(xdr, &dummy, &dummy_str); | 
|  | 5656 | if (unlikely(status)) | 
|  | 5657 | return status; | 
|  | 5658 | if (unlikely(dummy > NFS4_OPAQUE_LIMIT)) | 
|  | 5659 | return -EIO; | 
|  | 5660 | memcpy(res->impl_id->name, dummy_str, dummy); | 
|  | 5661 |  | 
|  | 5662 | /* nii_date */ | 
|  | 5663 | p = xdr_inline_decode(xdr, 12); | 
|  | 5664 | if (unlikely(!p)) | 
|  | 5665 | goto out_overflow; | 
|  | 5666 | p = xdr_decode_hyper(p, &res->impl_id->date.seconds); | 
|  | 5667 | res->impl_id->date.nseconds = be32_to_cpup(p); | 
|  | 5668 |  | 
|  | 5669 | /* if there's more than one entry, ignore the rest */ | 
|  | 5670 | } | 
| Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 5671 | return 0; | 
| Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 5672 | out_overflow: | 
|  | 5673 | print_overflow_msg(__func__, xdr); | 
|  | 5674 | return -EIO; | 
| Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 5675 | } | 
| Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 5676 |  | 
|  | 5677 | static int decode_chan_attrs(struct xdr_stream *xdr, | 
|  | 5678 | struct nfs4_channel_attrs *attrs) | 
|  | 5679 | { | 
|  | 5680 | __be32 *p; | 
| Benny Halevy | c9c30dd | 2011-06-11 17:08:39 -0400 | [diff] [blame] | 5681 | u32 nr_attrs, val; | 
| Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 5682 |  | 
| Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 5683 | p = xdr_inline_decode(xdr, 28); | 
|  | 5684 | if (unlikely(!p)) | 
|  | 5685 | goto out_overflow; | 
| Benny Halevy | c9c30dd | 2011-06-11 17:08:39 -0400 | [diff] [blame] | 5686 | val = be32_to_cpup(p++);	/* headerpadsz */ | 
|  | 5687 | if (val) | 
|  | 5688 | return -EINVAL;		/* no support for header padding yet */ | 
| Benny Halevy | 6f723f7 | 2009-08-14 17:19:37 +0300 | [diff] [blame] | 5689 | attrs->max_rqst_sz = be32_to_cpup(p++); | 
|  | 5690 | attrs->max_resp_sz = be32_to_cpup(p++); | 
|  | 5691 | attrs->max_resp_sz_cached = be32_to_cpup(p++); | 
|  | 5692 | attrs->max_ops = be32_to_cpup(p++); | 
|  | 5693 | attrs->max_reqs = be32_to_cpup(p++); | 
| Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 5694 | nr_attrs = be32_to_cpup(p); | 
| Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 5695 | if (unlikely(nr_attrs > 1)) { | 
| Weston Andros Adamson | a030889 | 2012-01-26 13:32:23 -0500 | [diff] [blame] | 5696 | printk(KERN_WARNING "NFS: %s: Invalid rdma channel attrs " | 
|  | 5697 | "count %u\n", __func__, nr_attrs); | 
| Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 5698 | return -EINVAL; | 
|  | 5699 | } | 
| Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 5700 | if (nr_attrs == 1) { | 
|  | 5701 | p = xdr_inline_decode(xdr, 4); /* skip rdma_attrs */ | 
|  | 5702 | if (unlikely(!p)) | 
|  | 5703 | goto out_overflow; | 
|  | 5704 | } | 
| Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 5705 | return 0; | 
| Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 5706 | out_overflow: | 
|  | 5707 | print_overflow_msg(__func__, xdr); | 
|  | 5708 | return -EIO; | 
| Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 5709 | } | 
|  | 5710 |  | 
| Benny Halevy | e78291e | 2009-08-14 17:20:00 +0300 | [diff] [blame] | 5711 | static int decode_sessionid(struct xdr_stream *xdr, struct nfs4_sessionid *sid) | 
|  | 5712 | { | 
|  | 5713 | return decode_opaque_fixed(xdr, sid->data, NFS4_MAX_SESSIONID_LEN); | 
| Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 5714 | } | 
|  | 5715 |  | 
| Weston Andros Adamson | 7c44f1ae | 2012-05-24 13:22:50 -0400 | [diff] [blame] | 5716 | static int decode_bind_conn_to_session(struct xdr_stream *xdr, | 
|  | 5717 | struct nfs41_bind_conn_to_session_res *res) | 
|  | 5718 | { | 
|  | 5719 | __be32 *p; | 
|  | 5720 | int status; | 
|  | 5721 |  | 
|  | 5722 | status = decode_op_hdr(xdr, OP_BIND_CONN_TO_SESSION); | 
|  | 5723 | if (!status) | 
| Trond Myklebust | 71a097c | 2015-02-18 09:27:18 -0800 | [diff] [blame] | 5724 | status = decode_sessionid(xdr, &res->sessionid); | 
| Weston Andros Adamson | 7c44f1ae | 2012-05-24 13:22:50 -0400 | [diff] [blame] | 5725 | if (unlikely(status)) | 
|  | 5726 | return status; | 
|  | 5727 |  | 
|  | 5728 | /* dir flags, rdma mode bool */ | 
|  | 5729 | p = xdr_inline_decode(xdr, 8); | 
|  | 5730 | if (unlikely(!p)) | 
|  | 5731 | goto out_overflow; | 
|  | 5732 |  | 
|  | 5733 | res->dir = be32_to_cpup(p++); | 
|  | 5734 | if (res->dir == 0 || res->dir > NFS4_CDFS4_BOTH) | 
|  | 5735 | return -EIO; | 
|  | 5736 | if (be32_to_cpup(p) == 0) | 
|  | 5737 | res->use_conn_in_rdma_mode = false; | 
|  | 5738 | else | 
|  | 5739 | res->use_conn_in_rdma_mode = true; | 
|  | 5740 |  | 
|  | 5741 | return 0; | 
|  | 5742 | out_overflow: | 
|  | 5743 | print_overflow_msg(__func__, xdr); | 
|  | 5744 | return -EIO; | 
|  | 5745 | } | 
|  | 5746 |  | 
| Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 5747 | static int decode_create_session(struct xdr_stream *xdr, | 
|  | 5748 | struct nfs41_create_session_res *res) | 
|  | 5749 | { | 
|  | 5750 | __be32 *p; | 
|  | 5751 | int status; | 
| Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 5752 |  | 
|  | 5753 | status = decode_op_hdr(xdr, OP_CREATE_SESSION); | 
| Benny Halevy | e78291e | 2009-08-14 17:20:00 +0300 | [diff] [blame] | 5754 | if (!status) | 
| Trond Myklebust | 79969dd | 2015-02-18 11:30:18 -0800 | [diff] [blame] | 5755 | status = decode_sessionid(xdr, &res->sessionid); | 
| Benny Halevy | e78291e | 2009-08-14 17:20:00 +0300 | [diff] [blame] | 5756 | if (unlikely(status)) | 
| Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 5757 | return status; | 
|  | 5758 |  | 
| Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 5759 | /* seqid, flags */ | 
| Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 5760 | p = xdr_inline_decode(xdr, 8); | 
|  | 5761 | if (unlikely(!p)) | 
|  | 5762 | goto out_overflow; | 
| Trond Myklebust | 79969dd | 2015-02-18 11:30:18 -0800 | [diff] [blame] | 5763 | res->seqid = be32_to_cpup(p++); | 
|  | 5764 | res->flags = be32_to_cpup(p); | 
| Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 5765 |  | 
|  | 5766 | /* Channel attributes */ | 
| Trond Myklebust | 79969dd | 2015-02-18 11:30:18 -0800 | [diff] [blame] | 5767 | status = decode_chan_attrs(xdr, &res->fc_attrs); | 
| Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 5768 | if (!status) | 
| Trond Myklebust | 79969dd | 2015-02-18 11:30:18 -0800 | [diff] [blame] | 5769 | status = decode_chan_attrs(xdr, &res->bc_attrs); | 
| Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 5770 | return status; | 
| Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 5771 | out_overflow: | 
|  | 5772 | print_overflow_msg(__func__, xdr); | 
|  | 5773 | return -EIO; | 
| Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 5774 | } | 
| Andy Adamson | 0f3e66c | 2009-04-01 09:22:34 -0400 | [diff] [blame] | 5775 |  | 
|  | 5776 | static int decode_destroy_session(struct xdr_stream *xdr, void *dummy) | 
|  | 5777 | { | 
|  | 5778 | return decode_op_hdr(xdr, OP_DESTROY_SESSION); | 
|  | 5779 | } | 
| Ricardo Labiaga | 18019753 | 2009-12-05 16:08:40 -0500 | [diff] [blame] | 5780 |  | 
| Trond Myklebust | 6624553 | 2012-05-25 17:18:09 -0400 | [diff] [blame] | 5781 | static int decode_destroy_clientid(struct xdr_stream *xdr, void *dummy) | 
|  | 5782 | { | 
|  | 5783 | return decode_op_hdr(xdr, OP_DESTROY_CLIENTID); | 
|  | 5784 | } | 
|  | 5785 |  | 
| Ricardo Labiaga | 18019753 | 2009-12-05 16:08:40 -0500 | [diff] [blame] | 5786 | static int decode_reclaim_complete(struct xdr_stream *xdr, void *dummy) | 
|  | 5787 | { | 
|  | 5788 | return decode_op_hdr(xdr, OP_RECLAIM_COMPLETE); | 
|  | 5789 | } | 
| Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 5790 | #endif /* CONFIG_NFS_V4_1 */ | 
|  | 5791 |  | 
| Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 5792 | static int decode_sequence(struct xdr_stream *xdr, | 
|  | 5793 | struct nfs4_sequence_res *res, | 
|  | 5794 | struct rpc_rqst *rqstp) | 
|  | 5795 | { | 
|  | 5796 | #if defined(CONFIG_NFS_V4_1) | 
| Trond Myklebust | e3725ec | 2012-11-16 12:25:01 -0500 | [diff] [blame] | 5797 | struct nfs4_session *session; | 
| Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 5798 | struct nfs4_sessionid id; | 
|  | 5799 | u32 dummy; | 
|  | 5800 | int status; | 
|  | 5801 | __be32 *p; | 
|  | 5802 |  | 
| Trond Myklebust | e3725ec | 2012-11-16 12:25:01 -0500 | [diff] [blame] | 5803 | if (res->sr_slot == NULL) | 
| Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 5804 | return 0; | 
| Chuck Lever | 3bd2384 | 2013-08-09 12:49:19 -0400 | [diff] [blame] | 5805 | if (!res->sr_slot->table->session) | 
|  | 5806 | return 0; | 
| Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 5807 |  | 
| Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 5808 | status = decode_op_hdr(xdr, OP_SEQUENCE); | 
| Benny Halevy | e78291e | 2009-08-14 17:20:00 +0300 | [diff] [blame] | 5809 | if (!status) | 
|  | 5810 | status = decode_sessionid(xdr, &id); | 
|  | 5811 | if (unlikely(status)) | 
| Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 5812 | goto out_err; | 
| Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 5813 |  | 
| Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 5814 | /* | 
|  | 5815 | * If the server returns different values for sessionID, slotID or | 
|  | 5816 | * sequence number, the server is looney tunes. | 
|  | 5817 | */ | 
| Trond Myklebust | fdcb457 | 2010-02-08 09:32:40 -0500 | [diff] [blame] | 5818 | status = -EREMOTEIO; | 
| Trond Myklebust | e3725ec | 2012-11-16 12:25:01 -0500 | [diff] [blame] | 5819 | session = res->sr_slot->table->session; | 
| Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 5820 |  | 
| Trond Myklebust | e3725ec | 2012-11-16 12:25:01 -0500 | [diff] [blame] | 5821 | if (memcmp(id.data, session->sess_id.data, | 
| Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 5822 | NFS4_MAX_SESSIONID_LEN)) { | 
|  | 5823 | dprintk("%s Invalid session id\n", __func__); | 
|  | 5824 | goto out_err; | 
|  | 5825 | } | 
| Benny Halevy | e78291e | 2009-08-14 17:20:00 +0300 | [diff] [blame] | 5826 |  | 
| Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 5827 | p = xdr_inline_decode(xdr, 20); | 
|  | 5828 | if (unlikely(!p)) | 
|  | 5829 | goto out_overflow; | 
| Benny Halevy | e78291e | 2009-08-14 17:20:00 +0300 | [diff] [blame] | 5830 |  | 
| Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 5831 | /* seqid */ | 
| Benny Halevy | 6f723f7 | 2009-08-14 17:19:37 +0300 | [diff] [blame] | 5832 | dummy = be32_to_cpup(p++); | 
| Benny Halevy | dfb4f309 | 2010-09-24 09:17:01 -0400 | [diff] [blame] | 5833 | if (dummy != res->sr_slot->seq_nr) { | 
| Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 5834 | dprintk("%s Invalid sequence number\n", __func__); | 
|  | 5835 | goto out_err; | 
|  | 5836 | } | 
|  | 5837 | /* slot id */ | 
| Benny Halevy | 6f723f7 | 2009-08-14 17:19:37 +0300 | [diff] [blame] | 5838 | dummy = be32_to_cpup(p++); | 
| Trond Myklebust | df2fabf | 2012-11-16 12:45:06 -0500 | [diff] [blame] | 5839 | if (dummy != res->sr_slot->slot_nr) { | 
| Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 5840 | dprintk("%s Invalid slot id\n", __func__); | 
|  | 5841 | goto out_err; | 
|  | 5842 | } | 
| Trond Myklebust | da0507b | 2012-11-20 18:10:30 -0500 | [diff] [blame] | 5843 | /* highest slot id */ | 
|  | 5844 | res->sr_highest_slotid = be32_to_cpup(p++); | 
| Trond Myklebust | 464ee9f | 2012-11-20 12:49:27 -0500 | [diff] [blame] | 5845 | /* target highest slot id */ | 
|  | 5846 | res->sr_target_highest_slotid = be32_to_cpup(p++); | 
| Alexandros Batsakis | 0629e37 | 2009-12-05 13:46:14 -0500 | [diff] [blame] | 5847 | /* result flags */ | 
|  | 5848 | res->sr_status_flags = be32_to_cpup(p); | 
| Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 5849 | status = 0; | 
|  | 5850 | out_err: | 
|  | 5851 | res->sr_status = status; | 
|  | 5852 | return status; | 
| Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 5853 | out_overflow: | 
|  | 5854 | print_overflow_msg(__func__, xdr); | 
|  | 5855 | status = -EIO; | 
|  | 5856 | goto out_err; | 
| Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 5857 | #else  /* CONFIG_NFS_V4_1 */ | 
| Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 5858 | return 0; | 
| Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 5859 | #endif /* CONFIG_NFS_V4_1 */ | 
| Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 5860 | } | 
|  | 5861 |  | 
| Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 5862 | #if defined(CONFIG_NFS_V4_1) | 
| Trond Myklebust | 93b717f | 2016-05-16 17:42:43 -0400 | [diff] [blame] | 5863 | static int decode_layout_stateid(struct xdr_stream *xdr, nfs4_stateid *stateid) | 
|  | 5864 | { | 
|  | 5865 | stateid->type = NFS4_LAYOUT_STATEID_TYPE; | 
|  | 5866 | return decode_stateid(xdr, stateid); | 
|  | 5867 | } | 
|  | 5868 |  | 
| Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 5869 | static int decode_getdeviceinfo(struct xdr_stream *xdr, | 
| Trond Myklebust | 4e59080 | 2015-03-09 14:01:25 -0400 | [diff] [blame] | 5870 | struct nfs4_getdeviceinfo_res *res) | 
| Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 5871 | { | 
| Trond Myklebust | 4e59080 | 2015-03-09 14:01:25 -0400 | [diff] [blame] | 5872 | struct pnfs_device *pdev = res->pdev; | 
| Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 5873 | __be32 *p; | 
|  | 5874 | uint32_t len, type; | 
|  | 5875 | int status; | 
|  | 5876 |  | 
|  | 5877 | status = decode_op_hdr(xdr, OP_GETDEVICEINFO); | 
|  | 5878 | if (status) { | 
|  | 5879 | if (status == -ETOOSMALL) { | 
|  | 5880 | p = xdr_inline_decode(xdr, 4); | 
|  | 5881 | if (unlikely(!p)) | 
|  | 5882 | goto out_overflow; | 
|  | 5883 | pdev->mincount = be32_to_cpup(p); | 
|  | 5884 | dprintk("%s: Min count too small. mincnt = %u\n", | 
|  | 5885 | __func__, pdev->mincount); | 
|  | 5886 | } | 
|  | 5887 | return status; | 
|  | 5888 | } | 
|  | 5889 |  | 
|  | 5890 | p = xdr_inline_decode(xdr, 8); | 
|  | 5891 | if (unlikely(!p)) | 
|  | 5892 | goto out_overflow; | 
|  | 5893 | type = be32_to_cpup(p++); | 
|  | 5894 | if (type != pdev->layout_type) { | 
|  | 5895 | dprintk("%s: layout mismatch req: %u pdev: %u\n", | 
|  | 5896 | __func__, pdev->layout_type, type); | 
|  | 5897 | return -EINVAL; | 
|  | 5898 | } | 
|  | 5899 | /* | 
|  | 5900 | * Get the length of the opaque device_addr4. xdr_read_pages places | 
|  | 5901 | * the opaque device_addr4 in the xdr_buf->pages (pnfs_device->pages) | 
|  | 5902 | * and places the remaining xdr data in xdr_buf->tail | 
|  | 5903 | */ | 
|  | 5904 | pdev->mincount = be32_to_cpup(p); | 
| Trond Myklebust | 13fe4ba | 2012-08-01 14:21:12 -0400 | [diff] [blame] | 5905 | if (xdr_read_pages(xdr, pdev->mincount) != pdev->mincount) | 
|  | 5906 | goto out_overflow; | 
| Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 5907 |  | 
|  | 5908 | /* Parse notification bitmap, verifying that it is zero. */ | 
|  | 5909 | p = xdr_inline_decode(xdr, 4); | 
|  | 5910 | if (unlikely(!p)) | 
|  | 5911 | goto out_overflow; | 
|  | 5912 | len = be32_to_cpup(p); | 
|  | 5913 | if (len) { | 
| Chuck Lever | ead0059 | 2010-12-14 14:58:21 +0000 | [diff] [blame] | 5914 | uint32_t i; | 
| Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 5915 |  | 
|  | 5916 | p = xdr_inline_decode(xdr, 4 * len); | 
|  | 5917 | if (unlikely(!p)) | 
|  | 5918 | goto out_overflow; | 
| Christoph Hellwig | 84c9dee | 2014-09-10 17:37:28 -0700 | [diff] [blame] | 5919 |  | 
| Trond Myklebust | 4e59080 | 2015-03-09 14:01:25 -0400 | [diff] [blame] | 5920 | res->notification = be32_to_cpup(p++); | 
| Christoph Hellwig | 84c9dee | 2014-09-10 17:37:28 -0700 | [diff] [blame] | 5921 | for (i = 1; i < len; i++) { | 
|  | 5922 | if (be32_to_cpup(p++)) { | 
|  | 5923 | dprintk("%s: unsupported notification\n", | 
| Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 5924 | __func__); | 
|  | 5925 | return -EIO; | 
|  | 5926 | } | 
|  | 5927 | } | 
|  | 5928 | } | 
|  | 5929 | return 0; | 
|  | 5930 | out_overflow: | 
|  | 5931 | print_overflow_msg(__func__, xdr); | 
|  | 5932 | return -EIO; | 
|  | 5933 | } | 
|  | 5934 |  | 
|  | 5935 | static int decode_layoutget(struct xdr_stream *xdr, struct rpc_rqst *req, | 
|  | 5936 | struct nfs4_layoutget_res *res) | 
|  | 5937 | { | 
|  | 5938 | __be32 *p; | 
|  | 5939 | int status; | 
|  | 5940 | u32 layout_count; | 
| Trond Myklebust | 64bd577 | 2012-06-20 22:35:05 -0400 | [diff] [blame] | 5941 | u32 recvd; | 
| Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 5942 |  | 
|  | 5943 | status = decode_op_hdr(xdr, OP_LAYOUTGET); | 
|  | 5944 | if (status) | 
|  | 5945 | return status; | 
| Trond Myklebust | ea9d23f | 2012-03-04 18:13:56 -0500 | [diff] [blame] | 5946 | p = xdr_inline_decode(xdr, 4); | 
| Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 5947 | if (unlikely(!p)) | 
|  | 5948 | goto out_overflow; | 
| Trond Myklebust | ea9d23f | 2012-03-04 18:13:56 -0500 | [diff] [blame] | 5949 | res->return_on_close = be32_to_cpup(p); | 
| Trond Myklebust | 93b717f | 2016-05-16 17:42:43 -0400 | [diff] [blame] | 5950 | decode_layout_stateid(xdr, &res->stateid); | 
| Trond Myklebust | ea9d23f | 2012-03-04 18:13:56 -0500 | [diff] [blame] | 5951 | p = xdr_inline_decode(xdr, 4); | 
|  | 5952 | if (unlikely(!p)) | 
|  | 5953 | goto out_overflow; | 
| Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 5954 | layout_count = be32_to_cpup(p); | 
|  | 5955 | if (!layout_count) { | 
|  | 5956 | dprintk("%s: server responded with empty layout array\n", | 
|  | 5957 | __func__); | 
|  | 5958 | return -EINVAL; | 
|  | 5959 | } | 
|  | 5960 |  | 
| Weston Andros Adamson | 35124a0 | 2011-03-24 16:48:21 -0400 | [diff] [blame] | 5961 | p = xdr_inline_decode(xdr, 28); | 
| Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 5962 | if (unlikely(!p)) | 
|  | 5963 | goto out_overflow; | 
|  | 5964 | p = xdr_decode_hyper(p, &res->range.offset); | 
|  | 5965 | p = xdr_decode_hyper(p, &res->range.length); | 
|  | 5966 | res->range.iomode = be32_to_cpup(p++); | 
|  | 5967 | res->type = be32_to_cpup(p++); | 
| Weston Andros Adamson | 35124a0 | 2011-03-24 16:48:21 -0400 | [diff] [blame] | 5968 | res->layoutp->len = be32_to_cpup(p); | 
| Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 5969 |  | 
|  | 5970 | dprintk("%s roff:%lu rlen:%lu riomode:%d, lo_type:0x%x, lo.len:%d\n", | 
|  | 5971 | __func__, | 
|  | 5972 | (unsigned long)res->range.offset, | 
|  | 5973 | (unsigned long)res->range.length, | 
|  | 5974 | res->range.iomode, | 
|  | 5975 | res->type, | 
| Weston Andros Adamson | 35124a0 | 2011-03-24 16:48:21 -0400 | [diff] [blame] | 5976 | res->layoutp->len); | 
| Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 5977 |  | 
| Trond Myklebust | 64bd577 | 2012-06-20 22:35:05 -0400 | [diff] [blame] | 5978 | recvd = xdr_read_pages(xdr, res->layoutp->len); | 
| Weston Andros Adamson | 35124a0 | 2011-03-24 16:48:21 -0400 | [diff] [blame] | 5979 | if (res->layoutp->len > recvd) { | 
|  | 5980 | dprintk("NFS: server cheating in layoutget reply: " | 
|  | 5981 | "layout len %u > recvd %u\n", | 
|  | 5982 | res->layoutp->len, recvd); | 
|  | 5983 | return -EINVAL; | 
|  | 5984 | } | 
|  | 5985 |  | 
| Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 5986 | if (layout_count > 1) { | 
|  | 5987 | /* We only handle a length one array at the moment.  Any | 
|  | 5988 | * further entries are just ignored.  Note that this means | 
|  | 5989 | * the client may see a response that is less than the | 
|  | 5990 | * minimum it requested. | 
|  | 5991 | */ | 
|  | 5992 | dprintk("%s: server responded with %d layouts, dropping tail\n", | 
|  | 5993 | __func__, layout_count); | 
|  | 5994 | } | 
|  | 5995 |  | 
|  | 5996 | return 0; | 
|  | 5997 | out_overflow: | 
|  | 5998 | print_overflow_msg(__func__, xdr); | 
|  | 5999 | return -EIO; | 
|  | 6000 | } | 
| Andy Adamson | 863a3c6 | 2011-03-23 13:27:54 +0000 | [diff] [blame] | 6001 |  | 
| Benny Halevy | cbe8260 | 2011-05-22 19:52:37 +0300 | [diff] [blame] | 6002 | static int decode_layoutreturn(struct xdr_stream *xdr, | 
|  | 6003 | struct nfs4_layoutreturn_res *res) | 
|  | 6004 | { | 
|  | 6005 | __be32 *p; | 
|  | 6006 | int status; | 
|  | 6007 |  | 
|  | 6008 | status = decode_op_hdr(xdr, OP_LAYOUTRETURN); | 
|  | 6009 | if (status) | 
|  | 6010 | return status; | 
|  | 6011 | p = xdr_inline_decode(xdr, 4); | 
|  | 6012 | if (unlikely(!p)) | 
|  | 6013 | goto out_overflow; | 
|  | 6014 | res->lrs_present = be32_to_cpup(p); | 
|  | 6015 | if (res->lrs_present) | 
| Trond Myklebust | 93b717f | 2016-05-16 17:42:43 -0400 | [diff] [blame] | 6016 | status = decode_layout_stateid(xdr, &res->stateid); | 
| Benny Halevy | cbe8260 | 2011-05-22 19:52:37 +0300 | [diff] [blame] | 6017 | return status; | 
|  | 6018 | out_overflow: | 
|  | 6019 | print_overflow_msg(__func__, xdr); | 
|  | 6020 | return -EIO; | 
|  | 6021 | } | 
|  | 6022 |  | 
| Andy Adamson | 863a3c6 | 2011-03-23 13:27:54 +0000 | [diff] [blame] | 6023 | static int decode_layoutcommit(struct xdr_stream *xdr, | 
|  | 6024 | struct rpc_rqst *req, | 
|  | 6025 | struct nfs4_layoutcommit_res *res) | 
|  | 6026 | { | 
|  | 6027 | __be32 *p; | 
|  | 6028 | __u32 sizechanged; | 
|  | 6029 | int status; | 
|  | 6030 |  | 
|  | 6031 | status = decode_op_hdr(xdr, OP_LAYOUTCOMMIT); | 
| Andy Adamson | db29c08 | 2011-07-30 20:52:38 -0400 | [diff] [blame] | 6032 | res->status = status; | 
| Andy Adamson | 863a3c6 | 2011-03-23 13:27:54 +0000 | [diff] [blame] | 6033 | if (status) | 
|  | 6034 | return status; | 
|  | 6035 |  | 
|  | 6036 | p = xdr_inline_decode(xdr, 4); | 
|  | 6037 | if (unlikely(!p)) | 
|  | 6038 | goto out_overflow; | 
|  | 6039 | sizechanged = be32_to_cpup(p); | 
|  | 6040 |  | 
|  | 6041 | if (sizechanged) { | 
|  | 6042 | /* throw away new size */ | 
|  | 6043 | p = xdr_inline_decode(xdr, 8); | 
|  | 6044 | if (unlikely(!p)) | 
|  | 6045 | goto out_overflow; | 
|  | 6046 | } | 
|  | 6047 | return 0; | 
|  | 6048 | out_overflow: | 
|  | 6049 | print_overflow_msg(__func__, xdr); | 
|  | 6050 | return -EIO; | 
|  | 6051 | } | 
| Bryan Schumaker | 7d97479 | 2011-06-02 14:59:08 -0400 | [diff] [blame] | 6052 |  | 
|  | 6053 | static int decode_test_stateid(struct xdr_stream *xdr, | 
|  | 6054 | struct nfs41_test_stateid_res *res) | 
|  | 6055 | { | 
|  | 6056 | __be32 *p; | 
|  | 6057 | int status; | 
|  | 6058 | int num_res; | 
|  | 6059 |  | 
|  | 6060 | status = decode_op_hdr(xdr, OP_TEST_STATEID); | 
|  | 6061 | if (status) | 
|  | 6062 | return status; | 
|  | 6063 |  | 
|  | 6064 | p = xdr_inline_decode(xdr, 4); | 
|  | 6065 | if (unlikely(!p)) | 
|  | 6066 | goto out_overflow; | 
|  | 6067 | num_res = be32_to_cpup(p++); | 
|  | 6068 | if (num_res != 1) | 
|  | 6069 | goto out; | 
|  | 6070 |  | 
|  | 6071 | p = xdr_inline_decode(xdr, 4); | 
|  | 6072 | if (unlikely(!p)) | 
|  | 6073 | goto out_overflow; | 
|  | 6074 | res->status = be32_to_cpup(p++); | 
| Bryan Schumaker | 1cab065 | 2012-01-31 10:39:29 -0500 | [diff] [blame] | 6075 |  | 
|  | 6076 | return status; | 
| Bryan Schumaker | 7d97479 | 2011-06-02 14:59:08 -0400 | [diff] [blame] | 6077 | out_overflow: | 
|  | 6078 | print_overflow_msg(__func__, xdr); | 
|  | 6079 | out: | 
|  | 6080 | return -EIO; | 
|  | 6081 | } | 
| Bryan Schumaker | 9aeda35 | 2011-06-02 14:59:09 -0400 | [diff] [blame] | 6082 |  | 
|  | 6083 | static int decode_free_stateid(struct xdr_stream *xdr, | 
|  | 6084 | struct nfs41_free_stateid_res *res) | 
|  | 6085 | { | 
| Andy Adamson | 9f79fb4 | 2013-09-10 12:56:29 -0400 | [diff] [blame] | 6086 | res->status = decode_op_hdr(xdr, OP_FREE_STATEID); | 
| Bryan Schumaker | 9aeda35 | 2011-06-02 14:59:09 -0400 | [diff] [blame] | 6087 | return res->status; | 
| Bryan Schumaker | 9aeda35 | 2011-06-02 14:59:09 -0400 | [diff] [blame] | 6088 | } | 
| Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 6089 | #endif /* CONFIG_NFS_V4_1 */ | 
|  | 6090 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6091 | /* | 
| Benny Halevy | 49c2559 | 2008-12-23 16:06:16 -0500 | [diff] [blame] | 6092 | * END OF "GENERIC" DECODE ROUTINES. | 
|  | 6093 | */ | 
|  | 6094 |  | 
|  | 6095 | /* | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6096 | * Decode OPEN_DOWNGRADE response | 
|  | 6097 | */ | 
| Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6098 | static int nfs4_xdr_dec_open_downgrade(struct rpc_rqst *rqstp, | 
|  | 6099 | struct xdr_stream *xdr, | 
|  | 6100 | struct nfs_closeres *res) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6101 | { | 
| Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6102 | struct compound_hdr hdr; | 
|  | 6103 | int status; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6104 |  | 
| Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6105 | status = decode_compound_hdr(xdr, &hdr); | 
| Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6106 | if (status) | 
|  | 6107 | goto out; | 
| Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6108 | status = decode_sequence(xdr, &res->seq_res, rqstp); | 
| Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6109 | if (status) | 
|  | 6110 | goto out; | 
| Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6111 | status = decode_putfh(xdr); | 
| Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6112 | if (status) | 
|  | 6113 | goto out; | 
| Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6114 | status = decode_open_downgrade(xdr, res); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6115 | out: | 
| Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6116 | return status; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6117 | } | 
|  | 6118 |  | 
|  | 6119 | /* | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6120 | * Decode ACCESS response | 
|  | 6121 | */ | 
| Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6122 | static int nfs4_xdr_dec_access(struct rpc_rqst *rqstp, struct xdr_stream *xdr, | 
|  | 6123 | struct nfs4_accessres *res) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6124 | { | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6125 | struct compound_hdr hdr; | 
|  | 6126 | int status; | 
| Andy Adamson | 6c0195a | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6127 |  | 
| Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6128 | status = decode_compound_hdr(xdr, &hdr); | 
| Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6129 | if (status) | 
|  | 6130 | goto out; | 
| Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6131 | status = decode_sequence(xdr, &res->seq_res, rqstp); | 
| Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6132 | if (status) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6133 | goto out; | 
| Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6134 | status = decode_putfh(xdr); | 
| Trond Myklebust | 76b3299 | 2007-08-10 17:45:11 -0400 | [diff] [blame] | 6135 | if (status != 0) | 
|  | 6136 | goto out; | 
| Weston Andros Adamson | 6168f62 | 2012-09-10 14:00:46 -0400 | [diff] [blame] | 6137 | status = decode_access(xdr, &res->supported, &res->access); | 
| Trond Myklebust | 76b3299 | 2007-08-10 17:45:11 -0400 | [diff] [blame] | 6138 | if (status != 0) | 
|  | 6139 | goto out; | 
| Trond Myklebust | 6926afd | 2012-01-07 13:22:46 -0500 | [diff] [blame] | 6140 | decode_getfattr(xdr, res->fattr, res->server); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6141 | out: | 
|  | 6142 | return status; | 
|  | 6143 | } | 
|  | 6144 |  | 
|  | 6145 | /* | 
|  | 6146 | * Decode LOOKUP response | 
|  | 6147 | */ | 
| Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6148 | static int nfs4_xdr_dec_lookup(struct rpc_rqst *rqstp, struct xdr_stream *xdr, | 
|  | 6149 | struct nfs4_lookup_res *res) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6150 | { | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6151 | struct compound_hdr hdr; | 
|  | 6152 | int status; | 
| Andy Adamson | 6c0195a | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6153 |  | 
| Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6154 | status = decode_compound_hdr(xdr, &hdr); | 
| Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6155 | if (status) | 
|  | 6156 | goto out; | 
| Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6157 | status = decode_sequence(xdr, &res->seq_res, rqstp); | 
| Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6158 | if (status) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6159 | goto out; | 
| Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6160 | status = decode_putfh(xdr); | 
|  | 6161 | if (status) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6162 | goto out; | 
| Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6163 | status = decode_lookup(xdr); | 
|  | 6164 | if (status) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6165 | goto out; | 
| Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6166 | status = decode_getfh(xdr, res->fh); | 
|  | 6167 | if (status) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6168 | goto out; | 
| David Quigley | aa9c266 | 2013-05-22 12:50:44 -0400 | [diff] [blame] | 6169 | status = decode_getfattr_label(xdr, res->fattr, res->label, res->server); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6170 | out: | 
|  | 6171 | return status; | 
|  | 6172 | } | 
|  | 6173 |  | 
|  | 6174 | /* | 
|  | 6175 | * Decode LOOKUP_ROOT response | 
|  | 6176 | */ | 
| Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6177 | static int nfs4_xdr_dec_lookup_root(struct rpc_rqst *rqstp, | 
|  | 6178 | struct xdr_stream *xdr, | 
|  | 6179 | struct nfs4_lookup_res *res) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6180 | { | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6181 | struct compound_hdr hdr; | 
|  | 6182 | int status; | 
| Andy Adamson | 6c0195a | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6183 |  | 
| Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6184 | status = decode_compound_hdr(xdr, &hdr); | 
| Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6185 | if (status) | 
|  | 6186 | goto out; | 
| Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6187 | status = decode_sequence(xdr, &res->seq_res, rqstp); | 
| Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6188 | if (status) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6189 | goto out; | 
| Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6190 | status = decode_putrootfh(xdr); | 
|  | 6191 | if (status) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6192 | goto out; | 
| Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6193 | status = decode_getfh(xdr, res->fh); | 
|  | 6194 | if (status == 0) | 
| David Quigley | aa9c266 | 2013-05-22 12:50:44 -0400 | [diff] [blame] | 6195 | status = decode_getfattr_label(xdr, res->fattr, | 
|  | 6196 | res->label, res->server); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6197 | out: | 
|  | 6198 | return status; | 
|  | 6199 | } | 
|  | 6200 |  | 
|  | 6201 | /* | 
|  | 6202 | * Decode REMOVE response | 
|  | 6203 | */ | 
| Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6204 | static int nfs4_xdr_dec_remove(struct rpc_rqst *rqstp, struct xdr_stream *xdr, | 
|  | 6205 | struct nfs_removeres *res) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6206 | { | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6207 | struct compound_hdr hdr; | 
|  | 6208 | int status; | 
| Andy Adamson | 6c0195a | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6209 |  | 
| Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6210 | status = decode_compound_hdr(xdr, &hdr); | 
| Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6211 | if (status) | 
|  | 6212 | goto out; | 
| Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6213 | status = decode_sequence(xdr, &res->seq_res, rqstp); | 
| Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6214 | if (status) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6215 | goto out; | 
| Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6216 | status = decode_putfh(xdr); | 
|  | 6217 | if (status) | 
| Trond Myklebust | 16e4295 | 2005-10-27 22:12:44 -0400 | [diff] [blame] | 6218 | goto out; | 
| Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6219 | status = decode_remove(xdr, &res->cinfo); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6220 | out: | 
|  | 6221 | return status; | 
|  | 6222 | } | 
|  | 6223 |  | 
|  | 6224 | /* | 
|  | 6225 | * Decode RENAME response | 
|  | 6226 | */ | 
| Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6227 | static int nfs4_xdr_dec_rename(struct rpc_rqst *rqstp, struct xdr_stream *xdr, | 
|  | 6228 | struct nfs_renameres *res) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6229 | { | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6230 | struct compound_hdr hdr; | 
|  | 6231 | int status; | 
| Andy Adamson | 6c0195a | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6232 |  | 
| Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6233 | status = decode_compound_hdr(xdr, &hdr); | 
| Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6234 | if (status) | 
|  | 6235 | goto out; | 
| Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6236 | status = decode_sequence(xdr, &res->seq_res, rqstp); | 
| Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6237 | if (status) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6238 | goto out; | 
| Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6239 | status = decode_putfh(xdr); | 
|  | 6240 | if (status) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6241 | goto out; | 
| Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6242 | status = decode_savefh(xdr); | 
|  | 6243 | if (status) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6244 | goto out; | 
| Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6245 | status = decode_putfh(xdr); | 
|  | 6246 | if (status) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6247 | goto out; | 
| Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6248 | status = decode_rename(xdr, &res->old_cinfo, &res->new_cinfo); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6249 | out: | 
|  | 6250 | return status; | 
|  | 6251 | } | 
|  | 6252 |  | 
|  | 6253 | /* | 
|  | 6254 | * Decode LINK response | 
|  | 6255 | */ | 
| Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6256 | static int nfs4_xdr_dec_link(struct rpc_rqst *rqstp, struct xdr_stream *xdr, | 
|  | 6257 | struct nfs4_link_res *res) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6258 | { | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6259 | struct compound_hdr hdr; | 
|  | 6260 | int status; | 
| Andy Adamson | 6c0195a | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6261 |  | 
| Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6262 | status = decode_compound_hdr(xdr, &hdr); | 
| Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6263 | if (status) | 
|  | 6264 | goto out; | 
| Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6265 | status = decode_sequence(xdr, &res->seq_res, rqstp); | 
| Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6266 | if (status) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6267 | goto out; | 
| Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6268 | status = decode_putfh(xdr); | 
|  | 6269 | if (status) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6270 | goto out; | 
| Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6271 | status = decode_savefh(xdr); | 
|  | 6272 | if (status) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6273 | goto out; | 
| Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6274 | status = decode_putfh(xdr); | 
|  | 6275 | if (status) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6276 | goto out; | 
| Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6277 | status = decode_link(xdr, &res->cinfo); | 
|  | 6278 | if (status) | 
| Trond Myklebust | 91ba2ee | 2005-10-27 22:12:42 -0400 | [diff] [blame] | 6279 | goto out; | 
|  | 6280 | /* | 
|  | 6281 | * Note order: OP_LINK leaves the directory as the current | 
|  | 6282 | *             filehandle. | 
|  | 6283 | */ | 
| Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6284 | status = decode_restorefh(xdr); | 
|  | 6285 | if (status) | 
| Trond Myklebust | 91ba2ee | 2005-10-27 22:12:42 -0400 | [diff] [blame] | 6286 | goto out; | 
| David Quigley | aa9c266 | 2013-05-22 12:50:44 -0400 | [diff] [blame] | 6287 | decode_getfattr_label(xdr, res->fattr, res->label, res->server); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6288 | out: | 
|  | 6289 | return status; | 
|  | 6290 | } | 
|  | 6291 |  | 
|  | 6292 | /* | 
|  | 6293 | * Decode CREATE response | 
|  | 6294 | */ | 
| Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6295 | static int nfs4_xdr_dec_create(struct rpc_rqst *rqstp, struct xdr_stream *xdr, | 
|  | 6296 | struct nfs4_create_res *res) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6297 | { | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6298 | struct compound_hdr hdr; | 
|  | 6299 | int status; | 
| Andy Adamson | 6c0195a | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6300 |  | 
| Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6301 | status = decode_compound_hdr(xdr, &hdr); | 
| Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6302 | if (status) | 
|  | 6303 | goto out; | 
| Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6304 | status = decode_sequence(xdr, &res->seq_res, rqstp); | 
| Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6305 | if (status) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6306 | goto out; | 
| Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6307 | status = decode_putfh(xdr); | 
|  | 6308 | if (status) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6309 | goto out; | 
| Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6310 | status = decode_create(xdr, &res->dir_cinfo); | 
|  | 6311 | if (status) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6312 | goto out; | 
| Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6313 | status = decode_getfh(xdr, res->fh); | 
|  | 6314 | if (status) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6315 | goto out; | 
| David Quigley | aa9c266 | 2013-05-22 12:50:44 -0400 | [diff] [blame] | 6316 | decode_getfattr_label(xdr, res->fattr, res->label, res->server); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6317 | out: | 
|  | 6318 | return status; | 
|  | 6319 | } | 
|  | 6320 |  | 
|  | 6321 | /* | 
|  | 6322 | * Decode SYMLINK response | 
|  | 6323 | */ | 
| Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6324 | static int nfs4_xdr_dec_symlink(struct rpc_rqst *rqstp, struct xdr_stream *xdr, | 
|  | 6325 | struct nfs4_create_res *res) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6326 | { | 
| Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6327 | return nfs4_xdr_dec_create(rqstp, xdr, res); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6328 | } | 
|  | 6329 |  | 
|  | 6330 | /* | 
|  | 6331 | * Decode GETATTR response | 
|  | 6332 | */ | 
| Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6333 | static int nfs4_xdr_dec_getattr(struct rpc_rqst *rqstp, struct xdr_stream *xdr, | 
|  | 6334 | struct nfs4_getattr_res *res) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6335 | { | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6336 | struct compound_hdr hdr; | 
|  | 6337 | int status; | 
| Andy Adamson | 6c0195a | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6338 |  | 
| Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6339 | status = decode_compound_hdr(xdr, &hdr); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6340 | if (status) | 
|  | 6341 | goto out; | 
| Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6342 | status = decode_sequence(xdr, &res->seq_res, rqstp); | 
| Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6343 | if (status) | 
|  | 6344 | goto out; | 
| Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6345 | status = decode_putfh(xdr); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6346 | if (status) | 
|  | 6347 | goto out; | 
| David Quigley | aa9c266 | 2013-05-22 12:50:44 -0400 | [diff] [blame] | 6348 | status = decode_getfattr_label(xdr, res->fattr, res->label, res->server); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6349 | out: | 
|  | 6350 | return status; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6351 | } | 
|  | 6352 |  | 
| J. Bruce Fields | 23ec696 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 6353 | /* | 
|  | 6354 | * Encode an SETACL request | 
|  | 6355 | */ | 
| Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 6356 | static void nfs4_xdr_enc_setacl(struct rpc_rqst *req, struct xdr_stream *xdr, | 
|  | 6357 | struct nfs_setaclargs *args) | 
| J. Bruce Fields | 23ec696 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 6358 | { | 
| Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6359 | struct compound_hdr hdr = { | 
| Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 6360 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), | 
| Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6361 | }; | 
| J. Bruce Fields | 23ec696 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 6362 |  | 
| Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 6363 | encode_compound_hdr(xdr, req, &hdr); | 
|  | 6364 | encode_sequence(xdr, &args->seq_args, &hdr); | 
|  | 6365 | encode_putfh(xdr, args->fh, &hdr); | 
|  | 6366 | encode_setacl(xdr, args, &hdr); | 
| Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 6367 | encode_nops(&hdr); | 
| J. Bruce Fields | 23ec696 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 6368 | } | 
| Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6369 |  | 
| J. Bruce Fields | 23ec696 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 6370 | /* | 
|  | 6371 | * Decode SETACL response | 
|  | 6372 | */ | 
|  | 6373 | static int | 
| Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6374 | nfs4_xdr_dec_setacl(struct rpc_rqst *rqstp, struct xdr_stream *xdr, | 
| Benny Halevy | 73c403a | 2009-04-01 09:22:01 -0400 | [diff] [blame] | 6375 | struct nfs_setaclres *res) | 
| J. Bruce Fields | 23ec696 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 6376 | { | 
| J. Bruce Fields | 23ec696 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 6377 | struct compound_hdr hdr; | 
|  | 6378 | int status; | 
|  | 6379 |  | 
| Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6380 | status = decode_compound_hdr(xdr, &hdr); | 
| J. Bruce Fields | 23ec696 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 6381 | if (status) | 
|  | 6382 | goto out; | 
| Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6383 | status = decode_sequence(xdr, &res->seq_res, rqstp); | 
| Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6384 | if (status) | 
|  | 6385 | goto out; | 
| Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6386 | status = decode_putfh(xdr); | 
| J. Bruce Fields | 23ec696 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 6387 | if (status) | 
|  | 6388 | goto out; | 
| Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6389 | status = decode_setattr(xdr); | 
| J. Bruce Fields | 23ec696 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 6390 | out: | 
|  | 6391 | return status; | 
|  | 6392 | } | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6393 |  | 
|  | 6394 | /* | 
| J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 6395 | * Decode GETACL response | 
|  | 6396 | */ | 
|  | 6397 | static int | 
| Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6398 | nfs4_xdr_dec_getacl(struct rpc_rqst *rqstp, struct xdr_stream *xdr, | 
| Benny Halevy | 663c79b | 2009-04-01 09:21:59 -0400 | [diff] [blame] | 6399 | struct nfs_getaclres *res) | 
| J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 6400 | { | 
| J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 6401 | struct compound_hdr hdr; | 
|  | 6402 | int status; | 
|  | 6403 |  | 
| Trond Myklebust | 331818f | 2012-02-03 18:30:53 -0500 | [diff] [blame] | 6404 | if (res->acl_scratch != NULL) { | 
|  | 6405 | void *p = page_address(res->acl_scratch); | 
|  | 6406 | xdr_set_scratch_buffer(xdr, p, PAGE_SIZE); | 
|  | 6407 | } | 
| Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6408 | status = decode_compound_hdr(xdr, &hdr); | 
| J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 6409 | if (status) | 
|  | 6410 | goto out; | 
| Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6411 | status = decode_sequence(xdr, &res->seq_res, rqstp); | 
| Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6412 | if (status) | 
|  | 6413 | goto out; | 
| Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6414 | status = decode_putfh(xdr); | 
| J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 6415 | if (status) | 
|  | 6416 | goto out; | 
| Andy Adamson | bf118a3 | 2011-12-07 11:55:27 -0500 | [diff] [blame] | 6417 | status = decode_getacl(xdr, rqstp, res); | 
| J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 6418 |  | 
|  | 6419 | out: | 
|  | 6420 | return status; | 
|  | 6421 | } | 
|  | 6422 |  | 
|  | 6423 | /* | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6424 | * Decode CLOSE response | 
|  | 6425 | */ | 
| Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6426 | static int nfs4_xdr_dec_close(struct rpc_rqst *rqstp, struct xdr_stream *xdr, | 
|  | 6427 | struct nfs_closeres *res) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6428 | { | 
| Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6429 | struct compound_hdr hdr; | 
|  | 6430 | int status; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6431 |  | 
| Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6432 | status = decode_compound_hdr(xdr, &hdr); | 
| Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6433 | if (status) | 
|  | 6434 | goto out; | 
| Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6435 | status = decode_sequence(xdr, &res->seq_res, rqstp); | 
| Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6436 | if (status) | 
|  | 6437 | goto out; | 
| Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6438 | status = decode_putfh(xdr); | 
| Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6439 | if (status) | 
|  | 6440 | goto out; | 
| Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6441 | status = decode_close(xdr, res); | 
| Trond Myklebust | 516a6af | 2005-10-27 22:12:41 -0400 | [diff] [blame] | 6442 | if (status != 0) | 
|  | 6443 | goto out; | 
|  | 6444 | /* | 
|  | 6445 | * Note: Server may do delete on close for this file | 
|  | 6446 | * 	in which case the getattr call will fail with | 
|  | 6447 | * 	an ESTALE error. Shouldn't be a problem, | 
|  | 6448 | * 	though, since fattr->valid will remain unset. | 
|  | 6449 | */ | 
| Trond Myklebust | 6926afd | 2012-01-07 13:22:46 -0500 | [diff] [blame] | 6450 | decode_getfattr(xdr, res->fattr, res->server); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6451 | out: | 
| Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6452 | return status; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6453 | } | 
|  | 6454 |  | 
|  | 6455 | /* | 
|  | 6456 | * Decode OPEN response | 
|  | 6457 | */ | 
| Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6458 | static int nfs4_xdr_dec_open(struct rpc_rqst *rqstp, struct xdr_stream *xdr, | 
|  | 6459 | struct nfs_openres *res) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6460 | { | 
| Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6461 | struct compound_hdr hdr; | 
|  | 6462 | int status; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6463 |  | 
| Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6464 | status = decode_compound_hdr(xdr, &hdr); | 
| Trond Myklebust | 56ae19f | 2005-10-27 22:12:40 -0400 | [diff] [blame] | 6465 | if (status) | 
|  | 6466 | goto out; | 
| Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6467 | status = decode_sequence(xdr, &res->seq_res, rqstp); | 
| Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6468 | if (status) | 
|  | 6469 | goto out; | 
| Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6470 | status = decode_putfh(xdr); | 
| Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6471 | if (status) | 
|  | 6472 | goto out; | 
| Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6473 | status = decode_open(xdr, res); | 
| Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6474 | if (status) | 
|  | 6475 | goto out; | 
| Weston Andros Adamson | 01913b4 | 2012-09-06 15:54:27 -0400 | [diff] [blame] | 6476 | status = decode_getfh(xdr, &res->fh); | 
|  | 6477 | if (status) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6478 | goto out; | 
| Weston Andros Adamson | ae2bb03 | 2012-10-02 14:49:52 -0700 | [diff] [blame] | 6479 | if (res->access_request) | 
|  | 6480 | decode_access(xdr, &res->access_supported, &res->access_result); | 
| David Quigley | aa9c266 | 2013-05-22 12:50:44 -0400 | [diff] [blame] | 6481 | decode_getfattr_label(xdr, res->f_attr, res->f_label, res->server); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6482 | out: | 
| Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6483 | return status; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6484 | } | 
|  | 6485 |  | 
|  | 6486 | /* | 
|  | 6487 | * Decode OPEN_CONFIRM response | 
|  | 6488 | */ | 
| Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6489 | static int nfs4_xdr_dec_open_confirm(struct rpc_rqst *rqstp, | 
|  | 6490 | struct xdr_stream *xdr, | 
|  | 6491 | struct nfs_open_confirmres *res) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6492 | { | 
| Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6493 | struct compound_hdr hdr; | 
|  | 6494 | int status; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6495 |  | 
| Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6496 | status = decode_compound_hdr(xdr, &hdr); | 
| Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6497 | if (status) | 
|  | 6498 | goto out; | 
| Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6499 | status = decode_putfh(xdr); | 
| Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6500 | if (status) | 
|  | 6501 | goto out; | 
| Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6502 | status = decode_open_confirm(xdr, res); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6503 | out: | 
| Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6504 | return status; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6505 | } | 
|  | 6506 |  | 
|  | 6507 | /* | 
|  | 6508 | * Decode OPEN response | 
|  | 6509 | */ | 
| Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6510 | static int nfs4_xdr_dec_open_noattr(struct rpc_rqst *rqstp, | 
|  | 6511 | struct xdr_stream *xdr, | 
|  | 6512 | struct nfs_openres *res) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6513 | { | 
| Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6514 | struct compound_hdr hdr; | 
|  | 6515 | int status; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6516 |  | 
| Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6517 | status = decode_compound_hdr(xdr, &hdr); | 
| Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6518 | if (status) | 
|  | 6519 | goto out; | 
| Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6520 | status = decode_sequence(xdr, &res->seq_res, rqstp); | 
| Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6521 | if (status) | 
|  | 6522 | goto out; | 
| Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6523 | status = decode_putfh(xdr); | 
| Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6524 | if (status) | 
|  | 6525 | goto out; | 
| Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6526 | status = decode_open(xdr, res); | 
| Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6527 | if (status) | 
|  | 6528 | goto out; | 
| Weston Andros Adamson | ae2bb03 | 2012-10-02 14:49:52 -0700 | [diff] [blame] | 6529 | if (res->access_request) | 
|  | 6530 | decode_access(xdr, &res->access_supported, &res->access_result); | 
| Trond Myklebust | 6926afd | 2012-01-07 13:22:46 -0500 | [diff] [blame] | 6531 | decode_getfattr(xdr, res->f_attr, res->server); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6532 | out: | 
| Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6533 | return status; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6534 | } | 
|  | 6535 |  | 
|  | 6536 | /* | 
|  | 6537 | * Decode SETATTR response | 
|  | 6538 | */ | 
| Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6539 | static int nfs4_xdr_dec_setattr(struct rpc_rqst *rqstp, | 
|  | 6540 | struct xdr_stream *xdr, | 
|  | 6541 | struct nfs_setattrres *res) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6542 | { | 
| Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6543 | struct compound_hdr hdr; | 
|  | 6544 | int status; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6545 |  | 
| Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6546 | status = decode_compound_hdr(xdr, &hdr); | 
| Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6547 | if (status) | 
|  | 6548 | goto out; | 
| Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6549 | status = decode_sequence(xdr, &res->seq_res, rqstp); | 
| Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6550 | if (status) | 
|  | 6551 | goto out; | 
| Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6552 | status = decode_putfh(xdr); | 
| Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6553 | if (status) | 
|  | 6554 | goto out; | 
| Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6555 | status = decode_setattr(xdr); | 
| Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6556 | if (status) | 
|  | 6557 | goto out; | 
| David Quigley | aa9c266 | 2013-05-22 12:50:44 -0400 | [diff] [blame] | 6558 | decode_getfattr_label(xdr, res->fattr, res->label, res->server); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6559 | out: | 
| Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6560 | return status; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6561 | } | 
|  | 6562 |  | 
|  | 6563 | /* | 
|  | 6564 | * Decode LOCK response | 
|  | 6565 | */ | 
| Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6566 | static int nfs4_xdr_dec_lock(struct rpc_rqst *rqstp, struct xdr_stream *xdr, | 
|  | 6567 | struct nfs_lock_res *res) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6568 | { | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6569 | struct compound_hdr hdr; | 
|  | 6570 | int status; | 
|  | 6571 |  | 
| Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6572 | status = decode_compound_hdr(xdr, &hdr); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6573 | if (status) | 
|  | 6574 | goto out; | 
| Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6575 | status = decode_sequence(xdr, &res->seq_res, rqstp); | 
| Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6576 | if (status) | 
|  | 6577 | goto out; | 
| Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6578 | status = decode_putfh(xdr); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6579 | if (status) | 
|  | 6580 | goto out; | 
| Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6581 | status = decode_lock(xdr, res); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6582 | out: | 
|  | 6583 | return status; | 
|  | 6584 | } | 
|  | 6585 |  | 
|  | 6586 | /* | 
|  | 6587 | * Decode LOCKT response | 
|  | 6588 | */ | 
| Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6589 | static int nfs4_xdr_dec_lockt(struct rpc_rqst *rqstp, struct xdr_stream *xdr, | 
|  | 6590 | struct nfs_lockt_res *res) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6591 | { | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6592 | struct compound_hdr hdr; | 
|  | 6593 | int status; | 
|  | 6594 |  | 
| Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6595 | status = decode_compound_hdr(xdr, &hdr); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6596 | if (status) | 
|  | 6597 | goto out; | 
| Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6598 | status = decode_sequence(xdr, &res->seq_res, rqstp); | 
| Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6599 | if (status) | 
|  | 6600 | goto out; | 
| Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6601 | status = decode_putfh(xdr); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6602 | if (status) | 
|  | 6603 | goto out; | 
| Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6604 | status = decode_lockt(xdr, res); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6605 | out: | 
|  | 6606 | return status; | 
|  | 6607 | } | 
|  | 6608 |  | 
|  | 6609 | /* | 
|  | 6610 | * Decode LOCKU response | 
|  | 6611 | */ | 
| Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6612 | static int nfs4_xdr_dec_locku(struct rpc_rqst *rqstp, struct xdr_stream *xdr, | 
|  | 6613 | struct nfs_locku_res *res) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6614 | { | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6615 | struct compound_hdr hdr; | 
|  | 6616 | int status; | 
|  | 6617 |  | 
| Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6618 | status = decode_compound_hdr(xdr, &hdr); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6619 | if (status) | 
|  | 6620 | goto out; | 
| Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6621 | status = decode_sequence(xdr, &res->seq_res, rqstp); | 
| Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6622 | if (status) | 
|  | 6623 | goto out; | 
| Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6624 | status = decode_putfh(xdr); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6625 | if (status) | 
|  | 6626 | goto out; | 
| Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6627 | status = decode_locku(xdr, res); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6628 | out: | 
|  | 6629 | return status; | 
|  | 6630 | } | 
|  | 6631 |  | 
| Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6632 | static int nfs4_xdr_dec_release_lockowner(struct rpc_rqst *rqstp, | 
|  | 6633 | struct xdr_stream *xdr, void *dummy) | 
| Trond Myklebust | d3c7b7c | 2010-07-01 12:49:01 -0400 | [diff] [blame] | 6634 | { | 
| Trond Myklebust | d3c7b7c | 2010-07-01 12:49:01 -0400 | [diff] [blame] | 6635 | struct compound_hdr hdr; | 
|  | 6636 | int status; | 
|  | 6637 |  | 
| Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6638 | status = decode_compound_hdr(xdr, &hdr); | 
| Trond Myklebust | d3c7b7c | 2010-07-01 12:49:01 -0400 | [diff] [blame] | 6639 | if (!status) | 
| Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6640 | status = decode_release_lockowner(xdr); | 
| Trond Myklebust | d3c7b7c | 2010-07-01 12:49:01 -0400 | [diff] [blame] | 6641 | return status; | 
|  | 6642 | } | 
|  | 6643 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6644 | /* | 
|  | 6645 | * Decode READLINK response | 
|  | 6646 | */ | 
| Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6647 | static int nfs4_xdr_dec_readlink(struct rpc_rqst *rqstp, | 
|  | 6648 | struct xdr_stream *xdr, | 
| Benny Halevy | f50c700 | 2009-04-01 09:21:55 -0400 | [diff] [blame] | 6649 | struct nfs4_readlink_res *res) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6650 | { | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6651 | struct compound_hdr hdr; | 
|  | 6652 | int status; | 
|  | 6653 |  | 
| Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6654 | status = decode_compound_hdr(xdr, &hdr); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6655 | if (status) | 
|  | 6656 | goto out; | 
| Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6657 | status = decode_sequence(xdr, &res->seq_res, rqstp); | 
| Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6658 | if (status) | 
|  | 6659 | goto out; | 
| Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6660 | status = decode_putfh(xdr); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6661 | if (status) | 
|  | 6662 | goto out; | 
| Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6663 | status = decode_readlink(xdr, rqstp); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6664 | out: | 
|  | 6665 | return status; | 
|  | 6666 | } | 
|  | 6667 |  | 
|  | 6668 | /* | 
|  | 6669 | * Decode READDIR response | 
|  | 6670 | */ | 
| Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6671 | static int nfs4_xdr_dec_readdir(struct rpc_rqst *rqstp, struct xdr_stream *xdr, | 
|  | 6672 | struct nfs4_readdir_res *res) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6673 | { | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6674 | struct compound_hdr hdr; | 
|  | 6675 | int status; | 
|  | 6676 |  | 
| Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6677 | status = decode_compound_hdr(xdr, &hdr); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6678 | if (status) | 
|  | 6679 | goto out; | 
| Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6680 | status = decode_sequence(xdr, &res->seq_res, rqstp); | 
| Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6681 | if (status) | 
|  | 6682 | goto out; | 
| Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6683 | status = decode_putfh(xdr); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6684 | if (status) | 
|  | 6685 | goto out; | 
| Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6686 | status = decode_readdir(xdr, rqstp, res); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6687 | out: | 
|  | 6688 | return status; | 
|  | 6689 | } | 
|  | 6690 |  | 
|  | 6691 | /* | 
|  | 6692 | * Decode Read response | 
|  | 6693 | */ | 
| Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6694 | static int nfs4_xdr_dec_read(struct rpc_rqst *rqstp, struct xdr_stream *xdr, | 
| Anna Schumaker | 9137bdf | 2014-05-06 09:12:25 -0400 | [diff] [blame] | 6695 | struct nfs_pgio_res *res) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6696 | { | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6697 | struct compound_hdr hdr; | 
|  | 6698 | int status; | 
|  | 6699 |  | 
| Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6700 | status = decode_compound_hdr(xdr, &hdr); | 
| Peng Tao | aabff4d | 2014-08-27 10:47:14 +0800 | [diff] [blame] | 6701 | res->op_status = hdr.status; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6702 | if (status) | 
|  | 6703 | goto out; | 
| Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6704 | status = decode_sequence(xdr, &res->seq_res, rqstp); | 
| Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6705 | if (status) | 
|  | 6706 | goto out; | 
| Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6707 | status = decode_putfh(xdr); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6708 | if (status) | 
|  | 6709 | goto out; | 
| Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6710 | status = decode_read(xdr, rqstp, res); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6711 | if (!status) | 
|  | 6712 | status = res->count; | 
|  | 6713 | out: | 
|  | 6714 | return status; | 
|  | 6715 | } | 
|  | 6716 |  | 
|  | 6717 | /* | 
|  | 6718 | * Decode WRITE response | 
|  | 6719 | */ | 
| Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6720 | static int nfs4_xdr_dec_write(struct rpc_rqst *rqstp, struct xdr_stream *xdr, | 
| Anna Schumaker | 9137bdf | 2014-05-06 09:12:25 -0400 | [diff] [blame] | 6721 | struct nfs_pgio_res *res) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6722 | { | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6723 | struct compound_hdr hdr; | 
|  | 6724 | int status; | 
|  | 6725 |  | 
| Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6726 | status = decode_compound_hdr(xdr, &hdr); | 
| Peng Tao | aabff4d | 2014-08-27 10:47:14 +0800 | [diff] [blame] | 6727 | res->op_status = hdr.status; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6728 | if (status) | 
|  | 6729 | goto out; | 
| Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6730 | status = decode_sequence(xdr, &res->seq_res, rqstp); | 
| Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6731 | if (status) | 
|  | 6732 | goto out; | 
| Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6733 | status = decode_putfh(xdr); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6734 | if (status) | 
|  | 6735 | goto out; | 
| Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6736 | status = decode_write(xdr, res); | 
| Trond Myklebust | 4f9838c | 2005-10-27 22:12:44 -0400 | [diff] [blame] | 6737 | if (status) | 
|  | 6738 | goto out; | 
| Fred Isaman | 7ffd106 | 2011-03-03 15:13:46 +0000 | [diff] [blame] | 6739 | if (res->fattr) | 
| Trond Myklebust | 6926afd | 2012-01-07 13:22:46 -0500 | [diff] [blame] | 6740 | decode_getfattr(xdr, res->fattr, res->server); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6741 | if (!status) | 
|  | 6742 | status = res->count; | 
|  | 6743 | out: | 
|  | 6744 | return status; | 
|  | 6745 | } | 
|  | 6746 |  | 
|  | 6747 | /* | 
|  | 6748 | * Decode COMMIT response | 
|  | 6749 | */ | 
| Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6750 | static int nfs4_xdr_dec_commit(struct rpc_rqst *rqstp, struct xdr_stream *xdr, | 
| Fred Isaman | 0b7c015 | 2012-04-20 14:47:39 -0400 | [diff] [blame] | 6751 | struct nfs_commitres *res) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6752 | { | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6753 | struct compound_hdr hdr; | 
|  | 6754 | int status; | 
|  | 6755 |  | 
| Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6756 | status = decode_compound_hdr(xdr, &hdr); | 
| Peng Tao | aabff4d | 2014-08-27 10:47:14 +0800 | [diff] [blame] | 6757 | res->op_status = hdr.status; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6758 | if (status) | 
|  | 6759 | goto out; | 
| Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6760 | status = decode_sequence(xdr, &res->seq_res, rqstp); | 
| Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6761 | if (status) | 
|  | 6762 | goto out; | 
| Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6763 | status = decode_putfh(xdr); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6764 | if (status) | 
|  | 6765 | goto out; | 
| Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6766 | status = decode_commit(xdr, res); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6767 | out: | 
|  | 6768 | return status; | 
|  | 6769 | } | 
|  | 6770 |  | 
|  | 6771 | /* | 
| Ricardo Labiaga | 8b17321 | 2009-12-05 16:08:39 -0500 | [diff] [blame] | 6772 | * Decode FSINFO response | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6773 | */ | 
| Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6774 | static int nfs4_xdr_dec_fsinfo(struct rpc_rqst *req, struct xdr_stream *xdr, | 
| Benny Halevy | 3dda5e4 | 2009-04-01 09:21:57 -0400 | [diff] [blame] | 6775 | struct nfs4_fsinfo_res *res) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6776 | { | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6777 | struct compound_hdr hdr; | 
|  | 6778 | int status; | 
|  | 6779 |  | 
| Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6780 | status = decode_compound_hdr(xdr, &hdr); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6781 | if (!status) | 
| Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6782 | status = decode_sequence(xdr, &res->seq_res, req); | 
| Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6783 | if (!status) | 
| Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6784 | status = decode_putfh(xdr); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6785 | if (!status) | 
| Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6786 | status = decode_fsinfo(xdr, res->fsinfo); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6787 | return status; | 
|  | 6788 | } | 
|  | 6789 |  | 
|  | 6790 | /* | 
| Ricardo Labiaga | 8b17321 | 2009-12-05 16:08:39 -0500 | [diff] [blame] | 6791 | * Decode PATHCONF response | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6792 | */ | 
| Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6793 | static int nfs4_xdr_dec_pathconf(struct rpc_rqst *req, struct xdr_stream *xdr, | 
| Benny Halevy | d45b298 | 2009-04-01 09:21:58 -0400 | [diff] [blame] | 6794 | struct nfs4_pathconf_res *res) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6795 | { | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6796 | struct compound_hdr hdr; | 
|  | 6797 | int status; | 
|  | 6798 |  | 
| Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6799 | status = decode_compound_hdr(xdr, &hdr); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6800 | if (!status) | 
| Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6801 | status = decode_sequence(xdr, &res->seq_res, req); | 
| Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6802 | if (!status) | 
| Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6803 | status = decode_putfh(xdr); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6804 | if (!status) | 
| Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6805 | status = decode_pathconf(xdr, res->pathconf); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6806 | return status; | 
|  | 6807 | } | 
|  | 6808 |  | 
|  | 6809 | /* | 
| Ricardo Labiaga | 8b17321 | 2009-12-05 16:08:39 -0500 | [diff] [blame] | 6810 | * Decode STATFS response | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6811 | */ | 
| Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6812 | static int nfs4_xdr_dec_statfs(struct rpc_rqst *req, struct xdr_stream *xdr, | 
| Benny Halevy | 24ad148 | 2009-04-01 09:21:56 -0400 | [diff] [blame] | 6813 | struct nfs4_statfs_res *res) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6814 | { | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6815 | struct compound_hdr hdr; | 
|  | 6816 | int status; | 
|  | 6817 |  | 
| Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6818 | status = decode_compound_hdr(xdr, &hdr); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6819 | if (!status) | 
| Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6820 | status = decode_sequence(xdr, &res->seq_res, req); | 
| Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6821 | if (!status) | 
| Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6822 | status = decode_putfh(xdr); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6823 | if (!status) | 
| Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6824 | status = decode_statfs(xdr, res->fsstat); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6825 | return status; | 
|  | 6826 | } | 
|  | 6827 |  | 
|  | 6828 | /* | 
| Ricardo Labiaga | 8b17321 | 2009-12-05 16:08:39 -0500 | [diff] [blame] | 6829 | * Decode GETATTR_BITMAP response | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6830 | */ | 
| Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6831 | static int nfs4_xdr_dec_server_caps(struct rpc_rqst *req, | 
|  | 6832 | struct xdr_stream *xdr, | 
|  | 6833 | struct nfs4_server_caps_res *res) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6834 | { | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6835 | struct compound_hdr hdr; | 
|  | 6836 | int status; | 
|  | 6837 |  | 
| Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6838 | status = decode_compound_hdr(xdr, &hdr); | 
| Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6839 | if (status) | 
|  | 6840 | goto out; | 
| Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6841 | status = decode_sequence(xdr, &res->seq_res, req); | 
| Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6842 | if (status) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6843 | goto out; | 
| Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6844 | status = decode_putfh(xdr); | 
|  | 6845 | if (status) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6846 | goto out; | 
| Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6847 | status = decode_server_caps(xdr, res); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6848 | out: | 
|  | 6849 | return status; | 
|  | 6850 | } | 
|  | 6851 |  | 
|  | 6852 | /* | 
|  | 6853 | * Decode RENEW response | 
|  | 6854 | */ | 
| Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6855 | static int nfs4_xdr_dec_renew(struct rpc_rqst *rqstp, struct xdr_stream *xdr, | 
|  | 6856 | void *__unused) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6857 | { | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6858 | struct compound_hdr hdr; | 
|  | 6859 | int status; | 
|  | 6860 |  | 
| Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6861 | status = decode_compound_hdr(xdr, &hdr); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6862 | if (!status) | 
| Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6863 | status = decode_renew(xdr); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6864 | return status; | 
|  | 6865 | } | 
|  | 6866 |  | 
|  | 6867 | /* | 
| Ricardo Labiaga | 8b17321 | 2009-12-05 16:08:39 -0500 | [diff] [blame] | 6868 | * Decode SETCLIENTID response | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6869 | */ | 
| Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6870 | static int nfs4_xdr_dec_setclientid(struct rpc_rqst *req, | 
|  | 6871 | struct xdr_stream *xdr, | 
|  | 6872 | struct nfs4_setclientid_res *res) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6873 | { | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6874 | struct compound_hdr hdr; | 
|  | 6875 | int status; | 
|  | 6876 |  | 
| Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6877 | status = decode_compound_hdr(xdr, &hdr); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6878 | if (!status) | 
| Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6879 | status = decode_setclientid(xdr, res); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6880 | return status; | 
|  | 6881 | } | 
|  | 6882 |  | 
|  | 6883 | /* | 
| Ricardo Labiaga | 8b17321 | 2009-12-05 16:08:39 -0500 | [diff] [blame] | 6884 | * Decode SETCLIENTID_CONFIRM response | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6885 | */ | 
| Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6886 | static int nfs4_xdr_dec_setclientid_confirm(struct rpc_rqst *req, | 
| Chuck Lever | 83ca7f5 | 2013-03-16 15:55:53 -0400 | [diff] [blame] | 6887 | struct xdr_stream *xdr) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6888 | { | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6889 | struct compound_hdr hdr; | 
|  | 6890 | int status; | 
|  | 6891 |  | 
| Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6892 | status = decode_compound_hdr(xdr, &hdr); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6893 | if (!status) | 
| Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6894 | status = decode_setclientid_confirm(xdr); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6895 | return status; | 
|  | 6896 | } | 
|  | 6897 |  | 
|  | 6898 | /* | 
| Ricardo Labiaga | 8b17321 | 2009-12-05 16:08:39 -0500 | [diff] [blame] | 6899 | * Decode DELEGRETURN response | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6900 | */ | 
| Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6901 | static int nfs4_xdr_dec_delegreturn(struct rpc_rqst *rqstp, | 
|  | 6902 | struct xdr_stream *xdr, | 
|  | 6903 | struct nfs4_delegreturnres *res) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6904 | { | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6905 | struct compound_hdr hdr; | 
|  | 6906 | int status; | 
|  | 6907 |  | 
| Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6908 | status = decode_compound_hdr(xdr, &hdr); | 
| Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6909 | if (status) | 
|  | 6910 | goto out; | 
| Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6911 | status = decode_sequence(xdr, &res->seq_res, rqstp); | 
| Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6912 | if (status) | 
| Trond Myklebust | fa178f2 | 2006-01-03 09:55:38 +0100 | [diff] [blame] | 6913 | goto out; | 
| Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6914 | status = decode_putfh(xdr); | 
| Trond Myklebust | fa178f2 | 2006-01-03 09:55:38 +0100 | [diff] [blame] | 6915 | if (status != 0) | 
|  | 6916 | goto out; | 
| Trond Myklebust | e144cbc | 2012-04-28 16:05:03 -0400 | [diff] [blame] | 6917 | status = decode_getfattr(xdr, res->fattr, res->server); | 
| Jeff Layton | 556ae3b | 2010-03-21 12:10:36 -0400 | [diff] [blame] | 6918 | if (status != 0) | 
|  | 6919 | goto out; | 
| Trond Myklebust | e144cbc | 2012-04-28 16:05:03 -0400 | [diff] [blame] | 6920 | status = decode_delegreturn(xdr); | 
| Trond Myklebust | fa178f2 | 2006-01-03 09:55:38 +0100 | [diff] [blame] | 6921 | out: | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6922 | return status; | 
|  | 6923 | } | 
|  | 6924 |  | 
| Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 6925 | /* | 
| Ricardo Labiaga | 8b17321 | 2009-12-05 16:08:39 -0500 | [diff] [blame] | 6926 | * Decode FS_LOCATIONS response | 
| Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 6927 | */ | 
| Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6928 | static int nfs4_xdr_dec_fs_locations(struct rpc_rqst *req, | 
|  | 6929 | struct xdr_stream *xdr, | 
| Benny Halevy | 2295846 | 2009-04-01 09:22:02 -0400 | [diff] [blame] | 6930 | struct nfs4_fs_locations_res *res) | 
| Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 6931 | { | 
| Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 6932 | struct compound_hdr hdr; | 
|  | 6933 | int status; | 
|  | 6934 |  | 
| Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6935 | status = decode_compound_hdr(xdr, &hdr); | 
| Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6936 | if (status) | 
|  | 6937 | goto out; | 
| Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6938 | status = decode_sequence(xdr, &res->seq_res, req); | 
| Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6939 | if (status) | 
| Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 6940 | goto out; | 
| Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6941 | status = decode_putfh(xdr); | 
|  | 6942 | if (status) | 
| Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 6943 | goto out; | 
| Chuck Lever | b03d735 | 2013-10-17 14:12:50 -0400 | [diff] [blame] | 6944 | if (res->migration) { | 
|  | 6945 | xdr_enter_page(xdr, PAGE_SIZE); | 
|  | 6946 | status = decode_getfattr_generic(xdr, | 
|  | 6947 | &res->fs_locations->fattr, | 
| Trond Myklebust | 8b7e3f4 | 2012-01-30 15:43:56 -0500 | [diff] [blame] | 6948 | NULL, res->fs_locations, | 
| David Quigley | aa9c266 | 2013-05-22 12:50:44 -0400 | [diff] [blame] | 6949 | NULL, res->fs_locations->server); | 
| Chuck Lever | b03d735 | 2013-10-17 14:12:50 -0400 | [diff] [blame] | 6950 | if (status) | 
|  | 6951 | goto out; | 
|  | 6952 | if (res->renew) | 
|  | 6953 | status = decode_renew(xdr); | 
|  | 6954 | } else { | 
|  | 6955 | status = decode_lookup(xdr); | 
|  | 6956 | if (status) | 
|  | 6957 | goto out; | 
|  | 6958 | xdr_enter_page(xdr, PAGE_SIZE); | 
|  | 6959 | status = decode_getfattr_generic(xdr, | 
|  | 6960 | &res->fs_locations->fattr, | 
|  | 6961 | NULL, res->fs_locations, | 
|  | 6962 | NULL, res->fs_locations->server); | 
|  | 6963 | } | 
| Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 6964 | out: | 
|  | 6965 | return status; | 
|  | 6966 | } | 
|  | 6967 |  | 
| Bryan Schumaker | 5a5ea0d | 2011-03-24 17:12:29 +0000 | [diff] [blame] | 6968 | /* | 
|  | 6969 | * Decode SECINFO response | 
|  | 6970 | */ | 
|  | 6971 | static int nfs4_xdr_dec_secinfo(struct rpc_rqst *rqstp, | 
|  | 6972 | struct xdr_stream *xdr, | 
|  | 6973 | struct nfs4_secinfo_res *res) | 
|  | 6974 | { | 
|  | 6975 | struct compound_hdr hdr; | 
|  | 6976 | int status; | 
|  | 6977 |  | 
|  | 6978 | status = decode_compound_hdr(xdr, &hdr); | 
|  | 6979 | if (status) | 
|  | 6980 | goto out; | 
|  | 6981 | status = decode_sequence(xdr, &res->seq_res, rqstp); | 
|  | 6982 | if (status) | 
|  | 6983 | goto out; | 
|  | 6984 | status = decode_putfh(xdr); | 
|  | 6985 | if (status) | 
|  | 6986 | goto out; | 
|  | 6987 | status = decode_secinfo(xdr, res); | 
| Bryan Schumaker | 5a5ea0d | 2011-03-24 17:12:29 +0000 | [diff] [blame] | 6988 | out: | 
|  | 6989 | return status; | 
|  | 6990 | } | 
|  | 6991 |  | 
| Chuck Lever | 44c9993 | 2013-10-17 14:13:30 -0400 | [diff] [blame] | 6992 | /* | 
|  | 6993 | * Decode FSID_PRESENT response | 
|  | 6994 | */ | 
|  | 6995 | static int nfs4_xdr_dec_fsid_present(struct rpc_rqst *rqstp, | 
|  | 6996 | struct xdr_stream *xdr, | 
|  | 6997 | struct nfs4_fsid_present_res *res) | 
|  | 6998 | { | 
|  | 6999 | struct compound_hdr hdr; | 
|  | 7000 | int status; | 
|  | 7001 |  | 
|  | 7002 | status = decode_compound_hdr(xdr, &hdr); | 
|  | 7003 | if (status) | 
|  | 7004 | goto out; | 
|  | 7005 | status = decode_sequence(xdr, &res->seq_res, rqstp); | 
|  | 7006 | if (status) | 
|  | 7007 | goto out; | 
|  | 7008 | status = decode_putfh(xdr); | 
|  | 7009 | if (status) | 
|  | 7010 | goto out; | 
|  | 7011 | status = decode_getfh(xdr, res->fh); | 
|  | 7012 | if (status) | 
|  | 7013 | goto out; | 
|  | 7014 | if (res->renew) | 
|  | 7015 | status = decode_renew(xdr); | 
|  | 7016 | out: | 
|  | 7017 | return status; | 
|  | 7018 | } | 
|  | 7019 |  | 
| Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 7020 | #if defined(CONFIG_NFS_V4_1) | 
|  | 7021 | /* | 
| Weston Andros Adamson | 7c44f1ae | 2012-05-24 13:22:50 -0400 | [diff] [blame] | 7022 | * Decode BIND_CONN_TO_SESSION response | 
|  | 7023 | */ | 
|  | 7024 | static int nfs4_xdr_dec_bind_conn_to_session(struct rpc_rqst *rqstp, | 
|  | 7025 | struct xdr_stream *xdr, | 
|  | 7026 | void *res) | 
|  | 7027 | { | 
|  | 7028 | struct compound_hdr hdr; | 
|  | 7029 | int status; | 
|  | 7030 |  | 
|  | 7031 | status = decode_compound_hdr(xdr, &hdr); | 
|  | 7032 | if (!status) | 
|  | 7033 | status = decode_bind_conn_to_session(xdr, res); | 
|  | 7034 | return status; | 
|  | 7035 | } | 
|  | 7036 |  | 
|  | 7037 | /* | 
| Ricardo Labiaga | 8b17321 | 2009-12-05 16:08:39 -0500 | [diff] [blame] | 7038 | * Decode EXCHANGE_ID response | 
| Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 7039 | */ | 
| Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 7040 | static int nfs4_xdr_dec_exchange_id(struct rpc_rqst *rqstp, | 
|  | 7041 | struct xdr_stream *xdr, | 
| Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 7042 | void *res) | 
|  | 7043 | { | 
| Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 7044 | struct compound_hdr hdr; | 
|  | 7045 | int status; | 
|  | 7046 |  | 
| Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 7047 | status = decode_compound_hdr(xdr, &hdr); | 
| Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 7048 | if (!status) | 
| Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 7049 | status = decode_exchange_id(xdr, res); | 
| Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 7050 | return status; | 
|  | 7051 | } | 
| Andy Adamson | 2050f0c | 2009-04-01 09:22:30 -0400 | [diff] [blame] | 7052 |  | 
|  | 7053 | /* | 
| Ricardo Labiaga | 8b17321 | 2009-12-05 16:08:39 -0500 | [diff] [blame] | 7054 | * Decode CREATE_SESSION response | 
| Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 7055 | */ | 
| Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 7056 | static int nfs4_xdr_dec_create_session(struct rpc_rqst *rqstp, | 
|  | 7057 | struct xdr_stream *xdr, | 
| Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 7058 | struct nfs41_create_session_res *res) | 
|  | 7059 | { | 
| Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 7060 | struct compound_hdr hdr; | 
|  | 7061 | int status; | 
|  | 7062 |  | 
| Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 7063 | status = decode_compound_hdr(xdr, &hdr); | 
| Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 7064 | if (!status) | 
| Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 7065 | status = decode_create_session(xdr, res); | 
| Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 7066 | return status; | 
|  | 7067 | } | 
|  | 7068 |  | 
|  | 7069 | /* | 
| Ricardo Labiaga | 8b17321 | 2009-12-05 16:08:39 -0500 | [diff] [blame] | 7070 | * Decode DESTROY_SESSION response | 
| Andy Adamson | 0f3e66c | 2009-04-01 09:22:34 -0400 | [diff] [blame] | 7071 | */ | 
| Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 7072 | static int nfs4_xdr_dec_destroy_session(struct rpc_rqst *rqstp, | 
|  | 7073 | struct xdr_stream *xdr, | 
|  | 7074 | void *res) | 
| Andy Adamson | 0f3e66c | 2009-04-01 09:22:34 -0400 | [diff] [blame] | 7075 | { | 
| Andy Adamson | 0f3e66c | 2009-04-01 09:22:34 -0400 | [diff] [blame] | 7076 | struct compound_hdr hdr; | 
|  | 7077 | int status; | 
|  | 7078 |  | 
| Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 7079 | status = decode_compound_hdr(xdr, &hdr); | 
| Andy Adamson | 0f3e66c | 2009-04-01 09:22:34 -0400 | [diff] [blame] | 7080 | if (!status) | 
| Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 7081 | status = decode_destroy_session(xdr, res); | 
| Andy Adamson | 0f3e66c | 2009-04-01 09:22:34 -0400 | [diff] [blame] | 7082 | return status; | 
|  | 7083 | } | 
|  | 7084 |  | 
|  | 7085 | /* | 
| Trond Myklebust | 6624553 | 2012-05-25 17:18:09 -0400 | [diff] [blame] | 7086 | * Decode DESTROY_CLIENTID response | 
|  | 7087 | */ | 
|  | 7088 | static int nfs4_xdr_dec_destroy_clientid(struct rpc_rqst *rqstp, | 
|  | 7089 | struct xdr_stream *xdr, | 
|  | 7090 | void *res) | 
|  | 7091 | { | 
|  | 7092 | struct compound_hdr hdr; | 
|  | 7093 | int status; | 
|  | 7094 |  | 
|  | 7095 | status = decode_compound_hdr(xdr, &hdr); | 
|  | 7096 | if (!status) | 
|  | 7097 | status = decode_destroy_clientid(xdr, res); | 
|  | 7098 | return status; | 
|  | 7099 | } | 
|  | 7100 |  | 
|  | 7101 | /* | 
| Ricardo Labiaga | 8b17321 | 2009-12-05 16:08:39 -0500 | [diff] [blame] | 7102 | * Decode SEQUENCE response | 
| Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 7103 | */ | 
| Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 7104 | static int nfs4_xdr_dec_sequence(struct rpc_rqst *rqstp, | 
|  | 7105 | struct xdr_stream *xdr, | 
| Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 7106 | struct nfs4_sequence_res *res) | 
|  | 7107 | { | 
| Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 7108 | struct compound_hdr hdr; | 
|  | 7109 | int status; | 
|  | 7110 |  | 
| Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 7111 | status = decode_compound_hdr(xdr, &hdr); | 
| Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 7112 | if (!status) | 
| Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 7113 | status = decode_sequence(xdr, res, rqstp); | 
| Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 7114 | return status; | 
|  | 7115 | } | 
|  | 7116 |  | 
|  | 7117 | /* | 
| Ricardo Labiaga | 8b17321 | 2009-12-05 16:08:39 -0500 | [diff] [blame] | 7118 | * Decode GET_LEASE_TIME response | 
| Andy Adamson | 2050f0c | 2009-04-01 09:22:30 -0400 | [diff] [blame] | 7119 | */ | 
| Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 7120 | static int nfs4_xdr_dec_get_lease_time(struct rpc_rqst *rqstp, | 
|  | 7121 | struct xdr_stream *xdr, | 
| Andy Adamson | 2050f0c | 2009-04-01 09:22:30 -0400 | [diff] [blame] | 7122 | struct nfs4_get_lease_time_res *res) | 
|  | 7123 | { | 
| Andy Adamson | 2050f0c | 2009-04-01 09:22:30 -0400 | [diff] [blame] | 7124 | struct compound_hdr hdr; | 
|  | 7125 | int status; | 
|  | 7126 |  | 
| Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 7127 | status = decode_compound_hdr(xdr, &hdr); | 
| Andy Adamson | 2050f0c | 2009-04-01 09:22:30 -0400 | [diff] [blame] | 7128 | if (!status) | 
| Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 7129 | status = decode_sequence(xdr, &res->lr_seq_res, rqstp); | 
| Andy Adamson | 2050f0c | 2009-04-01 09:22:30 -0400 | [diff] [blame] | 7130 | if (!status) | 
| Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 7131 | status = decode_putrootfh(xdr); | 
| Andy Adamson | 2050f0c | 2009-04-01 09:22:30 -0400 | [diff] [blame] | 7132 | if (!status) | 
| Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 7133 | status = decode_fsinfo(xdr, res->lr_fsinfo); | 
| Andy Adamson | 2050f0c | 2009-04-01 09:22:30 -0400 | [diff] [blame] | 7134 | return status; | 
|  | 7135 | } | 
| Ricardo Labiaga | 18019753 | 2009-12-05 16:08:40 -0500 | [diff] [blame] | 7136 |  | 
|  | 7137 | /* | 
|  | 7138 | * Decode RECLAIM_COMPLETE response | 
|  | 7139 | */ | 
| Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 7140 | static int nfs4_xdr_dec_reclaim_complete(struct rpc_rqst *rqstp, | 
|  | 7141 | struct xdr_stream *xdr, | 
| Ricardo Labiaga | 18019753 | 2009-12-05 16:08:40 -0500 | [diff] [blame] | 7142 | struct nfs41_reclaim_complete_res *res) | 
|  | 7143 | { | 
| Ricardo Labiaga | 18019753 | 2009-12-05 16:08:40 -0500 | [diff] [blame] | 7144 | struct compound_hdr hdr; | 
|  | 7145 | int status; | 
|  | 7146 |  | 
| Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 7147 | status = decode_compound_hdr(xdr, &hdr); | 
| Ricardo Labiaga | 18019753 | 2009-12-05 16:08:40 -0500 | [diff] [blame] | 7148 | if (!status) | 
| Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 7149 | status = decode_sequence(xdr, &res->seq_res, rqstp); | 
| Ricardo Labiaga | 18019753 | 2009-12-05 16:08:40 -0500 | [diff] [blame] | 7150 | if (!status) | 
| Himangi Saraogi | 8ee2b78 | 2014-06-27 00:09:09 +0530 | [diff] [blame] | 7151 | status = decode_reclaim_complete(xdr, NULL); | 
| Ricardo Labiaga | 18019753 | 2009-12-05 16:08:40 -0500 | [diff] [blame] | 7152 | return status; | 
|  | 7153 | } | 
| Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 7154 |  | 
|  | 7155 | /* | 
|  | 7156 | * Decode GETDEVINFO response | 
|  | 7157 | */ | 
| Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 7158 | static int nfs4_xdr_dec_getdeviceinfo(struct rpc_rqst *rqstp, | 
|  | 7159 | struct xdr_stream *xdr, | 
| Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 7160 | struct nfs4_getdeviceinfo_res *res) | 
|  | 7161 | { | 
| Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 7162 | struct compound_hdr hdr; | 
|  | 7163 | int status; | 
|  | 7164 |  | 
| Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 7165 | status = decode_compound_hdr(xdr, &hdr); | 
| Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 7166 | if (status != 0) | 
|  | 7167 | goto out; | 
| Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 7168 | status = decode_sequence(xdr, &res->seq_res, rqstp); | 
| Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 7169 | if (status != 0) | 
|  | 7170 | goto out; | 
| Trond Myklebust | 4e59080 | 2015-03-09 14:01:25 -0400 | [diff] [blame] | 7171 | status = decode_getdeviceinfo(xdr, res); | 
| Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 7172 | out: | 
|  | 7173 | return status; | 
|  | 7174 | } | 
|  | 7175 |  | 
|  | 7176 | /* | 
|  | 7177 | * Decode LAYOUTGET response | 
|  | 7178 | */ | 
| Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 7179 | static int nfs4_xdr_dec_layoutget(struct rpc_rqst *rqstp, | 
|  | 7180 | struct xdr_stream *xdr, | 
| Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 7181 | struct nfs4_layoutget_res *res) | 
|  | 7182 | { | 
| Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 7183 | struct compound_hdr hdr; | 
|  | 7184 | int status; | 
|  | 7185 |  | 
| Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 7186 | status = decode_compound_hdr(xdr, &hdr); | 
| Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 7187 | if (status) | 
|  | 7188 | goto out; | 
| Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 7189 | status = decode_sequence(xdr, &res->seq_res, rqstp); | 
| Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 7190 | if (status) | 
|  | 7191 | goto out; | 
| Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 7192 | status = decode_putfh(xdr); | 
| Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 7193 | if (status) | 
|  | 7194 | goto out; | 
| Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 7195 | status = decode_layoutget(xdr, rqstp, res); | 
| Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 7196 | out: | 
|  | 7197 | return status; | 
|  | 7198 | } | 
| Andy Adamson | 863a3c6 | 2011-03-23 13:27:54 +0000 | [diff] [blame] | 7199 |  | 
|  | 7200 | /* | 
| Benny Halevy | cbe8260 | 2011-05-22 19:52:37 +0300 | [diff] [blame] | 7201 | * Decode LAYOUTRETURN response | 
|  | 7202 | */ | 
|  | 7203 | static int nfs4_xdr_dec_layoutreturn(struct rpc_rqst *rqstp, | 
|  | 7204 | struct xdr_stream *xdr, | 
|  | 7205 | struct nfs4_layoutreturn_res *res) | 
|  | 7206 | { | 
|  | 7207 | struct compound_hdr hdr; | 
|  | 7208 | int status; | 
|  | 7209 |  | 
|  | 7210 | status = decode_compound_hdr(xdr, &hdr); | 
|  | 7211 | if (status) | 
|  | 7212 | goto out; | 
|  | 7213 | status = decode_sequence(xdr, &res->seq_res, rqstp); | 
|  | 7214 | if (status) | 
|  | 7215 | goto out; | 
|  | 7216 | status = decode_putfh(xdr); | 
|  | 7217 | if (status) | 
|  | 7218 | goto out; | 
|  | 7219 | status = decode_layoutreturn(xdr, res); | 
|  | 7220 | out: | 
|  | 7221 | return status; | 
|  | 7222 | } | 
|  | 7223 |  | 
|  | 7224 | /* | 
| Andy Adamson | 863a3c6 | 2011-03-23 13:27:54 +0000 | [diff] [blame] | 7225 | * Decode LAYOUTCOMMIT response | 
|  | 7226 | */ | 
|  | 7227 | static int nfs4_xdr_dec_layoutcommit(struct rpc_rqst *rqstp, | 
|  | 7228 | struct xdr_stream *xdr, | 
|  | 7229 | struct nfs4_layoutcommit_res *res) | 
|  | 7230 | { | 
|  | 7231 | struct compound_hdr hdr; | 
|  | 7232 | int status; | 
|  | 7233 |  | 
|  | 7234 | status = decode_compound_hdr(xdr, &hdr); | 
|  | 7235 | if (status) | 
|  | 7236 | goto out; | 
|  | 7237 | status = decode_sequence(xdr, &res->seq_res, rqstp); | 
|  | 7238 | if (status) | 
|  | 7239 | goto out; | 
|  | 7240 | status = decode_putfh(xdr); | 
|  | 7241 | if (status) | 
|  | 7242 | goto out; | 
|  | 7243 | status = decode_layoutcommit(xdr, rqstp, res); | 
|  | 7244 | if (status) | 
|  | 7245 | goto out; | 
| Trond Myklebust | 6926afd | 2012-01-07 13:22:46 -0500 | [diff] [blame] | 7246 | decode_getfattr(xdr, res->fattr, res->server); | 
| Andy Adamson | 863a3c6 | 2011-03-23 13:27:54 +0000 | [diff] [blame] | 7247 | out: | 
|  | 7248 | return status; | 
|  | 7249 | } | 
| Bryan Schumaker | fca78d6 | 2011-06-02 14:59:07 -0400 | [diff] [blame] | 7250 |  | 
|  | 7251 | /* | 
|  | 7252 | * Decode SECINFO_NO_NAME response | 
|  | 7253 | */ | 
|  | 7254 | static int nfs4_xdr_dec_secinfo_no_name(struct rpc_rqst *rqstp, | 
|  | 7255 | struct xdr_stream *xdr, | 
|  | 7256 | struct nfs4_secinfo_res *res) | 
|  | 7257 | { | 
|  | 7258 | struct compound_hdr hdr; | 
|  | 7259 | int status; | 
|  | 7260 |  | 
|  | 7261 | status = decode_compound_hdr(xdr, &hdr); | 
|  | 7262 | if (status) | 
|  | 7263 | goto out; | 
|  | 7264 | status = decode_sequence(xdr, &res->seq_res, rqstp); | 
|  | 7265 | if (status) | 
|  | 7266 | goto out; | 
|  | 7267 | status = decode_putrootfh(xdr); | 
|  | 7268 | if (status) | 
|  | 7269 | goto out; | 
| Bryan Schumaker | 31e4dda | 2012-04-27 13:27:38 -0400 | [diff] [blame] | 7270 | status = decode_secinfo_no_name(xdr, res); | 
| Bryan Schumaker | fca78d6 | 2011-06-02 14:59:07 -0400 | [diff] [blame] | 7271 | out: | 
|  | 7272 | return status; | 
|  | 7273 | } | 
| Bryan Schumaker | 7d97479 | 2011-06-02 14:59:08 -0400 | [diff] [blame] | 7274 |  | 
|  | 7275 | /* | 
|  | 7276 | * Decode TEST_STATEID response | 
|  | 7277 | */ | 
|  | 7278 | static int nfs4_xdr_dec_test_stateid(struct rpc_rqst *rqstp, | 
|  | 7279 | struct xdr_stream *xdr, | 
|  | 7280 | struct nfs41_test_stateid_res *res) | 
|  | 7281 | { | 
|  | 7282 | struct compound_hdr hdr; | 
|  | 7283 | int status; | 
|  | 7284 |  | 
|  | 7285 | status = decode_compound_hdr(xdr, &hdr); | 
|  | 7286 | if (status) | 
|  | 7287 | goto out; | 
|  | 7288 | status = decode_sequence(xdr, &res->seq_res, rqstp); | 
|  | 7289 | if (status) | 
|  | 7290 | goto out; | 
|  | 7291 | status = decode_test_stateid(xdr, res); | 
|  | 7292 | out: | 
|  | 7293 | return status; | 
|  | 7294 | } | 
| Bryan Schumaker | 9aeda35 | 2011-06-02 14:59:09 -0400 | [diff] [blame] | 7295 |  | 
|  | 7296 | /* | 
|  | 7297 | * Decode FREE_STATEID response | 
|  | 7298 | */ | 
|  | 7299 | static int nfs4_xdr_dec_free_stateid(struct rpc_rqst *rqstp, | 
|  | 7300 | struct xdr_stream *xdr, | 
|  | 7301 | struct nfs41_free_stateid_res *res) | 
|  | 7302 | { | 
|  | 7303 | struct compound_hdr hdr; | 
|  | 7304 | int status; | 
|  | 7305 |  | 
|  | 7306 | status = decode_compound_hdr(xdr, &hdr); | 
|  | 7307 | if (status) | 
|  | 7308 | goto out; | 
|  | 7309 | status = decode_sequence(xdr, &res->seq_res, rqstp); | 
|  | 7310 | if (status) | 
|  | 7311 | goto out; | 
|  | 7312 | status = decode_free_stateid(xdr, res); | 
|  | 7313 | out: | 
|  | 7314 | return status; | 
|  | 7315 | } | 
| Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 7316 | #endif /* CONFIG_NFS_V4_1 */ | 
|  | 7317 |  | 
| Chuck Lever | 573c4e1 | 2010-12-14 14:58:11 +0000 | [diff] [blame] | 7318 | /** | 
|  | 7319 | * nfs4_decode_dirent - Decode a single NFSv4 directory entry stored in | 
|  | 7320 | *                      the local page cache. | 
|  | 7321 | * @xdr: XDR stream where entry resides | 
|  | 7322 | * @entry: buffer to fill in with entry data | 
|  | 7323 | * @plus: boolean indicating whether this should be a readdirplus entry | 
|  | 7324 | * | 
|  | 7325 | * Returns zero if successful, otherwise a negative errno value is | 
|  | 7326 | * returned. | 
|  | 7327 | * | 
|  | 7328 | * This function is not invoked during READDIR reply decoding, but | 
|  | 7329 | * rather whenever an application invokes the getdents(2) system call | 
|  | 7330 | * on a directory already in our cache. | 
|  | 7331 | */ | 
|  | 7332 | int nfs4_decode_dirent(struct xdr_stream *xdr, struct nfs_entry *entry, | 
|  | 7333 | int plus) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7334 | { | 
| Trond Myklebust | 256e48b | 2012-06-21 11:18:13 -0400 | [diff] [blame] | 7335 | unsigned int savep; | 
| Fred Isaman | dae100c | 2011-07-30 20:52:37 -0400 | [diff] [blame] | 7336 | uint32_t bitmap[3] = {0}; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7337 | uint32_t len; | 
| Bryan Schumaker | babddc7 | 2010-10-20 15:44:29 -0400 | [diff] [blame] | 7338 | __be32 *p = xdr_inline_decode(xdr, 4); | 
|  | 7339 | if (unlikely(!p)) | 
|  | 7340 | goto out_overflow; | 
| Chuck Lever | c08e76d | 2011-01-28 12:40:55 -0500 | [diff] [blame] | 7341 | if (*p == xdr_zero) { | 
| Bryan Schumaker | babddc7 | 2010-10-20 15:44:29 -0400 | [diff] [blame] | 7342 | p = xdr_inline_decode(xdr, 4); | 
|  | 7343 | if (unlikely(!p)) | 
|  | 7344 | goto out_overflow; | 
| Chuck Lever | c08e76d | 2011-01-28 12:40:55 -0500 | [diff] [blame] | 7345 | if (*p == xdr_zero) | 
| Chuck Lever | 573c4e1 | 2010-12-14 14:58:11 +0000 | [diff] [blame] | 7346 | return -EAGAIN; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7347 | entry->eof = 1; | 
| Chuck Lever | 573c4e1 | 2010-12-14 14:58:11 +0000 | [diff] [blame] | 7348 | return -EBADCOOKIE; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7349 | } | 
|  | 7350 |  | 
| Bryan Schumaker | babddc7 | 2010-10-20 15:44:29 -0400 | [diff] [blame] | 7351 | p = xdr_inline_decode(xdr, 12); | 
|  | 7352 | if (unlikely(!p)) | 
|  | 7353 | goto out_overflow; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7354 | entry->prev_cookie = entry->cookie; | 
|  | 7355 | p = xdr_decode_hyper(p, &entry->cookie); | 
| Chuck Lever | c08e76d | 2011-01-28 12:40:55 -0500 | [diff] [blame] | 7356 | entry->len = be32_to_cpup(p); | 
| Bryan Schumaker | babddc7 | 2010-10-20 15:44:29 -0400 | [diff] [blame] | 7357 |  | 
| Trond Myklebust | 9af8c22 | 2010-10-24 11:52:55 -0400 | [diff] [blame] | 7358 | p = xdr_inline_decode(xdr, entry->len); | 
| Bryan Schumaker | babddc7 | 2010-10-20 15:44:29 -0400 | [diff] [blame] | 7359 | if (unlikely(!p)) | 
|  | 7360 | goto out_overflow; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7361 | entry->name = (const char *) p; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7362 |  | 
|  | 7363 | /* | 
|  | 7364 | * In case the server doesn't return an inode number, | 
|  | 7365 | * we fake one here.  (We don't use inode number 0, | 
|  | 7366 | * since glibc seems to choke on it...) | 
|  | 7367 | */ | 
|  | 7368 | entry->ino = 1; | 
| Trond Myklebust | 4f08222 | 2010-10-24 13:14:02 -0400 | [diff] [blame] | 7369 | entry->fattr->valid = 0; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7370 |  | 
| Trond Myklebust | 9af8c22 | 2010-10-24 11:52:55 -0400 | [diff] [blame] | 7371 | if (decode_attr_bitmap(xdr, bitmap) < 0) | 
| Bryan Schumaker | babddc7 | 2010-10-20 15:44:29 -0400 | [diff] [blame] | 7372 | goto out_overflow; | 
| Trond Myklebust | 9af8c22 | 2010-10-24 11:52:55 -0400 | [diff] [blame] | 7373 |  | 
| Trond Myklebust | 256e48b | 2012-06-21 11:18:13 -0400 | [diff] [blame] | 7374 | if (decode_attr_length(xdr, &len, &savep) < 0) | 
| Trond Myklebust | 9af8c22 | 2010-10-24 11:52:55 -0400 | [diff] [blame] | 7375 | goto out_overflow; | 
|  | 7376 |  | 
| Chuck Lever | 573c4e1 | 2010-12-14 14:58:11 +0000 | [diff] [blame] | 7377 | if (decode_getfattr_attrs(xdr, bitmap, entry->fattr, entry->fh, | 
| David Quigley | aa9c266 | 2013-05-22 12:50:44 -0400 | [diff] [blame] | 7378 | NULL, entry->label, entry->server) < 0) | 
| Trond Myklebust | 9af8c22 | 2010-10-24 11:52:55 -0400 | [diff] [blame] | 7379 | goto out_overflow; | 
| Trond Myklebust | 28331a4 | 2011-04-27 13:47:52 -0400 | [diff] [blame] | 7380 | if (entry->fattr->valid & NFS_ATTR_FATTR_MOUNTED_ON_FILEID) | 
|  | 7381 | entry->ino = entry->fattr->mounted_on_fileid; | 
|  | 7382 | else if (entry->fattr->valid & NFS_ATTR_FATTR_FILEID) | 
| Trond Myklebust | 9af8c22 | 2010-10-24 11:52:55 -0400 | [diff] [blame] | 7383 | entry->ino = entry->fattr->fileid; | 
|  | 7384 |  | 
| Trond Myklebust | 0b26a0b | 2010-11-20 14:26:44 -0500 | [diff] [blame] | 7385 | entry->d_type = DT_UNKNOWN; | 
|  | 7386 | if (entry->fattr->valid & NFS_ATTR_FATTR_TYPE) | 
|  | 7387 | entry->d_type = nfs_umode_to_dtype(entry->fattr->mode); | 
|  | 7388 |  | 
| Chuck Lever | 573c4e1 | 2010-12-14 14:58:11 +0000 | [diff] [blame] | 7389 | return 0; | 
| Bryan Schumaker | babddc7 | 2010-10-20 15:44:29 -0400 | [diff] [blame] | 7390 |  | 
|  | 7391 | out_overflow: | 
|  | 7392 | print_overflow_msg(__func__, xdr); | 
| Chuck Lever | 573c4e1 | 2010-12-14 14:58:11 +0000 | [diff] [blame] | 7393 | return -EAGAIN; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7394 | } | 
|  | 7395 |  | 
|  | 7396 | /* | 
|  | 7397 | * We need to translate between nfs status return values and | 
|  | 7398 | * the local errno values which may not be the same. | 
|  | 7399 | */ | 
|  | 7400 | static struct { | 
|  | 7401 | int stat; | 
|  | 7402 | int errno; | 
|  | 7403 | } nfs_errtbl[] = { | 
|  | 7404 | { NFS4_OK,		0		}, | 
| Benny Halevy | 856dff3 | 2008-03-31 17:39:06 +0300 | [diff] [blame] | 7405 | { NFS4ERR_PERM,		-EPERM		}, | 
|  | 7406 | { NFS4ERR_NOENT,	-ENOENT		}, | 
|  | 7407 | { NFS4ERR_IO,		-errno_NFSERR_IO}, | 
|  | 7408 | { NFS4ERR_NXIO,		-ENXIO		}, | 
|  | 7409 | { NFS4ERR_ACCESS,	-EACCES		}, | 
|  | 7410 | { NFS4ERR_EXIST,	-EEXIST		}, | 
|  | 7411 | { NFS4ERR_XDEV,		-EXDEV		}, | 
|  | 7412 | { NFS4ERR_NOTDIR,	-ENOTDIR	}, | 
|  | 7413 | { NFS4ERR_ISDIR,	-EISDIR		}, | 
|  | 7414 | { NFS4ERR_INVAL,	-EINVAL		}, | 
|  | 7415 | { NFS4ERR_FBIG,		-EFBIG		}, | 
|  | 7416 | { NFS4ERR_NOSPC,	-ENOSPC		}, | 
|  | 7417 | { NFS4ERR_ROFS,		-EROFS		}, | 
|  | 7418 | { NFS4ERR_MLINK,	-EMLINK		}, | 
|  | 7419 | { NFS4ERR_NAMETOOLONG,	-ENAMETOOLONG	}, | 
|  | 7420 | { NFS4ERR_NOTEMPTY,	-ENOTEMPTY	}, | 
|  | 7421 | { NFS4ERR_DQUOT,	-EDQUOT		}, | 
|  | 7422 | { NFS4ERR_STALE,	-ESTALE		}, | 
|  | 7423 | { NFS4ERR_BADHANDLE,	-EBADHANDLE	}, | 
| Benny Halevy | 856dff3 | 2008-03-31 17:39:06 +0300 | [diff] [blame] | 7424 | { NFS4ERR_BAD_COOKIE,	-EBADCOOKIE	}, | 
|  | 7425 | { NFS4ERR_NOTSUPP,	-ENOTSUPP	}, | 
|  | 7426 | { NFS4ERR_TOOSMALL,	-ETOOSMALL	}, | 
| Trond Myklebust | fdcb457 | 2010-02-08 09:32:40 -0500 | [diff] [blame] | 7427 | { NFS4ERR_SERVERFAULT,	-EREMOTEIO	}, | 
| Benny Halevy | 856dff3 | 2008-03-31 17:39:06 +0300 | [diff] [blame] | 7428 | { NFS4ERR_BADTYPE,	-EBADTYPE	}, | 
|  | 7429 | { NFS4ERR_LOCKED,	-EAGAIN		}, | 
| Benny Halevy | 856dff3 | 2008-03-31 17:39:06 +0300 | [diff] [blame] | 7430 | { NFS4ERR_SYMLINK,	-ELOOP		}, | 
|  | 7431 | { NFS4ERR_OP_ILLEGAL,	-EOPNOTSUPP	}, | 
|  | 7432 | { NFS4ERR_DEADLOCK,	-EDEADLK	}, | 
| Benny Halevy | 856dff3 | 2008-03-31 17:39:06 +0300 | [diff] [blame] | 7433 | { -1,			-EIO		} | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7434 | }; | 
|  | 7435 |  | 
|  | 7436 | /* | 
|  | 7437 | * Convert an NFS error code to a local one. | 
|  | 7438 | * This one is used jointly by NFSv2 and NFSv3. | 
|  | 7439 | */ | 
|  | 7440 | static int | 
| David Howells | 0a8ea43 | 2006-08-22 20:06:08 -0400 | [diff] [blame] | 7441 | nfs4_stat_to_errno(int stat) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7442 | { | 
|  | 7443 | int i; | 
|  | 7444 | for (i = 0; nfs_errtbl[i].stat != -1; i++) { | 
|  | 7445 | if (nfs_errtbl[i].stat == stat) | 
|  | 7446 | return nfs_errtbl[i].errno; | 
|  | 7447 | } | 
|  | 7448 | if (stat <= 10000 || stat > 10100) { | 
|  | 7449 | /* The server is looney tunes. */ | 
| Trond Myklebust | fdcb457 | 2010-02-08 09:32:40 -0500 | [diff] [blame] | 7450 | return -EREMOTEIO; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7451 | } | 
|  | 7452 | /* If we cannot translate the error, the recovery routines should | 
|  | 7453 | * handle it. | 
|  | 7454 | * Note: remaining NFSv4 error codes have values > 10000, so should | 
|  | 7455 | * not conflict with native Linux error codes. | 
|  | 7456 | */ | 
| Benny Halevy | 856dff3 | 2008-03-31 17:39:06 +0300 | [diff] [blame] | 7457 | return -stat; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7458 | } | 
|  | 7459 |  | 
| Anna Schumaker | 1c6dcbe | 2014-09-26 13:58:48 -0400 | [diff] [blame] | 7460 | #ifdef CONFIG_NFS_V4_2 | 
|  | 7461 | #include "nfs42xdr.c" | 
|  | 7462 | #endif /* CONFIG_NFS_V4_2 */ | 
|  | 7463 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7464 | #define PROC(proc, argtype, restype)				\ | 
|  | 7465 | [NFSPROC4_CLNT_##proc] = {					\ | 
|  | 7466 | .p_proc   = NFSPROC4_COMPOUND,				\ | 
| Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 7467 | .p_encode = (kxdreproc_t)nfs4_xdr_##argtype,		\ | 
| Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 7468 | .p_decode = (kxdrdproc_t)nfs4_xdr_##restype,		\ | 
| Chuck Lever | 2bea90d | 2007-03-29 16:47:53 -0400 | [diff] [blame] | 7469 | .p_arglen = NFS4_##argtype##_sz,			\ | 
|  | 7470 | .p_replen = NFS4_##restype##_sz,			\ | 
| Chuck Lever | cc0175c | 2006-03-20 13:44:22 -0500 | [diff] [blame] | 7471 | .p_statidx = NFSPROC4_CLNT_##proc,			\ | 
|  | 7472 | .p_name   = #proc,					\ | 
| Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 7473 | } | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7474 |  | 
| Anna Schumaker | 7c61f0d | 2015-04-14 10:34:20 -0400 | [diff] [blame] | 7475 | #define STUB(proc)		\ | 
|  | 7476 | [NFSPROC4_CLNT_##proc] = {	\ | 
|  | 7477 | .p_name = #proc,	\ | 
|  | 7478 | } | 
|  | 7479 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7480 | struct rpc_procinfo	nfs4_procedures[] = { | 
| Chuck Lever | 7d93bd71 | 2010-12-14 14:57:42 +0000 | [diff] [blame] | 7481 | PROC(READ,		enc_read,		dec_read), | 
|  | 7482 | PROC(WRITE,		enc_write,		dec_write), | 
|  | 7483 | PROC(COMMIT,		enc_commit,		dec_commit), | 
|  | 7484 | PROC(OPEN,		enc_open,		dec_open), | 
|  | 7485 | PROC(OPEN_CONFIRM,	enc_open_confirm,	dec_open_confirm), | 
|  | 7486 | PROC(OPEN_NOATTR,	enc_open_noattr,	dec_open_noattr), | 
|  | 7487 | PROC(OPEN_DOWNGRADE,	enc_open_downgrade,	dec_open_downgrade), | 
|  | 7488 | PROC(CLOSE,		enc_close,		dec_close), | 
|  | 7489 | PROC(SETATTR,		enc_setattr,		dec_setattr), | 
|  | 7490 | PROC(FSINFO,		enc_fsinfo,		dec_fsinfo), | 
|  | 7491 | PROC(RENEW,		enc_renew,		dec_renew), | 
|  | 7492 | PROC(SETCLIENTID,	enc_setclientid,	dec_setclientid), | 
|  | 7493 | PROC(SETCLIENTID_CONFIRM, enc_setclientid_confirm, dec_setclientid_confirm), | 
|  | 7494 | PROC(LOCK,		enc_lock,		dec_lock), | 
|  | 7495 | PROC(LOCKT,		enc_lockt,		dec_lockt), | 
|  | 7496 | PROC(LOCKU,		enc_locku,		dec_locku), | 
|  | 7497 | PROC(ACCESS,		enc_access,		dec_access), | 
|  | 7498 | PROC(GETATTR,		enc_getattr,		dec_getattr), | 
|  | 7499 | PROC(LOOKUP,		enc_lookup,		dec_lookup), | 
|  | 7500 | PROC(LOOKUP_ROOT,	enc_lookup_root,	dec_lookup_root), | 
|  | 7501 | PROC(REMOVE,		enc_remove,		dec_remove), | 
|  | 7502 | PROC(RENAME,		enc_rename,		dec_rename), | 
|  | 7503 | PROC(LINK,		enc_link,		dec_link), | 
|  | 7504 | PROC(SYMLINK,		enc_symlink,		dec_symlink), | 
|  | 7505 | PROC(CREATE,		enc_create,		dec_create), | 
|  | 7506 | PROC(PATHCONF,		enc_pathconf,		dec_pathconf), | 
|  | 7507 | PROC(STATFS,		enc_statfs,		dec_statfs), | 
|  | 7508 | PROC(READLINK,		enc_readlink,		dec_readlink), | 
|  | 7509 | PROC(READDIR,		enc_readdir,		dec_readdir), | 
|  | 7510 | PROC(SERVER_CAPS,	enc_server_caps,	dec_server_caps), | 
|  | 7511 | PROC(DELEGRETURN,	enc_delegreturn,	dec_delegreturn), | 
|  | 7512 | PROC(GETACL,		enc_getacl,		dec_getacl), | 
|  | 7513 | PROC(SETACL,		enc_setacl,		dec_setacl), | 
|  | 7514 | PROC(FS_LOCATIONS,	enc_fs_locations,	dec_fs_locations), | 
|  | 7515 | PROC(RELEASE_LOCKOWNER,	enc_release_lockowner,	dec_release_lockowner), | 
| Bryan Schumaker | 5a5ea0d | 2011-03-24 17:12:29 +0000 | [diff] [blame] | 7516 | PROC(SECINFO,		enc_secinfo,		dec_secinfo), | 
| Chuck Lever | 44c9993 | 2013-10-17 14:13:30 -0400 | [diff] [blame] | 7517 | PROC(FSID_PRESENT,	enc_fsid_present,	dec_fsid_present), | 
| Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 7518 | #if defined(CONFIG_NFS_V4_1) | 
| Chuck Lever | 7d93bd71 | 2010-12-14 14:57:42 +0000 | [diff] [blame] | 7519 | PROC(EXCHANGE_ID,	enc_exchange_id,	dec_exchange_id), | 
|  | 7520 | PROC(CREATE_SESSION,	enc_create_session,	dec_create_session), | 
|  | 7521 | PROC(DESTROY_SESSION,	enc_destroy_session,	dec_destroy_session), | 
|  | 7522 | PROC(SEQUENCE,		enc_sequence,		dec_sequence), | 
|  | 7523 | PROC(GET_LEASE_TIME,	enc_get_lease_time,	dec_get_lease_time), | 
|  | 7524 | PROC(RECLAIM_COMPLETE,	enc_reclaim_complete,	dec_reclaim_complete), | 
|  | 7525 | PROC(GETDEVICEINFO,	enc_getdeviceinfo,	dec_getdeviceinfo), | 
|  | 7526 | PROC(LAYOUTGET,		enc_layoutget,		dec_layoutget), | 
| Andy Adamson | 863a3c6 | 2011-03-23 13:27:54 +0000 | [diff] [blame] | 7527 | PROC(LAYOUTCOMMIT,	enc_layoutcommit,	dec_layoutcommit), | 
| Benny Halevy | cbe8260 | 2011-05-22 19:52:37 +0300 | [diff] [blame] | 7528 | PROC(LAYOUTRETURN,	enc_layoutreturn,	dec_layoutreturn), | 
| Bryan Schumaker | fca78d6 | 2011-06-02 14:59:07 -0400 | [diff] [blame] | 7529 | PROC(SECINFO_NO_NAME,	enc_secinfo_no_name,	dec_secinfo_no_name), | 
| Bryan Schumaker | 7d97479 | 2011-06-02 14:59:08 -0400 | [diff] [blame] | 7530 | PROC(TEST_STATEID,	enc_test_stateid,	dec_test_stateid), | 
| Bryan Schumaker | 9aeda35 | 2011-06-02 14:59:09 -0400 | [diff] [blame] | 7531 | PROC(FREE_STATEID,	enc_free_stateid,	dec_free_stateid), | 
| Anna Schumaker | 7c61f0d | 2015-04-14 10:34:20 -0400 | [diff] [blame] | 7532 | STUB(GETDEVICELIST), | 
| Trond Myklebust | ad24ecf | 2012-05-25 17:11:42 -0400 | [diff] [blame] | 7533 | PROC(BIND_CONN_TO_SESSION, | 
|  | 7534 | enc_bind_conn_to_session, dec_bind_conn_to_session), | 
| Trond Myklebust | 6624553 | 2012-05-25 17:18:09 -0400 | [diff] [blame] | 7535 | PROC(DESTROY_CLIENTID,	enc_destroy_clientid,	dec_destroy_clientid), | 
| Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 7536 | #endif /* CONFIG_NFS_V4_1 */ | 
| Anna Schumaker | 1c6dcbe | 2014-09-26 13:58:48 -0400 | [diff] [blame] | 7537 | #ifdef CONFIG_NFS_V4_2 | 
|  | 7538 | PROC(SEEK,		enc_seek,		dec_seek), | 
| Anna Schumaker | f4ac167 | 2014-11-25 13:18:15 -0500 | [diff] [blame] | 7539 | PROC(ALLOCATE,		enc_allocate,		dec_allocate), | 
| Anna Schumaker | 624bd5b | 2014-11-25 13:18:16 -0500 | [diff] [blame] | 7540 | PROC(DEALLOCATE,	enc_deallocate,		dec_deallocate), | 
| Trond Myklebust | be3a5d2 | 2015-06-23 19:51:55 +0800 | [diff] [blame] | 7541 | PROC(LAYOUTSTATS,	enc_layoutstats,	dec_layoutstats), | 
| Peng Tao | 3602277 | 2015-09-26 02:24:34 +0800 | [diff] [blame] | 7542 | PROC(CLONE,		enc_clone,		dec_clone), | 
| Anna Schumaker | 2e72448 | 2013-05-21 16:53:03 -0400 | [diff] [blame] | 7543 | PROC(COPY,		enc_copy,		dec_copy), | 
| Anna Schumaker | 1c6dcbe | 2014-09-26 13:58:48 -0400 | [diff] [blame] | 7544 | #endif /* CONFIG_NFS_V4_2 */ | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7545 | }; | 
|  | 7546 |  | 
| Trond Myklebust | a613fa1 | 2012-01-20 13:53:56 -0500 | [diff] [blame] | 7547 | const struct rpc_version nfs_version4 = { | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7548 | .number			= 4, | 
| Tobias Klauser | e8c96f8 | 2006-03-24 03:15:34 -0800 | [diff] [blame] | 7549 | .nrprocs		= ARRAY_SIZE(nfs4_procedures), | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7550 | .procs			= nfs4_procedures | 
|  | 7551 | }; | 
|  | 7552 |  | 
|  | 7553 | /* | 
|  | 7554 | * Local variables: | 
|  | 7555 | *  c-basic-offset: 8 | 
|  | 7556 | * End: | 
|  | 7557 | */ |