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" |
Chuck Lever | f23f658 | 2019-02-11 11:24:26 -0500 | [diff] [blame] | 57 | #include "nfs4trace.h" |
Alexandros Batsakis | 4882ef7 | 2009-12-05 13:30:21 -0500 | [diff] [blame] | 58 | #include "internal.h" |
Anna Schumaker | 40c64c2 | 2015-04-15 13:00:05 -0400 | [diff] [blame] | 59 | #include "nfs4idmap.h" |
Trond Myklebust | 76e697b | 2012-11-26 14:20:49 -0500 | [diff] [blame] | 60 | #include "nfs4session.h" |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 61 | #include "pnfs.h" |
Chuck Lever | f092075 | 2012-05-21 22:45:41 -0400 | [diff] [blame] | 62 | #include "netns.h" |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 63 | |
| 64 | #define NFSDBG_FACILITY NFSDBG_XDR |
| 65 | |
| 66 | /* Mapping from NFS error code to "errno" error code. */ |
| 67 | #define errno_NFSERR_IO EIO |
| 68 | |
Fred Isaman | 56f487f | 2016-09-21 11:43:41 -0400 | [diff] [blame] | 69 | struct compound_hdr; |
David Howells | 0a8ea43 | 2006-08-22 20:06:08 -0400 | [diff] [blame] | 70 | static int nfs4_stat_to_errno(int); |
Fred Isaman | 56f487f | 2016-09-21 11:43:41 -0400 | [diff] [blame] | 71 | static void encode_layoutget(struct xdr_stream *xdr, |
| 72 | const struct nfs4_layoutget_args *args, |
| 73 | struct compound_hdr *hdr); |
| 74 | static int decode_layoutget(struct xdr_stream *xdr, struct rpc_rqst *req, |
| 75 | struct nfs4_layoutget_res *res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 76 | |
| 77 | /* NFSv4 COMPOUND tags are only wanted for debugging purposes */ |
| 78 | #ifdef DEBUG |
| 79 | #define NFS4_MAXTAGLEN 20 |
| 80 | #else |
| 81 | #define NFS4_MAXTAGLEN 0 |
| 82 | #endif |
| 83 | |
Andy Adamson | 6c0195a | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 84 | /* lock,open owner id: |
Trond Myklebust | 9f958ab | 2007-07-02 13:58:33 -0400 | [diff] [blame] | 85 | * we currently use size 2 (u64) out of (NFS4_OPAQUE_LIMIT >> 2) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 86 | */ |
Trond Myklebust | 9ed5af26 | 2020-11-21 20:46:18 -0500 | [diff] [blame] | 87 | #define pagepad_maxsz (1) |
Trond Myklebust | 95b72eb | 2012-04-20 19:24:51 -0400 | [diff] [blame] | 88 | #define open_owner_id_maxsz (1 + 2 + 1 + 1 + 2) |
Trond Myklebust | d035c36 | 2010-12-21 10:45:27 -0500 | [diff] [blame] | 89 | #define lock_owner_id_maxsz (1 + 1 + 4) |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 90 | #define decode_lockowner_maxsz (1 + XDR_QUADLEN(IDMAP_NAMESZ)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 91 | #define compound_encode_hdr_maxsz (3 + (NFS4_MAXTAGLEN >> 2)) |
| 92 | #define compound_decode_hdr_maxsz (3 + (NFS4_MAXTAGLEN >> 2)) |
| 93 | #define op_encode_hdr_maxsz (1) |
| 94 | #define op_decode_hdr_maxsz (2) |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 95 | #define encode_stateid_maxsz (XDR_QUADLEN(NFS4_STATEID_SIZE)) |
| 96 | #define decode_stateid_maxsz (XDR_QUADLEN(NFS4_STATEID_SIZE)) |
| 97 | #define encode_verifier_maxsz (XDR_QUADLEN(NFS4_VERIFIER_SIZE)) |
| 98 | #define decode_verifier_maxsz (XDR_QUADLEN(NFS4_VERIFIER_SIZE)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 99 | #define encode_putfh_maxsz (op_encode_hdr_maxsz + 1 + \ |
| 100 | (NFS4_FHSIZE >> 2)) |
| 101 | #define decode_putfh_maxsz (op_decode_hdr_maxsz) |
| 102 | #define encode_putrootfh_maxsz (op_encode_hdr_maxsz) |
| 103 | #define decode_putrootfh_maxsz (op_decode_hdr_maxsz) |
| 104 | #define encode_getfh_maxsz (op_encode_hdr_maxsz) |
| 105 | #define decode_getfh_maxsz (op_decode_hdr_maxsz + 1 + \ |
| 106 | ((3+NFS4_FHSIZE) >> 2)) |
Andy Adamson | e5012d1 | 2011-07-11 17:17:42 -0400 | [diff] [blame] | 107 | #define nfs4_fattr_bitmap_maxsz 4 |
J. Bruce Fields | 9692820 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 108 | #define encode_getattr_maxsz (op_encode_hdr_maxsz + nfs4_fattr_bitmap_maxsz) |
Trond Myklebust | 36b3743 | 2018-03-20 17:03:10 -0400 | [diff] [blame] | 109 | #define nfstime4_maxsz (3) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 110 | #define nfs4_name_maxsz (1 + ((3 + NFS4_MAXNAMLEN) >> 2)) |
| 111 | #define nfs4_path_maxsz (1 + ((3 + NFS4_MAXPATHLEN) >> 2)) |
Trond Myklebust | bd625ba | 2007-07-08 18:38:23 -0400 | [diff] [blame] | 112 | #define nfs4_owner_maxsz (1 + XDR_QUADLEN(IDMAP_NAMESZ)) |
| 113 | #define nfs4_group_maxsz (1 + XDR_QUADLEN(IDMAP_NAMESZ)) |
David Quigley | aa9c266 | 2013-05-22 12:50:44 -0400 | [diff] [blame] | 114 | #ifdef CONFIG_NFS_V4_SECURITY_LABEL |
| 115 | /* PI(4 bytes) + LFS(4 bytes) + 1(for null terminator?) + MAXLABELLEN */ |
| 116 | #define nfs4_label_maxsz (4 + 4 + 1 + XDR_QUADLEN(NFS4_MAXLABELLEN)) |
David Quigley | aa9c266 | 2013-05-22 12:50:44 -0400 | [diff] [blame] | 117 | #else |
| 118 | #define nfs4_label_maxsz 0 |
David Quigley | aa9c266 | 2013-05-22 12:50:44 -0400 | [diff] [blame] | 119 | #endif |
Andy Adamson | 88034c3 | 2012-05-23 05:02:34 -0400 | [diff] [blame] | 120 | /* We support only one layout type per file system */ |
| 121 | #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] | 122 | /* This is based on getfattr, which uses the most attributes: */ |
| 123 | #define nfs4_fattr_value_maxsz (1 + (1 + 2 + 2 + 4 + 2 + 1 + 1 + 2 + 2 + \ |
Trond Myklebust | 36b3743 | 2018-03-20 17:03:10 -0400 | [diff] [blame] | 124 | 3*nfstime4_maxsz + \ |
| 125 | nfs4_owner_maxsz + \ |
David Quigley | aa9c266 | 2013-05-22 12:50:44 -0400 | [diff] [blame] | 126 | nfs4_group_maxsz + nfs4_label_maxsz + \ |
| 127 | decode_mdsthreshold_maxsz)) |
J. Bruce Fields | 9692820 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 128 | #define nfs4_fattr_maxsz (nfs4_fattr_bitmap_maxsz + \ |
| 129 | nfs4_fattr_value_maxsz) |
| 130 | #define decode_getattr_maxsz (op_decode_hdr_maxsz + nfs4_fattr_maxsz) |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 131 | #define encode_attrs_maxsz (nfs4_fattr_bitmap_maxsz + \ |
| 132 | 1 + 2 + 1 + \ |
| 133 | nfs4_owner_maxsz + \ |
| 134 | nfs4_group_maxsz + \ |
David Quigley | aa9c266 | 2013-05-22 12:50:44 -0400 | [diff] [blame] | 135 | nfs4_label_maxsz + \ |
Trond Myklebust | 36b3743 | 2018-03-20 17:03:10 -0400 | [diff] [blame] | 136 | 1 + nfstime4_maxsz + \ |
| 137 | 1 + nfstime4_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 138 | #define encode_savefh_maxsz (op_encode_hdr_maxsz) |
| 139 | #define decode_savefh_maxsz (op_decode_hdr_maxsz) |
Trond Myklebust | 56ae19f | 2005-10-27 22:12:40 -0400 | [diff] [blame] | 140 | #define encode_restorefh_maxsz (op_encode_hdr_maxsz) |
| 141 | #define decode_restorefh_maxsz (op_decode_hdr_maxsz) |
Fred Isaman | 2f42b5d | 2008-03-13 15:26:30 +0200 | [diff] [blame] | 142 | #define encode_fsinfo_maxsz (encode_getattr_maxsz) |
Fred Isaman | dae100c | 2011-07-30 20:52:37 -0400 | [diff] [blame] | 143 | /* The 5 accounts for the PNFS attributes, and assumes that at most three |
| 144 | * layout types will be returned. |
| 145 | */ |
| 146 | #define decode_fsinfo_maxsz (op_decode_hdr_maxsz + \ |
Trond Myklebust | 57a789a | 2021-03-26 10:17:25 -0400 | [diff] [blame] | 147 | nfs4_fattr_bitmap_maxsz + 1 + \ |
| 148 | 1 /* lease time */ + \ |
| 149 | 2 /* max filesize */ + \ |
| 150 | 2 /* max read */ + \ |
| 151 | 2 /* max write */ + \ |
| 152 | nfstime4_maxsz /* time delta */ + \ |
| 153 | 5 /* fs layout types */ + \ |
| 154 | 1 /* layout blksize */ + \ |
| 155 | 1 /* clone blksize */ + \ |
Trond Myklebust | 7f08a33 | 2021-03-26 09:50:19 -0400 | [diff] [blame] | 156 | 1 /* change attr type */ + \ |
Trond Myklebust | 57a789a | 2021-03-26 10:17:25 -0400 | [diff] [blame] | 157 | 1 /* xattr support */) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 158 | #define encode_renew_maxsz (op_encode_hdr_maxsz + 3) |
| 159 | #define decode_renew_maxsz (op_decode_hdr_maxsz) |
| 160 | #define encode_setclientid_maxsz \ |
| 161 | (op_encode_hdr_maxsz + \ |
Chuck Lever | cc38bac | 2007-12-10 14:56:54 -0500 | [diff] [blame] | 162 | XDR_QUADLEN(NFS4_VERIFIER_SIZE) + \ |
Jeff Layton | b8fb2f5 | 2015-06-09 19:43:58 -0400 | [diff] [blame] | 163 | /* client name */ \ |
| 164 | 1 + XDR_QUADLEN(NFS4_OPAQUE_LIMIT) + \ |
Chuck Lever | cc38bac | 2007-12-10 14:56:54 -0500 | [diff] [blame] | 165 | 1 /* sc_prog */ + \ |
Chuck Lever | 6dd3436 | 2014-11-08 20:15:18 -0500 | [diff] [blame] | 166 | 1 + XDR_QUADLEN(RPCBIND_MAXNETIDLEN) + \ |
| 167 | 1 + XDR_QUADLEN(RPCBIND_MAXUADDRLEN) + \ |
Chuck Lever | cc38bac | 2007-12-10 14:56:54 -0500 | [diff] [blame] | 168 | 1) /* sc_cb_ident */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 169 | #define decode_setclientid_maxsz \ |
| 170 | (op_decode_hdr_maxsz + \ |
Chuck Lever | 6dd3436 | 2014-11-08 20:15:18 -0500 | [diff] [blame] | 171 | 2 /* clientid */ + \ |
| 172 | XDR_QUADLEN(NFS4_VERIFIER_SIZE) + \ |
| 173 | 1 + XDR_QUADLEN(RPCBIND_MAXNETIDLEN) + \ |
| 174 | 1 + XDR_QUADLEN(RPCBIND_MAXUADDRLEN)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 175 | #define encode_setclientid_confirm_maxsz \ |
| 176 | (op_encode_hdr_maxsz + \ |
| 177 | 3 + (NFS4_VERIFIER_SIZE >> 2)) |
| 178 | #define decode_setclientid_confirm_maxsz \ |
| 179 | (op_decode_hdr_maxsz) |
Trond Myklebust | e688962 | 2007-07-02 13:58:30 -0400 | [diff] [blame] | 180 | #define encode_lookup_maxsz (op_encode_hdr_maxsz + nfs4_name_maxsz) |
| 181 | #define decode_lookup_maxsz (op_decode_hdr_maxsz) |
Jeff Layton | 5b5faaf | 2017-06-29 06:34:52 -0700 | [diff] [blame] | 182 | #define encode_lookupp_maxsz (op_encode_hdr_maxsz) |
| 183 | #define decode_lookupp_maxsz (op_decode_hdr_maxsz) |
Trond Myklebust | 2cebf82 | 2007-07-02 13:57:28 -0400 | [diff] [blame] | 184 | #define encode_share_access_maxsz \ |
| 185 | (2) |
Alexandros Batsakis | 4882ef7 | 2009-12-05 13:30:21 -0500 | [diff] [blame] | 186 | #define encode_createmode_maxsz (1 + encode_attrs_maxsz + encode_verifier_maxsz) |
Trond Myklebust | 2cebf82 | 2007-07-02 13:57:28 -0400 | [diff] [blame] | 187 | #define encode_opentype_maxsz (1 + encode_createmode_maxsz) |
| 188 | #define encode_claim_null_maxsz (1 + nfs4_name_maxsz) |
| 189 | #define encode_open_maxsz (op_encode_hdr_maxsz + \ |
| 190 | 2 + encode_share_access_maxsz + 2 + \ |
| 191 | open_owner_id_maxsz + \ |
| 192 | encode_opentype_maxsz + \ |
| 193 | encode_claim_null_maxsz) |
Trond Myklebust | 5a1f6d9 | 2017-02-19 16:08:29 -0500 | [diff] [blame] | 194 | #define decode_space_limit_maxsz (3) |
Trond Myklebust | 2cebf82 | 2007-07-02 13:57:28 -0400 | [diff] [blame] | 195 | #define decode_ace_maxsz (3 + nfs4_owner_maxsz) |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 196 | #define decode_delegation_maxsz (1 + decode_stateid_maxsz + 1 + \ |
Trond Myklebust | 5a1f6d9 | 2017-02-19 16:08:29 -0500 | [diff] [blame] | 197 | decode_space_limit_maxsz + \ |
Trond Myklebust | 2cebf82 | 2007-07-02 13:57:28 -0400 | [diff] [blame] | 198 | decode_ace_maxsz) |
| 199 | #define decode_change_info_maxsz (5) |
| 200 | #define decode_open_maxsz (op_decode_hdr_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 201 | decode_stateid_maxsz + \ |
Trond Myklebust | 2cebf82 | 2007-07-02 13:57:28 -0400 | [diff] [blame] | 202 | decode_change_info_maxsz + 1 + \ |
| 203 | nfs4_fattr_bitmap_maxsz + \ |
| 204 | decode_delegation_maxsz) |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 205 | #define encode_open_confirm_maxsz \ |
| 206 | (op_encode_hdr_maxsz + \ |
| 207 | encode_stateid_maxsz + 1) |
| 208 | #define decode_open_confirm_maxsz \ |
| 209 | (op_decode_hdr_maxsz + \ |
| 210 | decode_stateid_maxsz) |
| 211 | #define encode_open_downgrade_maxsz \ |
| 212 | (op_encode_hdr_maxsz + \ |
| 213 | encode_stateid_maxsz + 1 + \ |
| 214 | encode_share_access_maxsz) |
| 215 | #define decode_open_downgrade_maxsz \ |
| 216 | (op_decode_hdr_maxsz + \ |
| 217 | decode_stateid_maxsz) |
| 218 | #define encode_close_maxsz (op_encode_hdr_maxsz + \ |
| 219 | 1 + encode_stateid_maxsz) |
| 220 | #define decode_close_maxsz (op_decode_hdr_maxsz + \ |
| 221 | decode_stateid_maxsz) |
| 222 | #define encode_setattr_maxsz (op_encode_hdr_maxsz + \ |
| 223 | encode_stateid_maxsz + \ |
| 224 | encode_attrs_maxsz) |
| 225 | #define decode_setattr_maxsz (op_decode_hdr_maxsz + \ |
| 226 | nfs4_fattr_bitmap_maxsz) |
| 227 | #define encode_read_maxsz (op_encode_hdr_maxsz + \ |
| 228 | encode_stateid_maxsz + 3) |
Trond Myklebust | 9ed5af26 | 2020-11-21 20:46:18 -0500 | [diff] [blame] | 229 | #define decode_read_maxsz (op_decode_hdr_maxsz + 2 + pagepad_maxsz) |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 230 | #define encode_readdir_maxsz (op_encode_hdr_maxsz + \ |
David Quigley | aa9c266 | 2013-05-22 12:50:44 -0400 | [diff] [blame] | 231 | 2 + encode_verifier_maxsz + 5 + \ |
| 232 | nfs4_label_maxsz) |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 233 | #define decode_readdir_maxsz (op_decode_hdr_maxsz + \ |
Trond Myklebust | 9ed5af26 | 2020-11-21 20:46:18 -0500 | [diff] [blame] | 234 | decode_verifier_maxsz + pagepad_maxsz) |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 235 | #define encode_readlink_maxsz (op_encode_hdr_maxsz) |
Trond Myklebust | 9ed5af26 | 2020-11-21 20:46:18 -0500 | [diff] [blame] | 236 | #define decode_readlink_maxsz (op_decode_hdr_maxsz + 1 + pagepad_maxsz) |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 237 | #define encode_write_maxsz (op_encode_hdr_maxsz + \ |
| 238 | encode_stateid_maxsz + 4) |
| 239 | #define decode_write_maxsz (op_decode_hdr_maxsz + \ |
| 240 | 2 + decode_verifier_maxsz) |
| 241 | #define encode_commit_maxsz (op_encode_hdr_maxsz + 3) |
| 242 | #define decode_commit_maxsz (op_decode_hdr_maxsz + \ |
| 243 | decode_verifier_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 244 | #define encode_remove_maxsz (op_encode_hdr_maxsz + \ |
| 245 | nfs4_name_maxsz) |
Benny Halevy | 6ce1839 | 2009-04-01 09:22:06 -0400 | [diff] [blame] | 246 | #define decode_remove_maxsz (op_decode_hdr_maxsz + \ |
| 247 | decode_change_info_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 248 | #define encode_rename_maxsz (op_encode_hdr_maxsz + \ |
| 249 | 2 * nfs4_name_maxsz) |
Benny Halevy | 6ce1839 | 2009-04-01 09:22:06 -0400 | [diff] [blame] | 250 | #define decode_rename_maxsz (op_decode_hdr_maxsz + \ |
| 251 | decode_change_info_maxsz + \ |
| 252 | decode_change_info_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 253 | #define encode_link_maxsz (op_encode_hdr_maxsz + \ |
| 254 | nfs4_name_maxsz) |
Benny Halevy | 6ce1839 | 2009-04-01 09:22:06 -0400 | [diff] [blame] | 255 | #define decode_link_maxsz (op_decode_hdr_maxsz + decode_change_info_maxsz) |
Trond Myklebust | daccbde | 2010-06-25 18:11:43 -0400 | [diff] [blame] | 256 | #define encode_lockowner_maxsz (7) |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 257 | #define encode_lock_maxsz (op_encode_hdr_maxsz + \ |
| 258 | 7 + \ |
Trond Myklebust | daccbde | 2010-06-25 18:11:43 -0400 | [diff] [blame] | 259 | 1 + encode_stateid_maxsz + 1 + \ |
| 260 | encode_lockowner_maxsz) |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 261 | #define decode_lock_denied_maxsz \ |
| 262 | (8 + decode_lockowner_maxsz) |
| 263 | #define decode_lock_maxsz (op_decode_hdr_maxsz + \ |
| 264 | decode_lock_denied_maxsz) |
Trond Myklebust | daccbde | 2010-06-25 18:11:43 -0400 | [diff] [blame] | 265 | #define encode_lockt_maxsz (op_encode_hdr_maxsz + 5 + \ |
| 266 | encode_lockowner_maxsz) |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 267 | #define decode_lockt_maxsz (op_decode_hdr_maxsz + \ |
| 268 | decode_lock_denied_maxsz) |
| 269 | #define encode_locku_maxsz (op_encode_hdr_maxsz + 3 + \ |
| 270 | encode_stateid_maxsz + \ |
| 271 | 4) |
| 272 | #define decode_locku_maxsz (op_decode_hdr_maxsz + \ |
| 273 | decode_stateid_maxsz) |
Trond Myklebust | d3c7b7c | 2010-07-01 12:49:01 -0400 | [diff] [blame] | 274 | #define encode_release_lockowner_maxsz \ |
| 275 | (op_encode_hdr_maxsz + \ |
| 276 | encode_lockowner_maxsz) |
| 277 | #define decode_release_lockowner_maxsz \ |
| 278 | (op_decode_hdr_maxsz) |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 279 | #define encode_access_maxsz (op_encode_hdr_maxsz + 1) |
| 280 | #define decode_access_maxsz (op_decode_hdr_maxsz + 2) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 281 | #define encode_symlink_maxsz (op_encode_hdr_maxsz + \ |
| 282 | 1 + nfs4_name_maxsz + \ |
Chuck Lever | 94a6d75 | 2006-08-22 20:06:23 -0400 | [diff] [blame] | 283 | 1 + \ |
J. Bruce Fields | 9692820 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 284 | nfs4_fattr_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 285 | #define decode_symlink_maxsz (op_decode_hdr_maxsz + 8) |
| 286 | #define encode_create_maxsz (op_encode_hdr_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 287 | 1 + 2 + nfs4_name_maxsz + \ |
| 288 | encode_attrs_maxsz) |
Trond Myklebust | 2cebf82 | 2007-07-02 13:57:28 -0400 | [diff] [blame] | 289 | #define decode_create_maxsz (op_decode_hdr_maxsz + \ |
| 290 | decode_change_info_maxsz + \ |
| 291 | nfs4_fattr_bitmap_maxsz) |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 292 | #define encode_statfs_maxsz (encode_getattr_maxsz) |
| 293 | #define decode_statfs_maxsz (decode_getattr_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 294 | #define encode_delegreturn_maxsz (op_encode_hdr_maxsz + 4) |
| 295 | #define decode_delegreturn_maxsz (op_decode_hdr_maxsz) |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 296 | #define encode_getacl_maxsz (encode_getattr_maxsz) |
| 297 | #define decode_getacl_maxsz (op_decode_hdr_maxsz + \ |
Trond Myklebust | 9ed5af26 | 2020-11-21 20:46:18 -0500 | [diff] [blame] | 298 | nfs4_fattr_bitmap_maxsz + 1 + pagepad_maxsz) |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 299 | #define encode_setacl_maxsz (op_encode_hdr_maxsz + \ |
| 300 | encode_stateid_maxsz + 3) |
| 301 | #define decode_setacl_maxsz (decode_setattr_maxsz) |
Trond Myklebust | e688962 | 2007-07-02 13:58:30 -0400 | [diff] [blame] | 302 | #define encode_fs_locations_maxsz \ |
| 303 | (encode_getattr_maxsz) |
| 304 | #define decode_fs_locations_maxsz \ |
Trond Myklebust | 9ed5af26 | 2020-11-21 20:46:18 -0500 | [diff] [blame] | 305 | (pagepad_maxsz) |
Bryan Schumaker | 5a5ea0d | 2011-03-24 17:12:29 +0000 | [diff] [blame] | 306 | #define encode_secinfo_maxsz (op_encode_hdr_maxsz + nfs4_name_maxsz) |
Bryan Schumaker | 1650add | 2011-06-02 15:07:35 -0400 | [diff] [blame] | 307 | #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] | 308 | |
| 309 | #if defined(CONFIG_NFS_V4_1) |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 310 | #define NFS4_MAX_MACHINE_NAME_LEN (64) |
Jim Rees | d751f74 | 2012-11-16 18:12:06 -0500 | [diff] [blame] | 311 | #define IMPL_NAME_LIMIT (sizeof(utsname()->sysname) + sizeof(utsname()->release) + \ |
| 312 | sizeof(utsname()->version) + sizeof(utsname()->machine) + 8) |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 313 | |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 314 | #define encode_exchange_id_maxsz (op_encode_hdr_maxsz + \ |
| 315 | encode_verifier_maxsz + \ |
| 316 | 1 /* co_ownerid.len */ + \ |
Jeff Layton | b8fb2f5 | 2015-06-09 19:43:58 -0400 | [diff] [blame] | 317 | /* eia_clientowner */ \ |
| 318 | 1 + XDR_QUADLEN(NFS4_OPAQUE_LIMIT) + \ |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 319 | 1 /* flags */ + \ |
| 320 | 1 /* spa_how */ + \ |
Weston Andros Adamson | 2031cd1 | 2013-08-13 16:37:32 -0400 | [diff] [blame] | 321 | /* max is SP4_MACH_CRED (for now) */ + \ |
| 322 | 1 + NFS4_OP_MAP_NUM_WORDS + \ |
| 323 | 1 + NFS4_OP_MAP_NUM_WORDS + \ |
Weston Andros Adamson | db8ac8b | 2012-02-17 15:20:24 -0500 | [diff] [blame] | 324 | 1 /* implementation id array of size 1 */ + \ |
| 325 | 1 /* nii_domain */ + \ |
| 326 | XDR_QUADLEN(NFS4_OPAQUE_LIMIT) + \ |
| 327 | 1 /* nii_name */ + \ |
Jim Rees | d751f74 | 2012-11-16 18:12:06 -0500 | [diff] [blame] | 328 | XDR_QUADLEN(IMPL_NAME_LIMIT) + \ |
Weston Andros Adamson | db8ac8b | 2012-02-17 15:20:24 -0500 | [diff] [blame] | 329 | 3 /* nii_date */) |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 330 | #define decode_exchange_id_maxsz (op_decode_hdr_maxsz + \ |
| 331 | 2 /* eir_clientid */ + \ |
| 332 | 1 /* eir_sequenceid */ + \ |
| 333 | 1 /* eir_flags */ + \ |
| 334 | 1 /* spr_how */ + \ |
Weston Andros Adamson | 2031cd1 | 2013-08-13 16:37:32 -0400 | [diff] [blame] | 335 | /* max is SP4_MACH_CRED (for now) */ + \ |
| 336 | 1 + NFS4_OP_MAP_NUM_WORDS + \ |
| 337 | 1 + NFS4_OP_MAP_NUM_WORDS + \ |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 338 | 2 /* eir_server_owner.so_minor_id */ + \ |
| 339 | /* eir_server_owner.so_major_id<> */ \ |
| 340 | XDR_QUADLEN(NFS4_OPAQUE_LIMIT) + 1 + \ |
| 341 | /* eir_server_scope<> */ \ |
| 342 | XDR_QUADLEN(NFS4_OPAQUE_LIMIT) + 1 + \ |
| 343 | 1 /* eir_server_impl_id array length */ + \ |
Weston Andros Adamson | 7d2ed9a | 2012-02-17 15:20:26 -0500 | [diff] [blame] | 344 | 1 /* nii_domain */ + \ |
| 345 | XDR_QUADLEN(NFS4_OPAQUE_LIMIT) + \ |
| 346 | 1 /* nii_name */ + \ |
| 347 | XDR_QUADLEN(NFS4_OPAQUE_LIMIT) + \ |
| 348 | 3 /* nii_date */) |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 349 | #define encode_channel_attrs_maxsz (6 + 1 /* ca_rdma_ird.len (0) */) |
| 350 | #define decode_channel_attrs_maxsz (6 + \ |
| 351 | 1 /* ca_rdma_ird.len */ + \ |
| 352 | 1 /* ca_rdma_ird */) |
| 353 | #define encode_create_session_maxsz (op_encode_hdr_maxsz + \ |
| 354 | 2 /* csa_clientid */ + \ |
| 355 | 1 /* csa_sequence */ + \ |
| 356 | 1 /* csa_flags */ + \ |
| 357 | encode_channel_attrs_maxsz + \ |
| 358 | encode_channel_attrs_maxsz + \ |
| 359 | 1 /* csa_cb_program */ + \ |
| 360 | 1 /* csa_sec_parms.len (1) */ + \ |
| 361 | 1 /* cb_secflavor (AUTH_SYS) */ + \ |
| 362 | 1 /* stamp */ + \ |
| 363 | 1 /* machinename.len */ + \ |
| 364 | XDR_QUADLEN(NFS4_MAX_MACHINE_NAME_LEN) + \ |
| 365 | 1 /* uid */ + \ |
| 366 | 1 /* gid */ + \ |
| 367 | 1 /* gids.len (0) */) |
| 368 | #define decode_create_session_maxsz (op_decode_hdr_maxsz + \ |
| 369 | XDR_QUADLEN(NFS4_MAX_SESSIONID_LEN) + \ |
| 370 | 1 /* csr_sequence */ + \ |
| 371 | 1 /* csr_flags */ + \ |
| 372 | decode_channel_attrs_maxsz + \ |
| 373 | decode_channel_attrs_maxsz) |
Weston Andros Adamson | 7c44f1ae | 2012-05-24 13:22:50 -0400 | [diff] [blame] | 374 | #define encode_bind_conn_to_session_maxsz (op_encode_hdr_maxsz + \ |
| 375 | /* bctsa_sessid */ \ |
| 376 | XDR_QUADLEN(NFS4_MAX_SESSIONID_LEN) + \ |
| 377 | 1 /* bctsa_dir */ + \ |
| 378 | 1 /* bctsa_use_conn_in_rdma_mode */) |
| 379 | #define decode_bind_conn_to_session_maxsz (op_decode_hdr_maxsz + \ |
| 380 | /* bctsr_sessid */ \ |
| 381 | XDR_QUADLEN(NFS4_MAX_SESSIONID_LEN) + \ |
| 382 | 1 /* bctsr_dir */ + \ |
| 383 | 1 /* bctsr_use_conn_in_rdma_mode */) |
Andy Adamson | 0f3e66c | 2009-04-01 09:22:34 -0400 | [diff] [blame] | 384 | #define encode_destroy_session_maxsz (op_encode_hdr_maxsz + 4) |
| 385 | #define decode_destroy_session_maxsz (op_decode_hdr_maxsz) |
Trond Myklebust | 6624553 | 2012-05-25 17:18:09 -0400 | [diff] [blame] | 386 | #define encode_destroy_clientid_maxsz (op_encode_hdr_maxsz + 2) |
| 387 | #define decode_destroy_clientid_maxsz (op_decode_hdr_maxsz) |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 388 | #define encode_sequence_maxsz (op_encode_hdr_maxsz + \ |
| 389 | XDR_QUADLEN(NFS4_MAX_SESSIONID_LEN) + 4) |
| 390 | #define decode_sequence_maxsz (op_decode_hdr_maxsz + \ |
| 391 | XDR_QUADLEN(NFS4_MAX_SESSIONID_LEN) + 5) |
Ricardo Labiaga | 18019753 | 2009-12-05 16:08:40 -0500 | [diff] [blame] | 392 | #define encode_reclaim_complete_maxsz (op_encode_hdr_maxsz + 4) |
| 393 | #define decode_reclaim_complete_maxsz (op_decode_hdr_maxsz + 4) |
Christoph Hellwig | 84c9dee | 2014-09-10 17:37:28 -0700 | [diff] [blame] | 394 | #define encode_getdeviceinfo_maxsz (op_encode_hdr_maxsz + \ |
| 395 | XDR_QUADLEN(NFS4_DEVICEID4_SIZE) + \ |
| 396 | 1 /* layout type */ + \ |
| 397 | 1 /* maxcount */ + \ |
| 398 | 1 /* bitmap size */ + \ |
| 399 | 1 /* notification bitmap length */ + \ |
| 400 | 1 /* notification bitmap, word 0 */) |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 401 | #define decode_getdeviceinfo_maxsz (op_decode_hdr_maxsz + \ |
| 402 | 1 /* layout type */ + \ |
| 403 | 1 /* opaque devaddr4 length */ + \ |
| 404 | /* devaddr4 payload is read into page */ \ |
| 405 | 1 /* notification bitmap length */ + \ |
Chuck Lever | 02ef04e | 2019-02-11 11:25:25 -0500 | [diff] [blame] | 406 | 1 /* notification bitmap, word 0 */ + \ |
Trond Myklebust | 9ed5af26 | 2020-11-21 20:46:18 -0500 | [diff] [blame] | 407 | pagepad_maxsz /* possible XDR padding */) |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 408 | #define encode_layoutget_maxsz (op_encode_hdr_maxsz + 10 + \ |
| 409 | encode_stateid_maxsz) |
| 410 | #define decode_layoutget_maxsz (op_decode_hdr_maxsz + 8 + \ |
| 411 | decode_stateid_maxsz + \ |
Trond Myklebust | 9ed5af26 | 2020-11-21 20:46:18 -0500 | [diff] [blame] | 412 | XDR_QUADLEN(PNFS_LAYOUT_MAXSIZE) + \ |
| 413 | pagepad_maxsz) |
Andy Adamson | 863a3c6 | 2011-03-23 13:27:54 +0000 | [diff] [blame] | 414 | #define encode_layoutcommit_maxsz (op_encode_hdr_maxsz + \ |
| 415 | 2 /* offset */ + \ |
| 416 | 2 /* length */ + \ |
| 417 | 1 /* reclaim */ + \ |
| 418 | encode_stateid_maxsz + \ |
| 419 | 1 /* new offset (true) */ + \ |
| 420 | 2 /* last byte written */ + \ |
| 421 | 1 /* nt_timechanged (false) */ + \ |
| 422 | 1 /* layoutupdate4 layout type */ + \ |
Christoph Hellwig | 5f919c9 | 2014-08-21 11:09:25 -0500 | [diff] [blame] | 423 | 1 /* layoutupdate4 opaqueue len */) |
| 424 | /* the actual content of layoutupdate4 should |
| 425 | be allocated by drivers and spliced in |
| 426 | using xdr_write_pages */ |
Andy Adamson | 863a3c6 | 2011-03-23 13:27:54 +0000 | [diff] [blame] | 427 | #define decode_layoutcommit_maxsz (op_decode_hdr_maxsz + 3) |
Benny Halevy | cbe8260 | 2011-05-22 19:52:37 +0300 | [diff] [blame] | 428 | #define encode_layoutreturn_maxsz (8 + op_encode_hdr_maxsz + \ |
| 429 | encode_stateid_maxsz + \ |
Trond Myklebust | 6669cb8 | 2015-08-27 20:43:20 -0400 | [diff] [blame] | 430 | 1 + \ |
| 431 | XDR_QUADLEN(NFS4_OPAQUE_LIMIT)) |
Benny Halevy | cbe8260 | 2011-05-22 19:52:37 +0300 | [diff] [blame] | 432 | #define decode_layoutreturn_maxsz (op_decode_hdr_maxsz + \ |
| 433 | 1 + decode_stateid_maxsz) |
Bryan Schumaker | fca78d6 | 2011-06-02 14:59:07 -0400 | [diff] [blame] | 434 | #define encode_secinfo_no_name_maxsz (op_encode_hdr_maxsz + 1) |
| 435 | #define decode_secinfo_no_name_maxsz decode_secinfo_maxsz |
Bryan Schumaker | 7d97479 | 2011-06-02 14:59:08 -0400 | [diff] [blame] | 436 | #define encode_test_stateid_maxsz (op_encode_hdr_maxsz + 2 + \ |
| 437 | XDR_QUADLEN(NFS4_STATEID_SIZE)) |
| 438 | #define decode_test_stateid_maxsz (op_decode_hdr_maxsz + 2 + 1) |
Bryan Schumaker | 9aeda35 | 2011-06-02 14:59:09 -0400 | [diff] [blame] | 439 | #define encode_free_stateid_maxsz (op_encode_hdr_maxsz + 1 + \ |
| 440 | XDR_QUADLEN(NFS4_STATEID_SIZE)) |
Andy Adamson | 9f79fb4 | 2013-09-10 12:56:29 -0400 | [diff] [blame] | 441 | #define decode_free_stateid_maxsz (op_decode_hdr_maxsz) |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 442 | #else /* CONFIG_NFS_V4_1 */ |
| 443 | #define encode_sequence_maxsz 0 |
| 444 | #define decode_sequence_maxsz 0 |
Trond Myklebust | cf80516 | 2016-11-15 14:56:07 -0500 | [diff] [blame] | 445 | #define encode_layoutreturn_maxsz 0 |
| 446 | #define decode_layoutreturn_maxsz 0 |
Fred Isaman | 56f487f | 2016-09-21 11:43:41 -0400 | [diff] [blame] | 447 | #define encode_layoutget_maxsz 0 |
| 448 | #define decode_layoutget_maxsz 0 |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 449 | #endif /* CONFIG_NFS_V4_1 */ |
| 450 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 451 | #define NFS4_enc_compound_sz (1024) /* XXX: large enough? */ |
| 452 | #define NFS4_dec_compound_sz (1024) /* XXX: large enough? */ |
| 453 | #define NFS4_enc_read_sz (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 454 | encode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 455 | encode_putfh_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 456 | encode_read_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 457 | #define NFS4_dec_read_sz (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 458 | decode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 459 | decode_putfh_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 460 | decode_read_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 461 | #define NFS4_enc_readlink_sz (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 462 | encode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 463 | encode_putfh_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 464 | encode_readlink_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 465 | #define NFS4_dec_readlink_sz (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 466 | decode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 467 | decode_putfh_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 468 | decode_readlink_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 469 | #define NFS4_enc_readdir_sz (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 470 | encode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 471 | encode_putfh_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 472 | encode_readdir_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 473 | #define NFS4_dec_readdir_sz (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 474 | decode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 475 | decode_putfh_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 476 | decode_readdir_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 477 | #define NFS4_enc_write_sz (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 478 | encode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 479 | encode_putfh_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 480 | encode_write_maxsz + \ |
Trond Myklebust | 4f9838c | 2005-10-27 22:12:44 -0400 | [diff] [blame] | 481 | encode_getattr_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 482 | #define NFS4_dec_write_sz (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 483 | decode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 484 | decode_putfh_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 485 | decode_write_maxsz + \ |
Trond Myklebust | 4f9838c | 2005-10-27 22:12:44 -0400 | [diff] [blame] | 486 | decode_getattr_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 487 | #define NFS4_enc_commit_sz (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 488 | encode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 489 | encode_putfh_maxsz + \ |
Trond Myklebust | 8582715 | 2012-04-29 10:44:42 -0400 | [diff] [blame] | 490 | encode_commit_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 491 | #define NFS4_dec_commit_sz (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 492 | decode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 493 | decode_putfh_maxsz + \ |
Trond Myklebust | 8582715 | 2012-04-29 10:44:42 -0400 | [diff] [blame] | 494 | decode_commit_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 495 | #define NFS4_enc_open_sz (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 496 | encode_sequence_maxsz + \ |
Trond Myklebust | 2cebf82 | 2007-07-02 13:57:28 -0400 | [diff] [blame] | 497 | encode_putfh_maxsz + \ |
Trond Myklebust | 2cebf82 | 2007-07-02 13:57:28 -0400 | [diff] [blame] | 498 | encode_open_maxsz + \ |
Weston Andros Adamson | 6168f62 | 2012-09-10 14:00:46 -0400 | [diff] [blame] | 499 | encode_access_maxsz + \ |
Trond Myklebust | 2cebf82 | 2007-07-02 13:57:28 -0400 | [diff] [blame] | 500 | encode_getfh_maxsz + \ |
Fred Isaman | 56f487f | 2016-09-21 11:43:41 -0400 | [diff] [blame] | 501 | encode_getattr_maxsz + \ |
| 502 | encode_layoutget_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 503 | #define NFS4_dec_open_sz (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 504 | decode_sequence_maxsz + \ |
Trond Myklebust | 2cebf82 | 2007-07-02 13:57:28 -0400 | [diff] [blame] | 505 | decode_putfh_maxsz + \ |
Trond Myklebust | 2cebf82 | 2007-07-02 13:57:28 -0400 | [diff] [blame] | 506 | decode_open_maxsz + \ |
Weston Andros Adamson | 6168f62 | 2012-09-10 14:00:46 -0400 | [diff] [blame] | 507 | decode_access_maxsz + \ |
Trond Myklebust | 2cebf82 | 2007-07-02 13:57:28 -0400 | [diff] [blame] | 508 | decode_getfh_maxsz + \ |
Fred Isaman | 56f487f | 2016-09-21 11:43:41 -0400 | [diff] [blame] | 509 | decode_getattr_maxsz + \ |
| 510 | decode_layoutget_maxsz) |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 511 | #define NFS4_enc_open_confirm_sz \ |
| 512 | (compound_encode_hdr_maxsz + \ |
| 513 | encode_putfh_maxsz + \ |
| 514 | encode_open_confirm_maxsz) |
| 515 | #define NFS4_dec_open_confirm_sz \ |
| 516 | (compound_decode_hdr_maxsz + \ |
| 517 | decode_putfh_maxsz + \ |
| 518 | decode_open_confirm_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 519 | #define NFS4_enc_open_noattr_sz (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 520 | encode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 521 | encode_putfh_maxsz + \ |
Trond Myklebust | 2cebf82 | 2007-07-02 13:57:28 -0400 | [diff] [blame] | 522 | encode_open_maxsz + \ |
Weston Andros Adamson | 6168f62 | 2012-09-10 14:00:46 -0400 | [diff] [blame] | 523 | encode_access_maxsz + \ |
Fred Isaman | 56f487f | 2016-09-21 11:43:41 -0400 | [diff] [blame] | 524 | encode_getattr_maxsz + \ |
| 525 | encode_layoutget_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 526 | #define NFS4_dec_open_noattr_sz (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 527 | decode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 528 | decode_putfh_maxsz + \ |
Trond Myklebust | 2cebf82 | 2007-07-02 13:57:28 -0400 | [diff] [blame] | 529 | decode_open_maxsz + \ |
Weston Andros Adamson | 6168f62 | 2012-09-10 14:00:46 -0400 | [diff] [blame] | 530 | decode_access_maxsz + \ |
Fred Isaman | 56f487f | 2016-09-21 11:43:41 -0400 | [diff] [blame] | 531 | decode_getattr_maxsz + \ |
| 532 | decode_layoutget_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 533 | #define NFS4_enc_open_downgrade_sz \ |
| 534 | (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 535 | encode_sequence_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 536 | encode_putfh_maxsz + \ |
Trond Myklebust | b680814 | 2016-11-20 13:34:16 -0500 | [diff] [blame] | 537 | encode_layoutreturn_maxsz + \ |
Trond Myklebust | 3947b74 | 2016-10-27 18:27:02 -0400 | [diff] [blame] | 538 | encode_open_downgrade_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 539 | #define NFS4_dec_open_downgrade_sz \ |
| 540 | (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 541 | decode_sequence_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 542 | decode_putfh_maxsz + \ |
Trond Myklebust | b680814 | 2016-11-20 13:34:16 -0500 | [diff] [blame] | 543 | decode_layoutreturn_maxsz + \ |
Trond Myklebust | 3947b74 | 2016-10-27 18:27:02 -0400 | [diff] [blame] | 544 | decode_open_downgrade_maxsz) |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 545 | #define NFS4_enc_close_sz (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 546 | encode_sequence_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 547 | encode_putfh_maxsz + \ |
Trond Myklebust | cf80516 | 2016-11-15 14:56:07 -0500 | [diff] [blame] | 548 | encode_layoutreturn_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 549 | encode_close_maxsz + \ |
| 550 | encode_getattr_maxsz) |
| 551 | #define NFS4_dec_close_sz (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 552 | decode_sequence_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 553 | decode_putfh_maxsz + \ |
Trond Myklebust | cf80516 | 2016-11-15 14:56:07 -0500 | [diff] [blame] | 554 | decode_layoutreturn_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 555 | decode_close_maxsz + \ |
| 556 | decode_getattr_maxsz) |
| 557 | #define NFS4_enc_setattr_sz (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 558 | encode_sequence_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 559 | encode_putfh_maxsz + \ |
| 560 | encode_setattr_maxsz + \ |
| 561 | encode_getattr_maxsz) |
| 562 | #define NFS4_dec_setattr_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_setattr_maxsz + \ |
| 566 | decode_getattr_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 567 | #define NFS4_enc_fsinfo_sz (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 568 | encode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 569 | encode_putfh_maxsz + \ |
| 570 | encode_fsinfo_maxsz) |
| 571 | #define NFS4_dec_fsinfo_sz (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 572 | decode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 573 | decode_putfh_maxsz + \ |
| 574 | decode_fsinfo_maxsz) |
| 575 | #define NFS4_enc_renew_sz (compound_encode_hdr_maxsz + \ |
| 576 | encode_renew_maxsz) |
| 577 | #define NFS4_dec_renew_sz (compound_decode_hdr_maxsz + \ |
| 578 | decode_renew_maxsz) |
| 579 | #define NFS4_enc_setclientid_sz (compound_encode_hdr_maxsz + \ |
| 580 | encode_setclientid_maxsz) |
| 581 | #define NFS4_dec_setclientid_sz (compound_decode_hdr_maxsz + \ |
| 582 | decode_setclientid_maxsz) |
| 583 | #define NFS4_enc_setclientid_confirm_sz \ |
| 584 | (compound_encode_hdr_maxsz + \ |
Chuck Lever | 83ca7f5 | 2013-03-16 15:55:53 -0400 | [diff] [blame] | 585 | encode_setclientid_confirm_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 586 | #define NFS4_dec_setclientid_confirm_sz \ |
| 587 | (compound_decode_hdr_maxsz + \ |
Chuck Lever | 83ca7f5 | 2013-03-16 15:55:53 -0400 | [diff] [blame] | 588 | decode_setclientid_confirm_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 589 | #define NFS4_enc_lock_sz (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 590 | encode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 591 | encode_putfh_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 592 | encode_lock_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 593 | #define NFS4_dec_lock_sz (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 594 | decode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 595 | decode_putfh_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 596 | decode_lock_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 597 | #define NFS4_enc_lockt_sz (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 598 | encode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 599 | encode_putfh_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 600 | encode_lockt_maxsz) |
| 601 | #define NFS4_dec_lockt_sz (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 602 | decode_sequence_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 603 | decode_putfh_maxsz + \ |
| 604 | decode_lockt_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 605 | #define NFS4_enc_locku_sz (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 606 | encode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 607 | encode_putfh_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 608 | encode_locku_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 609 | #define NFS4_dec_locku_sz (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 610 | decode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 611 | decode_putfh_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 612 | decode_locku_maxsz) |
Trond Myklebust | d3c7b7c | 2010-07-01 12:49:01 -0400 | [diff] [blame] | 613 | #define NFS4_enc_release_lockowner_sz \ |
| 614 | (compound_encode_hdr_maxsz + \ |
| 615 | encode_lockowner_maxsz) |
| 616 | #define NFS4_dec_release_lockowner_sz \ |
| 617 | (compound_decode_hdr_maxsz + \ |
| 618 | decode_lockowner_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 619 | #define NFS4_enc_access_sz (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 620 | encode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 621 | encode_putfh_maxsz + \ |
Trond Myklebust | 76b3299 | 2007-08-10 17:45:11 -0400 | [diff] [blame] | 622 | encode_access_maxsz + \ |
| 623 | encode_getattr_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 624 | #define NFS4_dec_access_sz (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 625 | decode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 626 | decode_putfh_maxsz + \ |
Trond Myklebust | 76b3299 | 2007-08-10 17:45:11 -0400 | [diff] [blame] | 627 | decode_access_maxsz + \ |
| 628 | decode_getattr_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 629 | #define NFS4_enc_getattr_sz (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 630 | encode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 631 | encode_putfh_maxsz + \ |
Chuck Lever | 44c9993 | 2013-10-17 14:13:30 -0400 | [diff] [blame] | 632 | encode_getattr_maxsz + \ |
| 633 | encode_renew_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 634 | #define NFS4_dec_getattr_sz (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 635 | decode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 636 | decode_putfh_maxsz + \ |
Chuck Lever | 44c9993 | 2013-10-17 14:13:30 -0400 | [diff] [blame] | 637 | decode_getattr_maxsz + \ |
| 638 | decode_renew_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 639 | #define NFS4_enc_lookup_sz (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 640 | encode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 641 | encode_putfh_maxsz + \ |
| 642 | encode_lookup_maxsz + \ |
| 643 | encode_getattr_maxsz + \ |
| 644 | encode_getfh_maxsz) |
| 645 | #define NFS4_dec_lookup_sz (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 646 | decode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 647 | decode_putfh_maxsz + \ |
Trond Myklebust | e688962 | 2007-07-02 13:58:30 -0400 | [diff] [blame] | 648 | decode_lookup_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 649 | decode_getattr_maxsz + \ |
| 650 | decode_getfh_maxsz) |
Jeff Layton | 5b5faaf | 2017-06-29 06:34:52 -0700 | [diff] [blame] | 651 | #define NFS4_enc_lookupp_sz (compound_encode_hdr_maxsz + \ |
| 652 | encode_sequence_maxsz + \ |
| 653 | encode_putfh_maxsz + \ |
| 654 | encode_lookupp_maxsz + \ |
| 655 | encode_getattr_maxsz + \ |
| 656 | encode_getfh_maxsz) |
| 657 | #define NFS4_dec_lookupp_sz (compound_decode_hdr_maxsz + \ |
| 658 | decode_sequence_maxsz + \ |
| 659 | decode_putfh_maxsz + \ |
| 660 | decode_lookupp_maxsz + \ |
| 661 | decode_getattr_maxsz + \ |
| 662 | decode_getfh_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 663 | #define NFS4_enc_lookup_root_sz (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 664 | encode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 665 | encode_putrootfh_maxsz + \ |
| 666 | encode_getattr_maxsz + \ |
| 667 | encode_getfh_maxsz) |
| 668 | #define NFS4_dec_lookup_root_sz (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 669 | decode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 670 | decode_putrootfh_maxsz + \ |
| 671 | decode_getattr_maxsz + \ |
| 672 | decode_getfh_maxsz) |
| 673 | #define NFS4_enc_remove_sz (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 674 | encode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 675 | encode_putfh_maxsz + \ |
Trond Myklebust | 778d281 | 2012-04-27 13:48:19 -0400 | [diff] [blame] | 676 | encode_remove_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 677 | #define NFS4_dec_remove_sz (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 678 | decode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 679 | decode_putfh_maxsz + \ |
Trond Myklebust | 778d281 | 2012-04-27 13:48:19 -0400 | [diff] [blame] | 680 | decode_remove_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 681 | #define NFS4_enc_rename_sz (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 682 | encode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 683 | encode_putfh_maxsz + \ |
| 684 | encode_savefh_maxsz + \ |
| 685 | encode_putfh_maxsz + \ |
Trond Myklebust | 778d281 | 2012-04-27 13:48:19 -0400 | [diff] [blame] | 686 | encode_rename_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 687 | #define NFS4_dec_rename_sz (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 688 | decode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 689 | decode_putfh_maxsz + \ |
| 690 | decode_savefh_maxsz + \ |
| 691 | decode_putfh_maxsz + \ |
Trond Myklebust | 778d281 | 2012-04-27 13:48:19 -0400 | [diff] [blame] | 692 | decode_rename_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 693 | #define NFS4_enc_link_sz (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 694 | encode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 695 | encode_putfh_maxsz + \ |
| 696 | encode_savefh_maxsz + \ |
| 697 | encode_putfh_maxsz + \ |
Trond Myklebust | 91ba2ee | 2005-10-27 22:12:42 -0400 | [diff] [blame] | 698 | encode_link_maxsz + \ |
Trond Myklebust | 91ba2ee | 2005-10-27 22:12:42 -0400 | [diff] [blame] | 699 | encode_restorefh_maxsz + \ |
Trond Myklebust | a9f6991 | 2012-04-27 13:48:17 -0400 | [diff] [blame] | 700 | encode_getattr_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 701 | #define NFS4_dec_link_sz (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 702 | decode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 703 | decode_putfh_maxsz + \ |
| 704 | decode_savefh_maxsz + \ |
| 705 | decode_putfh_maxsz + \ |
Trond Myklebust | 91ba2ee | 2005-10-27 22:12:42 -0400 | [diff] [blame] | 706 | decode_link_maxsz + \ |
Trond Myklebust | 91ba2ee | 2005-10-27 22:12:42 -0400 | [diff] [blame] | 707 | decode_restorefh_maxsz + \ |
| 708 | decode_getattr_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 709 | #define NFS4_enc_symlink_sz (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 710 | encode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 711 | encode_putfh_maxsz + \ |
| 712 | encode_symlink_maxsz + \ |
| 713 | encode_getattr_maxsz + \ |
| 714 | encode_getfh_maxsz) |
| 715 | #define NFS4_dec_symlink_sz (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 716 | decode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 717 | decode_putfh_maxsz + \ |
| 718 | decode_symlink_maxsz + \ |
| 719 | decode_getattr_maxsz + \ |
| 720 | decode_getfh_maxsz) |
| 721 | #define NFS4_enc_create_sz (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 722 | encode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 723 | encode_putfh_maxsz + \ |
| 724 | encode_create_maxsz + \ |
Trond Myklebust | 56ae19f | 2005-10-27 22:12:40 -0400 | [diff] [blame] | 725 | encode_getfh_maxsz + \ |
Trond Myklebust | 56ae19f | 2005-10-27 22:12:40 -0400 | [diff] [blame] | 726 | encode_getattr_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 727 | #define NFS4_dec_create_sz (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 728 | decode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 729 | decode_putfh_maxsz + \ |
| 730 | decode_create_maxsz + \ |
Trond Myklebust | 56ae19f | 2005-10-27 22:12:40 -0400 | [diff] [blame] | 731 | decode_getfh_maxsz + \ |
Trond Myklebust | 56ae19f | 2005-10-27 22:12:40 -0400 | [diff] [blame] | 732 | decode_getattr_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 733 | #define NFS4_enc_pathconf_sz (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 734 | encode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 735 | encode_putfh_maxsz + \ |
| 736 | encode_getattr_maxsz) |
| 737 | #define NFS4_dec_pathconf_sz (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 738 | decode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 739 | decode_putfh_maxsz + \ |
| 740 | decode_getattr_maxsz) |
| 741 | #define NFS4_enc_statfs_sz (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 742 | encode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 743 | encode_putfh_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 744 | encode_statfs_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 745 | #define NFS4_dec_statfs_sz (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 746 | decode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 747 | decode_putfh_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 748 | decode_statfs_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 749 | #define NFS4_enc_server_caps_sz (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 750 | encode_sequence_maxsz + \ |
Trond Myklebust | ab91f26 | 2007-02-02 14:47:17 -0800 | [diff] [blame] | 751 | encode_putfh_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 752 | encode_getattr_maxsz) |
| 753 | #define NFS4_dec_server_caps_sz (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 754 | decode_sequence_maxsz + \ |
Trond Myklebust | ab91f26 | 2007-02-02 14:47:17 -0800 | [diff] [blame] | 755 | decode_putfh_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 756 | decode_getattr_maxsz) |
| 757 | #define NFS4_enc_delegreturn_sz (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 758 | encode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 759 | encode_putfh_maxsz + \ |
Trond Myklebust | 586f1c3 | 2016-11-15 15:03:33 -0500 | [diff] [blame] | 760 | encode_layoutreturn_maxsz + \ |
Trond Myklebust | fa178f2 | 2006-01-03 09:55:38 +0100 | [diff] [blame] | 761 | encode_delegreturn_maxsz + \ |
| 762 | encode_getattr_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 763 | #define NFS4_dec_delegreturn_sz (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 764 | decode_sequence_maxsz + \ |
Trond Myklebust | d8434d4c | 2016-11-16 13:54:00 -0500 | [diff] [blame] | 765 | decode_putfh_maxsz + \ |
Trond Myklebust | 586f1c3 | 2016-11-15 15:03:33 -0500 | [diff] [blame] | 766 | decode_layoutreturn_maxsz + \ |
Trond Myklebust | fa178f2 | 2006-01-03 09:55:38 +0100 | [diff] [blame] | 767 | decode_delegreturn_maxsz + \ |
| 768 | decode_getattr_maxsz) |
J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 769 | #define NFS4_enc_getacl_sz (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 770 | encode_sequence_maxsz + \ |
J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 771 | encode_putfh_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 772 | encode_getacl_maxsz) |
J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 773 | #define NFS4_dec_getacl_sz (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 774 | decode_sequence_maxsz + \ |
J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 775 | decode_putfh_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 776 | decode_getacl_maxsz) |
J. Bruce Fields | 23ec696 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 777 | #define NFS4_enc_setacl_sz (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 778 | encode_sequence_maxsz + \ |
J. Bruce Fields | 23ec696 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 779 | encode_putfh_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 780 | encode_setacl_maxsz) |
J. Bruce Fields | 23ec696 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 781 | #define NFS4_dec_setacl_sz (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 782 | decode_sequence_maxsz + \ |
J. Bruce Fields | 23ec696 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 783 | decode_putfh_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 784 | decode_setacl_maxsz) |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 785 | #define NFS4_enc_fs_locations_sz \ |
| 786 | (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 787 | encode_sequence_maxsz + \ |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 788 | encode_putfh_maxsz + \ |
Trond Myklebust | e688962 | 2007-07-02 13:58:30 -0400 | [diff] [blame] | 789 | encode_lookup_maxsz + \ |
Chuck Lever | b03d735 | 2013-10-17 14:12:50 -0400 | [diff] [blame] | 790 | encode_fs_locations_maxsz + \ |
| 791 | encode_renew_maxsz) |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 792 | #define NFS4_dec_fs_locations_sz \ |
| 793 | (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 794 | decode_sequence_maxsz + \ |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 795 | decode_putfh_maxsz + \ |
Trond Myklebust | e688962 | 2007-07-02 13:58:30 -0400 | [diff] [blame] | 796 | decode_lookup_maxsz + \ |
Chuck Lever | b03d735 | 2013-10-17 14:12:50 -0400 | [diff] [blame] | 797 | decode_fs_locations_maxsz + \ |
| 798 | decode_renew_maxsz) |
Bryan Schumaker | 5a5ea0d | 2011-03-24 17:12:29 +0000 | [diff] [blame] | 799 | #define NFS4_enc_secinfo_sz (compound_encode_hdr_maxsz + \ |
| 800 | encode_sequence_maxsz + \ |
| 801 | encode_putfh_maxsz + \ |
| 802 | encode_secinfo_maxsz) |
| 803 | #define NFS4_dec_secinfo_sz (compound_decode_hdr_maxsz + \ |
| 804 | decode_sequence_maxsz + \ |
| 805 | decode_putfh_maxsz + \ |
| 806 | decode_secinfo_maxsz) |
Chuck Lever | 44c9993 | 2013-10-17 14:13:30 -0400 | [diff] [blame] | 807 | #define NFS4_enc_fsid_present_sz \ |
| 808 | (compound_encode_hdr_maxsz + \ |
| 809 | encode_sequence_maxsz + \ |
| 810 | encode_putfh_maxsz + \ |
| 811 | encode_getfh_maxsz + \ |
| 812 | encode_renew_maxsz) |
| 813 | #define NFS4_dec_fsid_present_sz \ |
| 814 | (compound_decode_hdr_maxsz + \ |
| 815 | decode_sequence_maxsz + \ |
| 816 | decode_putfh_maxsz + \ |
| 817 | decode_getfh_maxsz + \ |
| 818 | decode_renew_maxsz) |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 819 | #if defined(CONFIG_NFS_V4_1) |
Weston Andros Adamson | 7c44f1ae | 2012-05-24 13:22:50 -0400 | [diff] [blame] | 820 | #define NFS4_enc_bind_conn_to_session_sz \ |
| 821 | (compound_encode_hdr_maxsz + \ |
| 822 | encode_bind_conn_to_session_maxsz) |
| 823 | #define NFS4_dec_bind_conn_to_session_sz \ |
| 824 | (compound_decode_hdr_maxsz + \ |
| 825 | decode_bind_conn_to_session_maxsz) |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 826 | #define NFS4_enc_exchange_id_sz \ |
| 827 | (compound_encode_hdr_maxsz + \ |
| 828 | encode_exchange_id_maxsz) |
| 829 | #define NFS4_dec_exchange_id_sz \ |
| 830 | (compound_decode_hdr_maxsz + \ |
| 831 | decode_exchange_id_maxsz) |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 832 | #define NFS4_enc_create_session_sz \ |
| 833 | (compound_encode_hdr_maxsz + \ |
| 834 | encode_create_session_maxsz) |
| 835 | #define NFS4_dec_create_session_sz \ |
| 836 | (compound_decode_hdr_maxsz + \ |
| 837 | decode_create_session_maxsz) |
Andy Adamson | 0f3e66c | 2009-04-01 09:22:34 -0400 | [diff] [blame] | 838 | #define NFS4_enc_destroy_session_sz (compound_encode_hdr_maxsz + \ |
| 839 | encode_destroy_session_maxsz) |
| 840 | #define NFS4_dec_destroy_session_sz (compound_decode_hdr_maxsz + \ |
| 841 | decode_destroy_session_maxsz) |
Trond Myklebust | 6624553 | 2012-05-25 17:18:09 -0400 | [diff] [blame] | 842 | #define NFS4_enc_destroy_clientid_sz (compound_encode_hdr_maxsz + \ |
| 843 | encode_destroy_clientid_maxsz) |
| 844 | #define NFS4_dec_destroy_clientid_sz (compound_decode_hdr_maxsz + \ |
| 845 | decode_destroy_clientid_maxsz) |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 846 | #define NFS4_enc_sequence_sz \ |
| 847 | (compound_decode_hdr_maxsz + \ |
| 848 | encode_sequence_maxsz) |
| 849 | #define NFS4_dec_sequence_sz \ |
| 850 | (compound_decode_hdr_maxsz + \ |
| 851 | decode_sequence_maxsz) |
Donald Buczek | 0efb01b | 2019-07-07 21:26:08 +0200 | [diff] [blame] | 852 | #endif |
Andy Adamson | 2050f0c | 2009-04-01 09:22:30 -0400 | [diff] [blame] | 853 | #define NFS4_enc_get_lease_time_sz (compound_encode_hdr_maxsz + \ |
| 854 | encode_sequence_maxsz + \ |
| 855 | encode_putrootfh_maxsz + \ |
| 856 | encode_fsinfo_maxsz) |
| 857 | #define NFS4_dec_get_lease_time_sz (compound_decode_hdr_maxsz + \ |
| 858 | decode_sequence_maxsz + \ |
| 859 | decode_putrootfh_maxsz + \ |
| 860 | decode_fsinfo_maxsz) |
Donald Buczek | 0efb01b | 2019-07-07 21:26:08 +0200 | [diff] [blame] | 861 | #if defined(CONFIG_NFS_V4_1) |
Ricardo Labiaga | 18019753 | 2009-12-05 16:08:40 -0500 | [diff] [blame] | 862 | #define NFS4_enc_reclaim_complete_sz (compound_encode_hdr_maxsz + \ |
| 863 | encode_sequence_maxsz + \ |
| 864 | encode_reclaim_complete_maxsz) |
| 865 | #define NFS4_dec_reclaim_complete_sz (compound_decode_hdr_maxsz + \ |
| 866 | decode_sequence_maxsz + \ |
| 867 | decode_reclaim_complete_maxsz) |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 868 | #define NFS4_enc_getdeviceinfo_sz (compound_encode_hdr_maxsz + \ |
| 869 | encode_sequence_maxsz +\ |
| 870 | encode_getdeviceinfo_maxsz) |
| 871 | #define NFS4_dec_getdeviceinfo_sz (compound_decode_hdr_maxsz + \ |
| 872 | decode_sequence_maxsz + \ |
| 873 | decode_getdeviceinfo_maxsz) |
| 874 | #define NFS4_enc_layoutget_sz (compound_encode_hdr_maxsz + \ |
| 875 | encode_sequence_maxsz + \ |
| 876 | encode_putfh_maxsz + \ |
| 877 | encode_layoutget_maxsz) |
| 878 | #define NFS4_dec_layoutget_sz (compound_decode_hdr_maxsz + \ |
| 879 | decode_sequence_maxsz + \ |
| 880 | decode_putfh_maxsz + \ |
| 881 | decode_layoutget_maxsz) |
Andy Adamson | 863a3c6 | 2011-03-23 13:27:54 +0000 | [diff] [blame] | 882 | #define NFS4_enc_layoutcommit_sz (compound_encode_hdr_maxsz + \ |
| 883 | encode_sequence_maxsz +\ |
| 884 | encode_putfh_maxsz + \ |
| 885 | encode_layoutcommit_maxsz + \ |
| 886 | encode_getattr_maxsz) |
| 887 | #define NFS4_dec_layoutcommit_sz (compound_decode_hdr_maxsz + \ |
| 888 | decode_sequence_maxsz + \ |
| 889 | decode_putfh_maxsz + \ |
| 890 | decode_layoutcommit_maxsz + \ |
| 891 | decode_getattr_maxsz) |
Benny Halevy | cbe8260 | 2011-05-22 19:52:37 +0300 | [diff] [blame] | 892 | #define NFS4_enc_layoutreturn_sz (compound_encode_hdr_maxsz + \ |
| 893 | encode_sequence_maxsz + \ |
| 894 | encode_putfh_maxsz + \ |
| 895 | encode_layoutreturn_maxsz) |
| 896 | #define NFS4_dec_layoutreturn_sz (compound_decode_hdr_maxsz + \ |
| 897 | decode_sequence_maxsz + \ |
| 898 | decode_putfh_maxsz + \ |
| 899 | decode_layoutreturn_maxsz) |
Bryan Schumaker | fca78d6 | 2011-06-02 14:59:07 -0400 | [diff] [blame] | 900 | #define NFS4_enc_secinfo_no_name_sz (compound_encode_hdr_maxsz + \ |
| 901 | encode_sequence_maxsz + \ |
| 902 | encode_putrootfh_maxsz +\ |
| 903 | encode_secinfo_no_name_maxsz) |
| 904 | #define NFS4_dec_secinfo_no_name_sz (compound_decode_hdr_maxsz + \ |
| 905 | decode_sequence_maxsz + \ |
| 906 | decode_putrootfh_maxsz + \ |
| 907 | decode_secinfo_no_name_maxsz) |
Bryan Schumaker | 7d97479 | 2011-06-02 14:59:08 -0400 | [diff] [blame] | 908 | #define NFS4_enc_test_stateid_sz (compound_encode_hdr_maxsz + \ |
| 909 | encode_sequence_maxsz + \ |
| 910 | encode_test_stateid_maxsz) |
| 911 | #define NFS4_dec_test_stateid_sz (compound_decode_hdr_maxsz + \ |
| 912 | decode_sequence_maxsz + \ |
| 913 | decode_test_stateid_maxsz) |
Bryan Schumaker | 9aeda35 | 2011-06-02 14:59:09 -0400 | [diff] [blame] | 914 | #define NFS4_enc_free_stateid_sz (compound_encode_hdr_maxsz + \ |
| 915 | encode_sequence_maxsz + \ |
| 916 | encode_free_stateid_maxsz) |
| 917 | #define NFS4_dec_free_stateid_sz (compound_decode_hdr_maxsz + \ |
| 918 | decode_sequence_maxsz + \ |
| 919 | decode_free_stateid_maxsz) |
Alexandros Batsakis | 2449ea2 | 2009-12-05 13:36:55 -0500 | [diff] [blame] | 920 | |
| 921 | const u32 nfs41_maxwrite_overhead = ((RPC_MAX_HEADER_WITH_AUTH + |
| 922 | compound_encode_hdr_maxsz + |
| 923 | encode_sequence_maxsz + |
| 924 | encode_putfh_maxsz + |
| 925 | encode_getattr_maxsz) * |
| 926 | XDR_UNIT); |
| 927 | |
| 928 | const u32 nfs41_maxread_overhead = ((RPC_MAX_HEADER_WITH_AUTH + |
| 929 | compound_decode_hdr_maxsz + |
| 930 | decode_sequence_maxsz + |
| 931 | decode_putfh_maxsz) * |
| 932 | XDR_UNIT); |
Andy Adamson | f1c097b | 2013-06-25 19:02:53 -0400 | [diff] [blame] | 933 | |
| 934 | const u32 nfs41_maxgetdevinfo_overhead = ((RPC_MAX_REPHEADER_WITH_AUTH + |
| 935 | compound_decode_hdr_maxsz + |
| 936 | decode_sequence_maxsz) * |
| 937 | XDR_UNIT); |
| 938 | EXPORT_SYMBOL_GPL(nfs41_maxgetdevinfo_overhead); |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 939 | #endif /* CONFIG_NFS_V4_1 */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 940 | |
Trond Myklebust | bca7947 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 941 | static const umode_t nfs_type2fmt[] = { |
| 942 | [NF4BAD] = 0, |
| 943 | [NF4REG] = S_IFREG, |
| 944 | [NF4DIR] = S_IFDIR, |
| 945 | [NF4BLK] = S_IFBLK, |
| 946 | [NF4CHR] = S_IFCHR, |
| 947 | [NF4LNK] = S_IFLNK, |
| 948 | [NF4SOCK] = S_IFSOCK, |
| 949 | [NF4FIFO] = S_IFIFO, |
| 950 | [NF4ATTRDIR] = 0, |
| 951 | [NF4NAMEDATTR] = 0, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 952 | }; |
| 953 | |
| 954 | struct compound_hdr { |
| 955 | int32_t status; |
| 956 | uint32_t nops; |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 957 | __be32 * nops_p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 958 | uint32_t taglen; |
| 959 | char * tag; |
Benny Halevy | 0c4e8c1 | 2009-04-01 09:22:07 -0400 | [diff] [blame] | 960 | uint32_t replen; /* expected reply words */ |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 961 | u32 minorversion; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 962 | }; |
| 963 | |
Benny Halevy | 13c65ce | 2009-08-14 17:19:25 +0300 | [diff] [blame] | 964 | static __be32 *reserve_space(struct xdr_stream *xdr, size_t nbytes) |
| 965 | { |
| 966 | __be32 *p = xdr_reserve_space(xdr, nbytes); |
| 967 | BUG_ON(!p); |
| 968 | return p; |
| 969 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 970 | |
Trond Myklebust | cb17e55 | 2012-03-04 18:13:56 -0500 | [diff] [blame] | 971 | static void encode_opaque_fixed(struct xdr_stream *xdr, const void *buf, size_t len) |
| 972 | { |
Trond Myklebust | ab6e9aa | 2017-02-19 16:08:26 -0500 | [diff] [blame] | 973 | WARN_ON_ONCE(xdr_stream_encode_opaque_fixed(xdr, buf, len) < 0); |
Trond Myklebust | cb17e55 | 2012-03-04 18:13:56 -0500 | [diff] [blame] | 974 | } |
| 975 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 976 | static void encode_string(struct xdr_stream *xdr, unsigned int len, const char *str) |
| 977 | { |
Trond Myklebust | ab6e9aa | 2017-02-19 16:08:26 -0500 | [diff] [blame] | 978 | WARN_ON_ONCE(xdr_stream_encode_opaque(xdr, str, len) < 0); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 979 | } |
| 980 | |
Trond Myklebust | 4ade982 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 981 | static void encode_uint32(struct xdr_stream *xdr, u32 n) |
| 982 | { |
Trond Myklebust | ab6e9aa | 2017-02-19 16:08:26 -0500 | [diff] [blame] | 983 | WARN_ON_ONCE(xdr_stream_encode_u32(xdr, n) < 0); |
Trond Myklebust | 4ade982 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 984 | } |
| 985 | |
Trond Myklebust | ff2eb68 | 2012-03-05 11:40:12 -0500 | [diff] [blame] | 986 | static void encode_uint64(struct xdr_stream *xdr, u64 n) |
| 987 | { |
Trond Myklebust | ab6e9aa | 2017-02-19 16:08:26 -0500 | [diff] [blame] | 988 | WARN_ON_ONCE(xdr_stream_encode_u64(xdr, n) < 0); |
Trond Myklebust | ff2eb68 | 2012-03-05 11:40:12 -0500 | [diff] [blame] | 989 | } |
| 990 | |
Trond Myklebust | 37c8876 | 2018-03-20 17:03:08 -0400 | [diff] [blame] | 991 | static ssize_t xdr_encode_bitmap4(struct xdr_stream *xdr, |
| 992 | const __u32 *bitmap, size_t len) |
| 993 | { |
| 994 | ssize_t ret; |
| 995 | |
| 996 | /* Trim empty words */ |
| 997 | while (len > 0 && bitmap[len-1] == 0) |
| 998 | len--; |
| 999 | ret = xdr_stream_encode_uint32_array(xdr, bitmap, len); |
| 1000 | if (WARN_ON_ONCE(ret < 0)) |
| 1001 | return ret; |
| 1002 | return len; |
| 1003 | } |
| 1004 | |
| 1005 | static size_t mask_bitmap4(const __u32 *bitmap, const __u32 *mask, |
| 1006 | __u32 *res, size_t len) |
| 1007 | { |
| 1008 | size_t i; |
| 1009 | __u32 tmp; |
| 1010 | |
| 1011 | while (len > 0 && (bitmap[len-1] == 0 || mask[len-1] == 0)) |
| 1012 | len--; |
| 1013 | for (i = len; i-- > 0;) { |
| 1014 | tmp = bitmap[i] & mask[i]; |
| 1015 | res[i] = tmp; |
| 1016 | } |
| 1017 | return len; |
| 1018 | } |
| 1019 | |
Trond Myklebust | 4ade982 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1020 | static void encode_nfs4_seqid(struct xdr_stream *xdr, |
| 1021 | const struct nfs_seqid *seqid) |
| 1022 | { |
Trond Myklebust | a679641 | 2015-01-23 19:04:44 -0500 | [diff] [blame] | 1023 | if (seqid != NULL) |
| 1024 | encode_uint32(xdr, seqid->sequence->counter); |
| 1025 | else |
| 1026 | encode_uint32(xdr, 0); |
Trond Myklebust | 4ade982 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1027 | } |
| 1028 | |
Benny Halevy | 0c4e8c1 | 2009-04-01 09:22:07 -0400 | [diff] [blame] | 1029 | static void encode_compound_hdr(struct xdr_stream *xdr, |
| 1030 | struct rpc_rqst *req, |
| 1031 | struct compound_hdr *hdr) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1032 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 1033 | __be32 *p; |
Benny Halevy | 0c4e8c1 | 2009-04-01 09:22:07 -0400 | [diff] [blame] | 1034 | |
| 1035 | /* initialize running count of expected bytes in reply. |
| 1036 | * NOTE: the replied tag SHOULD be the same is the one sent, |
| 1037 | * but this is not required as a MUST for the server to do so. */ |
Chuck Lever | cf500ba | 2019-02-11 11:25:20 -0500 | [diff] [blame] | 1038 | hdr->replen = 3 + hdr->taglen; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1039 | |
Trond Myklebust | 7fc3884 | 2012-10-15 11:51:21 -0400 | [diff] [blame] | 1040 | WARN_ON_ONCE(hdr->taglen > NFS4_MAXTAGLEN); |
Trond Myklebust | 6fdfb0bc | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1041 | encode_string(xdr, hdr->taglen, hdr->tag); |
| 1042 | p = reserve_space(xdr, 8); |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1043 | *p++ = cpu_to_be32(hdr->minorversion); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 1044 | hdr->nops_p = p; |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1045 | *p = cpu_to_be32(hdr->nops); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 1046 | } |
| 1047 | |
Trond Myklebust | ab19b48 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1048 | static void encode_op_hdr(struct xdr_stream *xdr, enum nfs_opnum4 op, |
| 1049 | uint32_t replen, |
| 1050 | struct compound_hdr *hdr) |
| 1051 | { |
| 1052 | encode_uint32(xdr, op); |
| 1053 | hdr->nops++; |
| 1054 | hdr->replen += replen; |
| 1055 | } |
| 1056 | |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 1057 | static void encode_nops(struct compound_hdr *hdr) |
| 1058 | { |
Trond Myklebust | 7fc3884 | 2012-10-15 11:51:21 -0400 | [diff] [blame] | 1059 | WARN_ON_ONCE(hdr->nops > NFS4_MAX_OPS); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 1060 | *hdr->nops_p = htonl(hdr->nops); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1061 | } |
| 1062 | |
Trond Myklebust | ea9d23f | 2012-03-04 18:13:56 -0500 | [diff] [blame] | 1063 | static void encode_nfs4_stateid(struct xdr_stream *xdr, const nfs4_stateid *stateid) |
| 1064 | { |
Trond Myklebust | 2d2f24a | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1065 | encode_opaque_fixed(xdr, stateid, NFS4_STATEID_SIZE); |
Trond Myklebust | ea9d23f | 2012-03-04 18:13:56 -0500 | [diff] [blame] | 1066 | } |
| 1067 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1068 | static void encode_nfs4_verifier(struct xdr_stream *xdr, const nfs4_verifier *verf) |
| 1069 | { |
Trond Myklebust | cb17e55 | 2012-03-04 18:13:56 -0500 | [diff] [blame] | 1070 | encode_opaque_fixed(xdr, verf->data, NFS4_VERIFIER_SIZE); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1071 | } |
| 1072 | |
Trond Myklebust | 36b3743 | 2018-03-20 17:03:10 -0400 | [diff] [blame] | 1073 | static __be32 * |
Trond Myklebust | e7d4b05 | 2019-10-04 16:43:09 -0400 | [diff] [blame] | 1074 | xdr_encode_nfstime4(__be32 *p, const struct timespec64 *t) |
Trond Myklebust | 36b3743 | 2018-03-20 17:03:10 -0400 | [diff] [blame] | 1075 | { |
Arnd Bergmann | a3167da | 2019-11-11 21:16:27 +0100 | [diff] [blame] | 1076 | p = xdr_encode_hyper(p, t->tv_sec); |
Trond Myklebust | 36b3743 | 2018-03-20 17:03:10 -0400 | [diff] [blame] | 1077 | *p++ = cpu_to_be32(t->tv_nsec); |
| 1078 | return p; |
| 1079 | } |
| 1080 | |
David Quigley | aa9c266 | 2013-05-22 12:50:44 -0400 | [diff] [blame] | 1081 | static void encode_attrs(struct xdr_stream *xdr, const struct iattr *iap, |
| 1082 | const struct nfs4_label *label, |
Trond Myklebust | 28cf22d | 2017-05-06 12:19:11 -0400 | [diff] [blame] | 1083 | const umode_t *umask, |
Kinglong Mee | 5334c5b | 2015-08-26 21:13:37 +0800 | [diff] [blame] | 1084 | const struct nfs_server *server, |
Trond Myklebust | 28cf22d | 2017-05-06 12:19:11 -0400 | [diff] [blame] | 1085 | const uint32_t attrmask[]) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1086 | { |
| 1087 | char owner_name[IDMAP_NAMESZ]; |
| 1088 | char owner_group[IDMAP_NAMESZ]; |
| 1089 | int owner_namelen = 0; |
| 1090 | int owner_grouplen = 0; |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 1091 | __be32 *p; |
Trond Myklebust | d7067b2 | 2013-07-17 17:09:01 -0400 | [diff] [blame] | 1092 | uint32_t len = 0; |
Trond Myklebust | d7067b2 | 2013-07-17 17:09:01 -0400 | [diff] [blame] | 1093 | uint32_t bmval[3] = { 0 }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1094 | |
| 1095 | /* |
| 1096 | * We reserve enough space to write the entire attribute buffer at once. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1097 | */ |
Trond Myklebust | 28cf22d | 2017-05-06 12:19:11 -0400 | [diff] [blame] | 1098 | if ((iap->ia_valid & ATTR_SIZE) && (attrmask[0] & FATTR4_WORD0_SIZE)) { |
Trond Myklebust | d7067b2 | 2013-07-17 17:09:01 -0400 | [diff] [blame] | 1099 | bmval[0] |= FATTR4_WORD0_SIZE; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1100 | len += 8; |
Trond Myklebust | d7067b2 | 2013-07-17 17:09:01 -0400 | [diff] [blame] | 1101 | } |
| 1102 | if (iap->ia_valid & ATTR_MODE) { |
Trond Myklebust | 28cf22d | 2017-05-06 12:19:11 -0400 | [diff] [blame] | 1103 | if (umask && (attrmask[2] & FATTR4_WORD2_MODE_UMASK)) { |
Andreas Gruenbacher | dff25dd | 2016-12-02 22:53:30 -0500 | [diff] [blame] | 1104 | bmval[2] |= FATTR4_WORD2_MODE_UMASK; |
| 1105 | len += 8; |
Trond Myklebust | 28cf22d | 2017-05-06 12:19:11 -0400 | [diff] [blame] | 1106 | } else if (attrmask[1] & FATTR4_WORD1_MODE) { |
Andreas Gruenbacher | dff25dd | 2016-12-02 22:53:30 -0500 | [diff] [blame] | 1107 | bmval[1] |= FATTR4_WORD1_MODE; |
| 1108 | len += 4; |
| 1109 | } |
Trond Myklebust | d7067b2 | 2013-07-17 17:09:01 -0400 | [diff] [blame] | 1110 | } |
Trond Myklebust | 28cf22d | 2017-05-06 12:19:11 -0400 | [diff] [blame] | 1111 | if ((iap->ia_valid & ATTR_UID) && (attrmask[1] & FATTR4_WORD1_OWNER)) { |
Trond Myklebust | e4fd72a | 2011-02-22 15:44:31 -0800 | [diff] [blame] | 1112 | 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] | 1113 | if (owner_namelen < 0) { |
Chuck Lever | fe82a18 | 2007-09-11 18:01:10 -0400 | [diff] [blame] | 1114 | dprintk("nfs: couldn't resolve uid %d to string\n", |
Eric W. Biederman | e578207 | 2013-02-01 14:22:02 -0800 | [diff] [blame] | 1115 | from_kuid(&init_user_ns, iap->ia_uid)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1116 | /* XXX */ |
| 1117 | strcpy(owner_name, "nobody"); |
| 1118 | owner_namelen = sizeof("nobody") - 1; |
| 1119 | /* goto out; */ |
| 1120 | } |
Trond Myklebust | d7067b2 | 2013-07-17 17:09:01 -0400 | [diff] [blame] | 1121 | bmval[1] |= FATTR4_WORD1_OWNER; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1122 | len += 4 + (XDR_QUADLEN(owner_namelen) << 2); |
| 1123 | } |
Trond Myklebust | 28cf22d | 2017-05-06 12:19:11 -0400 | [diff] [blame] | 1124 | if ((iap->ia_valid & ATTR_GID) && |
| 1125 | (attrmask[1] & FATTR4_WORD1_OWNER_GROUP)) { |
Trond Myklebust | e4fd72a | 2011-02-22 15:44:31 -0800 | [diff] [blame] | 1126 | 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] | 1127 | if (owner_grouplen < 0) { |
Chuck Lever | fe82a18 | 2007-09-11 18:01:10 -0400 | [diff] [blame] | 1128 | dprintk("nfs: couldn't resolve gid %d to string\n", |
Eric W. Biederman | e578207 | 2013-02-01 14:22:02 -0800 | [diff] [blame] | 1129 | from_kgid(&init_user_ns, iap->ia_gid)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1130 | strcpy(owner_group, "nobody"); |
| 1131 | owner_grouplen = sizeof("nobody") - 1; |
| 1132 | /* goto out; */ |
| 1133 | } |
Trond Myklebust | d7067b2 | 2013-07-17 17:09:01 -0400 | [diff] [blame] | 1134 | bmval[1] |= FATTR4_WORD1_OWNER_GROUP; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1135 | len += 4 + (XDR_QUADLEN(owner_grouplen) << 2); |
| 1136 | } |
Trond Myklebust | 28cf22d | 2017-05-06 12:19:11 -0400 | [diff] [blame] | 1137 | if (attrmask[1] & FATTR4_WORD1_TIME_ACCESS_SET) { |
| 1138 | if (iap->ia_valid & ATTR_ATIME_SET) { |
| 1139 | bmval[1] |= FATTR4_WORD1_TIME_ACCESS_SET; |
Trond Myklebust | 36b3743 | 2018-03-20 17:03:10 -0400 | [diff] [blame] | 1140 | len += 4 + (nfstime4_maxsz << 2); |
Trond Myklebust | 28cf22d | 2017-05-06 12:19:11 -0400 | [diff] [blame] | 1141 | } else if (iap->ia_valid & ATTR_ATIME) { |
| 1142 | bmval[1] |= FATTR4_WORD1_TIME_ACCESS_SET; |
| 1143 | len += 4; |
| 1144 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1145 | } |
Trond Myklebust | 28cf22d | 2017-05-06 12:19:11 -0400 | [diff] [blame] | 1146 | if (attrmask[1] & FATTR4_WORD1_TIME_MODIFY_SET) { |
| 1147 | if (iap->ia_valid & ATTR_MTIME_SET) { |
| 1148 | bmval[1] |= FATTR4_WORD1_TIME_MODIFY_SET; |
Trond Myklebust | 36b3743 | 2018-03-20 17:03:10 -0400 | [diff] [blame] | 1149 | len += 4 + (nfstime4_maxsz << 2); |
Trond Myklebust | 28cf22d | 2017-05-06 12:19:11 -0400 | [diff] [blame] | 1150 | } else if (iap->ia_valid & ATTR_MTIME) { |
| 1151 | bmval[1] |= FATTR4_WORD1_TIME_MODIFY_SET; |
| 1152 | len += 4; |
| 1153 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1154 | } |
Kinglong Mee | 5334c5b | 2015-08-26 21:13:37 +0800 | [diff] [blame] | 1155 | |
Trond Myklebust | 28cf22d | 2017-05-06 12:19:11 -0400 | [diff] [blame] | 1156 | if (label && (attrmask[2] & FATTR4_WORD2_SECURITY_LABEL)) { |
Trond Myklebust | d7067b2 | 2013-07-17 17:09:01 -0400 | [diff] [blame] | 1157 | len += 4 + 4 + 4 + (XDR_QUADLEN(label->len) << 2); |
| 1158 | bmval[2] |= FATTR4_WORD2_SECURITY_LABEL; |
| 1159 | } |
| 1160 | |
Trond Myklebust | 40a3426c | 2018-03-20 17:03:09 -0400 | [diff] [blame] | 1161 | xdr_encode_bitmap4(xdr, bmval, ARRAY_SIZE(bmval)); |
| 1162 | xdr_stream_encode_opaque_inline(xdr, (void **)&p, len); |
Trond Myklebust | d7067b2 | 2013-07-17 17:09:01 -0400 | [diff] [blame] | 1163 | |
| 1164 | if (bmval[0] & FATTR4_WORD0_SIZE) |
| 1165 | p = xdr_encode_hyper(p, iap->ia_size); |
| 1166 | if (bmval[1] & FATTR4_WORD1_MODE) |
| 1167 | *p++ = cpu_to_be32(iap->ia_mode & S_IALLUGO); |
| 1168 | if (bmval[1] & FATTR4_WORD1_OWNER) |
| 1169 | p = xdr_encode_opaque(p, owner_name, owner_namelen); |
| 1170 | if (bmval[1] & FATTR4_WORD1_OWNER_GROUP) |
| 1171 | p = xdr_encode_opaque(p, owner_group, owner_grouplen); |
| 1172 | if (bmval[1] & FATTR4_WORD1_TIME_ACCESS_SET) { |
| 1173 | if (iap->ia_valid & ATTR_ATIME_SET) { |
| 1174 | *p++ = cpu_to_be32(NFS4_SET_TO_CLIENT_TIME); |
Trond Myklebust | e7d4b05 | 2019-10-04 16:43:09 -0400 | [diff] [blame] | 1175 | p = xdr_encode_nfstime4(p, &iap->ia_atime); |
Trond Myklebust | d7067b2 | 2013-07-17 17:09:01 -0400 | [diff] [blame] | 1176 | } else |
| 1177 | *p++ = cpu_to_be32(NFS4_SET_TO_SERVER_TIME); |
| 1178 | } |
| 1179 | if (bmval[1] & FATTR4_WORD1_TIME_MODIFY_SET) { |
| 1180 | if (iap->ia_valid & ATTR_MTIME_SET) { |
| 1181 | *p++ = cpu_to_be32(NFS4_SET_TO_CLIENT_TIME); |
Trond Myklebust | e7d4b05 | 2019-10-04 16:43:09 -0400 | [diff] [blame] | 1182 | p = xdr_encode_nfstime4(p, &iap->ia_mtime); |
Trond Myklebust | d7067b2 | 2013-07-17 17:09:01 -0400 | [diff] [blame] | 1183 | } else |
| 1184 | *p++ = cpu_to_be32(NFS4_SET_TO_SERVER_TIME); |
| 1185 | } |
Jia-Ju Bai | e275146 | 2019-07-26 15:48:53 +0800 | [diff] [blame] | 1186 | if (label && (bmval[2] & FATTR4_WORD2_SECURITY_LABEL)) { |
David Quigley | aa9c266 | 2013-05-22 12:50:44 -0400 | [diff] [blame] | 1187 | *p++ = cpu_to_be32(label->lfs); |
| 1188 | *p++ = cpu_to_be32(label->pi); |
| 1189 | *p++ = cpu_to_be32(label->len); |
| 1190 | p = xdr_encode_opaque_fixed(p, label->label, label->len); |
| 1191 | } |
Andreas Gruenbacher | dff25dd | 2016-12-02 22:53:30 -0500 | [diff] [blame] | 1192 | if (bmval[2] & FATTR4_WORD2_MODE_UMASK) { |
| 1193 | *p++ = cpu_to_be32(iap->ia_mode & S_IALLUGO); |
| 1194 | *p++ = cpu_to_be32(*umask); |
| 1195 | } |
Andy Adamson | 6c0195a | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 1196 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1197 | /* out: */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1198 | } |
| 1199 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1200 | 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] | 1201 | { |
Trond Myklebust | 475d4ba | 2012-03-05 11:27:16 -0500 | [diff] [blame] | 1202 | encode_op_hdr(xdr, OP_ACCESS, decode_access_maxsz, hdr); |
| 1203 | encode_uint32(xdr, access); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1204 | } |
| 1205 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1206 | 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] | 1207 | { |
Trond Myklebust | ab19b48 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1208 | encode_op_hdr(xdr, OP_CLOSE, decode_close_maxsz, hdr); |
Trond Myklebust | 4ade982 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1209 | encode_nfs4_seqid(xdr, arg->seqid); |
Trond Myklebust | 566fcec | 2015-01-23 15:32:46 -0500 | [diff] [blame] | 1210 | encode_nfs4_stateid(xdr, &arg->stateid); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1211 | } |
| 1212 | |
Fred Isaman | 0b7c015 | 2012-04-20 14:47:39 -0400 | [diff] [blame] | 1213 | 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] | 1214 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 1215 | __be32 *p; |
Andy Adamson | 6c0195a | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 1216 | |
Trond Myklebust | 475d4ba | 2012-03-05 11:27:16 -0500 | [diff] [blame] | 1217 | encode_op_hdr(xdr, OP_COMMIT, decode_commit_maxsz, hdr); |
| 1218 | p = reserve_space(xdr, 12); |
Benny Halevy | b95be5a | 2009-08-14 17:19:01 +0300 | [diff] [blame] | 1219 | p = xdr_encode_hyper(p, args->offset); |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1220 | *p = cpu_to_be32(args->count); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1221 | } |
| 1222 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1223 | 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] | 1224 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 1225 | __be32 *p; |
Andy Adamson | 6c0195a | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 1226 | |
Trond Myklebust | 475d4ba | 2012-03-05 11:27:16 -0500 | [diff] [blame] | 1227 | encode_op_hdr(xdr, OP_CREATE, decode_create_maxsz, hdr); |
| 1228 | encode_uint32(xdr, create->ftype); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1229 | |
| 1230 | switch (create->ftype) { |
| 1231 | case NF4LNK: |
Benny Halevy | 13c65ce | 2009-08-14 17:19:25 +0300 | [diff] [blame] | 1232 | p = reserve_space(xdr, 4); |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1233 | *p = cpu_to_be32(create->u.symlink.len); |
Chuck Lever | 2fcc213 | 2015-08-03 13:04:26 -0400 | [diff] [blame] | 1234 | xdr_write_pages(xdr, create->u.symlink.pages, 0, |
| 1235 | create->u.symlink.len); |
| 1236 | xdr->buf->flags |= XDRBUF_WRITE; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1237 | break; |
| 1238 | |
| 1239 | case NF4BLK: case NF4CHR: |
Benny Halevy | 13c65ce | 2009-08-14 17:19:25 +0300 | [diff] [blame] | 1240 | p = reserve_space(xdr, 8); |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1241 | *p++ = cpu_to_be32(create->u.device.specdata1); |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1242 | *p = cpu_to_be32(create->u.device.specdata2); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1243 | break; |
| 1244 | |
| 1245 | default: |
| 1246 | break; |
| 1247 | } |
| 1248 | |
Benny Halevy | 811652b | 2009-08-14 17:19:34 +0300 | [diff] [blame] | 1249 | encode_string(xdr, create->name->len, create->name->name); |
Trond Myklebust | 28cf22d | 2017-05-06 12:19:11 -0400 | [diff] [blame] | 1250 | encode_attrs(xdr, create->attrs, create->label, &create->umask, |
| 1251 | create->server, create->server->attr_bitmask); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1252 | } |
| 1253 | |
Trond Myklebust | 37c8876 | 2018-03-20 17:03:08 -0400 | [diff] [blame] | 1254 | static void encode_getattr(struct xdr_stream *xdr, |
| 1255 | const __u32 *bitmap, const __u32 *mask, size_t len, |
| 1256 | struct compound_hdr *hdr) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1257 | { |
Trond Myklebust | 37c8876 | 2018-03-20 17:03:08 -0400 | [diff] [blame] | 1258 | __u32 masked_bitmap[nfs4_fattr_bitmap_maxsz]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1259 | |
Trond Myklebust | 475d4ba | 2012-03-05 11:27:16 -0500 | [diff] [blame] | 1260 | encode_op_hdr(xdr, OP_GETATTR, decode_getattr_maxsz, hdr); |
Trond Myklebust | 37c8876 | 2018-03-20 17:03:08 -0400 | [diff] [blame] | 1261 | if (mask) { |
| 1262 | if (WARN_ON_ONCE(len > ARRAY_SIZE(masked_bitmap))) |
| 1263 | len = ARRAY_SIZE(masked_bitmap); |
| 1264 | len = mask_bitmap4(bitmap, mask, masked_bitmap, len); |
| 1265 | bitmap = masked_bitmap; |
Fred Isaman | dae100c | 2011-07-30 20:52:37 -0400 | [diff] [blame] | 1266 | } |
Trond Myklebust | 37c8876 | 2018-03-20 17:03:08 -0400 | [diff] [blame] | 1267 | xdr_encode_bitmap4(xdr, bitmap, len); |
Fred Isaman | dae100c | 2011-07-30 20:52:37 -0400 | [diff] [blame] | 1268 | } |
| 1269 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1270 | 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] | 1271 | { |
Trond Myklebust | 37c8876 | 2018-03-20 17:03:08 -0400 | [diff] [blame] | 1272 | encode_getattr(xdr, nfs4_fattr_bitmap, bitmask, |
| 1273 | ARRAY_SIZE(nfs4_fattr_bitmap), hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1274 | } |
| 1275 | |
Andy Adamson | 88034c3 | 2012-05-23 05:02:34 -0400 | [diff] [blame] | 1276 | static void encode_getfattr_open(struct xdr_stream *xdr, const u32 *bitmask, |
Trond Myklebust | 1549210f | 2012-06-05 09:16:47 -0400 | [diff] [blame] | 1277 | const u32 *open_bitmap, |
Andy Adamson | 88034c3 | 2012-05-23 05:02:34 -0400 | [diff] [blame] | 1278 | struct compound_hdr *hdr) |
| 1279 | { |
Trond Myklebust | 37c8876 | 2018-03-20 17:03:08 -0400 | [diff] [blame] | 1280 | encode_getattr(xdr, open_bitmap, bitmask, 3, hdr); |
Andy Adamson | 88034c3 | 2012-05-23 05:02:34 -0400 | [diff] [blame] | 1281 | } |
| 1282 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1283 | 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] | 1284 | { |
Trond Myklebust | 37c8876 | 2018-03-20 17:03:08 -0400 | [diff] [blame] | 1285 | encode_getattr(xdr, nfs4_fsinfo_bitmap, bitmask, |
| 1286 | ARRAY_SIZE(nfs4_fsinfo_bitmap), hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1287 | } |
| 1288 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1289 | 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] | 1290 | { |
Trond Myklebust | 37c8876 | 2018-03-20 17:03:08 -0400 | [diff] [blame] | 1291 | encode_getattr(xdr, nfs4_fs_locations_bitmap, bitmask, |
| 1292 | ARRAY_SIZE(nfs4_fs_locations_bitmap), hdr); |
Manoj Naik | 830b8e3 | 2006-06-09 09:34:25 -0400 | [diff] [blame] | 1293 | } |
| 1294 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1295 | static void encode_getfh(struct xdr_stream *xdr, struct compound_hdr *hdr) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1296 | { |
Trond Myklebust | ab19b48 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1297 | encode_op_hdr(xdr, OP_GETFH, decode_getfh_maxsz, hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1298 | } |
| 1299 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1300 | 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] | 1301 | { |
Trond Myklebust | ab19b48 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1302 | encode_op_hdr(xdr, OP_LINK, decode_link_maxsz, hdr); |
Trond Myklebust | 6fdfb0bc | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1303 | encode_string(xdr, name->len, name->name); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1304 | } |
| 1305 | |
Trond Myklebust | 911d1aa | 2006-01-03 09:55:16 +0100 | [diff] [blame] | 1306 | static inline int nfs4_lock_type(struct file_lock *fl, int block) |
| 1307 | { |
Jeff Layton | f44106e | 2012-07-23 15:49:56 -0400 | [diff] [blame] | 1308 | if (fl->fl_type == F_RDLCK) |
Trond Myklebust | 911d1aa | 2006-01-03 09:55:16 +0100 | [diff] [blame] | 1309 | return block ? NFS4_READW_LT : NFS4_READ_LT; |
| 1310 | return block ? NFS4_WRITEW_LT : NFS4_WRITE_LT; |
| 1311 | } |
| 1312 | |
| 1313 | static inline uint64_t nfs4_lock_length(struct file_lock *fl) |
| 1314 | { |
| 1315 | if (fl->fl_end == OFFSET_MAX) |
| 1316 | return ~(uint64_t)0; |
| 1317 | return fl->fl_end - fl->fl_start + 1; |
| 1318 | } |
| 1319 | |
Trond Myklebust | daccbde | 2010-06-25 18:11:43 -0400 | [diff] [blame] | 1320 | static void encode_lockowner(struct xdr_stream *xdr, const struct nfs_lowner *lowner) |
| 1321 | { |
| 1322 | __be32 *p; |
| 1323 | |
Trond Myklebust | d035c36 | 2010-12-21 10:45:27 -0500 | [diff] [blame] | 1324 | p = reserve_space(xdr, 32); |
Trond Myklebust | daccbde | 2010-06-25 18:11:43 -0400 | [diff] [blame] | 1325 | p = xdr_encode_hyper(p, lowner->clientid); |
Trond Myklebust | d035c36 | 2010-12-21 10:45:27 -0500 | [diff] [blame] | 1326 | *p++ = cpu_to_be32(20); |
Trond Myklebust | daccbde | 2010-06-25 18:11:43 -0400 | [diff] [blame] | 1327 | p = xdr_encode_opaque_fixed(p, "lock id:", 8); |
Trond Myklebust | d035c36 | 2010-12-21 10:45:27 -0500 | [diff] [blame] | 1328 | *p++ = cpu_to_be32(lowner->s_dev); |
Trond Myklebust | daccbde | 2010-06-25 18:11:43 -0400 | [diff] [blame] | 1329 | xdr_encode_hyper(p, lowner->id); |
| 1330 | } |
| 1331 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1332 | /* |
| 1333 | * opcode,type,reclaim,offset,length,new_lock_owner = 32 |
| 1334 | * open_seqid,open_stateid,lock_seqid,lock_owner.clientid, lock_owner.id = 40 |
| 1335 | */ |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1336 | 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] | 1337 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 1338 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1339 | |
Trond Myklebust | 475d4ba | 2012-03-05 11:27:16 -0500 | [diff] [blame] | 1340 | encode_op_hdr(xdr, OP_LOCK, decode_lock_maxsz, hdr); |
| 1341 | p = reserve_space(xdr, 28); |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1342 | *p++ = cpu_to_be32(nfs4_lock_type(args->fl, args->block)); |
| 1343 | *p++ = cpu_to_be32(args->reclaim); |
Benny Halevy | b95be5a | 2009-08-14 17:19:01 +0300 | [diff] [blame] | 1344 | p = xdr_encode_hyper(p, args->fl->fl_start); |
| 1345 | p = xdr_encode_hyper(p, nfs4_lock_length(args->fl)); |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1346 | *p = cpu_to_be32(args->new_lock_owner); |
Trond Myklebust | 911d1aa | 2006-01-03 09:55:16 +0100 | [diff] [blame] | 1347 | if (args->new_lock_owner){ |
Trond Myklebust | 4ade982 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1348 | encode_nfs4_seqid(xdr, args->open_seqid); |
Trond Myklebust | 425c1d4 | 2015-01-24 14:57:53 -0500 | [diff] [blame] | 1349 | encode_nfs4_stateid(xdr, &args->open_stateid); |
Trond Myklebust | 4ade982 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1350 | encode_nfs4_seqid(xdr, args->lock_seqid); |
Trond Myklebust | daccbde | 2010-06-25 18:11:43 -0400 | [diff] [blame] | 1351 | encode_lockowner(xdr, &args->lock_owner); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1352 | } |
| 1353 | else { |
Trond Myklebust | 425c1d4 | 2015-01-24 14:57:53 -0500 | [diff] [blame] | 1354 | encode_nfs4_stateid(xdr, &args->lock_stateid); |
Trond Myklebust | 4ade982 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1355 | encode_nfs4_seqid(xdr, args->lock_seqid); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1356 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1357 | } |
| 1358 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1359 | 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] | 1360 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 1361 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1362 | |
Trond Myklebust | 475d4ba | 2012-03-05 11:27:16 -0500 | [diff] [blame] | 1363 | encode_op_hdr(xdr, OP_LOCKT, decode_lockt_maxsz, hdr); |
| 1364 | p = reserve_space(xdr, 20); |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1365 | *p++ = cpu_to_be32(nfs4_lock_type(args->fl, 0)); |
Benny Halevy | b95be5a | 2009-08-14 17:19:01 +0300 | [diff] [blame] | 1366 | p = xdr_encode_hyper(p, args->fl->fl_start); |
| 1367 | p = xdr_encode_hyper(p, nfs4_lock_length(args->fl)); |
Trond Myklebust | daccbde | 2010-06-25 18:11:43 -0400 | [diff] [blame] | 1368 | encode_lockowner(xdr, &args->lock_owner); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1369 | } |
| 1370 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1371 | 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] | 1372 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 1373 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1374 | |
Trond Myklebust | 475d4ba | 2012-03-05 11:27:16 -0500 | [diff] [blame] | 1375 | encode_op_hdr(xdr, OP_LOCKU, decode_locku_maxsz, hdr); |
| 1376 | encode_uint32(xdr, nfs4_lock_type(args->fl, 0)); |
Trond Myklebust | 4ade982 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1377 | encode_nfs4_seqid(xdr, args->seqid); |
Trond Myklebust | 425c1d4 | 2015-01-24 14:57:53 -0500 | [diff] [blame] | 1378 | encode_nfs4_stateid(xdr, &args->stateid); |
Trond Myklebust | ea9d23f | 2012-03-04 18:13:56 -0500 | [diff] [blame] | 1379 | p = reserve_space(xdr, 16); |
Benny Halevy | b95be5a | 2009-08-14 17:19:01 +0300 | [diff] [blame] | 1380 | p = xdr_encode_hyper(p, args->fl->fl_start); |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1381 | xdr_encode_hyper(p, nfs4_lock_length(args->fl)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1382 | } |
| 1383 | |
Trond Myklebust | d3c7b7c | 2010-07-01 12:49:01 -0400 | [diff] [blame] | 1384 | static void encode_release_lockowner(struct xdr_stream *xdr, const struct nfs_lowner *lowner, struct compound_hdr *hdr) |
| 1385 | { |
Trond Myklebust | ab19b48 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1386 | encode_op_hdr(xdr, OP_RELEASE_LOCKOWNER, decode_release_lockowner_maxsz, hdr); |
Trond Myklebust | d3c7b7c | 2010-07-01 12:49:01 -0400 | [diff] [blame] | 1387 | encode_lockowner(xdr, lowner); |
Trond Myklebust | d3c7b7c | 2010-07-01 12:49:01 -0400 | [diff] [blame] | 1388 | } |
| 1389 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1390 | 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] | 1391 | { |
Trond Myklebust | ab19b48 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1392 | encode_op_hdr(xdr, OP_LOOKUP, decode_lookup_maxsz, hdr); |
Trond Myklebust | 6fdfb0bc | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1393 | encode_string(xdr, name->len, name->name); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1394 | } |
| 1395 | |
Jeff Layton | 5b5faaf | 2017-06-29 06:34:52 -0700 | [diff] [blame] | 1396 | static void encode_lookupp(struct xdr_stream *xdr, struct compound_hdr *hdr) |
| 1397 | { |
| 1398 | encode_op_hdr(xdr, OP_LOOKUPP, decode_lookupp_maxsz, hdr); |
| 1399 | } |
| 1400 | |
Trond Myklebust | 6ae3733 | 2015-01-30 14:21:14 -0500 | [diff] [blame] | 1401 | static void encode_share_access(struct xdr_stream *xdr, u32 share_access) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1402 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 1403 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1404 | |
Benny Halevy | 13c65ce | 2009-08-14 17:19:25 +0300 | [diff] [blame] | 1405 | p = reserve_space(xdr, 8); |
Trond Myklebust | 6ae3733 | 2015-01-30 14:21:14 -0500 | [diff] [blame] | 1406 | *p++ = cpu_to_be32(share_access); |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1407 | *p = cpu_to_be32(0); /* for linux, share_deny = 0 always */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1408 | } |
| 1409 | |
| 1410 | static inline void encode_openhdr(struct xdr_stream *xdr, const struct nfs_openargs *arg) |
| 1411 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 1412 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1413 | /* |
| 1414 | * opcode 4, seqid 4, share_access 4, share_deny 4, clientid 8, ownerlen 4, |
| 1415 | * owner 4 = 32 |
| 1416 | */ |
Trond Myklebust | 4ade982 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1417 | encode_nfs4_seqid(xdr, arg->seqid); |
Trond Myklebust | 6ae3733 | 2015-01-30 14:21:14 -0500 | [diff] [blame] | 1418 | encode_share_access(xdr, arg->share_access); |
Trond Myklebust | 95b72eb | 2012-04-20 19:24:51 -0400 | [diff] [blame] | 1419 | p = reserve_space(xdr, 36); |
Benny Halevy | b95be5a | 2009-08-14 17:19:01 +0300 | [diff] [blame] | 1420 | p = xdr_encode_hyper(p, arg->clientid); |
Trond Myklebust | 95b72eb | 2012-04-20 19:24:51 -0400 | [diff] [blame] | 1421 | *p++ = cpu_to_be32(24); |
Benny Halevy | 93f0cf2 | 2009-08-14 17:19:06 +0300 | [diff] [blame] | 1422 | p = xdr_encode_opaque_fixed(p, "open id:", 8); |
Trond Myklebust | d035c36 | 2010-12-21 10:45:27 -0500 | [diff] [blame] | 1423 | *p++ = cpu_to_be32(arg->server->s_dev); |
Trond Myklebust | 95b72eb | 2012-04-20 19:24:51 -0400 | [diff] [blame] | 1424 | *p++ = cpu_to_be32(arg->id.uniquifier); |
| 1425 | xdr_encode_hyper(p, arg->id.create_time); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1426 | } |
| 1427 | |
| 1428 | static inline void encode_createmode(struct xdr_stream *xdr, const struct nfs_openargs *arg) |
| 1429 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 1430 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1431 | |
Benny Halevy | 13c65ce | 2009-08-14 17:19:25 +0300 | [diff] [blame] | 1432 | p = reserve_space(xdr, 4); |
Trond Myklebust | 549b19c | 2013-04-16 18:42:34 -0400 | [diff] [blame] | 1433 | switch(arg->createmode) { |
| 1434 | case NFS4_CREATE_UNCHECKED: |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1435 | *p = cpu_to_be32(NFS4_CREATE_UNCHECKED); |
Trond Myklebust | 28cf22d | 2017-05-06 12:19:11 -0400 | [diff] [blame] | 1436 | encode_attrs(xdr, arg->u.attrs, arg->label, &arg->umask, |
| 1437 | arg->server, arg->server->attr_bitmask); |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 1438 | break; |
Trond Myklebust | 549b19c | 2013-04-16 18:42:34 -0400 | [diff] [blame] | 1439 | case NFS4_CREATE_GUARDED: |
| 1440 | *p = cpu_to_be32(NFS4_CREATE_GUARDED); |
Trond Myklebust | 28cf22d | 2017-05-06 12:19:11 -0400 | [diff] [blame] | 1441 | encode_attrs(xdr, arg->u.attrs, arg->label, &arg->umask, |
| 1442 | arg->server, arg->server->attr_bitmask); |
Trond Myklebust | 549b19c | 2013-04-16 18:42:34 -0400 | [diff] [blame] | 1443 | break; |
| 1444 | case NFS4_CREATE_EXCLUSIVE: |
| 1445 | *p = cpu_to_be32(NFS4_CREATE_EXCLUSIVE); |
| 1446 | encode_nfs4_verifier(xdr, &arg->u.verifier); |
| 1447 | break; |
| 1448 | case NFS4_CREATE_EXCLUSIVE4_1: |
| 1449 | *p = cpu_to_be32(NFS4_CREATE_EXCLUSIVE4_1); |
| 1450 | encode_nfs4_verifier(xdr, &arg->u.verifier); |
Trond Myklebust | 28cf22d | 2017-05-06 12:19:11 -0400 | [diff] [blame] | 1451 | encode_attrs(xdr, arg->u.attrs, arg->label, &arg->umask, |
| 1452 | arg->server, arg->server->exclcreat_bitmask); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1453 | } |
| 1454 | } |
| 1455 | |
| 1456 | static void encode_opentype(struct xdr_stream *xdr, const struct nfs_openargs *arg) |
| 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); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1461 | switch (arg->open_flags & O_CREAT) { |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 1462 | case 0: |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1463 | *p = cpu_to_be32(NFS4_OPEN_NOCREATE); |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 1464 | break; |
| 1465 | default: |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1466 | *p = cpu_to_be32(NFS4_OPEN_CREATE); |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 1467 | encode_createmode(xdr, arg); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1468 | } |
| 1469 | } |
| 1470 | |
Trond Myklebust | bd7bf9d | 2008-12-23 15:21:53 -0500 | [diff] [blame] | 1471 | 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] | 1472 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 1473 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1474 | |
Benny Halevy | 13c65ce | 2009-08-14 17:19:25 +0300 | [diff] [blame] | 1475 | p = reserve_space(xdr, 4); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1476 | switch (delegation_type) { |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 1477 | case 0: |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1478 | *p = cpu_to_be32(NFS4_OPEN_DELEGATE_NONE); |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 1479 | break; |
| 1480 | case FMODE_READ: |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1481 | *p = cpu_to_be32(NFS4_OPEN_DELEGATE_READ); |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 1482 | break; |
| 1483 | case FMODE_WRITE|FMODE_READ: |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1484 | *p = cpu_to_be32(NFS4_OPEN_DELEGATE_WRITE); |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 1485 | break; |
| 1486 | default: |
| 1487 | BUG(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1488 | } |
| 1489 | } |
| 1490 | |
| 1491 | static inline void encode_claim_null(struct xdr_stream *xdr, const struct qstr *name) |
| 1492 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 1493 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1494 | |
Benny Halevy | 13c65ce | 2009-08-14 17:19:25 +0300 | [diff] [blame] | 1495 | p = reserve_space(xdr, 4); |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1496 | *p = cpu_to_be32(NFS4_OPEN_CLAIM_NULL); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1497 | encode_string(xdr, name->len, name->name); |
| 1498 | } |
| 1499 | |
Trond Myklebust | bd7bf9d | 2008-12-23 15:21:53 -0500 | [diff] [blame] | 1500 | 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] | 1501 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 1502 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1503 | |
Benny Halevy | 13c65ce | 2009-08-14 17:19:25 +0300 | [diff] [blame] | 1504 | p = reserve_space(xdr, 4); |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1505 | *p = cpu_to_be32(NFS4_OPEN_CLAIM_PREVIOUS); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1506 | encode_delegation_type(xdr, type); |
| 1507 | } |
| 1508 | |
| 1509 | static inline void encode_claim_delegate_cur(struct xdr_stream *xdr, const struct qstr *name, const nfs4_stateid *stateid) |
| 1510 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 1511 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1512 | |
Trond Myklebust | ea9d23f | 2012-03-04 18:13:56 -0500 | [diff] [blame] | 1513 | p = reserve_space(xdr, 4); |
| 1514 | *p = cpu_to_be32(NFS4_OPEN_CLAIM_DELEGATE_CUR); |
| 1515 | encode_nfs4_stateid(xdr, stateid); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1516 | encode_string(xdr, name->len, name->name); |
| 1517 | } |
| 1518 | |
Trond Myklebust | d9fc661 | 2013-03-15 15:39:06 -0400 | [diff] [blame] | 1519 | static inline void encode_claim_fh(struct xdr_stream *xdr) |
| 1520 | { |
| 1521 | __be32 *p; |
| 1522 | |
| 1523 | p = reserve_space(xdr, 4); |
| 1524 | *p = cpu_to_be32(NFS4_OPEN_CLAIM_FH); |
| 1525 | } |
| 1526 | |
| 1527 | static inline void encode_claim_delegate_cur_fh(struct xdr_stream *xdr, const nfs4_stateid *stateid) |
| 1528 | { |
| 1529 | __be32 *p; |
| 1530 | |
| 1531 | p = reserve_space(xdr, 4); |
| 1532 | *p = cpu_to_be32(NFS4_OPEN_CLAIM_DELEG_CUR_FH); |
| 1533 | encode_nfs4_stateid(xdr, stateid); |
| 1534 | } |
| 1535 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1536 | 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] | 1537 | { |
Trond Myklebust | ab19b48 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1538 | encode_op_hdr(xdr, OP_OPEN, decode_open_maxsz, hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1539 | encode_openhdr(xdr, arg); |
| 1540 | encode_opentype(xdr, arg); |
| 1541 | switch (arg->claim) { |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 1542 | case NFS4_OPEN_CLAIM_NULL: |
| 1543 | encode_claim_null(xdr, arg->name); |
| 1544 | break; |
| 1545 | case NFS4_OPEN_CLAIM_PREVIOUS: |
| 1546 | encode_claim_previous(xdr, arg->u.delegation_type); |
| 1547 | break; |
| 1548 | case NFS4_OPEN_CLAIM_DELEGATE_CUR: |
| 1549 | encode_claim_delegate_cur(xdr, arg->name, &arg->u.delegation); |
| 1550 | break; |
Trond Myklebust | d9fc661 | 2013-03-15 15:39:06 -0400 | [diff] [blame] | 1551 | case NFS4_OPEN_CLAIM_FH: |
| 1552 | encode_claim_fh(xdr); |
| 1553 | break; |
| 1554 | case NFS4_OPEN_CLAIM_DELEG_CUR_FH: |
| 1555 | encode_claim_delegate_cur_fh(xdr, &arg->u.delegation); |
| 1556 | break; |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 1557 | default: |
| 1558 | BUG(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1559 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1560 | } |
| 1561 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1562 | 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] | 1563 | { |
Trond Myklebust | ab19b48 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1564 | encode_op_hdr(xdr, OP_OPEN_CONFIRM, decode_open_confirm_maxsz, hdr); |
Trond Myklebust | ea9d23f | 2012-03-04 18:13:56 -0500 | [diff] [blame] | 1565 | encode_nfs4_stateid(xdr, arg->stateid); |
Trond Myklebust | 4ade982 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1566 | encode_nfs4_seqid(xdr, arg->seqid); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1567 | } |
| 1568 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1569 | 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] | 1570 | { |
Trond Myklebust | ab19b48 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1571 | encode_op_hdr(xdr, OP_OPEN_DOWNGRADE, decode_open_downgrade_maxsz, hdr); |
Trond Myklebust | 566fcec | 2015-01-23 15:32:46 -0500 | [diff] [blame] | 1572 | encode_nfs4_stateid(xdr, &arg->stateid); |
Trond Myklebust | 4ade982 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1573 | encode_nfs4_seqid(xdr, arg->seqid); |
Trond Myklebust | 6ae3733 | 2015-01-30 14:21:14 -0500 | [diff] [blame] | 1574 | encode_share_access(xdr, arg->share_access); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1575 | } |
| 1576 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1577 | static void |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 1578 | 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] | 1579 | { |
Trond Myklebust | ab19b48 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1580 | encode_op_hdr(xdr, OP_PUTFH, decode_putfh_maxsz, hdr); |
Trond Myklebust | 6fdfb0bc | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1581 | encode_string(xdr, fh->size, fh->data); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1582 | } |
| 1583 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1584 | static void encode_putrootfh(struct xdr_stream *xdr, struct compound_hdr *hdr) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1585 | { |
Trond Myklebust | ab19b48 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1586 | encode_op_hdr(xdr, OP_PUTROOTFH, decode_putrootfh_maxsz, hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1587 | } |
| 1588 | |
Anna Schumaker | 3c6b899 | 2014-05-06 09:12:24 -0400 | [diff] [blame] | 1589 | static void encode_read(struct xdr_stream *xdr, const struct nfs_pgio_args *args, |
| 1590 | struct compound_hdr *hdr) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1591 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 1592 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1593 | |
Trond Myklebust | ab19b48 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1594 | encode_op_hdr(xdr, OP_READ, decode_read_maxsz, hdr); |
Trond Myklebust | 9b20614 | 2013-03-17 15:52:00 -0400 | [diff] [blame] | 1595 | encode_nfs4_stateid(xdr, &args->stateid); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1596 | |
Benny Halevy | 13c65ce | 2009-08-14 17:19:25 +0300 | [diff] [blame] | 1597 | p = reserve_space(xdr, 12); |
Benny Halevy | b95be5a | 2009-08-14 17:19:01 +0300 | [diff] [blame] | 1598 | p = xdr_encode_hyper(p, args->offset); |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1599 | *p = cpu_to_be32(args->count); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1600 | } |
| 1601 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1602 | 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] | 1603 | { |
David Quigley | aa9c266 | 2013-05-22 12:50:44 -0400 | [diff] [blame] | 1604 | uint32_t attrs[3] = { |
Trond Myklebust | 28331a4 | 2011-04-27 13:47:52 -0400 | [diff] [blame] | 1605 | FATTR4_WORD0_RDATTR_ERROR, |
| 1606 | FATTR4_WORD1_MOUNTED_ON_FILEID, |
| 1607 | }; |
Trond Myklebust | 6f7a35b | 2010-10-24 12:11:42 -0400 | [diff] [blame] | 1608 | uint32_t dircount = readdir->count >> 1; |
Chuck Lever | cd93710 | 2012-03-02 17:14:31 -0500 | [diff] [blame] | 1609 | __be32 *p, verf[2]; |
Trond Myklebust | d204c5d | 2013-11-04 13:23:59 -0500 | [diff] [blame] | 1610 | uint32_t attrlen = 0; |
| 1611 | unsigned int i; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1612 | |
Bryan Schumaker | 82f2e54 | 2010-10-21 16:33:18 -0400 | [diff] [blame] | 1613 | if (readdir->plus) { |
| 1614 | attrs[0] |= FATTR4_WORD0_TYPE|FATTR4_WORD0_CHANGE|FATTR4_WORD0_SIZE| |
Trond Myklebust | 28331a4 | 2011-04-27 13:47:52 -0400 | [diff] [blame] | 1615 | FATTR4_WORD0_FSID|FATTR4_WORD0_FILEHANDLE|FATTR4_WORD0_FILEID; |
Bryan Schumaker | 82f2e54 | 2010-10-21 16:33:18 -0400 | [diff] [blame] | 1616 | attrs[1] |= FATTR4_WORD1_MODE|FATTR4_WORD1_NUMLINKS|FATTR4_WORD1_OWNER| |
| 1617 | FATTR4_WORD1_OWNER_GROUP|FATTR4_WORD1_RAWDEV| |
| 1618 | FATTR4_WORD1_SPACE_USED|FATTR4_WORD1_TIME_ACCESS| |
| 1619 | FATTR4_WORD1_TIME_METADATA|FATTR4_WORD1_TIME_MODIFY; |
Trond Myklebust | d204c5d | 2013-11-04 13:23:59 -0500 | [diff] [blame] | 1620 | attrs[2] |= FATTR4_WORD2_SECURITY_LABEL; |
Trond Myklebust | 6f7a35b | 2010-10-24 12:11:42 -0400 | [diff] [blame] | 1621 | dircount >>= 1; |
Bryan Schumaker | 82f2e54 | 2010-10-21 16:33:18 -0400 | [diff] [blame] | 1622 | } |
Trond Myklebust | 28331a4 | 2011-04-27 13:47:52 -0400 | [diff] [blame] | 1623 | /* Use mounted_on_fileid only if the server supports it */ |
| 1624 | if (!(readdir->bitmask[1] & FATTR4_WORD1_MOUNTED_ON_FILEID)) |
| 1625 | attrs[0] |= FATTR4_WORD0_FILEID; |
Trond Myklebust | d204c5d | 2013-11-04 13:23:59 -0500 | [diff] [blame] | 1626 | for (i = 0; i < ARRAY_SIZE(attrs); i++) { |
| 1627 | attrs[i] &= readdir->bitmask[i]; |
| 1628 | if (attrs[i] != 0) |
| 1629 | attrlen = i+1; |
| 1630 | } |
Bryan Schumaker | 82f2e54 | 2010-10-21 16:33:18 -0400 | [diff] [blame] | 1631 | |
Trond Myklebust | 475d4ba | 2012-03-05 11:27:16 -0500 | [diff] [blame] | 1632 | encode_op_hdr(xdr, OP_READDIR, decode_readdir_maxsz, hdr); |
Trond Myklebust | ff2eb68 | 2012-03-05 11:40:12 -0500 | [diff] [blame] | 1633 | encode_uint64(xdr, readdir->cookie); |
Chuck Lever | cd93710 | 2012-03-02 17:14:31 -0500 | [diff] [blame] | 1634 | encode_nfs4_verifier(xdr, &readdir->verifier); |
Trond Myklebust | d204c5d | 2013-11-04 13:23:59 -0500 | [diff] [blame] | 1635 | p = reserve_space(xdr, 12 + (attrlen << 2)); |
Trond Myklebust | 6f7a35b | 2010-10-24 12:11:42 -0400 | [diff] [blame] | 1636 | *p++ = cpu_to_be32(dircount); |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1637 | *p++ = cpu_to_be32(readdir->count); |
Trond Myklebust | d204c5d | 2013-11-04 13:23:59 -0500 | [diff] [blame] | 1638 | *p++ = cpu_to_be32(attrlen); |
| 1639 | for (i = 0; i < attrlen; i++) |
| 1640 | *p++ = cpu_to_be32(attrs[i]); |
Chuck Lever | cd93710 | 2012-03-02 17:14:31 -0500 | [diff] [blame] | 1641 | memcpy(verf, readdir->verifier.data, sizeof(verf)); |
David Quigley | aa9c266 | 2013-05-22 12:50:44 -0400 | [diff] [blame] | 1642 | |
| 1643 | dprintk("%s: cookie = %llu, verifier = %08x:%08x, bitmap = %08x:%08x:%08x\n", |
Fred Isaman | 4410924 | 2008-04-02 15:21:15 +0300 | [diff] [blame] | 1644 | __func__, |
Trond Myklebust | eadf459 | 2005-06-22 17:16:39 +0000 | [diff] [blame] | 1645 | (unsigned long long)readdir->cookie, |
Chuck Lever | cd93710 | 2012-03-02 17:14:31 -0500 | [diff] [blame] | 1646 | verf[0], verf[1], |
Trond Myklebust | eadf459 | 2005-06-22 17:16:39 +0000 | [diff] [blame] | 1647 | attrs[0] & readdir->bitmask[0], |
David Quigley | aa9c266 | 2013-05-22 12:50:44 -0400 | [diff] [blame] | 1648 | attrs[1] & readdir->bitmask[1], |
| 1649 | attrs[2] & readdir->bitmask[2]); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1650 | } |
| 1651 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1652 | 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] | 1653 | { |
Trond Myklebust | ab19b48 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1654 | encode_op_hdr(xdr, OP_READLINK, decode_readlink_maxsz, hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1655 | } |
| 1656 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1657 | 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] | 1658 | { |
Trond Myklebust | ab19b48 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1659 | encode_op_hdr(xdr, OP_REMOVE, decode_remove_maxsz, hdr); |
Trond Myklebust | 6fdfb0bc | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1660 | encode_string(xdr, name->len, name->name); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1661 | } |
| 1662 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1663 | 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] | 1664 | { |
Trond Myklebust | ab19b48 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1665 | encode_op_hdr(xdr, OP_RENAME, decode_rename_maxsz, hdr); |
Benny Halevy | 811652b | 2009-08-14 17:19:34 +0300 | [diff] [blame] | 1666 | encode_string(xdr, oldname->len, oldname->name); |
| 1667 | encode_string(xdr, newname->len, newname->name); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1668 | } |
| 1669 | |
Chuck Lever | bb4dae5 | 2012-03-01 17:01:48 -0500 | [diff] [blame] | 1670 | static void encode_renew(struct xdr_stream *xdr, clientid4 clid, |
| 1671 | struct compound_hdr *hdr) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1672 | { |
Trond Myklebust | 475d4ba | 2012-03-05 11:27:16 -0500 | [diff] [blame] | 1673 | encode_op_hdr(xdr, OP_RENEW, decode_renew_maxsz, hdr); |
Trond Myklebust | ff2eb68 | 2012-03-05 11:40:12 -0500 | [diff] [blame] | 1674 | encode_uint64(xdr, clid); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1675 | } |
| 1676 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1677 | static void |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 1678 | encode_restorefh(struct xdr_stream *xdr, struct compound_hdr *hdr) |
Trond Myklebust | 56ae19f | 2005-10-27 22:12:40 -0400 | [diff] [blame] | 1679 | { |
Trond Myklebust | ab19b48 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1680 | encode_op_hdr(xdr, OP_RESTOREFH, decode_restorefh_maxsz, hdr); |
Trond Myklebust | 56ae19f | 2005-10-27 22:12:40 -0400 | [diff] [blame] | 1681 | } |
| 1682 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 1683 | static void |
Christoph Hellwig | fcc8581 | 2017-05-08 10:01:49 +0200 | [diff] [blame] | 1684 | encode_setacl(struct xdr_stream *xdr, const struct nfs_setaclargs *arg, |
| 1685 | struct compound_hdr *hdr) |
J. Bruce Fields | 23ec696 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 1686 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 1687 | __be32 *p; |
J. Bruce Fields | 23ec696 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 1688 | |
Trond Myklebust | ab19b48 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1689 | encode_op_hdr(xdr, OP_SETATTR, decode_setacl_maxsz, hdr); |
Trond Myklebust | ea9d23f | 2012-03-04 18:13:56 -0500 | [diff] [blame] | 1690 | encode_nfs4_stateid(xdr, &zero_stateid); |
Benny Halevy | 13c65ce | 2009-08-14 17:19:25 +0300 | [diff] [blame] | 1691 | p = reserve_space(xdr, 2*4); |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1692 | *p++ = cpu_to_be32(1); |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1693 | *p = cpu_to_be32(FATTR4_WORD0_ACL); |
Benny Halevy | 13c65ce | 2009-08-14 17:19:25 +0300 | [diff] [blame] | 1694 | p = reserve_space(xdr, 4); |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1695 | *p = cpu_to_be32(arg->acl_len); |
Andreas Gruenbacher | 8fbcf23 | 2015-11-03 18:25:34 +0100 | [diff] [blame] | 1696 | xdr_write_pages(xdr, arg->acl_pages, 0, arg->acl_len); |
J. Bruce Fields | 23ec696 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 1697 | } |
| 1698 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1699 | static void |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 1700 | encode_savefh(struct xdr_stream *xdr, struct compound_hdr *hdr) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1701 | { |
Trond Myklebust | ab19b48 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1702 | encode_op_hdr(xdr, OP_SAVEFH, decode_savefh_maxsz, hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1703 | } |
| 1704 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1705 | 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] | 1706 | { |
Trond Myklebust | ab19b48 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1707 | encode_op_hdr(xdr, OP_SETATTR, decode_setattr_maxsz, hdr); |
Trond Myklebust | ea9d23f | 2012-03-04 18:13:56 -0500 | [diff] [blame] | 1708 | encode_nfs4_stateid(xdr, &arg->stateid); |
Trond Myklebust | 28cf22d | 2017-05-06 12:19:11 -0400 | [diff] [blame] | 1709 | encode_attrs(xdr, arg->iap, arg->label, NULL, server, |
| 1710 | server->attr_bitmask); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1711 | } |
| 1712 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1713 | 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] | 1714 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 1715 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1716 | |
Trond Myklebust | 7001951 | 2012-03-04 20:49:32 -0500 | [diff] [blame] | 1717 | encode_op_hdr(xdr, OP_SETCLIENTID, decode_setclientid_maxsz, hdr); |
Chuck Lever | cd93710 | 2012-03-02 17:14:31 -0500 | [diff] [blame] | 1718 | encode_nfs4_verifier(xdr, setclientid->sc_verifier); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1719 | |
Jeff Layton | 3a6bb73 | 2015-06-09 19:43:57 -0400 | [diff] [blame] | 1720 | encode_string(xdr, strlen(setclientid->sc_clnt->cl_owner_id), |
| 1721 | setclientid->sc_clnt->cl_owner_id); |
Benny Halevy | 13c65ce | 2009-08-14 17:19:25 +0300 | [diff] [blame] | 1722 | p = reserve_space(xdr, 4); |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1723 | *p = cpu_to_be32(setclientid->sc_prog); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1724 | encode_string(xdr, setclientid->sc_netid_len, setclientid->sc_netid); |
| 1725 | encode_string(xdr, setclientid->sc_uaddr_len, setclientid->sc_uaddr); |
Benny Halevy | 13c65ce | 2009-08-14 17:19:25 +0300 | [diff] [blame] | 1726 | p = reserve_space(xdr, 4); |
Jeff Layton | 3a6bb73 | 2015-06-09 19:43:57 -0400 | [diff] [blame] | 1727 | *p = cpu_to_be32(setclientid->sc_clnt->cl_cb_ident); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1728 | } |
| 1729 | |
Trond Myklebust | bb8b27e | 2010-04-16 16:43:06 -0400 | [diff] [blame] | 1730 | 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] | 1731 | { |
Trond Myklebust | 475d4ba | 2012-03-05 11:27:16 -0500 | [diff] [blame] | 1732 | encode_op_hdr(xdr, OP_SETCLIENTID_CONFIRM, |
| 1733 | decode_setclientid_confirm_maxsz, hdr); |
Trond Myklebust | ff2eb68 | 2012-03-05 11:40:12 -0500 | [diff] [blame] | 1734 | encode_uint64(xdr, arg->clientid); |
Chuck Lever | cd93710 | 2012-03-02 17:14:31 -0500 | [diff] [blame] | 1735 | encode_nfs4_verifier(xdr, &arg->confirm); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1736 | } |
| 1737 | |
Anna Schumaker | 3c6b899 | 2014-05-06 09:12:24 -0400 | [diff] [blame] | 1738 | static void encode_write(struct xdr_stream *xdr, const struct nfs_pgio_args *args, |
| 1739 | struct compound_hdr *hdr) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1740 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 1741 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1742 | |
Trond Myklebust | ab19b48 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1743 | encode_op_hdr(xdr, OP_WRITE, decode_write_maxsz, hdr); |
Trond Myklebust | 9b20614 | 2013-03-17 15:52:00 -0400 | [diff] [blame] | 1744 | encode_nfs4_stateid(xdr, &args->stateid); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1745 | |
Benny Halevy | 13c65ce | 2009-08-14 17:19:25 +0300 | [diff] [blame] | 1746 | p = reserve_space(xdr, 16); |
Benny Halevy | b95be5a | 2009-08-14 17:19:01 +0300 | [diff] [blame] | 1747 | p = xdr_encode_hyper(p, args->offset); |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1748 | *p++ = cpu_to_be32(args->stable); |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1749 | *p = cpu_to_be32(args->count); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1750 | |
| 1751 | xdr_write_pages(xdr, args->pages, args->pgbase, args->count); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1752 | } |
| 1753 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1754 | 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] | 1755 | { |
Trond Myklebust | ab19b48 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1756 | encode_op_hdr(xdr, OP_DELEGRETURN, decode_delegreturn_maxsz, hdr); |
Trond Myklebust | ea9d23f | 2012-03-04 18:13:56 -0500 | [diff] [blame] | 1757 | encode_nfs4_stateid(xdr, stateid); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1758 | } |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 1759 | |
Bryan Schumaker | 5a5ea0d | 2011-03-24 17:12:29 +0000 | [diff] [blame] | 1760 | static void encode_secinfo(struct xdr_stream *xdr, const struct qstr *name, struct compound_hdr *hdr) |
| 1761 | { |
Trond Myklebust | ab19b48 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1762 | encode_op_hdr(xdr, OP_SECINFO, decode_secinfo_maxsz, hdr); |
Trond Myklebust | 6fdfb0bc | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1763 | encode_string(xdr, name->len, name->name); |
Bryan Schumaker | 5a5ea0d | 2011-03-24 17:12:29 +0000 | [diff] [blame] | 1764 | } |
| 1765 | |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 1766 | #if defined(CONFIG_NFS_V4_1) |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 1767 | /* NFSv4.1 operations */ |
Weston Andros Adamson | 7c44f1ae | 2012-05-24 13:22:50 -0400 | [diff] [blame] | 1768 | static void encode_bind_conn_to_session(struct xdr_stream *xdr, |
Christoph Hellwig | fcc8581 | 2017-05-08 10:01:49 +0200 | [diff] [blame] | 1769 | const struct nfs41_bind_conn_to_session_args *args, |
Weston Andros Adamson | 7c44f1ae | 2012-05-24 13:22:50 -0400 | [diff] [blame] | 1770 | struct compound_hdr *hdr) |
| 1771 | { |
| 1772 | __be32 *p; |
| 1773 | |
| 1774 | encode_op_hdr(xdr, OP_BIND_CONN_TO_SESSION, |
| 1775 | decode_bind_conn_to_session_maxsz, hdr); |
Trond Myklebust | 71a097c | 2015-02-18 09:27:18 -0800 | [diff] [blame] | 1776 | encode_opaque_fixed(xdr, args->sessionid.data, NFS4_MAX_SESSIONID_LEN); |
Weston Andros Adamson | 7c44f1ae | 2012-05-24 13:22:50 -0400 | [diff] [blame] | 1777 | p = xdr_reserve_space(xdr, 8); |
Trond Myklebust | 71a097c | 2015-02-18 09:27:18 -0800 | [diff] [blame] | 1778 | *p++ = cpu_to_be32(args->dir); |
| 1779 | *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] | 1780 | } |
| 1781 | |
Christoph Hellwig | fcc8581 | 2017-05-08 10:01:49 +0200 | [diff] [blame] | 1782 | static void encode_op_map(struct xdr_stream *xdr, const struct nfs4_op_map *op_map) |
Weston Andros Adamson | 2031cd1 | 2013-08-13 16:37:32 -0400 | [diff] [blame] | 1783 | { |
| 1784 | unsigned int i; |
| 1785 | encode_uint32(xdr, NFS4_OP_MAP_NUM_WORDS); |
| 1786 | for (i = 0; i < NFS4_OP_MAP_NUM_WORDS; i++) |
| 1787 | encode_uint32(xdr, op_map->u.words[i]); |
| 1788 | } |
| 1789 | |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 1790 | static void encode_exchange_id(struct xdr_stream *xdr, |
Christoph Hellwig | fcc8581 | 2017-05-08 10:01:49 +0200 | [diff] [blame] | 1791 | const struct nfs41_exchange_id_args *args, |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 1792 | struct compound_hdr *hdr) |
| 1793 | { |
| 1794 | __be32 *p; |
Jim Rees | d751f74 | 2012-11-16 18:12:06 -0500 | [diff] [blame] | 1795 | char impl_name[IMPL_NAME_LIMIT]; |
Weston Andros Adamson | db8ac8b | 2012-02-17 15:20:24 -0500 | [diff] [blame] | 1796 | int len = 0; |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 1797 | |
Trond Myklebust | 7001951 | 2012-03-04 20:49:32 -0500 | [diff] [blame] | 1798 | encode_op_hdr(xdr, OP_EXCHANGE_ID, decode_exchange_id_maxsz, hdr); |
Trond Myklebust | fd40559 | 2017-08-01 16:02:47 -0400 | [diff] [blame] | 1799 | encode_nfs4_verifier(xdr, &args->verifier); |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 1800 | |
Jeff Layton | 3a6bb73 | 2015-06-09 19:43:57 -0400 | [diff] [blame] | 1801 | encode_string(xdr, strlen(args->client->cl_owner_id), |
| 1802 | args->client->cl_owner_id); |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 1803 | |
Weston Andros Adamson | 2031cd1 | 2013-08-13 16:37:32 -0400 | [diff] [blame] | 1804 | encode_uint32(xdr, args->flags); |
| 1805 | encode_uint32(xdr, args->state_protect.how); |
| 1806 | |
| 1807 | switch (args->state_protect.how) { |
| 1808 | case SP4_NONE: |
| 1809 | break; |
| 1810 | case SP4_MACH_CRED: |
| 1811 | encode_op_map(xdr, &args->state_protect.enforce); |
| 1812 | encode_op_map(xdr, &args->state_protect.allow); |
| 1813 | break; |
| 1814 | default: |
| 1815 | WARN_ON_ONCE(1); |
| 1816 | break; |
| 1817 | } |
Weston Andros Adamson | db8ac8b | 2012-02-17 15:20:24 -0500 | [diff] [blame] | 1818 | |
| 1819 | if (send_implementation_id && |
| 1820 | sizeof(CONFIG_NFS_V4_1_IMPLEMENTATION_ID_DOMAIN) > 1 && |
| 1821 | sizeof(CONFIG_NFS_V4_1_IMPLEMENTATION_ID_DOMAIN) |
Jim Rees | d751f74 | 2012-11-16 18:12:06 -0500 | [diff] [blame] | 1822 | <= sizeof(impl_name) + 1) |
Weston Andros Adamson | db8ac8b | 2012-02-17 15:20:24 -0500 | [diff] [blame] | 1823 | len = snprintf(impl_name, sizeof(impl_name), "%s %s %s %s", |
| 1824 | utsname()->sysname, utsname()->release, |
| 1825 | utsname()->version, utsname()->machine); |
| 1826 | |
| 1827 | if (len > 0) { |
Weston Andros Adamson | 2031cd1 | 2013-08-13 16:37:32 -0400 | [diff] [blame] | 1828 | encode_uint32(xdr, 1); /* implementation id array length=1 */ |
Weston Andros Adamson | db8ac8b | 2012-02-17 15:20:24 -0500 | [diff] [blame] | 1829 | |
| 1830 | encode_string(xdr, |
| 1831 | sizeof(CONFIG_NFS_V4_1_IMPLEMENTATION_ID_DOMAIN) - 1, |
| 1832 | CONFIG_NFS_V4_1_IMPLEMENTATION_ID_DOMAIN); |
| 1833 | encode_string(xdr, len, impl_name); |
| 1834 | /* just send zeros for nii_date - the date is in nii_name */ |
| 1835 | p = reserve_space(xdr, 12); |
| 1836 | p = xdr_encode_hyper(p, 0); |
| 1837 | *p = cpu_to_be32(0); |
| 1838 | } else |
Weston Andros Adamson | 2031cd1 | 2013-08-13 16:37:32 -0400 | [diff] [blame] | 1839 | encode_uint32(xdr, 0); /* implementation id array length=0 */ |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 1840 | } |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 1841 | |
| 1842 | static void encode_create_session(struct xdr_stream *xdr, |
Christoph Hellwig | fcc8581 | 2017-05-08 10:01:49 +0200 | [diff] [blame] | 1843 | const struct nfs41_create_session_args *args, |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 1844 | struct compound_hdr *hdr) |
| 1845 | { |
| 1846 | __be32 *p; |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 1847 | struct nfs_client *clp = args->client; |
Trond Myklebust | 89f0ff3 | 2015-01-03 14:47:43 -0500 | [diff] [blame] | 1848 | struct rpc_clnt *clnt = clp->cl_rpcclient; |
Chuck Lever | f092075 | 2012-05-21 22:45:41 -0400 | [diff] [blame] | 1849 | struct nfs_net *nn = net_generic(clp->cl_net, nfs_net_id); |
Mike Sager | 8e0d46e | 2009-12-17 12:06:26 -0500 | [diff] [blame] | 1850 | u32 max_resp_sz_cached; |
| 1851 | |
| 1852 | /* |
| 1853 | * Assumes OPEN is the biggest non-idempotent compound. |
| 1854 | * 2 is the verifier. |
| 1855 | */ |
J. Bruce Fields | 35c036e | 2017-09-20 12:42:13 -0400 | [diff] [blame] | 1856 | max_resp_sz_cached = (NFS4_dec_open_sz + RPC_REPHDRSIZE + 2) |
| 1857 | * XDR_UNIT + RPC_MAX_AUTH_SIZE; |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 1858 | |
Trond Myklebust | 475d4ba | 2012-03-05 11:27:16 -0500 | [diff] [blame] | 1859 | encode_op_hdr(xdr, OP_CREATE_SESSION, decode_create_session_maxsz, hdr); |
Trond Myklebust | 89f0ff3 | 2015-01-03 14:47:43 -0500 | [diff] [blame] | 1860 | p = reserve_space(xdr, 16 + 2*28 + 20 + clnt->cl_nodelen + 12); |
Trond Myklebust | 79969dd | 2015-02-18 11:30:18 -0800 | [diff] [blame] | 1861 | p = xdr_encode_hyper(p, args->clientid); |
| 1862 | *p++ = cpu_to_be32(args->seqid); /*Sequence id */ |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1863 | *p++ = cpu_to_be32(args->flags); /*flags */ |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 1864 | |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 1865 | /* Fore Channel */ |
Benny Halevy | c9c30dd | 2011-06-11 17:08:39 -0400 | [diff] [blame] | 1866 | *p++ = cpu_to_be32(0); /* header padding size */ |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1867 | *p++ = cpu_to_be32(args->fc_attrs.max_rqst_sz); /* max req size */ |
| 1868 | *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] | 1869 | *p++ = cpu_to_be32(max_resp_sz_cached); /* Max resp sz cached */ |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1870 | *p++ = cpu_to_be32(args->fc_attrs.max_ops); /* max operations */ |
| 1871 | *p++ = cpu_to_be32(args->fc_attrs.max_reqs); /* max requests */ |
| 1872 | *p++ = cpu_to_be32(0); /* rdmachannel_attrs */ |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 1873 | |
| 1874 | /* Back Channel */ |
Benny Halevy | c9c30dd | 2011-06-11 17:08:39 -0400 | [diff] [blame] | 1875 | *p++ = cpu_to_be32(0); /* header padding size */ |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1876 | *p++ = cpu_to_be32(args->bc_attrs.max_rqst_sz); /* max req size */ |
| 1877 | *p++ = cpu_to_be32(args->bc_attrs.max_resp_sz); /* max resp size */ |
| 1878 | *p++ = cpu_to_be32(args->bc_attrs.max_resp_sz_cached); /* Max resp sz cached */ |
| 1879 | *p++ = cpu_to_be32(args->bc_attrs.max_ops); /* max operations */ |
| 1880 | *p++ = cpu_to_be32(args->bc_attrs.max_reqs); /* max requests */ |
| 1881 | *p++ = cpu_to_be32(0); /* rdmachannel_attrs */ |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 1882 | |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1883 | *p++ = cpu_to_be32(args->cb_program); /* cb_program */ |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1884 | *p++ = cpu_to_be32(1); |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1885 | *p++ = cpu_to_be32(RPC_AUTH_UNIX); /* auth_sys */ |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 1886 | |
| 1887 | /* authsys_parms rfc1831 */ |
Deepa Dinamani | 2f86e09 | 2016-10-01 16:46:26 -0700 | [diff] [blame] | 1888 | *p++ = cpu_to_be32(ktime_to_ns(nn->boot_time)); /* stamp */ |
Trond Myklebust | 89f0ff3 | 2015-01-03 14:47:43 -0500 | [diff] [blame] | 1889 | p = xdr_encode_array(p, clnt->cl_nodename, clnt->cl_nodelen); |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1890 | *p++ = cpu_to_be32(0); /* UID */ |
| 1891 | *p++ = cpu_to_be32(0); /* GID */ |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1892 | *p = cpu_to_be32(0); /* No more gids */ |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 1893 | } |
Andy Adamson | 0f3e66c | 2009-04-01 09:22:34 -0400 | [diff] [blame] | 1894 | |
| 1895 | static void encode_destroy_session(struct xdr_stream *xdr, |
Christoph Hellwig | fcc8581 | 2017-05-08 10:01:49 +0200 | [diff] [blame] | 1896 | const struct nfs4_session *session, |
Andy Adamson | 0f3e66c | 2009-04-01 09:22:34 -0400 | [diff] [blame] | 1897 | struct compound_hdr *hdr) |
| 1898 | { |
Trond Myklebust | 475d4ba | 2012-03-05 11:27:16 -0500 | [diff] [blame] | 1899 | encode_op_hdr(xdr, OP_DESTROY_SESSION, decode_destroy_session_maxsz, hdr); |
| 1900 | encode_opaque_fixed(xdr, session->sess_id.data, NFS4_MAX_SESSIONID_LEN); |
Andy Adamson | 0f3e66c | 2009-04-01 09:22:34 -0400 | [diff] [blame] | 1901 | } |
Ricardo Labiaga | 18019753 | 2009-12-05 16:08:40 -0500 | [diff] [blame] | 1902 | |
Trond Myklebust | 6624553 | 2012-05-25 17:18:09 -0400 | [diff] [blame] | 1903 | static void encode_destroy_clientid(struct xdr_stream *xdr, |
| 1904 | uint64_t clientid, |
| 1905 | struct compound_hdr *hdr) |
| 1906 | { |
| 1907 | encode_op_hdr(xdr, OP_DESTROY_CLIENTID, decode_destroy_clientid_maxsz, hdr); |
| 1908 | encode_uint64(xdr, clientid); |
| 1909 | } |
| 1910 | |
Ricardo Labiaga | 18019753 | 2009-12-05 16:08:40 -0500 | [diff] [blame] | 1911 | static void encode_reclaim_complete(struct xdr_stream *xdr, |
Christoph Hellwig | fcc8581 | 2017-05-08 10:01:49 +0200 | [diff] [blame] | 1912 | const struct nfs41_reclaim_complete_args *args, |
Ricardo Labiaga | 18019753 | 2009-12-05 16:08:40 -0500 | [diff] [blame] | 1913 | struct compound_hdr *hdr) |
| 1914 | { |
Trond Myklebust | 475d4ba | 2012-03-05 11:27:16 -0500 | [diff] [blame] | 1915 | encode_op_hdr(xdr, OP_RECLAIM_COMPLETE, decode_reclaim_complete_maxsz, hdr); |
| 1916 | encode_uint32(xdr, args->one_fs); |
Ricardo Labiaga | 18019753 | 2009-12-05 16:08:40 -0500 | [diff] [blame] | 1917 | } |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 1918 | #endif /* CONFIG_NFS_V4_1 */ |
| 1919 | |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 1920 | static void encode_sequence(struct xdr_stream *xdr, |
| 1921 | const struct nfs4_sequence_args *args, |
| 1922 | struct compound_hdr *hdr) |
| 1923 | { |
| 1924 | #if defined(CONFIG_NFS_V4_1) |
Trond Myklebust | 2b2fa71 | 2012-11-16 12:58:36 -0500 | [diff] [blame] | 1925 | struct nfs4_session *session; |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 1926 | struct nfs4_slot_table *tp; |
Trond Myklebust | 2b2fa71 | 2012-11-16 12:58:36 -0500 | [diff] [blame] | 1927 | struct nfs4_slot *slot = args->sa_slot; |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 1928 | __be32 *p; |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 1929 | |
Trond Myklebust | 2b2fa71 | 2012-11-16 12:58:36 -0500 | [diff] [blame] | 1930 | tp = slot->table; |
| 1931 | session = tp->session; |
Chuck Lever | 3bd2384 | 2013-08-09 12:49:19 -0400 | [diff] [blame] | 1932 | if (!session) |
| 1933 | return; |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 1934 | |
Trond Myklebust | 475d4ba | 2012-03-05 11:27:16 -0500 | [diff] [blame] | 1935 | encode_op_hdr(xdr, OP_SEQUENCE, decode_sequence_maxsz, hdr); |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 1936 | |
| 1937 | /* |
| 1938 | * Sessionid + seqid + slotid + max slotid + cache_this |
| 1939 | */ |
| 1940 | dprintk("%s: sessionid=%u:%u:%u:%u seqid=%d slotid=%d " |
| 1941 | "max_slotid=%d cache_this=%d\n", |
| 1942 | __func__, |
| 1943 | ((u32 *)session->sess_id.data)[0], |
| 1944 | ((u32 *)session->sess_id.data)[1], |
| 1945 | ((u32 *)session->sess_id.data)[2], |
| 1946 | ((u32 *)session->sess_id.data)[3], |
Trond Myklebust | 2b2fa71 | 2012-11-16 12:58:36 -0500 | [diff] [blame] | 1947 | slot->seq_nr, slot->slot_nr, |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 1948 | tp->highest_used_slotid, args->sa_cache_this); |
Trond Myklebust | 475d4ba | 2012-03-05 11:27:16 -0500 | [diff] [blame] | 1949 | p = reserve_space(xdr, NFS4_MAX_SESSIONID_LEN + 16); |
Benny Halevy | 93f0cf2 | 2009-08-14 17:19:06 +0300 | [diff] [blame] | 1950 | 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] | 1951 | *p++ = cpu_to_be32(slot->seq_nr); |
Trond Myklebust | 2b2fa71 | 2012-11-16 12:58:36 -0500 | [diff] [blame] | 1952 | *p++ = cpu_to_be32(slot->slot_nr); |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1953 | *p++ = cpu_to_be32(tp->highest_used_slotid); |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1954 | *p = cpu_to_be32(args->sa_cache_this); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 1955 | #endif /* CONFIG_NFS_V4_1 */ |
| 1956 | } |
| 1957 | |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 1958 | #ifdef CONFIG_NFS_V4_1 |
| 1959 | static void |
| 1960 | encode_getdeviceinfo(struct xdr_stream *xdr, |
| 1961 | const struct nfs4_getdeviceinfo_args *args, |
| 1962 | struct compound_hdr *hdr) |
| 1963 | { |
| 1964 | __be32 *p; |
| 1965 | |
Trond Myklebust | 475d4ba | 2012-03-05 11:27:16 -0500 | [diff] [blame] | 1966 | encode_op_hdr(xdr, OP_GETDEVICEINFO, decode_getdeviceinfo_maxsz, hdr); |
Christoph Hellwig | 84c9dee | 2014-09-10 17:37:28 -0700 | [diff] [blame] | 1967 | p = reserve_space(xdr, NFS4_DEVICEID4_SIZE + 4 + 4); |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 1968 | p = xdr_encode_opaque_fixed(p, args->pdev->dev_id.data, |
| 1969 | NFS4_DEVICEID4_SIZE); |
| 1970 | *p++ = cpu_to_be32(args->pdev->layout_type); |
Andy Adamson | f1c097b | 2013-06-25 19:02:53 -0400 | [diff] [blame] | 1971 | *p++ = cpu_to_be32(args->pdev->maxcount); /* gdia_maxcount */ |
Christoph Hellwig | 84c9dee | 2014-09-10 17:37:28 -0700 | [diff] [blame] | 1972 | |
| 1973 | p = reserve_space(xdr, 4 + 4); |
| 1974 | *p++ = cpu_to_be32(1); /* bitmap length */ |
Trond Myklebust | 4e59080 | 2015-03-09 14:01:25 -0400 | [diff] [blame] | 1975 | *p++ = cpu_to_be32(args->notify_types); |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 1976 | } |
| 1977 | |
| 1978 | static void |
| 1979 | encode_layoutget(struct xdr_stream *xdr, |
| 1980 | const struct nfs4_layoutget_args *args, |
| 1981 | struct compound_hdr *hdr) |
| 1982 | { |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 1983 | __be32 *p; |
| 1984 | |
Trond Myklebust | 475d4ba | 2012-03-05 11:27:16 -0500 | [diff] [blame] | 1985 | encode_op_hdr(xdr, OP_LAYOUTGET, decode_layoutget_maxsz, hdr); |
| 1986 | p = reserve_space(xdr, 36); |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 1987 | *p++ = cpu_to_be32(0); /* Signal layout available */ |
| 1988 | *p++ = cpu_to_be32(args->type); |
| 1989 | *p++ = cpu_to_be32(args->range.iomode); |
| 1990 | p = xdr_encode_hyper(p, args->range.offset); |
| 1991 | p = xdr_encode_hyper(p, args->range.length); |
| 1992 | p = xdr_encode_hyper(p, args->minlength); |
Trond Myklebust | ea9d23f | 2012-03-04 18:13:56 -0500 | [diff] [blame] | 1993 | encode_nfs4_stateid(xdr, &args->stateid); |
Trond Myklebust | 475d4ba | 2012-03-05 11:27:16 -0500 | [diff] [blame] | 1994 | encode_uint32(xdr, args->maxcount); |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 1995 | |
| 1996 | dprintk("%s: 1st type:0x%x iomode:%d off:%lu len:%lu mc:%d\n", |
| 1997 | __func__, |
| 1998 | args->type, |
| 1999 | args->range.iomode, |
| 2000 | (unsigned long)args->range.offset, |
| 2001 | (unsigned long)args->range.length, |
| 2002 | args->maxcount); |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 2003 | } |
Andy Adamson | 863a3c6 | 2011-03-23 13:27:54 +0000 | [diff] [blame] | 2004 | |
| 2005 | static int |
| 2006 | encode_layoutcommit(struct xdr_stream *xdr, |
Benny Halevy | ac7db72 | 2011-05-22 19:53:48 +0300 | [diff] [blame] | 2007 | struct inode *inode, |
Christoph Hellwig | fcc8581 | 2017-05-08 10:01:49 +0200 | [diff] [blame] | 2008 | const struct nfs4_layoutcommit_args *args, |
Andy Adamson | 863a3c6 | 2011-03-23 13:27:54 +0000 | [diff] [blame] | 2009 | struct compound_hdr *hdr) |
| 2010 | { |
| 2011 | __be32 *p; |
| 2012 | |
| 2013 | dprintk("%s: lbw: %llu type: %d\n", __func__, args->lastbytewritten, |
| 2014 | NFS_SERVER(args->inode)->pnfs_curr_ld->id); |
| 2015 | |
Trond Myklebust | 475d4ba | 2012-03-05 11:27:16 -0500 | [diff] [blame] | 2016 | encode_op_hdr(xdr, OP_LAYOUTCOMMIT, decode_layoutcommit_maxsz, hdr); |
| 2017 | p = reserve_space(xdr, 20); |
Andy Adamson | 863a3c6 | 2011-03-23 13:27:54 +0000 | [diff] [blame] | 2018 | /* Only whole file layouts */ |
| 2019 | p = xdr_encode_hyper(p, 0); /* offset */ |
Peng Tao | 3557c6c | 2011-07-30 20:52:34 -0400 | [diff] [blame] | 2020 | p = xdr_encode_hyper(p, args->lastbytewritten + 1); /* length */ |
Trond Myklebust | ea9d23f | 2012-03-04 18:13:56 -0500 | [diff] [blame] | 2021 | *p = cpu_to_be32(0); /* reclaim */ |
| 2022 | encode_nfs4_stateid(xdr, &args->stateid); |
Trond Myklebust | 2e18d4d | 2016-06-26 18:54:58 -0400 | [diff] [blame] | 2023 | if (args->lastbytewritten != U64_MAX) { |
| 2024 | p = reserve_space(xdr, 20); |
| 2025 | *p++ = cpu_to_be32(1); /* newoffset = TRUE */ |
| 2026 | p = xdr_encode_hyper(p, args->lastbytewritten); |
| 2027 | } else { |
| 2028 | p = reserve_space(xdr, 12); |
| 2029 | *p++ = cpu_to_be32(0); /* newoffset = FALSE */ |
| 2030 | } |
Andy Adamson | 863a3c6 | 2011-03-23 13:27:54 +0000 | [diff] [blame] | 2031 | *p++ = cpu_to_be32(0); /* Never send time_modify_changed */ |
| 2032 | *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] | 2033 | |
Trond Myklebust | 7350474 | 2017-04-20 16:48:14 -0400 | [diff] [blame] | 2034 | encode_uint32(xdr, args->layoutupdate_len); |
| 2035 | if (args->layoutupdate_pages) |
| 2036 | xdr_write_pages(xdr, args->layoutupdate_pages, 0, |
| 2037 | args->layoutupdate_len); |
Andy Adamson | 863a3c6 | 2011-03-23 13:27:54 +0000 | [diff] [blame] | 2038 | |
Andy Adamson | 863a3c6 | 2011-03-23 13:27:54 +0000 | [diff] [blame] | 2039 | return 0; |
| 2040 | } |
Benny Halevy | cbe8260 | 2011-05-22 19:52:37 +0300 | [diff] [blame] | 2041 | |
| 2042 | static void |
| 2043 | encode_layoutreturn(struct xdr_stream *xdr, |
| 2044 | const struct nfs4_layoutreturn_args *args, |
| 2045 | struct compound_hdr *hdr) |
| 2046 | { |
| 2047 | __be32 *p; |
| 2048 | |
Trond Myklebust | 475d4ba | 2012-03-05 11:27:16 -0500 | [diff] [blame] | 2049 | encode_op_hdr(xdr, OP_LAYOUTRETURN, decode_layoutreturn_maxsz, hdr); |
| 2050 | p = reserve_space(xdr, 16); |
Benny Halevy | cbe8260 | 2011-05-22 19:52:37 +0300 | [diff] [blame] | 2051 | *p++ = cpu_to_be32(0); /* reclaim. always 0 for now */ |
| 2052 | *p++ = cpu_to_be32(args->layout_type); |
Peng Tao | 15eb67c | 2014-11-17 09:30:36 +0800 | [diff] [blame] | 2053 | *p++ = cpu_to_be32(args->range.iomode); |
Benny Halevy | cbe8260 | 2011-05-22 19:52:37 +0300 | [diff] [blame] | 2054 | *p = cpu_to_be32(RETURN_FILE); |
Trond Myklebust | ea9d23f | 2012-03-04 18:13:56 -0500 | [diff] [blame] | 2055 | p = reserve_space(xdr, 16); |
Peng Tao | 15eb67c | 2014-11-17 09:30:36 +0800 | [diff] [blame] | 2056 | p = xdr_encode_hyper(p, args->range.offset); |
| 2057 | p = xdr_encode_hyper(p, args->range.length); |
Benny Halevy | cbe8260 | 2011-05-22 19:52:37 +0300 | [diff] [blame] | 2058 | spin_lock(&args->inode->i_lock); |
Trond Myklebust | ea9d23f | 2012-03-04 18:13:56 -0500 | [diff] [blame] | 2059 | encode_nfs4_stateid(xdr, &args->stateid); |
Benny Halevy | cbe8260 | 2011-05-22 19:52:37 +0300 | [diff] [blame] | 2060 | spin_unlock(&args->inode->i_lock); |
Trond Myklebust | 4d796d7 | 2016-09-23 11:38:08 -0400 | [diff] [blame] | 2061 | if (args->ld_private->ops && args->ld_private->ops->encode) |
| 2062 | args->ld_private->ops->encode(xdr, args, args->ld_private); |
Trond Myklebust | 94e5c57 | 2016-09-15 18:49:52 -0400 | [diff] [blame] | 2063 | else |
Trond Myklebust | 475d4ba | 2012-03-05 11:27:16 -0500 | [diff] [blame] | 2064 | encode_uint32(xdr, 0); |
Benny Halevy | cbe8260 | 2011-05-22 19:52:37 +0300 | [diff] [blame] | 2065 | } |
Bryan Schumaker | fca78d6 | 2011-06-02 14:59:07 -0400 | [diff] [blame] | 2066 | |
| 2067 | static int |
| 2068 | encode_secinfo_no_name(struct xdr_stream *xdr, |
| 2069 | const struct nfs41_secinfo_no_name_args *args, |
| 2070 | struct compound_hdr *hdr) |
| 2071 | { |
Trond Myklebust | 475d4ba | 2012-03-05 11:27:16 -0500 | [diff] [blame] | 2072 | encode_op_hdr(xdr, OP_SECINFO_NO_NAME, decode_secinfo_no_name_maxsz, hdr); |
| 2073 | encode_uint32(xdr, args->style); |
Bryan Schumaker | fca78d6 | 2011-06-02 14:59:07 -0400 | [diff] [blame] | 2074 | return 0; |
| 2075 | } |
Bryan Schumaker | 7d97479 | 2011-06-02 14:59:08 -0400 | [diff] [blame] | 2076 | |
| 2077 | static void encode_test_stateid(struct xdr_stream *xdr, |
Christoph Hellwig | fcc8581 | 2017-05-08 10:01:49 +0200 | [diff] [blame] | 2078 | const struct nfs41_test_stateid_args *args, |
Bryan Schumaker | 7d97479 | 2011-06-02 14:59:08 -0400 | [diff] [blame] | 2079 | struct compound_hdr *hdr) |
| 2080 | { |
Trond Myklebust | 475d4ba | 2012-03-05 11:27:16 -0500 | [diff] [blame] | 2081 | encode_op_hdr(xdr, OP_TEST_STATEID, decode_test_stateid_maxsz, hdr); |
| 2082 | encode_uint32(xdr, 1); |
Trond Myklebust | ea9d23f | 2012-03-04 18:13:56 -0500 | [diff] [blame] | 2083 | encode_nfs4_stateid(xdr, args->stateid); |
Bryan Schumaker | 7d97479 | 2011-06-02 14:59:08 -0400 | [diff] [blame] | 2084 | } |
Bryan Schumaker | 9aeda35 | 2011-06-02 14:59:09 -0400 | [diff] [blame] | 2085 | |
| 2086 | static void encode_free_stateid(struct xdr_stream *xdr, |
Christoph Hellwig | fcc8581 | 2017-05-08 10:01:49 +0200 | [diff] [blame] | 2087 | const struct nfs41_free_stateid_args *args, |
Bryan Schumaker | 9aeda35 | 2011-06-02 14:59:09 -0400 | [diff] [blame] | 2088 | struct compound_hdr *hdr) |
| 2089 | { |
Trond Myklebust | ab19b48 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 2090 | encode_op_hdr(xdr, OP_FREE_STATEID, decode_free_stateid_maxsz, hdr); |
Trond Myklebust | 7c1d5fa | 2013-05-03 14:40:01 -0400 | [diff] [blame] | 2091 | encode_nfs4_stateid(xdr, &args->stateid); |
Bryan Schumaker | 9aeda35 | 2011-06-02 14:59:09 -0400 | [diff] [blame] | 2092 | } |
Trond Myklebust | cf80516 | 2016-11-15 14:56:07 -0500 | [diff] [blame] | 2093 | #else |
| 2094 | static inline void |
| 2095 | encode_layoutreturn(struct xdr_stream *xdr, |
| 2096 | const struct nfs4_layoutreturn_args *args, |
| 2097 | struct compound_hdr *hdr) |
| 2098 | { |
| 2099 | } |
Fred Isaman | 56f487f | 2016-09-21 11:43:41 -0400 | [diff] [blame] | 2100 | |
| 2101 | static void |
| 2102 | encode_layoutget(struct xdr_stream *xdr, |
| 2103 | const struct nfs4_layoutget_args *args, |
| 2104 | struct compound_hdr *hdr) |
| 2105 | { |
| 2106 | } |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 2107 | #endif /* CONFIG_NFS_V4_1 */ |
| 2108 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2109 | /* |
| 2110 | * END OF "GENERIC" ENCODE ROUTINES. |
| 2111 | */ |
| 2112 | |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2113 | static u32 nfs4_xdr_minorversion(const struct nfs4_sequence_args *args) |
| 2114 | { |
| 2115 | #if defined(CONFIG_NFS_V4_1) |
Chuck Lever | 3bd2384 | 2013-08-09 12:49:19 -0400 | [diff] [blame] | 2116 | struct nfs4_session *session = args->sa_slot->table->session; |
| 2117 | if (session) |
| 2118 | return session->clp->cl_mvops->minor_version; |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2119 | #endif /* CONFIG_NFS_V4_1 */ |
| 2120 | return 0; |
| 2121 | } |
| 2122 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2123 | /* |
| 2124 | * Encode an ACCESS request |
| 2125 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2126 | static void nfs4_xdr_enc_access(struct rpc_rqst *req, struct xdr_stream *xdr, |
Christoph Hellwig | fcc8581 | 2017-05-08 10:01:49 +0200 | [diff] [blame] | 2127 | const void *data) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2128 | { |
Christoph Hellwig | fcc8581 | 2017-05-08 10:01:49 +0200 | [diff] [blame] | 2129 | const struct nfs4_accessargs *args = data; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2130 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2131 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2132 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2133 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2134 | encode_compound_hdr(xdr, req, &hdr); |
| 2135 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2136 | encode_putfh(xdr, args->fh, &hdr); |
| 2137 | encode_access(xdr, args->access, &hdr); |
Trond Myklebust | 8bcbe7d | 2018-03-20 17:03:11 -0400 | [diff] [blame] | 2138 | if (args->bitmask) |
| 2139 | encode_getfattr(xdr, args->bitmask, &hdr); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2140 | encode_nops(&hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2141 | } |
| 2142 | |
| 2143 | /* |
| 2144 | * Encode LOOKUP request |
| 2145 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2146 | static void nfs4_xdr_enc_lookup(struct rpc_rqst *req, struct xdr_stream *xdr, |
Christoph Hellwig | fcc8581 | 2017-05-08 10:01:49 +0200 | [diff] [blame] | 2147 | const void *data) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2148 | { |
Christoph Hellwig | fcc8581 | 2017-05-08 10:01:49 +0200 | [diff] [blame] | 2149 | const struct nfs4_lookup_arg *args = data; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2150 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2151 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2152 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2153 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2154 | encode_compound_hdr(xdr, req, &hdr); |
| 2155 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2156 | encode_putfh(xdr, args->dir_fh, &hdr); |
| 2157 | encode_lookup(xdr, args->name, &hdr); |
| 2158 | encode_getfh(xdr, &hdr); |
| 2159 | encode_getfattr(xdr, args->bitmask, &hdr); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2160 | encode_nops(&hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2161 | } |
| 2162 | |
| 2163 | /* |
Jeff Layton | 5b5faaf | 2017-06-29 06:34:52 -0700 | [diff] [blame] | 2164 | * Encode LOOKUPP request |
| 2165 | */ |
| 2166 | static void nfs4_xdr_enc_lookupp(struct rpc_rqst *req, struct xdr_stream *xdr, |
| 2167 | const void *data) |
| 2168 | { |
| 2169 | const struct nfs4_lookupp_arg *args = data; |
| 2170 | struct compound_hdr hdr = { |
| 2171 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
| 2172 | }; |
| 2173 | |
| 2174 | encode_compound_hdr(xdr, req, &hdr); |
| 2175 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2176 | encode_putfh(xdr, args->fh, &hdr); |
| 2177 | encode_lookupp(xdr, &hdr); |
| 2178 | encode_getfh(xdr, &hdr); |
| 2179 | encode_getfattr(xdr, args->bitmask, &hdr); |
| 2180 | encode_nops(&hdr); |
| 2181 | } |
| 2182 | |
| 2183 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2184 | * Encode LOOKUP_ROOT request |
| 2185 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2186 | static void nfs4_xdr_enc_lookup_root(struct rpc_rqst *req, |
| 2187 | struct xdr_stream *xdr, |
Christoph Hellwig | fcc8581 | 2017-05-08 10:01:49 +0200 | [diff] [blame] | 2188 | const void *data) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2189 | { |
Christoph Hellwig | fcc8581 | 2017-05-08 10:01:49 +0200 | [diff] [blame] | 2190 | const struct nfs4_lookup_root_arg *args = data; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2191 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2192 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2193 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2194 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2195 | encode_compound_hdr(xdr, req, &hdr); |
| 2196 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2197 | encode_putrootfh(xdr, &hdr); |
| 2198 | encode_getfh(xdr, &hdr); |
| 2199 | encode_getfattr(xdr, args->bitmask, &hdr); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2200 | encode_nops(&hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2201 | } |
| 2202 | |
| 2203 | /* |
| 2204 | * Encode REMOVE request |
| 2205 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2206 | static void nfs4_xdr_enc_remove(struct rpc_rqst *req, struct xdr_stream *xdr, |
Christoph Hellwig | fcc8581 | 2017-05-08 10:01:49 +0200 | [diff] [blame] | 2207 | const void *data) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2208 | { |
Christoph Hellwig | fcc8581 | 2017-05-08 10:01:49 +0200 | [diff] [blame] | 2209 | const struct nfs_removeargs *args = data; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2210 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2211 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2212 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2213 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2214 | encode_compound_hdr(xdr, req, &hdr); |
| 2215 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2216 | encode_putfh(xdr, args->fh, &hdr); |
| 2217 | encode_remove(xdr, &args->name, &hdr); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2218 | encode_nops(&hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2219 | } |
| 2220 | |
| 2221 | /* |
| 2222 | * Encode RENAME request |
| 2223 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2224 | static void nfs4_xdr_enc_rename(struct rpc_rqst *req, struct xdr_stream *xdr, |
Christoph Hellwig | fcc8581 | 2017-05-08 10:01:49 +0200 | [diff] [blame] | 2225 | const void *data) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2226 | { |
Christoph Hellwig | fcc8581 | 2017-05-08 10:01:49 +0200 | [diff] [blame] | 2227 | const struct nfs_renameargs *args = data; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2228 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2229 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2230 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2231 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2232 | encode_compound_hdr(xdr, req, &hdr); |
| 2233 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2234 | encode_putfh(xdr, args->old_dir, &hdr); |
| 2235 | encode_savefh(xdr, &hdr); |
| 2236 | encode_putfh(xdr, args->new_dir, &hdr); |
| 2237 | encode_rename(xdr, args->old_name, args->new_name, &hdr); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2238 | encode_nops(&hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2239 | } |
| 2240 | |
| 2241 | /* |
| 2242 | * Encode LINK request |
| 2243 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2244 | static void nfs4_xdr_enc_link(struct rpc_rqst *req, struct xdr_stream *xdr, |
Christoph Hellwig | fcc8581 | 2017-05-08 10:01:49 +0200 | [diff] [blame] | 2245 | const void *data) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2246 | { |
Christoph Hellwig | fcc8581 | 2017-05-08 10:01:49 +0200 | [diff] [blame] | 2247 | const struct nfs4_link_arg *args = data; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2248 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2249 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2250 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2251 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2252 | encode_compound_hdr(xdr, req, &hdr); |
| 2253 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2254 | encode_putfh(xdr, args->fh, &hdr); |
| 2255 | encode_savefh(xdr, &hdr); |
| 2256 | encode_putfh(xdr, args->dir_fh, &hdr); |
| 2257 | encode_link(xdr, args->name, &hdr); |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2258 | encode_restorefh(xdr, &hdr); |
| 2259 | encode_getfattr(xdr, args->bitmask, &hdr); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2260 | encode_nops(&hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2261 | } |
| 2262 | |
| 2263 | /* |
| 2264 | * Encode CREATE request |
| 2265 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2266 | static void nfs4_xdr_enc_create(struct rpc_rqst *req, struct xdr_stream *xdr, |
Christoph Hellwig | fcc8581 | 2017-05-08 10:01:49 +0200 | [diff] [blame] | 2267 | const void *data) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2268 | { |
Christoph Hellwig | fcc8581 | 2017-05-08 10:01:49 +0200 | [diff] [blame] | 2269 | const struct nfs4_create_arg *args = data; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2270 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2271 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2272 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2273 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2274 | encode_compound_hdr(xdr, req, &hdr); |
| 2275 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2276 | encode_putfh(xdr, args->dir_fh, &hdr); |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2277 | encode_create(xdr, args, &hdr); |
| 2278 | encode_getfh(xdr, &hdr); |
| 2279 | encode_getfattr(xdr, args->bitmask, &hdr); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2280 | encode_nops(&hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2281 | } |
| 2282 | |
| 2283 | /* |
| 2284 | * Encode SYMLINK request |
| 2285 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2286 | static void nfs4_xdr_enc_symlink(struct rpc_rqst *req, struct xdr_stream *xdr, |
Christoph Hellwig | fcc8581 | 2017-05-08 10:01:49 +0200 | [diff] [blame] | 2287 | const void *data) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2288 | { |
Christoph Hellwig | fcc8581 | 2017-05-08 10:01:49 +0200 | [diff] [blame] | 2289 | const struct nfs4_create_arg *args = data; |
| 2290 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2291 | nfs4_xdr_enc_create(req, xdr, args); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2292 | } |
| 2293 | |
| 2294 | /* |
| 2295 | * Encode GETATTR request |
| 2296 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2297 | static void nfs4_xdr_enc_getattr(struct rpc_rqst *req, struct xdr_stream *xdr, |
Christoph Hellwig | fcc8581 | 2017-05-08 10:01:49 +0200 | [diff] [blame] | 2298 | const void *data) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2299 | { |
Christoph Hellwig | fcc8581 | 2017-05-08 10:01:49 +0200 | [diff] [blame] | 2300 | const struct nfs4_getattr_arg *args = data; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2301 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2302 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2303 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2304 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2305 | encode_compound_hdr(xdr, req, &hdr); |
| 2306 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2307 | encode_putfh(xdr, args->fh, &hdr); |
| 2308 | encode_getfattr(xdr, args->bitmask, &hdr); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2309 | encode_nops(&hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2310 | } |
| 2311 | |
| 2312 | /* |
| 2313 | * Encode a CLOSE request |
| 2314 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2315 | static void nfs4_xdr_enc_close(struct rpc_rqst *req, struct xdr_stream *xdr, |
Christoph Hellwig | fcc8581 | 2017-05-08 10:01:49 +0200 | [diff] [blame] | 2316 | const void *data) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2317 | { |
Christoph Hellwig | fcc8581 | 2017-05-08 10:01:49 +0200 | [diff] [blame] | 2318 | const struct nfs_closeargs *args = data; |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 2319 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2320 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 2321 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2322 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2323 | encode_compound_hdr(xdr, req, &hdr); |
| 2324 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2325 | encode_putfh(xdr, args->fh, &hdr); |
Trond Myklebust | cf80516 | 2016-11-15 14:56:07 -0500 | [diff] [blame] | 2326 | if (args->lr_args) |
| 2327 | encode_layoutreturn(xdr, args->lr_args, &hdr); |
Trond Myklebust | 3ecefc9 | 2016-10-27 18:25:04 -0400 | [diff] [blame] | 2328 | if (args->bitmask != NULL) |
| 2329 | encode_getfattr(xdr, args->bitmask, &hdr); |
Trond Myklebust | d8d8498 | 2016-12-19 12:14:44 -0500 | [diff] [blame] | 2330 | encode_close(xdr, args, &hdr); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2331 | encode_nops(&hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2332 | } |
| 2333 | |
| 2334 | /* |
| 2335 | * Encode an OPEN request |
| 2336 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2337 | static void nfs4_xdr_enc_open(struct rpc_rqst *req, struct xdr_stream *xdr, |
Christoph Hellwig | fcc8581 | 2017-05-08 10:01:49 +0200 | [diff] [blame] | 2338 | const void *data) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2339 | { |
Christoph Hellwig | fcc8581 | 2017-05-08 10:01:49 +0200 | [diff] [blame] | 2340 | const struct nfs_openargs *args = data; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2341 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2342 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2343 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2344 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2345 | encode_compound_hdr(xdr, req, &hdr); |
| 2346 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2347 | encode_putfh(xdr, args->fh, &hdr); |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2348 | encode_open(xdr, args, &hdr); |
| 2349 | encode_getfh(xdr, &hdr); |
Weston Andros Adamson | ae2bb03 | 2012-10-02 14:49:52 -0700 | [diff] [blame] | 2350 | if (args->access) |
| 2351 | encode_access(xdr, args->access, &hdr); |
Trond Myklebust | 1549210f | 2012-06-05 09:16:47 -0400 | [diff] [blame] | 2352 | encode_getfattr_open(xdr, args->bitmask, args->open_bitmap, &hdr); |
Fred Isaman | 56f487f | 2016-09-21 11:43:41 -0400 | [diff] [blame] | 2353 | if (args->lg_args) { |
| 2354 | encode_layoutget(xdr, args->lg_args, &hdr); |
Chuck Lever | cf500ba | 2019-02-11 11:25:20 -0500 | [diff] [blame] | 2355 | rpc_prepare_reply_pages(req, args->lg_args->layout.pages, 0, |
| 2356 | args->lg_args->layout.pglen, |
Trond Myklebust | 9ed5af26 | 2020-11-21 20:46:18 -0500 | [diff] [blame] | 2357 | hdr.replen - pagepad_maxsz); |
Fred Isaman | 56f487f | 2016-09-21 11:43:41 -0400 | [diff] [blame] | 2358 | } |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2359 | encode_nops(&hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2360 | } |
| 2361 | |
| 2362 | /* |
| 2363 | * Encode an OPEN_CONFIRM request |
| 2364 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2365 | static void nfs4_xdr_enc_open_confirm(struct rpc_rqst *req, |
| 2366 | struct xdr_stream *xdr, |
Christoph Hellwig | fcc8581 | 2017-05-08 10:01:49 +0200 | [diff] [blame] | 2367 | const void *data) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2368 | { |
Christoph Hellwig | fcc8581 | 2017-05-08 10:01:49 +0200 | [diff] [blame] | 2369 | const struct nfs_open_confirmargs *args = data; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2370 | struct compound_hdr hdr = { |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2371 | .nops = 0, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2372 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2373 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2374 | encode_compound_hdr(xdr, req, &hdr); |
| 2375 | encode_putfh(xdr, args->fh, &hdr); |
| 2376 | encode_open_confirm(xdr, args, &hdr); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2377 | encode_nops(&hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2378 | } |
| 2379 | |
| 2380 | /* |
| 2381 | * Encode an OPEN request with no attributes. |
| 2382 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2383 | static void nfs4_xdr_enc_open_noattr(struct rpc_rqst *req, |
| 2384 | struct xdr_stream *xdr, |
Christoph Hellwig | fcc8581 | 2017-05-08 10:01:49 +0200 | [diff] [blame] | 2385 | const void *data) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2386 | { |
Christoph Hellwig | fcc8581 | 2017-05-08 10:01:49 +0200 | [diff] [blame] | 2387 | const struct nfs_openargs *args = data; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2388 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2389 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2390 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2391 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2392 | encode_compound_hdr(xdr, req, &hdr); |
| 2393 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2394 | encode_putfh(xdr, args->fh, &hdr); |
| 2395 | encode_open(xdr, args, &hdr); |
Weston Andros Adamson | ae2bb03 | 2012-10-02 14:49:52 -0700 | [diff] [blame] | 2396 | if (args->access) |
| 2397 | encode_access(xdr, args->access, &hdr); |
Andy Adamson | e23008e | 2012-10-02 21:07:32 -0400 | [diff] [blame] | 2398 | encode_getfattr_open(xdr, args->bitmask, args->open_bitmap, &hdr); |
Fred Isaman | 56f487f | 2016-09-21 11:43:41 -0400 | [diff] [blame] | 2399 | if (args->lg_args) { |
| 2400 | encode_layoutget(xdr, args->lg_args, &hdr); |
Chuck Lever | cf500ba | 2019-02-11 11:25:20 -0500 | [diff] [blame] | 2401 | rpc_prepare_reply_pages(req, args->lg_args->layout.pages, 0, |
| 2402 | args->lg_args->layout.pglen, |
Trond Myklebust | 9ed5af26 | 2020-11-21 20:46:18 -0500 | [diff] [blame] | 2403 | hdr.replen - pagepad_maxsz); |
Fred Isaman | 56f487f | 2016-09-21 11:43:41 -0400 | [diff] [blame] | 2404 | } |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2405 | encode_nops(&hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2406 | } |
| 2407 | |
| 2408 | /* |
| 2409 | * Encode an OPEN_DOWNGRADE request |
| 2410 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2411 | static void nfs4_xdr_enc_open_downgrade(struct rpc_rqst *req, |
| 2412 | struct xdr_stream *xdr, |
Christoph Hellwig | fcc8581 | 2017-05-08 10:01:49 +0200 | [diff] [blame] | 2413 | const void *data) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2414 | { |
Christoph Hellwig | fcc8581 | 2017-05-08 10:01:49 +0200 | [diff] [blame] | 2415 | const struct nfs_closeargs *args = data; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2416 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2417 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2418 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2419 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2420 | encode_compound_hdr(xdr, req, &hdr); |
| 2421 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2422 | encode_putfh(xdr, args->fh, &hdr); |
Trond Myklebust | b680814 | 2016-11-20 13:34:16 -0500 | [diff] [blame] | 2423 | if (args->lr_args) |
| 2424 | encode_layoutreturn(xdr, args->lr_args, &hdr); |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2425 | encode_open_downgrade(xdr, args, &hdr); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2426 | encode_nops(&hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2427 | } |
| 2428 | |
| 2429 | /* |
| 2430 | * Encode a LOCK request |
| 2431 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2432 | static void nfs4_xdr_enc_lock(struct rpc_rqst *req, struct xdr_stream *xdr, |
Christoph Hellwig | fcc8581 | 2017-05-08 10:01:49 +0200 | [diff] [blame] | 2433 | const void *data) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2434 | { |
Christoph Hellwig | fcc8581 | 2017-05-08 10:01:49 +0200 | [diff] [blame] | 2435 | const struct nfs_lock_args *args = data; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2436 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2437 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2438 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2439 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2440 | encode_compound_hdr(xdr, req, &hdr); |
| 2441 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2442 | encode_putfh(xdr, args->fh, &hdr); |
| 2443 | encode_lock(xdr, args, &hdr); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2444 | encode_nops(&hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2445 | } |
| 2446 | |
| 2447 | /* |
| 2448 | * Encode a LOCKT request |
| 2449 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2450 | static void nfs4_xdr_enc_lockt(struct rpc_rqst *req, struct xdr_stream *xdr, |
Christoph Hellwig | fcc8581 | 2017-05-08 10:01:49 +0200 | [diff] [blame] | 2451 | const void *data) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2452 | { |
Christoph Hellwig | fcc8581 | 2017-05-08 10:01:49 +0200 | [diff] [blame] | 2453 | const struct nfs_lockt_args *args = data; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2454 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2455 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2456 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2457 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2458 | encode_compound_hdr(xdr, req, &hdr); |
| 2459 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2460 | encode_putfh(xdr, args->fh, &hdr); |
| 2461 | encode_lockt(xdr, args, &hdr); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2462 | encode_nops(&hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2463 | } |
| 2464 | |
| 2465 | /* |
| 2466 | * Encode a LOCKU request |
| 2467 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2468 | static void nfs4_xdr_enc_locku(struct rpc_rqst *req, struct xdr_stream *xdr, |
Christoph Hellwig | fcc8581 | 2017-05-08 10:01:49 +0200 | [diff] [blame] | 2469 | const void *data) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2470 | { |
Christoph Hellwig | fcc8581 | 2017-05-08 10:01:49 +0200 | [diff] [blame] | 2471 | const struct nfs_locku_args *args = data; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2472 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2473 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2474 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2475 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2476 | encode_compound_hdr(xdr, req, &hdr); |
| 2477 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2478 | encode_putfh(xdr, args->fh, &hdr); |
| 2479 | encode_locku(xdr, args, &hdr); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2480 | encode_nops(&hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2481 | } |
| 2482 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2483 | static void nfs4_xdr_enc_release_lockowner(struct rpc_rqst *req, |
| 2484 | struct xdr_stream *xdr, |
Christoph Hellwig | fcc8581 | 2017-05-08 10:01:49 +0200 | [diff] [blame] | 2485 | const void *data) |
Trond Myklebust | d3c7b7c | 2010-07-01 12:49:01 -0400 | [diff] [blame] | 2486 | { |
Christoph Hellwig | fcc8581 | 2017-05-08 10:01:49 +0200 | [diff] [blame] | 2487 | const struct nfs_release_lockowner_args *args = data; |
Trond Myklebust | d3c7b7c | 2010-07-01 12:49:01 -0400 | [diff] [blame] | 2488 | struct compound_hdr hdr = { |
| 2489 | .minorversion = 0, |
| 2490 | }; |
| 2491 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2492 | encode_compound_hdr(xdr, req, &hdr); |
| 2493 | encode_release_lockowner(xdr, &args->lock_owner, &hdr); |
Trond Myklebust | d3c7b7c | 2010-07-01 12:49:01 -0400 | [diff] [blame] | 2494 | encode_nops(&hdr); |
Trond Myklebust | d3c7b7c | 2010-07-01 12:49:01 -0400 | [diff] [blame] | 2495 | } |
| 2496 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2497 | /* |
| 2498 | * Encode a READLINK request |
| 2499 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2500 | static void nfs4_xdr_enc_readlink(struct rpc_rqst *req, struct xdr_stream *xdr, |
Christoph Hellwig | fcc8581 | 2017-05-08 10:01:49 +0200 | [diff] [blame] | 2501 | const void *data) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2502 | { |
Christoph Hellwig | fcc8581 | 2017-05-08 10:01:49 +0200 | [diff] [blame] | 2503 | const struct nfs4_readlink *args = data; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2504 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2505 | .minorversion = nfs4_xdr_minorversion(&args->seq_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 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2508 | encode_compound_hdr(xdr, req, &hdr); |
| 2509 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2510 | encode_putfh(xdr, args->fh, &hdr); |
| 2511 | encode_readlink(xdr, args, req, &hdr); |
Trond Myklebust | e3a535e | 2007-07-19 10:03:38 -0400 | [diff] [blame] | 2512 | |
Chuck Lever | cf500ba | 2019-02-11 11:25:20 -0500 | [diff] [blame] | 2513 | rpc_prepare_reply_pages(req, args->pages, args->pgbase, |
Trond Myklebust | 9ed5af26 | 2020-11-21 20:46:18 -0500 | [diff] [blame] | 2514 | args->pglen, hdr.replen - pagepad_maxsz); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2515 | encode_nops(&hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2516 | } |
| 2517 | |
| 2518 | /* |
| 2519 | * Encode a READDIR request |
| 2520 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2521 | static void nfs4_xdr_enc_readdir(struct rpc_rqst *req, struct xdr_stream *xdr, |
Christoph Hellwig | fcc8581 | 2017-05-08 10:01:49 +0200 | [diff] [blame] | 2522 | const void *data) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2523 | { |
Christoph Hellwig | fcc8581 | 2017-05-08 10:01:49 +0200 | [diff] [blame] | 2524 | const struct nfs4_readdir_arg *args = data; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2525 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2526 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2527 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2528 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2529 | encode_compound_hdr(xdr, req, &hdr); |
| 2530 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2531 | encode_putfh(xdr, args->fh, &hdr); |
| 2532 | encode_readdir(xdr, args, req, &hdr); |
Trond Myklebust | d6ac02d | 2007-07-19 10:03:37 -0400 | [diff] [blame] | 2533 | |
Chuck Lever | cf500ba | 2019-02-11 11:25:20 -0500 | [diff] [blame] | 2534 | rpc_prepare_reply_pages(req, args->pages, args->pgbase, |
Trond Myklebust | 9ed5af26 | 2020-11-21 20:46:18 -0500 | [diff] [blame] | 2535 | args->count, hdr.replen - pagepad_maxsz); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2536 | encode_nops(&hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2537 | } |
| 2538 | |
| 2539 | /* |
| 2540 | * Encode a READ request |
| 2541 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2542 | static void nfs4_xdr_enc_read(struct rpc_rqst *req, struct xdr_stream *xdr, |
Christoph Hellwig | fcc8581 | 2017-05-08 10:01:49 +0200 | [diff] [blame] | 2543 | const void *data) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2544 | { |
Christoph Hellwig | fcc8581 | 2017-05-08 10:01:49 +0200 | [diff] [blame] | 2545 | const struct nfs_pgio_args *args = data; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2546 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2547 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2548 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2549 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2550 | encode_compound_hdr(xdr, req, &hdr); |
| 2551 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2552 | encode_putfh(xdr, args->fh, &hdr); |
| 2553 | encode_read(xdr, args, &hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2554 | |
Chuck Lever | cf500ba | 2019-02-11 11:25:20 -0500 | [diff] [blame] | 2555 | rpc_prepare_reply_pages(req, args->pages, args->pgbase, |
Trond Myklebust | 9ed5af26 | 2020-11-21 20:46:18 -0500 | [diff] [blame] | 2556 | args->count, hdr.replen - pagepad_maxsz); |
\"Talpey, Thomas\ | 4f22ccc | 2007-09-10 13:44:58 -0400 | [diff] [blame] | 2557 | req->rq_rcv_buf.flags |= XDRBUF_READ; |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2558 | encode_nops(&hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2559 | } |
| 2560 | |
| 2561 | /* |
| 2562 | * Encode an SETATTR request |
| 2563 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2564 | static void nfs4_xdr_enc_setattr(struct rpc_rqst *req, struct xdr_stream *xdr, |
Christoph Hellwig | fcc8581 | 2017-05-08 10:01:49 +0200 | [diff] [blame] | 2565 | const void *data) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2566 | { |
Christoph Hellwig | fcc8581 | 2017-05-08 10:01:49 +0200 | [diff] [blame] | 2567 | const struct nfs_setattrargs *args = data; |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 2568 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2569 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 2570 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2571 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2572 | encode_compound_hdr(xdr, req, &hdr); |
| 2573 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2574 | encode_putfh(xdr, args->fh, &hdr); |
| 2575 | encode_setattr(xdr, args, args->server, &hdr); |
| 2576 | encode_getfattr(xdr, args->bitmask, &hdr); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2577 | encode_nops(&hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2578 | } |
| 2579 | |
| 2580 | /* |
J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 2581 | * Encode a GETACL request |
| 2582 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2583 | static void nfs4_xdr_enc_getacl(struct rpc_rqst *req, struct xdr_stream *xdr, |
Christoph Hellwig | fcc8581 | 2017-05-08 10:01:49 +0200 | [diff] [blame] | 2584 | const void *data) |
J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 2585 | { |
Christoph Hellwig | fcc8581 | 2017-05-08 10:01:49 +0200 | [diff] [blame] | 2586 | const struct nfs_getaclargs *args = data; |
J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 2587 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2588 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 2589 | }; |
Trond Myklebust | 37c8876 | 2018-03-20 17:03:08 -0400 | [diff] [blame] | 2590 | const __u32 nfs4_acl_bitmap[1] = { |
| 2591 | [0] = FATTR4_WORD0_ACL, |
| 2592 | }; |
Benny Halevy | 28f5669 | 2009-04-01 09:22:09 -0400 | [diff] [blame] | 2593 | uint32_t replen; |
J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 2594 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2595 | encode_compound_hdr(xdr, req, &hdr); |
| 2596 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2597 | encode_putfh(xdr, args->fh, &hdr); |
J. Bruce Fields | 6682c14 | 2017-02-23 14:53:39 -0500 | [diff] [blame] | 2598 | replen = hdr.replen + op_decode_hdr_maxsz; |
Trond Myklebust | 37c8876 | 2018-03-20 17:03:08 -0400 | [diff] [blame] | 2599 | encode_getattr(xdr, nfs4_acl_bitmap, NULL, |
| 2600 | ARRAY_SIZE(nfs4_acl_bitmap), &hdr); |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 2601 | |
Chuck Lever | cf500ba | 2019-02-11 11:25:20 -0500 | [diff] [blame] | 2602 | rpc_prepare_reply_pages(req, args->acl_pages, 0, |
Trond Myklebust | 9ed5af26 | 2020-11-21 20:46:18 -0500 | [diff] [blame] | 2603 | args->acl_len, replen); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2604 | encode_nops(&hdr); |
J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 2605 | } |
| 2606 | |
| 2607 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2608 | * Encode a WRITE request |
| 2609 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2610 | static void nfs4_xdr_enc_write(struct rpc_rqst *req, struct xdr_stream *xdr, |
Christoph Hellwig | fcc8581 | 2017-05-08 10:01:49 +0200 | [diff] [blame] | 2611 | const void *data) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2612 | { |
Christoph Hellwig | fcc8581 | 2017-05-08 10:01:49 +0200 | [diff] [blame] | 2613 | const struct nfs_pgio_args *args = data; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2614 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2615 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2616 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2617 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2618 | encode_compound_hdr(xdr, req, &hdr); |
| 2619 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2620 | encode_putfh(xdr, args->fh, &hdr); |
| 2621 | encode_write(xdr, args, &hdr); |
\"Talpey, Thomas\ | 4f22ccc | 2007-09-10 13:44:58 -0400 | [diff] [blame] | 2622 | req->rq_snd_buf.flags |= XDRBUF_WRITE; |
Fred Isaman | 7ffd106 | 2011-03-03 15:13:46 +0000 | [diff] [blame] | 2623 | if (args->bitmask) |
| 2624 | encode_getfattr(xdr, args->bitmask, &hdr); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2625 | encode_nops(&hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2626 | } |
| 2627 | |
| 2628 | /* |
| 2629 | * a COMMIT request |
| 2630 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2631 | static void nfs4_xdr_enc_commit(struct rpc_rqst *req, struct xdr_stream *xdr, |
Christoph Hellwig | fcc8581 | 2017-05-08 10:01:49 +0200 | [diff] [blame] | 2632 | const void *data) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2633 | { |
Christoph Hellwig | fcc8581 | 2017-05-08 10:01:49 +0200 | [diff] [blame] | 2634 | const struct nfs_commitargs *args = data; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2635 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2636 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2637 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2638 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2639 | encode_compound_hdr(xdr, req, &hdr); |
| 2640 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2641 | encode_putfh(xdr, args->fh, &hdr); |
| 2642 | encode_commit(xdr, args, &hdr); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2643 | encode_nops(&hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2644 | } |
| 2645 | |
| 2646 | /* |
| 2647 | * FSINFO request |
| 2648 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2649 | static void nfs4_xdr_enc_fsinfo(struct rpc_rqst *req, struct xdr_stream *xdr, |
Christoph Hellwig | fcc8581 | 2017-05-08 10:01:49 +0200 | [diff] [blame] | 2650 | const void *data) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2651 | { |
Christoph Hellwig | fcc8581 | 2017-05-08 10:01:49 +0200 | [diff] [blame] | 2652 | const struct nfs4_fsinfo_arg *args = data; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2653 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2654 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2655 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2656 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2657 | encode_compound_hdr(xdr, req, &hdr); |
| 2658 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2659 | encode_putfh(xdr, args->fh, &hdr); |
| 2660 | encode_fsinfo(xdr, args->bitmask, &hdr); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2661 | encode_nops(&hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2662 | } |
| 2663 | |
| 2664 | /* |
| 2665 | * a PATHCONF request |
| 2666 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2667 | static void nfs4_xdr_enc_pathconf(struct rpc_rqst *req, struct xdr_stream *xdr, |
Christoph Hellwig | fcc8581 | 2017-05-08 10:01:49 +0200 | [diff] [blame] | 2668 | const void *data) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2669 | { |
Christoph Hellwig | fcc8581 | 2017-05-08 10:01:49 +0200 | [diff] [blame] | 2670 | const struct nfs4_pathconf_arg *args = data; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2671 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2672 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2673 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2674 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2675 | encode_compound_hdr(xdr, req, &hdr); |
| 2676 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2677 | encode_putfh(xdr, args->fh, &hdr); |
Trond Myklebust | 37c8876 | 2018-03-20 17:03:08 -0400 | [diff] [blame] | 2678 | encode_getattr(xdr, nfs4_pathconf_bitmap, args->bitmask, |
| 2679 | ARRAY_SIZE(nfs4_pathconf_bitmap), &hdr); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2680 | encode_nops(&hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2681 | } |
| 2682 | |
| 2683 | /* |
| 2684 | * a STATFS request |
| 2685 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2686 | static void nfs4_xdr_enc_statfs(struct rpc_rqst *req, struct xdr_stream *xdr, |
Christoph Hellwig | fcc8581 | 2017-05-08 10:01:49 +0200 | [diff] [blame] | 2687 | const void *data) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2688 | { |
Christoph Hellwig | fcc8581 | 2017-05-08 10:01:49 +0200 | [diff] [blame] | 2689 | const struct nfs4_statfs_arg *args = data; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2690 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2691 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2692 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2693 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2694 | encode_compound_hdr(xdr, req, &hdr); |
| 2695 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2696 | encode_putfh(xdr, args->fh, &hdr); |
Trond Myklebust | 37c8876 | 2018-03-20 17:03:08 -0400 | [diff] [blame] | 2697 | encode_getattr(xdr, nfs4_statfs_bitmap, args->bitmask, |
| 2698 | ARRAY_SIZE(nfs4_statfs_bitmap), &hdr); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2699 | encode_nops(&hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2700 | } |
| 2701 | |
| 2702 | /* |
| 2703 | * GETATTR_BITMAP request |
| 2704 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2705 | static void nfs4_xdr_enc_server_caps(struct rpc_rqst *req, |
| 2706 | struct xdr_stream *xdr, |
Christoph Hellwig | fcc8581 | 2017-05-08 10:01:49 +0200 | [diff] [blame] | 2707 | const void *data) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2708 | { |
Christoph Hellwig | fcc8581 | 2017-05-08 10:01:49 +0200 | [diff] [blame] | 2709 | const struct nfs4_server_caps_arg *args = data; |
Kinglong Mee | 8c61282 | 2015-08-26 21:12:58 +0800 | [diff] [blame] | 2710 | const u32 *bitmask = args->bitmask; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2711 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2712 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2713 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2714 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2715 | encode_compound_hdr(xdr, req, &hdr); |
| 2716 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2717 | encode_putfh(xdr, args->fhandle, &hdr); |
Trond Myklebust | 37c8876 | 2018-03-20 17:03:08 -0400 | [diff] [blame] | 2718 | encode_getattr(xdr, bitmask, NULL, 3, &hdr); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2719 | encode_nops(&hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2720 | } |
| 2721 | |
| 2722 | /* |
| 2723 | * a RENEW request |
| 2724 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2725 | static void nfs4_xdr_enc_renew(struct rpc_rqst *req, struct xdr_stream *xdr, |
Christoph Hellwig | fcc8581 | 2017-05-08 10:01:49 +0200 | [diff] [blame] | 2726 | const void *data) |
| 2727 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2728 | { |
Christoph Hellwig | fcc8581 | 2017-05-08 10:01:49 +0200 | [diff] [blame] | 2729 | const struct nfs_client *clp = data; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2730 | struct compound_hdr hdr = { |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2731 | .nops = 0, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2732 | }; |
| 2733 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2734 | encode_compound_hdr(xdr, req, &hdr); |
Chuck Lever | bb4dae5 | 2012-03-01 17:01:48 -0500 | [diff] [blame] | 2735 | encode_renew(xdr, clp->cl_clientid, &hdr); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2736 | encode_nops(&hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2737 | } |
| 2738 | |
| 2739 | /* |
| 2740 | * a SETCLIENTID request |
| 2741 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2742 | static void nfs4_xdr_enc_setclientid(struct rpc_rqst *req, |
| 2743 | struct xdr_stream *xdr, |
Christoph Hellwig | fcc8581 | 2017-05-08 10:01:49 +0200 | [diff] [blame] | 2744 | const void *data) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2745 | { |
Christoph Hellwig | fcc8581 | 2017-05-08 10:01:49 +0200 | [diff] [blame] | 2746 | const struct nfs4_setclientid *sc = data; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2747 | struct compound_hdr hdr = { |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2748 | .nops = 0, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2749 | }; |
| 2750 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2751 | encode_compound_hdr(xdr, req, &hdr); |
| 2752 | encode_setclientid(xdr, sc, &hdr); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2753 | encode_nops(&hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2754 | } |
| 2755 | |
| 2756 | /* |
| 2757 | * a SETCLIENTID_CONFIRM request |
| 2758 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2759 | static void nfs4_xdr_enc_setclientid_confirm(struct rpc_rqst *req, |
| 2760 | struct xdr_stream *xdr, |
Christoph Hellwig | fcc8581 | 2017-05-08 10:01:49 +0200 | [diff] [blame] | 2761 | const void *data) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2762 | { |
Christoph Hellwig | fcc8581 | 2017-05-08 10:01:49 +0200 | [diff] [blame] | 2763 | const struct nfs4_setclientid_res *arg = data; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2764 | struct compound_hdr hdr = { |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2765 | .nops = 0, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2766 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2767 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2768 | encode_compound_hdr(xdr, req, &hdr); |
| 2769 | encode_setclientid_confirm(xdr, arg, &hdr); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2770 | encode_nops(&hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2771 | } |
| 2772 | |
| 2773 | /* |
| 2774 | * DELEGRETURN request |
| 2775 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2776 | static void nfs4_xdr_enc_delegreturn(struct rpc_rqst *req, |
| 2777 | struct xdr_stream *xdr, |
Christoph Hellwig | fcc8581 | 2017-05-08 10:01:49 +0200 | [diff] [blame] | 2778 | const void *data) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2779 | { |
Christoph Hellwig | fcc8581 | 2017-05-08 10:01:49 +0200 | [diff] [blame] | 2780 | const struct nfs4_delegreturnargs *args = data; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2781 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2782 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2783 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2784 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2785 | encode_compound_hdr(xdr, req, &hdr); |
| 2786 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2787 | encode_putfh(xdr, args->fhandle, &hdr); |
Trond Myklebust | 586f1c3 | 2016-11-15 15:03:33 -0500 | [diff] [blame] | 2788 | if (args->lr_args) |
| 2789 | encode_layoutreturn(xdr, args->lr_args, &hdr); |
Trond Myklebust | 8ac2b422 | 2016-12-19 10:23:10 -0500 | [diff] [blame] | 2790 | if (args->bitmask) |
| 2791 | encode_getfattr(xdr, args->bitmask, &hdr); |
Trond Myklebust | e144cbc | 2012-04-28 16:05:03 -0400 | [diff] [blame] | 2792 | encode_delegreturn(xdr, args->stateid, &hdr); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2793 | encode_nops(&hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2794 | } |
| 2795 | |
| 2796 | /* |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 2797 | * Encode FS_LOCATIONS request |
| 2798 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2799 | static void nfs4_xdr_enc_fs_locations(struct rpc_rqst *req, |
| 2800 | struct xdr_stream *xdr, |
Christoph Hellwig | fcc8581 | 2017-05-08 10:01:49 +0200 | [diff] [blame] | 2801 | const void *data) |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 2802 | { |
Christoph Hellwig | fcc8581 | 2017-05-08 10:01:49 +0200 | [diff] [blame] | 2803 | const struct nfs4_fs_locations_arg *args = data; |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 2804 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2805 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 2806 | }; |
Benny Halevy | 28f5669 | 2009-04-01 09:22:09 -0400 | [diff] [blame] | 2807 | uint32_t replen; |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 2808 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2809 | encode_compound_hdr(xdr, req, &hdr); |
| 2810 | encode_sequence(xdr, &args->seq_args, &hdr); |
Chuck Lever | b03d735 | 2013-10-17 14:12:50 -0400 | [diff] [blame] | 2811 | if (args->migration) { |
| 2812 | encode_putfh(xdr, args->fh, &hdr); |
| 2813 | replen = hdr.replen; |
| 2814 | encode_fs_locations(xdr, args->bitmask, &hdr); |
| 2815 | if (args->renew) |
| 2816 | encode_renew(xdr, args->clientid, &hdr); |
| 2817 | } else { |
| 2818 | encode_putfh(xdr, args->dir_fh, &hdr); |
| 2819 | encode_lookup(xdr, args->name, &hdr); |
| 2820 | replen = hdr.replen; |
| 2821 | encode_fs_locations(xdr, args->bitmask, &hdr); |
| 2822 | } |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 2823 | |
Chuck Lever | cf500ba | 2019-02-11 11:25:20 -0500 | [diff] [blame] | 2824 | rpc_prepare_reply_pages(req, (struct page **)&args->page, 0, |
Trond Myklebust | 9ed5af26 | 2020-11-21 20:46:18 -0500 | [diff] [blame] | 2825 | PAGE_SIZE, replen); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2826 | encode_nops(&hdr); |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 2827 | } |
| 2828 | |
Bryan Schumaker | 5a5ea0d | 2011-03-24 17:12:29 +0000 | [diff] [blame] | 2829 | /* |
| 2830 | * Encode SECINFO request |
| 2831 | */ |
| 2832 | static void nfs4_xdr_enc_secinfo(struct rpc_rqst *req, |
| 2833 | struct xdr_stream *xdr, |
Christoph Hellwig | fcc8581 | 2017-05-08 10:01:49 +0200 | [diff] [blame] | 2834 | const void *data) |
Bryan Schumaker | 5a5ea0d | 2011-03-24 17:12:29 +0000 | [diff] [blame] | 2835 | { |
Christoph Hellwig | fcc8581 | 2017-05-08 10:01:49 +0200 | [diff] [blame] | 2836 | const struct nfs4_secinfo_arg *args = data; |
Bryan Schumaker | 5a5ea0d | 2011-03-24 17:12:29 +0000 | [diff] [blame] | 2837 | struct compound_hdr hdr = { |
| 2838 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
| 2839 | }; |
| 2840 | |
| 2841 | encode_compound_hdr(xdr, req, &hdr); |
| 2842 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2843 | encode_putfh(xdr, args->dir_fh, &hdr); |
| 2844 | encode_secinfo(xdr, args->name, &hdr); |
| 2845 | encode_nops(&hdr); |
| 2846 | } |
| 2847 | |
Chuck Lever | 44c9993 | 2013-10-17 14:13:30 -0400 | [diff] [blame] | 2848 | /* |
| 2849 | * Encode FSID_PRESENT request |
| 2850 | */ |
| 2851 | static void nfs4_xdr_enc_fsid_present(struct rpc_rqst *req, |
| 2852 | struct xdr_stream *xdr, |
Christoph Hellwig | fcc8581 | 2017-05-08 10:01:49 +0200 | [diff] [blame] | 2853 | const void *data) |
Chuck Lever | 44c9993 | 2013-10-17 14:13:30 -0400 | [diff] [blame] | 2854 | { |
Christoph Hellwig | fcc8581 | 2017-05-08 10:01:49 +0200 | [diff] [blame] | 2855 | const struct nfs4_fsid_present_arg *args = data; |
Chuck Lever | 44c9993 | 2013-10-17 14:13:30 -0400 | [diff] [blame] | 2856 | struct compound_hdr hdr = { |
| 2857 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
| 2858 | }; |
| 2859 | |
| 2860 | encode_compound_hdr(xdr, req, &hdr); |
| 2861 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2862 | encode_putfh(xdr, args->fh, &hdr); |
| 2863 | encode_getfh(xdr, &hdr); |
| 2864 | if (args->renew) |
| 2865 | encode_renew(xdr, args->clientid, &hdr); |
| 2866 | encode_nops(&hdr); |
| 2867 | } |
| 2868 | |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 2869 | #if defined(CONFIG_NFS_V4_1) |
| 2870 | /* |
Weston Andros Adamson | 7c44f1ae | 2012-05-24 13:22:50 -0400 | [diff] [blame] | 2871 | * BIND_CONN_TO_SESSION request |
| 2872 | */ |
| 2873 | static void nfs4_xdr_enc_bind_conn_to_session(struct rpc_rqst *req, |
| 2874 | struct xdr_stream *xdr, |
Christoph Hellwig | fcc8581 | 2017-05-08 10:01:49 +0200 | [diff] [blame] | 2875 | const void *data) |
Weston Andros Adamson | 7c44f1ae | 2012-05-24 13:22:50 -0400 | [diff] [blame] | 2876 | { |
Christoph Hellwig | fcc8581 | 2017-05-08 10:01:49 +0200 | [diff] [blame] | 2877 | const struct nfs41_bind_conn_to_session_args *args = data; |
Weston Andros Adamson | 7c44f1ae | 2012-05-24 13:22:50 -0400 | [diff] [blame] | 2878 | struct compound_hdr hdr = { |
Trond Myklebust | 71a097c | 2015-02-18 09:27:18 -0800 | [diff] [blame] | 2879 | .minorversion = args->client->cl_mvops->minor_version, |
Weston Andros Adamson | 7c44f1ae | 2012-05-24 13:22:50 -0400 | [diff] [blame] | 2880 | }; |
| 2881 | |
| 2882 | encode_compound_hdr(xdr, req, &hdr); |
Trond Myklebust | 71a097c | 2015-02-18 09:27:18 -0800 | [diff] [blame] | 2883 | encode_bind_conn_to_session(xdr, args, &hdr); |
Weston Andros Adamson | 7c44f1ae | 2012-05-24 13:22:50 -0400 | [diff] [blame] | 2884 | encode_nops(&hdr); |
| 2885 | } |
| 2886 | |
| 2887 | /* |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 2888 | * EXCHANGE_ID request |
| 2889 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2890 | static void nfs4_xdr_enc_exchange_id(struct rpc_rqst *req, |
| 2891 | struct xdr_stream *xdr, |
Christoph Hellwig | fcc8581 | 2017-05-08 10:01:49 +0200 | [diff] [blame] | 2892 | const void *data) |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 2893 | { |
Christoph Hellwig | fcc8581 | 2017-05-08 10:01:49 +0200 | [diff] [blame] | 2894 | const struct nfs41_exchange_id_args *args = data; |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 2895 | struct compound_hdr hdr = { |
Trond Myklebust | a443234 | 2010-06-16 09:52:27 -0400 | [diff] [blame] | 2896 | .minorversion = args->client->cl_mvops->minor_version, |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 2897 | }; |
| 2898 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2899 | encode_compound_hdr(xdr, req, &hdr); |
| 2900 | encode_exchange_id(xdr, args, &hdr); |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 2901 | encode_nops(&hdr); |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 2902 | } |
Andy Adamson | 2050f0c | 2009-04-01 09:22:30 -0400 | [diff] [blame] | 2903 | |
| 2904 | /* |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 2905 | * a CREATE_SESSION request |
| 2906 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2907 | static void nfs4_xdr_enc_create_session(struct rpc_rqst *req, |
| 2908 | struct xdr_stream *xdr, |
Christoph Hellwig | fcc8581 | 2017-05-08 10:01:49 +0200 | [diff] [blame] | 2909 | const void *data) |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 2910 | { |
Christoph Hellwig | fcc8581 | 2017-05-08 10:01:49 +0200 | [diff] [blame] | 2911 | const struct nfs41_create_session_args *args = data; |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 2912 | struct compound_hdr hdr = { |
Trond Myklebust | a443234 | 2010-06-16 09:52:27 -0400 | [diff] [blame] | 2913 | .minorversion = args->client->cl_mvops->minor_version, |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 2914 | }; |
| 2915 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2916 | encode_compound_hdr(xdr, req, &hdr); |
| 2917 | encode_create_session(xdr, args, &hdr); |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 2918 | encode_nops(&hdr); |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 2919 | } |
| 2920 | |
| 2921 | /* |
Andy Adamson | 0f3e66c | 2009-04-01 09:22:34 -0400 | [diff] [blame] | 2922 | * a DESTROY_SESSION request |
| 2923 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2924 | static void nfs4_xdr_enc_destroy_session(struct rpc_rqst *req, |
| 2925 | struct xdr_stream *xdr, |
Christoph Hellwig | fcc8581 | 2017-05-08 10:01:49 +0200 | [diff] [blame] | 2926 | const void *data) |
Andy Adamson | 0f3e66c | 2009-04-01 09:22:34 -0400 | [diff] [blame] | 2927 | { |
Christoph Hellwig | fcc8581 | 2017-05-08 10:01:49 +0200 | [diff] [blame] | 2928 | const struct nfs4_session *session = data; |
Andy Adamson | 0f3e66c | 2009-04-01 09:22:34 -0400 | [diff] [blame] | 2929 | struct compound_hdr hdr = { |
Trond Myklebust | a443234 | 2010-06-16 09:52:27 -0400 | [diff] [blame] | 2930 | .minorversion = session->clp->cl_mvops->minor_version, |
Andy Adamson | 0f3e66c | 2009-04-01 09:22:34 -0400 | [diff] [blame] | 2931 | }; |
| 2932 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2933 | encode_compound_hdr(xdr, req, &hdr); |
| 2934 | encode_destroy_session(xdr, session, &hdr); |
Andy Adamson | 0f3e66c | 2009-04-01 09:22:34 -0400 | [diff] [blame] | 2935 | encode_nops(&hdr); |
Andy Adamson | 0f3e66c | 2009-04-01 09:22:34 -0400 | [diff] [blame] | 2936 | } |
| 2937 | |
| 2938 | /* |
Trond Myklebust | 6624553 | 2012-05-25 17:18:09 -0400 | [diff] [blame] | 2939 | * a DESTROY_CLIENTID request |
| 2940 | */ |
| 2941 | static void nfs4_xdr_enc_destroy_clientid(struct rpc_rqst *req, |
| 2942 | struct xdr_stream *xdr, |
Christoph Hellwig | fcc8581 | 2017-05-08 10:01:49 +0200 | [diff] [blame] | 2943 | const void *data) |
Trond Myklebust | 6624553 | 2012-05-25 17:18:09 -0400 | [diff] [blame] | 2944 | { |
Christoph Hellwig | fcc8581 | 2017-05-08 10:01:49 +0200 | [diff] [blame] | 2945 | const struct nfs_client *clp = data; |
Trond Myklebust | 6624553 | 2012-05-25 17:18:09 -0400 | [diff] [blame] | 2946 | struct compound_hdr hdr = { |
| 2947 | .minorversion = clp->cl_mvops->minor_version, |
| 2948 | }; |
| 2949 | |
| 2950 | encode_compound_hdr(xdr, req, &hdr); |
| 2951 | encode_destroy_clientid(xdr, clp->cl_clientid, &hdr); |
| 2952 | encode_nops(&hdr); |
| 2953 | } |
| 2954 | |
| 2955 | /* |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 2956 | * a SEQUENCE request |
| 2957 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2958 | static void nfs4_xdr_enc_sequence(struct rpc_rqst *req, struct xdr_stream *xdr, |
Christoph Hellwig | fcc8581 | 2017-05-08 10:01:49 +0200 | [diff] [blame] | 2959 | const void *data) |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 2960 | { |
Christoph Hellwig | fcc8581 | 2017-05-08 10:01:49 +0200 | [diff] [blame] | 2961 | const struct nfs4_sequence_args *args = data; |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 2962 | struct compound_hdr hdr = { |
| 2963 | .minorversion = nfs4_xdr_minorversion(args), |
| 2964 | }; |
| 2965 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2966 | encode_compound_hdr(xdr, req, &hdr); |
| 2967 | encode_sequence(xdr, args, &hdr); |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 2968 | encode_nops(&hdr); |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 2969 | } |
| 2970 | |
Donald Buczek | 0efb01b | 2019-07-07 21:26:08 +0200 | [diff] [blame] | 2971 | #endif |
| 2972 | |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 2973 | /* |
Andy Adamson | 2050f0c | 2009-04-01 09:22:30 -0400 | [diff] [blame] | 2974 | * a GET_LEASE_TIME request |
| 2975 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2976 | static void nfs4_xdr_enc_get_lease_time(struct rpc_rqst *req, |
| 2977 | struct xdr_stream *xdr, |
Christoph Hellwig | fcc8581 | 2017-05-08 10:01:49 +0200 | [diff] [blame] | 2978 | const void *data) |
Andy Adamson | 2050f0c | 2009-04-01 09:22:30 -0400 | [diff] [blame] | 2979 | { |
Christoph Hellwig | fcc8581 | 2017-05-08 10:01:49 +0200 | [diff] [blame] | 2980 | const struct nfs4_get_lease_time_args *args = data; |
Andy Adamson | 2050f0c | 2009-04-01 09:22:30 -0400 | [diff] [blame] | 2981 | struct compound_hdr hdr = { |
| 2982 | .minorversion = nfs4_xdr_minorversion(&args->la_seq_args), |
| 2983 | }; |
Fred Isaman | dae100c | 2011-07-30 20:52:37 -0400 | [diff] [blame] | 2984 | const u32 lease_bitmap[3] = { FATTR4_WORD0_LEASE_TIME }; |
Andy Adamson | 2050f0c | 2009-04-01 09:22:30 -0400 | [diff] [blame] | 2985 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2986 | encode_compound_hdr(xdr, req, &hdr); |
| 2987 | encode_sequence(xdr, &args->la_seq_args, &hdr); |
| 2988 | encode_putrootfh(xdr, &hdr); |
| 2989 | encode_fsinfo(xdr, lease_bitmap, &hdr); |
Andy Adamson | 2050f0c | 2009-04-01 09:22:30 -0400 | [diff] [blame] | 2990 | encode_nops(&hdr); |
Andy Adamson | 2050f0c | 2009-04-01 09:22:30 -0400 | [diff] [blame] | 2991 | } |
Ricardo Labiaga | 18019753 | 2009-12-05 16:08:40 -0500 | [diff] [blame] | 2992 | |
Donald Buczek | 0efb01b | 2019-07-07 21:26:08 +0200 | [diff] [blame] | 2993 | #ifdef CONFIG_NFS_V4_1 |
| 2994 | |
Ricardo Labiaga | 18019753 | 2009-12-05 16:08:40 -0500 | [diff] [blame] | 2995 | /* |
| 2996 | * a RECLAIM_COMPLETE request |
| 2997 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2998 | static void nfs4_xdr_enc_reclaim_complete(struct rpc_rqst *req, |
| 2999 | struct xdr_stream *xdr, |
Christoph Hellwig | fcc8581 | 2017-05-08 10:01:49 +0200 | [diff] [blame] | 3000 | const void *data) |
Ricardo Labiaga | 18019753 | 2009-12-05 16:08:40 -0500 | [diff] [blame] | 3001 | { |
Christoph Hellwig | fcc8581 | 2017-05-08 10:01:49 +0200 | [diff] [blame] | 3002 | const struct nfs41_reclaim_complete_args *args = data; |
Ricardo Labiaga | 18019753 | 2009-12-05 16:08:40 -0500 | [diff] [blame] | 3003 | struct compound_hdr hdr = { |
| 3004 | .minorversion = nfs4_xdr_minorversion(&args->seq_args) |
| 3005 | }; |
| 3006 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 3007 | encode_compound_hdr(xdr, req, &hdr); |
| 3008 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 3009 | encode_reclaim_complete(xdr, args, &hdr); |
Ricardo Labiaga | 18019753 | 2009-12-05 16:08:40 -0500 | [diff] [blame] | 3010 | encode_nops(&hdr); |
Ricardo Labiaga | 18019753 | 2009-12-05 16:08:40 -0500 | [diff] [blame] | 3011 | } |
| 3012 | |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 3013 | /* |
| 3014 | * Encode GETDEVICEINFO request |
| 3015 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 3016 | static void nfs4_xdr_enc_getdeviceinfo(struct rpc_rqst *req, |
| 3017 | struct xdr_stream *xdr, |
Christoph Hellwig | fcc8581 | 2017-05-08 10:01:49 +0200 | [diff] [blame] | 3018 | const void *data) |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 3019 | { |
Christoph Hellwig | fcc8581 | 2017-05-08 10:01:49 +0200 | [diff] [blame] | 3020 | const struct nfs4_getdeviceinfo_args *args = data; |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 3021 | struct compound_hdr hdr = { |
| 3022 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
| 3023 | }; |
Trond Myklebust | 046e5cc | 2020-11-13 21:42:16 -0500 | [diff] [blame] | 3024 | uint32_t replen; |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 3025 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 3026 | encode_compound_hdr(xdr, req, &hdr); |
| 3027 | encode_sequence(xdr, &args->seq_args, &hdr); |
Trond Myklebust | 046e5cc | 2020-11-13 21:42:16 -0500 | [diff] [blame] | 3028 | |
Trond Myklebust | 9ed5af26 | 2020-11-21 20:46:18 -0500 | [diff] [blame] | 3029 | replen = hdr.replen + op_decode_hdr_maxsz + 2; |
Trond Myklebust | 046e5cc | 2020-11-13 21:42:16 -0500 | [diff] [blame] | 3030 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 3031 | encode_getdeviceinfo(xdr, args, &hdr); |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 3032 | |
Trond Myklebust | 046e5cc | 2020-11-13 21:42:16 -0500 | [diff] [blame] | 3033 | /* set up reply kvec. device_addr4 opaque data is read into the |
| 3034 | * pages */ |
Chuck Lever | cf500ba | 2019-02-11 11:25:20 -0500 | [diff] [blame] | 3035 | rpc_prepare_reply_pages(req, args->pdev->pages, args->pdev->pgbase, |
Trond Myklebust | 9ed5af26 | 2020-11-21 20:46:18 -0500 | [diff] [blame] | 3036 | args->pdev->pglen, replen); |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 3037 | encode_nops(&hdr); |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 3038 | } |
| 3039 | |
| 3040 | /* |
| 3041 | * Encode LAYOUTGET request |
| 3042 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 3043 | static void nfs4_xdr_enc_layoutget(struct rpc_rqst *req, |
| 3044 | struct xdr_stream *xdr, |
Christoph Hellwig | fcc8581 | 2017-05-08 10:01:49 +0200 | [diff] [blame] | 3045 | const void *data) |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 3046 | { |
Christoph Hellwig | fcc8581 | 2017-05-08 10:01:49 +0200 | [diff] [blame] | 3047 | const struct nfs4_layoutget_args *args = data; |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 3048 | struct compound_hdr hdr = { |
| 3049 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
| 3050 | }; |
| 3051 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 3052 | encode_compound_hdr(xdr, req, &hdr); |
| 3053 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 3054 | encode_putfh(xdr, NFS_FH(args->inode), &hdr); |
| 3055 | encode_layoutget(xdr, args, &hdr); |
Weston Andros Adamson | 35124a0 | 2011-03-24 16:48:21 -0400 | [diff] [blame] | 3056 | |
Chuck Lever | cf500ba | 2019-02-11 11:25:20 -0500 | [diff] [blame] | 3057 | rpc_prepare_reply_pages(req, args->layout.pages, 0, |
Trond Myklebust | 9ed5af26 | 2020-11-21 20:46:18 -0500 | [diff] [blame] | 3058 | args->layout.pglen, hdr.replen - pagepad_maxsz); |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 3059 | encode_nops(&hdr); |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 3060 | } |
Andy Adamson | 863a3c6 | 2011-03-23 13:27:54 +0000 | [diff] [blame] | 3061 | |
| 3062 | /* |
| 3063 | * Encode LAYOUTCOMMIT request |
| 3064 | */ |
Benny Halevy | cbe8260 | 2011-05-22 19:52:37 +0300 | [diff] [blame] | 3065 | static void nfs4_xdr_enc_layoutcommit(struct rpc_rqst *req, |
| 3066 | struct xdr_stream *xdr, |
Christoph Hellwig | fcc8581 | 2017-05-08 10:01:49 +0200 | [diff] [blame] | 3067 | const void *priv) |
Andy Adamson | 863a3c6 | 2011-03-23 13:27:54 +0000 | [diff] [blame] | 3068 | { |
Christoph Hellwig | fcc8581 | 2017-05-08 10:01:49 +0200 | [diff] [blame] | 3069 | const struct nfs4_layoutcommit_args *args = priv; |
Benny Halevy | ac7db72 | 2011-05-22 19:53:48 +0300 | [diff] [blame] | 3070 | struct nfs4_layoutcommit_data *data = |
| 3071 | container_of(args, struct nfs4_layoutcommit_data, args); |
Andy Adamson | 863a3c6 | 2011-03-23 13:27:54 +0000 | [diff] [blame] | 3072 | struct compound_hdr hdr = { |
| 3073 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
| 3074 | }; |
| 3075 | |
| 3076 | encode_compound_hdr(xdr, req, &hdr); |
| 3077 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 3078 | encode_putfh(xdr, NFS_FH(args->inode), &hdr); |
Benny Halevy | ac7db72 | 2011-05-22 19:53:48 +0300 | [diff] [blame] | 3079 | encode_layoutcommit(xdr, data->args.inode, args, &hdr); |
Andy Adamson | 863a3c6 | 2011-03-23 13:27:54 +0000 | [diff] [blame] | 3080 | encode_getfattr(xdr, args->bitmask, &hdr); |
| 3081 | encode_nops(&hdr); |
Benny Halevy | cbe8260 | 2011-05-22 19:52:37 +0300 | [diff] [blame] | 3082 | } |
| 3083 | |
| 3084 | /* |
| 3085 | * Encode LAYOUTRETURN request |
| 3086 | */ |
| 3087 | static void nfs4_xdr_enc_layoutreturn(struct rpc_rqst *req, |
| 3088 | struct xdr_stream *xdr, |
Christoph Hellwig | fcc8581 | 2017-05-08 10:01:49 +0200 | [diff] [blame] | 3089 | const void *data) |
Benny Halevy | cbe8260 | 2011-05-22 19:52:37 +0300 | [diff] [blame] | 3090 | { |
Christoph Hellwig | fcc8581 | 2017-05-08 10:01:49 +0200 | [diff] [blame] | 3091 | const struct nfs4_layoutreturn_args *args = data; |
Benny Halevy | cbe8260 | 2011-05-22 19:52:37 +0300 | [diff] [blame] | 3092 | struct compound_hdr hdr = { |
| 3093 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
| 3094 | }; |
| 3095 | |
| 3096 | encode_compound_hdr(xdr, req, &hdr); |
| 3097 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 3098 | encode_putfh(xdr, NFS_FH(args->inode), &hdr); |
| 3099 | encode_layoutreturn(xdr, args, &hdr); |
| 3100 | encode_nops(&hdr); |
Andy Adamson | 863a3c6 | 2011-03-23 13:27:54 +0000 | [diff] [blame] | 3101 | } |
Bryan Schumaker | fca78d6 | 2011-06-02 14:59:07 -0400 | [diff] [blame] | 3102 | |
| 3103 | /* |
| 3104 | * Encode SECINFO_NO_NAME request |
| 3105 | */ |
Christoph Hellwig | fcc8581 | 2017-05-08 10:01:49 +0200 | [diff] [blame] | 3106 | static void nfs4_xdr_enc_secinfo_no_name(struct rpc_rqst *req, |
Bryan Schumaker | fca78d6 | 2011-06-02 14:59:07 -0400 | [diff] [blame] | 3107 | struct xdr_stream *xdr, |
Christoph Hellwig | fcc8581 | 2017-05-08 10:01:49 +0200 | [diff] [blame] | 3108 | const void *data) |
Bryan Schumaker | fca78d6 | 2011-06-02 14:59:07 -0400 | [diff] [blame] | 3109 | { |
Christoph Hellwig | fcc8581 | 2017-05-08 10:01:49 +0200 | [diff] [blame] | 3110 | const struct nfs41_secinfo_no_name_args *args = data; |
Bryan Schumaker | fca78d6 | 2011-06-02 14:59:07 -0400 | [diff] [blame] | 3111 | struct compound_hdr hdr = { |
| 3112 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
| 3113 | }; |
| 3114 | |
| 3115 | encode_compound_hdr(xdr, req, &hdr); |
| 3116 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 3117 | encode_putrootfh(xdr, &hdr); |
| 3118 | encode_secinfo_no_name(xdr, args, &hdr); |
| 3119 | encode_nops(&hdr); |
Bryan Schumaker | fca78d6 | 2011-06-02 14:59:07 -0400 | [diff] [blame] | 3120 | } |
Bryan Schumaker | 7d97479 | 2011-06-02 14:59:08 -0400 | [diff] [blame] | 3121 | |
| 3122 | /* |
| 3123 | * Encode TEST_STATEID request |
| 3124 | */ |
| 3125 | static void nfs4_xdr_enc_test_stateid(struct rpc_rqst *req, |
| 3126 | struct xdr_stream *xdr, |
Christoph Hellwig | fcc8581 | 2017-05-08 10:01:49 +0200 | [diff] [blame] | 3127 | const void *data) |
Bryan Schumaker | 7d97479 | 2011-06-02 14:59:08 -0400 | [diff] [blame] | 3128 | { |
Christoph Hellwig | fcc8581 | 2017-05-08 10:01:49 +0200 | [diff] [blame] | 3129 | const struct nfs41_test_stateid_args *args = data; |
Bryan Schumaker | 7d97479 | 2011-06-02 14:59:08 -0400 | [diff] [blame] | 3130 | struct compound_hdr hdr = { |
| 3131 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
| 3132 | }; |
| 3133 | |
| 3134 | encode_compound_hdr(xdr, req, &hdr); |
| 3135 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 3136 | encode_test_stateid(xdr, args, &hdr); |
| 3137 | encode_nops(&hdr); |
| 3138 | } |
Bryan Schumaker | 9aeda35 | 2011-06-02 14:59:09 -0400 | [diff] [blame] | 3139 | |
| 3140 | /* |
| 3141 | * Encode FREE_STATEID request |
| 3142 | */ |
| 3143 | static void nfs4_xdr_enc_free_stateid(struct rpc_rqst *req, |
| 3144 | struct xdr_stream *xdr, |
Christoph Hellwig | fcc8581 | 2017-05-08 10:01:49 +0200 | [diff] [blame] | 3145 | const void *data) |
Bryan Schumaker | 9aeda35 | 2011-06-02 14:59:09 -0400 | [diff] [blame] | 3146 | { |
Christoph Hellwig | fcc8581 | 2017-05-08 10:01:49 +0200 | [diff] [blame] | 3147 | const struct nfs41_free_stateid_args *args = data; |
Bryan Schumaker | 9aeda35 | 2011-06-02 14:59:09 -0400 | [diff] [blame] | 3148 | struct compound_hdr hdr = { |
| 3149 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
| 3150 | }; |
| 3151 | |
| 3152 | encode_compound_hdr(xdr, req, &hdr); |
| 3153 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 3154 | encode_free_stateid(xdr, args, &hdr); |
| 3155 | encode_nops(&hdr); |
| 3156 | } |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 3157 | #endif /* CONFIG_NFS_V4_1 */ |
| 3158 | |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 3159 | 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] | 3160 | { |
Trond Myklebust | 6da59ce | 2017-02-19 16:08:27 -0500 | [diff] [blame] | 3161 | ssize_t ret = xdr_stream_decode_opaque_inline(xdr, (void **)string, |
| 3162 | NFS4_OPAQUE_LIMIT); |
Chuck Lever | eb72f48 | 2019-02-11 11:24:21 -0500 | [diff] [blame] | 3163 | if (unlikely(ret < 0)) |
Trond Myklebust | 6da59ce | 2017-02-19 16:08:27 -0500 | [diff] [blame] | 3164 | return -EIO; |
Trond Myklebust | 6da59ce | 2017-02-19 16:08:27 -0500 | [diff] [blame] | 3165 | *len = ret; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3166 | return 0; |
| 3167 | } |
| 3168 | |
| 3169 | static int decode_compound_hdr(struct xdr_stream *xdr, struct compound_hdr *hdr) |
| 3170 | { |
Trond Myklebust | 6659db4 | 2021-11-04 17:18:01 -0400 | [diff] [blame] | 3171 | ssize_t ret; |
| 3172 | void *ptr; |
| 3173 | u32 tmp; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3174 | |
Trond Myklebust | 6659db4 | 2021-11-04 17:18:01 -0400 | [diff] [blame] | 3175 | if (xdr_stream_decode_u32(xdr, &tmp) < 0) |
Chuck Lever | eb72f48 | 2019-02-11 11:24:21 -0500 | [diff] [blame] | 3176 | return -EIO; |
Trond Myklebust | 6659db4 | 2021-11-04 17:18:01 -0400 | [diff] [blame] | 3177 | hdr->status = tmp; |
Andy Adamson | 6c0195a | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 3178 | |
Trond Myklebust | 6659db4 | 2021-11-04 17:18:01 -0400 | [diff] [blame] | 3179 | ret = xdr_stream_decode_opaque_inline(xdr, &ptr, NFS4_OPAQUE_LIMIT); |
| 3180 | if (ret < 0) |
Chuck Lever | eb72f48 | 2019-02-11 11:24:21 -0500 | [diff] [blame] | 3181 | return -EIO; |
Trond Myklebust | 6659db4 | 2021-11-04 17:18:01 -0400 | [diff] [blame] | 3182 | hdr->taglen = ret; |
| 3183 | hdr->tag = ptr; |
| 3184 | |
| 3185 | if (xdr_stream_decode_u32(xdr, &tmp) < 0) |
| 3186 | return -EIO; |
| 3187 | hdr->nops = tmp; |
Benny Halevy | aadf615 | 2008-12-23 16:06:13 -0500 | [diff] [blame] | 3188 | if (unlikely(hdr->nops < 1)) |
| 3189 | return nfs4_stat_to_errno(hdr->status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3190 | return 0; |
| 3191 | } |
| 3192 | |
Trond Myklebust | c7848f6 | 2013-12-04 17:39:23 -0500 | [diff] [blame] | 3193 | static bool __decode_op_hdr(struct xdr_stream *xdr, enum nfs_opnum4 expected, |
| 3194 | int *nfs_retval) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3195 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3196 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3197 | uint32_t opnum; |
| 3198 | int32_t nfserr; |
| 3199 | |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3200 | p = xdr_inline_decode(xdr, 8); |
| 3201 | if (unlikely(!p)) |
| 3202 | goto out_overflow; |
Benny Halevy | 6f723f7 | 2009-08-14 17:19:37 +0300 | [diff] [blame] | 3203 | opnum = be32_to_cpup(p++); |
Trond Myklebust | c7848f6 | 2013-12-04 17:39:23 -0500 | [diff] [blame] | 3204 | if (unlikely(opnum != expected)) |
| 3205 | goto out_bad_operation; |
Chuck Lever | f23f658 | 2019-02-11 11:24:26 -0500 | [diff] [blame] | 3206 | if (unlikely(*p != cpu_to_be32(NFS_OK))) |
| 3207 | goto out_status; |
| 3208 | *nfs_retval = 0; |
| 3209 | return true; |
| 3210 | out_status: |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3211 | nfserr = be32_to_cpup(p); |
Chuck Lever | 62a92ba | 2019-06-19 10:34:09 -0400 | [diff] [blame] | 3212 | trace_nfs4_xdr_status(xdr, opnum, nfserr); |
Chuck Lever | f23f658 | 2019-02-11 11:24:26 -0500 | [diff] [blame] | 3213 | *nfs_retval = nfs4_stat_to_errno(nfserr); |
Trond Myklebust | c7848f6 | 2013-12-04 17:39:23 -0500 | [diff] [blame] | 3214 | return true; |
| 3215 | out_bad_operation: |
Trond Myklebust | da934ae | 2021-04-01 14:38:13 -0400 | [diff] [blame] | 3216 | trace_nfs4_xdr_bad_operation(xdr, opnum, expected); |
Trond Myklebust | c7848f6 | 2013-12-04 17:39:23 -0500 | [diff] [blame] | 3217 | *nfs_retval = -EREMOTEIO; |
| 3218 | return false; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3219 | out_overflow: |
Trond Myklebust | c7848f6 | 2013-12-04 17:39:23 -0500 | [diff] [blame] | 3220 | *nfs_retval = -EIO; |
| 3221 | return false; |
| 3222 | } |
| 3223 | |
| 3224 | static int decode_op_hdr(struct xdr_stream *xdr, enum nfs_opnum4 expected) |
| 3225 | { |
| 3226 | int retval; |
| 3227 | |
| 3228 | __decode_op_hdr(xdr, expected, &retval); |
| 3229 | return retval; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3230 | } |
| 3231 | |
| 3232 | /* Dummy routine */ |
Trond Myklebust | 1bbe60f | 2017-02-19 16:08:30 -0500 | [diff] [blame] | 3233 | static int decode_ace(struct xdr_stream *xdr, void *ace) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3234 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3235 | __be32 *p; |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 3236 | unsigned int strlen; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3237 | char *str; |
| 3238 | |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3239 | p = xdr_inline_decode(xdr, 12); |
Chuck Lever | eb72f48 | 2019-02-11 11:24:21 -0500 | [diff] [blame] | 3240 | if (unlikely(!p)) |
| 3241 | return -EIO; |
| 3242 | return decode_opaque_inline(xdr, &strlen, &str); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3243 | } |
| 3244 | |
Trond Myklebust | 37c8876 | 2018-03-20 17:03:08 -0400 | [diff] [blame] | 3245 | static ssize_t |
| 3246 | decode_bitmap4(struct xdr_stream *xdr, uint32_t *bitmap, size_t sz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3247 | { |
Trond Myklebust | 37c8876 | 2018-03-20 17:03:08 -0400 | [diff] [blame] | 3248 | ssize_t ret; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3249 | |
Trond Myklebust | 37c8876 | 2018-03-20 17:03:08 -0400 | [diff] [blame] | 3250 | ret = xdr_stream_decode_uint32_array(xdr, bitmap, sz); |
| 3251 | if (likely(ret >= 0)) |
| 3252 | return ret; |
Chuck Lever | eb72f48 | 2019-02-11 11:24:21 -0500 | [diff] [blame] | 3253 | if (ret != -EMSGSIZE) |
| 3254 | return -EIO; |
| 3255 | return sz; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3256 | } |
| 3257 | |
Trond Myklebust | 37c8876 | 2018-03-20 17:03:08 -0400 | [diff] [blame] | 3258 | static int decode_attr_bitmap(struct xdr_stream *xdr, uint32_t *bitmap) |
| 3259 | { |
| 3260 | ssize_t ret; |
| 3261 | ret = decode_bitmap4(xdr, bitmap, 3); |
| 3262 | return ret < 0 ? ret : 0; |
| 3263 | } |
| 3264 | |
Trond Myklebust | 256e48b | 2012-06-21 11:18:13 -0400 | [diff] [blame] | 3265 | 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] | 3266 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3267 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3268 | |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3269 | p = xdr_inline_decode(xdr, 4); |
| 3270 | if (unlikely(!p)) |
Chuck Lever | eb72f48 | 2019-02-11 11:24:21 -0500 | [diff] [blame] | 3271 | return -EIO; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3272 | *attrlen = be32_to_cpup(p); |
Trond Myklebust | 256e48b | 2012-06-21 11:18:13 -0400 | [diff] [blame] | 3273 | *savep = xdr_stream_pos(xdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3274 | return 0; |
| 3275 | } |
| 3276 | |
| 3277 | static int decode_attr_supported(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t *bitmask) |
| 3278 | { |
| 3279 | if (likely(bitmap[0] & FATTR4_WORD0_SUPPORTED_ATTRS)) { |
Roman Borisov | 3388bff | 2010-10-13 16:54:51 +0400 | [diff] [blame] | 3280 | int ret; |
| 3281 | ret = decode_attr_bitmap(xdr, bitmask); |
| 3282 | if (unlikely(ret < 0)) |
| 3283 | return ret; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3284 | bitmap[0] &= ~FATTR4_WORD0_SUPPORTED_ATTRS; |
| 3285 | } else |
Fred Isaman | dae100c | 2011-07-30 20:52:37 -0400 | [diff] [blame] | 3286 | bitmask[0] = bitmask[1] = bitmask[2] = 0; |
| 3287 | dprintk("%s: bitmask=%08x:%08x:%08x\n", __func__, |
| 3288 | bitmask[0], bitmask[1], bitmask[2]); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3289 | return 0; |
| 3290 | } |
| 3291 | |
| 3292 | static int decode_attr_type(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t *type) |
| 3293 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3294 | __be32 *p; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3295 | int ret = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3296 | |
| 3297 | *type = 0; |
| 3298 | if (unlikely(bitmap[0] & (FATTR4_WORD0_TYPE - 1U))) |
| 3299 | return -EIO; |
| 3300 | if (likely(bitmap[0] & FATTR4_WORD0_TYPE)) { |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3301 | p = xdr_inline_decode(xdr, 4); |
| 3302 | if (unlikely(!p)) |
Chuck Lever | eb72f48 | 2019-02-11 11:24:21 -0500 | [diff] [blame] | 3303 | return -EIO; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3304 | *type = be32_to_cpup(p); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3305 | if (*type < NF4REG || *type > NF4NAMEDATTR) { |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3306 | dprintk("%s: bad type %d\n", __func__, *type); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3307 | return -EIO; |
| 3308 | } |
| 3309 | bitmap[0] &= ~FATTR4_WORD0_TYPE; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3310 | ret = NFS_ATTR_FATTR_TYPE; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3311 | } |
Trond Myklebust | bca7947 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 3312 | dprintk("%s: type=0%o\n", __func__, nfs_type2fmt[*type]); |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3313 | return ret; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3314 | } |
| 3315 | |
Chuck Lever | 264e635 | 2012-03-01 17:02:05 -0500 | [diff] [blame] | 3316 | static int decode_attr_fh_expire_type(struct xdr_stream *xdr, |
| 3317 | uint32_t *bitmap, uint32_t *type) |
| 3318 | { |
| 3319 | __be32 *p; |
| 3320 | |
| 3321 | *type = 0; |
| 3322 | if (unlikely(bitmap[0] & (FATTR4_WORD0_FH_EXPIRE_TYPE - 1U))) |
| 3323 | return -EIO; |
| 3324 | if (likely(bitmap[0] & FATTR4_WORD0_FH_EXPIRE_TYPE)) { |
| 3325 | p = xdr_inline_decode(xdr, 4); |
| 3326 | if (unlikely(!p)) |
Chuck Lever | eb72f48 | 2019-02-11 11:24:21 -0500 | [diff] [blame] | 3327 | return -EIO; |
Chuck Lever | 264e635 | 2012-03-01 17:02:05 -0500 | [diff] [blame] | 3328 | *type = be32_to_cpup(p); |
| 3329 | bitmap[0] &= ~FATTR4_WORD0_FH_EXPIRE_TYPE; |
| 3330 | } |
| 3331 | dprintk("%s: expire type=0x%x\n", __func__, *type); |
| 3332 | return 0; |
Chuck Lever | 264e635 | 2012-03-01 17:02:05 -0500 | [diff] [blame] | 3333 | } |
| 3334 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3335 | static int decode_attr_change(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *change) |
| 3336 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3337 | __be32 *p; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3338 | int ret = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3339 | |
| 3340 | *change = 0; |
| 3341 | if (unlikely(bitmap[0] & (FATTR4_WORD0_CHANGE - 1U))) |
| 3342 | return -EIO; |
| 3343 | if (likely(bitmap[0] & FATTR4_WORD0_CHANGE)) { |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3344 | p = xdr_inline_decode(xdr, 8); |
| 3345 | if (unlikely(!p)) |
Chuck Lever | eb72f48 | 2019-02-11 11:24:21 -0500 | [diff] [blame] | 3346 | return -EIO; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3347 | xdr_decode_hyper(p, change); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3348 | bitmap[0] &= ~FATTR4_WORD0_CHANGE; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3349 | ret = NFS_ATTR_FATTR_CHANGE; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3350 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3351 | dprintk("%s: change attribute=%Lu\n", __func__, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3352 | (unsigned long long)*change); |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3353 | return ret; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3354 | } |
| 3355 | |
| 3356 | static int decode_attr_size(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *size) |
| 3357 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3358 | __be32 *p; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3359 | int ret = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3360 | |
| 3361 | *size = 0; |
| 3362 | if (unlikely(bitmap[0] & (FATTR4_WORD0_SIZE - 1U))) |
| 3363 | return -EIO; |
| 3364 | if (likely(bitmap[0] & FATTR4_WORD0_SIZE)) { |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3365 | p = xdr_inline_decode(xdr, 8); |
| 3366 | if (unlikely(!p)) |
Chuck Lever | eb72f48 | 2019-02-11 11:24:21 -0500 | [diff] [blame] | 3367 | return -EIO; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3368 | xdr_decode_hyper(p, size); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3369 | bitmap[0] &= ~FATTR4_WORD0_SIZE; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3370 | ret = NFS_ATTR_FATTR_SIZE; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3371 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3372 | dprintk("%s: file size=%Lu\n", __func__, (unsigned long long)*size); |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3373 | return ret; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3374 | } |
| 3375 | |
| 3376 | static int decode_attr_link_support(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t *res) |
| 3377 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3378 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3379 | |
| 3380 | *res = 0; |
| 3381 | if (unlikely(bitmap[0] & (FATTR4_WORD0_LINK_SUPPORT - 1U))) |
| 3382 | return -EIO; |
| 3383 | if (likely(bitmap[0] & FATTR4_WORD0_LINK_SUPPORT)) { |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3384 | p = xdr_inline_decode(xdr, 4); |
| 3385 | if (unlikely(!p)) |
Chuck Lever | eb72f48 | 2019-02-11 11:24:21 -0500 | [diff] [blame] | 3386 | return -EIO; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3387 | *res = be32_to_cpup(p); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3388 | bitmap[0] &= ~FATTR4_WORD0_LINK_SUPPORT; |
| 3389 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3390 | dprintk("%s: link support=%s\n", __func__, *res == 0 ? "false" : "true"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3391 | return 0; |
| 3392 | } |
| 3393 | |
| 3394 | static int decode_attr_symlink_support(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t *res) |
| 3395 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3396 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3397 | |
| 3398 | *res = 0; |
| 3399 | if (unlikely(bitmap[0] & (FATTR4_WORD0_SYMLINK_SUPPORT - 1U))) |
| 3400 | return -EIO; |
| 3401 | if (likely(bitmap[0] & FATTR4_WORD0_SYMLINK_SUPPORT)) { |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3402 | p = xdr_inline_decode(xdr, 4); |
| 3403 | if (unlikely(!p)) |
Chuck Lever | eb72f48 | 2019-02-11 11:24:21 -0500 | [diff] [blame] | 3404 | return -EIO; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3405 | *res = be32_to_cpup(p); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3406 | bitmap[0] &= ~FATTR4_WORD0_SYMLINK_SUPPORT; |
| 3407 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3408 | dprintk("%s: symlink support=%s\n", __func__, *res == 0 ? "false" : "true"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3409 | return 0; |
| 3410 | } |
| 3411 | |
Trond Myklebust | 8b4bdcf | 2006-06-09 09:34:19 -0400 | [diff] [blame] | 3412 | 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] | 3413 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3414 | __be32 *p; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3415 | int ret = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3416 | |
| 3417 | fsid->major = 0; |
| 3418 | fsid->minor = 0; |
| 3419 | if (unlikely(bitmap[0] & (FATTR4_WORD0_FSID - 1U))) |
| 3420 | return -EIO; |
| 3421 | if (likely(bitmap[0] & FATTR4_WORD0_FSID)) { |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3422 | p = xdr_inline_decode(xdr, 16); |
| 3423 | if (unlikely(!p)) |
Chuck Lever | eb72f48 | 2019-02-11 11:24:21 -0500 | [diff] [blame] | 3424 | return -EIO; |
Benny Halevy | 3ceb4db | 2009-08-14 17:19:41 +0300 | [diff] [blame] | 3425 | p = xdr_decode_hyper(p, &fsid->major); |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3426 | xdr_decode_hyper(p, &fsid->minor); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3427 | bitmap[0] &= ~FATTR4_WORD0_FSID; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3428 | ret = NFS_ATTR_FATTR_FSID; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3429 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3430 | dprintk("%s: fsid=(0x%Lx/0x%Lx)\n", __func__, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3431 | (unsigned long long)fsid->major, |
| 3432 | (unsigned long long)fsid->minor); |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3433 | return ret; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3434 | } |
| 3435 | |
| 3436 | static int decode_attr_lease_time(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t *res) |
| 3437 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3438 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3439 | |
| 3440 | *res = 60; |
| 3441 | if (unlikely(bitmap[0] & (FATTR4_WORD0_LEASE_TIME - 1U))) |
| 3442 | return -EIO; |
| 3443 | if (likely(bitmap[0] & FATTR4_WORD0_LEASE_TIME)) { |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3444 | p = xdr_inline_decode(xdr, 4); |
| 3445 | if (unlikely(!p)) |
Chuck Lever | eb72f48 | 2019-02-11 11:24:21 -0500 | [diff] [blame] | 3446 | return -EIO; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3447 | *res = be32_to_cpup(p); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3448 | bitmap[0] &= ~FATTR4_WORD0_LEASE_TIME; |
| 3449 | } |
Donald Buczek | 2eaf426 | 2019-07-07 21:26:07 +0200 | [diff] [blame] | 3450 | dprintk("%s: lease time=%u\n", __func__, (unsigned int)*res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3451 | return 0; |
| 3452 | } |
| 3453 | |
Trond Myklebust | ee7b75f | 2011-06-16 13:15:41 -0400 | [diff] [blame] | 3454 | 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] | 3455 | { |
| 3456 | __be32 *p; |
| 3457 | |
| 3458 | if (unlikely(bitmap[0] & (FATTR4_WORD0_RDATTR_ERROR - 1U))) |
| 3459 | return -EIO; |
| 3460 | if (likely(bitmap[0] & FATTR4_WORD0_RDATTR_ERROR)) { |
| 3461 | p = xdr_inline_decode(xdr, 4); |
| 3462 | if (unlikely(!p)) |
Chuck Lever | eb72f48 | 2019-02-11 11:24:21 -0500 | [diff] [blame] | 3463 | return -EIO; |
Bryan Schumaker | ae42c70 | 2010-10-21 16:33:17 -0400 | [diff] [blame] | 3464 | bitmap[0] &= ~FATTR4_WORD0_RDATTR_ERROR; |
Trond Myklebust | ee7b75f | 2011-06-16 13:15:41 -0400 | [diff] [blame] | 3465 | *res = -be32_to_cpup(p); |
Bryan Schumaker | ae42c70 | 2010-10-21 16:33:17 -0400 | [diff] [blame] | 3466 | } |
| 3467 | return 0; |
Bryan Schumaker | ae42c70 | 2010-10-21 16:33:17 -0400 | [diff] [blame] | 3468 | } |
| 3469 | |
Kinglong Mee | 8c61282 | 2015-08-26 21:12:58 +0800 | [diff] [blame] | 3470 | static int decode_attr_exclcreat_supported(struct xdr_stream *xdr, |
| 3471 | uint32_t *bitmap, uint32_t *bitmask) |
| 3472 | { |
| 3473 | if (likely(bitmap[2] & FATTR4_WORD2_SUPPATTR_EXCLCREAT)) { |
| 3474 | int ret; |
| 3475 | ret = decode_attr_bitmap(xdr, bitmask); |
| 3476 | if (unlikely(ret < 0)) |
| 3477 | return ret; |
| 3478 | bitmap[2] &= ~FATTR4_WORD2_SUPPATTR_EXCLCREAT; |
| 3479 | } else |
| 3480 | bitmask[0] = bitmask[1] = bitmask[2] = 0; |
| 3481 | dprintk("%s: bitmask=%08x:%08x:%08x\n", __func__, |
| 3482 | bitmask[0], bitmask[1], bitmask[2]); |
| 3483 | return 0; |
| 3484 | } |
| 3485 | |
Bryan Schumaker | ae42c70 | 2010-10-21 16:33:17 -0400 | [diff] [blame] | 3486 | static int decode_attr_filehandle(struct xdr_stream *xdr, uint32_t *bitmap, struct nfs_fh *fh) |
| 3487 | { |
| 3488 | __be32 *p; |
Frank Sorenson | 86bbd74 | 2018-10-23 10:34:57 -0500 | [diff] [blame] | 3489 | u32 len; |
Bryan Schumaker | ae42c70 | 2010-10-21 16:33:17 -0400 | [diff] [blame] | 3490 | |
Trond Myklebust | 7ad0735 | 2010-10-23 15:34:20 -0400 | [diff] [blame] | 3491 | if (fh != NULL) |
| 3492 | memset(fh, 0, sizeof(*fh)); |
Bryan Schumaker | ae42c70 | 2010-10-21 16:33:17 -0400 | [diff] [blame] | 3493 | |
| 3494 | if (unlikely(bitmap[0] & (FATTR4_WORD0_FILEHANDLE - 1U))) |
| 3495 | return -EIO; |
| 3496 | if (likely(bitmap[0] & FATTR4_WORD0_FILEHANDLE)) { |
| 3497 | p = xdr_inline_decode(xdr, 4); |
| 3498 | if (unlikely(!p)) |
Chuck Lever | eb72f48 | 2019-02-11 11:24:21 -0500 | [diff] [blame] | 3499 | return -EIO; |
Bryan Schumaker | ae42c70 | 2010-10-21 16:33:17 -0400 | [diff] [blame] | 3500 | len = be32_to_cpup(p); |
Trond Myklebust | eb3d58c | 2021-04-01 14:03:26 -0400 | [diff] [blame] | 3501 | if (len > NFS4_FHSIZE || len == 0) { |
| 3502 | trace_nfs4_xdr_bad_filehandle(xdr, OP_READDIR, |
| 3503 | NFS4ERR_BADHANDLE); |
| 3504 | return -EREMOTEIO; |
| 3505 | } |
Bryan Schumaker | ae42c70 | 2010-10-21 16:33:17 -0400 | [diff] [blame] | 3506 | p = xdr_inline_decode(xdr, len); |
| 3507 | if (unlikely(!p)) |
Chuck Lever | eb72f48 | 2019-02-11 11:24:21 -0500 | [diff] [blame] | 3508 | return -EIO; |
Trond Myklebust | 7ad0735 | 2010-10-23 15:34:20 -0400 | [diff] [blame] | 3509 | if (fh != NULL) { |
| 3510 | memcpy(fh->data, p, len); |
| 3511 | fh->size = len; |
| 3512 | } |
Bryan Schumaker | ae42c70 | 2010-10-21 16:33:17 -0400 | [diff] [blame] | 3513 | bitmap[0] &= ~FATTR4_WORD0_FILEHANDLE; |
| 3514 | } |
| 3515 | return 0; |
Bryan Schumaker | ae42c70 | 2010-10-21 16:33:17 -0400 | [diff] [blame] | 3516 | } |
| 3517 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3518 | static int decode_attr_aclsupport(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t *res) |
| 3519 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3520 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3521 | |
Malahal Naineni | a1800ac | 2014-01-27 15:31:09 -0600 | [diff] [blame] | 3522 | *res = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3523 | if (unlikely(bitmap[0] & (FATTR4_WORD0_ACLSUPPORT - 1U))) |
| 3524 | return -EIO; |
| 3525 | if (likely(bitmap[0] & FATTR4_WORD0_ACLSUPPORT)) { |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3526 | p = xdr_inline_decode(xdr, 4); |
| 3527 | if (unlikely(!p)) |
Chuck Lever | eb72f48 | 2019-02-11 11:24:21 -0500 | [diff] [blame] | 3528 | return -EIO; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3529 | *res = be32_to_cpup(p); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3530 | bitmap[0] &= ~FATTR4_WORD0_ACLSUPPORT; |
| 3531 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3532 | dprintk("%s: ACLs supported=%u\n", __func__, (unsigned int)*res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3533 | return 0; |
| 3534 | } |
| 3535 | |
Trond Myklebust | 1ab5be4 | 2021-12-17 15:36:54 -0500 | [diff] [blame] | 3536 | static int decode_attr_case_insensitive(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t *res) |
| 3537 | { |
| 3538 | __be32 *p; |
| 3539 | |
| 3540 | *res = 0; |
| 3541 | if (unlikely(bitmap[0] & (FATTR4_WORD0_CASE_INSENSITIVE - 1U))) |
| 3542 | return -EIO; |
| 3543 | if (likely(bitmap[0] & FATTR4_WORD0_CASE_INSENSITIVE)) { |
| 3544 | p = xdr_inline_decode(xdr, 4); |
| 3545 | if (unlikely(!p)) |
| 3546 | return -EIO; |
| 3547 | *res = be32_to_cpup(p); |
| 3548 | bitmap[0] &= ~FATTR4_WORD0_CASE_INSENSITIVE; |
| 3549 | } |
| 3550 | dprintk("%s: case_insensitive=%s\n", __func__, *res == 0 ? "false" : "true"); |
| 3551 | return 0; |
| 3552 | } |
| 3553 | |
| 3554 | static int decode_attr_case_preserving(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t *res) |
| 3555 | { |
| 3556 | __be32 *p; |
| 3557 | |
| 3558 | *res = 0; |
| 3559 | if (unlikely(bitmap[0] & (FATTR4_WORD0_CASE_PRESERVING - 1U))) |
| 3560 | return -EIO; |
| 3561 | if (likely(bitmap[0] & FATTR4_WORD0_CASE_PRESERVING)) { |
| 3562 | p = xdr_inline_decode(xdr, 4); |
| 3563 | if (unlikely(!p)) |
| 3564 | return -EIO; |
| 3565 | *res = be32_to_cpup(p); |
| 3566 | bitmap[0] &= ~FATTR4_WORD0_CASE_PRESERVING; |
| 3567 | } |
| 3568 | dprintk("%s: case_preserving=%s\n", __func__, *res == 0 ? "false" : "true"); |
| 3569 | return 0; |
| 3570 | } |
| 3571 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3572 | static int decode_attr_fileid(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *fileid) |
| 3573 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3574 | __be32 *p; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3575 | int ret = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3576 | |
| 3577 | *fileid = 0; |
| 3578 | if (unlikely(bitmap[0] & (FATTR4_WORD0_FILEID - 1U))) |
| 3579 | return -EIO; |
| 3580 | if (likely(bitmap[0] & FATTR4_WORD0_FILEID)) { |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3581 | p = xdr_inline_decode(xdr, 8); |
| 3582 | if (unlikely(!p)) |
Chuck Lever | eb72f48 | 2019-02-11 11:24:21 -0500 | [diff] [blame] | 3583 | return -EIO; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3584 | xdr_decode_hyper(p, fileid); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3585 | bitmap[0] &= ~FATTR4_WORD0_FILEID; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3586 | ret = NFS_ATTR_FATTR_FILEID; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3587 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3588 | dprintk("%s: fileid=%Lu\n", __func__, (unsigned long long)*fileid); |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3589 | return ret; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3590 | } |
| 3591 | |
Manoj Naik | 99baf62 | 2006-06-09 09:34:24 -0400 | [diff] [blame] | 3592 | static int decode_attr_mounted_on_fileid(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *fileid) |
| 3593 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3594 | __be32 *p; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3595 | int ret = 0; |
Manoj Naik | 99baf62 | 2006-06-09 09:34:24 -0400 | [diff] [blame] | 3596 | |
| 3597 | *fileid = 0; |
| 3598 | if (unlikely(bitmap[1] & (FATTR4_WORD1_MOUNTED_ON_FILEID - 1U))) |
| 3599 | return -EIO; |
| 3600 | if (likely(bitmap[1] & FATTR4_WORD1_MOUNTED_ON_FILEID)) { |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3601 | p = xdr_inline_decode(xdr, 8); |
| 3602 | if (unlikely(!p)) |
Chuck Lever | eb72f48 | 2019-02-11 11:24:21 -0500 | [diff] [blame] | 3603 | return -EIO; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3604 | xdr_decode_hyper(p, fileid); |
Manoj Naik | 99baf62 | 2006-06-09 09:34:24 -0400 | [diff] [blame] | 3605 | bitmap[1] &= ~FATTR4_WORD1_MOUNTED_ON_FILEID; |
Trond Myklebust | 28331a4 | 2011-04-27 13:47:52 -0400 | [diff] [blame] | 3606 | ret = NFS_ATTR_FATTR_MOUNTED_ON_FILEID; |
Manoj Naik | 99baf62 | 2006-06-09 09:34:24 -0400 | [diff] [blame] | 3607 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3608 | dprintk("%s: fileid=%Lu\n", __func__, (unsigned long long)*fileid); |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3609 | return ret; |
Manoj Naik | 99baf62 | 2006-06-09 09:34:24 -0400 | [diff] [blame] | 3610 | } |
| 3611 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3612 | static int decode_attr_files_avail(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *res) |
| 3613 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3614 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3615 | int status = 0; |
| 3616 | |
| 3617 | *res = 0; |
| 3618 | if (unlikely(bitmap[0] & (FATTR4_WORD0_FILES_AVAIL - 1U))) |
| 3619 | return -EIO; |
| 3620 | if (likely(bitmap[0] & FATTR4_WORD0_FILES_AVAIL)) { |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3621 | p = xdr_inline_decode(xdr, 8); |
| 3622 | if (unlikely(!p)) |
Chuck Lever | eb72f48 | 2019-02-11 11:24:21 -0500 | [diff] [blame] | 3623 | return -EIO; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3624 | xdr_decode_hyper(p, res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3625 | bitmap[0] &= ~FATTR4_WORD0_FILES_AVAIL; |
| 3626 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3627 | dprintk("%s: files avail=%Lu\n", __func__, (unsigned long long)*res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3628 | return status; |
| 3629 | } |
| 3630 | |
| 3631 | static int decode_attr_files_free(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *res) |
| 3632 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3633 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3634 | int status = 0; |
| 3635 | |
| 3636 | *res = 0; |
| 3637 | if (unlikely(bitmap[0] & (FATTR4_WORD0_FILES_FREE - 1U))) |
| 3638 | return -EIO; |
| 3639 | if (likely(bitmap[0] & FATTR4_WORD0_FILES_FREE)) { |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3640 | p = xdr_inline_decode(xdr, 8); |
| 3641 | if (unlikely(!p)) |
Chuck Lever | eb72f48 | 2019-02-11 11:24:21 -0500 | [diff] [blame] | 3642 | return -EIO; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3643 | xdr_decode_hyper(p, res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3644 | bitmap[0] &= ~FATTR4_WORD0_FILES_FREE; |
| 3645 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3646 | dprintk("%s: files free=%Lu\n", __func__, (unsigned long long)*res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3647 | return status; |
| 3648 | } |
| 3649 | |
| 3650 | static int decode_attr_files_total(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *res) |
| 3651 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3652 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3653 | int status = 0; |
| 3654 | |
| 3655 | *res = 0; |
| 3656 | if (unlikely(bitmap[0] & (FATTR4_WORD0_FILES_TOTAL - 1U))) |
| 3657 | return -EIO; |
| 3658 | if (likely(bitmap[0] & FATTR4_WORD0_FILES_TOTAL)) { |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3659 | p = xdr_inline_decode(xdr, 8); |
| 3660 | if (unlikely(!p)) |
Chuck Lever | eb72f48 | 2019-02-11 11:24:21 -0500 | [diff] [blame] | 3661 | return -EIO; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3662 | xdr_decode_hyper(p, res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3663 | bitmap[0] &= ~FATTR4_WORD0_FILES_TOTAL; |
| 3664 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3665 | dprintk("%s: files total=%Lu\n", __func__, (unsigned long long)*res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3666 | return status; |
| 3667 | } |
| 3668 | |
Manoj Naik | 7aaa0b3 | 2006-06-09 09:34:23 -0400 | [diff] [blame] | 3669 | static int decode_pathname(struct xdr_stream *xdr, struct nfs4_pathname *path) |
| 3670 | { |
Chuck Lever | 464ad6b | 2007-10-26 13:32:08 -0400 | [diff] [blame] | 3671 | u32 n; |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3672 | __be32 *p; |
Manoj Naik | 7aaa0b3 | 2006-06-09 09:34:23 -0400 | [diff] [blame] | 3673 | int status = 0; |
| 3674 | |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3675 | p = xdr_inline_decode(xdr, 4); |
| 3676 | if (unlikely(!p)) |
Chuck Lever | eb72f48 | 2019-02-11 11:24:21 -0500 | [diff] [blame] | 3677 | return -EIO; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3678 | n = be32_to_cpup(p); |
Andy Adamson | 33a43f2 | 2006-06-09 09:34:30 -0400 | [diff] [blame] | 3679 | if (n == 0) |
| 3680 | goto root_path; |
Chuck Lever | 02a2976 | 2012-03-01 17:00:31 -0500 | [diff] [blame] | 3681 | dprintk("pathname4: "); |
Trond Myklebust | 809b426 | 2013-03-27 11:54:45 -0400 | [diff] [blame] | 3682 | if (n > NFS4_PATHNAME_MAXCOMPONENTS) { |
| 3683 | dprintk("cannot parse %d components in path\n", n); |
| 3684 | goto out_eio; |
| 3685 | } |
| 3686 | for (path->ncomponents = 0; path->ncomponents < n; path->ncomponents++) { |
Manoj Naik | 7aaa0b3 | 2006-06-09 09:34:23 -0400 | [diff] [blame] | 3687 | struct nfs4_string *component = &path->components[path->ncomponents]; |
| 3688 | status = decode_opaque_inline(xdr, &component->len, &component->data); |
| 3689 | if (unlikely(status != 0)) |
| 3690 | goto out_eio; |
Trond Myklebust | 95a13f7 | 2012-03-14 21:55:01 -0400 | [diff] [blame] | 3691 | ifdebug (XDR) |
Chuck Lever | 02a2976 | 2012-03-01 17:00:31 -0500 | [diff] [blame] | 3692 | pr_cont("%s%.*s ", |
| 3693 | (path->ncomponents != n ? "/ " : ""), |
| 3694 | component->len, component->data); |
Manoj Naik | 7aaa0b3 | 2006-06-09 09:34:23 -0400 | [diff] [blame] | 3695 | } |
| 3696 | out: |
Manoj Naik | 7aaa0b3 | 2006-06-09 09:34:23 -0400 | [diff] [blame] | 3697 | return status; |
Andy Adamson | 33a43f2 | 2006-06-09 09:34:30 -0400 | [diff] [blame] | 3698 | root_path: |
| 3699 | /* a root pathname is sent as a zero component4 */ |
| 3700 | path->ncomponents = 1; |
| 3701 | path->components[0].len=0; |
| 3702 | path->components[0].data=NULL; |
Chuck Lever | 02a2976 | 2012-03-01 17:00:31 -0500 | [diff] [blame] | 3703 | dprintk("pathname4: /\n"); |
Andy Adamson | 33a43f2 | 2006-06-09 09:34:30 -0400 | [diff] [blame] | 3704 | goto out; |
Manoj Naik | 7aaa0b3 | 2006-06-09 09:34:23 -0400 | [diff] [blame] | 3705 | out_eio: |
| 3706 | dprintk(" status %d", status); |
| 3707 | status = -EIO; |
| 3708 | goto out; |
| 3709 | } |
| 3710 | |
| 3711 | 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] | 3712 | { |
| 3713 | int n; |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3714 | __be32 *p; |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 3715 | int status = -EIO; |
| 3716 | |
| 3717 | if (unlikely(bitmap[0] & (FATTR4_WORD0_FS_LOCATIONS -1U))) |
| 3718 | goto out; |
| 3719 | status = 0; |
| 3720 | if (unlikely(!(bitmap[0] & FATTR4_WORD0_FS_LOCATIONS))) |
| 3721 | goto out; |
Kinglong Mee | f54423a | 2015-11-18 10:39:26 +0800 | [diff] [blame] | 3722 | bitmap[0] &= ~FATTR4_WORD0_FS_LOCATIONS; |
Trond Myklebust | 8b7e3f4 | 2012-01-30 15:43:56 -0500 | [diff] [blame] | 3723 | status = -EIO; |
| 3724 | /* Ignore borken servers that return unrequested attrs */ |
| 3725 | if (unlikely(res == NULL)) |
| 3726 | goto out; |
Chuck Lever | 02a2976 | 2012-03-01 17:00:31 -0500 | [diff] [blame] | 3727 | dprintk("%s: fsroot:\n", __func__); |
Manoj Naik | 7aaa0b3 | 2006-06-09 09:34:23 -0400 | [diff] [blame] | 3728 | status = decode_pathname(xdr, &res->fs_path); |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 3729 | if (unlikely(status != 0)) |
| 3730 | goto out; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3731 | p = xdr_inline_decode(xdr, 4); |
| 3732 | if (unlikely(!p)) |
Chuck Lever | eb72f48 | 2019-02-11 11:24:21 -0500 | [diff] [blame] | 3733 | goto out_eio; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3734 | n = be32_to_cpup(p); |
Trond Myklebust | 809b426 | 2013-03-27 11:54:45 -0400 | [diff] [blame] | 3735 | for (res->nlocations = 0; res->nlocations < n; res->nlocations++) { |
Chuck Lever | 464ad6b | 2007-10-26 13:32:08 -0400 | [diff] [blame] | 3736 | u32 m; |
Trond Myklebust | 809b426 | 2013-03-27 11:54:45 -0400 | [diff] [blame] | 3737 | struct nfs4_fs_location *loc; |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 3738 | |
Trond Myklebust | 809b426 | 2013-03-27 11:54:45 -0400 | [diff] [blame] | 3739 | if (res->nlocations == NFS4_FS_LOCATIONS_MAXENTRIES) |
| 3740 | break; |
| 3741 | loc = &res->locations[res->nlocations]; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3742 | p = xdr_inline_decode(xdr, 4); |
| 3743 | if (unlikely(!p)) |
Chuck Lever | eb72f48 | 2019-02-11 11:24:21 -0500 | [diff] [blame] | 3744 | goto out_eio; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3745 | m = be32_to_cpup(p); |
Manoj Naik | 7aaa0b3 | 2006-06-09 09:34:23 -0400 | [diff] [blame] | 3746 | |
Chuck Lever | 02a2976 | 2012-03-01 17:00:31 -0500 | [diff] [blame] | 3747 | dprintk("%s: servers:\n", __func__); |
Trond Myklebust | 809b426 | 2013-03-27 11:54:45 -0400 | [diff] [blame] | 3748 | for (loc->nservers = 0; loc->nservers < m; loc->nservers++) { |
| 3749 | struct nfs4_string *server; |
| 3750 | |
| 3751 | if (loc->nservers == NFS4_FS_LOCATION_MAXSERVERS) { |
Chuck Lever | 464ad6b | 2007-10-26 13:32:08 -0400 | [diff] [blame] | 3752 | unsigned int i; |
| 3753 | dprintk("%s: using first %u of %u servers " |
| 3754 | "returned for location %u\n", |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3755 | __func__, |
Chuck Lever | 464ad6b | 2007-10-26 13:32:08 -0400 | [diff] [blame] | 3756 | NFS4_FS_LOCATION_MAXSERVERS, |
| 3757 | m, res->nlocations); |
Manoj Naik | 7aaa0b3 | 2006-06-09 09:34:23 -0400 | [diff] [blame] | 3758 | for (i = loc->nservers; i < m; i++) { |
Trond Myklebust | 2e42c3e | 2007-05-14 17:20:41 -0400 | [diff] [blame] | 3759 | unsigned int len; |
Manoj Naik | 7aaa0b3 | 2006-06-09 09:34:23 -0400 | [diff] [blame] | 3760 | char *data; |
| 3761 | status = decode_opaque_inline(xdr, &len, &data); |
| 3762 | if (unlikely(status != 0)) |
| 3763 | goto out_eio; |
| 3764 | } |
Trond Myklebust | 809b426 | 2013-03-27 11:54:45 -0400 | [diff] [blame] | 3765 | break; |
Manoj Naik | 7aaa0b3 | 2006-06-09 09:34:23 -0400 | [diff] [blame] | 3766 | } |
Trond Myklebust | 809b426 | 2013-03-27 11:54:45 -0400 | [diff] [blame] | 3767 | server = &loc->servers[loc->nservers]; |
| 3768 | status = decode_opaque_inline(xdr, &server->len, &server->data); |
| 3769 | if (unlikely(status != 0)) |
| 3770 | goto out_eio; |
| 3771 | dprintk("%s ", server->data); |
Manoj Naik | 7aaa0b3 | 2006-06-09 09:34:23 -0400 | [diff] [blame] | 3772 | } |
| 3773 | status = decode_pathname(xdr, &loc->rootpath); |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 3774 | if (unlikely(status != 0)) |
| 3775 | goto out_eio; |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 3776 | } |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3777 | if (res->nlocations != 0) |
Chuck Lever | 81934dd | 2012-03-01 17:01:57 -0500 | [diff] [blame] | 3778 | status = NFS_ATTR_FATTR_V4_LOCATIONS; |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 3779 | out: |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3780 | dprintk("%s: fs_locations done, error = %d\n", __func__, status); |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 3781 | return status; |
| 3782 | out_eio: |
| 3783 | status = -EIO; |
| 3784 | goto out; |
| 3785 | } |
| 3786 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3787 | static int decode_attr_maxfilesize(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *res) |
| 3788 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3789 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3790 | int status = 0; |
| 3791 | |
| 3792 | *res = 0; |
| 3793 | if (unlikely(bitmap[0] & (FATTR4_WORD0_MAXFILESIZE - 1U))) |
| 3794 | return -EIO; |
| 3795 | if (likely(bitmap[0] & FATTR4_WORD0_MAXFILESIZE)) { |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3796 | p = xdr_inline_decode(xdr, 8); |
| 3797 | if (unlikely(!p)) |
Chuck Lever | eb72f48 | 2019-02-11 11:24:21 -0500 | [diff] [blame] | 3798 | return -EIO; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3799 | xdr_decode_hyper(p, res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3800 | bitmap[0] &= ~FATTR4_WORD0_MAXFILESIZE; |
| 3801 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3802 | dprintk("%s: maxfilesize=%Lu\n", __func__, (unsigned long long)*res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3803 | return status; |
| 3804 | } |
| 3805 | |
| 3806 | static int decode_attr_maxlink(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t *maxlink) |
| 3807 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3808 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3809 | int status = 0; |
| 3810 | |
| 3811 | *maxlink = 1; |
| 3812 | if (unlikely(bitmap[0] & (FATTR4_WORD0_MAXLINK - 1U))) |
| 3813 | return -EIO; |
| 3814 | if (likely(bitmap[0] & FATTR4_WORD0_MAXLINK)) { |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3815 | p = xdr_inline_decode(xdr, 4); |
| 3816 | if (unlikely(!p)) |
Chuck Lever | eb72f48 | 2019-02-11 11:24:21 -0500 | [diff] [blame] | 3817 | return -EIO; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3818 | *maxlink = be32_to_cpup(p); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3819 | bitmap[0] &= ~FATTR4_WORD0_MAXLINK; |
| 3820 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3821 | dprintk("%s: maxlink=%u\n", __func__, *maxlink); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3822 | return status; |
| 3823 | } |
| 3824 | |
| 3825 | static int decode_attr_maxname(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t *maxname) |
| 3826 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3827 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3828 | int status = 0; |
| 3829 | |
| 3830 | *maxname = 1024; |
| 3831 | if (unlikely(bitmap[0] & (FATTR4_WORD0_MAXNAME - 1U))) |
| 3832 | return -EIO; |
| 3833 | if (likely(bitmap[0] & FATTR4_WORD0_MAXNAME)) { |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3834 | p = xdr_inline_decode(xdr, 4); |
| 3835 | if (unlikely(!p)) |
Chuck Lever | eb72f48 | 2019-02-11 11:24:21 -0500 | [diff] [blame] | 3836 | return -EIO; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3837 | *maxname = be32_to_cpup(p); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3838 | bitmap[0] &= ~FATTR4_WORD0_MAXNAME; |
| 3839 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3840 | dprintk("%s: maxname=%u\n", __func__, *maxname); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3841 | return status; |
| 3842 | } |
| 3843 | |
| 3844 | static int decode_attr_maxread(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t *res) |
| 3845 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3846 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3847 | int status = 0; |
| 3848 | |
| 3849 | *res = 1024; |
| 3850 | if (unlikely(bitmap[0] & (FATTR4_WORD0_MAXREAD - 1U))) |
| 3851 | return -EIO; |
| 3852 | if (likely(bitmap[0] & FATTR4_WORD0_MAXREAD)) { |
| 3853 | uint64_t maxread; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3854 | p = xdr_inline_decode(xdr, 8); |
| 3855 | if (unlikely(!p)) |
Chuck Lever | eb72f48 | 2019-02-11 11:24:21 -0500 | [diff] [blame] | 3856 | return -EIO; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3857 | xdr_decode_hyper(p, &maxread); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3858 | if (maxread > 0x7FFFFFFF) |
| 3859 | maxread = 0x7FFFFFFF; |
| 3860 | *res = (uint32_t)maxread; |
| 3861 | bitmap[0] &= ~FATTR4_WORD0_MAXREAD; |
| 3862 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3863 | dprintk("%s: maxread=%lu\n", __func__, (unsigned long)*res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3864 | return status; |
| 3865 | } |
| 3866 | |
| 3867 | static int decode_attr_maxwrite(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t *res) |
| 3868 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3869 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3870 | int status = 0; |
| 3871 | |
| 3872 | *res = 1024; |
| 3873 | if (unlikely(bitmap[0] & (FATTR4_WORD0_MAXWRITE - 1U))) |
| 3874 | return -EIO; |
| 3875 | if (likely(bitmap[0] & FATTR4_WORD0_MAXWRITE)) { |
| 3876 | uint64_t maxwrite; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3877 | p = xdr_inline_decode(xdr, 8); |
| 3878 | if (unlikely(!p)) |
Chuck Lever | eb72f48 | 2019-02-11 11:24:21 -0500 | [diff] [blame] | 3879 | return -EIO; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3880 | xdr_decode_hyper(p, &maxwrite); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3881 | if (maxwrite > 0x7FFFFFFF) |
| 3882 | maxwrite = 0x7FFFFFFF; |
| 3883 | *res = (uint32_t)maxwrite; |
| 3884 | bitmap[0] &= ~FATTR4_WORD0_MAXWRITE; |
| 3885 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3886 | dprintk("%s: maxwrite=%lu\n", __func__, (unsigned long)*res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3887 | return status; |
| 3888 | } |
| 3889 | |
Trond Myklebust | bca7947 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 3890 | 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] | 3891 | { |
Trond Myklebust | bca7947 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 3892 | uint32_t tmp; |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3893 | __be32 *p; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3894 | int ret = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3895 | |
| 3896 | *mode = 0; |
| 3897 | if (unlikely(bitmap[1] & (FATTR4_WORD1_MODE - 1U))) |
| 3898 | return -EIO; |
| 3899 | if (likely(bitmap[1] & FATTR4_WORD1_MODE)) { |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3900 | p = xdr_inline_decode(xdr, 4); |
| 3901 | if (unlikely(!p)) |
Chuck Lever | eb72f48 | 2019-02-11 11:24:21 -0500 | [diff] [blame] | 3902 | return -EIO; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3903 | tmp = be32_to_cpup(p); |
Trond Myklebust | bca7947 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 3904 | *mode = tmp & ~S_IFMT; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3905 | bitmap[1] &= ~FATTR4_WORD1_MODE; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3906 | ret = NFS_ATTR_FATTR_MODE; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3907 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3908 | dprintk("%s: file mode=0%o\n", __func__, (unsigned int)*mode); |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3909 | return ret; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3910 | } |
| 3911 | |
| 3912 | static int decode_attr_nlink(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t *nlink) |
| 3913 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3914 | __be32 *p; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3915 | int ret = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3916 | |
| 3917 | *nlink = 1; |
| 3918 | if (unlikely(bitmap[1] & (FATTR4_WORD1_NUMLINKS - 1U))) |
| 3919 | return -EIO; |
| 3920 | if (likely(bitmap[1] & FATTR4_WORD1_NUMLINKS)) { |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3921 | p = xdr_inline_decode(xdr, 4); |
| 3922 | if (unlikely(!p)) |
Chuck Lever | eb72f48 | 2019-02-11 11:24:21 -0500 | [diff] [blame] | 3923 | return -EIO; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3924 | *nlink = be32_to_cpup(p); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3925 | bitmap[1] &= ~FATTR4_WORD1_NUMLINKS; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3926 | ret = NFS_ATTR_FATTR_NLINK; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3927 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3928 | dprintk("%s: nlink=%u\n", __func__, (unsigned int)*nlink); |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3929 | return ret; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3930 | } |
| 3931 | |
Trond Myklebust | 686a816 | 2017-02-19 16:08:32 -0500 | [diff] [blame] | 3932 | static ssize_t decode_nfs4_string(struct xdr_stream *xdr, |
| 3933 | struct nfs4_string *name, gfp_t gfp_flags) |
| 3934 | { |
| 3935 | ssize_t ret; |
| 3936 | |
| 3937 | ret = xdr_stream_decode_string_dup(xdr, &name->data, |
| 3938 | XDR_MAX_NETOBJ, gfp_flags); |
| 3939 | name->len = 0; |
| 3940 | if (ret > 0) |
| 3941 | name->len = ret; |
| 3942 | return ret; |
| 3943 | } |
| 3944 | |
Trond Myklebust | 80e52ac | 2009-08-09 15:06:19 -0400 | [diff] [blame] | 3945 | 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] | 3946 | const struct nfs_server *server, kuid_t *uid, |
Trond Myklebust | 6926afd1 | 2012-01-07 13:22:46 -0500 | [diff] [blame] | 3947 | struct nfs4_string *owner_name) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3948 | { |
Trond Myklebust | 686a816 | 2017-02-19 16:08:32 -0500 | [diff] [blame] | 3949 | ssize_t len; |
| 3950 | char *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3951 | |
Eric W. Biederman | e578207 | 2013-02-01 14:22:02 -0800 | [diff] [blame] | 3952 | *uid = make_kuid(&init_user_ns, -2); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3953 | if (unlikely(bitmap[1] & (FATTR4_WORD1_OWNER - 1U))) |
| 3954 | return -EIO; |
Trond Myklebust | 686a816 | 2017-02-19 16:08:32 -0500 | [diff] [blame] | 3955 | if (!(bitmap[1] & FATTR4_WORD1_OWNER)) |
| 3956 | return 0; |
| 3957 | bitmap[1] &= ~FATTR4_WORD1_OWNER; |
| 3958 | |
| 3959 | if (owner_name != NULL) { |
Trond Myklebust | e8d8aa4 | 2018-03-20 17:03:07 -0400 | [diff] [blame] | 3960 | len = decode_nfs4_string(xdr, owner_name, GFP_NOIO); |
Trond Myklebust | 686a816 | 2017-02-19 16:08:32 -0500 | [diff] [blame] | 3961 | if (len <= 0) |
| 3962 | goto out; |
| 3963 | dprintk("%s: name=%s\n", __func__, owner_name->data); |
| 3964 | return NFS_ATTR_FATTR_OWNER_NAME; |
| 3965 | } else { |
| 3966 | len = xdr_stream_decode_opaque_inline(xdr, (void **)&p, |
| 3967 | XDR_MAX_NETOBJ); |
| 3968 | if (len <= 0 || nfs_map_name_to_uid(server, p, len, uid) != 0) |
| 3969 | goto out; |
| 3970 | dprintk("%s: uid=%d\n", __func__, (int)from_kuid(&init_user_ns, *uid)); |
| 3971 | return NFS_ATTR_FATTR_OWNER; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3972 | } |
Trond Myklebust | 686a816 | 2017-02-19 16:08:32 -0500 | [diff] [blame] | 3973 | out: |
Chuck Lever | eb72f48 | 2019-02-11 11:24:21 -0500 | [diff] [blame] | 3974 | if (len == -EBADMSG) |
| 3975 | return -EIO; |
| 3976 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3977 | } |
| 3978 | |
Trond Myklebust | 80e52ac | 2009-08-09 15:06:19 -0400 | [diff] [blame] | 3979 | 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] | 3980 | const struct nfs_server *server, kgid_t *gid, |
Trond Myklebust | 6926afd1 | 2012-01-07 13:22:46 -0500 | [diff] [blame] | 3981 | struct nfs4_string *group_name) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3982 | { |
Trond Myklebust | 686a816 | 2017-02-19 16:08:32 -0500 | [diff] [blame] | 3983 | ssize_t len; |
| 3984 | char *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3985 | |
Eric W. Biederman | e578207 | 2013-02-01 14:22:02 -0800 | [diff] [blame] | 3986 | *gid = make_kgid(&init_user_ns, -2); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3987 | if (unlikely(bitmap[1] & (FATTR4_WORD1_OWNER_GROUP - 1U))) |
| 3988 | return -EIO; |
Trond Myklebust | 686a816 | 2017-02-19 16:08:32 -0500 | [diff] [blame] | 3989 | if (!(bitmap[1] & FATTR4_WORD1_OWNER_GROUP)) |
| 3990 | return 0; |
| 3991 | bitmap[1] &= ~FATTR4_WORD1_OWNER_GROUP; |
| 3992 | |
| 3993 | if (group_name != NULL) { |
Trond Myklebust | e8d8aa4 | 2018-03-20 17:03:07 -0400 | [diff] [blame] | 3994 | len = decode_nfs4_string(xdr, group_name, GFP_NOIO); |
Trond Myklebust | 686a816 | 2017-02-19 16:08:32 -0500 | [diff] [blame] | 3995 | if (len <= 0) |
| 3996 | goto out; |
| 3997 | dprintk("%s: name=%s\n", __func__, group_name->data); |
Kinglong Mee | 6f1f622 | 2017-03-06 17:49:42 +0800 | [diff] [blame] | 3998 | return NFS_ATTR_FATTR_GROUP_NAME; |
Trond Myklebust | 686a816 | 2017-02-19 16:08:32 -0500 | [diff] [blame] | 3999 | } else { |
| 4000 | len = xdr_stream_decode_opaque_inline(xdr, (void **)&p, |
| 4001 | XDR_MAX_NETOBJ); |
| 4002 | if (len <= 0 || nfs_map_group_to_gid(server, p, len, gid) != 0) |
| 4003 | goto out; |
| 4004 | dprintk("%s: gid=%d\n", __func__, (int)from_kgid(&init_user_ns, *gid)); |
| 4005 | return NFS_ATTR_FATTR_GROUP; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4006 | } |
Trond Myklebust | 686a816 | 2017-02-19 16:08:32 -0500 | [diff] [blame] | 4007 | out: |
Chuck Lever | eb72f48 | 2019-02-11 11:24:21 -0500 | [diff] [blame] | 4008 | if (len == -EBADMSG) |
| 4009 | return -EIO; |
| 4010 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4011 | } |
| 4012 | |
| 4013 | static int decode_attr_rdev(struct xdr_stream *xdr, uint32_t *bitmap, dev_t *rdev) |
| 4014 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 4015 | uint32_t major = 0, minor = 0; |
| 4016 | __be32 *p; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 4017 | int ret = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4018 | |
| 4019 | *rdev = MKDEV(0,0); |
| 4020 | if (unlikely(bitmap[1] & (FATTR4_WORD1_RAWDEV - 1U))) |
| 4021 | return -EIO; |
| 4022 | if (likely(bitmap[1] & FATTR4_WORD1_RAWDEV)) { |
| 4023 | dev_t tmp; |
| 4024 | |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 4025 | p = xdr_inline_decode(xdr, 8); |
| 4026 | if (unlikely(!p)) |
Chuck Lever | eb72f48 | 2019-02-11 11:24:21 -0500 | [diff] [blame] | 4027 | return -EIO; |
Benny Halevy | 6f723f7 | 2009-08-14 17:19:37 +0300 | [diff] [blame] | 4028 | major = be32_to_cpup(p++); |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 4029 | minor = be32_to_cpup(p); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4030 | tmp = MKDEV(major, minor); |
| 4031 | if (MAJOR(tmp) == major && MINOR(tmp) == minor) |
| 4032 | *rdev = tmp; |
| 4033 | bitmap[1] &= ~ FATTR4_WORD1_RAWDEV; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 4034 | ret = NFS_ATTR_FATTR_RDEV; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4035 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 4036 | dprintk("%s: rdev=(0x%x:0x%x)\n", __func__, major, minor); |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 4037 | return ret; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4038 | } |
| 4039 | |
| 4040 | static int decode_attr_space_avail(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *res) |
| 4041 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 4042 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4043 | int status = 0; |
| 4044 | |
| 4045 | *res = 0; |
| 4046 | if (unlikely(bitmap[1] & (FATTR4_WORD1_SPACE_AVAIL - 1U))) |
| 4047 | return -EIO; |
| 4048 | if (likely(bitmap[1] & FATTR4_WORD1_SPACE_AVAIL)) { |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 4049 | p = xdr_inline_decode(xdr, 8); |
| 4050 | if (unlikely(!p)) |
Chuck Lever | eb72f48 | 2019-02-11 11:24:21 -0500 | [diff] [blame] | 4051 | return -EIO; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 4052 | xdr_decode_hyper(p, res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4053 | bitmap[1] &= ~FATTR4_WORD1_SPACE_AVAIL; |
| 4054 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 4055 | dprintk("%s: space avail=%Lu\n", __func__, (unsigned long long)*res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4056 | return status; |
| 4057 | } |
| 4058 | |
| 4059 | static int decode_attr_space_free(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *res) |
| 4060 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 4061 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4062 | int status = 0; |
| 4063 | |
| 4064 | *res = 0; |
| 4065 | if (unlikely(bitmap[1] & (FATTR4_WORD1_SPACE_FREE - 1U))) |
| 4066 | return -EIO; |
| 4067 | if (likely(bitmap[1] & FATTR4_WORD1_SPACE_FREE)) { |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 4068 | p = xdr_inline_decode(xdr, 8); |
| 4069 | if (unlikely(!p)) |
Chuck Lever | eb72f48 | 2019-02-11 11:24:21 -0500 | [diff] [blame] | 4070 | return -EIO; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 4071 | xdr_decode_hyper(p, res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4072 | bitmap[1] &= ~FATTR4_WORD1_SPACE_FREE; |
| 4073 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 4074 | dprintk("%s: space free=%Lu\n", __func__, (unsigned long long)*res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4075 | return status; |
| 4076 | } |
| 4077 | |
| 4078 | static int decode_attr_space_total(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *res) |
| 4079 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 4080 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4081 | int status = 0; |
| 4082 | |
| 4083 | *res = 0; |
| 4084 | if (unlikely(bitmap[1] & (FATTR4_WORD1_SPACE_TOTAL - 1U))) |
| 4085 | return -EIO; |
| 4086 | if (likely(bitmap[1] & FATTR4_WORD1_SPACE_TOTAL)) { |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 4087 | p = xdr_inline_decode(xdr, 8); |
| 4088 | if (unlikely(!p)) |
Chuck Lever | eb72f48 | 2019-02-11 11:24:21 -0500 | [diff] [blame] | 4089 | return -EIO; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 4090 | xdr_decode_hyper(p, res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4091 | bitmap[1] &= ~FATTR4_WORD1_SPACE_TOTAL; |
| 4092 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 4093 | dprintk("%s: space total=%Lu\n", __func__, (unsigned long long)*res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4094 | return status; |
| 4095 | } |
| 4096 | |
| 4097 | static int decode_attr_space_used(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *used) |
| 4098 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 4099 | __be32 *p; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 4100 | int ret = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4101 | |
| 4102 | *used = 0; |
| 4103 | if (unlikely(bitmap[1] & (FATTR4_WORD1_SPACE_USED - 1U))) |
| 4104 | return -EIO; |
| 4105 | if (likely(bitmap[1] & FATTR4_WORD1_SPACE_USED)) { |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 4106 | p = xdr_inline_decode(xdr, 8); |
| 4107 | if (unlikely(!p)) |
Chuck Lever | eb72f48 | 2019-02-11 11:24:21 -0500 | [diff] [blame] | 4108 | return -EIO; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 4109 | xdr_decode_hyper(p, used); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4110 | bitmap[1] &= ~FATTR4_WORD1_SPACE_USED; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 4111 | ret = NFS_ATTR_FATTR_SPACE_USED; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4112 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 4113 | dprintk("%s: space used=%Lu\n", __func__, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4114 | (unsigned long long)*used); |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 4115 | return ret; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4116 | } |
| 4117 | |
Trond Myklebust | 36b3743 | 2018-03-20 17:03:10 -0400 | [diff] [blame] | 4118 | static __be32 * |
Trond Myklebust | e86d5a0 | 2019-10-04 16:38:56 -0400 | [diff] [blame] | 4119 | xdr_decode_nfstime4(__be32 *p, struct timespec64 *t) |
Trond Myklebust | 36b3743 | 2018-03-20 17:03:10 -0400 | [diff] [blame] | 4120 | { |
| 4121 | __u64 sec; |
| 4122 | |
| 4123 | p = xdr_decode_hyper(p, &sec); |
Trond Myklebust | e86d5a0 | 2019-10-04 16:38:56 -0400 | [diff] [blame] | 4124 | t-> tv_sec = sec; |
Trond Myklebust | 36b3743 | 2018-03-20 17:03:10 -0400 | [diff] [blame] | 4125 | t->tv_nsec = be32_to_cpup(p++); |
| 4126 | return p; |
| 4127 | } |
| 4128 | |
Trond Myklebust | e86d5a0 | 2019-10-04 16:38:56 -0400 | [diff] [blame] | 4129 | static int decode_attr_time(struct xdr_stream *xdr, struct timespec64 *time) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4130 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 4131 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4132 | |
Trond Myklebust | 36b3743 | 2018-03-20 17:03:10 -0400 | [diff] [blame] | 4133 | p = xdr_inline_decode(xdr, nfstime4_maxsz << 2); |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 4134 | if (unlikely(!p)) |
Chuck Lever | eb72f48 | 2019-02-11 11:24:21 -0500 | [diff] [blame] | 4135 | return -EIO; |
Trond Myklebust | 36b3743 | 2018-03-20 17:03:10 -0400 | [diff] [blame] | 4136 | xdr_decode_nfstime4(p, time); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4137 | return 0; |
| 4138 | } |
| 4139 | |
Trond Myklebust | e86d5a0 | 2019-10-04 16:38:56 -0400 | [diff] [blame] | 4140 | static int decode_attr_time_access(struct xdr_stream *xdr, uint32_t *bitmap, struct timespec64 *time) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4141 | { |
| 4142 | int status = 0; |
| 4143 | |
| 4144 | time->tv_sec = 0; |
| 4145 | time->tv_nsec = 0; |
| 4146 | if (unlikely(bitmap[1] & (FATTR4_WORD1_TIME_ACCESS - 1U))) |
| 4147 | return -EIO; |
| 4148 | if (likely(bitmap[1] & FATTR4_WORD1_TIME_ACCESS)) { |
| 4149 | status = decode_attr_time(xdr, time); |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 4150 | if (status == 0) |
| 4151 | status = NFS_ATTR_FATTR_ATIME; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4152 | bitmap[1] &= ~FATTR4_WORD1_TIME_ACCESS; |
| 4153 | } |
Arnd Bergmann | ae08483 | 2019-11-11 21:16:23 +0100 | [diff] [blame] | 4154 | dprintk("%s: atime=%lld\n", __func__, time->tv_sec); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4155 | return status; |
| 4156 | } |
| 4157 | |
Trond Myklebust | e86d5a0 | 2019-10-04 16:38:56 -0400 | [diff] [blame] | 4158 | static int decode_attr_time_metadata(struct xdr_stream *xdr, uint32_t *bitmap, struct timespec64 *time) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4159 | { |
| 4160 | int status = 0; |
| 4161 | |
| 4162 | time->tv_sec = 0; |
| 4163 | time->tv_nsec = 0; |
| 4164 | if (unlikely(bitmap[1] & (FATTR4_WORD1_TIME_METADATA - 1U))) |
| 4165 | return -EIO; |
| 4166 | if (likely(bitmap[1] & FATTR4_WORD1_TIME_METADATA)) { |
| 4167 | status = decode_attr_time(xdr, time); |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 4168 | if (status == 0) |
| 4169 | status = NFS_ATTR_FATTR_CTIME; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4170 | bitmap[1] &= ~FATTR4_WORD1_TIME_METADATA; |
| 4171 | } |
Arnd Bergmann | ae08483 | 2019-11-11 21:16:23 +0100 | [diff] [blame] | 4172 | dprintk("%s: ctime=%lld\n", __func__, time->tv_sec); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4173 | return status; |
| 4174 | } |
| 4175 | |
Ricardo Labiaga | 55b6e77 | 2010-10-12 16:30:06 -0700 | [diff] [blame] | 4176 | static int decode_attr_time_delta(struct xdr_stream *xdr, uint32_t *bitmap, |
Trond Myklebust | e86d5a0 | 2019-10-04 16:38:56 -0400 | [diff] [blame] | 4177 | struct timespec64 *time) |
Ricardo Labiaga | 55b6e77 | 2010-10-12 16:30:06 -0700 | [diff] [blame] | 4178 | { |
| 4179 | int status = 0; |
| 4180 | |
| 4181 | time->tv_sec = 0; |
| 4182 | time->tv_nsec = 0; |
| 4183 | if (unlikely(bitmap[1] & (FATTR4_WORD1_TIME_DELTA - 1U))) |
| 4184 | return -EIO; |
| 4185 | if (likely(bitmap[1] & FATTR4_WORD1_TIME_DELTA)) { |
| 4186 | status = decode_attr_time(xdr, time); |
| 4187 | bitmap[1] &= ~FATTR4_WORD1_TIME_DELTA; |
| 4188 | } |
Arnd Bergmann | ae08483 | 2019-11-11 21:16:23 +0100 | [diff] [blame] | 4189 | dprintk("%s: time_delta=%lld %ld\n", __func__, time->tv_sec, |
| 4190 | time->tv_nsec); |
Ricardo Labiaga | 55b6e77 | 2010-10-12 16:30:06 -0700 | [diff] [blame] | 4191 | return status; |
| 4192 | } |
| 4193 | |
David Quigley | aa9c266 | 2013-05-22 12:50:44 -0400 | [diff] [blame] | 4194 | static int decode_attr_security_label(struct xdr_stream *xdr, uint32_t *bitmap, |
| 4195 | struct nfs4_label *label) |
| 4196 | { |
| 4197 | uint32_t pi = 0; |
| 4198 | uint32_t lfs = 0; |
| 4199 | __u32 len; |
| 4200 | __be32 *p; |
| 4201 | int status = 0; |
| 4202 | |
| 4203 | if (unlikely(bitmap[2] & (FATTR4_WORD2_SECURITY_LABEL - 1U))) |
| 4204 | return -EIO; |
| 4205 | if (likely(bitmap[2] & FATTR4_WORD2_SECURITY_LABEL)) { |
| 4206 | p = xdr_inline_decode(xdr, 4); |
| 4207 | if (unlikely(!p)) |
Chuck Lever | eb72f48 | 2019-02-11 11:24:21 -0500 | [diff] [blame] | 4208 | return -EIO; |
David Quigley | aa9c266 | 2013-05-22 12:50:44 -0400 | [diff] [blame] | 4209 | lfs = be32_to_cpup(p++); |
| 4210 | p = xdr_inline_decode(xdr, 4); |
| 4211 | if (unlikely(!p)) |
Chuck Lever | eb72f48 | 2019-02-11 11:24:21 -0500 | [diff] [blame] | 4212 | return -EIO; |
David Quigley | aa9c266 | 2013-05-22 12:50:44 -0400 | [diff] [blame] | 4213 | pi = be32_to_cpup(p++); |
| 4214 | p = xdr_inline_decode(xdr, 4); |
| 4215 | if (unlikely(!p)) |
Chuck Lever | eb72f48 | 2019-02-11 11:24:21 -0500 | [diff] [blame] | 4216 | return -EIO; |
David Quigley | aa9c266 | 2013-05-22 12:50:44 -0400 | [diff] [blame] | 4217 | len = be32_to_cpup(p++); |
| 4218 | p = xdr_inline_decode(xdr, len); |
| 4219 | if (unlikely(!p)) |
Chuck Lever | eb72f48 | 2019-02-11 11:24:21 -0500 | [diff] [blame] | 4220 | return -EIO; |
David Quigley | aa9c266 | 2013-05-22 12:50:44 -0400 | [diff] [blame] | 4221 | if (len < NFS4_MAXLABELLEN) { |
| 4222 | if (label) { |
Jeffrey Mitchell | b4487b9 | 2020-08-05 12:23:19 -0500 | [diff] [blame] | 4223 | if (label->len) { |
| 4224 | if (label->len < len) |
| 4225 | return -ERANGE; |
| 4226 | memcpy(label->label, p, len); |
| 4227 | } |
David Quigley | aa9c266 | 2013-05-22 12:50:44 -0400 | [diff] [blame] | 4228 | label->len = len; |
| 4229 | label->pi = pi; |
| 4230 | label->lfs = lfs; |
| 4231 | status = NFS_ATTR_FATTR_V4_SECURITY_LABEL; |
| 4232 | } |
| 4233 | bitmap[2] &= ~FATTR4_WORD2_SECURITY_LABEL; |
| 4234 | } else |
| 4235 | printk(KERN_WARNING "%s: label too long (%u)!\n", |
| 4236 | __func__, len); |
Olga Kornievskaia | 2c52c83 | 2021-11-29 15:33:56 -0500 | [diff] [blame] | 4237 | if (label && label->label) |
| 4238 | dprintk("%s: label=%.*s, len=%d, PI=%d, LFS=%d\n", |
| 4239 | __func__, label->len, (char *)label->label, |
| 4240 | label->len, label->pi, label->lfs); |
David Quigley | aa9c266 | 2013-05-22 12:50:44 -0400 | [diff] [blame] | 4241 | } |
David Quigley | aa9c266 | 2013-05-22 12:50:44 -0400 | [diff] [blame] | 4242 | return status; |
David Quigley | aa9c266 | 2013-05-22 12:50:44 -0400 | [diff] [blame] | 4243 | } |
| 4244 | |
Trond Myklebust | e86d5a0 | 2019-10-04 16:38:56 -0400 | [diff] [blame] | 4245 | static int decode_attr_time_modify(struct xdr_stream *xdr, uint32_t *bitmap, struct timespec64 *time) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4246 | { |
| 4247 | int status = 0; |
| 4248 | |
| 4249 | time->tv_sec = 0; |
| 4250 | time->tv_nsec = 0; |
| 4251 | if (unlikely(bitmap[1] & (FATTR4_WORD1_TIME_MODIFY - 1U))) |
| 4252 | return -EIO; |
| 4253 | if (likely(bitmap[1] & FATTR4_WORD1_TIME_MODIFY)) { |
| 4254 | status = decode_attr_time(xdr, time); |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 4255 | if (status == 0) |
| 4256 | status = NFS_ATTR_FATTR_MTIME; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4257 | bitmap[1] &= ~FATTR4_WORD1_TIME_MODIFY; |
| 4258 | } |
Arnd Bergmann | ae08483 | 2019-11-11 21:16:23 +0100 | [diff] [blame] | 4259 | dprintk("%s: mtime=%lld\n", __func__, time->tv_sec); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4260 | return status; |
| 4261 | } |
| 4262 | |
Frank van der Linden | b78ef84 | 2020-06-23 22:38:55 +0000 | [diff] [blame] | 4263 | static int decode_attr_xattrsupport(struct xdr_stream *xdr, uint32_t *bitmap, |
| 4264 | uint32_t *res) |
| 4265 | { |
| 4266 | __be32 *p; |
| 4267 | |
| 4268 | *res = 0; |
| 4269 | if (unlikely(bitmap[2] & (FATTR4_WORD2_XATTR_SUPPORT - 1U))) |
| 4270 | return -EIO; |
| 4271 | if (likely(bitmap[2] & FATTR4_WORD2_XATTR_SUPPORT)) { |
| 4272 | p = xdr_inline_decode(xdr, 4); |
| 4273 | if (unlikely(!p)) |
| 4274 | return -EIO; |
| 4275 | *res = be32_to_cpup(p); |
| 4276 | bitmap[2] &= ~FATTR4_WORD2_XATTR_SUPPORT; |
| 4277 | } |
| 4278 | dprintk("%s: XATTR support=%s\n", __func__, |
| 4279 | *res == 0 ? "false" : "true"); |
| 4280 | return 0; |
| 4281 | } |
| 4282 | |
Trond Myklebust | 256e48b | 2012-06-21 11:18:13 -0400 | [diff] [blame] | 4283 | 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] | 4284 | { |
| 4285 | unsigned int attrwords = XDR_QUADLEN(attrlen); |
Trond Myklebust | 256e48b | 2012-06-21 11:18:13 -0400 | [diff] [blame] | 4286 | unsigned int nwords = (xdr_stream_pos(xdr) - savep) >> 2; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4287 | |
| 4288 | if (unlikely(attrwords != nwords)) { |
Chuck Lever | fe82a18 | 2007-09-11 18:01:10 -0400 | [diff] [blame] | 4289 | dprintk("%s: server returned incorrect attribute length: " |
| 4290 | "%u %c %u\n", |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 4291 | __func__, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4292 | attrwords << 2, |
| 4293 | (attrwords < nwords) ? '<' : '>', |
| 4294 | nwords << 2); |
| 4295 | return -EIO; |
| 4296 | } |
| 4297 | return 0; |
| 4298 | } |
| 4299 | |
| 4300 | static int decode_change_info(struct xdr_stream *xdr, struct nfs4_change_info *cinfo) |
| 4301 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 4302 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4303 | |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 4304 | p = xdr_inline_decode(xdr, 20); |
| 4305 | if (unlikely(!p)) |
Chuck Lever | eb72f48 | 2019-02-11 11:24:21 -0500 | [diff] [blame] | 4306 | return -EIO; |
Benny Halevy | 6f723f7 | 2009-08-14 17:19:37 +0300 | [diff] [blame] | 4307 | cinfo->atomic = be32_to_cpup(p++); |
Benny Halevy | 3ceb4db | 2009-08-14 17:19:41 +0300 | [diff] [blame] | 4308 | p = xdr_decode_hyper(p, &cinfo->before); |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 4309 | xdr_decode_hyper(p, &cinfo->after); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4310 | return 0; |
| 4311 | } |
| 4312 | |
Weston Andros Adamson | 6168f62 | 2012-09-10 14:00:46 -0400 | [diff] [blame] | 4313 | static int decode_access(struct xdr_stream *xdr, u32 *supported, u32 *access) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4314 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 4315 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4316 | uint32_t supp, acc; |
| 4317 | int status; |
| 4318 | |
| 4319 | status = decode_op_hdr(xdr, OP_ACCESS); |
| 4320 | if (status) |
| 4321 | return status; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 4322 | p = xdr_inline_decode(xdr, 8); |
| 4323 | if (unlikely(!p)) |
Chuck Lever | eb72f48 | 2019-02-11 11:24:21 -0500 | [diff] [blame] | 4324 | return -EIO; |
Benny Halevy | 6f723f7 | 2009-08-14 17:19:37 +0300 | [diff] [blame] | 4325 | supp = be32_to_cpup(p++); |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 4326 | acc = be32_to_cpup(p); |
Weston Andros Adamson | 6168f62 | 2012-09-10 14:00:46 -0400 | [diff] [blame] | 4327 | *supported = supp; |
| 4328 | *access = acc; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4329 | return 0; |
| 4330 | } |
| 4331 | |
Benny Halevy | 07d3043 | 2009-08-14 17:19:52 +0300 | [diff] [blame] | 4332 | 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] | 4333 | { |
Trond Myklebust | ab6e9aa | 2017-02-19 16:08:26 -0500 | [diff] [blame] | 4334 | ssize_t ret = xdr_stream_decode_opaque_fixed(xdr, buf, len); |
Chuck Lever | eb72f48 | 2019-02-11 11:24:21 -0500 | [diff] [blame] | 4335 | if (unlikely(ret < 0)) |
Trond Myklebust | ab6e9aa | 2017-02-19 16:08:26 -0500 | [diff] [blame] | 4336 | return -EIO; |
Trond Myklebust | ab6e9aa | 2017-02-19 16:08:26 -0500 | [diff] [blame] | 4337 | return 0; |
Benny Halevy | 07d3043 | 2009-08-14 17:19:52 +0300 | [diff] [blame] | 4338 | } |
| 4339 | |
| 4340 | static int decode_stateid(struct xdr_stream *xdr, nfs4_stateid *stateid) |
| 4341 | { |
Trond Myklebust | 2d2f24a | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 4342 | return decode_opaque_fixed(xdr, stateid, NFS4_STATEID_SIZE); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4343 | } |
| 4344 | |
Trond Myklebust | 93b717f | 2016-05-16 17:42:43 -0400 | [diff] [blame] | 4345 | static int decode_open_stateid(struct xdr_stream *xdr, nfs4_stateid *stateid) |
| 4346 | { |
| 4347 | stateid->type = NFS4_OPEN_STATEID_TYPE; |
| 4348 | return decode_stateid(xdr, stateid); |
| 4349 | } |
| 4350 | |
| 4351 | static int decode_lock_stateid(struct xdr_stream *xdr, nfs4_stateid *stateid) |
| 4352 | { |
| 4353 | stateid->type = NFS4_LOCK_STATEID_TYPE; |
| 4354 | return decode_stateid(xdr, stateid); |
| 4355 | } |
| 4356 | |
| 4357 | static int decode_delegation_stateid(struct xdr_stream *xdr, nfs4_stateid *stateid) |
| 4358 | { |
| 4359 | stateid->type = NFS4_DELEGATION_STATEID_TYPE; |
| 4360 | return decode_stateid(xdr, stateid); |
| 4361 | } |
| 4362 | |
Trond Myklebust | fcd8843 | 2017-11-07 12:39:44 -0500 | [diff] [blame] | 4363 | static int decode_invalid_stateid(struct xdr_stream *xdr, nfs4_stateid *stateid) |
| 4364 | { |
| 4365 | nfs4_stateid dummy; |
| 4366 | |
| 4367 | nfs4_stateid_copy(stateid, &invalid_stateid); |
| 4368 | return decode_stateid(xdr, &dummy); |
| 4369 | } |
| 4370 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4371 | static int decode_close(struct xdr_stream *xdr, struct nfs_closeres *res) |
| 4372 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4373 | int status; |
| 4374 | |
| 4375 | status = decode_op_hdr(xdr, OP_CLOSE); |
Trond Myklebust | c1d5193 | 2008-04-07 13:20:54 -0400 | [diff] [blame] | 4376 | if (status != -EIO) |
| 4377 | nfs_increment_open_seqid(status, res->seqid); |
Benny Halevy | 07d3043 | 2009-08-14 17:19:52 +0300 | [diff] [blame] | 4378 | if (!status) |
Trond Myklebust | fcd8843 | 2017-11-07 12:39:44 -0500 | [diff] [blame] | 4379 | status = decode_invalid_stateid(xdr, &res->stateid); |
Benny Halevy | 07d3043 | 2009-08-14 17:19:52 +0300 | [diff] [blame] | 4380 | return status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4381 | } |
| 4382 | |
Benny Halevy | db942bb | 2009-08-14 17:19:56 +0300 | [diff] [blame] | 4383 | static int decode_verifier(struct xdr_stream *xdr, void *verifier) |
| 4384 | { |
Chuck Lever | cd93710 | 2012-03-02 17:14:31 -0500 | [diff] [blame] | 4385 | return decode_opaque_fixed(xdr, verifier, NFS4_VERIFIER_SIZE); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4386 | } |
| 4387 | |
Trond Myklebust | 2f2c63b | 2012-06-08 11:56:09 -0400 | [diff] [blame] | 4388 | static int decode_write_verifier(struct xdr_stream *xdr, struct nfs_write_verifier *verifier) |
| 4389 | { |
| 4390 | return decode_opaque_fixed(xdr, verifier->data, NFS4_VERIFIER_SIZE); |
| 4391 | } |
| 4392 | |
Fred Isaman | 0b7c015 | 2012-04-20 14:47:39 -0400 | [diff] [blame] | 4393 | static int decode_commit(struct xdr_stream *xdr, struct nfs_commitres *res) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4394 | { |
Trond Myklebust | 221203c | 2020-01-06 15:25:04 -0500 | [diff] [blame] | 4395 | struct nfs_writeverf *verf = res->verf; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4396 | int status; |
| 4397 | |
| 4398 | status = decode_op_hdr(xdr, OP_COMMIT); |
Benny Halevy | db942bb | 2009-08-14 17:19:56 +0300 | [diff] [blame] | 4399 | if (!status) |
Trond Myklebust | 221203c | 2020-01-06 15:25:04 -0500 | [diff] [blame] | 4400 | status = decode_write_verifier(xdr, &verf->verifier); |
| 4401 | if (!status) |
| 4402 | verf->committed = NFS_FILE_SYNC; |
Benny Halevy | db942bb | 2009-08-14 17:19:56 +0300 | [diff] [blame] | 4403 | return status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4404 | } |
| 4405 | |
| 4406 | static int decode_create(struct xdr_stream *xdr, struct nfs4_change_info *cinfo) |
| 4407 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 4408 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4409 | uint32_t bmlen; |
| 4410 | int status; |
| 4411 | |
| 4412 | status = decode_op_hdr(xdr, OP_CREATE); |
| 4413 | if (status) |
| 4414 | return status; |
| 4415 | if ((status = decode_change_info(xdr, cinfo))) |
| 4416 | return status; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 4417 | p = xdr_inline_decode(xdr, 4); |
| 4418 | if (unlikely(!p)) |
Chuck Lever | eb72f48 | 2019-02-11 11:24:21 -0500 | [diff] [blame] | 4419 | return -EIO; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 4420 | bmlen = be32_to_cpup(p); |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 4421 | p = xdr_inline_decode(xdr, bmlen << 2); |
| 4422 | if (likely(p)) |
| 4423 | return 0; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 4424 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4425 | } |
| 4426 | |
| 4427 | static int decode_server_caps(struct xdr_stream *xdr, struct nfs4_server_caps_res *res) |
| 4428 | { |
Trond Myklebust | 256e48b | 2012-06-21 11:18:13 -0400 | [diff] [blame] | 4429 | unsigned int savep; |
Fred Isaman | dae100c | 2011-07-30 20:52:37 -0400 | [diff] [blame] | 4430 | uint32_t attrlen, bitmap[3] = {0}; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4431 | int status; |
| 4432 | |
| 4433 | if ((status = decode_op_hdr(xdr, OP_GETATTR)) != 0) |
| 4434 | goto xdr_error; |
| 4435 | if ((status = decode_attr_bitmap(xdr, bitmap)) != 0) |
| 4436 | goto xdr_error; |
| 4437 | if ((status = decode_attr_length(xdr, &attrlen, &savep)) != 0) |
| 4438 | goto xdr_error; |
| 4439 | if ((status = decode_attr_supported(xdr, bitmap, res->attr_bitmask)) != 0) |
| 4440 | goto xdr_error; |
Chuck Lever | 264e635 | 2012-03-01 17:02:05 -0500 | [diff] [blame] | 4441 | if ((status = decode_attr_fh_expire_type(xdr, bitmap, |
| 4442 | &res->fh_expire_type)) != 0) |
| 4443 | goto xdr_error; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4444 | if ((status = decode_attr_link_support(xdr, bitmap, &res->has_links)) != 0) |
| 4445 | goto xdr_error; |
| 4446 | if ((status = decode_attr_symlink_support(xdr, bitmap, &res->has_symlinks)) != 0) |
| 4447 | goto xdr_error; |
| 4448 | if ((status = decode_attr_aclsupport(xdr, bitmap, &res->acl_bitmask)) != 0) |
| 4449 | goto xdr_error; |
Trond Myklebust | 1ab5be4 | 2021-12-17 15:36:54 -0500 | [diff] [blame] | 4450 | if ((status = decode_attr_case_insensitive(xdr, bitmap, &res->case_insensitive)) != 0) |
| 4451 | goto xdr_error; |
| 4452 | if ((status = decode_attr_case_preserving(xdr, bitmap, &res->case_preserving)) != 0) |
| 4453 | goto xdr_error; |
Kinglong Mee | 8c61282 | 2015-08-26 21:12:58 +0800 | [diff] [blame] | 4454 | if ((status = decode_attr_exclcreat_supported(xdr, bitmap, |
| 4455 | res->exclcreat_bitmask)) != 0) |
| 4456 | goto xdr_error; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4457 | status = verify_attr_len(xdr, savep, attrlen); |
| 4458 | xdr_error: |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 4459 | dprintk("%s: xdr returned %d!\n", __func__, -status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4460 | return status; |
| 4461 | } |
Andy Adamson | 6c0195a | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 4462 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4463 | static int decode_statfs(struct xdr_stream *xdr, struct nfs_fsstat *fsstat) |
| 4464 | { |
Trond Myklebust | 256e48b | 2012-06-21 11:18:13 -0400 | [diff] [blame] | 4465 | unsigned int savep; |
Fred Isaman | dae100c | 2011-07-30 20:52:37 -0400 | [diff] [blame] | 4466 | uint32_t attrlen, bitmap[3] = {0}; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4467 | int status; |
Andy Adamson | 6c0195a | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 4468 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4469 | if ((status = decode_op_hdr(xdr, OP_GETATTR)) != 0) |
| 4470 | goto xdr_error; |
| 4471 | if ((status = decode_attr_bitmap(xdr, bitmap)) != 0) |
| 4472 | goto xdr_error; |
| 4473 | if ((status = decode_attr_length(xdr, &attrlen, &savep)) != 0) |
| 4474 | goto xdr_error; |
| 4475 | |
| 4476 | if ((status = decode_attr_files_avail(xdr, bitmap, &fsstat->afiles)) != 0) |
| 4477 | goto xdr_error; |
| 4478 | if ((status = decode_attr_files_free(xdr, bitmap, &fsstat->ffiles)) != 0) |
| 4479 | goto xdr_error; |
| 4480 | if ((status = decode_attr_files_total(xdr, bitmap, &fsstat->tfiles)) != 0) |
| 4481 | goto xdr_error; |
Andreas Gruenbacher | 1ca843a | 2015-11-03 18:25:33 +0100 | [diff] [blame] | 4482 | |
| 4483 | status = -EIO; |
| 4484 | if (unlikely(bitmap[0])) |
| 4485 | goto xdr_error; |
| 4486 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4487 | if ((status = decode_attr_space_avail(xdr, bitmap, &fsstat->abytes)) != 0) |
| 4488 | goto xdr_error; |
| 4489 | if ((status = decode_attr_space_free(xdr, bitmap, &fsstat->fbytes)) != 0) |
| 4490 | goto xdr_error; |
| 4491 | if ((status = decode_attr_space_total(xdr, bitmap, &fsstat->tbytes)) != 0) |
| 4492 | goto xdr_error; |
| 4493 | |
| 4494 | status = verify_attr_len(xdr, savep, attrlen); |
| 4495 | xdr_error: |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 4496 | dprintk("%s: xdr returned %d!\n", __func__, -status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4497 | return status; |
| 4498 | } |
| 4499 | |
| 4500 | static int decode_pathconf(struct xdr_stream *xdr, struct nfs_pathconf *pathconf) |
| 4501 | { |
Trond Myklebust | 256e48b | 2012-06-21 11:18:13 -0400 | [diff] [blame] | 4502 | unsigned int savep; |
Fred Isaman | dae100c | 2011-07-30 20:52:37 -0400 | [diff] [blame] | 4503 | uint32_t attrlen, bitmap[3] = {0}; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4504 | int status; |
Andy Adamson | 6c0195a | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 4505 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4506 | if ((status = decode_op_hdr(xdr, OP_GETATTR)) != 0) |
| 4507 | goto xdr_error; |
| 4508 | if ((status = decode_attr_bitmap(xdr, bitmap)) != 0) |
| 4509 | goto xdr_error; |
| 4510 | if ((status = decode_attr_length(xdr, &attrlen, &savep)) != 0) |
| 4511 | goto xdr_error; |
| 4512 | |
| 4513 | if ((status = decode_attr_maxlink(xdr, bitmap, &pathconf->max_link)) != 0) |
| 4514 | goto xdr_error; |
| 4515 | if ((status = decode_attr_maxname(xdr, bitmap, &pathconf->max_namelen)) != 0) |
| 4516 | goto xdr_error; |
| 4517 | |
| 4518 | status = verify_attr_len(xdr, savep, attrlen); |
| 4519 | xdr_error: |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 4520 | dprintk("%s: xdr returned %d!\n", __func__, -status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4521 | return status; |
| 4522 | } |
| 4523 | |
Andy Adamson | 88034c3 | 2012-05-23 05:02:34 -0400 | [diff] [blame] | 4524 | static int decode_threshold_hint(struct xdr_stream *xdr, |
| 4525 | uint32_t *bitmap, |
| 4526 | uint64_t *res, |
| 4527 | uint32_t hint_bit) |
| 4528 | { |
| 4529 | __be32 *p; |
| 4530 | |
| 4531 | *res = 0; |
| 4532 | if (likely(bitmap[0] & hint_bit)) { |
| 4533 | p = xdr_inline_decode(xdr, 8); |
| 4534 | if (unlikely(!p)) |
Chuck Lever | eb72f48 | 2019-02-11 11:24:21 -0500 | [diff] [blame] | 4535 | return -EIO; |
Andy Adamson | 88034c3 | 2012-05-23 05:02:34 -0400 | [diff] [blame] | 4536 | xdr_decode_hyper(p, res); |
| 4537 | } |
| 4538 | return 0; |
Andy Adamson | 88034c3 | 2012-05-23 05:02:34 -0400 | [diff] [blame] | 4539 | } |
| 4540 | |
| 4541 | static int decode_first_threshold_item4(struct xdr_stream *xdr, |
| 4542 | struct nfs4_threshold *res) |
| 4543 | { |
Trond Myklebust | 256e48b | 2012-06-21 11:18:13 -0400 | [diff] [blame] | 4544 | __be32 *p; |
| 4545 | unsigned int savep; |
Andy Adamson | 88034c3 | 2012-05-23 05:02:34 -0400 | [diff] [blame] | 4546 | uint32_t bitmap[3] = {0,}, attrlen; |
| 4547 | int status; |
| 4548 | |
| 4549 | /* layout type */ |
| 4550 | p = xdr_inline_decode(xdr, 4); |
Chuck Lever | eb72f48 | 2019-02-11 11:24:21 -0500 | [diff] [blame] | 4551 | if (unlikely(!p)) |
Andy Adamson | 88034c3 | 2012-05-23 05:02:34 -0400 | [diff] [blame] | 4552 | return -EIO; |
Andy Adamson | 88034c3 | 2012-05-23 05:02:34 -0400 | [diff] [blame] | 4553 | res->l_type = be32_to_cpup(p); |
| 4554 | |
| 4555 | /* thi_hintset bitmap */ |
| 4556 | status = decode_attr_bitmap(xdr, bitmap); |
| 4557 | if (status < 0) |
| 4558 | goto xdr_error; |
| 4559 | |
| 4560 | /* thi_hintlist length */ |
| 4561 | status = decode_attr_length(xdr, &attrlen, &savep); |
| 4562 | if (status < 0) |
| 4563 | goto xdr_error; |
| 4564 | /* thi_hintlist */ |
| 4565 | status = decode_threshold_hint(xdr, bitmap, &res->rd_sz, THRESHOLD_RD); |
| 4566 | if (status < 0) |
| 4567 | goto xdr_error; |
| 4568 | status = decode_threshold_hint(xdr, bitmap, &res->wr_sz, THRESHOLD_WR); |
| 4569 | if (status < 0) |
| 4570 | goto xdr_error; |
| 4571 | status = decode_threshold_hint(xdr, bitmap, &res->rd_io_sz, |
| 4572 | THRESHOLD_RD_IO); |
| 4573 | if (status < 0) |
| 4574 | goto xdr_error; |
| 4575 | status = decode_threshold_hint(xdr, bitmap, &res->wr_io_sz, |
| 4576 | THRESHOLD_WR_IO); |
| 4577 | if (status < 0) |
| 4578 | goto xdr_error; |
| 4579 | |
| 4580 | status = verify_attr_len(xdr, savep, attrlen); |
| 4581 | res->bm = bitmap[0]; |
| 4582 | |
| 4583 | dprintk("%s bm=0x%x rd_sz=%llu wr_sz=%llu rd_io=%llu wr_io=%llu\n", |
| 4584 | __func__, res->bm, res->rd_sz, res->wr_sz, res->rd_io_sz, |
| 4585 | res->wr_io_sz); |
| 4586 | xdr_error: |
| 4587 | dprintk("%s ret=%d!\n", __func__, status); |
| 4588 | return status; |
| 4589 | } |
| 4590 | |
| 4591 | /* |
| 4592 | * Thresholds on pNFS direct I/O vrs MDS I/O |
| 4593 | */ |
| 4594 | static int decode_attr_mdsthreshold(struct xdr_stream *xdr, |
| 4595 | uint32_t *bitmap, |
| 4596 | struct nfs4_threshold *res) |
| 4597 | { |
| 4598 | __be32 *p; |
| 4599 | int status = 0; |
| 4600 | uint32_t num; |
| 4601 | |
| 4602 | if (unlikely(bitmap[2] & (FATTR4_WORD2_MDSTHRESHOLD - 1U))) |
| 4603 | return -EIO; |
Trond Myklebust | 029c534 | 2012-06-05 09:35:44 -0400 | [diff] [blame] | 4604 | if (bitmap[2] & FATTR4_WORD2_MDSTHRESHOLD) { |
Trond Myklebust | 1549210f | 2012-06-05 09:16:47 -0400 | [diff] [blame] | 4605 | /* Did the server return an unrequested attribute? */ |
| 4606 | if (unlikely(res == NULL)) |
| 4607 | return -EREMOTEIO; |
Andy Adamson | 88034c3 | 2012-05-23 05:02:34 -0400 | [diff] [blame] | 4608 | p = xdr_inline_decode(xdr, 4); |
| 4609 | if (unlikely(!p)) |
Chuck Lever | eb72f48 | 2019-02-11 11:24:21 -0500 | [diff] [blame] | 4610 | return -EIO; |
Andy Adamson | 88034c3 | 2012-05-23 05:02:34 -0400 | [diff] [blame] | 4611 | num = be32_to_cpup(p); |
| 4612 | if (num == 0) |
| 4613 | return 0; |
| 4614 | if (num > 1) |
| 4615 | printk(KERN_INFO "%s: Warning: Multiple pNFS layout " |
| 4616 | "drivers per filesystem not supported\n", |
| 4617 | __func__); |
| 4618 | |
| 4619 | status = decode_first_threshold_item4(xdr, res); |
Trond Myklebust | 029c534 | 2012-06-05 09:35:44 -0400 | [diff] [blame] | 4620 | bitmap[2] &= ~FATTR4_WORD2_MDSTHRESHOLD; |
Andy Adamson | 88034c3 | 2012-05-23 05:02:34 -0400 | [diff] [blame] | 4621 | } |
| 4622 | return status; |
Andy Adamson | 88034c3 | 2012-05-23 05:02:34 -0400 | [diff] [blame] | 4623 | } |
| 4624 | |
Bryan Schumaker | ae42c70 | 2010-10-21 16:33:17 -0400 | [diff] [blame] | 4625 | static int decode_getfattr_attrs(struct xdr_stream *xdr, uint32_t *bitmap, |
| 4626 | struct nfs_fattr *fattr, struct nfs_fh *fh, |
Anna Schumaker | 1e2f67d | 2021-10-22 13:11:13 -0400 | [diff] [blame] | 4627 | struct nfs4_fs_locations *fs_loc, const struct nfs_server *server) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4628 | { |
Trond Myklebust | bca7947 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 4629 | int status; |
| 4630 | umode_t fmode = 0; |
Bryan Schumaker | ae42c70 | 2010-10-21 16:33:17 -0400 | [diff] [blame] | 4631 | uint32_t type; |
Trond Myklebust | ee7b75f | 2011-06-16 13:15:41 -0400 | [diff] [blame] | 4632 | int32_t err; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4633 | |
Trond Myklebust | f26c7a7 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 4634 | status = decode_attr_type(xdr, bitmap, &type); |
| 4635 | if (status < 0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4636 | goto xdr_error; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 4637 | fattr->mode = 0; |
| 4638 | if (status != 0) { |
| 4639 | fattr->mode |= nfs_type2fmt[type]; |
| 4640 | fattr->valid |= status; |
| 4641 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4642 | |
Trond Myklebust | f26c7a7 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 4643 | status = decode_attr_change(xdr, bitmap, &fattr->change_attr); |
| 4644 | if (status < 0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4645 | goto xdr_error; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 4646 | fattr->valid |= status; |
Trond Myklebust | f26c7a7 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 4647 | |
| 4648 | status = decode_attr_size(xdr, bitmap, &fattr->size); |
| 4649 | if (status < 0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4650 | goto xdr_error; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 4651 | fattr->valid |= status; |
Trond Myklebust | f26c7a7 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 4652 | |
| 4653 | status = decode_attr_fsid(xdr, bitmap, &fattr->fsid); |
| 4654 | if (status < 0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4655 | goto xdr_error; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 4656 | fattr->valid |= status; |
Trond Myklebust | f26c7a7 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 4657 | |
Trond Myklebust | ee7b75f | 2011-06-16 13:15:41 -0400 | [diff] [blame] | 4658 | err = 0; |
| 4659 | status = decode_attr_error(xdr, bitmap, &err); |
Bryan Schumaker | ae42c70 | 2010-10-21 16:33:17 -0400 | [diff] [blame] | 4660 | if (status < 0) |
| 4661 | goto xdr_error; |
| 4662 | |
| 4663 | status = decode_attr_filehandle(xdr, bitmap, fh); |
| 4664 | if (status < 0) |
| 4665 | goto xdr_error; |
| 4666 | |
Trond Myklebust | f26c7a7 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 4667 | status = decode_attr_fileid(xdr, bitmap, &fattr->fileid); |
| 4668 | if (status < 0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4669 | goto xdr_error; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 4670 | fattr->valid |= status; |
Trond Myklebust | f26c7a7 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 4671 | |
Trond Myklebust | 8b7e3f4 | 2012-01-30 15:43:56 -0500 | [diff] [blame] | 4672 | status = decode_attr_fs_locations(xdr, bitmap, fs_loc); |
Trond Myklebust | f26c7a7 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 4673 | if (status < 0) |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 4674 | goto xdr_error; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 4675 | fattr->valid |= status; |
Trond Myklebust | f26c7a7 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 4676 | |
Andreas Gruenbacher | 1ca843a | 2015-11-03 18:25:33 +0100 | [diff] [blame] | 4677 | status = -EIO; |
| 4678 | if (unlikely(bitmap[0])) |
| 4679 | goto xdr_error; |
| 4680 | |
Trond Myklebust | f26c7a7 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 4681 | status = decode_attr_mode(xdr, bitmap, &fmode); |
| 4682 | if (status < 0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4683 | goto xdr_error; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 4684 | if (status != 0) { |
| 4685 | fattr->mode |= fmode; |
| 4686 | fattr->valid |= status; |
| 4687 | } |
Trond Myklebust | f26c7a7 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 4688 | |
| 4689 | status = decode_attr_nlink(xdr, bitmap, &fattr->nlink); |
| 4690 | if (status < 0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4691 | goto xdr_error; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 4692 | fattr->valid |= status; |
Trond Myklebust | f26c7a7 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 4693 | |
Trond Myklebust | 6926afd1 | 2012-01-07 13:22:46 -0500 | [diff] [blame] | 4694 | status = decode_attr_owner(xdr, bitmap, server, &fattr->uid, fattr->owner_name); |
Trond Myklebust | f26c7a7 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 4695 | if (status < 0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4696 | goto xdr_error; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 4697 | fattr->valid |= status; |
Trond Myklebust | f26c7a7 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 4698 | |
Trond Myklebust | 6926afd1 | 2012-01-07 13:22:46 -0500 | [diff] [blame] | 4699 | status = decode_attr_group(xdr, bitmap, server, &fattr->gid, fattr->group_name); |
Trond Myklebust | f26c7a7 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 4700 | if (status < 0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4701 | goto xdr_error; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 4702 | fattr->valid |= status; |
Trond Myklebust | f26c7a7 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 4703 | |
| 4704 | status = decode_attr_rdev(xdr, bitmap, &fattr->rdev); |
| 4705 | if (status < 0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4706 | goto xdr_error; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 4707 | fattr->valid |= status; |
Trond Myklebust | f26c7a7 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 4708 | |
| 4709 | status = decode_attr_space_used(xdr, bitmap, &fattr->du.nfs3.used); |
| 4710 | if (status < 0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4711 | goto xdr_error; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 4712 | fattr->valid |= status; |
Trond Myklebust | f26c7a7 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 4713 | |
| 4714 | status = decode_attr_time_access(xdr, bitmap, &fattr->atime); |
| 4715 | if (status < 0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4716 | goto xdr_error; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 4717 | fattr->valid |= status; |
Trond Myklebust | f26c7a7 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 4718 | |
| 4719 | status = decode_attr_time_metadata(xdr, bitmap, &fattr->ctime); |
| 4720 | if (status < 0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4721 | goto xdr_error; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 4722 | fattr->valid |= status; |
Trond Myklebust | f26c7a7 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 4723 | |
| 4724 | status = decode_attr_time_modify(xdr, bitmap, &fattr->mtime); |
| 4725 | if (status < 0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4726 | goto xdr_error; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 4727 | fattr->valid |= status; |
Trond Myklebust | f26c7a7 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 4728 | |
Trond Myklebust | 28331a4 | 2011-04-27 13:47:52 -0400 | [diff] [blame] | 4729 | status = decode_attr_mounted_on_fileid(xdr, bitmap, &fattr->mounted_on_fileid); |
Trond Myklebust | f26c7a7 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 4730 | if (status < 0) |
Manoj Naik | 99baf62 | 2006-06-09 09:34:24 -0400 | [diff] [blame] | 4731 | goto xdr_error; |
Trond Myklebust | 28331a4 | 2011-04-27 13:47:52 -0400 | [diff] [blame] | 4732 | fattr->valid |= status; |
Trond Myklebust | f26c7a7 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 4733 | |
Andreas Gruenbacher | 1ca843a | 2015-11-03 18:25:33 +0100 | [diff] [blame] | 4734 | status = -EIO; |
| 4735 | if (unlikely(bitmap[1])) |
| 4736 | goto xdr_error; |
| 4737 | |
Andy Adamson | 88034c3 | 2012-05-23 05:02:34 -0400 | [diff] [blame] | 4738 | status = decode_attr_mdsthreshold(xdr, bitmap, fattr->mdsthreshold); |
| 4739 | if (status < 0) |
| 4740 | goto xdr_error; |
| 4741 | |
Anna Schumaker | 1e2f67d | 2021-10-22 13:11:13 -0400 | [diff] [blame] | 4742 | if (fattr->label) { |
| 4743 | status = decode_attr_security_label(xdr, bitmap, fattr->label); |
David Quigley | aa9c266 | 2013-05-22 12:50:44 -0400 | [diff] [blame] | 4744 | if (status < 0) |
| 4745 | goto xdr_error; |
| 4746 | fattr->valid |= status; |
| 4747 | } |
| 4748 | |
Bryan Schumaker | ae42c70 | 2010-10-21 16:33:17 -0400 | [diff] [blame] | 4749 | xdr_error: |
| 4750 | dprintk("%s: xdr returned %d\n", __func__, -status); |
| 4751 | return status; |
| 4752 | } |
| 4753 | |
| 4754 | 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] | 4755 | struct nfs_fh *fh, struct nfs4_fs_locations *fs_loc, |
Anna Schumaker | 1e2f67d | 2021-10-22 13:11:13 -0400 | [diff] [blame] | 4756 | const struct nfs_server *server) |
Bryan Schumaker | ae42c70 | 2010-10-21 16:33:17 -0400 | [diff] [blame] | 4757 | { |
Trond Myklebust | 256e48b | 2012-06-21 11:18:13 -0400 | [diff] [blame] | 4758 | unsigned int savep; |
Bryan Schumaker | ae42c70 | 2010-10-21 16:33:17 -0400 | [diff] [blame] | 4759 | uint32_t attrlen, |
Fred Isaman | dae100c | 2011-07-30 20:52:37 -0400 | [diff] [blame] | 4760 | bitmap[3] = {0}; |
Bryan Schumaker | ae42c70 | 2010-10-21 16:33:17 -0400 | [diff] [blame] | 4761 | int status; |
| 4762 | |
| 4763 | status = decode_op_hdr(xdr, OP_GETATTR); |
| 4764 | if (status < 0) |
| 4765 | goto xdr_error; |
| 4766 | |
| 4767 | status = decode_attr_bitmap(xdr, bitmap); |
| 4768 | if (status < 0) |
| 4769 | goto xdr_error; |
| 4770 | |
| 4771 | status = decode_attr_length(xdr, &attrlen, &savep); |
| 4772 | if (status < 0) |
| 4773 | goto xdr_error; |
| 4774 | |
Anna Schumaker | 1e2f67d | 2021-10-22 13:11:13 -0400 | [diff] [blame] | 4775 | status = decode_getfattr_attrs(xdr, bitmap, fattr, fh, fs_loc, server); |
Bryan Schumaker | ae42c70 | 2010-10-21 16:33:17 -0400 | [diff] [blame] | 4776 | if (status < 0) |
| 4777 | goto xdr_error; |
| 4778 | |
Trond Myklebust | f26c7a7 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 4779 | status = verify_attr_len(xdr, savep, attrlen); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4780 | xdr_error: |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 4781 | dprintk("%s: xdr returned %d\n", __func__, -status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4782 | return status; |
| 4783 | } |
| 4784 | |
Bryan Schumaker | ae42c70 | 2010-10-21 16:33:17 -0400 | [diff] [blame] | 4785 | static int decode_getfattr(struct xdr_stream *xdr, struct nfs_fattr *fattr, |
Trond Myklebust | 6926afd1 | 2012-01-07 13:22:46 -0500 | [diff] [blame] | 4786 | const struct nfs_server *server) |
Bryan Schumaker | ae42c70 | 2010-10-21 16:33:17 -0400 | [diff] [blame] | 4787 | { |
Anna Schumaker | 1e2f67d | 2021-10-22 13:11:13 -0400 | [diff] [blame] | 4788 | return decode_getfattr_generic(xdr, fattr, NULL, NULL, server); |
Bryan Schumaker | ae42c70 | 2010-10-21 16:33:17 -0400 | [diff] [blame] | 4789 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4790 | |
Andy Adamson | 504913f | 2010-10-20 00:17:57 -0400 | [diff] [blame] | 4791 | /* |
Jeff Layton | 3132e49 | 2016-08-10 15:58:24 -0400 | [diff] [blame] | 4792 | * Decode potentially multiple layout types. |
Andy Adamson | 504913f | 2010-10-20 00:17:57 -0400 | [diff] [blame] | 4793 | */ |
Jeff Layton | 3132e49 | 2016-08-10 15:58:24 -0400 | [diff] [blame] | 4794 | static int decode_pnfs_layout_types(struct xdr_stream *xdr, |
Jeff Layton | ca440c3 | 2016-09-15 14:40:49 -0400 | [diff] [blame] | 4795 | struct nfs_fsinfo *fsinfo) |
Andy Adamson | 504913f | 2010-10-20 00:17:57 -0400 | [diff] [blame] | 4796 | { |
Trond Myklebust | b8a8a0d | 2013-08-20 21:08:56 -0400 | [diff] [blame] | 4797 | __be32 *p; |
Jeff Layton | ca440c3 | 2016-09-15 14:40:49 -0400 | [diff] [blame] | 4798 | uint32_t i; |
Andy Adamson | 504913f | 2010-10-20 00:17:57 -0400 | [diff] [blame] | 4799 | |
| 4800 | p = xdr_inline_decode(xdr, 4); |
| 4801 | if (unlikely(!p)) |
Chuck Lever | eb72f48 | 2019-02-11 11:24:21 -0500 | [diff] [blame] | 4802 | return -EIO; |
Jeff Layton | ca440c3 | 2016-09-15 14:40:49 -0400 | [diff] [blame] | 4803 | fsinfo->nlayouttypes = be32_to_cpup(p); |
Andy Adamson | 504913f | 2010-10-20 00:17:57 -0400 | [diff] [blame] | 4804 | |
| 4805 | /* pNFS is not supported by the underlying file system */ |
Jeff Layton | ca440c3 | 2016-09-15 14:40:49 -0400 | [diff] [blame] | 4806 | if (fsinfo->nlayouttypes == 0) |
Andy Adamson | 504913f | 2010-10-20 00:17:57 -0400 | [diff] [blame] | 4807 | return 0; |
Andy Adamson | 504913f | 2010-10-20 00:17:57 -0400 | [diff] [blame] | 4808 | |
| 4809 | /* Decode and set first layout type, move xdr->p past unused types */ |
Jeff Layton | ca440c3 | 2016-09-15 14:40:49 -0400 | [diff] [blame] | 4810 | p = xdr_inline_decode(xdr, fsinfo->nlayouttypes * 4); |
Andy Adamson | 504913f | 2010-10-20 00:17:57 -0400 | [diff] [blame] | 4811 | if (unlikely(!p)) |
Chuck Lever | eb72f48 | 2019-02-11 11:24:21 -0500 | [diff] [blame] | 4812 | return -EIO; |
Jeff Layton | ca440c3 | 2016-09-15 14:40:49 -0400 | [diff] [blame] | 4813 | |
| 4814 | /* If we get too many, then just cap it at the max */ |
| 4815 | if (fsinfo->nlayouttypes > NFS_MAX_LAYOUT_TYPES) { |
| 4816 | printk(KERN_INFO "NFS: %s: Warning: Too many (%u) pNFS layout types\n", |
| 4817 | __func__, fsinfo->nlayouttypes); |
| 4818 | fsinfo->nlayouttypes = NFS_MAX_LAYOUT_TYPES; |
| 4819 | } |
| 4820 | |
| 4821 | for(i = 0; i < fsinfo->nlayouttypes; ++i) |
| 4822 | fsinfo->layouttype[i] = be32_to_cpup(p++); |
Andy Adamson | 504913f | 2010-10-20 00:17:57 -0400 | [diff] [blame] | 4823 | return 0; |
Andy Adamson | 504913f | 2010-10-20 00:17:57 -0400 | [diff] [blame] | 4824 | } |
| 4825 | |
| 4826 | /* |
| 4827 | * The type of file system exported. |
| 4828 | * Note we must ensure that layouttype is set in any non-error case. |
| 4829 | */ |
| 4830 | static int decode_attr_pnfstype(struct xdr_stream *xdr, uint32_t *bitmap, |
Jeff Layton | ca440c3 | 2016-09-15 14:40:49 -0400 | [diff] [blame] | 4831 | struct nfs_fsinfo *fsinfo) |
Andy Adamson | 504913f | 2010-10-20 00:17:57 -0400 | [diff] [blame] | 4832 | { |
| 4833 | int status = 0; |
| 4834 | |
| 4835 | dprintk("%s: bitmap is %x\n", __func__, bitmap[1]); |
| 4836 | if (unlikely(bitmap[1] & (FATTR4_WORD1_FS_LAYOUT_TYPES - 1U))) |
| 4837 | return -EIO; |
| 4838 | if (bitmap[1] & FATTR4_WORD1_FS_LAYOUT_TYPES) { |
Jeff Layton | ca440c3 | 2016-09-15 14:40:49 -0400 | [diff] [blame] | 4839 | status = decode_pnfs_layout_types(xdr, fsinfo); |
Andy Adamson | 504913f | 2010-10-20 00:17:57 -0400 | [diff] [blame] | 4840 | bitmap[1] &= ~FATTR4_WORD1_FS_LAYOUT_TYPES; |
Jeff Layton | 3132e49 | 2016-08-10 15:58:24 -0400 | [diff] [blame] | 4841 | } |
Andy Adamson | 504913f | 2010-10-20 00:17:57 -0400 | [diff] [blame] | 4842 | return status; |
| 4843 | } |
| 4844 | |
Fred Isaman | dae100c | 2011-07-30 20:52:37 -0400 | [diff] [blame] | 4845 | /* |
| 4846 | * The prefered block size for layout directed io |
| 4847 | */ |
| 4848 | static int decode_attr_layout_blksize(struct xdr_stream *xdr, uint32_t *bitmap, |
| 4849 | uint32_t *res) |
| 4850 | { |
| 4851 | __be32 *p; |
| 4852 | |
| 4853 | dprintk("%s: bitmap is %x\n", __func__, bitmap[2]); |
| 4854 | *res = 0; |
| 4855 | if (bitmap[2] & FATTR4_WORD2_LAYOUT_BLKSIZE) { |
| 4856 | p = xdr_inline_decode(xdr, 4); |
Chuck Lever | eb72f48 | 2019-02-11 11:24:21 -0500 | [diff] [blame] | 4857 | if (unlikely(!p)) |
Fred Isaman | dae100c | 2011-07-30 20:52:37 -0400 | [diff] [blame] | 4858 | return -EIO; |
Fred Isaman | dae100c | 2011-07-30 20:52:37 -0400 | [diff] [blame] | 4859 | *res = be32_to_cpup(p); |
| 4860 | bitmap[2] &= ~FATTR4_WORD2_LAYOUT_BLKSIZE; |
| 4861 | } |
| 4862 | return 0; |
| 4863 | } |
| 4864 | |
Peng Tao | 2a92ee9 | 2015-09-26 02:24:37 +0800 | [diff] [blame] | 4865 | /* |
| 4866 | * The granularity of a CLONE operation. |
| 4867 | */ |
| 4868 | static int decode_attr_clone_blksize(struct xdr_stream *xdr, uint32_t *bitmap, |
| 4869 | uint32_t *res) |
| 4870 | { |
| 4871 | __be32 *p; |
| 4872 | |
| 4873 | dprintk("%s: bitmap is %x\n", __func__, bitmap[2]); |
| 4874 | *res = 0; |
| 4875 | if (bitmap[2] & FATTR4_WORD2_CLONE_BLKSIZE) { |
| 4876 | p = xdr_inline_decode(xdr, 4); |
Chuck Lever | eb72f48 | 2019-02-11 11:24:21 -0500 | [diff] [blame] | 4877 | if (unlikely(!p)) |
Peng Tao | 2a92ee9 | 2015-09-26 02:24:37 +0800 | [diff] [blame] | 4878 | return -EIO; |
Peng Tao | 2a92ee9 | 2015-09-26 02:24:37 +0800 | [diff] [blame] | 4879 | *res = be32_to_cpup(p); |
| 4880 | bitmap[2] &= ~FATTR4_WORD2_CLONE_BLKSIZE; |
| 4881 | } |
| 4882 | return 0; |
| 4883 | } |
| 4884 | |
Trond Myklebust | 7f08a33 | 2021-03-26 09:50:19 -0400 | [diff] [blame] | 4885 | static int decode_attr_change_attr_type(struct xdr_stream *xdr, |
| 4886 | uint32_t *bitmap, |
| 4887 | enum nfs4_change_attr_type *res) |
| 4888 | { |
| 4889 | u32 tmp = NFS4_CHANGE_TYPE_IS_UNDEFINED; |
| 4890 | |
| 4891 | dprintk("%s: bitmap is %x\n", __func__, bitmap[2]); |
| 4892 | if (bitmap[2] & FATTR4_WORD2_CHANGE_ATTR_TYPE) { |
| 4893 | if (xdr_stream_decode_u32(xdr, &tmp)) |
| 4894 | return -EIO; |
| 4895 | bitmap[2] &= ~FATTR4_WORD2_CHANGE_ATTR_TYPE; |
| 4896 | } |
| 4897 | |
| 4898 | switch(tmp) { |
| 4899 | case NFS4_CHANGE_TYPE_IS_MONOTONIC_INCR: |
| 4900 | case NFS4_CHANGE_TYPE_IS_VERSION_COUNTER: |
| 4901 | case NFS4_CHANGE_TYPE_IS_VERSION_COUNTER_NOPNFS: |
| 4902 | case NFS4_CHANGE_TYPE_IS_TIME_METADATA: |
| 4903 | *res = tmp; |
| 4904 | break; |
| 4905 | default: |
| 4906 | *res = NFS4_CHANGE_TYPE_IS_UNDEFINED; |
| 4907 | } |
| 4908 | return 0; |
| 4909 | } |
| 4910 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4911 | static int decode_fsinfo(struct xdr_stream *xdr, struct nfs_fsinfo *fsinfo) |
| 4912 | { |
Trond Myklebust | 256e48b | 2012-06-21 11:18:13 -0400 | [diff] [blame] | 4913 | unsigned int savep; |
Fred Isaman | dae100c | 2011-07-30 20:52:37 -0400 | [diff] [blame] | 4914 | uint32_t attrlen, bitmap[3]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4915 | int status; |
| 4916 | |
| 4917 | if ((status = decode_op_hdr(xdr, OP_GETATTR)) != 0) |
| 4918 | goto xdr_error; |
| 4919 | if ((status = decode_attr_bitmap(xdr, bitmap)) != 0) |
| 4920 | goto xdr_error; |
| 4921 | if ((status = decode_attr_length(xdr, &attrlen, &savep)) != 0) |
| 4922 | goto xdr_error; |
| 4923 | |
| 4924 | fsinfo->rtmult = fsinfo->wtmult = 512; /* ??? */ |
| 4925 | |
| 4926 | if ((status = decode_attr_lease_time(xdr, bitmap, &fsinfo->lease_time)) != 0) |
| 4927 | goto xdr_error; |
| 4928 | if ((status = decode_attr_maxfilesize(xdr, bitmap, &fsinfo->maxfilesize)) != 0) |
| 4929 | goto xdr_error; |
| 4930 | if ((status = decode_attr_maxread(xdr, bitmap, &fsinfo->rtmax)) != 0) |
| 4931 | goto xdr_error; |
| 4932 | fsinfo->rtpref = fsinfo->dtpref = fsinfo->rtmax; |
| 4933 | if ((status = decode_attr_maxwrite(xdr, bitmap, &fsinfo->wtmax)) != 0) |
| 4934 | goto xdr_error; |
| 4935 | fsinfo->wtpref = fsinfo->wtmax; |
Andreas Gruenbacher | 1ca843a | 2015-11-03 18:25:33 +0100 | [diff] [blame] | 4936 | |
| 4937 | status = -EIO; |
| 4938 | if (unlikely(bitmap[0])) |
| 4939 | goto xdr_error; |
| 4940 | |
Ricardo Labiaga | 55b6e77 | 2010-10-12 16:30:06 -0700 | [diff] [blame] | 4941 | status = decode_attr_time_delta(xdr, bitmap, &fsinfo->time_delta); |
| 4942 | if (status != 0) |
| 4943 | goto xdr_error; |
Jeff Layton | ca440c3 | 2016-09-15 14:40:49 -0400 | [diff] [blame] | 4944 | status = decode_attr_pnfstype(xdr, bitmap, fsinfo); |
Andy Adamson | 504913f | 2010-10-20 00:17:57 -0400 | [diff] [blame] | 4945 | if (status != 0) |
| 4946 | goto xdr_error; |
Andreas Gruenbacher | 1ca843a | 2015-11-03 18:25:33 +0100 | [diff] [blame] | 4947 | |
| 4948 | status = -EIO; |
| 4949 | if (unlikely(bitmap[1])) |
| 4950 | goto xdr_error; |
| 4951 | |
Fred Isaman | dae100c | 2011-07-30 20:52:37 -0400 | [diff] [blame] | 4952 | status = decode_attr_layout_blksize(xdr, bitmap, &fsinfo->blksize); |
| 4953 | if (status) |
| 4954 | goto xdr_error; |
Peng Tao | 2a92ee9 | 2015-09-26 02:24:37 +0800 | [diff] [blame] | 4955 | status = decode_attr_clone_blksize(xdr, bitmap, &fsinfo->clone_blksize); |
| 4956 | if (status) |
| 4957 | goto xdr_error; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4958 | |
Trond Myklebust | 7f08a33 | 2021-03-26 09:50:19 -0400 | [diff] [blame] | 4959 | status = decode_attr_change_attr_type(xdr, bitmap, |
| 4960 | &fsinfo->change_attr_type); |
| 4961 | if (status) |
| 4962 | goto xdr_error; |
| 4963 | |
Frank van der Linden | b78ef84 | 2020-06-23 22:38:55 +0000 | [diff] [blame] | 4964 | status = decode_attr_xattrsupport(xdr, bitmap, |
| 4965 | &fsinfo->xattr_support); |
| 4966 | if (status) |
| 4967 | goto xdr_error; |
| 4968 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4969 | status = verify_attr_len(xdr, savep, attrlen); |
| 4970 | xdr_error: |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 4971 | dprintk("%s: xdr returned %d!\n", __func__, -status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4972 | return status; |
| 4973 | } |
| 4974 | |
| 4975 | static int decode_getfh(struct xdr_stream *xdr, struct nfs_fh *fh) |
| 4976 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 4977 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4978 | uint32_t len; |
| 4979 | int status; |
| 4980 | |
Trond Myklebust | 9936781 | 2007-07-17 21:52:41 -0400 | [diff] [blame] | 4981 | /* Zero handle first to allow comparisons */ |
| 4982 | memset(fh, 0, sizeof(*fh)); |
| 4983 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4984 | status = decode_op_hdr(xdr, OP_GETFH); |
| 4985 | if (status) |
| 4986 | return status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4987 | |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 4988 | p = xdr_inline_decode(xdr, 4); |
| 4989 | if (unlikely(!p)) |
Chuck Lever | eb72f48 | 2019-02-11 11:24:21 -0500 | [diff] [blame] | 4990 | return -EIO; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 4991 | len = be32_to_cpup(p); |
Trond Myklebust | eb3d58c | 2021-04-01 14:03:26 -0400 | [diff] [blame] | 4992 | if (len > NFS4_FHSIZE || len == 0) { |
| 4993 | trace_nfs4_xdr_bad_filehandle(xdr, OP_GETFH, NFS4ERR_BADHANDLE); |
| 4994 | return -EREMOTEIO; |
| 4995 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4996 | fh->size = len; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 4997 | p = xdr_inline_decode(xdr, len); |
| 4998 | if (unlikely(!p)) |
Chuck Lever | eb72f48 | 2019-02-11 11:24:21 -0500 | [diff] [blame] | 4999 | return -EIO; |
Benny Halevy | 99398d0 | 2009-08-14 17:20:05 +0300 | [diff] [blame] | 5000 | memcpy(fh->data, p, len); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5001 | return 0; |
| 5002 | } |
| 5003 | |
| 5004 | static int decode_link(struct xdr_stream *xdr, struct nfs4_change_info *cinfo) |
| 5005 | { |
| 5006 | int status; |
Andy Adamson | 6c0195a | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 5007 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5008 | status = decode_op_hdr(xdr, OP_LINK); |
| 5009 | if (status) |
| 5010 | return status; |
| 5011 | return decode_change_info(xdr, cinfo); |
| 5012 | } |
| 5013 | |
| 5014 | /* |
| 5015 | * We create the owner, so we know a proper owner.id length is 4. |
| 5016 | */ |
Trond Myklebust | 911d1aa | 2006-01-03 09:55:16 +0100 | [diff] [blame] | 5017 | 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] | 5018 | { |
Trond Myklebust | 911d1aa | 2006-01-03 09:55:16 +0100 | [diff] [blame] | 5019 | uint64_t offset, length, clientid; |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 5020 | __be32 *p; |
Trond Myklebust | 911d1aa | 2006-01-03 09:55:16 +0100 | [diff] [blame] | 5021 | uint32_t namelen, type; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5022 | |
Bryan Schumaker | babddc7 | 2010-10-20 15:44:29 -0400 | [diff] [blame] | 5023 | p = xdr_inline_decode(xdr, 32); /* read 32 bytes */ |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 5024 | if (unlikely(!p)) |
Chuck Lever | eb72f48 | 2019-02-11 11:24:21 -0500 | [diff] [blame] | 5025 | return -EIO; |
Bryan Schumaker | babddc7 | 2010-10-20 15:44:29 -0400 | [diff] [blame] | 5026 | p = xdr_decode_hyper(p, &offset); /* read 2 8-byte long words */ |
Benny Halevy | 3ceb4db | 2009-08-14 17:19:41 +0300 | [diff] [blame] | 5027 | p = xdr_decode_hyper(p, &length); |
Bryan Schumaker | babddc7 | 2010-10-20 15:44:29 -0400 | [diff] [blame] | 5028 | type = be32_to_cpup(p++); /* 4 byte read */ |
| 5029 | if (fl != NULL) { /* manipulate file lock */ |
Trond Myklebust | 911d1aa | 2006-01-03 09:55:16 +0100 | [diff] [blame] | 5030 | fl->fl_start = (loff_t)offset; |
| 5031 | fl->fl_end = fl->fl_start + (loff_t)length - 1; |
| 5032 | if (length == ~(uint64_t)0) |
| 5033 | fl->fl_end = OFFSET_MAX; |
| 5034 | fl->fl_type = F_WRLCK; |
| 5035 | if (type & 1) |
| 5036 | fl->fl_type = F_RDLCK; |
| 5037 | fl->fl_pid = 0; |
| 5038 | } |
Bryan Schumaker | babddc7 | 2010-10-20 15:44:29 -0400 | [diff] [blame] | 5039 | p = xdr_decode_hyper(p, &clientid); /* read 8 bytes */ |
| 5040 | namelen = be32_to_cpup(p); /* read 4 bytes */ /* have read all 32 bytes now */ |
| 5041 | p = xdr_inline_decode(xdr, namelen); /* variable size field */ |
Chuck Lever | eb72f48 | 2019-02-11 11:24:21 -0500 | [diff] [blame] | 5042 | if (likely(!p)) |
| 5043 | return -EIO; |
| 5044 | return -NFS4ERR_DENIED; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5045 | } |
| 5046 | |
Trond Myklebust | 911d1aa | 2006-01-03 09:55:16 +0100 | [diff] [blame] | 5047 | 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] | 5048 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5049 | int status; |
| 5050 | |
| 5051 | status = decode_op_hdr(xdr, OP_LOCK); |
Trond Myklebust | c1d5193 | 2008-04-07 13:20:54 -0400 | [diff] [blame] | 5052 | if (status == -EIO) |
| 5053 | goto out; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5054 | if (status == 0) { |
Trond Myklebust | 93b717f | 2016-05-16 17:42:43 -0400 | [diff] [blame] | 5055 | status = decode_lock_stateid(xdr, &res->stateid); |
Benny Halevy | 07d3043 | 2009-08-14 17:19:52 +0300 | [diff] [blame] | 5056 | if (unlikely(status)) |
| 5057 | goto out; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5058 | } else if (status == -NFS4ERR_DENIED) |
Trond Myklebust | c1d5193 | 2008-04-07 13:20:54 -0400 | [diff] [blame] | 5059 | status = decode_lock_denied(xdr, NULL); |
| 5060 | if (res->open_seqid != NULL) |
| 5061 | nfs_increment_open_seqid(status, res->open_seqid); |
| 5062 | nfs_increment_lock_seqid(status, res->lock_seqid); |
| 5063 | out: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5064 | return status; |
| 5065 | } |
| 5066 | |
Trond Myklebust | 911d1aa | 2006-01-03 09:55:16 +0100 | [diff] [blame] | 5067 | 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] | 5068 | { |
| 5069 | int status; |
| 5070 | status = decode_op_hdr(xdr, OP_LOCKT); |
| 5071 | if (status == -NFS4ERR_DENIED) |
Trond Myklebust | 911d1aa | 2006-01-03 09:55:16 +0100 | [diff] [blame] | 5072 | return decode_lock_denied(xdr, res->denied); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5073 | return status; |
| 5074 | } |
| 5075 | |
Trond Myklebust | 911d1aa | 2006-01-03 09:55:16 +0100 | [diff] [blame] | 5076 | 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] | 5077 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5078 | int status; |
| 5079 | |
| 5080 | status = decode_op_hdr(xdr, OP_LOCKU); |
Trond Myklebust | c1d5193 | 2008-04-07 13:20:54 -0400 | [diff] [blame] | 5081 | if (status != -EIO) |
| 5082 | nfs_increment_lock_seqid(status, res->seqid); |
Benny Halevy | 07d3043 | 2009-08-14 17:19:52 +0300 | [diff] [blame] | 5083 | if (status == 0) |
Trond Myklebust | 93b717f | 2016-05-16 17:42:43 -0400 | [diff] [blame] | 5084 | status = decode_lock_stateid(xdr, &res->stateid); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5085 | return status; |
| 5086 | } |
| 5087 | |
Trond Myklebust | d3c7b7c | 2010-07-01 12:49:01 -0400 | [diff] [blame] | 5088 | static int decode_release_lockowner(struct xdr_stream *xdr) |
| 5089 | { |
| 5090 | return decode_op_hdr(xdr, OP_RELEASE_LOCKOWNER); |
| 5091 | } |
| 5092 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5093 | static int decode_lookup(struct xdr_stream *xdr) |
| 5094 | { |
| 5095 | return decode_op_hdr(xdr, OP_LOOKUP); |
| 5096 | } |
| 5097 | |
Jeff Layton | 5b5faaf | 2017-06-29 06:34:52 -0700 | [diff] [blame] | 5098 | static int decode_lookupp(struct xdr_stream *xdr) |
| 5099 | { |
| 5100 | return decode_op_hdr(xdr, OP_LOOKUPP); |
| 5101 | } |
| 5102 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5103 | /* This is too sick! */ |
Trond Myklebust | 7d160a6 | 2015-09-05 19:06:57 -0400 | [diff] [blame] | 5104 | static int decode_space_limit(struct xdr_stream *xdr, |
| 5105 | unsigned long *pagemod_limit) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5106 | { |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 5107 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5108 | uint32_t limit_type, nblocks, blocksize; |
Trond Myklebust | 7d160a6 | 2015-09-05 19:06:57 -0400 | [diff] [blame] | 5109 | u64 maxsize = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5110 | |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 5111 | p = xdr_inline_decode(xdr, 12); |
| 5112 | if (unlikely(!p)) |
Chuck Lever | eb72f48 | 2019-02-11 11:24:21 -0500 | [diff] [blame] | 5113 | return -EIO; |
Benny Halevy | 6f723f7 | 2009-08-14 17:19:37 +0300 | [diff] [blame] | 5114 | limit_type = be32_to_cpup(p++); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5115 | switch (limit_type) { |
Trond Myklebust | 7d160a6 | 2015-09-05 19:06:57 -0400 | [diff] [blame] | 5116 | case NFS4_LIMIT_SIZE: |
| 5117 | xdr_decode_hyper(p, &maxsize); |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 5118 | break; |
Trond Myklebust | 7d160a6 | 2015-09-05 19:06:57 -0400 | [diff] [blame] | 5119 | case NFS4_LIMIT_BLOCKS: |
Benny Halevy | 6f723f7 | 2009-08-14 17:19:37 +0300 | [diff] [blame] | 5120 | nblocks = be32_to_cpup(p++); |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 5121 | blocksize = be32_to_cpup(p); |
Trond Myklebust | 7d160a6 | 2015-09-05 19:06:57 -0400 | [diff] [blame] | 5122 | maxsize = (uint64_t)nblocks * (uint64_t)blocksize; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5123 | } |
Kirill A. Shutemov | 09cbfea | 2016-04-01 15:29:47 +0300 | [diff] [blame] | 5124 | maxsize >>= PAGE_SHIFT; |
Trond Myklebust | 7d160a6 | 2015-09-05 19:06:57 -0400 | [diff] [blame] | 5125 | *pagemod_limit = min_t(u64, maxsize, ULONG_MAX); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5126 | return 0; |
| 5127 | } |
| 5128 | |
Trond Myklebust | 6ae3733 | 2015-01-30 14:21:14 -0500 | [diff] [blame] | 5129 | static int decode_rw_delegation(struct xdr_stream *xdr, |
| 5130 | uint32_t delegation_type, |
| 5131 | struct nfs_openres *res) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5132 | { |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 5133 | __be32 *p; |
Benny Halevy | 07d3043 | 2009-08-14 17:19:52 +0300 | [diff] [blame] | 5134 | int status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5135 | |
Trond Myklebust | 93b717f | 2016-05-16 17:42:43 -0400 | [diff] [blame] | 5136 | status = decode_delegation_stateid(xdr, &res->delegation); |
Benny Halevy | 07d3043 | 2009-08-14 17:19:52 +0300 | [diff] [blame] | 5137 | if (unlikely(status)) |
| 5138 | return status; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 5139 | p = xdr_inline_decode(xdr, 4); |
| 5140 | if (unlikely(!p)) |
Chuck Lever | eb72f48 | 2019-02-11 11:24:21 -0500 | [diff] [blame] | 5141 | return -EIO; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 5142 | res->do_recall = be32_to_cpup(p); |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 5143 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5144 | switch (delegation_type) { |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 5145 | case NFS4_OPEN_DELEGATE_READ: |
| 5146 | res->delegation_type = FMODE_READ; |
| 5147 | break; |
| 5148 | case NFS4_OPEN_DELEGATE_WRITE: |
| 5149 | res->delegation_type = FMODE_WRITE|FMODE_READ; |
Trond Myklebust | 7d160a6 | 2015-09-05 19:06:57 -0400 | [diff] [blame] | 5150 | if (decode_space_limit(xdr, &res->pagemod_limit) < 0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5151 | return -EIO; |
| 5152 | } |
Trond Myklebust | 1bbe60f | 2017-02-19 16:08:30 -0500 | [diff] [blame] | 5153 | return decode_ace(xdr, NULL); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5154 | } |
| 5155 | |
Trond Myklebust | 6ae3733 | 2015-01-30 14:21:14 -0500 | [diff] [blame] | 5156 | static int decode_no_delegation(struct xdr_stream *xdr, struct nfs_openres *res) |
| 5157 | { |
| 5158 | __be32 *p; |
| 5159 | uint32_t why_no_delegation; |
| 5160 | |
| 5161 | p = xdr_inline_decode(xdr, 4); |
| 5162 | if (unlikely(!p)) |
Chuck Lever | eb72f48 | 2019-02-11 11:24:21 -0500 | [diff] [blame] | 5163 | return -EIO; |
Trond Myklebust | 6ae3733 | 2015-01-30 14:21:14 -0500 | [diff] [blame] | 5164 | why_no_delegation = be32_to_cpup(p); |
| 5165 | switch (why_no_delegation) { |
| 5166 | case WND4_CONTENTION: |
| 5167 | case WND4_RESOURCE: |
| 5168 | xdr_inline_decode(xdr, 4); |
| 5169 | /* Ignore for now */ |
| 5170 | } |
| 5171 | return 0; |
Trond Myklebust | 6ae3733 | 2015-01-30 14:21:14 -0500 | [diff] [blame] | 5172 | } |
| 5173 | |
| 5174 | static int decode_delegation(struct xdr_stream *xdr, struct nfs_openres *res) |
| 5175 | { |
| 5176 | __be32 *p; |
| 5177 | uint32_t delegation_type; |
| 5178 | |
| 5179 | p = xdr_inline_decode(xdr, 4); |
| 5180 | if (unlikely(!p)) |
Chuck Lever | eb72f48 | 2019-02-11 11:24:21 -0500 | [diff] [blame] | 5181 | return -EIO; |
Trond Myklebust | 6ae3733 | 2015-01-30 14:21:14 -0500 | [diff] [blame] | 5182 | delegation_type = be32_to_cpup(p); |
| 5183 | res->delegation_type = 0; |
| 5184 | switch (delegation_type) { |
| 5185 | case NFS4_OPEN_DELEGATE_NONE: |
| 5186 | return 0; |
| 5187 | case NFS4_OPEN_DELEGATE_READ: |
| 5188 | case NFS4_OPEN_DELEGATE_WRITE: |
| 5189 | return decode_rw_delegation(xdr, delegation_type, res); |
| 5190 | case NFS4_OPEN_DELEGATE_NONE_EXT: |
| 5191 | return decode_no_delegation(xdr, res); |
| 5192 | } |
| 5193 | return -EIO; |
Trond Myklebust | 6ae3733 | 2015-01-30 14:21:14 -0500 | [diff] [blame] | 5194 | } |
| 5195 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5196 | static int decode_open(struct xdr_stream *xdr, struct nfs_openres *res) |
| 5197 | { |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 5198 | __be32 *p; |
Jeff Layton | aa53ed5 | 2007-06-05 14:49:03 -0400 | [diff] [blame] | 5199 | uint32_t savewords, bmlen, i; |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 5200 | int status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5201 | |
Trond Myklebust | c7848f6 | 2013-12-04 17:39:23 -0500 | [diff] [blame] | 5202 | if (!__decode_op_hdr(xdr, OP_OPEN, &status)) |
| 5203 | return status; |
| 5204 | nfs_increment_open_seqid(status, res->seqid); |
| 5205 | if (status) |
| 5206 | return status; |
Trond Myklebust | 93b717f | 2016-05-16 17:42:43 -0400 | [diff] [blame] | 5207 | status = decode_open_stateid(xdr, &res->stateid); |
Benny Halevy | 07d3043 | 2009-08-14 17:19:52 +0300 | [diff] [blame] | 5208 | if (unlikely(status)) |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 5209 | return status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5210 | |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 5211 | decode_change_info(xdr, &res->cinfo); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5212 | |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 5213 | p = xdr_inline_decode(xdr, 8); |
| 5214 | if (unlikely(!p)) |
Chuck Lever | eb72f48 | 2019-02-11 11:24:21 -0500 | [diff] [blame] | 5215 | return -EIO; |
Benny Halevy | 6f723f7 | 2009-08-14 17:19:37 +0300 | [diff] [blame] | 5216 | res->rflags = be32_to_cpup(p++); |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 5217 | bmlen = be32_to_cpup(p); |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 5218 | if (bmlen > 10) |
| 5219 | goto xdr_error; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5220 | |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 5221 | p = xdr_inline_decode(xdr, bmlen << 2); |
| 5222 | if (unlikely(!p)) |
Chuck Lever | eb72f48 | 2019-02-11 11:24:21 -0500 | [diff] [blame] | 5223 | return -EIO; |
Jeff Layton | aa53ed5 | 2007-06-05 14:49:03 -0400 | [diff] [blame] | 5224 | savewords = min_t(uint32_t, bmlen, NFS4_BITMAP_SIZE); |
| 5225 | for (i = 0; i < savewords; ++i) |
Benny Halevy | 6f723f7 | 2009-08-14 17:19:37 +0300 | [diff] [blame] | 5226 | res->attrset[i] = be32_to_cpup(p++); |
Jeff Layton | aa53ed5 | 2007-06-05 14:49:03 -0400 | [diff] [blame] | 5227 | for (; i < NFS4_BITMAP_SIZE; i++) |
| 5228 | res->attrset[i] = 0; |
| 5229 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5230 | return decode_delegation(xdr, res); |
| 5231 | xdr_error: |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 5232 | dprintk("%s: Bitmap too large! Length = %u\n", __func__, bmlen); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5233 | return -EIO; |
| 5234 | } |
| 5235 | |
| 5236 | static int decode_open_confirm(struct xdr_stream *xdr, struct nfs_open_confirmres *res) |
| 5237 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5238 | int status; |
| 5239 | |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 5240 | status = decode_op_hdr(xdr, OP_OPEN_CONFIRM); |
Trond Myklebust | c1d5193 | 2008-04-07 13:20:54 -0400 | [diff] [blame] | 5241 | if (status != -EIO) |
| 5242 | nfs_increment_open_seqid(status, res->seqid); |
Benny Halevy | 07d3043 | 2009-08-14 17:19:52 +0300 | [diff] [blame] | 5243 | if (!status) |
Trond Myklebust | 93b717f | 2016-05-16 17:42:43 -0400 | [diff] [blame] | 5244 | status = decode_open_stateid(xdr, &res->stateid); |
Benny Halevy | 07d3043 | 2009-08-14 17:19:52 +0300 | [diff] [blame] | 5245 | return status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5246 | } |
| 5247 | |
| 5248 | static int decode_open_downgrade(struct xdr_stream *xdr, struct nfs_closeres *res) |
| 5249 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5250 | int status; |
| 5251 | |
| 5252 | status = decode_op_hdr(xdr, OP_OPEN_DOWNGRADE); |
Trond Myklebust | c1d5193 | 2008-04-07 13:20:54 -0400 | [diff] [blame] | 5253 | if (status != -EIO) |
| 5254 | nfs_increment_open_seqid(status, res->seqid); |
Benny Halevy | 07d3043 | 2009-08-14 17:19:52 +0300 | [diff] [blame] | 5255 | if (!status) |
Trond Myklebust | 93b717f | 2016-05-16 17:42:43 -0400 | [diff] [blame] | 5256 | status = decode_open_stateid(xdr, &res->stateid); |
Benny Halevy | 07d3043 | 2009-08-14 17:19:52 +0300 | [diff] [blame] | 5257 | return status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5258 | } |
| 5259 | |
| 5260 | static int decode_putfh(struct xdr_stream *xdr) |
| 5261 | { |
| 5262 | return decode_op_hdr(xdr, OP_PUTFH); |
| 5263 | } |
| 5264 | |
| 5265 | static int decode_putrootfh(struct xdr_stream *xdr) |
| 5266 | { |
| 5267 | return decode_op_hdr(xdr, OP_PUTROOTFH); |
| 5268 | } |
| 5269 | |
Anna Schumaker | 9137bdf | 2014-05-06 09:12:25 -0400 | [diff] [blame] | 5270 | static int decode_read(struct xdr_stream *xdr, struct rpc_rqst *req, |
| 5271 | struct nfs_pgio_res *res) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5272 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 5273 | __be32 *p; |
Trond Myklebust | 64bd577 | 2012-06-20 22:35:05 -0400 | [diff] [blame] | 5274 | uint32_t count, eof, recvd; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5275 | int status; |
| 5276 | |
| 5277 | status = decode_op_hdr(xdr, OP_READ); |
| 5278 | if (status) |
| 5279 | return status; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 5280 | p = xdr_inline_decode(xdr, 8); |
| 5281 | if (unlikely(!p)) |
Chuck Lever | eb72f48 | 2019-02-11 11:24:21 -0500 | [diff] [blame] | 5282 | return -EIO; |
Benny Halevy | 6f723f7 | 2009-08-14 17:19:37 +0300 | [diff] [blame] | 5283 | eof = be32_to_cpup(p++); |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 5284 | count = be32_to_cpup(p); |
Trond Myklebust | 64bd577 | 2012-06-20 22:35:05 -0400 | [diff] [blame] | 5285 | recvd = xdr_read_pages(xdr, count); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5286 | if (count > recvd) { |
Chuck Lever | fe82a18 | 2007-09-11 18:01:10 -0400 | [diff] [blame] | 5287 | dprintk("NFS: server cheating in read reply: " |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5288 | "count %u > recvd %u\n", count, recvd); |
| 5289 | count = recvd; |
| 5290 | eof = 0; |
| 5291 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5292 | res->eof = eof; |
| 5293 | res->count = count; |
| 5294 | return 0; |
| 5295 | } |
| 5296 | |
| 5297 | static int decode_readdir(struct xdr_stream *xdr, struct rpc_rqst *req, struct nfs4_readdir_res *readdir) |
| 5298 | { |
Chuck Lever | bcecff7 | 2007-10-26 13:32:03 -0400 | [diff] [blame] | 5299 | int status; |
Chuck Lever | cd93710 | 2012-03-02 17:14:31 -0500 | [diff] [blame] | 5300 | __be32 verf[2]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5301 | |
| 5302 | status = decode_op_hdr(xdr, OP_READDIR); |
Benny Halevy | db942bb | 2009-08-14 17:19:56 +0300 | [diff] [blame] | 5303 | if (!status) |
| 5304 | status = decode_verifier(xdr, readdir->verifier.data); |
| 5305 | if (unlikely(status)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5306 | return status; |
Chuck Lever | cd93710 | 2012-03-02 17:14:31 -0500 | [diff] [blame] | 5307 | memcpy(verf, readdir->verifier.data, sizeof(verf)); |
Fred Isaman | 4410924 | 2008-04-02 15:21:15 +0300 | [diff] [blame] | 5308 | dprintk("%s: verifier = %08x:%08x\n", |
Chuck Lever | cd93710 | 2012-03-02 17:14:31 -0500 | [diff] [blame] | 5309 | __func__, verf[0], verf[1]); |
Trond Myklebust | 64bd577 | 2012-06-20 22:35:05 -0400 | [diff] [blame] | 5310 | return xdr_read_pages(xdr, xdr->buf->page_len); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5311 | } |
| 5312 | |
| 5313 | static int decode_readlink(struct xdr_stream *xdr, struct rpc_rqst *req) |
| 5314 | { |
| 5315 | struct xdr_buf *rcvbuf = &req->rq_rcv_buf; |
Chuck Lever | bcecff7 | 2007-10-26 13:32:03 -0400 | [diff] [blame] | 5316 | u32 len, recvd; |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 5317 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5318 | int status; |
| 5319 | |
| 5320 | status = decode_op_hdr(xdr, OP_READLINK); |
| 5321 | if (status) |
| 5322 | return status; |
| 5323 | |
| 5324 | /* Convert length of symlink */ |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 5325 | p = xdr_inline_decode(xdr, 4); |
| 5326 | if (unlikely(!p)) |
Chuck Lever | eb72f48 | 2019-02-11 11:24:21 -0500 | [diff] [blame] | 5327 | return -EIO; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 5328 | len = be32_to_cpup(p); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5329 | if (len >= rcvbuf->page_len || len <= 0) { |
Chuck Lever | fe82a18 | 2007-09-11 18:01:10 -0400 | [diff] [blame] | 5330 | dprintk("nfs: server returned giant symlink!\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5331 | return -ENAMETOOLONG; |
| 5332 | } |
Trond Myklebust | 64bd577 | 2012-06-20 22:35:05 -0400 | [diff] [blame] | 5333 | recvd = xdr_read_pages(xdr, len); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5334 | if (recvd < len) { |
Chuck Lever | fe82a18 | 2007-09-11 18:01:10 -0400 | [diff] [blame] | 5335 | dprintk("NFS: server cheating in readlink reply: " |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5336 | "count %u > recvd %u\n", len, recvd); |
| 5337 | return -EIO; |
| 5338 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5339 | /* |
| 5340 | * The XDR encode routine has set things up so that |
| 5341 | * the link text will be copied directly into the |
| 5342 | * buffer. We just have to do overflow-checking, |
Randy Dunlap | a503291 | 2020-08-10 19:18:35 -0700 | [diff] [blame] | 5343 | * and null-terminate the text (the VFS expects |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5344 | * null-termination). |
| 5345 | */ |
Chuck Lever | b4687da | 2010-09-21 16:55:48 -0400 | [diff] [blame] | 5346 | xdr_terminate_string(rcvbuf, len); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5347 | return 0; |
| 5348 | } |
| 5349 | |
| 5350 | static int decode_remove(struct xdr_stream *xdr, struct nfs4_change_info *cinfo) |
| 5351 | { |
| 5352 | int status; |
| 5353 | |
| 5354 | status = decode_op_hdr(xdr, OP_REMOVE); |
| 5355 | if (status) |
| 5356 | goto out; |
| 5357 | status = decode_change_info(xdr, cinfo); |
| 5358 | out: |
| 5359 | return status; |
| 5360 | } |
| 5361 | |
| 5362 | static int decode_rename(struct xdr_stream *xdr, struct nfs4_change_info *old_cinfo, |
| 5363 | struct nfs4_change_info *new_cinfo) |
| 5364 | { |
| 5365 | int status; |
| 5366 | |
| 5367 | status = decode_op_hdr(xdr, OP_RENAME); |
| 5368 | if (status) |
| 5369 | goto out; |
| 5370 | if ((status = decode_change_info(xdr, old_cinfo))) |
| 5371 | goto out; |
| 5372 | status = decode_change_info(xdr, new_cinfo); |
| 5373 | out: |
| 5374 | return status; |
| 5375 | } |
| 5376 | |
| 5377 | static int decode_renew(struct xdr_stream *xdr) |
| 5378 | { |
| 5379 | return decode_op_hdr(xdr, OP_RENEW); |
| 5380 | } |
| 5381 | |
Trond Myklebust | 56ae19f | 2005-10-27 22:12:40 -0400 | [diff] [blame] | 5382 | static int |
| 5383 | decode_restorefh(struct xdr_stream *xdr) |
| 5384 | { |
| 5385 | return decode_op_hdr(xdr, OP_RESTOREFH); |
| 5386 | } |
| 5387 | |
J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 5388 | static int decode_getacl(struct xdr_stream *xdr, struct rpc_rqst *req, |
Andy Adamson | bf118a3 | 2011-12-07 11:55:27 -0500 | [diff] [blame] | 5389 | struct nfs_getaclres *res) |
J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 5390 | { |
Trond Myklebust | 256e48b | 2012-06-21 11:18:13 -0400 | [diff] [blame] | 5391 | unsigned int savep; |
J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 5392 | uint32_t attrlen, |
Fred Isaman | dae100c | 2011-07-30 20:52:37 -0400 | [diff] [blame] | 5393 | bitmap[3] = {0}; |
J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 5394 | int status; |
| 5395 | |
Andy Adamson | bf118a3 | 2011-12-07 11:55:27 -0500 | [diff] [blame] | 5396 | res->acl_len = 0; |
J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 5397 | if ((status = decode_op_hdr(xdr, OP_GETATTR)) != 0) |
| 5398 | goto out; |
Sachin Prabhu | 5a00689 | 2012-04-17 14:35:39 +0100 | [diff] [blame] | 5399 | |
Trond Myklebust | 519d395 | 2012-08-14 17:30:10 -0400 | [diff] [blame] | 5400 | xdr_enter_page(xdr, xdr->buf->page_len); |
| 5401 | |
J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 5402 | if ((status = decode_attr_bitmap(xdr, bitmap)) != 0) |
| 5403 | goto out; |
| 5404 | if ((status = decode_attr_length(xdr, &attrlen, &savep)) != 0) |
| 5405 | goto out; |
| 5406 | |
| 5407 | if (unlikely(bitmap[0] & (FATTR4_WORD0_ACL - 1U))) |
| 5408 | return -EIO; |
| 5409 | if (likely(bitmap[0] & FATTR4_WORD0_ACL)) { |
J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 5410 | |
Andy Adamson | bf118a3 | 2011-12-07 11:55:27 -0500 | [diff] [blame] | 5411 | /* The bitmap (xdr len + bitmaps) and the attr xdr len words |
| 5412 | * are stored with the acl data to handle the problem of |
| 5413 | * variable length bitmaps.*/ |
Anna Schumaker | a14a635 | 2020-04-17 11:01:50 -0400 | [diff] [blame] | 5414 | res->acl_data_offset = xdr_page_pos(xdr); |
Trond Myklebust | 519d395 | 2012-08-14 17:30:10 -0400 | [diff] [blame] | 5415 | res->acl_len = attrlen; |
Trond Myklebust | 1f1ea6c | 2012-08-26 11:44:43 -0700 | [diff] [blame] | 5416 | |
| 5417 | /* Check for receive buffer overflow */ |
Trond Myklebust | 1706846 | 2020-11-21 21:41:08 -0500 | [diff] [blame] | 5418 | if (res->acl_len > xdr_stream_remaining(xdr) || |
Trond Myklebust | 1f1ea6c | 2012-08-26 11:44:43 -0700 | [diff] [blame] | 5419 | res->acl_len + res->acl_data_offset > xdr->buf->page_len) { |
| 5420 | res->acl_flags |= NFS4_ACL_TRUNC; |
Trond Myklebust | 1706846 | 2020-11-21 21:41:08 -0500 | [diff] [blame] | 5421 | dprintk("NFS: acl reply: attrlen %u > page_len %zu\n", |
| 5422 | attrlen, xdr_stream_remaining(xdr)); |
J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 5423 | } |
J. Bruce Fields | 8c233cf | 2005-10-13 16:54:27 -0400 | [diff] [blame] | 5424 | } else |
| 5425 | status = -EOPNOTSUPP; |
J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 5426 | |
| 5427 | out: |
| 5428 | return status; |
| 5429 | } |
| 5430 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5431 | static int |
| 5432 | decode_savefh(struct xdr_stream *xdr) |
| 5433 | { |
| 5434 | return decode_op_hdr(xdr, OP_SAVEFH); |
| 5435 | } |
| 5436 | |
Benny Halevy | 9e9ecc0 | 2009-04-01 09:22:00 -0400 | [diff] [blame] | 5437 | static int decode_setattr(struct xdr_stream *xdr) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5438 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5439 | int status; |
| 5440 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5441 | status = decode_op_hdr(xdr, OP_SETATTR); |
| 5442 | if (status) |
| 5443 | return status; |
Trond Myklebust | 37c8876 | 2018-03-20 17:03:08 -0400 | [diff] [blame] | 5444 | if (decode_bitmap4(xdr, NULL, 0) >= 0) |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 5445 | return 0; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 5446 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5447 | } |
| 5448 | |
Trond Myklebust | bb8b27e | 2010-04-16 16:43:06 -0400 | [diff] [blame] | 5449 | 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] | 5450 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 5451 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5452 | uint32_t opnum; |
| 5453 | int32_t nfserr; |
| 5454 | |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 5455 | p = xdr_inline_decode(xdr, 8); |
| 5456 | if (unlikely(!p)) |
Chuck Lever | eb72f48 | 2019-02-11 11:24:21 -0500 | [diff] [blame] | 5457 | return -EIO; |
Benny Halevy | 6f723f7 | 2009-08-14 17:19:37 +0300 | [diff] [blame] | 5458 | opnum = be32_to_cpup(p++); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5459 | if (opnum != OP_SETCLIENTID) { |
Chuck Lever | fe82a18 | 2007-09-11 18:01:10 -0400 | [diff] [blame] | 5460 | dprintk("nfs: decode_setclientid: Server returned operation" |
Andy Adamson | 6c0195a | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 5461 | " %d\n", opnum); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5462 | return -EIO; |
| 5463 | } |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 5464 | nfserr = be32_to_cpup(p); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5465 | if (nfserr == NFS_OK) { |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 5466 | p = xdr_inline_decode(xdr, 8 + NFS4_VERIFIER_SIZE); |
| 5467 | if (unlikely(!p)) |
Chuck Lever | eb72f48 | 2019-02-11 11:24:21 -0500 | [diff] [blame] | 5468 | return -EIO; |
Trond Myklebust | bb8b27e | 2010-04-16 16:43:06 -0400 | [diff] [blame] | 5469 | p = xdr_decode_hyper(p, &res->clientid); |
| 5470 | memcpy(res->confirm.data, p, NFS4_VERIFIER_SIZE); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5471 | } else if (nfserr == NFSERR_CLID_INUSE) { |
| 5472 | uint32_t len; |
| 5473 | |
| 5474 | /* skip netid string */ |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 5475 | p = xdr_inline_decode(xdr, 4); |
| 5476 | if (unlikely(!p)) |
Chuck Lever | eb72f48 | 2019-02-11 11:24:21 -0500 | [diff] [blame] | 5477 | return -EIO; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 5478 | len = be32_to_cpup(p); |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 5479 | p = xdr_inline_decode(xdr, len); |
| 5480 | if (unlikely(!p)) |
Chuck Lever | eb72f48 | 2019-02-11 11:24:21 -0500 | [diff] [blame] | 5481 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5482 | |
| 5483 | /* skip uaddr string */ |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 5484 | p = xdr_inline_decode(xdr, 4); |
| 5485 | if (unlikely(!p)) |
Chuck Lever | eb72f48 | 2019-02-11 11:24:21 -0500 | [diff] [blame] | 5486 | return -EIO; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 5487 | len = be32_to_cpup(p); |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 5488 | p = xdr_inline_decode(xdr, len); |
| 5489 | if (unlikely(!p)) |
Chuck Lever | eb72f48 | 2019-02-11 11:24:21 -0500 | [diff] [blame] | 5490 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5491 | return -NFSERR_CLID_INUSE; |
| 5492 | } else |
Benny Halevy | 856dff3 | 2008-03-31 17:39:06 +0300 | [diff] [blame] | 5493 | return nfs4_stat_to_errno(nfserr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5494 | |
| 5495 | return 0; |
| 5496 | } |
| 5497 | |
| 5498 | static int decode_setclientid_confirm(struct xdr_stream *xdr) |
| 5499 | { |
| 5500 | return decode_op_hdr(xdr, OP_SETCLIENTID_CONFIRM); |
| 5501 | } |
| 5502 | |
Anna Schumaker | 9137bdf | 2014-05-06 09:12:25 -0400 | [diff] [blame] | 5503 | 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] | 5504 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 5505 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5506 | int status; |
| 5507 | |
| 5508 | status = decode_op_hdr(xdr, OP_WRITE); |
| 5509 | if (status) |
| 5510 | return status; |
| 5511 | |
Trond Myklebust | 2f2c63b | 2012-06-08 11:56:09 -0400 | [diff] [blame] | 5512 | p = xdr_inline_decode(xdr, 8); |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 5513 | if (unlikely(!p)) |
Chuck Lever | eb72f48 | 2019-02-11 11:24:21 -0500 | [diff] [blame] | 5514 | return -EIO; |
Benny Halevy | 6f723f7 | 2009-08-14 17:19:37 +0300 | [diff] [blame] | 5515 | res->count = be32_to_cpup(p++); |
| 5516 | res->verf->committed = be32_to_cpup(p++); |
Trond Myklebust | 2f2c63b | 2012-06-08 11:56:09 -0400 | [diff] [blame] | 5517 | return decode_write_verifier(xdr, &res->verf->verifier); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5518 | } |
| 5519 | |
| 5520 | static int decode_delegreturn(struct xdr_stream *xdr) |
| 5521 | { |
| 5522 | return decode_op_hdr(xdr, OP_DELEGRETURN); |
| 5523 | } |
| 5524 | |
Chuck Lever | fb15b26 | 2013-03-16 15:54:34 -0400 | [diff] [blame] | 5525 | static int decode_secinfo_gss(struct xdr_stream *xdr, |
| 5526 | struct nfs4_secinfo4 *flavor) |
Bryan Schumaker | 5a5ea0d | 2011-03-24 17:12:29 +0000 | [diff] [blame] | 5527 | { |
Chuck Lever | fb15b26 | 2013-03-16 15:54:34 -0400 | [diff] [blame] | 5528 | u32 oid_len; |
Bryan Schumaker | 5a5ea0d | 2011-03-24 17:12:29 +0000 | [diff] [blame] | 5529 | __be32 *p; |
| 5530 | |
| 5531 | p = xdr_inline_decode(xdr, 4); |
| 5532 | if (unlikely(!p)) |
Chuck Lever | eb72f48 | 2019-02-11 11:24:21 -0500 | [diff] [blame] | 5533 | return -EIO; |
Chuck Lever | fb15b26 | 2013-03-16 15:54:34 -0400 | [diff] [blame] | 5534 | oid_len = be32_to_cpup(p); |
| 5535 | if (oid_len > GSS_OID_MAX_LEN) |
Chuck Lever | eb72f48 | 2019-02-11 11:24:21 -0500 | [diff] [blame] | 5536 | return -EINVAL; |
Bryan Schumaker | 5a5ea0d | 2011-03-24 17:12:29 +0000 | [diff] [blame] | 5537 | |
Chuck Lever | fb15b26 | 2013-03-16 15:54:34 -0400 | [diff] [blame] | 5538 | p = xdr_inline_decode(xdr, oid_len); |
Bryan Schumaker | 5a5ea0d | 2011-03-24 17:12:29 +0000 | [diff] [blame] | 5539 | if (unlikely(!p)) |
Chuck Lever | eb72f48 | 2019-02-11 11:24:21 -0500 | [diff] [blame] | 5540 | return -EIO; |
Chuck Lever | fb15b26 | 2013-03-16 15:54:34 -0400 | [diff] [blame] | 5541 | memcpy(flavor->flavor_info.oid.data, p, oid_len); |
| 5542 | flavor->flavor_info.oid.len = oid_len; |
Bryan Schumaker | 5a5ea0d | 2011-03-24 17:12:29 +0000 | [diff] [blame] | 5543 | |
| 5544 | p = xdr_inline_decode(xdr, 8); |
| 5545 | if (unlikely(!p)) |
Chuck Lever | eb72f48 | 2019-02-11 11:24:21 -0500 | [diff] [blame] | 5546 | return -EIO; |
Chuck Lever | fb15b26 | 2013-03-16 15:54:34 -0400 | [diff] [blame] | 5547 | flavor->flavor_info.qop = be32_to_cpup(p++); |
| 5548 | flavor->flavor_info.service = be32_to_cpup(p); |
Bryan Schumaker | 5a5ea0d | 2011-03-24 17:12:29 +0000 | [diff] [blame] | 5549 | |
| 5550 | return 0; |
Bryan Schumaker | 5a5ea0d | 2011-03-24 17:12:29 +0000 | [diff] [blame] | 5551 | } |
| 5552 | |
Bryan Schumaker | 31e4dda | 2012-04-27 13:27:38 -0400 | [diff] [blame] | 5553 | 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] | 5554 | { |
Chuck Lever | fb15b26 | 2013-03-16 15:54:34 -0400 | [diff] [blame] | 5555 | struct nfs4_secinfo4 *sec_flavor; |
| 5556 | unsigned int i, num_flavors; |
Bryan Schumaker | 5a5ea0d | 2011-03-24 17:12:29 +0000 | [diff] [blame] | 5557 | int status; |
| 5558 | __be32 *p; |
Bryan Schumaker | 5a5ea0d | 2011-03-24 17:12:29 +0000 | [diff] [blame] | 5559 | |
Bryan Schumaker | 5a5ea0d | 2011-03-24 17:12:29 +0000 | [diff] [blame] | 5560 | p = xdr_inline_decode(xdr, 4); |
| 5561 | if (unlikely(!p)) |
Chuck Lever | eb72f48 | 2019-02-11 11:24:21 -0500 | [diff] [blame] | 5562 | return -EIO; |
Bryan Schumaker | 5a5ea0d | 2011-03-24 17:12:29 +0000 | [diff] [blame] | 5563 | |
Bryan Schumaker | c3dfc28 | 2011-04-13 14:31:31 -0400 | [diff] [blame] | 5564 | res->flavors->num_flavors = 0; |
| 5565 | num_flavors = be32_to_cpup(p); |
| 5566 | |
| 5567 | for (i = 0; i < num_flavors; i++) { |
Bryan Schumaker | 5a5ea0d | 2011-03-24 17:12:29 +0000 | [diff] [blame] | 5568 | sec_flavor = &res->flavors->flavors[i]; |
Bryan Schumaker | c3dfc28 | 2011-04-13 14:31:31 -0400 | [diff] [blame] | 5569 | if ((char *)&sec_flavor[1] - (char *)res->flavors > PAGE_SIZE) |
Bryan Schumaker | 5a5ea0d | 2011-03-24 17:12:29 +0000 | [diff] [blame] | 5570 | break; |
| 5571 | |
| 5572 | p = xdr_inline_decode(xdr, 4); |
| 5573 | if (unlikely(!p)) |
Chuck Lever | eb72f48 | 2019-02-11 11:24:21 -0500 | [diff] [blame] | 5574 | return -EIO; |
Bryan Schumaker | 5a5ea0d | 2011-03-24 17:12:29 +0000 | [diff] [blame] | 5575 | sec_flavor->flavor = be32_to_cpup(p); |
| 5576 | |
| 5577 | if (sec_flavor->flavor == RPC_AUTH_GSS) { |
Bryan Schumaker | 613e901 | 2011-04-27 15:28:44 -0400 | [diff] [blame] | 5578 | status = decode_secinfo_gss(xdr, sec_flavor); |
| 5579 | if (status) |
| 5580 | goto out; |
Bryan Schumaker | 5a5ea0d | 2011-03-24 17:12:29 +0000 | [diff] [blame] | 5581 | } |
Bryan Schumaker | c3dfc28 | 2011-04-13 14:31:31 -0400 | [diff] [blame] | 5582 | res->flavors->num_flavors++; |
Bryan Schumaker | 5a5ea0d | 2011-03-24 17:12:29 +0000 | [diff] [blame] | 5583 | } |
| 5584 | |
Bryan Schumaker | 31e4dda | 2012-04-27 13:27:38 -0400 | [diff] [blame] | 5585 | status = 0; |
Bryan Schumaker | 613e901 | 2011-04-27 15:28:44 -0400 | [diff] [blame] | 5586 | out: |
| 5587 | return status; |
Bryan Schumaker | 5a5ea0d | 2011-03-24 17:12:29 +0000 | [diff] [blame] | 5588 | } |
| 5589 | |
Bryan Schumaker | 31e4dda | 2012-04-27 13:27:38 -0400 | [diff] [blame] | 5590 | static int decode_secinfo(struct xdr_stream *xdr, struct nfs4_secinfo_res *res) |
| 5591 | { |
| 5592 | int status = decode_op_hdr(xdr, OP_SECINFO); |
| 5593 | if (status) |
| 5594 | return status; |
| 5595 | return decode_secinfo_common(xdr, res); |
| 5596 | } |
| 5597 | |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 5598 | #if defined(CONFIG_NFS_V4_1) |
Bryan Schumaker | 31e4dda | 2012-04-27 13:27:38 -0400 | [diff] [blame] | 5599 | static int decode_secinfo_no_name(struct xdr_stream *xdr, struct nfs4_secinfo_res *res) |
| 5600 | { |
| 5601 | int status = decode_op_hdr(xdr, OP_SECINFO_NO_NAME); |
| 5602 | if (status) |
| 5603 | return status; |
| 5604 | return decode_secinfo_common(xdr, res); |
| 5605 | } |
| 5606 | |
Weston Andros Adamson | 2031cd1 | 2013-08-13 16:37:32 -0400 | [diff] [blame] | 5607 | static int decode_op_map(struct xdr_stream *xdr, struct nfs4_op_map *op_map) |
| 5608 | { |
Trond Myklebust | f114759 | 2021-11-04 17:33:36 -0400 | [diff] [blame] | 5609 | if (xdr_stream_decode_uint32_array(xdr, op_map->u.words, |
| 5610 | ARRAY_SIZE(op_map->u.words)) < 0) |
Pan Bian | 4edabfd | 2017-04-23 14:49:41 +0800 | [diff] [blame] | 5611 | return -EIO; |
Weston Andros Adamson | 2031cd1 | 2013-08-13 16:37:32 -0400 | [diff] [blame] | 5612 | return 0; |
| 5613 | } |
| 5614 | |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 5615 | static int decode_exchange_id(struct xdr_stream *xdr, |
| 5616 | struct nfs41_exchange_id_res *res) |
| 5617 | { |
| 5618 | __be32 *p; |
| 5619 | uint32_t dummy; |
Benny Halevy | 2460ba5 | 2009-08-14 17:20:10 +0300 | [diff] [blame] | 5620 | char *dummy_str; |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 5621 | int status; |
Weston Andros Adamson | 7d2ed9a | 2012-02-17 15:20:26 -0500 | [diff] [blame] | 5622 | uint32_t impl_id_count; |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 5623 | |
| 5624 | status = decode_op_hdr(xdr, OP_EXCHANGE_ID); |
| 5625 | if (status) |
| 5626 | return status; |
| 5627 | |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 5628 | p = xdr_inline_decode(xdr, 8); |
| 5629 | if (unlikely(!p)) |
Chuck Lever | eb72f48 | 2019-02-11 11:24:21 -0500 | [diff] [blame] | 5630 | return -EIO; |
Trond Myklebust | 32b0131 | 2012-05-26 13:41:04 -0400 | [diff] [blame] | 5631 | xdr_decode_hyper(p, &res->clientid); |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 5632 | p = xdr_inline_decode(xdr, 12); |
| 5633 | if (unlikely(!p)) |
Chuck Lever | eb72f48 | 2019-02-11 11:24:21 -0500 | [diff] [blame] | 5634 | return -EIO; |
Trond Myklebust | 32b0131 | 2012-05-26 13:41:04 -0400 | [diff] [blame] | 5635 | res->seqid = be32_to_cpup(p++); |
| 5636 | res->flags = be32_to_cpup(p++); |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 5637 | |
Weston Andros Adamson | 2031cd1 | 2013-08-13 16:37:32 -0400 | [diff] [blame] | 5638 | res->state_protect.how = be32_to_cpup(p); |
| 5639 | switch (res->state_protect.how) { |
| 5640 | case SP4_NONE: |
| 5641 | break; |
| 5642 | case SP4_MACH_CRED: |
| 5643 | status = decode_op_map(xdr, &res->state_protect.enforce); |
| 5644 | if (status) |
| 5645 | return status; |
| 5646 | status = decode_op_map(xdr, &res->state_protect.allow); |
| 5647 | if (status) |
| 5648 | return status; |
| 5649 | break; |
| 5650 | default: |
| 5651 | WARN_ON_ONCE(1); |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 5652 | return -EIO; |
Weston Andros Adamson | 2031cd1 | 2013-08-13 16:37:32 -0400 | [diff] [blame] | 5653 | } |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 5654 | |
Chuck Lever | acdeb69 | 2012-05-21 22:46:16 -0400 | [diff] [blame] | 5655 | /* server_owner4.so_minor_id */ |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 5656 | p = xdr_inline_decode(xdr, 8); |
| 5657 | if (unlikely(!p)) |
Chuck Lever | eb72f48 | 2019-02-11 11:24:21 -0500 | [diff] [blame] | 5658 | return -EIO; |
Chuck Lever | acdeb69 | 2012-05-21 22:46:16 -0400 | [diff] [blame] | 5659 | p = xdr_decode_hyper(p, &res->server_owner->minor_id); |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 5660 | |
Chuck Lever | acdeb69 | 2012-05-21 22:46:16 -0400 | [diff] [blame] | 5661 | /* server_owner4.so_major_id */ |
Benny Halevy | 2460ba5 | 2009-08-14 17:20:10 +0300 | [diff] [blame] | 5662 | status = decode_opaque_inline(xdr, &dummy, &dummy_str); |
| 5663 | if (unlikely(status)) |
| 5664 | return status; |
Chuck Lever | acdeb69 | 2012-05-21 22:46:16 -0400 | [diff] [blame] | 5665 | memcpy(res->server_owner->major_id, dummy_str, dummy); |
| 5666 | res->server_owner->major_id_sz = dummy; |
Weston Andros Adamson | 78fe0f4 | 2011-05-31 19:05:47 -0400 | [diff] [blame] | 5667 | |
Chuck Lever | acdeb69 | 2012-05-21 22:46:16 -0400 | [diff] [blame] | 5668 | /* server_scope4 */ |
| 5669 | status = decode_opaque_inline(xdr, &dummy, &dummy_str); |
| 5670 | if (unlikely(status)) |
| 5671 | return status; |
Weston Andros Adamson | 78fe0f4 | 2011-05-31 19:05:47 -0400 | [diff] [blame] | 5672 | memcpy(res->server_scope->server_scope, dummy_str, dummy); |
| 5673 | res->server_scope->server_scope_sz = dummy; |
| 5674 | |
Weston Andros Adamson | 7d2ed9a | 2012-02-17 15:20:26 -0500 | [diff] [blame] | 5675 | /* Implementation Id */ |
| 5676 | p = xdr_inline_decode(xdr, 4); |
| 5677 | if (unlikely(!p)) |
Chuck Lever | eb72f48 | 2019-02-11 11:24:21 -0500 | [diff] [blame] | 5678 | return -EIO; |
Weston Andros Adamson | 7d2ed9a | 2012-02-17 15:20:26 -0500 | [diff] [blame] | 5679 | impl_id_count = be32_to_cpup(p++); |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 5680 | |
Weston Andros Adamson | 7d2ed9a | 2012-02-17 15:20:26 -0500 | [diff] [blame] | 5681 | if (impl_id_count) { |
| 5682 | /* nii_domain */ |
| 5683 | status = decode_opaque_inline(xdr, &dummy, &dummy_str); |
| 5684 | if (unlikely(status)) |
| 5685 | return status; |
Weston Andros Adamson | 7d2ed9a | 2012-02-17 15:20:26 -0500 | [diff] [blame] | 5686 | memcpy(res->impl_id->domain, dummy_str, dummy); |
| 5687 | |
| 5688 | /* nii_name */ |
| 5689 | status = decode_opaque_inline(xdr, &dummy, &dummy_str); |
| 5690 | if (unlikely(status)) |
| 5691 | return status; |
Weston Andros Adamson | 7d2ed9a | 2012-02-17 15:20:26 -0500 | [diff] [blame] | 5692 | memcpy(res->impl_id->name, dummy_str, dummy); |
| 5693 | |
| 5694 | /* nii_date */ |
| 5695 | p = xdr_inline_decode(xdr, 12); |
| 5696 | if (unlikely(!p)) |
Chuck Lever | eb72f48 | 2019-02-11 11:24:21 -0500 | [diff] [blame] | 5697 | return -EIO; |
Weston Andros Adamson | 7d2ed9a | 2012-02-17 15:20:26 -0500 | [diff] [blame] | 5698 | p = xdr_decode_hyper(p, &res->impl_id->date.seconds); |
| 5699 | res->impl_id->date.nseconds = be32_to_cpup(p); |
| 5700 | |
| 5701 | /* if there's more than one entry, ignore the rest */ |
| 5702 | } |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 5703 | return 0; |
| 5704 | } |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 5705 | |
| 5706 | static int decode_chan_attrs(struct xdr_stream *xdr, |
| 5707 | struct nfs4_channel_attrs *attrs) |
| 5708 | { |
| 5709 | __be32 *p; |
Benny Halevy | c9c30dd | 2011-06-11 17:08:39 -0400 | [diff] [blame] | 5710 | u32 nr_attrs, val; |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 5711 | |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 5712 | p = xdr_inline_decode(xdr, 28); |
| 5713 | if (unlikely(!p)) |
Chuck Lever | eb72f48 | 2019-02-11 11:24:21 -0500 | [diff] [blame] | 5714 | return -EIO; |
Benny Halevy | c9c30dd | 2011-06-11 17:08:39 -0400 | [diff] [blame] | 5715 | val = be32_to_cpup(p++); /* headerpadsz */ |
| 5716 | if (val) |
| 5717 | return -EINVAL; /* no support for header padding yet */ |
Benny Halevy | 6f723f7 | 2009-08-14 17:19:37 +0300 | [diff] [blame] | 5718 | attrs->max_rqst_sz = be32_to_cpup(p++); |
| 5719 | attrs->max_resp_sz = be32_to_cpup(p++); |
| 5720 | attrs->max_resp_sz_cached = be32_to_cpup(p++); |
| 5721 | attrs->max_ops = be32_to_cpup(p++); |
| 5722 | attrs->max_reqs = be32_to_cpup(p++); |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 5723 | nr_attrs = be32_to_cpup(p); |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 5724 | if (unlikely(nr_attrs > 1)) { |
Weston Andros Adamson | a030889 | 2012-01-26 13:32:23 -0500 | [diff] [blame] | 5725 | printk(KERN_WARNING "NFS: %s: Invalid rdma channel attrs " |
| 5726 | "count %u\n", __func__, nr_attrs); |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 5727 | return -EINVAL; |
| 5728 | } |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 5729 | if (nr_attrs == 1) { |
| 5730 | p = xdr_inline_decode(xdr, 4); /* skip rdma_attrs */ |
| 5731 | if (unlikely(!p)) |
Chuck Lever | eb72f48 | 2019-02-11 11:24:21 -0500 | [diff] [blame] | 5732 | return -EIO; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 5733 | } |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 5734 | return 0; |
| 5735 | } |
| 5736 | |
Benny Halevy | e78291e | 2009-08-14 17:20:00 +0300 | [diff] [blame] | 5737 | static int decode_sessionid(struct xdr_stream *xdr, struct nfs4_sessionid *sid) |
| 5738 | { |
| 5739 | return decode_opaque_fixed(xdr, sid->data, NFS4_MAX_SESSIONID_LEN); |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 5740 | } |
| 5741 | |
Weston Andros Adamson | 7c44f1ae | 2012-05-24 13:22:50 -0400 | [diff] [blame] | 5742 | static int decode_bind_conn_to_session(struct xdr_stream *xdr, |
| 5743 | struct nfs41_bind_conn_to_session_res *res) |
| 5744 | { |
| 5745 | __be32 *p; |
| 5746 | int status; |
| 5747 | |
| 5748 | status = decode_op_hdr(xdr, OP_BIND_CONN_TO_SESSION); |
| 5749 | if (!status) |
Trond Myklebust | 71a097c | 2015-02-18 09:27:18 -0800 | [diff] [blame] | 5750 | status = decode_sessionid(xdr, &res->sessionid); |
Weston Andros Adamson | 7c44f1ae | 2012-05-24 13:22:50 -0400 | [diff] [blame] | 5751 | if (unlikely(status)) |
| 5752 | return status; |
| 5753 | |
| 5754 | /* dir flags, rdma mode bool */ |
| 5755 | p = xdr_inline_decode(xdr, 8); |
| 5756 | if (unlikely(!p)) |
Chuck Lever | eb72f48 | 2019-02-11 11:24:21 -0500 | [diff] [blame] | 5757 | return -EIO; |
Weston Andros Adamson | 7c44f1ae | 2012-05-24 13:22:50 -0400 | [diff] [blame] | 5758 | |
| 5759 | res->dir = be32_to_cpup(p++); |
| 5760 | if (res->dir == 0 || res->dir > NFS4_CDFS4_BOTH) |
| 5761 | return -EIO; |
| 5762 | if (be32_to_cpup(p) == 0) |
| 5763 | res->use_conn_in_rdma_mode = false; |
| 5764 | else |
| 5765 | res->use_conn_in_rdma_mode = true; |
| 5766 | |
| 5767 | return 0; |
Weston Andros Adamson | 7c44f1ae | 2012-05-24 13:22:50 -0400 | [diff] [blame] | 5768 | } |
| 5769 | |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 5770 | static int decode_create_session(struct xdr_stream *xdr, |
| 5771 | struct nfs41_create_session_res *res) |
| 5772 | { |
| 5773 | __be32 *p; |
| 5774 | int status; |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 5775 | |
| 5776 | status = decode_op_hdr(xdr, OP_CREATE_SESSION); |
Benny Halevy | e78291e | 2009-08-14 17:20:00 +0300 | [diff] [blame] | 5777 | if (!status) |
Trond Myklebust | 79969dd | 2015-02-18 11:30:18 -0800 | [diff] [blame] | 5778 | status = decode_sessionid(xdr, &res->sessionid); |
Benny Halevy | e78291e | 2009-08-14 17:20:00 +0300 | [diff] [blame] | 5779 | if (unlikely(status)) |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 5780 | return status; |
| 5781 | |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 5782 | /* seqid, flags */ |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 5783 | p = xdr_inline_decode(xdr, 8); |
| 5784 | if (unlikely(!p)) |
Chuck Lever | eb72f48 | 2019-02-11 11:24:21 -0500 | [diff] [blame] | 5785 | return -EIO; |
Trond Myklebust | 79969dd | 2015-02-18 11:30:18 -0800 | [diff] [blame] | 5786 | res->seqid = be32_to_cpup(p++); |
| 5787 | res->flags = be32_to_cpup(p); |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 5788 | |
| 5789 | /* Channel attributes */ |
Trond Myklebust | 79969dd | 2015-02-18 11:30:18 -0800 | [diff] [blame] | 5790 | status = decode_chan_attrs(xdr, &res->fc_attrs); |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 5791 | if (!status) |
Trond Myklebust | 79969dd | 2015-02-18 11:30:18 -0800 | [diff] [blame] | 5792 | status = decode_chan_attrs(xdr, &res->bc_attrs); |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 5793 | return status; |
| 5794 | } |
Andy Adamson | 0f3e66c | 2009-04-01 09:22:34 -0400 | [diff] [blame] | 5795 | |
| 5796 | static int decode_destroy_session(struct xdr_stream *xdr, void *dummy) |
| 5797 | { |
| 5798 | return decode_op_hdr(xdr, OP_DESTROY_SESSION); |
| 5799 | } |
Ricardo Labiaga | 18019753 | 2009-12-05 16:08:40 -0500 | [diff] [blame] | 5800 | |
Trond Myklebust | 6624553 | 2012-05-25 17:18:09 -0400 | [diff] [blame] | 5801 | static int decode_destroy_clientid(struct xdr_stream *xdr, void *dummy) |
| 5802 | { |
| 5803 | return decode_op_hdr(xdr, OP_DESTROY_CLIENTID); |
| 5804 | } |
| 5805 | |
Ricardo Labiaga | 18019753 | 2009-12-05 16:08:40 -0500 | [diff] [blame] | 5806 | static int decode_reclaim_complete(struct xdr_stream *xdr, void *dummy) |
| 5807 | { |
| 5808 | return decode_op_hdr(xdr, OP_RECLAIM_COMPLETE); |
| 5809 | } |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 5810 | #endif /* CONFIG_NFS_V4_1 */ |
| 5811 | |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 5812 | static int decode_sequence(struct xdr_stream *xdr, |
| 5813 | struct nfs4_sequence_res *res, |
| 5814 | struct rpc_rqst *rqstp) |
| 5815 | { |
| 5816 | #if defined(CONFIG_NFS_V4_1) |
Trond Myklebust | e3725ec | 2012-11-16 12:25:01 -0500 | [diff] [blame] | 5817 | struct nfs4_session *session; |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 5818 | struct nfs4_sessionid id; |
| 5819 | u32 dummy; |
| 5820 | int status; |
| 5821 | __be32 *p; |
| 5822 | |
Trond Myklebust | e3725ec | 2012-11-16 12:25:01 -0500 | [diff] [blame] | 5823 | if (res->sr_slot == NULL) |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 5824 | return 0; |
Chuck Lever | 3bd2384 | 2013-08-09 12:49:19 -0400 | [diff] [blame] | 5825 | if (!res->sr_slot->table->session) |
| 5826 | return 0; |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 5827 | |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 5828 | status = decode_op_hdr(xdr, OP_SEQUENCE); |
Benny Halevy | e78291e | 2009-08-14 17:20:00 +0300 | [diff] [blame] | 5829 | if (!status) |
| 5830 | status = decode_sessionid(xdr, &id); |
| 5831 | if (unlikely(status)) |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 5832 | goto out_err; |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 5833 | |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 5834 | /* |
| 5835 | * If the server returns different values for sessionID, slotID or |
| 5836 | * sequence number, the server is looney tunes. |
| 5837 | */ |
Trond Myklebust | fdcb457 | 2010-02-08 09:32:40 -0500 | [diff] [blame] | 5838 | status = -EREMOTEIO; |
Trond Myklebust | e3725ec | 2012-11-16 12:25:01 -0500 | [diff] [blame] | 5839 | session = res->sr_slot->table->session; |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 5840 | |
Trond Myklebust | e3725ec | 2012-11-16 12:25:01 -0500 | [diff] [blame] | 5841 | if (memcmp(id.data, session->sess_id.data, |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 5842 | NFS4_MAX_SESSIONID_LEN)) { |
| 5843 | dprintk("%s Invalid session id\n", __func__); |
| 5844 | goto out_err; |
| 5845 | } |
Benny Halevy | e78291e | 2009-08-14 17:20:00 +0300 | [diff] [blame] | 5846 | |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 5847 | p = xdr_inline_decode(xdr, 20); |
| 5848 | if (unlikely(!p)) |
| 5849 | goto out_overflow; |
Benny Halevy | e78291e | 2009-08-14 17:20:00 +0300 | [diff] [blame] | 5850 | |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 5851 | /* seqid */ |
Benny Halevy | 6f723f7 | 2009-08-14 17:19:37 +0300 | [diff] [blame] | 5852 | dummy = be32_to_cpup(p++); |
Benny Halevy | dfb4f309 | 2010-09-24 09:17:01 -0400 | [diff] [blame] | 5853 | if (dummy != res->sr_slot->seq_nr) { |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 5854 | dprintk("%s Invalid sequence number\n", __func__); |
| 5855 | goto out_err; |
| 5856 | } |
| 5857 | /* slot id */ |
Benny Halevy | 6f723f7 | 2009-08-14 17:19:37 +0300 | [diff] [blame] | 5858 | dummy = be32_to_cpup(p++); |
Trond Myklebust | df2fabf | 2012-11-16 12:45:06 -0500 | [diff] [blame] | 5859 | if (dummy != res->sr_slot->slot_nr) { |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 5860 | dprintk("%s Invalid slot id\n", __func__); |
| 5861 | goto out_err; |
| 5862 | } |
Trond Myklebust | da0507b | 2012-11-20 18:10:30 -0500 | [diff] [blame] | 5863 | /* highest slot id */ |
| 5864 | res->sr_highest_slotid = be32_to_cpup(p++); |
Trond Myklebust | 464ee9f | 2012-11-20 12:49:27 -0500 | [diff] [blame] | 5865 | /* target highest slot id */ |
| 5866 | res->sr_target_highest_slotid = be32_to_cpup(p++); |
Alexandros Batsakis | 0629e37 | 2009-12-05 13:46:14 -0500 | [diff] [blame] | 5867 | /* result flags */ |
| 5868 | res->sr_status_flags = be32_to_cpup(p); |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 5869 | status = 0; |
| 5870 | out_err: |
| 5871 | res->sr_status = status; |
| 5872 | return status; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 5873 | out_overflow: |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 5874 | status = -EIO; |
| 5875 | goto out_err; |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 5876 | #else /* CONFIG_NFS_V4_1 */ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 5877 | return 0; |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 5878 | #endif /* CONFIG_NFS_V4_1 */ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 5879 | } |
| 5880 | |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 5881 | #if defined(CONFIG_NFS_V4_1) |
Trond Myklebust | 93b717f | 2016-05-16 17:42:43 -0400 | [diff] [blame] | 5882 | static int decode_layout_stateid(struct xdr_stream *xdr, nfs4_stateid *stateid) |
| 5883 | { |
| 5884 | stateid->type = NFS4_LAYOUT_STATEID_TYPE; |
| 5885 | return decode_stateid(xdr, stateid); |
| 5886 | } |
| 5887 | |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 5888 | static int decode_getdeviceinfo(struct xdr_stream *xdr, |
Trond Myklebust | 4e59080 | 2015-03-09 14:01:25 -0400 | [diff] [blame] | 5889 | struct nfs4_getdeviceinfo_res *res) |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 5890 | { |
Trond Myklebust | 4e59080 | 2015-03-09 14:01:25 -0400 | [diff] [blame] | 5891 | struct pnfs_device *pdev = res->pdev; |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 5892 | __be32 *p; |
| 5893 | uint32_t len, type; |
| 5894 | int status; |
| 5895 | |
| 5896 | status = decode_op_hdr(xdr, OP_GETDEVICEINFO); |
| 5897 | if (status) { |
| 5898 | if (status == -ETOOSMALL) { |
| 5899 | p = xdr_inline_decode(xdr, 4); |
| 5900 | if (unlikely(!p)) |
Chuck Lever | eb72f48 | 2019-02-11 11:24:21 -0500 | [diff] [blame] | 5901 | return -EIO; |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 5902 | pdev->mincount = be32_to_cpup(p); |
| 5903 | dprintk("%s: Min count too small. mincnt = %u\n", |
| 5904 | __func__, pdev->mincount); |
| 5905 | } |
| 5906 | return status; |
| 5907 | } |
| 5908 | |
| 5909 | p = xdr_inline_decode(xdr, 8); |
| 5910 | if (unlikely(!p)) |
Chuck Lever | eb72f48 | 2019-02-11 11:24:21 -0500 | [diff] [blame] | 5911 | return -EIO; |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 5912 | type = be32_to_cpup(p++); |
| 5913 | if (type != pdev->layout_type) { |
| 5914 | dprintk("%s: layout mismatch req: %u pdev: %u\n", |
| 5915 | __func__, pdev->layout_type, type); |
| 5916 | return -EINVAL; |
| 5917 | } |
| 5918 | /* |
| 5919 | * Get the length of the opaque device_addr4. xdr_read_pages places |
| 5920 | * the opaque device_addr4 in the xdr_buf->pages (pnfs_device->pages) |
| 5921 | * and places the remaining xdr data in xdr_buf->tail |
| 5922 | */ |
| 5923 | pdev->mincount = be32_to_cpup(p); |
Trond Myklebust | 13fe4ba | 2012-08-01 14:21:12 -0400 | [diff] [blame] | 5924 | if (xdr_read_pages(xdr, pdev->mincount) != pdev->mincount) |
Chuck Lever | eb72f48 | 2019-02-11 11:24:21 -0500 | [diff] [blame] | 5925 | return -EIO; |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 5926 | |
| 5927 | /* Parse notification bitmap, verifying that it is zero. */ |
| 5928 | p = xdr_inline_decode(xdr, 4); |
| 5929 | if (unlikely(!p)) |
Chuck Lever | eb72f48 | 2019-02-11 11:24:21 -0500 | [diff] [blame] | 5930 | return -EIO; |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 5931 | len = be32_to_cpup(p); |
| 5932 | if (len) { |
Chuck Lever | ead0059 | 2010-12-14 14:58:21 +0000 | [diff] [blame] | 5933 | uint32_t i; |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 5934 | |
| 5935 | p = xdr_inline_decode(xdr, 4 * len); |
| 5936 | if (unlikely(!p)) |
Chuck Lever | eb72f48 | 2019-02-11 11:24:21 -0500 | [diff] [blame] | 5937 | return -EIO; |
Christoph Hellwig | 84c9dee | 2014-09-10 17:37:28 -0700 | [diff] [blame] | 5938 | |
Trond Myklebust | 4e59080 | 2015-03-09 14:01:25 -0400 | [diff] [blame] | 5939 | res->notification = be32_to_cpup(p++); |
Christoph Hellwig | 84c9dee | 2014-09-10 17:37:28 -0700 | [diff] [blame] | 5940 | for (i = 1; i < len; i++) { |
| 5941 | if (be32_to_cpup(p++)) { |
| 5942 | dprintk("%s: unsupported notification\n", |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 5943 | __func__); |
| 5944 | return -EIO; |
| 5945 | } |
| 5946 | } |
| 5947 | } |
| 5948 | return 0; |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 5949 | } |
| 5950 | |
| 5951 | static int decode_layoutget(struct xdr_stream *xdr, struct rpc_rqst *req, |
| 5952 | struct nfs4_layoutget_res *res) |
| 5953 | { |
| 5954 | __be32 *p; |
| 5955 | int status; |
| 5956 | u32 layout_count; |
Trond Myklebust | 64bd577 | 2012-06-20 22:35:05 -0400 | [diff] [blame] | 5957 | u32 recvd; |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 5958 | |
| 5959 | status = decode_op_hdr(xdr, OP_LAYOUTGET); |
| 5960 | if (status) |
Fred Isaman | 808ba32 | 2016-10-04 15:02:21 -0400 | [diff] [blame] | 5961 | goto out; |
Trond Myklebust | ea9d23f | 2012-03-04 18:13:56 -0500 | [diff] [blame] | 5962 | p = xdr_inline_decode(xdr, 4); |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 5963 | if (unlikely(!p)) |
| 5964 | goto out_overflow; |
Trond Myklebust | ea9d23f | 2012-03-04 18:13:56 -0500 | [diff] [blame] | 5965 | res->return_on_close = be32_to_cpup(p); |
Trond Myklebust | 93b717f | 2016-05-16 17:42:43 -0400 | [diff] [blame] | 5966 | decode_layout_stateid(xdr, &res->stateid); |
Trond Myklebust | ea9d23f | 2012-03-04 18:13:56 -0500 | [diff] [blame] | 5967 | p = xdr_inline_decode(xdr, 4); |
| 5968 | if (unlikely(!p)) |
| 5969 | goto out_overflow; |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 5970 | layout_count = be32_to_cpup(p); |
| 5971 | if (!layout_count) { |
| 5972 | dprintk("%s: server responded with empty layout array\n", |
| 5973 | __func__); |
Fred Isaman | 808ba32 | 2016-10-04 15:02:21 -0400 | [diff] [blame] | 5974 | status = -EINVAL; |
| 5975 | goto out; |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 5976 | } |
| 5977 | |
Weston Andros Adamson | 35124a0 | 2011-03-24 16:48:21 -0400 | [diff] [blame] | 5978 | p = xdr_inline_decode(xdr, 28); |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 5979 | if (unlikely(!p)) |
| 5980 | goto out_overflow; |
| 5981 | p = xdr_decode_hyper(p, &res->range.offset); |
| 5982 | p = xdr_decode_hyper(p, &res->range.length); |
| 5983 | res->range.iomode = be32_to_cpup(p++); |
| 5984 | res->type = be32_to_cpup(p++); |
Weston Andros Adamson | 35124a0 | 2011-03-24 16:48:21 -0400 | [diff] [blame] | 5985 | res->layoutp->len = be32_to_cpup(p); |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 5986 | |
| 5987 | dprintk("%s roff:%lu rlen:%lu riomode:%d, lo_type:0x%x, lo.len:%d\n", |
| 5988 | __func__, |
| 5989 | (unsigned long)res->range.offset, |
| 5990 | (unsigned long)res->range.length, |
| 5991 | res->range.iomode, |
| 5992 | res->type, |
Weston Andros Adamson | 35124a0 | 2011-03-24 16:48:21 -0400 | [diff] [blame] | 5993 | res->layoutp->len); |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 5994 | |
Trond Myklebust | 64bd577 | 2012-06-20 22:35:05 -0400 | [diff] [blame] | 5995 | recvd = xdr_read_pages(xdr, res->layoutp->len); |
Weston Andros Adamson | 35124a0 | 2011-03-24 16:48:21 -0400 | [diff] [blame] | 5996 | if (res->layoutp->len > recvd) { |
| 5997 | dprintk("NFS: server cheating in layoutget reply: " |
| 5998 | "layout len %u > recvd %u\n", |
| 5999 | res->layoutp->len, recvd); |
Fred Isaman | 808ba32 | 2016-10-04 15:02:21 -0400 | [diff] [blame] | 6000 | status = -EINVAL; |
| 6001 | goto out; |
Weston Andros Adamson | 35124a0 | 2011-03-24 16:48:21 -0400 | [diff] [blame] | 6002 | } |
| 6003 | |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 6004 | if (layout_count > 1) { |
| 6005 | /* We only handle a length one array at the moment. Any |
| 6006 | * further entries are just ignored. Note that this means |
| 6007 | * the client may see a response that is less than the |
| 6008 | * minimum it requested. |
| 6009 | */ |
| 6010 | dprintk("%s: server responded with %d layouts, dropping tail\n", |
| 6011 | __func__, layout_count); |
| 6012 | } |
| 6013 | |
Fred Isaman | 808ba32 | 2016-10-04 15:02:21 -0400 | [diff] [blame] | 6014 | out: |
| 6015 | res->status = status; |
| 6016 | return status; |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 6017 | out_overflow: |
Fred Isaman | 808ba32 | 2016-10-04 15:02:21 -0400 | [diff] [blame] | 6018 | status = -EIO; |
| 6019 | goto out; |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 6020 | } |
Andy Adamson | 863a3c6 | 2011-03-23 13:27:54 +0000 | [diff] [blame] | 6021 | |
Benny Halevy | cbe8260 | 2011-05-22 19:52:37 +0300 | [diff] [blame] | 6022 | static int decode_layoutreturn(struct xdr_stream *xdr, |
| 6023 | struct nfs4_layoutreturn_res *res) |
| 6024 | { |
| 6025 | __be32 *p; |
| 6026 | int status; |
| 6027 | |
| 6028 | status = decode_op_hdr(xdr, OP_LAYOUTRETURN); |
| 6029 | if (status) |
| 6030 | return status; |
| 6031 | p = xdr_inline_decode(xdr, 4); |
| 6032 | if (unlikely(!p)) |
Chuck Lever | eb72f48 | 2019-02-11 11:24:21 -0500 | [diff] [blame] | 6033 | return -EIO; |
Benny Halevy | cbe8260 | 2011-05-22 19:52:37 +0300 | [diff] [blame] | 6034 | res->lrs_present = be32_to_cpup(p); |
| 6035 | if (res->lrs_present) |
Trond Myklebust | 93b717f | 2016-05-16 17:42:43 -0400 | [diff] [blame] | 6036 | status = decode_layout_stateid(xdr, &res->stateid); |
Trond Myklebust | fcd8843 | 2017-11-07 12:39:44 -0500 | [diff] [blame] | 6037 | else |
| 6038 | nfs4_stateid_copy(&res->stateid, &invalid_stateid); |
Benny Halevy | cbe8260 | 2011-05-22 19:52:37 +0300 | [diff] [blame] | 6039 | return status; |
Benny Halevy | cbe8260 | 2011-05-22 19:52:37 +0300 | [diff] [blame] | 6040 | } |
| 6041 | |
Andy Adamson | 863a3c6 | 2011-03-23 13:27:54 +0000 | [diff] [blame] | 6042 | static int decode_layoutcommit(struct xdr_stream *xdr, |
| 6043 | struct rpc_rqst *req, |
| 6044 | struct nfs4_layoutcommit_res *res) |
| 6045 | { |
| 6046 | __be32 *p; |
| 6047 | __u32 sizechanged; |
| 6048 | int status; |
| 6049 | |
| 6050 | status = decode_op_hdr(xdr, OP_LAYOUTCOMMIT); |
Andy Adamson | db29c08 | 2011-07-30 20:52:38 -0400 | [diff] [blame] | 6051 | res->status = status; |
Andy Adamson | 863a3c6 | 2011-03-23 13:27:54 +0000 | [diff] [blame] | 6052 | if (status) |
| 6053 | return status; |
| 6054 | |
| 6055 | p = xdr_inline_decode(xdr, 4); |
| 6056 | if (unlikely(!p)) |
Chuck Lever | eb72f48 | 2019-02-11 11:24:21 -0500 | [diff] [blame] | 6057 | return -EIO; |
Andy Adamson | 863a3c6 | 2011-03-23 13:27:54 +0000 | [diff] [blame] | 6058 | sizechanged = be32_to_cpup(p); |
| 6059 | |
| 6060 | if (sizechanged) { |
| 6061 | /* throw away new size */ |
| 6062 | p = xdr_inline_decode(xdr, 8); |
| 6063 | if (unlikely(!p)) |
Chuck Lever | eb72f48 | 2019-02-11 11:24:21 -0500 | [diff] [blame] | 6064 | return -EIO; |
Andy Adamson | 863a3c6 | 2011-03-23 13:27:54 +0000 | [diff] [blame] | 6065 | } |
| 6066 | return 0; |
Andy Adamson | 863a3c6 | 2011-03-23 13:27:54 +0000 | [diff] [blame] | 6067 | } |
Bryan Schumaker | 7d97479 | 2011-06-02 14:59:08 -0400 | [diff] [blame] | 6068 | |
| 6069 | static int decode_test_stateid(struct xdr_stream *xdr, |
| 6070 | struct nfs41_test_stateid_res *res) |
| 6071 | { |
| 6072 | __be32 *p; |
| 6073 | int status; |
| 6074 | int num_res; |
| 6075 | |
| 6076 | status = decode_op_hdr(xdr, OP_TEST_STATEID); |
| 6077 | if (status) |
| 6078 | return status; |
| 6079 | |
| 6080 | p = xdr_inline_decode(xdr, 4); |
| 6081 | if (unlikely(!p)) |
Chuck Lever | eb72f48 | 2019-02-11 11:24:21 -0500 | [diff] [blame] | 6082 | return -EIO; |
Bryan Schumaker | 7d97479 | 2011-06-02 14:59:08 -0400 | [diff] [blame] | 6083 | num_res = be32_to_cpup(p++); |
| 6084 | if (num_res != 1) |
Chuck Lever | eb72f48 | 2019-02-11 11:24:21 -0500 | [diff] [blame] | 6085 | return -EIO; |
Bryan Schumaker | 7d97479 | 2011-06-02 14:59:08 -0400 | [diff] [blame] | 6086 | |
| 6087 | p = xdr_inline_decode(xdr, 4); |
| 6088 | if (unlikely(!p)) |
Chuck Lever | eb72f48 | 2019-02-11 11:24:21 -0500 | [diff] [blame] | 6089 | return -EIO; |
Bryan Schumaker | 7d97479 | 2011-06-02 14:59:08 -0400 | [diff] [blame] | 6090 | res->status = be32_to_cpup(p++); |
Bryan Schumaker | 1cab065 | 2012-01-31 10:39:29 -0500 | [diff] [blame] | 6091 | |
| 6092 | return status; |
Bryan Schumaker | 7d97479 | 2011-06-02 14:59:08 -0400 | [diff] [blame] | 6093 | } |
Bryan Schumaker | 9aeda35 | 2011-06-02 14:59:09 -0400 | [diff] [blame] | 6094 | |
| 6095 | static int decode_free_stateid(struct xdr_stream *xdr, |
| 6096 | struct nfs41_free_stateid_res *res) |
| 6097 | { |
Andy Adamson | 9f79fb4 | 2013-09-10 12:56:29 -0400 | [diff] [blame] | 6098 | res->status = decode_op_hdr(xdr, OP_FREE_STATEID); |
Bryan Schumaker | 9aeda35 | 2011-06-02 14:59:09 -0400 | [diff] [blame] | 6099 | return res->status; |
Bryan Schumaker | 9aeda35 | 2011-06-02 14:59:09 -0400 | [diff] [blame] | 6100 | } |
Trond Myklebust | cf80516 | 2016-11-15 14:56:07 -0500 | [diff] [blame] | 6101 | #else |
| 6102 | static inline |
| 6103 | int decode_layoutreturn(struct xdr_stream *xdr, |
| 6104 | struct nfs4_layoutreturn_res *res) |
| 6105 | { |
| 6106 | return 0; |
| 6107 | } |
Fred Isaman | 56f487f | 2016-09-21 11:43:41 -0400 | [diff] [blame] | 6108 | |
| 6109 | static int decode_layoutget(struct xdr_stream *xdr, struct rpc_rqst *req, |
| 6110 | struct nfs4_layoutget_res *res) |
| 6111 | { |
| 6112 | return 0; |
| 6113 | } |
| 6114 | |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 6115 | #endif /* CONFIG_NFS_V4_1 */ |
| 6116 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6117 | /* |
Benny Halevy | 49c2559 | 2008-12-23 16:06:16 -0500 | [diff] [blame] | 6118 | * END OF "GENERIC" DECODE ROUTINES. |
| 6119 | */ |
| 6120 | |
| 6121 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6122 | * Decode OPEN_DOWNGRADE response |
| 6123 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6124 | static int nfs4_xdr_dec_open_downgrade(struct rpc_rqst *rqstp, |
| 6125 | struct xdr_stream *xdr, |
Christoph Hellwig | fc01648 | 2017-05-08 15:09:02 +0200 | [diff] [blame] | 6126 | void *data) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6127 | { |
Christoph Hellwig | fc01648 | 2017-05-08 15:09:02 +0200 | [diff] [blame] | 6128 | struct nfs_closeres *res = data; |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6129 | struct compound_hdr hdr; |
| 6130 | int status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6131 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6132 | status = decode_compound_hdr(xdr, &hdr); |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6133 | if (status) |
| 6134 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6135 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6136 | if (status) |
| 6137 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6138 | status = decode_putfh(xdr); |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6139 | if (status) |
| 6140 | goto out; |
Trond Myklebust | b680814 | 2016-11-20 13:34:16 -0500 | [diff] [blame] | 6141 | if (res->lr_res) { |
| 6142 | status = decode_layoutreturn(xdr, res->lr_res); |
| 6143 | res->lr_ret = status; |
| 6144 | if (status) |
| 6145 | goto out; |
| 6146 | } |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6147 | status = decode_open_downgrade(xdr, res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6148 | out: |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6149 | return status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6150 | } |
| 6151 | |
| 6152 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6153 | * Decode ACCESS response |
| 6154 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6155 | static int nfs4_xdr_dec_access(struct rpc_rqst *rqstp, struct xdr_stream *xdr, |
Christoph Hellwig | fc01648 | 2017-05-08 15:09:02 +0200 | [diff] [blame] | 6156 | void *data) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6157 | { |
Christoph Hellwig | fc01648 | 2017-05-08 15:09:02 +0200 | [diff] [blame] | 6158 | struct nfs4_accessres *res = data; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6159 | struct compound_hdr hdr; |
| 6160 | int status; |
Andy Adamson | 6c0195a | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6161 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6162 | status = decode_compound_hdr(xdr, &hdr); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6163 | if (status) |
| 6164 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6165 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6166 | if (status) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6167 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6168 | status = decode_putfh(xdr); |
Trond Myklebust | 76b3299 | 2007-08-10 17:45:11 -0400 | [diff] [blame] | 6169 | if (status != 0) |
| 6170 | goto out; |
Weston Andros Adamson | 6168f62 | 2012-09-10 14:00:46 -0400 | [diff] [blame] | 6171 | status = decode_access(xdr, &res->supported, &res->access); |
Trond Myklebust | 76b3299 | 2007-08-10 17:45:11 -0400 | [diff] [blame] | 6172 | if (status != 0) |
| 6173 | goto out; |
Trond Myklebust | 8bcbe7d | 2018-03-20 17:03:11 -0400 | [diff] [blame] | 6174 | if (res->fattr) |
| 6175 | decode_getfattr(xdr, res->fattr, res->server); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6176 | out: |
| 6177 | return status; |
| 6178 | } |
| 6179 | |
| 6180 | /* |
| 6181 | * Decode LOOKUP response |
| 6182 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6183 | static int nfs4_xdr_dec_lookup(struct rpc_rqst *rqstp, struct xdr_stream *xdr, |
Christoph Hellwig | fc01648 | 2017-05-08 15:09:02 +0200 | [diff] [blame] | 6184 | void *data) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6185 | { |
Christoph Hellwig | fc01648 | 2017-05-08 15:09:02 +0200 | [diff] [blame] | 6186 | struct nfs4_lookup_res *res = data; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6187 | struct compound_hdr hdr; |
| 6188 | int status; |
Andy Adamson | 6c0195a | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6189 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6190 | status = decode_compound_hdr(xdr, &hdr); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6191 | if (status) |
| 6192 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6193 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6194 | if (status) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6195 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6196 | status = decode_putfh(xdr); |
| 6197 | if (status) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6198 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6199 | status = decode_lookup(xdr); |
| 6200 | if (status) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6201 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6202 | status = decode_getfh(xdr, res->fh); |
| 6203 | if (status) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6204 | goto out; |
Anna Schumaker | 1e2f67d | 2021-10-22 13:11:13 -0400 | [diff] [blame] | 6205 | status = decode_getfattr(xdr, res->fattr, res->server); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6206 | out: |
| 6207 | return status; |
| 6208 | } |
| 6209 | |
| 6210 | /* |
Jeff Layton | 5b5faaf | 2017-06-29 06:34:52 -0700 | [diff] [blame] | 6211 | * Decode LOOKUPP response |
| 6212 | */ |
| 6213 | static int nfs4_xdr_dec_lookupp(struct rpc_rqst *rqstp, struct xdr_stream *xdr, |
| 6214 | void *data) |
| 6215 | { |
| 6216 | struct nfs4_lookupp_res *res = data; |
| 6217 | struct compound_hdr hdr; |
| 6218 | int status; |
| 6219 | |
| 6220 | status = decode_compound_hdr(xdr, &hdr); |
| 6221 | if (status) |
| 6222 | goto out; |
| 6223 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
| 6224 | if (status) |
| 6225 | goto out; |
| 6226 | status = decode_putfh(xdr); |
| 6227 | if (status) |
| 6228 | goto out; |
| 6229 | status = decode_lookupp(xdr); |
| 6230 | if (status) |
| 6231 | goto out; |
| 6232 | status = decode_getfh(xdr, res->fh); |
| 6233 | if (status) |
| 6234 | goto out; |
Anna Schumaker | 1e2f67d | 2021-10-22 13:11:13 -0400 | [diff] [blame] | 6235 | status = decode_getfattr(xdr, res->fattr, res->server); |
Jeff Layton | 5b5faaf | 2017-06-29 06:34:52 -0700 | [diff] [blame] | 6236 | out: |
| 6237 | return status; |
| 6238 | } |
| 6239 | |
| 6240 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6241 | * Decode LOOKUP_ROOT response |
| 6242 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6243 | static int nfs4_xdr_dec_lookup_root(struct rpc_rqst *rqstp, |
| 6244 | struct xdr_stream *xdr, |
Christoph Hellwig | fc01648 | 2017-05-08 15:09:02 +0200 | [diff] [blame] | 6245 | void *data) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6246 | { |
Christoph Hellwig | fc01648 | 2017-05-08 15:09:02 +0200 | [diff] [blame] | 6247 | struct nfs4_lookup_res *res = data; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6248 | struct compound_hdr hdr; |
| 6249 | int status; |
Andy Adamson | 6c0195a | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6250 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6251 | status = decode_compound_hdr(xdr, &hdr); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6252 | if (status) |
| 6253 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6254 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6255 | if (status) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6256 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6257 | status = decode_putrootfh(xdr); |
| 6258 | if (status) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6259 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6260 | status = decode_getfh(xdr, res->fh); |
| 6261 | if (status == 0) |
Anna Schumaker | 1e2f67d | 2021-10-22 13:11:13 -0400 | [diff] [blame] | 6262 | status = decode_getfattr(xdr, res->fattr, res->server); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6263 | out: |
| 6264 | return status; |
| 6265 | } |
| 6266 | |
| 6267 | /* |
| 6268 | * Decode REMOVE response |
| 6269 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6270 | static int nfs4_xdr_dec_remove(struct rpc_rqst *rqstp, struct xdr_stream *xdr, |
Christoph Hellwig | fc01648 | 2017-05-08 15:09:02 +0200 | [diff] [blame] | 6271 | void *data) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6272 | { |
Christoph Hellwig | fc01648 | 2017-05-08 15:09:02 +0200 | [diff] [blame] | 6273 | struct nfs_removeres *res = data; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6274 | struct compound_hdr hdr; |
| 6275 | int status; |
Andy Adamson | 6c0195a | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6276 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6277 | status = decode_compound_hdr(xdr, &hdr); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6278 | if (status) |
| 6279 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6280 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6281 | if (status) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6282 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6283 | status = decode_putfh(xdr); |
| 6284 | if (status) |
Trond Myklebust | 16e4295 | 2005-10-27 22:12:44 -0400 | [diff] [blame] | 6285 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6286 | status = decode_remove(xdr, &res->cinfo); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6287 | out: |
| 6288 | return status; |
| 6289 | } |
| 6290 | |
| 6291 | /* |
| 6292 | * Decode RENAME response |
| 6293 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6294 | static int nfs4_xdr_dec_rename(struct rpc_rqst *rqstp, struct xdr_stream *xdr, |
Christoph Hellwig | fc01648 | 2017-05-08 15:09:02 +0200 | [diff] [blame] | 6295 | void *data) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6296 | { |
Christoph Hellwig | fc01648 | 2017-05-08 15:09:02 +0200 | [diff] [blame] | 6297 | struct nfs_renameres *res = data; |
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_savefh(xdr); |
| 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_putfh(xdr); |
| 6314 | if (status) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6315 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6316 | status = decode_rename(xdr, &res->old_cinfo, &res->new_cinfo); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6317 | out: |
| 6318 | return status; |
| 6319 | } |
| 6320 | |
| 6321 | /* |
| 6322 | * Decode LINK response |
| 6323 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6324 | static int nfs4_xdr_dec_link(struct rpc_rqst *rqstp, struct xdr_stream *xdr, |
Christoph Hellwig | fc01648 | 2017-05-08 15:09:02 +0200 | [diff] [blame] | 6325 | void *data) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6326 | { |
Christoph Hellwig | fc01648 | 2017-05-08 15:09:02 +0200 | [diff] [blame] | 6327 | struct nfs4_link_res *res = data; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6328 | struct compound_hdr hdr; |
| 6329 | int status; |
Andy Adamson | 6c0195a | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6330 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6331 | status = decode_compound_hdr(xdr, &hdr); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6332 | if (status) |
| 6333 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6334 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6335 | if (status) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6336 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6337 | status = decode_putfh(xdr); |
| 6338 | if (status) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6339 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6340 | status = decode_savefh(xdr); |
| 6341 | if (status) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6342 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6343 | status = decode_putfh(xdr); |
| 6344 | if (status) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6345 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6346 | status = decode_link(xdr, &res->cinfo); |
| 6347 | if (status) |
Trond Myklebust | 91ba2ee | 2005-10-27 22:12:42 -0400 | [diff] [blame] | 6348 | goto out; |
| 6349 | /* |
| 6350 | * Note order: OP_LINK leaves the directory as the current |
| 6351 | * filehandle. |
| 6352 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6353 | status = decode_restorefh(xdr); |
| 6354 | if (status) |
Trond Myklebust | 91ba2ee | 2005-10-27 22:12:42 -0400 | [diff] [blame] | 6355 | goto out; |
Anna Schumaker | 1e2f67d | 2021-10-22 13:11:13 -0400 | [diff] [blame] | 6356 | decode_getfattr(xdr, res->fattr, res->server); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6357 | out: |
| 6358 | return status; |
| 6359 | } |
| 6360 | |
| 6361 | /* |
| 6362 | * Decode CREATE response |
| 6363 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6364 | static int nfs4_xdr_dec_create(struct rpc_rqst *rqstp, struct xdr_stream *xdr, |
Christoph Hellwig | fc01648 | 2017-05-08 15:09:02 +0200 | [diff] [blame] | 6365 | void *data) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6366 | { |
Christoph Hellwig | fc01648 | 2017-05-08 15:09:02 +0200 | [diff] [blame] | 6367 | struct nfs4_create_res *res = data; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6368 | struct compound_hdr hdr; |
| 6369 | int status; |
Andy Adamson | 6c0195a | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6370 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6371 | status = decode_compound_hdr(xdr, &hdr); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6372 | if (status) |
| 6373 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6374 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6375 | if (status) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6376 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6377 | status = decode_putfh(xdr); |
| 6378 | if (status) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6379 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6380 | status = decode_create(xdr, &res->dir_cinfo); |
| 6381 | if (status) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6382 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6383 | status = decode_getfh(xdr, res->fh); |
| 6384 | if (status) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6385 | goto out; |
Anna Schumaker | 1e2f67d | 2021-10-22 13:11:13 -0400 | [diff] [blame] | 6386 | decode_getfattr(xdr, res->fattr, res->server); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6387 | out: |
| 6388 | return status; |
| 6389 | } |
| 6390 | |
| 6391 | /* |
| 6392 | * Decode SYMLINK response |
| 6393 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6394 | static int nfs4_xdr_dec_symlink(struct rpc_rqst *rqstp, struct xdr_stream *xdr, |
Christoph Hellwig | fc01648 | 2017-05-08 15:09:02 +0200 | [diff] [blame] | 6395 | void *res) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6396 | { |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6397 | return nfs4_xdr_dec_create(rqstp, xdr, res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6398 | } |
| 6399 | |
| 6400 | /* |
| 6401 | * Decode GETATTR response |
| 6402 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6403 | static int nfs4_xdr_dec_getattr(struct rpc_rqst *rqstp, struct xdr_stream *xdr, |
Christoph Hellwig | fc01648 | 2017-05-08 15:09:02 +0200 | [diff] [blame] | 6404 | void *data) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6405 | { |
Christoph Hellwig | fc01648 | 2017-05-08 15:09:02 +0200 | [diff] [blame] | 6406 | struct nfs4_getattr_res *res = data; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6407 | struct compound_hdr hdr; |
| 6408 | int status; |
Andy Adamson | 6c0195a | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6409 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6410 | status = decode_compound_hdr(xdr, &hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6411 | if (status) |
| 6412 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6413 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6414 | if (status) |
| 6415 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6416 | status = decode_putfh(xdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6417 | if (status) |
| 6418 | goto out; |
Anna Schumaker | 1e2f67d | 2021-10-22 13:11:13 -0400 | [diff] [blame] | 6419 | status = decode_getfattr(xdr, res->fattr, res->server); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6420 | out: |
| 6421 | return status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6422 | } |
| 6423 | |
J. Bruce Fields | 23ec696 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 6424 | /* |
| 6425 | * Encode an SETACL request |
| 6426 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 6427 | static void nfs4_xdr_enc_setacl(struct rpc_rqst *req, struct xdr_stream *xdr, |
Christoph Hellwig | fcc8581 | 2017-05-08 10:01:49 +0200 | [diff] [blame] | 6428 | const void *data) |
J. Bruce Fields | 23ec696 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 6429 | { |
Christoph Hellwig | fcc8581 | 2017-05-08 10:01:49 +0200 | [diff] [blame] | 6430 | const struct nfs_setaclargs *args = data; |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6431 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 6432 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6433 | }; |
J. Bruce Fields | 23ec696 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 6434 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 6435 | encode_compound_hdr(xdr, req, &hdr); |
| 6436 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 6437 | encode_putfh(xdr, args->fh, &hdr); |
| 6438 | encode_setacl(xdr, args, &hdr); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 6439 | encode_nops(&hdr); |
J. Bruce Fields | 23ec696 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 6440 | } |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6441 | |
J. Bruce Fields | 23ec696 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 6442 | /* |
| 6443 | * Decode SETACL response |
| 6444 | */ |
| 6445 | static int |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6446 | nfs4_xdr_dec_setacl(struct rpc_rqst *rqstp, struct xdr_stream *xdr, |
Christoph Hellwig | fc01648 | 2017-05-08 15:09:02 +0200 | [diff] [blame] | 6447 | void *data) |
J. Bruce Fields | 23ec696 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 6448 | { |
Christoph Hellwig | fc01648 | 2017-05-08 15:09:02 +0200 | [diff] [blame] | 6449 | struct nfs_setaclres *res = data; |
J. Bruce Fields | 23ec696 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 6450 | struct compound_hdr hdr; |
| 6451 | int status; |
| 6452 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6453 | status = decode_compound_hdr(xdr, &hdr); |
J. Bruce Fields | 23ec696 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 6454 | if (status) |
| 6455 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6456 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6457 | if (status) |
| 6458 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6459 | status = decode_putfh(xdr); |
J. Bruce Fields | 23ec696 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 6460 | if (status) |
| 6461 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6462 | status = decode_setattr(xdr); |
J. Bruce Fields | 23ec696 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 6463 | out: |
| 6464 | return status; |
| 6465 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6466 | |
| 6467 | /* |
J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 6468 | * Decode GETACL response |
| 6469 | */ |
| 6470 | static int |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6471 | nfs4_xdr_dec_getacl(struct rpc_rqst *rqstp, struct xdr_stream *xdr, |
Christoph Hellwig | fc01648 | 2017-05-08 15:09:02 +0200 | [diff] [blame] | 6472 | void *data) |
J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 6473 | { |
Christoph Hellwig | fc01648 | 2017-05-08 15:09:02 +0200 | [diff] [blame] | 6474 | struct nfs_getaclres *res = data; |
J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 6475 | struct compound_hdr hdr; |
| 6476 | int status; |
| 6477 | |
Chuck Lever | 0ae4c3e | 2020-11-11 15:52:47 -0500 | [diff] [blame] | 6478 | if (res->acl_scratch != NULL) |
| 6479 | xdr_set_scratch_page(xdr, res->acl_scratch); |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6480 | status = decode_compound_hdr(xdr, &hdr); |
J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 6481 | if (status) |
| 6482 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6483 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6484 | if (status) |
| 6485 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6486 | status = decode_putfh(xdr); |
J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 6487 | if (status) |
| 6488 | goto out; |
Andy Adamson | bf118a3 | 2011-12-07 11:55:27 -0500 | [diff] [blame] | 6489 | status = decode_getacl(xdr, rqstp, res); |
J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 6490 | |
| 6491 | out: |
| 6492 | return status; |
| 6493 | } |
| 6494 | |
| 6495 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6496 | * Decode CLOSE response |
| 6497 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6498 | static int nfs4_xdr_dec_close(struct rpc_rqst *rqstp, struct xdr_stream *xdr, |
Christoph Hellwig | fc01648 | 2017-05-08 15:09:02 +0200 | [diff] [blame] | 6499 | void *data) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6500 | { |
Christoph Hellwig | fc01648 | 2017-05-08 15:09:02 +0200 | [diff] [blame] | 6501 | struct nfs_closeres *res = data; |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6502 | struct compound_hdr hdr; |
| 6503 | int status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6504 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6505 | status = decode_compound_hdr(xdr, &hdr); |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6506 | if (status) |
| 6507 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6508 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6509 | if (status) |
| 6510 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6511 | status = decode_putfh(xdr); |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6512 | if (status) |
| 6513 | goto out; |
Trond Myklebust | cf80516 | 2016-11-15 14:56:07 -0500 | [diff] [blame] | 6514 | if (res->lr_res) { |
| 6515 | status = decode_layoutreturn(xdr, res->lr_res); |
| 6516 | res->lr_ret = status; |
| 6517 | if (status) |
| 6518 | goto out; |
| 6519 | } |
Trond Myklebust | d8d8498 | 2016-12-19 12:14:44 -0500 | [diff] [blame] | 6520 | if (res->fattr != NULL) { |
| 6521 | status = decode_getfattr(xdr, res->fattr, res->server); |
| 6522 | if (status != 0) |
| 6523 | goto out; |
| 6524 | } |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6525 | status = decode_close(xdr, res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6526 | out: |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6527 | return status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6528 | } |
| 6529 | |
| 6530 | /* |
| 6531 | * Decode OPEN response |
| 6532 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6533 | static int nfs4_xdr_dec_open(struct rpc_rqst *rqstp, struct xdr_stream *xdr, |
Christoph Hellwig | fc01648 | 2017-05-08 15:09:02 +0200 | [diff] [blame] | 6534 | void *data) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6535 | { |
Christoph Hellwig | fc01648 | 2017-05-08 15:09:02 +0200 | [diff] [blame] | 6536 | struct nfs_openres *res = data; |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6537 | struct compound_hdr hdr; |
| 6538 | int status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6539 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6540 | status = decode_compound_hdr(xdr, &hdr); |
Trond Myklebust | 56ae19f | 2005-10-27 22:12:40 -0400 | [diff] [blame] | 6541 | if (status) |
| 6542 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6543 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6544 | if (status) |
| 6545 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6546 | status = decode_putfh(xdr); |
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_open(xdr, res); |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6550 | if (status) |
| 6551 | goto out; |
Weston Andros Adamson | 01913b4 | 2012-09-06 15:54:27 -0400 | [diff] [blame] | 6552 | status = decode_getfh(xdr, &res->fh); |
| 6553 | if (status) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6554 | goto out; |
Weston Andros Adamson | ae2bb03 | 2012-10-02 14:49:52 -0700 | [diff] [blame] | 6555 | if (res->access_request) |
| 6556 | decode_access(xdr, &res->access_supported, &res->access_result); |
Anna Schumaker | 1e2f67d | 2021-10-22 13:11:13 -0400 | [diff] [blame] | 6557 | decode_getfattr(xdr, res->f_attr, res->server); |
Fred Isaman | 56f487f | 2016-09-21 11:43:41 -0400 | [diff] [blame] | 6558 | if (res->lg_res) |
| 6559 | decode_layoutget(xdr, rqstp, res->lg_res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6560 | out: |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6561 | return status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6562 | } |
| 6563 | |
| 6564 | /* |
| 6565 | * Decode OPEN_CONFIRM response |
| 6566 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6567 | static int nfs4_xdr_dec_open_confirm(struct rpc_rqst *rqstp, |
| 6568 | struct xdr_stream *xdr, |
Christoph Hellwig | fc01648 | 2017-05-08 15:09:02 +0200 | [diff] [blame] | 6569 | void *data) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6570 | { |
Christoph Hellwig | fc01648 | 2017-05-08 15:09:02 +0200 | [diff] [blame] | 6571 | struct nfs_open_confirmres *res = data; |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6572 | struct compound_hdr hdr; |
| 6573 | int status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6574 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6575 | status = decode_compound_hdr(xdr, &hdr); |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [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); |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6579 | if (status) |
| 6580 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6581 | status = decode_open_confirm(xdr, res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6582 | out: |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6583 | return status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6584 | } |
| 6585 | |
| 6586 | /* |
| 6587 | * Decode OPEN response |
| 6588 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6589 | static int nfs4_xdr_dec_open_noattr(struct rpc_rqst *rqstp, |
| 6590 | struct xdr_stream *xdr, |
Christoph Hellwig | fc01648 | 2017-05-08 15:09:02 +0200 | [diff] [blame] | 6591 | void *data) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6592 | { |
Christoph Hellwig | fc01648 | 2017-05-08 15:09:02 +0200 | [diff] [blame] | 6593 | struct nfs_openres *res = data; |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6594 | struct compound_hdr hdr; |
| 6595 | int status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6596 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6597 | status = decode_compound_hdr(xdr, &hdr); |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6598 | if (status) |
| 6599 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6600 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6601 | if (status) |
| 6602 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6603 | status = decode_putfh(xdr); |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6604 | if (status) |
| 6605 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6606 | status = decode_open(xdr, res); |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6607 | if (status) |
| 6608 | goto out; |
Weston Andros Adamson | ae2bb03 | 2012-10-02 14:49:52 -0700 | [diff] [blame] | 6609 | if (res->access_request) |
| 6610 | decode_access(xdr, &res->access_supported, &res->access_result); |
Trond Myklebust | 6926afd1 | 2012-01-07 13:22:46 -0500 | [diff] [blame] | 6611 | decode_getfattr(xdr, res->f_attr, res->server); |
Fred Isaman | 56f487f | 2016-09-21 11:43:41 -0400 | [diff] [blame] | 6612 | if (res->lg_res) |
| 6613 | decode_layoutget(xdr, rqstp, res->lg_res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6614 | out: |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6615 | return status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6616 | } |
| 6617 | |
| 6618 | /* |
| 6619 | * Decode SETATTR response |
| 6620 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6621 | static int nfs4_xdr_dec_setattr(struct rpc_rqst *rqstp, |
| 6622 | struct xdr_stream *xdr, |
Christoph Hellwig | fc01648 | 2017-05-08 15:09:02 +0200 | [diff] [blame] | 6623 | void *data) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6624 | { |
Christoph Hellwig | fc01648 | 2017-05-08 15:09:02 +0200 | [diff] [blame] | 6625 | struct nfs_setattrres *res = data; |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6626 | struct compound_hdr hdr; |
| 6627 | int status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6628 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6629 | status = decode_compound_hdr(xdr, &hdr); |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6630 | if (status) |
| 6631 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6632 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6633 | if (status) |
| 6634 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6635 | status = decode_putfh(xdr); |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6636 | if (status) |
| 6637 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6638 | status = decode_setattr(xdr); |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6639 | if (status) |
| 6640 | goto out; |
Anna Schumaker | 1e2f67d | 2021-10-22 13:11:13 -0400 | [diff] [blame] | 6641 | decode_getfattr(xdr, res->fattr, res->server); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6642 | out: |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6643 | return status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6644 | } |
| 6645 | |
| 6646 | /* |
| 6647 | * Decode LOCK response |
| 6648 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6649 | static int nfs4_xdr_dec_lock(struct rpc_rqst *rqstp, struct xdr_stream *xdr, |
Christoph Hellwig | fc01648 | 2017-05-08 15:09:02 +0200 | [diff] [blame] | 6650 | void *data) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6651 | { |
Christoph Hellwig | fc01648 | 2017-05-08 15:09:02 +0200 | [diff] [blame] | 6652 | struct nfs_lock_res *res = data; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6653 | struct compound_hdr hdr; |
| 6654 | int status; |
| 6655 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6656 | status = decode_compound_hdr(xdr, &hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6657 | if (status) |
| 6658 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6659 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6660 | if (status) |
| 6661 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6662 | status = decode_putfh(xdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6663 | if (status) |
| 6664 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6665 | status = decode_lock(xdr, res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6666 | out: |
| 6667 | return status; |
| 6668 | } |
| 6669 | |
| 6670 | /* |
| 6671 | * Decode LOCKT response |
| 6672 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6673 | static int nfs4_xdr_dec_lockt(struct rpc_rqst *rqstp, struct xdr_stream *xdr, |
Christoph Hellwig | fc01648 | 2017-05-08 15:09:02 +0200 | [diff] [blame] | 6674 | void *data) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6675 | { |
Christoph Hellwig | fc01648 | 2017-05-08 15:09:02 +0200 | [diff] [blame] | 6676 | struct nfs_lockt_res *res = data; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6677 | struct compound_hdr hdr; |
| 6678 | int status; |
| 6679 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6680 | status = decode_compound_hdr(xdr, &hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6681 | if (status) |
| 6682 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6683 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6684 | if (status) |
| 6685 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6686 | status = decode_putfh(xdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6687 | if (status) |
| 6688 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6689 | status = decode_lockt(xdr, res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6690 | out: |
| 6691 | return status; |
| 6692 | } |
| 6693 | |
| 6694 | /* |
| 6695 | * Decode LOCKU response |
| 6696 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6697 | static int nfs4_xdr_dec_locku(struct rpc_rqst *rqstp, struct xdr_stream *xdr, |
Christoph Hellwig | fc01648 | 2017-05-08 15:09:02 +0200 | [diff] [blame] | 6698 | void *data) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6699 | { |
Christoph Hellwig | fc01648 | 2017-05-08 15:09:02 +0200 | [diff] [blame] | 6700 | struct nfs_locku_res *res = data; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6701 | struct compound_hdr hdr; |
| 6702 | int status; |
| 6703 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6704 | status = decode_compound_hdr(xdr, &hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6705 | if (status) |
| 6706 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6707 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6708 | if (status) |
| 6709 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6710 | status = decode_putfh(xdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6711 | if (status) |
| 6712 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6713 | status = decode_locku(xdr, res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6714 | out: |
| 6715 | return status; |
| 6716 | } |
| 6717 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6718 | static int nfs4_xdr_dec_release_lockowner(struct rpc_rqst *rqstp, |
| 6719 | struct xdr_stream *xdr, void *dummy) |
Trond Myklebust | d3c7b7c | 2010-07-01 12:49:01 -0400 | [diff] [blame] | 6720 | { |
Trond Myklebust | d3c7b7c | 2010-07-01 12:49:01 -0400 | [diff] [blame] | 6721 | struct compound_hdr hdr; |
| 6722 | int status; |
| 6723 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6724 | status = decode_compound_hdr(xdr, &hdr); |
Trond Myklebust | d3c7b7c | 2010-07-01 12:49:01 -0400 | [diff] [blame] | 6725 | if (!status) |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6726 | status = decode_release_lockowner(xdr); |
Trond Myklebust | d3c7b7c | 2010-07-01 12:49:01 -0400 | [diff] [blame] | 6727 | return status; |
| 6728 | } |
| 6729 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6730 | /* |
| 6731 | * Decode READLINK response |
| 6732 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6733 | static int nfs4_xdr_dec_readlink(struct rpc_rqst *rqstp, |
| 6734 | struct xdr_stream *xdr, |
Christoph Hellwig | fc01648 | 2017-05-08 15:09:02 +0200 | [diff] [blame] | 6735 | void *data) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6736 | { |
Christoph Hellwig | fc01648 | 2017-05-08 15:09:02 +0200 | [diff] [blame] | 6737 | struct nfs4_readlink_res *res = data; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6738 | struct compound_hdr hdr; |
| 6739 | int status; |
| 6740 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6741 | status = decode_compound_hdr(xdr, &hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6742 | if (status) |
| 6743 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6744 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6745 | if (status) |
| 6746 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6747 | status = decode_putfh(xdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6748 | if (status) |
| 6749 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6750 | status = decode_readlink(xdr, rqstp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6751 | out: |
| 6752 | return status; |
| 6753 | } |
| 6754 | |
| 6755 | /* |
| 6756 | * Decode READDIR response |
| 6757 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6758 | static int nfs4_xdr_dec_readdir(struct rpc_rqst *rqstp, struct xdr_stream *xdr, |
Christoph Hellwig | fc01648 | 2017-05-08 15:09:02 +0200 | [diff] [blame] | 6759 | void *data) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6760 | { |
Christoph Hellwig | fc01648 | 2017-05-08 15:09:02 +0200 | [diff] [blame] | 6761 | struct nfs4_readdir_res *res = data; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6762 | struct compound_hdr hdr; |
| 6763 | int status; |
| 6764 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6765 | status = decode_compound_hdr(xdr, &hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6766 | if (status) |
| 6767 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6768 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6769 | if (status) |
| 6770 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6771 | status = decode_putfh(xdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6772 | if (status) |
| 6773 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6774 | status = decode_readdir(xdr, rqstp, res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6775 | out: |
| 6776 | return status; |
| 6777 | } |
| 6778 | |
| 6779 | /* |
| 6780 | * Decode Read response |
| 6781 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6782 | static int nfs4_xdr_dec_read(struct rpc_rqst *rqstp, struct xdr_stream *xdr, |
Christoph Hellwig | fc01648 | 2017-05-08 15:09:02 +0200 | [diff] [blame] | 6783 | void *data) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6784 | { |
Christoph Hellwig | fc01648 | 2017-05-08 15:09:02 +0200 | [diff] [blame] | 6785 | struct nfs_pgio_res *res = data; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6786 | struct compound_hdr hdr; |
| 6787 | int status; |
| 6788 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6789 | status = decode_compound_hdr(xdr, &hdr); |
Peng Tao | aabff4d | 2014-08-27 10:47:14 +0800 | [diff] [blame] | 6790 | res->op_status = hdr.status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6791 | if (status) |
| 6792 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6793 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6794 | if (status) |
| 6795 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6796 | status = decode_putfh(xdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6797 | if (status) |
| 6798 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6799 | status = decode_read(xdr, rqstp, res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6800 | if (!status) |
| 6801 | status = res->count; |
| 6802 | out: |
| 6803 | return status; |
| 6804 | } |
| 6805 | |
| 6806 | /* |
| 6807 | * Decode WRITE response |
| 6808 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6809 | static int nfs4_xdr_dec_write(struct rpc_rqst *rqstp, struct xdr_stream *xdr, |
Christoph Hellwig | fc01648 | 2017-05-08 15:09:02 +0200 | [diff] [blame] | 6810 | void *data) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6811 | { |
Christoph Hellwig | fc01648 | 2017-05-08 15:09:02 +0200 | [diff] [blame] | 6812 | struct nfs_pgio_res *res = data; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6813 | struct compound_hdr hdr; |
| 6814 | int status; |
| 6815 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6816 | status = decode_compound_hdr(xdr, &hdr); |
Peng Tao | aabff4d | 2014-08-27 10:47:14 +0800 | [diff] [blame] | 6817 | res->op_status = hdr.status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6818 | if (status) |
| 6819 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6820 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6821 | if (status) |
| 6822 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6823 | status = decode_putfh(xdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6824 | if (status) |
| 6825 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6826 | status = decode_write(xdr, res); |
Trond Myklebust | 4f9838c | 2005-10-27 22:12:44 -0400 | [diff] [blame] | 6827 | if (status) |
| 6828 | goto out; |
Fred Isaman | 7ffd106 | 2011-03-03 15:13:46 +0000 | [diff] [blame] | 6829 | if (res->fattr) |
Trond Myklebust | 6926afd1 | 2012-01-07 13:22:46 -0500 | [diff] [blame] | 6830 | decode_getfattr(xdr, res->fattr, res->server); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6831 | if (!status) |
| 6832 | status = res->count; |
| 6833 | out: |
| 6834 | return status; |
| 6835 | } |
| 6836 | |
| 6837 | /* |
| 6838 | * Decode COMMIT response |
| 6839 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6840 | static int nfs4_xdr_dec_commit(struct rpc_rqst *rqstp, struct xdr_stream *xdr, |
Christoph Hellwig | fc01648 | 2017-05-08 15:09:02 +0200 | [diff] [blame] | 6841 | void *data) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6842 | { |
Christoph Hellwig | fc01648 | 2017-05-08 15:09:02 +0200 | [diff] [blame] | 6843 | struct nfs_commitres *res = data; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6844 | struct compound_hdr hdr; |
| 6845 | int status; |
| 6846 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6847 | status = decode_compound_hdr(xdr, &hdr); |
Peng Tao | aabff4d | 2014-08-27 10:47:14 +0800 | [diff] [blame] | 6848 | res->op_status = hdr.status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6849 | if (status) |
| 6850 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6851 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6852 | if (status) |
| 6853 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6854 | status = decode_putfh(xdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6855 | if (status) |
| 6856 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6857 | status = decode_commit(xdr, res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6858 | out: |
| 6859 | return status; |
| 6860 | } |
| 6861 | |
| 6862 | /* |
Ricardo Labiaga | 8b17321 | 2009-12-05 16:08:39 -0500 | [diff] [blame] | 6863 | * Decode FSINFO response |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6864 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6865 | static int nfs4_xdr_dec_fsinfo(struct rpc_rqst *req, struct xdr_stream *xdr, |
Christoph Hellwig | fc01648 | 2017-05-08 15:09:02 +0200 | [diff] [blame] | 6866 | void *data) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6867 | { |
Christoph Hellwig | fc01648 | 2017-05-08 15:09:02 +0200 | [diff] [blame] | 6868 | struct nfs4_fsinfo_res *res = data; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6869 | struct compound_hdr hdr; |
| 6870 | int status; |
| 6871 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6872 | status = decode_compound_hdr(xdr, &hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6873 | if (!status) |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6874 | status = decode_sequence(xdr, &res->seq_res, req); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6875 | if (!status) |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6876 | status = decode_putfh(xdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6877 | if (!status) |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6878 | status = decode_fsinfo(xdr, res->fsinfo); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6879 | return status; |
| 6880 | } |
| 6881 | |
| 6882 | /* |
Ricardo Labiaga | 8b17321 | 2009-12-05 16:08:39 -0500 | [diff] [blame] | 6883 | * Decode PATHCONF response |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6884 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6885 | static int nfs4_xdr_dec_pathconf(struct rpc_rqst *req, struct xdr_stream *xdr, |
Christoph Hellwig | fc01648 | 2017-05-08 15:09:02 +0200 | [diff] [blame] | 6886 | void *data) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6887 | { |
Christoph Hellwig | fc01648 | 2017-05-08 15:09:02 +0200 | [diff] [blame] | 6888 | struct nfs4_pathconf_res *res = data; |
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_sequence(xdr, &res->seq_res, req); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6895 | if (!status) |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6896 | status = decode_putfh(xdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6897 | if (!status) |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6898 | status = decode_pathconf(xdr, res->pathconf); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6899 | return status; |
| 6900 | } |
| 6901 | |
| 6902 | /* |
Ricardo Labiaga | 8b17321 | 2009-12-05 16:08:39 -0500 | [diff] [blame] | 6903 | * Decode STATFS response |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6904 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6905 | static int nfs4_xdr_dec_statfs(struct rpc_rqst *req, struct xdr_stream *xdr, |
Christoph Hellwig | fc01648 | 2017-05-08 15:09:02 +0200 | [diff] [blame] | 6906 | void *data) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6907 | { |
Christoph Hellwig | fc01648 | 2017-05-08 15:09:02 +0200 | [diff] [blame] | 6908 | struct nfs4_statfs_res *res = data; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6909 | struct compound_hdr hdr; |
| 6910 | int status; |
| 6911 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6912 | status = decode_compound_hdr(xdr, &hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6913 | if (!status) |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6914 | status = decode_sequence(xdr, &res->seq_res, req); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6915 | if (!status) |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6916 | status = decode_putfh(xdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6917 | if (!status) |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6918 | status = decode_statfs(xdr, res->fsstat); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6919 | return status; |
| 6920 | } |
| 6921 | |
| 6922 | /* |
Ricardo Labiaga | 8b17321 | 2009-12-05 16:08:39 -0500 | [diff] [blame] | 6923 | * Decode GETATTR_BITMAP response |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6924 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6925 | static int nfs4_xdr_dec_server_caps(struct rpc_rqst *req, |
| 6926 | struct xdr_stream *xdr, |
Christoph Hellwig | fc01648 | 2017-05-08 15:09:02 +0200 | [diff] [blame] | 6927 | void *data) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6928 | { |
Christoph Hellwig | fc01648 | 2017-05-08 15:09:02 +0200 | [diff] [blame] | 6929 | struct nfs4_server_caps_res *res = data; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6930 | struct compound_hdr hdr; |
| 6931 | int status; |
| 6932 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6933 | status = decode_compound_hdr(xdr, &hdr); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6934 | if (status) |
| 6935 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6936 | status = decode_sequence(xdr, &res->seq_res, req); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6937 | if (status) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6938 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6939 | status = decode_putfh(xdr); |
| 6940 | if (status) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6941 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6942 | status = decode_server_caps(xdr, res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6943 | out: |
| 6944 | return status; |
| 6945 | } |
| 6946 | |
| 6947 | /* |
| 6948 | * Decode RENEW response |
| 6949 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6950 | static int nfs4_xdr_dec_renew(struct rpc_rqst *rqstp, struct xdr_stream *xdr, |
| 6951 | void *__unused) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6952 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6953 | struct compound_hdr hdr; |
| 6954 | int status; |
| 6955 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6956 | status = decode_compound_hdr(xdr, &hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6957 | if (!status) |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6958 | status = decode_renew(xdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6959 | return status; |
| 6960 | } |
| 6961 | |
| 6962 | /* |
Ricardo Labiaga | 8b17321 | 2009-12-05 16:08:39 -0500 | [diff] [blame] | 6963 | * Decode SETCLIENTID response |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6964 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6965 | static int nfs4_xdr_dec_setclientid(struct rpc_rqst *req, |
| 6966 | struct xdr_stream *xdr, |
Christoph Hellwig | fc01648 | 2017-05-08 15:09:02 +0200 | [diff] [blame] | 6967 | void *data) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6968 | { |
Christoph Hellwig | fc01648 | 2017-05-08 15:09:02 +0200 | [diff] [blame] | 6969 | struct nfs4_setclientid_res *res = data; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6970 | struct compound_hdr hdr; |
| 6971 | int status; |
| 6972 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6973 | status = decode_compound_hdr(xdr, &hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6974 | if (!status) |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6975 | status = decode_setclientid(xdr, res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6976 | return status; |
| 6977 | } |
| 6978 | |
| 6979 | /* |
Ricardo Labiaga | 8b17321 | 2009-12-05 16:08:39 -0500 | [diff] [blame] | 6980 | * Decode SETCLIENTID_CONFIRM response |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6981 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6982 | static int nfs4_xdr_dec_setclientid_confirm(struct rpc_rqst *req, |
Christoph Hellwig | fc01648 | 2017-05-08 15:09:02 +0200 | [diff] [blame] | 6983 | struct xdr_stream *xdr, |
| 6984 | void *data) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6985 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6986 | struct compound_hdr hdr; |
| 6987 | int status; |
| 6988 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6989 | status = decode_compound_hdr(xdr, &hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6990 | if (!status) |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6991 | status = decode_setclientid_confirm(xdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6992 | return status; |
| 6993 | } |
| 6994 | |
| 6995 | /* |
Ricardo Labiaga | 8b17321 | 2009-12-05 16:08:39 -0500 | [diff] [blame] | 6996 | * Decode DELEGRETURN response |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6997 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6998 | static int nfs4_xdr_dec_delegreturn(struct rpc_rqst *rqstp, |
| 6999 | struct xdr_stream *xdr, |
Christoph Hellwig | fc01648 | 2017-05-08 15:09:02 +0200 | [diff] [blame] | 7000 | void *data) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7001 | { |
Christoph Hellwig | fc01648 | 2017-05-08 15:09:02 +0200 | [diff] [blame] | 7002 | struct nfs4_delegreturnres *res = data; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7003 | struct compound_hdr hdr; |
| 7004 | int status; |
| 7005 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 7006 | status = decode_compound_hdr(xdr, &hdr); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 7007 | if (status) |
| 7008 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 7009 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 7010 | if (status) |
Trond Myklebust | fa178f2 | 2006-01-03 09:55:38 +0100 | [diff] [blame] | 7011 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 7012 | status = decode_putfh(xdr); |
Trond Myklebust | fa178f2 | 2006-01-03 09:55:38 +0100 | [diff] [blame] | 7013 | if (status != 0) |
| 7014 | goto out; |
Trond Myklebust | 586f1c3 | 2016-11-15 15:03:33 -0500 | [diff] [blame] | 7015 | if (res->lr_res) { |
| 7016 | status = decode_layoutreturn(xdr, res->lr_res); |
| 7017 | res->lr_ret = status; |
| 7018 | if (status) |
| 7019 | goto out; |
| 7020 | } |
Trond Myklebust | 8ac2b422 | 2016-12-19 10:23:10 -0500 | [diff] [blame] | 7021 | if (res->fattr) { |
| 7022 | status = decode_getfattr(xdr, res->fattr, res->server); |
| 7023 | if (status != 0) |
| 7024 | goto out; |
| 7025 | } |
Trond Myklebust | e144cbc | 2012-04-28 16:05:03 -0400 | [diff] [blame] | 7026 | status = decode_delegreturn(xdr); |
Trond Myklebust | fa178f2 | 2006-01-03 09:55:38 +0100 | [diff] [blame] | 7027 | out: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7028 | return status; |
| 7029 | } |
| 7030 | |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 7031 | /* |
Ricardo Labiaga | 8b17321 | 2009-12-05 16:08:39 -0500 | [diff] [blame] | 7032 | * Decode FS_LOCATIONS response |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 7033 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 7034 | static int nfs4_xdr_dec_fs_locations(struct rpc_rqst *req, |
| 7035 | struct xdr_stream *xdr, |
Christoph Hellwig | fc01648 | 2017-05-08 15:09:02 +0200 | [diff] [blame] | 7036 | void *data) |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 7037 | { |
Christoph Hellwig | fc01648 | 2017-05-08 15:09:02 +0200 | [diff] [blame] | 7038 | struct nfs4_fs_locations_res *res = data; |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 7039 | struct compound_hdr hdr; |
| 7040 | int status; |
| 7041 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 7042 | status = decode_compound_hdr(xdr, &hdr); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 7043 | if (status) |
| 7044 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 7045 | status = decode_sequence(xdr, &res->seq_res, req); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 7046 | if (status) |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 7047 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 7048 | status = decode_putfh(xdr); |
| 7049 | if (status) |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 7050 | goto out; |
Chuck Lever | b03d735 | 2013-10-17 14:12:50 -0400 | [diff] [blame] | 7051 | if (res->migration) { |
| 7052 | xdr_enter_page(xdr, PAGE_SIZE); |
| 7053 | status = decode_getfattr_generic(xdr, |
| 7054 | &res->fs_locations->fattr, |
Trond Myklebust | 8b7e3f4 | 2012-01-30 15:43:56 -0500 | [diff] [blame] | 7055 | NULL, res->fs_locations, |
Anna Schumaker | 1e2f67d | 2021-10-22 13:11:13 -0400 | [diff] [blame] | 7056 | res->fs_locations->server); |
Chuck Lever | b03d735 | 2013-10-17 14:12:50 -0400 | [diff] [blame] | 7057 | if (status) |
| 7058 | goto out; |
| 7059 | if (res->renew) |
| 7060 | status = decode_renew(xdr); |
| 7061 | } else { |
| 7062 | status = decode_lookup(xdr); |
| 7063 | if (status) |
| 7064 | goto out; |
| 7065 | xdr_enter_page(xdr, PAGE_SIZE); |
| 7066 | status = decode_getfattr_generic(xdr, |
| 7067 | &res->fs_locations->fattr, |
| 7068 | NULL, res->fs_locations, |
Anna Schumaker | 1e2f67d | 2021-10-22 13:11:13 -0400 | [diff] [blame] | 7069 | res->fs_locations->server); |
Chuck Lever | b03d735 | 2013-10-17 14:12:50 -0400 | [diff] [blame] | 7070 | } |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 7071 | out: |
| 7072 | return status; |
| 7073 | } |
| 7074 | |
Bryan Schumaker | 5a5ea0d | 2011-03-24 17:12:29 +0000 | [diff] [blame] | 7075 | /* |
| 7076 | * Decode SECINFO response |
| 7077 | */ |
| 7078 | static int nfs4_xdr_dec_secinfo(struct rpc_rqst *rqstp, |
| 7079 | struct xdr_stream *xdr, |
Christoph Hellwig | fc01648 | 2017-05-08 15:09:02 +0200 | [diff] [blame] | 7080 | void *data) |
Bryan Schumaker | 5a5ea0d | 2011-03-24 17:12:29 +0000 | [diff] [blame] | 7081 | { |
Christoph Hellwig | fc01648 | 2017-05-08 15:09:02 +0200 | [diff] [blame] | 7082 | struct nfs4_secinfo_res *res = data; |
Bryan Schumaker | 5a5ea0d | 2011-03-24 17:12:29 +0000 | [diff] [blame] | 7083 | struct compound_hdr hdr; |
| 7084 | int status; |
| 7085 | |
| 7086 | status = decode_compound_hdr(xdr, &hdr); |
| 7087 | if (status) |
| 7088 | goto out; |
| 7089 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
| 7090 | if (status) |
| 7091 | goto out; |
| 7092 | status = decode_putfh(xdr); |
| 7093 | if (status) |
| 7094 | goto out; |
| 7095 | status = decode_secinfo(xdr, res); |
Bryan Schumaker | 5a5ea0d | 2011-03-24 17:12:29 +0000 | [diff] [blame] | 7096 | out: |
| 7097 | return status; |
| 7098 | } |
| 7099 | |
Chuck Lever | 44c9993 | 2013-10-17 14:13:30 -0400 | [diff] [blame] | 7100 | /* |
| 7101 | * Decode FSID_PRESENT response |
| 7102 | */ |
| 7103 | static int nfs4_xdr_dec_fsid_present(struct rpc_rqst *rqstp, |
| 7104 | struct xdr_stream *xdr, |
Christoph Hellwig | fc01648 | 2017-05-08 15:09:02 +0200 | [diff] [blame] | 7105 | void *data) |
Chuck Lever | 44c9993 | 2013-10-17 14:13:30 -0400 | [diff] [blame] | 7106 | { |
Christoph Hellwig | fc01648 | 2017-05-08 15:09:02 +0200 | [diff] [blame] | 7107 | struct nfs4_fsid_present_res *res = data; |
Chuck Lever | 44c9993 | 2013-10-17 14:13:30 -0400 | [diff] [blame] | 7108 | struct compound_hdr hdr; |
| 7109 | int status; |
| 7110 | |
| 7111 | status = decode_compound_hdr(xdr, &hdr); |
| 7112 | if (status) |
| 7113 | goto out; |
| 7114 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
| 7115 | if (status) |
| 7116 | goto out; |
| 7117 | status = decode_putfh(xdr); |
| 7118 | if (status) |
| 7119 | goto out; |
| 7120 | status = decode_getfh(xdr, res->fh); |
| 7121 | if (status) |
| 7122 | goto out; |
| 7123 | if (res->renew) |
| 7124 | status = decode_renew(xdr); |
| 7125 | out: |
| 7126 | return status; |
| 7127 | } |
| 7128 | |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 7129 | #if defined(CONFIG_NFS_V4_1) |
| 7130 | /* |
Weston Andros Adamson | 7c44f1ae | 2012-05-24 13:22:50 -0400 | [diff] [blame] | 7131 | * Decode BIND_CONN_TO_SESSION response |
| 7132 | */ |
| 7133 | static int nfs4_xdr_dec_bind_conn_to_session(struct rpc_rqst *rqstp, |
| 7134 | struct xdr_stream *xdr, |
| 7135 | void *res) |
| 7136 | { |
| 7137 | struct compound_hdr hdr; |
| 7138 | int status; |
| 7139 | |
| 7140 | status = decode_compound_hdr(xdr, &hdr); |
| 7141 | if (!status) |
| 7142 | status = decode_bind_conn_to_session(xdr, res); |
| 7143 | return status; |
| 7144 | } |
| 7145 | |
| 7146 | /* |
Ricardo Labiaga | 8b17321 | 2009-12-05 16:08:39 -0500 | [diff] [blame] | 7147 | * Decode EXCHANGE_ID response |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 7148 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 7149 | static int nfs4_xdr_dec_exchange_id(struct rpc_rqst *rqstp, |
| 7150 | struct xdr_stream *xdr, |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 7151 | void *res) |
| 7152 | { |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 7153 | struct compound_hdr hdr; |
| 7154 | int status; |
| 7155 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 7156 | status = decode_compound_hdr(xdr, &hdr); |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 7157 | if (!status) |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 7158 | status = decode_exchange_id(xdr, res); |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 7159 | return status; |
| 7160 | } |
Andy Adamson | 2050f0c | 2009-04-01 09:22:30 -0400 | [diff] [blame] | 7161 | |
| 7162 | /* |
Ricardo Labiaga | 8b17321 | 2009-12-05 16:08:39 -0500 | [diff] [blame] | 7163 | * Decode CREATE_SESSION response |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 7164 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 7165 | static int nfs4_xdr_dec_create_session(struct rpc_rqst *rqstp, |
| 7166 | struct xdr_stream *xdr, |
Christoph Hellwig | fc01648 | 2017-05-08 15:09:02 +0200 | [diff] [blame] | 7167 | void *res) |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 7168 | { |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 7169 | struct compound_hdr hdr; |
| 7170 | int status; |
| 7171 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 7172 | status = decode_compound_hdr(xdr, &hdr); |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 7173 | if (!status) |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 7174 | status = decode_create_session(xdr, res); |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 7175 | return status; |
| 7176 | } |
| 7177 | |
| 7178 | /* |
Ricardo Labiaga | 8b17321 | 2009-12-05 16:08:39 -0500 | [diff] [blame] | 7179 | * Decode DESTROY_SESSION response |
Andy Adamson | 0f3e66c | 2009-04-01 09:22:34 -0400 | [diff] [blame] | 7180 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 7181 | static int nfs4_xdr_dec_destroy_session(struct rpc_rqst *rqstp, |
| 7182 | struct xdr_stream *xdr, |
| 7183 | void *res) |
Andy Adamson | 0f3e66c | 2009-04-01 09:22:34 -0400 | [diff] [blame] | 7184 | { |
Andy Adamson | 0f3e66c | 2009-04-01 09:22:34 -0400 | [diff] [blame] | 7185 | struct compound_hdr hdr; |
| 7186 | int status; |
| 7187 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 7188 | status = decode_compound_hdr(xdr, &hdr); |
Andy Adamson | 0f3e66c | 2009-04-01 09:22:34 -0400 | [diff] [blame] | 7189 | if (!status) |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 7190 | status = decode_destroy_session(xdr, res); |
Andy Adamson | 0f3e66c | 2009-04-01 09:22:34 -0400 | [diff] [blame] | 7191 | return status; |
| 7192 | } |
| 7193 | |
| 7194 | /* |
Trond Myklebust | 6624553 | 2012-05-25 17:18:09 -0400 | [diff] [blame] | 7195 | * Decode DESTROY_CLIENTID response |
| 7196 | */ |
| 7197 | static int nfs4_xdr_dec_destroy_clientid(struct rpc_rqst *rqstp, |
| 7198 | struct xdr_stream *xdr, |
| 7199 | void *res) |
| 7200 | { |
| 7201 | struct compound_hdr hdr; |
| 7202 | int status; |
| 7203 | |
| 7204 | status = decode_compound_hdr(xdr, &hdr); |
| 7205 | if (!status) |
| 7206 | status = decode_destroy_clientid(xdr, res); |
| 7207 | return status; |
| 7208 | } |
| 7209 | |
| 7210 | /* |
Ricardo Labiaga | 8b17321 | 2009-12-05 16:08:39 -0500 | [diff] [blame] | 7211 | * Decode SEQUENCE response |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 7212 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 7213 | static int nfs4_xdr_dec_sequence(struct rpc_rqst *rqstp, |
| 7214 | struct xdr_stream *xdr, |
Christoph Hellwig | fc01648 | 2017-05-08 15:09:02 +0200 | [diff] [blame] | 7215 | void *res) |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 7216 | { |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 7217 | struct compound_hdr hdr; |
| 7218 | int status; |
| 7219 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 7220 | status = decode_compound_hdr(xdr, &hdr); |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 7221 | if (!status) |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 7222 | status = decode_sequence(xdr, res, rqstp); |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 7223 | return status; |
| 7224 | } |
| 7225 | |
Donald Buczek | 0efb01b | 2019-07-07 21:26:08 +0200 | [diff] [blame] | 7226 | #endif |
| 7227 | |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 7228 | /* |
Ricardo Labiaga | 8b17321 | 2009-12-05 16:08:39 -0500 | [diff] [blame] | 7229 | * Decode GET_LEASE_TIME response |
Andy Adamson | 2050f0c | 2009-04-01 09:22:30 -0400 | [diff] [blame] | 7230 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 7231 | static int nfs4_xdr_dec_get_lease_time(struct rpc_rqst *rqstp, |
| 7232 | struct xdr_stream *xdr, |
Christoph Hellwig | fc01648 | 2017-05-08 15:09:02 +0200 | [diff] [blame] | 7233 | void *data) |
Andy Adamson | 2050f0c | 2009-04-01 09:22:30 -0400 | [diff] [blame] | 7234 | { |
Christoph Hellwig | fc01648 | 2017-05-08 15:09:02 +0200 | [diff] [blame] | 7235 | struct nfs4_get_lease_time_res *res = data; |
Andy Adamson | 2050f0c | 2009-04-01 09:22:30 -0400 | [diff] [blame] | 7236 | struct compound_hdr hdr; |
| 7237 | int status; |
| 7238 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 7239 | status = decode_compound_hdr(xdr, &hdr); |
Andy Adamson | 2050f0c | 2009-04-01 09:22:30 -0400 | [diff] [blame] | 7240 | if (!status) |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 7241 | status = decode_sequence(xdr, &res->lr_seq_res, rqstp); |
Andy Adamson | 2050f0c | 2009-04-01 09:22:30 -0400 | [diff] [blame] | 7242 | if (!status) |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 7243 | status = decode_putrootfh(xdr); |
Andy Adamson | 2050f0c | 2009-04-01 09:22:30 -0400 | [diff] [blame] | 7244 | if (!status) |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 7245 | status = decode_fsinfo(xdr, res->lr_fsinfo); |
Andy Adamson | 2050f0c | 2009-04-01 09:22:30 -0400 | [diff] [blame] | 7246 | return status; |
| 7247 | } |
Ricardo Labiaga | 18019753 | 2009-12-05 16:08:40 -0500 | [diff] [blame] | 7248 | |
Donald Buczek | 0efb01b | 2019-07-07 21:26:08 +0200 | [diff] [blame] | 7249 | #ifdef CONFIG_NFS_V4_1 |
| 7250 | |
Ricardo Labiaga | 18019753 | 2009-12-05 16:08:40 -0500 | [diff] [blame] | 7251 | /* |
| 7252 | * Decode RECLAIM_COMPLETE response |
| 7253 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 7254 | static int nfs4_xdr_dec_reclaim_complete(struct rpc_rqst *rqstp, |
| 7255 | struct xdr_stream *xdr, |
Christoph Hellwig | fc01648 | 2017-05-08 15:09:02 +0200 | [diff] [blame] | 7256 | void *data) |
Ricardo Labiaga | 18019753 | 2009-12-05 16:08:40 -0500 | [diff] [blame] | 7257 | { |
Christoph Hellwig | fc01648 | 2017-05-08 15:09:02 +0200 | [diff] [blame] | 7258 | struct nfs41_reclaim_complete_res *res = data; |
Ricardo Labiaga | 18019753 | 2009-12-05 16:08:40 -0500 | [diff] [blame] | 7259 | struct compound_hdr hdr; |
| 7260 | int status; |
| 7261 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 7262 | status = decode_compound_hdr(xdr, &hdr); |
Ricardo Labiaga | 18019753 | 2009-12-05 16:08:40 -0500 | [diff] [blame] | 7263 | if (!status) |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 7264 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
Ricardo Labiaga | 18019753 | 2009-12-05 16:08:40 -0500 | [diff] [blame] | 7265 | if (!status) |
Himangi Saraogi | 8ee2b78 | 2014-06-27 00:09:09 +0530 | [diff] [blame] | 7266 | status = decode_reclaim_complete(xdr, NULL); |
Ricardo Labiaga | 18019753 | 2009-12-05 16:08:40 -0500 | [diff] [blame] | 7267 | return status; |
| 7268 | } |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 7269 | |
| 7270 | /* |
| 7271 | * Decode GETDEVINFO response |
| 7272 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 7273 | static int nfs4_xdr_dec_getdeviceinfo(struct rpc_rqst *rqstp, |
| 7274 | struct xdr_stream *xdr, |
Christoph Hellwig | fc01648 | 2017-05-08 15:09:02 +0200 | [diff] [blame] | 7275 | void *data) |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 7276 | { |
Christoph Hellwig | fc01648 | 2017-05-08 15:09:02 +0200 | [diff] [blame] | 7277 | struct nfs4_getdeviceinfo_res *res = data; |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 7278 | struct compound_hdr hdr; |
| 7279 | int status; |
| 7280 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 7281 | status = decode_compound_hdr(xdr, &hdr); |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 7282 | if (status != 0) |
| 7283 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 7284 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 7285 | if (status != 0) |
| 7286 | goto out; |
Trond Myklebust | 4e59080 | 2015-03-09 14:01:25 -0400 | [diff] [blame] | 7287 | status = decode_getdeviceinfo(xdr, res); |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 7288 | out: |
| 7289 | return status; |
| 7290 | } |
| 7291 | |
| 7292 | /* |
| 7293 | * Decode LAYOUTGET response |
| 7294 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 7295 | static int nfs4_xdr_dec_layoutget(struct rpc_rqst *rqstp, |
| 7296 | struct xdr_stream *xdr, |
Christoph Hellwig | fc01648 | 2017-05-08 15:09:02 +0200 | [diff] [blame] | 7297 | void *data) |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 7298 | { |
Christoph Hellwig | fc01648 | 2017-05-08 15:09:02 +0200 | [diff] [blame] | 7299 | struct nfs4_layoutget_res *res = data; |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 7300 | struct compound_hdr hdr; |
| 7301 | int status; |
| 7302 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 7303 | status = decode_compound_hdr(xdr, &hdr); |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 7304 | if (status) |
| 7305 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 7306 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 7307 | if (status) |
| 7308 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 7309 | status = decode_putfh(xdr); |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 7310 | if (status) |
| 7311 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 7312 | status = decode_layoutget(xdr, rqstp, res); |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 7313 | out: |
| 7314 | return status; |
| 7315 | } |
Andy Adamson | 863a3c6 | 2011-03-23 13:27:54 +0000 | [diff] [blame] | 7316 | |
| 7317 | /* |
Benny Halevy | cbe8260 | 2011-05-22 19:52:37 +0300 | [diff] [blame] | 7318 | * Decode LAYOUTRETURN response |
| 7319 | */ |
| 7320 | static int nfs4_xdr_dec_layoutreturn(struct rpc_rqst *rqstp, |
| 7321 | struct xdr_stream *xdr, |
Christoph Hellwig | fc01648 | 2017-05-08 15:09:02 +0200 | [diff] [blame] | 7322 | void *data) |
Benny Halevy | cbe8260 | 2011-05-22 19:52:37 +0300 | [diff] [blame] | 7323 | { |
Christoph Hellwig | fc01648 | 2017-05-08 15:09:02 +0200 | [diff] [blame] | 7324 | struct nfs4_layoutreturn_res *res = data; |
Benny Halevy | cbe8260 | 2011-05-22 19:52:37 +0300 | [diff] [blame] | 7325 | struct compound_hdr hdr; |
| 7326 | int status; |
| 7327 | |
| 7328 | status = decode_compound_hdr(xdr, &hdr); |
| 7329 | if (status) |
| 7330 | goto out; |
| 7331 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
| 7332 | if (status) |
| 7333 | goto out; |
| 7334 | status = decode_putfh(xdr); |
| 7335 | if (status) |
| 7336 | goto out; |
| 7337 | status = decode_layoutreturn(xdr, res); |
| 7338 | out: |
| 7339 | return status; |
| 7340 | } |
| 7341 | |
| 7342 | /* |
Andy Adamson | 863a3c6 | 2011-03-23 13:27:54 +0000 | [diff] [blame] | 7343 | * Decode LAYOUTCOMMIT response |
| 7344 | */ |
| 7345 | static int nfs4_xdr_dec_layoutcommit(struct rpc_rqst *rqstp, |
| 7346 | struct xdr_stream *xdr, |
Christoph Hellwig | fc01648 | 2017-05-08 15:09:02 +0200 | [diff] [blame] | 7347 | void *data) |
Andy Adamson | 863a3c6 | 2011-03-23 13:27:54 +0000 | [diff] [blame] | 7348 | { |
Christoph Hellwig | fc01648 | 2017-05-08 15:09:02 +0200 | [diff] [blame] | 7349 | struct nfs4_layoutcommit_res *res = data; |
Andy Adamson | 863a3c6 | 2011-03-23 13:27:54 +0000 | [diff] [blame] | 7350 | struct compound_hdr hdr; |
| 7351 | int status; |
| 7352 | |
| 7353 | status = decode_compound_hdr(xdr, &hdr); |
| 7354 | if (status) |
| 7355 | goto out; |
| 7356 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
| 7357 | if (status) |
| 7358 | goto out; |
| 7359 | status = decode_putfh(xdr); |
| 7360 | if (status) |
| 7361 | goto out; |
| 7362 | status = decode_layoutcommit(xdr, rqstp, res); |
| 7363 | if (status) |
| 7364 | goto out; |
Trond Myklebust | 6926afd1 | 2012-01-07 13:22:46 -0500 | [diff] [blame] | 7365 | decode_getfattr(xdr, res->fattr, res->server); |
Andy Adamson | 863a3c6 | 2011-03-23 13:27:54 +0000 | [diff] [blame] | 7366 | out: |
| 7367 | return status; |
| 7368 | } |
Bryan Schumaker | fca78d6 | 2011-06-02 14:59:07 -0400 | [diff] [blame] | 7369 | |
| 7370 | /* |
| 7371 | * Decode SECINFO_NO_NAME response |
| 7372 | */ |
| 7373 | static int nfs4_xdr_dec_secinfo_no_name(struct rpc_rqst *rqstp, |
| 7374 | struct xdr_stream *xdr, |
Christoph Hellwig | fc01648 | 2017-05-08 15:09:02 +0200 | [diff] [blame] | 7375 | void *data) |
Bryan Schumaker | fca78d6 | 2011-06-02 14:59:07 -0400 | [diff] [blame] | 7376 | { |
Christoph Hellwig | fc01648 | 2017-05-08 15:09:02 +0200 | [diff] [blame] | 7377 | struct nfs4_secinfo_res *res = data; |
Bryan Schumaker | fca78d6 | 2011-06-02 14:59:07 -0400 | [diff] [blame] | 7378 | struct compound_hdr hdr; |
| 7379 | int status; |
| 7380 | |
| 7381 | status = decode_compound_hdr(xdr, &hdr); |
| 7382 | if (status) |
| 7383 | goto out; |
| 7384 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
| 7385 | if (status) |
| 7386 | goto out; |
| 7387 | status = decode_putrootfh(xdr); |
| 7388 | if (status) |
| 7389 | goto out; |
Bryan Schumaker | 31e4dda | 2012-04-27 13:27:38 -0400 | [diff] [blame] | 7390 | status = decode_secinfo_no_name(xdr, res); |
Bryan Schumaker | fca78d6 | 2011-06-02 14:59:07 -0400 | [diff] [blame] | 7391 | out: |
| 7392 | return status; |
| 7393 | } |
Bryan Schumaker | 7d97479 | 2011-06-02 14:59:08 -0400 | [diff] [blame] | 7394 | |
| 7395 | /* |
| 7396 | * Decode TEST_STATEID response |
| 7397 | */ |
| 7398 | static int nfs4_xdr_dec_test_stateid(struct rpc_rqst *rqstp, |
| 7399 | struct xdr_stream *xdr, |
Christoph Hellwig | fc01648 | 2017-05-08 15:09:02 +0200 | [diff] [blame] | 7400 | void *data) |
Bryan Schumaker | 7d97479 | 2011-06-02 14:59:08 -0400 | [diff] [blame] | 7401 | { |
Christoph Hellwig | fc01648 | 2017-05-08 15:09:02 +0200 | [diff] [blame] | 7402 | struct nfs41_test_stateid_res *res = data; |
Bryan Schumaker | 7d97479 | 2011-06-02 14:59:08 -0400 | [diff] [blame] | 7403 | struct compound_hdr hdr; |
| 7404 | int status; |
| 7405 | |
| 7406 | status = decode_compound_hdr(xdr, &hdr); |
| 7407 | if (status) |
| 7408 | goto out; |
| 7409 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
| 7410 | if (status) |
| 7411 | goto out; |
| 7412 | status = decode_test_stateid(xdr, res); |
| 7413 | out: |
| 7414 | return status; |
| 7415 | } |
Bryan Schumaker | 9aeda35 | 2011-06-02 14:59:09 -0400 | [diff] [blame] | 7416 | |
| 7417 | /* |
| 7418 | * Decode FREE_STATEID response |
| 7419 | */ |
| 7420 | static int nfs4_xdr_dec_free_stateid(struct rpc_rqst *rqstp, |
| 7421 | struct xdr_stream *xdr, |
Christoph Hellwig | fc01648 | 2017-05-08 15:09:02 +0200 | [diff] [blame] | 7422 | void *data) |
Bryan Schumaker | 9aeda35 | 2011-06-02 14:59:09 -0400 | [diff] [blame] | 7423 | { |
Christoph Hellwig | fc01648 | 2017-05-08 15:09:02 +0200 | [diff] [blame] | 7424 | struct nfs41_free_stateid_res *res = data; |
Bryan Schumaker | 9aeda35 | 2011-06-02 14:59:09 -0400 | [diff] [blame] | 7425 | struct compound_hdr hdr; |
| 7426 | int status; |
| 7427 | |
| 7428 | status = decode_compound_hdr(xdr, &hdr); |
| 7429 | if (status) |
| 7430 | goto out; |
| 7431 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
| 7432 | if (status) |
| 7433 | goto out; |
| 7434 | status = decode_free_stateid(xdr, res); |
| 7435 | out: |
| 7436 | return status; |
| 7437 | } |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 7438 | #endif /* CONFIG_NFS_V4_1 */ |
| 7439 | |
Chuck Lever | 573c4e1 | 2010-12-14 14:58:11 +0000 | [diff] [blame] | 7440 | /** |
| 7441 | * nfs4_decode_dirent - Decode a single NFSv4 directory entry stored in |
| 7442 | * the local page cache. |
| 7443 | * @xdr: XDR stream where entry resides |
| 7444 | * @entry: buffer to fill in with entry data |
| 7445 | * @plus: boolean indicating whether this should be a readdirplus entry |
| 7446 | * |
| 7447 | * Returns zero if successful, otherwise a negative errno value is |
| 7448 | * returned. |
| 7449 | * |
| 7450 | * This function is not invoked during READDIR reply decoding, but |
| 7451 | * rather whenever an application invokes the getdents(2) system call |
| 7452 | * on a directory already in our cache. |
| 7453 | */ |
| 7454 | int nfs4_decode_dirent(struct xdr_stream *xdr, struct nfs_entry *entry, |
Benjamin Coddington | a7a3b1e | 2017-06-20 08:33:44 -0400 | [diff] [blame] | 7455 | bool plus) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7456 | { |
Trond Myklebust | 256e48b | 2012-06-21 11:18:13 -0400 | [diff] [blame] | 7457 | unsigned int savep; |
Fred Isaman | dae100c | 2011-07-30 20:52:37 -0400 | [diff] [blame] | 7458 | uint32_t bitmap[3] = {0}; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7459 | uint32_t len; |
Frank Sorenson | 98de9ce | 2018-04-02 16:12:45 -0500 | [diff] [blame] | 7460 | uint64_t new_cookie; |
Bryan Schumaker | babddc7 | 2010-10-20 15:44:29 -0400 | [diff] [blame] | 7461 | __be32 *p = xdr_inline_decode(xdr, 4); |
| 7462 | if (unlikely(!p)) |
Chuck Lever | eb72f48 | 2019-02-11 11:24:21 -0500 | [diff] [blame] | 7463 | return -EAGAIN; |
Chuck Lever | c08e76d | 2011-01-28 12:40:55 -0500 | [diff] [blame] | 7464 | if (*p == xdr_zero) { |
Bryan Schumaker | babddc7 | 2010-10-20 15:44:29 -0400 | [diff] [blame] | 7465 | p = xdr_inline_decode(xdr, 4); |
| 7466 | if (unlikely(!p)) |
Chuck Lever | eb72f48 | 2019-02-11 11:24:21 -0500 | [diff] [blame] | 7467 | return -EAGAIN; |
Chuck Lever | c08e76d | 2011-01-28 12:40:55 -0500 | [diff] [blame] | 7468 | if (*p == xdr_zero) |
Chuck Lever | 573c4e1 | 2010-12-14 14:58:11 +0000 | [diff] [blame] | 7469 | return -EAGAIN; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7470 | entry->eof = 1; |
Chuck Lever | 573c4e1 | 2010-12-14 14:58:11 +0000 | [diff] [blame] | 7471 | return -EBADCOOKIE; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7472 | } |
| 7473 | |
Bryan Schumaker | babddc7 | 2010-10-20 15:44:29 -0400 | [diff] [blame] | 7474 | p = xdr_inline_decode(xdr, 12); |
| 7475 | if (unlikely(!p)) |
Chuck Lever | eb72f48 | 2019-02-11 11:24:21 -0500 | [diff] [blame] | 7476 | return -EAGAIN; |
Frank Sorenson | 98de9ce | 2018-04-02 16:12:45 -0500 | [diff] [blame] | 7477 | p = xdr_decode_hyper(p, &new_cookie); |
Chuck Lever | c08e76d | 2011-01-28 12:40:55 -0500 | [diff] [blame] | 7478 | entry->len = be32_to_cpup(p); |
Bryan Schumaker | babddc7 | 2010-10-20 15:44:29 -0400 | [diff] [blame] | 7479 | |
Trond Myklebust | 9af8c22 | 2010-10-24 11:52:55 -0400 | [diff] [blame] | 7480 | p = xdr_inline_decode(xdr, entry->len); |
Bryan Schumaker | babddc7 | 2010-10-20 15:44:29 -0400 | [diff] [blame] | 7481 | if (unlikely(!p)) |
Chuck Lever | eb72f48 | 2019-02-11 11:24:21 -0500 | [diff] [blame] | 7482 | return -EAGAIN; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7483 | entry->name = (const char *) p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7484 | |
| 7485 | /* |
| 7486 | * In case the server doesn't return an inode number, |
| 7487 | * we fake one here. (We don't use inode number 0, |
| 7488 | * since glibc seems to choke on it...) |
| 7489 | */ |
| 7490 | entry->ino = 1; |
Trond Myklebust | 4f08222 | 2010-10-24 13:14:02 -0400 | [diff] [blame] | 7491 | entry->fattr->valid = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7492 | |
Trond Myklebust | 9af8c22 | 2010-10-24 11:52:55 -0400 | [diff] [blame] | 7493 | if (decode_attr_bitmap(xdr, bitmap) < 0) |
Chuck Lever | eb72f48 | 2019-02-11 11:24:21 -0500 | [diff] [blame] | 7494 | return -EAGAIN; |
Trond Myklebust | 9af8c22 | 2010-10-24 11:52:55 -0400 | [diff] [blame] | 7495 | |
Trond Myklebust | 256e48b | 2012-06-21 11:18:13 -0400 | [diff] [blame] | 7496 | if (decode_attr_length(xdr, &len, &savep) < 0) |
Chuck Lever | eb72f48 | 2019-02-11 11:24:21 -0500 | [diff] [blame] | 7497 | return -EAGAIN; |
Trond Myklebust | 9af8c22 | 2010-10-24 11:52:55 -0400 | [diff] [blame] | 7498 | |
Chuck Lever | 573c4e1 | 2010-12-14 14:58:11 +0000 | [diff] [blame] | 7499 | if (decode_getfattr_attrs(xdr, bitmap, entry->fattr, entry->fh, |
Anna Schumaker | 1e2f67d | 2021-10-22 13:11:13 -0400 | [diff] [blame] | 7500 | NULL, entry->server) < 0) |
Chuck Lever | eb72f48 | 2019-02-11 11:24:21 -0500 | [diff] [blame] | 7501 | return -EAGAIN; |
Trond Myklebust | 28331a4 | 2011-04-27 13:47:52 -0400 | [diff] [blame] | 7502 | if (entry->fattr->valid & NFS_ATTR_FATTR_MOUNTED_ON_FILEID) |
| 7503 | entry->ino = entry->fattr->mounted_on_fileid; |
| 7504 | else if (entry->fattr->valid & NFS_ATTR_FATTR_FILEID) |
Trond Myklebust | 9af8c22 | 2010-10-24 11:52:55 -0400 | [diff] [blame] | 7505 | entry->ino = entry->fattr->fileid; |
| 7506 | |
Trond Myklebust | 0b26a0b | 2010-11-20 14:26:44 -0500 | [diff] [blame] | 7507 | entry->d_type = DT_UNKNOWN; |
| 7508 | if (entry->fattr->valid & NFS_ATTR_FATTR_TYPE) |
| 7509 | entry->d_type = nfs_umode_to_dtype(entry->fattr->mode); |
| 7510 | |
Frank Sorenson | 98de9ce | 2018-04-02 16:12:45 -0500 | [diff] [blame] | 7511 | entry->prev_cookie = entry->cookie; |
| 7512 | entry->cookie = new_cookie; |
| 7513 | |
Chuck Lever | 573c4e1 | 2010-12-14 14:58:11 +0000 | [diff] [blame] | 7514 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7515 | } |
| 7516 | |
| 7517 | /* |
| 7518 | * We need to translate between nfs status return values and |
| 7519 | * the local errno values which may not be the same. |
| 7520 | */ |
| 7521 | static struct { |
| 7522 | int stat; |
| 7523 | int errno; |
| 7524 | } nfs_errtbl[] = { |
| 7525 | { NFS4_OK, 0 }, |
Benny Halevy | 856dff3 | 2008-03-31 17:39:06 +0300 | [diff] [blame] | 7526 | { NFS4ERR_PERM, -EPERM }, |
| 7527 | { NFS4ERR_NOENT, -ENOENT }, |
| 7528 | { NFS4ERR_IO, -errno_NFSERR_IO}, |
| 7529 | { NFS4ERR_NXIO, -ENXIO }, |
| 7530 | { NFS4ERR_ACCESS, -EACCES }, |
| 7531 | { NFS4ERR_EXIST, -EEXIST }, |
| 7532 | { NFS4ERR_XDEV, -EXDEV }, |
| 7533 | { NFS4ERR_NOTDIR, -ENOTDIR }, |
| 7534 | { NFS4ERR_ISDIR, -EISDIR }, |
| 7535 | { NFS4ERR_INVAL, -EINVAL }, |
| 7536 | { NFS4ERR_FBIG, -EFBIG }, |
| 7537 | { NFS4ERR_NOSPC, -ENOSPC }, |
| 7538 | { NFS4ERR_ROFS, -EROFS }, |
| 7539 | { NFS4ERR_MLINK, -EMLINK }, |
| 7540 | { NFS4ERR_NAMETOOLONG, -ENAMETOOLONG }, |
| 7541 | { NFS4ERR_NOTEMPTY, -ENOTEMPTY }, |
| 7542 | { NFS4ERR_DQUOT, -EDQUOT }, |
| 7543 | { NFS4ERR_STALE, -ESTALE }, |
| 7544 | { NFS4ERR_BADHANDLE, -EBADHANDLE }, |
Benny Halevy | 856dff3 | 2008-03-31 17:39:06 +0300 | [diff] [blame] | 7545 | { NFS4ERR_BAD_COOKIE, -EBADCOOKIE }, |
| 7546 | { NFS4ERR_NOTSUPP, -ENOTSUPP }, |
| 7547 | { NFS4ERR_TOOSMALL, -ETOOSMALL }, |
Trond Myklebust | fdcb457 | 2010-02-08 09:32:40 -0500 | [diff] [blame] | 7548 | { NFS4ERR_SERVERFAULT, -EREMOTEIO }, |
Benny Halevy | 856dff3 | 2008-03-31 17:39:06 +0300 | [diff] [blame] | 7549 | { NFS4ERR_BADTYPE, -EBADTYPE }, |
| 7550 | { NFS4ERR_LOCKED, -EAGAIN }, |
Benny Halevy | 856dff3 | 2008-03-31 17:39:06 +0300 | [diff] [blame] | 7551 | { NFS4ERR_SYMLINK, -ELOOP }, |
| 7552 | { NFS4ERR_OP_ILLEGAL, -EOPNOTSUPP }, |
| 7553 | { NFS4ERR_DEADLOCK, -EDEADLK }, |
Frank van der Linden | 3e1f021 | 2020-06-23 22:38:56 +0000 | [diff] [blame] | 7554 | { NFS4ERR_NOXATTR, -ENODATA }, |
| 7555 | { NFS4ERR_XATTR2BIG, -E2BIG }, |
Benny Halevy | 856dff3 | 2008-03-31 17:39:06 +0300 | [diff] [blame] | 7556 | { -1, -EIO } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7557 | }; |
| 7558 | |
| 7559 | /* |
| 7560 | * Convert an NFS error code to a local one. |
| 7561 | * This one is used jointly by NFSv2 and NFSv3. |
| 7562 | */ |
| 7563 | static int |
David Howells | 0a8ea43 | 2006-08-22 20:06:08 -0400 | [diff] [blame] | 7564 | nfs4_stat_to_errno(int stat) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7565 | { |
| 7566 | int i; |
| 7567 | for (i = 0; nfs_errtbl[i].stat != -1; i++) { |
| 7568 | if (nfs_errtbl[i].stat == stat) |
| 7569 | return nfs_errtbl[i].errno; |
| 7570 | } |
| 7571 | if (stat <= 10000 || stat > 10100) { |
| 7572 | /* The server is looney tunes. */ |
Trond Myklebust | fdcb457 | 2010-02-08 09:32:40 -0500 | [diff] [blame] | 7573 | return -EREMOTEIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7574 | } |
| 7575 | /* If we cannot translate the error, the recovery routines should |
| 7576 | * handle it. |
| 7577 | * Note: remaining NFSv4 error codes have values > 10000, so should |
| 7578 | * not conflict with native Linux error codes. |
| 7579 | */ |
Benny Halevy | 856dff3 | 2008-03-31 17:39:06 +0300 | [diff] [blame] | 7580 | return -stat; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7581 | } |
| 7582 | |
Anna Schumaker | 1c6dcbe | 2014-09-26 13:58:48 -0400 | [diff] [blame] | 7583 | #ifdef CONFIG_NFS_V4_2 |
| 7584 | #include "nfs42xdr.c" |
| 7585 | #endif /* CONFIG_NFS_V4_2 */ |
| 7586 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7587 | #define PROC(proc, argtype, restype) \ |
| 7588 | [NFSPROC4_CLNT_##proc] = { \ |
| 7589 | .p_proc = NFSPROC4_COMPOUND, \ |
Christoph Hellwig | fcc8581 | 2017-05-08 10:01:49 +0200 | [diff] [blame] | 7590 | .p_encode = nfs4_xdr_##argtype, \ |
Christoph Hellwig | fc01648 | 2017-05-08 15:09:02 +0200 | [diff] [blame] | 7591 | .p_decode = nfs4_xdr_##restype, \ |
Chuck Lever | 2bea90d | 2007-03-29 16:47:53 -0400 | [diff] [blame] | 7592 | .p_arglen = NFS4_##argtype##_sz, \ |
| 7593 | .p_replen = NFS4_##restype##_sz, \ |
Chuck Lever | cc0175c | 2006-03-20 13:44:22 -0500 | [diff] [blame] | 7594 | .p_statidx = NFSPROC4_CLNT_##proc, \ |
| 7595 | .p_name = #proc, \ |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 7596 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7597 | |
Anna Schumaker | 7c61f0d | 2015-04-14 10:34:20 -0400 | [diff] [blame] | 7598 | #define STUB(proc) \ |
| 7599 | [NFSPROC4_CLNT_##proc] = { \ |
| 7600 | .p_name = #proc, \ |
| 7601 | } |
| 7602 | |
Trond Myklebust | 8634ef5 | 2018-01-06 09:53:49 -0500 | [diff] [blame] | 7603 | #if defined(CONFIG_NFS_V4_1) |
| 7604 | #define PROC41(proc, argtype, restype) \ |
| 7605 | PROC(proc, argtype, restype) |
| 7606 | #else |
| 7607 | #define PROC41(proc, argtype, restype) \ |
| 7608 | STUB(proc) |
| 7609 | #endif |
| 7610 | |
| 7611 | #if defined(CONFIG_NFS_V4_2) |
| 7612 | #define PROC42(proc, argtype, restype) \ |
| 7613 | PROC(proc, argtype, restype) |
| 7614 | #else |
| 7615 | #define PROC42(proc, argtype, restype) \ |
| 7616 | STUB(proc) |
| 7617 | #endif |
| 7618 | |
Christoph Hellwig | 511e936 | 2017-05-12 15:36:49 +0200 | [diff] [blame] | 7619 | const struct rpc_procinfo nfs4_procedures[] = { |
Chuck Lever | 7d93bd71 | 2010-12-14 14:57:42 +0000 | [diff] [blame] | 7620 | PROC(READ, enc_read, dec_read), |
| 7621 | PROC(WRITE, enc_write, dec_write), |
| 7622 | PROC(COMMIT, enc_commit, dec_commit), |
| 7623 | PROC(OPEN, enc_open, dec_open), |
| 7624 | PROC(OPEN_CONFIRM, enc_open_confirm, dec_open_confirm), |
| 7625 | PROC(OPEN_NOATTR, enc_open_noattr, dec_open_noattr), |
| 7626 | PROC(OPEN_DOWNGRADE, enc_open_downgrade, dec_open_downgrade), |
| 7627 | PROC(CLOSE, enc_close, dec_close), |
| 7628 | PROC(SETATTR, enc_setattr, dec_setattr), |
| 7629 | PROC(FSINFO, enc_fsinfo, dec_fsinfo), |
| 7630 | PROC(RENEW, enc_renew, dec_renew), |
| 7631 | PROC(SETCLIENTID, enc_setclientid, dec_setclientid), |
| 7632 | PROC(SETCLIENTID_CONFIRM, enc_setclientid_confirm, dec_setclientid_confirm), |
| 7633 | PROC(LOCK, enc_lock, dec_lock), |
| 7634 | PROC(LOCKT, enc_lockt, dec_lockt), |
| 7635 | PROC(LOCKU, enc_locku, dec_locku), |
| 7636 | PROC(ACCESS, enc_access, dec_access), |
| 7637 | PROC(GETATTR, enc_getattr, dec_getattr), |
| 7638 | PROC(LOOKUP, enc_lookup, dec_lookup), |
| 7639 | PROC(LOOKUP_ROOT, enc_lookup_root, dec_lookup_root), |
| 7640 | PROC(REMOVE, enc_remove, dec_remove), |
| 7641 | PROC(RENAME, enc_rename, dec_rename), |
| 7642 | PROC(LINK, enc_link, dec_link), |
| 7643 | PROC(SYMLINK, enc_symlink, dec_symlink), |
| 7644 | PROC(CREATE, enc_create, dec_create), |
| 7645 | PROC(PATHCONF, enc_pathconf, dec_pathconf), |
| 7646 | PROC(STATFS, enc_statfs, dec_statfs), |
| 7647 | PROC(READLINK, enc_readlink, dec_readlink), |
| 7648 | PROC(READDIR, enc_readdir, dec_readdir), |
| 7649 | PROC(SERVER_CAPS, enc_server_caps, dec_server_caps), |
| 7650 | PROC(DELEGRETURN, enc_delegreturn, dec_delegreturn), |
| 7651 | PROC(GETACL, enc_getacl, dec_getacl), |
| 7652 | PROC(SETACL, enc_setacl, dec_setacl), |
| 7653 | PROC(FS_LOCATIONS, enc_fs_locations, dec_fs_locations), |
| 7654 | PROC(RELEASE_LOCKOWNER, enc_release_lockowner, dec_release_lockowner), |
Bryan Schumaker | 5a5ea0d | 2011-03-24 17:12:29 +0000 | [diff] [blame] | 7655 | PROC(SECINFO, enc_secinfo, dec_secinfo), |
Chuck Lever | 44c9993 | 2013-10-17 14:13:30 -0400 | [diff] [blame] | 7656 | PROC(FSID_PRESENT, enc_fsid_present, dec_fsid_present), |
Trond Myklebust | 8634ef5 | 2018-01-06 09:53:49 -0500 | [diff] [blame] | 7657 | PROC41(EXCHANGE_ID, enc_exchange_id, dec_exchange_id), |
| 7658 | PROC41(CREATE_SESSION, enc_create_session, dec_create_session), |
| 7659 | PROC41(DESTROY_SESSION, enc_destroy_session, dec_destroy_session), |
| 7660 | PROC41(SEQUENCE, enc_sequence, dec_sequence), |
Donald Buczek | 0efb01b | 2019-07-07 21:26:08 +0200 | [diff] [blame] | 7661 | PROC(GET_LEASE_TIME, enc_get_lease_time, dec_get_lease_time), |
Trond Myklebust | 8634ef5 | 2018-01-06 09:53:49 -0500 | [diff] [blame] | 7662 | PROC41(RECLAIM_COMPLETE,enc_reclaim_complete, dec_reclaim_complete), |
| 7663 | PROC41(GETDEVICEINFO, enc_getdeviceinfo, dec_getdeviceinfo), |
| 7664 | PROC41(LAYOUTGET, enc_layoutget, dec_layoutget), |
| 7665 | PROC41(LAYOUTCOMMIT, enc_layoutcommit, dec_layoutcommit), |
| 7666 | PROC41(LAYOUTRETURN, enc_layoutreturn, dec_layoutreturn), |
| 7667 | PROC41(SECINFO_NO_NAME, enc_secinfo_no_name, dec_secinfo_no_name), |
| 7668 | PROC41(TEST_STATEID, enc_test_stateid, dec_test_stateid), |
| 7669 | PROC41(FREE_STATEID, enc_free_stateid, dec_free_stateid), |
Anna Schumaker | 7c61f0d | 2015-04-14 10:34:20 -0400 | [diff] [blame] | 7670 | STUB(GETDEVICELIST), |
Trond Myklebust | 8634ef5 | 2018-01-06 09:53:49 -0500 | [diff] [blame] | 7671 | PROC41(BIND_CONN_TO_SESSION, |
Trond Myklebust | ad24ecf | 2012-05-25 17:11:42 -0400 | [diff] [blame] | 7672 | enc_bind_conn_to_session, dec_bind_conn_to_session), |
Trond Myklebust | 8634ef5 | 2018-01-06 09:53:49 -0500 | [diff] [blame] | 7673 | PROC41(DESTROY_CLIENTID,enc_destroy_clientid, dec_destroy_clientid), |
| 7674 | PROC42(SEEK, enc_seek, dec_seek), |
| 7675 | PROC42(ALLOCATE, enc_allocate, dec_allocate), |
| 7676 | PROC42(DEALLOCATE, enc_deallocate, dec_deallocate), |
| 7677 | PROC42(LAYOUTSTATS, enc_layoutstats, dec_layoutstats), |
| 7678 | PROC42(CLONE, enc_clone, dec_clone), |
| 7679 | PROC42(COPY, enc_copy, dec_copy), |
Olga Kornievskaia | cb95dee | 2018-07-09 15:13:29 -0400 | [diff] [blame] | 7680 | PROC42(OFFLOAD_CANCEL, enc_offload_cancel, dec_offload_cancel), |
Olga Kornievskaia | 0491567 | 2019-06-04 16:14:30 -0400 | [diff] [blame] | 7681 | PROC42(COPY_NOTIFY, enc_copy_notify, dec_copy_notify), |
Trond Myklebust | 8634ef5 | 2018-01-06 09:53:49 -0500 | [diff] [blame] | 7682 | PROC(LOOKUPP, enc_lookupp, dec_lookupp), |
Trond Myklebust | 3eb8609 | 2019-02-08 10:31:05 -0500 | [diff] [blame] | 7683 | PROC42(LAYOUTERROR, enc_layouterror, dec_layouterror), |
Frank van der Linden | 3e1f021 | 2020-06-23 22:38:56 +0000 | [diff] [blame] | 7684 | PROC42(GETXATTR, enc_getxattr, dec_getxattr), |
| 7685 | PROC42(SETXATTR, enc_setxattr, dec_setxattr), |
| 7686 | PROC42(LISTXATTRS, enc_listxattrs, dec_listxattrs), |
| 7687 | PROC42(REMOVEXATTR, enc_removexattr, dec_removexattr), |
Anna Schumaker | c567552 | 2014-05-28 13:41:22 -0400 | [diff] [blame] | 7688 | PROC42(READ_PLUS, enc_read_plus, dec_read_plus), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7689 | }; |
| 7690 | |
Christoph Hellwig | c551858 | 2017-05-08 23:27:10 +0200 | [diff] [blame] | 7691 | static unsigned int nfs_version4_counts[ARRAY_SIZE(nfs4_procedures)]; |
Trond Myklebust | a613fa1 | 2012-01-20 13:53:56 -0500 | [diff] [blame] | 7692 | const struct rpc_version nfs_version4 = { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7693 | .number = 4, |
Tobias Klauser | e8c96f8 | 2006-03-24 03:15:34 -0800 | [diff] [blame] | 7694 | .nrprocs = ARRAY_SIZE(nfs4_procedures), |
Christoph Hellwig | c551858 | 2017-05-08 23:27:10 +0200 | [diff] [blame] | 7695 | .procs = nfs4_procedures, |
| 7696 | .counts = nfs_version4_counts, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7697 | }; |