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> |
Andreas Gruenbacher | dff25dd | 2016-12-02 22:53:30 -0500 | [diff] [blame] | 55 | #include <linux/fs_struct.h> |
Chuck Lever | f092075 | 2012-05-21 22:45:41 -0400 | [diff] [blame] | 56 | |
Trond Myklebust | 4ce7971 | 2005-06-22 17:16:21 +0000 | [diff] [blame] | 57 | #include "nfs4_fs.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 | |
David Howells | 0a8ea43 | 2006-08-22 20:06:08 -0400 | [diff] [blame] | 69 | static int nfs4_stat_to_errno(int); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 70 | |
| 71 | /* NFSv4 COMPOUND tags are only wanted for debugging purposes */ |
| 72 | #ifdef DEBUG |
| 73 | #define NFS4_MAXTAGLEN 20 |
| 74 | #else |
| 75 | #define NFS4_MAXTAGLEN 0 |
| 76 | #endif |
| 77 | |
Andy Adamson | 6c0195a | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 78 | /* lock,open owner id: |
Trond Myklebust | 9f958ab | 2007-07-02 13:58:33 -0400 | [diff] [blame] | 79 | * we currently use size 2 (u64) out of (NFS4_OPAQUE_LIMIT >> 2) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 80 | */ |
Trond Myklebust | 95b72eb | 2012-04-20 19:24:51 -0400 | [diff] [blame] | 81 | #define open_owner_id_maxsz (1 + 2 + 1 + 1 + 2) |
Trond Myklebust | d035c36 | 2010-12-21 10:45:27 -0500 | [diff] [blame] | 82 | #define lock_owner_id_maxsz (1 + 1 + 4) |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 83 | #define decode_lockowner_maxsz (1 + XDR_QUADLEN(IDMAP_NAMESZ)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 84 | #define compound_encode_hdr_maxsz (3 + (NFS4_MAXTAGLEN >> 2)) |
| 85 | #define compound_decode_hdr_maxsz (3 + (NFS4_MAXTAGLEN >> 2)) |
| 86 | #define op_encode_hdr_maxsz (1) |
| 87 | #define op_decode_hdr_maxsz (2) |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 88 | #define encode_stateid_maxsz (XDR_QUADLEN(NFS4_STATEID_SIZE)) |
| 89 | #define decode_stateid_maxsz (XDR_QUADLEN(NFS4_STATEID_SIZE)) |
| 90 | #define encode_verifier_maxsz (XDR_QUADLEN(NFS4_VERIFIER_SIZE)) |
| 91 | #define decode_verifier_maxsz (XDR_QUADLEN(NFS4_VERIFIER_SIZE)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 92 | #define encode_putfh_maxsz (op_encode_hdr_maxsz + 1 + \ |
| 93 | (NFS4_FHSIZE >> 2)) |
| 94 | #define decode_putfh_maxsz (op_decode_hdr_maxsz) |
| 95 | #define encode_putrootfh_maxsz (op_encode_hdr_maxsz) |
| 96 | #define decode_putrootfh_maxsz (op_decode_hdr_maxsz) |
| 97 | #define encode_getfh_maxsz (op_encode_hdr_maxsz) |
| 98 | #define decode_getfh_maxsz (op_decode_hdr_maxsz + 1 + \ |
| 99 | ((3+NFS4_FHSIZE) >> 2)) |
Andy Adamson | e5012d1 | 2011-07-11 17:17:42 -0400 | [diff] [blame] | 100 | #define nfs4_fattr_bitmap_maxsz 4 |
J. Bruce Fields | 9692820 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 101 | #define encode_getattr_maxsz (op_encode_hdr_maxsz + nfs4_fattr_bitmap_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 102 | #define nfs4_name_maxsz (1 + ((3 + NFS4_MAXNAMLEN) >> 2)) |
| 103 | #define nfs4_path_maxsz (1 + ((3 + NFS4_MAXPATHLEN) >> 2)) |
Trond Myklebust | bd625ba | 2007-07-08 18:38:23 -0400 | [diff] [blame] | 104 | #define nfs4_owner_maxsz (1 + XDR_QUADLEN(IDMAP_NAMESZ)) |
| 105 | #define nfs4_group_maxsz (1 + XDR_QUADLEN(IDMAP_NAMESZ)) |
David Quigley | aa9c266 | 2013-05-22 12:50:44 -0400 | [diff] [blame] | 106 | #ifdef CONFIG_NFS_V4_SECURITY_LABEL |
| 107 | /* PI(4 bytes) + LFS(4 bytes) + 1(for null terminator?) + MAXLABELLEN */ |
| 108 | #define nfs4_label_maxsz (4 + 4 + 1 + XDR_QUADLEN(NFS4_MAXLABELLEN)) |
David Quigley | aa9c266 | 2013-05-22 12:50:44 -0400 | [diff] [blame] | 109 | #else |
| 110 | #define nfs4_label_maxsz 0 |
David Quigley | aa9c266 | 2013-05-22 12:50:44 -0400 | [diff] [blame] | 111 | #endif |
Andy Adamson | 88034c3 | 2012-05-23 05:02:34 -0400 | [diff] [blame] | 112 | /* We support only one layout type per file system */ |
| 113 | #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] | 114 | /* This is based on getfattr, which uses the most attributes: */ |
| 115 | #define nfs4_fattr_value_maxsz (1 + (1 + 2 + 2 + 4 + 2 + 1 + 1 + 2 + 2 + \ |
Andy Adamson | 88034c3 | 2012-05-23 05:02:34 -0400 | [diff] [blame] | 116 | 3 + 3 + 3 + nfs4_owner_maxsz + \ |
David Quigley | aa9c266 | 2013-05-22 12:50:44 -0400 | [diff] [blame] | 117 | nfs4_group_maxsz + nfs4_label_maxsz + \ |
| 118 | decode_mdsthreshold_maxsz)) |
J. Bruce Fields | 9692820 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 119 | #define nfs4_fattr_maxsz (nfs4_fattr_bitmap_maxsz + \ |
| 120 | nfs4_fattr_value_maxsz) |
| 121 | #define decode_getattr_maxsz (op_decode_hdr_maxsz + nfs4_fattr_maxsz) |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 122 | #define encode_attrs_maxsz (nfs4_fattr_bitmap_maxsz + \ |
| 123 | 1 + 2 + 1 + \ |
| 124 | nfs4_owner_maxsz + \ |
| 125 | nfs4_group_maxsz + \ |
David Quigley | aa9c266 | 2013-05-22 12:50:44 -0400 | [diff] [blame] | 126 | nfs4_label_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 127 | 4 + 4) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 128 | #define encode_savefh_maxsz (op_encode_hdr_maxsz) |
| 129 | #define decode_savefh_maxsz (op_decode_hdr_maxsz) |
Trond Myklebust | 56ae19f | 2005-10-27 22:12:40 -0400 | [diff] [blame] | 130 | #define encode_restorefh_maxsz (op_encode_hdr_maxsz) |
| 131 | #define decode_restorefh_maxsz (op_decode_hdr_maxsz) |
Fred Isaman | 2f42b5d | 2008-03-13 15:26:30 +0200 | [diff] [blame] | 132 | #define encode_fsinfo_maxsz (encode_getattr_maxsz) |
Fred Isaman | dae100c | 2011-07-30 20:52:37 -0400 | [diff] [blame] | 133 | /* The 5 accounts for the PNFS attributes, and assumes that at most three |
| 134 | * layout types will be returned. |
| 135 | */ |
| 136 | #define decode_fsinfo_maxsz (op_decode_hdr_maxsz + \ |
| 137 | nfs4_fattr_bitmap_maxsz + 4 + 8 + 5) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 138 | #define encode_renew_maxsz (op_encode_hdr_maxsz + 3) |
| 139 | #define decode_renew_maxsz (op_decode_hdr_maxsz) |
| 140 | #define encode_setclientid_maxsz \ |
| 141 | (op_encode_hdr_maxsz + \ |
Chuck Lever | cc38bac | 2007-12-10 14:56:54 -0500 | [diff] [blame] | 142 | XDR_QUADLEN(NFS4_VERIFIER_SIZE) + \ |
Jeff Layton | b8fb2f5 | 2015-06-09 19:43:58 -0400 | [diff] [blame] | 143 | /* client name */ \ |
| 144 | 1 + XDR_QUADLEN(NFS4_OPAQUE_LIMIT) + \ |
Chuck Lever | cc38bac | 2007-12-10 14:56:54 -0500 | [diff] [blame] | 145 | 1 /* sc_prog */ + \ |
Chuck Lever | 6dd3436 | 2014-11-08 20:15:18 -0500 | [diff] [blame] | 146 | 1 + XDR_QUADLEN(RPCBIND_MAXNETIDLEN) + \ |
| 147 | 1 + XDR_QUADLEN(RPCBIND_MAXUADDRLEN) + \ |
Chuck Lever | cc38bac | 2007-12-10 14:56:54 -0500 | [diff] [blame] | 148 | 1) /* sc_cb_ident */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 149 | #define decode_setclientid_maxsz \ |
| 150 | (op_decode_hdr_maxsz + \ |
Chuck Lever | 6dd3436 | 2014-11-08 20:15:18 -0500 | [diff] [blame] | 151 | 2 /* clientid */ + \ |
| 152 | XDR_QUADLEN(NFS4_VERIFIER_SIZE) + \ |
| 153 | 1 + XDR_QUADLEN(RPCBIND_MAXNETIDLEN) + \ |
| 154 | 1 + XDR_QUADLEN(RPCBIND_MAXUADDRLEN)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 155 | #define encode_setclientid_confirm_maxsz \ |
| 156 | (op_encode_hdr_maxsz + \ |
| 157 | 3 + (NFS4_VERIFIER_SIZE >> 2)) |
| 158 | #define decode_setclientid_confirm_maxsz \ |
| 159 | (op_decode_hdr_maxsz) |
Trond Myklebust | e688962 | 2007-07-02 13:58:30 -0400 | [diff] [blame] | 160 | #define encode_lookup_maxsz (op_encode_hdr_maxsz + nfs4_name_maxsz) |
| 161 | #define decode_lookup_maxsz (op_decode_hdr_maxsz) |
Jeff Layton | 5b5faaf | 2017-06-29 06:34:52 -0700 | [diff] [blame] | 162 | #define encode_lookupp_maxsz (op_encode_hdr_maxsz) |
| 163 | #define decode_lookupp_maxsz (op_decode_hdr_maxsz) |
Trond Myklebust | 2cebf82 | 2007-07-02 13:57:28 -0400 | [diff] [blame] | 164 | #define encode_share_access_maxsz \ |
| 165 | (2) |
Alexandros Batsakis | 4882ef7 | 2009-12-05 13:30:21 -0500 | [diff] [blame] | 166 | #define encode_createmode_maxsz (1 + encode_attrs_maxsz + encode_verifier_maxsz) |
Trond Myklebust | 2cebf82 | 2007-07-02 13:57:28 -0400 | [diff] [blame] | 167 | #define encode_opentype_maxsz (1 + encode_createmode_maxsz) |
| 168 | #define encode_claim_null_maxsz (1 + nfs4_name_maxsz) |
| 169 | #define encode_open_maxsz (op_encode_hdr_maxsz + \ |
| 170 | 2 + encode_share_access_maxsz + 2 + \ |
| 171 | open_owner_id_maxsz + \ |
| 172 | encode_opentype_maxsz + \ |
| 173 | encode_claim_null_maxsz) |
Trond Myklebust | 5a1f6d9 | 2017-02-19 16:08:29 -0500 | [diff] [blame] | 174 | #define decode_space_limit_maxsz (3) |
Trond Myklebust | 2cebf82 | 2007-07-02 13:57:28 -0400 | [diff] [blame] | 175 | #define decode_ace_maxsz (3 + nfs4_owner_maxsz) |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 176 | #define decode_delegation_maxsz (1 + decode_stateid_maxsz + 1 + \ |
Trond Myklebust | 5a1f6d9 | 2017-02-19 16:08:29 -0500 | [diff] [blame] | 177 | decode_space_limit_maxsz + \ |
Trond Myklebust | 2cebf82 | 2007-07-02 13:57:28 -0400 | [diff] [blame] | 178 | decode_ace_maxsz) |
| 179 | #define decode_change_info_maxsz (5) |
| 180 | #define decode_open_maxsz (op_decode_hdr_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 181 | decode_stateid_maxsz + \ |
Trond Myklebust | 2cebf82 | 2007-07-02 13:57:28 -0400 | [diff] [blame] | 182 | decode_change_info_maxsz + 1 + \ |
| 183 | nfs4_fattr_bitmap_maxsz + \ |
| 184 | decode_delegation_maxsz) |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 185 | #define encode_open_confirm_maxsz \ |
| 186 | (op_encode_hdr_maxsz + \ |
| 187 | encode_stateid_maxsz + 1) |
| 188 | #define decode_open_confirm_maxsz \ |
| 189 | (op_decode_hdr_maxsz + \ |
| 190 | decode_stateid_maxsz) |
| 191 | #define encode_open_downgrade_maxsz \ |
| 192 | (op_encode_hdr_maxsz + \ |
| 193 | encode_stateid_maxsz + 1 + \ |
| 194 | encode_share_access_maxsz) |
| 195 | #define decode_open_downgrade_maxsz \ |
| 196 | (op_decode_hdr_maxsz + \ |
| 197 | decode_stateid_maxsz) |
| 198 | #define encode_close_maxsz (op_encode_hdr_maxsz + \ |
| 199 | 1 + encode_stateid_maxsz) |
| 200 | #define decode_close_maxsz (op_decode_hdr_maxsz + \ |
| 201 | decode_stateid_maxsz) |
| 202 | #define encode_setattr_maxsz (op_encode_hdr_maxsz + \ |
| 203 | encode_stateid_maxsz + \ |
| 204 | encode_attrs_maxsz) |
| 205 | #define decode_setattr_maxsz (op_decode_hdr_maxsz + \ |
| 206 | nfs4_fattr_bitmap_maxsz) |
| 207 | #define encode_read_maxsz (op_encode_hdr_maxsz + \ |
| 208 | encode_stateid_maxsz + 3) |
| 209 | #define decode_read_maxsz (op_decode_hdr_maxsz + 2) |
| 210 | #define encode_readdir_maxsz (op_encode_hdr_maxsz + \ |
David Quigley | aa9c266 | 2013-05-22 12:50:44 -0400 | [diff] [blame] | 211 | 2 + encode_verifier_maxsz + 5 + \ |
| 212 | nfs4_label_maxsz) |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 213 | #define decode_readdir_maxsz (op_decode_hdr_maxsz + \ |
Chuck Lever | a7697f6 | 2014-03-12 12:51:17 -0400 | [diff] [blame] | 214 | decode_verifier_maxsz) |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 215 | #define encode_readlink_maxsz (op_encode_hdr_maxsz) |
| 216 | #define decode_readlink_maxsz (op_decode_hdr_maxsz + 1) |
| 217 | #define encode_write_maxsz (op_encode_hdr_maxsz + \ |
| 218 | encode_stateid_maxsz + 4) |
| 219 | #define decode_write_maxsz (op_decode_hdr_maxsz + \ |
| 220 | 2 + decode_verifier_maxsz) |
| 221 | #define encode_commit_maxsz (op_encode_hdr_maxsz + 3) |
| 222 | #define decode_commit_maxsz (op_decode_hdr_maxsz + \ |
| 223 | decode_verifier_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 224 | #define encode_remove_maxsz (op_encode_hdr_maxsz + \ |
| 225 | nfs4_name_maxsz) |
Benny Halevy | 6ce1839 | 2009-04-01 09:22:06 -0400 | [diff] [blame] | 226 | #define decode_remove_maxsz (op_decode_hdr_maxsz + \ |
| 227 | decode_change_info_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 228 | #define encode_rename_maxsz (op_encode_hdr_maxsz + \ |
| 229 | 2 * nfs4_name_maxsz) |
Benny Halevy | 6ce1839 | 2009-04-01 09:22:06 -0400 | [diff] [blame] | 230 | #define decode_rename_maxsz (op_decode_hdr_maxsz + \ |
| 231 | decode_change_info_maxsz + \ |
| 232 | decode_change_info_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 233 | #define encode_link_maxsz (op_encode_hdr_maxsz + \ |
| 234 | nfs4_name_maxsz) |
Benny Halevy | 6ce1839 | 2009-04-01 09:22:06 -0400 | [diff] [blame] | 235 | #define decode_link_maxsz (op_decode_hdr_maxsz + decode_change_info_maxsz) |
Trond Myklebust | daccbde | 2010-06-25 18:11:43 -0400 | [diff] [blame] | 236 | #define encode_lockowner_maxsz (7) |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 237 | #define encode_lock_maxsz (op_encode_hdr_maxsz + \ |
| 238 | 7 + \ |
Trond Myklebust | daccbde | 2010-06-25 18:11:43 -0400 | [diff] [blame] | 239 | 1 + encode_stateid_maxsz + 1 + \ |
| 240 | encode_lockowner_maxsz) |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 241 | #define decode_lock_denied_maxsz \ |
| 242 | (8 + decode_lockowner_maxsz) |
| 243 | #define decode_lock_maxsz (op_decode_hdr_maxsz + \ |
| 244 | decode_lock_denied_maxsz) |
Trond Myklebust | daccbde | 2010-06-25 18:11:43 -0400 | [diff] [blame] | 245 | #define encode_lockt_maxsz (op_encode_hdr_maxsz + 5 + \ |
| 246 | encode_lockowner_maxsz) |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 247 | #define decode_lockt_maxsz (op_decode_hdr_maxsz + \ |
| 248 | decode_lock_denied_maxsz) |
| 249 | #define encode_locku_maxsz (op_encode_hdr_maxsz + 3 + \ |
| 250 | encode_stateid_maxsz + \ |
| 251 | 4) |
| 252 | #define decode_locku_maxsz (op_decode_hdr_maxsz + \ |
| 253 | decode_stateid_maxsz) |
Trond Myklebust | d3c7b7c | 2010-07-01 12:49:01 -0400 | [diff] [blame] | 254 | #define encode_release_lockowner_maxsz \ |
| 255 | (op_encode_hdr_maxsz + \ |
| 256 | encode_lockowner_maxsz) |
| 257 | #define decode_release_lockowner_maxsz \ |
| 258 | (op_decode_hdr_maxsz) |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 259 | #define encode_access_maxsz (op_encode_hdr_maxsz + 1) |
| 260 | #define decode_access_maxsz (op_decode_hdr_maxsz + 2) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 261 | #define encode_symlink_maxsz (op_encode_hdr_maxsz + \ |
| 262 | 1 + nfs4_name_maxsz + \ |
Chuck Lever | 94a6d75 | 2006-08-22 20:06:23 -0400 | [diff] [blame] | 263 | 1 + \ |
J. Bruce Fields | 9692820 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 264 | nfs4_fattr_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 265 | #define decode_symlink_maxsz (op_decode_hdr_maxsz + 8) |
| 266 | #define encode_create_maxsz (op_encode_hdr_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 267 | 1 + 2 + nfs4_name_maxsz + \ |
| 268 | encode_attrs_maxsz) |
Trond Myklebust | 2cebf82 | 2007-07-02 13:57:28 -0400 | [diff] [blame] | 269 | #define decode_create_maxsz (op_decode_hdr_maxsz + \ |
| 270 | decode_change_info_maxsz + \ |
| 271 | nfs4_fattr_bitmap_maxsz) |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 272 | #define encode_statfs_maxsz (encode_getattr_maxsz) |
| 273 | #define decode_statfs_maxsz (decode_getattr_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 274 | #define encode_delegreturn_maxsz (op_encode_hdr_maxsz + 4) |
| 275 | #define decode_delegreturn_maxsz (op_decode_hdr_maxsz) |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 276 | #define encode_getacl_maxsz (encode_getattr_maxsz) |
| 277 | #define decode_getacl_maxsz (op_decode_hdr_maxsz + \ |
| 278 | nfs4_fattr_bitmap_maxsz + 1) |
| 279 | #define encode_setacl_maxsz (op_encode_hdr_maxsz + \ |
| 280 | encode_stateid_maxsz + 3) |
| 281 | #define decode_setacl_maxsz (decode_setattr_maxsz) |
Trond Myklebust | e688962 | 2007-07-02 13:58:30 -0400 | [diff] [blame] | 282 | #define encode_fs_locations_maxsz \ |
| 283 | (encode_getattr_maxsz) |
| 284 | #define decode_fs_locations_maxsz \ |
| 285 | (0) |
Bryan Schumaker | 5a5ea0d | 2011-03-24 17:12:29 +0000 | [diff] [blame] | 286 | #define encode_secinfo_maxsz (op_encode_hdr_maxsz + nfs4_name_maxsz) |
Bryan Schumaker | 1650add | 2011-06-02 15:07:35 -0400 | [diff] [blame] | 287 | #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] | 288 | |
| 289 | #if defined(CONFIG_NFS_V4_1) |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 290 | #define NFS4_MAX_MACHINE_NAME_LEN (64) |
Jim Rees | d751f74 | 2012-11-16 18:12:06 -0500 | [diff] [blame] | 291 | #define IMPL_NAME_LIMIT (sizeof(utsname()->sysname) + sizeof(utsname()->release) + \ |
| 292 | sizeof(utsname()->version) + sizeof(utsname()->machine) + 8) |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 293 | |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 294 | #define encode_exchange_id_maxsz (op_encode_hdr_maxsz + \ |
| 295 | encode_verifier_maxsz + \ |
| 296 | 1 /* co_ownerid.len */ + \ |
Jeff Layton | b8fb2f5 | 2015-06-09 19:43:58 -0400 | [diff] [blame] | 297 | /* eia_clientowner */ \ |
| 298 | 1 + XDR_QUADLEN(NFS4_OPAQUE_LIMIT) + \ |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 299 | 1 /* flags */ + \ |
| 300 | 1 /* spa_how */ + \ |
Weston Andros Adamson | 2031cd1 | 2013-08-13 16:37:32 -0400 | [diff] [blame] | 301 | /* max is SP4_MACH_CRED (for now) */ + \ |
| 302 | 1 + NFS4_OP_MAP_NUM_WORDS + \ |
| 303 | 1 + NFS4_OP_MAP_NUM_WORDS + \ |
Weston Andros Adamson | db8ac8b | 2012-02-17 15:20:24 -0500 | [diff] [blame] | 304 | 1 /* implementation id array of size 1 */ + \ |
| 305 | 1 /* nii_domain */ + \ |
| 306 | XDR_QUADLEN(NFS4_OPAQUE_LIMIT) + \ |
| 307 | 1 /* nii_name */ + \ |
Jim Rees | d751f74 | 2012-11-16 18:12:06 -0500 | [diff] [blame] | 308 | XDR_QUADLEN(IMPL_NAME_LIMIT) + \ |
Weston Andros Adamson | db8ac8b | 2012-02-17 15:20:24 -0500 | [diff] [blame] | 309 | 3 /* nii_date */) |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 310 | #define decode_exchange_id_maxsz (op_decode_hdr_maxsz + \ |
| 311 | 2 /* eir_clientid */ + \ |
| 312 | 1 /* eir_sequenceid */ + \ |
| 313 | 1 /* eir_flags */ + \ |
| 314 | 1 /* spr_how */ + \ |
Weston Andros Adamson | 2031cd1 | 2013-08-13 16:37:32 -0400 | [diff] [blame] | 315 | /* max is SP4_MACH_CRED (for now) */ + \ |
| 316 | 1 + NFS4_OP_MAP_NUM_WORDS + \ |
| 317 | 1 + NFS4_OP_MAP_NUM_WORDS + \ |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 318 | 2 /* eir_server_owner.so_minor_id */ + \ |
| 319 | /* eir_server_owner.so_major_id<> */ \ |
| 320 | XDR_QUADLEN(NFS4_OPAQUE_LIMIT) + 1 + \ |
| 321 | /* eir_server_scope<> */ \ |
| 322 | XDR_QUADLEN(NFS4_OPAQUE_LIMIT) + 1 + \ |
| 323 | 1 /* eir_server_impl_id array length */ + \ |
Weston Andros Adamson | 7d2ed9a | 2012-02-17 15:20:26 -0500 | [diff] [blame] | 324 | 1 /* nii_domain */ + \ |
| 325 | XDR_QUADLEN(NFS4_OPAQUE_LIMIT) + \ |
| 326 | 1 /* nii_name */ + \ |
| 327 | XDR_QUADLEN(NFS4_OPAQUE_LIMIT) + \ |
| 328 | 3 /* nii_date */) |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 329 | #define encode_channel_attrs_maxsz (6 + 1 /* ca_rdma_ird.len (0) */) |
| 330 | #define decode_channel_attrs_maxsz (6 + \ |
| 331 | 1 /* ca_rdma_ird.len */ + \ |
| 332 | 1 /* ca_rdma_ird */) |
| 333 | #define encode_create_session_maxsz (op_encode_hdr_maxsz + \ |
| 334 | 2 /* csa_clientid */ + \ |
| 335 | 1 /* csa_sequence */ + \ |
| 336 | 1 /* csa_flags */ + \ |
| 337 | encode_channel_attrs_maxsz + \ |
| 338 | encode_channel_attrs_maxsz + \ |
| 339 | 1 /* csa_cb_program */ + \ |
| 340 | 1 /* csa_sec_parms.len (1) */ + \ |
| 341 | 1 /* cb_secflavor (AUTH_SYS) */ + \ |
| 342 | 1 /* stamp */ + \ |
| 343 | 1 /* machinename.len */ + \ |
| 344 | XDR_QUADLEN(NFS4_MAX_MACHINE_NAME_LEN) + \ |
| 345 | 1 /* uid */ + \ |
| 346 | 1 /* gid */ + \ |
| 347 | 1 /* gids.len (0) */) |
| 348 | #define decode_create_session_maxsz (op_decode_hdr_maxsz + \ |
| 349 | XDR_QUADLEN(NFS4_MAX_SESSIONID_LEN) + \ |
| 350 | 1 /* csr_sequence */ + \ |
| 351 | 1 /* csr_flags */ + \ |
| 352 | decode_channel_attrs_maxsz + \ |
| 353 | decode_channel_attrs_maxsz) |
Weston Andros Adamson | 7c44f1ae | 2012-05-24 13:22:50 -0400 | [diff] [blame] | 354 | #define encode_bind_conn_to_session_maxsz (op_encode_hdr_maxsz + \ |
| 355 | /* bctsa_sessid */ \ |
| 356 | XDR_QUADLEN(NFS4_MAX_SESSIONID_LEN) + \ |
| 357 | 1 /* bctsa_dir */ + \ |
| 358 | 1 /* bctsa_use_conn_in_rdma_mode */) |
| 359 | #define decode_bind_conn_to_session_maxsz (op_decode_hdr_maxsz + \ |
| 360 | /* bctsr_sessid */ \ |
| 361 | XDR_QUADLEN(NFS4_MAX_SESSIONID_LEN) + \ |
| 362 | 1 /* bctsr_dir */ + \ |
| 363 | 1 /* bctsr_use_conn_in_rdma_mode */) |
Andy Adamson | 0f3e66c | 2009-04-01 09:22:34 -0400 | [diff] [blame] | 364 | #define encode_destroy_session_maxsz (op_encode_hdr_maxsz + 4) |
| 365 | #define decode_destroy_session_maxsz (op_decode_hdr_maxsz) |
Trond Myklebust | 6624553 | 2012-05-25 17:18:09 -0400 | [diff] [blame] | 366 | #define encode_destroy_clientid_maxsz (op_encode_hdr_maxsz + 2) |
| 367 | #define decode_destroy_clientid_maxsz (op_decode_hdr_maxsz) |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 368 | #define encode_sequence_maxsz (op_encode_hdr_maxsz + \ |
| 369 | XDR_QUADLEN(NFS4_MAX_SESSIONID_LEN) + 4) |
| 370 | #define decode_sequence_maxsz (op_decode_hdr_maxsz + \ |
| 371 | XDR_QUADLEN(NFS4_MAX_SESSIONID_LEN) + 5) |
Ricardo Labiaga | 18019753 | 2009-12-05 16:08:40 -0500 | [diff] [blame] | 372 | #define encode_reclaim_complete_maxsz (op_encode_hdr_maxsz + 4) |
| 373 | #define decode_reclaim_complete_maxsz (op_decode_hdr_maxsz + 4) |
Christoph Hellwig | 84c9dee | 2014-09-10 17:37:28 -0700 | [diff] [blame] | 374 | #define encode_getdeviceinfo_maxsz (op_encode_hdr_maxsz + \ |
| 375 | XDR_QUADLEN(NFS4_DEVICEID4_SIZE) + \ |
| 376 | 1 /* layout type */ + \ |
| 377 | 1 /* maxcount */ + \ |
| 378 | 1 /* bitmap size */ + \ |
| 379 | 1 /* notification bitmap length */ + \ |
| 380 | 1 /* notification bitmap, word 0 */) |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 381 | #define decode_getdeviceinfo_maxsz (op_decode_hdr_maxsz + \ |
| 382 | 1 /* layout type */ + \ |
| 383 | 1 /* opaque devaddr4 length */ + \ |
| 384 | /* devaddr4 payload is read into page */ \ |
| 385 | 1 /* notification bitmap length */ + \ |
Christoph Hellwig | 84c9dee | 2014-09-10 17:37:28 -0700 | [diff] [blame] | 386 | 1 /* notification bitmap, word 0 */) |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 387 | #define encode_layoutget_maxsz (op_encode_hdr_maxsz + 10 + \ |
| 388 | encode_stateid_maxsz) |
| 389 | #define decode_layoutget_maxsz (op_decode_hdr_maxsz + 8 + \ |
| 390 | decode_stateid_maxsz + \ |
| 391 | XDR_QUADLEN(PNFS_LAYOUT_MAXSIZE)) |
Andy Adamson | 863a3c6 | 2011-03-23 13:27:54 +0000 | [diff] [blame] | 392 | #define encode_layoutcommit_maxsz (op_encode_hdr_maxsz + \ |
| 393 | 2 /* offset */ + \ |
| 394 | 2 /* length */ + \ |
| 395 | 1 /* reclaim */ + \ |
| 396 | encode_stateid_maxsz + \ |
| 397 | 1 /* new offset (true) */ + \ |
| 398 | 2 /* last byte written */ + \ |
| 399 | 1 /* nt_timechanged (false) */ + \ |
| 400 | 1 /* layoutupdate4 layout type */ + \ |
Christoph Hellwig | 5f919c9 | 2014-08-21 11:09:25 -0500 | [diff] [blame] | 401 | 1 /* layoutupdate4 opaqueue len */) |
| 402 | /* the actual content of layoutupdate4 should |
| 403 | be allocated by drivers and spliced in |
| 404 | using xdr_write_pages */ |
Andy Adamson | 863a3c6 | 2011-03-23 13:27:54 +0000 | [diff] [blame] | 405 | #define decode_layoutcommit_maxsz (op_decode_hdr_maxsz + 3) |
Benny Halevy | cbe8260 | 2011-05-22 19:52:37 +0300 | [diff] [blame] | 406 | #define encode_layoutreturn_maxsz (8 + op_encode_hdr_maxsz + \ |
| 407 | encode_stateid_maxsz + \ |
Trond Myklebust | 6669cb8 | 2015-08-27 20:43:20 -0400 | [diff] [blame] | 408 | 1 + \ |
| 409 | XDR_QUADLEN(NFS4_OPAQUE_LIMIT)) |
Benny Halevy | cbe8260 | 2011-05-22 19:52:37 +0300 | [diff] [blame] | 410 | #define decode_layoutreturn_maxsz (op_decode_hdr_maxsz + \ |
| 411 | 1 + decode_stateid_maxsz) |
Bryan Schumaker | fca78d6 | 2011-06-02 14:59:07 -0400 | [diff] [blame] | 412 | #define encode_secinfo_no_name_maxsz (op_encode_hdr_maxsz + 1) |
| 413 | #define decode_secinfo_no_name_maxsz decode_secinfo_maxsz |
Bryan Schumaker | 7d97479 | 2011-06-02 14:59:08 -0400 | [diff] [blame] | 414 | #define encode_test_stateid_maxsz (op_encode_hdr_maxsz + 2 + \ |
| 415 | XDR_QUADLEN(NFS4_STATEID_SIZE)) |
| 416 | #define decode_test_stateid_maxsz (op_decode_hdr_maxsz + 2 + 1) |
Bryan Schumaker | 9aeda35 | 2011-06-02 14:59:09 -0400 | [diff] [blame] | 417 | #define encode_free_stateid_maxsz (op_encode_hdr_maxsz + 1 + \ |
| 418 | XDR_QUADLEN(NFS4_STATEID_SIZE)) |
Andy Adamson | 9f79fb4 | 2013-09-10 12:56:29 -0400 | [diff] [blame] | 419 | #define decode_free_stateid_maxsz (op_decode_hdr_maxsz) |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 420 | #else /* CONFIG_NFS_V4_1 */ |
| 421 | #define encode_sequence_maxsz 0 |
| 422 | #define decode_sequence_maxsz 0 |
Trond Myklebust | cf80516 | 2016-11-15 14:56:07 -0500 | [diff] [blame] | 423 | #define encode_layoutreturn_maxsz 0 |
| 424 | #define decode_layoutreturn_maxsz 0 |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 425 | #endif /* CONFIG_NFS_V4_1 */ |
| 426 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 427 | #define NFS4_enc_compound_sz (1024) /* XXX: large enough? */ |
| 428 | #define NFS4_dec_compound_sz (1024) /* XXX: large enough? */ |
| 429 | #define NFS4_enc_read_sz (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 430 | encode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 431 | encode_putfh_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 432 | encode_read_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 433 | #define NFS4_dec_read_sz (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 434 | decode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 435 | decode_putfh_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 436 | decode_read_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 437 | #define NFS4_enc_readlink_sz (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 438 | encode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 439 | encode_putfh_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 440 | encode_readlink_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 441 | #define NFS4_dec_readlink_sz (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 442 | decode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 443 | decode_putfh_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 444 | decode_readlink_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 445 | #define NFS4_enc_readdir_sz (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 446 | encode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 447 | encode_putfh_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 448 | encode_readdir_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 449 | #define NFS4_dec_readdir_sz (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 450 | decode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 451 | decode_putfh_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 452 | decode_readdir_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 453 | #define NFS4_enc_write_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_write_maxsz + \ |
Trond Myklebust | 4f9838c | 2005-10-27 22:12:44 -0400 | [diff] [blame] | 457 | encode_getattr_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 458 | #define NFS4_dec_write_sz (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 459 | decode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 460 | decode_putfh_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 461 | decode_write_maxsz + \ |
Trond Myklebust | 4f9838c | 2005-10-27 22:12:44 -0400 | [diff] [blame] | 462 | decode_getattr_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 463 | #define NFS4_enc_commit_sz (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 464 | encode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 465 | encode_putfh_maxsz + \ |
Trond Myklebust | 8582715 | 2012-04-29 10:44:42 -0400 | [diff] [blame] | 466 | encode_commit_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 467 | #define NFS4_dec_commit_sz (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 468 | decode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 469 | decode_putfh_maxsz + \ |
Trond Myklebust | 8582715 | 2012-04-29 10:44:42 -0400 | [diff] [blame] | 470 | decode_commit_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 471 | #define NFS4_enc_open_sz (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 472 | encode_sequence_maxsz + \ |
Trond Myklebust | 2cebf82 | 2007-07-02 13:57:28 -0400 | [diff] [blame] | 473 | encode_putfh_maxsz + \ |
Trond Myklebust | 2cebf82 | 2007-07-02 13:57:28 -0400 | [diff] [blame] | 474 | encode_open_maxsz + \ |
Weston Andros Adamson | 6168f62 | 2012-09-10 14:00:46 -0400 | [diff] [blame] | 475 | encode_access_maxsz + \ |
Trond Myklebust | 2cebf82 | 2007-07-02 13:57:28 -0400 | [diff] [blame] | 476 | encode_getfh_maxsz + \ |
Trond Myklebust | 2cebf82 | 2007-07-02 13:57:28 -0400 | [diff] [blame] | 477 | encode_getattr_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 478 | #define NFS4_dec_open_sz (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 479 | decode_sequence_maxsz + \ |
Trond Myklebust | 2cebf82 | 2007-07-02 13:57:28 -0400 | [diff] [blame] | 480 | decode_putfh_maxsz + \ |
Trond Myklebust | 2cebf82 | 2007-07-02 13:57:28 -0400 | [diff] [blame] | 481 | decode_open_maxsz + \ |
Weston Andros Adamson | 6168f62 | 2012-09-10 14:00:46 -0400 | [diff] [blame] | 482 | decode_access_maxsz + \ |
Trond Myklebust | 2cebf82 | 2007-07-02 13:57:28 -0400 | [diff] [blame] | 483 | decode_getfh_maxsz + \ |
Trond Myklebust | 2cebf82 | 2007-07-02 13:57:28 -0400 | [diff] [blame] | 484 | decode_getattr_maxsz) |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 485 | #define NFS4_enc_open_confirm_sz \ |
| 486 | (compound_encode_hdr_maxsz + \ |
| 487 | encode_putfh_maxsz + \ |
| 488 | encode_open_confirm_maxsz) |
| 489 | #define NFS4_dec_open_confirm_sz \ |
| 490 | (compound_decode_hdr_maxsz + \ |
| 491 | decode_putfh_maxsz + \ |
| 492 | decode_open_confirm_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 493 | #define NFS4_enc_open_noattr_sz (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 494 | encode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 495 | encode_putfh_maxsz + \ |
Trond Myklebust | 2cebf82 | 2007-07-02 13:57:28 -0400 | [diff] [blame] | 496 | encode_open_maxsz + \ |
Weston Andros Adamson | 6168f62 | 2012-09-10 14:00:46 -0400 | [diff] [blame] | 497 | encode_access_maxsz + \ |
Trond Myklebust | 2cebf82 | 2007-07-02 13:57:28 -0400 | [diff] [blame] | 498 | encode_getattr_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 499 | #define NFS4_dec_open_noattr_sz (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 500 | decode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 501 | decode_putfh_maxsz + \ |
Trond Myklebust | 2cebf82 | 2007-07-02 13:57:28 -0400 | [diff] [blame] | 502 | decode_open_maxsz + \ |
Weston Andros Adamson | 6168f62 | 2012-09-10 14:00:46 -0400 | [diff] [blame] | 503 | decode_access_maxsz + \ |
Trond Myklebust | 2cebf82 | 2007-07-02 13:57:28 -0400 | [diff] [blame] | 504 | decode_getattr_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 505 | #define NFS4_enc_open_downgrade_sz \ |
| 506 | (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 507 | encode_sequence_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 508 | encode_putfh_maxsz + \ |
Trond Myklebust | b680814 | 2016-11-20 13:34:16 -0500 | [diff] [blame] | 509 | encode_layoutreturn_maxsz + \ |
Trond Myklebust | 3947b74 | 2016-10-27 18:27:02 -0400 | [diff] [blame] | 510 | encode_open_downgrade_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 511 | #define NFS4_dec_open_downgrade_sz \ |
| 512 | (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 513 | decode_sequence_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 514 | decode_putfh_maxsz + \ |
Trond Myklebust | b680814 | 2016-11-20 13:34:16 -0500 | [diff] [blame] | 515 | decode_layoutreturn_maxsz + \ |
Trond Myklebust | 3947b74 | 2016-10-27 18:27:02 -0400 | [diff] [blame] | 516 | decode_open_downgrade_maxsz) |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 517 | #define NFS4_enc_close_sz (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 518 | encode_sequence_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 519 | encode_putfh_maxsz + \ |
Trond Myklebust | cf80516 | 2016-11-15 14:56:07 -0500 | [diff] [blame] | 520 | encode_layoutreturn_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 521 | encode_close_maxsz + \ |
| 522 | encode_getattr_maxsz) |
| 523 | #define NFS4_dec_close_sz (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 524 | decode_sequence_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 525 | decode_putfh_maxsz + \ |
Trond Myklebust | cf80516 | 2016-11-15 14:56:07 -0500 | [diff] [blame] | 526 | decode_layoutreturn_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 527 | decode_close_maxsz + \ |
| 528 | decode_getattr_maxsz) |
| 529 | #define NFS4_enc_setattr_sz (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 530 | encode_sequence_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 531 | encode_putfh_maxsz + \ |
| 532 | encode_setattr_maxsz + \ |
| 533 | encode_getattr_maxsz) |
| 534 | #define NFS4_dec_setattr_sz (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 535 | decode_sequence_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 536 | decode_putfh_maxsz + \ |
| 537 | decode_setattr_maxsz + \ |
| 538 | decode_getattr_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 539 | #define NFS4_enc_fsinfo_sz (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 540 | encode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 541 | encode_putfh_maxsz + \ |
| 542 | encode_fsinfo_maxsz) |
| 543 | #define NFS4_dec_fsinfo_sz (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 544 | decode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 545 | decode_putfh_maxsz + \ |
| 546 | decode_fsinfo_maxsz) |
| 547 | #define NFS4_enc_renew_sz (compound_encode_hdr_maxsz + \ |
| 548 | encode_renew_maxsz) |
| 549 | #define NFS4_dec_renew_sz (compound_decode_hdr_maxsz + \ |
| 550 | decode_renew_maxsz) |
| 551 | #define NFS4_enc_setclientid_sz (compound_encode_hdr_maxsz + \ |
| 552 | encode_setclientid_maxsz) |
| 553 | #define NFS4_dec_setclientid_sz (compound_decode_hdr_maxsz + \ |
| 554 | decode_setclientid_maxsz) |
| 555 | #define NFS4_enc_setclientid_confirm_sz \ |
| 556 | (compound_encode_hdr_maxsz + \ |
Chuck Lever | 83ca7f5 | 2013-03-16 15:55:53 -0400 | [diff] [blame] | 557 | encode_setclientid_confirm_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 558 | #define NFS4_dec_setclientid_confirm_sz \ |
| 559 | (compound_decode_hdr_maxsz + \ |
Chuck Lever | 83ca7f5 | 2013-03-16 15:55:53 -0400 | [diff] [blame] | 560 | decode_setclientid_confirm_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 561 | #define NFS4_enc_lock_sz (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 562 | encode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 563 | encode_putfh_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 564 | encode_lock_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 565 | #define NFS4_dec_lock_sz (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 566 | decode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 567 | decode_putfh_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 568 | decode_lock_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 569 | #define NFS4_enc_lockt_sz (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 570 | encode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 571 | encode_putfh_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 572 | encode_lockt_maxsz) |
| 573 | #define NFS4_dec_lockt_sz (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 574 | decode_sequence_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 575 | decode_putfh_maxsz + \ |
| 576 | decode_lockt_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 577 | #define NFS4_enc_locku_sz (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 578 | encode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 579 | encode_putfh_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 580 | encode_locku_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 581 | #define NFS4_dec_locku_sz (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 582 | decode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 583 | decode_putfh_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 584 | decode_locku_maxsz) |
Trond Myklebust | d3c7b7c | 2010-07-01 12:49:01 -0400 | [diff] [blame] | 585 | #define NFS4_enc_release_lockowner_sz \ |
| 586 | (compound_encode_hdr_maxsz + \ |
| 587 | encode_lockowner_maxsz) |
| 588 | #define NFS4_dec_release_lockowner_sz \ |
| 589 | (compound_decode_hdr_maxsz + \ |
| 590 | decode_lockowner_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 591 | #define NFS4_enc_access_sz (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 592 | encode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 593 | encode_putfh_maxsz + \ |
Trond Myklebust | 76b3299 | 2007-08-10 17:45:11 -0400 | [diff] [blame] | 594 | encode_access_maxsz + \ |
| 595 | encode_getattr_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 596 | #define NFS4_dec_access_sz (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 597 | decode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 598 | decode_putfh_maxsz + \ |
Trond Myklebust | 76b3299 | 2007-08-10 17:45:11 -0400 | [diff] [blame] | 599 | decode_access_maxsz + \ |
| 600 | decode_getattr_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 601 | #define NFS4_enc_getattr_sz (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 602 | encode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 603 | encode_putfh_maxsz + \ |
Chuck Lever | 44c9993 | 2013-10-17 14:13:30 -0400 | [diff] [blame] | 604 | encode_getattr_maxsz + \ |
| 605 | encode_renew_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 606 | #define NFS4_dec_getattr_sz (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 607 | decode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 608 | decode_putfh_maxsz + \ |
Chuck Lever | 44c9993 | 2013-10-17 14:13:30 -0400 | [diff] [blame] | 609 | decode_getattr_maxsz + \ |
| 610 | decode_renew_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 611 | #define NFS4_enc_lookup_sz (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 612 | encode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 613 | encode_putfh_maxsz + \ |
| 614 | encode_lookup_maxsz + \ |
| 615 | encode_getattr_maxsz + \ |
| 616 | encode_getfh_maxsz) |
| 617 | #define NFS4_dec_lookup_sz (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 618 | decode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 619 | decode_putfh_maxsz + \ |
Trond Myklebust | e688962 | 2007-07-02 13:58:30 -0400 | [diff] [blame] | 620 | decode_lookup_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 621 | decode_getattr_maxsz + \ |
| 622 | decode_getfh_maxsz) |
Jeff Layton | 5b5faaf | 2017-06-29 06:34:52 -0700 | [diff] [blame] | 623 | #define NFS4_enc_lookupp_sz (compound_encode_hdr_maxsz + \ |
| 624 | encode_sequence_maxsz + \ |
| 625 | encode_putfh_maxsz + \ |
| 626 | encode_lookupp_maxsz + \ |
| 627 | encode_getattr_maxsz + \ |
| 628 | encode_getfh_maxsz) |
| 629 | #define NFS4_dec_lookupp_sz (compound_decode_hdr_maxsz + \ |
| 630 | decode_sequence_maxsz + \ |
| 631 | decode_putfh_maxsz + \ |
| 632 | decode_lookupp_maxsz + \ |
| 633 | decode_getattr_maxsz + \ |
| 634 | decode_getfh_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 635 | #define NFS4_enc_lookup_root_sz (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 636 | encode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 637 | encode_putrootfh_maxsz + \ |
| 638 | encode_getattr_maxsz + \ |
| 639 | encode_getfh_maxsz) |
| 640 | #define NFS4_dec_lookup_root_sz (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 641 | decode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 642 | decode_putrootfh_maxsz + \ |
| 643 | decode_getattr_maxsz + \ |
| 644 | decode_getfh_maxsz) |
| 645 | #define NFS4_enc_remove_sz (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 646 | encode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 647 | encode_putfh_maxsz + \ |
Trond Myklebust | 778d281 | 2012-04-27 13:48:19 -0400 | [diff] [blame] | 648 | encode_remove_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 649 | #define NFS4_dec_remove_sz (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 650 | decode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 651 | decode_putfh_maxsz + \ |
Trond Myklebust | 778d281 | 2012-04-27 13:48:19 -0400 | [diff] [blame] | 652 | decode_remove_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 653 | #define NFS4_enc_rename_sz (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 654 | encode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 655 | encode_putfh_maxsz + \ |
| 656 | encode_savefh_maxsz + \ |
| 657 | encode_putfh_maxsz + \ |
Trond Myklebust | 778d281 | 2012-04-27 13:48:19 -0400 | [diff] [blame] | 658 | encode_rename_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 659 | #define NFS4_dec_rename_sz (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 660 | decode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 661 | decode_putfh_maxsz + \ |
| 662 | decode_savefh_maxsz + \ |
| 663 | decode_putfh_maxsz + \ |
Trond Myklebust | 778d281 | 2012-04-27 13:48:19 -0400 | [diff] [blame] | 664 | decode_rename_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 665 | #define NFS4_enc_link_sz (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 666 | encode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 667 | encode_putfh_maxsz + \ |
| 668 | encode_savefh_maxsz + \ |
| 669 | encode_putfh_maxsz + \ |
Trond Myklebust | 91ba2ee | 2005-10-27 22:12:42 -0400 | [diff] [blame] | 670 | encode_link_maxsz + \ |
Trond Myklebust | 91ba2ee | 2005-10-27 22:12:42 -0400 | [diff] [blame] | 671 | encode_restorefh_maxsz + \ |
Trond Myklebust | a9f6991 | 2012-04-27 13:48:17 -0400 | [diff] [blame] | 672 | encode_getattr_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 673 | #define NFS4_dec_link_sz (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 674 | decode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 675 | decode_putfh_maxsz + \ |
| 676 | decode_savefh_maxsz + \ |
| 677 | decode_putfh_maxsz + \ |
Trond Myklebust | 91ba2ee | 2005-10-27 22:12:42 -0400 | [diff] [blame] | 678 | decode_link_maxsz + \ |
Trond Myklebust | 91ba2ee | 2005-10-27 22:12:42 -0400 | [diff] [blame] | 679 | decode_restorefh_maxsz + \ |
| 680 | decode_getattr_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 681 | #define NFS4_enc_symlink_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_symlink_maxsz + \ |
| 685 | encode_getattr_maxsz + \ |
| 686 | encode_getfh_maxsz) |
| 687 | #define NFS4_dec_symlink_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_symlink_maxsz + \ |
| 691 | decode_getattr_maxsz + \ |
| 692 | decode_getfh_maxsz) |
| 693 | #define NFS4_enc_create_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_create_maxsz + \ |
Trond Myklebust | 56ae19f | 2005-10-27 22:12:40 -0400 | [diff] [blame] | 697 | encode_getfh_maxsz + \ |
Trond Myklebust | 56ae19f | 2005-10-27 22:12:40 -0400 | [diff] [blame] | 698 | encode_getattr_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 699 | #define NFS4_dec_create_sz (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 700 | decode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 701 | decode_putfh_maxsz + \ |
| 702 | decode_create_maxsz + \ |
Trond Myklebust | 56ae19f | 2005-10-27 22:12:40 -0400 | [diff] [blame] | 703 | decode_getfh_maxsz + \ |
Trond Myklebust | 56ae19f | 2005-10-27 22:12:40 -0400 | [diff] [blame] | 704 | decode_getattr_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 705 | #define NFS4_enc_pathconf_sz (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 706 | encode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 707 | encode_putfh_maxsz + \ |
| 708 | encode_getattr_maxsz) |
| 709 | #define NFS4_dec_pathconf_sz (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 710 | decode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 711 | decode_putfh_maxsz + \ |
| 712 | decode_getattr_maxsz) |
| 713 | #define NFS4_enc_statfs_sz (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 714 | encode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 715 | encode_putfh_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 716 | encode_statfs_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 717 | #define NFS4_dec_statfs_sz (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 718 | decode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 719 | decode_putfh_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 720 | decode_statfs_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 721 | #define NFS4_enc_server_caps_sz (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 722 | encode_sequence_maxsz + \ |
Trond Myklebust | ab91f26 | 2007-02-02 14:47:17 -0800 | [diff] [blame] | 723 | encode_putfh_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 724 | encode_getattr_maxsz) |
| 725 | #define NFS4_dec_server_caps_sz (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 726 | decode_sequence_maxsz + \ |
Trond Myklebust | ab91f26 | 2007-02-02 14:47:17 -0800 | [diff] [blame] | 727 | decode_putfh_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 728 | decode_getattr_maxsz) |
| 729 | #define NFS4_enc_delegreturn_sz (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 730 | encode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 731 | encode_putfh_maxsz + \ |
Trond Myklebust | 586f1c3 | 2016-11-15 15:03:33 -0500 | [diff] [blame] | 732 | encode_layoutreturn_maxsz + \ |
Trond Myklebust | fa178f2 | 2006-01-03 09:55:38 +0100 | [diff] [blame] | 733 | encode_delegreturn_maxsz + \ |
| 734 | encode_getattr_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 735 | #define NFS4_dec_delegreturn_sz (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 736 | decode_sequence_maxsz + \ |
Trond Myklebust | d8434d4c | 2016-11-16 13:54:00 -0500 | [diff] [blame] | 737 | decode_putfh_maxsz + \ |
Trond Myklebust | 586f1c3 | 2016-11-15 15:03:33 -0500 | [diff] [blame] | 738 | decode_layoutreturn_maxsz + \ |
Trond Myklebust | fa178f2 | 2006-01-03 09:55:38 +0100 | [diff] [blame] | 739 | decode_delegreturn_maxsz + \ |
| 740 | decode_getattr_maxsz) |
J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 741 | #define NFS4_enc_getacl_sz (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 742 | encode_sequence_maxsz + \ |
J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 743 | encode_putfh_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 744 | encode_getacl_maxsz) |
J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 745 | #define NFS4_dec_getacl_sz (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 746 | decode_sequence_maxsz + \ |
J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 747 | decode_putfh_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 748 | decode_getacl_maxsz) |
J. Bruce Fields | 23ec696 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 749 | #define NFS4_enc_setacl_sz (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 750 | encode_sequence_maxsz + \ |
J. Bruce Fields | 23ec696 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 751 | encode_putfh_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 752 | encode_setacl_maxsz) |
J. Bruce Fields | 23ec696 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 753 | #define NFS4_dec_setacl_sz (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 754 | decode_sequence_maxsz + \ |
J. Bruce Fields | 23ec696 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 755 | decode_putfh_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 756 | decode_setacl_maxsz) |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 757 | #define NFS4_enc_fs_locations_sz \ |
| 758 | (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 759 | encode_sequence_maxsz + \ |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 760 | encode_putfh_maxsz + \ |
Trond Myklebust | e688962 | 2007-07-02 13:58:30 -0400 | [diff] [blame] | 761 | encode_lookup_maxsz + \ |
Chuck Lever | b03d735 | 2013-10-17 14:12:50 -0400 | [diff] [blame] | 762 | encode_fs_locations_maxsz + \ |
| 763 | encode_renew_maxsz) |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 764 | #define NFS4_dec_fs_locations_sz \ |
| 765 | (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 766 | decode_sequence_maxsz + \ |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 767 | decode_putfh_maxsz + \ |
Trond Myklebust | e688962 | 2007-07-02 13:58:30 -0400 | [diff] [blame] | 768 | decode_lookup_maxsz + \ |
Chuck Lever | b03d735 | 2013-10-17 14:12:50 -0400 | [diff] [blame] | 769 | decode_fs_locations_maxsz + \ |
| 770 | decode_renew_maxsz) |
Bryan Schumaker | 5a5ea0d | 2011-03-24 17:12:29 +0000 | [diff] [blame] | 771 | #define NFS4_enc_secinfo_sz (compound_encode_hdr_maxsz + \ |
| 772 | encode_sequence_maxsz + \ |
| 773 | encode_putfh_maxsz + \ |
| 774 | encode_secinfo_maxsz) |
| 775 | #define NFS4_dec_secinfo_sz (compound_decode_hdr_maxsz + \ |
| 776 | decode_sequence_maxsz + \ |
| 777 | decode_putfh_maxsz + \ |
| 778 | decode_secinfo_maxsz) |
Chuck Lever | 44c9993 | 2013-10-17 14:13:30 -0400 | [diff] [blame] | 779 | #define NFS4_enc_fsid_present_sz \ |
| 780 | (compound_encode_hdr_maxsz + \ |
| 781 | encode_sequence_maxsz + \ |
| 782 | encode_putfh_maxsz + \ |
| 783 | encode_getfh_maxsz + \ |
| 784 | encode_renew_maxsz) |
| 785 | #define NFS4_dec_fsid_present_sz \ |
| 786 | (compound_decode_hdr_maxsz + \ |
| 787 | decode_sequence_maxsz + \ |
| 788 | decode_putfh_maxsz + \ |
| 789 | decode_getfh_maxsz + \ |
| 790 | decode_renew_maxsz) |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 791 | #if defined(CONFIG_NFS_V4_1) |
Weston Andros Adamson | 7c44f1ae | 2012-05-24 13:22:50 -0400 | [diff] [blame] | 792 | #define NFS4_enc_bind_conn_to_session_sz \ |
| 793 | (compound_encode_hdr_maxsz + \ |
| 794 | encode_bind_conn_to_session_maxsz) |
| 795 | #define NFS4_dec_bind_conn_to_session_sz \ |
| 796 | (compound_decode_hdr_maxsz + \ |
| 797 | decode_bind_conn_to_session_maxsz) |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 798 | #define NFS4_enc_exchange_id_sz \ |
| 799 | (compound_encode_hdr_maxsz + \ |
| 800 | encode_exchange_id_maxsz) |
| 801 | #define NFS4_dec_exchange_id_sz \ |
| 802 | (compound_decode_hdr_maxsz + \ |
| 803 | decode_exchange_id_maxsz) |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 804 | #define NFS4_enc_create_session_sz \ |
| 805 | (compound_encode_hdr_maxsz + \ |
| 806 | encode_create_session_maxsz) |
| 807 | #define NFS4_dec_create_session_sz \ |
| 808 | (compound_decode_hdr_maxsz + \ |
| 809 | decode_create_session_maxsz) |
Andy Adamson | 0f3e66c | 2009-04-01 09:22:34 -0400 | [diff] [blame] | 810 | #define NFS4_enc_destroy_session_sz (compound_encode_hdr_maxsz + \ |
| 811 | encode_destroy_session_maxsz) |
| 812 | #define NFS4_dec_destroy_session_sz (compound_decode_hdr_maxsz + \ |
| 813 | decode_destroy_session_maxsz) |
Trond Myklebust | 6624553 | 2012-05-25 17:18:09 -0400 | [diff] [blame] | 814 | #define NFS4_enc_destroy_clientid_sz (compound_encode_hdr_maxsz + \ |
| 815 | encode_destroy_clientid_maxsz) |
| 816 | #define NFS4_dec_destroy_clientid_sz (compound_decode_hdr_maxsz + \ |
| 817 | decode_destroy_clientid_maxsz) |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 818 | #define NFS4_enc_sequence_sz \ |
| 819 | (compound_decode_hdr_maxsz + \ |
| 820 | encode_sequence_maxsz) |
| 821 | #define NFS4_dec_sequence_sz \ |
| 822 | (compound_decode_hdr_maxsz + \ |
| 823 | decode_sequence_maxsz) |
Andy Adamson | 2050f0c | 2009-04-01 09:22:30 -0400 | [diff] [blame] | 824 | #define NFS4_enc_get_lease_time_sz (compound_encode_hdr_maxsz + \ |
| 825 | encode_sequence_maxsz + \ |
| 826 | encode_putrootfh_maxsz + \ |
| 827 | encode_fsinfo_maxsz) |
| 828 | #define NFS4_dec_get_lease_time_sz (compound_decode_hdr_maxsz + \ |
| 829 | decode_sequence_maxsz + \ |
| 830 | decode_putrootfh_maxsz + \ |
| 831 | decode_fsinfo_maxsz) |
Ricardo Labiaga | 18019753 | 2009-12-05 16:08:40 -0500 | [diff] [blame] | 832 | #define NFS4_enc_reclaim_complete_sz (compound_encode_hdr_maxsz + \ |
| 833 | encode_sequence_maxsz + \ |
| 834 | encode_reclaim_complete_maxsz) |
| 835 | #define NFS4_dec_reclaim_complete_sz (compound_decode_hdr_maxsz + \ |
| 836 | decode_sequence_maxsz + \ |
| 837 | decode_reclaim_complete_maxsz) |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 838 | #define NFS4_enc_getdeviceinfo_sz (compound_encode_hdr_maxsz + \ |
| 839 | encode_sequence_maxsz +\ |
| 840 | encode_getdeviceinfo_maxsz) |
| 841 | #define NFS4_dec_getdeviceinfo_sz (compound_decode_hdr_maxsz + \ |
| 842 | decode_sequence_maxsz + \ |
| 843 | decode_getdeviceinfo_maxsz) |
| 844 | #define NFS4_enc_layoutget_sz (compound_encode_hdr_maxsz + \ |
| 845 | encode_sequence_maxsz + \ |
| 846 | encode_putfh_maxsz + \ |
| 847 | encode_layoutget_maxsz) |
| 848 | #define NFS4_dec_layoutget_sz (compound_decode_hdr_maxsz + \ |
| 849 | decode_sequence_maxsz + \ |
| 850 | decode_putfh_maxsz + \ |
| 851 | decode_layoutget_maxsz) |
Andy Adamson | 863a3c6 | 2011-03-23 13:27:54 +0000 | [diff] [blame] | 852 | #define NFS4_enc_layoutcommit_sz (compound_encode_hdr_maxsz + \ |
| 853 | encode_sequence_maxsz +\ |
| 854 | encode_putfh_maxsz + \ |
| 855 | encode_layoutcommit_maxsz + \ |
| 856 | encode_getattr_maxsz) |
| 857 | #define NFS4_dec_layoutcommit_sz (compound_decode_hdr_maxsz + \ |
| 858 | decode_sequence_maxsz + \ |
| 859 | decode_putfh_maxsz + \ |
| 860 | decode_layoutcommit_maxsz + \ |
| 861 | decode_getattr_maxsz) |
Benny Halevy | cbe8260 | 2011-05-22 19:52:37 +0300 | [diff] [blame] | 862 | #define NFS4_enc_layoutreturn_sz (compound_encode_hdr_maxsz + \ |
| 863 | encode_sequence_maxsz + \ |
| 864 | encode_putfh_maxsz + \ |
| 865 | encode_layoutreturn_maxsz) |
| 866 | #define NFS4_dec_layoutreturn_sz (compound_decode_hdr_maxsz + \ |
| 867 | decode_sequence_maxsz + \ |
| 868 | decode_putfh_maxsz + \ |
| 869 | decode_layoutreturn_maxsz) |
Bryan Schumaker | fca78d6 | 2011-06-02 14:59:07 -0400 | [diff] [blame] | 870 | #define NFS4_enc_secinfo_no_name_sz (compound_encode_hdr_maxsz + \ |
| 871 | encode_sequence_maxsz + \ |
| 872 | encode_putrootfh_maxsz +\ |
| 873 | encode_secinfo_no_name_maxsz) |
| 874 | #define NFS4_dec_secinfo_no_name_sz (compound_decode_hdr_maxsz + \ |
| 875 | decode_sequence_maxsz + \ |
| 876 | decode_putrootfh_maxsz + \ |
| 877 | decode_secinfo_no_name_maxsz) |
Bryan Schumaker | 7d97479 | 2011-06-02 14:59:08 -0400 | [diff] [blame] | 878 | #define NFS4_enc_test_stateid_sz (compound_encode_hdr_maxsz + \ |
| 879 | encode_sequence_maxsz + \ |
| 880 | encode_test_stateid_maxsz) |
| 881 | #define NFS4_dec_test_stateid_sz (compound_decode_hdr_maxsz + \ |
| 882 | decode_sequence_maxsz + \ |
| 883 | decode_test_stateid_maxsz) |
Bryan Schumaker | 9aeda35 | 2011-06-02 14:59:09 -0400 | [diff] [blame] | 884 | #define NFS4_enc_free_stateid_sz (compound_encode_hdr_maxsz + \ |
| 885 | encode_sequence_maxsz + \ |
| 886 | encode_free_stateid_maxsz) |
| 887 | #define NFS4_dec_free_stateid_sz (compound_decode_hdr_maxsz + \ |
| 888 | decode_sequence_maxsz + \ |
| 889 | decode_free_stateid_maxsz) |
Alexandros Batsakis | 2449ea2 | 2009-12-05 13:36:55 -0500 | [diff] [blame] | 890 | |
| 891 | const u32 nfs41_maxwrite_overhead = ((RPC_MAX_HEADER_WITH_AUTH + |
| 892 | compound_encode_hdr_maxsz + |
| 893 | encode_sequence_maxsz + |
| 894 | encode_putfh_maxsz + |
| 895 | encode_getattr_maxsz) * |
| 896 | XDR_UNIT); |
| 897 | |
| 898 | const u32 nfs41_maxread_overhead = ((RPC_MAX_HEADER_WITH_AUTH + |
| 899 | compound_decode_hdr_maxsz + |
| 900 | decode_sequence_maxsz + |
| 901 | decode_putfh_maxsz) * |
| 902 | XDR_UNIT); |
Andy Adamson | f1c097b | 2013-06-25 19:02:53 -0400 | [diff] [blame] | 903 | |
| 904 | const u32 nfs41_maxgetdevinfo_overhead = ((RPC_MAX_REPHEADER_WITH_AUTH + |
| 905 | compound_decode_hdr_maxsz + |
| 906 | decode_sequence_maxsz) * |
| 907 | XDR_UNIT); |
| 908 | EXPORT_SYMBOL_GPL(nfs41_maxgetdevinfo_overhead); |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 909 | #endif /* CONFIG_NFS_V4_1 */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 910 | |
Trond Myklebust | bca7947 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 911 | static const umode_t nfs_type2fmt[] = { |
| 912 | [NF4BAD] = 0, |
| 913 | [NF4REG] = S_IFREG, |
| 914 | [NF4DIR] = S_IFDIR, |
| 915 | [NF4BLK] = S_IFBLK, |
| 916 | [NF4CHR] = S_IFCHR, |
| 917 | [NF4LNK] = S_IFLNK, |
| 918 | [NF4SOCK] = S_IFSOCK, |
| 919 | [NF4FIFO] = S_IFIFO, |
| 920 | [NF4ATTRDIR] = 0, |
| 921 | [NF4NAMEDATTR] = 0, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 922 | }; |
| 923 | |
| 924 | struct compound_hdr { |
| 925 | int32_t status; |
| 926 | uint32_t nops; |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 927 | __be32 * nops_p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 928 | uint32_t taglen; |
| 929 | char * tag; |
Benny Halevy | 0c4e8c1 | 2009-04-01 09:22:07 -0400 | [diff] [blame] | 930 | uint32_t replen; /* expected reply words */ |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 931 | u32 minorversion; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 932 | }; |
| 933 | |
Benny Halevy | 13c65ce | 2009-08-14 17:19:25 +0300 | [diff] [blame] | 934 | static __be32 *reserve_space(struct xdr_stream *xdr, size_t nbytes) |
| 935 | { |
| 936 | __be32 *p = xdr_reserve_space(xdr, nbytes); |
| 937 | BUG_ON(!p); |
| 938 | return p; |
| 939 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 940 | |
Trond Myklebust | cb17e55 | 2012-03-04 18:13:56 -0500 | [diff] [blame] | 941 | static void encode_opaque_fixed(struct xdr_stream *xdr, const void *buf, size_t len) |
| 942 | { |
Trond Myklebust | ab6e9aa | 2017-02-19 16:08:26 -0500 | [diff] [blame] | 943 | WARN_ON_ONCE(xdr_stream_encode_opaque_fixed(xdr, buf, len) < 0); |
Trond Myklebust | cb17e55 | 2012-03-04 18:13:56 -0500 | [diff] [blame] | 944 | } |
| 945 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 946 | static void encode_string(struct xdr_stream *xdr, unsigned int len, const char *str) |
| 947 | { |
Trond Myklebust | ab6e9aa | 2017-02-19 16:08:26 -0500 | [diff] [blame] | 948 | WARN_ON_ONCE(xdr_stream_encode_opaque(xdr, str, len) < 0); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 949 | } |
| 950 | |
Trond Myklebust | 4ade982 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 951 | static void encode_uint32(struct xdr_stream *xdr, u32 n) |
| 952 | { |
Trond Myklebust | ab6e9aa | 2017-02-19 16:08:26 -0500 | [diff] [blame] | 953 | WARN_ON_ONCE(xdr_stream_encode_u32(xdr, n) < 0); |
Trond Myklebust | 4ade982 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 954 | } |
| 955 | |
Trond Myklebust | ff2eb68 | 2012-03-05 11:40:12 -0500 | [diff] [blame] | 956 | static void encode_uint64(struct xdr_stream *xdr, u64 n) |
| 957 | { |
Trond Myklebust | ab6e9aa | 2017-02-19 16:08:26 -0500 | [diff] [blame] | 958 | WARN_ON_ONCE(xdr_stream_encode_u64(xdr, n) < 0); |
Trond Myklebust | ff2eb68 | 2012-03-05 11:40:12 -0500 | [diff] [blame] | 959 | } |
| 960 | |
Trond Myklebust | 4ade982 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 961 | static void encode_nfs4_seqid(struct xdr_stream *xdr, |
| 962 | const struct nfs_seqid *seqid) |
| 963 | { |
Trond Myklebust | a679641 | 2015-01-23 19:04:44 -0500 | [diff] [blame] | 964 | if (seqid != NULL) |
| 965 | encode_uint32(xdr, seqid->sequence->counter); |
| 966 | else |
| 967 | encode_uint32(xdr, 0); |
Trond Myklebust | 4ade982 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 968 | } |
| 969 | |
Benny Halevy | 0c4e8c1 | 2009-04-01 09:22:07 -0400 | [diff] [blame] | 970 | static void encode_compound_hdr(struct xdr_stream *xdr, |
| 971 | struct rpc_rqst *req, |
| 972 | struct compound_hdr *hdr) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 973 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 974 | __be32 *p; |
Trond Myklebust | a17c215 | 2010-07-31 14:29:08 -0400 | [diff] [blame] | 975 | struct rpc_auth *auth = req->rq_cred->cr_auth; |
Benny Halevy | 0c4e8c1 | 2009-04-01 09:22:07 -0400 | [diff] [blame] | 976 | |
| 977 | /* initialize running count of expected bytes in reply. |
| 978 | * NOTE: the replied tag SHOULD be the same is the one sent, |
| 979 | * but this is not required as a MUST for the server to do so. */ |
| 980 | hdr->replen = RPC_REPHDRSIZE + auth->au_rslack + 3 + hdr->taglen; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 981 | |
Trond Myklebust | 7fc3884 | 2012-10-15 11:51:21 -0400 | [diff] [blame] | 982 | WARN_ON_ONCE(hdr->taglen > NFS4_MAXTAGLEN); |
Trond Myklebust | 6fdfb0bc | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 983 | encode_string(xdr, hdr->taglen, hdr->tag); |
| 984 | p = reserve_space(xdr, 8); |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 985 | *p++ = cpu_to_be32(hdr->minorversion); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 986 | hdr->nops_p = p; |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 987 | *p = cpu_to_be32(hdr->nops); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 988 | } |
| 989 | |
Trond Myklebust | ab19b48 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 990 | static void encode_op_hdr(struct xdr_stream *xdr, enum nfs_opnum4 op, |
| 991 | uint32_t replen, |
| 992 | struct compound_hdr *hdr) |
| 993 | { |
| 994 | encode_uint32(xdr, op); |
| 995 | hdr->nops++; |
| 996 | hdr->replen += replen; |
| 997 | } |
| 998 | |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 999 | static void encode_nops(struct compound_hdr *hdr) |
| 1000 | { |
Trond Myklebust | 7fc3884 | 2012-10-15 11:51:21 -0400 | [diff] [blame] | 1001 | WARN_ON_ONCE(hdr->nops > NFS4_MAX_OPS); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 1002 | *hdr->nops_p = htonl(hdr->nops); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1003 | } |
| 1004 | |
Trond Myklebust | ea9d23f | 2012-03-04 18:13:56 -0500 | [diff] [blame] | 1005 | static void encode_nfs4_stateid(struct xdr_stream *xdr, const nfs4_stateid *stateid) |
| 1006 | { |
Trond Myklebust | 2d2f24a | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1007 | encode_opaque_fixed(xdr, stateid, NFS4_STATEID_SIZE); |
Trond Myklebust | ea9d23f | 2012-03-04 18:13:56 -0500 | [diff] [blame] | 1008 | } |
| 1009 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1010 | static void encode_nfs4_verifier(struct xdr_stream *xdr, const nfs4_verifier *verf) |
| 1011 | { |
Trond Myklebust | cb17e55 | 2012-03-04 18:13:56 -0500 | [diff] [blame] | 1012 | encode_opaque_fixed(xdr, verf->data, NFS4_VERIFIER_SIZE); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1013 | } |
| 1014 | |
David Quigley | aa9c266 | 2013-05-22 12:50:44 -0400 | [diff] [blame] | 1015 | static void encode_attrs(struct xdr_stream *xdr, const struct iattr *iap, |
| 1016 | const struct nfs4_label *label, |
Trond Myklebust | 28cf22d | 2017-05-06 12:19:11 -0400 | [diff] [blame] | 1017 | const umode_t *umask, |
Kinglong Mee | 5334c5b | 2015-08-26 21:13:37 +0800 | [diff] [blame] | 1018 | const struct nfs_server *server, |
Trond Myklebust | 28cf22d | 2017-05-06 12:19:11 -0400 | [diff] [blame] | 1019 | const uint32_t attrmask[]) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1020 | { |
| 1021 | char owner_name[IDMAP_NAMESZ]; |
| 1022 | char owner_group[IDMAP_NAMESZ]; |
| 1023 | int owner_namelen = 0; |
| 1024 | int owner_grouplen = 0; |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 1025 | __be32 *p; |
Trond Myklebust | d7067b2 | 2013-07-17 17:09:01 -0400 | [diff] [blame] | 1026 | unsigned i; |
| 1027 | uint32_t len = 0; |
| 1028 | uint32_t bmval_len; |
| 1029 | uint32_t bmval[3] = { 0 }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1030 | |
| 1031 | /* |
| 1032 | * We reserve enough space to write the entire attribute buffer at once. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1033 | */ |
Trond Myklebust | 28cf22d | 2017-05-06 12:19:11 -0400 | [diff] [blame] | 1034 | if ((iap->ia_valid & ATTR_SIZE) && (attrmask[0] & FATTR4_WORD0_SIZE)) { |
Trond Myklebust | d7067b2 | 2013-07-17 17:09:01 -0400 | [diff] [blame] | 1035 | bmval[0] |= FATTR4_WORD0_SIZE; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1036 | len += 8; |
Trond Myklebust | d7067b2 | 2013-07-17 17:09:01 -0400 | [diff] [blame] | 1037 | } |
| 1038 | if (iap->ia_valid & ATTR_MODE) { |
Trond Myklebust | 28cf22d | 2017-05-06 12:19:11 -0400 | [diff] [blame] | 1039 | if (umask && (attrmask[2] & FATTR4_WORD2_MODE_UMASK)) { |
Andreas Gruenbacher | dff25dd | 2016-12-02 22:53:30 -0500 | [diff] [blame] | 1040 | bmval[2] |= FATTR4_WORD2_MODE_UMASK; |
| 1041 | len += 8; |
Trond Myklebust | 28cf22d | 2017-05-06 12:19:11 -0400 | [diff] [blame] | 1042 | } else if (attrmask[1] & FATTR4_WORD1_MODE) { |
Andreas Gruenbacher | dff25dd | 2016-12-02 22:53:30 -0500 | [diff] [blame] | 1043 | bmval[1] |= FATTR4_WORD1_MODE; |
| 1044 | len += 4; |
| 1045 | } |
Trond Myklebust | d7067b2 | 2013-07-17 17:09:01 -0400 | [diff] [blame] | 1046 | } |
Trond Myklebust | 28cf22d | 2017-05-06 12:19:11 -0400 | [diff] [blame] | 1047 | if ((iap->ia_valid & ATTR_UID) && (attrmask[1] & FATTR4_WORD1_OWNER)) { |
Trond Myklebust | e4fd72a | 2011-02-22 15:44:31 -0800 | [diff] [blame] | 1048 | 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] | 1049 | if (owner_namelen < 0) { |
Chuck Lever | fe82a18 | 2007-09-11 18:01:10 -0400 | [diff] [blame] | 1050 | dprintk("nfs: couldn't resolve uid %d to string\n", |
Eric W. Biederman | e578207 | 2013-02-01 14:22:02 -0800 | [diff] [blame] | 1051 | from_kuid(&init_user_ns, iap->ia_uid)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1052 | /* XXX */ |
| 1053 | strcpy(owner_name, "nobody"); |
| 1054 | owner_namelen = sizeof("nobody") - 1; |
| 1055 | /* goto out; */ |
| 1056 | } |
Trond Myklebust | d7067b2 | 2013-07-17 17:09:01 -0400 | [diff] [blame] | 1057 | bmval[1] |= FATTR4_WORD1_OWNER; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1058 | len += 4 + (XDR_QUADLEN(owner_namelen) << 2); |
| 1059 | } |
Trond Myklebust | 28cf22d | 2017-05-06 12:19:11 -0400 | [diff] [blame] | 1060 | if ((iap->ia_valid & ATTR_GID) && |
| 1061 | (attrmask[1] & FATTR4_WORD1_OWNER_GROUP)) { |
Trond Myklebust | e4fd72a | 2011-02-22 15:44:31 -0800 | [diff] [blame] | 1062 | 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] | 1063 | if (owner_grouplen < 0) { |
Chuck Lever | fe82a18 | 2007-09-11 18:01:10 -0400 | [diff] [blame] | 1064 | dprintk("nfs: couldn't resolve gid %d to string\n", |
Eric W. Biederman | e578207 | 2013-02-01 14:22:02 -0800 | [diff] [blame] | 1065 | from_kgid(&init_user_ns, iap->ia_gid)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1066 | strcpy(owner_group, "nobody"); |
| 1067 | owner_grouplen = sizeof("nobody") - 1; |
| 1068 | /* goto out; */ |
| 1069 | } |
Trond Myklebust | d7067b2 | 2013-07-17 17:09:01 -0400 | [diff] [blame] | 1070 | bmval[1] |= FATTR4_WORD1_OWNER_GROUP; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1071 | len += 4 + (XDR_QUADLEN(owner_grouplen) << 2); |
| 1072 | } |
Trond Myklebust | 28cf22d | 2017-05-06 12:19:11 -0400 | [diff] [blame] | 1073 | if (attrmask[1] & FATTR4_WORD1_TIME_ACCESS_SET) { |
| 1074 | if (iap->ia_valid & ATTR_ATIME_SET) { |
| 1075 | bmval[1] |= FATTR4_WORD1_TIME_ACCESS_SET; |
| 1076 | len += 16; |
| 1077 | } else if (iap->ia_valid & ATTR_ATIME) { |
| 1078 | bmval[1] |= FATTR4_WORD1_TIME_ACCESS_SET; |
| 1079 | len += 4; |
| 1080 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1081 | } |
Trond Myklebust | 28cf22d | 2017-05-06 12:19:11 -0400 | [diff] [blame] | 1082 | if (attrmask[1] & FATTR4_WORD1_TIME_MODIFY_SET) { |
| 1083 | if (iap->ia_valid & ATTR_MTIME_SET) { |
| 1084 | bmval[1] |= FATTR4_WORD1_TIME_MODIFY_SET; |
| 1085 | len += 16; |
| 1086 | } else if (iap->ia_valid & ATTR_MTIME) { |
| 1087 | bmval[1] |= FATTR4_WORD1_TIME_MODIFY_SET; |
| 1088 | len += 4; |
| 1089 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1090 | } |
Kinglong Mee | 5334c5b | 2015-08-26 21:13:37 +0800 | [diff] [blame] | 1091 | |
Trond Myklebust | 28cf22d | 2017-05-06 12:19:11 -0400 | [diff] [blame] | 1092 | if (label && (attrmask[2] & FATTR4_WORD2_SECURITY_LABEL)) { |
Trond Myklebust | d7067b2 | 2013-07-17 17:09:01 -0400 | [diff] [blame] | 1093 | len += 4 + 4 + 4 + (XDR_QUADLEN(label->len) << 2); |
| 1094 | bmval[2] |= FATTR4_WORD2_SECURITY_LABEL; |
| 1095 | } |
| 1096 | |
| 1097 | if (bmval[2] != 0) |
| 1098 | bmval_len = 3; |
| 1099 | else if (bmval[1] != 0) |
| 1100 | bmval_len = 2; |
| 1101 | else |
| 1102 | bmval_len = 1; |
| 1103 | |
| 1104 | p = reserve_space(xdr, 4 + (bmval_len << 2) + 4 + len); |
| 1105 | |
| 1106 | *p++ = cpu_to_be32(bmval_len); |
| 1107 | for (i = 0; i < bmval_len; i++) |
| 1108 | *p++ = cpu_to_be32(bmval[i]); |
| 1109 | *p++ = cpu_to_be32(len); |
| 1110 | |
| 1111 | if (bmval[0] & FATTR4_WORD0_SIZE) |
| 1112 | p = xdr_encode_hyper(p, iap->ia_size); |
| 1113 | if (bmval[1] & FATTR4_WORD1_MODE) |
| 1114 | *p++ = cpu_to_be32(iap->ia_mode & S_IALLUGO); |
| 1115 | if (bmval[1] & FATTR4_WORD1_OWNER) |
| 1116 | p = xdr_encode_opaque(p, owner_name, owner_namelen); |
| 1117 | if (bmval[1] & FATTR4_WORD1_OWNER_GROUP) |
| 1118 | p = xdr_encode_opaque(p, owner_group, owner_grouplen); |
| 1119 | if (bmval[1] & FATTR4_WORD1_TIME_ACCESS_SET) { |
| 1120 | if (iap->ia_valid & ATTR_ATIME_SET) { |
| 1121 | *p++ = cpu_to_be32(NFS4_SET_TO_CLIENT_TIME); |
| 1122 | p = xdr_encode_hyper(p, (s64)iap->ia_atime.tv_sec); |
| 1123 | *p++ = cpu_to_be32(iap->ia_atime.tv_nsec); |
| 1124 | } else |
| 1125 | *p++ = cpu_to_be32(NFS4_SET_TO_SERVER_TIME); |
| 1126 | } |
| 1127 | if (bmval[1] & FATTR4_WORD1_TIME_MODIFY_SET) { |
| 1128 | if (iap->ia_valid & ATTR_MTIME_SET) { |
| 1129 | *p++ = cpu_to_be32(NFS4_SET_TO_CLIENT_TIME); |
| 1130 | p = xdr_encode_hyper(p, (s64)iap->ia_mtime.tv_sec); |
| 1131 | *p++ = cpu_to_be32(iap->ia_mtime.tv_nsec); |
| 1132 | } else |
| 1133 | *p++ = cpu_to_be32(NFS4_SET_TO_SERVER_TIME); |
| 1134 | } |
| 1135 | if (bmval[2] & FATTR4_WORD2_SECURITY_LABEL) { |
David Quigley | aa9c266 | 2013-05-22 12:50:44 -0400 | [diff] [blame] | 1136 | *p++ = cpu_to_be32(label->lfs); |
| 1137 | *p++ = cpu_to_be32(label->pi); |
| 1138 | *p++ = cpu_to_be32(label->len); |
| 1139 | p = xdr_encode_opaque_fixed(p, label->label, label->len); |
| 1140 | } |
Andreas Gruenbacher | dff25dd | 2016-12-02 22:53:30 -0500 | [diff] [blame] | 1141 | if (bmval[2] & FATTR4_WORD2_MODE_UMASK) { |
| 1142 | *p++ = cpu_to_be32(iap->ia_mode & S_IALLUGO); |
| 1143 | *p++ = cpu_to_be32(*umask); |
| 1144 | } |
Andy Adamson | 6c0195a | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 1145 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1146 | /* out: */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1147 | } |
| 1148 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1149 | 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] | 1150 | { |
Trond Myklebust | 475d4ba | 2012-03-05 11:27:16 -0500 | [diff] [blame] | 1151 | encode_op_hdr(xdr, OP_ACCESS, decode_access_maxsz, hdr); |
| 1152 | encode_uint32(xdr, access); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1153 | } |
| 1154 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1155 | 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] | 1156 | { |
Trond Myklebust | ab19b48 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1157 | encode_op_hdr(xdr, OP_CLOSE, decode_close_maxsz, hdr); |
Trond Myklebust | 4ade982 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1158 | encode_nfs4_seqid(xdr, arg->seqid); |
Trond Myklebust | 566fcec | 2015-01-23 15:32:46 -0500 | [diff] [blame] | 1159 | encode_nfs4_stateid(xdr, &arg->stateid); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1160 | } |
| 1161 | |
Fred Isaman | 0b7c015 | 2012-04-20 14:47:39 -0400 | [diff] [blame] | 1162 | 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] | 1163 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 1164 | __be32 *p; |
Andy Adamson | 6c0195a | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 1165 | |
Trond Myklebust | 475d4ba | 2012-03-05 11:27:16 -0500 | [diff] [blame] | 1166 | encode_op_hdr(xdr, OP_COMMIT, decode_commit_maxsz, hdr); |
| 1167 | p = reserve_space(xdr, 12); |
Benny Halevy | b95be5a | 2009-08-14 17:19:01 +0300 | [diff] [blame] | 1168 | p = xdr_encode_hyper(p, args->offset); |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1169 | *p = cpu_to_be32(args->count); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1170 | } |
| 1171 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1172 | 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] | 1173 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 1174 | __be32 *p; |
Andy Adamson | 6c0195a | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 1175 | |
Trond Myklebust | 475d4ba | 2012-03-05 11:27:16 -0500 | [diff] [blame] | 1176 | encode_op_hdr(xdr, OP_CREATE, decode_create_maxsz, hdr); |
| 1177 | encode_uint32(xdr, create->ftype); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1178 | |
| 1179 | switch (create->ftype) { |
| 1180 | case NF4LNK: |
Benny Halevy | 13c65ce | 2009-08-14 17:19:25 +0300 | [diff] [blame] | 1181 | p = reserve_space(xdr, 4); |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1182 | *p = cpu_to_be32(create->u.symlink.len); |
Chuck Lever | 2fcc213 | 2015-08-03 13:04:26 -0400 | [diff] [blame] | 1183 | xdr_write_pages(xdr, create->u.symlink.pages, 0, |
| 1184 | create->u.symlink.len); |
| 1185 | xdr->buf->flags |= XDRBUF_WRITE; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1186 | break; |
| 1187 | |
| 1188 | case NF4BLK: case NF4CHR: |
Benny Halevy | 13c65ce | 2009-08-14 17:19:25 +0300 | [diff] [blame] | 1189 | p = reserve_space(xdr, 8); |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1190 | *p++ = cpu_to_be32(create->u.device.specdata1); |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1191 | *p = cpu_to_be32(create->u.device.specdata2); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1192 | break; |
| 1193 | |
| 1194 | default: |
| 1195 | break; |
| 1196 | } |
| 1197 | |
Benny Halevy | 811652b | 2009-08-14 17:19:34 +0300 | [diff] [blame] | 1198 | encode_string(xdr, create->name->len, create->name->name); |
Trond Myklebust | 28cf22d | 2017-05-06 12:19:11 -0400 | [diff] [blame] | 1199 | encode_attrs(xdr, create->attrs, create->label, &create->umask, |
| 1200 | create->server, create->server->attr_bitmask); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1201 | } |
| 1202 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1203 | static void encode_getattr_one(struct xdr_stream *xdr, uint32_t bitmap, struct compound_hdr *hdr) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1204 | { |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 1205 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1206 | |
Trond Myklebust | 475d4ba | 2012-03-05 11:27:16 -0500 | [diff] [blame] | 1207 | encode_op_hdr(xdr, OP_GETATTR, decode_getattr_maxsz, hdr); |
| 1208 | p = reserve_space(xdr, 8); |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1209 | *p++ = cpu_to_be32(1); |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1210 | *p = cpu_to_be32(bitmap); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1211 | } |
| 1212 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1213 | static void encode_getattr_two(struct xdr_stream *xdr, uint32_t bm0, uint32_t bm1, struct compound_hdr *hdr) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1214 | { |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 1215 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1216 | |
Trond Myklebust | 475d4ba | 2012-03-05 11:27:16 -0500 | [diff] [blame] | 1217 | encode_op_hdr(xdr, OP_GETATTR, decode_getattr_maxsz, hdr); |
| 1218 | p = reserve_space(xdr, 12); |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1219 | *p++ = cpu_to_be32(2); |
| 1220 | *p++ = cpu_to_be32(bm0); |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1221 | *p = cpu_to_be32(bm1); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1222 | } |
| 1223 | |
Fred Isaman | dae100c | 2011-07-30 20:52:37 -0400 | [diff] [blame] | 1224 | static void |
| 1225 | encode_getattr_three(struct xdr_stream *xdr, |
| 1226 | uint32_t bm0, uint32_t bm1, uint32_t bm2, |
| 1227 | struct compound_hdr *hdr) |
| 1228 | { |
| 1229 | __be32 *p; |
| 1230 | |
Trond Myklebust | ab19b48 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1231 | encode_op_hdr(xdr, OP_GETATTR, decode_getattr_maxsz, hdr); |
Fred Isaman | dae100c | 2011-07-30 20:52:37 -0400 | [diff] [blame] | 1232 | if (bm2) { |
| 1233 | p = reserve_space(xdr, 16); |
| 1234 | *p++ = cpu_to_be32(3); |
| 1235 | *p++ = cpu_to_be32(bm0); |
| 1236 | *p++ = cpu_to_be32(bm1); |
| 1237 | *p = cpu_to_be32(bm2); |
| 1238 | } else if (bm1) { |
| 1239 | p = reserve_space(xdr, 12); |
| 1240 | *p++ = cpu_to_be32(2); |
| 1241 | *p++ = cpu_to_be32(bm0); |
| 1242 | *p = cpu_to_be32(bm1); |
| 1243 | } else { |
| 1244 | p = reserve_space(xdr, 8); |
| 1245 | *p++ = cpu_to_be32(1); |
| 1246 | *p = cpu_to_be32(bm0); |
| 1247 | } |
Fred Isaman | dae100c | 2011-07-30 20:52:37 -0400 | [diff] [blame] | 1248 | } |
| 1249 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1250 | 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] | 1251 | { |
David Quigley | a09df2c | 2013-05-22 12:50:41 -0400 | [diff] [blame] | 1252 | encode_getattr_three(xdr, bitmask[0] & nfs4_fattr_bitmap[0], |
| 1253 | bitmask[1] & nfs4_fattr_bitmap[1], |
| 1254 | bitmask[2] & nfs4_fattr_bitmap[2], |
| 1255 | hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1256 | } |
| 1257 | |
Andy Adamson | 88034c3 | 2012-05-23 05:02:34 -0400 | [diff] [blame] | 1258 | static void encode_getfattr_open(struct xdr_stream *xdr, const u32 *bitmask, |
Trond Myklebust | 1549210f | 2012-06-05 09:16:47 -0400 | [diff] [blame] | 1259 | const u32 *open_bitmap, |
Andy Adamson | 88034c3 | 2012-05-23 05:02:34 -0400 | [diff] [blame] | 1260 | struct compound_hdr *hdr) |
| 1261 | { |
| 1262 | encode_getattr_three(xdr, |
Trond Myklebust | 1549210f | 2012-06-05 09:16:47 -0400 | [diff] [blame] | 1263 | bitmask[0] & open_bitmap[0], |
| 1264 | bitmask[1] & open_bitmap[1], |
| 1265 | bitmask[2] & open_bitmap[2], |
Andy Adamson | 88034c3 | 2012-05-23 05:02:34 -0400 | [diff] [blame] | 1266 | hdr); |
| 1267 | } |
| 1268 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1269 | 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] | 1270 | { |
Fred Isaman | dae100c | 2011-07-30 20:52:37 -0400 | [diff] [blame] | 1271 | encode_getattr_three(xdr, |
| 1272 | bitmask[0] & nfs4_fsinfo_bitmap[0], |
| 1273 | bitmask[1] & nfs4_fsinfo_bitmap[1], |
| 1274 | bitmask[2] & nfs4_fsinfo_bitmap[2], |
| 1275 | hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1276 | } |
| 1277 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1278 | 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] | 1279 | { |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1280 | encode_getattr_two(xdr, bitmask[0] & nfs4_fs_locations_bitmap[0], |
| 1281 | bitmask[1] & nfs4_fs_locations_bitmap[1], hdr); |
Manoj Naik | 830b8e3 | 2006-06-09 09:34:25 -0400 | [diff] [blame] | 1282 | } |
| 1283 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1284 | static void encode_getfh(struct xdr_stream *xdr, struct compound_hdr *hdr) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1285 | { |
Trond Myklebust | ab19b48 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1286 | encode_op_hdr(xdr, OP_GETFH, decode_getfh_maxsz, 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_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] | 1290 | { |
Trond Myklebust | ab19b48 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1291 | encode_op_hdr(xdr, OP_LINK, decode_link_maxsz, hdr); |
Trond Myklebust | 6fdfb0bc | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1292 | encode_string(xdr, name->len, name->name); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1293 | } |
| 1294 | |
Trond Myklebust | 911d1aa | 2006-01-03 09:55:16 +0100 | [diff] [blame] | 1295 | static inline int nfs4_lock_type(struct file_lock *fl, int block) |
| 1296 | { |
Jeff Layton | f44106e | 2012-07-23 15:49:56 -0400 | [diff] [blame] | 1297 | if (fl->fl_type == F_RDLCK) |
Trond Myklebust | 911d1aa | 2006-01-03 09:55:16 +0100 | [diff] [blame] | 1298 | return block ? NFS4_READW_LT : NFS4_READ_LT; |
| 1299 | return block ? NFS4_WRITEW_LT : NFS4_WRITE_LT; |
| 1300 | } |
| 1301 | |
| 1302 | static inline uint64_t nfs4_lock_length(struct file_lock *fl) |
| 1303 | { |
| 1304 | if (fl->fl_end == OFFSET_MAX) |
| 1305 | return ~(uint64_t)0; |
| 1306 | return fl->fl_end - fl->fl_start + 1; |
| 1307 | } |
| 1308 | |
Trond Myklebust | daccbde | 2010-06-25 18:11:43 -0400 | [diff] [blame] | 1309 | static void encode_lockowner(struct xdr_stream *xdr, const struct nfs_lowner *lowner) |
| 1310 | { |
| 1311 | __be32 *p; |
| 1312 | |
Trond Myklebust | d035c36 | 2010-12-21 10:45:27 -0500 | [diff] [blame] | 1313 | p = reserve_space(xdr, 32); |
Trond Myklebust | daccbde | 2010-06-25 18:11:43 -0400 | [diff] [blame] | 1314 | p = xdr_encode_hyper(p, lowner->clientid); |
Trond Myklebust | d035c36 | 2010-12-21 10:45:27 -0500 | [diff] [blame] | 1315 | *p++ = cpu_to_be32(20); |
Trond Myklebust | daccbde | 2010-06-25 18:11:43 -0400 | [diff] [blame] | 1316 | p = xdr_encode_opaque_fixed(p, "lock id:", 8); |
Trond Myklebust | d035c36 | 2010-12-21 10:45:27 -0500 | [diff] [blame] | 1317 | *p++ = cpu_to_be32(lowner->s_dev); |
Trond Myklebust | daccbde | 2010-06-25 18:11:43 -0400 | [diff] [blame] | 1318 | xdr_encode_hyper(p, lowner->id); |
| 1319 | } |
| 1320 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1321 | /* |
| 1322 | * opcode,type,reclaim,offset,length,new_lock_owner = 32 |
| 1323 | * open_seqid,open_stateid,lock_seqid,lock_owner.clientid, lock_owner.id = 40 |
| 1324 | */ |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1325 | 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] | 1326 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 1327 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1328 | |
Trond Myklebust | 475d4ba | 2012-03-05 11:27:16 -0500 | [diff] [blame] | 1329 | encode_op_hdr(xdr, OP_LOCK, decode_lock_maxsz, hdr); |
| 1330 | p = reserve_space(xdr, 28); |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1331 | *p++ = cpu_to_be32(nfs4_lock_type(args->fl, args->block)); |
| 1332 | *p++ = cpu_to_be32(args->reclaim); |
Benny Halevy | b95be5a | 2009-08-14 17:19:01 +0300 | [diff] [blame] | 1333 | p = xdr_encode_hyper(p, args->fl->fl_start); |
| 1334 | p = xdr_encode_hyper(p, nfs4_lock_length(args->fl)); |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1335 | *p = cpu_to_be32(args->new_lock_owner); |
Trond Myklebust | 911d1aa | 2006-01-03 09:55:16 +0100 | [diff] [blame] | 1336 | if (args->new_lock_owner){ |
Trond Myklebust | 4ade982 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1337 | encode_nfs4_seqid(xdr, args->open_seqid); |
Trond Myklebust | 425c1d4 | 2015-01-24 14:57:53 -0500 | [diff] [blame] | 1338 | encode_nfs4_stateid(xdr, &args->open_stateid); |
Trond Myklebust | 4ade982 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1339 | encode_nfs4_seqid(xdr, args->lock_seqid); |
Trond Myklebust | daccbde | 2010-06-25 18:11:43 -0400 | [diff] [blame] | 1340 | encode_lockowner(xdr, &args->lock_owner); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1341 | } |
| 1342 | else { |
Trond Myklebust | 425c1d4 | 2015-01-24 14:57:53 -0500 | [diff] [blame] | 1343 | encode_nfs4_stateid(xdr, &args->lock_stateid); |
Trond Myklebust | 4ade982 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1344 | encode_nfs4_seqid(xdr, args->lock_seqid); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1345 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1346 | } |
| 1347 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1348 | 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] | 1349 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 1350 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1351 | |
Trond Myklebust | 475d4ba | 2012-03-05 11:27:16 -0500 | [diff] [blame] | 1352 | encode_op_hdr(xdr, OP_LOCKT, decode_lockt_maxsz, hdr); |
| 1353 | p = reserve_space(xdr, 20); |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1354 | *p++ = cpu_to_be32(nfs4_lock_type(args->fl, 0)); |
Benny Halevy | b95be5a | 2009-08-14 17:19:01 +0300 | [diff] [blame] | 1355 | p = xdr_encode_hyper(p, args->fl->fl_start); |
| 1356 | p = xdr_encode_hyper(p, nfs4_lock_length(args->fl)); |
Trond Myklebust | daccbde | 2010-06-25 18:11:43 -0400 | [diff] [blame] | 1357 | encode_lockowner(xdr, &args->lock_owner); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1358 | } |
| 1359 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1360 | 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] | 1361 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 1362 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1363 | |
Trond Myklebust | 475d4ba | 2012-03-05 11:27:16 -0500 | [diff] [blame] | 1364 | encode_op_hdr(xdr, OP_LOCKU, decode_locku_maxsz, hdr); |
| 1365 | encode_uint32(xdr, nfs4_lock_type(args->fl, 0)); |
Trond Myklebust | 4ade982 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1366 | encode_nfs4_seqid(xdr, args->seqid); |
Trond Myklebust | 425c1d4 | 2015-01-24 14:57:53 -0500 | [diff] [blame] | 1367 | encode_nfs4_stateid(xdr, &args->stateid); |
Trond Myklebust | ea9d23f | 2012-03-04 18:13:56 -0500 | [diff] [blame] | 1368 | p = reserve_space(xdr, 16); |
Benny Halevy | b95be5a | 2009-08-14 17:19:01 +0300 | [diff] [blame] | 1369 | p = xdr_encode_hyper(p, args->fl->fl_start); |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1370 | xdr_encode_hyper(p, nfs4_lock_length(args->fl)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1371 | } |
| 1372 | |
Trond Myklebust | d3c7b7c | 2010-07-01 12:49:01 -0400 | [diff] [blame] | 1373 | static void encode_release_lockowner(struct xdr_stream *xdr, const struct nfs_lowner *lowner, struct compound_hdr *hdr) |
| 1374 | { |
Trond Myklebust | ab19b48 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1375 | encode_op_hdr(xdr, OP_RELEASE_LOCKOWNER, decode_release_lockowner_maxsz, hdr); |
Trond Myklebust | d3c7b7c | 2010-07-01 12:49:01 -0400 | [diff] [blame] | 1376 | encode_lockowner(xdr, lowner); |
Trond Myklebust | d3c7b7c | 2010-07-01 12:49:01 -0400 | [diff] [blame] | 1377 | } |
| 1378 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1379 | 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] | 1380 | { |
Trond Myklebust | ab19b48 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1381 | encode_op_hdr(xdr, OP_LOOKUP, decode_lookup_maxsz, hdr); |
Trond Myklebust | 6fdfb0bc | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1382 | encode_string(xdr, name->len, name->name); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1383 | } |
| 1384 | |
Jeff Layton | 5b5faaf | 2017-06-29 06:34:52 -0700 | [diff] [blame] | 1385 | static void encode_lookupp(struct xdr_stream *xdr, struct compound_hdr *hdr) |
| 1386 | { |
| 1387 | encode_op_hdr(xdr, OP_LOOKUPP, decode_lookupp_maxsz, hdr); |
| 1388 | } |
| 1389 | |
Trond Myklebust | 6ae3733 | 2015-01-30 14:21:14 -0500 | [diff] [blame] | 1390 | static void encode_share_access(struct xdr_stream *xdr, u32 share_access) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1391 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 1392 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1393 | |
Benny Halevy | 13c65ce | 2009-08-14 17:19:25 +0300 | [diff] [blame] | 1394 | p = reserve_space(xdr, 8); |
Trond Myklebust | 6ae3733 | 2015-01-30 14:21:14 -0500 | [diff] [blame] | 1395 | *p++ = cpu_to_be32(share_access); |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1396 | *p = cpu_to_be32(0); /* for linux, share_deny = 0 always */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1397 | } |
| 1398 | |
| 1399 | static inline void encode_openhdr(struct xdr_stream *xdr, const struct nfs_openargs *arg) |
| 1400 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 1401 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1402 | /* |
| 1403 | * opcode 4, seqid 4, share_access 4, share_deny 4, clientid 8, ownerlen 4, |
| 1404 | * owner 4 = 32 |
| 1405 | */ |
Trond Myklebust | 4ade982 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1406 | encode_nfs4_seqid(xdr, arg->seqid); |
Trond Myklebust | 6ae3733 | 2015-01-30 14:21:14 -0500 | [diff] [blame] | 1407 | encode_share_access(xdr, arg->share_access); |
Trond Myklebust | 95b72eb | 2012-04-20 19:24:51 -0400 | [diff] [blame] | 1408 | p = reserve_space(xdr, 36); |
Benny Halevy | b95be5a | 2009-08-14 17:19:01 +0300 | [diff] [blame] | 1409 | p = xdr_encode_hyper(p, arg->clientid); |
Trond Myklebust | 95b72eb | 2012-04-20 19:24:51 -0400 | [diff] [blame] | 1410 | *p++ = cpu_to_be32(24); |
Benny Halevy | 93f0cf2 | 2009-08-14 17:19:06 +0300 | [diff] [blame] | 1411 | p = xdr_encode_opaque_fixed(p, "open id:", 8); |
Trond Myklebust | d035c36 | 2010-12-21 10:45:27 -0500 | [diff] [blame] | 1412 | *p++ = cpu_to_be32(arg->server->s_dev); |
Trond Myklebust | 95b72eb | 2012-04-20 19:24:51 -0400 | [diff] [blame] | 1413 | *p++ = cpu_to_be32(arg->id.uniquifier); |
| 1414 | xdr_encode_hyper(p, arg->id.create_time); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1415 | } |
| 1416 | |
| 1417 | static inline void encode_createmode(struct xdr_stream *xdr, const struct nfs_openargs *arg) |
| 1418 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 1419 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1420 | |
Benny Halevy | 13c65ce | 2009-08-14 17:19:25 +0300 | [diff] [blame] | 1421 | p = reserve_space(xdr, 4); |
Trond Myklebust | 549b19c | 2013-04-16 18:42:34 -0400 | [diff] [blame] | 1422 | switch(arg->createmode) { |
| 1423 | case NFS4_CREATE_UNCHECKED: |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1424 | *p = cpu_to_be32(NFS4_CREATE_UNCHECKED); |
Trond Myklebust | 28cf22d | 2017-05-06 12:19:11 -0400 | [diff] [blame] | 1425 | encode_attrs(xdr, arg->u.attrs, arg->label, &arg->umask, |
| 1426 | arg->server, arg->server->attr_bitmask); |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 1427 | break; |
Trond Myklebust | 549b19c | 2013-04-16 18:42:34 -0400 | [diff] [blame] | 1428 | case NFS4_CREATE_GUARDED: |
| 1429 | *p = cpu_to_be32(NFS4_CREATE_GUARDED); |
Trond Myklebust | 28cf22d | 2017-05-06 12:19:11 -0400 | [diff] [blame] | 1430 | encode_attrs(xdr, arg->u.attrs, arg->label, &arg->umask, |
| 1431 | arg->server, arg->server->attr_bitmask); |
Trond Myklebust | 549b19c | 2013-04-16 18:42:34 -0400 | [diff] [blame] | 1432 | break; |
| 1433 | case NFS4_CREATE_EXCLUSIVE: |
| 1434 | *p = cpu_to_be32(NFS4_CREATE_EXCLUSIVE); |
| 1435 | encode_nfs4_verifier(xdr, &arg->u.verifier); |
| 1436 | break; |
| 1437 | case NFS4_CREATE_EXCLUSIVE4_1: |
| 1438 | *p = cpu_to_be32(NFS4_CREATE_EXCLUSIVE4_1); |
| 1439 | encode_nfs4_verifier(xdr, &arg->u.verifier); |
Trond Myklebust | 28cf22d | 2017-05-06 12:19:11 -0400 | [diff] [blame] | 1440 | encode_attrs(xdr, arg->u.attrs, arg->label, &arg->umask, |
| 1441 | arg->server, arg->server->exclcreat_bitmask); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1442 | } |
| 1443 | } |
| 1444 | |
| 1445 | static void encode_opentype(struct xdr_stream *xdr, const struct nfs_openargs *arg) |
| 1446 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 1447 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1448 | |
Benny Halevy | 13c65ce | 2009-08-14 17:19:25 +0300 | [diff] [blame] | 1449 | p = reserve_space(xdr, 4); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1450 | switch (arg->open_flags & O_CREAT) { |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 1451 | case 0: |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1452 | *p = cpu_to_be32(NFS4_OPEN_NOCREATE); |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 1453 | break; |
| 1454 | default: |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1455 | *p = cpu_to_be32(NFS4_OPEN_CREATE); |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 1456 | encode_createmode(xdr, arg); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1457 | } |
| 1458 | } |
| 1459 | |
Trond Myklebust | bd7bf9d | 2008-12-23 15:21:53 -0500 | [diff] [blame] | 1460 | 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] | 1461 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 1462 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1463 | |
Benny Halevy | 13c65ce | 2009-08-14 17:19:25 +0300 | [diff] [blame] | 1464 | p = reserve_space(xdr, 4); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1465 | switch (delegation_type) { |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 1466 | case 0: |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1467 | *p = cpu_to_be32(NFS4_OPEN_DELEGATE_NONE); |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 1468 | break; |
| 1469 | case FMODE_READ: |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1470 | *p = cpu_to_be32(NFS4_OPEN_DELEGATE_READ); |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 1471 | break; |
| 1472 | case FMODE_WRITE|FMODE_READ: |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1473 | *p = cpu_to_be32(NFS4_OPEN_DELEGATE_WRITE); |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 1474 | break; |
| 1475 | default: |
| 1476 | BUG(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1477 | } |
| 1478 | } |
| 1479 | |
| 1480 | static inline void encode_claim_null(struct xdr_stream *xdr, const struct qstr *name) |
| 1481 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 1482 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1483 | |
Benny Halevy | 13c65ce | 2009-08-14 17:19:25 +0300 | [diff] [blame] | 1484 | p = reserve_space(xdr, 4); |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1485 | *p = cpu_to_be32(NFS4_OPEN_CLAIM_NULL); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1486 | encode_string(xdr, name->len, name->name); |
| 1487 | } |
| 1488 | |
Trond Myklebust | bd7bf9d | 2008-12-23 15:21:53 -0500 | [diff] [blame] | 1489 | 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] | 1490 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 1491 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1492 | |
Benny Halevy | 13c65ce | 2009-08-14 17:19:25 +0300 | [diff] [blame] | 1493 | p = reserve_space(xdr, 4); |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1494 | *p = cpu_to_be32(NFS4_OPEN_CLAIM_PREVIOUS); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1495 | encode_delegation_type(xdr, type); |
| 1496 | } |
| 1497 | |
| 1498 | static inline void encode_claim_delegate_cur(struct xdr_stream *xdr, const struct qstr *name, const nfs4_stateid *stateid) |
| 1499 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 1500 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1501 | |
Trond Myklebust | ea9d23f | 2012-03-04 18:13:56 -0500 | [diff] [blame] | 1502 | p = reserve_space(xdr, 4); |
| 1503 | *p = cpu_to_be32(NFS4_OPEN_CLAIM_DELEGATE_CUR); |
| 1504 | encode_nfs4_stateid(xdr, stateid); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1505 | encode_string(xdr, name->len, name->name); |
| 1506 | } |
| 1507 | |
Trond Myklebust | d9fc661 | 2013-03-15 15:39:06 -0400 | [diff] [blame] | 1508 | static inline void encode_claim_fh(struct xdr_stream *xdr) |
| 1509 | { |
| 1510 | __be32 *p; |
| 1511 | |
| 1512 | p = reserve_space(xdr, 4); |
| 1513 | *p = cpu_to_be32(NFS4_OPEN_CLAIM_FH); |
| 1514 | } |
| 1515 | |
| 1516 | static inline void encode_claim_delegate_cur_fh(struct xdr_stream *xdr, const nfs4_stateid *stateid) |
| 1517 | { |
| 1518 | __be32 *p; |
| 1519 | |
| 1520 | p = reserve_space(xdr, 4); |
| 1521 | *p = cpu_to_be32(NFS4_OPEN_CLAIM_DELEG_CUR_FH); |
| 1522 | encode_nfs4_stateid(xdr, stateid); |
| 1523 | } |
| 1524 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1525 | 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] | 1526 | { |
Trond Myklebust | ab19b48 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1527 | encode_op_hdr(xdr, OP_OPEN, decode_open_maxsz, hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1528 | encode_openhdr(xdr, arg); |
| 1529 | encode_opentype(xdr, arg); |
| 1530 | switch (arg->claim) { |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 1531 | case NFS4_OPEN_CLAIM_NULL: |
| 1532 | encode_claim_null(xdr, arg->name); |
| 1533 | break; |
| 1534 | case NFS4_OPEN_CLAIM_PREVIOUS: |
| 1535 | encode_claim_previous(xdr, arg->u.delegation_type); |
| 1536 | break; |
| 1537 | case NFS4_OPEN_CLAIM_DELEGATE_CUR: |
| 1538 | encode_claim_delegate_cur(xdr, arg->name, &arg->u.delegation); |
| 1539 | break; |
Trond Myklebust | d9fc661 | 2013-03-15 15:39:06 -0400 | [diff] [blame] | 1540 | case NFS4_OPEN_CLAIM_FH: |
| 1541 | encode_claim_fh(xdr); |
| 1542 | break; |
| 1543 | case NFS4_OPEN_CLAIM_DELEG_CUR_FH: |
| 1544 | encode_claim_delegate_cur_fh(xdr, &arg->u.delegation); |
| 1545 | break; |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 1546 | default: |
| 1547 | BUG(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1548 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1549 | } |
| 1550 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1551 | 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] | 1552 | { |
Trond Myklebust | ab19b48 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1553 | encode_op_hdr(xdr, OP_OPEN_CONFIRM, decode_open_confirm_maxsz, hdr); |
Trond Myklebust | ea9d23f | 2012-03-04 18:13:56 -0500 | [diff] [blame] | 1554 | encode_nfs4_stateid(xdr, arg->stateid); |
Trond Myklebust | 4ade982 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1555 | encode_nfs4_seqid(xdr, arg->seqid); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1556 | } |
| 1557 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1558 | 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] | 1559 | { |
Trond Myklebust | ab19b48 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1560 | encode_op_hdr(xdr, OP_OPEN_DOWNGRADE, decode_open_downgrade_maxsz, hdr); |
Trond Myklebust | 566fcec | 2015-01-23 15:32:46 -0500 | [diff] [blame] | 1561 | encode_nfs4_stateid(xdr, &arg->stateid); |
Trond Myklebust | 4ade982 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1562 | encode_nfs4_seqid(xdr, arg->seqid); |
Trond Myklebust | 6ae3733 | 2015-01-30 14:21:14 -0500 | [diff] [blame] | 1563 | encode_share_access(xdr, arg->share_access); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1564 | } |
| 1565 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1566 | static void |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 1567 | 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] | 1568 | { |
Trond Myklebust | ab19b48 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1569 | encode_op_hdr(xdr, OP_PUTFH, decode_putfh_maxsz, hdr); |
Trond Myklebust | 6fdfb0bc | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1570 | encode_string(xdr, fh->size, fh->data); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1571 | } |
| 1572 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1573 | static void encode_putrootfh(struct xdr_stream *xdr, struct compound_hdr *hdr) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1574 | { |
Trond Myklebust | ab19b48 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1575 | encode_op_hdr(xdr, OP_PUTROOTFH, decode_putrootfh_maxsz, hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1576 | } |
| 1577 | |
Anna Schumaker | 3c6b899 | 2014-05-06 09:12:24 -0400 | [diff] [blame] | 1578 | static void encode_read(struct xdr_stream *xdr, const struct nfs_pgio_args *args, |
| 1579 | struct compound_hdr *hdr) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1580 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 1581 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1582 | |
Trond Myklebust | ab19b48 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1583 | encode_op_hdr(xdr, OP_READ, decode_read_maxsz, hdr); |
Trond Myklebust | 9b20614 | 2013-03-17 15:52:00 -0400 | [diff] [blame] | 1584 | encode_nfs4_stateid(xdr, &args->stateid); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1585 | |
Benny Halevy | 13c65ce | 2009-08-14 17:19:25 +0300 | [diff] [blame] | 1586 | p = reserve_space(xdr, 12); |
Benny Halevy | b95be5a | 2009-08-14 17:19:01 +0300 | [diff] [blame] | 1587 | p = xdr_encode_hyper(p, args->offset); |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1588 | *p = cpu_to_be32(args->count); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1589 | } |
| 1590 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1591 | 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] | 1592 | { |
David Quigley | aa9c266 | 2013-05-22 12:50:44 -0400 | [diff] [blame] | 1593 | uint32_t attrs[3] = { |
Trond Myklebust | 28331a4 | 2011-04-27 13:47:52 -0400 | [diff] [blame] | 1594 | FATTR4_WORD0_RDATTR_ERROR, |
| 1595 | FATTR4_WORD1_MOUNTED_ON_FILEID, |
| 1596 | }; |
Trond Myklebust | 6f7a35b | 2010-10-24 12:11:42 -0400 | [diff] [blame] | 1597 | uint32_t dircount = readdir->count >> 1; |
Chuck Lever | cd93710 | 2012-03-02 17:14:31 -0500 | [diff] [blame] | 1598 | __be32 *p, verf[2]; |
Trond Myklebust | d204c5d | 2013-11-04 13:23:59 -0500 | [diff] [blame] | 1599 | uint32_t attrlen = 0; |
| 1600 | unsigned int i; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1601 | |
Bryan Schumaker | 82f2e54 | 2010-10-21 16:33:18 -0400 | [diff] [blame] | 1602 | if (readdir->plus) { |
| 1603 | attrs[0] |= FATTR4_WORD0_TYPE|FATTR4_WORD0_CHANGE|FATTR4_WORD0_SIZE| |
Trond Myklebust | 28331a4 | 2011-04-27 13:47:52 -0400 | [diff] [blame] | 1604 | FATTR4_WORD0_FSID|FATTR4_WORD0_FILEHANDLE|FATTR4_WORD0_FILEID; |
Bryan Schumaker | 82f2e54 | 2010-10-21 16:33:18 -0400 | [diff] [blame] | 1605 | attrs[1] |= FATTR4_WORD1_MODE|FATTR4_WORD1_NUMLINKS|FATTR4_WORD1_OWNER| |
| 1606 | FATTR4_WORD1_OWNER_GROUP|FATTR4_WORD1_RAWDEV| |
| 1607 | FATTR4_WORD1_SPACE_USED|FATTR4_WORD1_TIME_ACCESS| |
| 1608 | FATTR4_WORD1_TIME_METADATA|FATTR4_WORD1_TIME_MODIFY; |
Trond Myklebust | d204c5d | 2013-11-04 13:23:59 -0500 | [diff] [blame] | 1609 | attrs[2] |= FATTR4_WORD2_SECURITY_LABEL; |
Trond Myklebust | 6f7a35b | 2010-10-24 12:11:42 -0400 | [diff] [blame] | 1610 | dircount >>= 1; |
Bryan Schumaker | 82f2e54 | 2010-10-21 16:33:18 -0400 | [diff] [blame] | 1611 | } |
Trond Myklebust | 28331a4 | 2011-04-27 13:47:52 -0400 | [diff] [blame] | 1612 | /* Use mounted_on_fileid only if the server supports it */ |
| 1613 | if (!(readdir->bitmask[1] & FATTR4_WORD1_MOUNTED_ON_FILEID)) |
| 1614 | attrs[0] |= FATTR4_WORD0_FILEID; |
Trond Myklebust | d204c5d | 2013-11-04 13:23:59 -0500 | [diff] [blame] | 1615 | for (i = 0; i < ARRAY_SIZE(attrs); i++) { |
| 1616 | attrs[i] &= readdir->bitmask[i]; |
| 1617 | if (attrs[i] != 0) |
| 1618 | attrlen = i+1; |
| 1619 | } |
Bryan Schumaker | 82f2e54 | 2010-10-21 16:33:18 -0400 | [diff] [blame] | 1620 | |
Trond Myklebust | 475d4ba | 2012-03-05 11:27:16 -0500 | [diff] [blame] | 1621 | encode_op_hdr(xdr, OP_READDIR, decode_readdir_maxsz, hdr); |
Trond Myklebust | ff2eb68 | 2012-03-05 11:40:12 -0500 | [diff] [blame] | 1622 | encode_uint64(xdr, readdir->cookie); |
Chuck Lever | cd93710 | 2012-03-02 17:14:31 -0500 | [diff] [blame] | 1623 | encode_nfs4_verifier(xdr, &readdir->verifier); |
Trond Myklebust | d204c5d | 2013-11-04 13:23:59 -0500 | [diff] [blame] | 1624 | p = reserve_space(xdr, 12 + (attrlen << 2)); |
Trond Myklebust | 6f7a35b | 2010-10-24 12:11:42 -0400 | [diff] [blame] | 1625 | *p++ = cpu_to_be32(dircount); |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1626 | *p++ = cpu_to_be32(readdir->count); |
Trond Myklebust | d204c5d | 2013-11-04 13:23:59 -0500 | [diff] [blame] | 1627 | *p++ = cpu_to_be32(attrlen); |
| 1628 | for (i = 0; i < attrlen; i++) |
| 1629 | *p++ = cpu_to_be32(attrs[i]); |
Chuck Lever | cd93710 | 2012-03-02 17:14:31 -0500 | [diff] [blame] | 1630 | memcpy(verf, readdir->verifier.data, sizeof(verf)); |
David Quigley | aa9c266 | 2013-05-22 12:50:44 -0400 | [diff] [blame] | 1631 | |
| 1632 | dprintk("%s: cookie = %llu, verifier = %08x:%08x, bitmap = %08x:%08x:%08x\n", |
Fred Isaman | 4410924 | 2008-04-02 15:21:15 +0300 | [diff] [blame] | 1633 | __func__, |
Trond Myklebust | eadf459 | 2005-06-22 17:16:39 +0000 | [diff] [blame] | 1634 | (unsigned long long)readdir->cookie, |
Chuck Lever | cd93710 | 2012-03-02 17:14:31 -0500 | [diff] [blame] | 1635 | verf[0], verf[1], |
Trond Myklebust | eadf459 | 2005-06-22 17:16:39 +0000 | [diff] [blame] | 1636 | attrs[0] & readdir->bitmask[0], |
David Quigley | aa9c266 | 2013-05-22 12:50:44 -0400 | [diff] [blame] | 1637 | attrs[1] & readdir->bitmask[1], |
| 1638 | attrs[2] & readdir->bitmask[2]); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1639 | } |
| 1640 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1641 | 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] | 1642 | { |
Trond Myklebust | ab19b48 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1643 | encode_op_hdr(xdr, OP_READLINK, decode_readlink_maxsz, hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1644 | } |
| 1645 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1646 | 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] | 1647 | { |
Trond Myklebust | ab19b48 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1648 | encode_op_hdr(xdr, OP_REMOVE, decode_remove_maxsz, hdr); |
Trond Myklebust | 6fdfb0bc | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1649 | encode_string(xdr, name->len, name->name); |
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_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] | 1653 | { |
Trond Myklebust | ab19b48 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1654 | encode_op_hdr(xdr, OP_RENAME, decode_rename_maxsz, hdr); |
Benny Halevy | 811652b | 2009-08-14 17:19:34 +0300 | [diff] [blame] | 1655 | encode_string(xdr, oldname->len, oldname->name); |
| 1656 | encode_string(xdr, newname->len, newname->name); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1657 | } |
| 1658 | |
Chuck Lever | bb4dae5 | 2012-03-01 17:01:48 -0500 | [diff] [blame] | 1659 | static void encode_renew(struct xdr_stream *xdr, clientid4 clid, |
| 1660 | struct compound_hdr *hdr) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1661 | { |
Trond Myklebust | 475d4ba | 2012-03-05 11:27:16 -0500 | [diff] [blame] | 1662 | encode_op_hdr(xdr, OP_RENEW, decode_renew_maxsz, hdr); |
Trond Myklebust | ff2eb68 | 2012-03-05 11:40:12 -0500 | [diff] [blame] | 1663 | encode_uint64(xdr, clid); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1664 | } |
| 1665 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1666 | static void |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 1667 | encode_restorefh(struct xdr_stream *xdr, struct compound_hdr *hdr) |
Trond Myklebust | 56ae19f | 2005-10-27 22:12:40 -0400 | [diff] [blame] | 1668 | { |
Trond Myklebust | ab19b48 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1669 | encode_op_hdr(xdr, OP_RESTOREFH, decode_restorefh_maxsz, hdr); |
Trond Myklebust | 56ae19f | 2005-10-27 22:12:40 -0400 | [diff] [blame] | 1670 | } |
| 1671 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 1672 | static void |
Christoph Hellwig | fcc8581 | 2017-05-08 10:01:49 +0200 | [diff] [blame] | 1673 | encode_setacl(struct xdr_stream *xdr, const struct nfs_setaclargs *arg, |
| 1674 | struct compound_hdr *hdr) |
J. Bruce Fields | 23ec696 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 1675 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 1676 | __be32 *p; |
J. Bruce Fields | 23ec696 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 1677 | |
Trond Myklebust | ab19b48 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1678 | encode_op_hdr(xdr, OP_SETATTR, decode_setacl_maxsz, hdr); |
Trond Myklebust | ea9d23f | 2012-03-04 18:13:56 -0500 | [diff] [blame] | 1679 | encode_nfs4_stateid(xdr, &zero_stateid); |
Benny Halevy | 13c65ce | 2009-08-14 17:19:25 +0300 | [diff] [blame] | 1680 | p = reserve_space(xdr, 2*4); |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1681 | *p++ = cpu_to_be32(1); |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1682 | *p = cpu_to_be32(FATTR4_WORD0_ACL); |
Benny Halevy | 13c65ce | 2009-08-14 17:19:25 +0300 | [diff] [blame] | 1683 | p = reserve_space(xdr, 4); |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1684 | *p = cpu_to_be32(arg->acl_len); |
Andreas Gruenbacher | 8fbcf23 | 2015-11-03 18:25:34 +0100 | [diff] [blame] | 1685 | xdr_write_pages(xdr, arg->acl_pages, 0, arg->acl_len); |
J. Bruce Fields | 23ec696 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 1686 | } |
| 1687 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1688 | static void |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 1689 | encode_savefh(struct xdr_stream *xdr, struct compound_hdr *hdr) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1690 | { |
Trond Myklebust | ab19b48 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1691 | encode_op_hdr(xdr, OP_SAVEFH, decode_savefh_maxsz, hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1692 | } |
| 1693 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1694 | 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] | 1695 | { |
Trond Myklebust | ab19b48 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1696 | encode_op_hdr(xdr, OP_SETATTR, decode_setattr_maxsz, hdr); |
Trond Myklebust | ea9d23f | 2012-03-04 18:13:56 -0500 | [diff] [blame] | 1697 | encode_nfs4_stateid(xdr, &arg->stateid); |
Trond Myklebust | 28cf22d | 2017-05-06 12:19:11 -0400 | [diff] [blame] | 1698 | encode_attrs(xdr, arg->iap, arg->label, NULL, server, |
| 1699 | server->attr_bitmask); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1700 | } |
| 1701 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1702 | 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] | 1703 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 1704 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1705 | |
Trond Myklebust | 7001951 | 2012-03-04 20:49:32 -0500 | [diff] [blame] | 1706 | encode_op_hdr(xdr, OP_SETCLIENTID, decode_setclientid_maxsz, hdr); |
Chuck Lever | cd93710 | 2012-03-02 17:14:31 -0500 | [diff] [blame] | 1707 | encode_nfs4_verifier(xdr, setclientid->sc_verifier); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1708 | |
Jeff Layton | 3a6bb73 | 2015-06-09 19:43:57 -0400 | [diff] [blame] | 1709 | encode_string(xdr, strlen(setclientid->sc_clnt->cl_owner_id), |
| 1710 | setclientid->sc_clnt->cl_owner_id); |
Benny Halevy | 13c65ce | 2009-08-14 17:19:25 +0300 | [diff] [blame] | 1711 | p = reserve_space(xdr, 4); |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1712 | *p = cpu_to_be32(setclientid->sc_prog); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1713 | encode_string(xdr, setclientid->sc_netid_len, setclientid->sc_netid); |
| 1714 | encode_string(xdr, setclientid->sc_uaddr_len, setclientid->sc_uaddr); |
Benny Halevy | 13c65ce | 2009-08-14 17:19:25 +0300 | [diff] [blame] | 1715 | p = reserve_space(xdr, 4); |
Jeff Layton | 3a6bb73 | 2015-06-09 19:43:57 -0400 | [diff] [blame] | 1716 | *p = cpu_to_be32(setclientid->sc_clnt->cl_cb_ident); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1717 | } |
| 1718 | |
Trond Myklebust | bb8b27e | 2010-04-16 16:43:06 -0400 | [diff] [blame] | 1719 | 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] | 1720 | { |
Trond Myklebust | 475d4ba | 2012-03-05 11:27:16 -0500 | [diff] [blame] | 1721 | encode_op_hdr(xdr, OP_SETCLIENTID_CONFIRM, |
| 1722 | decode_setclientid_confirm_maxsz, hdr); |
Trond Myklebust | ff2eb68 | 2012-03-05 11:40:12 -0500 | [diff] [blame] | 1723 | encode_uint64(xdr, arg->clientid); |
Chuck Lever | cd93710 | 2012-03-02 17:14:31 -0500 | [diff] [blame] | 1724 | encode_nfs4_verifier(xdr, &arg->confirm); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1725 | } |
| 1726 | |
Anna Schumaker | 3c6b899 | 2014-05-06 09:12:24 -0400 | [diff] [blame] | 1727 | static void encode_write(struct xdr_stream *xdr, const struct nfs_pgio_args *args, |
| 1728 | struct compound_hdr *hdr) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1729 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 1730 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1731 | |
Trond Myklebust | ab19b48 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1732 | encode_op_hdr(xdr, OP_WRITE, decode_write_maxsz, hdr); |
Trond Myklebust | 9b20614 | 2013-03-17 15:52:00 -0400 | [diff] [blame] | 1733 | encode_nfs4_stateid(xdr, &args->stateid); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1734 | |
Benny Halevy | 13c65ce | 2009-08-14 17:19:25 +0300 | [diff] [blame] | 1735 | p = reserve_space(xdr, 16); |
Benny Halevy | b95be5a | 2009-08-14 17:19:01 +0300 | [diff] [blame] | 1736 | p = xdr_encode_hyper(p, args->offset); |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1737 | *p++ = cpu_to_be32(args->stable); |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1738 | *p = cpu_to_be32(args->count); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1739 | |
| 1740 | xdr_write_pages(xdr, args->pages, args->pgbase, args->count); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1741 | } |
| 1742 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1743 | 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] | 1744 | { |
Trond Myklebust | ab19b48 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1745 | encode_op_hdr(xdr, OP_DELEGRETURN, decode_delegreturn_maxsz, hdr); |
Trond Myklebust | ea9d23f | 2012-03-04 18:13:56 -0500 | [diff] [blame] | 1746 | encode_nfs4_stateid(xdr, stateid); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1747 | } |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 1748 | |
Bryan Schumaker | 5a5ea0d | 2011-03-24 17:12:29 +0000 | [diff] [blame] | 1749 | static void encode_secinfo(struct xdr_stream *xdr, const struct qstr *name, struct compound_hdr *hdr) |
| 1750 | { |
Trond Myklebust | ab19b48 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1751 | encode_op_hdr(xdr, OP_SECINFO, decode_secinfo_maxsz, hdr); |
Trond Myklebust | 6fdfb0bc | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1752 | encode_string(xdr, name->len, name->name); |
Bryan Schumaker | 5a5ea0d | 2011-03-24 17:12:29 +0000 | [diff] [blame] | 1753 | } |
| 1754 | |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 1755 | #if defined(CONFIG_NFS_V4_1) |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 1756 | /* NFSv4.1 operations */ |
Weston Andros Adamson | 7c44f1ae | 2012-05-24 13:22:50 -0400 | [diff] [blame] | 1757 | static void encode_bind_conn_to_session(struct xdr_stream *xdr, |
Christoph Hellwig | fcc8581 | 2017-05-08 10:01:49 +0200 | [diff] [blame] | 1758 | const struct nfs41_bind_conn_to_session_args *args, |
Weston Andros Adamson | 7c44f1ae | 2012-05-24 13:22:50 -0400 | [diff] [blame] | 1759 | struct compound_hdr *hdr) |
| 1760 | { |
| 1761 | __be32 *p; |
| 1762 | |
| 1763 | encode_op_hdr(xdr, OP_BIND_CONN_TO_SESSION, |
| 1764 | decode_bind_conn_to_session_maxsz, hdr); |
Trond Myklebust | 71a097c | 2015-02-18 09:27:18 -0800 | [diff] [blame] | 1765 | encode_opaque_fixed(xdr, args->sessionid.data, NFS4_MAX_SESSIONID_LEN); |
Weston Andros Adamson | 7c44f1ae | 2012-05-24 13:22:50 -0400 | [diff] [blame] | 1766 | p = xdr_reserve_space(xdr, 8); |
Trond Myklebust | 71a097c | 2015-02-18 09:27:18 -0800 | [diff] [blame] | 1767 | *p++ = cpu_to_be32(args->dir); |
| 1768 | *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] | 1769 | } |
| 1770 | |
Christoph Hellwig | fcc8581 | 2017-05-08 10:01:49 +0200 | [diff] [blame] | 1771 | 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] | 1772 | { |
| 1773 | unsigned int i; |
| 1774 | encode_uint32(xdr, NFS4_OP_MAP_NUM_WORDS); |
| 1775 | for (i = 0; i < NFS4_OP_MAP_NUM_WORDS; i++) |
| 1776 | encode_uint32(xdr, op_map->u.words[i]); |
| 1777 | } |
| 1778 | |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 1779 | static void encode_exchange_id(struct xdr_stream *xdr, |
Christoph Hellwig | fcc8581 | 2017-05-08 10:01:49 +0200 | [diff] [blame] | 1780 | const struct nfs41_exchange_id_args *args, |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 1781 | struct compound_hdr *hdr) |
| 1782 | { |
| 1783 | __be32 *p; |
Jim Rees | d751f74 | 2012-11-16 18:12:06 -0500 | [diff] [blame] | 1784 | char impl_name[IMPL_NAME_LIMIT]; |
Weston Andros Adamson | db8ac8b | 2012-02-17 15:20:24 -0500 | [diff] [blame] | 1785 | int len = 0; |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 1786 | |
Trond Myklebust | 7001951 | 2012-03-04 20:49:32 -0500 | [diff] [blame] | 1787 | encode_op_hdr(xdr, OP_EXCHANGE_ID, decode_exchange_id_maxsz, hdr); |
Trond Myklebust | fd40559 | 2017-08-01 16:02:47 -0400 | [diff] [blame] | 1788 | encode_nfs4_verifier(xdr, &args->verifier); |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 1789 | |
Jeff Layton | 3a6bb73 | 2015-06-09 19:43:57 -0400 | [diff] [blame] | 1790 | encode_string(xdr, strlen(args->client->cl_owner_id), |
| 1791 | args->client->cl_owner_id); |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 1792 | |
Weston Andros Adamson | 2031cd1 | 2013-08-13 16:37:32 -0400 | [diff] [blame] | 1793 | encode_uint32(xdr, args->flags); |
| 1794 | encode_uint32(xdr, args->state_protect.how); |
| 1795 | |
| 1796 | switch (args->state_protect.how) { |
| 1797 | case SP4_NONE: |
| 1798 | break; |
| 1799 | case SP4_MACH_CRED: |
| 1800 | encode_op_map(xdr, &args->state_protect.enforce); |
| 1801 | encode_op_map(xdr, &args->state_protect.allow); |
| 1802 | break; |
| 1803 | default: |
| 1804 | WARN_ON_ONCE(1); |
| 1805 | break; |
| 1806 | } |
Weston Andros Adamson | db8ac8b | 2012-02-17 15:20:24 -0500 | [diff] [blame] | 1807 | |
| 1808 | if (send_implementation_id && |
| 1809 | sizeof(CONFIG_NFS_V4_1_IMPLEMENTATION_ID_DOMAIN) > 1 && |
| 1810 | sizeof(CONFIG_NFS_V4_1_IMPLEMENTATION_ID_DOMAIN) |
Jim Rees | d751f74 | 2012-11-16 18:12:06 -0500 | [diff] [blame] | 1811 | <= sizeof(impl_name) + 1) |
Weston Andros Adamson | db8ac8b | 2012-02-17 15:20:24 -0500 | [diff] [blame] | 1812 | len = snprintf(impl_name, sizeof(impl_name), "%s %s %s %s", |
| 1813 | utsname()->sysname, utsname()->release, |
| 1814 | utsname()->version, utsname()->machine); |
| 1815 | |
| 1816 | if (len > 0) { |
Weston Andros Adamson | 2031cd1 | 2013-08-13 16:37:32 -0400 | [diff] [blame] | 1817 | encode_uint32(xdr, 1); /* implementation id array length=1 */ |
Weston Andros Adamson | db8ac8b | 2012-02-17 15:20:24 -0500 | [diff] [blame] | 1818 | |
| 1819 | encode_string(xdr, |
| 1820 | sizeof(CONFIG_NFS_V4_1_IMPLEMENTATION_ID_DOMAIN) - 1, |
| 1821 | CONFIG_NFS_V4_1_IMPLEMENTATION_ID_DOMAIN); |
| 1822 | encode_string(xdr, len, impl_name); |
| 1823 | /* just send zeros for nii_date - the date is in nii_name */ |
| 1824 | p = reserve_space(xdr, 12); |
| 1825 | p = xdr_encode_hyper(p, 0); |
| 1826 | *p = cpu_to_be32(0); |
| 1827 | } else |
Weston Andros Adamson | 2031cd1 | 2013-08-13 16:37:32 -0400 | [diff] [blame] | 1828 | encode_uint32(xdr, 0); /* implementation id array length=0 */ |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 1829 | } |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 1830 | |
| 1831 | static void encode_create_session(struct xdr_stream *xdr, |
Christoph Hellwig | fcc8581 | 2017-05-08 10:01:49 +0200 | [diff] [blame] | 1832 | const struct nfs41_create_session_args *args, |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 1833 | struct compound_hdr *hdr) |
| 1834 | { |
| 1835 | __be32 *p; |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 1836 | struct nfs_client *clp = args->client; |
Trond Myklebust | 89f0ff3 | 2015-01-03 14:47:43 -0500 | [diff] [blame] | 1837 | struct rpc_clnt *clnt = clp->cl_rpcclient; |
Chuck Lever | f092075 | 2012-05-21 22:45:41 -0400 | [diff] [blame] | 1838 | struct nfs_net *nn = net_generic(clp->cl_net, nfs_net_id); |
Mike Sager | 8e0d46e | 2009-12-17 12:06:26 -0500 | [diff] [blame] | 1839 | u32 max_resp_sz_cached; |
| 1840 | |
| 1841 | /* |
| 1842 | * Assumes OPEN is the biggest non-idempotent compound. |
| 1843 | * 2 is the verifier. |
| 1844 | */ |
| 1845 | max_resp_sz_cached = (NFS4_dec_open_sz + RPC_REPHDRSIZE + |
| 1846 | RPC_MAX_AUTH_SIZE + 2) * XDR_UNIT; |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 1847 | |
Trond Myklebust | 475d4ba | 2012-03-05 11:27:16 -0500 | [diff] [blame] | 1848 | encode_op_hdr(xdr, OP_CREATE_SESSION, decode_create_session_maxsz, hdr); |
Trond Myklebust | 89f0ff3 | 2015-01-03 14:47:43 -0500 | [diff] [blame] | 1849 | p = reserve_space(xdr, 16 + 2*28 + 20 + clnt->cl_nodelen + 12); |
Trond Myklebust | 79969dd | 2015-02-18 11:30:18 -0800 | [diff] [blame] | 1850 | p = xdr_encode_hyper(p, args->clientid); |
| 1851 | *p++ = cpu_to_be32(args->seqid); /*Sequence id */ |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1852 | *p++ = cpu_to_be32(args->flags); /*flags */ |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 1853 | |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 1854 | /* Fore Channel */ |
Benny Halevy | c9c30dd | 2011-06-11 17:08:39 -0400 | [diff] [blame] | 1855 | *p++ = cpu_to_be32(0); /* header padding size */ |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1856 | *p++ = cpu_to_be32(args->fc_attrs.max_rqst_sz); /* max req size */ |
| 1857 | *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] | 1858 | *p++ = cpu_to_be32(max_resp_sz_cached); /* Max resp sz cached */ |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1859 | *p++ = cpu_to_be32(args->fc_attrs.max_ops); /* max operations */ |
| 1860 | *p++ = cpu_to_be32(args->fc_attrs.max_reqs); /* max requests */ |
| 1861 | *p++ = cpu_to_be32(0); /* rdmachannel_attrs */ |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 1862 | |
| 1863 | /* Back Channel */ |
Benny Halevy | c9c30dd | 2011-06-11 17:08:39 -0400 | [diff] [blame] | 1864 | *p++ = cpu_to_be32(0); /* header padding size */ |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1865 | *p++ = cpu_to_be32(args->bc_attrs.max_rqst_sz); /* max req size */ |
| 1866 | *p++ = cpu_to_be32(args->bc_attrs.max_resp_sz); /* max resp size */ |
| 1867 | *p++ = cpu_to_be32(args->bc_attrs.max_resp_sz_cached); /* Max resp sz cached */ |
| 1868 | *p++ = cpu_to_be32(args->bc_attrs.max_ops); /* max operations */ |
| 1869 | *p++ = cpu_to_be32(args->bc_attrs.max_reqs); /* max requests */ |
| 1870 | *p++ = cpu_to_be32(0); /* rdmachannel_attrs */ |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 1871 | |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1872 | *p++ = cpu_to_be32(args->cb_program); /* cb_program */ |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1873 | *p++ = cpu_to_be32(1); |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1874 | *p++ = cpu_to_be32(RPC_AUTH_UNIX); /* auth_sys */ |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 1875 | |
| 1876 | /* authsys_parms rfc1831 */ |
Deepa Dinamani | 2f86e09 | 2016-10-01 16:46:26 -0700 | [diff] [blame] | 1877 | *p++ = cpu_to_be32(ktime_to_ns(nn->boot_time)); /* stamp */ |
Trond Myklebust | 89f0ff3 | 2015-01-03 14:47:43 -0500 | [diff] [blame] | 1878 | p = xdr_encode_array(p, clnt->cl_nodename, clnt->cl_nodelen); |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1879 | *p++ = cpu_to_be32(0); /* UID */ |
| 1880 | *p++ = cpu_to_be32(0); /* GID */ |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1881 | *p = cpu_to_be32(0); /* No more gids */ |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 1882 | } |
Andy Adamson | 0f3e66c | 2009-04-01 09:22:34 -0400 | [diff] [blame] | 1883 | |
| 1884 | static void encode_destroy_session(struct xdr_stream *xdr, |
Christoph Hellwig | fcc8581 | 2017-05-08 10:01:49 +0200 | [diff] [blame] | 1885 | const struct nfs4_session *session, |
Andy Adamson | 0f3e66c | 2009-04-01 09:22:34 -0400 | [diff] [blame] | 1886 | struct compound_hdr *hdr) |
| 1887 | { |
Trond Myklebust | 475d4ba | 2012-03-05 11:27:16 -0500 | [diff] [blame] | 1888 | encode_op_hdr(xdr, OP_DESTROY_SESSION, decode_destroy_session_maxsz, hdr); |
| 1889 | encode_opaque_fixed(xdr, session->sess_id.data, NFS4_MAX_SESSIONID_LEN); |
Andy Adamson | 0f3e66c | 2009-04-01 09:22:34 -0400 | [diff] [blame] | 1890 | } |
Ricardo Labiaga | 18019753 | 2009-12-05 16:08:40 -0500 | [diff] [blame] | 1891 | |
Trond Myklebust | 6624553 | 2012-05-25 17:18:09 -0400 | [diff] [blame] | 1892 | static void encode_destroy_clientid(struct xdr_stream *xdr, |
| 1893 | uint64_t clientid, |
| 1894 | struct compound_hdr *hdr) |
| 1895 | { |
| 1896 | encode_op_hdr(xdr, OP_DESTROY_CLIENTID, decode_destroy_clientid_maxsz, hdr); |
| 1897 | encode_uint64(xdr, clientid); |
| 1898 | } |
| 1899 | |
Ricardo Labiaga | 18019753 | 2009-12-05 16:08:40 -0500 | [diff] [blame] | 1900 | static void encode_reclaim_complete(struct xdr_stream *xdr, |
Christoph Hellwig | fcc8581 | 2017-05-08 10:01:49 +0200 | [diff] [blame] | 1901 | const struct nfs41_reclaim_complete_args *args, |
Ricardo Labiaga | 18019753 | 2009-12-05 16:08:40 -0500 | [diff] [blame] | 1902 | struct compound_hdr *hdr) |
| 1903 | { |
Trond Myklebust | 475d4ba | 2012-03-05 11:27:16 -0500 | [diff] [blame] | 1904 | encode_op_hdr(xdr, OP_RECLAIM_COMPLETE, decode_reclaim_complete_maxsz, hdr); |
| 1905 | encode_uint32(xdr, args->one_fs); |
Ricardo Labiaga | 18019753 | 2009-12-05 16:08:40 -0500 | [diff] [blame] | 1906 | } |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 1907 | #endif /* CONFIG_NFS_V4_1 */ |
| 1908 | |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 1909 | static void encode_sequence(struct xdr_stream *xdr, |
| 1910 | const struct nfs4_sequence_args *args, |
| 1911 | struct compound_hdr *hdr) |
| 1912 | { |
| 1913 | #if defined(CONFIG_NFS_V4_1) |
Trond Myklebust | 2b2fa71 | 2012-11-16 12:58:36 -0500 | [diff] [blame] | 1914 | struct nfs4_session *session; |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 1915 | struct nfs4_slot_table *tp; |
Trond Myklebust | 2b2fa71 | 2012-11-16 12:58:36 -0500 | [diff] [blame] | 1916 | struct nfs4_slot *slot = args->sa_slot; |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 1917 | __be32 *p; |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 1918 | |
Trond Myklebust | 2b2fa71 | 2012-11-16 12:58:36 -0500 | [diff] [blame] | 1919 | tp = slot->table; |
| 1920 | session = tp->session; |
Chuck Lever | 3bd2384 | 2013-08-09 12:49:19 -0400 | [diff] [blame] | 1921 | if (!session) |
| 1922 | return; |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 1923 | |
Trond Myklebust | 475d4ba | 2012-03-05 11:27:16 -0500 | [diff] [blame] | 1924 | encode_op_hdr(xdr, OP_SEQUENCE, decode_sequence_maxsz, hdr); |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 1925 | |
| 1926 | /* |
| 1927 | * Sessionid + seqid + slotid + max slotid + cache_this |
| 1928 | */ |
| 1929 | dprintk("%s: sessionid=%u:%u:%u:%u seqid=%d slotid=%d " |
| 1930 | "max_slotid=%d cache_this=%d\n", |
| 1931 | __func__, |
| 1932 | ((u32 *)session->sess_id.data)[0], |
| 1933 | ((u32 *)session->sess_id.data)[1], |
| 1934 | ((u32 *)session->sess_id.data)[2], |
| 1935 | ((u32 *)session->sess_id.data)[3], |
Trond Myklebust | 2b2fa71 | 2012-11-16 12:58:36 -0500 | [diff] [blame] | 1936 | slot->seq_nr, slot->slot_nr, |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 1937 | tp->highest_used_slotid, args->sa_cache_this); |
Trond Myklebust | 475d4ba | 2012-03-05 11:27:16 -0500 | [diff] [blame] | 1938 | p = reserve_space(xdr, NFS4_MAX_SESSIONID_LEN + 16); |
Benny Halevy | 93f0cf2 | 2009-08-14 17:19:06 +0300 | [diff] [blame] | 1939 | 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] | 1940 | *p++ = cpu_to_be32(slot->seq_nr); |
Trond Myklebust | 2b2fa71 | 2012-11-16 12:58:36 -0500 | [diff] [blame] | 1941 | *p++ = cpu_to_be32(slot->slot_nr); |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1942 | *p++ = cpu_to_be32(tp->highest_used_slotid); |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1943 | *p = cpu_to_be32(args->sa_cache_this); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 1944 | #endif /* CONFIG_NFS_V4_1 */ |
| 1945 | } |
| 1946 | |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 1947 | #ifdef CONFIG_NFS_V4_1 |
| 1948 | static void |
| 1949 | encode_getdeviceinfo(struct xdr_stream *xdr, |
| 1950 | const struct nfs4_getdeviceinfo_args *args, |
| 1951 | struct compound_hdr *hdr) |
| 1952 | { |
| 1953 | __be32 *p; |
| 1954 | |
Trond Myklebust | 475d4ba | 2012-03-05 11:27:16 -0500 | [diff] [blame] | 1955 | encode_op_hdr(xdr, OP_GETDEVICEINFO, decode_getdeviceinfo_maxsz, hdr); |
Christoph Hellwig | 84c9dee | 2014-09-10 17:37:28 -0700 | [diff] [blame] | 1956 | p = reserve_space(xdr, NFS4_DEVICEID4_SIZE + 4 + 4); |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 1957 | p = xdr_encode_opaque_fixed(p, args->pdev->dev_id.data, |
| 1958 | NFS4_DEVICEID4_SIZE); |
| 1959 | *p++ = cpu_to_be32(args->pdev->layout_type); |
Andy Adamson | f1c097b | 2013-06-25 19:02:53 -0400 | [diff] [blame] | 1960 | *p++ = cpu_to_be32(args->pdev->maxcount); /* gdia_maxcount */ |
Christoph Hellwig | 84c9dee | 2014-09-10 17:37:28 -0700 | [diff] [blame] | 1961 | |
| 1962 | p = reserve_space(xdr, 4 + 4); |
| 1963 | *p++ = cpu_to_be32(1); /* bitmap length */ |
Trond Myklebust | 4e59080 | 2015-03-09 14:01:25 -0400 | [diff] [blame] | 1964 | *p++ = cpu_to_be32(args->notify_types); |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 1965 | } |
| 1966 | |
| 1967 | static void |
| 1968 | encode_layoutget(struct xdr_stream *xdr, |
| 1969 | const struct nfs4_layoutget_args *args, |
| 1970 | struct compound_hdr *hdr) |
| 1971 | { |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 1972 | __be32 *p; |
| 1973 | |
Trond Myklebust | 475d4ba | 2012-03-05 11:27:16 -0500 | [diff] [blame] | 1974 | encode_op_hdr(xdr, OP_LAYOUTGET, decode_layoutget_maxsz, hdr); |
| 1975 | p = reserve_space(xdr, 36); |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 1976 | *p++ = cpu_to_be32(0); /* Signal layout available */ |
| 1977 | *p++ = cpu_to_be32(args->type); |
| 1978 | *p++ = cpu_to_be32(args->range.iomode); |
| 1979 | p = xdr_encode_hyper(p, args->range.offset); |
| 1980 | p = xdr_encode_hyper(p, args->range.length); |
| 1981 | p = xdr_encode_hyper(p, args->minlength); |
Trond Myklebust | ea9d23f | 2012-03-04 18:13:56 -0500 | [diff] [blame] | 1982 | encode_nfs4_stateid(xdr, &args->stateid); |
Trond Myklebust | 475d4ba | 2012-03-05 11:27:16 -0500 | [diff] [blame] | 1983 | encode_uint32(xdr, args->maxcount); |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 1984 | |
| 1985 | dprintk("%s: 1st type:0x%x iomode:%d off:%lu len:%lu mc:%d\n", |
| 1986 | __func__, |
| 1987 | args->type, |
| 1988 | args->range.iomode, |
| 1989 | (unsigned long)args->range.offset, |
| 1990 | (unsigned long)args->range.length, |
| 1991 | args->maxcount); |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 1992 | } |
Andy Adamson | 863a3c6 | 2011-03-23 13:27:54 +0000 | [diff] [blame] | 1993 | |
| 1994 | static int |
| 1995 | encode_layoutcommit(struct xdr_stream *xdr, |
Benny Halevy | ac7db72 | 2011-05-22 19:53:48 +0300 | [diff] [blame] | 1996 | struct inode *inode, |
Christoph Hellwig | fcc8581 | 2017-05-08 10:01:49 +0200 | [diff] [blame] | 1997 | const struct nfs4_layoutcommit_args *args, |
Andy Adamson | 863a3c6 | 2011-03-23 13:27:54 +0000 | [diff] [blame] | 1998 | struct compound_hdr *hdr) |
| 1999 | { |
| 2000 | __be32 *p; |
| 2001 | |
| 2002 | dprintk("%s: lbw: %llu type: %d\n", __func__, args->lastbytewritten, |
| 2003 | NFS_SERVER(args->inode)->pnfs_curr_ld->id); |
| 2004 | |
Trond Myklebust | 475d4ba | 2012-03-05 11:27:16 -0500 | [diff] [blame] | 2005 | encode_op_hdr(xdr, OP_LAYOUTCOMMIT, decode_layoutcommit_maxsz, hdr); |
| 2006 | p = reserve_space(xdr, 20); |
Andy Adamson | 863a3c6 | 2011-03-23 13:27:54 +0000 | [diff] [blame] | 2007 | /* Only whole file layouts */ |
| 2008 | p = xdr_encode_hyper(p, 0); /* offset */ |
Peng Tao | 3557c6c | 2011-07-30 20:52:34 -0400 | [diff] [blame] | 2009 | p = xdr_encode_hyper(p, args->lastbytewritten + 1); /* length */ |
Trond Myklebust | ea9d23f | 2012-03-04 18:13:56 -0500 | [diff] [blame] | 2010 | *p = cpu_to_be32(0); /* reclaim */ |
| 2011 | encode_nfs4_stateid(xdr, &args->stateid); |
Trond Myklebust | 2e18d4d | 2016-06-26 18:54:58 -0400 | [diff] [blame] | 2012 | if (args->lastbytewritten != U64_MAX) { |
| 2013 | p = reserve_space(xdr, 20); |
| 2014 | *p++ = cpu_to_be32(1); /* newoffset = TRUE */ |
| 2015 | p = xdr_encode_hyper(p, args->lastbytewritten); |
| 2016 | } else { |
| 2017 | p = reserve_space(xdr, 12); |
| 2018 | *p++ = cpu_to_be32(0); /* newoffset = FALSE */ |
| 2019 | } |
Andy Adamson | 863a3c6 | 2011-03-23 13:27:54 +0000 | [diff] [blame] | 2020 | *p++ = cpu_to_be32(0); /* Never send time_modify_changed */ |
| 2021 | *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] | 2022 | |
Trond Myklebust | 7350474 | 2017-04-20 16:48:14 -0400 | [diff] [blame] | 2023 | encode_uint32(xdr, args->layoutupdate_len); |
| 2024 | if (args->layoutupdate_pages) |
| 2025 | xdr_write_pages(xdr, args->layoutupdate_pages, 0, |
| 2026 | args->layoutupdate_len); |
Andy Adamson | 863a3c6 | 2011-03-23 13:27:54 +0000 | [diff] [blame] | 2027 | |
Andy Adamson | 863a3c6 | 2011-03-23 13:27:54 +0000 | [diff] [blame] | 2028 | return 0; |
| 2029 | } |
Benny Halevy | cbe8260 | 2011-05-22 19:52:37 +0300 | [diff] [blame] | 2030 | |
| 2031 | static void |
| 2032 | encode_layoutreturn(struct xdr_stream *xdr, |
| 2033 | const struct nfs4_layoutreturn_args *args, |
| 2034 | struct compound_hdr *hdr) |
| 2035 | { |
| 2036 | __be32 *p; |
| 2037 | |
Trond Myklebust | 475d4ba | 2012-03-05 11:27:16 -0500 | [diff] [blame] | 2038 | encode_op_hdr(xdr, OP_LAYOUTRETURN, decode_layoutreturn_maxsz, hdr); |
| 2039 | p = reserve_space(xdr, 16); |
Benny Halevy | cbe8260 | 2011-05-22 19:52:37 +0300 | [diff] [blame] | 2040 | *p++ = cpu_to_be32(0); /* reclaim. always 0 for now */ |
| 2041 | *p++ = cpu_to_be32(args->layout_type); |
Peng Tao | 15eb67c | 2014-11-17 09:30:36 +0800 | [diff] [blame] | 2042 | *p++ = cpu_to_be32(args->range.iomode); |
Benny Halevy | cbe8260 | 2011-05-22 19:52:37 +0300 | [diff] [blame] | 2043 | *p = cpu_to_be32(RETURN_FILE); |
Trond Myklebust | ea9d23f | 2012-03-04 18:13:56 -0500 | [diff] [blame] | 2044 | p = reserve_space(xdr, 16); |
Peng Tao | 15eb67c | 2014-11-17 09:30:36 +0800 | [diff] [blame] | 2045 | p = xdr_encode_hyper(p, args->range.offset); |
| 2046 | p = xdr_encode_hyper(p, args->range.length); |
Benny Halevy | cbe8260 | 2011-05-22 19:52:37 +0300 | [diff] [blame] | 2047 | spin_lock(&args->inode->i_lock); |
Trond Myklebust | ea9d23f | 2012-03-04 18:13:56 -0500 | [diff] [blame] | 2048 | encode_nfs4_stateid(xdr, &args->stateid); |
Benny Halevy | cbe8260 | 2011-05-22 19:52:37 +0300 | [diff] [blame] | 2049 | spin_unlock(&args->inode->i_lock); |
Trond Myklebust | 4d796d7 | 2016-09-23 11:38:08 -0400 | [diff] [blame] | 2050 | if (args->ld_private->ops && args->ld_private->ops->encode) |
| 2051 | args->ld_private->ops->encode(xdr, args, args->ld_private); |
Trond Myklebust | 94e5c57 | 2016-09-15 18:49:52 -0400 | [diff] [blame] | 2052 | else |
Trond Myklebust | 475d4ba | 2012-03-05 11:27:16 -0500 | [diff] [blame] | 2053 | encode_uint32(xdr, 0); |
Benny Halevy | cbe8260 | 2011-05-22 19:52:37 +0300 | [diff] [blame] | 2054 | } |
Bryan Schumaker | fca78d6 | 2011-06-02 14:59:07 -0400 | [diff] [blame] | 2055 | |
| 2056 | static int |
| 2057 | encode_secinfo_no_name(struct xdr_stream *xdr, |
| 2058 | const struct nfs41_secinfo_no_name_args *args, |
| 2059 | struct compound_hdr *hdr) |
| 2060 | { |
Trond Myklebust | 475d4ba | 2012-03-05 11:27:16 -0500 | [diff] [blame] | 2061 | encode_op_hdr(xdr, OP_SECINFO_NO_NAME, decode_secinfo_no_name_maxsz, hdr); |
| 2062 | encode_uint32(xdr, args->style); |
Bryan Schumaker | fca78d6 | 2011-06-02 14:59:07 -0400 | [diff] [blame] | 2063 | return 0; |
| 2064 | } |
Bryan Schumaker | 7d97479 | 2011-06-02 14:59:08 -0400 | [diff] [blame] | 2065 | |
| 2066 | static void encode_test_stateid(struct xdr_stream *xdr, |
Christoph Hellwig | fcc8581 | 2017-05-08 10:01:49 +0200 | [diff] [blame] | 2067 | const struct nfs41_test_stateid_args *args, |
Bryan Schumaker | 7d97479 | 2011-06-02 14:59:08 -0400 | [diff] [blame] | 2068 | struct compound_hdr *hdr) |
| 2069 | { |
Trond Myklebust | 475d4ba | 2012-03-05 11:27:16 -0500 | [diff] [blame] | 2070 | encode_op_hdr(xdr, OP_TEST_STATEID, decode_test_stateid_maxsz, hdr); |
| 2071 | encode_uint32(xdr, 1); |
Trond Myklebust | ea9d23f | 2012-03-04 18:13:56 -0500 | [diff] [blame] | 2072 | encode_nfs4_stateid(xdr, args->stateid); |
Bryan Schumaker | 7d97479 | 2011-06-02 14:59:08 -0400 | [diff] [blame] | 2073 | } |
Bryan Schumaker | 9aeda35 | 2011-06-02 14:59:09 -0400 | [diff] [blame] | 2074 | |
| 2075 | static void encode_free_stateid(struct xdr_stream *xdr, |
Christoph Hellwig | fcc8581 | 2017-05-08 10:01:49 +0200 | [diff] [blame] | 2076 | const struct nfs41_free_stateid_args *args, |
Bryan Schumaker | 9aeda35 | 2011-06-02 14:59:09 -0400 | [diff] [blame] | 2077 | struct compound_hdr *hdr) |
| 2078 | { |
Trond Myklebust | ab19b48 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 2079 | encode_op_hdr(xdr, OP_FREE_STATEID, decode_free_stateid_maxsz, hdr); |
Trond Myklebust | 7c1d5fa | 2013-05-03 14:40:01 -0400 | [diff] [blame] | 2080 | encode_nfs4_stateid(xdr, &args->stateid); |
Bryan Schumaker | 9aeda35 | 2011-06-02 14:59:09 -0400 | [diff] [blame] | 2081 | } |
Trond Myklebust | cf80516 | 2016-11-15 14:56:07 -0500 | [diff] [blame] | 2082 | #else |
| 2083 | static inline void |
| 2084 | encode_layoutreturn(struct xdr_stream *xdr, |
| 2085 | const struct nfs4_layoutreturn_args *args, |
| 2086 | struct compound_hdr *hdr) |
| 2087 | { |
| 2088 | } |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 2089 | #endif /* CONFIG_NFS_V4_1 */ |
| 2090 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2091 | /* |
| 2092 | * END OF "GENERIC" ENCODE ROUTINES. |
| 2093 | */ |
| 2094 | |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2095 | static u32 nfs4_xdr_minorversion(const struct nfs4_sequence_args *args) |
| 2096 | { |
| 2097 | #if defined(CONFIG_NFS_V4_1) |
Chuck Lever | 3bd2384 | 2013-08-09 12:49:19 -0400 | [diff] [blame] | 2098 | struct nfs4_session *session = args->sa_slot->table->session; |
| 2099 | if (session) |
| 2100 | return session->clp->cl_mvops->minor_version; |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2101 | #endif /* CONFIG_NFS_V4_1 */ |
| 2102 | return 0; |
| 2103 | } |
| 2104 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2105 | /* |
| 2106 | * Encode an ACCESS request |
| 2107 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2108 | 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] | 2109 | const void *data) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2110 | { |
Christoph Hellwig | fcc8581 | 2017-05-08 10:01:49 +0200 | [diff] [blame] | 2111 | const struct nfs4_accessargs *args = data; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2112 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2113 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2114 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2115 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2116 | encode_compound_hdr(xdr, req, &hdr); |
| 2117 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2118 | encode_putfh(xdr, args->fh, &hdr); |
| 2119 | encode_access(xdr, args->access, &hdr); |
| 2120 | encode_getfattr(xdr, args->bitmask, &hdr); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2121 | encode_nops(&hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2122 | } |
| 2123 | |
| 2124 | /* |
| 2125 | * Encode LOOKUP request |
| 2126 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2127 | 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] | 2128 | const void *data) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2129 | { |
Christoph Hellwig | fcc8581 | 2017-05-08 10:01:49 +0200 | [diff] [blame] | 2130 | const struct nfs4_lookup_arg *args = data; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2131 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2132 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2133 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2134 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2135 | encode_compound_hdr(xdr, req, &hdr); |
| 2136 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2137 | encode_putfh(xdr, args->dir_fh, &hdr); |
| 2138 | encode_lookup(xdr, args->name, &hdr); |
| 2139 | encode_getfh(xdr, &hdr); |
| 2140 | encode_getfattr(xdr, args->bitmask, &hdr); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2141 | encode_nops(&hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2142 | } |
| 2143 | |
| 2144 | /* |
Jeff Layton | 5b5faaf | 2017-06-29 06:34:52 -0700 | [diff] [blame] | 2145 | * Encode LOOKUPP request |
| 2146 | */ |
| 2147 | static void nfs4_xdr_enc_lookupp(struct rpc_rqst *req, struct xdr_stream *xdr, |
| 2148 | const void *data) |
| 2149 | { |
| 2150 | const struct nfs4_lookupp_arg *args = data; |
| 2151 | struct compound_hdr hdr = { |
| 2152 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
| 2153 | }; |
| 2154 | |
| 2155 | encode_compound_hdr(xdr, req, &hdr); |
| 2156 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2157 | encode_putfh(xdr, args->fh, &hdr); |
| 2158 | encode_lookupp(xdr, &hdr); |
| 2159 | encode_getfh(xdr, &hdr); |
| 2160 | encode_getfattr(xdr, args->bitmask, &hdr); |
| 2161 | encode_nops(&hdr); |
| 2162 | } |
| 2163 | |
| 2164 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2165 | * Encode LOOKUP_ROOT request |
| 2166 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2167 | static void nfs4_xdr_enc_lookup_root(struct rpc_rqst *req, |
| 2168 | struct xdr_stream *xdr, |
Christoph Hellwig | fcc8581 | 2017-05-08 10:01:49 +0200 | [diff] [blame] | 2169 | const void *data) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2170 | { |
Christoph Hellwig | fcc8581 | 2017-05-08 10:01:49 +0200 | [diff] [blame] | 2171 | const struct nfs4_lookup_root_arg *args = data; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2172 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2173 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2174 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2175 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2176 | encode_compound_hdr(xdr, req, &hdr); |
| 2177 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2178 | encode_putrootfh(xdr, &hdr); |
| 2179 | encode_getfh(xdr, &hdr); |
| 2180 | encode_getfattr(xdr, args->bitmask, &hdr); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2181 | encode_nops(&hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2182 | } |
| 2183 | |
| 2184 | /* |
| 2185 | * Encode REMOVE request |
| 2186 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2187 | 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] | 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 nfs_removeargs *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_putfh(xdr, args->fh, &hdr); |
| 2198 | encode_remove(xdr, &args->name, &hdr); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2199 | encode_nops(&hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2200 | } |
| 2201 | |
| 2202 | /* |
| 2203 | * Encode RENAME request |
| 2204 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2205 | 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] | 2206 | const void *data) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2207 | { |
Christoph Hellwig | fcc8581 | 2017-05-08 10:01:49 +0200 | [diff] [blame] | 2208 | const struct nfs_renameargs *args = data; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2209 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2210 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2211 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2212 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2213 | encode_compound_hdr(xdr, req, &hdr); |
| 2214 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2215 | encode_putfh(xdr, args->old_dir, &hdr); |
| 2216 | encode_savefh(xdr, &hdr); |
| 2217 | encode_putfh(xdr, args->new_dir, &hdr); |
| 2218 | encode_rename(xdr, args->old_name, args->new_name, &hdr); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2219 | encode_nops(&hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2220 | } |
| 2221 | |
| 2222 | /* |
| 2223 | * Encode LINK request |
| 2224 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2225 | 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] | 2226 | const void *data) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2227 | { |
Christoph Hellwig | fcc8581 | 2017-05-08 10:01:49 +0200 | [diff] [blame] | 2228 | const struct nfs4_link_arg *args = data; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2229 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2230 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2231 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2232 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2233 | encode_compound_hdr(xdr, req, &hdr); |
| 2234 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2235 | encode_putfh(xdr, args->fh, &hdr); |
| 2236 | encode_savefh(xdr, &hdr); |
| 2237 | encode_putfh(xdr, args->dir_fh, &hdr); |
| 2238 | encode_link(xdr, args->name, &hdr); |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2239 | encode_restorefh(xdr, &hdr); |
| 2240 | encode_getfattr(xdr, args->bitmask, &hdr); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2241 | encode_nops(&hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2242 | } |
| 2243 | |
| 2244 | /* |
| 2245 | * Encode CREATE request |
| 2246 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2247 | 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] | 2248 | const void *data) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2249 | { |
Christoph Hellwig | fcc8581 | 2017-05-08 10:01:49 +0200 | [diff] [blame] | 2250 | const struct nfs4_create_arg *args = data; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2251 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2252 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2253 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2254 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2255 | encode_compound_hdr(xdr, req, &hdr); |
| 2256 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2257 | encode_putfh(xdr, args->dir_fh, &hdr); |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2258 | encode_create(xdr, args, &hdr); |
| 2259 | encode_getfh(xdr, &hdr); |
| 2260 | encode_getfattr(xdr, args->bitmask, &hdr); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2261 | encode_nops(&hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2262 | } |
| 2263 | |
| 2264 | /* |
| 2265 | * Encode SYMLINK request |
| 2266 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2267 | 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] | 2268 | const void *data) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2269 | { |
Christoph Hellwig | fcc8581 | 2017-05-08 10:01:49 +0200 | [diff] [blame] | 2270 | const struct nfs4_create_arg *args = data; |
| 2271 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2272 | nfs4_xdr_enc_create(req, xdr, args); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2273 | } |
| 2274 | |
| 2275 | /* |
| 2276 | * Encode GETATTR request |
| 2277 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2278 | 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] | 2279 | const void *data) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2280 | { |
Christoph Hellwig | fcc8581 | 2017-05-08 10:01:49 +0200 | [diff] [blame] | 2281 | const struct nfs4_getattr_arg *args = data; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2282 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2283 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2284 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2285 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2286 | encode_compound_hdr(xdr, req, &hdr); |
| 2287 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2288 | encode_putfh(xdr, args->fh, &hdr); |
| 2289 | encode_getfattr(xdr, args->bitmask, &hdr); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2290 | encode_nops(&hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2291 | } |
| 2292 | |
| 2293 | /* |
| 2294 | * Encode a CLOSE request |
| 2295 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2296 | 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] | 2297 | const void *data) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2298 | { |
Christoph Hellwig | fcc8581 | 2017-05-08 10:01:49 +0200 | [diff] [blame] | 2299 | const struct nfs_closeargs *args = data; |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 2300 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2301 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 2302 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2303 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2304 | encode_compound_hdr(xdr, req, &hdr); |
| 2305 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2306 | encode_putfh(xdr, args->fh, &hdr); |
Trond Myklebust | cf80516 | 2016-11-15 14:56:07 -0500 | [diff] [blame] | 2307 | if (args->lr_args) |
| 2308 | encode_layoutreturn(xdr, args->lr_args, &hdr); |
Trond Myklebust | 3ecefc9 | 2016-10-27 18:25:04 -0400 | [diff] [blame] | 2309 | if (args->bitmask != NULL) |
| 2310 | encode_getfattr(xdr, args->bitmask, &hdr); |
Trond Myklebust | d8d8498 | 2016-12-19 12:14:44 -0500 | [diff] [blame] | 2311 | encode_close(xdr, args, &hdr); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2312 | encode_nops(&hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2313 | } |
| 2314 | |
| 2315 | /* |
| 2316 | * Encode an OPEN request |
| 2317 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2318 | 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] | 2319 | const void *data) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2320 | { |
Christoph Hellwig | fcc8581 | 2017-05-08 10:01:49 +0200 | [diff] [blame] | 2321 | const struct nfs_openargs *args = data; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2322 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2323 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2324 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2325 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2326 | encode_compound_hdr(xdr, req, &hdr); |
| 2327 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2328 | encode_putfh(xdr, args->fh, &hdr); |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2329 | encode_open(xdr, args, &hdr); |
| 2330 | encode_getfh(xdr, &hdr); |
Weston Andros Adamson | ae2bb03 | 2012-10-02 14:49:52 -0700 | [diff] [blame] | 2331 | if (args->access) |
| 2332 | encode_access(xdr, args->access, &hdr); |
Trond Myklebust | 1549210f | 2012-06-05 09:16:47 -0400 | [diff] [blame] | 2333 | encode_getfattr_open(xdr, args->bitmask, args->open_bitmap, &hdr); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2334 | encode_nops(&hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2335 | } |
| 2336 | |
| 2337 | /* |
| 2338 | * Encode an OPEN_CONFIRM request |
| 2339 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2340 | static void nfs4_xdr_enc_open_confirm(struct rpc_rqst *req, |
| 2341 | struct xdr_stream *xdr, |
Christoph Hellwig | fcc8581 | 2017-05-08 10:01:49 +0200 | [diff] [blame] | 2342 | const void *data) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2343 | { |
Christoph Hellwig | fcc8581 | 2017-05-08 10:01:49 +0200 | [diff] [blame] | 2344 | const struct nfs_open_confirmargs *args = data; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2345 | struct compound_hdr hdr = { |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2346 | .nops = 0, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2347 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2348 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2349 | encode_compound_hdr(xdr, req, &hdr); |
| 2350 | encode_putfh(xdr, args->fh, &hdr); |
| 2351 | encode_open_confirm(xdr, args, &hdr); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2352 | encode_nops(&hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2353 | } |
| 2354 | |
| 2355 | /* |
| 2356 | * Encode an OPEN request with no attributes. |
| 2357 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2358 | static void nfs4_xdr_enc_open_noattr(struct rpc_rqst *req, |
| 2359 | struct xdr_stream *xdr, |
Christoph Hellwig | fcc8581 | 2017-05-08 10:01:49 +0200 | [diff] [blame] | 2360 | const void *data) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2361 | { |
Christoph Hellwig | fcc8581 | 2017-05-08 10:01:49 +0200 | [diff] [blame] | 2362 | const struct nfs_openargs *args = data; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2363 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2364 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2365 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2366 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2367 | encode_compound_hdr(xdr, req, &hdr); |
| 2368 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2369 | encode_putfh(xdr, args->fh, &hdr); |
| 2370 | encode_open(xdr, args, &hdr); |
Weston Andros Adamson | ae2bb03 | 2012-10-02 14:49:52 -0700 | [diff] [blame] | 2371 | if (args->access) |
| 2372 | encode_access(xdr, args->access, &hdr); |
Andy Adamson | e23008e | 2012-10-02 21:07:32 -0400 | [diff] [blame] | 2373 | encode_getfattr_open(xdr, args->bitmask, args->open_bitmap, &hdr); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2374 | encode_nops(&hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2375 | } |
| 2376 | |
| 2377 | /* |
| 2378 | * Encode an OPEN_DOWNGRADE request |
| 2379 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2380 | static void nfs4_xdr_enc_open_downgrade(struct rpc_rqst *req, |
| 2381 | struct xdr_stream *xdr, |
Christoph Hellwig | fcc8581 | 2017-05-08 10:01:49 +0200 | [diff] [blame] | 2382 | const void *data) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2383 | { |
Christoph Hellwig | fcc8581 | 2017-05-08 10:01:49 +0200 | [diff] [blame] | 2384 | const struct nfs_closeargs *args = data; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2385 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2386 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2387 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2388 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2389 | encode_compound_hdr(xdr, req, &hdr); |
| 2390 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2391 | encode_putfh(xdr, args->fh, &hdr); |
Trond Myklebust | b680814 | 2016-11-20 13:34:16 -0500 | [diff] [blame] | 2392 | if (args->lr_args) |
| 2393 | encode_layoutreturn(xdr, args->lr_args, &hdr); |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2394 | encode_open_downgrade(xdr, args, &hdr); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2395 | encode_nops(&hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2396 | } |
| 2397 | |
| 2398 | /* |
| 2399 | * Encode a LOCK request |
| 2400 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2401 | 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] | 2402 | const void *data) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2403 | { |
Christoph Hellwig | fcc8581 | 2017-05-08 10:01:49 +0200 | [diff] [blame] | 2404 | const struct nfs_lock_args *args = data; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2405 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2406 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2407 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2408 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2409 | encode_compound_hdr(xdr, req, &hdr); |
| 2410 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2411 | encode_putfh(xdr, args->fh, &hdr); |
| 2412 | encode_lock(xdr, args, &hdr); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2413 | encode_nops(&hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2414 | } |
| 2415 | |
| 2416 | /* |
| 2417 | * Encode a LOCKT request |
| 2418 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2419 | 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] | 2420 | const void *data) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2421 | { |
Christoph Hellwig | fcc8581 | 2017-05-08 10:01:49 +0200 | [diff] [blame] | 2422 | const struct nfs_lockt_args *args = data; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2423 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2424 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2425 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2426 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2427 | encode_compound_hdr(xdr, req, &hdr); |
| 2428 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2429 | encode_putfh(xdr, args->fh, &hdr); |
| 2430 | encode_lockt(xdr, args, &hdr); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2431 | encode_nops(&hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2432 | } |
| 2433 | |
| 2434 | /* |
| 2435 | * Encode a LOCKU request |
| 2436 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2437 | 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] | 2438 | const void *data) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2439 | { |
Christoph Hellwig | fcc8581 | 2017-05-08 10:01:49 +0200 | [diff] [blame] | 2440 | const struct nfs_locku_args *args = data; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2441 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2442 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2443 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2444 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2445 | encode_compound_hdr(xdr, req, &hdr); |
| 2446 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2447 | encode_putfh(xdr, args->fh, &hdr); |
| 2448 | encode_locku(xdr, args, &hdr); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2449 | encode_nops(&hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2450 | } |
| 2451 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2452 | static void nfs4_xdr_enc_release_lockowner(struct rpc_rqst *req, |
| 2453 | struct xdr_stream *xdr, |
Christoph Hellwig | fcc8581 | 2017-05-08 10:01:49 +0200 | [diff] [blame] | 2454 | const void *data) |
Trond Myklebust | d3c7b7c | 2010-07-01 12:49:01 -0400 | [diff] [blame] | 2455 | { |
Christoph Hellwig | fcc8581 | 2017-05-08 10:01:49 +0200 | [diff] [blame] | 2456 | const struct nfs_release_lockowner_args *args = data; |
Trond Myklebust | d3c7b7c | 2010-07-01 12:49:01 -0400 | [diff] [blame] | 2457 | struct compound_hdr hdr = { |
| 2458 | .minorversion = 0, |
| 2459 | }; |
| 2460 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2461 | encode_compound_hdr(xdr, req, &hdr); |
| 2462 | encode_release_lockowner(xdr, &args->lock_owner, &hdr); |
Trond Myklebust | d3c7b7c | 2010-07-01 12:49:01 -0400 | [diff] [blame] | 2463 | encode_nops(&hdr); |
Trond Myklebust | d3c7b7c | 2010-07-01 12:49:01 -0400 | [diff] [blame] | 2464 | } |
| 2465 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2466 | /* |
| 2467 | * Encode a READLINK request |
| 2468 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2469 | 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] | 2470 | const void *data) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2471 | { |
Christoph Hellwig | fcc8581 | 2017-05-08 10:01:49 +0200 | [diff] [blame] | 2472 | const struct nfs4_readlink *args = data; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2473 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2474 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2475 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2476 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2477 | encode_compound_hdr(xdr, req, &hdr); |
| 2478 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2479 | encode_putfh(xdr, args->fh, &hdr); |
| 2480 | encode_readlink(xdr, args, req, &hdr); |
Trond Myklebust | e3a535e | 2007-07-19 10:03:38 -0400 | [diff] [blame] | 2481 | |
Benny Halevy | 28f5669 | 2009-04-01 09:22:09 -0400 | [diff] [blame] | 2482 | xdr_inline_pages(&req->rq_rcv_buf, hdr.replen << 2, args->pages, |
Trond Myklebust | e3a535e | 2007-07-19 10:03:38 -0400 | [diff] [blame] | 2483 | args->pgbase, args->pglen); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2484 | encode_nops(&hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2485 | } |
| 2486 | |
| 2487 | /* |
| 2488 | * Encode a READDIR request |
| 2489 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2490 | 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] | 2491 | const void *data) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2492 | { |
Christoph Hellwig | fcc8581 | 2017-05-08 10:01:49 +0200 | [diff] [blame] | 2493 | const struct nfs4_readdir_arg *args = data; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2494 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2495 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2496 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2497 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2498 | encode_compound_hdr(xdr, req, &hdr); |
| 2499 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2500 | encode_putfh(xdr, args->fh, &hdr); |
| 2501 | encode_readdir(xdr, args, req, &hdr); |
Trond Myklebust | d6ac02d | 2007-07-19 10:03:37 -0400 | [diff] [blame] | 2502 | |
Benny Halevy | 28f5669 | 2009-04-01 09:22:09 -0400 | [diff] [blame] | 2503 | xdr_inline_pages(&req->rq_rcv_buf, hdr.replen << 2, args->pages, |
Trond Myklebust | d6ac02d | 2007-07-19 10:03:37 -0400 | [diff] [blame] | 2504 | args->pgbase, args->count); |
| 2505 | dprintk("%s: inlined page args = (%u, %p, %u, %u)\n", |
Benny Halevy | 28f5669 | 2009-04-01 09:22:09 -0400 | [diff] [blame] | 2506 | __func__, hdr.replen << 2, args->pages, |
Trond Myklebust | d6ac02d | 2007-07-19 10:03:37 -0400 | [diff] [blame] | 2507 | args->pgbase, args->count); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2508 | encode_nops(&hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2509 | } |
| 2510 | |
| 2511 | /* |
| 2512 | * Encode a READ request |
| 2513 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2514 | 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] | 2515 | const void *data) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2516 | { |
Christoph Hellwig | fcc8581 | 2017-05-08 10:01:49 +0200 | [diff] [blame] | 2517 | const struct nfs_pgio_args *args = data; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2518 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2519 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2520 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2521 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2522 | encode_compound_hdr(xdr, req, &hdr); |
| 2523 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2524 | encode_putfh(xdr, args->fh, &hdr); |
| 2525 | encode_read(xdr, args, &hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2526 | |
Benny Halevy | 28f5669 | 2009-04-01 09:22:09 -0400 | [diff] [blame] | 2527 | xdr_inline_pages(&req->rq_rcv_buf, hdr.replen << 2, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2528 | args->pages, args->pgbase, args->count); |
\"Talpey, Thomas\ | 4f22ccc | 2007-09-10 13:44:58 -0400 | [diff] [blame] | 2529 | req->rq_rcv_buf.flags |= XDRBUF_READ; |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2530 | encode_nops(&hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2531 | } |
| 2532 | |
| 2533 | /* |
| 2534 | * Encode an SETATTR request |
| 2535 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2536 | 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] | 2537 | const void *data) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2538 | { |
Christoph Hellwig | fcc8581 | 2017-05-08 10:01:49 +0200 | [diff] [blame] | 2539 | const struct nfs_setattrargs *args = data; |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 2540 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2541 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 2542 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2543 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2544 | encode_compound_hdr(xdr, req, &hdr); |
| 2545 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2546 | encode_putfh(xdr, args->fh, &hdr); |
| 2547 | encode_setattr(xdr, args, args->server, &hdr); |
| 2548 | encode_getfattr(xdr, args->bitmask, &hdr); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2549 | encode_nops(&hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2550 | } |
| 2551 | |
| 2552 | /* |
J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 2553 | * Encode a GETACL request |
| 2554 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2555 | 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] | 2556 | const void *data) |
J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 2557 | { |
Christoph Hellwig | fcc8581 | 2017-05-08 10:01:49 +0200 | [diff] [blame] | 2558 | const struct nfs_getaclargs *args = data; |
J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 2559 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2560 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 2561 | }; |
Benny Halevy | 28f5669 | 2009-04-01 09:22:09 -0400 | [diff] [blame] | 2562 | uint32_t replen; |
J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 2563 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2564 | encode_compound_hdr(xdr, req, &hdr); |
| 2565 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2566 | encode_putfh(xdr, args->fh, &hdr); |
J. Bruce Fields | 6682c14 | 2017-02-23 14:53:39 -0500 | [diff] [blame] | 2567 | replen = hdr.replen + op_decode_hdr_maxsz; |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2568 | encode_getattr_two(xdr, FATTR4_WORD0_ACL, 0, &hdr); |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 2569 | |
Benny Halevy | 28f5669 | 2009-04-01 09:22:09 -0400 | [diff] [blame] | 2570 | xdr_inline_pages(&req->rq_rcv_buf, replen << 2, |
Andreas Gruenbacher | 8fbcf23 | 2015-11-03 18:25:34 +0100 | [diff] [blame] | 2571 | args->acl_pages, 0, args->acl_len); |
Andy Adamson | bf118a3 | 2011-12-07 11:55:27 -0500 | [diff] [blame] | 2572 | |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2573 | encode_nops(&hdr); |
J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 2574 | } |
| 2575 | |
| 2576 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2577 | * Encode a WRITE request |
| 2578 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2579 | 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] | 2580 | const void *data) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2581 | { |
Christoph Hellwig | fcc8581 | 2017-05-08 10:01:49 +0200 | [diff] [blame] | 2582 | const struct nfs_pgio_args *args = data; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2583 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2584 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2585 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2586 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2587 | encode_compound_hdr(xdr, req, &hdr); |
| 2588 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2589 | encode_putfh(xdr, args->fh, &hdr); |
| 2590 | encode_write(xdr, args, &hdr); |
\"Talpey, Thomas\ | 4f22ccc | 2007-09-10 13:44:58 -0400 | [diff] [blame] | 2591 | req->rq_snd_buf.flags |= XDRBUF_WRITE; |
Fred Isaman | 7ffd106 | 2011-03-03 15:13:46 +0000 | [diff] [blame] | 2592 | if (args->bitmask) |
| 2593 | encode_getfattr(xdr, args->bitmask, &hdr); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2594 | encode_nops(&hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2595 | } |
| 2596 | |
| 2597 | /* |
| 2598 | * a COMMIT request |
| 2599 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2600 | 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] | 2601 | const void *data) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2602 | { |
Christoph Hellwig | fcc8581 | 2017-05-08 10:01:49 +0200 | [diff] [blame] | 2603 | const struct nfs_commitargs *args = data; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2604 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2605 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2606 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2607 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2608 | encode_compound_hdr(xdr, req, &hdr); |
| 2609 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2610 | encode_putfh(xdr, args->fh, &hdr); |
| 2611 | encode_commit(xdr, args, &hdr); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2612 | encode_nops(&hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2613 | } |
| 2614 | |
| 2615 | /* |
| 2616 | * FSINFO request |
| 2617 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2618 | 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] | 2619 | const void *data) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2620 | { |
Christoph Hellwig | fcc8581 | 2017-05-08 10:01:49 +0200 | [diff] [blame] | 2621 | const struct nfs4_fsinfo_arg *args = data; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2622 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2623 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2624 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2625 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2626 | encode_compound_hdr(xdr, req, &hdr); |
| 2627 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2628 | encode_putfh(xdr, args->fh, &hdr); |
| 2629 | encode_fsinfo(xdr, args->bitmask, &hdr); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2630 | encode_nops(&hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2631 | } |
| 2632 | |
| 2633 | /* |
| 2634 | * a PATHCONF request |
| 2635 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2636 | 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] | 2637 | const void *data) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2638 | { |
Christoph Hellwig | fcc8581 | 2017-05-08 10:01:49 +0200 | [diff] [blame] | 2639 | const struct nfs4_pathconf_arg *args = data; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2640 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2641 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2642 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2643 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2644 | encode_compound_hdr(xdr, req, &hdr); |
| 2645 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2646 | encode_putfh(xdr, args->fh, &hdr); |
| 2647 | encode_getattr_one(xdr, args->bitmask[0] & nfs4_pathconf_bitmap[0], |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 2648 | &hdr); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2649 | encode_nops(&hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2650 | } |
| 2651 | |
| 2652 | /* |
| 2653 | * a STATFS request |
| 2654 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2655 | 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] | 2656 | const void *data) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2657 | { |
Christoph Hellwig | fcc8581 | 2017-05-08 10:01:49 +0200 | [diff] [blame] | 2658 | const struct nfs4_statfs_arg *args = data; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2659 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2660 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2661 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2662 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2663 | encode_compound_hdr(xdr, req, &hdr); |
| 2664 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2665 | encode_putfh(xdr, args->fh, &hdr); |
| 2666 | encode_getattr_two(xdr, args->bitmask[0] & nfs4_statfs_bitmap[0], |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 2667 | args->bitmask[1] & nfs4_statfs_bitmap[1], &hdr); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2668 | encode_nops(&hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2669 | } |
| 2670 | |
| 2671 | /* |
| 2672 | * GETATTR_BITMAP request |
| 2673 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2674 | static void nfs4_xdr_enc_server_caps(struct rpc_rqst *req, |
| 2675 | struct xdr_stream *xdr, |
Christoph Hellwig | fcc8581 | 2017-05-08 10:01:49 +0200 | [diff] [blame] | 2676 | const void *data) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2677 | { |
Christoph Hellwig | fcc8581 | 2017-05-08 10:01:49 +0200 | [diff] [blame] | 2678 | const struct nfs4_server_caps_arg *args = data; |
Kinglong Mee | 8c61282 | 2015-08-26 21:12:58 +0800 | [diff] [blame] | 2679 | const u32 *bitmask = args->bitmask; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2680 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2681 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2682 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2683 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2684 | encode_compound_hdr(xdr, req, &hdr); |
| 2685 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2686 | encode_putfh(xdr, args->fhandle, &hdr); |
Kinglong Mee | 8c61282 | 2015-08-26 21:12:58 +0800 | [diff] [blame] | 2687 | encode_getattr_three(xdr, bitmask[0], bitmask[1], bitmask[2], &hdr); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2688 | encode_nops(&hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2689 | } |
| 2690 | |
| 2691 | /* |
| 2692 | * a RENEW request |
| 2693 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2694 | 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] | 2695 | const void *data) |
| 2696 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2697 | { |
Christoph Hellwig | fcc8581 | 2017-05-08 10:01:49 +0200 | [diff] [blame] | 2698 | const struct nfs_client *clp = data; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2699 | struct compound_hdr hdr = { |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2700 | .nops = 0, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2701 | }; |
| 2702 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2703 | encode_compound_hdr(xdr, req, &hdr); |
Chuck Lever | bb4dae5 | 2012-03-01 17:01:48 -0500 | [diff] [blame] | 2704 | encode_renew(xdr, clp->cl_clientid, &hdr); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2705 | encode_nops(&hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2706 | } |
| 2707 | |
| 2708 | /* |
| 2709 | * a SETCLIENTID request |
| 2710 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2711 | static void nfs4_xdr_enc_setclientid(struct rpc_rqst *req, |
| 2712 | struct xdr_stream *xdr, |
Christoph Hellwig | fcc8581 | 2017-05-08 10:01:49 +0200 | [diff] [blame] | 2713 | const void *data) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2714 | { |
Christoph Hellwig | fcc8581 | 2017-05-08 10:01:49 +0200 | [diff] [blame] | 2715 | const struct nfs4_setclientid *sc = data; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2716 | struct compound_hdr hdr = { |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2717 | .nops = 0, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2718 | }; |
| 2719 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2720 | encode_compound_hdr(xdr, req, &hdr); |
| 2721 | encode_setclientid(xdr, sc, &hdr); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2722 | encode_nops(&hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2723 | } |
| 2724 | |
| 2725 | /* |
| 2726 | * a SETCLIENTID_CONFIRM request |
| 2727 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2728 | static void nfs4_xdr_enc_setclientid_confirm(struct rpc_rqst *req, |
| 2729 | struct xdr_stream *xdr, |
Christoph Hellwig | fcc8581 | 2017-05-08 10:01:49 +0200 | [diff] [blame] | 2730 | const void *data) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2731 | { |
Christoph Hellwig | fcc8581 | 2017-05-08 10:01:49 +0200 | [diff] [blame] | 2732 | const struct nfs4_setclientid_res *arg = data; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2733 | struct compound_hdr hdr = { |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2734 | .nops = 0, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2735 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2736 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2737 | encode_compound_hdr(xdr, req, &hdr); |
| 2738 | encode_setclientid_confirm(xdr, arg, &hdr); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2739 | encode_nops(&hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2740 | } |
| 2741 | |
| 2742 | /* |
| 2743 | * DELEGRETURN request |
| 2744 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2745 | static void nfs4_xdr_enc_delegreturn(struct rpc_rqst *req, |
| 2746 | struct xdr_stream *xdr, |
Christoph Hellwig | fcc8581 | 2017-05-08 10:01:49 +0200 | [diff] [blame] | 2747 | const void *data) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2748 | { |
Christoph Hellwig | fcc8581 | 2017-05-08 10:01:49 +0200 | [diff] [blame] | 2749 | const struct nfs4_delegreturnargs *args = data; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2750 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2751 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2752 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2753 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2754 | encode_compound_hdr(xdr, req, &hdr); |
| 2755 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2756 | encode_putfh(xdr, args->fhandle, &hdr); |
Trond Myklebust | 586f1c3 | 2016-11-15 15:03:33 -0500 | [diff] [blame] | 2757 | if (args->lr_args) |
| 2758 | encode_layoutreturn(xdr, args->lr_args, &hdr); |
Trond Myklebust | 8ac2b422 | 2016-12-19 10:23:10 -0500 | [diff] [blame] | 2759 | if (args->bitmask) |
| 2760 | encode_getfattr(xdr, args->bitmask, &hdr); |
Trond Myklebust | e144cbc | 2012-04-28 16:05:03 -0400 | [diff] [blame] | 2761 | encode_delegreturn(xdr, args->stateid, &hdr); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2762 | encode_nops(&hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2763 | } |
| 2764 | |
| 2765 | /* |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 2766 | * Encode FS_LOCATIONS request |
| 2767 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2768 | static void nfs4_xdr_enc_fs_locations(struct rpc_rqst *req, |
| 2769 | struct xdr_stream *xdr, |
Christoph Hellwig | fcc8581 | 2017-05-08 10:01:49 +0200 | [diff] [blame] | 2770 | const void *data) |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 2771 | { |
Christoph Hellwig | fcc8581 | 2017-05-08 10:01:49 +0200 | [diff] [blame] | 2772 | const struct nfs4_fs_locations_arg *args = data; |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 2773 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2774 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 2775 | }; |
Benny Halevy | 28f5669 | 2009-04-01 09:22:09 -0400 | [diff] [blame] | 2776 | uint32_t replen; |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 2777 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2778 | encode_compound_hdr(xdr, req, &hdr); |
| 2779 | encode_sequence(xdr, &args->seq_args, &hdr); |
Chuck Lever | b03d735 | 2013-10-17 14:12:50 -0400 | [diff] [blame] | 2780 | if (args->migration) { |
| 2781 | encode_putfh(xdr, args->fh, &hdr); |
| 2782 | replen = hdr.replen; |
| 2783 | encode_fs_locations(xdr, args->bitmask, &hdr); |
| 2784 | if (args->renew) |
| 2785 | encode_renew(xdr, args->clientid, &hdr); |
| 2786 | } else { |
| 2787 | encode_putfh(xdr, args->dir_fh, &hdr); |
| 2788 | encode_lookup(xdr, args->name, &hdr); |
| 2789 | replen = hdr.replen; |
| 2790 | encode_fs_locations(xdr, args->bitmask, &hdr); |
| 2791 | } |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 2792 | |
Chuck Lever | b03d735 | 2013-10-17 14:12:50 -0400 | [diff] [blame] | 2793 | /* Set up reply kvec to capture returned fs_locations array. */ |
Christoph Hellwig | fcc8581 | 2017-05-08 10:01:49 +0200 | [diff] [blame] | 2794 | xdr_inline_pages(&req->rq_rcv_buf, replen << 2, |
| 2795 | (struct page **)&args->page, 0, PAGE_SIZE); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2796 | encode_nops(&hdr); |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 2797 | } |
| 2798 | |
Bryan Schumaker | 5a5ea0d | 2011-03-24 17:12:29 +0000 | [diff] [blame] | 2799 | /* |
| 2800 | * Encode SECINFO request |
| 2801 | */ |
| 2802 | static void nfs4_xdr_enc_secinfo(struct rpc_rqst *req, |
| 2803 | struct xdr_stream *xdr, |
Christoph Hellwig | fcc8581 | 2017-05-08 10:01:49 +0200 | [diff] [blame] | 2804 | const void *data) |
Bryan Schumaker | 5a5ea0d | 2011-03-24 17:12:29 +0000 | [diff] [blame] | 2805 | { |
Christoph Hellwig | fcc8581 | 2017-05-08 10:01:49 +0200 | [diff] [blame] | 2806 | const struct nfs4_secinfo_arg *args = data; |
Bryan Schumaker | 5a5ea0d | 2011-03-24 17:12:29 +0000 | [diff] [blame] | 2807 | struct compound_hdr hdr = { |
| 2808 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
| 2809 | }; |
| 2810 | |
| 2811 | encode_compound_hdr(xdr, req, &hdr); |
| 2812 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2813 | encode_putfh(xdr, args->dir_fh, &hdr); |
| 2814 | encode_secinfo(xdr, args->name, &hdr); |
| 2815 | encode_nops(&hdr); |
| 2816 | } |
| 2817 | |
Chuck Lever | 44c9993 | 2013-10-17 14:13:30 -0400 | [diff] [blame] | 2818 | /* |
| 2819 | * Encode FSID_PRESENT request |
| 2820 | */ |
| 2821 | static void nfs4_xdr_enc_fsid_present(struct rpc_rqst *req, |
| 2822 | struct xdr_stream *xdr, |
Christoph Hellwig | fcc8581 | 2017-05-08 10:01:49 +0200 | [diff] [blame] | 2823 | const void *data) |
Chuck Lever | 44c9993 | 2013-10-17 14:13:30 -0400 | [diff] [blame] | 2824 | { |
Christoph Hellwig | fcc8581 | 2017-05-08 10:01:49 +0200 | [diff] [blame] | 2825 | const struct nfs4_fsid_present_arg *args = data; |
Chuck Lever | 44c9993 | 2013-10-17 14:13:30 -0400 | [diff] [blame] | 2826 | struct compound_hdr hdr = { |
| 2827 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
| 2828 | }; |
| 2829 | |
| 2830 | encode_compound_hdr(xdr, req, &hdr); |
| 2831 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2832 | encode_putfh(xdr, args->fh, &hdr); |
| 2833 | encode_getfh(xdr, &hdr); |
| 2834 | if (args->renew) |
| 2835 | encode_renew(xdr, args->clientid, &hdr); |
| 2836 | encode_nops(&hdr); |
| 2837 | } |
| 2838 | |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 2839 | #if defined(CONFIG_NFS_V4_1) |
| 2840 | /* |
Weston Andros Adamson | 7c44f1ae | 2012-05-24 13:22:50 -0400 | [diff] [blame] | 2841 | * BIND_CONN_TO_SESSION request |
| 2842 | */ |
| 2843 | static void nfs4_xdr_enc_bind_conn_to_session(struct rpc_rqst *req, |
| 2844 | struct xdr_stream *xdr, |
Christoph Hellwig | fcc8581 | 2017-05-08 10:01:49 +0200 | [diff] [blame] | 2845 | const void *data) |
Weston Andros Adamson | 7c44f1ae | 2012-05-24 13:22:50 -0400 | [diff] [blame] | 2846 | { |
Christoph Hellwig | fcc8581 | 2017-05-08 10:01:49 +0200 | [diff] [blame] | 2847 | const struct nfs41_bind_conn_to_session_args *args = data; |
Weston Andros Adamson | 7c44f1ae | 2012-05-24 13:22:50 -0400 | [diff] [blame] | 2848 | struct compound_hdr hdr = { |
Trond Myklebust | 71a097c | 2015-02-18 09:27:18 -0800 | [diff] [blame] | 2849 | .minorversion = args->client->cl_mvops->minor_version, |
Weston Andros Adamson | 7c44f1ae | 2012-05-24 13:22:50 -0400 | [diff] [blame] | 2850 | }; |
| 2851 | |
| 2852 | encode_compound_hdr(xdr, req, &hdr); |
Trond Myklebust | 71a097c | 2015-02-18 09:27:18 -0800 | [diff] [blame] | 2853 | encode_bind_conn_to_session(xdr, args, &hdr); |
Weston Andros Adamson | 7c44f1ae | 2012-05-24 13:22:50 -0400 | [diff] [blame] | 2854 | encode_nops(&hdr); |
| 2855 | } |
| 2856 | |
| 2857 | /* |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 2858 | * EXCHANGE_ID request |
| 2859 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2860 | static void nfs4_xdr_enc_exchange_id(struct rpc_rqst *req, |
| 2861 | struct xdr_stream *xdr, |
Christoph Hellwig | fcc8581 | 2017-05-08 10:01:49 +0200 | [diff] [blame] | 2862 | const void *data) |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 2863 | { |
Christoph Hellwig | fcc8581 | 2017-05-08 10:01:49 +0200 | [diff] [blame] | 2864 | const struct nfs41_exchange_id_args *args = data; |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 2865 | struct compound_hdr hdr = { |
Trond Myklebust | a443234 | 2010-06-16 09:52:27 -0400 | [diff] [blame] | 2866 | .minorversion = args->client->cl_mvops->minor_version, |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 2867 | }; |
| 2868 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2869 | encode_compound_hdr(xdr, req, &hdr); |
| 2870 | encode_exchange_id(xdr, args, &hdr); |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 2871 | encode_nops(&hdr); |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 2872 | } |
Andy Adamson | 2050f0c | 2009-04-01 09:22:30 -0400 | [diff] [blame] | 2873 | |
| 2874 | /* |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 2875 | * a CREATE_SESSION request |
| 2876 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2877 | static void nfs4_xdr_enc_create_session(struct rpc_rqst *req, |
| 2878 | struct xdr_stream *xdr, |
Christoph Hellwig | fcc8581 | 2017-05-08 10:01:49 +0200 | [diff] [blame] | 2879 | const void *data) |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 2880 | { |
Christoph Hellwig | fcc8581 | 2017-05-08 10:01:49 +0200 | [diff] [blame] | 2881 | const struct nfs41_create_session_args *args = data; |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 2882 | struct compound_hdr hdr = { |
Trond Myklebust | a443234 | 2010-06-16 09:52:27 -0400 | [diff] [blame] | 2883 | .minorversion = args->client->cl_mvops->minor_version, |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 2884 | }; |
| 2885 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2886 | encode_compound_hdr(xdr, req, &hdr); |
| 2887 | encode_create_session(xdr, args, &hdr); |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 2888 | encode_nops(&hdr); |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 2889 | } |
| 2890 | |
| 2891 | /* |
Andy Adamson | 0f3e66c | 2009-04-01 09:22:34 -0400 | [diff] [blame] | 2892 | * a DESTROY_SESSION request |
| 2893 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2894 | static void nfs4_xdr_enc_destroy_session(struct rpc_rqst *req, |
| 2895 | struct xdr_stream *xdr, |
Christoph Hellwig | fcc8581 | 2017-05-08 10:01:49 +0200 | [diff] [blame] | 2896 | const void *data) |
Andy Adamson | 0f3e66c | 2009-04-01 09:22:34 -0400 | [diff] [blame] | 2897 | { |
Christoph Hellwig | fcc8581 | 2017-05-08 10:01:49 +0200 | [diff] [blame] | 2898 | const struct nfs4_session *session = data; |
Andy Adamson | 0f3e66c | 2009-04-01 09:22:34 -0400 | [diff] [blame] | 2899 | struct compound_hdr hdr = { |
Trond Myklebust | a443234 | 2010-06-16 09:52:27 -0400 | [diff] [blame] | 2900 | .minorversion = session->clp->cl_mvops->minor_version, |
Andy Adamson | 0f3e66c | 2009-04-01 09:22:34 -0400 | [diff] [blame] | 2901 | }; |
| 2902 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2903 | encode_compound_hdr(xdr, req, &hdr); |
| 2904 | encode_destroy_session(xdr, session, &hdr); |
Andy Adamson | 0f3e66c | 2009-04-01 09:22:34 -0400 | [diff] [blame] | 2905 | encode_nops(&hdr); |
Andy Adamson | 0f3e66c | 2009-04-01 09:22:34 -0400 | [diff] [blame] | 2906 | } |
| 2907 | |
| 2908 | /* |
Trond Myklebust | 6624553 | 2012-05-25 17:18:09 -0400 | [diff] [blame] | 2909 | * a DESTROY_CLIENTID request |
| 2910 | */ |
| 2911 | static void nfs4_xdr_enc_destroy_clientid(struct rpc_rqst *req, |
| 2912 | struct xdr_stream *xdr, |
Christoph Hellwig | fcc8581 | 2017-05-08 10:01:49 +0200 | [diff] [blame] | 2913 | const void *data) |
Trond Myklebust | 6624553 | 2012-05-25 17:18:09 -0400 | [diff] [blame] | 2914 | { |
Christoph Hellwig | fcc8581 | 2017-05-08 10:01:49 +0200 | [diff] [blame] | 2915 | const struct nfs_client *clp = data; |
Trond Myklebust | 6624553 | 2012-05-25 17:18:09 -0400 | [diff] [blame] | 2916 | struct compound_hdr hdr = { |
| 2917 | .minorversion = clp->cl_mvops->minor_version, |
| 2918 | }; |
| 2919 | |
| 2920 | encode_compound_hdr(xdr, req, &hdr); |
| 2921 | encode_destroy_clientid(xdr, clp->cl_clientid, &hdr); |
| 2922 | encode_nops(&hdr); |
| 2923 | } |
| 2924 | |
| 2925 | /* |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 2926 | * a SEQUENCE request |
| 2927 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2928 | 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] | 2929 | const void *data) |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 2930 | { |
Christoph Hellwig | fcc8581 | 2017-05-08 10:01:49 +0200 | [diff] [blame] | 2931 | const struct nfs4_sequence_args *args = data; |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 2932 | struct compound_hdr hdr = { |
| 2933 | .minorversion = nfs4_xdr_minorversion(args), |
| 2934 | }; |
| 2935 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2936 | encode_compound_hdr(xdr, req, &hdr); |
| 2937 | encode_sequence(xdr, args, &hdr); |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 2938 | encode_nops(&hdr); |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 2939 | } |
| 2940 | |
| 2941 | /* |
Andy Adamson | 2050f0c | 2009-04-01 09:22:30 -0400 | [diff] [blame] | 2942 | * a GET_LEASE_TIME request |
| 2943 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2944 | static void nfs4_xdr_enc_get_lease_time(struct rpc_rqst *req, |
| 2945 | struct xdr_stream *xdr, |
Christoph Hellwig | fcc8581 | 2017-05-08 10:01:49 +0200 | [diff] [blame] | 2946 | const void *data) |
Andy Adamson | 2050f0c | 2009-04-01 09:22:30 -0400 | [diff] [blame] | 2947 | { |
Christoph Hellwig | fcc8581 | 2017-05-08 10:01:49 +0200 | [diff] [blame] | 2948 | const struct nfs4_get_lease_time_args *args = data; |
Andy Adamson | 2050f0c | 2009-04-01 09:22:30 -0400 | [diff] [blame] | 2949 | struct compound_hdr hdr = { |
| 2950 | .minorversion = nfs4_xdr_minorversion(&args->la_seq_args), |
| 2951 | }; |
Fred Isaman | dae100c | 2011-07-30 20:52:37 -0400 | [diff] [blame] | 2952 | const u32 lease_bitmap[3] = { FATTR4_WORD0_LEASE_TIME }; |
Andy Adamson | 2050f0c | 2009-04-01 09:22:30 -0400 | [diff] [blame] | 2953 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2954 | encode_compound_hdr(xdr, req, &hdr); |
| 2955 | encode_sequence(xdr, &args->la_seq_args, &hdr); |
| 2956 | encode_putrootfh(xdr, &hdr); |
| 2957 | encode_fsinfo(xdr, lease_bitmap, &hdr); |
Andy Adamson | 2050f0c | 2009-04-01 09:22:30 -0400 | [diff] [blame] | 2958 | encode_nops(&hdr); |
Andy Adamson | 2050f0c | 2009-04-01 09:22:30 -0400 | [diff] [blame] | 2959 | } |
Ricardo Labiaga | 18019753 | 2009-12-05 16:08:40 -0500 | [diff] [blame] | 2960 | |
| 2961 | /* |
| 2962 | * a RECLAIM_COMPLETE request |
| 2963 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2964 | static void nfs4_xdr_enc_reclaim_complete(struct rpc_rqst *req, |
| 2965 | struct xdr_stream *xdr, |
Christoph Hellwig | fcc8581 | 2017-05-08 10:01:49 +0200 | [diff] [blame] | 2966 | const void *data) |
Ricardo Labiaga | 18019753 | 2009-12-05 16:08:40 -0500 | [diff] [blame] | 2967 | { |
Christoph Hellwig | fcc8581 | 2017-05-08 10:01:49 +0200 | [diff] [blame] | 2968 | const struct nfs41_reclaim_complete_args *args = data; |
Ricardo Labiaga | 18019753 | 2009-12-05 16:08:40 -0500 | [diff] [blame] | 2969 | struct compound_hdr hdr = { |
| 2970 | .minorversion = nfs4_xdr_minorversion(&args->seq_args) |
| 2971 | }; |
| 2972 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2973 | encode_compound_hdr(xdr, req, &hdr); |
| 2974 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2975 | encode_reclaim_complete(xdr, args, &hdr); |
Ricardo Labiaga | 18019753 | 2009-12-05 16:08:40 -0500 | [diff] [blame] | 2976 | encode_nops(&hdr); |
Ricardo Labiaga | 18019753 | 2009-12-05 16:08:40 -0500 | [diff] [blame] | 2977 | } |
| 2978 | |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 2979 | /* |
| 2980 | * Encode GETDEVICEINFO request |
| 2981 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2982 | static void nfs4_xdr_enc_getdeviceinfo(struct rpc_rqst *req, |
| 2983 | struct xdr_stream *xdr, |
Christoph Hellwig | fcc8581 | 2017-05-08 10:01:49 +0200 | [diff] [blame] | 2984 | const void *data) |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 2985 | { |
Christoph Hellwig | fcc8581 | 2017-05-08 10:01:49 +0200 | [diff] [blame] | 2986 | const struct nfs4_getdeviceinfo_args *args = data; |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 2987 | struct compound_hdr hdr = { |
| 2988 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
| 2989 | }; |
| 2990 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2991 | encode_compound_hdr(xdr, req, &hdr); |
| 2992 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2993 | encode_getdeviceinfo(xdr, args, &hdr); |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 2994 | |
| 2995 | /* set up reply kvec. Subtract notification bitmap max size (2) |
| 2996 | * so that notification bitmap is put in xdr_buf tail */ |
| 2997 | xdr_inline_pages(&req->rq_rcv_buf, (hdr.replen - 2) << 2, |
| 2998 | args->pdev->pages, args->pdev->pgbase, |
| 2999 | args->pdev->pglen); |
| 3000 | |
| 3001 | encode_nops(&hdr); |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 3002 | } |
| 3003 | |
| 3004 | /* |
| 3005 | * Encode LAYOUTGET request |
| 3006 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 3007 | static void nfs4_xdr_enc_layoutget(struct rpc_rqst *req, |
| 3008 | struct xdr_stream *xdr, |
Christoph Hellwig | fcc8581 | 2017-05-08 10:01:49 +0200 | [diff] [blame] | 3009 | const void *data) |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 3010 | { |
Christoph Hellwig | fcc8581 | 2017-05-08 10:01:49 +0200 | [diff] [blame] | 3011 | const struct nfs4_layoutget_args *args = data; |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 3012 | struct compound_hdr hdr = { |
| 3013 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
| 3014 | }; |
| 3015 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 3016 | encode_compound_hdr(xdr, req, &hdr); |
| 3017 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 3018 | encode_putfh(xdr, NFS_FH(args->inode), &hdr); |
| 3019 | encode_layoutget(xdr, args, &hdr); |
Weston Andros Adamson | 35124a0 | 2011-03-24 16:48:21 -0400 | [diff] [blame] | 3020 | |
| 3021 | xdr_inline_pages(&req->rq_rcv_buf, hdr.replen << 2, |
| 3022 | args->layout.pages, 0, args->layout.pglen); |
| 3023 | |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 3024 | encode_nops(&hdr); |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 3025 | } |
Andy Adamson | 863a3c6 | 2011-03-23 13:27:54 +0000 | [diff] [blame] | 3026 | |
| 3027 | /* |
| 3028 | * Encode LAYOUTCOMMIT request |
| 3029 | */ |
Benny Halevy | cbe8260 | 2011-05-22 19:52:37 +0300 | [diff] [blame] | 3030 | static void nfs4_xdr_enc_layoutcommit(struct rpc_rqst *req, |
| 3031 | struct xdr_stream *xdr, |
Christoph Hellwig | fcc8581 | 2017-05-08 10:01:49 +0200 | [diff] [blame] | 3032 | const void *priv) |
Andy Adamson | 863a3c6 | 2011-03-23 13:27:54 +0000 | [diff] [blame] | 3033 | { |
Christoph Hellwig | fcc8581 | 2017-05-08 10:01:49 +0200 | [diff] [blame] | 3034 | const struct nfs4_layoutcommit_args *args = priv; |
Benny Halevy | ac7db72 | 2011-05-22 19:53:48 +0300 | [diff] [blame] | 3035 | struct nfs4_layoutcommit_data *data = |
| 3036 | container_of(args, struct nfs4_layoutcommit_data, args); |
Andy Adamson | 863a3c6 | 2011-03-23 13:27:54 +0000 | [diff] [blame] | 3037 | struct compound_hdr hdr = { |
| 3038 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
| 3039 | }; |
| 3040 | |
| 3041 | encode_compound_hdr(xdr, req, &hdr); |
| 3042 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 3043 | encode_putfh(xdr, NFS_FH(args->inode), &hdr); |
Benny Halevy | ac7db72 | 2011-05-22 19:53:48 +0300 | [diff] [blame] | 3044 | encode_layoutcommit(xdr, data->args.inode, args, &hdr); |
Andy Adamson | 863a3c6 | 2011-03-23 13:27:54 +0000 | [diff] [blame] | 3045 | encode_getfattr(xdr, args->bitmask, &hdr); |
| 3046 | encode_nops(&hdr); |
Benny Halevy | cbe8260 | 2011-05-22 19:52:37 +0300 | [diff] [blame] | 3047 | } |
| 3048 | |
| 3049 | /* |
| 3050 | * Encode LAYOUTRETURN request |
| 3051 | */ |
| 3052 | static void nfs4_xdr_enc_layoutreturn(struct rpc_rqst *req, |
| 3053 | struct xdr_stream *xdr, |
Christoph Hellwig | fcc8581 | 2017-05-08 10:01:49 +0200 | [diff] [blame] | 3054 | const void *data) |
Benny Halevy | cbe8260 | 2011-05-22 19:52:37 +0300 | [diff] [blame] | 3055 | { |
Christoph Hellwig | fcc8581 | 2017-05-08 10:01:49 +0200 | [diff] [blame] | 3056 | const struct nfs4_layoutreturn_args *args = data; |
Benny Halevy | cbe8260 | 2011-05-22 19:52:37 +0300 | [diff] [blame] | 3057 | struct compound_hdr hdr = { |
| 3058 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
| 3059 | }; |
| 3060 | |
| 3061 | encode_compound_hdr(xdr, req, &hdr); |
| 3062 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 3063 | encode_putfh(xdr, NFS_FH(args->inode), &hdr); |
| 3064 | encode_layoutreturn(xdr, args, &hdr); |
| 3065 | encode_nops(&hdr); |
Andy Adamson | 863a3c6 | 2011-03-23 13:27:54 +0000 | [diff] [blame] | 3066 | } |
Bryan Schumaker | fca78d6 | 2011-06-02 14:59:07 -0400 | [diff] [blame] | 3067 | |
| 3068 | /* |
| 3069 | * Encode SECINFO_NO_NAME request |
| 3070 | */ |
Christoph Hellwig | fcc8581 | 2017-05-08 10:01:49 +0200 | [diff] [blame] | 3071 | static void nfs4_xdr_enc_secinfo_no_name(struct rpc_rqst *req, |
Bryan Schumaker | fca78d6 | 2011-06-02 14:59:07 -0400 | [diff] [blame] | 3072 | struct xdr_stream *xdr, |
Christoph Hellwig | fcc8581 | 2017-05-08 10:01:49 +0200 | [diff] [blame] | 3073 | const void *data) |
Bryan Schumaker | fca78d6 | 2011-06-02 14:59:07 -0400 | [diff] [blame] | 3074 | { |
Christoph Hellwig | fcc8581 | 2017-05-08 10:01:49 +0200 | [diff] [blame] | 3075 | const struct nfs41_secinfo_no_name_args *args = data; |
Bryan Schumaker | fca78d6 | 2011-06-02 14:59:07 -0400 | [diff] [blame] | 3076 | struct compound_hdr hdr = { |
| 3077 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
| 3078 | }; |
| 3079 | |
| 3080 | encode_compound_hdr(xdr, req, &hdr); |
| 3081 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 3082 | encode_putrootfh(xdr, &hdr); |
| 3083 | encode_secinfo_no_name(xdr, args, &hdr); |
| 3084 | encode_nops(&hdr); |
Bryan Schumaker | fca78d6 | 2011-06-02 14:59:07 -0400 | [diff] [blame] | 3085 | } |
Bryan Schumaker | 7d97479 | 2011-06-02 14:59:08 -0400 | [diff] [blame] | 3086 | |
| 3087 | /* |
| 3088 | * Encode TEST_STATEID request |
| 3089 | */ |
| 3090 | static void nfs4_xdr_enc_test_stateid(struct rpc_rqst *req, |
| 3091 | struct xdr_stream *xdr, |
Christoph Hellwig | fcc8581 | 2017-05-08 10:01:49 +0200 | [diff] [blame] | 3092 | const void *data) |
Bryan Schumaker | 7d97479 | 2011-06-02 14:59:08 -0400 | [diff] [blame] | 3093 | { |
Christoph Hellwig | fcc8581 | 2017-05-08 10:01:49 +0200 | [diff] [blame] | 3094 | const struct nfs41_test_stateid_args *args = data; |
Bryan Schumaker | 7d97479 | 2011-06-02 14:59:08 -0400 | [diff] [blame] | 3095 | struct compound_hdr hdr = { |
| 3096 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
| 3097 | }; |
| 3098 | |
| 3099 | encode_compound_hdr(xdr, req, &hdr); |
| 3100 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 3101 | encode_test_stateid(xdr, args, &hdr); |
| 3102 | encode_nops(&hdr); |
| 3103 | } |
Bryan Schumaker | 9aeda35 | 2011-06-02 14:59:09 -0400 | [diff] [blame] | 3104 | |
| 3105 | /* |
| 3106 | * Encode FREE_STATEID request |
| 3107 | */ |
| 3108 | static void nfs4_xdr_enc_free_stateid(struct rpc_rqst *req, |
| 3109 | struct xdr_stream *xdr, |
Christoph Hellwig | fcc8581 | 2017-05-08 10:01:49 +0200 | [diff] [blame] | 3110 | const void *data) |
Bryan Schumaker | 9aeda35 | 2011-06-02 14:59:09 -0400 | [diff] [blame] | 3111 | { |
Christoph Hellwig | fcc8581 | 2017-05-08 10:01:49 +0200 | [diff] [blame] | 3112 | const struct nfs41_free_stateid_args *args = data; |
Bryan Schumaker | 9aeda35 | 2011-06-02 14:59:09 -0400 | [diff] [blame] | 3113 | struct compound_hdr hdr = { |
| 3114 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
| 3115 | }; |
| 3116 | |
| 3117 | encode_compound_hdr(xdr, req, &hdr); |
| 3118 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 3119 | encode_free_stateid(xdr, args, &hdr); |
| 3120 | encode_nops(&hdr); |
| 3121 | } |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 3122 | #endif /* CONFIG_NFS_V4_1 */ |
| 3123 | |
Benny Halevy | 686841b | 2009-08-14 17:19:48 +0300 | [diff] [blame] | 3124 | static void print_overflow_msg(const char *func, const struct xdr_stream *xdr) |
| 3125 | { |
| 3126 | dprintk("nfs: %s: prematurely hit end of receive buffer. " |
| 3127 | "Remaining buffer length is %tu words.\n", |
| 3128 | func, xdr->end - xdr->p); |
| 3129 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3130 | |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 3131 | 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] | 3132 | { |
Trond Myklebust | 6da59ce | 2017-02-19 16:08:27 -0500 | [diff] [blame] | 3133 | ssize_t ret = xdr_stream_decode_opaque_inline(xdr, (void **)string, |
| 3134 | NFS4_OPAQUE_LIMIT); |
| 3135 | if (unlikely(ret < 0)) { |
| 3136 | if (ret == -EBADMSG) |
| 3137 | print_overflow_msg(__func__, xdr); |
| 3138 | return -EIO; |
| 3139 | } |
| 3140 | *len = ret; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3141 | return 0; |
| 3142 | } |
| 3143 | |
| 3144 | static int decode_compound_hdr(struct xdr_stream *xdr, struct compound_hdr *hdr) |
| 3145 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3146 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3147 | |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3148 | p = xdr_inline_decode(xdr, 8); |
| 3149 | if (unlikely(!p)) |
| 3150 | goto out_overflow; |
Benny Halevy | 6f723f7 | 2009-08-14 17:19:37 +0300 | [diff] [blame] | 3151 | hdr->status = be32_to_cpup(p++); |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3152 | hdr->taglen = be32_to_cpup(p); |
Andy Adamson | 6c0195a | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 3153 | |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3154 | p = xdr_inline_decode(xdr, hdr->taglen + 4); |
| 3155 | if (unlikely(!p)) |
| 3156 | goto out_overflow; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3157 | hdr->tag = (char *)p; |
| 3158 | p += XDR_QUADLEN(hdr->taglen); |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3159 | hdr->nops = be32_to_cpup(p); |
Benny Halevy | aadf615 | 2008-12-23 16:06:13 -0500 | [diff] [blame] | 3160 | if (unlikely(hdr->nops < 1)) |
| 3161 | return nfs4_stat_to_errno(hdr->status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3162 | return 0; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3163 | out_overflow: |
| 3164 | print_overflow_msg(__func__, xdr); |
| 3165 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3166 | } |
| 3167 | |
Trond Myklebust | c7848f6 | 2013-12-04 17:39:23 -0500 | [diff] [blame] | 3168 | static bool __decode_op_hdr(struct xdr_stream *xdr, enum nfs_opnum4 expected, |
| 3169 | int *nfs_retval) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3170 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3171 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3172 | uint32_t opnum; |
| 3173 | int32_t nfserr; |
| 3174 | |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3175 | p = xdr_inline_decode(xdr, 8); |
| 3176 | if (unlikely(!p)) |
| 3177 | goto out_overflow; |
Benny Halevy | 6f723f7 | 2009-08-14 17:19:37 +0300 | [diff] [blame] | 3178 | opnum = be32_to_cpup(p++); |
Trond Myklebust | c7848f6 | 2013-12-04 17:39:23 -0500 | [diff] [blame] | 3179 | if (unlikely(opnum != expected)) |
| 3180 | goto out_bad_operation; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3181 | nfserr = be32_to_cpup(p); |
Trond Myklebust | c7848f6 | 2013-12-04 17:39:23 -0500 | [diff] [blame] | 3182 | if (nfserr == NFS_OK) |
| 3183 | *nfs_retval = 0; |
| 3184 | else |
| 3185 | *nfs_retval = nfs4_stat_to_errno(nfserr); |
| 3186 | return true; |
| 3187 | out_bad_operation: |
| 3188 | dprintk("nfs: Server returned operation" |
| 3189 | " %d but we issued a request for %d\n", |
| 3190 | opnum, expected); |
| 3191 | *nfs_retval = -EREMOTEIO; |
| 3192 | return false; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3193 | out_overflow: |
| 3194 | print_overflow_msg(__func__, xdr); |
Trond Myklebust | c7848f6 | 2013-12-04 17:39:23 -0500 | [diff] [blame] | 3195 | *nfs_retval = -EIO; |
| 3196 | return false; |
| 3197 | } |
| 3198 | |
| 3199 | static int decode_op_hdr(struct xdr_stream *xdr, enum nfs_opnum4 expected) |
| 3200 | { |
| 3201 | int retval; |
| 3202 | |
| 3203 | __decode_op_hdr(xdr, expected, &retval); |
| 3204 | return retval; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3205 | } |
| 3206 | |
| 3207 | /* Dummy routine */ |
Trond Myklebust | 1bbe60f | 2017-02-19 16:08:30 -0500 | [diff] [blame] | 3208 | static int decode_ace(struct xdr_stream *xdr, void *ace) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3209 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3210 | __be32 *p; |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 3211 | unsigned int strlen; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3212 | char *str; |
| 3213 | |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3214 | p = xdr_inline_decode(xdr, 12); |
| 3215 | if (likely(p)) |
| 3216 | return decode_opaque_inline(xdr, &strlen, &str); |
| 3217 | print_overflow_msg(__func__, xdr); |
| 3218 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3219 | } |
| 3220 | |
| 3221 | static int decode_attr_bitmap(struct xdr_stream *xdr, uint32_t *bitmap) |
| 3222 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3223 | uint32_t bmlen; |
| 3224 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3225 | |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3226 | p = xdr_inline_decode(xdr, 4); |
| 3227 | if (unlikely(!p)) |
| 3228 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3229 | bmlen = be32_to_cpup(p); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3230 | |
Fred Isaman | dae100c | 2011-07-30 20:52:37 -0400 | [diff] [blame] | 3231 | bitmap[0] = bitmap[1] = bitmap[2] = 0; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3232 | p = xdr_inline_decode(xdr, (bmlen << 2)); |
| 3233 | if (unlikely(!p)) |
| 3234 | goto out_overflow; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3235 | if (bmlen > 0) { |
Benny Halevy | 6f723f7 | 2009-08-14 17:19:37 +0300 | [diff] [blame] | 3236 | bitmap[0] = be32_to_cpup(p++); |
Fred Isaman | dae100c | 2011-07-30 20:52:37 -0400 | [diff] [blame] | 3237 | if (bmlen > 1) { |
| 3238 | bitmap[1] = be32_to_cpup(p++); |
| 3239 | if (bmlen > 2) |
| 3240 | bitmap[2] = be32_to_cpup(p); |
| 3241 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3242 | } |
| 3243 | return 0; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3244 | out_overflow: |
| 3245 | print_overflow_msg(__func__, xdr); |
| 3246 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3247 | } |
| 3248 | |
Trond Myklebust | 256e48b | 2012-06-21 11:18:13 -0400 | [diff] [blame] | 3249 | 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] | 3250 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3251 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3252 | |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3253 | p = xdr_inline_decode(xdr, 4); |
| 3254 | if (unlikely(!p)) |
| 3255 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3256 | *attrlen = be32_to_cpup(p); |
Trond Myklebust | 256e48b | 2012-06-21 11:18:13 -0400 | [diff] [blame] | 3257 | *savep = xdr_stream_pos(xdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3258 | return 0; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3259 | out_overflow: |
| 3260 | print_overflow_msg(__func__, xdr); |
| 3261 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3262 | } |
| 3263 | |
| 3264 | static int decode_attr_supported(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t *bitmask) |
| 3265 | { |
| 3266 | if (likely(bitmap[0] & FATTR4_WORD0_SUPPORTED_ATTRS)) { |
Roman Borisov | 3388bff | 2010-10-13 16:54:51 +0400 | [diff] [blame] | 3267 | int ret; |
| 3268 | ret = decode_attr_bitmap(xdr, bitmask); |
| 3269 | if (unlikely(ret < 0)) |
| 3270 | return ret; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3271 | bitmap[0] &= ~FATTR4_WORD0_SUPPORTED_ATTRS; |
| 3272 | } else |
Fred Isaman | dae100c | 2011-07-30 20:52:37 -0400 | [diff] [blame] | 3273 | bitmask[0] = bitmask[1] = bitmask[2] = 0; |
| 3274 | dprintk("%s: bitmask=%08x:%08x:%08x\n", __func__, |
| 3275 | bitmask[0], bitmask[1], bitmask[2]); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3276 | return 0; |
| 3277 | } |
| 3278 | |
| 3279 | static int decode_attr_type(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t *type) |
| 3280 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3281 | __be32 *p; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3282 | int ret = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3283 | |
| 3284 | *type = 0; |
| 3285 | if (unlikely(bitmap[0] & (FATTR4_WORD0_TYPE - 1U))) |
| 3286 | return -EIO; |
| 3287 | if (likely(bitmap[0] & FATTR4_WORD0_TYPE)) { |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3288 | p = xdr_inline_decode(xdr, 4); |
| 3289 | if (unlikely(!p)) |
| 3290 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3291 | *type = be32_to_cpup(p); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3292 | if (*type < NF4REG || *type > NF4NAMEDATTR) { |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3293 | dprintk("%s: bad type %d\n", __func__, *type); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3294 | return -EIO; |
| 3295 | } |
| 3296 | bitmap[0] &= ~FATTR4_WORD0_TYPE; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3297 | ret = NFS_ATTR_FATTR_TYPE; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3298 | } |
Trond Myklebust | bca7947 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 3299 | dprintk("%s: type=0%o\n", __func__, nfs_type2fmt[*type]); |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3300 | return ret; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3301 | out_overflow: |
| 3302 | print_overflow_msg(__func__, xdr); |
| 3303 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3304 | } |
| 3305 | |
Chuck Lever | 264e635 | 2012-03-01 17:02:05 -0500 | [diff] [blame] | 3306 | static int decode_attr_fh_expire_type(struct xdr_stream *xdr, |
| 3307 | uint32_t *bitmap, uint32_t *type) |
| 3308 | { |
| 3309 | __be32 *p; |
| 3310 | |
| 3311 | *type = 0; |
| 3312 | if (unlikely(bitmap[0] & (FATTR4_WORD0_FH_EXPIRE_TYPE - 1U))) |
| 3313 | return -EIO; |
| 3314 | if (likely(bitmap[0] & FATTR4_WORD0_FH_EXPIRE_TYPE)) { |
| 3315 | p = xdr_inline_decode(xdr, 4); |
| 3316 | if (unlikely(!p)) |
| 3317 | goto out_overflow; |
| 3318 | *type = be32_to_cpup(p); |
| 3319 | bitmap[0] &= ~FATTR4_WORD0_FH_EXPIRE_TYPE; |
| 3320 | } |
| 3321 | dprintk("%s: expire type=0x%x\n", __func__, *type); |
| 3322 | return 0; |
| 3323 | out_overflow: |
| 3324 | print_overflow_msg(__func__, xdr); |
| 3325 | return -EIO; |
| 3326 | } |
| 3327 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3328 | static int decode_attr_change(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *change) |
| 3329 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3330 | __be32 *p; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3331 | int ret = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3332 | |
| 3333 | *change = 0; |
| 3334 | if (unlikely(bitmap[0] & (FATTR4_WORD0_CHANGE - 1U))) |
| 3335 | return -EIO; |
| 3336 | if (likely(bitmap[0] & FATTR4_WORD0_CHANGE)) { |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3337 | p = xdr_inline_decode(xdr, 8); |
| 3338 | if (unlikely(!p)) |
| 3339 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3340 | xdr_decode_hyper(p, change); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3341 | bitmap[0] &= ~FATTR4_WORD0_CHANGE; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3342 | ret = NFS_ATTR_FATTR_CHANGE; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3343 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3344 | dprintk("%s: change attribute=%Lu\n", __func__, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3345 | (unsigned long long)*change); |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3346 | return ret; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3347 | out_overflow: |
| 3348 | print_overflow_msg(__func__, xdr); |
| 3349 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3350 | } |
| 3351 | |
| 3352 | static int decode_attr_size(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *size) |
| 3353 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3354 | __be32 *p; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3355 | int ret = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3356 | |
| 3357 | *size = 0; |
| 3358 | if (unlikely(bitmap[0] & (FATTR4_WORD0_SIZE - 1U))) |
| 3359 | return -EIO; |
| 3360 | if (likely(bitmap[0] & FATTR4_WORD0_SIZE)) { |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3361 | p = xdr_inline_decode(xdr, 8); |
| 3362 | if (unlikely(!p)) |
| 3363 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3364 | xdr_decode_hyper(p, size); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3365 | bitmap[0] &= ~FATTR4_WORD0_SIZE; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3366 | ret = NFS_ATTR_FATTR_SIZE; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3367 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3368 | dprintk("%s: file size=%Lu\n", __func__, (unsigned long long)*size); |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3369 | return ret; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3370 | out_overflow: |
| 3371 | print_overflow_msg(__func__, xdr); |
| 3372 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3373 | } |
| 3374 | |
| 3375 | static int decode_attr_link_support(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t *res) |
| 3376 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3377 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3378 | |
| 3379 | *res = 0; |
| 3380 | if (unlikely(bitmap[0] & (FATTR4_WORD0_LINK_SUPPORT - 1U))) |
| 3381 | return -EIO; |
| 3382 | if (likely(bitmap[0] & FATTR4_WORD0_LINK_SUPPORT)) { |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3383 | p = xdr_inline_decode(xdr, 4); |
| 3384 | if (unlikely(!p)) |
| 3385 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3386 | *res = be32_to_cpup(p); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3387 | bitmap[0] &= ~FATTR4_WORD0_LINK_SUPPORT; |
| 3388 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3389 | dprintk("%s: link support=%s\n", __func__, *res == 0 ? "false" : "true"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3390 | return 0; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3391 | out_overflow: |
| 3392 | print_overflow_msg(__func__, xdr); |
| 3393 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3394 | } |
| 3395 | |
| 3396 | static int decode_attr_symlink_support(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t *res) |
| 3397 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3398 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3399 | |
| 3400 | *res = 0; |
| 3401 | if (unlikely(bitmap[0] & (FATTR4_WORD0_SYMLINK_SUPPORT - 1U))) |
| 3402 | return -EIO; |
| 3403 | if (likely(bitmap[0] & FATTR4_WORD0_SYMLINK_SUPPORT)) { |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3404 | p = xdr_inline_decode(xdr, 4); |
| 3405 | if (unlikely(!p)) |
| 3406 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3407 | *res = be32_to_cpup(p); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3408 | bitmap[0] &= ~FATTR4_WORD0_SYMLINK_SUPPORT; |
| 3409 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3410 | dprintk("%s: symlink support=%s\n", __func__, *res == 0 ? "false" : "true"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3411 | return 0; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3412 | out_overflow: |
| 3413 | print_overflow_msg(__func__, xdr); |
| 3414 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3415 | } |
| 3416 | |
Trond Myklebust | 8b4bdcf | 2006-06-09 09:34:19 -0400 | [diff] [blame] | 3417 | 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] | 3418 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3419 | __be32 *p; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3420 | int ret = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3421 | |
| 3422 | fsid->major = 0; |
| 3423 | fsid->minor = 0; |
| 3424 | if (unlikely(bitmap[0] & (FATTR4_WORD0_FSID - 1U))) |
| 3425 | return -EIO; |
| 3426 | if (likely(bitmap[0] & FATTR4_WORD0_FSID)) { |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3427 | p = xdr_inline_decode(xdr, 16); |
| 3428 | if (unlikely(!p)) |
| 3429 | goto out_overflow; |
Benny Halevy | 3ceb4db | 2009-08-14 17:19:41 +0300 | [diff] [blame] | 3430 | p = xdr_decode_hyper(p, &fsid->major); |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3431 | xdr_decode_hyper(p, &fsid->minor); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3432 | bitmap[0] &= ~FATTR4_WORD0_FSID; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3433 | ret = NFS_ATTR_FATTR_FSID; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3434 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3435 | dprintk("%s: fsid=(0x%Lx/0x%Lx)\n", __func__, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3436 | (unsigned long long)fsid->major, |
| 3437 | (unsigned long long)fsid->minor); |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3438 | return ret; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3439 | out_overflow: |
| 3440 | print_overflow_msg(__func__, xdr); |
| 3441 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3442 | } |
| 3443 | |
| 3444 | static int decode_attr_lease_time(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t *res) |
| 3445 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3446 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3447 | |
| 3448 | *res = 60; |
| 3449 | if (unlikely(bitmap[0] & (FATTR4_WORD0_LEASE_TIME - 1U))) |
| 3450 | return -EIO; |
| 3451 | if (likely(bitmap[0] & FATTR4_WORD0_LEASE_TIME)) { |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3452 | p = xdr_inline_decode(xdr, 4); |
| 3453 | if (unlikely(!p)) |
| 3454 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3455 | *res = be32_to_cpup(p); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3456 | bitmap[0] &= ~FATTR4_WORD0_LEASE_TIME; |
| 3457 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3458 | dprintk("%s: file size=%u\n", __func__, (unsigned int)*res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3459 | return 0; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3460 | out_overflow: |
| 3461 | print_overflow_msg(__func__, xdr); |
| 3462 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3463 | } |
| 3464 | |
Trond Myklebust | ee7b75f | 2011-06-16 13:15:41 -0400 | [diff] [blame] | 3465 | 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] | 3466 | { |
| 3467 | __be32 *p; |
| 3468 | |
| 3469 | if (unlikely(bitmap[0] & (FATTR4_WORD0_RDATTR_ERROR - 1U))) |
| 3470 | return -EIO; |
| 3471 | if (likely(bitmap[0] & FATTR4_WORD0_RDATTR_ERROR)) { |
| 3472 | p = xdr_inline_decode(xdr, 4); |
| 3473 | if (unlikely(!p)) |
| 3474 | goto out_overflow; |
| 3475 | bitmap[0] &= ~FATTR4_WORD0_RDATTR_ERROR; |
Trond Myklebust | ee7b75f | 2011-06-16 13:15:41 -0400 | [diff] [blame] | 3476 | *res = -be32_to_cpup(p); |
Bryan Schumaker | ae42c70 | 2010-10-21 16:33:17 -0400 | [diff] [blame] | 3477 | } |
| 3478 | return 0; |
| 3479 | out_overflow: |
| 3480 | print_overflow_msg(__func__, xdr); |
| 3481 | return -EIO; |
| 3482 | } |
| 3483 | |
Kinglong Mee | 8c61282 | 2015-08-26 21:12:58 +0800 | [diff] [blame] | 3484 | static int decode_attr_exclcreat_supported(struct xdr_stream *xdr, |
| 3485 | uint32_t *bitmap, uint32_t *bitmask) |
| 3486 | { |
| 3487 | if (likely(bitmap[2] & FATTR4_WORD2_SUPPATTR_EXCLCREAT)) { |
| 3488 | int ret; |
| 3489 | ret = decode_attr_bitmap(xdr, bitmask); |
| 3490 | if (unlikely(ret < 0)) |
| 3491 | return ret; |
| 3492 | bitmap[2] &= ~FATTR4_WORD2_SUPPATTR_EXCLCREAT; |
| 3493 | } else |
| 3494 | bitmask[0] = bitmask[1] = bitmask[2] = 0; |
| 3495 | dprintk("%s: bitmask=%08x:%08x:%08x\n", __func__, |
| 3496 | bitmask[0], bitmask[1], bitmask[2]); |
| 3497 | return 0; |
| 3498 | } |
| 3499 | |
Bryan Schumaker | ae42c70 | 2010-10-21 16:33:17 -0400 | [diff] [blame] | 3500 | static int decode_attr_filehandle(struct xdr_stream *xdr, uint32_t *bitmap, struct nfs_fh *fh) |
| 3501 | { |
| 3502 | __be32 *p; |
| 3503 | int len; |
| 3504 | |
Trond Myklebust | 7ad0735 | 2010-10-23 15:34:20 -0400 | [diff] [blame] | 3505 | if (fh != NULL) |
| 3506 | memset(fh, 0, sizeof(*fh)); |
Bryan Schumaker | ae42c70 | 2010-10-21 16:33:17 -0400 | [diff] [blame] | 3507 | |
| 3508 | if (unlikely(bitmap[0] & (FATTR4_WORD0_FILEHANDLE - 1U))) |
| 3509 | return -EIO; |
| 3510 | if (likely(bitmap[0] & FATTR4_WORD0_FILEHANDLE)) { |
| 3511 | p = xdr_inline_decode(xdr, 4); |
| 3512 | if (unlikely(!p)) |
| 3513 | goto out_overflow; |
| 3514 | len = be32_to_cpup(p); |
| 3515 | if (len > NFS4_FHSIZE) |
| 3516 | return -EIO; |
Bryan Schumaker | ae42c70 | 2010-10-21 16:33:17 -0400 | [diff] [blame] | 3517 | p = xdr_inline_decode(xdr, len); |
| 3518 | if (unlikely(!p)) |
| 3519 | goto out_overflow; |
Trond Myklebust | 7ad0735 | 2010-10-23 15:34:20 -0400 | [diff] [blame] | 3520 | if (fh != NULL) { |
| 3521 | memcpy(fh->data, p, len); |
| 3522 | fh->size = len; |
| 3523 | } |
Bryan Schumaker | ae42c70 | 2010-10-21 16:33:17 -0400 | [diff] [blame] | 3524 | bitmap[0] &= ~FATTR4_WORD0_FILEHANDLE; |
| 3525 | } |
| 3526 | return 0; |
| 3527 | out_overflow: |
| 3528 | print_overflow_msg(__func__, xdr); |
| 3529 | return -EIO; |
| 3530 | } |
| 3531 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3532 | static int decode_attr_aclsupport(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t *res) |
| 3533 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3534 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3535 | |
Malahal Naineni | a1800ac | 2014-01-27 15:31:09 -0600 | [diff] [blame] | 3536 | *res = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3537 | if (unlikely(bitmap[0] & (FATTR4_WORD0_ACLSUPPORT - 1U))) |
| 3538 | return -EIO; |
| 3539 | if (likely(bitmap[0] & FATTR4_WORD0_ACLSUPPORT)) { |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3540 | p = xdr_inline_decode(xdr, 4); |
| 3541 | if (unlikely(!p)) |
| 3542 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3543 | *res = be32_to_cpup(p); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3544 | bitmap[0] &= ~FATTR4_WORD0_ACLSUPPORT; |
| 3545 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3546 | dprintk("%s: ACLs supported=%u\n", __func__, (unsigned int)*res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3547 | return 0; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3548 | out_overflow: |
| 3549 | print_overflow_msg(__func__, xdr); |
| 3550 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3551 | } |
| 3552 | |
| 3553 | static int decode_attr_fileid(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *fileid) |
| 3554 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3555 | __be32 *p; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3556 | int ret = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3557 | |
| 3558 | *fileid = 0; |
| 3559 | if (unlikely(bitmap[0] & (FATTR4_WORD0_FILEID - 1U))) |
| 3560 | return -EIO; |
| 3561 | if (likely(bitmap[0] & FATTR4_WORD0_FILEID)) { |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3562 | p = xdr_inline_decode(xdr, 8); |
| 3563 | if (unlikely(!p)) |
| 3564 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3565 | xdr_decode_hyper(p, fileid); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3566 | bitmap[0] &= ~FATTR4_WORD0_FILEID; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3567 | ret = NFS_ATTR_FATTR_FILEID; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3568 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3569 | dprintk("%s: fileid=%Lu\n", __func__, (unsigned long long)*fileid); |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3570 | return ret; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3571 | out_overflow: |
| 3572 | print_overflow_msg(__func__, xdr); |
| 3573 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3574 | } |
| 3575 | |
Manoj Naik | 99baf62 | 2006-06-09 09:34:24 -0400 | [diff] [blame] | 3576 | static int decode_attr_mounted_on_fileid(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *fileid) |
| 3577 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3578 | __be32 *p; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3579 | int ret = 0; |
Manoj Naik | 99baf62 | 2006-06-09 09:34:24 -0400 | [diff] [blame] | 3580 | |
| 3581 | *fileid = 0; |
| 3582 | if (unlikely(bitmap[1] & (FATTR4_WORD1_MOUNTED_ON_FILEID - 1U))) |
| 3583 | return -EIO; |
| 3584 | if (likely(bitmap[1] & FATTR4_WORD1_MOUNTED_ON_FILEID)) { |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3585 | p = xdr_inline_decode(xdr, 8); |
| 3586 | if (unlikely(!p)) |
| 3587 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3588 | xdr_decode_hyper(p, fileid); |
Manoj Naik | 99baf62 | 2006-06-09 09:34:24 -0400 | [diff] [blame] | 3589 | bitmap[1] &= ~FATTR4_WORD1_MOUNTED_ON_FILEID; |
Trond Myklebust | 28331a4 | 2011-04-27 13:47:52 -0400 | [diff] [blame] | 3590 | ret = NFS_ATTR_FATTR_MOUNTED_ON_FILEID; |
Manoj Naik | 99baf62 | 2006-06-09 09:34:24 -0400 | [diff] [blame] | 3591 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3592 | dprintk("%s: fileid=%Lu\n", __func__, (unsigned long long)*fileid); |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3593 | return ret; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3594 | out_overflow: |
| 3595 | print_overflow_msg(__func__, xdr); |
| 3596 | return -EIO; |
Manoj Naik | 99baf62 | 2006-06-09 09:34:24 -0400 | [diff] [blame] | 3597 | } |
| 3598 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3599 | static int decode_attr_files_avail(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *res) |
| 3600 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3601 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3602 | int status = 0; |
| 3603 | |
| 3604 | *res = 0; |
| 3605 | if (unlikely(bitmap[0] & (FATTR4_WORD0_FILES_AVAIL - 1U))) |
| 3606 | return -EIO; |
| 3607 | if (likely(bitmap[0] & FATTR4_WORD0_FILES_AVAIL)) { |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3608 | p = xdr_inline_decode(xdr, 8); |
| 3609 | if (unlikely(!p)) |
| 3610 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3611 | xdr_decode_hyper(p, res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3612 | bitmap[0] &= ~FATTR4_WORD0_FILES_AVAIL; |
| 3613 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3614 | dprintk("%s: files avail=%Lu\n", __func__, (unsigned long long)*res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3615 | return status; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3616 | out_overflow: |
| 3617 | print_overflow_msg(__func__, xdr); |
| 3618 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3619 | } |
| 3620 | |
| 3621 | static int decode_attr_files_free(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *res) |
| 3622 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3623 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3624 | int status = 0; |
| 3625 | |
| 3626 | *res = 0; |
| 3627 | if (unlikely(bitmap[0] & (FATTR4_WORD0_FILES_FREE - 1U))) |
| 3628 | return -EIO; |
| 3629 | if (likely(bitmap[0] & FATTR4_WORD0_FILES_FREE)) { |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3630 | p = xdr_inline_decode(xdr, 8); |
| 3631 | if (unlikely(!p)) |
| 3632 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3633 | xdr_decode_hyper(p, res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3634 | bitmap[0] &= ~FATTR4_WORD0_FILES_FREE; |
| 3635 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3636 | dprintk("%s: files free=%Lu\n", __func__, (unsigned long long)*res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3637 | return status; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3638 | out_overflow: |
| 3639 | print_overflow_msg(__func__, xdr); |
| 3640 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3641 | } |
| 3642 | |
| 3643 | static int decode_attr_files_total(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *res) |
| 3644 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3645 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3646 | int status = 0; |
| 3647 | |
| 3648 | *res = 0; |
| 3649 | if (unlikely(bitmap[0] & (FATTR4_WORD0_FILES_TOTAL - 1U))) |
| 3650 | return -EIO; |
| 3651 | if (likely(bitmap[0] & FATTR4_WORD0_FILES_TOTAL)) { |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3652 | p = xdr_inline_decode(xdr, 8); |
| 3653 | if (unlikely(!p)) |
| 3654 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3655 | xdr_decode_hyper(p, res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3656 | bitmap[0] &= ~FATTR4_WORD0_FILES_TOTAL; |
| 3657 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3658 | dprintk("%s: files total=%Lu\n", __func__, (unsigned long long)*res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3659 | return status; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3660 | out_overflow: |
| 3661 | print_overflow_msg(__func__, xdr); |
| 3662 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3663 | } |
| 3664 | |
Manoj Naik | 7aaa0b3 | 2006-06-09 09:34:23 -0400 | [diff] [blame] | 3665 | static int decode_pathname(struct xdr_stream *xdr, struct nfs4_pathname *path) |
| 3666 | { |
Chuck Lever | 464ad6b | 2007-10-26 13:32:08 -0400 | [diff] [blame] | 3667 | u32 n; |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3668 | __be32 *p; |
Manoj Naik | 7aaa0b3 | 2006-06-09 09:34:23 -0400 | [diff] [blame] | 3669 | int status = 0; |
| 3670 | |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3671 | p = xdr_inline_decode(xdr, 4); |
| 3672 | if (unlikely(!p)) |
| 3673 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3674 | n = be32_to_cpup(p); |
Andy Adamson | 33a43f2 | 2006-06-09 09:34:30 -0400 | [diff] [blame] | 3675 | if (n == 0) |
| 3676 | goto root_path; |
Chuck Lever | 02a2976 | 2012-03-01 17:00:31 -0500 | [diff] [blame] | 3677 | dprintk("pathname4: "); |
Trond Myklebust | 809b426 | 2013-03-27 11:54:45 -0400 | [diff] [blame] | 3678 | if (n > NFS4_PATHNAME_MAXCOMPONENTS) { |
| 3679 | dprintk("cannot parse %d components in path\n", n); |
| 3680 | goto out_eio; |
| 3681 | } |
| 3682 | for (path->ncomponents = 0; path->ncomponents < n; path->ncomponents++) { |
Manoj Naik | 7aaa0b3 | 2006-06-09 09:34:23 -0400 | [diff] [blame] | 3683 | struct nfs4_string *component = &path->components[path->ncomponents]; |
| 3684 | status = decode_opaque_inline(xdr, &component->len, &component->data); |
| 3685 | if (unlikely(status != 0)) |
| 3686 | goto out_eio; |
Trond Myklebust | 95a13f7 | 2012-03-14 21:55:01 -0400 | [diff] [blame] | 3687 | ifdebug (XDR) |
Chuck Lever | 02a2976 | 2012-03-01 17:00:31 -0500 | [diff] [blame] | 3688 | pr_cont("%s%.*s ", |
| 3689 | (path->ncomponents != n ? "/ " : ""), |
| 3690 | component->len, component->data); |
Manoj Naik | 7aaa0b3 | 2006-06-09 09:34:23 -0400 | [diff] [blame] | 3691 | } |
| 3692 | out: |
Manoj Naik | 7aaa0b3 | 2006-06-09 09:34:23 -0400 | [diff] [blame] | 3693 | return status; |
Andy Adamson | 33a43f2 | 2006-06-09 09:34:30 -0400 | [diff] [blame] | 3694 | root_path: |
| 3695 | /* a root pathname is sent as a zero component4 */ |
| 3696 | path->ncomponents = 1; |
| 3697 | path->components[0].len=0; |
| 3698 | path->components[0].data=NULL; |
Chuck Lever | 02a2976 | 2012-03-01 17:00:31 -0500 | [diff] [blame] | 3699 | dprintk("pathname4: /\n"); |
Andy Adamson | 33a43f2 | 2006-06-09 09:34:30 -0400 | [diff] [blame] | 3700 | goto out; |
Manoj Naik | 7aaa0b3 | 2006-06-09 09:34:23 -0400 | [diff] [blame] | 3701 | out_eio: |
| 3702 | dprintk(" status %d", status); |
| 3703 | status = -EIO; |
| 3704 | goto out; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3705 | out_overflow: |
| 3706 | print_overflow_msg(__func__, xdr); |
| 3707 | return -EIO; |
Manoj Naik | 7aaa0b3 | 2006-06-09 09:34:23 -0400 | [diff] [blame] | 3708 | } |
| 3709 | |
| 3710 | 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] | 3711 | { |
| 3712 | int n; |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3713 | __be32 *p; |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 3714 | int status = -EIO; |
| 3715 | |
| 3716 | if (unlikely(bitmap[0] & (FATTR4_WORD0_FS_LOCATIONS -1U))) |
| 3717 | goto out; |
| 3718 | status = 0; |
| 3719 | if (unlikely(!(bitmap[0] & FATTR4_WORD0_FS_LOCATIONS))) |
| 3720 | goto out; |
Kinglong Mee | f54423a | 2015-11-18 10:39:26 +0800 | [diff] [blame] | 3721 | bitmap[0] &= ~FATTR4_WORD0_FS_LOCATIONS; |
Trond Myklebust | 8b7e3f4 | 2012-01-30 15:43:56 -0500 | [diff] [blame] | 3722 | status = -EIO; |
| 3723 | /* Ignore borken servers that return unrequested attrs */ |
| 3724 | if (unlikely(res == NULL)) |
| 3725 | goto out; |
Chuck Lever | 02a2976 | 2012-03-01 17:00:31 -0500 | [diff] [blame] | 3726 | dprintk("%s: fsroot:\n", __func__); |
Manoj Naik | 7aaa0b3 | 2006-06-09 09:34:23 -0400 | [diff] [blame] | 3727 | status = decode_pathname(xdr, &res->fs_path); |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 3728 | if (unlikely(status != 0)) |
| 3729 | goto out; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3730 | p = xdr_inline_decode(xdr, 4); |
| 3731 | if (unlikely(!p)) |
| 3732 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3733 | n = be32_to_cpup(p); |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 3734 | if (n <= 0) |
| 3735 | goto out_eio; |
Trond Myklebust | 809b426 | 2013-03-27 11:54:45 -0400 | [diff] [blame] | 3736 | for (res->nlocations = 0; res->nlocations < n; res->nlocations++) { |
Chuck Lever | 464ad6b | 2007-10-26 13:32:08 -0400 | [diff] [blame] | 3737 | u32 m; |
Trond Myklebust | 809b426 | 2013-03-27 11:54:45 -0400 | [diff] [blame] | 3738 | struct nfs4_fs_location *loc; |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 3739 | |
Trond Myklebust | 809b426 | 2013-03-27 11:54:45 -0400 | [diff] [blame] | 3740 | if (res->nlocations == NFS4_FS_LOCATIONS_MAXENTRIES) |
| 3741 | break; |
| 3742 | loc = &res->locations[res->nlocations]; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3743 | p = xdr_inline_decode(xdr, 4); |
| 3744 | if (unlikely(!p)) |
| 3745 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3746 | m = be32_to_cpup(p); |
Manoj Naik | 7aaa0b3 | 2006-06-09 09:34:23 -0400 | [diff] [blame] | 3747 | |
Chuck Lever | 02a2976 | 2012-03-01 17:00:31 -0500 | [diff] [blame] | 3748 | dprintk("%s: servers:\n", __func__); |
Trond Myklebust | 809b426 | 2013-03-27 11:54:45 -0400 | [diff] [blame] | 3749 | for (loc->nservers = 0; loc->nservers < m; loc->nservers++) { |
| 3750 | struct nfs4_string *server; |
| 3751 | |
| 3752 | if (loc->nservers == NFS4_FS_LOCATION_MAXSERVERS) { |
Chuck Lever | 464ad6b | 2007-10-26 13:32:08 -0400 | [diff] [blame] | 3753 | unsigned int i; |
| 3754 | dprintk("%s: using first %u of %u servers " |
| 3755 | "returned for location %u\n", |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3756 | __func__, |
Chuck Lever | 464ad6b | 2007-10-26 13:32:08 -0400 | [diff] [blame] | 3757 | NFS4_FS_LOCATION_MAXSERVERS, |
| 3758 | m, res->nlocations); |
Manoj Naik | 7aaa0b3 | 2006-06-09 09:34:23 -0400 | [diff] [blame] | 3759 | for (i = loc->nservers; i < m; i++) { |
Trond Myklebust | 2e42c3e | 2007-05-14 17:20:41 -0400 | [diff] [blame] | 3760 | unsigned int len; |
Manoj Naik | 7aaa0b3 | 2006-06-09 09:34:23 -0400 | [diff] [blame] | 3761 | char *data; |
| 3762 | status = decode_opaque_inline(xdr, &len, &data); |
| 3763 | if (unlikely(status != 0)) |
| 3764 | goto out_eio; |
| 3765 | } |
Trond Myklebust | 809b426 | 2013-03-27 11:54:45 -0400 | [diff] [blame] | 3766 | break; |
Manoj Naik | 7aaa0b3 | 2006-06-09 09:34:23 -0400 | [diff] [blame] | 3767 | } |
Trond Myklebust | 809b426 | 2013-03-27 11:54:45 -0400 | [diff] [blame] | 3768 | server = &loc->servers[loc->nservers]; |
| 3769 | status = decode_opaque_inline(xdr, &server->len, &server->data); |
| 3770 | if (unlikely(status != 0)) |
| 3771 | goto out_eio; |
| 3772 | dprintk("%s ", server->data); |
Manoj Naik | 7aaa0b3 | 2006-06-09 09:34:23 -0400 | [diff] [blame] | 3773 | } |
| 3774 | status = decode_pathname(xdr, &loc->rootpath); |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 3775 | if (unlikely(status != 0)) |
| 3776 | goto out_eio; |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 3777 | } |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3778 | if (res->nlocations != 0) |
Chuck Lever | 81934dd | 2012-03-01 17:01:57 -0500 | [diff] [blame] | 3779 | status = NFS_ATTR_FATTR_V4_LOCATIONS; |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 3780 | out: |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3781 | dprintk("%s: fs_locations done, error = %d\n", __func__, status); |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 3782 | return status; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3783 | out_overflow: |
| 3784 | print_overflow_msg(__func__, xdr); |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 3785 | out_eio: |
| 3786 | status = -EIO; |
| 3787 | goto out; |
| 3788 | } |
| 3789 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3790 | static int decode_attr_maxfilesize(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *res) |
| 3791 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3792 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3793 | int status = 0; |
| 3794 | |
| 3795 | *res = 0; |
| 3796 | if (unlikely(bitmap[0] & (FATTR4_WORD0_MAXFILESIZE - 1U))) |
| 3797 | return -EIO; |
| 3798 | if (likely(bitmap[0] & FATTR4_WORD0_MAXFILESIZE)) { |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3799 | p = xdr_inline_decode(xdr, 8); |
| 3800 | if (unlikely(!p)) |
| 3801 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3802 | xdr_decode_hyper(p, res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3803 | bitmap[0] &= ~FATTR4_WORD0_MAXFILESIZE; |
| 3804 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3805 | dprintk("%s: maxfilesize=%Lu\n", __func__, (unsigned long long)*res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3806 | return status; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3807 | out_overflow: |
| 3808 | print_overflow_msg(__func__, xdr); |
| 3809 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3810 | } |
| 3811 | |
| 3812 | static int decode_attr_maxlink(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t *maxlink) |
| 3813 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3814 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3815 | int status = 0; |
| 3816 | |
| 3817 | *maxlink = 1; |
| 3818 | if (unlikely(bitmap[0] & (FATTR4_WORD0_MAXLINK - 1U))) |
| 3819 | return -EIO; |
| 3820 | if (likely(bitmap[0] & FATTR4_WORD0_MAXLINK)) { |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3821 | p = xdr_inline_decode(xdr, 4); |
| 3822 | if (unlikely(!p)) |
| 3823 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3824 | *maxlink = be32_to_cpup(p); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3825 | bitmap[0] &= ~FATTR4_WORD0_MAXLINK; |
| 3826 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3827 | dprintk("%s: maxlink=%u\n", __func__, *maxlink); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3828 | return status; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3829 | out_overflow: |
| 3830 | print_overflow_msg(__func__, xdr); |
| 3831 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3832 | } |
| 3833 | |
| 3834 | static int decode_attr_maxname(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t *maxname) |
| 3835 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3836 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3837 | int status = 0; |
| 3838 | |
| 3839 | *maxname = 1024; |
| 3840 | if (unlikely(bitmap[0] & (FATTR4_WORD0_MAXNAME - 1U))) |
| 3841 | return -EIO; |
| 3842 | if (likely(bitmap[0] & FATTR4_WORD0_MAXNAME)) { |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3843 | p = xdr_inline_decode(xdr, 4); |
| 3844 | if (unlikely(!p)) |
| 3845 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3846 | *maxname = be32_to_cpup(p); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3847 | bitmap[0] &= ~FATTR4_WORD0_MAXNAME; |
| 3848 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3849 | dprintk("%s: maxname=%u\n", __func__, *maxname); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3850 | return status; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3851 | out_overflow: |
| 3852 | print_overflow_msg(__func__, xdr); |
| 3853 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3854 | } |
| 3855 | |
| 3856 | static int decode_attr_maxread(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t *res) |
| 3857 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3858 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3859 | int status = 0; |
| 3860 | |
| 3861 | *res = 1024; |
| 3862 | if (unlikely(bitmap[0] & (FATTR4_WORD0_MAXREAD - 1U))) |
| 3863 | return -EIO; |
| 3864 | if (likely(bitmap[0] & FATTR4_WORD0_MAXREAD)) { |
| 3865 | uint64_t maxread; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3866 | p = xdr_inline_decode(xdr, 8); |
| 3867 | if (unlikely(!p)) |
| 3868 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3869 | xdr_decode_hyper(p, &maxread); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3870 | if (maxread > 0x7FFFFFFF) |
| 3871 | maxread = 0x7FFFFFFF; |
| 3872 | *res = (uint32_t)maxread; |
| 3873 | bitmap[0] &= ~FATTR4_WORD0_MAXREAD; |
| 3874 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3875 | dprintk("%s: maxread=%lu\n", __func__, (unsigned long)*res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3876 | return status; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3877 | out_overflow: |
| 3878 | print_overflow_msg(__func__, xdr); |
| 3879 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3880 | } |
| 3881 | |
| 3882 | static int decode_attr_maxwrite(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t *res) |
| 3883 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3884 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3885 | int status = 0; |
| 3886 | |
| 3887 | *res = 1024; |
| 3888 | if (unlikely(bitmap[0] & (FATTR4_WORD0_MAXWRITE - 1U))) |
| 3889 | return -EIO; |
| 3890 | if (likely(bitmap[0] & FATTR4_WORD0_MAXWRITE)) { |
| 3891 | uint64_t maxwrite; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3892 | p = xdr_inline_decode(xdr, 8); |
| 3893 | if (unlikely(!p)) |
| 3894 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3895 | xdr_decode_hyper(p, &maxwrite); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3896 | if (maxwrite > 0x7FFFFFFF) |
| 3897 | maxwrite = 0x7FFFFFFF; |
| 3898 | *res = (uint32_t)maxwrite; |
| 3899 | bitmap[0] &= ~FATTR4_WORD0_MAXWRITE; |
| 3900 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3901 | dprintk("%s: maxwrite=%lu\n", __func__, (unsigned long)*res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3902 | return status; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3903 | out_overflow: |
| 3904 | print_overflow_msg(__func__, xdr); |
| 3905 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3906 | } |
| 3907 | |
Trond Myklebust | bca7947 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 3908 | 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] | 3909 | { |
Trond Myklebust | bca7947 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 3910 | uint32_t tmp; |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3911 | __be32 *p; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3912 | int ret = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3913 | |
| 3914 | *mode = 0; |
| 3915 | if (unlikely(bitmap[1] & (FATTR4_WORD1_MODE - 1U))) |
| 3916 | return -EIO; |
| 3917 | if (likely(bitmap[1] & FATTR4_WORD1_MODE)) { |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3918 | p = xdr_inline_decode(xdr, 4); |
| 3919 | if (unlikely(!p)) |
| 3920 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3921 | tmp = be32_to_cpup(p); |
Trond Myklebust | bca7947 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 3922 | *mode = tmp & ~S_IFMT; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3923 | bitmap[1] &= ~FATTR4_WORD1_MODE; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3924 | ret = NFS_ATTR_FATTR_MODE; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3925 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3926 | dprintk("%s: file mode=0%o\n", __func__, (unsigned int)*mode); |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3927 | return ret; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3928 | out_overflow: |
| 3929 | print_overflow_msg(__func__, xdr); |
| 3930 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3931 | } |
| 3932 | |
| 3933 | static int decode_attr_nlink(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t *nlink) |
| 3934 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3935 | __be32 *p; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3936 | int ret = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3937 | |
| 3938 | *nlink = 1; |
| 3939 | if (unlikely(bitmap[1] & (FATTR4_WORD1_NUMLINKS - 1U))) |
| 3940 | return -EIO; |
| 3941 | if (likely(bitmap[1] & FATTR4_WORD1_NUMLINKS)) { |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3942 | p = xdr_inline_decode(xdr, 4); |
| 3943 | if (unlikely(!p)) |
| 3944 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3945 | *nlink = be32_to_cpup(p); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3946 | bitmap[1] &= ~FATTR4_WORD1_NUMLINKS; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3947 | ret = NFS_ATTR_FATTR_NLINK; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3948 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3949 | dprintk("%s: nlink=%u\n", __func__, (unsigned int)*nlink); |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3950 | return ret; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3951 | out_overflow: |
| 3952 | print_overflow_msg(__func__, xdr); |
| 3953 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3954 | } |
| 3955 | |
Trond Myklebust | 686a816 | 2017-02-19 16:08:32 -0500 | [diff] [blame] | 3956 | static ssize_t decode_nfs4_string(struct xdr_stream *xdr, |
| 3957 | struct nfs4_string *name, gfp_t gfp_flags) |
| 3958 | { |
| 3959 | ssize_t ret; |
| 3960 | |
| 3961 | ret = xdr_stream_decode_string_dup(xdr, &name->data, |
| 3962 | XDR_MAX_NETOBJ, gfp_flags); |
| 3963 | name->len = 0; |
| 3964 | if (ret > 0) |
| 3965 | name->len = ret; |
| 3966 | return ret; |
| 3967 | } |
| 3968 | |
Trond Myklebust | 80e52ac | 2009-08-09 15:06:19 -0400 | [diff] [blame] | 3969 | 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] | 3970 | const struct nfs_server *server, kuid_t *uid, |
Trond Myklebust | 6926afd | 2012-01-07 13:22:46 -0500 | [diff] [blame] | 3971 | struct nfs4_string *owner_name) |
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 | ssize_t len; |
| 3974 | char *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3975 | |
Eric W. Biederman | e578207 | 2013-02-01 14:22:02 -0800 | [diff] [blame] | 3976 | *uid = make_kuid(&init_user_ns, -2); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3977 | if (unlikely(bitmap[1] & (FATTR4_WORD1_OWNER - 1U))) |
| 3978 | return -EIO; |
Trond Myklebust | 686a816 | 2017-02-19 16:08:32 -0500 | [diff] [blame] | 3979 | if (!(bitmap[1] & FATTR4_WORD1_OWNER)) |
| 3980 | return 0; |
| 3981 | bitmap[1] &= ~FATTR4_WORD1_OWNER; |
| 3982 | |
| 3983 | if (owner_name != NULL) { |
| 3984 | len = decode_nfs4_string(xdr, owner_name, GFP_NOWAIT); |
| 3985 | if (len <= 0) |
| 3986 | goto out; |
| 3987 | dprintk("%s: name=%s\n", __func__, owner_name->data); |
| 3988 | return NFS_ATTR_FATTR_OWNER_NAME; |
| 3989 | } else { |
| 3990 | len = xdr_stream_decode_opaque_inline(xdr, (void **)&p, |
| 3991 | XDR_MAX_NETOBJ); |
| 3992 | if (len <= 0 || nfs_map_name_to_uid(server, p, len, uid) != 0) |
| 3993 | goto out; |
| 3994 | dprintk("%s: uid=%d\n", __func__, (int)from_kuid(&init_user_ns, *uid)); |
| 3995 | return NFS_ATTR_FATTR_OWNER; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3996 | } |
Trond Myklebust | 686a816 | 2017-02-19 16:08:32 -0500 | [diff] [blame] | 3997 | out: |
| 3998 | if (len != -EBADMSG) |
| 3999 | return 0; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 4000 | print_overflow_msg(__func__, xdr); |
| 4001 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4002 | } |
| 4003 | |
Trond Myklebust | 80e52ac | 2009-08-09 15:06:19 -0400 | [diff] [blame] | 4004 | 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] | 4005 | const struct nfs_server *server, kgid_t *gid, |
Trond Myklebust | 6926afd | 2012-01-07 13:22:46 -0500 | [diff] [blame] | 4006 | struct nfs4_string *group_name) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4007 | { |
Trond Myklebust | 686a816 | 2017-02-19 16:08:32 -0500 | [diff] [blame] | 4008 | ssize_t len; |
| 4009 | char *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4010 | |
Eric W. Biederman | e578207 | 2013-02-01 14:22:02 -0800 | [diff] [blame] | 4011 | *gid = make_kgid(&init_user_ns, -2); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4012 | if (unlikely(bitmap[1] & (FATTR4_WORD1_OWNER_GROUP - 1U))) |
| 4013 | return -EIO; |
Trond Myklebust | 686a816 | 2017-02-19 16:08:32 -0500 | [diff] [blame] | 4014 | if (!(bitmap[1] & FATTR4_WORD1_OWNER_GROUP)) |
| 4015 | return 0; |
| 4016 | bitmap[1] &= ~FATTR4_WORD1_OWNER_GROUP; |
| 4017 | |
| 4018 | if (group_name != NULL) { |
| 4019 | len = decode_nfs4_string(xdr, group_name, GFP_NOWAIT); |
| 4020 | if (len <= 0) |
| 4021 | goto out; |
| 4022 | dprintk("%s: name=%s\n", __func__, group_name->data); |
Kinglong Mee | 6f1f622 | 2017-03-06 17:49:42 +0800 | [diff] [blame] | 4023 | return NFS_ATTR_FATTR_GROUP_NAME; |
Trond Myklebust | 686a816 | 2017-02-19 16:08:32 -0500 | [diff] [blame] | 4024 | } else { |
| 4025 | len = xdr_stream_decode_opaque_inline(xdr, (void **)&p, |
| 4026 | XDR_MAX_NETOBJ); |
| 4027 | if (len <= 0 || nfs_map_group_to_gid(server, p, len, gid) != 0) |
| 4028 | goto out; |
| 4029 | dprintk("%s: gid=%d\n", __func__, (int)from_kgid(&init_user_ns, *gid)); |
| 4030 | return NFS_ATTR_FATTR_GROUP; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4031 | } |
Trond Myklebust | 686a816 | 2017-02-19 16:08:32 -0500 | [diff] [blame] | 4032 | out: |
| 4033 | if (len != -EBADMSG) |
| 4034 | return 0; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 4035 | print_overflow_msg(__func__, xdr); |
| 4036 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4037 | } |
| 4038 | |
| 4039 | static int decode_attr_rdev(struct xdr_stream *xdr, uint32_t *bitmap, dev_t *rdev) |
| 4040 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 4041 | uint32_t major = 0, minor = 0; |
| 4042 | __be32 *p; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 4043 | int ret = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4044 | |
| 4045 | *rdev = MKDEV(0,0); |
| 4046 | if (unlikely(bitmap[1] & (FATTR4_WORD1_RAWDEV - 1U))) |
| 4047 | return -EIO; |
| 4048 | if (likely(bitmap[1] & FATTR4_WORD1_RAWDEV)) { |
| 4049 | dev_t tmp; |
| 4050 | |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 4051 | p = xdr_inline_decode(xdr, 8); |
| 4052 | if (unlikely(!p)) |
| 4053 | goto out_overflow; |
Benny Halevy | 6f723f7 | 2009-08-14 17:19:37 +0300 | [diff] [blame] | 4054 | major = be32_to_cpup(p++); |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 4055 | minor = be32_to_cpup(p); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4056 | tmp = MKDEV(major, minor); |
| 4057 | if (MAJOR(tmp) == major && MINOR(tmp) == minor) |
| 4058 | *rdev = tmp; |
| 4059 | bitmap[1] &= ~ FATTR4_WORD1_RAWDEV; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 4060 | ret = NFS_ATTR_FATTR_RDEV; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4061 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 4062 | dprintk("%s: rdev=(0x%x:0x%x)\n", __func__, major, minor); |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 4063 | return ret; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 4064 | out_overflow: |
| 4065 | print_overflow_msg(__func__, xdr); |
| 4066 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4067 | } |
| 4068 | |
| 4069 | static int decode_attr_space_avail(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *res) |
| 4070 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 4071 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4072 | int status = 0; |
| 4073 | |
| 4074 | *res = 0; |
| 4075 | if (unlikely(bitmap[1] & (FATTR4_WORD1_SPACE_AVAIL - 1U))) |
| 4076 | return -EIO; |
| 4077 | if (likely(bitmap[1] & FATTR4_WORD1_SPACE_AVAIL)) { |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 4078 | p = xdr_inline_decode(xdr, 8); |
| 4079 | if (unlikely(!p)) |
| 4080 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 4081 | xdr_decode_hyper(p, res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4082 | bitmap[1] &= ~FATTR4_WORD1_SPACE_AVAIL; |
| 4083 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 4084 | dprintk("%s: space avail=%Lu\n", __func__, (unsigned long long)*res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4085 | return status; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 4086 | out_overflow: |
| 4087 | print_overflow_msg(__func__, xdr); |
| 4088 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4089 | } |
| 4090 | |
| 4091 | static int decode_attr_space_free(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *res) |
| 4092 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 4093 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4094 | int status = 0; |
| 4095 | |
| 4096 | *res = 0; |
| 4097 | if (unlikely(bitmap[1] & (FATTR4_WORD1_SPACE_FREE - 1U))) |
| 4098 | return -EIO; |
| 4099 | if (likely(bitmap[1] & FATTR4_WORD1_SPACE_FREE)) { |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 4100 | p = xdr_inline_decode(xdr, 8); |
| 4101 | if (unlikely(!p)) |
| 4102 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 4103 | xdr_decode_hyper(p, res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4104 | bitmap[1] &= ~FATTR4_WORD1_SPACE_FREE; |
| 4105 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 4106 | dprintk("%s: space free=%Lu\n", __func__, (unsigned long long)*res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4107 | return status; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 4108 | out_overflow: |
| 4109 | print_overflow_msg(__func__, xdr); |
| 4110 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4111 | } |
| 4112 | |
| 4113 | static int decode_attr_space_total(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *res) |
| 4114 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 4115 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4116 | int status = 0; |
| 4117 | |
| 4118 | *res = 0; |
| 4119 | if (unlikely(bitmap[1] & (FATTR4_WORD1_SPACE_TOTAL - 1U))) |
| 4120 | return -EIO; |
| 4121 | if (likely(bitmap[1] & FATTR4_WORD1_SPACE_TOTAL)) { |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 4122 | p = xdr_inline_decode(xdr, 8); |
| 4123 | if (unlikely(!p)) |
| 4124 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 4125 | xdr_decode_hyper(p, res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4126 | bitmap[1] &= ~FATTR4_WORD1_SPACE_TOTAL; |
| 4127 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 4128 | dprintk("%s: space total=%Lu\n", __func__, (unsigned long long)*res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4129 | return status; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 4130 | out_overflow: |
| 4131 | print_overflow_msg(__func__, xdr); |
| 4132 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4133 | } |
| 4134 | |
| 4135 | static int decode_attr_space_used(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *used) |
| 4136 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 4137 | __be32 *p; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 4138 | int ret = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4139 | |
| 4140 | *used = 0; |
| 4141 | if (unlikely(bitmap[1] & (FATTR4_WORD1_SPACE_USED - 1U))) |
| 4142 | return -EIO; |
| 4143 | if (likely(bitmap[1] & FATTR4_WORD1_SPACE_USED)) { |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 4144 | p = xdr_inline_decode(xdr, 8); |
| 4145 | if (unlikely(!p)) |
| 4146 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 4147 | xdr_decode_hyper(p, used); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4148 | bitmap[1] &= ~FATTR4_WORD1_SPACE_USED; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 4149 | ret = NFS_ATTR_FATTR_SPACE_USED; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4150 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 4151 | dprintk("%s: space used=%Lu\n", __func__, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4152 | (unsigned long long)*used); |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 4153 | return ret; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 4154 | out_overflow: |
| 4155 | print_overflow_msg(__func__, xdr); |
| 4156 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4157 | } |
| 4158 | |
| 4159 | static int decode_attr_time(struct xdr_stream *xdr, struct timespec *time) |
| 4160 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 4161 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4162 | uint64_t sec; |
| 4163 | uint32_t nsec; |
| 4164 | |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 4165 | p = xdr_inline_decode(xdr, 12); |
| 4166 | if (unlikely(!p)) |
| 4167 | goto out_overflow; |
Benny Halevy | 3ceb4db | 2009-08-14 17:19:41 +0300 | [diff] [blame] | 4168 | p = xdr_decode_hyper(p, &sec); |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 4169 | nsec = be32_to_cpup(p); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4170 | time->tv_sec = (time_t)sec; |
| 4171 | time->tv_nsec = (long)nsec; |
| 4172 | return 0; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 4173 | out_overflow: |
| 4174 | print_overflow_msg(__func__, xdr); |
| 4175 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4176 | } |
| 4177 | |
| 4178 | static int decode_attr_time_access(struct xdr_stream *xdr, uint32_t *bitmap, struct timespec *time) |
| 4179 | { |
| 4180 | int status = 0; |
| 4181 | |
| 4182 | time->tv_sec = 0; |
| 4183 | time->tv_nsec = 0; |
| 4184 | if (unlikely(bitmap[1] & (FATTR4_WORD1_TIME_ACCESS - 1U))) |
| 4185 | return -EIO; |
| 4186 | if (likely(bitmap[1] & FATTR4_WORD1_TIME_ACCESS)) { |
| 4187 | status = decode_attr_time(xdr, time); |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 4188 | if (status == 0) |
| 4189 | status = NFS_ATTR_FATTR_ATIME; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4190 | bitmap[1] &= ~FATTR4_WORD1_TIME_ACCESS; |
| 4191 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 4192 | dprintk("%s: atime=%ld\n", __func__, (long)time->tv_sec); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4193 | return status; |
| 4194 | } |
| 4195 | |
| 4196 | static int decode_attr_time_metadata(struct xdr_stream *xdr, uint32_t *bitmap, struct timespec *time) |
| 4197 | { |
| 4198 | int status = 0; |
| 4199 | |
| 4200 | time->tv_sec = 0; |
| 4201 | time->tv_nsec = 0; |
| 4202 | if (unlikely(bitmap[1] & (FATTR4_WORD1_TIME_METADATA - 1U))) |
| 4203 | return -EIO; |
| 4204 | if (likely(bitmap[1] & FATTR4_WORD1_TIME_METADATA)) { |
| 4205 | status = decode_attr_time(xdr, time); |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 4206 | if (status == 0) |
| 4207 | status = NFS_ATTR_FATTR_CTIME; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4208 | bitmap[1] &= ~FATTR4_WORD1_TIME_METADATA; |
| 4209 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 4210 | dprintk("%s: ctime=%ld\n", __func__, (long)time->tv_sec); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4211 | return status; |
| 4212 | } |
| 4213 | |
Ricardo Labiaga | 55b6e77 | 2010-10-12 16:30:06 -0700 | [diff] [blame] | 4214 | static int decode_attr_time_delta(struct xdr_stream *xdr, uint32_t *bitmap, |
| 4215 | struct timespec *time) |
| 4216 | { |
| 4217 | int status = 0; |
| 4218 | |
| 4219 | time->tv_sec = 0; |
| 4220 | time->tv_nsec = 0; |
| 4221 | if (unlikely(bitmap[1] & (FATTR4_WORD1_TIME_DELTA - 1U))) |
| 4222 | return -EIO; |
| 4223 | if (likely(bitmap[1] & FATTR4_WORD1_TIME_DELTA)) { |
| 4224 | status = decode_attr_time(xdr, time); |
| 4225 | bitmap[1] &= ~FATTR4_WORD1_TIME_DELTA; |
| 4226 | } |
| 4227 | dprintk("%s: time_delta=%ld %ld\n", __func__, (long)time->tv_sec, |
| 4228 | (long)time->tv_nsec); |
| 4229 | return status; |
| 4230 | } |
| 4231 | |
David Quigley | aa9c266 | 2013-05-22 12:50:44 -0400 | [diff] [blame] | 4232 | static int decode_attr_security_label(struct xdr_stream *xdr, uint32_t *bitmap, |
| 4233 | struct nfs4_label *label) |
| 4234 | { |
| 4235 | uint32_t pi = 0; |
| 4236 | uint32_t lfs = 0; |
| 4237 | __u32 len; |
| 4238 | __be32 *p; |
| 4239 | int status = 0; |
| 4240 | |
| 4241 | if (unlikely(bitmap[2] & (FATTR4_WORD2_SECURITY_LABEL - 1U))) |
| 4242 | return -EIO; |
| 4243 | if (likely(bitmap[2] & FATTR4_WORD2_SECURITY_LABEL)) { |
| 4244 | p = xdr_inline_decode(xdr, 4); |
| 4245 | if (unlikely(!p)) |
| 4246 | goto out_overflow; |
| 4247 | lfs = be32_to_cpup(p++); |
| 4248 | p = xdr_inline_decode(xdr, 4); |
| 4249 | if (unlikely(!p)) |
| 4250 | goto out_overflow; |
| 4251 | pi = be32_to_cpup(p++); |
| 4252 | p = xdr_inline_decode(xdr, 4); |
| 4253 | if (unlikely(!p)) |
| 4254 | goto out_overflow; |
| 4255 | len = be32_to_cpup(p++); |
| 4256 | p = xdr_inline_decode(xdr, len); |
| 4257 | if (unlikely(!p)) |
| 4258 | goto out_overflow; |
| 4259 | if (len < NFS4_MAXLABELLEN) { |
| 4260 | if (label) { |
| 4261 | memcpy(label->label, p, len); |
| 4262 | label->len = len; |
| 4263 | label->pi = pi; |
| 4264 | label->lfs = lfs; |
| 4265 | status = NFS_ATTR_FATTR_V4_SECURITY_LABEL; |
| 4266 | } |
| 4267 | bitmap[2] &= ~FATTR4_WORD2_SECURITY_LABEL; |
| 4268 | } else |
| 4269 | printk(KERN_WARNING "%s: label too long (%u)!\n", |
| 4270 | __func__, len); |
| 4271 | } |
| 4272 | if (label && label->label) |
| 4273 | dprintk("%s: label=%s, len=%d, PI=%d, LFS=%d\n", __func__, |
| 4274 | (char *)label->label, label->len, label->pi, label->lfs); |
| 4275 | return status; |
| 4276 | |
| 4277 | out_overflow: |
| 4278 | print_overflow_msg(__func__, xdr); |
| 4279 | return -EIO; |
| 4280 | } |
| 4281 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4282 | static int decode_attr_time_modify(struct xdr_stream *xdr, uint32_t *bitmap, struct timespec *time) |
| 4283 | { |
| 4284 | int status = 0; |
| 4285 | |
| 4286 | time->tv_sec = 0; |
| 4287 | time->tv_nsec = 0; |
| 4288 | if (unlikely(bitmap[1] & (FATTR4_WORD1_TIME_MODIFY - 1U))) |
| 4289 | return -EIO; |
| 4290 | if (likely(bitmap[1] & FATTR4_WORD1_TIME_MODIFY)) { |
| 4291 | status = decode_attr_time(xdr, time); |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 4292 | if (status == 0) |
| 4293 | status = NFS_ATTR_FATTR_MTIME; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4294 | bitmap[1] &= ~FATTR4_WORD1_TIME_MODIFY; |
| 4295 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 4296 | dprintk("%s: mtime=%ld\n", __func__, (long)time->tv_sec); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4297 | return status; |
| 4298 | } |
| 4299 | |
Trond Myklebust | 256e48b | 2012-06-21 11:18:13 -0400 | [diff] [blame] | 4300 | 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] | 4301 | { |
| 4302 | unsigned int attrwords = XDR_QUADLEN(attrlen); |
Trond Myklebust | 256e48b | 2012-06-21 11:18:13 -0400 | [diff] [blame] | 4303 | unsigned int nwords = (xdr_stream_pos(xdr) - savep) >> 2; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4304 | |
| 4305 | if (unlikely(attrwords != nwords)) { |
Chuck Lever | fe82a18 | 2007-09-11 18:01:10 -0400 | [diff] [blame] | 4306 | dprintk("%s: server returned incorrect attribute length: " |
| 4307 | "%u %c %u\n", |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 4308 | __func__, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4309 | attrwords << 2, |
| 4310 | (attrwords < nwords) ? '<' : '>', |
| 4311 | nwords << 2); |
| 4312 | return -EIO; |
| 4313 | } |
| 4314 | return 0; |
| 4315 | } |
| 4316 | |
| 4317 | static int decode_change_info(struct xdr_stream *xdr, struct nfs4_change_info *cinfo) |
| 4318 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 4319 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4320 | |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 4321 | p = xdr_inline_decode(xdr, 20); |
| 4322 | if (unlikely(!p)) |
| 4323 | goto out_overflow; |
Benny Halevy | 6f723f7 | 2009-08-14 17:19:37 +0300 | [diff] [blame] | 4324 | cinfo->atomic = be32_to_cpup(p++); |
Benny Halevy | 3ceb4db | 2009-08-14 17:19:41 +0300 | [diff] [blame] | 4325 | p = xdr_decode_hyper(p, &cinfo->before); |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 4326 | xdr_decode_hyper(p, &cinfo->after); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4327 | return 0; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 4328 | out_overflow: |
| 4329 | print_overflow_msg(__func__, xdr); |
| 4330 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4331 | } |
| 4332 | |
Weston Andros Adamson | 6168f62 | 2012-09-10 14:00:46 -0400 | [diff] [blame] | 4333 | static int decode_access(struct xdr_stream *xdr, u32 *supported, u32 *access) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4334 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 4335 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4336 | uint32_t supp, acc; |
| 4337 | int status; |
| 4338 | |
| 4339 | status = decode_op_hdr(xdr, OP_ACCESS); |
| 4340 | if (status) |
| 4341 | return status; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 4342 | p = xdr_inline_decode(xdr, 8); |
| 4343 | if (unlikely(!p)) |
| 4344 | goto out_overflow; |
Benny Halevy | 6f723f7 | 2009-08-14 17:19:37 +0300 | [diff] [blame] | 4345 | supp = be32_to_cpup(p++); |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 4346 | acc = be32_to_cpup(p); |
Weston Andros Adamson | 6168f62 | 2012-09-10 14:00:46 -0400 | [diff] [blame] | 4347 | *supported = supp; |
| 4348 | *access = acc; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4349 | return 0; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 4350 | out_overflow: |
| 4351 | print_overflow_msg(__func__, xdr); |
| 4352 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4353 | } |
| 4354 | |
Benny Halevy | 07d3043 | 2009-08-14 17:19:52 +0300 | [diff] [blame] | 4355 | 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] | 4356 | { |
Trond Myklebust | ab6e9aa | 2017-02-19 16:08:26 -0500 | [diff] [blame] | 4357 | ssize_t ret = xdr_stream_decode_opaque_fixed(xdr, buf, len); |
| 4358 | if (unlikely(ret < 0)) { |
| 4359 | print_overflow_msg(__func__, xdr); |
| 4360 | return -EIO; |
Benny Halevy | 07d3043 | 2009-08-14 17:19:52 +0300 | [diff] [blame] | 4361 | } |
Trond Myklebust | ab6e9aa | 2017-02-19 16:08:26 -0500 | [diff] [blame] | 4362 | return 0; |
Benny Halevy | 07d3043 | 2009-08-14 17:19:52 +0300 | [diff] [blame] | 4363 | } |
| 4364 | |
| 4365 | static int decode_stateid(struct xdr_stream *xdr, nfs4_stateid *stateid) |
| 4366 | { |
Trond Myklebust | 2d2f24a | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 4367 | return decode_opaque_fixed(xdr, stateid, NFS4_STATEID_SIZE); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4368 | } |
| 4369 | |
Trond Myklebust | 93b717f | 2016-05-16 17:42:43 -0400 | [diff] [blame] | 4370 | static int decode_open_stateid(struct xdr_stream *xdr, nfs4_stateid *stateid) |
| 4371 | { |
| 4372 | stateid->type = NFS4_OPEN_STATEID_TYPE; |
| 4373 | return decode_stateid(xdr, stateid); |
| 4374 | } |
| 4375 | |
| 4376 | static int decode_lock_stateid(struct xdr_stream *xdr, nfs4_stateid *stateid) |
| 4377 | { |
| 4378 | stateid->type = NFS4_LOCK_STATEID_TYPE; |
| 4379 | return decode_stateid(xdr, stateid); |
| 4380 | } |
| 4381 | |
| 4382 | static int decode_delegation_stateid(struct xdr_stream *xdr, nfs4_stateid *stateid) |
| 4383 | { |
| 4384 | stateid->type = NFS4_DELEGATION_STATEID_TYPE; |
| 4385 | return decode_stateid(xdr, stateid); |
| 4386 | } |
| 4387 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4388 | static int decode_close(struct xdr_stream *xdr, struct nfs_closeres *res) |
| 4389 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4390 | int status; |
| 4391 | |
| 4392 | status = decode_op_hdr(xdr, OP_CLOSE); |
Trond Myklebust | c1d5193 | 2008-04-07 13:20:54 -0400 | [diff] [blame] | 4393 | if (status != -EIO) |
| 4394 | nfs_increment_open_seqid(status, res->seqid); |
Benny Halevy | 07d3043 | 2009-08-14 17:19:52 +0300 | [diff] [blame] | 4395 | if (!status) |
Trond Myklebust | 93b717f | 2016-05-16 17:42:43 -0400 | [diff] [blame] | 4396 | status = decode_open_stateid(xdr, &res->stateid); |
Benny Halevy | 07d3043 | 2009-08-14 17:19:52 +0300 | [diff] [blame] | 4397 | return status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4398 | } |
| 4399 | |
Benny Halevy | db942bb | 2009-08-14 17:19:56 +0300 | [diff] [blame] | 4400 | static int decode_verifier(struct xdr_stream *xdr, void *verifier) |
| 4401 | { |
Chuck Lever | cd93710 | 2012-03-02 17:14:31 -0500 | [diff] [blame] | 4402 | return decode_opaque_fixed(xdr, verifier, NFS4_VERIFIER_SIZE); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4403 | } |
| 4404 | |
Trond Myklebust | 2f2c63b | 2012-06-08 11:56:09 -0400 | [diff] [blame] | 4405 | static int decode_write_verifier(struct xdr_stream *xdr, struct nfs_write_verifier *verifier) |
| 4406 | { |
| 4407 | return decode_opaque_fixed(xdr, verifier->data, NFS4_VERIFIER_SIZE); |
| 4408 | } |
| 4409 | |
Fred Isaman | 0b7c015 | 2012-04-20 14:47:39 -0400 | [diff] [blame] | 4410 | static int decode_commit(struct xdr_stream *xdr, struct nfs_commitres *res) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4411 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4412 | int status; |
| 4413 | |
| 4414 | status = decode_op_hdr(xdr, OP_COMMIT); |
Benny Halevy | db942bb | 2009-08-14 17:19:56 +0300 | [diff] [blame] | 4415 | if (!status) |
Trond Myklebust | 2f2c63b | 2012-06-08 11:56:09 -0400 | [diff] [blame] | 4416 | status = decode_write_verifier(xdr, &res->verf->verifier); |
Benny Halevy | db942bb | 2009-08-14 17:19:56 +0300 | [diff] [blame] | 4417 | return status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4418 | } |
| 4419 | |
| 4420 | static int decode_create(struct xdr_stream *xdr, struct nfs4_change_info *cinfo) |
| 4421 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 4422 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4423 | uint32_t bmlen; |
| 4424 | int status; |
| 4425 | |
| 4426 | status = decode_op_hdr(xdr, OP_CREATE); |
| 4427 | if (status) |
| 4428 | return status; |
| 4429 | if ((status = decode_change_info(xdr, cinfo))) |
| 4430 | return status; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 4431 | p = xdr_inline_decode(xdr, 4); |
| 4432 | if (unlikely(!p)) |
| 4433 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 4434 | bmlen = be32_to_cpup(p); |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 4435 | p = xdr_inline_decode(xdr, bmlen << 2); |
| 4436 | if (likely(p)) |
| 4437 | return 0; |
| 4438 | out_overflow: |
| 4439 | print_overflow_msg(__func__, xdr); |
| 4440 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4441 | } |
| 4442 | |
| 4443 | static int decode_server_caps(struct xdr_stream *xdr, struct nfs4_server_caps_res *res) |
| 4444 | { |
Trond Myklebust | 256e48b | 2012-06-21 11:18:13 -0400 | [diff] [blame] | 4445 | unsigned int savep; |
Fred Isaman | dae100c | 2011-07-30 20:52:37 -0400 | [diff] [blame] | 4446 | uint32_t attrlen, bitmap[3] = {0}; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4447 | int status; |
| 4448 | |
| 4449 | if ((status = decode_op_hdr(xdr, OP_GETATTR)) != 0) |
| 4450 | goto xdr_error; |
| 4451 | if ((status = decode_attr_bitmap(xdr, bitmap)) != 0) |
| 4452 | goto xdr_error; |
| 4453 | if ((status = decode_attr_length(xdr, &attrlen, &savep)) != 0) |
| 4454 | goto xdr_error; |
| 4455 | if ((status = decode_attr_supported(xdr, bitmap, res->attr_bitmask)) != 0) |
| 4456 | goto xdr_error; |
Chuck Lever | 264e635 | 2012-03-01 17:02:05 -0500 | [diff] [blame] | 4457 | if ((status = decode_attr_fh_expire_type(xdr, bitmap, |
| 4458 | &res->fh_expire_type)) != 0) |
| 4459 | goto xdr_error; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4460 | if ((status = decode_attr_link_support(xdr, bitmap, &res->has_links)) != 0) |
| 4461 | goto xdr_error; |
| 4462 | if ((status = decode_attr_symlink_support(xdr, bitmap, &res->has_symlinks)) != 0) |
| 4463 | goto xdr_error; |
| 4464 | if ((status = decode_attr_aclsupport(xdr, bitmap, &res->acl_bitmask)) != 0) |
| 4465 | goto xdr_error; |
Kinglong Mee | 8c61282 | 2015-08-26 21:12:58 +0800 | [diff] [blame] | 4466 | if ((status = decode_attr_exclcreat_supported(xdr, bitmap, |
| 4467 | res->exclcreat_bitmask)) != 0) |
| 4468 | goto xdr_error; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4469 | status = verify_attr_len(xdr, savep, attrlen); |
| 4470 | xdr_error: |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 4471 | dprintk("%s: xdr returned %d!\n", __func__, -status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4472 | return status; |
| 4473 | } |
Andy Adamson | 6c0195a | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 4474 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4475 | static int decode_statfs(struct xdr_stream *xdr, struct nfs_fsstat *fsstat) |
| 4476 | { |
Trond Myklebust | 256e48b | 2012-06-21 11:18:13 -0400 | [diff] [blame] | 4477 | unsigned int savep; |
Fred Isaman | dae100c | 2011-07-30 20:52:37 -0400 | [diff] [blame] | 4478 | uint32_t attrlen, bitmap[3] = {0}; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4479 | int status; |
Andy Adamson | 6c0195a | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 4480 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4481 | if ((status = decode_op_hdr(xdr, OP_GETATTR)) != 0) |
| 4482 | goto xdr_error; |
| 4483 | if ((status = decode_attr_bitmap(xdr, bitmap)) != 0) |
| 4484 | goto xdr_error; |
| 4485 | if ((status = decode_attr_length(xdr, &attrlen, &savep)) != 0) |
| 4486 | goto xdr_error; |
| 4487 | |
| 4488 | if ((status = decode_attr_files_avail(xdr, bitmap, &fsstat->afiles)) != 0) |
| 4489 | goto xdr_error; |
| 4490 | if ((status = decode_attr_files_free(xdr, bitmap, &fsstat->ffiles)) != 0) |
| 4491 | goto xdr_error; |
| 4492 | if ((status = decode_attr_files_total(xdr, bitmap, &fsstat->tfiles)) != 0) |
| 4493 | goto xdr_error; |
Andreas Gruenbacher | 1ca843a | 2015-11-03 18:25:33 +0100 | [diff] [blame] | 4494 | |
| 4495 | status = -EIO; |
| 4496 | if (unlikely(bitmap[0])) |
| 4497 | goto xdr_error; |
| 4498 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4499 | if ((status = decode_attr_space_avail(xdr, bitmap, &fsstat->abytes)) != 0) |
| 4500 | goto xdr_error; |
| 4501 | if ((status = decode_attr_space_free(xdr, bitmap, &fsstat->fbytes)) != 0) |
| 4502 | goto xdr_error; |
| 4503 | if ((status = decode_attr_space_total(xdr, bitmap, &fsstat->tbytes)) != 0) |
| 4504 | goto xdr_error; |
| 4505 | |
| 4506 | status = verify_attr_len(xdr, savep, attrlen); |
| 4507 | xdr_error: |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 4508 | dprintk("%s: xdr returned %d!\n", __func__, -status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4509 | return status; |
| 4510 | } |
| 4511 | |
| 4512 | static int decode_pathconf(struct xdr_stream *xdr, struct nfs_pathconf *pathconf) |
| 4513 | { |
Trond Myklebust | 256e48b | 2012-06-21 11:18:13 -0400 | [diff] [blame] | 4514 | unsigned int savep; |
Fred Isaman | dae100c | 2011-07-30 20:52:37 -0400 | [diff] [blame] | 4515 | uint32_t attrlen, bitmap[3] = {0}; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4516 | int status; |
Andy Adamson | 6c0195a | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 4517 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4518 | if ((status = decode_op_hdr(xdr, OP_GETATTR)) != 0) |
| 4519 | goto xdr_error; |
| 4520 | if ((status = decode_attr_bitmap(xdr, bitmap)) != 0) |
| 4521 | goto xdr_error; |
| 4522 | if ((status = decode_attr_length(xdr, &attrlen, &savep)) != 0) |
| 4523 | goto xdr_error; |
| 4524 | |
| 4525 | if ((status = decode_attr_maxlink(xdr, bitmap, &pathconf->max_link)) != 0) |
| 4526 | goto xdr_error; |
| 4527 | if ((status = decode_attr_maxname(xdr, bitmap, &pathconf->max_namelen)) != 0) |
| 4528 | goto xdr_error; |
| 4529 | |
| 4530 | status = verify_attr_len(xdr, savep, attrlen); |
| 4531 | xdr_error: |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 4532 | dprintk("%s: xdr returned %d!\n", __func__, -status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4533 | return status; |
| 4534 | } |
| 4535 | |
Andy Adamson | 88034c3 | 2012-05-23 05:02:34 -0400 | [diff] [blame] | 4536 | static int decode_threshold_hint(struct xdr_stream *xdr, |
| 4537 | uint32_t *bitmap, |
| 4538 | uint64_t *res, |
| 4539 | uint32_t hint_bit) |
| 4540 | { |
| 4541 | __be32 *p; |
| 4542 | |
| 4543 | *res = 0; |
| 4544 | if (likely(bitmap[0] & hint_bit)) { |
| 4545 | p = xdr_inline_decode(xdr, 8); |
| 4546 | if (unlikely(!p)) |
| 4547 | goto out_overflow; |
| 4548 | xdr_decode_hyper(p, res); |
| 4549 | } |
| 4550 | return 0; |
| 4551 | out_overflow: |
| 4552 | print_overflow_msg(__func__, xdr); |
| 4553 | return -EIO; |
| 4554 | } |
| 4555 | |
| 4556 | static int decode_first_threshold_item4(struct xdr_stream *xdr, |
| 4557 | struct nfs4_threshold *res) |
| 4558 | { |
Trond Myklebust | 256e48b | 2012-06-21 11:18:13 -0400 | [diff] [blame] | 4559 | __be32 *p; |
| 4560 | unsigned int savep; |
Andy Adamson | 88034c3 | 2012-05-23 05:02:34 -0400 | [diff] [blame] | 4561 | uint32_t bitmap[3] = {0,}, attrlen; |
| 4562 | int status; |
| 4563 | |
| 4564 | /* layout type */ |
| 4565 | p = xdr_inline_decode(xdr, 4); |
| 4566 | if (unlikely(!p)) { |
| 4567 | print_overflow_msg(__func__, xdr); |
| 4568 | return -EIO; |
| 4569 | } |
| 4570 | res->l_type = be32_to_cpup(p); |
| 4571 | |
| 4572 | /* thi_hintset bitmap */ |
| 4573 | status = decode_attr_bitmap(xdr, bitmap); |
| 4574 | if (status < 0) |
| 4575 | goto xdr_error; |
| 4576 | |
| 4577 | /* thi_hintlist length */ |
| 4578 | status = decode_attr_length(xdr, &attrlen, &savep); |
| 4579 | if (status < 0) |
| 4580 | goto xdr_error; |
| 4581 | /* thi_hintlist */ |
| 4582 | status = decode_threshold_hint(xdr, bitmap, &res->rd_sz, THRESHOLD_RD); |
| 4583 | if (status < 0) |
| 4584 | goto xdr_error; |
| 4585 | status = decode_threshold_hint(xdr, bitmap, &res->wr_sz, THRESHOLD_WR); |
| 4586 | if (status < 0) |
| 4587 | goto xdr_error; |
| 4588 | status = decode_threshold_hint(xdr, bitmap, &res->rd_io_sz, |
| 4589 | THRESHOLD_RD_IO); |
| 4590 | if (status < 0) |
| 4591 | goto xdr_error; |
| 4592 | status = decode_threshold_hint(xdr, bitmap, &res->wr_io_sz, |
| 4593 | THRESHOLD_WR_IO); |
| 4594 | if (status < 0) |
| 4595 | goto xdr_error; |
| 4596 | |
| 4597 | status = verify_attr_len(xdr, savep, attrlen); |
| 4598 | res->bm = bitmap[0]; |
| 4599 | |
| 4600 | dprintk("%s bm=0x%x rd_sz=%llu wr_sz=%llu rd_io=%llu wr_io=%llu\n", |
| 4601 | __func__, res->bm, res->rd_sz, res->wr_sz, res->rd_io_sz, |
| 4602 | res->wr_io_sz); |
| 4603 | xdr_error: |
| 4604 | dprintk("%s ret=%d!\n", __func__, status); |
| 4605 | return status; |
| 4606 | } |
| 4607 | |
| 4608 | /* |
| 4609 | * Thresholds on pNFS direct I/O vrs MDS I/O |
| 4610 | */ |
| 4611 | static int decode_attr_mdsthreshold(struct xdr_stream *xdr, |
| 4612 | uint32_t *bitmap, |
| 4613 | struct nfs4_threshold *res) |
| 4614 | { |
| 4615 | __be32 *p; |
| 4616 | int status = 0; |
| 4617 | uint32_t num; |
| 4618 | |
| 4619 | if (unlikely(bitmap[2] & (FATTR4_WORD2_MDSTHRESHOLD - 1U))) |
| 4620 | return -EIO; |
Trond Myklebust | 029c534 | 2012-06-05 09:35:44 -0400 | [diff] [blame] | 4621 | if (bitmap[2] & FATTR4_WORD2_MDSTHRESHOLD) { |
Trond Myklebust | 1549210f | 2012-06-05 09:16:47 -0400 | [diff] [blame] | 4622 | /* Did the server return an unrequested attribute? */ |
| 4623 | if (unlikely(res == NULL)) |
| 4624 | return -EREMOTEIO; |
Andy Adamson | 88034c3 | 2012-05-23 05:02:34 -0400 | [diff] [blame] | 4625 | p = xdr_inline_decode(xdr, 4); |
| 4626 | if (unlikely(!p)) |
| 4627 | goto out_overflow; |
| 4628 | num = be32_to_cpup(p); |
| 4629 | if (num == 0) |
| 4630 | return 0; |
| 4631 | if (num > 1) |
| 4632 | printk(KERN_INFO "%s: Warning: Multiple pNFS layout " |
| 4633 | "drivers per filesystem not supported\n", |
| 4634 | __func__); |
| 4635 | |
| 4636 | status = decode_first_threshold_item4(xdr, res); |
Trond Myklebust | 029c534 | 2012-06-05 09:35:44 -0400 | [diff] [blame] | 4637 | bitmap[2] &= ~FATTR4_WORD2_MDSTHRESHOLD; |
Andy Adamson | 88034c3 | 2012-05-23 05:02:34 -0400 | [diff] [blame] | 4638 | } |
| 4639 | return status; |
| 4640 | out_overflow: |
| 4641 | print_overflow_msg(__func__, xdr); |
| 4642 | return -EIO; |
| 4643 | } |
| 4644 | |
Bryan Schumaker | ae42c70 | 2010-10-21 16:33:17 -0400 | [diff] [blame] | 4645 | static int decode_getfattr_attrs(struct xdr_stream *xdr, uint32_t *bitmap, |
| 4646 | struct nfs_fattr *fattr, struct nfs_fh *fh, |
David Quigley | aa9c266 | 2013-05-22 12:50:44 -0400 | [diff] [blame] | 4647 | struct nfs4_fs_locations *fs_loc, struct nfs4_label *label, |
Trond Myklebust | 6926afd | 2012-01-07 13:22:46 -0500 | [diff] [blame] | 4648 | const struct nfs_server *server) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4649 | { |
Trond Myklebust | bca7947 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 4650 | int status; |
| 4651 | umode_t fmode = 0; |
Bryan Schumaker | ae42c70 | 2010-10-21 16:33:17 -0400 | [diff] [blame] | 4652 | uint32_t type; |
Trond Myklebust | ee7b75f | 2011-06-16 13:15:41 -0400 | [diff] [blame] | 4653 | int32_t err; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4654 | |
Trond Myklebust | f26c7a7 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 4655 | status = decode_attr_type(xdr, bitmap, &type); |
| 4656 | if (status < 0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4657 | goto xdr_error; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 4658 | fattr->mode = 0; |
| 4659 | if (status != 0) { |
| 4660 | fattr->mode |= nfs_type2fmt[type]; |
| 4661 | fattr->valid |= status; |
| 4662 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4663 | |
Trond Myklebust | f26c7a7 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 4664 | status = decode_attr_change(xdr, bitmap, &fattr->change_attr); |
| 4665 | if (status < 0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4666 | goto xdr_error; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 4667 | fattr->valid |= status; |
Trond Myklebust | f26c7a7 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 4668 | |
| 4669 | status = decode_attr_size(xdr, bitmap, &fattr->size); |
| 4670 | if (status < 0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4671 | goto xdr_error; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 4672 | fattr->valid |= status; |
Trond Myklebust | f26c7a7 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 4673 | |
| 4674 | status = decode_attr_fsid(xdr, bitmap, &fattr->fsid); |
| 4675 | if (status < 0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4676 | goto xdr_error; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 4677 | fattr->valid |= status; |
Trond Myklebust | f26c7a7 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 4678 | |
Trond Myklebust | ee7b75f | 2011-06-16 13:15:41 -0400 | [diff] [blame] | 4679 | err = 0; |
| 4680 | status = decode_attr_error(xdr, bitmap, &err); |
Bryan Schumaker | ae42c70 | 2010-10-21 16:33:17 -0400 | [diff] [blame] | 4681 | if (status < 0) |
| 4682 | goto xdr_error; |
| 4683 | |
| 4684 | status = decode_attr_filehandle(xdr, bitmap, fh); |
| 4685 | if (status < 0) |
| 4686 | goto xdr_error; |
| 4687 | |
Trond Myklebust | f26c7a7 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 4688 | status = decode_attr_fileid(xdr, bitmap, &fattr->fileid); |
| 4689 | if (status < 0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4690 | goto xdr_error; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 4691 | fattr->valid |= status; |
Trond Myklebust | f26c7a7 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 4692 | |
Trond Myklebust | 8b7e3f4 | 2012-01-30 15:43:56 -0500 | [diff] [blame] | 4693 | status = decode_attr_fs_locations(xdr, bitmap, fs_loc); |
Trond Myklebust | f26c7a7 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 4694 | if (status < 0) |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 4695 | goto xdr_error; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 4696 | fattr->valid |= status; |
Trond Myklebust | f26c7a7 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 4697 | |
Andreas Gruenbacher | 1ca843a | 2015-11-03 18:25:33 +0100 | [diff] [blame] | 4698 | status = -EIO; |
| 4699 | if (unlikely(bitmap[0])) |
| 4700 | goto xdr_error; |
| 4701 | |
Trond Myklebust | f26c7a7 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 4702 | status = decode_attr_mode(xdr, bitmap, &fmode); |
| 4703 | if (status < 0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4704 | goto xdr_error; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 4705 | if (status != 0) { |
| 4706 | fattr->mode |= fmode; |
| 4707 | fattr->valid |= status; |
| 4708 | } |
Trond Myklebust | f26c7a7 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 4709 | |
| 4710 | status = decode_attr_nlink(xdr, bitmap, &fattr->nlink); |
| 4711 | if (status < 0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4712 | goto xdr_error; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 4713 | fattr->valid |= status; |
Trond Myklebust | f26c7a7 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 4714 | |
Trond Myklebust | 6926afd | 2012-01-07 13:22:46 -0500 | [diff] [blame] | 4715 | status = decode_attr_owner(xdr, bitmap, server, &fattr->uid, fattr->owner_name); |
Trond Myklebust | f26c7a7 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 4716 | if (status < 0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4717 | goto xdr_error; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 4718 | fattr->valid |= status; |
Trond Myklebust | f26c7a7 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 4719 | |
Trond Myklebust | 6926afd | 2012-01-07 13:22:46 -0500 | [diff] [blame] | 4720 | status = decode_attr_group(xdr, bitmap, server, &fattr->gid, fattr->group_name); |
Trond Myklebust | f26c7a7 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 4721 | if (status < 0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4722 | goto xdr_error; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 4723 | fattr->valid |= status; |
Trond Myklebust | f26c7a7 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 4724 | |
| 4725 | status = decode_attr_rdev(xdr, bitmap, &fattr->rdev); |
| 4726 | if (status < 0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4727 | goto xdr_error; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 4728 | fattr->valid |= status; |
Trond Myklebust | f26c7a7 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 4729 | |
| 4730 | status = decode_attr_space_used(xdr, bitmap, &fattr->du.nfs3.used); |
| 4731 | if (status < 0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4732 | goto xdr_error; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 4733 | fattr->valid |= status; |
Trond Myklebust | f26c7a7 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 4734 | |
| 4735 | status = decode_attr_time_access(xdr, bitmap, &fattr->atime); |
| 4736 | if (status < 0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4737 | goto xdr_error; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 4738 | fattr->valid |= status; |
Trond Myklebust | f26c7a7 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 4739 | |
| 4740 | status = decode_attr_time_metadata(xdr, bitmap, &fattr->ctime); |
| 4741 | if (status < 0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4742 | goto xdr_error; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 4743 | fattr->valid |= status; |
Trond Myklebust | f26c7a7 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 4744 | |
| 4745 | status = decode_attr_time_modify(xdr, bitmap, &fattr->mtime); |
| 4746 | if (status < 0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4747 | goto xdr_error; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 4748 | fattr->valid |= status; |
Trond Myklebust | f26c7a7 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 4749 | |
Trond Myklebust | 28331a4 | 2011-04-27 13:47:52 -0400 | [diff] [blame] | 4750 | status = decode_attr_mounted_on_fileid(xdr, bitmap, &fattr->mounted_on_fileid); |
Trond Myklebust | f26c7a7 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 4751 | if (status < 0) |
Manoj Naik | 99baf62 | 2006-06-09 09:34:24 -0400 | [diff] [blame] | 4752 | goto xdr_error; |
Trond Myklebust | 28331a4 | 2011-04-27 13:47:52 -0400 | [diff] [blame] | 4753 | fattr->valid |= status; |
Trond Myklebust | f26c7a7 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 4754 | |
Andreas Gruenbacher | 1ca843a | 2015-11-03 18:25:33 +0100 | [diff] [blame] | 4755 | status = -EIO; |
| 4756 | if (unlikely(bitmap[1])) |
| 4757 | goto xdr_error; |
| 4758 | |
Andy Adamson | 88034c3 | 2012-05-23 05:02:34 -0400 | [diff] [blame] | 4759 | status = decode_attr_mdsthreshold(xdr, bitmap, fattr->mdsthreshold); |
| 4760 | if (status < 0) |
| 4761 | goto xdr_error; |
| 4762 | |
David Quigley | aa9c266 | 2013-05-22 12:50:44 -0400 | [diff] [blame] | 4763 | if (label) { |
| 4764 | status = decode_attr_security_label(xdr, bitmap, label); |
| 4765 | if (status < 0) |
| 4766 | goto xdr_error; |
| 4767 | fattr->valid |= status; |
| 4768 | } |
| 4769 | |
Bryan Schumaker | ae42c70 | 2010-10-21 16:33:17 -0400 | [diff] [blame] | 4770 | xdr_error: |
| 4771 | dprintk("%s: xdr returned %d\n", __func__, -status); |
| 4772 | return status; |
| 4773 | } |
| 4774 | |
| 4775 | 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] | 4776 | struct nfs_fh *fh, struct nfs4_fs_locations *fs_loc, |
David Quigley | aa9c266 | 2013-05-22 12:50:44 -0400 | [diff] [blame] | 4777 | struct nfs4_label *label, const struct nfs_server *server) |
Bryan Schumaker | ae42c70 | 2010-10-21 16:33:17 -0400 | [diff] [blame] | 4778 | { |
Trond Myklebust | 256e48b | 2012-06-21 11:18:13 -0400 | [diff] [blame] | 4779 | unsigned int savep; |
Bryan Schumaker | ae42c70 | 2010-10-21 16:33:17 -0400 | [diff] [blame] | 4780 | uint32_t attrlen, |
Fred Isaman | dae100c | 2011-07-30 20:52:37 -0400 | [diff] [blame] | 4781 | bitmap[3] = {0}; |
Bryan Schumaker | ae42c70 | 2010-10-21 16:33:17 -0400 | [diff] [blame] | 4782 | int status; |
| 4783 | |
| 4784 | status = decode_op_hdr(xdr, OP_GETATTR); |
| 4785 | if (status < 0) |
| 4786 | goto xdr_error; |
| 4787 | |
| 4788 | status = decode_attr_bitmap(xdr, bitmap); |
| 4789 | if (status < 0) |
| 4790 | goto xdr_error; |
| 4791 | |
| 4792 | status = decode_attr_length(xdr, &attrlen, &savep); |
| 4793 | if (status < 0) |
| 4794 | goto xdr_error; |
| 4795 | |
David Quigley | aa9c266 | 2013-05-22 12:50:44 -0400 | [diff] [blame] | 4796 | status = decode_getfattr_attrs(xdr, bitmap, fattr, fh, fs_loc, |
| 4797 | label, server); |
Bryan Schumaker | ae42c70 | 2010-10-21 16:33:17 -0400 | [diff] [blame] | 4798 | if (status < 0) |
| 4799 | goto xdr_error; |
| 4800 | |
Trond Myklebust | f26c7a7 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 4801 | status = verify_attr_len(xdr, savep, attrlen); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4802 | xdr_error: |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 4803 | dprintk("%s: xdr returned %d\n", __func__, -status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4804 | return status; |
| 4805 | } |
| 4806 | |
David Quigley | aa9c266 | 2013-05-22 12:50:44 -0400 | [diff] [blame] | 4807 | static int decode_getfattr_label(struct xdr_stream *xdr, struct nfs_fattr *fattr, |
| 4808 | struct nfs4_label *label, const struct nfs_server *server) |
| 4809 | { |
| 4810 | return decode_getfattr_generic(xdr, fattr, NULL, NULL, label, server); |
| 4811 | } |
| 4812 | |
Bryan Schumaker | ae42c70 | 2010-10-21 16:33:17 -0400 | [diff] [blame] | 4813 | static int decode_getfattr(struct xdr_stream *xdr, struct nfs_fattr *fattr, |
Trond Myklebust | 6926afd | 2012-01-07 13:22:46 -0500 | [diff] [blame] | 4814 | const struct nfs_server *server) |
Bryan Schumaker | ae42c70 | 2010-10-21 16:33:17 -0400 | [diff] [blame] | 4815 | { |
David Quigley | aa9c266 | 2013-05-22 12:50:44 -0400 | [diff] [blame] | 4816 | return decode_getfattr_generic(xdr, fattr, NULL, NULL, NULL, server); |
Bryan Schumaker | ae42c70 | 2010-10-21 16:33:17 -0400 | [diff] [blame] | 4817 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4818 | |
Andy Adamson | 504913f | 2010-10-20 00:17:57 -0400 | [diff] [blame] | 4819 | /* |
Jeff Layton | 3132e49 | 2016-08-10 15:58:24 -0400 | [diff] [blame] | 4820 | * Decode potentially multiple layout types. |
Andy Adamson | 504913f | 2010-10-20 00:17:57 -0400 | [diff] [blame] | 4821 | */ |
Jeff Layton | 3132e49 | 2016-08-10 15:58:24 -0400 | [diff] [blame] | 4822 | static int decode_pnfs_layout_types(struct xdr_stream *xdr, |
Jeff Layton | ca440c3 | 2016-09-15 14:40:49 -0400 | [diff] [blame] | 4823 | struct nfs_fsinfo *fsinfo) |
Andy Adamson | 504913f | 2010-10-20 00:17:57 -0400 | [diff] [blame] | 4824 | { |
Trond Myklebust | b8a8a0d | 2013-08-20 21:08:56 -0400 | [diff] [blame] | 4825 | __be32 *p; |
Jeff Layton | ca440c3 | 2016-09-15 14:40:49 -0400 | [diff] [blame] | 4826 | uint32_t i; |
Andy Adamson | 504913f | 2010-10-20 00:17:57 -0400 | [diff] [blame] | 4827 | |
| 4828 | p = xdr_inline_decode(xdr, 4); |
| 4829 | if (unlikely(!p)) |
| 4830 | goto out_overflow; |
Jeff Layton | ca440c3 | 2016-09-15 14:40:49 -0400 | [diff] [blame] | 4831 | fsinfo->nlayouttypes = be32_to_cpup(p); |
Andy Adamson | 504913f | 2010-10-20 00:17:57 -0400 | [diff] [blame] | 4832 | |
| 4833 | /* pNFS is not supported by the underlying file system */ |
Jeff Layton | ca440c3 | 2016-09-15 14:40:49 -0400 | [diff] [blame] | 4834 | if (fsinfo->nlayouttypes == 0) |
Andy Adamson | 504913f | 2010-10-20 00:17:57 -0400 | [diff] [blame] | 4835 | return 0; |
Andy Adamson | 504913f | 2010-10-20 00:17:57 -0400 | [diff] [blame] | 4836 | |
| 4837 | /* Decode and set first layout type, move xdr->p past unused types */ |
Jeff Layton | ca440c3 | 2016-09-15 14:40:49 -0400 | [diff] [blame] | 4838 | p = xdr_inline_decode(xdr, fsinfo->nlayouttypes * 4); |
Andy Adamson | 504913f | 2010-10-20 00:17:57 -0400 | [diff] [blame] | 4839 | if (unlikely(!p)) |
| 4840 | goto out_overflow; |
Jeff Layton | ca440c3 | 2016-09-15 14:40:49 -0400 | [diff] [blame] | 4841 | |
| 4842 | /* If we get too many, then just cap it at the max */ |
| 4843 | if (fsinfo->nlayouttypes > NFS_MAX_LAYOUT_TYPES) { |
| 4844 | printk(KERN_INFO "NFS: %s: Warning: Too many (%u) pNFS layout types\n", |
| 4845 | __func__, fsinfo->nlayouttypes); |
| 4846 | fsinfo->nlayouttypes = NFS_MAX_LAYOUT_TYPES; |
| 4847 | } |
| 4848 | |
| 4849 | for(i = 0; i < fsinfo->nlayouttypes; ++i) |
| 4850 | fsinfo->layouttype[i] = be32_to_cpup(p++); |
Andy Adamson | 504913f | 2010-10-20 00:17:57 -0400 | [diff] [blame] | 4851 | return 0; |
| 4852 | out_overflow: |
| 4853 | print_overflow_msg(__func__, xdr); |
| 4854 | return -EIO; |
| 4855 | } |
| 4856 | |
| 4857 | /* |
| 4858 | * The type of file system exported. |
| 4859 | * Note we must ensure that layouttype is set in any non-error case. |
| 4860 | */ |
| 4861 | static int decode_attr_pnfstype(struct xdr_stream *xdr, uint32_t *bitmap, |
Jeff Layton | ca440c3 | 2016-09-15 14:40:49 -0400 | [diff] [blame] | 4862 | struct nfs_fsinfo *fsinfo) |
Andy Adamson | 504913f | 2010-10-20 00:17:57 -0400 | [diff] [blame] | 4863 | { |
| 4864 | int status = 0; |
| 4865 | |
| 4866 | dprintk("%s: bitmap is %x\n", __func__, bitmap[1]); |
| 4867 | if (unlikely(bitmap[1] & (FATTR4_WORD1_FS_LAYOUT_TYPES - 1U))) |
| 4868 | return -EIO; |
| 4869 | if (bitmap[1] & FATTR4_WORD1_FS_LAYOUT_TYPES) { |
Jeff Layton | ca440c3 | 2016-09-15 14:40:49 -0400 | [diff] [blame] | 4870 | status = decode_pnfs_layout_types(xdr, fsinfo); |
Andy Adamson | 504913f | 2010-10-20 00:17:57 -0400 | [diff] [blame] | 4871 | bitmap[1] &= ~FATTR4_WORD1_FS_LAYOUT_TYPES; |
Jeff Layton | 3132e49 | 2016-08-10 15:58:24 -0400 | [diff] [blame] | 4872 | } |
Andy Adamson | 504913f | 2010-10-20 00:17:57 -0400 | [diff] [blame] | 4873 | return status; |
| 4874 | } |
| 4875 | |
Fred Isaman | dae100c | 2011-07-30 20:52:37 -0400 | [diff] [blame] | 4876 | /* |
| 4877 | * The prefered block size for layout directed io |
| 4878 | */ |
| 4879 | static int decode_attr_layout_blksize(struct xdr_stream *xdr, uint32_t *bitmap, |
| 4880 | uint32_t *res) |
| 4881 | { |
| 4882 | __be32 *p; |
| 4883 | |
| 4884 | dprintk("%s: bitmap is %x\n", __func__, bitmap[2]); |
| 4885 | *res = 0; |
| 4886 | if (bitmap[2] & FATTR4_WORD2_LAYOUT_BLKSIZE) { |
| 4887 | p = xdr_inline_decode(xdr, 4); |
| 4888 | if (unlikely(!p)) { |
| 4889 | print_overflow_msg(__func__, xdr); |
| 4890 | return -EIO; |
| 4891 | } |
| 4892 | *res = be32_to_cpup(p); |
| 4893 | bitmap[2] &= ~FATTR4_WORD2_LAYOUT_BLKSIZE; |
| 4894 | } |
| 4895 | return 0; |
| 4896 | } |
| 4897 | |
Peng Tao | 2a92ee9 | 2015-09-26 02:24:37 +0800 | [diff] [blame] | 4898 | /* |
| 4899 | * The granularity of a CLONE operation. |
| 4900 | */ |
| 4901 | static int decode_attr_clone_blksize(struct xdr_stream *xdr, uint32_t *bitmap, |
| 4902 | uint32_t *res) |
| 4903 | { |
| 4904 | __be32 *p; |
| 4905 | |
| 4906 | dprintk("%s: bitmap is %x\n", __func__, bitmap[2]); |
| 4907 | *res = 0; |
| 4908 | if (bitmap[2] & FATTR4_WORD2_CLONE_BLKSIZE) { |
| 4909 | p = xdr_inline_decode(xdr, 4); |
| 4910 | if (unlikely(!p)) { |
| 4911 | print_overflow_msg(__func__, xdr); |
| 4912 | return -EIO; |
| 4913 | } |
| 4914 | *res = be32_to_cpup(p); |
| 4915 | bitmap[2] &= ~FATTR4_WORD2_CLONE_BLKSIZE; |
| 4916 | } |
| 4917 | return 0; |
| 4918 | } |
| 4919 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4920 | static int decode_fsinfo(struct xdr_stream *xdr, struct nfs_fsinfo *fsinfo) |
| 4921 | { |
Trond Myklebust | 256e48b | 2012-06-21 11:18:13 -0400 | [diff] [blame] | 4922 | unsigned int savep; |
Fred Isaman | dae100c | 2011-07-30 20:52:37 -0400 | [diff] [blame] | 4923 | uint32_t attrlen, bitmap[3]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4924 | int status; |
| 4925 | |
| 4926 | if ((status = decode_op_hdr(xdr, OP_GETATTR)) != 0) |
| 4927 | goto xdr_error; |
| 4928 | if ((status = decode_attr_bitmap(xdr, bitmap)) != 0) |
| 4929 | goto xdr_error; |
| 4930 | if ((status = decode_attr_length(xdr, &attrlen, &savep)) != 0) |
| 4931 | goto xdr_error; |
| 4932 | |
| 4933 | fsinfo->rtmult = fsinfo->wtmult = 512; /* ??? */ |
| 4934 | |
| 4935 | if ((status = decode_attr_lease_time(xdr, bitmap, &fsinfo->lease_time)) != 0) |
| 4936 | goto xdr_error; |
| 4937 | if ((status = decode_attr_maxfilesize(xdr, bitmap, &fsinfo->maxfilesize)) != 0) |
| 4938 | goto xdr_error; |
| 4939 | if ((status = decode_attr_maxread(xdr, bitmap, &fsinfo->rtmax)) != 0) |
| 4940 | goto xdr_error; |
| 4941 | fsinfo->rtpref = fsinfo->dtpref = fsinfo->rtmax; |
| 4942 | if ((status = decode_attr_maxwrite(xdr, bitmap, &fsinfo->wtmax)) != 0) |
| 4943 | goto xdr_error; |
| 4944 | fsinfo->wtpref = fsinfo->wtmax; |
Andreas Gruenbacher | 1ca843a | 2015-11-03 18:25:33 +0100 | [diff] [blame] | 4945 | |
| 4946 | status = -EIO; |
| 4947 | if (unlikely(bitmap[0])) |
| 4948 | goto xdr_error; |
| 4949 | |
Ricardo Labiaga | 55b6e77 | 2010-10-12 16:30:06 -0700 | [diff] [blame] | 4950 | status = decode_attr_time_delta(xdr, bitmap, &fsinfo->time_delta); |
| 4951 | if (status != 0) |
| 4952 | goto xdr_error; |
Jeff Layton | ca440c3 | 2016-09-15 14:40:49 -0400 | [diff] [blame] | 4953 | status = decode_attr_pnfstype(xdr, bitmap, fsinfo); |
Andy Adamson | 504913f | 2010-10-20 00:17:57 -0400 | [diff] [blame] | 4954 | if (status != 0) |
| 4955 | goto xdr_error; |
Andreas Gruenbacher | 1ca843a | 2015-11-03 18:25:33 +0100 | [diff] [blame] | 4956 | |
| 4957 | status = -EIO; |
| 4958 | if (unlikely(bitmap[1])) |
| 4959 | goto xdr_error; |
| 4960 | |
Fred Isaman | dae100c | 2011-07-30 20:52:37 -0400 | [diff] [blame] | 4961 | status = decode_attr_layout_blksize(xdr, bitmap, &fsinfo->blksize); |
| 4962 | if (status) |
| 4963 | goto xdr_error; |
Peng Tao | 2a92ee9 | 2015-09-26 02:24:37 +0800 | [diff] [blame] | 4964 | status = decode_attr_clone_blksize(xdr, bitmap, &fsinfo->clone_blksize); |
| 4965 | if (status) |
| 4966 | goto xdr_error; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4967 | |
| 4968 | status = verify_attr_len(xdr, savep, attrlen); |
| 4969 | xdr_error: |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 4970 | dprintk("%s: xdr returned %d!\n", __func__, -status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4971 | return status; |
| 4972 | } |
| 4973 | |
| 4974 | static int decode_getfh(struct xdr_stream *xdr, struct nfs_fh *fh) |
| 4975 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 4976 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4977 | uint32_t len; |
| 4978 | int status; |
| 4979 | |
Trond Myklebust | 9936781 | 2007-07-17 21:52:41 -0400 | [diff] [blame] | 4980 | /* Zero handle first to allow comparisons */ |
| 4981 | memset(fh, 0, sizeof(*fh)); |
| 4982 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4983 | status = decode_op_hdr(xdr, OP_GETFH); |
| 4984 | if (status) |
| 4985 | return status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4986 | |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 4987 | p = xdr_inline_decode(xdr, 4); |
| 4988 | if (unlikely(!p)) |
| 4989 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 4990 | len = be32_to_cpup(p); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4991 | if (len > NFS4_FHSIZE) |
| 4992 | return -EIO; |
| 4993 | fh->size = len; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 4994 | p = xdr_inline_decode(xdr, len); |
| 4995 | if (unlikely(!p)) |
| 4996 | goto out_overflow; |
Benny Halevy | 99398d0 | 2009-08-14 17:20:05 +0300 | [diff] [blame] | 4997 | memcpy(fh->data, p, len); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4998 | return 0; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 4999 | out_overflow: |
| 5000 | print_overflow_msg(__func__, xdr); |
| 5001 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 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)) |
| 5025 | goto out_overflow; |
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 */ |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 5042 | if (likely(p)) |
| 5043 | return -NFS4ERR_DENIED; |
| 5044 | out_overflow: |
| 5045 | print_overflow_msg(__func__, xdr); |
| 5046 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5047 | } |
| 5048 | |
Trond Myklebust | 911d1aa | 2006-01-03 09:55:16 +0100 | [diff] [blame] | 5049 | 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] | 5050 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5051 | int status; |
| 5052 | |
| 5053 | status = decode_op_hdr(xdr, OP_LOCK); |
Trond Myklebust | c1d5193 | 2008-04-07 13:20:54 -0400 | [diff] [blame] | 5054 | if (status == -EIO) |
| 5055 | goto out; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5056 | if (status == 0) { |
Trond Myklebust | 93b717f | 2016-05-16 17:42:43 -0400 | [diff] [blame] | 5057 | status = decode_lock_stateid(xdr, &res->stateid); |
Benny Halevy | 07d3043 | 2009-08-14 17:19:52 +0300 | [diff] [blame] | 5058 | if (unlikely(status)) |
| 5059 | goto out; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5060 | } else if (status == -NFS4ERR_DENIED) |
Trond Myklebust | c1d5193 | 2008-04-07 13:20:54 -0400 | [diff] [blame] | 5061 | status = decode_lock_denied(xdr, NULL); |
| 5062 | if (res->open_seqid != NULL) |
| 5063 | nfs_increment_open_seqid(status, res->open_seqid); |
| 5064 | nfs_increment_lock_seqid(status, res->lock_seqid); |
| 5065 | out: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5066 | return status; |
| 5067 | } |
| 5068 | |
Trond Myklebust | 911d1aa | 2006-01-03 09:55:16 +0100 | [diff] [blame] | 5069 | 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] | 5070 | { |
| 5071 | int status; |
| 5072 | status = decode_op_hdr(xdr, OP_LOCKT); |
| 5073 | if (status == -NFS4ERR_DENIED) |
Trond Myklebust | 911d1aa | 2006-01-03 09:55:16 +0100 | [diff] [blame] | 5074 | return decode_lock_denied(xdr, res->denied); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5075 | return status; |
| 5076 | } |
| 5077 | |
Trond Myklebust | 911d1aa | 2006-01-03 09:55:16 +0100 | [diff] [blame] | 5078 | 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] | 5079 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5080 | int status; |
| 5081 | |
| 5082 | status = decode_op_hdr(xdr, OP_LOCKU); |
Trond Myklebust | c1d5193 | 2008-04-07 13:20:54 -0400 | [diff] [blame] | 5083 | if (status != -EIO) |
| 5084 | nfs_increment_lock_seqid(status, res->seqid); |
Benny Halevy | 07d3043 | 2009-08-14 17:19:52 +0300 | [diff] [blame] | 5085 | if (status == 0) |
Trond Myklebust | 93b717f | 2016-05-16 17:42:43 -0400 | [diff] [blame] | 5086 | status = decode_lock_stateid(xdr, &res->stateid); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5087 | return status; |
| 5088 | } |
| 5089 | |
Trond Myklebust | d3c7b7c | 2010-07-01 12:49:01 -0400 | [diff] [blame] | 5090 | static int decode_release_lockowner(struct xdr_stream *xdr) |
| 5091 | { |
| 5092 | return decode_op_hdr(xdr, OP_RELEASE_LOCKOWNER); |
| 5093 | } |
| 5094 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5095 | static int decode_lookup(struct xdr_stream *xdr) |
| 5096 | { |
| 5097 | return decode_op_hdr(xdr, OP_LOOKUP); |
| 5098 | } |
| 5099 | |
Jeff Layton | 5b5faaf | 2017-06-29 06:34:52 -0700 | [diff] [blame] | 5100 | static int decode_lookupp(struct xdr_stream *xdr) |
| 5101 | { |
| 5102 | return decode_op_hdr(xdr, OP_LOOKUPP); |
| 5103 | } |
| 5104 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5105 | /* This is too sick! */ |
Trond Myklebust | 7d160a6 | 2015-09-05 19:06:57 -0400 | [diff] [blame] | 5106 | static int decode_space_limit(struct xdr_stream *xdr, |
| 5107 | unsigned long *pagemod_limit) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5108 | { |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 5109 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5110 | uint32_t limit_type, nblocks, blocksize; |
Trond Myklebust | 7d160a6 | 2015-09-05 19:06:57 -0400 | [diff] [blame] | 5111 | u64 maxsize = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5112 | |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 5113 | p = xdr_inline_decode(xdr, 12); |
| 5114 | if (unlikely(!p)) |
| 5115 | goto out_overflow; |
Benny Halevy | 6f723f7 | 2009-08-14 17:19:37 +0300 | [diff] [blame] | 5116 | limit_type = be32_to_cpup(p++); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5117 | switch (limit_type) { |
Trond Myklebust | 7d160a6 | 2015-09-05 19:06:57 -0400 | [diff] [blame] | 5118 | case NFS4_LIMIT_SIZE: |
| 5119 | xdr_decode_hyper(p, &maxsize); |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 5120 | break; |
Trond Myklebust | 7d160a6 | 2015-09-05 19:06:57 -0400 | [diff] [blame] | 5121 | case NFS4_LIMIT_BLOCKS: |
Benny Halevy | 6f723f7 | 2009-08-14 17:19:37 +0300 | [diff] [blame] | 5122 | nblocks = be32_to_cpup(p++); |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 5123 | blocksize = be32_to_cpup(p); |
Trond Myklebust | 7d160a6 | 2015-09-05 19:06:57 -0400 | [diff] [blame] | 5124 | maxsize = (uint64_t)nblocks * (uint64_t)blocksize; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5125 | } |
Kirill A. Shutemov | 09cbfea | 2016-04-01 15:29:47 +0300 | [diff] [blame] | 5126 | maxsize >>= PAGE_SHIFT; |
Trond Myklebust | 7d160a6 | 2015-09-05 19:06:57 -0400 | [diff] [blame] | 5127 | *pagemod_limit = min_t(u64, maxsize, ULONG_MAX); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5128 | return 0; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 5129 | out_overflow: |
| 5130 | print_overflow_msg(__func__, xdr); |
| 5131 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5132 | } |
| 5133 | |
Trond Myklebust | 6ae3733 | 2015-01-30 14:21:14 -0500 | [diff] [blame] | 5134 | static int decode_rw_delegation(struct xdr_stream *xdr, |
| 5135 | uint32_t delegation_type, |
| 5136 | struct nfs_openres *res) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5137 | { |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 5138 | __be32 *p; |
Benny Halevy | 07d3043 | 2009-08-14 17:19:52 +0300 | [diff] [blame] | 5139 | int status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5140 | |
Trond Myklebust | 93b717f | 2016-05-16 17:42:43 -0400 | [diff] [blame] | 5141 | status = decode_delegation_stateid(xdr, &res->delegation); |
Benny Halevy | 07d3043 | 2009-08-14 17:19:52 +0300 | [diff] [blame] | 5142 | if (unlikely(status)) |
| 5143 | return status; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 5144 | p = xdr_inline_decode(xdr, 4); |
| 5145 | if (unlikely(!p)) |
| 5146 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 5147 | res->do_recall = be32_to_cpup(p); |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 5148 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5149 | switch (delegation_type) { |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 5150 | case NFS4_OPEN_DELEGATE_READ: |
| 5151 | res->delegation_type = FMODE_READ; |
| 5152 | break; |
| 5153 | case NFS4_OPEN_DELEGATE_WRITE: |
| 5154 | res->delegation_type = FMODE_WRITE|FMODE_READ; |
Trond Myklebust | 7d160a6 | 2015-09-05 19:06:57 -0400 | [diff] [blame] | 5155 | if (decode_space_limit(xdr, &res->pagemod_limit) < 0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5156 | return -EIO; |
| 5157 | } |
Trond Myklebust | 1bbe60f | 2017-02-19 16:08:30 -0500 | [diff] [blame] | 5158 | return decode_ace(xdr, NULL); |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 5159 | out_overflow: |
| 5160 | print_overflow_msg(__func__, xdr); |
| 5161 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5162 | } |
| 5163 | |
Trond Myklebust | 6ae3733 | 2015-01-30 14:21:14 -0500 | [diff] [blame] | 5164 | static int decode_no_delegation(struct xdr_stream *xdr, struct nfs_openres *res) |
| 5165 | { |
| 5166 | __be32 *p; |
| 5167 | uint32_t why_no_delegation; |
| 5168 | |
| 5169 | p = xdr_inline_decode(xdr, 4); |
| 5170 | if (unlikely(!p)) |
| 5171 | goto out_overflow; |
| 5172 | why_no_delegation = be32_to_cpup(p); |
| 5173 | switch (why_no_delegation) { |
| 5174 | case WND4_CONTENTION: |
| 5175 | case WND4_RESOURCE: |
| 5176 | xdr_inline_decode(xdr, 4); |
| 5177 | /* Ignore for now */ |
| 5178 | } |
| 5179 | return 0; |
| 5180 | out_overflow: |
| 5181 | print_overflow_msg(__func__, xdr); |
| 5182 | return -EIO; |
| 5183 | } |
| 5184 | |
| 5185 | static int decode_delegation(struct xdr_stream *xdr, struct nfs_openres *res) |
| 5186 | { |
| 5187 | __be32 *p; |
| 5188 | uint32_t delegation_type; |
| 5189 | |
| 5190 | p = xdr_inline_decode(xdr, 4); |
| 5191 | if (unlikely(!p)) |
| 5192 | goto out_overflow; |
| 5193 | delegation_type = be32_to_cpup(p); |
| 5194 | res->delegation_type = 0; |
| 5195 | switch (delegation_type) { |
| 5196 | case NFS4_OPEN_DELEGATE_NONE: |
| 5197 | return 0; |
| 5198 | case NFS4_OPEN_DELEGATE_READ: |
| 5199 | case NFS4_OPEN_DELEGATE_WRITE: |
| 5200 | return decode_rw_delegation(xdr, delegation_type, res); |
| 5201 | case NFS4_OPEN_DELEGATE_NONE_EXT: |
| 5202 | return decode_no_delegation(xdr, res); |
| 5203 | } |
| 5204 | return -EIO; |
| 5205 | out_overflow: |
| 5206 | print_overflow_msg(__func__, xdr); |
| 5207 | return -EIO; |
| 5208 | } |
| 5209 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5210 | static int decode_open(struct xdr_stream *xdr, struct nfs_openres *res) |
| 5211 | { |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 5212 | __be32 *p; |
Jeff Layton | aa53ed5 | 2007-06-05 14:49:03 -0400 | [diff] [blame] | 5213 | uint32_t savewords, bmlen, i; |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 5214 | int status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5215 | |
Trond Myklebust | c7848f6 | 2013-12-04 17:39:23 -0500 | [diff] [blame] | 5216 | if (!__decode_op_hdr(xdr, OP_OPEN, &status)) |
| 5217 | return status; |
| 5218 | nfs_increment_open_seqid(status, res->seqid); |
| 5219 | if (status) |
| 5220 | return status; |
Trond Myklebust | 93b717f | 2016-05-16 17:42:43 -0400 | [diff] [blame] | 5221 | status = decode_open_stateid(xdr, &res->stateid); |
Benny Halevy | 07d3043 | 2009-08-14 17:19:52 +0300 | [diff] [blame] | 5222 | if (unlikely(status)) |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 5223 | return status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5224 | |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 5225 | decode_change_info(xdr, &res->cinfo); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5226 | |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 5227 | p = xdr_inline_decode(xdr, 8); |
| 5228 | if (unlikely(!p)) |
| 5229 | goto out_overflow; |
Benny Halevy | 6f723f7 | 2009-08-14 17:19:37 +0300 | [diff] [blame] | 5230 | res->rflags = be32_to_cpup(p++); |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 5231 | bmlen = be32_to_cpup(p); |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 5232 | if (bmlen > 10) |
| 5233 | goto xdr_error; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5234 | |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 5235 | p = xdr_inline_decode(xdr, bmlen << 2); |
| 5236 | if (unlikely(!p)) |
| 5237 | goto out_overflow; |
Jeff Layton | aa53ed5 | 2007-06-05 14:49:03 -0400 | [diff] [blame] | 5238 | savewords = min_t(uint32_t, bmlen, NFS4_BITMAP_SIZE); |
| 5239 | for (i = 0; i < savewords; ++i) |
Benny Halevy | 6f723f7 | 2009-08-14 17:19:37 +0300 | [diff] [blame] | 5240 | res->attrset[i] = be32_to_cpup(p++); |
Jeff Layton | aa53ed5 | 2007-06-05 14:49:03 -0400 | [diff] [blame] | 5241 | for (; i < NFS4_BITMAP_SIZE; i++) |
| 5242 | res->attrset[i] = 0; |
| 5243 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5244 | return decode_delegation(xdr, res); |
| 5245 | xdr_error: |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 5246 | dprintk("%s: Bitmap too large! Length = %u\n", __func__, bmlen); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5247 | return -EIO; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 5248 | out_overflow: |
| 5249 | print_overflow_msg(__func__, xdr); |
| 5250 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5251 | } |
| 5252 | |
| 5253 | static int decode_open_confirm(struct xdr_stream *xdr, struct nfs_open_confirmres *res) |
| 5254 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5255 | int status; |
| 5256 | |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 5257 | status = decode_op_hdr(xdr, OP_OPEN_CONFIRM); |
Trond Myklebust | c1d5193 | 2008-04-07 13:20:54 -0400 | [diff] [blame] | 5258 | if (status != -EIO) |
| 5259 | nfs_increment_open_seqid(status, res->seqid); |
Benny Halevy | 07d3043 | 2009-08-14 17:19:52 +0300 | [diff] [blame] | 5260 | if (!status) |
Trond Myklebust | 93b717f | 2016-05-16 17:42:43 -0400 | [diff] [blame] | 5261 | status = decode_open_stateid(xdr, &res->stateid); |
Benny Halevy | 07d3043 | 2009-08-14 17:19:52 +0300 | [diff] [blame] | 5262 | return status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5263 | } |
| 5264 | |
| 5265 | static int decode_open_downgrade(struct xdr_stream *xdr, struct nfs_closeres *res) |
| 5266 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5267 | int status; |
| 5268 | |
| 5269 | status = decode_op_hdr(xdr, OP_OPEN_DOWNGRADE); |
Trond Myklebust | c1d5193 | 2008-04-07 13:20:54 -0400 | [diff] [blame] | 5270 | if (status != -EIO) |
| 5271 | nfs_increment_open_seqid(status, res->seqid); |
Benny Halevy | 07d3043 | 2009-08-14 17:19:52 +0300 | [diff] [blame] | 5272 | if (!status) |
Trond Myklebust | 93b717f | 2016-05-16 17:42:43 -0400 | [diff] [blame] | 5273 | status = decode_open_stateid(xdr, &res->stateid); |
Benny Halevy | 07d3043 | 2009-08-14 17:19:52 +0300 | [diff] [blame] | 5274 | return status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5275 | } |
| 5276 | |
| 5277 | static int decode_putfh(struct xdr_stream *xdr) |
| 5278 | { |
| 5279 | return decode_op_hdr(xdr, OP_PUTFH); |
| 5280 | } |
| 5281 | |
| 5282 | static int decode_putrootfh(struct xdr_stream *xdr) |
| 5283 | { |
| 5284 | return decode_op_hdr(xdr, OP_PUTROOTFH); |
| 5285 | } |
| 5286 | |
Anna Schumaker | 9137bdf | 2014-05-06 09:12:25 -0400 | [diff] [blame] | 5287 | static int decode_read(struct xdr_stream *xdr, struct rpc_rqst *req, |
| 5288 | struct nfs_pgio_res *res) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5289 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 5290 | __be32 *p; |
Trond Myklebust | 64bd577 | 2012-06-20 22:35:05 -0400 | [diff] [blame] | 5291 | uint32_t count, eof, recvd; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5292 | int status; |
| 5293 | |
| 5294 | status = decode_op_hdr(xdr, OP_READ); |
| 5295 | if (status) |
| 5296 | return status; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 5297 | p = xdr_inline_decode(xdr, 8); |
| 5298 | if (unlikely(!p)) |
| 5299 | goto out_overflow; |
Benny Halevy | 6f723f7 | 2009-08-14 17:19:37 +0300 | [diff] [blame] | 5300 | eof = be32_to_cpup(p++); |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 5301 | count = be32_to_cpup(p); |
Trond Myklebust | 64bd577 | 2012-06-20 22:35:05 -0400 | [diff] [blame] | 5302 | recvd = xdr_read_pages(xdr, count); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5303 | if (count > recvd) { |
Chuck Lever | fe82a18 | 2007-09-11 18:01:10 -0400 | [diff] [blame] | 5304 | dprintk("NFS: server cheating in read reply: " |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5305 | "count %u > recvd %u\n", count, recvd); |
| 5306 | count = recvd; |
| 5307 | eof = 0; |
| 5308 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5309 | res->eof = eof; |
| 5310 | res->count = count; |
| 5311 | return 0; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 5312 | out_overflow: |
| 5313 | print_overflow_msg(__func__, xdr); |
| 5314 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5315 | } |
| 5316 | |
| 5317 | static int decode_readdir(struct xdr_stream *xdr, struct rpc_rqst *req, struct nfs4_readdir_res *readdir) |
| 5318 | { |
Chuck Lever | bcecff7 | 2007-10-26 13:32:03 -0400 | [diff] [blame] | 5319 | int status; |
Chuck Lever | cd93710 | 2012-03-02 17:14:31 -0500 | [diff] [blame] | 5320 | __be32 verf[2]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5321 | |
| 5322 | status = decode_op_hdr(xdr, OP_READDIR); |
Benny Halevy | db942bb | 2009-08-14 17:19:56 +0300 | [diff] [blame] | 5323 | if (!status) |
| 5324 | status = decode_verifier(xdr, readdir->verifier.data); |
| 5325 | if (unlikely(status)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5326 | return status; |
Chuck Lever | cd93710 | 2012-03-02 17:14:31 -0500 | [diff] [blame] | 5327 | memcpy(verf, readdir->verifier.data, sizeof(verf)); |
Fred Isaman | 4410924 | 2008-04-02 15:21:15 +0300 | [diff] [blame] | 5328 | dprintk("%s: verifier = %08x:%08x\n", |
Chuck Lever | cd93710 | 2012-03-02 17:14:31 -0500 | [diff] [blame] | 5329 | __func__, verf[0], verf[1]); |
Trond Myklebust | 64bd577 | 2012-06-20 22:35:05 -0400 | [diff] [blame] | 5330 | return xdr_read_pages(xdr, xdr->buf->page_len); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5331 | } |
| 5332 | |
| 5333 | static int decode_readlink(struct xdr_stream *xdr, struct rpc_rqst *req) |
| 5334 | { |
| 5335 | struct xdr_buf *rcvbuf = &req->rq_rcv_buf; |
Chuck Lever | bcecff7 | 2007-10-26 13:32:03 -0400 | [diff] [blame] | 5336 | u32 len, recvd; |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 5337 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5338 | int status; |
| 5339 | |
| 5340 | status = decode_op_hdr(xdr, OP_READLINK); |
| 5341 | if (status) |
| 5342 | return status; |
| 5343 | |
| 5344 | /* Convert length of symlink */ |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 5345 | p = xdr_inline_decode(xdr, 4); |
| 5346 | if (unlikely(!p)) |
| 5347 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 5348 | len = be32_to_cpup(p); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5349 | if (len >= rcvbuf->page_len || len <= 0) { |
Chuck Lever | fe82a18 | 2007-09-11 18:01:10 -0400 | [diff] [blame] | 5350 | dprintk("nfs: server returned giant symlink!\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5351 | return -ENAMETOOLONG; |
| 5352 | } |
Trond Myklebust | 64bd577 | 2012-06-20 22:35:05 -0400 | [diff] [blame] | 5353 | recvd = xdr_read_pages(xdr, len); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5354 | if (recvd < len) { |
Chuck Lever | fe82a18 | 2007-09-11 18:01:10 -0400 | [diff] [blame] | 5355 | dprintk("NFS: server cheating in readlink reply: " |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5356 | "count %u > recvd %u\n", len, recvd); |
| 5357 | return -EIO; |
| 5358 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5359 | /* |
| 5360 | * The XDR encode routine has set things up so that |
| 5361 | * the link text will be copied directly into the |
| 5362 | * buffer. We just have to do overflow-checking, |
| 5363 | * and and null-terminate the text (the VFS expects |
| 5364 | * null-termination). |
| 5365 | */ |
Chuck Lever | b4687da | 2010-09-21 16:55:48 -0400 | [diff] [blame] | 5366 | xdr_terminate_string(rcvbuf, len); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5367 | return 0; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 5368 | out_overflow: |
| 5369 | print_overflow_msg(__func__, xdr); |
| 5370 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5371 | } |
| 5372 | |
| 5373 | static int decode_remove(struct xdr_stream *xdr, struct nfs4_change_info *cinfo) |
| 5374 | { |
| 5375 | int status; |
| 5376 | |
| 5377 | status = decode_op_hdr(xdr, OP_REMOVE); |
| 5378 | if (status) |
| 5379 | goto out; |
| 5380 | status = decode_change_info(xdr, cinfo); |
| 5381 | out: |
| 5382 | return status; |
| 5383 | } |
| 5384 | |
| 5385 | static int decode_rename(struct xdr_stream *xdr, struct nfs4_change_info *old_cinfo, |
| 5386 | struct nfs4_change_info *new_cinfo) |
| 5387 | { |
| 5388 | int status; |
| 5389 | |
| 5390 | status = decode_op_hdr(xdr, OP_RENAME); |
| 5391 | if (status) |
| 5392 | goto out; |
| 5393 | if ((status = decode_change_info(xdr, old_cinfo))) |
| 5394 | goto out; |
| 5395 | status = decode_change_info(xdr, new_cinfo); |
| 5396 | out: |
| 5397 | return status; |
| 5398 | } |
| 5399 | |
| 5400 | static int decode_renew(struct xdr_stream *xdr) |
| 5401 | { |
| 5402 | return decode_op_hdr(xdr, OP_RENEW); |
| 5403 | } |
| 5404 | |
Trond Myklebust | 56ae19f | 2005-10-27 22:12:40 -0400 | [diff] [blame] | 5405 | static int |
| 5406 | decode_restorefh(struct xdr_stream *xdr) |
| 5407 | { |
| 5408 | return decode_op_hdr(xdr, OP_RESTOREFH); |
| 5409 | } |
| 5410 | |
J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 5411 | static int decode_getacl(struct xdr_stream *xdr, struct rpc_rqst *req, |
Andy Adamson | bf118a3 | 2011-12-07 11:55:27 -0500 | [diff] [blame] | 5412 | struct nfs_getaclres *res) |
J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 5413 | { |
Trond Myklebust | 256e48b | 2012-06-21 11:18:13 -0400 | [diff] [blame] | 5414 | unsigned int savep; |
J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 5415 | uint32_t attrlen, |
Fred Isaman | dae100c | 2011-07-30 20:52:37 -0400 | [diff] [blame] | 5416 | bitmap[3] = {0}; |
J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 5417 | int status; |
Trond Myklebust | cff298c | 2012-08-14 17:14:17 -0400 | [diff] [blame] | 5418 | unsigned int pg_offset; |
J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 5419 | |
Andy Adamson | bf118a3 | 2011-12-07 11:55:27 -0500 | [diff] [blame] | 5420 | res->acl_len = 0; |
J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 5421 | if ((status = decode_op_hdr(xdr, OP_GETATTR)) != 0) |
| 5422 | goto out; |
Sachin Prabhu | 5a00689 | 2012-04-17 14:35:39 +0100 | [diff] [blame] | 5423 | |
Trond Myklebust | 519d395 | 2012-08-14 17:30:10 -0400 | [diff] [blame] | 5424 | xdr_enter_page(xdr, xdr->buf->page_len); |
| 5425 | |
Trond Myklebust | cff298c | 2012-08-14 17:14:17 -0400 | [diff] [blame] | 5426 | /* Calculate the offset of the page data */ |
| 5427 | pg_offset = xdr->buf->head[0].iov_len; |
Sachin Prabhu | 5a00689 | 2012-04-17 14:35:39 +0100 | [diff] [blame] | 5428 | |
J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 5429 | if ((status = decode_attr_bitmap(xdr, bitmap)) != 0) |
| 5430 | goto out; |
| 5431 | if ((status = decode_attr_length(xdr, &attrlen, &savep)) != 0) |
| 5432 | goto out; |
| 5433 | |
| 5434 | if (unlikely(bitmap[0] & (FATTR4_WORD0_ACL - 1U))) |
| 5435 | return -EIO; |
| 5436 | if (likely(bitmap[0] & FATTR4_WORD0_ACL)) { |
J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 5437 | |
Andy Adamson | bf118a3 | 2011-12-07 11:55:27 -0500 | [diff] [blame] | 5438 | /* The bitmap (xdr len + bitmaps) and the attr xdr len words |
| 5439 | * are stored with the acl data to handle the problem of |
| 5440 | * variable length bitmaps.*/ |
Trond Myklebust | cff298c | 2012-08-14 17:14:17 -0400 | [diff] [blame] | 5441 | res->acl_data_offset = xdr_stream_pos(xdr) - pg_offset; |
Trond Myklebust | 519d395 | 2012-08-14 17:30:10 -0400 | [diff] [blame] | 5442 | res->acl_len = attrlen; |
Trond Myklebust | 1f1ea6c | 2012-08-26 11:44:43 -0700 | [diff] [blame] | 5443 | |
| 5444 | /* Check for receive buffer overflow */ |
| 5445 | if (res->acl_len > (xdr->nwords << 2) || |
| 5446 | res->acl_len + res->acl_data_offset > xdr->buf->page_len) { |
| 5447 | res->acl_flags |= NFS4_ACL_TRUNC; |
Trond Myklebust | 519d395 | 2012-08-14 17:30:10 -0400 | [diff] [blame] | 5448 | dprintk("NFS: acl reply: attrlen %u > page_len %u\n", |
Trond Myklebust | cff298c | 2012-08-14 17:14:17 -0400 | [diff] [blame] | 5449 | attrlen, xdr->nwords << 2); |
J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 5450 | } |
J. Bruce Fields | 8c233cf | 2005-10-13 16:54:27 -0400 | [diff] [blame] | 5451 | } else |
| 5452 | status = -EOPNOTSUPP; |
J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 5453 | |
| 5454 | out: |
| 5455 | return status; |
| 5456 | } |
| 5457 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5458 | static int |
| 5459 | decode_savefh(struct xdr_stream *xdr) |
| 5460 | { |
| 5461 | return decode_op_hdr(xdr, OP_SAVEFH); |
| 5462 | } |
| 5463 | |
Benny Halevy | 9e9ecc0 | 2009-04-01 09:22:00 -0400 | [diff] [blame] | 5464 | static int decode_setattr(struct xdr_stream *xdr) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5465 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 5466 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5467 | uint32_t bmlen; |
| 5468 | int status; |
| 5469 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5470 | status = decode_op_hdr(xdr, OP_SETATTR); |
| 5471 | if (status) |
| 5472 | return status; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 5473 | p = xdr_inline_decode(xdr, 4); |
| 5474 | if (unlikely(!p)) |
| 5475 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 5476 | bmlen = be32_to_cpup(p); |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 5477 | p = xdr_inline_decode(xdr, bmlen << 2); |
| 5478 | if (likely(p)) |
| 5479 | return 0; |
| 5480 | out_overflow: |
| 5481 | print_overflow_msg(__func__, xdr); |
| 5482 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5483 | } |
| 5484 | |
Trond Myklebust | bb8b27e | 2010-04-16 16:43:06 -0400 | [diff] [blame] | 5485 | 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] | 5486 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 5487 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5488 | uint32_t opnum; |
| 5489 | int32_t nfserr; |
| 5490 | |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 5491 | p = xdr_inline_decode(xdr, 8); |
| 5492 | if (unlikely(!p)) |
| 5493 | goto out_overflow; |
Benny Halevy | 6f723f7 | 2009-08-14 17:19:37 +0300 | [diff] [blame] | 5494 | opnum = be32_to_cpup(p++); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5495 | if (opnum != OP_SETCLIENTID) { |
Chuck Lever | fe82a18 | 2007-09-11 18:01:10 -0400 | [diff] [blame] | 5496 | dprintk("nfs: decode_setclientid: Server returned operation" |
Andy Adamson | 6c0195a | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 5497 | " %d\n", opnum); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5498 | return -EIO; |
| 5499 | } |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 5500 | nfserr = be32_to_cpup(p); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5501 | if (nfserr == NFS_OK) { |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 5502 | p = xdr_inline_decode(xdr, 8 + NFS4_VERIFIER_SIZE); |
| 5503 | if (unlikely(!p)) |
| 5504 | goto out_overflow; |
Trond Myklebust | bb8b27e | 2010-04-16 16:43:06 -0400 | [diff] [blame] | 5505 | p = xdr_decode_hyper(p, &res->clientid); |
| 5506 | memcpy(res->confirm.data, p, NFS4_VERIFIER_SIZE); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5507 | } else if (nfserr == NFSERR_CLID_INUSE) { |
| 5508 | uint32_t len; |
| 5509 | |
| 5510 | /* skip netid string */ |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 5511 | p = xdr_inline_decode(xdr, 4); |
| 5512 | if (unlikely(!p)) |
| 5513 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 5514 | len = be32_to_cpup(p); |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 5515 | p = xdr_inline_decode(xdr, len); |
| 5516 | if (unlikely(!p)) |
| 5517 | goto out_overflow; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5518 | |
| 5519 | /* skip uaddr string */ |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 5520 | p = xdr_inline_decode(xdr, 4); |
| 5521 | if (unlikely(!p)) |
| 5522 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 5523 | len = be32_to_cpup(p); |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 5524 | p = xdr_inline_decode(xdr, len); |
| 5525 | if (unlikely(!p)) |
| 5526 | goto out_overflow; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5527 | return -NFSERR_CLID_INUSE; |
| 5528 | } else |
Benny Halevy | 856dff3 | 2008-03-31 17:39:06 +0300 | [diff] [blame] | 5529 | return nfs4_stat_to_errno(nfserr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5530 | |
| 5531 | return 0; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 5532 | out_overflow: |
| 5533 | print_overflow_msg(__func__, xdr); |
| 5534 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5535 | } |
| 5536 | |
| 5537 | static int decode_setclientid_confirm(struct xdr_stream *xdr) |
| 5538 | { |
| 5539 | return decode_op_hdr(xdr, OP_SETCLIENTID_CONFIRM); |
| 5540 | } |
| 5541 | |
Anna Schumaker | 9137bdf | 2014-05-06 09:12:25 -0400 | [diff] [blame] | 5542 | 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] | 5543 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 5544 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5545 | int status; |
| 5546 | |
| 5547 | status = decode_op_hdr(xdr, OP_WRITE); |
| 5548 | if (status) |
| 5549 | return status; |
| 5550 | |
Trond Myklebust | 2f2c63b | 2012-06-08 11:56:09 -0400 | [diff] [blame] | 5551 | p = xdr_inline_decode(xdr, 8); |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 5552 | if (unlikely(!p)) |
| 5553 | goto out_overflow; |
Benny Halevy | 6f723f7 | 2009-08-14 17:19:37 +0300 | [diff] [blame] | 5554 | res->count = be32_to_cpup(p++); |
| 5555 | res->verf->committed = be32_to_cpup(p++); |
Trond Myklebust | 2f2c63b | 2012-06-08 11:56:09 -0400 | [diff] [blame] | 5556 | return decode_write_verifier(xdr, &res->verf->verifier); |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 5557 | out_overflow: |
| 5558 | print_overflow_msg(__func__, xdr); |
| 5559 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5560 | } |
| 5561 | |
| 5562 | static int decode_delegreturn(struct xdr_stream *xdr) |
| 5563 | { |
| 5564 | return decode_op_hdr(xdr, OP_DELEGRETURN); |
| 5565 | } |
| 5566 | |
Chuck Lever | fb15b26 | 2013-03-16 15:54:34 -0400 | [diff] [blame] | 5567 | static int decode_secinfo_gss(struct xdr_stream *xdr, |
| 5568 | struct nfs4_secinfo4 *flavor) |
Bryan Schumaker | 5a5ea0d | 2011-03-24 17:12:29 +0000 | [diff] [blame] | 5569 | { |
Chuck Lever | fb15b26 | 2013-03-16 15:54:34 -0400 | [diff] [blame] | 5570 | u32 oid_len; |
Bryan Schumaker | 5a5ea0d | 2011-03-24 17:12:29 +0000 | [diff] [blame] | 5571 | __be32 *p; |
| 5572 | |
| 5573 | p = xdr_inline_decode(xdr, 4); |
| 5574 | if (unlikely(!p)) |
| 5575 | goto out_overflow; |
Chuck Lever | fb15b26 | 2013-03-16 15:54:34 -0400 | [diff] [blame] | 5576 | oid_len = be32_to_cpup(p); |
| 5577 | if (oid_len > GSS_OID_MAX_LEN) |
Bryan Schumaker | 5a5ea0d | 2011-03-24 17:12:29 +0000 | [diff] [blame] | 5578 | goto out_err; |
| 5579 | |
Chuck Lever | fb15b26 | 2013-03-16 15:54:34 -0400 | [diff] [blame] | 5580 | p = xdr_inline_decode(xdr, oid_len); |
Bryan Schumaker | 5a5ea0d | 2011-03-24 17:12:29 +0000 | [diff] [blame] | 5581 | if (unlikely(!p)) |
| 5582 | goto out_overflow; |
Chuck Lever | fb15b26 | 2013-03-16 15:54:34 -0400 | [diff] [blame] | 5583 | memcpy(flavor->flavor_info.oid.data, p, oid_len); |
| 5584 | flavor->flavor_info.oid.len = oid_len; |
Bryan Schumaker | 5a5ea0d | 2011-03-24 17:12:29 +0000 | [diff] [blame] | 5585 | |
| 5586 | p = xdr_inline_decode(xdr, 8); |
| 5587 | if (unlikely(!p)) |
| 5588 | goto out_overflow; |
Chuck Lever | fb15b26 | 2013-03-16 15:54:34 -0400 | [diff] [blame] | 5589 | flavor->flavor_info.qop = be32_to_cpup(p++); |
| 5590 | flavor->flavor_info.service = be32_to_cpup(p); |
Bryan Schumaker | 5a5ea0d | 2011-03-24 17:12:29 +0000 | [diff] [blame] | 5591 | |
| 5592 | return 0; |
| 5593 | |
| 5594 | out_overflow: |
| 5595 | print_overflow_msg(__func__, xdr); |
| 5596 | return -EIO; |
| 5597 | out_err: |
| 5598 | return -EINVAL; |
| 5599 | } |
| 5600 | |
Bryan Schumaker | 31e4dda | 2012-04-27 13:27:38 -0400 | [diff] [blame] | 5601 | 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] | 5602 | { |
Chuck Lever | fb15b26 | 2013-03-16 15:54:34 -0400 | [diff] [blame] | 5603 | struct nfs4_secinfo4 *sec_flavor; |
| 5604 | unsigned int i, num_flavors; |
Bryan Schumaker | 5a5ea0d | 2011-03-24 17:12:29 +0000 | [diff] [blame] | 5605 | int status; |
| 5606 | __be32 *p; |
Bryan Schumaker | 5a5ea0d | 2011-03-24 17:12:29 +0000 | [diff] [blame] | 5607 | |
Bryan Schumaker | 5a5ea0d | 2011-03-24 17:12:29 +0000 | [diff] [blame] | 5608 | p = xdr_inline_decode(xdr, 4); |
| 5609 | if (unlikely(!p)) |
| 5610 | goto out_overflow; |
Bryan Schumaker | 5a5ea0d | 2011-03-24 17:12:29 +0000 | [diff] [blame] | 5611 | |
Bryan Schumaker | c3dfc28 | 2011-04-13 14:31:31 -0400 | [diff] [blame] | 5612 | res->flavors->num_flavors = 0; |
| 5613 | num_flavors = be32_to_cpup(p); |
| 5614 | |
| 5615 | for (i = 0; i < num_flavors; i++) { |
Bryan Schumaker | 5a5ea0d | 2011-03-24 17:12:29 +0000 | [diff] [blame] | 5616 | sec_flavor = &res->flavors->flavors[i]; |
Bryan Schumaker | c3dfc28 | 2011-04-13 14:31:31 -0400 | [diff] [blame] | 5617 | if ((char *)&sec_flavor[1] - (char *)res->flavors > PAGE_SIZE) |
Bryan Schumaker | 5a5ea0d | 2011-03-24 17:12:29 +0000 | [diff] [blame] | 5618 | break; |
| 5619 | |
| 5620 | p = xdr_inline_decode(xdr, 4); |
| 5621 | if (unlikely(!p)) |
| 5622 | goto out_overflow; |
| 5623 | sec_flavor->flavor = be32_to_cpup(p); |
| 5624 | |
| 5625 | if (sec_flavor->flavor == RPC_AUTH_GSS) { |
Bryan Schumaker | 613e901 | 2011-04-27 15:28:44 -0400 | [diff] [blame] | 5626 | status = decode_secinfo_gss(xdr, sec_flavor); |
| 5627 | if (status) |
| 5628 | goto out; |
Bryan Schumaker | 5a5ea0d | 2011-03-24 17:12:29 +0000 | [diff] [blame] | 5629 | } |
Bryan Schumaker | c3dfc28 | 2011-04-13 14:31:31 -0400 | [diff] [blame] | 5630 | res->flavors->num_flavors++; |
Bryan Schumaker | 5a5ea0d | 2011-03-24 17:12:29 +0000 | [diff] [blame] | 5631 | } |
| 5632 | |
Bryan Schumaker | 31e4dda | 2012-04-27 13:27:38 -0400 | [diff] [blame] | 5633 | status = 0; |
Bryan Schumaker | 613e901 | 2011-04-27 15:28:44 -0400 | [diff] [blame] | 5634 | out: |
| 5635 | return status; |
Bryan Schumaker | 5a5ea0d | 2011-03-24 17:12:29 +0000 | [diff] [blame] | 5636 | out_overflow: |
| 5637 | print_overflow_msg(__func__, xdr); |
| 5638 | return -EIO; |
| 5639 | } |
| 5640 | |
Bryan Schumaker | 31e4dda | 2012-04-27 13:27:38 -0400 | [diff] [blame] | 5641 | static int decode_secinfo(struct xdr_stream *xdr, struct nfs4_secinfo_res *res) |
| 5642 | { |
| 5643 | int status = decode_op_hdr(xdr, OP_SECINFO); |
| 5644 | if (status) |
| 5645 | return status; |
| 5646 | return decode_secinfo_common(xdr, res); |
| 5647 | } |
| 5648 | |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 5649 | #if defined(CONFIG_NFS_V4_1) |
Bryan Schumaker | 31e4dda | 2012-04-27 13:27:38 -0400 | [diff] [blame] | 5650 | static int decode_secinfo_no_name(struct xdr_stream *xdr, struct nfs4_secinfo_res *res) |
| 5651 | { |
| 5652 | int status = decode_op_hdr(xdr, OP_SECINFO_NO_NAME); |
| 5653 | if (status) |
| 5654 | return status; |
| 5655 | return decode_secinfo_common(xdr, res); |
| 5656 | } |
| 5657 | |
Weston Andros Adamson | 2031cd1 | 2013-08-13 16:37:32 -0400 | [diff] [blame] | 5658 | static int decode_op_map(struct xdr_stream *xdr, struct nfs4_op_map *op_map) |
| 5659 | { |
| 5660 | __be32 *p; |
| 5661 | uint32_t bitmap_words; |
| 5662 | unsigned int i; |
| 5663 | |
| 5664 | p = xdr_inline_decode(xdr, 4); |
Pan Bian | 4edabfd | 2017-04-23 14:49:41 +0800 | [diff] [blame] | 5665 | if (!p) |
| 5666 | return -EIO; |
Weston Andros Adamson | 2031cd1 | 2013-08-13 16:37:32 -0400 | [diff] [blame] | 5667 | bitmap_words = be32_to_cpup(p++); |
| 5668 | if (bitmap_words > NFS4_OP_MAP_NUM_WORDS) |
| 5669 | return -EIO; |
| 5670 | p = xdr_inline_decode(xdr, 4 * bitmap_words); |
| 5671 | for (i = 0; i < bitmap_words; i++) |
| 5672 | op_map->u.words[i] = be32_to_cpup(p++); |
| 5673 | |
| 5674 | return 0; |
| 5675 | } |
| 5676 | |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 5677 | static int decode_exchange_id(struct xdr_stream *xdr, |
| 5678 | struct nfs41_exchange_id_res *res) |
| 5679 | { |
| 5680 | __be32 *p; |
| 5681 | uint32_t dummy; |
Benny Halevy | 2460ba5 | 2009-08-14 17:20:10 +0300 | [diff] [blame] | 5682 | char *dummy_str; |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 5683 | int status; |
Weston Andros Adamson | 7d2ed9a | 2012-02-17 15:20:26 -0500 | [diff] [blame] | 5684 | uint32_t impl_id_count; |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 5685 | |
| 5686 | status = decode_op_hdr(xdr, OP_EXCHANGE_ID); |
| 5687 | if (status) |
| 5688 | return status; |
| 5689 | |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 5690 | p = xdr_inline_decode(xdr, 8); |
| 5691 | if (unlikely(!p)) |
| 5692 | goto out_overflow; |
Trond Myklebust | 32b0131 | 2012-05-26 13:41:04 -0400 | [diff] [blame] | 5693 | xdr_decode_hyper(p, &res->clientid); |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 5694 | p = xdr_inline_decode(xdr, 12); |
| 5695 | if (unlikely(!p)) |
| 5696 | goto out_overflow; |
Trond Myklebust | 32b0131 | 2012-05-26 13:41:04 -0400 | [diff] [blame] | 5697 | res->seqid = be32_to_cpup(p++); |
| 5698 | res->flags = be32_to_cpup(p++); |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 5699 | |
Weston Andros Adamson | 2031cd1 | 2013-08-13 16:37:32 -0400 | [diff] [blame] | 5700 | res->state_protect.how = be32_to_cpup(p); |
| 5701 | switch (res->state_protect.how) { |
| 5702 | case SP4_NONE: |
| 5703 | break; |
| 5704 | case SP4_MACH_CRED: |
| 5705 | status = decode_op_map(xdr, &res->state_protect.enforce); |
| 5706 | if (status) |
| 5707 | return status; |
| 5708 | status = decode_op_map(xdr, &res->state_protect.allow); |
| 5709 | if (status) |
| 5710 | return status; |
| 5711 | break; |
| 5712 | default: |
| 5713 | WARN_ON_ONCE(1); |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 5714 | return -EIO; |
Weston Andros Adamson | 2031cd1 | 2013-08-13 16:37:32 -0400 | [diff] [blame] | 5715 | } |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 5716 | |
Chuck Lever | acdeb69 | 2012-05-21 22:46:16 -0400 | [diff] [blame] | 5717 | /* server_owner4.so_minor_id */ |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 5718 | p = xdr_inline_decode(xdr, 8); |
| 5719 | if (unlikely(!p)) |
| 5720 | goto out_overflow; |
Chuck Lever | acdeb69 | 2012-05-21 22:46:16 -0400 | [diff] [blame] | 5721 | p = xdr_decode_hyper(p, &res->server_owner->minor_id); |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 5722 | |
Chuck Lever | acdeb69 | 2012-05-21 22:46:16 -0400 | [diff] [blame] | 5723 | /* server_owner4.so_major_id */ |
Benny Halevy | 2460ba5 | 2009-08-14 17:20:10 +0300 | [diff] [blame] | 5724 | status = decode_opaque_inline(xdr, &dummy, &dummy_str); |
| 5725 | if (unlikely(status)) |
| 5726 | return status; |
Chuck Lever | acdeb69 | 2012-05-21 22:46:16 -0400 | [diff] [blame] | 5727 | memcpy(res->server_owner->major_id, dummy_str, dummy); |
| 5728 | res->server_owner->major_id_sz = dummy; |
Weston Andros Adamson | 78fe0f4 | 2011-05-31 19:05:47 -0400 | [diff] [blame] | 5729 | |
Chuck Lever | acdeb69 | 2012-05-21 22:46:16 -0400 | [diff] [blame] | 5730 | /* server_scope4 */ |
| 5731 | status = decode_opaque_inline(xdr, &dummy, &dummy_str); |
| 5732 | if (unlikely(status)) |
| 5733 | return status; |
Weston Andros Adamson | 78fe0f4 | 2011-05-31 19:05:47 -0400 | [diff] [blame] | 5734 | memcpy(res->server_scope->server_scope, dummy_str, dummy); |
| 5735 | res->server_scope->server_scope_sz = dummy; |
| 5736 | |
Weston Andros Adamson | 7d2ed9a | 2012-02-17 15:20:26 -0500 | [diff] [blame] | 5737 | /* Implementation Id */ |
| 5738 | p = xdr_inline_decode(xdr, 4); |
| 5739 | if (unlikely(!p)) |
| 5740 | goto out_overflow; |
| 5741 | impl_id_count = be32_to_cpup(p++); |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 5742 | |
Weston Andros Adamson | 7d2ed9a | 2012-02-17 15:20:26 -0500 | [diff] [blame] | 5743 | if (impl_id_count) { |
| 5744 | /* nii_domain */ |
| 5745 | status = decode_opaque_inline(xdr, &dummy, &dummy_str); |
| 5746 | if (unlikely(status)) |
| 5747 | return status; |
Weston Andros Adamson | 7d2ed9a | 2012-02-17 15:20:26 -0500 | [diff] [blame] | 5748 | memcpy(res->impl_id->domain, dummy_str, dummy); |
| 5749 | |
| 5750 | /* nii_name */ |
| 5751 | status = decode_opaque_inline(xdr, &dummy, &dummy_str); |
| 5752 | if (unlikely(status)) |
| 5753 | return status; |
Weston Andros Adamson | 7d2ed9a | 2012-02-17 15:20:26 -0500 | [diff] [blame] | 5754 | memcpy(res->impl_id->name, dummy_str, dummy); |
| 5755 | |
| 5756 | /* nii_date */ |
| 5757 | p = xdr_inline_decode(xdr, 12); |
| 5758 | if (unlikely(!p)) |
| 5759 | goto out_overflow; |
| 5760 | p = xdr_decode_hyper(p, &res->impl_id->date.seconds); |
| 5761 | res->impl_id->date.nseconds = be32_to_cpup(p); |
| 5762 | |
| 5763 | /* if there's more than one entry, ignore the rest */ |
| 5764 | } |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 5765 | return 0; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 5766 | out_overflow: |
| 5767 | print_overflow_msg(__func__, xdr); |
| 5768 | return -EIO; |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 5769 | } |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 5770 | |
| 5771 | static int decode_chan_attrs(struct xdr_stream *xdr, |
| 5772 | struct nfs4_channel_attrs *attrs) |
| 5773 | { |
| 5774 | __be32 *p; |
Benny Halevy | c9c30dd | 2011-06-11 17:08:39 -0400 | [diff] [blame] | 5775 | u32 nr_attrs, val; |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 5776 | |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 5777 | p = xdr_inline_decode(xdr, 28); |
| 5778 | if (unlikely(!p)) |
| 5779 | goto out_overflow; |
Benny Halevy | c9c30dd | 2011-06-11 17:08:39 -0400 | [diff] [blame] | 5780 | val = be32_to_cpup(p++); /* headerpadsz */ |
| 5781 | if (val) |
| 5782 | return -EINVAL; /* no support for header padding yet */ |
Benny Halevy | 6f723f7 | 2009-08-14 17:19:37 +0300 | [diff] [blame] | 5783 | attrs->max_rqst_sz = be32_to_cpup(p++); |
| 5784 | attrs->max_resp_sz = be32_to_cpup(p++); |
| 5785 | attrs->max_resp_sz_cached = be32_to_cpup(p++); |
| 5786 | attrs->max_ops = be32_to_cpup(p++); |
| 5787 | attrs->max_reqs = be32_to_cpup(p++); |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 5788 | nr_attrs = be32_to_cpup(p); |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 5789 | if (unlikely(nr_attrs > 1)) { |
Weston Andros Adamson | a030889 | 2012-01-26 13:32:23 -0500 | [diff] [blame] | 5790 | printk(KERN_WARNING "NFS: %s: Invalid rdma channel attrs " |
| 5791 | "count %u\n", __func__, nr_attrs); |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 5792 | return -EINVAL; |
| 5793 | } |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 5794 | if (nr_attrs == 1) { |
| 5795 | p = xdr_inline_decode(xdr, 4); /* skip rdma_attrs */ |
| 5796 | if (unlikely(!p)) |
| 5797 | goto out_overflow; |
| 5798 | } |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 5799 | return 0; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 5800 | out_overflow: |
| 5801 | print_overflow_msg(__func__, xdr); |
| 5802 | return -EIO; |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 5803 | } |
| 5804 | |
Benny Halevy | e78291e | 2009-08-14 17:20:00 +0300 | [diff] [blame] | 5805 | static int decode_sessionid(struct xdr_stream *xdr, struct nfs4_sessionid *sid) |
| 5806 | { |
| 5807 | return decode_opaque_fixed(xdr, sid->data, NFS4_MAX_SESSIONID_LEN); |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 5808 | } |
| 5809 | |
Weston Andros Adamson | 7c44f1ae | 2012-05-24 13:22:50 -0400 | [diff] [blame] | 5810 | static int decode_bind_conn_to_session(struct xdr_stream *xdr, |
| 5811 | struct nfs41_bind_conn_to_session_res *res) |
| 5812 | { |
| 5813 | __be32 *p; |
| 5814 | int status; |
| 5815 | |
| 5816 | status = decode_op_hdr(xdr, OP_BIND_CONN_TO_SESSION); |
| 5817 | if (!status) |
Trond Myklebust | 71a097c | 2015-02-18 09:27:18 -0800 | [diff] [blame] | 5818 | status = decode_sessionid(xdr, &res->sessionid); |
Weston Andros Adamson | 7c44f1ae | 2012-05-24 13:22:50 -0400 | [diff] [blame] | 5819 | if (unlikely(status)) |
| 5820 | return status; |
| 5821 | |
| 5822 | /* dir flags, rdma mode bool */ |
| 5823 | p = xdr_inline_decode(xdr, 8); |
| 5824 | if (unlikely(!p)) |
| 5825 | goto out_overflow; |
| 5826 | |
| 5827 | res->dir = be32_to_cpup(p++); |
| 5828 | if (res->dir == 0 || res->dir > NFS4_CDFS4_BOTH) |
| 5829 | return -EIO; |
| 5830 | if (be32_to_cpup(p) == 0) |
| 5831 | res->use_conn_in_rdma_mode = false; |
| 5832 | else |
| 5833 | res->use_conn_in_rdma_mode = true; |
| 5834 | |
| 5835 | return 0; |
| 5836 | out_overflow: |
| 5837 | print_overflow_msg(__func__, xdr); |
| 5838 | return -EIO; |
| 5839 | } |
| 5840 | |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 5841 | static int decode_create_session(struct xdr_stream *xdr, |
| 5842 | struct nfs41_create_session_res *res) |
| 5843 | { |
| 5844 | __be32 *p; |
| 5845 | int status; |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 5846 | |
| 5847 | status = decode_op_hdr(xdr, OP_CREATE_SESSION); |
Benny Halevy | e78291e | 2009-08-14 17:20:00 +0300 | [diff] [blame] | 5848 | if (!status) |
Trond Myklebust | 79969dd | 2015-02-18 11:30:18 -0800 | [diff] [blame] | 5849 | status = decode_sessionid(xdr, &res->sessionid); |
Benny Halevy | e78291e | 2009-08-14 17:20:00 +0300 | [diff] [blame] | 5850 | if (unlikely(status)) |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 5851 | return status; |
| 5852 | |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 5853 | /* seqid, flags */ |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 5854 | p = xdr_inline_decode(xdr, 8); |
| 5855 | if (unlikely(!p)) |
| 5856 | goto out_overflow; |
Trond Myklebust | 79969dd | 2015-02-18 11:30:18 -0800 | [diff] [blame] | 5857 | res->seqid = be32_to_cpup(p++); |
| 5858 | res->flags = be32_to_cpup(p); |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 5859 | |
| 5860 | /* Channel attributes */ |
Trond Myklebust | 79969dd | 2015-02-18 11:30:18 -0800 | [diff] [blame] | 5861 | status = decode_chan_attrs(xdr, &res->fc_attrs); |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 5862 | if (!status) |
Trond Myklebust | 79969dd | 2015-02-18 11:30:18 -0800 | [diff] [blame] | 5863 | status = decode_chan_attrs(xdr, &res->bc_attrs); |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 5864 | return status; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 5865 | out_overflow: |
| 5866 | print_overflow_msg(__func__, xdr); |
| 5867 | return -EIO; |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 5868 | } |
Andy Adamson | 0f3e66c | 2009-04-01 09:22:34 -0400 | [diff] [blame] | 5869 | |
| 5870 | static int decode_destroy_session(struct xdr_stream *xdr, void *dummy) |
| 5871 | { |
| 5872 | return decode_op_hdr(xdr, OP_DESTROY_SESSION); |
| 5873 | } |
Ricardo Labiaga | 18019753 | 2009-12-05 16:08:40 -0500 | [diff] [blame] | 5874 | |
Trond Myklebust | 6624553 | 2012-05-25 17:18:09 -0400 | [diff] [blame] | 5875 | static int decode_destroy_clientid(struct xdr_stream *xdr, void *dummy) |
| 5876 | { |
| 5877 | return decode_op_hdr(xdr, OP_DESTROY_CLIENTID); |
| 5878 | } |
| 5879 | |
Ricardo Labiaga | 18019753 | 2009-12-05 16:08:40 -0500 | [diff] [blame] | 5880 | static int decode_reclaim_complete(struct xdr_stream *xdr, void *dummy) |
| 5881 | { |
| 5882 | return decode_op_hdr(xdr, OP_RECLAIM_COMPLETE); |
| 5883 | } |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 5884 | #endif /* CONFIG_NFS_V4_1 */ |
| 5885 | |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 5886 | static int decode_sequence(struct xdr_stream *xdr, |
| 5887 | struct nfs4_sequence_res *res, |
| 5888 | struct rpc_rqst *rqstp) |
| 5889 | { |
| 5890 | #if defined(CONFIG_NFS_V4_1) |
Trond Myklebust | e3725ec | 2012-11-16 12:25:01 -0500 | [diff] [blame] | 5891 | struct nfs4_session *session; |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 5892 | struct nfs4_sessionid id; |
| 5893 | u32 dummy; |
| 5894 | int status; |
| 5895 | __be32 *p; |
| 5896 | |
Trond Myklebust | e3725ec | 2012-11-16 12:25:01 -0500 | [diff] [blame] | 5897 | if (res->sr_slot == NULL) |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 5898 | return 0; |
Chuck Lever | 3bd2384 | 2013-08-09 12:49:19 -0400 | [diff] [blame] | 5899 | if (!res->sr_slot->table->session) |
| 5900 | return 0; |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 5901 | |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 5902 | status = decode_op_hdr(xdr, OP_SEQUENCE); |
Benny Halevy | e78291e | 2009-08-14 17:20:00 +0300 | [diff] [blame] | 5903 | if (!status) |
| 5904 | status = decode_sessionid(xdr, &id); |
| 5905 | if (unlikely(status)) |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 5906 | goto out_err; |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 5907 | |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 5908 | /* |
| 5909 | * If the server returns different values for sessionID, slotID or |
| 5910 | * sequence number, the server is looney tunes. |
| 5911 | */ |
Trond Myklebust | fdcb457 | 2010-02-08 09:32:40 -0500 | [diff] [blame] | 5912 | status = -EREMOTEIO; |
Trond Myklebust | e3725ec | 2012-11-16 12:25:01 -0500 | [diff] [blame] | 5913 | session = res->sr_slot->table->session; |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 5914 | |
Trond Myklebust | e3725ec | 2012-11-16 12:25:01 -0500 | [diff] [blame] | 5915 | if (memcmp(id.data, session->sess_id.data, |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 5916 | NFS4_MAX_SESSIONID_LEN)) { |
| 5917 | dprintk("%s Invalid session id\n", __func__); |
| 5918 | goto out_err; |
| 5919 | } |
Benny Halevy | e78291e | 2009-08-14 17:20:00 +0300 | [diff] [blame] | 5920 | |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 5921 | p = xdr_inline_decode(xdr, 20); |
| 5922 | if (unlikely(!p)) |
| 5923 | goto out_overflow; |
Benny Halevy | e78291e | 2009-08-14 17:20:00 +0300 | [diff] [blame] | 5924 | |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 5925 | /* seqid */ |
Benny Halevy | 6f723f7 | 2009-08-14 17:19:37 +0300 | [diff] [blame] | 5926 | dummy = be32_to_cpup(p++); |
Benny Halevy | dfb4f309 | 2010-09-24 09:17:01 -0400 | [diff] [blame] | 5927 | if (dummy != res->sr_slot->seq_nr) { |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 5928 | dprintk("%s Invalid sequence number\n", __func__); |
| 5929 | goto out_err; |
| 5930 | } |
| 5931 | /* slot id */ |
Benny Halevy | 6f723f7 | 2009-08-14 17:19:37 +0300 | [diff] [blame] | 5932 | dummy = be32_to_cpup(p++); |
Trond Myklebust | df2fabf | 2012-11-16 12:45:06 -0500 | [diff] [blame] | 5933 | if (dummy != res->sr_slot->slot_nr) { |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 5934 | dprintk("%s Invalid slot id\n", __func__); |
| 5935 | goto out_err; |
| 5936 | } |
Trond Myklebust | da0507b | 2012-11-20 18:10:30 -0500 | [diff] [blame] | 5937 | /* highest slot id */ |
| 5938 | res->sr_highest_slotid = be32_to_cpup(p++); |
Trond Myklebust | 464ee9f | 2012-11-20 12:49:27 -0500 | [diff] [blame] | 5939 | /* target highest slot id */ |
| 5940 | res->sr_target_highest_slotid = be32_to_cpup(p++); |
Alexandros Batsakis | 0629e37 | 2009-12-05 13:46:14 -0500 | [diff] [blame] | 5941 | /* result flags */ |
| 5942 | res->sr_status_flags = be32_to_cpup(p); |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 5943 | status = 0; |
| 5944 | out_err: |
| 5945 | res->sr_status = status; |
| 5946 | return status; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 5947 | out_overflow: |
| 5948 | print_overflow_msg(__func__, xdr); |
| 5949 | status = -EIO; |
| 5950 | goto out_err; |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 5951 | #else /* CONFIG_NFS_V4_1 */ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 5952 | return 0; |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 5953 | #endif /* CONFIG_NFS_V4_1 */ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 5954 | } |
| 5955 | |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 5956 | #if defined(CONFIG_NFS_V4_1) |
Trond Myklebust | 93b717f | 2016-05-16 17:42:43 -0400 | [diff] [blame] | 5957 | static int decode_layout_stateid(struct xdr_stream *xdr, nfs4_stateid *stateid) |
| 5958 | { |
| 5959 | stateid->type = NFS4_LAYOUT_STATEID_TYPE; |
| 5960 | return decode_stateid(xdr, stateid); |
| 5961 | } |
| 5962 | |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 5963 | static int decode_getdeviceinfo(struct xdr_stream *xdr, |
Trond Myklebust | 4e59080 | 2015-03-09 14:01:25 -0400 | [diff] [blame] | 5964 | struct nfs4_getdeviceinfo_res *res) |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 5965 | { |
Trond Myklebust | 4e59080 | 2015-03-09 14:01:25 -0400 | [diff] [blame] | 5966 | struct pnfs_device *pdev = res->pdev; |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 5967 | __be32 *p; |
| 5968 | uint32_t len, type; |
| 5969 | int status; |
| 5970 | |
| 5971 | status = decode_op_hdr(xdr, OP_GETDEVICEINFO); |
| 5972 | if (status) { |
| 5973 | if (status == -ETOOSMALL) { |
| 5974 | p = xdr_inline_decode(xdr, 4); |
| 5975 | if (unlikely(!p)) |
| 5976 | goto out_overflow; |
| 5977 | pdev->mincount = be32_to_cpup(p); |
| 5978 | dprintk("%s: Min count too small. mincnt = %u\n", |
| 5979 | __func__, pdev->mincount); |
| 5980 | } |
| 5981 | return status; |
| 5982 | } |
| 5983 | |
| 5984 | p = xdr_inline_decode(xdr, 8); |
| 5985 | if (unlikely(!p)) |
| 5986 | goto out_overflow; |
| 5987 | type = be32_to_cpup(p++); |
| 5988 | if (type != pdev->layout_type) { |
| 5989 | dprintk("%s: layout mismatch req: %u pdev: %u\n", |
| 5990 | __func__, pdev->layout_type, type); |
| 5991 | return -EINVAL; |
| 5992 | } |
| 5993 | /* |
| 5994 | * Get the length of the opaque device_addr4. xdr_read_pages places |
| 5995 | * the opaque device_addr4 in the xdr_buf->pages (pnfs_device->pages) |
| 5996 | * and places the remaining xdr data in xdr_buf->tail |
| 5997 | */ |
| 5998 | pdev->mincount = be32_to_cpup(p); |
Trond Myklebust | 13fe4ba | 2012-08-01 14:21:12 -0400 | [diff] [blame] | 5999 | if (xdr_read_pages(xdr, pdev->mincount) != pdev->mincount) |
| 6000 | goto out_overflow; |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 6001 | |
| 6002 | /* Parse notification bitmap, verifying that it is zero. */ |
| 6003 | p = xdr_inline_decode(xdr, 4); |
| 6004 | if (unlikely(!p)) |
| 6005 | goto out_overflow; |
| 6006 | len = be32_to_cpup(p); |
| 6007 | if (len) { |
Chuck Lever | ead0059 | 2010-12-14 14:58:21 +0000 | [diff] [blame] | 6008 | uint32_t i; |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 6009 | |
| 6010 | p = xdr_inline_decode(xdr, 4 * len); |
| 6011 | if (unlikely(!p)) |
| 6012 | goto out_overflow; |
Christoph Hellwig | 84c9dee | 2014-09-10 17:37:28 -0700 | [diff] [blame] | 6013 | |
Trond Myklebust | 4e59080 | 2015-03-09 14:01:25 -0400 | [diff] [blame] | 6014 | res->notification = be32_to_cpup(p++); |
Christoph Hellwig | 84c9dee | 2014-09-10 17:37:28 -0700 | [diff] [blame] | 6015 | for (i = 1; i < len; i++) { |
| 6016 | if (be32_to_cpup(p++)) { |
| 6017 | dprintk("%s: unsupported notification\n", |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 6018 | __func__); |
| 6019 | return -EIO; |
| 6020 | } |
| 6021 | } |
| 6022 | } |
| 6023 | return 0; |
| 6024 | out_overflow: |
| 6025 | print_overflow_msg(__func__, xdr); |
| 6026 | return -EIO; |
| 6027 | } |
| 6028 | |
| 6029 | static int decode_layoutget(struct xdr_stream *xdr, struct rpc_rqst *req, |
| 6030 | struct nfs4_layoutget_res *res) |
| 6031 | { |
| 6032 | __be32 *p; |
| 6033 | int status; |
| 6034 | u32 layout_count; |
Trond Myklebust | 64bd577 | 2012-06-20 22:35:05 -0400 | [diff] [blame] | 6035 | u32 recvd; |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 6036 | |
| 6037 | status = decode_op_hdr(xdr, OP_LAYOUTGET); |
| 6038 | if (status) |
| 6039 | return status; |
Trond Myklebust | ea9d23f | 2012-03-04 18:13:56 -0500 | [diff] [blame] | 6040 | p = xdr_inline_decode(xdr, 4); |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 6041 | if (unlikely(!p)) |
| 6042 | goto out_overflow; |
Trond Myklebust | ea9d23f | 2012-03-04 18:13:56 -0500 | [diff] [blame] | 6043 | res->return_on_close = be32_to_cpup(p); |
Trond Myklebust | 93b717f | 2016-05-16 17:42:43 -0400 | [diff] [blame] | 6044 | decode_layout_stateid(xdr, &res->stateid); |
Trond Myklebust | ea9d23f | 2012-03-04 18:13:56 -0500 | [diff] [blame] | 6045 | p = xdr_inline_decode(xdr, 4); |
| 6046 | if (unlikely(!p)) |
| 6047 | goto out_overflow; |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 6048 | layout_count = be32_to_cpup(p); |
| 6049 | if (!layout_count) { |
| 6050 | dprintk("%s: server responded with empty layout array\n", |
| 6051 | __func__); |
| 6052 | return -EINVAL; |
| 6053 | } |
| 6054 | |
Weston Andros Adamson | 35124a0 | 2011-03-24 16:48:21 -0400 | [diff] [blame] | 6055 | p = xdr_inline_decode(xdr, 28); |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 6056 | if (unlikely(!p)) |
| 6057 | goto out_overflow; |
| 6058 | p = xdr_decode_hyper(p, &res->range.offset); |
| 6059 | p = xdr_decode_hyper(p, &res->range.length); |
| 6060 | res->range.iomode = be32_to_cpup(p++); |
| 6061 | res->type = be32_to_cpup(p++); |
Weston Andros Adamson | 35124a0 | 2011-03-24 16:48:21 -0400 | [diff] [blame] | 6062 | res->layoutp->len = be32_to_cpup(p); |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 6063 | |
| 6064 | dprintk("%s roff:%lu rlen:%lu riomode:%d, lo_type:0x%x, lo.len:%d\n", |
| 6065 | __func__, |
| 6066 | (unsigned long)res->range.offset, |
| 6067 | (unsigned long)res->range.length, |
| 6068 | res->range.iomode, |
| 6069 | res->type, |
Weston Andros Adamson | 35124a0 | 2011-03-24 16:48:21 -0400 | [diff] [blame] | 6070 | res->layoutp->len); |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 6071 | |
Trond Myklebust | 64bd577 | 2012-06-20 22:35:05 -0400 | [diff] [blame] | 6072 | recvd = xdr_read_pages(xdr, res->layoutp->len); |
Weston Andros Adamson | 35124a0 | 2011-03-24 16:48:21 -0400 | [diff] [blame] | 6073 | if (res->layoutp->len > recvd) { |
| 6074 | dprintk("NFS: server cheating in layoutget reply: " |
| 6075 | "layout len %u > recvd %u\n", |
| 6076 | res->layoutp->len, recvd); |
| 6077 | return -EINVAL; |
| 6078 | } |
| 6079 | |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 6080 | if (layout_count > 1) { |
| 6081 | /* We only handle a length one array at the moment. Any |
| 6082 | * further entries are just ignored. Note that this means |
| 6083 | * the client may see a response that is less than the |
| 6084 | * minimum it requested. |
| 6085 | */ |
| 6086 | dprintk("%s: server responded with %d layouts, dropping tail\n", |
| 6087 | __func__, layout_count); |
| 6088 | } |
| 6089 | |
| 6090 | return 0; |
| 6091 | out_overflow: |
| 6092 | print_overflow_msg(__func__, xdr); |
| 6093 | return -EIO; |
| 6094 | } |
Andy Adamson | 863a3c6 | 2011-03-23 13:27:54 +0000 | [diff] [blame] | 6095 | |
Benny Halevy | cbe8260 | 2011-05-22 19:52:37 +0300 | [diff] [blame] | 6096 | static int decode_layoutreturn(struct xdr_stream *xdr, |
| 6097 | struct nfs4_layoutreturn_res *res) |
| 6098 | { |
| 6099 | __be32 *p; |
| 6100 | int status; |
| 6101 | |
| 6102 | status = decode_op_hdr(xdr, OP_LAYOUTRETURN); |
| 6103 | if (status) |
| 6104 | return status; |
| 6105 | p = xdr_inline_decode(xdr, 4); |
| 6106 | if (unlikely(!p)) |
| 6107 | goto out_overflow; |
| 6108 | res->lrs_present = be32_to_cpup(p); |
| 6109 | if (res->lrs_present) |
Trond Myklebust | 93b717f | 2016-05-16 17:42:43 -0400 | [diff] [blame] | 6110 | status = decode_layout_stateid(xdr, &res->stateid); |
Benny Halevy | cbe8260 | 2011-05-22 19:52:37 +0300 | [diff] [blame] | 6111 | return status; |
| 6112 | out_overflow: |
| 6113 | print_overflow_msg(__func__, xdr); |
| 6114 | return -EIO; |
| 6115 | } |
| 6116 | |
Andy Adamson | 863a3c6 | 2011-03-23 13:27:54 +0000 | [diff] [blame] | 6117 | static int decode_layoutcommit(struct xdr_stream *xdr, |
| 6118 | struct rpc_rqst *req, |
| 6119 | struct nfs4_layoutcommit_res *res) |
| 6120 | { |
| 6121 | __be32 *p; |
| 6122 | __u32 sizechanged; |
| 6123 | int status; |
| 6124 | |
| 6125 | status = decode_op_hdr(xdr, OP_LAYOUTCOMMIT); |
Andy Adamson | db29c08 | 2011-07-30 20:52:38 -0400 | [diff] [blame] | 6126 | res->status = status; |
Andy Adamson | 863a3c6 | 2011-03-23 13:27:54 +0000 | [diff] [blame] | 6127 | if (status) |
| 6128 | return status; |
| 6129 | |
| 6130 | p = xdr_inline_decode(xdr, 4); |
| 6131 | if (unlikely(!p)) |
| 6132 | goto out_overflow; |
| 6133 | sizechanged = be32_to_cpup(p); |
| 6134 | |
| 6135 | if (sizechanged) { |
| 6136 | /* throw away new size */ |
| 6137 | p = xdr_inline_decode(xdr, 8); |
| 6138 | if (unlikely(!p)) |
| 6139 | goto out_overflow; |
| 6140 | } |
| 6141 | return 0; |
| 6142 | out_overflow: |
| 6143 | print_overflow_msg(__func__, xdr); |
| 6144 | return -EIO; |
| 6145 | } |
Bryan Schumaker | 7d97479 | 2011-06-02 14:59:08 -0400 | [diff] [blame] | 6146 | |
| 6147 | static int decode_test_stateid(struct xdr_stream *xdr, |
| 6148 | struct nfs41_test_stateid_res *res) |
| 6149 | { |
| 6150 | __be32 *p; |
| 6151 | int status; |
| 6152 | int num_res; |
| 6153 | |
| 6154 | status = decode_op_hdr(xdr, OP_TEST_STATEID); |
| 6155 | if (status) |
| 6156 | return status; |
| 6157 | |
| 6158 | p = xdr_inline_decode(xdr, 4); |
| 6159 | if (unlikely(!p)) |
| 6160 | goto out_overflow; |
| 6161 | num_res = be32_to_cpup(p++); |
| 6162 | if (num_res != 1) |
| 6163 | goto out; |
| 6164 | |
| 6165 | p = xdr_inline_decode(xdr, 4); |
| 6166 | if (unlikely(!p)) |
| 6167 | goto out_overflow; |
| 6168 | res->status = be32_to_cpup(p++); |
Bryan Schumaker | 1cab065 | 2012-01-31 10:39:29 -0500 | [diff] [blame] | 6169 | |
| 6170 | return status; |
Bryan Schumaker | 7d97479 | 2011-06-02 14:59:08 -0400 | [diff] [blame] | 6171 | out_overflow: |
| 6172 | print_overflow_msg(__func__, xdr); |
| 6173 | out: |
| 6174 | return -EIO; |
| 6175 | } |
Bryan Schumaker | 9aeda35 | 2011-06-02 14:59:09 -0400 | [diff] [blame] | 6176 | |
| 6177 | static int decode_free_stateid(struct xdr_stream *xdr, |
| 6178 | struct nfs41_free_stateid_res *res) |
| 6179 | { |
Andy Adamson | 9f79fb4 | 2013-09-10 12:56:29 -0400 | [diff] [blame] | 6180 | res->status = decode_op_hdr(xdr, OP_FREE_STATEID); |
Bryan Schumaker | 9aeda35 | 2011-06-02 14:59:09 -0400 | [diff] [blame] | 6181 | return res->status; |
Bryan Schumaker | 9aeda35 | 2011-06-02 14:59:09 -0400 | [diff] [blame] | 6182 | } |
Trond Myklebust | cf80516 | 2016-11-15 14:56:07 -0500 | [diff] [blame] | 6183 | #else |
| 6184 | static inline |
| 6185 | int decode_layoutreturn(struct xdr_stream *xdr, |
| 6186 | struct nfs4_layoutreturn_res *res) |
| 6187 | { |
| 6188 | return 0; |
| 6189 | } |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 6190 | #endif /* CONFIG_NFS_V4_1 */ |
| 6191 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6192 | /* |
Benny Halevy | 49c2559 | 2008-12-23 16:06:16 -0500 | [diff] [blame] | 6193 | * END OF "GENERIC" DECODE ROUTINES. |
| 6194 | */ |
| 6195 | |
| 6196 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6197 | * Decode OPEN_DOWNGRADE response |
| 6198 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6199 | static int nfs4_xdr_dec_open_downgrade(struct rpc_rqst *rqstp, |
| 6200 | struct xdr_stream *xdr, |
Christoph Hellwig | fc01648 | 2017-05-08 15:09:02 +0200 | [diff] [blame] | 6201 | void *data) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6202 | { |
Christoph Hellwig | fc01648 | 2017-05-08 15:09:02 +0200 | [diff] [blame] | 6203 | struct nfs_closeres *res = data; |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6204 | struct compound_hdr hdr; |
| 6205 | int status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6206 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6207 | status = decode_compound_hdr(xdr, &hdr); |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6208 | if (status) |
| 6209 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6210 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6211 | if (status) |
| 6212 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6213 | status = decode_putfh(xdr); |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6214 | if (status) |
| 6215 | goto out; |
Trond Myklebust | b680814 | 2016-11-20 13:34:16 -0500 | [diff] [blame] | 6216 | if (res->lr_res) { |
| 6217 | status = decode_layoutreturn(xdr, res->lr_res); |
| 6218 | res->lr_ret = status; |
| 6219 | if (status) |
| 6220 | goto out; |
| 6221 | } |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6222 | status = decode_open_downgrade(xdr, res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6223 | out: |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6224 | return status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6225 | } |
| 6226 | |
| 6227 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6228 | * Decode ACCESS response |
| 6229 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6230 | 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] | 6231 | void *data) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6232 | { |
Christoph Hellwig | fc01648 | 2017-05-08 15:09:02 +0200 | [diff] [blame] | 6233 | struct nfs4_accessres *res = data; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6234 | struct compound_hdr hdr; |
| 6235 | int status; |
Andy Adamson | 6c0195a | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6236 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6237 | status = decode_compound_hdr(xdr, &hdr); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6238 | if (status) |
| 6239 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6240 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6241 | if (status) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6242 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6243 | status = decode_putfh(xdr); |
Trond Myklebust | 76b3299 | 2007-08-10 17:45:11 -0400 | [diff] [blame] | 6244 | if (status != 0) |
| 6245 | goto out; |
Weston Andros Adamson | 6168f62 | 2012-09-10 14:00:46 -0400 | [diff] [blame] | 6246 | status = decode_access(xdr, &res->supported, &res->access); |
Trond Myklebust | 76b3299 | 2007-08-10 17:45:11 -0400 | [diff] [blame] | 6247 | if (status != 0) |
| 6248 | goto out; |
Trond Myklebust | 6926afd | 2012-01-07 13:22:46 -0500 | [diff] [blame] | 6249 | decode_getfattr(xdr, res->fattr, res->server); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6250 | out: |
| 6251 | return status; |
| 6252 | } |
| 6253 | |
| 6254 | /* |
| 6255 | * Decode LOOKUP response |
| 6256 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6257 | 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] | 6258 | void *data) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6259 | { |
Christoph Hellwig | fc01648 | 2017-05-08 15:09:02 +0200 | [diff] [blame] | 6260 | struct nfs4_lookup_res *res = data; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6261 | struct compound_hdr hdr; |
| 6262 | int status; |
Andy Adamson | 6c0195a | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6263 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6264 | status = decode_compound_hdr(xdr, &hdr); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6265 | if (status) |
| 6266 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6267 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6268 | if (status) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6269 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6270 | status = decode_putfh(xdr); |
| 6271 | if (status) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6272 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6273 | status = decode_lookup(xdr); |
| 6274 | if (status) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6275 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6276 | status = decode_getfh(xdr, res->fh); |
| 6277 | if (status) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6278 | goto out; |
David Quigley | aa9c266 | 2013-05-22 12:50:44 -0400 | [diff] [blame] | 6279 | status = decode_getfattr_label(xdr, res->fattr, res->label, res->server); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6280 | out: |
| 6281 | return status; |
| 6282 | } |
| 6283 | |
| 6284 | /* |
Jeff Layton | 5b5faaf | 2017-06-29 06:34:52 -0700 | [diff] [blame] | 6285 | * Decode LOOKUPP response |
| 6286 | */ |
| 6287 | static int nfs4_xdr_dec_lookupp(struct rpc_rqst *rqstp, struct xdr_stream *xdr, |
| 6288 | void *data) |
| 6289 | { |
| 6290 | struct nfs4_lookupp_res *res = data; |
| 6291 | struct compound_hdr hdr; |
| 6292 | int status; |
| 6293 | |
| 6294 | status = decode_compound_hdr(xdr, &hdr); |
| 6295 | if (status) |
| 6296 | goto out; |
| 6297 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
| 6298 | if (status) |
| 6299 | goto out; |
| 6300 | status = decode_putfh(xdr); |
| 6301 | if (status) |
| 6302 | goto out; |
| 6303 | status = decode_lookupp(xdr); |
| 6304 | if (status) |
| 6305 | goto out; |
| 6306 | status = decode_getfh(xdr, res->fh); |
| 6307 | if (status) |
| 6308 | goto out; |
| 6309 | status = decode_getfattr_label(xdr, res->fattr, res->label, res->server); |
| 6310 | out: |
| 6311 | return status; |
| 6312 | } |
| 6313 | |
| 6314 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6315 | * Decode LOOKUP_ROOT response |
| 6316 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6317 | static int nfs4_xdr_dec_lookup_root(struct rpc_rqst *rqstp, |
| 6318 | struct xdr_stream *xdr, |
Christoph Hellwig | fc01648 | 2017-05-08 15:09:02 +0200 | [diff] [blame] | 6319 | void *data) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6320 | { |
Christoph Hellwig | fc01648 | 2017-05-08 15:09:02 +0200 | [diff] [blame] | 6321 | struct nfs4_lookup_res *res = data; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6322 | struct compound_hdr hdr; |
| 6323 | int status; |
Andy Adamson | 6c0195a | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6324 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6325 | status = decode_compound_hdr(xdr, &hdr); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6326 | if (status) |
| 6327 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6328 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6329 | if (status) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6330 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6331 | status = decode_putrootfh(xdr); |
| 6332 | if (status) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6333 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6334 | status = decode_getfh(xdr, res->fh); |
| 6335 | if (status == 0) |
David Quigley | aa9c266 | 2013-05-22 12:50:44 -0400 | [diff] [blame] | 6336 | status = decode_getfattr_label(xdr, res->fattr, |
| 6337 | res->label, res->server); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6338 | out: |
| 6339 | return status; |
| 6340 | } |
| 6341 | |
| 6342 | /* |
| 6343 | * Decode REMOVE response |
| 6344 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6345 | 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] | 6346 | void *data) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6347 | { |
Christoph Hellwig | fc01648 | 2017-05-08 15:09:02 +0200 | [diff] [blame] | 6348 | struct nfs_removeres *res = data; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6349 | struct compound_hdr hdr; |
| 6350 | int status; |
Andy Adamson | 6c0195a | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6351 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6352 | status = decode_compound_hdr(xdr, &hdr); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6353 | if (status) |
| 6354 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6355 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6356 | if (status) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6357 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6358 | status = decode_putfh(xdr); |
| 6359 | if (status) |
Trond Myklebust | 16e4295 | 2005-10-27 22:12:44 -0400 | [diff] [blame] | 6360 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6361 | status = decode_remove(xdr, &res->cinfo); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6362 | out: |
| 6363 | return status; |
| 6364 | } |
| 6365 | |
| 6366 | /* |
| 6367 | * Decode RENAME response |
| 6368 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6369 | 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] | 6370 | void *data) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6371 | { |
Christoph Hellwig | fc01648 | 2017-05-08 15:09:02 +0200 | [diff] [blame] | 6372 | struct nfs_renameres *res = data; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6373 | struct compound_hdr hdr; |
| 6374 | int status; |
Andy Adamson | 6c0195a | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6375 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6376 | status = decode_compound_hdr(xdr, &hdr); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6377 | if (status) |
| 6378 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6379 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6380 | if (status) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6381 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6382 | status = decode_putfh(xdr); |
| 6383 | if (status) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6384 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6385 | status = decode_savefh(xdr); |
| 6386 | if (status) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6387 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6388 | status = decode_putfh(xdr); |
| 6389 | if (status) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6390 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6391 | status = decode_rename(xdr, &res->old_cinfo, &res->new_cinfo); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6392 | out: |
| 6393 | return status; |
| 6394 | } |
| 6395 | |
| 6396 | /* |
| 6397 | * Decode LINK response |
| 6398 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6399 | 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] | 6400 | void *data) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6401 | { |
Christoph Hellwig | fc01648 | 2017-05-08 15:09:02 +0200 | [diff] [blame] | 6402 | struct nfs4_link_res *res = data; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6403 | struct compound_hdr hdr; |
| 6404 | int status; |
Andy Adamson | 6c0195a | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6405 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6406 | status = decode_compound_hdr(xdr, &hdr); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6407 | if (status) |
| 6408 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6409 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6410 | if (status) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6411 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6412 | status = decode_putfh(xdr); |
| 6413 | if (status) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6414 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6415 | status = decode_savefh(xdr); |
| 6416 | if (status) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6417 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6418 | status = decode_putfh(xdr); |
| 6419 | if (status) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6420 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6421 | status = decode_link(xdr, &res->cinfo); |
| 6422 | if (status) |
Trond Myklebust | 91ba2ee | 2005-10-27 22:12:42 -0400 | [diff] [blame] | 6423 | goto out; |
| 6424 | /* |
| 6425 | * Note order: OP_LINK leaves the directory as the current |
| 6426 | * filehandle. |
| 6427 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6428 | status = decode_restorefh(xdr); |
| 6429 | if (status) |
Trond Myklebust | 91ba2ee | 2005-10-27 22:12:42 -0400 | [diff] [blame] | 6430 | goto out; |
David Quigley | aa9c266 | 2013-05-22 12:50:44 -0400 | [diff] [blame] | 6431 | decode_getfattr_label(xdr, res->fattr, res->label, res->server); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6432 | out: |
| 6433 | return status; |
| 6434 | } |
| 6435 | |
| 6436 | /* |
| 6437 | * Decode CREATE response |
| 6438 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6439 | 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] | 6440 | void *data) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6441 | { |
Christoph Hellwig | fc01648 | 2017-05-08 15:09:02 +0200 | [diff] [blame] | 6442 | struct nfs4_create_res *res = data; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6443 | struct compound_hdr hdr; |
| 6444 | int status; |
Andy Adamson | 6c0195a | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6445 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6446 | status = decode_compound_hdr(xdr, &hdr); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6447 | if (status) |
| 6448 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6449 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6450 | if (status) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6451 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6452 | status = decode_putfh(xdr); |
| 6453 | if (status) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6454 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6455 | status = decode_create(xdr, &res->dir_cinfo); |
| 6456 | if (status) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6457 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6458 | status = decode_getfh(xdr, res->fh); |
| 6459 | if (status) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6460 | goto out; |
David Quigley | aa9c266 | 2013-05-22 12:50:44 -0400 | [diff] [blame] | 6461 | decode_getfattr_label(xdr, res->fattr, res->label, res->server); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6462 | out: |
| 6463 | return status; |
| 6464 | } |
| 6465 | |
| 6466 | /* |
| 6467 | * Decode SYMLINK response |
| 6468 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6469 | 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] | 6470 | void *res) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6471 | { |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6472 | return nfs4_xdr_dec_create(rqstp, xdr, res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6473 | } |
| 6474 | |
| 6475 | /* |
| 6476 | * Decode GETATTR response |
| 6477 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6478 | 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] | 6479 | void *data) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6480 | { |
Christoph Hellwig | fc01648 | 2017-05-08 15:09:02 +0200 | [diff] [blame] | 6481 | struct nfs4_getattr_res *res = data; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6482 | struct compound_hdr hdr; |
| 6483 | int status; |
Andy Adamson | 6c0195a | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6484 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6485 | status = decode_compound_hdr(xdr, &hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6486 | if (status) |
| 6487 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6488 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6489 | if (status) |
| 6490 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6491 | status = decode_putfh(xdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6492 | if (status) |
| 6493 | goto out; |
David Quigley | aa9c266 | 2013-05-22 12:50:44 -0400 | [diff] [blame] | 6494 | status = decode_getfattr_label(xdr, res->fattr, res->label, res->server); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6495 | out: |
| 6496 | return status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6497 | } |
| 6498 | |
J. Bruce Fields | 23ec696 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 6499 | /* |
| 6500 | * Encode an SETACL request |
| 6501 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 6502 | 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] | 6503 | const void *data) |
J. Bruce Fields | 23ec696 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 6504 | { |
Christoph Hellwig | fcc8581 | 2017-05-08 10:01:49 +0200 | [diff] [blame] | 6505 | const struct nfs_setaclargs *args = data; |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6506 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 6507 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6508 | }; |
J. Bruce Fields | 23ec696 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 6509 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 6510 | encode_compound_hdr(xdr, req, &hdr); |
| 6511 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 6512 | encode_putfh(xdr, args->fh, &hdr); |
| 6513 | encode_setacl(xdr, args, &hdr); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 6514 | encode_nops(&hdr); |
J. Bruce Fields | 23ec696 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 6515 | } |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6516 | |
J. Bruce Fields | 23ec696 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 6517 | /* |
| 6518 | * Decode SETACL response |
| 6519 | */ |
| 6520 | static int |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6521 | nfs4_xdr_dec_setacl(struct rpc_rqst *rqstp, struct xdr_stream *xdr, |
Christoph Hellwig | fc01648 | 2017-05-08 15:09:02 +0200 | [diff] [blame] | 6522 | void *data) |
J. Bruce Fields | 23ec696 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 6523 | { |
Christoph Hellwig | fc01648 | 2017-05-08 15:09:02 +0200 | [diff] [blame] | 6524 | struct nfs_setaclres *res = data; |
J. Bruce Fields | 23ec696 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 6525 | struct compound_hdr hdr; |
| 6526 | int status; |
| 6527 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6528 | status = decode_compound_hdr(xdr, &hdr); |
J. Bruce Fields | 23ec696 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 6529 | if (status) |
| 6530 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6531 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6532 | if (status) |
| 6533 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6534 | status = decode_putfh(xdr); |
J. Bruce Fields | 23ec696 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 6535 | if (status) |
| 6536 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6537 | status = decode_setattr(xdr); |
J. Bruce Fields | 23ec696 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 6538 | out: |
| 6539 | return status; |
| 6540 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6541 | |
| 6542 | /* |
J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 6543 | * Decode GETACL response |
| 6544 | */ |
| 6545 | static int |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6546 | nfs4_xdr_dec_getacl(struct rpc_rqst *rqstp, struct xdr_stream *xdr, |
Christoph Hellwig | fc01648 | 2017-05-08 15:09:02 +0200 | [diff] [blame] | 6547 | void *data) |
J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 6548 | { |
Christoph Hellwig | fc01648 | 2017-05-08 15:09:02 +0200 | [diff] [blame] | 6549 | struct nfs_getaclres *res = data; |
J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 6550 | struct compound_hdr hdr; |
| 6551 | int status; |
| 6552 | |
Trond Myklebust | 331818f | 2012-02-03 18:30:53 -0500 | [diff] [blame] | 6553 | if (res->acl_scratch != NULL) { |
| 6554 | void *p = page_address(res->acl_scratch); |
| 6555 | xdr_set_scratch_buffer(xdr, p, PAGE_SIZE); |
| 6556 | } |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6557 | status = decode_compound_hdr(xdr, &hdr); |
J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 6558 | if (status) |
| 6559 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6560 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6561 | if (status) |
| 6562 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6563 | status = decode_putfh(xdr); |
J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 6564 | if (status) |
| 6565 | goto out; |
Andy Adamson | bf118a3 | 2011-12-07 11:55:27 -0500 | [diff] [blame] | 6566 | status = decode_getacl(xdr, rqstp, res); |
J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 6567 | |
| 6568 | out: |
| 6569 | return status; |
| 6570 | } |
| 6571 | |
| 6572 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6573 | * Decode CLOSE response |
| 6574 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6575 | 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] | 6576 | void *data) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6577 | { |
Christoph Hellwig | fc01648 | 2017-05-08 15:09:02 +0200 | [diff] [blame] | 6578 | struct nfs_closeres *res = data; |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6579 | struct compound_hdr hdr; |
| 6580 | int status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6581 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6582 | status = decode_compound_hdr(xdr, &hdr); |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6583 | if (status) |
| 6584 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6585 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6586 | if (status) |
| 6587 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6588 | status = decode_putfh(xdr); |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6589 | if (status) |
| 6590 | goto out; |
Trond Myklebust | cf80516 | 2016-11-15 14:56:07 -0500 | [diff] [blame] | 6591 | if (res->lr_res) { |
| 6592 | status = decode_layoutreturn(xdr, res->lr_res); |
| 6593 | res->lr_ret = status; |
| 6594 | if (status) |
| 6595 | goto out; |
| 6596 | } |
Trond Myklebust | d8d8498 | 2016-12-19 12:14:44 -0500 | [diff] [blame] | 6597 | if (res->fattr != NULL) { |
| 6598 | status = decode_getfattr(xdr, res->fattr, res->server); |
| 6599 | if (status != 0) |
| 6600 | goto out; |
| 6601 | } |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6602 | status = decode_close(xdr, res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6603 | out: |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6604 | return status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6605 | } |
| 6606 | |
| 6607 | /* |
| 6608 | * Decode OPEN response |
| 6609 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6610 | 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] | 6611 | void *data) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6612 | { |
Christoph Hellwig | fc01648 | 2017-05-08 15:09:02 +0200 | [diff] [blame] | 6613 | struct nfs_openres *res = data; |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6614 | struct compound_hdr hdr; |
| 6615 | int status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6616 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6617 | status = decode_compound_hdr(xdr, &hdr); |
Trond Myklebust | 56ae19f | 2005-10-27 22:12:40 -0400 | [diff] [blame] | 6618 | if (status) |
| 6619 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6620 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6621 | if (status) |
| 6622 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6623 | status = decode_putfh(xdr); |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6624 | if (status) |
| 6625 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6626 | status = decode_open(xdr, res); |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6627 | if (status) |
| 6628 | goto out; |
Weston Andros Adamson | 01913b4 | 2012-09-06 15:54:27 -0400 | [diff] [blame] | 6629 | status = decode_getfh(xdr, &res->fh); |
| 6630 | if (status) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6631 | goto out; |
Weston Andros Adamson | ae2bb03 | 2012-10-02 14:49:52 -0700 | [diff] [blame] | 6632 | if (res->access_request) |
| 6633 | decode_access(xdr, &res->access_supported, &res->access_result); |
David Quigley | aa9c266 | 2013-05-22 12:50:44 -0400 | [diff] [blame] | 6634 | decode_getfattr_label(xdr, res->f_attr, res->f_label, res->server); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6635 | out: |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6636 | return status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6637 | } |
| 6638 | |
| 6639 | /* |
| 6640 | * Decode OPEN_CONFIRM response |
| 6641 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6642 | static int nfs4_xdr_dec_open_confirm(struct rpc_rqst *rqstp, |
| 6643 | struct xdr_stream *xdr, |
Christoph Hellwig | fc01648 | 2017-05-08 15:09:02 +0200 | [diff] [blame] | 6644 | void *data) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6645 | { |
Christoph Hellwig | fc01648 | 2017-05-08 15:09:02 +0200 | [diff] [blame] | 6646 | struct nfs_open_confirmres *res = data; |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6647 | struct compound_hdr hdr; |
| 6648 | int status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6649 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6650 | status = decode_compound_hdr(xdr, &hdr); |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6651 | if (status) |
| 6652 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6653 | status = decode_putfh(xdr); |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6654 | if (status) |
| 6655 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6656 | status = decode_open_confirm(xdr, res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6657 | out: |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6658 | return status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6659 | } |
| 6660 | |
| 6661 | /* |
| 6662 | * Decode OPEN response |
| 6663 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6664 | static int nfs4_xdr_dec_open_noattr(struct rpc_rqst *rqstp, |
| 6665 | struct xdr_stream *xdr, |
Christoph Hellwig | fc01648 | 2017-05-08 15:09:02 +0200 | [diff] [blame] | 6666 | void *data) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6667 | { |
Christoph Hellwig | fc01648 | 2017-05-08 15:09:02 +0200 | [diff] [blame] | 6668 | struct nfs_openres *res = data; |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6669 | struct compound_hdr hdr; |
| 6670 | int status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6671 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6672 | status = decode_compound_hdr(xdr, &hdr); |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6673 | if (status) |
| 6674 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6675 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6676 | if (status) |
| 6677 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6678 | status = decode_putfh(xdr); |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6679 | if (status) |
| 6680 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6681 | status = decode_open(xdr, res); |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6682 | if (status) |
| 6683 | goto out; |
Weston Andros Adamson | ae2bb03 | 2012-10-02 14:49:52 -0700 | [diff] [blame] | 6684 | if (res->access_request) |
| 6685 | decode_access(xdr, &res->access_supported, &res->access_result); |
Trond Myklebust | 6926afd | 2012-01-07 13:22:46 -0500 | [diff] [blame] | 6686 | decode_getfattr(xdr, res->f_attr, res->server); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6687 | out: |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6688 | return status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6689 | } |
| 6690 | |
| 6691 | /* |
| 6692 | * Decode SETATTR response |
| 6693 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6694 | static int nfs4_xdr_dec_setattr(struct rpc_rqst *rqstp, |
| 6695 | struct xdr_stream *xdr, |
Christoph Hellwig | fc01648 | 2017-05-08 15:09:02 +0200 | [diff] [blame] | 6696 | void *data) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6697 | { |
Christoph Hellwig | fc01648 | 2017-05-08 15:09:02 +0200 | [diff] [blame] | 6698 | struct nfs_setattrres *res = data; |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6699 | struct compound_hdr hdr; |
| 6700 | int status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6701 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6702 | status = decode_compound_hdr(xdr, &hdr); |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6703 | if (status) |
| 6704 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6705 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6706 | if (status) |
| 6707 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6708 | status = decode_putfh(xdr); |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6709 | if (status) |
| 6710 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6711 | status = decode_setattr(xdr); |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6712 | if (status) |
| 6713 | goto out; |
David Quigley | aa9c266 | 2013-05-22 12:50:44 -0400 | [diff] [blame] | 6714 | decode_getfattr_label(xdr, res->fattr, res->label, res->server); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6715 | out: |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6716 | return status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6717 | } |
| 6718 | |
| 6719 | /* |
| 6720 | * Decode LOCK response |
| 6721 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6722 | 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] | 6723 | void *data) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6724 | { |
Christoph Hellwig | fc01648 | 2017-05-08 15:09:02 +0200 | [diff] [blame] | 6725 | struct nfs_lock_res *res = data; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6726 | struct compound_hdr hdr; |
| 6727 | int status; |
| 6728 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6729 | status = decode_compound_hdr(xdr, &hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6730 | if (status) |
| 6731 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6732 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6733 | if (status) |
| 6734 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6735 | status = decode_putfh(xdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6736 | if (status) |
| 6737 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6738 | status = decode_lock(xdr, res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6739 | out: |
| 6740 | return status; |
| 6741 | } |
| 6742 | |
| 6743 | /* |
| 6744 | * Decode LOCKT response |
| 6745 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6746 | 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] | 6747 | void *data) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6748 | { |
Christoph Hellwig | fc01648 | 2017-05-08 15:09:02 +0200 | [diff] [blame] | 6749 | struct nfs_lockt_res *res = data; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6750 | struct compound_hdr hdr; |
| 6751 | int status; |
| 6752 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6753 | status = decode_compound_hdr(xdr, &hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6754 | if (status) |
| 6755 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6756 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6757 | if (status) |
| 6758 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6759 | status = decode_putfh(xdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6760 | if (status) |
| 6761 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6762 | status = decode_lockt(xdr, res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6763 | out: |
| 6764 | return status; |
| 6765 | } |
| 6766 | |
| 6767 | /* |
| 6768 | * Decode LOCKU response |
| 6769 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6770 | 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] | 6771 | void *data) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6772 | { |
Christoph Hellwig | fc01648 | 2017-05-08 15:09:02 +0200 | [diff] [blame] | 6773 | struct nfs_locku_res *res = data; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6774 | struct compound_hdr hdr; |
| 6775 | int status; |
| 6776 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6777 | status = decode_compound_hdr(xdr, &hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6778 | if (status) |
| 6779 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6780 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6781 | if (status) |
| 6782 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6783 | status = decode_putfh(xdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6784 | if (status) |
| 6785 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6786 | status = decode_locku(xdr, res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6787 | out: |
| 6788 | return status; |
| 6789 | } |
| 6790 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6791 | static int nfs4_xdr_dec_release_lockowner(struct rpc_rqst *rqstp, |
| 6792 | struct xdr_stream *xdr, void *dummy) |
Trond Myklebust | d3c7b7c | 2010-07-01 12:49:01 -0400 | [diff] [blame] | 6793 | { |
Trond Myklebust | d3c7b7c | 2010-07-01 12:49:01 -0400 | [diff] [blame] | 6794 | struct compound_hdr hdr; |
| 6795 | int status; |
| 6796 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6797 | status = decode_compound_hdr(xdr, &hdr); |
Trond Myklebust | d3c7b7c | 2010-07-01 12:49:01 -0400 | [diff] [blame] | 6798 | if (!status) |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6799 | status = decode_release_lockowner(xdr); |
Trond Myklebust | d3c7b7c | 2010-07-01 12:49:01 -0400 | [diff] [blame] | 6800 | return status; |
| 6801 | } |
| 6802 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6803 | /* |
| 6804 | * Decode READLINK response |
| 6805 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6806 | static int nfs4_xdr_dec_readlink(struct rpc_rqst *rqstp, |
| 6807 | struct xdr_stream *xdr, |
Christoph Hellwig | fc01648 | 2017-05-08 15:09:02 +0200 | [diff] [blame] | 6808 | void *data) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6809 | { |
Christoph Hellwig | fc01648 | 2017-05-08 15:09:02 +0200 | [diff] [blame] | 6810 | struct nfs4_readlink_res *res = data; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6811 | struct compound_hdr hdr; |
| 6812 | int status; |
| 6813 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6814 | status = decode_compound_hdr(xdr, &hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6815 | if (status) |
| 6816 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6817 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6818 | if (status) |
| 6819 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6820 | status = decode_putfh(xdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6821 | if (status) |
| 6822 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6823 | status = decode_readlink(xdr, rqstp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6824 | out: |
| 6825 | return status; |
| 6826 | } |
| 6827 | |
| 6828 | /* |
| 6829 | * Decode READDIR response |
| 6830 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6831 | 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] | 6832 | void *data) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6833 | { |
Christoph Hellwig | fc01648 | 2017-05-08 15:09:02 +0200 | [diff] [blame] | 6834 | struct nfs4_readdir_res *res = data; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6835 | struct compound_hdr hdr; |
| 6836 | int status; |
| 6837 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6838 | status = decode_compound_hdr(xdr, &hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6839 | if (status) |
| 6840 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6841 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6842 | if (status) |
| 6843 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6844 | status = decode_putfh(xdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6845 | if (status) |
| 6846 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6847 | status = decode_readdir(xdr, rqstp, res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6848 | out: |
| 6849 | return status; |
| 6850 | } |
| 6851 | |
| 6852 | /* |
| 6853 | * Decode Read response |
| 6854 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6855 | 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] | 6856 | void *data) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6857 | { |
Christoph Hellwig | fc01648 | 2017-05-08 15:09:02 +0200 | [diff] [blame] | 6858 | struct nfs_pgio_res *res = data; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6859 | struct compound_hdr hdr; |
| 6860 | int status; |
| 6861 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6862 | status = decode_compound_hdr(xdr, &hdr); |
Peng Tao | aabff4d | 2014-08-27 10:47:14 +0800 | [diff] [blame] | 6863 | res->op_status = hdr.status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6864 | if (status) |
| 6865 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6866 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6867 | if (status) |
| 6868 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6869 | status = decode_putfh(xdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6870 | if (status) |
| 6871 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6872 | status = decode_read(xdr, rqstp, res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6873 | if (!status) |
| 6874 | status = res->count; |
| 6875 | out: |
| 6876 | return status; |
| 6877 | } |
| 6878 | |
| 6879 | /* |
| 6880 | * Decode WRITE response |
| 6881 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6882 | 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] | 6883 | void *data) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6884 | { |
Christoph Hellwig | fc01648 | 2017-05-08 15:09:02 +0200 | [diff] [blame] | 6885 | struct nfs_pgio_res *res = data; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6886 | struct compound_hdr hdr; |
| 6887 | int status; |
| 6888 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6889 | status = decode_compound_hdr(xdr, &hdr); |
Peng Tao | aabff4d | 2014-08-27 10:47:14 +0800 | [diff] [blame] | 6890 | res->op_status = hdr.status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6891 | if (status) |
| 6892 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6893 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6894 | if (status) |
| 6895 | goto out; |
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) |
| 6898 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6899 | status = decode_write(xdr, res); |
Trond Myklebust | 4f9838c | 2005-10-27 22:12:44 -0400 | [diff] [blame] | 6900 | if (status) |
| 6901 | goto out; |
Fred Isaman | 7ffd106 | 2011-03-03 15:13:46 +0000 | [diff] [blame] | 6902 | if (res->fattr) |
Trond Myklebust | 6926afd | 2012-01-07 13:22:46 -0500 | [diff] [blame] | 6903 | decode_getfattr(xdr, res->fattr, res->server); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6904 | if (!status) |
| 6905 | status = res->count; |
| 6906 | out: |
| 6907 | return status; |
| 6908 | } |
| 6909 | |
| 6910 | /* |
| 6911 | * Decode COMMIT response |
| 6912 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6913 | 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] | 6914 | void *data) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6915 | { |
Christoph Hellwig | fc01648 | 2017-05-08 15:09:02 +0200 | [diff] [blame] | 6916 | struct nfs_commitres *res = data; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6917 | struct compound_hdr hdr; |
| 6918 | int status; |
| 6919 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6920 | status = decode_compound_hdr(xdr, &hdr); |
Peng Tao | aabff4d | 2014-08-27 10:47:14 +0800 | [diff] [blame] | 6921 | res->op_status = hdr.status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6922 | if (status) |
| 6923 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6924 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6925 | if (status) |
| 6926 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6927 | status = decode_putfh(xdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6928 | if (status) |
| 6929 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6930 | status = decode_commit(xdr, res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6931 | out: |
| 6932 | return status; |
| 6933 | } |
| 6934 | |
| 6935 | /* |
Ricardo Labiaga | 8b17321 | 2009-12-05 16:08:39 -0500 | [diff] [blame] | 6936 | * Decode FSINFO response |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6937 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6938 | 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] | 6939 | void *data) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6940 | { |
Christoph Hellwig | fc01648 | 2017-05-08 15:09:02 +0200 | [diff] [blame] | 6941 | struct nfs4_fsinfo_res *res = data; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6942 | struct compound_hdr hdr; |
| 6943 | int status; |
| 6944 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6945 | status = decode_compound_hdr(xdr, &hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6946 | if (!status) |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6947 | status = decode_sequence(xdr, &res->seq_res, req); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6948 | if (!status) |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6949 | status = decode_putfh(xdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6950 | if (!status) |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6951 | status = decode_fsinfo(xdr, res->fsinfo); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6952 | return status; |
| 6953 | } |
| 6954 | |
| 6955 | /* |
Ricardo Labiaga | 8b17321 | 2009-12-05 16:08:39 -0500 | [diff] [blame] | 6956 | * Decode PATHCONF response |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6957 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6958 | 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] | 6959 | void *data) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6960 | { |
Christoph Hellwig | fc01648 | 2017-05-08 15:09:02 +0200 | [diff] [blame] | 6961 | struct nfs4_pathconf_res *res = data; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6962 | struct compound_hdr hdr; |
| 6963 | int status; |
| 6964 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6965 | status = decode_compound_hdr(xdr, &hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6966 | if (!status) |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6967 | status = decode_sequence(xdr, &res->seq_res, req); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6968 | if (!status) |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6969 | status = decode_putfh(xdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6970 | if (!status) |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6971 | status = decode_pathconf(xdr, res->pathconf); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6972 | return status; |
| 6973 | } |
| 6974 | |
| 6975 | /* |
Ricardo Labiaga | 8b17321 | 2009-12-05 16:08:39 -0500 | [diff] [blame] | 6976 | * Decode STATFS response |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6977 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6978 | 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] | 6979 | void *data) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6980 | { |
Christoph Hellwig | fc01648 | 2017-05-08 15:09:02 +0200 | [diff] [blame] | 6981 | struct nfs4_statfs_res *res = data; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6982 | struct compound_hdr hdr; |
| 6983 | int status; |
| 6984 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6985 | status = decode_compound_hdr(xdr, &hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6986 | if (!status) |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6987 | status = decode_sequence(xdr, &res->seq_res, req); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6988 | if (!status) |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6989 | status = decode_putfh(xdr); |
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_statfs(xdr, res->fsstat); |
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 GETATTR_BITMAP 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_server_caps(struct rpc_rqst *req, |
| 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_server_caps_res *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, req); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 7010 | if (status) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7011 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 7012 | status = decode_putfh(xdr); |
| 7013 | if (status) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7014 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 7015 | status = decode_server_caps(xdr, res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7016 | out: |
| 7017 | return status; |
| 7018 | } |
| 7019 | |
| 7020 | /* |
| 7021 | * Decode RENEW response |
| 7022 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 7023 | static int nfs4_xdr_dec_renew(struct rpc_rqst *rqstp, struct xdr_stream *xdr, |
| 7024 | void *__unused) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7025 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7026 | struct compound_hdr hdr; |
| 7027 | int status; |
| 7028 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 7029 | status = decode_compound_hdr(xdr, &hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7030 | if (!status) |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 7031 | status = decode_renew(xdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7032 | return status; |
| 7033 | } |
| 7034 | |
| 7035 | /* |
Ricardo Labiaga | 8b17321 | 2009-12-05 16:08:39 -0500 | [diff] [blame] | 7036 | * Decode SETCLIENTID response |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7037 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 7038 | static int nfs4_xdr_dec_setclientid(struct rpc_rqst *req, |
| 7039 | struct xdr_stream *xdr, |
Christoph Hellwig | fc01648 | 2017-05-08 15:09:02 +0200 | [diff] [blame] | 7040 | void *data) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7041 | { |
Christoph Hellwig | fc01648 | 2017-05-08 15:09:02 +0200 | [diff] [blame] | 7042 | struct nfs4_setclientid_res *res = data; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7043 | struct compound_hdr hdr; |
| 7044 | int status; |
| 7045 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 7046 | status = decode_compound_hdr(xdr, &hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7047 | if (!status) |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 7048 | status = decode_setclientid(xdr, res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7049 | return status; |
| 7050 | } |
| 7051 | |
| 7052 | /* |
Ricardo Labiaga | 8b17321 | 2009-12-05 16:08:39 -0500 | [diff] [blame] | 7053 | * Decode SETCLIENTID_CONFIRM response |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7054 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 7055 | static int nfs4_xdr_dec_setclientid_confirm(struct rpc_rqst *req, |
Christoph Hellwig | fc01648 | 2017-05-08 15:09:02 +0200 | [diff] [blame] | 7056 | struct xdr_stream *xdr, |
| 7057 | void *data) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7058 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7059 | struct compound_hdr hdr; |
| 7060 | int status; |
| 7061 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 7062 | status = decode_compound_hdr(xdr, &hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7063 | if (!status) |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 7064 | status = decode_setclientid_confirm(xdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7065 | return status; |
| 7066 | } |
| 7067 | |
| 7068 | /* |
Ricardo Labiaga | 8b17321 | 2009-12-05 16:08:39 -0500 | [diff] [blame] | 7069 | * Decode DELEGRETURN response |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7070 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 7071 | static int nfs4_xdr_dec_delegreturn(struct rpc_rqst *rqstp, |
| 7072 | struct xdr_stream *xdr, |
Christoph Hellwig | fc01648 | 2017-05-08 15:09:02 +0200 | [diff] [blame] | 7073 | void *data) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7074 | { |
Christoph Hellwig | fc01648 | 2017-05-08 15:09:02 +0200 | [diff] [blame] | 7075 | struct nfs4_delegreturnres *res = data; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7076 | struct compound_hdr hdr; |
| 7077 | int status; |
| 7078 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 7079 | status = decode_compound_hdr(xdr, &hdr); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 7080 | if (status) |
| 7081 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 7082 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 7083 | if (status) |
Trond Myklebust | fa178f2 | 2006-01-03 09:55:38 +0100 | [diff] [blame] | 7084 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 7085 | status = decode_putfh(xdr); |
Trond Myklebust | fa178f2 | 2006-01-03 09:55:38 +0100 | [diff] [blame] | 7086 | if (status != 0) |
| 7087 | goto out; |
Trond Myklebust | 586f1c3 | 2016-11-15 15:03:33 -0500 | [diff] [blame] | 7088 | if (res->lr_res) { |
| 7089 | status = decode_layoutreturn(xdr, res->lr_res); |
| 7090 | res->lr_ret = status; |
| 7091 | if (status) |
| 7092 | goto out; |
| 7093 | } |
Trond Myklebust | 8ac2b422 | 2016-12-19 10:23:10 -0500 | [diff] [blame] | 7094 | if (res->fattr) { |
| 7095 | status = decode_getfattr(xdr, res->fattr, res->server); |
| 7096 | if (status != 0) |
| 7097 | goto out; |
| 7098 | } |
Trond Myklebust | e144cbc | 2012-04-28 16:05:03 -0400 | [diff] [blame] | 7099 | status = decode_delegreturn(xdr); |
Trond Myklebust | fa178f2 | 2006-01-03 09:55:38 +0100 | [diff] [blame] | 7100 | out: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7101 | return status; |
| 7102 | } |
| 7103 | |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 7104 | /* |
Ricardo Labiaga | 8b17321 | 2009-12-05 16:08:39 -0500 | [diff] [blame] | 7105 | * Decode FS_LOCATIONS response |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 7106 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 7107 | static int nfs4_xdr_dec_fs_locations(struct rpc_rqst *req, |
| 7108 | struct xdr_stream *xdr, |
Christoph Hellwig | fc01648 | 2017-05-08 15:09:02 +0200 | [diff] [blame] | 7109 | void *data) |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 7110 | { |
Christoph Hellwig | fc01648 | 2017-05-08 15:09:02 +0200 | [diff] [blame] | 7111 | struct nfs4_fs_locations_res *res = data; |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 7112 | struct compound_hdr hdr; |
| 7113 | int status; |
| 7114 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 7115 | status = decode_compound_hdr(xdr, &hdr); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 7116 | if (status) |
| 7117 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 7118 | status = decode_sequence(xdr, &res->seq_res, req); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 7119 | if (status) |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 7120 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 7121 | status = decode_putfh(xdr); |
| 7122 | if (status) |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 7123 | goto out; |
Chuck Lever | b03d735 | 2013-10-17 14:12:50 -0400 | [diff] [blame] | 7124 | if (res->migration) { |
| 7125 | xdr_enter_page(xdr, PAGE_SIZE); |
| 7126 | status = decode_getfattr_generic(xdr, |
| 7127 | &res->fs_locations->fattr, |
Trond Myklebust | 8b7e3f4 | 2012-01-30 15:43:56 -0500 | [diff] [blame] | 7128 | NULL, res->fs_locations, |
David Quigley | aa9c266 | 2013-05-22 12:50:44 -0400 | [diff] [blame] | 7129 | NULL, res->fs_locations->server); |
Chuck Lever | b03d735 | 2013-10-17 14:12:50 -0400 | [diff] [blame] | 7130 | if (status) |
| 7131 | goto out; |
| 7132 | if (res->renew) |
| 7133 | status = decode_renew(xdr); |
| 7134 | } else { |
| 7135 | status = decode_lookup(xdr); |
| 7136 | if (status) |
| 7137 | goto out; |
| 7138 | xdr_enter_page(xdr, PAGE_SIZE); |
| 7139 | status = decode_getfattr_generic(xdr, |
| 7140 | &res->fs_locations->fattr, |
| 7141 | NULL, res->fs_locations, |
| 7142 | NULL, res->fs_locations->server); |
| 7143 | } |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 7144 | out: |
| 7145 | return status; |
| 7146 | } |
| 7147 | |
Bryan Schumaker | 5a5ea0d | 2011-03-24 17:12:29 +0000 | [diff] [blame] | 7148 | /* |
| 7149 | * Decode SECINFO response |
| 7150 | */ |
| 7151 | static int nfs4_xdr_dec_secinfo(struct rpc_rqst *rqstp, |
| 7152 | struct xdr_stream *xdr, |
Christoph Hellwig | fc01648 | 2017-05-08 15:09:02 +0200 | [diff] [blame] | 7153 | void *data) |
Bryan Schumaker | 5a5ea0d | 2011-03-24 17:12:29 +0000 | [diff] [blame] | 7154 | { |
Christoph Hellwig | fc01648 | 2017-05-08 15:09:02 +0200 | [diff] [blame] | 7155 | struct nfs4_secinfo_res *res = data; |
Bryan Schumaker | 5a5ea0d | 2011-03-24 17:12:29 +0000 | [diff] [blame] | 7156 | struct compound_hdr hdr; |
| 7157 | int status; |
| 7158 | |
| 7159 | status = decode_compound_hdr(xdr, &hdr); |
| 7160 | if (status) |
| 7161 | goto out; |
| 7162 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
| 7163 | if (status) |
| 7164 | goto out; |
| 7165 | status = decode_putfh(xdr); |
| 7166 | if (status) |
| 7167 | goto out; |
| 7168 | status = decode_secinfo(xdr, res); |
Bryan Schumaker | 5a5ea0d | 2011-03-24 17:12:29 +0000 | [diff] [blame] | 7169 | out: |
| 7170 | return status; |
| 7171 | } |
| 7172 | |
Chuck Lever | 44c9993 | 2013-10-17 14:13:30 -0400 | [diff] [blame] | 7173 | /* |
| 7174 | * Decode FSID_PRESENT response |
| 7175 | */ |
| 7176 | static int nfs4_xdr_dec_fsid_present(struct rpc_rqst *rqstp, |
| 7177 | struct xdr_stream *xdr, |
Christoph Hellwig | fc01648 | 2017-05-08 15:09:02 +0200 | [diff] [blame] | 7178 | void *data) |
Chuck Lever | 44c9993 | 2013-10-17 14:13:30 -0400 | [diff] [blame] | 7179 | { |
Christoph Hellwig | fc01648 | 2017-05-08 15:09:02 +0200 | [diff] [blame] | 7180 | struct nfs4_fsid_present_res *res = data; |
Chuck Lever | 44c9993 | 2013-10-17 14:13:30 -0400 | [diff] [blame] | 7181 | struct compound_hdr hdr; |
| 7182 | int status; |
| 7183 | |
| 7184 | status = decode_compound_hdr(xdr, &hdr); |
| 7185 | if (status) |
| 7186 | goto out; |
| 7187 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
| 7188 | if (status) |
| 7189 | goto out; |
| 7190 | status = decode_putfh(xdr); |
| 7191 | if (status) |
| 7192 | goto out; |
| 7193 | status = decode_getfh(xdr, res->fh); |
| 7194 | if (status) |
| 7195 | goto out; |
| 7196 | if (res->renew) |
| 7197 | status = decode_renew(xdr); |
| 7198 | out: |
| 7199 | return status; |
| 7200 | } |
| 7201 | |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 7202 | #if defined(CONFIG_NFS_V4_1) |
| 7203 | /* |
Weston Andros Adamson | 7c44f1ae | 2012-05-24 13:22:50 -0400 | [diff] [blame] | 7204 | * Decode BIND_CONN_TO_SESSION response |
| 7205 | */ |
| 7206 | static int nfs4_xdr_dec_bind_conn_to_session(struct rpc_rqst *rqstp, |
| 7207 | struct xdr_stream *xdr, |
| 7208 | void *res) |
| 7209 | { |
| 7210 | struct compound_hdr hdr; |
| 7211 | int status; |
| 7212 | |
| 7213 | status = decode_compound_hdr(xdr, &hdr); |
| 7214 | if (!status) |
| 7215 | status = decode_bind_conn_to_session(xdr, res); |
| 7216 | return status; |
| 7217 | } |
| 7218 | |
| 7219 | /* |
Ricardo Labiaga | 8b17321 | 2009-12-05 16:08:39 -0500 | [diff] [blame] | 7220 | * Decode EXCHANGE_ID response |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 7221 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 7222 | static int nfs4_xdr_dec_exchange_id(struct rpc_rqst *rqstp, |
| 7223 | struct xdr_stream *xdr, |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 7224 | void *res) |
| 7225 | { |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 7226 | struct compound_hdr hdr; |
| 7227 | int status; |
| 7228 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 7229 | status = decode_compound_hdr(xdr, &hdr); |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 7230 | if (!status) |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 7231 | status = decode_exchange_id(xdr, res); |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 7232 | return status; |
| 7233 | } |
Andy Adamson | 2050f0c | 2009-04-01 09:22:30 -0400 | [diff] [blame] | 7234 | |
| 7235 | /* |
Ricardo Labiaga | 8b17321 | 2009-12-05 16:08:39 -0500 | [diff] [blame] | 7236 | * Decode CREATE_SESSION response |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 7237 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 7238 | static int nfs4_xdr_dec_create_session(struct rpc_rqst *rqstp, |
| 7239 | struct xdr_stream *xdr, |
Christoph Hellwig | fc01648 | 2017-05-08 15:09:02 +0200 | [diff] [blame] | 7240 | void *res) |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 7241 | { |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 7242 | struct compound_hdr hdr; |
| 7243 | int status; |
| 7244 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 7245 | status = decode_compound_hdr(xdr, &hdr); |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 7246 | if (!status) |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 7247 | status = decode_create_session(xdr, res); |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 7248 | return status; |
| 7249 | } |
| 7250 | |
| 7251 | /* |
Ricardo Labiaga | 8b17321 | 2009-12-05 16:08:39 -0500 | [diff] [blame] | 7252 | * Decode DESTROY_SESSION response |
Andy Adamson | 0f3e66c | 2009-04-01 09:22:34 -0400 | [diff] [blame] | 7253 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 7254 | static int nfs4_xdr_dec_destroy_session(struct rpc_rqst *rqstp, |
| 7255 | struct xdr_stream *xdr, |
| 7256 | void *res) |
Andy Adamson | 0f3e66c | 2009-04-01 09:22:34 -0400 | [diff] [blame] | 7257 | { |
Andy Adamson | 0f3e66c | 2009-04-01 09:22:34 -0400 | [diff] [blame] | 7258 | struct compound_hdr hdr; |
| 7259 | int status; |
| 7260 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 7261 | status = decode_compound_hdr(xdr, &hdr); |
Andy Adamson | 0f3e66c | 2009-04-01 09:22:34 -0400 | [diff] [blame] | 7262 | if (!status) |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 7263 | status = decode_destroy_session(xdr, res); |
Andy Adamson | 0f3e66c | 2009-04-01 09:22:34 -0400 | [diff] [blame] | 7264 | return status; |
| 7265 | } |
| 7266 | |
| 7267 | /* |
Trond Myklebust | 6624553 | 2012-05-25 17:18:09 -0400 | [diff] [blame] | 7268 | * Decode DESTROY_CLIENTID response |
| 7269 | */ |
| 7270 | static int nfs4_xdr_dec_destroy_clientid(struct rpc_rqst *rqstp, |
| 7271 | struct xdr_stream *xdr, |
| 7272 | void *res) |
| 7273 | { |
| 7274 | struct compound_hdr hdr; |
| 7275 | int status; |
| 7276 | |
| 7277 | status = decode_compound_hdr(xdr, &hdr); |
| 7278 | if (!status) |
| 7279 | status = decode_destroy_clientid(xdr, res); |
| 7280 | return status; |
| 7281 | } |
| 7282 | |
| 7283 | /* |
Ricardo Labiaga | 8b17321 | 2009-12-05 16:08:39 -0500 | [diff] [blame] | 7284 | * Decode SEQUENCE response |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 7285 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 7286 | static int nfs4_xdr_dec_sequence(struct rpc_rqst *rqstp, |
| 7287 | struct xdr_stream *xdr, |
Christoph Hellwig | fc01648 | 2017-05-08 15:09:02 +0200 | [diff] [blame] | 7288 | void *res) |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 7289 | { |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 7290 | struct compound_hdr hdr; |
| 7291 | int status; |
| 7292 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 7293 | status = decode_compound_hdr(xdr, &hdr); |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 7294 | if (!status) |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 7295 | status = decode_sequence(xdr, res, rqstp); |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 7296 | return status; |
| 7297 | } |
| 7298 | |
| 7299 | /* |
Ricardo Labiaga | 8b17321 | 2009-12-05 16:08:39 -0500 | [diff] [blame] | 7300 | * Decode GET_LEASE_TIME response |
Andy Adamson | 2050f0c | 2009-04-01 09:22:30 -0400 | [diff] [blame] | 7301 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 7302 | static int nfs4_xdr_dec_get_lease_time(struct rpc_rqst *rqstp, |
| 7303 | struct xdr_stream *xdr, |
Christoph Hellwig | fc01648 | 2017-05-08 15:09:02 +0200 | [diff] [blame] | 7304 | void *data) |
Andy Adamson | 2050f0c | 2009-04-01 09:22:30 -0400 | [diff] [blame] | 7305 | { |
Christoph Hellwig | fc01648 | 2017-05-08 15:09:02 +0200 | [diff] [blame] | 7306 | struct nfs4_get_lease_time_res *res = data; |
Andy Adamson | 2050f0c | 2009-04-01 09:22:30 -0400 | [diff] [blame] | 7307 | struct compound_hdr hdr; |
| 7308 | int status; |
| 7309 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 7310 | status = decode_compound_hdr(xdr, &hdr); |
Andy Adamson | 2050f0c | 2009-04-01 09:22:30 -0400 | [diff] [blame] | 7311 | if (!status) |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 7312 | status = decode_sequence(xdr, &res->lr_seq_res, rqstp); |
Andy Adamson | 2050f0c | 2009-04-01 09:22:30 -0400 | [diff] [blame] | 7313 | if (!status) |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 7314 | status = decode_putrootfh(xdr); |
Andy Adamson | 2050f0c | 2009-04-01 09:22:30 -0400 | [diff] [blame] | 7315 | if (!status) |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 7316 | status = decode_fsinfo(xdr, res->lr_fsinfo); |
Andy Adamson | 2050f0c | 2009-04-01 09:22:30 -0400 | [diff] [blame] | 7317 | return status; |
| 7318 | } |
Ricardo Labiaga | 18019753 | 2009-12-05 16:08:40 -0500 | [diff] [blame] | 7319 | |
| 7320 | /* |
| 7321 | * Decode RECLAIM_COMPLETE response |
| 7322 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 7323 | static int nfs4_xdr_dec_reclaim_complete(struct rpc_rqst *rqstp, |
| 7324 | struct xdr_stream *xdr, |
Christoph Hellwig | fc01648 | 2017-05-08 15:09:02 +0200 | [diff] [blame] | 7325 | void *data) |
Ricardo Labiaga | 18019753 | 2009-12-05 16:08:40 -0500 | [diff] [blame] | 7326 | { |
Christoph Hellwig | fc01648 | 2017-05-08 15:09:02 +0200 | [diff] [blame] | 7327 | struct nfs41_reclaim_complete_res *res = data; |
Ricardo Labiaga | 18019753 | 2009-12-05 16:08:40 -0500 | [diff] [blame] | 7328 | struct compound_hdr hdr; |
| 7329 | int status; |
| 7330 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 7331 | status = decode_compound_hdr(xdr, &hdr); |
Ricardo Labiaga | 18019753 | 2009-12-05 16:08:40 -0500 | [diff] [blame] | 7332 | if (!status) |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 7333 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
Ricardo Labiaga | 18019753 | 2009-12-05 16:08:40 -0500 | [diff] [blame] | 7334 | if (!status) |
Himangi Saraogi | 8ee2b78 | 2014-06-27 00:09:09 +0530 | [diff] [blame] | 7335 | status = decode_reclaim_complete(xdr, NULL); |
Ricardo Labiaga | 18019753 | 2009-12-05 16:08:40 -0500 | [diff] [blame] | 7336 | return status; |
| 7337 | } |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 7338 | |
| 7339 | /* |
| 7340 | * Decode GETDEVINFO response |
| 7341 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 7342 | static int nfs4_xdr_dec_getdeviceinfo(struct rpc_rqst *rqstp, |
| 7343 | struct xdr_stream *xdr, |
Christoph Hellwig | fc01648 | 2017-05-08 15:09:02 +0200 | [diff] [blame] | 7344 | void *data) |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 7345 | { |
Christoph Hellwig | fc01648 | 2017-05-08 15:09:02 +0200 | [diff] [blame] | 7346 | struct nfs4_getdeviceinfo_res *res = data; |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 7347 | struct compound_hdr hdr; |
| 7348 | int status; |
| 7349 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 7350 | status = decode_compound_hdr(xdr, &hdr); |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 7351 | if (status != 0) |
| 7352 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 7353 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 7354 | if (status != 0) |
| 7355 | goto out; |
Trond Myklebust | 4e59080 | 2015-03-09 14:01:25 -0400 | [diff] [blame] | 7356 | status = decode_getdeviceinfo(xdr, res); |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 7357 | out: |
| 7358 | return status; |
| 7359 | } |
| 7360 | |
| 7361 | /* |
| 7362 | * Decode LAYOUTGET response |
| 7363 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 7364 | static int nfs4_xdr_dec_layoutget(struct rpc_rqst *rqstp, |
| 7365 | struct xdr_stream *xdr, |
Christoph Hellwig | fc01648 | 2017-05-08 15:09:02 +0200 | [diff] [blame] | 7366 | void *data) |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 7367 | { |
Christoph Hellwig | fc01648 | 2017-05-08 15:09:02 +0200 | [diff] [blame] | 7368 | struct nfs4_layoutget_res *res = data; |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 7369 | struct compound_hdr hdr; |
| 7370 | int status; |
| 7371 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 7372 | status = decode_compound_hdr(xdr, &hdr); |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 7373 | if (status) |
| 7374 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 7375 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 7376 | if (status) |
| 7377 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 7378 | status = decode_putfh(xdr); |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 7379 | if (status) |
| 7380 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 7381 | status = decode_layoutget(xdr, rqstp, res); |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 7382 | out: |
| 7383 | return status; |
| 7384 | } |
Andy Adamson | 863a3c6 | 2011-03-23 13:27:54 +0000 | [diff] [blame] | 7385 | |
| 7386 | /* |
Benny Halevy | cbe8260 | 2011-05-22 19:52:37 +0300 | [diff] [blame] | 7387 | * Decode LAYOUTRETURN response |
| 7388 | */ |
| 7389 | static int nfs4_xdr_dec_layoutreturn(struct rpc_rqst *rqstp, |
| 7390 | struct xdr_stream *xdr, |
Christoph Hellwig | fc01648 | 2017-05-08 15:09:02 +0200 | [diff] [blame] | 7391 | void *data) |
Benny Halevy | cbe8260 | 2011-05-22 19:52:37 +0300 | [diff] [blame] | 7392 | { |
Christoph Hellwig | fc01648 | 2017-05-08 15:09:02 +0200 | [diff] [blame] | 7393 | struct nfs4_layoutreturn_res *res = data; |
Benny Halevy | cbe8260 | 2011-05-22 19:52:37 +0300 | [diff] [blame] | 7394 | struct compound_hdr hdr; |
| 7395 | int status; |
| 7396 | |
| 7397 | status = decode_compound_hdr(xdr, &hdr); |
| 7398 | if (status) |
| 7399 | goto out; |
| 7400 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
| 7401 | if (status) |
| 7402 | goto out; |
| 7403 | status = decode_putfh(xdr); |
| 7404 | if (status) |
| 7405 | goto out; |
| 7406 | status = decode_layoutreturn(xdr, res); |
| 7407 | out: |
| 7408 | return status; |
| 7409 | } |
| 7410 | |
| 7411 | /* |
Andy Adamson | 863a3c6 | 2011-03-23 13:27:54 +0000 | [diff] [blame] | 7412 | * Decode LAYOUTCOMMIT response |
| 7413 | */ |
| 7414 | static int nfs4_xdr_dec_layoutcommit(struct rpc_rqst *rqstp, |
| 7415 | struct xdr_stream *xdr, |
Christoph Hellwig | fc01648 | 2017-05-08 15:09:02 +0200 | [diff] [blame] | 7416 | void *data) |
Andy Adamson | 863a3c6 | 2011-03-23 13:27:54 +0000 | [diff] [blame] | 7417 | { |
Christoph Hellwig | fc01648 | 2017-05-08 15:09:02 +0200 | [diff] [blame] | 7418 | struct nfs4_layoutcommit_res *res = data; |
Andy Adamson | 863a3c6 | 2011-03-23 13:27:54 +0000 | [diff] [blame] | 7419 | struct compound_hdr hdr; |
| 7420 | int status; |
| 7421 | |
| 7422 | status = decode_compound_hdr(xdr, &hdr); |
| 7423 | if (status) |
| 7424 | goto out; |
| 7425 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
| 7426 | if (status) |
| 7427 | goto out; |
| 7428 | status = decode_putfh(xdr); |
| 7429 | if (status) |
| 7430 | goto out; |
| 7431 | status = decode_layoutcommit(xdr, rqstp, res); |
| 7432 | if (status) |
| 7433 | goto out; |
Trond Myklebust | 6926afd | 2012-01-07 13:22:46 -0500 | [diff] [blame] | 7434 | decode_getfattr(xdr, res->fattr, res->server); |
Andy Adamson | 863a3c6 | 2011-03-23 13:27:54 +0000 | [diff] [blame] | 7435 | out: |
| 7436 | return status; |
| 7437 | } |
Bryan Schumaker | fca78d6 | 2011-06-02 14:59:07 -0400 | [diff] [blame] | 7438 | |
| 7439 | /* |
| 7440 | * Decode SECINFO_NO_NAME response |
| 7441 | */ |
| 7442 | static int nfs4_xdr_dec_secinfo_no_name(struct rpc_rqst *rqstp, |
| 7443 | struct xdr_stream *xdr, |
Christoph Hellwig | fc01648 | 2017-05-08 15:09:02 +0200 | [diff] [blame] | 7444 | void *data) |
Bryan Schumaker | fca78d6 | 2011-06-02 14:59:07 -0400 | [diff] [blame] | 7445 | { |
Christoph Hellwig | fc01648 | 2017-05-08 15:09:02 +0200 | [diff] [blame] | 7446 | struct nfs4_secinfo_res *res = data; |
Bryan Schumaker | fca78d6 | 2011-06-02 14:59:07 -0400 | [diff] [blame] | 7447 | struct compound_hdr hdr; |
| 7448 | int status; |
| 7449 | |
| 7450 | status = decode_compound_hdr(xdr, &hdr); |
| 7451 | if (status) |
| 7452 | goto out; |
| 7453 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
| 7454 | if (status) |
| 7455 | goto out; |
| 7456 | status = decode_putrootfh(xdr); |
| 7457 | if (status) |
| 7458 | goto out; |
Bryan Schumaker | 31e4dda | 2012-04-27 13:27:38 -0400 | [diff] [blame] | 7459 | status = decode_secinfo_no_name(xdr, res); |
Bryan Schumaker | fca78d6 | 2011-06-02 14:59:07 -0400 | [diff] [blame] | 7460 | out: |
| 7461 | return status; |
| 7462 | } |
Bryan Schumaker | 7d97479 | 2011-06-02 14:59:08 -0400 | [diff] [blame] | 7463 | |
| 7464 | /* |
| 7465 | * Decode TEST_STATEID response |
| 7466 | */ |
| 7467 | static int nfs4_xdr_dec_test_stateid(struct rpc_rqst *rqstp, |
| 7468 | struct xdr_stream *xdr, |
Christoph Hellwig | fc01648 | 2017-05-08 15:09:02 +0200 | [diff] [blame] | 7469 | void *data) |
Bryan Schumaker | 7d97479 | 2011-06-02 14:59:08 -0400 | [diff] [blame] | 7470 | { |
Christoph Hellwig | fc01648 | 2017-05-08 15:09:02 +0200 | [diff] [blame] | 7471 | struct nfs41_test_stateid_res *res = data; |
Bryan Schumaker | 7d97479 | 2011-06-02 14:59:08 -0400 | [diff] [blame] | 7472 | struct compound_hdr hdr; |
| 7473 | int status; |
| 7474 | |
| 7475 | status = decode_compound_hdr(xdr, &hdr); |
| 7476 | if (status) |
| 7477 | goto out; |
| 7478 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
| 7479 | if (status) |
| 7480 | goto out; |
| 7481 | status = decode_test_stateid(xdr, res); |
| 7482 | out: |
| 7483 | return status; |
| 7484 | } |
Bryan Schumaker | 9aeda35 | 2011-06-02 14:59:09 -0400 | [diff] [blame] | 7485 | |
| 7486 | /* |
| 7487 | * Decode FREE_STATEID response |
| 7488 | */ |
| 7489 | static int nfs4_xdr_dec_free_stateid(struct rpc_rqst *rqstp, |
| 7490 | struct xdr_stream *xdr, |
Christoph Hellwig | fc01648 | 2017-05-08 15:09:02 +0200 | [diff] [blame] | 7491 | void *data) |
Bryan Schumaker | 9aeda35 | 2011-06-02 14:59:09 -0400 | [diff] [blame] | 7492 | { |
Christoph Hellwig | fc01648 | 2017-05-08 15:09:02 +0200 | [diff] [blame] | 7493 | struct nfs41_free_stateid_res *res = data; |
Bryan Schumaker | 9aeda35 | 2011-06-02 14:59:09 -0400 | [diff] [blame] | 7494 | struct compound_hdr hdr; |
| 7495 | int status; |
| 7496 | |
| 7497 | status = decode_compound_hdr(xdr, &hdr); |
| 7498 | if (status) |
| 7499 | goto out; |
| 7500 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
| 7501 | if (status) |
| 7502 | goto out; |
| 7503 | status = decode_free_stateid(xdr, res); |
| 7504 | out: |
| 7505 | return status; |
| 7506 | } |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 7507 | #endif /* CONFIG_NFS_V4_1 */ |
| 7508 | |
Chuck Lever | 573c4e1 | 2010-12-14 14:58:11 +0000 | [diff] [blame] | 7509 | /** |
| 7510 | * nfs4_decode_dirent - Decode a single NFSv4 directory entry stored in |
| 7511 | * the local page cache. |
| 7512 | * @xdr: XDR stream where entry resides |
| 7513 | * @entry: buffer to fill in with entry data |
| 7514 | * @plus: boolean indicating whether this should be a readdirplus entry |
| 7515 | * |
| 7516 | * Returns zero if successful, otherwise a negative errno value is |
| 7517 | * returned. |
| 7518 | * |
| 7519 | * This function is not invoked during READDIR reply decoding, but |
| 7520 | * rather whenever an application invokes the getdents(2) system call |
| 7521 | * on a directory already in our cache. |
| 7522 | */ |
| 7523 | int nfs4_decode_dirent(struct xdr_stream *xdr, struct nfs_entry *entry, |
Benjamin Coddington | a7a3b1e | 2017-06-20 08:33:44 -0400 | [diff] [blame] | 7524 | bool plus) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7525 | { |
Trond Myklebust | 256e48b | 2012-06-21 11:18:13 -0400 | [diff] [blame] | 7526 | unsigned int savep; |
Fred Isaman | dae100c | 2011-07-30 20:52:37 -0400 | [diff] [blame] | 7527 | uint32_t bitmap[3] = {0}; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7528 | uint32_t len; |
Bryan Schumaker | babddc7 | 2010-10-20 15:44:29 -0400 | [diff] [blame] | 7529 | __be32 *p = xdr_inline_decode(xdr, 4); |
| 7530 | if (unlikely(!p)) |
| 7531 | goto out_overflow; |
Chuck Lever | c08e76d | 2011-01-28 12:40:55 -0500 | [diff] [blame] | 7532 | if (*p == xdr_zero) { |
Bryan Schumaker | babddc7 | 2010-10-20 15:44:29 -0400 | [diff] [blame] | 7533 | p = xdr_inline_decode(xdr, 4); |
| 7534 | if (unlikely(!p)) |
| 7535 | goto out_overflow; |
Chuck Lever | c08e76d | 2011-01-28 12:40:55 -0500 | [diff] [blame] | 7536 | if (*p == xdr_zero) |
Chuck Lever | 573c4e1 | 2010-12-14 14:58:11 +0000 | [diff] [blame] | 7537 | return -EAGAIN; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7538 | entry->eof = 1; |
Chuck Lever | 573c4e1 | 2010-12-14 14:58:11 +0000 | [diff] [blame] | 7539 | return -EBADCOOKIE; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7540 | } |
| 7541 | |
Bryan Schumaker | babddc7 | 2010-10-20 15:44:29 -0400 | [diff] [blame] | 7542 | p = xdr_inline_decode(xdr, 12); |
| 7543 | if (unlikely(!p)) |
| 7544 | goto out_overflow; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7545 | entry->prev_cookie = entry->cookie; |
| 7546 | p = xdr_decode_hyper(p, &entry->cookie); |
Chuck Lever | c08e76d | 2011-01-28 12:40:55 -0500 | [diff] [blame] | 7547 | entry->len = be32_to_cpup(p); |
Bryan Schumaker | babddc7 | 2010-10-20 15:44:29 -0400 | [diff] [blame] | 7548 | |
Trond Myklebust | 9af8c22 | 2010-10-24 11:52:55 -0400 | [diff] [blame] | 7549 | p = xdr_inline_decode(xdr, entry->len); |
Bryan Schumaker | babddc7 | 2010-10-20 15:44:29 -0400 | [diff] [blame] | 7550 | if (unlikely(!p)) |
| 7551 | goto out_overflow; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7552 | entry->name = (const char *) p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7553 | |
| 7554 | /* |
| 7555 | * In case the server doesn't return an inode number, |
| 7556 | * we fake one here. (We don't use inode number 0, |
| 7557 | * since glibc seems to choke on it...) |
| 7558 | */ |
| 7559 | entry->ino = 1; |
Trond Myklebust | 4f08222 | 2010-10-24 13:14:02 -0400 | [diff] [blame] | 7560 | entry->fattr->valid = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7561 | |
Trond Myklebust | 9af8c22 | 2010-10-24 11:52:55 -0400 | [diff] [blame] | 7562 | if (decode_attr_bitmap(xdr, bitmap) < 0) |
Bryan Schumaker | babddc7 | 2010-10-20 15:44:29 -0400 | [diff] [blame] | 7563 | goto out_overflow; |
Trond Myklebust | 9af8c22 | 2010-10-24 11:52:55 -0400 | [diff] [blame] | 7564 | |
Trond Myklebust | 256e48b | 2012-06-21 11:18:13 -0400 | [diff] [blame] | 7565 | if (decode_attr_length(xdr, &len, &savep) < 0) |
Trond Myklebust | 9af8c22 | 2010-10-24 11:52:55 -0400 | [diff] [blame] | 7566 | goto out_overflow; |
| 7567 | |
Chuck Lever | 573c4e1 | 2010-12-14 14:58:11 +0000 | [diff] [blame] | 7568 | if (decode_getfattr_attrs(xdr, bitmap, entry->fattr, entry->fh, |
David Quigley | aa9c266 | 2013-05-22 12:50:44 -0400 | [diff] [blame] | 7569 | NULL, entry->label, entry->server) < 0) |
Trond Myklebust | 9af8c22 | 2010-10-24 11:52:55 -0400 | [diff] [blame] | 7570 | goto out_overflow; |
Trond Myklebust | 28331a4 | 2011-04-27 13:47:52 -0400 | [diff] [blame] | 7571 | if (entry->fattr->valid & NFS_ATTR_FATTR_MOUNTED_ON_FILEID) |
| 7572 | entry->ino = entry->fattr->mounted_on_fileid; |
| 7573 | else if (entry->fattr->valid & NFS_ATTR_FATTR_FILEID) |
Trond Myklebust | 9af8c22 | 2010-10-24 11:52:55 -0400 | [diff] [blame] | 7574 | entry->ino = entry->fattr->fileid; |
| 7575 | |
Trond Myklebust | 0b26a0b | 2010-11-20 14:26:44 -0500 | [diff] [blame] | 7576 | entry->d_type = DT_UNKNOWN; |
| 7577 | if (entry->fattr->valid & NFS_ATTR_FATTR_TYPE) |
| 7578 | entry->d_type = nfs_umode_to_dtype(entry->fattr->mode); |
| 7579 | |
Chuck Lever | 573c4e1 | 2010-12-14 14:58:11 +0000 | [diff] [blame] | 7580 | return 0; |
Bryan Schumaker | babddc7 | 2010-10-20 15:44:29 -0400 | [diff] [blame] | 7581 | |
| 7582 | out_overflow: |
| 7583 | print_overflow_msg(__func__, xdr); |
Chuck Lever | 573c4e1 | 2010-12-14 14:58:11 +0000 | [diff] [blame] | 7584 | return -EAGAIN; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7585 | } |
| 7586 | |
| 7587 | /* |
| 7588 | * We need to translate between nfs status return values and |
| 7589 | * the local errno values which may not be the same. |
| 7590 | */ |
| 7591 | static struct { |
| 7592 | int stat; |
| 7593 | int errno; |
| 7594 | } nfs_errtbl[] = { |
| 7595 | { NFS4_OK, 0 }, |
Benny Halevy | 856dff3 | 2008-03-31 17:39:06 +0300 | [diff] [blame] | 7596 | { NFS4ERR_PERM, -EPERM }, |
| 7597 | { NFS4ERR_NOENT, -ENOENT }, |
| 7598 | { NFS4ERR_IO, -errno_NFSERR_IO}, |
| 7599 | { NFS4ERR_NXIO, -ENXIO }, |
| 7600 | { NFS4ERR_ACCESS, -EACCES }, |
| 7601 | { NFS4ERR_EXIST, -EEXIST }, |
| 7602 | { NFS4ERR_XDEV, -EXDEV }, |
| 7603 | { NFS4ERR_NOTDIR, -ENOTDIR }, |
| 7604 | { NFS4ERR_ISDIR, -EISDIR }, |
| 7605 | { NFS4ERR_INVAL, -EINVAL }, |
| 7606 | { NFS4ERR_FBIG, -EFBIG }, |
| 7607 | { NFS4ERR_NOSPC, -ENOSPC }, |
| 7608 | { NFS4ERR_ROFS, -EROFS }, |
| 7609 | { NFS4ERR_MLINK, -EMLINK }, |
| 7610 | { NFS4ERR_NAMETOOLONG, -ENAMETOOLONG }, |
| 7611 | { NFS4ERR_NOTEMPTY, -ENOTEMPTY }, |
| 7612 | { NFS4ERR_DQUOT, -EDQUOT }, |
| 7613 | { NFS4ERR_STALE, -ESTALE }, |
| 7614 | { NFS4ERR_BADHANDLE, -EBADHANDLE }, |
Benny Halevy | 856dff3 | 2008-03-31 17:39:06 +0300 | [diff] [blame] | 7615 | { NFS4ERR_BAD_COOKIE, -EBADCOOKIE }, |
| 7616 | { NFS4ERR_NOTSUPP, -ENOTSUPP }, |
| 7617 | { NFS4ERR_TOOSMALL, -ETOOSMALL }, |
Trond Myklebust | fdcb457 | 2010-02-08 09:32:40 -0500 | [diff] [blame] | 7618 | { NFS4ERR_SERVERFAULT, -EREMOTEIO }, |
Benny Halevy | 856dff3 | 2008-03-31 17:39:06 +0300 | [diff] [blame] | 7619 | { NFS4ERR_BADTYPE, -EBADTYPE }, |
| 7620 | { NFS4ERR_LOCKED, -EAGAIN }, |
Benny Halevy | 856dff3 | 2008-03-31 17:39:06 +0300 | [diff] [blame] | 7621 | { NFS4ERR_SYMLINK, -ELOOP }, |
| 7622 | { NFS4ERR_OP_ILLEGAL, -EOPNOTSUPP }, |
| 7623 | { NFS4ERR_DEADLOCK, -EDEADLK }, |
Benny Halevy | 856dff3 | 2008-03-31 17:39:06 +0300 | [diff] [blame] | 7624 | { -1, -EIO } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7625 | }; |
| 7626 | |
| 7627 | /* |
| 7628 | * Convert an NFS error code to a local one. |
| 7629 | * This one is used jointly by NFSv2 and NFSv3. |
| 7630 | */ |
| 7631 | static int |
David Howells | 0a8ea43 | 2006-08-22 20:06:08 -0400 | [diff] [blame] | 7632 | nfs4_stat_to_errno(int stat) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7633 | { |
| 7634 | int i; |
| 7635 | for (i = 0; nfs_errtbl[i].stat != -1; i++) { |
| 7636 | if (nfs_errtbl[i].stat == stat) |
| 7637 | return nfs_errtbl[i].errno; |
| 7638 | } |
| 7639 | if (stat <= 10000 || stat > 10100) { |
| 7640 | /* The server is looney tunes. */ |
Trond Myklebust | fdcb457 | 2010-02-08 09:32:40 -0500 | [diff] [blame] | 7641 | return -EREMOTEIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7642 | } |
| 7643 | /* If we cannot translate the error, the recovery routines should |
| 7644 | * handle it. |
| 7645 | * Note: remaining NFSv4 error codes have values > 10000, so should |
| 7646 | * not conflict with native Linux error codes. |
| 7647 | */ |
Benny Halevy | 856dff3 | 2008-03-31 17:39:06 +0300 | [diff] [blame] | 7648 | return -stat; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7649 | } |
| 7650 | |
Anna Schumaker | 1c6dcbe | 2014-09-26 13:58:48 -0400 | [diff] [blame] | 7651 | #ifdef CONFIG_NFS_V4_2 |
| 7652 | #include "nfs42xdr.c" |
| 7653 | #endif /* CONFIG_NFS_V4_2 */ |
| 7654 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7655 | #define PROC(proc, argtype, restype) \ |
| 7656 | [NFSPROC4_CLNT_##proc] = { \ |
| 7657 | .p_proc = NFSPROC4_COMPOUND, \ |
Christoph Hellwig | fcc8581 | 2017-05-08 10:01:49 +0200 | [diff] [blame] | 7658 | .p_encode = nfs4_xdr_##argtype, \ |
Christoph Hellwig | fc01648 | 2017-05-08 15:09:02 +0200 | [diff] [blame] | 7659 | .p_decode = nfs4_xdr_##restype, \ |
Chuck Lever | 2bea90d | 2007-03-29 16:47:53 -0400 | [diff] [blame] | 7660 | .p_arglen = NFS4_##argtype##_sz, \ |
| 7661 | .p_replen = NFS4_##restype##_sz, \ |
Chuck Lever | cc0175c | 2006-03-20 13:44:22 -0500 | [diff] [blame] | 7662 | .p_statidx = NFSPROC4_CLNT_##proc, \ |
| 7663 | .p_name = #proc, \ |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 7664 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7665 | |
Anna Schumaker | 7c61f0d | 2015-04-14 10:34:20 -0400 | [diff] [blame] | 7666 | #define STUB(proc) \ |
| 7667 | [NFSPROC4_CLNT_##proc] = { \ |
| 7668 | .p_name = #proc, \ |
| 7669 | } |
| 7670 | |
Christoph Hellwig | 511e936 | 2017-05-12 15:36:49 +0200 | [diff] [blame] | 7671 | const struct rpc_procinfo nfs4_procedures[] = { |
Chuck Lever | 7d93bd71 | 2010-12-14 14:57:42 +0000 | [diff] [blame] | 7672 | PROC(READ, enc_read, dec_read), |
| 7673 | PROC(WRITE, enc_write, dec_write), |
| 7674 | PROC(COMMIT, enc_commit, dec_commit), |
| 7675 | PROC(OPEN, enc_open, dec_open), |
| 7676 | PROC(OPEN_CONFIRM, enc_open_confirm, dec_open_confirm), |
| 7677 | PROC(OPEN_NOATTR, enc_open_noattr, dec_open_noattr), |
| 7678 | PROC(OPEN_DOWNGRADE, enc_open_downgrade, dec_open_downgrade), |
| 7679 | PROC(CLOSE, enc_close, dec_close), |
| 7680 | PROC(SETATTR, enc_setattr, dec_setattr), |
| 7681 | PROC(FSINFO, enc_fsinfo, dec_fsinfo), |
| 7682 | PROC(RENEW, enc_renew, dec_renew), |
| 7683 | PROC(SETCLIENTID, enc_setclientid, dec_setclientid), |
| 7684 | PROC(SETCLIENTID_CONFIRM, enc_setclientid_confirm, dec_setclientid_confirm), |
| 7685 | PROC(LOCK, enc_lock, dec_lock), |
| 7686 | PROC(LOCKT, enc_lockt, dec_lockt), |
| 7687 | PROC(LOCKU, enc_locku, dec_locku), |
| 7688 | PROC(ACCESS, enc_access, dec_access), |
| 7689 | PROC(GETATTR, enc_getattr, dec_getattr), |
| 7690 | PROC(LOOKUP, enc_lookup, dec_lookup), |
Jeff Layton | 5b5faaf | 2017-06-29 06:34:52 -0700 | [diff] [blame] | 7691 | PROC(LOOKUPP, enc_lookupp, dec_lookupp), |
Chuck Lever | 7d93bd71 | 2010-12-14 14:57:42 +0000 | [diff] [blame] | 7692 | PROC(LOOKUP_ROOT, enc_lookup_root, dec_lookup_root), |
| 7693 | PROC(REMOVE, enc_remove, dec_remove), |
| 7694 | PROC(RENAME, enc_rename, dec_rename), |
| 7695 | PROC(LINK, enc_link, dec_link), |
| 7696 | PROC(SYMLINK, enc_symlink, dec_symlink), |
| 7697 | PROC(CREATE, enc_create, dec_create), |
| 7698 | PROC(PATHCONF, enc_pathconf, dec_pathconf), |
| 7699 | PROC(STATFS, enc_statfs, dec_statfs), |
| 7700 | PROC(READLINK, enc_readlink, dec_readlink), |
| 7701 | PROC(READDIR, enc_readdir, dec_readdir), |
| 7702 | PROC(SERVER_CAPS, enc_server_caps, dec_server_caps), |
| 7703 | PROC(DELEGRETURN, enc_delegreturn, dec_delegreturn), |
| 7704 | PROC(GETACL, enc_getacl, dec_getacl), |
| 7705 | PROC(SETACL, enc_setacl, dec_setacl), |
| 7706 | PROC(FS_LOCATIONS, enc_fs_locations, dec_fs_locations), |
| 7707 | PROC(RELEASE_LOCKOWNER, enc_release_lockowner, dec_release_lockowner), |
Bryan Schumaker | 5a5ea0d | 2011-03-24 17:12:29 +0000 | [diff] [blame] | 7708 | PROC(SECINFO, enc_secinfo, dec_secinfo), |
Chuck Lever | 44c9993 | 2013-10-17 14:13:30 -0400 | [diff] [blame] | 7709 | PROC(FSID_PRESENT, enc_fsid_present, dec_fsid_present), |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 7710 | #if defined(CONFIG_NFS_V4_1) |
Chuck Lever | 7d93bd71 | 2010-12-14 14:57:42 +0000 | [diff] [blame] | 7711 | PROC(EXCHANGE_ID, enc_exchange_id, dec_exchange_id), |
| 7712 | PROC(CREATE_SESSION, enc_create_session, dec_create_session), |
| 7713 | PROC(DESTROY_SESSION, enc_destroy_session, dec_destroy_session), |
| 7714 | PROC(SEQUENCE, enc_sequence, dec_sequence), |
| 7715 | PROC(GET_LEASE_TIME, enc_get_lease_time, dec_get_lease_time), |
| 7716 | PROC(RECLAIM_COMPLETE, enc_reclaim_complete, dec_reclaim_complete), |
| 7717 | PROC(GETDEVICEINFO, enc_getdeviceinfo, dec_getdeviceinfo), |
| 7718 | PROC(LAYOUTGET, enc_layoutget, dec_layoutget), |
Andy Adamson | 863a3c6 | 2011-03-23 13:27:54 +0000 | [diff] [blame] | 7719 | PROC(LAYOUTCOMMIT, enc_layoutcommit, dec_layoutcommit), |
Benny Halevy | cbe8260 | 2011-05-22 19:52:37 +0300 | [diff] [blame] | 7720 | PROC(LAYOUTRETURN, enc_layoutreturn, dec_layoutreturn), |
Bryan Schumaker | fca78d6 | 2011-06-02 14:59:07 -0400 | [diff] [blame] | 7721 | PROC(SECINFO_NO_NAME, enc_secinfo_no_name, dec_secinfo_no_name), |
Bryan Schumaker | 7d97479 | 2011-06-02 14:59:08 -0400 | [diff] [blame] | 7722 | PROC(TEST_STATEID, enc_test_stateid, dec_test_stateid), |
Bryan Schumaker | 9aeda35 | 2011-06-02 14:59:09 -0400 | [diff] [blame] | 7723 | PROC(FREE_STATEID, enc_free_stateid, dec_free_stateid), |
Anna Schumaker | 7c61f0d | 2015-04-14 10:34:20 -0400 | [diff] [blame] | 7724 | STUB(GETDEVICELIST), |
Trond Myklebust | ad24ecf | 2012-05-25 17:11:42 -0400 | [diff] [blame] | 7725 | PROC(BIND_CONN_TO_SESSION, |
| 7726 | enc_bind_conn_to_session, dec_bind_conn_to_session), |
Trond Myklebust | 6624553 | 2012-05-25 17:18:09 -0400 | [diff] [blame] | 7727 | PROC(DESTROY_CLIENTID, enc_destroy_clientid, dec_destroy_clientid), |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 7728 | #endif /* CONFIG_NFS_V4_1 */ |
Anna Schumaker | 1c6dcbe | 2014-09-26 13:58:48 -0400 | [diff] [blame] | 7729 | #ifdef CONFIG_NFS_V4_2 |
| 7730 | PROC(SEEK, enc_seek, dec_seek), |
Anna Schumaker | f4ac167 | 2014-11-25 13:18:15 -0500 | [diff] [blame] | 7731 | PROC(ALLOCATE, enc_allocate, dec_allocate), |
Anna Schumaker | 624bd5b | 2014-11-25 13:18:16 -0500 | [diff] [blame] | 7732 | PROC(DEALLOCATE, enc_deallocate, dec_deallocate), |
Trond Myklebust | be3a5d2 | 2015-06-23 19:51:55 +0800 | [diff] [blame] | 7733 | PROC(LAYOUTSTATS, enc_layoutstats, dec_layoutstats), |
Peng Tao | 3602277 | 2015-09-26 02:24:34 +0800 | [diff] [blame] | 7734 | PROC(CLONE, enc_clone, dec_clone), |
Anna Schumaker | 2e72448 | 2013-05-21 16:53:03 -0400 | [diff] [blame] | 7735 | PROC(COPY, enc_copy, dec_copy), |
Anna Schumaker | 1c6dcbe | 2014-09-26 13:58:48 -0400 | [diff] [blame] | 7736 | #endif /* CONFIG_NFS_V4_2 */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7737 | }; |
| 7738 | |
Christoph Hellwig | c551858 | 2017-05-08 23:27:10 +0200 | [diff] [blame] | 7739 | static unsigned int nfs_version4_counts[ARRAY_SIZE(nfs4_procedures)]; |
Trond Myklebust | a613fa1 | 2012-01-20 13:53:56 -0500 | [diff] [blame] | 7740 | const struct rpc_version nfs_version4 = { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7741 | .number = 4, |
Tobias Klauser | e8c96f8 | 2006-03-24 03:15:34 -0800 | [diff] [blame] | 7742 | .nrprocs = ARRAY_SIZE(nfs4_procedures), |
Christoph Hellwig | c551858 | 2017-05-08 23:27:10 +0200 | [diff] [blame] | 7743 | .procs = nfs4_procedures, |
| 7744 | .counts = nfs_version4_counts, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7745 | }; |
| 7746 | |
| 7747 | /* |
| 7748 | * Local variables: |
| 7749 | * c-basic-offset: 8 |
| 7750 | * End: |
| 7751 | */ |