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> |
| 55 | #include <linux/nfs_idmap.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" |
Trond Myklebust | 76e697b | 2012-11-26 14:20:49 -0500 | [diff] [blame] | 59 | #include "nfs4session.h" |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 60 | #include "pnfs.h" |
Chuck Lever | f092075 | 2012-05-21 22:45:41 -0400 | [diff] [blame] | 61 | #include "netns.h" |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 62 | |
| 63 | #define NFSDBG_FACILITY NFSDBG_XDR |
| 64 | |
| 65 | /* Mapping from NFS error code to "errno" error code. */ |
| 66 | #define errno_NFSERR_IO EIO |
| 67 | |
David Howells | 0a8ea43 | 2006-08-22 20:06:08 -0400 | [diff] [blame] | 68 | static int nfs4_stat_to_errno(int); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 69 | |
| 70 | /* NFSv4 COMPOUND tags are only wanted for debugging purposes */ |
| 71 | #ifdef DEBUG |
| 72 | #define NFS4_MAXTAGLEN 20 |
| 73 | #else |
| 74 | #define NFS4_MAXTAGLEN 0 |
| 75 | #endif |
| 76 | |
Andy Adamson | 6c0195a | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 77 | /* lock,open owner id: |
Trond Myklebust | 9f958ab | 2007-07-02 13:58:33 -0400 | [diff] [blame] | 78 | * we currently use size 2 (u64) out of (NFS4_OPAQUE_LIMIT >> 2) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 79 | */ |
Trond Myklebust | 95b72eb | 2012-04-20 19:24:51 -0400 | [diff] [blame] | 80 | #define open_owner_id_maxsz (1 + 2 + 1 + 1 + 2) |
Trond Myklebust | d035c36 | 2010-12-21 10:45:27 -0500 | [diff] [blame] | 81 | #define lock_owner_id_maxsz (1 + 1 + 4) |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 82 | #define decode_lockowner_maxsz (1 + XDR_QUADLEN(IDMAP_NAMESZ)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 83 | #define compound_encode_hdr_maxsz (3 + (NFS4_MAXTAGLEN >> 2)) |
| 84 | #define compound_decode_hdr_maxsz (3 + (NFS4_MAXTAGLEN >> 2)) |
| 85 | #define op_encode_hdr_maxsz (1) |
| 86 | #define op_decode_hdr_maxsz (2) |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 87 | #define encode_stateid_maxsz (XDR_QUADLEN(NFS4_STATEID_SIZE)) |
| 88 | #define decode_stateid_maxsz (XDR_QUADLEN(NFS4_STATEID_SIZE)) |
| 89 | #define encode_verifier_maxsz (XDR_QUADLEN(NFS4_VERIFIER_SIZE)) |
| 90 | #define decode_verifier_maxsz (XDR_QUADLEN(NFS4_VERIFIER_SIZE)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 91 | #define encode_putfh_maxsz (op_encode_hdr_maxsz + 1 + \ |
| 92 | (NFS4_FHSIZE >> 2)) |
| 93 | #define decode_putfh_maxsz (op_decode_hdr_maxsz) |
| 94 | #define encode_putrootfh_maxsz (op_encode_hdr_maxsz) |
| 95 | #define decode_putrootfh_maxsz (op_decode_hdr_maxsz) |
| 96 | #define encode_getfh_maxsz (op_encode_hdr_maxsz) |
| 97 | #define decode_getfh_maxsz (op_decode_hdr_maxsz + 1 + \ |
| 98 | ((3+NFS4_FHSIZE) >> 2)) |
Andy Adamson | e5012d1 | 2011-07-11 17:17:42 -0400 | [diff] [blame] | 99 | #define nfs4_fattr_bitmap_maxsz 4 |
J. Bruce Fields | 9692820 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 100 | #define encode_getattr_maxsz (op_encode_hdr_maxsz + nfs4_fattr_bitmap_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 101 | #define nfs4_name_maxsz (1 + ((3 + NFS4_MAXNAMLEN) >> 2)) |
| 102 | #define nfs4_path_maxsz (1 + ((3 + NFS4_MAXPATHLEN) >> 2)) |
Trond Myklebust | bd625ba | 2007-07-08 18:38:23 -0400 | [diff] [blame] | 103 | #define nfs4_owner_maxsz (1 + XDR_QUADLEN(IDMAP_NAMESZ)) |
| 104 | #define nfs4_group_maxsz (1 + XDR_QUADLEN(IDMAP_NAMESZ)) |
David Quigley | aa9c266 | 2013-05-22 12:50:44 -0400 | [diff] [blame] | 105 | #ifdef CONFIG_NFS_V4_SECURITY_LABEL |
| 106 | /* PI(4 bytes) + LFS(4 bytes) + 1(for null terminator?) + MAXLABELLEN */ |
| 107 | #define nfs4_label_maxsz (4 + 4 + 1 + XDR_QUADLEN(NFS4_MAXLABELLEN)) |
David Quigley | aa9c266 | 2013-05-22 12:50:44 -0400 | [diff] [blame] | 108 | #else |
| 109 | #define nfs4_label_maxsz 0 |
David Quigley | aa9c266 | 2013-05-22 12:50:44 -0400 | [diff] [blame] | 110 | #endif |
Andy Adamson | 88034c3 | 2012-05-23 05:02:34 -0400 | [diff] [blame] | 111 | /* We support only one layout type per file system */ |
| 112 | #define decode_mdsthreshold_maxsz (1 + 1 + nfs4_fattr_bitmap_maxsz + 1 + 8) |
J. Bruce Fields | 9692820 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 113 | /* This is based on getfattr, which uses the most attributes: */ |
| 114 | #define nfs4_fattr_value_maxsz (1 + (1 + 2 + 2 + 4 + 2 + 1 + 1 + 2 + 2 + \ |
Andy Adamson | 88034c3 | 2012-05-23 05:02:34 -0400 | [diff] [blame] | 115 | 3 + 3 + 3 + nfs4_owner_maxsz + \ |
David Quigley | aa9c266 | 2013-05-22 12:50:44 -0400 | [diff] [blame] | 116 | nfs4_group_maxsz + nfs4_label_maxsz + \ |
| 117 | decode_mdsthreshold_maxsz)) |
J. Bruce Fields | 9692820 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 118 | #define nfs4_fattr_maxsz (nfs4_fattr_bitmap_maxsz + \ |
| 119 | nfs4_fattr_value_maxsz) |
| 120 | #define decode_getattr_maxsz (op_decode_hdr_maxsz + nfs4_fattr_maxsz) |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 121 | #define encode_attrs_maxsz (nfs4_fattr_bitmap_maxsz + \ |
| 122 | 1 + 2 + 1 + \ |
| 123 | nfs4_owner_maxsz + \ |
| 124 | nfs4_group_maxsz + \ |
David Quigley | aa9c266 | 2013-05-22 12:50:44 -0400 | [diff] [blame] | 125 | nfs4_label_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 126 | 4 + 4) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 127 | #define encode_savefh_maxsz (op_encode_hdr_maxsz) |
| 128 | #define decode_savefh_maxsz (op_decode_hdr_maxsz) |
Trond Myklebust | 56ae19f | 2005-10-27 22:12:40 -0400 | [diff] [blame] | 129 | #define encode_restorefh_maxsz (op_encode_hdr_maxsz) |
| 130 | #define decode_restorefh_maxsz (op_decode_hdr_maxsz) |
Fred Isaman | 2f42b5d | 2008-03-13 15:26:30 +0200 | [diff] [blame] | 131 | #define encode_fsinfo_maxsz (encode_getattr_maxsz) |
Fred Isaman | dae100c | 2011-07-30 20:52:37 -0400 | [diff] [blame] | 132 | /* The 5 accounts for the PNFS attributes, and assumes that at most three |
| 133 | * layout types will be returned. |
| 134 | */ |
| 135 | #define decode_fsinfo_maxsz (op_decode_hdr_maxsz + \ |
| 136 | nfs4_fattr_bitmap_maxsz + 4 + 8 + 5) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 137 | #define encode_renew_maxsz (op_encode_hdr_maxsz + 3) |
| 138 | #define decode_renew_maxsz (op_decode_hdr_maxsz) |
| 139 | #define encode_setclientid_maxsz \ |
| 140 | (op_encode_hdr_maxsz + \ |
Chuck Lever | cc38bac | 2007-12-10 14:56:54 -0500 | [diff] [blame] | 141 | XDR_QUADLEN(NFS4_VERIFIER_SIZE) + \ |
| 142 | XDR_QUADLEN(NFS4_SETCLIENTID_NAMELEN) + \ |
| 143 | 1 /* sc_prog */ + \ |
| 144 | XDR_QUADLEN(RPCBIND_MAXNETIDLEN) + \ |
| 145 | XDR_QUADLEN(RPCBIND_MAXUADDRLEN) + \ |
| 146 | 1) /* sc_cb_ident */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 147 | #define decode_setclientid_maxsz \ |
| 148 | (op_decode_hdr_maxsz + \ |
| 149 | 2 + \ |
| 150 | 1024) /* large value for CLID_INUSE */ |
| 151 | #define encode_setclientid_confirm_maxsz \ |
| 152 | (op_encode_hdr_maxsz + \ |
| 153 | 3 + (NFS4_VERIFIER_SIZE >> 2)) |
| 154 | #define decode_setclientid_confirm_maxsz \ |
| 155 | (op_decode_hdr_maxsz) |
Trond Myklebust | e688962 | 2007-07-02 13:58:30 -0400 | [diff] [blame] | 156 | #define encode_lookup_maxsz (op_encode_hdr_maxsz + nfs4_name_maxsz) |
| 157 | #define decode_lookup_maxsz (op_decode_hdr_maxsz) |
Trond Myklebust | 2cebf82 | 2007-07-02 13:57:28 -0400 | [diff] [blame] | 158 | #define encode_share_access_maxsz \ |
| 159 | (2) |
Alexandros Batsakis | 4882ef7 | 2009-12-05 13:30:21 -0500 | [diff] [blame] | 160 | #define encode_createmode_maxsz (1 + encode_attrs_maxsz + encode_verifier_maxsz) |
Trond Myklebust | 2cebf82 | 2007-07-02 13:57:28 -0400 | [diff] [blame] | 161 | #define encode_opentype_maxsz (1 + encode_createmode_maxsz) |
| 162 | #define encode_claim_null_maxsz (1 + nfs4_name_maxsz) |
| 163 | #define encode_open_maxsz (op_encode_hdr_maxsz + \ |
| 164 | 2 + encode_share_access_maxsz + 2 + \ |
| 165 | open_owner_id_maxsz + \ |
| 166 | encode_opentype_maxsz + \ |
| 167 | encode_claim_null_maxsz) |
| 168 | #define decode_ace_maxsz (3 + nfs4_owner_maxsz) |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 169 | #define decode_delegation_maxsz (1 + decode_stateid_maxsz + 1 + \ |
Trond Myklebust | 2cebf82 | 2007-07-02 13:57:28 -0400 | [diff] [blame] | 170 | decode_ace_maxsz) |
| 171 | #define decode_change_info_maxsz (5) |
| 172 | #define decode_open_maxsz (op_decode_hdr_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 173 | decode_stateid_maxsz + \ |
Trond Myklebust | 2cebf82 | 2007-07-02 13:57:28 -0400 | [diff] [blame] | 174 | decode_change_info_maxsz + 1 + \ |
| 175 | nfs4_fattr_bitmap_maxsz + \ |
| 176 | decode_delegation_maxsz) |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 177 | #define encode_open_confirm_maxsz \ |
| 178 | (op_encode_hdr_maxsz + \ |
| 179 | encode_stateid_maxsz + 1) |
| 180 | #define decode_open_confirm_maxsz \ |
| 181 | (op_decode_hdr_maxsz + \ |
| 182 | decode_stateid_maxsz) |
| 183 | #define encode_open_downgrade_maxsz \ |
| 184 | (op_encode_hdr_maxsz + \ |
| 185 | encode_stateid_maxsz + 1 + \ |
| 186 | encode_share_access_maxsz) |
| 187 | #define decode_open_downgrade_maxsz \ |
| 188 | (op_decode_hdr_maxsz + \ |
| 189 | decode_stateid_maxsz) |
| 190 | #define encode_close_maxsz (op_encode_hdr_maxsz + \ |
| 191 | 1 + encode_stateid_maxsz) |
| 192 | #define decode_close_maxsz (op_decode_hdr_maxsz + \ |
| 193 | decode_stateid_maxsz) |
| 194 | #define encode_setattr_maxsz (op_encode_hdr_maxsz + \ |
| 195 | encode_stateid_maxsz + \ |
| 196 | encode_attrs_maxsz) |
| 197 | #define decode_setattr_maxsz (op_decode_hdr_maxsz + \ |
| 198 | nfs4_fattr_bitmap_maxsz) |
| 199 | #define encode_read_maxsz (op_encode_hdr_maxsz + \ |
| 200 | encode_stateid_maxsz + 3) |
| 201 | #define decode_read_maxsz (op_decode_hdr_maxsz + 2) |
| 202 | #define encode_readdir_maxsz (op_encode_hdr_maxsz + \ |
David Quigley | aa9c266 | 2013-05-22 12:50:44 -0400 | [diff] [blame] | 203 | 2 + encode_verifier_maxsz + 5 + \ |
| 204 | nfs4_label_maxsz) |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 205 | #define decode_readdir_maxsz (op_decode_hdr_maxsz + \ |
Chuck Lever | a7697f6 | 2014-03-12 12:51:17 -0400 | [diff] [blame] | 206 | decode_verifier_maxsz) |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 207 | #define encode_readlink_maxsz (op_encode_hdr_maxsz) |
| 208 | #define decode_readlink_maxsz (op_decode_hdr_maxsz + 1) |
| 209 | #define encode_write_maxsz (op_encode_hdr_maxsz + \ |
| 210 | encode_stateid_maxsz + 4) |
| 211 | #define decode_write_maxsz (op_decode_hdr_maxsz + \ |
| 212 | 2 + decode_verifier_maxsz) |
| 213 | #define encode_commit_maxsz (op_encode_hdr_maxsz + 3) |
| 214 | #define decode_commit_maxsz (op_decode_hdr_maxsz + \ |
| 215 | decode_verifier_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 216 | #define encode_remove_maxsz (op_encode_hdr_maxsz + \ |
| 217 | nfs4_name_maxsz) |
Benny Halevy | 6ce1839 | 2009-04-01 09:22:06 -0400 | [diff] [blame] | 218 | #define decode_remove_maxsz (op_decode_hdr_maxsz + \ |
| 219 | decode_change_info_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 220 | #define encode_rename_maxsz (op_encode_hdr_maxsz + \ |
| 221 | 2 * nfs4_name_maxsz) |
Benny Halevy | 6ce1839 | 2009-04-01 09:22:06 -0400 | [diff] [blame] | 222 | #define decode_rename_maxsz (op_decode_hdr_maxsz + \ |
| 223 | decode_change_info_maxsz + \ |
| 224 | decode_change_info_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 225 | #define encode_link_maxsz (op_encode_hdr_maxsz + \ |
| 226 | nfs4_name_maxsz) |
Benny Halevy | 6ce1839 | 2009-04-01 09:22:06 -0400 | [diff] [blame] | 227 | #define decode_link_maxsz (op_decode_hdr_maxsz + decode_change_info_maxsz) |
Trond Myklebust | daccbde | 2010-06-25 18:11:43 -0400 | [diff] [blame] | 228 | #define encode_lockowner_maxsz (7) |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 229 | #define encode_lock_maxsz (op_encode_hdr_maxsz + \ |
| 230 | 7 + \ |
Trond Myklebust | daccbde | 2010-06-25 18:11:43 -0400 | [diff] [blame] | 231 | 1 + encode_stateid_maxsz + 1 + \ |
| 232 | encode_lockowner_maxsz) |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 233 | #define decode_lock_denied_maxsz \ |
| 234 | (8 + decode_lockowner_maxsz) |
| 235 | #define decode_lock_maxsz (op_decode_hdr_maxsz + \ |
| 236 | decode_lock_denied_maxsz) |
Trond Myklebust | daccbde | 2010-06-25 18:11:43 -0400 | [diff] [blame] | 237 | #define encode_lockt_maxsz (op_encode_hdr_maxsz + 5 + \ |
| 238 | encode_lockowner_maxsz) |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 239 | #define decode_lockt_maxsz (op_decode_hdr_maxsz + \ |
| 240 | decode_lock_denied_maxsz) |
| 241 | #define encode_locku_maxsz (op_encode_hdr_maxsz + 3 + \ |
| 242 | encode_stateid_maxsz + \ |
| 243 | 4) |
| 244 | #define decode_locku_maxsz (op_decode_hdr_maxsz + \ |
| 245 | decode_stateid_maxsz) |
Trond Myklebust | d3c7b7c | 2010-07-01 12:49:01 -0400 | [diff] [blame] | 246 | #define encode_release_lockowner_maxsz \ |
| 247 | (op_encode_hdr_maxsz + \ |
| 248 | encode_lockowner_maxsz) |
| 249 | #define decode_release_lockowner_maxsz \ |
| 250 | (op_decode_hdr_maxsz) |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 251 | #define encode_access_maxsz (op_encode_hdr_maxsz + 1) |
| 252 | #define decode_access_maxsz (op_decode_hdr_maxsz + 2) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 253 | #define encode_symlink_maxsz (op_encode_hdr_maxsz + \ |
| 254 | 1 + nfs4_name_maxsz + \ |
Chuck Lever | 94a6d75 | 2006-08-22 20:06:23 -0400 | [diff] [blame] | 255 | 1 + \ |
J. Bruce Fields | 9692820 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 256 | nfs4_fattr_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 257 | #define decode_symlink_maxsz (op_decode_hdr_maxsz + 8) |
| 258 | #define encode_create_maxsz (op_encode_hdr_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 259 | 1 + 2 + nfs4_name_maxsz + \ |
| 260 | encode_attrs_maxsz) |
Trond Myklebust | 2cebf82 | 2007-07-02 13:57:28 -0400 | [diff] [blame] | 261 | #define decode_create_maxsz (op_decode_hdr_maxsz + \ |
| 262 | decode_change_info_maxsz + \ |
| 263 | nfs4_fattr_bitmap_maxsz) |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 264 | #define encode_statfs_maxsz (encode_getattr_maxsz) |
| 265 | #define decode_statfs_maxsz (decode_getattr_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 266 | #define encode_delegreturn_maxsz (op_encode_hdr_maxsz + 4) |
| 267 | #define decode_delegreturn_maxsz (op_decode_hdr_maxsz) |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 268 | #define encode_getacl_maxsz (encode_getattr_maxsz) |
| 269 | #define decode_getacl_maxsz (op_decode_hdr_maxsz + \ |
| 270 | nfs4_fattr_bitmap_maxsz + 1) |
| 271 | #define encode_setacl_maxsz (op_encode_hdr_maxsz + \ |
| 272 | encode_stateid_maxsz + 3) |
| 273 | #define decode_setacl_maxsz (decode_setattr_maxsz) |
Trond Myklebust | e688962 | 2007-07-02 13:58:30 -0400 | [diff] [blame] | 274 | #define encode_fs_locations_maxsz \ |
| 275 | (encode_getattr_maxsz) |
| 276 | #define decode_fs_locations_maxsz \ |
| 277 | (0) |
Bryan Schumaker | 5a5ea0d | 2011-03-24 17:12:29 +0000 | [diff] [blame] | 278 | #define encode_secinfo_maxsz (op_encode_hdr_maxsz + nfs4_name_maxsz) |
Bryan Schumaker | 1650add | 2011-06-02 15:07:35 -0400 | [diff] [blame] | 279 | #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] | 280 | |
| 281 | #if defined(CONFIG_NFS_V4_1) |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 282 | #define NFS4_MAX_MACHINE_NAME_LEN (64) |
Jim Rees | d751f74 | 2012-11-16 18:12:06 -0500 | [diff] [blame] | 283 | #define IMPL_NAME_LIMIT (sizeof(utsname()->sysname) + sizeof(utsname()->release) + \ |
| 284 | sizeof(utsname()->version) + sizeof(utsname()->machine) + 8) |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 285 | |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 286 | #define encode_exchange_id_maxsz (op_encode_hdr_maxsz + \ |
| 287 | encode_verifier_maxsz + \ |
| 288 | 1 /* co_ownerid.len */ + \ |
| 289 | XDR_QUADLEN(NFS4_EXCHANGE_ID_LEN) + \ |
| 290 | 1 /* flags */ + \ |
| 291 | 1 /* spa_how */ + \ |
Weston Andros Adamson | 2031cd1 | 2013-08-13 16:37:32 -0400 | [diff] [blame] | 292 | /* max is SP4_MACH_CRED (for now) */ + \ |
| 293 | 1 + NFS4_OP_MAP_NUM_WORDS + \ |
| 294 | 1 + NFS4_OP_MAP_NUM_WORDS + \ |
Weston Andros Adamson | db8ac8b | 2012-02-17 15:20:24 -0500 | [diff] [blame] | 295 | 1 /* implementation id array of size 1 */ + \ |
| 296 | 1 /* nii_domain */ + \ |
| 297 | XDR_QUADLEN(NFS4_OPAQUE_LIMIT) + \ |
| 298 | 1 /* nii_name */ + \ |
Jim Rees | d751f74 | 2012-11-16 18:12:06 -0500 | [diff] [blame] | 299 | XDR_QUADLEN(IMPL_NAME_LIMIT) + \ |
Weston Andros Adamson | db8ac8b | 2012-02-17 15:20:24 -0500 | [diff] [blame] | 300 | 3 /* nii_date */) |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 301 | #define decode_exchange_id_maxsz (op_decode_hdr_maxsz + \ |
| 302 | 2 /* eir_clientid */ + \ |
| 303 | 1 /* eir_sequenceid */ + \ |
| 304 | 1 /* eir_flags */ + \ |
| 305 | 1 /* spr_how */ + \ |
Weston Andros Adamson | 2031cd1 | 2013-08-13 16:37:32 -0400 | [diff] [blame] | 306 | /* max is SP4_MACH_CRED (for now) */ + \ |
| 307 | 1 + NFS4_OP_MAP_NUM_WORDS + \ |
| 308 | 1 + NFS4_OP_MAP_NUM_WORDS + \ |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 309 | 2 /* eir_server_owner.so_minor_id */ + \ |
| 310 | /* eir_server_owner.so_major_id<> */ \ |
| 311 | XDR_QUADLEN(NFS4_OPAQUE_LIMIT) + 1 + \ |
| 312 | /* eir_server_scope<> */ \ |
| 313 | XDR_QUADLEN(NFS4_OPAQUE_LIMIT) + 1 + \ |
| 314 | 1 /* eir_server_impl_id array length */ + \ |
Weston Andros Adamson | 7d2ed9a | 2012-02-17 15:20:26 -0500 | [diff] [blame] | 315 | 1 /* nii_domain */ + \ |
| 316 | XDR_QUADLEN(NFS4_OPAQUE_LIMIT) + \ |
| 317 | 1 /* nii_name */ + \ |
| 318 | XDR_QUADLEN(NFS4_OPAQUE_LIMIT) + \ |
| 319 | 3 /* nii_date */) |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 320 | #define encode_channel_attrs_maxsz (6 + 1 /* ca_rdma_ird.len (0) */) |
| 321 | #define decode_channel_attrs_maxsz (6 + \ |
| 322 | 1 /* ca_rdma_ird.len */ + \ |
| 323 | 1 /* ca_rdma_ird */) |
| 324 | #define encode_create_session_maxsz (op_encode_hdr_maxsz + \ |
| 325 | 2 /* csa_clientid */ + \ |
| 326 | 1 /* csa_sequence */ + \ |
| 327 | 1 /* csa_flags */ + \ |
| 328 | encode_channel_attrs_maxsz + \ |
| 329 | encode_channel_attrs_maxsz + \ |
| 330 | 1 /* csa_cb_program */ + \ |
| 331 | 1 /* csa_sec_parms.len (1) */ + \ |
| 332 | 1 /* cb_secflavor (AUTH_SYS) */ + \ |
| 333 | 1 /* stamp */ + \ |
| 334 | 1 /* machinename.len */ + \ |
| 335 | XDR_QUADLEN(NFS4_MAX_MACHINE_NAME_LEN) + \ |
| 336 | 1 /* uid */ + \ |
| 337 | 1 /* gid */ + \ |
| 338 | 1 /* gids.len (0) */) |
| 339 | #define decode_create_session_maxsz (op_decode_hdr_maxsz + \ |
| 340 | XDR_QUADLEN(NFS4_MAX_SESSIONID_LEN) + \ |
| 341 | 1 /* csr_sequence */ + \ |
| 342 | 1 /* csr_flags */ + \ |
| 343 | decode_channel_attrs_maxsz + \ |
| 344 | decode_channel_attrs_maxsz) |
Weston Andros Adamson | 7c44f1ae | 2012-05-24 13:22:50 -0400 | [diff] [blame] | 345 | #define encode_bind_conn_to_session_maxsz (op_encode_hdr_maxsz + \ |
| 346 | /* bctsa_sessid */ \ |
| 347 | XDR_QUADLEN(NFS4_MAX_SESSIONID_LEN) + \ |
| 348 | 1 /* bctsa_dir */ + \ |
| 349 | 1 /* bctsa_use_conn_in_rdma_mode */) |
| 350 | #define decode_bind_conn_to_session_maxsz (op_decode_hdr_maxsz + \ |
| 351 | /* bctsr_sessid */ \ |
| 352 | XDR_QUADLEN(NFS4_MAX_SESSIONID_LEN) + \ |
| 353 | 1 /* bctsr_dir */ + \ |
| 354 | 1 /* bctsr_use_conn_in_rdma_mode */) |
Andy Adamson | 0f3e66c | 2009-04-01 09:22:34 -0400 | [diff] [blame] | 355 | #define encode_destroy_session_maxsz (op_encode_hdr_maxsz + 4) |
| 356 | #define decode_destroy_session_maxsz (op_decode_hdr_maxsz) |
Trond Myklebust | 6624553 | 2012-05-25 17:18:09 -0400 | [diff] [blame] | 357 | #define encode_destroy_clientid_maxsz (op_encode_hdr_maxsz + 2) |
| 358 | #define decode_destroy_clientid_maxsz (op_decode_hdr_maxsz) |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 359 | #define encode_sequence_maxsz (op_encode_hdr_maxsz + \ |
| 360 | XDR_QUADLEN(NFS4_MAX_SESSIONID_LEN) + 4) |
| 361 | #define decode_sequence_maxsz (op_decode_hdr_maxsz + \ |
| 362 | XDR_QUADLEN(NFS4_MAX_SESSIONID_LEN) + 5) |
Ricardo Labiaga | 18019753 | 2009-12-05 16:08:40 -0500 | [diff] [blame] | 363 | #define encode_reclaim_complete_maxsz (op_encode_hdr_maxsz + 4) |
| 364 | #define decode_reclaim_complete_maxsz (op_decode_hdr_maxsz + 4) |
Christoph Hellwig | 84c9dee | 2014-09-10 17:37:28 -0700 | [diff] [blame^] | 365 | #define encode_getdeviceinfo_maxsz (op_encode_hdr_maxsz + \ |
| 366 | XDR_QUADLEN(NFS4_DEVICEID4_SIZE) + \ |
| 367 | 1 /* layout type */ + \ |
| 368 | 1 /* maxcount */ + \ |
| 369 | 1 /* bitmap size */ + \ |
| 370 | 1 /* notification bitmap length */ + \ |
| 371 | 1 /* notification bitmap, word 0 */) |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 372 | #define decode_getdeviceinfo_maxsz (op_decode_hdr_maxsz + \ |
| 373 | 1 /* layout type */ + \ |
| 374 | 1 /* opaque devaddr4 length */ + \ |
| 375 | /* devaddr4 payload is read into page */ \ |
| 376 | 1 /* notification bitmap length */ + \ |
Christoph Hellwig | 84c9dee | 2014-09-10 17:37:28 -0700 | [diff] [blame^] | 377 | 1 /* notification bitmap, word 0 */) |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 378 | #define encode_layoutget_maxsz (op_encode_hdr_maxsz + 10 + \ |
| 379 | encode_stateid_maxsz) |
| 380 | #define decode_layoutget_maxsz (op_decode_hdr_maxsz + 8 + \ |
| 381 | decode_stateid_maxsz + \ |
| 382 | XDR_QUADLEN(PNFS_LAYOUT_MAXSIZE)) |
Andy Adamson | 863a3c6 | 2011-03-23 13:27:54 +0000 | [diff] [blame] | 383 | #define encode_layoutcommit_maxsz (op_encode_hdr_maxsz + \ |
| 384 | 2 /* offset */ + \ |
| 385 | 2 /* length */ + \ |
| 386 | 1 /* reclaim */ + \ |
| 387 | encode_stateid_maxsz + \ |
| 388 | 1 /* new offset (true) */ + \ |
| 389 | 2 /* last byte written */ + \ |
| 390 | 1 /* nt_timechanged (false) */ + \ |
| 391 | 1 /* layoutupdate4 layout type */ + \ |
Christoph Hellwig | 5f919c9 | 2014-08-21 11:09:25 -0500 | [diff] [blame] | 392 | 1 /* layoutupdate4 opaqueue len */) |
| 393 | /* the actual content of layoutupdate4 should |
| 394 | be allocated by drivers and spliced in |
| 395 | using xdr_write_pages */ |
Andy Adamson | 863a3c6 | 2011-03-23 13:27:54 +0000 | [diff] [blame] | 396 | #define decode_layoutcommit_maxsz (op_decode_hdr_maxsz + 3) |
Benny Halevy | cbe8260 | 2011-05-22 19:52:37 +0300 | [diff] [blame] | 397 | #define encode_layoutreturn_maxsz (8 + op_encode_hdr_maxsz + \ |
| 398 | encode_stateid_maxsz + \ |
| 399 | 1 /* FIXME: opaque lrf_body always empty at the moment */) |
| 400 | #define decode_layoutreturn_maxsz (op_decode_hdr_maxsz + \ |
| 401 | 1 + decode_stateid_maxsz) |
Bryan Schumaker | fca78d6 | 2011-06-02 14:59:07 -0400 | [diff] [blame] | 402 | #define encode_secinfo_no_name_maxsz (op_encode_hdr_maxsz + 1) |
| 403 | #define decode_secinfo_no_name_maxsz decode_secinfo_maxsz |
Bryan Schumaker | 7d97479 | 2011-06-02 14:59:08 -0400 | [diff] [blame] | 404 | #define encode_test_stateid_maxsz (op_encode_hdr_maxsz + 2 + \ |
| 405 | XDR_QUADLEN(NFS4_STATEID_SIZE)) |
| 406 | #define decode_test_stateid_maxsz (op_decode_hdr_maxsz + 2 + 1) |
Bryan Schumaker | 9aeda35 | 2011-06-02 14:59:09 -0400 | [diff] [blame] | 407 | #define encode_free_stateid_maxsz (op_encode_hdr_maxsz + 1 + \ |
| 408 | XDR_QUADLEN(NFS4_STATEID_SIZE)) |
Andy Adamson | 9f79fb4 | 2013-09-10 12:56:29 -0400 | [diff] [blame] | 409 | #define decode_free_stateid_maxsz (op_decode_hdr_maxsz) |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 410 | #else /* CONFIG_NFS_V4_1 */ |
| 411 | #define encode_sequence_maxsz 0 |
| 412 | #define decode_sequence_maxsz 0 |
| 413 | #endif /* CONFIG_NFS_V4_1 */ |
| 414 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 415 | #define NFS4_enc_compound_sz (1024) /* XXX: large enough? */ |
| 416 | #define NFS4_dec_compound_sz (1024) /* XXX: large enough? */ |
| 417 | #define NFS4_enc_read_sz (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 418 | encode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 419 | encode_putfh_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 420 | encode_read_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 421 | #define NFS4_dec_read_sz (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 422 | decode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 423 | decode_putfh_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 424 | decode_read_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 425 | #define NFS4_enc_readlink_sz (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 426 | encode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 427 | encode_putfh_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 428 | encode_readlink_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 429 | #define NFS4_dec_readlink_sz (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 430 | decode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 431 | decode_putfh_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 432 | decode_readlink_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 433 | #define NFS4_enc_readdir_sz (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 434 | encode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 435 | encode_putfh_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 436 | encode_readdir_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 437 | #define NFS4_dec_readdir_sz (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 438 | decode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 439 | decode_putfh_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 440 | decode_readdir_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 441 | #define NFS4_enc_write_sz (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 442 | encode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 443 | encode_putfh_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 444 | encode_write_maxsz + \ |
Trond Myklebust | 4f9838c | 2005-10-27 22:12:44 -0400 | [diff] [blame] | 445 | encode_getattr_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 446 | #define NFS4_dec_write_sz (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 447 | decode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 448 | decode_putfh_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 449 | decode_write_maxsz + \ |
Trond Myklebust | 4f9838c | 2005-10-27 22:12:44 -0400 | [diff] [blame] | 450 | decode_getattr_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 451 | #define NFS4_enc_commit_sz (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 452 | encode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 453 | encode_putfh_maxsz + \ |
Trond Myklebust | 8582715 | 2012-04-29 10:44:42 -0400 | [diff] [blame] | 454 | encode_commit_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 455 | #define NFS4_dec_commit_sz (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 456 | decode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 457 | decode_putfh_maxsz + \ |
Trond Myklebust | 8582715 | 2012-04-29 10:44:42 -0400 | [diff] [blame] | 458 | decode_commit_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 459 | #define NFS4_enc_open_sz (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 460 | encode_sequence_maxsz + \ |
Trond Myklebust | 2cebf82 | 2007-07-02 13:57:28 -0400 | [diff] [blame] | 461 | encode_putfh_maxsz + \ |
Trond Myklebust | 2cebf82 | 2007-07-02 13:57:28 -0400 | [diff] [blame] | 462 | encode_open_maxsz + \ |
Weston Andros Adamson | 6168f62 | 2012-09-10 14:00:46 -0400 | [diff] [blame] | 463 | encode_access_maxsz + \ |
Trond Myklebust | 2cebf82 | 2007-07-02 13:57:28 -0400 | [diff] [blame] | 464 | encode_getfh_maxsz + \ |
Trond Myklebust | 2cebf82 | 2007-07-02 13:57:28 -0400 | [diff] [blame] | 465 | encode_getattr_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 466 | #define NFS4_dec_open_sz (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 467 | decode_sequence_maxsz + \ |
Trond Myklebust | 2cebf82 | 2007-07-02 13:57:28 -0400 | [diff] [blame] | 468 | decode_putfh_maxsz + \ |
Trond Myklebust | 2cebf82 | 2007-07-02 13:57:28 -0400 | [diff] [blame] | 469 | decode_open_maxsz + \ |
Weston Andros Adamson | 6168f62 | 2012-09-10 14:00:46 -0400 | [diff] [blame] | 470 | decode_access_maxsz + \ |
Trond Myklebust | 2cebf82 | 2007-07-02 13:57:28 -0400 | [diff] [blame] | 471 | decode_getfh_maxsz + \ |
Trond Myklebust | 2cebf82 | 2007-07-02 13:57:28 -0400 | [diff] [blame] | 472 | decode_getattr_maxsz) |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 473 | #define NFS4_enc_open_confirm_sz \ |
| 474 | (compound_encode_hdr_maxsz + \ |
| 475 | encode_putfh_maxsz + \ |
| 476 | encode_open_confirm_maxsz) |
| 477 | #define NFS4_dec_open_confirm_sz \ |
| 478 | (compound_decode_hdr_maxsz + \ |
| 479 | decode_putfh_maxsz + \ |
| 480 | decode_open_confirm_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 481 | #define NFS4_enc_open_noattr_sz (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 482 | encode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 483 | encode_putfh_maxsz + \ |
Trond Myklebust | 2cebf82 | 2007-07-02 13:57:28 -0400 | [diff] [blame] | 484 | encode_open_maxsz + \ |
Weston Andros Adamson | 6168f62 | 2012-09-10 14:00:46 -0400 | [diff] [blame] | 485 | encode_access_maxsz + \ |
Trond Myklebust | 2cebf82 | 2007-07-02 13:57:28 -0400 | [diff] [blame] | 486 | encode_getattr_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 487 | #define NFS4_dec_open_noattr_sz (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 488 | decode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 489 | decode_putfh_maxsz + \ |
Trond Myklebust | 2cebf82 | 2007-07-02 13:57:28 -0400 | [diff] [blame] | 490 | decode_open_maxsz + \ |
Weston Andros Adamson | 6168f62 | 2012-09-10 14:00:46 -0400 | [diff] [blame] | 491 | decode_access_maxsz + \ |
Trond Myklebust | 2cebf82 | 2007-07-02 13:57:28 -0400 | [diff] [blame] | 492 | decode_getattr_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 493 | #define NFS4_enc_open_downgrade_sz \ |
| 494 | (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 495 | encode_sequence_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 496 | encode_putfh_maxsz + \ |
| 497 | encode_open_downgrade_maxsz + \ |
| 498 | encode_getattr_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 499 | #define NFS4_dec_open_downgrade_sz \ |
| 500 | (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 501 | decode_sequence_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 502 | decode_putfh_maxsz + \ |
| 503 | decode_open_downgrade_maxsz + \ |
| 504 | decode_getattr_maxsz) |
| 505 | #define NFS4_enc_close_sz (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 506 | encode_sequence_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 507 | encode_putfh_maxsz + \ |
| 508 | encode_close_maxsz + \ |
| 509 | encode_getattr_maxsz) |
| 510 | #define NFS4_dec_close_sz (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 511 | decode_sequence_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 512 | decode_putfh_maxsz + \ |
| 513 | decode_close_maxsz + \ |
| 514 | decode_getattr_maxsz) |
| 515 | #define NFS4_enc_setattr_sz (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 516 | encode_sequence_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 517 | encode_putfh_maxsz + \ |
| 518 | encode_setattr_maxsz + \ |
| 519 | encode_getattr_maxsz) |
| 520 | #define NFS4_dec_setattr_sz (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 521 | decode_sequence_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 522 | decode_putfh_maxsz + \ |
| 523 | decode_setattr_maxsz + \ |
| 524 | decode_getattr_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 525 | #define NFS4_enc_fsinfo_sz (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 526 | encode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 527 | encode_putfh_maxsz + \ |
| 528 | encode_fsinfo_maxsz) |
| 529 | #define NFS4_dec_fsinfo_sz (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 530 | decode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 531 | decode_putfh_maxsz + \ |
| 532 | decode_fsinfo_maxsz) |
| 533 | #define NFS4_enc_renew_sz (compound_encode_hdr_maxsz + \ |
| 534 | encode_renew_maxsz) |
| 535 | #define NFS4_dec_renew_sz (compound_decode_hdr_maxsz + \ |
| 536 | decode_renew_maxsz) |
| 537 | #define NFS4_enc_setclientid_sz (compound_encode_hdr_maxsz + \ |
| 538 | encode_setclientid_maxsz) |
| 539 | #define NFS4_dec_setclientid_sz (compound_decode_hdr_maxsz + \ |
| 540 | decode_setclientid_maxsz) |
| 541 | #define NFS4_enc_setclientid_confirm_sz \ |
| 542 | (compound_encode_hdr_maxsz + \ |
Chuck Lever | 83ca7f5 | 2013-03-16 15:55:53 -0400 | [diff] [blame] | 543 | encode_setclientid_confirm_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 544 | #define NFS4_dec_setclientid_confirm_sz \ |
| 545 | (compound_decode_hdr_maxsz + \ |
Chuck Lever | 83ca7f5 | 2013-03-16 15:55:53 -0400 | [diff] [blame] | 546 | decode_setclientid_confirm_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 547 | #define NFS4_enc_lock_sz (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 548 | encode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 549 | encode_putfh_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 550 | encode_lock_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 551 | #define NFS4_dec_lock_sz (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 552 | decode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 553 | decode_putfh_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 554 | decode_lock_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 555 | #define NFS4_enc_lockt_sz (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 556 | encode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 557 | encode_putfh_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 558 | encode_lockt_maxsz) |
| 559 | #define NFS4_dec_lockt_sz (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 560 | decode_sequence_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 561 | decode_putfh_maxsz + \ |
| 562 | decode_lockt_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 563 | #define NFS4_enc_locku_sz (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 564 | encode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 565 | encode_putfh_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 566 | encode_locku_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 567 | #define NFS4_dec_locku_sz (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 568 | decode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 569 | decode_putfh_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 570 | decode_locku_maxsz) |
Trond Myklebust | d3c7b7c | 2010-07-01 12:49:01 -0400 | [diff] [blame] | 571 | #define NFS4_enc_release_lockowner_sz \ |
| 572 | (compound_encode_hdr_maxsz + \ |
| 573 | encode_lockowner_maxsz) |
| 574 | #define NFS4_dec_release_lockowner_sz \ |
| 575 | (compound_decode_hdr_maxsz + \ |
| 576 | decode_lockowner_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 577 | #define NFS4_enc_access_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 | 76b3299 | 2007-08-10 17:45:11 -0400 | [diff] [blame] | 580 | encode_access_maxsz + \ |
| 581 | encode_getattr_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 582 | #define NFS4_dec_access_sz (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 583 | decode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 584 | decode_putfh_maxsz + \ |
Trond Myklebust | 76b3299 | 2007-08-10 17:45:11 -0400 | [diff] [blame] | 585 | decode_access_maxsz + \ |
| 586 | decode_getattr_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 587 | #define NFS4_enc_getattr_sz (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 588 | encode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 589 | encode_putfh_maxsz + \ |
Chuck Lever | 44c9993 | 2013-10-17 14:13:30 -0400 | [diff] [blame] | 590 | encode_getattr_maxsz + \ |
| 591 | encode_renew_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 592 | #define NFS4_dec_getattr_sz (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 593 | decode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 594 | decode_putfh_maxsz + \ |
Chuck Lever | 44c9993 | 2013-10-17 14:13:30 -0400 | [diff] [blame] | 595 | decode_getattr_maxsz + \ |
| 596 | decode_renew_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 597 | #define NFS4_enc_lookup_sz (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 598 | encode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 599 | encode_putfh_maxsz + \ |
| 600 | encode_lookup_maxsz + \ |
| 601 | encode_getattr_maxsz + \ |
| 602 | encode_getfh_maxsz) |
| 603 | #define NFS4_dec_lookup_sz (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 604 | decode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 605 | decode_putfh_maxsz + \ |
Trond Myklebust | e688962 | 2007-07-02 13:58:30 -0400 | [diff] [blame] | 606 | decode_lookup_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 607 | decode_getattr_maxsz + \ |
| 608 | decode_getfh_maxsz) |
| 609 | #define NFS4_enc_lookup_root_sz (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 610 | encode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 611 | encode_putrootfh_maxsz + \ |
| 612 | encode_getattr_maxsz + \ |
| 613 | encode_getfh_maxsz) |
| 614 | #define NFS4_dec_lookup_root_sz (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 615 | decode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 616 | decode_putrootfh_maxsz + \ |
| 617 | decode_getattr_maxsz + \ |
| 618 | decode_getfh_maxsz) |
| 619 | #define NFS4_enc_remove_sz (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 620 | encode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 621 | encode_putfh_maxsz + \ |
Trond Myklebust | 778d281 | 2012-04-27 13:48:19 -0400 | [diff] [blame] | 622 | encode_remove_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 623 | #define NFS4_dec_remove_sz (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 624 | decode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 625 | decode_putfh_maxsz + \ |
Trond Myklebust | 778d281 | 2012-04-27 13:48:19 -0400 | [diff] [blame] | 626 | decode_remove_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 627 | #define NFS4_enc_rename_sz (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 628 | encode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 629 | encode_putfh_maxsz + \ |
| 630 | encode_savefh_maxsz + \ |
| 631 | encode_putfh_maxsz + \ |
Trond Myklebust | 778d281 | 2012-04-27 13:48:19 -0400 | [diff] [blame] | 632 | encode_rename_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 633 | #define NFS4_dec_rename_sz (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 634 | decode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 635 | decode_putfh_maxsz + \ |
| 636 | decode_savefh_maxsz + \ |
| 637 | decode_putfh_maxsz + \ |
Trond Myklebust | 778d281 | 2012-04-27 13:48:19 -0400 | [diff] [blame] | 638 | decode_rename_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 639 | #define NFS4_enc_link_sz (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 640 | encode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 641 | encode_putfh_maxsz + \ |
| 642 | encode_savefh_maxsz + \ |
| 643 | encode_putfh_maxsz + \ |
Trond Myklebust | 91ba2ee | 2005-10-27 22:12:42 -0400 | [diff] [blame] | 644 | encode_link_maxsz + \ |
Trond Myklebust | 91ba2ee | 2005-10-27 22:12:42 -0400 | [diff] [blame] | 645 | encode_restorefh_maxsz + \ |
Trond Myklebust | a9f6991 | 2012-04-27 13:48:17 -0400 | [diff] [blame] | 646 | encode_getattr_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 647 | #define NFS4_dec_link_sz (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 648 | decode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 649 | decode_putfh_maxsz + \ |
| 650 | decode_savefh_maxsz + \ |
| 651 | decode_putfh_maxsz + \ |
Trond Myklebust | 91ba2ee | 2005-10-27 22:12:42 -0400 | [diff] [blame] | 652 | decode_link_maxsz + \ |
Trond Myklebust | 91ba2ee | 2005-10-27 22:12:42 -0400 | [diff] [blame] | 653 | decode_restorefh_maxsz + \ |
| 654 | decode_getattr_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 655 | #define NFS4_enc_symlink_sz (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 656 | encode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 657 | encode_putfh_maxsz + \ |
| 658 | encode_symlink_maxsz + \ |
| 659 | encode_getattr_maxsz + \ |
| 660 | encode_getfh_maxsz) |
| 661 | #define NFS4_dec_symlink_sz (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 662 | decode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 663 | decode_putfh_maxsz + \ |
| 664 | decode_symlink_maxsz + \ |
| 665 | decode_getattr_maxsz + \ |
| 666 | decode_getfh_maxsz) |
| 667 | #define NFS4_enc_create_sz (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 668 | encode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 669 | encode_putfh_maxsz + \ |
| 670 | encode_create_maxsz + \ |
Trond Myklebust | 56ae19f | 2005-10-27 22:12:40 -0400 | [diff] [blame] | 671 | encode_getfh_maxsz + \ |
Trond Myklebust | 56ae19f | 2005-10-27 22:12:40 -0400 | [diff] [blame] | 672 | encode_getattr_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 673 | #define NFS4_dec_create_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_create_maxsz + \ |
Trond Myklebust | 56ae19f | 2005-10-27 22:12:40 -0400 | [diff] [blame] | 677 | decode_getfh_maxsz + \ |
Trond Myklebust | 56ae19f | 2005-10-27 22:12:40 -0400 | [diff] [blame] | 678 | decode_getattr_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 679 | #define NFS4_enc_pathconf_sz (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 680 | encode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 681 | encode_putfh_maxsz + \ |
| 682 | encode_getattr_maxsz) |
| 683 | #define NFS4_dec_pathconf_sz (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 684 | decode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 685 | decode_putfh_maxsz + \ |
| 686 | decode_getattr_maxsz) |
| 687 | #define NFS4_enc_statfs_sz (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 688 | encode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 689 | encode_putfh_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 690 | encode_statfs_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 691 | #define NFS4_dec_statfs_sz (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 692 | decode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 693 | decode_putfh_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 694 | decode_statfs_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 695 | #define NFS4_enc_server_caps_sz (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 696 | encode_sequence_maxsz + \ |
Trond Myklebust | ab91f26 | 2007-02-02 14:47:17 -0800 | [diff] [blame] | 697 | encode_putfh_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 698 | encode_getattr_maxsz) |
| 699 | #define NFS4_dec_server_caps_sz (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 700 | decode_sequence_maxsz + \ |
Trond Myklebust | ab91f26 | 2007-02-02 14:47:17 -0800 | [diff] [blame] | 701 | decode_putfh_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 702 | decode_getattr_maxsz) |
| 703 | #define NFS4_enc_delegreturn_sz (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 704 | encode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 705 | encode_putfh_maxsz + \ |
Trond Myklebust | fa178f2 | 2006-01-03 09:55:38 +0100 | [diff] [blame] | 706 | encode_delegreturn_maxsz + \ |
| 707 | encode_getattr_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 708 | #define NFS4_dec_delegreturn_sz (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 709 | decode_sequence_maxsz + \ |
Trond Myklebust | fa178f2 | 2006-01-03 09:55:38 +0100 | [diff] [blame] | 710 | decode_delegreturn_maxsz + \ |
| 711 | decode_getattr_maxsz) |
J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 712 | #define NFS4_enc_getacl_sz (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 713 | encode_sequence_maxsz + \ |
J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 714 | encode_putfh_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 715 | encode_getacl_maxsz) |
J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 716 | #define NFS4_dec_getacl_sz (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 717 | decode_sequence_maxsz + \ |
J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 718 | decode_putfh_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 719 | decode_getacl_maxsz) |
J. Bruce Fields | 23ec696 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 720 | #define NFS4_enc_setacl_sz (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 721 | encode_sequence_maxsz + \ |
J. Bruce Fields | 23ec696 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 722 | encode_putfh_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 723 | encode_setacl_maxsz) |
J. Bruce Fields | 23ec696 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 724 | #define NFS4_dec_setacl_sz (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 725 | decode_sequence_maxsz + \ |
J. Bruce Fields | 23ec696 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 726 | decode_putfh_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 727 | decode_setacl_maxsz) |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 728 | #define NFS4_enc_fs_locations_sz \ |
| 729 | (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 730 | encode_sequence_maxsz + \ |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 731 | encode_putfh_maxsz + \ |
Trond Myklebust | e688962 | 2007-07-02 13:58:30 -0400 | [diff] [blame] | 732 | encode_lookup_maxsz + \ |
Chuck Lever | b03d735 | 2013-10-17 14:12:50 -0400 | [diff] [blame] | 733 | encode_fs_locations_maxsz + \ |
| 734 | encode_renew_maxsz) |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 735 | #define NFS4_dec_fs_locations_sz \ |
| 736 | (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 737 | decode_sequence_maxsz + \ |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 738 | decode_putfh_maxsz + \ |
Trond Myklebust | e688962 | 2007-07-02 13:58:30 -0400 | [diff] [blame] | 739 | decode_lookup_maxsz + \ |
Chuck Lever | b03d735 | 2013-10-17 14:12:50 -0400 | [diff] [blame] | 740 | decode_fs_locations_maxsz + \ |
| 741 | decode_renew_maxsz) |
Bryan Schumaker | 5a5ea0d | 2011-03-24 17:12:29 +0000 | [diff] [blame] | 742 | #define NFS4_enc_secinfo_sz (compound_encode_hdr_maxsz + \ |
| 743 | encode_sequence_maxsz + \ |
| 744 | encode_putfh_maxsz + \ |
| 745 | encode_secinfo_maxsz) |
| 746 | #define NFS4_dec_secinfo_sz (compound_decode_hdr_maxsz + \ |
| 747 | decode_sequence_maxsz + \ |
| 748 | decode_putfh_maxsz + \ |
| 749 | decode_secinfo_maxsz) |
Chuck Lever | 44c9993 | 2013-10-17 14:13:30 -0400 | [diff] [blame] | 750 | #define NFS4_enc_fsid_present_sz \ |
| 751 | (compound_encode_hdr_maxsz + \ |
| 752 | encode_sequence_maxsz + \ |
| 753 | encode_putfh_maxsz + \ |
| 754 | encode_getfh_maxsz + \ |
| 755 | encode_renew_maxsz) |
| 756 | #define NFS4_dec_fsid_present_sz \ |
| 757 | (compound_decode_hdr_maxsz + \ |
| 758 | decode_sequence_maxsz + \ |
| 759 | decode_putfh_maxsz + \ |
| 760 | decode_getfh_maxsz + \ |
| 761 | decode_renew_maxsz) |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 762 | #if defined(CONFIG_NFS_V4_1) |
Weston Andros Adamson | 7c44f1ae | 2012-05-24 13:22:50 -0400 | [diff] [blame] | 763 | #define NFS4_enc_bind_conn_to_session_sz \ |
| 764 | (compound_encode_hdr_maxsz + \ |
| 765 | encode_bind_conn_to_session_maxsz) |
| 766 | #define NFS4_dec_bind_conn_to_session_sz \ |
| 767 | (compound_decode_hdr_maxsz + \ |
| 768 | decode_bind_conn_to_session_maxsz) |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 769 | #define NFS4_enc_exchange_id_sz \ |
| 770 | (compound_encode_hdr_maxsz + \ |
| 771 | encode_exchange_id_maxsz) |
| 772 | #define NFS4_dec_exchange_id_sz \ |
| 773 | (compound_decode_hdr_maxsz + \ |
| 774 | decode_exchange_id_maxsz) |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 775 | #define NFS4_enc_create_session_sz \ |
| 776 | (compound_encode_hdr_maxsz + \ |
| 777 | encode_create_session_maxsz) |
| 778 | #define NFS4_dec_create_session_sz \ |
| 779 | (compound_decode_hdr_maxsz + \ |
| 780 | decode_create_session_maxsz) |
Andy Adamson | 0f3e66c | 2009-04-01 09:22:34 -0400 | [diff] [blame] | 781 | #define NFS4_enc_destroy_session_sz (compound_encode_hdr_maxsz + \ |
| 782 | encode_destroy_session_maxsz) |
| 783 | #define NFS4_dec_destroy_session_sz (compound_decode_hdr_maxsz + \ |
| 784 | decode_destroy_session_maxsz) |
Trond Myklebust | 6624553 | 2012-05-25 17:18:09 -0400 | [diff] [blame] | 785 | #define NFS4_enc_destroy_clientid_sz (compound_encode_hdr_maxsz + \ |
| 786 | encode_destroy_clientid_maxsz) |
| 787 | #define NFS4_dec_destroy_clientid_sz (compound_decode_hdr_maxsz + \ |
| 788 | decode_destroy_clientid_maxsz) |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 789 | #define NFS4_enc_sequence_sz \ |
| 790 | (compound_decode_hdr_maxsz + \ |
| 791 | encode_sequence_maxsz) |
| 792 | #define NFS4_dec_sequence_sz \ |
| 793 | (compound_decode_hdr_maxsz + \ |
| 794 | decode_sequence_maxsz) |
Andy Adamson | 2050f0c | 2009-04-01 09:22:30 -0400 | [diff] [blame] | 795 | #define NFS4_enc_get_lease_time_sz (compound_encode_hdr_maxsz + \ |
| 796 | encode_sequence_maxsz + \ |
| 797 | encode_putrootfh_maxsz + \ |
| 798 | encode_fsinfo_maxsz) |
| 799 | #define NFS4_dec_get_lease_time_sz (compound_decode_hdr_maxsz + \ |
| 800 | decode_sequence_maxsz + \ |
| 801 | decode_putrootfh_maxsz + \ |
| 802 | decode_fsinfo_maxsz) |
Ricardo Labiaga | 18019753 | 2009-12-05 16:08:40 -0500 | [diff] [blame] | 803 | #define NFS4_enc_reclaim_complete_sz (compound_encode_hdr_maxsz + \ |
| 804 | encode_sequence_maxsz + \ |
| 805 | encode_reclaim_complete_maxsz) |
| 806 | #define NFS4_dec_reclaim_complete_sz (compound_decode_hdr_maxsz + \ |
| 807 | decode_sequence_maxsz + \ |
| 808 | decode_reclaim_complete_maxsz) |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 809 | #define NFS4_enc_getdeviceinfo_sz (compound_encode_hdr_maxsz + \ |
| 810 | encode_sequence_maxsz +\ |
| 811 | encode_getdeviceinfo_maxsz) |
| 812 | #define NFS4_dec_getdeviceinfo_sz (compound_decode_hdr_maxsz + \ |
| 813 | decode_sequence_maxsz + \ |
| 814 | decode_getdeviceinfo_maxsz) |
| 815 | #define NFS4_enc_layoutget_sz (compound_encode_hdr_maxsz + \ |
| 816 | encode_sequence_maxsz + \ |
| 817 | encode_putfh_maxsz + \ |
| 818 | encode_layoutget_maxsz) |
| 819 | #define NFS4_dec_layoutget_sz (compound_decode_hdr_maxsz + \ |
| 820 | decode_sequence_maxsz + \ |
| 821 | decode_putfh_maxsz + \ |
| 822 | decode_layoutget_maxsz) |
Andy Adamson | 863a3c6 | 2011-03-23 13:27:54 +0000 | [diff] [blame] | 823 | #define NFS4_enc_layoutcommit_sz (compound_encode_hdr_maxsz + \ |
| 824 | encode_sequence_maxsz +\ |
| 825 | encode_putfh_maxsz + \ |
| 826 | encode_layoutcommit_maxsz + \ |
| 827 | encode_getattr_maxsz) |
| 828 | #define NFS4_dec_layoutcommit_sz (compound_decode_hdr_maxsz + \ |
| 829 | decode_sequence_maxsz + \ |
| 830 | decode_putfh_maxsz + \ |
| 831 | decode_layoutcommit_maxsz + \ |
| 832 | decode_getattr_maxsz) |
Benny Halevy | cbe8260 | 2011-05-22 19:52:37 +0300 | [diff] [blame] | 833 | #define NFS4_enc_layoutreturn_sz (compound_encode_hdr_maxsz + \ |
| 834 | encode_sequence_maxsz + \ |
| 835 | encode_putfh_maxsz + \ |
| 836 | encode_layoutreturn_maxsz) |
| 837 | #define NFS4_dec_layoutreturn_sz (compound_decode_hdr_maxsz + \ |
| 838 | decode_sequence_maxsz + \ |
| 839 | decode_putfh_maxsz + \ |
| 840 | decode_layoutreturn_maxsz) |
Bryan Schumaker | fca78d6 | 2011-06-02 14:59:07 -0400 | [diff] [blame] | 841 | #define NFS4_enc_secinfo_no_name_sz (compound_encode_hdr_maxsz + \ |
| 842 | encode_sequence_maxsz + \ |
| 843 | encode_putrootfh_maxsz +\ |
| 844 | encode_secinfo_no_name_maxsz) |
| 845 | #define NFS4_dec_secinfo_no_name_sz (compound_decode_hdr_maxsz + \ |
| 846 | decode_sequence_maxsz + \ |
| 847 | decode_putrootfh_maxsz + \ |
| 848 | decode_secinfo_no_name_maxsz) |
Bryan Schumaker | 7d97479 | 2011-06-02 14:59:08 -0400 | [diff] [blame] | 849 | #define NFS4_enc_test_stateid_sz (compound_encode_hdr_maxsz + \ |
| 850 | encode_sequence_maxsz + \ |
| 851 | encode_test_stateid_maxsz) |
| 852 | #define NFS4_dec_test_stateid_sz (compound_decode_hdr_maxsz + \ |
| 853 | decode_sequence_maxsz + \ |
| 854 | decode_test_stateid_maxsz) |
Bryan Schumaker | 9aeda35 | 2011-06-02 14:59:09 -0400 | [diff] [blame] | 855 | #define NFS4_enc_free_stateid_sz (compound_encode_hdr_maxsz + \ |
| 856 | encode_sequence_maxsz + \ |
| 857 | encode_free_stateid_maxsz) |
| 858 | #define NFS4_dec_free_stateid_sz (compound_decode_hdr_maxsz + \ |
| 859 | decode_sequence_maxsz + \ |
| 860 | decode_free_stateid_maxsz) |
Alexandros Batsakis | 2449ea2 | 2009-12-05 13:36:55 -0500 | [diff] [blame] | 861 | |
| 862 | const u32 nfs41_maxwrite_overhead = ((RPC_MAX_HEADER_WITH_AUTH + |
| 863 | compound_encode_hdr_maxsz + |
| 864 | encode_sequence_maxsz + |
| 865 | encode_putfh_maxsz + |
| 866 | encode_getattr_maxsz) * |
| 867 | XDR_UNIT); |
| 868 | |
| 869 | const u32 nfs41_maxread_overhead = ((RPC_MAX_HEADER_WITH_AUTH + |
| 870 | compound_decode_hdr_maxsz + |
| 871 | decode_sequence_maxsz + |
| 872 | decode_putfh_maxsz) * |
| 873 | XDR_UNIT); |
Andy Adamson | f1c097b | 2013-06-25 19:02:53 -0400 | [diff] [blame] | 874 | |
| 875 | const u32 nfs41_maxgetdevinfo_overhead = ((RPC_MAX_REPHEADER_WITH_AUTH + |
| 876 | compound_decode_hdr_maxsz + |
| 877 | decode_sequence_maxsz) * |
| 878 | XDR_UNIT); |
| 879 | EXPORT_SYMBOL_GPL(nfs41_maxgetdevinfo_overhead); |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 880 | #endif /* CONFIG_NFS_V4_1 */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 881 | |
Trond Myklebust | bca7947 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 882 | static const umode_t nfs_type2fmt[] = { |
| 883 | [NF4BAD] = 0, |
| 884 | [NF4REG] = S_IFREG, |
| 885 | [NF4DIR] = S_IFDIR, |
| 886 | [NF4BLK] = S_IFBLK, |
| 887 | [NF4CHR] = S_IFCHR, |
| 888 | [NF4LNK] = S_IFLNK, |
| 889 | [NF4SOCK] = S_IFSOCK, |
| 890 | [NF4FIFO] = S_IFIFO, |
| 891 | [NF4ATTRDIR] = 0, |
| 892 | [NF4NAMEDATTR] = 0, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 893 | }; |
| 894 | |
| 895 | struct compound_hdr { |
| 896 | int32_t status; |
| 897 | uint32_t nops; |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 898 | __be32 * nops_p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 899 | uint32_t taglen; |
| 900 | char * tag; |
Benny Halevy | 0c4e8c1 | 2009-04-01 09:22:07 -0400 | [diff] [blame] | 901 | uint32_t replen; /* expected reply words */ |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 902 | u32 minorversion; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 903 | }; |
| 904 | |
Benny Halevy | 13c65ce | 2009-08-14 17:19:25 +0300 | [diff] [blame] | 905 | static __be32 *reserve_space(struct xdr_stream *xdr, size_t nbytes) |
| 906 | { |
| 907 | __be32 *p = xdr_reserve_space(xdr, nbytes); |
| 908 | BUG_ON(!p); |
| 909 | return p; |
| 910 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 911 | |
Trond Myklebust | cb17e55 | 2012-03-04 18:13:56 -0500 | [diff] [blame] | 912 | static void encode_opaque_fixed(struct xdr_stream *xdr, const void *buf, size_t len) |
| 913 | { |
| 914 | __be32 *p; |
| 915 | |
| 916 | p = xdr_reserve_space(xdr, len); |
| 917 | xdr_encode_opaque_fixed(p, buf, len); |
| 918 | } |
| 919 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 920 | static void encode_string(struct xdr_stream *xdr, unsigned int len, const char *str) |
| 921 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 922 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 923 | |
Trond Myklebust | 6fdfb0bc | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 924 | p = reserve_space(xdr, 4 + len); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 925 | xdr_encode_opaque(p, str, len); |
| 926 | } |
| 927 | |
Trond Myklebust | 4ade982 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 928 | static void encode_uint32(struct xdr_stream *xdr, u32 n) |
| 929 | { |
| 930 | __be32 *p; |
| 931 | |
| 932 | p = reserve_space(xdr, 4); |
| 933 | *p = cpu_to_be32(n); |
| 934 | } |
| 935 | |
Trond Myklebust | ff2eb68 | 2012-03-05 11:40:12 -0500 | [diff] [blame] | 936 | static void encode_uint64(struct xdr_stream *xdr, u64 n) |
| 937 | { |
| 938 | __be32 *p; |
| 939 | |
| 940 | p = reserve_space(xdr, 8); |
| 941 | xdr_encode_hyper(p, n); |
| 942 | } |
| 943 | |
Trond Myklebust | 4ade982 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 944 | static void encode_nfs4_seqid(struct xdr_stream *xdr, |
| 945 | const struct nfs_seqid *seqid) |
| 946 | { |
| 947 | encode_uint32(xdr, seqid->sequence->counter); |
| 948 | } |
| 949 | |
Benny Halevy | 0c4e8c1 | 2009-04-01 09:22:07 -0400 | [diff] [blame] | 950 | static void encode_compound_hdr(struct xdr_stream *xdr, |
| 951 | struct rpc_rqst *req, |
| 952 | struct compound_hdr *hdr) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 953 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 954 | __be32 *p; |
Trond Myklebust | a17c215 | 2010-07-31 14:29:08 -0400 | [diff] [blame] | 955 | struct rpc_auth *auth = req->rq_cred->cr_auth; |
Benny Halevy | 0c4e8c1 | 2009-04-01 09:22:07 -0400 | [diff] [blame] | 956 | |
| 957 | /* initialize running count of expected bytes in reply. |
| 958 | * NOTE: the replied tag SHOULD be the same is the one sent, |
| 959 | * but this is not required as a MUST for the server to do so. */ |
| 960 | hdr->replen = RPC_REPHDRSIZE + auth->au_rslack + 3 + hdr->taglen; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 961 | |
Trond Myklebust | 7fc3884 | 2012-10-15 11:51:21 -0400 | [diff] [blame] | 962 | WARN_ON_ONCE(hdr->taglen > NFS4_MAXTAGLEN); |
Trond Myklebust | 6fdfb0bc | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 963 | encode_string(xdr, hdr->taglen, hdr->tag); |
| 964 | p = reserve_space(xdr, 8); |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 965 | *p++ = cpu_to_be32(hdr->minorversion); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 966 | hdr->nops_p = p; |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 967 | *p = cpu_to_be32(hdr->nops); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 968 | } |
| 969 | |
Trond Myklebust | ab19b48 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 970 | static void encode_op_hdr(struct xdr_stream *xdr, enum nfs_opnum4 op, |
| 971 | uint32_t replen, |
| 972 | struct compound_hdr *hdr) |
| 973 | { |
| 974 | encode_uint32(xdr, op); |
| 975 | hdr->nops++; |
| 976 | hdr->replen += replen; |
| 977 | } |
| 978 | |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 979 | static void encode_nops(struct compound_hdr *hdr) |
| 980 | { |
Trond Myklebust | 7fc3884 | 2012-10-15 11:51:21 -0400 | [diff] [blame] | 981 | WARN_ON_ONCE(hdr->nops > NFS4_MAX_OPS); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 982 | *hdr->nops_p = htonl(hdr->nops); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 983 | } |
| 984 | |
Trond Myklebust | ea9d23f | 2012-03-04 18:13:56 -0500 | [diff] [blame] | 985 | static void encode_nfs4_stateid(struct xdr_stream *xdr, const nfs4_stateid *stateid) |
| 986 | { |
Trond Myklebust | 2d2f24a | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 987 | encode_opaque_fixed(xdr, stateid, NFS4_STATEID_SIZE); |
Trond Myklebust | ea9d23f | 2012-03-04 18:13:56 -0500 | [diff] [blame] | 988 | } |
| 989 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 990 | static void encode_nfs4_verifier(struct xdr_stream *xdr, const nfs4_verifier *verf) |
| 991 | { |
Trond Myklebust | cb17e55 | 2012-03-04 18:13:56 -0500 | [diff] [blame] | 992 | encode_opaque_fixed(xdr, verf->data, NFS4_VERIFIER_SIZE); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 993 | } |
| 994 | |
David Quigley | aa9c266 | 2013-05-22 12:50:44 -0400 | [diff] [blame] | 995 | static void encode_attrs(struct xdr_stream *xdr, const struct iattr *iap, |
| 996 | const struct nfs4_label *label, |
| 997 | const struct nfs_server *server) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 998 | { |
| 999 | char owner_name[IDMAP_NAMESZ]; |
| 1000 | char owner_group[IDMAP_NAMESZ]; |
| 1001 | int owner_namelen = 0; |
| 1002 | int owner_grouplen = 0; |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 1003 | __be32 *p; |
Trond Myklebust | d7067b2 | 2013-07-17 17:09:01 -0400 | [diff] [blame] | 1004 | unsigned i; |
| 1005 | uint32_t len = 0; |
| 1006 | uint32_t bmval_len; |
| 1007 | uint32_t bmval[3] = { 0 }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1008 | |
| 1009 | /* |
| 1010 | * We reserve enough space to write the entire attribute buffer at once. |
| 1011 | * In the worst-case, this would be |
David Quigley | a09df2c | 2013-05-22 12:50:41 -0400 | [diff] [blame] | 1012 | * 16(bitmap) + 4(attrlen) + 8(size) + 4(mode) + 4(atime) + 4(mtime) |
| 1013 | * = 40 bytes, plus any contribution from variable-length fields |
J. Bruce Fields | 23ec696 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 1014 | * such as owner/group. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1015 | */ |
Trond Myklebust | d7067b2 | 2013-07-17 17:09:01 -0400 | [diff] [blame] | 1016 | if (iap->ia_valid & ATTR_SIZE) { |
| 1017 | bmval[0] |= FATTR4_WORD0_SIZE; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1018 | len += 8; |
Trond Myklebust | d7067b2 | 2013-07-17 17:09:01 -0400 | [diff] [blame] | 1019 | } |
| 1020 | if (iap->ia_valid & ATTR_MODE) { |
| 1021 | bmval[1] |= FATTR4_WORD1_MODE; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1022 | len += 4; |
Trond Myklebust | d7067b2 | 2013-07-17 17:09:01 -0400 | [diff] [blame] | 1023 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1024 | if (iap->ia_valid & ATTR_UID) { |
Trond Myklebust | e4fd72a | 2011-02-22 15:44:31 -0800 | [diff] [blame] | 1025 | 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] | 1026 | if (owner_namelen < 0) { |
Chuck Lever | fe82a18 | 2007-09-11 18:01:10 -0400 | [diff] [blame] | 1027 | dprintk("nfs: couldn't resolve uid %d to string\n", |
Eric W. Biederman | e578207 | 2013-02-01 14:22:02 -0800 | [diff] [blame] | 1028 | from_kuid(&init_user_ns, iap->ia_uid)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1029 | /* XXX */ |
| 1030 | strcpy(owner_name, "nobody"); |
| 1031 | owner_namelen = sizeof("nobody") - 1; |
| 1032 | /* goto out; */ |
| 1033 | } |
Trond Myklebust | d7067b2 | 2013-07-17 17:09:01 -0400 | [diff] [blame] | 1034 | bmval[1] |= FATTR4_WORD1_OWNER; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1035 | len += 4 + (XDR_QUADLEN(owner_namelen) << 2); |
| 1036 | } |
| 1037 | if (iap->ia_valid & ATTR_GID) { |
Trond Myklebust | e4fd72a | 2011-02-22 15:44:31 -0800 | [diff] [blame] | 1038 | 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] | 1039 | if (owner_grouplen < 0) { |
Chuck Lever | fe82a18 | 2007-09-11 18:01:10 -0400 | [diff] [blame] | 1040 | dprintk("nfs: couldn't resolve gid %d to string\n", |
Eric W. Biederman | e578207 | 2013-02-01 14:22:02 -0800 | [diff] [blame] | 1041 | from_kgid(&init_user_ns, iap->ia_gid)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1042 | strcpy(owner_group, "nobody"); |
| 1043 | owner_grouplen = sizeof("nobody") - 1; |
| 1044 | /* goto out; */ |
| 1045 | } |
Trond Myklebust | d7067b2 | 2013-07-17 17:09:01 -0400 | [diff] [blame] | 1046 | bmval[1] |= FATTR4_WORD1_OWNER_GROUP; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1047 | len += 4 + (XDR_QUADLEN(owner_grouplen) << 2); |
| 1048 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1049 | if (iap->ia_valid & ATTR_ATIME_SET) { |
Trond Myklebust | d7067b2 | 2013-07-17 17:09:01 -0400 | [diff] [blame] | 1050 | bmval[1] |= FATTR4_WORD1_TIME_ACCESS_SET; |
| 1051 | len += 16; |
| 1052 | } else if (iap->ia_valid & ATTR_ATIME) { |
| 1053 | bmval[1] |= FATTR4_WORD1_TIME_ACCESS_SET; |
| 1054 | len += 4; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1055 | } |
| 1056 | if (iap->ia_valid & ATTR_MTIME_SET) { |
Trond Myklebust | d7067b2 | 2013-07-17 17:09:01 -0400 | [diff] [blame] | 1057 | bmval[1] |= FATTR4_WORD1_TIME_MODIFY_SET; |
| 1058 | len += 16; |
| 1059 | } else if (iap->ia_valid & ATTR_MTIME) { |
| 1060 | bmval[1] |= FATTR4_WORD1_TIME_MODIFY_SET; |
| 1061 | len += 4; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1062 | } |
David Quigley | aa9c266 | 2013-05-22 12:50:44 -0400 | [diff] [blame] | 1063 | if (label) { |
Trond Myklebust | d7067b2 | 2013-07-17 17:09:01 -0400 | [diff] [blame] | 1064 | len += 4 + 4 + 4 + (XDR_QUADLEN(label->len) << 2); |
| 1065 | bmval[2] |= FATTR4_WORD2_SECURITY_LABEL; |
| 1066 | } |
| 1067 | |
| 1068 | if (bmval[2] != 0) |
| 1069 | bmval_len = 3; |
| 1070 | else if (bmval[1] != 0) |
| 1071 | bmval_len = 2; |
| 1072 | else |
| 1073 | bmval_len = 1; |
| 1074 | |
| 1075 | p = reserve_space(xdr, 4 + (bmval_len << 2) + 4 + len); |
| 1076 | |
| 1077 | *p++ = cpu_to_be32(bmval_len); |
| 1078 | for (i = 0; i < bmval_len; i++) |
| 1079 | *p++ = cpu_to_be32(bmval[i]); |
| 1080 | *p++ = cpu_to_be32(len); |
| 1081 | |
| 1082 | if (bmval[0] & FATTR4_WORD0_SIZE) |
| 1083 | p = xdr_encode_hyper(p, iap->ia_size); |
| 1084 | if (bmval[1] & FATTR4_WORD1_MODE) |
| 1085 | *p++ = cpu_to_be32(iap->ia_mode & S_IALLUGO); |
| 1086 | if (bmval[1] & FATTR4_WORD1_OWNER) |
| 1087 | p = xdr_encode_opaque(p, owner_name, owner_namelen); |
| 1088 | if (bmval[1] & FATTR4_WORD1_OWNER_GROUP) |
| 1089 | p = xdr_encode_opaque(p, owner_group, owner_grouplen); |
| 1090 | if (bmval[1] & FATTR4_WORD1_TIME_ACCESS_SET) { |
| 1091 | if (iap->ia_valid & ATTR_ATIME_SET) { |
| 1092 | *p++ = cpu_to_be32(NFS4_SET_TO_CLIENT_TIME); |
| 1093 | p = xdr_encode_hyper(p, (s64)iap->ia_atime.tv_sec); |
| 1094 | *p++ = cpu_to_be32(iap->ia_atime.tv_nsec); |
| 1095 | } else |
| 1096 | *p++ = cpu_to_be32(NFS4_SET_TO_SERVER_TIME); |
| 1097 | } |
| 1098 | if (bmval[1] & FATTR4_WORD1_TIME_MODIFY_SET) { |
| 1099 | if (iap->ia_valid & ATTR_MTIME_SET) { |
| 1100 | *p++ = cpu_to_be32(NFS4_SET_TO_CLIENT_TIME); |
| 1101 | p = xdr_encode_hyper(p, (s64)iap->ia_mtime.tv_sec); |
| 1102 | *p++ = cpu_to_be32(iap->ia_mtime.tv_nsec); |
| 1103 | } else |
| 1104 | *p++ = cpu_to_be32(NFS4_SET_TO_SERVER_TIME); |
| 1105 | } |
| 1106 | if (bmval[2] & FATTR4_WORD2_SECURITY_LABEL) { |
David Quigley | aa9c266 | 2013-05-22 12:50:44 -0400 | [diff] [blame] | 1107 | *p++ = cpu_to_be32(label->lfs); |
| 1108 | *p++ = cpu_to_be32(label->pi); |
| 1109 | *p++ = cpu_to_be32(label->len); |
| 1110 | p = xdr_encode_opaque_fixed(p, label->label, label->len); |
| 1111 | } |
Andy Adamson | 6c0195a | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 1112 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1113 | /* out: */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1114 | } |
| 1115 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1116 | 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] | 1117 | { |
Trond Myklebust | 475d4ba | 2012-03-05 11:27:16 -0500 | [diff] [blame] | 1118 | encode_op_hdr(xdr, OP_ACCESS, decode_access_maxsz, hdr); |
| 1119 | encode_uint32(xdr, access); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1120 | } |
| 1121 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1122 | 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] | 1123 | { |
Trond Myklebust | ab19b48 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1124 | encode_op_hdr(xdr, OP_CLOSE, decode_close_maxsz, hdr); |
Trond Myklebust | 4ade982 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1125 | encode_nfs4_seqid(xdr, arg->seqid); |
Trond Myklebust | ea9d23f | 2012-03-04 18:13:56 -0500 | [diff] [blame] | 1126 | encode_nfs4_stateid(xdr, arg->stateid); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1127 | } |
| 1128 | |
Fred Isaman | 0b7c015 | 2012-04-20 14:47:39 -0400 | [diff] [blame] | 1129 | 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] | 1130 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 1131 | __be32 *p; |
Andy Adamson | 6c0195a | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 1132 | |
Trond Myklebust | 475d4ba | 2012-03-05 11:27:16 -0500 | [diff] [blame] | 1133 | encode_op_hdr(xdr, OP_COMMIT, decode_commit_maxsz, hdr); |
| 1134 | p = reserve_space(xdr, 12); |
Benny Halevy | b95be5a | 2009-08-14 17:19:01 +0300 | [diff] [blame] | 1135 | p = xdr_encode_hyper(p, args->offset); |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1136 | *p = cpu_to_be32(args->count); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1137 | } |
| 1138 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1139 | 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] | 1140 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 1141 | __be32 *p; |
Andy Adamson | 6c0195a | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 1142 | |
Trond Myklebust | 475d4ba | 2012-03-05 11:27:16 -0500 | [diff] [blame] | 1143 | encode_op_hdr(xdr, OP_CREATE, decode_create_maxsz, hdr); |
| 1144 | encode_uint32(xdr, create->ftype); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1145 | |
| 1146 | switch (create->ftype) { |
| 1147 | case NF4LNK: |
Benny Halevy | 13c65ce | 2009-08-14 17:19:25 +0300 | [diff] [blame] | 1148 | p = reserve_space(xdr, 4); |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1149 | *p = cpu_to_be32(create->u.symlink.len); |
Chuck Lever | 94a6d75 | 2006-08-22 20:06:23 -0400 | [diff] [blame] | 1150 | xdr_write_pages(xdr, create->u.symlink.pages, 0, create->u.symlink.len); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1151 | break; |
| 1152 | |
| 1153 | case NF4BLK: case NF4CHR: |
Benny Halevy | 13c65ce | 2009-08-14 17:19:25 +0300 | [diff] [blame] | 1154 | p = reserve_space(xdr, 8); |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1155 | *p++ = cpu_to_be32(create->u.device.specdata1); |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1156 | *p = cpu_to_be32(create->u.device.specdata2); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1157 | break; |
| 1158 | |
| 1159 | default: |
| 1160 | break; |
| 1161 | } |
| 1162 | |
Benny Halevy | 811652b | 2009-08-14 17:19:34 +0300 | [diff] [blame] | 1163 | encode_string(xdr, create->name->len, create->name->name); |
David Quigley | aa9c266 | 2013-05-22 12:50:44 -0400 | [diff] [blame] | 1164 | encode_attrs(xdr, create->attrs, create->label, create->server); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1165 | } |
| 1166 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1167 | 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] | 1168 | { |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 1169 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1170 | |
Trond Myklebust | 475d4ba | 2012-03-05 11:27:16 -0500 | [diff] [blame] | 1171 | encode_op_hdr(xdr, OP_GETATTR, decode_getattr_maxsz, hdr); |
| 1172 | p = reserve_space(xdr, 8); |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1173 | *p++ = cpu_to_be32(1); |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1174 | *p = cpu_to_be32(bitmap); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1175 | } |
| 1176 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1177 | 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] | 1178 | { |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 1179 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1180 | |
Trond Myklebust | 475d4ba | 2012-03-05 11:27:16 -0500 | [diff] [blame] | 1181 | encode_op_hdr(xdr, OP_GETATTR, decode_getattr_maxsz, hdr); |
| 1182 | p = reserve_space(xdr, 12); |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1183 | *p++ = cpu_to_be32(2); |
| 1184 | *p++ = cpu_to_be32(bm0); |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1185 | *p = cpu_to_be32(bm1); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1186 | } |
| 1187 | |
Fred Isaman | dae100c | 2011-07-30 20:52:37 -0400 | [diff] [blame] | 1188 | static void |
| 1189 | encode_getattr_three(struct xdr_stream *xdr, |
| 1190 | uint32_t bm0, uint32_t bm1, uint32_t bm2, |
| 1191 | struct compound_hdr *hdr) |
| 1192 | { |
| 1193 | __be32 *p; |
| 1194 | |
Trond Myklebust | ab19b48 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1195 | encode_op_hdr(xdr, OP_GETATTR, decode_getattr_maxsz, hdr); |
Fred Isaman | dae100c | 2011-07-30 20:52:37 -0400 | [diff] [blame] | 1196 | if (bm2) { |
| 1197 | p = reserve_space(xdr, 16); |
| 1198 | *p++ = cpu_to_be32(3); |
| 1199 | *p++ = cpu_to_be32(bm0); |
| 1200 | *p++ = cpu_to_be32(bm1); |
| 1201 | *p = cpu_to_be32(bm2); |
| 1202 | } else if (bm1) { |
| 1203 | p = reserve_space(xdr, 12); |
| 1204 | *p++ = cpu_to_be32(2); |
| 1205 | *p++ = cpu_to_be32(bm0); |
| 1206 | *p = cpu_to_be32(bm1); |
| 1207 | } else { |
| 1208 | p = reserve_space(xdr, 8); |
| 1209 | *p++ = cpu_to_be32(1); |
| 1210 | *p = cpu_to_be32(bm0); |
| 1211 | } |
Fred Isaman | dae100c | 2011-07-30 20:52:37 -0400 | [diff] [blame] | 1212 | } |
| 1213 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1214 | 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] | 1215 | { |
David Quigley | a09df2c | 2013-05-22 12:50:41 -0400 | [diff] [blame] | 1216 | encode_getattr_three(xdr, bitmask[0] & nfs4_fattr_bitmap[0], |
| 1217 | bitmask[1] & nfs4_fattr_bitmap[1], |
| 1218 | bitmask[2] & nfs4_fattr_bitmap[2], |
| 1219 | hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1220 | } |
| 1221 | |
Andy Adamson | 88034c3 | 2012-05-23 05:02:34 -0400 | [diff] [blame] | 1222 | static void encode_getfattr_open(struct xdr_stream *xdr, const u32 *bitmask, |
Trond Myklebust | 1549210f | 2012-06-05 09:16:47 -0400 | [diff] [blame] | 1223 | const u32 *open_bitmap, |
Andy Adamson | 88034c3 | 2012-05-23 05:02:34 -0400 | [diff] [blame] | 1224 | struct compound_hdr *hdr) |
| 1225 | { |
| 1226 | encode_getattr_three(xdr, |
Trond Myklebust | 1549210f | 2012-06-05 09:16:47 -0400 | [diff] [blame] | 1227 | bitmask[0] & open_bitmap[0], |
| 1228 | bitmask[1] & open_bitmap[1], |
| 1229 | bitmask[2] & open_bitmap[2], |
Andy Adamson | 88034c3 | 2012-05-23 05:02:34 -0400 | [diff] [blame] | 1230 | hdr); |
| 1231 | } |
| 1232 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1233 | 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] | 1234 | { |
Fred Isaman | dae100c | 2011-07-30 20:52:37 -0400 | [diff] [blame] | 1235 | encode_getattr_three(xdr, |
| 1236 | bitmask[0] & nfs4_fsinfo_bitmap[0], |
| 1237 | bitmask[1] & nfs4_fsinfo_bitmap[1], |
| 1238 | bitmask[2] & nfs4_fsinfo_bitmap[2], |
| 1239 | hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1240 | } |
| 1241 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1242 | 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] | 1243 | { |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1244 | encode_getattr_two(xdr, bitmask[0] & nfs4_fs_locations_bitmap[0], |
| 1245 | bitmask[1] & nfs4_fs_locations_bitmap[1], hdr); |
Manoj Naik | 830b8e3 | 2006-06-09 09:34:25 -0400 | [diff] [blame] | 1246 | } |
| 1247 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1248 | static void encode_getfh(struct xdr_stream *xdr, struct compound_hdr *hdr) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1249 | { |
Trond Myklebust | ab19b48 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1250 | encode_op_hdr(xdr, OP_GETFH, decode_getfh_maxsz, hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1251 | } |
| 1252 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1253 | 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] | 1254 | { |
Trond Myklebust | ab19b48 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1255 | encode_op_hdr(xdr, OP_LINK, decode_link_maxsz, hdr); |
Trond Myklebust | 6fdfb0bc | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1256 | encode_string(xdr, name->len, name->name); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1257 | } |
| 1258 | |
Trond Myklebust | 911d1aa | 2006-01-03 09:55:16 +0100 | [diff] [blame] | 1259 | static inline int nfs4_lock_type(struct file_lock *fl, int block) |
| 1260 | { |
Jeff Layton | f44106e | 2012-07-23 15:49:56 -0400 | [diff] [blame] | 1261 | if (fl->fl_type == F_RDLCK) |
Trond Myklebust | 911d1aa | 2006-01-03 09:55:16 +0100 | [diff] [blame] | 1262 | return block ? NFS4_READW_LT : NFS4_READ_LT; |
| 1263 | return block ? NFS4_WRITEW_LT : NFS4_WRITE_LT; |
| 1264 | } |
| 1265 | |
| 1266 | static inline uint64_t nfs4_lock_length(struct file_lock *fl) |
| 1267 | { |
| 1268 | if (fl->fl_end == OFFSET_MAX) |
| 1269 | return ~(uint64_t)0; |
| 1270 | return fl->fl_end - fl->fl_start + 1; |
| 1271 | } |
| 1272 | |
Trond Myklebust | daccbde | 2010-06-25 18:11:43 -0400 | [diff] [blame] | 1273 | static void encode_lockowner(struct xdr_stream *xdr, const struct nfs_lowner *lowner) |
| 1274 | { |
| 1275 | __be32 *p; |
| 1276 | |
Trond Myklebust | d035c36 | 2010-12-21 10:45:27 -0500 | [diff] [blame] | 1277 | p = reserve_space(xdr, 32); |
Trond Myklebust | daccbde | 2010-06-25 18:11:43 -0400 | [diff] [blame] | 1278 | p = xdr_encode_hyper(p, lowner->clientid); |
Trond Myklebust | d035c36 | 2010-12-21 10:45:27 -0500 | [diff] [blame] | 1279 | *p++ = cpu_to_be32(20); |
Trond Myklebust | daccbde | 2010-06-25 18:11:43 -0400 | [diff] [blame] | 1280 | p = xdr_encode_opaque_fixed(p, "lock id:", 8); |
Trond Myklebust | d035c36 | 2010-12-21 10:45:27 -0500 | [diff] [blame] | 1281 | *p++ = cpu_to_be32(lowner->s_dev); |
Trond Myklebust | daccbde | 2010-06-25 18:11:43 -0400 | [diff] [blame] | 1282 | xdr_encode_hyper(p, lowner->id); |
| 1283 | } |
| 1284 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1285 | /* |
| 1286 | * opcode,type,reclaim,offset,length,new_lock_owner = 32 |
| 1287 | * open_seqid,open_stateid,lock_seqid,lock_owner.clientid, lock_owner.id = 40 |
| 1288 | */ |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1289 | 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] | 1290 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 1291 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1292 | |
Trond Myklebust | 475d4ba | 2012-03-05 11:27:16 -0500 | [diff] [blame] | 1293 | encode_op_hdr(xdr, OP_LOCK, decode_lock_maxsz, hdr); |
| 1294 | p = reserve_space(xdr, 28); |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1295 | *p++ = cpu_to_be32(nfs4_lock_type(args->fl, args->block)); |
| 1296 | *p++ = cpu_to_be32(args->reclaim); |
Benny Halevy | b95be5a | 2009-08-14 17:19:01 +0300 | [diff] [blame] | 1297 | p = xdr_encode_hyper(p, args->fl->fl_start); |
| 1298 | p = xdr_encode_hyper(p, nfs4_lock_length(args->fl)); |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1299 | *p = cpu_to_be32(args->new_lock_owner); |
Trond Myklebust | 911d1aa | 2006-01-03 09:55:16 +0100 | [diff] [blame] | 1300 | if (args->new_lock_owner){ |
Trond Myklebust | 4ade982 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1301 | encode_nfs4_seqid(xdr, args->open_seqid); |
Trond Myklebust | ea9d23f | 2012-03-04 18:13:56 -0500 | [diff] [blame] | 1302 | encode_nfs4_stateid(xdr, args->open_stateid); |
Trond Myklebust | 4ade982 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1303 | encode_nfs4_seqid(xdr, args->lock_seqid); |
Trond Myklebust | daccbde | 2010-06-25 18:11:43 -0400 | [diff] [blame] | 1304 | encode_lockowner(xdr, &args->lock_owner); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1305 | } |
| 1306 | else { |
Trond Myklebust | ea9d23f | 2012-03-04 18:13:56 -0500 | [diff] [blame] | 1307 | encode_nfs4_stateid(xdr, args->lock_stateid); |
Trond Myklebust | 4ade982 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1308 | encode_nfs4_seqid(xdr, args->lock_seqid); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1309 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1310 | } |
| 1311 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1312 | 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] | 1313 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 1314 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1315 | |
Trond Myklebust | 475d4ba | 2012-03-05 11:27:16 -0500 | [diff] [blame] | 1316 | encode_op_hdr(xdr, OP_LOCKT, decode_lockt_maxsz, hdr); |
| 1317 | p = reserve_space(xdr, 20); |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1318 | *p++ = cpu_to_be32(nfs4_lock_type(args->fl, 0)); |
Benny Halevy | b95be5a | 2009-08-14 17:19:01 +0300 | [diff] [blame] | 1319 | p = xdr_encode_hyper(p, args->fl->fl_start); |
| 1320 | p = xdr_encode_hyper(p, nfs4_lock_length(args->fl)); |
Trond Myklebust | daccbde | 2010-06-25 18:11:43 -0400 | [diff] [blame] | 1321 | encode_lockowner(xdr, &args->lock_owner); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1322 | } |
| 1323 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1324 | 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] | 1325 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 1326 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1327 | |
Trond Myklebust | 475d4ba | 2012-03-05 11:27:16 -0500 | [diff] [blame] | 1328 | encode_op_hdr(xdr, OP_LOCKU, decode_locku_maxsz, hdr); |
| 1329 | encode_uint32(xdr, nfs4_lock_type(args->fl, 0)); |
Trond Myklebust | 4ade982 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1330 | encode_nfs4_seqid(xdr, args->seqid); |
Trond Myklebust | ea9d23f | 2012-03-04 18:13:56 -0500 | [diff] [blame] | 1331 | encode_nfs4_stateid(xdr, args->stateid); |
| 1332 | p = reserve_space(xdr, 16); |
Benny Halevy | b95be5a | 2009-08-14 17:19:01 +0300 | [diff] [blame] | 1333 | p = xdr_encode_hyper(p, args->fl->fl_start); |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1334 | xdr_encode_hyper(p, nfs4_lock_length(args->fl)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1335 | } |
| 1336 | |
Trond Myklebust | d3c7b7c | 2010-07-01 12:49:01 -0400 | [diff] [blame] | 1337 | static void encode_release_lockowner(struct xdr_stream *xdr, const struct nfs_lowner *lowner, struct compound_hdr *hdr) |
| 1338 | { |
Trond Myklebust | ab19b48 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1339 | encode_op_hdr(xdr, OP_RELEASE_LOCKOWNER, decode_release_lockowner_maxsz, hdr); |
Trond Myklebust | d3c7b7c | 2010-07-01 12:49:01 -0400 | [diff] [blame] | 1340 | encode_lockowner(xdr, lowner); |
Trond Myklebust | d3c7b7c | 2010-07-01 12:49:01 -0400 | [diff] [blame] | 1341 | } |
| 1342 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1343 | 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] | 1344 | { |
Trond Myklebust | ab19b48 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1345 | encode_op_hdr(xdr, OP_LOOKUP, decode_lookup_maxsz, hdr); |
Trond Myklebust | 6fdfb0bc | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1346 | encode_string(xdr, name->len, name->name); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1347 | } |
| 1348 | |
Trond Myklebust | dc0b027 | 2008-12-23 15:21:56 -0500 | [diff] [blame] | 1349 | static void encode_share_access(struct xdr_stream *xdr, fmode_t fmode) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1350 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 1351 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1352 | |
Benny Halevy | 13c65ce | 2009-08-14 17:19:25 +0300 | [diff] [blame] | 1353 | p = reserve_space(xdr, 8); |
Trond Myklebust | dc0b027 | 2008-12-23 15:21:56 -0500 | [diff] [blame] | 1354 | switch (fmode & (FMODE_READ|FMODE_WRITE)) { |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 1355 | case FMODE_READ: |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1356 | *p++ = cpu_to_be32(NFS4_SHARE_ACCESS_READ); |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 1357 | break; |
| 1358 | case FMODE_WRITE: |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1359 | *p++ = cpu_to_be32(NFS4_SHARE_ACCESS_WRITE); |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 1360 | break; |
| 1361 | case FMODE_READ|FMODE_WRITE: |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1362 | *p++ = cpu_to_be32(NFS4_SHARE_ACCESS_BOTH); |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 1363 | break; |
| 1364 | default: |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1365 | *p++ = cpu_to_be32(0); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1366 | } |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1367 | *p = cpu_to_be32(0); /* for linux, share_deny = 0 always */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1368 | } |
| 1369 | |
| 1370 | static inline void encode_openhdr(struct xdr_stream *xdr, const struct nfs_openargs *arg) |
| 1371 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 1372 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1373 | /* |
| 1374 | * opcode 4, seqid 4, share_access 4, share_deny 4, clientid 8, ownerlen 4, |
| 1375 | * owner 4 = 32 |
| 1376 | */ |
Trond Myklebust | 4ade982 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1377 | encode_nfs4_seqid(xdr, arg->seqid); |
Trond Myklebust | dc0b027 | 2008-12-23 15:21:56 -0500 | [diff] [blame] | 1378 | encode_share_access(xdr, arg->fmode); |
Trond Myklebust | 95b72eb | 2012-04-20 19:24:51 -0400 | [diff] [blame] | 1379 | p = reserve_space(xdr, 36); |
Benny Halevy | b95be5a | 2009-08-14 17:19:01 +0300 | [diff] [blame] | 1380 | p = xdr_encode_hyper(p, arg->clientid); |
Trond Myklebust | 95b72eb | 2012-04-20 19:24:51 -0400 | [diff] [blame] | 1381 | *p++ = cpu_to_be32(24); |
Benny Halevy | 93f0cf2 | 2009-08-14 17:19:06 +0300 | [diff] [blame] | 1382 | p = xdr_encode_opaque_fixed(p, "open id:", 8); |
Trond Myklebust | d035c36 | 2010-12-21 10:45:27 -0500 | [diff] [blame] | 1383 | *p++ = cpu_to_be32(arg->server->s_dev); |
Trond Myklebust | 95b72eb | 2012-04-20 19:24:51 -0400 | [diff] [blame] | 1384 | *p++ = cpu_to_be32(arg->id.uniquifier); |
| 1385 | xdr_encode_hyper(p, arg->id.create_time); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1386 | } |
| 1387 | |
| 1388 | static inline void encode_createmode(struct xdr_stream *xdr, const struct nfs_openargs *arg) |
| 1389 | { |
Trond Myklebust | 549b19c | 2013-04-16 18:42:34 -0400 | [diff] [blame] | 1390 | struct iattr dummy; |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 1391 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1392 | |
Benny Halevy | 13c65ce | 2009-08-14 17:19:25 +0300 | [diff] [blame] | 1393 | p = reserve_space(xdr, 4); |
Trond Myklebust | 549b19c | 2013-04-16 18:42:34 -0400 | [diff] [blame] | 1394 | switch(arg->createmode) { |
| 1395 | case NFS4_CREATE_UNCHECKED: |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1396 | *p = cpu_to_be32(NFS4_CREATE_UNCHECKED); |
David Quigley | aa9c266 | 2013-05-22 12:50:44 -0400 | [diff] [blame] | 1397 | encode_attrs(xdr, arg->u.attrs, arg->label, arg->server); |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 1398 | break; |
Trond Myklebust | 549b19c | 2013-04-16 18:42:34 -0400 | [diff] [blame] | 1399 | case NFS4_CREATE_GUARDED: |
| 1400 | *p = cpu_to_be32(NFS4_CREATE_GUARDED); |
David Quigley | aa9c266 | 2013-05-22 12:50:44 -0400 | [diff] [blame] | 1401 | encode_attrs(xdr, arg->u.attrs, arg->label, arg->server); |
Trond Myklebust | 549b19c | 2013-04-16 18:42:34 -0400 | [diff] [blame] | 1402 | break; |
| 1403 | case NFS4_CREATE_EXCLUSIVE: |
| 1404 | *p = cpu_to_be32(NFS4_CREATE_EXCLUSIVE); |
| 1405 | encode_nfs4_verifier(xdr, &arg->u.verifier); |
| 1406 | break; |
| 1407 | case NFS4_CREATE_EXCLUSIVE4_1: |
| 1408 | *p = cpu_to_be32(NFS4_CREATE_EXCLUSIVE4_1); |
| 1409 | encode_nfs4_verifier(xdr, &arg->u.verifier); |
| 1410 | dummy.ia_valid = 0; |
David Quigley | aa9c266 | 2013-05-22 12:50:44 -0400 | [diff] [blame] | 1411 | encode_attrs(xdr, &dummy, arg->label, arg->server); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1412 | } |
| 1413 | } |
| 1414 | |
| 1415 | static void encode_opentype(struct xdr_stream *xdr, const struct nfs_openargs *arg) |
| 1416 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 1417 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1418 | |
Benny Halevy | 13c65ce | 2009-08-14 17:19:25 +0300 | [diff] [blame] | 1419 | p = reserve_space(xdr, 4); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1420 | switch (arg->open_flags & O_CREAT) { |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 1421 | case 0: |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1422 | *p = cpu_to_be32(NFS4_OPEN_NOCREATE); |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 1423 | break; |
| 1424 | default: |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1425 | *p = cpu_to_be32(NFS4_OPEN_CREATE); |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 1426 | encode_createmode(xdr, arg); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1427 | } |
| 1428 | } |
| 1429 | |
Trond Myklebust | bd7bf9d | 2008-12-23 15:21:53 -0500 | [diff] [blame] | 1430 | 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] | 1431 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 1432 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1433 | |
Benny Halevy | 13c65ce | 2009-08-14 17:19:25 +0300 | [diff] [blame] | 1434 | p = reserve_space(xdr, 4); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1435 | switch (delegation_type) { |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 1436 | case 0: |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1437 | *p = cpu_to_be32(NFS4_OPEN_DELEGATE_NONE); |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 1438 | break; |
| 1439 | case FMODE_READ: |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1440 | *p = cpu_to_be32(NFS4_OPEN_DELEGATE_READ); |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 1441 | break; |
| 1442 | case FMODE_WRITE|FMODE_READ: |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1443 | *p = cpu_to_be32(NFS4_OPEN_DELEGATE_WRITE); |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 1444 | break; |
| 1445 | default: |
| 1446 | BUG(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1447 | } |
| 1448 | } |
| 1449 | |
| 1450 | static inline void encode_claim_null(struct xdr_stream *xdr, const struct qstr *name) |
| 1451 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 1452 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1453 | |
Benny Halevy | 13c65ce | 2009-08-14 17:19:25 +0300 | [diff] [blame] | 1454 | p = reserve_space(xdr, 4); |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1455 | *p = cpu_to_be32(NFS4_OPEN_CLAIM_NULL); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1456 | encode_string(xdr, name->len, name->name); |
| 1457 | } |
| 1458 | |
Trond Myklebust | bd7bf9d | 2008-12-23 15:21:53 -0500 | [diff] [blame] | 1459 | 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] | 1460 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 1461 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1462 | |
Benny Halevy | 13c65ce | 2009-08-14 17:19:25 +0300 | [diff] [blame] | 1463 | p = reserve_space(xdr, 4); |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1464 | *p = cpu_to_be32(NFS4_OPEN_CLAIM_PREVIOUS); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1465 | encode_delegation_type(xdr, type); |
| 1466 | } |
| 1467 | |
| 1468 | static inline void encode_claim_delegate_cur(struct xdr_stream *xdr, const struct qstr *name, const nfs4_stateid *stateid) |
| 1469 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 1470 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1471 | |
Trond Myklebust | ea9d23f | 2012-03-04 18:13:56 -0500 | [diff] [blame] | 1472 | p = reserve_space(xdr, 4); |
| 1473 | *p = cpu_to_be32(NFS4_OPEN_CLAIM_DELEGATE_CUR); |
| 1474 | encode_nfs4_stateid(xdr, stateid); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1475 | encode_string(xdr, name->len, name->name); |
| 1476 | } |
| 1477 | |
Trond Myklebust | d9fc661 | 2013-03-15 15:39:06 -0400 | [diff] [blame] | 1478 | static inline void encode_claim_fh(struct xdr_stream *xdr) |
| 1479 | { |
| 1480 | __be32 *p; |
| 1481 | |
| 1482 | p = reserve_space(xdr, 4); |
| 1483 | *p = cpu_to_be32(NFS4_OPEN_CLAIM_FH); |
| 1484 | } |
| 1485 | |
| 1486 | static inline void encode_claim_delegate_cur_fh(struct xdr_stream *xdr, const nfs4_stateid *stateid) |
| 1487 | { |
| 1488 | __be32 *p; |
| 1489 | |
| 1490 | p = reserve_space(xdr, 4); |
| 1491 | *p = cpu_to_be32(NFS4_OPEN_CLAIM_DELEG_CUR_FH); |
| 1492 | encode_nfs4_stateid(xdr, stateid); |
| 1493 | } |
| 1494 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1495 | 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] | 1496 | { |
Trond Myklebust | ab19b48 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1497 | encode_op_hdr(xdr, OP_OPEN, decode_open_maxsz, hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1498 | encode_openhdr(xdr, arg); |
| 1499 | encode_opentype(xdr, arg); |
| 1500 | switch (arg->claim) { |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 1501 | case NFS4_OPEN_CLAIM_NULL: |
| 1502 | encode_claim_null(xdr, arg->name); |
| 1503 | break; |
| 1504 | case NFS4_OPEN_CLAIM_PREVIOUS: |
| 1505 | encode_claim_previous(xdr, arg->u.delegation_type); |
| 1506 | break; |
| 1507 | case NFS4_OPEN_CLAIM_DELEGATE_CUR: |
| 1508 | encode_claim_delegate_cur(xdr, arg->name, &arg->u.delegation); |
| 1509 | break; |
Trond Myklebust | d9fc661 | 2013-03-15 15:39:06 -0400 | [diff] [blame] | 1510 | case NFS4_OPEN_CLAIM_FH: |
| 1511 | encode_claim_fh(xdr); |
| 1512 | break; |
| 1513 | case NFS4_OPEN_CLAIM_DELEG_CUR_FH: |
| 1514 | encode_claim_delegate_cur_fh(xdr, &arg->u.delegation); |
| 1515 | break; |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 1516 | default: |
| 1517 | BUG(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1518 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1519 | } |
| 1520 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1521 | 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] | 1522 | { |
Trond Myklebust | ab19b48 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1523 | encode_op_hdr(xdr, OP_OPEN_CONFIRM, decode_open_confirm_maxsz, hdr); |
Trond Myklebust | ea9d23f | 2012-03-04 18:13:56 -0500 | [diff] [blame] | 1524 | encode_nfs4_stateid(xdr, arg->stateid); |
Trond Myklebust | 4ade982 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1525 | encode_nfs4_seqid(xdr, arg->seqid); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1526 | } |
| 1527 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1528 | 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] | 1529 | { |
Trond Myklebust | ab19b48 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1530 | encode_op_hdr(xdr, OP_OPEN_DOWNGRADE, decode_open_downgrade_maxsz, hdr); |
Trond Myklebust | ea9d23f | 2012-03-04 18:13:56 -0500 | [diff] [blame] | 1531 | encode_nfs4_stateid(xdr, arg->stateid); |
Trond Myklebust | 4ade982 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1532 | encode_nfs4_seqid(xdr, arg->seqid); |
Trond Myklebust | dc0b027 | 2008-12-23 15:21:56 -0500 | [diff] [blame] | 1533 | encode_share_access(xdr, arg->fmode); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1534 | } |
| 1535 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1536 | static void |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 1537 | 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] | 1538 | { |
Trond Myklebust | ab19b48 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1539 | encode_op_hdr(xdr, OP_PUTFH, decode_putfh_maxsz, hdr); |
Trond Myklebust | 6fdfb0bc | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1540 | encode_string(xdr, fh->size, fh->data); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1541 | } |
| 1542 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1543 | static void encode_putrootfh(struct xdr_stream *xdr, struct compound_hdr *hdr) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1544 | { |
Trond Myklebust | ab19b48 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1545 | encode_op_hdr(xdr, OP_PUTROOTFH, decode_putrootfh_maxsz, hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1546 | } |
| 1547 | |
Anna Schumaker | 3c6b899 | 2014-05-06 09:12:24 -0400 | [diff] [blame] | 1548 | static void encode_read(struct xdr_stream *xdr, const struct nfs_pgio_args *args, |
| 1549 | struct compound_hdr *hdr) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1550 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 1551 | __be32 *p; |
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_READ, decode_read_maxsz, hdr); |
Trond Myklebust | 9b20614 | 2013-03-17 15:52:00 -0400 | [diff] [blame] | 1554 | encode_nfs4_stateid(xdr, &args->stateid); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1555 | |
Benny Halevy | 13c65ce | 2009-08-14 17:19:25 +0300 | [diff] [blame] | 1556 | p = reserve_space(xdr, 12); |
Benny Halevy | b95be5a | 2009-08-14 17:19:01 +0300 | [diff] [blame] | 1557 | p = xdr_encode_hyper(p, args->offset); |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1558 | *p = cpu_to_be32(args->count); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1559 | } |
| 1560 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1561 | 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] | 1562 | { |
David Quigley | aa9c266 | 2013-05-22 12:50:44 -0400 | [diff] [blame] | 1563 | uint32_t attrs[3] = { |
Trond Myklebust | 28331a4 | 2011-04-27 13:47:52 -0400 | [diff] [blame] | 1564 | FATTR4_WORD0_RDATTR_ERROR, |
| 1565 | FATTR4_WORD1_MOUNTED_ON_FILEID, |
| 1566 | }; |
Trond Myklebust | 6f7a35b | 2010-10-24 12:11:42 -0400 | [diff] [blame] | 1567 | uint32_t dircount = readdir->count >> 1; |
Chuck Lever | cd93710 | 2012-03-02 17:14:31 -0500 | [diff] [blame] | 1568 | __be32 *p, verf[2]; |
Trond Myklebust | d204c5d | 2013-11-04 13:23:59 -0500 | [diff] [blame] | 1569 | uint32_t attrlen = 0; |
| 1570 | unsigned int i; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1571 | |
Bryan Schumaker | 82f2e54 | 2010-10-21 16:33:18 -0400 | [diff] [blame] | 1572 | if (readdir->plus) { |
| 1573 | attrs[0] |= FATTR4_WORD0_TYPE|FATTR4_WORD0_CHANGE|FATTR4_WORD0_SIZE| |
Trond Myklebust | 28331a4 | 2011-04-27 13:47:52 -0400 | [diff] [blame] | 1574 | FATTR4_WORD0_FSID|FATTR4_WORD0_FILEHANDLE|FATTR4_WORD0_FILEID; |
Bryan Schumaker | 82f2e54 | 2010-10-21 16:33:18 -0400 | [diff] [blame] | 1575 | attrs[1] |= FATTR4_WORD1_MODE|FATTR4_WORD1_NUMLINKS|FATTR4_WORD1_OWNER| |
| 1576 | FATTR4_WORD1_OWNER_GROUP|FATTR4_WORD1_RAWDEV| |
| 1577 | FATTR4_WORD1_SPACE_USED|FATTR4_WORD1_TIME_ACCESS| |
| 1578 | FATTR4_WORD1_TIME_METADATA|FATTR4_WORD1_TIME_MODIFY; |
Trond Myklebust | d204c5d | 2013-11-04 13:23:59 -0500 | [diff] [blame] | 1579 | attrs[2] |= FATTR4_WORD2_SECURITY_LABEL; |
Trond Myklebust | 6f7a35b | 2010-10-24 12:11:42 -0400 | [diff] [blame] | 1580 | dircount >>= 1; |
Bryan Schumaker | 82f2e54 | 2010-10-21 16:33:18 -0400 | [diff] [blame] | 1581 | } |
Trond Myklebust | 28331a4 | 2011-04-27 13:47:52 -0400 | [diff] [blame] | 1582 | /* Use mounted_on_fileid only if the server supports it */ |
| 1583 | if (!(readdir->bitmask[1] & FATTR4_WORD1_MOUNTED_ON_FILEID)) |
| 1584 | attrs[0] |= FATTR4_WORD0_FILEID; |
Trond Myklebust | d204c5d | 2013-11-04 13:23:59 -0500 | [diff] [blame] | 1585 | for (i = 0; i < ARRAY_SIZE(attrs); i++) { |
| 1586 | attrs[i] &= readdir->bitmask[i]; |
| 1587 | if (attrs[i] != 0) |
| 1588 | attrlen = i+1; |
| 1589 | } |
Bryan Schumaker | 82f2e54 | 2010-10-21 16:33:18 -0400 | [diff] [blame] | 1590 | |
Trond Myklebust | 475d4ba | 2012-03-05 11:27:16 -0500 | [diff] [blame] | 1591 | encode_op_hdr(xdr, OP_READDIR, decode_readdir_maxsz, hdr); |
Trond Myklebust | ff2eb68 | 2012-03-05 11:40:12 -0500 | [diff] [blame] | 1592 | encode_uint64(xdr, readdir->cookie); |
Chuck Lever | cd93710 | 2012-03-02 17:14:31 -0500 | [diff] [blame] | 1593 | encode_nfs4_verifier(xdr, &readdir->verifier); |
Trond Myklebust | d204c5d | 2013-11-04 13:23:59 -0500 | [diff] [blame] | 1594 | p = reserve_space(xdr, 12 + (attrlen << 2)); |
Trond Myklebust | 6f7a35b | 2010-10-24 12:11:42 -0400 | [diff] [blame] | 1595 | *p++ = cpu_to_be32(dircount); |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1596 | *p++ = cpu_to_be32(readdir->count); |
Trond Myklebust | d204c5d | 2013-11-04 13:23:59 -0500 | [diff] [blame] | 1597 | *p++ = cpu_to_be32(attrlen); |
| 1598 | for (i = 0; i < attrlen; i++) |
| 1599 | *p++ = cpu_to_be32(attrs[i]); |
Chuck Lever | cd93710 | 2012-03-02 17:14:31 -0500 | [diff] [blame] | 1600 | memcpy(verf, readdir->verifier.data, sizeof(verf)); |
David Quigley | aa9c266 | 2013-05-22 12:50:44 -0400 | [diff] [blame] | 1601 | |
| 1602 | dprintk("%s: cookie = %llu, verifier = %08x:%08x, bitmap = %08x:%08x:%08x\n", |
Fred Isaman | 4410924 | 2008-04-02 15:21:15 +0300 | [diff] [blame] | 1603 | __func__, |
Trond Myklebust | eadf459 | 2005-06-22 17:16:39 +0000 | [diff] [blame] | 1604 | (unsigned long long)readdir->cookie, |
Chuck Lever | cd93710 | 2012-03-02 17:14:31 -0500 | [diff] [blame] | 1605 | verf[0], verf[1], |
Trond Myklebust | eadf459 | 2005-06-22 17:16:39 +0000 | [diff] [blame] | 1606 | attrs[0] & readdir->bitmask[0], |
David Quigley | aa9c266 | 2013-05-22 12:50:44 -0400 | [diff] [blame] | 1607 | attrs[1] & readdir->bitmask[1], |
| 1608 | attrs[2] & readdir->bitmask[2]); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1609 | } |
| 1610 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1611 | 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] | 1612 | { |
Trond Myklebust | ab19b48 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1613 | encode_op_hdr(xdr, OP_READLINK, decode_readlink_maxsz, hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1614 | } |
| 1615 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1616 | 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] | 1617 | { |
Trond Myklebust | ab19b48 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1618 | encode_op_hdr(xdr, OP_REMOVE, decode_remove_maxsz, hdr); |
Trond Myklebust | 6fdfb0bc | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1619 | encode_string(xdr, name->len, name->name); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1620 | } |
| 1621 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1622 | static void encode_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] | 1623 | { |
Trond Myklebust | ab19b48 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1624 | encode_op_hdr(xdr, OP_RENAME, decode_rename_maxsz, hdr); |
Benny Halevy | 811652b | 2009-08-14 17:19:34 +0300 | [diff] [blame] | 1625 | encode_string(xdr, oldname->len, oldname->name); |
| 1626 | encode_string(xdr, newname->len, newname->name); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1627 | } |
| 1628 | |
Chuck Lever | bb4dae5 | 2012-03-01 17:01:48 -0500 | [diff] [blame] | 1629 | static void encode_renew(struct xdr_stream *xdr, clientid4 clid, |
| 1630 | struct compound_hdr *hdr) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1631 | { |
Trond Myklebust | 475d4ba | 2012-03-05 11:27:16 -0500 | [diff] [blame] | 1632 | encode_op_hdr(xdr, OP_RENEW, decode_renew_maxsz, hdr); |
Trond Myklebust | ff2eb68 | 2012-03-05 11:40:12 -0500 | [diff] [blame] | 1633 | encode_uint64(xdr, clid); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1634 | } |
| 1635 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1636 | static void |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 1637 | encode_restorefh(struct xdr_stream *xdr, struct compound_hdr *hdr) |
Trond Myklebust | 56ae19f | 2005-10-27 22:12:40 -0400 | [diff] [blame] | 1638 | { |
Trond Myklebust | ab19b48 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1639 | encode_op_hdr(xdr, OP_RESTOREFH, decode_restorefh_maxsz, hdr); |
Trond Myklebust | 56ae19f | 2005-10-27 22:12:40 -0400 | [diff] [blame] | 1640 | } |
| 1641 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 1642 | static void |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 1643 | encode_setacl(struct xdr_stream *xdr, struct nfs_setaclargs *arg, struct compound_hdr *hdr) |
J. Bruce Fields | 23ec696 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 1644 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 1645 | __be32 *p; |
J. Bruce Fields | 23ec696 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 1646 | |
Trond Myklebust | ab19b48 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1647 | encode_op_hdr(xdr, OP_SETATTR, decode_setacl_maxsz, hdr); |
Trond Myklebust | ea9d23f | 2012-03-04 18:13:56 -0500 | [diff] [blame] | 1648 | encode_nfs4_stateid(xdr, &zero_stateid); |
Benny Halevy | 13c65ce | 2009-08-14 17:19:25 +0300 | [diff] [blame] | 1649 | p = reserve_space(xdr, 2*4); |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1650 | *p++ = cpu_to_be32(1); |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1651 | *p = cpu_to_be32(FATTR4_WORD0_ACL); |
Benny Halevy | 13c65ce | 2009-08-14 17:19:25 +0300 | [diff] [blame] | 1652 | p = reserve_space(xdr, 4); |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1653 | *p = cpu_to_be32(arg->acl_len); |
J. Bruce Fields | 23ec696 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 1654 | xdr_write_pages(xdr, arg->acl_pages, arg->acl_pgbase, arg->acl_len); |
J. Bruce Fields | 23ec696 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 1655 | } |
| 1656 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1657 | static void |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 1658 | encode_savefh(struct xdr_stream *xdr, struct compound_hdr *hdr) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1659 | { |
Trond Myklebust | ab19b48 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1660 | encode_op_hdr(xdr, OP_SAVEFH, decode_savefh_maxsz, hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1661 | } |
| 1662 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1663 | static void encode_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] | 1664 | { |
Trond Myklebust | ab19b48 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1665 | encode_op_hdr(xdr, OP_SETATTR, decode_setattr_maxsz, hdr); |
Trond Myklebust | ea9d23f | 2012-03-04 18:13:56 -0500 | [diff] [blame] | 1666 | encode_nfs4_stateid(xdr, &arg->stateid); |
David Quigley | aa9c266 | 2013-05-22 12:50:44 -0400 | [diff] [blame] | 1667 | encode_attrs(xdr, arg->iap, arg->label, server); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1668 | } |
| 1669 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1670 | 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] | 1671 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 1672 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1673 | |
Trond Myklebust | 7001951 | 2012-03-04 20:49:32 -0500 | [diff] [blame] | 1674 | encode_op_hdr(xdr, OP_SETCLIENTID, decode_setclientid_maxsz, hdr); |
Chuck Lever | cd93710 | 2012-03-02 17:14:31 -0500 | [diff] [blame] | 1675 | encode_nfs4_verifier(xdr, setclientid->sc_verifier); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1676 | |
| 1677 | encode_string(xdr, setclientid->sc_name_len, setclientid->sc_name); |
Benny Halevy | 13c65ce | 2009-08-14 17:19:25 +0300 | [diff] [blame] | 1678 | p = reserve_space(xdr, 4); |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1679 | *p = cpu_to_be32(setclientid->sc_prog); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1680 | encode_string(xdr, setclientid->sc_netid_len, setclientid->sc_netid); |
| 1681 | encode_string(xdr, setclientid->sc_uaddr_len, setclientid->sc_uaddr); |
Benny Halevy | 13c65ce | 2009-08-14 17:19:25 +0300 | [diff] [blame] | 1682 | p = reserve_space(xdr, 4); |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1683 | *p = cpu_to_be32(setclientid->sc_cb_ident); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1684 | } |
| 1685 | |
Trond Myklebust | bb8b27e | 2010-04-16 16:43:06 -0400 | [diff] [blame] | 1686 | 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] | 1687 | { |
Trond Myklebust | 475d4ba | 2012-03-05 11:27:16 -0500 | [diff] [blame] | 1688 | encode_op_hdr(xdr, OP_SETCLIENTID_CONFIRM, |
| 1689 | decode_setclientid_confirm_maxsz, hdr); |
Trond Myklebust | ff2eb68 | 2012-03-05 11:40:12 -0500 | [diff] [blame] | 1690 | encode_uint64(xdr, arg->clientid); |
Chuck Lever | cd93710 | 2012-03-02 17:14:31 -0500 | [diff] [blame] | 1691 | encode_nfs4_verifier(xdr, &arg->confirm); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1692 | } |
| 1693 | |
Anna Schumaker | 3c6b899 | 2014-05-06 09:12:24 -0400 | [diff] [blame] | 1694 | static void encode_write(struct xdr_stream *xdr, const struct nfs_pgio_args *args, |
| 1695 | struct compound_hdr *hdr) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1696 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 1697 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1698 | |
Trond Myklebust | ab19b48 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1699 | encode_op_hdr(xdr, OP_WRITE, decode_write_maxsz, hdr); |
Trond Myklebust | 9b20614 | 2013-03-17 15:52:00 -0400 | [diff] [blame] | 1700 | encode_nfs4_stateid(xdr, &args->stateid); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1701 | |
Benny Halevy | 13c65ce | 2009-08-14 17:19:25 +0300 | [diff] [blame] | 1702 | p = reserve_space(xdr, 16); |
Benny Halevy | b95be5a | 2009-08-14 17:19:01 +0300 | [diff] [blame] | 1703 | p = xdr_encode_hyper(p, args->offset); |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1704 | *p++ = cpu_to_be32(args->stable); |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1705 | *p = cpu_to_be32(args->count); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1706 | |
| 1707 | xdr_write_pages(xdr, args->pages, args->pgbase, args->count); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1708 | } |
| 1709 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1710 | 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] | 1711 | { |
Trond Myklebust | ab19b48 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1712 | encode_op_hdr(xdr, OP_DELEGRETURN, decode_delegreturn_maxsz, hdr); |
Trond Myklebust | ea9d23f | 2012-03-04 18:13:56 -0500 | [diff] [blame] | 1713 | encode_nfs4_stateid(xdr, stateid); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1714 | } |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 1715 | |
Bryan Schumaker | 5a5ea0d | 2011-03-24 17:12:29 +0000 | [diff] [blame] | 1716 | static void encode_secinfo(struct xdr_stream *xdr, const struct qstr *name, struct compound_hdr *hdr) |
| 1717 | { |
Trond Myklebust | ab19b48 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1718 | encode_op_hdr(xdr, OP_SECINFO, decode_secinfo_maxsz, hdr); |
Trond Myklebust | 6fdfb0bc | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1719 | encode_string(xdr, name->len, name->name); |
Bryan Schumaker | 5a5ea0d | 2011-03-24 17:12:29 +0000 | [diff] [blame] | 1720 | } |
| 1721 | |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 1722 | #if defined(CONFIG_NFS_V4_1) |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 1723 | /* NFSv4.1 operations */ |
Weston Andros Adamson | 7c44f1ae | 2012-05-24 13:22:50 -0400 | [diff] [blame] | 1724 | static void encode_bind_conn_to_session(struct xdr_stream *xdr, |
| 1725 | struct nfs4_session *session, |
| 1726 | struct compound_hdr *hdr) |
| 1727 | { |
| 1728 | __be32 *p; |
| 1729 | |
| 1730 | encode_op_hdr(xdr, OP_BIND_CONN_TO_SESSION, |
| 1731 | decode_bind_conn_to_session_maxsz, hdr); |
| 1732 | encode_opaque_fixed(xdr, session->sess_id.data, NFS4_MAX_SESSIONID_LEN); |
| 1733 | p = xdr_reserve_space(xdr, 8); |
| 1734 | *p++ = cpu_to_be32(NFS4_CDFC4_BACK_OR_BOTH); |
| 1735 | *p = 0; /* use_conn_in_rdma_mode = False */ |
| 1736 | } |
| 1737 | |
Weston Andros Adamson | 2031cd1 | 2013-08-13 16:37:32 -0400 | [diff] [blame] | 1738 | static void encode_op_map(struct xdr_stream *xdr, struct nfs4_op_map *op_map) |
| 1739 | { |
| 1740 | unsigned int i; |
| 1741 | encode_uint32(xdr, NFS4_OP_MAP_NUM_WORDS); |
| 1742 | for (i = 0; i < NFS4_OP_MAP_NUM_WORDS; i++) |
| 1743 | encode_uint32(xdr, op_map->u.words[i]); |
| 1744 | } |
| 1745 | |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 1746 | static void encode_exchange_id(struct xdr_stream *xdr, |
| 1747 | struct nfs41_exchange_id_args *args, |
| 1748 | struct compound_hdr *hdr) |
| 1749 | { |
| 1750 | __be32 *p; |
Jim Rees | d751f74 | 2012-11-16 18:12:06 -0500 | [diff] [blame] | 1751 | char impl_name[IMPL_NAME_LIMIT]; |
Weston Andros Adamson | db8ac8b | 2012-02-17 15:20:24 -0500 | [diff] [blame] | 1752 | int len = 0; |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 1753 | |
Trond Myklebust | 7001951 | 2012-03-04 20:49:32 -0500 | [diff] [blame] | 1754 | encode_op_hdr(xdr, OP_EXCHANGE_ID, decode_exchange_id_maxsz, hdr); |
Chuck Lever | cd93710 | 2012-03-02 17:14:31 -0500 | [diff] [blame] | 1755 | encode_nfs4_verifier(xdr, args->verifier); |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 1756 | |
| 1757 | encode_string(xdr, args->id_len, args->id); |
| 1758 | |
Weston Andros Adamson | 2031cd1 | 2013-08-13 16:37:32 -0400 | [diff] [blame] | 1759 | encode_uint32(xdr, args->flags); |
| 1760 | encode_uint32(xdr, args->state_protect.how); |
| 1761 | |
| 1762 | switch (args->state_protect.how) { |
| 1763 | case SP4_NONE: |
| 1764 | break; |
| 1765 | case SP4_MACH_CRED: |
| 1766 | encode_op_map(xdr, &args->state_protect.enforce); |
| 1767 | encode_op_map(xdr, &args->state_protect.allow); |
| 1768 | break; |
| 1769 | default: |
| 1770 | WARN_ON_ONCE(1); |
| 1771 | break; |
| 1772 | } |
Weston Andros Adamson | db8ac8b | 2012-02-17 15:20:24 -0500 | [diff] [blame] | 1773 | |
| 1774 | if (send_implementation_id && |
| 1775 | sizeof(CONFIG_NFS_V4_1_IMPLEMENTATION_ID_DOMAIN) > 1 && |
| 1776 | sizeof(CONFIG_NFS_V4_1_IMPLEMENTATION_ID_DOMAIN) |
Jim Rees | d751f74 | 2012-11-16 18:12:06 -0500 | [diff] [blame] | 1777 | <= sizeof(impl_name) + 1) |
Weston Andros Adamson | db8ac8b | 2012-02-17 15:20:24 -0500 | [diff] [blame] | 1778 | len = snprintf(impl_name, sizeof(impl_name), "%s %s %s %s", |
| 1779 | utsname()->sysname, utsname()->release, |
| 1780 | utsname()->version, utsname()->machine); |
| 1781 | |
| 1782 | if (len > 0) { |
Weston Andros Adamson | 2031cd1 | 2013-08-13 16:37:32 -0400 | [diff] [blame] | 1783 | encode_uint32(xdr, 1); /* implementation id array length=1 */ |
Weston Andros Adamson | db8ac8b | 2012-02-17 15:20:24 -0500 | [diff] [blame] | 1784 | |
| 1785 | encode_string(xdr, |
| 1786 | sizeof(CONFIG_NFS_V4_1_IMPLEMENTATION_ID_DOMAIN) - 1, |
| 1787 | CONFIG_NFS_V4_1_IMPLEMENTATION_ID_DOMAIN); |
| 1788 | encode_string(xdr, len, impl_name); |
| 1789 | /* just send zeros for nii_date - the date is in nii_name */ |
| 1790 | p = reserve_space(xdr, 12); |
| 1791 | p = xdr_encode_hyper(p, 0); |
| 1792 | *p = cpu_to_be32(0); |
| 1793 | } else |
Weston Andros Adamson | 2031cd1 | 2013-08-13 16:37:32 -0400 | [diff] [blame] | 1794 | encode_uint32(xdr, 0); /* implementation id array length=0 */ |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 1795 | } |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 1796 | |
| 1797 | static void encode_create_session(struct xdr_stream *xdr, |
| 1798 | struct nfs41_create_session_args *args, |
| 1799 | struct compound_hdr *hdr) |
| 1800 | { |
| 1801 | __be32 *p; |
| 1802 | char machine_name[NFS4_MAX_MACHINE_NAME_LEN]; |
| 1803 | uint32_t len; |
| 1804 | struct nfs_client *clp = args->client; |
Chuck Lever | f092075 | 2012-05-21 22:45:41 -0400 | [diff] [blame] | 1805 | struct nfs_net *nn = net_generic(clp->cl_net, nfs_net_id); |
Mike Sager | 8e0d46e | 2009-12-17 12:06:26 -0500 | [diff] [blame] | 1806 | u32 max_resp_sz_cached; |
| 1807 | |
| 1808 | /* |
| 1809 | * Assumes OPEN is the biggest non-idempotent compound. |
| 1810 | * 2 is the verifier. |
| 1811 | */ |
| 1812 | max_resp_sz_cached = (NFS4_dec_open_sz + RPC_REPHDRSIZE + |
| 1813 | RPC_MAX_AUTH_SIZE + 2) * XDR_UNIT; |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 1814 | |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 1815 | len = scnprintf(machine_name, sizeof(machine_name), "%s", |
| 1816 | clp->cl_ipaddr); |
Benny Halevy | 42edd69 | 2009-08-14 17:19:13 +0300 | [diff] [blame] | 1817 | |
Trond Myklebust | 475d4ba | 2012-03-05 11:27:16 -0500 | [diff] [blame] | 1818 | encode_op_hdr(xdr, OP_CREATE_SESSION, decode_create_session_maxsz, hdr); |
| 1819 | p = reserve_space(xdr, 16 + 2*28 + 20 + len + 12); |
Andy Adamson | 114f64b | 2011-03-09 13:13:45 -0500 | [diff] [blame] | 1820 | p = xdr_encode_hyper(p, clp->cl_clientid); |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1821 | *p++ = cpu_to_be32(clp->cl_seqid); /*Sequence id */ |
| 1822 | *p++ = cpu_to_be32(args->flags); /*flags */ |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 1823 | |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 1824 | /* Fore Channel */ |
Benny Halevy | c9c30dd | 2011-06-11 17:08:39 -0400 | [diff] [blame] | 1825 | *p++ = cpu_to_be32(0); /* header padding size */ |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1826 | *p++ = cpu_to_be32(args->fc_attrs.max_rqst_sz); /* max req size */ |
| 1827 | *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] | 1828 | *p++ = cpu_to_be32(max_resp_sz_cached); /* Max resp sz cached */ |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1829 | *p++ = cpu_to_be32(args->fc_attrs.max_ops); /* max operations */ |
| 1830 | *p++ = cpu_to_be32(args->fc_attrs.max_reqs); /* max requests */ |
| 1831 | *p++ = cpu_to_be32(0); /* rdmachannel_attrs */ |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 1832 | |
| 1833 | /* Back Channel */ |
Benny Halevy | c9c30dd | 2011-06-11 17:08:39 -0400 | [diff] [blame] | 1834 | *p++ = cpu_to_be32(0); /* header padding size */ |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1835 | *p++ = cpu_to_be32(args->bc_attrs.max_rqst_sz); /* max req size */ |
| 1836 | *p++ = cpu_to_be32(args->bc_attrs.max_resp_sz); /* max resp size */ |
| 1837 | *p++ = cpu_to_be32(args->bc_attrs.max_resp_sz_cached); /* Max resp sz cached */ |
| 1838 | *p++ = cpu_to_be32(args->bc_attrs.max_ops); /* max operations */ |
| 1839 | *p++ = cpu_to_be32(args->bc_attrs.max_reqs); /* max requests */ |
| 1840 | *p++ = cpu_to_be32(0); /* rdmachannel_attrs */ |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 1841 | |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1842 | *p++ = cpu_to_be32(args->cb_program); /* cb_program */ |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1843 | *p++ = cpu_to_be32(1); |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1844 | *p++ = cpu_to_be32(RPC_AUTH_UNIX); /* auth_sys */ |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 1845 | |
| 1846 | /* authsys_parms rfc1831 */ |
Trond Myklebust | 17f26b1 | 2013-08-21 15:48:42 -0400 | [diff] [blame] | 1847 | *p++ = cpu_to_be32(nn->boot_time.tv_nsec); /* stamp */ |
Benny Halevy | 811652b | 2009-08-14 17:19:34 +0300 | [diff] [blame] | 1848 | p = xdr_encode_opaque(p, machine_name, len); |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1849 | *p++ = cpu_to_be32(0); /* UID */ |
| 1850 | *p++ = cpu_to_be32(0); /* GID */ |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1851 | *p = cpu_to_be32(0); /* No more gids */ |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 1852 | } |
Andy Adamson | 0f3e66c | 2009-04-01 09:22:34 -0400 | [diff] [blame] | 1853 | |
| 1854 | static void encode_destroy_session(struct xdr_stream *xdr, |
| 1855 | struct nfs4_session *session, |
| 1856 | struct compound_hdr *hdr) |
| 1857 | { |
Trond Myklebust | 475d4ba | 2012-03-05 11:27:16 -0500 | [diff] [blame] | 1858 | encode_op_hdr(xdr, OP_DESTROY_SESSION, decode_destroy_session_maxsz, hdr); |
| 1859 | encode_opaque_fixed(xdr, session->sess_id.data, NFS4_MAX_SESSIONID_LEN); |
Andy Adamson | 0f3e66c | 2009-04-01 09:22:34 -0400 | [diff] [blame] | 1860 | } |
Ricardo Labiaga | 18019753 | 2009-12-05 16:08:40 -0500 | [diff] [blame] | 1861 | |
Trond Myklebust | 6624553 | 2012-05-25 17:18:09 -0400 | [diff] [blame] | 1862 | static void encode_destroy_clientid(struct xdr_stream *xdr, |
| 1863 | uint64_t clientid, |
| 1864 | struct compound_hdr *hdr) |
| 1865 | { |
| 1866 | encode_op_hdr(xdr, OP_DESTROY_CLIENTID, decode_destroy_clientid_maxsz, hdr); |
| 1867 | encode_uint64(xdr, clientid); |
| 1868 | } |
| 1869 | |
Ricardo Labiaga | 18019753 | 2009-12-05 16:08:40 -0500 | [diff] [blame] | 1870 | static void encode_reclaim_complete(struct xdr_stream *xdr, |
| 1871 | struct nfs41_reclaim_complete_args *args, |
| 1872 | struct compound_hdr *hdr) |
| 1873 | { |
Trond Myklebust | 475d4ba | 2012-03-05 11:27:16 -0500 | [diff] [blame] | 1874 | encode_op_hdr(xdr, OP_RECLAIM_COMPLETE, decode_reclaim_complete_maxsz, hdr); |
| 1875 | encode_uint32(xdr, args->one_fs); |
Ricardo Labiaga | 18019753 | 2009-12-05 16:08:40 -0500 | [diff] [blame] | 1876 | } |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 1877 | #endif /* CONFIG_NFS_V4_1 */ |
| 1878 | |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 1879 | static void encode_sequence(struct xdr_stream *xdr, |
| 1880 | const struct nfs4_sequence_args *args, |
| 1881 | struct compound_hdr *hdr) |
| 1882 | { |
| 1883 | #if defined(CONFIG_NFS_V4_1) |
Trond Myklebust | 2b2fa71 | 2012-11-16 12:58:36 -0500 | [diff] [blame] | 1884 | struct nfs4_session *session; |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 1885 | struct nfs4_slot_table *tp; |
Trond Myklebust | 2b2fa71 | 2012-11-16 12:58:36 -0500 | [diff] [blame] | 1886 | struct nfs4_slot *slot = args->sa_slot; |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 1887 | __be32 *p; |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 1888 | |
Trond Myklebust | 2b2fa71 | 2012-11-16 12:58:36 -0500 | [diff] [blame] | 1889 | tp = slot->table; |
| 1890 | session = tp->session; |
Chuck Lever | 3bd2384 | 2013-08-09 12:49:19 -0400 | [diff] [blame] | 1891 | if (!session) |
| 1892 | return; |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 1893 | |
Trond Myklebust | 475d4ba | 2012-03-05 11:27:16 -0500 | [diff] [blame] | 1894 | encode_op_hdr(xdr, OP_SEQUENCE, decode_sequence_maxsz, hdr); |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 1895 | |
| 1896 | /* |
| 1897 | * Sessionid + seqid + slotid + max slotid + cache_this |
| 1898 | */ |
| 1899 | dprintk("%s: sessionid=%u:%u:%u:%u seqid=%d slotid=%d " |
| 1900 | "max_slotid=%d cache_this=%d\n", |
| 1901 | __func__, |
| 1902 | ((u32 *)session->sess_id.data)[0], |
| 1903 | ((u32 *)session->sess_id.data)[1], |
| 1904 | ((u32 *)session->sess_id.data)[2], |
| 1905 | ((u32 *)session->sess_id.data)[3], |
Trond Myklebust | 2b2fa71 | 2012-11-16 12:58:36 -0500 | [diff] [blame] | 1906 | slot->seq_nr, slot->slot_nr, |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 1907 | tp->highest_used_slotid, args->sa_cache_this); |
Trond Myklebust | 475d4ba | 2012-03-05 11:27:16 -0500 | [diff] [blame] | 1908 | p = reserve_space(xdr, NFS4_MAX_SESSIONID_LEN + 16); |
Benny Halevy | 93f0cf2 | 2009-08-14 17:19:06 +0300 | [diff] [blame] | 1909 | 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] | 1910 | *p++ = cpu_to_be32(slot->seq_nr); |
Trond Myklebust | 2b2fa71 | 2012-11-16 12:58:36 -0500 | [diff] [blame] | 1911 | *p++ = cpu_to_be32(slot->slot_nr); |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1912 | *p++ = cpu_to_be32(tp->highest_used_slotid); |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1913 | *p = cpu_to_be32(args->sa_cache_this); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 1914 | #endif /* CONFIG_NFS_V4_1 */ |
| 1915 | } |
| 1916 | |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 1917 | #ifdef CONFIG_NFS_V4_1 |
| 1918 | static void |
| 1919 | encode_getdeviceinfo(struct xdr_stream *xdr, |
| 1920 | const struct nfs4_getdeviceinfo_args *args, |
| 1921 | struct compound_hdr *hdr) |
| 1922 | { |
| 1923 | __be32 *p; |
| 1924 | |
Trond Myklebust | 475d4ba | 2012-03-05 11:27:16 -0500 | [diff] [blame] | 1925 | encode_op_hdr(xdr, OP_GETDEVICEINFO, decode_getdeviceinfo_maxsz, hdr); |
Christoph Hellwig | 84c9dee | 2014-09-10 17:37:28 -0700 | [diff] [blame^] | 1926 | p = reserve_space(xdr, NFS4_DEVICEID4_SIZE + 4 + 4); |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 1927 | p = xdr_encode_opaque_fixed(p, args->pdev->dev_id.data, |
| 1928 | NFS4_DEVICEID4_SIZE); |
| 1929 | *p++ = cpu_to_be32(args->pdev->layout_type); |
Andy Adamson | f1c097b | 2013-06-25 19:02:53 -0400 | [diff] [blame] | 1930 | *p++ = cpu_to_be32(args->pdev->maxcount); /* gdia_maxcount */ |
Christoph Hellwig | 84c9dee | 2014-09-10 17:37:28 -0700 | [diff] [blame^] | 1931 | |
| 1932 | p = reserve_space(xdr, 4 + 4); |
| 1933 | *p++ = cpu_to_be32(1); /* bitmap length */ |
| 1934 | *p++ = cpu_to_be32(NOTIFY_DEVICEID4_CHANGE | NOTIFY_DEVICEID4_DELETE); |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 1935 | } |
| 1936 | |
| 1937 | static void |
| 1938 | encode_layoutget(struct xdr_stream *xdr, |
| 1939 | const struct nfs4_layoutget_args *args, |
| 1940 | struct compound_hdr *hdr) |
| 1941 | { |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 1942 | __be32 *p; |
| 1943 | |
Trond Myklebust | 475d4ba | 2012-03-05 11:27:16 -0500 | [diff] [blame] | 1944 | encode_op_hdr(xdr, OP_LAYOUTGET, decode_layoutget_maxsz, hdr); |
| 1945 | p = reserve_space(xdr, 36); |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 1946 | *p++ = cpu_to_be32(0); /* Signal layout available */ |
| 1947 | *p++ = cpu_to_be32(args->type); |
| 1948 | *p++ = cpu_to_be32(args->range.iomode); |
| 1949 | p = xdr_encode_hyper(p, args->range.offset); |
| 1950 | p = xdr_encode_hyper(p, args->range.length); |
| 1951 | p = xdr_encode_hyper(p, args->minlength); |
Trond Myklebust | ea9d23f | 2012-03-04 18:13:56 -0500 | [diff] [blame] | 1952 | encode_nfs4_stateid(xdr, &args->stateid); |
Trond Myklebust | 475d4ba | 2012-03-05 11:27:16 -0500 | [diff] [blame] | 1953 | encode_uint32(xdr, args->maxcount); |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 1954 | |
| 1955 | dprintk("%s: 1st type:0x%x iomode:%d off:%lu len:%lu mc:%d\n", |
| 1956 | __func__, |
| 1957 | args->type, |
| 1958 | args->range.iomode, |
| 1959 | (unsigned long)args->range.offset, |
| 1960 | (unsigned long)args->range.length, |
| 1961 | args->maxcount); |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 1962 | } |
Andy Adamson | 863a3c6 | 2011-03-23 13:27:54 +0000 | [diff] [blame] | 1963 | |
| 1964 | static int |
| 1965 | encode_layoutcommit(struct xdr_stream *xdr, |
Benny Halevy | ac7db72 | 2011-05-22 19:53:48 +0300 | [diff] [blame] | 1966 | struct inode *inode, |
Christoph Hellwig | 5f919c9 | 2014-08-21 11:09:25 -0500 | [diff] [blame] | 1967 | struct nfs4_layoutcommit_args *args, |
Andy Adamson | 863a3c6 | 2011-03-23 13:27:54 +0000 | [diff] [blame] | 1968 | struct compound_hdr *hdr) |
| 1969 | { |
| 1970 | __be32 *p; |
| 1971 | |
| 1972 | dprintk("%s: lbw: %llu type: %d\n", __func__, args->lastbytewritten, |
| 1973 | NFS_SERVER(args->inode)->pnfs_curr_ld->id); |
| 1974 | |
Trond Myklebust | 475d4ba | 2012-03-05 11:27:16 -0500 | [diff] [blame] | 1975 | encode_op_hdr(xdr, OP_LAYOUTCOMMIT, decode_layoutcommit_maxsz, hdr); |
| 1976 | p = reserve_space(xdr, 20); |
Andy Adamson | 863a3c6 | 2011-03-23 13:27:54 +0000 | [diff] [blame] | 1977 | /* Only whole file layouts */ |
| 1978 | p = xdr_encode_hyper(p, 0); /* offset */ |
Peng Tao | 3557c6c | 2011-07-30 20:52:34 -0400 | [diff] [blame] | 1979 | p = xdr_encode_hyper(p, args->lastbytewritten + 1); /* length */ |
Trond Myklebust | ea9d23f | 2012-03-04 18:13:56 -0500 | [diff] [blame] | 1980 | *p = cpu_to_be32(0); /* reclaim */ |
| 1981 | encode_nfs4_stateid(xdr, &args->stateid); |
| 1982 | p = reserve_space(xdr, 20); |
Andy Adamson | 863a3c6 | 2011-03-23 13:27:54 +0000 | [diff] [blame] | 1983 | *p++ = cpu_to_be32(1); /* newoffset = TRUE */ |
| 1984 | p = xdr_encode_hyper(p, args->lastbytewritten); |
| 1985 | *p++ = cpu_to_be32(0); /* Never send time_modify_changed */ |
| 1986 | *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] | 1987 | |
Christoph Hellwig | 5f919c9 | 2014-08-21 11:09:25 -0500 | [diff] [blame] | 1988 | if (NFS_SERVER(inode)->pnfs_curr_ld->encode_layoutcommit) { |
Benny Halevy | ac7db72 | 2011-05-22 19:53:48 +0300 | [diff] [blame] | 1989 | NFS_SERVER(inode)->pnfs_curr_ld->encode_layoutcommit( |
| 1990 | NFS_I(inode)->layout, xdr, args); |
Christoph Hellwig | 5f919c9 | 2014-08-21 11:09:25 -0500 | [diff] [blame] | 1991 | } else { |
| 1992 | encode_uint32(xdr, args->layoutupdate_len); |
| 1993 | if (args->layoutupdate_pages) { |
| 1994 | xdr_write_pages(xdr, args->layoutupdate_pages, 0, |
| 1995 | args->layoutupdate_len); |
| 1996 | } |
| 1997 | } |
Andy Adamson | 863a3c6 | 2011-03-23 13:27:54 +0000 | [diff] [blame] | 1998 | |
Andy Adamson | 863a3c6 | 2011-03-23 13:27:54 +0000 | [diff] [blame] | 1999 | return 0; |
| 2000 | } |
Benny Halevy | cbe8260 | 2011-05-22 19:52:37 +0300 | [diff] [blame] | 2001 | |
| 2002 | static void |
| 2003 | encode_layoutreturn(struct xdr_stream *xdr, |
| 2004 | const struct nfs4_layoutreturn_args *args, |
| 2005 | struct compound_hdr *hdr) |
| 2006 | { |
| 2007 | __be32 *p; |
| 2008 | |
Trond Myklebust | 475d4ba | 2012-03-05 11:27:16 -0500 | [diff] [blame] | 2009 | encode_op_hdr(xdr, OP_LAYOUTRETURN, decode_layoutreturn_maxsz, hdr); |
| 2010 | p = reserve_space(xdr, 16); |
Benny Halevy | cbe8260 | 2011-05-22 19:52:37 +0300 | [diff] [blame] | 2011 | *p++ = cpu_to_be32(0); /* reclaim. always 0 for now */ |
| 2012 | *p++ = cpu_to_be32(args->layout_type); |
| 2013 | *p++ = cpu_to_be32(IOMODE_ANY); |
| 2014 | *p = cpu_to_be32(RETURN_FILE); |
Trond Myklebust | ea9d23f | 2012-03-04 18:13:56 -0500 | [diff] [blame] | 2015 | p = reserve_space(xdr, 16); |
Benny Halevy | cbe8260 | 2011-05-22 19:52:37 +0300 | [diff] [blame] | 2016 | p = xdr_encode_hyper(p, 0); |
| 2017 | p = xdr_encode_hyper(p, NFS4_MAX_UINT64); |
| 2018 | spin_lock(&args->inode->i_lock); |
Trond Myklebust | ea9d23f | 2012-03-04 18:13:56 -0500 | [diff] [blame] | 2019 | encode_nfs4_stateid(xdr, &args->stateid); |
Benny Halevy | cbe8260 | 2011-05-22 19:52:37 +0300 | [diff] [blame] | 2020 | spin_unlock(&args->inode->i_lock); |
Andy Adamson | 04a5554 | 2011-05-22 19:53:10 +0300 | [diff] [blame] | 2021 | if (NFS_SERVER(args->inode)->pnfs_curr_ld->encode_layoutreturn) { |
| 2022 | NFS_SERVER(args->inode)->pnfs_curr_ld->encode_layoutreturn( |
| 2023 | NFS_I(args->inode)->layout, xdr, args); |
Trond Myklebust | 475d4ba | 2012-03-05 11:27:16 -0500 | [diff] [blame] | 2024 | } else |
| 2025 | encode_uint32(xdr, 0); |
Benny Halevy | cbe8260 | 2011-05-22 19:52:37 +0300 | [diff] [blame] | 2026 | } |
Bryan Schumaker | fca78d6 | 2011-06-02 14:59:07 -0400 | [diff] [blame] | 2027 | |
| 2028 | static int |
| 2029 | encode_secinfo_no_name(struct xdr_stream *xdr, |
| 2030 | const struct nfs41_secinfo_no_name_args *args, |
| 2031 | struct compound_hdr *hdr) |
| 2032 | { |
Trond Myklebust | 475d4ba | 2012-03-05 11:27:16 -0500 | [diff] [blame] | 2033 | encode_op_hdr(xdr, OP_SECINFO_NO_NAME, decode_secinfo_no_name_maxsz, hdr); |
| 2034 | encode_uint32(xdr, args->style); |
Bryan Schumaker | fca78d6 | 2011-06-02 14:59:07 -0400 | [diff] [blame] | 2035 | return 0; |
| 2036 | } |
Bryan Schumaker | 7d97479 | 2011-06-02 14:59:08 -0400 | [diff] [blame] | 2037 | |
| 2038 | static void encode_test_stateid(struct xdr_stream *xdr, |
| 2039 | struct nfs41_test_stateid_args *args, |
| 2040 | struct compound_hdr *hdr) |
| 2041 | { |
Trond Myklebust | 475d4ba | 2012-03-05 11:27:16 -0500 | [diff] [blame] | 2042 | encode_op_hdr(xdr, OP_TEST_STATEID, decode_test_stateid_maxsz, hdr); |
| 2043 | encode_uint32(xdr, 1); |
Trond Myklebust | ea9d23f | 2012-03-04 18:13:56 -0500 | [diff] [blame] | 2044 | encode_nfs4_stateid(xdr, args->stateid); |
Bryan Schumaker | 7d97479 | 2011-06-02 14:59:08 -0400 | [diff] [blame] | 2045 | } |
Bryan Schumaker | 9aeda35 | 2011-06-02 14:59:09 -0400 | [diff] [blame] | 2046 | |
| 2047 | static void encode_free_stateid(struct xdr_stream *xdr, |
| 2048 | struct nfs41_free_stateid_args *args, |
| 2049 | struct compound_hdr *hdr) |
| 2050 | { |
Trond Myklebust | ab19b48 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 2051 | encode_op_hdr(xdr, OP_FREE_STATEID, decode_free_stateid_maxsz, hdr); |
Trond Myklebust | 7c1d5fa | 2013-05-03 14:40:01 -0400 | [diff] [blame] | 2052 | encode_nfs4_stateid(xdr, &args->stateid); |
Bryan Schumaker | 9aeda35 | 2011-06-02 14:59:09 -0400 | [diff] [blame] | 2053 | } |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 2054 | #endif /* CONFIG_NFS_V4_1 */ |
| 2055 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2056 | /* |
| 2057 | * END OF "GENERIC" ENCODE ROUTINES. |
| 2058 | */ |
| 2059 | |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2060 | static u32 nfs4_xdr_minorversion(const struct nfs4_sequence_args *args) |
| 2061 | { |
| 2062 | #if defined(CONFIG_NFS_V4_1) |
Chuck Lever | 3bd2384 | 2013-08-09 12:49:19 -0400 | [diff] [blame] | 2063 | struct nfs4_session *session = args->sa_slot->table->session; |
| 2064 | if (session) |
| 2065 | return session->clp->cl_mvops->minor_version; |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2066 | #endif /* CONFIG_NFS_V4_1 */ |
| 2067 | return 0; |
| 2068 | } |
| 2069 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2070 | /* |
| 2071 | * Encode an ACCESS request |
| 2072 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2073 | static void nfs4_xdr_enc_access(struct rpc_rqst *req, struct xdr_stream *xdr, |
| 2074 | const struct nfs4_accessargs *args) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2075 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2076 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2077 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2078 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2079 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2080 | encode_compound_hdr(xdr, req, &hdr); |
| 2081 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2082 | encode_putfh(xdr, args->fh, &hdr); |
| 2083 | encode_access(xdr, args->access, &hdr); |
| 2084 | encode_getfattr(xdr, args->bitmask, &hdr); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2085 | encode_nops(&hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2086 | } |
| 2087 | |
| 2088 | /* |
| 2089 | * Encode LOOKUP request |
| 2090 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2091 | static void nfs4_xdr_enc_lookup(struct rpc_rqst *req, struct xdr_stream *xdr, |
| 2092 | const struct nfs4_lookup_arg *args) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2093 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2094 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2095 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2096 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2097 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2098 | encode_compound_hdr(xdr, req, &hdr); |
| 2099 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2100 | encode_putfh(xdr, args->dir_fh, &hdr); |
| 2101 | encode_lookup(xdr, args->name, &hdr); |
| 2102 | encode_getfh(xdr, &hdr); |
| 2103 | encode_getfattr(xdr, args->bitmask, &hdr); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2104 | encode_nops(&hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2105 | } |
| 2106 | |
| 2107 | /* |
| 2108 | * Encode LOOKUP_ROOT request |
| 2109 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2110 | static void nfs4_xdr_enc_lookup_root(struct rpc_rqst *req, |
| 2111 | struct xdr_stream *xdr, |
| 2112 | const struct nfs4_lookup_root_arg *args) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2113 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2114 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2115 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2116 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2117 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2118 | encode_compound_hdr(xdr, req, &hdr); |
| 2119 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2120 | encode_putrootfh(xdr, &hdr); |
| 2121 | encode_getfh(xdr, &hdr); |
| 2122 | encode_getfattr(xdr, args->bitmask, &hdr); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2123 | encode_nops(&hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2124 | } |
| 2125 | |
| 2126 | /* |
| 2127 | * Encode REMOVE request |
| 2128 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2129 | static void nfs4_xdr_enc_remove(struct rpc_rqst *req, struct xdr_stream *xdr, |
| 2130 | const struct nfs_removeargs *args) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2131 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2132 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2133 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2134 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2135 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2136 | encode_compound_hdr(xdr, req, &hdr); |
| 2137 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2138 | encode_putfh(xdr, args->fh, &hdr); |
| 2139 | encode_remove(xdr, &args->name, &hdr); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2140 | encode_nops(&hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2141 | } |
| 2142 | |
| 2143 | /* |
| 2144 | * Encode RENAME request |
| 2145 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2146 | static void nfs4_xdr_enc_rename(struct rpc_rqst *req, struct xdr_stream *xdr, |
| 2147 | const struct nfs_renameargs *args) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2148 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2149 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2150 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2151 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2152 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2153 | encode_compound_hdr(xdr, req, &hdr); |
| 2154 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2155 | encode_putfh(xdr, args->old_dir, &hdr); |
| 2156 | encode_savefh(xdr, &hdr); |
| 2157 | encode_putfh(xdr, args->new_dir, &hdr); |
| 2158 | encode_rename(xdr, args->old_name, args->new_name, &hdr); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2159 | encode_nops(&hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2160 | } |
| 2161 | |
| 2162 | /* |
| 2163 | * Encode LINK request |
| 2164 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2165 | static void nfs4_xdr_enc_link(struct rpc_rqst *req, struct xdr_stream *xdr, |
| 2166 | const struct nfs4_link_arg *args) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2167 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2168 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2169 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2170 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2171 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2172 | encode_compound_hdr(xdr, req, &hdr); |
| 2173 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2174 | encode_putfh(xdr, args->fh, &hdr); |
| 2175 | encode_savefh(xdr, &hdr); |
| 2176 | encode_putfh(xdr, args->dir_fh, &hdr); |
| 2177 | encode_link(xdr, args->name, &hdr); |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2178 | encode_restorefh(xdr, &hdr); |
| 2179 | encode_getfattr(xdr, args->bitmask, &hdr); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2180 | encode_nops(&hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2181 | } |
| 2182 | |
| 2183 | /* |
| 2184 | * Encode CREATE request |
| 2185 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2186 | static void nfs4_xdr_enc_create(struct rpc_rqst *req, struct xdr_stream *xdr, |
| 2187 | const struct nfs4_create_arg *args) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2188 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2189 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2190 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2191 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2192 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2193 | encode_compound_hdr(xdr, req, &hdr); |
| 2194 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2195 | encode_putfh(xdr, args->dir_fh, &hdr); |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2196 | encode_create(xdr, args, &hdr); |
| 2197 | encode_getfh(xdr, &hdr); |
| 2198 | encode_getfattr(xdr, args->bitmask, &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 SYMLINK request |
| 2204 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2205 | static void nfs4_xdr_enc_symlink(struct rpc_rqst *req, struct xdr_stream *xdr, |
| 2206 | const struct nfs4_create_arg *args) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2207 | { |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2208 | nfs4_xdr_enc_create(req, xdr, args); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2209 | } |
| 2210 | |
| 2211 | /* |
| 2212 | * Encode GETATTR request |
| 2213 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2214 | static void nfs4_xdr_enc_getattr(struct rpc_rqst *req, struct xdr_stream *xdr, |
| 2215 | const struct nfs4_getattr_arg *args) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2216 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2217 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2218 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2219 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2220 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2221 | encode_compound_hdr(xdr, req, &hdr); |
| 2222 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2223 | encode_putfh(xdr, args->fh, &hdr); |
| 2224 | encode_getfattr(xdr, args->bitmask, &hdr); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2225 | encode_nops(&hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2226 | } |
| 2227 | |
| 2228 | /* |
| 2229 | * Encode a CLOSE request |
| 2230 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2231 | static void nfs4_xdr_enc_close(struct rpc_rqst *req, struct xdr_stream *xdr, |
| 2232 | struct nfs_closeargs *args) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2233 | { |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 2234 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2235 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 2236 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2237 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2238 | encode_compound_hdr(xdr, req, &hdr); |
| 2239 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2240 | encode_putfh(xdr, args->fh, &hdr); |
| 2241 | encode_close(xdr, args, &hdr); |
| 2242 | encode_getfattr(xdr, args->bitmask, &hdr); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2243 | encode_nops(&hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2244 | } |
| 2245 | |
| 2246 | /* |
| 2247 | * Encode an OPEN request |
| 2248 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2249 | static void nfs4_xdr_enc_open(struct rpc_rqst *req, struct xdr_stream *xdr, |
| 2250 | struct nfs_openargs *args) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2251 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2252 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2253 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2254 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2255 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2256 | encode_compound_hdr(xdr, req, &hdr); |
| 2257 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2258 | encode_putfh(xdr, args->fh, &hdr); |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2259 | encode_open(xdr, args, &hdr); |
| 2260 | encode_getfh(xdr, &hdr); |
Weston Andros Adamson | ae2bb03 | 2012-10-02 14:49:52 -0700 | [diff] [blame] | 2261 | if (args->access) |
| 2262 | encode_access(xdr, args->access, &hdr); |
Trond Myklebust | 1549210f | 2012-06-05 09:16:47 -0400 | [diff] [blame] | 2263 | encode_getfattr_open(xdr, args->bitmask, args->open_bitmap, &hdr); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2264 | encode_nops(&hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2265 | } |
| 2266 | |
| 2267 | /* |
| 2268 | * Encode an OPEN_CONFIRM request |
| 2269 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2270 | static void nfs4_xdr_enc_open_confirm(struct rpc_rqst *req, |
| 2271 | struct xdr_stream *xdr, |
| 2272 | struct nfs_open_confirmargs *args) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2273 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2274 | struct compound_hdr hdr = { |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2275 | .nops = 0, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2276 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2277 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2278 | encode_compound_hdr(xdr, req, &hdr); |
| 2279 | encode_putfh(xdr, args->fh, &hdr); |
| 2280 | encode_open_confirm(xdr, args, &hdr); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2281 | encode_nops(&hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2282 | } |
| 2283 | |
| 2284 | /* |
| 2285 | * Encode an OPEN request with no attributes. |
| 2286 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2287 | static void nfs4_xdr_enc_open_noattr(struct rpc_rqst *req, |
| 2288 | struct xdr_stream *xdr, |
| 2289 | struct nfs_openargs *args) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2290 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2291 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2292 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2293 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2294 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2295 | encode_compound_hdr(xdr, req, &hdr); |
| 2296 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2297 | encode_putfh(xdr, args->fh, &hdr); |
| 2298 | encode_open(xdr, args, &hdr); |
Weston Andros Adamson | ae2bb03 | 2012-10-02 14:49:52 -0700 | [diff] [blame] | 2299 | if (args->access) |
| 2300 | encode_access(xdr, args->access, &hdr); |
Andy Adamson | e23008e | 2012-10-02 21:07:32 -0400 | [diff] [blame] | 2301 | encode_getfattr_open(xdr, args->bitmask, args->open_bitmap, &hdr); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2302 | encode_nops(&hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2303 | } |
| 2304 | |
| 2305 | /* |
| 2306 | * Encode an OPEN_DOWNGRADE request |
| 2307 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2308 | static void nfs4_xdr_enc_open_downgrade(struct rpc_rqst *req, |
| 2309 | struct xdr_stream *xdr, |
| 2310 | struct nfs_closeargs *args) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2311 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2312 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2313 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2314 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2315 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2316 | encode_compound_hdr(xdr, req, &hdr); |
| 2317 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2318 | encode_putfh(xdr, args->fh, &hdr); |
| 2319 | encode_open_downgrade(xdr, args, &hdr); |
| 2320 | encode_getfattr(xdr, args->bitmask, &hdr); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2321 | encode_nops(&hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2322 | } |
| 2323 | |
| 2324 | /* |
| 2325 | * Encode a LOCK request |
| 2326 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2327 | static void nfs4_xdr_enc_lock(struct rpc_rqst *req, struct xdr_stream *xdr, |
| 2328 | struct nfs_lock_args *args) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2329 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2330 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2331 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2332 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2333 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2334 | encode_compound_hdr(xdr, req, &hdr); |
| 2335 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2336 | encode_putfh(xdr, args->fh, &hdr); |
| 2337 | encode_lock(xdr, args, &hdr); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2338 | encode_nops(&hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2339 | } |
| 2340 | |
| 2341 | /* |
| 2342 | * Encode a LOCKT request |
| 2343 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2344 | static void nfs4_xdr_enc_lockt(struct rpc_rqst *req, struct xdr_stream *xdr, |
| 2345 | struct nfs_lockt_args *args) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2346 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2347 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2348 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2349 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2350 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2351 | encode_compound_hdr(xdr, req, &hdr); |
| 2352 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2353 | encode_putfh(xdr, args->fh, &hdr); |
| 2354 | encode_lockt(xdr, args, &hdr); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2355 | encode_nops(&hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2356 | } |
| 2357 | |
| 2358 | /* |
| 2359 | * Encode a LOCKU request |
| 2360 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2361 | static void nfs4_xdr_enc_locku(struct rpc_rqst *req, struct xdr_stream *xdr, |
| 2362 | struct nfs_locku_args *args) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2363 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2364 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2365 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2366 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2367 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2368 | encode_compound_hdr(xdr, req, &hdr); |
| 2369 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2370 | encode_putfh(xdr, args->fh, &hdr); |
| 2371 | encode_locku(xdr, args, &hdr); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2372 | encode_nops(&hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2373 | } |
| 2374 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2375 | static void nfs4_xdr_enc_release_lockowner(struct rpc_rqst *req, |
| 2376 | struct xdr_stream *xdr, |
| 2377 | struct nfs_release_lockowner_args *args) |
Trond Myklebust | d3c7b7c | 2010-07-01 12:49:01 -0400 | [diff] [blame] | 2378 | { |
Trond Myklebust | d3c7b7c | 2010-07-01 12:49:01 -0400 | [diff] [blame] | 2379 | struct compound_hdr hdr = { |
| 2380 | .minorversion = 0, |
| 2381 | }; |
| 2382 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2383 | encode_compound_hdr(xdr, req, &hdr); |
| 2384 | encode_release_lockowner(xdr, &args->lock_owner, &hdr); |
Trond Myklebust | d3c7b7c | 2010-07-01 12:49:01 -0400 | [diff] [blame] | 2385 | encode_nops(&hdr); |
Trond Myklebust | d3c7b7c | 2010-07-01 12:49:01 -0400 | [diff] [blame] | 2386 | } |
| 2387 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2388 | /* |
| 2389 | * Encode a READLINK request |
| 2390 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2391 | static void nfs4_xdr_enc_readlink(struct rpc_rqst *req, struct xdr_stream *xdr, |
| 2392 | const struct nfs4_readlink *args) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2393 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2394 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2395 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2396 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2397 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2398 | encode_compound_hdr(xdr, req, &hdr); |
| 2399 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2400 | encode_putfh(xdr, args->fh, &hdr); |
| 2401 | encode_readlink(xdr, args, req, &hdr); |
Trond Myklebust | e3a535e | 2007-07-19 10:03:38 -0400 | [diff] [blame] | 2402 | |
Benny Halevy | 28f5669 | 2009-04-01 09:22:09 -0400 | [diff] [blame] | 2403 | xdr_inline_pages(&req->rq_rcv_buf, hdr.replen << 2, args->pages, |
Trond Myklebust | e3a535e | 2007-07-19 10:03:38 -0400 | [diff] [blame] | 2404 | args->pgbase, args->pglen); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2405 | encode_nops(&hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2406 | } |
| 2407 | |
| 2408 | /* |
| 2409 | * Encode a READDIR request |
| 2410 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2411 | static void nfs4_xdr_enc_readdir(struct rpc_rqst *req, struct xdr_stream *xdr, |
| 2412 | const struct nfs4_readdir_arg *args) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2413 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2414 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2415 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2416 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2417 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2418 | encode_compound_hdr(xdr, req, &hdr); |
| 2419 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2420 | encode_putfh(xdr, args->fh, &hdr); |
| 2421 | encode_readdir(xdr, args, req, &hdr); |
Trond Myklebust | d6ac02d | 2007-07-19 10:03:37 -0400 | [diff] [blame] | 2422 | |
Benny Halevy | 28f5669 | 2009-04-01 09:22:09 -0400 | [diff] [blame] | 2423 | xdr_inline_pages(&req->rq_rcv_buf, hdr.replen << 2, args->pages, |
Trond Myklebust | d6ac02d | 2007-07-19 10:03:37 -0400 | [diff] [blame] | 2424 | args->pgbase, args->count); |
| 2425 | dprintk("%s: inlined page args = (%u, %p, %u, %u)\n", |
Benny Halevy | 28f5669 | 2009-04-01 09:22:09 -0400 | [diff] [blame] | 2426 | __func__, hdr.replen << 2, args->pages, |
Trond Myklebust | d6ac02d | 2007-07-19 10:03:37 -0400 | [diff] [blame] | 2427 | args->pgbase, args->count); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2428 | encode_nops(&hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2429 | } |
| 2430 | |
| 2431 | /* |
| 2432 | * Encode a READ request |
| 2433 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2434 | static void nfs4_xdr_enc_read(struct rpc_rqst *req, struct xdr_stream *xdr, |
Anna Schumaker | 3c6b899 | 2014-05-06 09:12:24 -0400 | [diff] [blame] | 2435 | struct nfs_pgio_args *args) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2436 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2437 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2438 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2439 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2440 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2441 | encode_compound_hdr(xdr, req, &hdr); |
| 2442 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2443 | encode_putfh(xdr, args->fh, &hdr); |
| 2444 | encode_read(xdr, args, &hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2445 | |
Benny Halevy | 28f5669 | 2009-04-01 09:22:09 -0400 | [diff] [blame] | 2446 | xdr_inline_pages(&req->rq_rcv_buf, hdr.replen << 2, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2447 | args->pages, args->pgbase, args->count); |
\"Talpey, Thomas\ | 4f22ccc | 2007-09-10 13:44:58 -0400 | [diff] [blame] | 2448 | req->rq_rcv_buf.flags |= XDRBUF_READ; |
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 | |
| 2452 | /* |
| 2453 | * Encode an SETATTR request |
| 2454 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2455 | static void nfs4_xdr_enc_setattr(struct rpc_rqst *req, struct xdr_stream *xdr, |
| 2456 | struct nfs_setattrargs *args) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2457 | { |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 2458 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2459 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 2460 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2461 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2462 | encode_compound_hdr(xdr, req, &hdr); |
| 2463 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2464 | encode_putfh(xdr, args->fh, &hdr); |
| 2465 | encode_setattr(xdr, args, args->server, &hdr); |
| 2466 | encode_getfattr(xdr, args->bitmask, &hdr); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2467 | encode_nops(&hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2468 | } |
| 2469 | |
| 2470 | /* |
J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 2471 | * Encode a GETACL request |
| 2472 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2473 | static void nfs4_xdr_enc_getacl(struct rpc_rqst *req, struct xdr_stream *xdr, |
| 2474 | struct nfs_getaclargs *args) |
J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 2475 | { |
J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 2476 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2477 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 2478 | }; |
Benny Halevy | 28f5669 | 2009-04-01 09:22:09 -0400 | [diff] [blame] | 2479 | uint32_t replen; |
J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 2480 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2481 | encode_compound_hdr(xdr, req, &hdr); |
| 2482 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2483 | encode_putfh(xdr, args->fh, &hdr); |
Andy Adamson | bf118a3 | 2011-12-07 11:55:27 -0500 | [diff] [blame] | 2484 | replen = hdr.replen + op_decode_hdr_maxsz + 1; |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2485 | encode_getattr_two(xdr, FATTR4_WORD0_ACL, 0, &hdr); |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 2486 | |
Benny Halevy | 28f5669 | 2009-04-01 09:22:09 -0400 | [diff] [blame] | 2487 | xdr_inline_pages(&req->rq_rcv_buf, replen << 2, |
J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 2488 | args->acl_pages, args->acl_pgbase, args->acl_len); |
Andy Adamson | bf118a3 | 2011-12-07 11:55:27 -0500 | [diff] [blame] | 2489 | |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2490 | encode_nops(&hdr); |
J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 2491 | } |
| 2492 | |
| 2493 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2494 | * Encode a WRITE request |
| 2495 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2496 | static void nfs4_xdr_enc_write(struct rpc_rqst *req, struct xdr_stream *xdr, |
Anna Schumaker | 3c6b899 | 2014-05-06 09:12:24 -0400 | [diff] [blame] | 2497 | struct nfs_pgio_args *args) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2498 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2499 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2500 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2501 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2502 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2503 | encode_compound_hdr(xdr, req, &hdr); |
| 2504 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2505 | encode_putfh(xdr, args->fh, &hdr); |
| 2506 | encode_write(xdr, args, &hdr); |
\"Talpey, Thomas\ | 4f22ccc | 2007-09-10 13:44:58 -0400 | [diff] [blame] | 2507 | req->rq_snd_buf.flags |= XDRBUF_WRITE; |
Fred Isaman | 7ffd106 | 2011-03-03 15:13:46 +0000 | [diff] [blame] | 2508 | if (args->bitmask) |
| 2509 | encode_getfattr(xdr, args->bitmask, &hdr); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2510 | encode_nops(&hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2511 | } |
| 2512 | |
| 2513 | /* |
| 2514 | * a COMMIT request |
| 2515 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2516 | static void nfs4_xdr_enc_commit(struct rpc_rqst *req, struct xdr_stream *xdr, |
Fred Isaman | 0b7c015 | 2012-04-20 14:47:39 -0400 | [diff] [blame] | 2517 | struct nfs_commitargs *args) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2518 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2519 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2520 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2521 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2522 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2523 | encode_compound_hdr(xdr, req, &hdr); |
| 2524 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2525 | encode_putfh(xdr, args->fh, &hdr); |
| 2526 | encode_commit(xdr, args, &hdr); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2527 | encode_nops(&hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2528 | } |
| 2529 | |
| 2530 | /* |
| 2531 | * FSINFO request |
| 2532 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2533 | static void nfs4_xdr_enc_fsinfo(struct rpc_rqst *req, struct xdr_stream *xdr, |
| 2534 | struct nfs4_fsinfo_arg *args) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2535 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2536 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2537 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2538 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2539 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2540 | encode_compound_hdr(xdr, req, &hdr); |
| 2541 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2542 | encode_putfh(xdr, args->fh, &hdr); |
| 2543 | encode_fsinfo(xdr, args->bitmask, &hdr); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2544 | encode_nops(&hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2545 | } |
| 2546 | |
| 2547 | /* |
| 2548 | * a PATHCONF request |
| 2549 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2550 | static void nfs4_xdr_enc_pathconf(struct rpc_rqst *req, struct xdr_stream *xdr, |
| 2551 | const struct nfs4_pathconf_arg *args) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2552 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2553 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2554 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2555 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2556 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2557 | encode_compound_hdr(xdr, req, &hdr); |
| 2558 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2559 | encode_putfh(xdr, args->fh, &hdr); |
| 2560 | encode_getattr_one(xdr, args->bitmask[0] & nfs4_pathconf_bitmap[0], |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 2561 | &hdr); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2562 | encode_nops(&hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2563 | } |
| 2564 | |
| 2565 | /* |
| 2566 | * a STATFS request |
| 2567 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2568 | static void nfs4_xdr_enc_statfs(struct rpc_rqst *req, struct xdr_stream *xdr, |
| 2569 | const struct nfs4_statfs_arg *args) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2570 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2571 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2572 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2573 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2574 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2575 | encode_compound_hdr(xdr, req, &hdr); |
| 2576 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2577 | encode_putfh(xdr, args->fh, &hdr); |
| 2578 | encode_getattr_two(xdr, args->bitmask[0] & nfs4_statfs_bitmap[0], |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 2579 | args->bitmask[1] & nfs4_statfs_bitmap[1], &hdr); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2580 | encode_nops(&hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2581 | } |
| 2582 | |
| 2583 | /* |
| 2584 | * GETATTR_BITMAP request |
| 2585 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2586 | static void nfs4_xdr_enc_server_caps(struct rpc_rqst *req, |
| 2587 | struct xdr_stream *xdr, |
| 2588 | struct nfs4_server_caps_arg *args) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2589 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2590 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2591 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2592 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2593 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2594 | encode_compound_hdr(xdr, req, &hdr); |
| 2595 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2596 | encode_putfh(xdr, args->fhandle, &hdr); |
| 2597 | encode_getattr_one(xdr, FATTR4_WORD0_SUPPORTED_ATTRS| |
Chuck Lever | 264e635 | 2012-03-01 17:02:05 -0500 | [diff] [blame] | 2598 | FATTR4_WORD0_FH_EXPIRE_TYPE| |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 2599 | FATTR4_WORD0_LINK_SUPPORT| |
| 2600 | FATTR4_WORD0_SYMLINK_SUPPORT| |
| 2601 | FATTR4_WORD0_ACLSUPPORT, &hdr); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2602 | encode_nops(&hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2603 | } |
| 2604 | |
| 2605 | /* |
| 2606 | * a RENEW request |
| 2607 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2608 | static void nfs4_xdr_enc_renew(struct rpc_rqst *req, struct xdr_stream *xdr, |
| 2609 | struct nfs_client *clp) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2610 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2611 | struct compound_hdr hdr = { |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2612 | .nops = 0, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2613 | }; |
| 2614 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2615 | encode_compound_hdr(xdr, req, &hdr); |
Chuck Lever | bb4dae5 | 2012-03-01 17:01:48 -0500 | [diff] [blame] | 2616 | encode_renew(xdr, clp->cl_clientid, &hdr); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2617 | encode_nops(&hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2618 | } |
| 2619 | |
| 2620 | /* |
| 2621 | * a SETCLIENTID request |
| 2622 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2623 | static void nfs4_xdr_enc_setclientid(struct rpc_rqst *req, |
| 2624 | struct xdr_stream *xdr, |
| 2625 | struct nfs4_setclientid *sc) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2626 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2627 | struct compound_hdr hdr = { |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2628 | .nops = 0, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2629 | }; |
| 2630 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2631 | encode_compound_hdr(xdr, req, &hdr); |
| 2632 | encode_setclientid(xdr, sc, &hdr); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2633 | encode_nops(&hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2634 | } |
| 2635 | |
| 2636 | /* |
| 2637 | * a SETCLIENTID_CONFIRM request |
| 2638 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2639 | static void nfs4_xdr_enc_setclientid_confirm(struct rpc_rqst *req, |
| 2640 | struct xdr_stream *xdr, |
| 2641 | struct nfs4_setclientid_res *arg) |
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 | struct compound_hdr hdr = { |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2644 | .nops = 0, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2645 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2646 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2647 | encode_compound_hdr(xdr, req, &hdr); |
| 2648 | encode_setclientid_confirm(xdr, arg, &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 | * DELEGRETURN request |
| 2654 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2655 | static void nfs4_xdr_enc_delegreturn(struct rpc_rqst *req, |
| 2656 | struct xdr_stream *xdr, |
| 2657 | const struct nfs4_delegreturnargs *args) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2658 | { |
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->fhandle, &hdr); |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2666 | encode_getfattr(xdr, args->bitmask, &hdr); |
Trond Myklebust | e144cbc | 2012-04-28 16:05:03 -0400 | [diff] [blame] | 2667 | encode_delegreturn(xdr, args->stateid, &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 | /* |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 2672 | * Encode FS_LOCATIONS request |
| 2673 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2674 | static void nfs4_xdr_enc_fs_locations(struct rpc_rqst *req, |
| 2675 | struct xdr_stream *xdr, |
| 2676 | struct nfs4_fs_locations_arg *args) |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 2677 | { |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 2678 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2679 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 2680 | }; |
Benny Halevy | 28f5669 | 2009-04-01 09:22:09 -0400 | [diff] [blame] | 2681 | uint32_t replen; |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 2682 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2683 | encode_compound_hdr(xdr, req, &hdr); |
| 2684 | encode_sequence(xdr, &args->seq_args, &hdr); |
Chuck Lever | b03d735 | 2013-10-17 14:12:50 -0400 | [diff] [blame] | 2685 | if (args->migration) { |
| 2686 | encode_putfh(xdr, args->fh, &hdr); |
| 2687 | replen = hdr.replen; |
| 2688 | encode_fs_locations(xdr, args->bitmask, &hdr); |
| 2689 | if (args->renew) |
| 2690 | encode_renew(xdr, args->clientid, &hdr); |
| 2691 | } else { |
| 2692 | encode_putfh(xdr, args->dir_fh, &hdr); |
| 2693 | encode_lookup(xdr, args->name, &hdr); |
| 2694 | replen = hdr.replen; |
| 2695 | encode_fs_locations(xdr, args->bitmask, &hdr); |
| 2696 | } |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 2697 | |
Chuck Lever | b03d735 | 2013-10-17 14:12:50 -0400 | [diff] [blame] | 2698 | /* Set up reply kvec to capture returned fs_locations array. */ |
Benny Halevy | 28f5669 | 2009-04-01 09:22:09 -0400 | [diff] [blame] | 2699 | xdr_inline_pages(&req->rq_rcv_buf, replen << 2, &args->page, |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 2700 | 0, PAGE_SIZE); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2701 | encode_nops(&hdr); |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 2702 | } |
| 2703 | |
Bryan Schumaker | 5a5ea0d | 2011-03-24 17:12:29 +0000 | [diff] [blame] | 2704 | /* |
| 2705 | * Encode SECINFO request |
| 2706 | */ |
| 2707 | static void nfs4_xdr_enc_secinfo(struct rpc_rqst *req, |
| 2708 | struct xdr_stream *xdr, |
| 2709 | struct nfs4_secinfo_arg *args) |
| 2710 | { |
| 2711 | struct compound_hdr hdr = { |
| 2712 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
| 2713 | }; |
| 2714 | |
| 2715 | encode_compound_hdr(xdr, req, &hdr); |
| 2716 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2717 | encode_putfh(xdr, args->dir_fh, &hdr); |
| 2718 | encode_secinfo(xdr, args->name, &hdr); |
| 2719 | encode_nops(&hdr); |
| 2720 | } |
| 2721 | |
Chuck Lever | 44c9993 | 2013-10-17 14:13:30 -0400 | [diff] [blame] | 2722 | /* |
| 2723 | * Encode FSID_PRESENT request |
| 2724 | */ |
| 2725 | static void nfs4_xdr_enc_fsid_present(struct rpc_rqst *req, |
| 2726 | struct xdr_stream *xdr, |
| 2727 | struct nfs4_fsid_present_arg *args) |
| 2728 | { |
| 2729 | struct compound_hdr hdr = { |
| 2730 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
| 2731 | }; |
| 2732 | |
| 2733 | encode_compound_hdr(xdr, req, &hdr); |
| 2734 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2735 | encode_putfh(xdr, args->fh, &hdr); |
| 2736 | encode_getfh(xdr, &hdr); |
| 2737 | if (args->renew) |
| 2738 | encode_renew(xdr, args->clientid, &hdr); |
| 2739 | encode_nops(&hdr); |
| 2740 | } |
| 2741 | |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 2742 | #if defined(CONFIG_NFS_V4_1) |
| 2743 | /* |
Weston Andros Adamson | 7c44f1ae | 2012-05-24 13:22:50 -0400 | [diff] [blame] | 2744 | * BIND_CONN_TO_SESSION request |
| 2745 | */ |
| 2746 | static void nfs4_xdr_enc_bind_conn_to_session(struct rpc_rqst *req, |
| 2747 | struct xdr_stream *xdr, |
| 2748 | struct nfs_client *clp) |
| 2749 | { |
| 2750 | struct compound_hdr hdr = { |
| 2751 | .minorversion = clp->cl_mvops->minor_version, |
| 2752 | }; |
| 2753 | |
| 2754 | encode_compound_hdr(xdr, req, &hdr); |
| 2755 | encode_bind_conn_to_session(xdr, clp->cl_session, &hdr); |
| 2756 | encode_nops(&hdr); |
| 2757 | } |
| 2758 | |
| 2759 | /* |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 2760 | * EXCHANGE_ID request |
| 2761 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2762 | static void nfs4_xdr_enc_exchange_id(struct rpc_rqst *req, |
| 2763 | struct xdr_stream *xdr, |
| 2764 | struct nfs41_exchange_id_args *args) |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 2765 | { |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 2766 | struct compound_hdr hdr = { |
Trond Myklebust | a443234 | 2010-06-16 09:52:27 -0400 | [diff] [blame] | 2767 | .minorversion = args->client->cl_mvops->minor_version, |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 2768 | }; |
| 2769 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2770 | encode_compound_hdr(xdr, req, &hdr); |
| 2771 | encode_exchange_id(xdr, args, &hdr); |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 2772 | encode_nops(&hdr); |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 2773 | } |
Andy Adamson | 2050f0c | 2009-04-01 09:22:30 -0400 | [diff] [blame] | 2774 | |
| 2775 | /* |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 2776 | * a CREATE_SESSION request |
| 2777 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2778 | static void nfs4_xdr_enc_create_session(struct rpc_rqst *req, |
| 2779 | struct xdr_stream *xdr, |
| 2780 | struct nfs41_create_session_args *args) |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 2781 | { |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 2782 | struct compound_hdr hdr = { |
Trond Myklebust | a443234 | 2010-06-16 09:52:27 -0400 | [diff] [blame] | 2783 | .minorversion = args->client->cl_mvops->minor_version, |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 2784 | }; |
| 2785 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2786 | encode_compound_hdr(xdr, req, &hdr); |
| 2787 | encode_create_session(xdr, args, &hdr); |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 2788 | encode_nops(&hdr); |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 2789 | } |
| 2790 | |
| 2791 | /* |
Andy Adamson | 0f3e66c | 2009-04-01 09:22:34 -0400 | [diff] [blame] | 2792 | * a DESTROY_SESSION request |
| 2793 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2794 | static void nfs4_xdr_enc_destroy_session(struct rpc_rqst *req, |
| 2795 | struct xdr_stream *xdr, |
| 2796 | struct nfs4_session *session) |
Andy Adamson | 0f3e66c | 2009-04-01 09:22:34 -0400 | [diff] [blame] | 2797 | { |
Andy Adamson | 0f3e66c | 2009-04-01 09:22:34 -0400 | [diff] [blame] | 2798 | struct compound_hdr hdr = { |
Trond Myklebust | a443234 | 2010-06-16 09:52:27 -0400 | [diff] [blame] | 2799 | .minorversion = session->clp->cl_mvops->minor_version, |
Andy Adamson | 0f3e66c | 2009-04-01 09:22:34 -0400 | [diff] [blame] | 2800 | }; |
| 2801 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2802 | encode_compound_hdr(xdr, req, &hdr); |
| 2803 | encode_destroy_session(xdr, session, &hdr); |
Andy Adamson | 0f3e66c | 2009-04-01 09:22:34 -0400 | [diff] [blame] | 2804 | encode_nops(&hdr); |
Andy Adamson | 0f3e66c | 2009-04-01 09:22:34 -0400 | [diff] [blame] | 2805 | } |
| 2806 | |
| 2807 | /* |
Trond Myklebust | 6624553 | 2012-05-25 17:18:09 -0400 | [diff] [blame] | 2808 | * a DESTROY_CLIENTID request |
| 2809 | */ |
| 2810 | static void nfs4_xdr_enc_destroy_clientid(struct rpc_rqst *req, |
| 2811 | struct xdr_stream *xdr, |
| 2812 | struct nfs_client *clp) |
| 2813 | { |
| 2814 | struct compound_hdr hdr = { |
| 2815 | .minorversion = clp->cl_mvops->minor_version, |
| 2816 | }; |
| 2817 | |
| 2818 | encode_compound_hdr(xdr, req, &hdr); |
| 2819 | encode_destroy_clientid(xdr, clp->cl_clientid, &hdr); |
| 2820 | encode_nops(&hdr); |
| 2821 | } |
| 2822 | |
| 2823 | /* |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 2824 | * a SEQUENCE request |
| 2825 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2826 | static void nfs4_xdr_enc_sequence(struct rpc_rqst *req, struct xdr_stream *xdr, |
| 2827 | struct nfs4_sequence_args *args) |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 2828 | { |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 2829 | struct compound_hdr hdr = { |
| 2830 | .minorversion = nfs4_xdr_minorversion(args), |
| 2831 | }; |
| 2832 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2833 | encode_compound_hdr(xdr, req, &hdr); |
| 2834 | encode_sequence(xdr, args, &hdr); |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 2835 | encode_nops(&hdr); |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 2836 | } |
| 2837 | |
| 2838 | /* |
Andy Adamson | 2050f0c | 2009-04-01 09:22:30 -0400 | [diff] [blame] | 2839 | * a GET_LEASE_TIME request |
| 2840 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2841 | static void nfs4_xdr_enc_get_lease_time(struct rpc_rqst *req, |
| 2842 | struct xdr_stream *xdr, |
| 2843 | struct nfs4_get_lease_time_args *args) |
Andy Adamson | 2050f0c | 2009-04-01 09:22:30 -0400 | [diff] [blame] | 2844 | { |
Andy Adamson | 2050f0c | 2009-04-01 09:22:30 -0400 | [diff] [blame] | 2845 | struct compound_hdr hdr = { |
| 2846 | .minorversion = nfs4_xdr_minorversion(&args->la_seq_args), |
| 2847 | }; |
Fred Isaman | dae100c | 2011-07-30 20:52:37 -0400 | [diff] [blame] | 2848 | const u32 lease_bitmap[3] = { FATTR4_WORD0_LEASE_TIME }; |
Andy Adamson | 2050f0c | 2009-04-01 09:22:30 -0400 | [diff] [blame] | 2849 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2850 | encode_compound_hdr(xdr, req, &hdr); |
| 2851 | encode_sequence(xdr, &args->la_seq_args, &hdr); |
| 2852 | encode_putrootfh(xdr, &hdr); |
| 2853 | encode_fsinfo(xdr, lease_bitmap, &hdr); |
Andy Adamson | 2050f0c | 2009-04-01 09:22:30 -0400 | [diff] [blame] | 2854 | encode_nops(&hdr); |
Andy Adamson | 2050f0c | 2009-04-01 09:22:30 -0400 | [diff] [blame] | 2855 | } |
Ricardo Labiaga | 18019753 | 2009-12-05 16:08:40 -0500 | [diff] [blame] | 2856 | |
| 2857 | /* |
| 2858 | * a RECLAIM_COMPLETE request |
| 2859 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2860 | static void nfs4_xdr_enc_reclaim_complete(struct rpc_rqst *req, |
| 2861 | struct xdr_stream *xdr, |
| 2862 | struct nfs41_reclaim_complete_args *args) |
Ricardo Labiaga | 18019753 | 2009-12-05 16:08:40 -0500 | [diff] [blame] | 2863 | { |
Ricardo Labiaga | 18019753 | 2009-12-05 16:08:40 -0500 | [diff] [blame] | 2864 | struct compound_hdr hdr = { |
| 2865 | .minorversion = nfs4_xdr_minorversion(&args->seq_args) |
| 2866 | }; |
| 2867 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2868 | encode_compound_hdr(xdr, req, &hdr); |
| 2869 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2870 | encode_reclaim_complete(xdr, args, &hdr); |
Ricardo Labiaga | 18019753 | 2009-12-05 16:08:40 -0500 | [diff] [blame] | 2871 | encode_nops(&hdr); |
Ricardo Labiaga | 18019753 | 2009-12-05 16:08:40 -0500 | [diff] [blame] | 2872 | } |
| 2873 | |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 2874 | /* |
| 2875 | * Encode GETDEVICEINFO request |
| 2876 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2877 | static void nfs4_xdr_enc_getdeviceinfo(struct rpc_rqst *req, |
| 2878 | struct xdr_stream *xdr, |
| 2879 | struct nfs4_getdeviceinfo_args *args) |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 2880 | { |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 2881 | struct compound_hdr hdr = { |
| 2882 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
| 2883 | }; |
| 2884 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2885 | encode_compound_hdr(xdr, req, &hdr); |
| 2886 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2887 | encode_getdeviceinfo(xdr, args, &hdr); |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 2888 | |
| 2889 | /* set up reply kvec. Subtract notification bitmap max size (2) |
| 2890 | * so that notification bitmap is put in xdr_buf tail */ |
| 2891 | xdr_inline_pages(&req->rq_rcv_buf, (hdr.replen - 2) << 2, |
| 2892 | args->pdev->pages, args->pdev->pgbase, |
| 2893 | args->pdev->pglen); |
| 2894 | |
| 2895 | encode_nops(&hdr); |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 2896 | } |
| 2897 | |
| 2898 | /* |
| 2899 | * Encode LAYOUTGET request |
| 2900 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2901 | static void nfs4_xdr_enc_layoutget(struct rpc_rqst *req, |
| 2902 | struct xdr_stream *xdr, |
| 2903 | struct nfs4_layoutget_args *args) |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 2904 | { |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 2905 | struct compound_hdr hdr = { |
| 2906 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
| 2907 | }; |
| 2908 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2909 | encode_compound_hdr(xdr, req, &hdr); |
| 2910 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2911 | encode_putfh(xdr, NFS_FH(args->inode), &hdr); |
| 2912 | encode_layoutget(xdr, args, &hdr); |
Weston Andros Adamson | 35124a0 | 2011-03-24 16:48:21 -0400 | [diff] [blame] | 2913 | |
| 2914 | xdr_inline_pages(&req->rq_rcv_buf, hdr.replen << 2, |
| 2915 | args->layout.pages, 0, args->layout.pglen); |
| 2916 | |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 2917 | encode_nops(&hdr); |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 2918 | } |
Andy Adamson | 863a3c6 | 2011-03-23 13:27:54 +0000 | [diff] [blame] | 2919 | |
| 2920 | /* |
| 2921 | * Encode LAYOUTCOMMIT request |
| 2922 | */ |
Benny Halevy | cbe8260 | 2011-05-22 19:52:37 +0300 | [diff] [blame] | 2923 | static void nfs4_xdr_enc_layoutcommit(struct rpc_rqst *req, |
| 2924 | struct xdr_stream *xdr, |
| 2925 | struct nfs4_layoutcommit_args *args) |
Andy Adamson | 863a3c6 | 2011-03-23 13:27:54 +0000 | [diff] [blame] | 2926 | { |
Benny Halevy | ac7db72 | 2011-05-22 19:53:48 +0300 | [diff] [blame] | 2927 | struct nfs4_layoutcommit_data *data = |
| 2928 | container_of(args, struct nfs4_layoutcommit_data, args); |
Andy Adamson | 863a3c6 | 2011-03-23 13:27:54 +0000 | [diff] [blame] | 2929 | struct compound_hdr hdr = { |
| 2930 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
| 2931 | }; |
| 2932 | |
| 2933 | encode_compound_hdr(xdr, req, &hdr); |
| 2934 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2935 | encode_putfh(xdr, NFS_FH(args->inode), &hdr); |
Benny Halevy | ac7db72 | 2011-05-22 19:53:48 +0300 | [diff] [blame] | 2936 | encode_layoutcommit(xdr, data->args.inode, args, &hdr); |
Andy Adamson | 863a3c6 | 2011-03-23 13:27:54 +0000 | [diff] [blame] | 2937 | encode_getfattr(xdr, args->bitmask, &hdr); |
| 2938 | encode_nops(&hdr); |
Benny Halevy | cbe8260 | 2011-05-22 19:52:37 +0300 | [diff] [blame] | 2939 | } |
| 2940 | |
| 2941 | /* |
| 2942 | * Encode LAYOUTRETURN request |
| 2943 | */ |
| 2944 | static void nfs4_xdr_enc_layoutreturn(struct rpc_rqst *req, |
| 2945 | struct xdr_stream *xdr, |
| 2946 | struct nfs4_layoutreturn_args *args) |
| 2947 | { |
| 2948 | struct compound_hdr hdr = { |
| 2949 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
| 2950 | }; |
| 2951 | |
| 2952 | encode_compound_hdr(xdr, req, &hdr); |
| 2953 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2954 | encode_putfh(xdr, NFS_FH(args->inode), &hdr); |
| 2955 | encode_layoutreturn(xdr, args, &hdr); |
| 2956 | encode_nops(&hdr); |
Andy Adamson | 863a3c6 | 2011-03-23 13:27:54 +0000 | [diff] [blame] | 2957 | } |
Bryan Schumaker | fca78d6 | 2011-06-02 14:59:07 -0400 | [diff] [blame] | 2958 | |
| 2959 | /* |
| 2960 | * Encode SECINFO_NO_NAME request |
| 2961 | */ |
| 2962 | static int nfs4_xdr_enc_secinfo_no_name(struct rpc_rqst *req, |
| 2963 | struct xdr_stream *xdr, |
| 2964 | struct nfs41_secinfo_no_name_args *args) |
| 2965 | { |
| 2966 | struct compound_hdr hdr = { |
| 2967 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
| 2968 | }; |
| 2969 | |
| 2970 | encode_compound_hdr(xdr, req, &hdr); |
| 2971 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2972 | encode_putrootfh(xdr, &hdr); |
| 2973 | encode_secinfo_no_name(xdr, args, &hdr); |
| 2974 | encode_nops(&hdr); |
| 2975 | return 0; |
| 2976 | } |
Bryan Schumaker | 7d97479 | 2011-06-02 14:59:08 -0400 | [diff] [blame] | 2977 | |
| 2978 | /* |
| 2979 | * Encode TEST_STATEID request |
| 2980 | */ |
| 2981 | static void nfs4_xdr_enc_test_stateid(struct rpc_rqst *req, |
| 2982 | struct xdr_stream *xdr, |
| 2983 | struct nfs41_test_stateid_args *args) |
| 2984 | { |
| 2985 | struct compound_hdr hdr = { |
| 2986 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
| 2987 | }; |
| 2988 | |
| 2989 | encode_compound_hdr(xdr, req, &hdr); |
| 2990 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2991 | encode_test_stateid(xdr, args, &hdr); |
| 2992 | encode_nops(&hdr); |
| 2993 | } |
Bryan Schumaker | 9aeda35 | 2011-06-02 14:59:09 -0400 | [diff] [blame] | 2994 | |
| 2995 | /* |
| 2996 | * Encode FREE_STATEID request |
| 2997 | */ |
| 2998 | static void nfs4_xdr_enc_free_stateid(struct rpc_rqst *req, |
| 2999 | struct xdr_stream *xdr, |
| 3000 | struct nfs41_free_stateid_args *args) |
| 3001 | { |
| 3002 | struct compound_hdr hdr = { |
| 3003 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
| 3004 | }; |
| 3005 | |
| 3006 | encode_compound_hdr(xdr, req, &hdr); |
| 3007 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 3008 | encode_free_stateid(xdr, args, &hdr); |
| 3009 | encode_nops(&hdr); |
| 3010 | } |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 3011 | #endif /* CONFIG_NFS_V4_1 */ |
| 3012 | |
Benny Halevy | 686841b | 2009-08-14 17:19:48 +0300 | [diff] [blame] | 3013 | static void print_overflow_msg(const char *func, const struct xdr_stream *xdr) |
| 3014 | { |
| 3015 | dprintk("nfs: %s: prematurely hit end of receive buffer. " |
| 3016 | "Remaining buffer length is %tu words.\n", |
| 3017 | func, xdr->end - xdr->p); |
| 3018 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3019 | |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 3020 | 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] | 3021 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3022 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3023 | |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3024 | p = xdr_inline_decode(xdr, 4); |
| 3025 | if (unlikely(!p)) |
| 3026 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3027 | *len = be32_to_cpup(p); |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3028 | p = xdr_inline_decode(xdr, *len); |
| 3029 | if (unlikely(!p)) |
| 3030 | goto out_overflow; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3031 | *string = (char *)p; |
| 3032 | return 0; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3033 | out_overflow: |
| 3034 | print_overflow_msg(__func__, xdr); |
| 3035 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3036 | } |
| 3037 | |
| 3038 | static int decode_compound_hdr(struct xdr_stream *xdr, struct compound_hdr *hdr) |
| 3039 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3040 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3041 | |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3042 | p = xdr_inline_decode(xdr, 8); |
| 3043 | if (unlikely(!p)) |
| 3044 | goto out_overflow; |
Benny Halevy | 6f723f7 | 2009-08-14 17:19:37 +0300 | [diff] [blame] | 3045 | hdr->status = be32_to_cpup(p++); |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3046 | hdr->taglen = be32_to_cpup(p); |
Andy Adamson | 6c0195a | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 3047 | |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3048 | p = xdr_inline_decode(xdr, hdr->taglen + 4); |
| 3049 | if (unlikely(!p)) |
| 3050 | goto out_overflow; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3051 | hdr->tag = (char *)p; |
| 3052 | p += XDR_QUADLEN(hdr->taglen); |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3053 | hdr->nops = be32_to_cpup(p); |
Benny Halevy | aadf615 | 2008-12-23 16:06:13 -0500 | [diff] [blame] | 3054 | if (unlikely(hdr->nops < 1)) |
| 3055 | return nfs4_stat_to_errno(hdr->status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3056 | return 0; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3057 | out_overflow: |
| 3058 | print_overflow_msg(__func__, xdr); |
| 3059 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3060 | } |
| 3061 | |
Trond Myklebust | c7848f6 | 2013-12-04 17:39:23 -0500 | [diff] [blame] | 3062 | static bool __decode_op_hdr(struct xdr_stream *xdr, enum nfs_opnum4 expected, |
| 3063 | int *nfs_retval) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3064 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3065 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3066 | uint32_t opnum; |
| 3067 | int32_t nfserr; |
| 3068 | |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3069 | p = xdr_inline_decode(xdr, 8); |
| 3070 | if (unlikely(!p)) |
| 3071 | goto out_overflow; |
Benny Halevy | 6f723f7 | 2009-08-14 17:19:37 +0300 | [diff] [blame] | 3072 | opnum = be32_to_cpup(p++); |
Trond Myklebust | c7848f6 | 2013-12-04 17:39:23 -0500 | [diff] [blame] | 3073 | if (unlikely(opnum != expected)) |
| 3074 | goto out_bad_operation; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3075 | nfserr = be32_to_cpup(p); |
Trond Myklebust | c7848f6 | 2013-12-04 17:39:23 -0500 | [diff] [blame] | 3076 | if (nfserr == NFS_OK) |
| 3077 | *nfs_retval = 0; |
| 3078 | else |
| 3079 | *nfs_retval = nfs4_stat_to_errno(nfserr); |
| 3080 | return true; |
| 3081 | out_bad_operation: |
| 3082 | dprintk("nfs: Server returned operation" |
| 3083 | " %d but we issued a request for %d\n", |
| 3084 | opnum, expected); |
| 3085 | *nfs_retval = -EREMOTEIO; |
| 3086 | return false; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3087 | out_overflow: |
| 3088 | print_overflow_msg(__func__, xdr); |
Trond Myklebust | c7848f6 | 2013-12-04 17:39:23 -0500 | [diff] [blame] | 3089 | *nfs_retval = -EIO; |
| 3090 | return false; |
| 3091 | } |
| 3092 | |
| 3093 | static int decode_op_hdr(struct xdr_stream *xdr, enum nfs_opnum4 expected) |
| 3094 | { |
| 3095 | int retval; |
| 3096 | |
| 3097 | __decode_op_hdr(xdr, expected, &retval); |
| 3098 | return retval; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3099 | } |
| 3100 | |
| 3101 | /* Dummy routine */ |
David Howells | adfa6f9 | 2006-08-22 20:06:08 -0400 | [diff] [blame] | 3102 | static int decode_ace(struct xdr_stream *xdr, void *ace, struct nfs_client *clp) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3103 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3104 | __be32 *p; |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 3105 | unsigned int strlen; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3106 | char *str; |
| 3107 | |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3108 | p = xdr_inline_decode(xdr, 12); |
| 3109 | if (likely(p)) |
| 3110 | return decode_opaque_inline(xdr, &strlen, &str); |
| 3111 | print_overflow_msg(__func__, xdr); |
| 3112 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3113 | } |
| 3114 | |
| 3115 | static int decode_attr_bitmap(struct xdr_stream *xdr, uint32_t *bitmap) |
| 3116 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3117 | uint32_t bmlen; |
| 3118 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3119 | |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3120 | p = xdr_inline_decode(xdr, 4); |
| 3121 | if (unlikely(!p)) |
| 3122 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3123 | bmlen = be32_to_cpup(p); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3124 | |
Fred Isaman | dae100c | 2011-07-30 20:52:37 -0400 | [diff] [blame] | 3125 | bitmap[0] = bitmap[1] = bitmap[2] = 0; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3126 | p = xdr_inline_decode(xdr, (bmlen << 2)); |
| 3127 | if (unlikely(!p)) |
| 3128 | goto out_overflow; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3129 | if (bmlen > 0) { |
Benny Halevy | 6f723f7 | 2009-08-14 17:19:37 +0300 | [diff] [blame] | 3130 | bitmap[0] = be32_to_cpup(p++); |
Fred Isaman | dae100c | 2011-07-30 20:52:37 -0400 | [diff] [blame] | 3131 | if (bmlen > 1) { |
| 3132 | bitmap[1] = be32_to_cpup(p++); |
| 3133 | if (bmlen > 2) |
| 3134 | bitmap[2] = be32_to_cpup(p); |
| 3135 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3136 | } |
| 3137 | return 0; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3138 | out_overflow: |
| 3139 | print_overflow_msg(__func__, xdr); |
| 3140 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3141 | } |
| 3142 | |
Trond Myklebust | 256e48b | 2012-06-21 11:18:13 -0400 | [diff] [blame] | 3143 | 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] | 3144 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3145 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3146 | |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3147 | p = xdr_inline_decode(xdr, 4); |
| 3148 | if (unlikely(!p)) |
| 3149 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3150 | *attrlen = be32_to_cpup(p); |
Trond Myklebust | 256e48b | 2012-06-21 11:18:13 -0400 | [diff] [blame] | 3151 | *savep = xdr_stream_pos(xdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3152 | return 0; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3153 | out_overflow: |
| 3154 | print_overflow_msg(__func__, xdr); |
| 3155 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3156 | } |
| 3157 | |
| 3158 | static int decode_attr_supported(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t *bitmask) |
| 3159 | { |
| 3160 | if (likely(bitmap[0] & FATTR4_WORD0_SUPPORTED_ATTRS)) { |
Roman Borisov | 3388bff | 2010-10-13 16:54:51 +0400 | [diff] [blame] | 3161 | int ret; |
| 3162 | ret = decode_attr_bitmap(xdr, bitmask); |
| 3163 | if (unlikely(ret < 0)) |
| 3164 | return ret; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3165 | bitmap[0] &= ~FATTR4_WORD0_SUPPORTED_ATTRS; |
| 3166 | } else |
Fred Isaman | dae100c | 2011-07-30 20:52:37 -0400 | [diff] [blame] | 3167 | bitmask[0] = bitmask[1] = bitmask[2] = 0; |
| 3168 | dprintk("%s: bitmask=%08x:%08x:%08x\n", __func__, |
| 3169 | bitmask[0], bitmask[1], bitmask[2]); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3170 | return 0; |
| 3171 | } |
| 3172 | |
| 3173 | static int decode_attr_type(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t *type) |
| 3174 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3175 | __be32 *p; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3176 | int ret = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3177 | |
| 3178 | *type = 0; |
| 3179 | if (unlikely(bitmap[0] & (FATTR4_WORD0_TYPE - 1U))) |
| 3180 | return -EIO; |
| 3181 | if (likely(bitmap[0] & FATTR4_WORD0_TYPE)) { |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3182 | p = xdr_inline_decode(xdr, 4); |
| 3183 | if (unlikely(!p)) |
| 3184 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3185 | *type = be32_to_cpup(p); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3186 | if (*type < NF4REG || *type > NF4NAMEDATTR) { |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3187 | dprintk("%s: bad type %d\n", __func__, *type); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3188 | return -EIO; |
| 3189 | } |
| 3190 | bitmap[0] &= ~FATTR4_WORD0_TYPE; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3191 | ret = NFS_ATTR_FATTR_TYPE; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3192 | } |
Trond Myklebust | bca7947 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 3193 | dprintk("%s: type=0%o\n", __func__, nfs_type2fmt[*type]); |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3194 | return ret; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3195 | out_overflow: |
| 3196 | print_overflow_msg(__func__, xdr); |
| 3197 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3198 | } |
| 3199 | |
Chuck Lever | 264e635 | 2012-03-01 17:02:05 -0500 | [diff] [blame] | 3200 | static int decode_attr_fh_expire_type(struct xdr_stream *xdr, |
| 3201 | uint32_t *bitmap, uint32_t *type) |
| 3202 | { |
| 3203 | __be32 *p; |
| 3204 | |
| 3205 | *type = 0; |
| 3206 | if (unlikely(bitmap[0] & (FATTR4_WORD0_FH_EXPIRE_TYPE - 1U))) |
| 3207 | return -EIO; |
| 3208 | if (likely(bitmap[0] & FATTR4_WORD0_FH_EXPIRE_TYPE)) { |
| 3209 | p = xdr_inline_decode(xdr, 4); |
| 3210 | if (unlikely(!p)) |
| 3211 | goto out_overflow; |
| 3212 | *type = be32_to_cpup(p); |
| 3213 | bitmap[0] &= ~FATTR4_WORD0_FH_EXPIRE_TYPE; |
| 3214 | } |
| 3215 | dprintk("%s: expire type=0x%x\n", __func__, *type); |
| 3216 | return 0; |
| 3217 | out_overflow: |
| 3218 | print_overflow_msg(__func__, xdr); |
| 3219 | return -EIO; |
| 3220 | } |
| 3221 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3222 | static int decode_attr_change(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *change) |
| 3223 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3224 | __be32 *p; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3225 | int ret = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3226 | |
| 3227 | *change = 0; |
| 3228 | if (unlikely(bitmap[0] & (FATTR4_WORD0_CHANGE - 1U))) |
| 3229 | return -EIO; |
| 3230 | if (likely(bitmap[0] & FATTR4_WORD0_CHANGE)) { |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3231 | p = xdr_inline_decode(xdr, 8); |
| 3232 | if (unlikely(!p)) |
| 3233 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3234 | xdr_decode_hyper(p, change); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3235 | bitmap[0] &= ~FATTR4_WORD0_CHANGE; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3236 | ret = NFS_ATTR_FATTR_CHANGE; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3237 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3238 | dprintk("%s: change attribute=%Lu\n", __func__, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3239 | (unsigned long long)*change); |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3240 | return ret; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3241 | out_overflow: |
| 3242 | print_overflow_msg(__func__, xdr); |
| 3243 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3244 | } |
| 3245 | |
| 3246 | static int decode_attr_size(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *size) |
| 3247 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3248 | __be32 *p; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3249 | int ret = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3250 | |
| 3251 | *size = 0; |
| 3252 | if (unlikely(bitmap[0] & (FATTR4_WORD0_SIZE - 1U))) |
| 3253 | return -EIO; |
| 3254 | if (likely(bitmap[0] & FATTR4_WORD0_SIZE)) { |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3255 | p = xdr_inline_decode(xdr, 8); |
| 3256 | if (unlikely(!p)) |
| 3257 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3258 | xdr_decode_hyper(p, size); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3259 | bitmap[0] &= ~FATTR4_WORD0_SIZE; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3260 | ret = NFS_ATTR_FATTR_SIZE; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3261 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3262 | dprintk("%s: file size=%Lu\n", __func__, (unsigned long long)*size); |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3263 | return ret; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3264 | out_overflow: |
| 3265 | print_overflow_msg(__func__, xdr); |
| 3266 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3267 | } |
| 3268 | |
| 3269 | static int decode_attr_link_support(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t *res) |
| 3270 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3271 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3272 | |
| 3273 | *res = 0; |
| 3274 | if (unlikely(bitmap[0] & (FATTR4_WORD0_LINK_SUPPORT - 1U))) |
| 3275 | return -EIO; |
| 3276 | if (likely(bitmap[0] & FATTR4_WORD0_LINK_SUPPORT)) { |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3277 | p = xdr_inline_decode(xdr, 4); |
| 3278 | if (unlikely(!p)) |
| 3279 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3280 | *res = be32_to_cpup(p); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3281 | bitmap[0] &= ~FATTR4_WORD0_LINK_SUPPORT; |
| 3282 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3283 | dprintk("%s: link support=%s\n", __func__, *res == 0 ? "false" : "true"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3284 | return 0; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3285 | out_overflow: |
| 3286 | print_overflow_msg(__func__, xdr); |
| 3287 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3288 | } |
| 3289 | |
| 3290 | static int decode_attr_symlink_support(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t *res) |
| 3291 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3292 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3293 | |
| 3294 | *res = 0; |
| 3295 | if (unlikely(bitmap[0] & (FATTR4_WORD0_SYMLINK_SUPPORT - 1U))) |
| 3296 | return -EIO; |
| 3297 | if (likely(bitmap[0] & FATTR4_WORD0_SYMLINK_SUPPORT)) { |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3298 | p = xdr_inline_decode(xdr, 4); |
| 3299 | if (unlikely(!p)) |
| 3300 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3301 | *res = be32_to_cpup(p); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3302 | bitmap[0] &= ~FATTR4_WORD0_SYMLINK_SUPPORT; |
| 3303 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3304 | dprintk("%s: symlink support=%s\n", __func__, *res == 0 ? "false" : "true"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3305 | return 0; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3306 | out_overflow: |
| 3307 | print_overflow_msg(__func__, xdr); |
| 3308 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3309 | } |
| 3310 | |
Trond Myklebust | 8b4bdcf | 2006-06-09 09:34:19 -0400 | [diff] [blame] | 3311 | 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] | 3312 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3313 | __be32 *p; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3314 | int ret = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3315 | |
| 3316 | fsid->major = 0; |
| 3317 | fsid->minor = 0; |
| 3318 | if (unlikely(bitmap[0] & (FATTR4_WORD0_FSID - 1U))) |
| 3319 | return -EIO; |
| 3320 | if (likely(bitmap[0] & FATTR4_WORD0_FSID)) { |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3321 | p = xdr_inline_decode(xdr, 16); |
| 3322 | if (unlikely(!p)) |
| 3323 | goto out_overflow; |
Benny Halevy | 3ceb4db | 2009-08-14 17:19:41 +0300 | [diff] [blame] | 3324 | p = xdr_decode_hyper(p, &fsid->major); |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3325 | xdr_decode_hyper(p, &fsid->minor); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3326 | bitmap[0] &= ~FATTR4_WORD0_FSID; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3327 | ret = NFS_ATTR_FATTR_FSID; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3328 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3329 | dprintk("%s: fsid=(0x%Lx/0x%Lx)\n", __func__, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3330 | (unsigned long long)fsid->major, |
| 3331 | (unsigned long long)fsid->minor); |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3332 | return ret; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3333 | out_overflow: |
| 3334 | print_overflow_msg(__func__, xdr); |
| 3335 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3336 | } |
| 3337 | |
| 3338 | static int decode_attr_lease_time(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t *res) |
| 3339 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3340 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3341 | |
| 3342 | *res = 60; |
| 3343 | if (unlikely(bitmap[0] & (FATTR4_WORD0_LEASE_TIME - 1U))) |
| 3344 | return -EIO; |
| 3345 | if (likely(bitmap[0] & FATTR4_WORD0_LEASE_TIME)) { |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3346 | p = xdr_inline_decode(xdr, 4); |
| 3347 | if (unlikely(!p)) |
| 3348 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3349 | *res = be32_to_cpup(p); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3350 | bitmap[0] &= ~FATTR4_WORD0_LEASE_TIME; |
| 3351 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3352 | dprintk("%s: file size=%u\n", __func__, (unsigned int)*res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3353 | return 0; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3354 | out_overflow: |
| 3355 | print_overflow_msg(__func__, xdr); |
| 3356 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3357 | } |
| 3358 | |
Trond Myklebust | ee7b75f | 2011-06-16 13:15:41 -0400 | [diff] [blame] | 3359 | 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] | 3360 | { |
| 3361 | __be32 *p; |
| 3362 | |
| 3363 | if (unlikely(bitmap[0] & (FATTR4_WORD0_RDATTR_ERROR - 1U))) |
| 3364 | return -EIO; |
| 3365 | if (likely(bitmap[0] & FATTR4_WORD0_RDATTR_ERROR)) { |
| 3366 | p = xdr_inline_decode(xdr, 4); |
| 3367 | if (unlikely(!p)) |
| 3368 | goto out_overflow; |
| 3369 | bitmap[0] &= ~FATTR4_WORD0_RDATTR_ERROR; |
Trond Myklebust | ee7b75f | 2011-06-16 13:15:41 -0400 | [diff] [blame] | 3370 | *res = -be32_to_cpup(p); |
Bryan Schumaker | ae42c70 | 2010-10-21 16:33:17 -0400 | [diff] [blame] | 3371 | } |
| 3372 | return 0; |
| 3373 | out_overflow: |
| 3374 | print_overflow_msg(__func__, xdr); |
| 3375 | return -EIO; |
| 3376 | } |
| 3377 | |
| 3378 | static int decode_attr_filehandle(struct xdr_stream *xdr, uint32_t *bitmap, struct nfs_fh *fh) |
| 3379 | { |
| 3380 | __be32 *p; |
| 3381 | int len; |
| 3382 | |
Trond Myklebust | 7ad0735 | 2010-10-23 15:34:20 -0400 | [diff] [blame] | 3383 | if (fh != NULL) |
| 3384 | memset(fh, 0, sizeof(*fh)); |
Bryan Schumaker | ae42c70 | 2010-10-21 16:33:17 -0400 | [diff] [blame] | 3385 | |
| 3386 | if (unlikely(bitmap[0] & (FATTR4_WORD0_FILEHANDLE - 1U))) |
| 3387 | return -EIO; |
| 3388 | if (likely(bitmap[0] & FATTR4_WORD0_FILEHANDLE)) { |
| 3389 | p = xdr_inline_decode(xdr, 4); |
| 3390 | if (unlikely(!p)) |
| 3391 | goto out_overflow; |
| 3392 | len = be32_to_cpup(p); |
| 3393 | if (len > NFS4_FHSIZE) |
| 3394 | return -EIO; |
Bryan Schumaker | ae42c70 | 2010-10-21 16:33:17 -0400 | [diff] [blame] | 3395 | p = xdr_inline_decode(xdr, len); |
| 3396 | if (unlikely(!p)) |
| 3397 | goto out_overflow; |
Trond Myklebust | 7ad0735 | 2010-10-23 15:34:20 -0400 | [diff] [blame] | 3398 | if (fh != NULL) { |
| 3399 | memcpy(fh->data, p, len); |
| 3400 | fh->size = len; |
| 3401 | } |
Bryan Schumaker | ae42c70 | 2010-10-21 16:33:17 -0400 | [diff] [blame] | 3402 | bitmap[0] &= ~FATTR4_WORD0_FILEHANDLE; |
| 3403 | } |
| 3404 | return 0; |
| 3405 | out_overflow: |
| 3406 | print_overflow_msg(__func__, xdr); |
| 3407 | return -EIO; |
| 3408 | } |
| 3409 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3410 | static int decode_attr_aclsupport(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t *res) |
| 3411 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3412 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3413 | |
Malahal Naineni | a1800ac | 2014-01-27 15:31:09 -0600 | [diff] [blame] | 3414 | *res = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3415 | if (unlikely(bitmap[0] & (FATTR4_WORD0_ACLSUPPORT - 1U))) |
| 3416 | return -EIO; |
| 3417 | if (likely(bitmap[0] & FATTR4_WORD0_ACLSUPPORT)) { |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3418 | p = xdr_inline_decode(xdr, 4); |
| 3419 | if (unlikely(!p)) |
| 3420 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3421 | *res = be32_to_cpup(p); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3422 | bitmap[0] &= ~FATTR4_WORD0_ACLSUPPORT; |
| 3423 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3424 | dprintk("%s: ACLs supported=%u\n", __func__, (unsigned int)*res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3425 | return 0; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3426 | out_overflow: |
| 3427 | print_overflow_msg(__func__, xdr); |
| 3428 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3429 | } |
| 3430 | |
| 3431 | static int decode_attr_fileid(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *fileid) |
| 3432 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3433 | __be32 *p; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3434 | int ret = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3435 | |
| 3436 | *fileid = 0; |
| 3437 | if (unlikely(bitmap[0] & (FATTR4_WORD0_FILEID - 1U))) |
| 3438 | return -EIO; |
| 3439 | if (likely(bitmap[0] & FATTR4_WORD0_FILEID)) { |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3440 | p = xdr_inline_decode(xdr, 8); |
| 3441 | if (unlikely(!p)) |
| 3442 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3443 | xdr_decode_hyper(p, fileid); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3444 | bitmap[0] &= ~FATTR4_WORD0_FILEID; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3445 | ret = NFS_ATTR_FATTR_FILEID; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3446 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3447 | dprintk("%s: fileid=%Lu\n", __func__, (unsigned long long)*fileid); |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3448 | return ret; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3449 | out_overflow: |
| 3450 | print_overflow_msg(__func__, xdr); |
| 3451 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3452 | } |
| 3453 | |
Manoj Naik | 99baf62 | 2006-06-09 09:34:24 -0400 | [diff] [blame] | 3454 | static int decode_attr_mounted_on_fileid(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *fileid) |
| 3455 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3456 | __be32 *p; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3457 | int ret = 0; |
Manoj Naik | 99baf62 | 2006-06-09 09:34:24 -0400 | [diff] [blame] | 3458 | |
| 3459 | *fileid = 0; |
| 3460 | if (unlikely(bitmap[1] & (FATTR4_WORD1_MOUNTED_ON_FILEID - 1U))) |
| 3461 | return -EIO; |
| 3462 | if (likely(bitmap[1] & FATTR4_WORD1_MOUNTED_ON_FILEID)) { |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3463 | p = xdr_inline_decode(xdr, 8); |
| 3464 | if (unlikely(!p)) |
| 3465 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3466 | xdr_decode_hyper(p, fileid); |
Manoj Naik | 99baf62 | 2006-06-09 09:34:24 -0400 | [diff] [blame] | 3467 | bitmap[1] &= ~FATTR4_WORD1_MOUNTED_ON_FILEID; |
Trond Myklebust | 28331a4 | 2011-04-27 13:47:52 -0400 | [diff] [blame] | 3468 | ret = NFS_ATTR_FATTR_MOUNTED_ON_FILEID; |
Manoj Naik | 99baf62 | 2006-06-09 09:34:24 -0400 | [diff] [blame] | 3469 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3470 | dprintk("%s: fileid=%Lu\n", __func__, (unsigned long long)*fileid); |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3471 | return ret; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3472 | out_overflow: |
| 3473 | print_overflow_msg(__func__, xdr); |
| 3474 | return -EIO; |
Manoj Naik | 99baf62 | 2006-06-09 09:34:24 -0400 | [diff] [blame] | 3475 | } |
| 3476 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3477 | static int decode_attr_files_avail(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *res) |
| 3478 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3479 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3480 | int status = 0; |
| 3481 | |
| 3482 | *res = 0; |
| 3483 | if (unlikely(bitmap[0] & (FATTR4_WORD0_FILES_AVAIL - 1U))) |
| 3484 | return -EIO; |
| 3485 | if (likely(bitmap[0] & FATTR4_WORD0_FILES_AVAIL)) { |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3486 | p = xdr_inline_decode(xdr, 8); |
| 3487 | if (unlikely(!p)) |
| 3488 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3489 | xdr_decode_hyper(p, res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3490 | bitmap[0] &= ~FATTR4_WORD0_FILES_AVAIL; |
| 3491 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3492 | dprintk("%s: files avail=%Lu\n", __func__, (unsigned long long)*res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3493 | return status; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3494 | out_overflow: |
| 3495 | print_overflow_msg(__func__, xdr); |
| 3496 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3497 | } |
| 3498 | |
| 3499 | static int decode_attr_files_free(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *res) |
| 3500 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3501 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3502 | int status = 0; |
| 3503 | |
| 3504 | *res = 0; |
| 3505 | if (unlikely(bitmap[0] & (FATTR4_WORD0_FILES_FREE - 1U))) |
| 3506 | return -EIO; |
| 3507 | if (likely(bitmap[0] & FATTR4_WORD0_FILES_FREE)) { |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3508 | p = xdr_inline_decode(xdr, 8); |
| 3509 | if (unlikely(!p)) |
| 3510 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3511 | xdr_decode_hyper(p, res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3512 | bitmap[0] &= ~FATTR4_WORD0_FILES_FREE; |
| 3513 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3514 | dprintk("%s: files free=%Lu\n", __func__, (unsigned long long)*res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3515 | return status; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3516 | out_overflow: |
| 3517 | print_overflow_msg(__func__, xdr); |
| 3518 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3519 | } |
| 3520 | |
| 3521 | static int decode_attr_files_total(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *res) |
| 3522 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3523 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3524 | int status = 0; |
| 3525 | |
| 3526 | *res = 0; |
| 3527 | if (unlikely(bitmap[0] & (FATTR4_WORD0_FILES_TOTAL - 1U))) |
| 3528 | return -EIO; |
| 3529 | if (likely(bitmap[0] & FATTR4_WORD0_FILES_TOTAL)) { |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3530 | p = xdr_inline_decode(xdr, 8); |
| 3531 | if (unlikely(!p)) |
| 3532 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3533 | xdr_decode_hyper(p, res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3534 | bitmap[0] &= ~FATTR4_WORD0_FILES_TOTAL; |
| 3535 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3536 | dprintk("%s: files total=%Lu\n", __func__, (unsigned long long)*res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3537 | return status; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3538 | out_overflow: |
| 3539 | print_overflow_msg(__func__, xdr); |
| 3540 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3541 | } |
| 3542 | |
Manoj Naik | 7aaa0b3 | 2006-06-09 09:34:23 -0400 | [diff] [blame] | 3543 | static int decode_pathname(struct xdr_stream *xdr, struct nfs4_pathname *path) |
| 3544 | { |
Chuck Lever | 464ad6b | 2007-10-26 13:32:08 -0400 | [diff] [blame] | 3545 | u32 n; |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3546 | __be32 *p; |
Manoj Naik | 7aaa0b3 | 2006-06-09 09:34:23 -0400 | [diff] [blame] | 3547 | int status = 0; |
| 3548 | |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3549 | p = xdr_inline_decode(xdr, 4); |
| 3550 | if (unlikely(!p)) |
| 3551 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3552 | n = be32_to_cpup(p); |
Andy Adamson | 33a43f2 | 2006-06-09 09:34:30 -0400 | [diff] [blame] | 3553 | if (n == 0) |
| 3554 | goto root_path; |
Chuck Lever | 02a2976 | 2012-03-01 17:00:31 -0500 | [diff] [blame] | 3555 | dprintk("pathname4: "); |
Trond Myklebust | 809b426 | 2013-03-27 11:54:45 -0400 | [diff] [blame] | 3556 | if (n > NFS4_PATHNAME_MAXCOMPONENTS) { |
| 3557 | dprintk("cannot parse %d components in path\n", n); |
| 3558 | goto out_eio; |
| 3559 | } |
| 3560 | for (path->ncomponents = 0; path->ncomponents < n; path->ncomponents++) { |
Manoj Naik | 7aaa0b3 | 2006-06-09 09:34:23 -0400 | [diff] [blame] | 3561 | struct nfs4_string *component = &path->components[path->ncomponents]; |
| 3562 | status = decode_opaque_inline(xdr, &component->len, &component->data); |
| 3563 | if (unlikely(status != 0)) |
| 3564 | goto out_eio; |
Trond Myklebust | 95a13f7 | 2012-03-14 21:55:01 -0400 | [diff] [blame] | 3565 | ifdebug (XDR) |
Chuck Lever | 02a2976 | 2012-03-01 17:00:31 -0500 | [diff] [blame] | 3566 | pr_cont("%s%.*s ", |
| 3567 | (path->ncomponents != n ? "/ " : ""), |
| 3568 | component->len, component->data); |
Manoj Naik | 7aaa0b3 | 2006-06-09 09:34:23 -0400 | [diff] [blame] | 3569 | } |
| 3570 | out: |
Manoj Naik | 7aaa0b3 | 2006-06-09 09:34:23 -0400 | [diff] [blame] | 3571 | return status; |
Andy Adamson | 33a43f2 | 2006-06-09 09:34:30 -0400 | [diff] [blame] | 3572 | root_path: |
| 3573 | /* a root pathname is sent as a zero component4 */ |
| 3574 | path->ncomponents = 1; |
| 3575 | path->components[0].len=0; |
| 3576 | path->components[0].data=NULL; |
Chuck Lever | 02a2976 | 2012-03-01 17:00:31 -0500 | [diff] [blame] | 3577 | dprintk("pathname4: /\n"); |
Andy Adamson | 33a43f2 | 2006-06-09 09:34:30 -0400 | [diff] [blame] | 3578 | goto out; |
Manoj Naik | 7aaa0b3 | 2006-06-09 09:34:23 -0400 | [diff] [blame] | 3579 | out_eio: |
| 3580 | dprintk(" status %d", status); |
| 3581 | status = -EIO; |
| 3582 | goto out; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3583 | out_overflow: |
| 3584 | print_overflow_msg(__func__, xdr); |
| 3585 | return -EIO; |
Manoj Naik | 7aaa0b3 | 2006-06-09 09:34:23 -0400 | [diff] [blame] | 3586 | } |
| 3587 | |
| 3588 | 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] | 3589 | { |
| 3590 | int n; |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3591 | __be32 *p; |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 3592 | int status = -EIO; |
| 3593 | |
| 3594 | if (unlikely(bitmap[0] & (FATTR4_WORD0_FS_LOCATIONS -1U))) |
| 3595 | goto out; |
| 3596 | status = 0; |
| 3597 | if (unlikely(!(bitmap[0] & FATTR4_WORD0_FS_LOCATIONS))) |
| 3598 | goto out; |
Trond Myklebust | 8b7e3f4 | 2012-01-30 15:43:56 -0500 | [diff] [blame] | 3599 | status = -EIO; |
| 3600 | /* Ignore borken servers that return unrequested attrs */ |
| 3601 | if (unlikely(res == NULL)) |
| 3602 | goto out; |
Chuck Lever | 02a2976 | 2012-03-01 17:00:31 -0500 | [diff] [blame] | 3603 | dprintk("%s: fsroot:\n", __func__); |
Manoj Naik | 7aaa0b3 | 2006-06-09 09:34:23 -0400 | [diff] [blame] | 3604 | status = decode_pathname(xdr, &res->fs_path); |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 3605 | if (unlikely(status != 0)) |
| 3606 | goto out; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3607 | p = xdr_inline_decode(xdr, 4); |
| 3608 | if (unlikely(!p)) |
| 3609 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3610 | n = be32_to_cpup(p); |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 3611 | if (n <= 0) |
| 3612 | goto out_eio; |
Trond Myklebust | 809b426 | 2013-03-27 11:54:45 -0400 | [diff] [blame] | 3613 | for (res->nlocations = 0; res->nlocations < n; res->nlocations++) { |
Chuck Lever | 464ad6b | 2007-10-26 13:32:08 -0400 | [diff] [blame] | 3614 | u32 m; |
Trond Myklebust | 809b426 | 2013-03-27 11:54:45 -0400 | [diff] [blame] | 3615 | struct nfs4_fs_location *loc; |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 3616 | |
Trond Myklebust | 809b426 | 2013-03-27 11:54:45 -0400 | [diff] [blame] | 3617 | if (res->nlocations == NFS4_FS_LOCATIONS_MAXENTRIES) |
| 3618 | break; |
| 3619 | loc = &res->locations[res->nlocations]; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3620 | p = xdr_inline_decode(xdr, 4); |
| 3621 | if (unlikely(!p)) |
| 3622 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3623 | m = be32_to_cpup(p); |
Manoj Naik | 7aaa0b3 | 2006-06-09 09:34:23 -0400 | [diff] [blame] | 3624 | |
Chuck Lever | 02a2976 | 2012-03-01 17:00:31 -0500 | [diff] [blame] | 3625 | dprintk("%s: servers:\n", __func__); |
Trond Myklebust | 809b426 | 2013-03-27 11:54:45 -0400 | [diff] [blame] | 3626 | for (loc->nservers = 0; loc->nservers < m; loc->nservers++) { |
| 3627 | struct nfs4_string *server; |
| 3628 | |
| 3629 | if (loc->nservers == NFS4_FS_LOCATION_MAXSERVERS) { |
Chuck Lever | 464ad6b | 2007-10-26 13:32:08 -0400 | [diff] [blame] | 3630 | unsigned int i; |
| 3631 | dprintk("%s: using first %u of %u servers " |
| 3632 | "returned for location %u\n", |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3633 | __func__, |
Chuck Lever | 464ad6b | 2007-10-26 13:32:08 -0400 | [diff] [blame] | 3634 | NFS4_FS_LOCATION_MAXSERVERS, |
| 3635 | m, res->nlocations); |
Manoj Naik | 7aaa0b3 | 2006-06-09 09:34:23 -0400 | [diff] [blame] | 3636 | for (i = loc->nservers; i < m; i++) { |
Trond Myklebust | 2e42c3e | 2007-05-14 17:20:41 -0400 | [diff] [blame] | 3637 | unsigned int len; |
Manoj Naik | 7aaa0b3 | 2006-06-09 09:34:23 -0400 | [diff] [blame] | 3638 | char *data; |
| 3639 | status = decode_opaque_inline(xdr, &len, &data); |
| 3640 | if (unlikely(status != 0)) |
| 3641 | goto out_eio; |
| 3642 | } |
Trond Myklebust | 809b426 | 2013-03-27 11:54:45 -0400 | [diff] [blame] | 3643 | break; |
Manoj Naik | 7aaa0b3 | 2006-06-09 09:34:23 -0400 | [diff] [blame] | 3644 | } |
Trond Myklebust | 809b426 | 2013-03-27 11:54:45 -0400 | [diff] [blame] | 3645 | server = &loc->servers[loc->nservers]; |
| 3646 | status = decode_opaque_inline(xdr, &server->len, &server->data); |
| 3647 | if (unlikely(status != 0)) |
| 3648 | goto out_eio; |
| 3649 | dprintk("%s ", server->data); |
Manoj Naik | 7aaa0b3 | 2006-06-09 09:34:23 -0400 | [diff] [blame] | 3650 | } |
| 3651 | status = decode_pathname(xdr, &loc->rootpath); |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 3652 | if (unlikely(status != 0)) |
| 3653 | goto out_eio; |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 3654 | } |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3655 | if (res->nlocations != 0) |
Chuck Lever | 81934dd | 2012-03-01 17:01:57 -0500 | [diff] [blame] | 3656 | status = NFS_ATTR_FATTR_V4_LOCATIONS; |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 3657 | out: |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3658 | dprintk("%s: fs_locations done, error = %d\n", __func__, status); |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [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); |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 3662 | out_eio: |
| 3663 | status = -EIO; |
| 3664 | goto out; |
| 3665 | } |
| 3666 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3667 | static int decode_attr_maxfilesize(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *res) |
| 3668 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3669 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3670 | int status = 0; |
| 3671 | |
| 3672 | *res = 0; |
| 3673 | if (unlikely(bitmap[0] & (FATTR4_WORD0_MAXFILESIZE - 1U))) |
| 3674 | return -EIO; |
| 3675 | if (likely(bitmap[0] & FATTR4_WORD0_MAXFILESIZE)) { |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3676 | p = xdr_inline_decode(xdr, 8); |
| 3677 | if (unlikely(!p)) |
| 3678 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3679 | xdr_decode_hyper(p, res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3680 | bitmap[0] &= ~FATTR4_WORD0_MAXFILESIZE; |
| 3681 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3682 | dprintk("%s: maxfilesize=%Lu\n", __func__, (unsigned long long)*res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3683 | return status; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3684 | out_overflow: |
| 3685 | print_overflow_msg(__func__, xdr); |
| 3686 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3687 | } |
| 3688 | |
| 3689 | static int decode_attr_maxlink(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t *maxlink) |
| 3690 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3691 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3692 | int status = 0; |
| 3693 | |
| 3694 | *maxlink = 1; |
| 3695 | if (unlikely(bitmap[0] & (FATTR4_WORD0_MAXLINK - 1U))) |
| 3696 | return -EIO; |
| 3697 | if (likely(bitmap[0] & FATTR4_WORD0_MAXLINK)) { |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3698 | p = xdr_inline_decode(xdr, 4); |
| 3699 | if (unlikely(!p)) |
| 3700 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3701 | *maxlink = be32_to_cpup(p); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3702 | bitmap[0] &= ~FATTR4_WORD0_MAXLINK; |
| 3703 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3704 | dprintk("%s: maxlink=%u\n", __func__, *maxlink); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3705 | return status; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3706 | out_overflow: |
| 3707 | print_overflow_msg(__func__, xdr); |
| 3708 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3709 | } |
| 3710 | |
| 3711 | static int decode_attr_maxname(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t *maxname) |
| 3712 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3713 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3714 | int status = 0; |
| 3715 | |
| 3716 | *maxname = 1024; |
| 3717 | if (unlikely(bitmap[0] & (FATTR4_WORD0_MAXNAME - 1U))) |
| 3718 | return -EIO; |
| 3719 | if (likely(bitmap[0] & FATTR4_WORD0_MAXNAME)) { |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3720 | p = xdr_inline_decode(xdr, 4); |
| 3721 | if (unlikely(!p)) |
| 3722 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3723 | *maxname = be32_to_cpup(p); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3724 | bitmap[0] &= ~FATTR4_WORD0_MAXNAME; |
| 3725 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3726 | dprintk("%s: maxname=%u\n", __func__, *maxname); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3727 | return status; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3728 | out_overflow: |
| 3729 | print_overflow_msg(__func__, xdr); |
| 3730 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3731 | } |
| 3732 | |
| 3733 | static int decode_attr_maxread(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t *res) |
| 3734 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3735 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3736 | int status = 0; |
| 3737 | |
| 3738 | *res = 1024; |
| 3739 | if (unlikely(bitmap[0] & (FATTR4_WORD0_MAXREAD - 1U))) |
| 3740 | return -EIO; |
| 3741 | if (likely(bitmap[0] & FATTR4_WORD0_MAXREAD)) { |
| 3742 | uint64_t maxread; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3743 | p = xdr_inline_decode(xdr, 8); |
| 3744 | if (unlikely(!p)) |
| 3745 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3746 | xdr_decode_hyper(p, &maxread); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3747 | if (maxread > 0x7FFFFFFF) |
| 3748 | maxread = 0x7FFFFFFF; |
| 3749 | *res = (uint32_t)maxread; |
| 3750 | bitmap[0] &= ~FATTR4_WORD0_MAXREAD; |
| 3751 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3752 | dprintk("%s: maxread=%lu\n", __func__, (unsigned long)*res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3753 | return status; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3754 | out_overflow: |
| 3755 | print_overflow_msg(__func__, xdr); |
| 3756 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3757 | } |
| 3758 | |
| 3759 | static int decode_attr_maxwrite(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t *res) |
| 3760 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3761 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3762 | int status = 0; |
| 3763 | |
| 3764 | *res = 1024; |
| 3765 | if (unlikely(bitmap[0] & (FATTR4_WORD0_MAXWRITE - 1U))) |
| 3766 | return -EIO; |
| 3767 | if (likely(bitmap[0] & FATTR4_WORD0_MAXWRITE)) { |
| 3768 | uint64_t maxwrite; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3769 | p = xdr_inline_decode(xdr, 8); |
| 3770 | if (unlikely(!p)) |
| 3771 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3772 | xdr_decode_hyper(p, &maxwrite); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3773 | if (maxwrite > 0x7FFFFFFF) |
| 3774 | maxwrite = 0x7FFFFFFF; |
| 3775 | *res = (uint32_t)maxwrite; |
| 3776 | bitmap[0] &= ~FATTR4_WORD0_MAXWRITE; |
| 3777 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3778 | dprintk("%s: maxwrite=%lu\n", __func__, (unsigned long)*res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3779 | return status; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3780 | out_overflow: |
| 3781 | print_overflow_msg(__func__, xdr); |
| 3782 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3783 | } |
| 3784 | |
Trond Myklebust | bca7947 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 3785 | 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] | 3786 | { |
Trond Myklebust | bca7947 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 3787 | uint32_t tmp; |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3788 | __be32 *p; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3789 | int ret = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3790 | |
| 3791 | *mode = 0; |
| 3792 | if (unlikely(bitmap[1] & (FATTR4_WORD1_MODE - 1U))) |
| 3793 | return -EIO; |
| 3794 | if (likely(bitmap[1] & FATTR4_WORD1_MODE)) { |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3795 | p = xdr_inline_decode(xdr, 4); |
| 3796 | if (unlikely(!p)) |
| 3797 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3798 | tmp = be32_to_cpup(p); |
Trond Myklebust | bca7947 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 3799 | *mode = tmp & ~S_IFMT; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3800 | bitmap[1] &= ~FATTR4_WORD1_MODE; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3801 | ret = NFS_ATTR_FATTR_MODE; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3802 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3803 | dprintk("%s: file mode=0%o\n", __func__, (unsigned int)*mode); |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3804 | return ret; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3805 | out_overflow: |
| 3806 | print_overflow_msg(__func__, xdr); |
| 3807 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3808 | } |
| 3809 | |
| 3810 | static int decode_attr_nlink(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t *nlink) |
| 3811 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3812 | __be32 *p; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3813 | int ret = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3814 | |
| 3815 | *nlink = 1; |
| 3816 | if (unlikely(bitmap[1] & (FATTR4_WORD1_NUMLINKS - 1U))) |
| 3817 | return -EIO; |
| 3818 | if (likely(bitmap[1] & FATTR4_WORD1_NUMLINKS)) { |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3819 | p = xdr_inline_decode(xdr, 4); |
| 3820 | if (unlikely(!p)) |
| 3821 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3822 | *nlink = be32_to_cpup(p); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3823 | bitmap[1] &= ~FATTR4_WORD1_NUMLINKS; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3824 | ret = NFS_ATTR_FATTR_NLINK; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3825 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3826 | dprintk("%s: nlink=%u\n", __func__, (unsigned int)*nlink); |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3827 | return ret; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3828 | out_overflow: |
| 3829 | print_overflow_msg(__func__, xdr); |
| 3830 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3831 | } |
| 3832 | |
Trond Myklebust | 80e52ac | 2009-08-09 15:06:19 -0400 | [diff] [blame] | 3833 | 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] | 3834 | const struct nfs_server *server, kuid_t *uid, |
Trond Myklebust | 6926afd1 | 2012-01-07 13:22:46 -0500 | [diff] [blame] | 3835 | struct nfs4_string *owner_name) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3836 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3837 | uint32_t len; |
| 3838 | __be32 *p; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3839 | int ret = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3840 | |
Eric W. Biederman | e578207 | 2013-02-01 14:22:02 -0800 | [diff] [blame] | 3841 | *uid = make_kuid(&init_user_ns, -2); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3842 | if (unlikely(bitmap[1] & (FATTR4_WORD1_OWNER - 1U))) |
| 3843 | return -EIO; |
| 3844 | if (likely(bitmap[1] & FATTR4_WORD1_OWNER)) { |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3845 | p = xdr_inline_decode(xdr, 4); |
| 3846 | if (unlikely(!p)) |
| 3847 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3848 | len = be32_to_cpup(p); |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3849 | p = xdr_inline_decode(xdr, len); |
| 3850 | if (unlikely(!p)) |
| 3851 | goto out_overflow; |
Trond Myklebust | 6926afd1 | 2012-01-07 13:22:46 -0500 | [diff] [blame] | 3852 | if (owner_name != NULL) { |
| 3853 | owner_name->data = kmemdup(p, len, GFP_NOWAIT); |
| 3854 | if (owner_name->data != NULL) { |
| 3855 | owner_name->len = len; |
| 3856 | ret = NFS_ATTR_FATTR_OWNER_NAME; |
| 3857 | } |
Trond Myklebust | 80e52ac | 2009-08-09 15:06:19 -0400 | [diff] [blame] | 3858 | } else if (len < XDR_MAX_NETOBJ) { |
Trond Myklebust | e4fd72a | 2011-02-22 15:44:31 -0800 | [diff] [blame] | 3859 | if (nfs_map_name_to_uid(server, (char *)p, len, uid) == 0) |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3860 | ret = NFS_ATTR_FATTR_OWNER; |
| 3861 | else |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3862 | dprintk("%s: nfs_map_name_to_uid failed!\n", |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3863 | __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3864 | } else |
Chuck Lever | fe82a18 | 2007-09-11 18:01:10 -0400 | [diff] [blame] | 3865 | dprintk("%s: name too long (%u)!\n", |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3866 | __func__, len); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3867 | bitmap[1] &= ~FATTR4_WORD1_OWNER; |
| 3868 | } |
Eric W. Biederman | e578207 | 2013-02-01 14:22:02 -0800 | [diff] [blame] | 3869 | dprintk("%s: uid=%d\n", __func__, (int)from_kuid(&init_user_ns, *uid)); |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3870 | return ret; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3871 | out_overflow: |
| 3872 | print_overflow_msg(__func__, xdr); |
| 3873 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3874 | } |
| 3875 | |
Trond Myklebust | 80e52ac | 2009-08-09 15:06:19 -0400 | [diff] [blame] | 3876 | 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] | 3877 | const struct nfs_server *server, kgid_t *gid, |
Trond Myklebust | 6926afd1 | 2012-01-07 13:22:46 -0500 | [diff] [blame] | 3878 | struct nfs4_string *group_name) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3879 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3880 | uint32_t len; |
| 3881 | __be32 *p; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3882 | int ret = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3883 | |
Eric W. Biederman | e578207 | 2013-02-01 14:22:02 -0800 | [diff] [blame] | 3884 | *gid = make_kgid(&init_user_ns, -2); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3885 | if (unlikely(bitmap[1] & (FATTR4_WORD1_OWNER_GROUP - 1U))) |
| 3886 | return -EIO; |
| 3887 | if (likely(bitmap[1] & FATTR4_WORD1_OWNER_GROUP)) { |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3888 | p = xdr_inline_decode(xdr, 4); |
| 3889 | if (unlikely(!p)) |
| 3890 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3891 | len = be32_to_cpup(p); |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3892 | p = xdr_inline_decode(xdr, len); |
| 3893 | if (unlikely(!p)) |
| 3894 | goto out_overflow; |
Trond Myklebust | 6926afd1 | 2012-01-07 13:22:46 -0500 | [diff] [blame] | 3895 | if (group_name != NULL) { |
| 3896 | group_name->data = kmemdup(p, len, GFP_NOWAIT); |
| 3897 | if (group_name->data != NULL) { |
| 3898 | group_name->len = len; |
| 3899 | ret = NFS_ATTR_FATTR_GROUP_NAME; |
| 3900 | } |
Trond Myklebust | 80e52ac | 2009-08-09 15:06:19 -0400 | [diff] [blame] | 3901 | } else if (len < XDR_MAX_NETOBJ) { |
Trond Myklebust | e4fd72a | 2011-02-22 15:44:31 -0800 | [diff] [blame] | 3902 | if (nfs_map_group_to_gid(server, (char *)p, len, gid) == 0) |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3903 | ret = NFS_ATTR_FATTR_GROUP; |
| 3904 | else |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3905 | dprintk("%s: nfs_map_group_to_gid failed!\n", |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3906 | __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3907 | } else |
Chuck Lever | fe82a18 | 2007-09-11 18:01:10 -0400 | [diff] [blame] | 3908 | dprintk("%s: name too long (%u)!\n", |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3909 | __func__, len); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3910 | bitmap[1] &= ~FATTR4_WORD1_OWNER_GROUP; |
| 3911 | } |
Eric W. Biederman | e578207 | 2013-02-01 14:22:02 -0800 | [diff] [blame] | 3912 | dprintk("%s: gid=%d\n", __func__, (int)from_kgid(&init_user_ns, *gid)); |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3913 | return ret; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3914 | out_overflow: |
| 3915 | print_overflow_msg(__func__, xdr); |
| 3916 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3917 | } |
| 3918 | |
| 3919 | static int decode_attr_rdev(struct xdr_stream *xdr, uint32_t *bitmap, dev_t *rdev) |
| 3920 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3921 | uint32_t major = 0, minor = 0; |
| 3922 | __be32 *p; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3923 | int ret = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3924 | |
| 3925 | *rdev = MKDEV(0,0); |
| 3926 | if (unlikely(bitmap[1] & (FATTR4_WORD1_RAWDEV - 1U))) |
| 3927 | return -EIO; |
| 3928 | if (likely(bitmap[1] & FATTR4_WORD1_RAWDEV)) { |
| 3929 | dev_t tmp; |
| 3930 | |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3931 | p = xdr_inline_decode(xdr, 8); |
| 3932 | if (unlikely(!p)) |
| 3933 | goto out_overflow; |
Benny Halevy | 6f723f7 | 2009-08-14 17:19:37 +0300 | [diff] [blame] | 3934 | major = be32_to_cpup(p++); |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3935 | minor = be32_to_cpup(p); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3936 | tmp = MKDEV(major, minor); |
| 3937 | if (MAJOR(tmp) == major && MINOR(tmp) == minor) |
| 3938 | *rdev = tmp; |
| 3939 | bitmap[1] &= ~ FATTR4_WORD1_RAWDEV; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3940 | ret = NFS_ATTR_FATTR_RDEV; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3941 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3942 | dprintk("%s: rdev=(0x%x:0x%x)\n", __func__, major, minor); |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3943 | return ret; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3944 | out_overflow: |
| 3945 | print_overflow_msg(__func__, xdr); |
| 3946 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3947 | } |
| 3948 | |
| 3949 | static int decode_attr_space_avail(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *res) |
| 3950 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3951 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3952 | int status = 0; |
| 3953 | |
| 3954 | *res = 0; |
| 3955 | if (unlikely(bitmap[1] & (FATTR4_WORD1_SPACE_AVAIL - 1U))) |
| 3956 | return -EIO; |
| 3957 | if (likely(bitmap[1] & FATTR4_WORD1_SPACE_AVAIL)) { |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3958 | p = xdr_inline_decode(xdr, 8); |
| 3959 | if (unlikely(!p)) |
| 3960 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3961 | xdr_decode_hyper(p, res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3962 | bitmap[1] &= ~FATTR4_WORD1_SPACE_AVAIL; |
| 3963 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3964 | dprintk("%s: space avail=%Lu\n", __func__, (unsigned long long)*res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3965 | return status; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3966 | out_overflow: |
| 3967 | print_overflow_msg(__func__, xdr); |
| 3968 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3969 | } |
| 3970 | |
| 3971 | static int decode_attr_space_free(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *res) |
| 3972 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3973 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3974 | int status = 0; |
| 3975 | |
| 3976 | *res = 0; |
| 3977 | if (unlikely(bitmap[1] & (FATTR4_WORD1_SPACE_FREE - 1U))) |
| 3978 | return -EIO; |
| 3979 | if (likely(bitmap[1] & FATTR4_WORD1_SPACE_FREE)) { |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3980 | p = xdr_inline_decode(xdr, 8); |
| 3981 | if (unlikely(!p)) |
| 3982 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3983 | xdr_decode_hyper(p, res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3984 | bitmap[1] &= ~FATTR4_WORD1_SPACE_FREE; |
| 3985 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3986 | dprintk("%s: space free=%Lu\n", __func__, (unsigned long long)*res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3987 | return status; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3988 | out_overflow: |
| 3989 | print_overflow_msg(__func__, xdr); |
| 3990 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3991 | } |
| 3992 | |
| 3993 | static int decode_attr_space_total(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *res) |
| 3994 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3995 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3996 | int status = 0; |
| 3997 | |
| 3998 | *res = 0; |
| 3999 | if (unlikely(bitmap[1] & (FATTR4_WORD1_SPACE_TOTAL - 1U))) |
| 4000 | return -EIO; |
| 4001 | if (likely(bitmap[1] & FATTR4_WORD1_SPACE_TOTAL)) { |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 4002 | p = xdr_inline_decode(xdr, 8); |
| 4003 | if (unlikely(!p)) |
| 4004 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 4005 | xdr_decode_hyper(p, res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4006 | bitmap[1] &= ~FATTR4_WORD1_SPACE_TOTAL; |
| 4007 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 4008 | dprintk("%s: space total=%Lu\n", __func__, (unsigned long long)*res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4009 | return status; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 4010 | out_overflow: |
| 4011 | print_overflow_msg(__func__, xdr); |
| 4012 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4013 | } |
| 4014 | |
| 4015 | static int decode_attr_space_used(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *used) |
| 4016 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 4017 | __be32 *p; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 4018 | int ret = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4019 | |
| 4020 | *used = 0; |
| 4021 | if (unlikely(bitmap[1] & (FATTR4_WORD1_SPACE_USED - 1U))) |
| 4022 | return -EIO; |
| 4023 | if (likely(bitmap[1] & FATTR4_WORD1_SPACE_USED)) { |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 4024 | p = xdr_inline_decode(xdr, 8); |
| 4025 | if (unlikely(!p)) |
| 4026 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 4027 | xdr_decode_hyper(p, used); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4028 | bitmap[1] &= ~FATTR4_WORD1_SPACE_USED; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 4029 | ret = NFS_ATTR_FATTR_SPACE_USED; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4030 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 4031 | dprintk("%s: space used=%Lu\n", __func__, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4032 | (unsigned long long)*used); |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 4033 | return ret; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 4034 | out_overflow: |
| 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_time(struct xdr_stream *xdr, struct timespec *time) |
| 4040 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 4041 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4042 | uint64_t sec; |
| 4043 | uint32_t nsec; |
| 4044 | |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 4045 | p = xdr_inline_decode(xdr, 12); |
| 4046 | if (unlikely(!p)) |
| 4047 | goto out_overflow; |
Benny Halevy | 3ceb4db | 2009-08-14 17:19:41 +0300 | [diff] [blame] | 4048 | p = xdr_decode_hyper(p, &sec); |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 4049 | nsec = be32_to_cpup(p); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4050 | time->tv_sec = (time_t)sec; |
| 4051 | time->tv_nsec = (long)nsec; |
| 4052 | return 0; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 4053 | out_overflow: |
| 4054 | print_overflow_msg(__func__, xdr); |
| 4055 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4056 | } |
| 4057 | |
| 4058 | static int decode_attr_time_access(struct xdr_stream *xdr, uint32_t *bitmap, struct timespec *time) |
| 4059 | { |
| 4060 | int status = 0; |
| 4061 | |
| 4062 | time->tv_sec = 0; |
| 4063 | time->tv_nsec = 0; |
| 4064 | if (unlikely(bitmap[1] & (FATTR4_WORD1_TIME_ACCESS - 1U))) |
| 4065 | return -EIO; |
| 4066 | if (likely(bitmap[1] & FATTR4_WORD1_TIME_ACCESS)) { |
| 4067 | status = decode_attr_time(xdr, time); |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 4068 | if (status == 0) |
| 4069 | status = NFS_ATTR_FATTR_ATIME; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4070 | bitmap[1] &= ~FATTR4_WORD1_TIME_ACCESS; |
| 4071 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 4072 | dprintk("%s: atime=%ld\n", __func__, (long)time->tv_sec); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4073 | return status; |
| 4074 | } |
| 4075 | |
| 4076 | static int decode_attr_time_metadata(struct xdr_stream *xdr, uint32_t *bitmap, struct timespec *time) |
| 4077 | { |
| 4078 | int status = 0; |
| 4079 | |
| 4080 | time->tv_sec = 0; |
| 4081 | time->tv_nsec = 0; |
| 4082 | if (unlikely(bitmap[1] & (FATTR4_WORD1_TIME_METADATA - 1U))) |
| 4083 | return -EIO; |
| 4084 | if (likely(bitmap[1] & FATTR4_WORD1_TIME_METADATA)) { |
| 4085 | status = decode_attr_time(xdr, time); |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 4086 | if (status == 0) |
| 4087 | status = NFS_ATTR_FATTR_CTIME; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4088 | bitmap[1] &= ~FATTR4_WORD1_TIME_METADATA; |
| 4089 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 4090 | dprintk("%s: ctime=%ld\n", __func__, (long)time->tv_sec); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4091 | return status; |
| 4092 | } |
| 4093 | |
Ricardo Labiaga | 55b6e77 | 2010-10-12 16:30:06 -0700 | [diff] [blame] | 4094 | static int decode_attr_time_delta(struct xdr_stream *xdr, uint32_t *bitmap, |
| 4095 | struct timespec *time) |
| 4096 | { |
| 4097 | int status = 0; |
| 4098 | |
| 4099 | time->tv_sec = 0; |
| 4100 | time->tv_nsec = 0; |
| 4101 | if (unlikely(bitmap[1] & (FATTR4_WORD1_TIME_DELTA - 1U))) |
| 4102 | return -EIO; |
| 4103 | if (likely(bitmap[1] & FATTR4_WORD1_TIME_DELTA)) { |
| 4104 | status = decode_attr_time(xdr, time); |
| 4105 | bitmap[1] &= ~FATTR4_WORD1_TIME_DELTA; |
| 4106 | } |
| 4107 | dprintk("%s: time_delta=%ld %ld\n", __func__, (long)time->tv_sec, |
| 4108 | (long)time->tv_nsec); |
| 4109 | return status; |
| 4110 | } |
| 4111 | |
David Quigley | aa9c266 | 2013-05-22 12:50:44 -0400 | [diff] [blame] | 4112 | static int decode_attr_security_label(struct xdr_stream *xdr, uint32_t *bitmap, |
| 4113 | struct nfs4_label *label) |
| 4114 | { |
| 4115 | uint32_t pi = 0; |
| 4116 | uint32_t lfs = 0; |
| 4117 | __u32 len; |
| 4118 | __be32 *p; |
| 4119 | int status = 0; |
| 4120 | |
| 4121 | if (unlikely(bitmap[2] & (FATTR4_WORD2_SECURITY_LABEL - 1U))) |
| 4122 | return -EIO; |
| 4123 | if (likely(bitmap[2] & FATTR4_WORD2_SECURITY_LABEL)) { |
| 4124 | p = xdr_inline_decode(xdr, 4); |
| 4125 | if (unlikely(!p)) |
| 4126 | goto out_overflow; |
| 4127 | lfs = be32_to_cpup(p++); |
| 4128 | p = xdr_inline_decode(xdr, 4); |
| 4129 | if (unlikely(!p)) |
| 4130 | goto out_overflow; |
| 4131 | pi = be32_to_cpup(p++); |
| 4132 | p = xdr_inline_decode(xdr, 4); |
| 4133 | if (unlikely(!p)) |
| 4134 | goto out_overflow; |
| 4135 | len = be32_to_cpup(p++); |
| 4136 | p = xdr_inline_decode(xdr, len); |
| 4137 | if (unlikely(!p)) |
| 4138 | goto out_overflow; |
| 4139 | if (len < NFS4_MAXLABELLEN) { |
| 4140 | if (label) { |
| 4141 | memcpy(label->label, p, len); |
| 4142 | label->len = len; |
| 4143 | label->pi = pi; |
| 4144 | label->lfs = lfs; |
| 4145 | status = NFS_ATTR_FATTR_V4_SECURITY_LABEL; |
| 4146 | } |
| 4147 | bitmap[2] &= ~FATTR4_WORD2_SECURITY_LABEL; |
| 4148 | } else |
| 4149 | printk(KERN_WARNING "%s: label too long (%u)!\n", |
| 4150 | __func__, len); |
| 4151 | } |
| 4152 | if (label && label->label) |
| 4153 | dprintk("%s: label=%s, len=%d, PI=%d, LFS=%d\n", __func__, |
| 4154 | (char *)label->label, label->len, label->pi, label->lfs); |
| 4155 | return status; |
| 4156 | |
| 4157 | out_overflow: |
| 4158 | print_overflow_msg(__func__, xdr); |
| 4159 | return -EIO; |
| 4160 | } |
| 4161 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4162 | static int decode_attr_time_modify(struct xdr_stream *xdr, uint32_t *bitmap, struct timespec *time) |
| 4163 | { |
| 4164 | int status = 0; |
| 4165 | |
| 4166 | time->tv_sec = 0; |
| 4167 | time->tv_nsec = 0; |
| 4168 | if (unlikely(bitmap[1] & (FATTR4_WORD1_TIME_MODIFY - 1U))) |
| 4169 | return -EIO; |
| 4170 | if (likely(bitmap[1] & FATTR4_WORD1_TIME_MODIFY)) { |
| 4171 | status = decode_attr_time(xdr, time); |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 4172 | if (status == 0) |
| 4173 | status = NFS_ATTR_FATTR_MTIME; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4174 | bitmap[1] &= ~FATTR4_WORD1_TIME_MODIFY; |
| 4175 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 4176 | dprintk("%s: mtime=%ld\n", __func__, (long)time->tv_sec); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4177 | return status; |
| 4178 | } |
| 4179 | |
Trond Myklebust | 256e48b | 2012-06-21 11:18:13 -0400 | [diff] [blame] | 4180 | 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] | 4181 | { |
| 4182 | unsigned int attrwords = XDR_QUADLEN(attrlen); |
Trond Myklebust | 256e48b | 2012-06-21 11:18:13 -0400 | [diff] [blame] | 4183 | unsigned int nwords = (xdr_stream_pos(xdr) - savep) >> 2; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4184 | |
| 4185 | if (unlikely(attrwords != nwords)) { |
Chuck Lever | fe82a18 | 2007-09-11 18:01:10 -0400 | [diff] [blame] | 4186 | dprintk("%s: server returned incorrect attribute length: " |
| 4187 | "%u %c %u\n", |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 4188 | __func__, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4189 | attrwords << 2, |
| 4190 | (attrwords < nwords) ? '<' : '>', |
| 4191 | nwords << 2); |
| 4192 | return -EIO; |
| 4193 | } |
| 4194 | return 0; |
| 4195 | } |
| 4196 | |
| 4197 | static int decode_change_info(struct xdr_stream *xdr, struct nfs4_change_info *cinfo) |
| 4198 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 4199 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4200 | |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 4201 | p = xdr_inline_decode(xdr, 20); |
| 4202 | if (unlikely(!p)) |
| 4203 | goto out_overflow; |
Benny Halevy | 6f723f7 | 2009-08-14 17:19:37 +0300 | [diff] [blame] | 4204 | cinfo->atomic = be32_to_cpup(p++); |
Benny Halevy | 3ceb4db | 2009-08-14 17:19:41 +0300 | [diff] [blame] | 4205 | p = xdr_decode_hyper(p, &cinfo->before); |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 4206 | xdr_decode_hyper(p, &cinfo->after); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4207 | return 0; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 4208 | out_overflow: |
| 4209 | print_overflow_msg(__func__, xdr); |
| 4210 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4211 | } |
| 4212 | |
Weston Andros Adamson | 6168f62 | 2012-09-10 14:00:46 -0400 | [diff] [blame] | 4213 | static int decode_access(struct xdr_stream *xdr, u32 *supported, u32 *access) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4214 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 4215 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4216 | uint32_t supp, acc; |
| 4217 | int status; |
| 4218 | |
| 4219 | status = decode_op_hdr(xdr, OP_ACCESS); |
| 4220 | if (status) |
| 4221 | return status; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 4222 | p = xdr_inline_decode(xdr, 8); |
| 4223 | if (unlikely(!p)) |
| 4224 | goto out_overflow; |
Benny Halevy | 6f723f7 | 2009-08-14 17:19:37 +0300 | [diff] [blame] | 4225 | supp = be32_to_cpup(p++); |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 4226 | acc = be32_to_cpup(p); |
Weston Andros Adamson | 6168f62 | 2012-09-10 14:00:46 -0400 | [diff] [blame] | 4227 | *supported = supp; |
| 4228 | *access = acc; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4229 | return 0; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 4230 | out_overflow: |
| 4231 | print_overflow_msg(__func__, xdr); |
| 4232 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4233 | } |
| 4234 | |
Benny Halevy | 07d3043 | 2009-08-14 17:19:52 +0300 | [diff] [blame] | 4235 | 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] | 4236 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 4237 | __be32 *p; |
Benny Halevy | 07d3043 | 2009-08-14 17:19:52 +0300 | [diff] [blame] | 4238 | |
| 4239 | p = xdr_inline_decode(xdr, len); |
| 4240 | if (likely(p)) { |
| 4241 | memcpy(buf, p, len); |
| 4242 | return 0; |
| 4243 | } |
| 4244 | print_overflow_msg(__func__, xdr); |
| 4245 | return -EIO; |
| 4246 | } |
| 4247 | |
| 4248 | static int decode_stateid(struct xdr_stream *xdr, nfs4_stateid *stateid) |
| 4249 | { |
Trond Myklebust | 2d2f24a | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 4250 | return decode_opaque_fixed(xdr, stateid, NFS4_STATEID_SIZE); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4251 | } |
| 4252 | |
| 4253 | static int decode_close(struct xdr_stream *xdr, struct nfs_closeres *res) |
| 4254 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4255 | int status; |
| 4256 | |
| 4257 | status = decode_op_hdr(xdr, OP_CLOSE); |
Trond Myklebust | c1d5193 | 2008-04-07 13:20:54 -0400 | [diff] [blame] | 4258 | if (status != -EIO) |
| 4259 | nfs_increment_open_seqid(status, res->seqid); |
Benny Halevy | 07d3043 | 2009-08-14 17:19:52 +0300 | [diff] [blame] | 4260 | if (!status) |
| 4261 | status = decode_stateid(xdr, &res->stateid); |
| 4262 | return status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4263 | } |
| 4264 | |
Benny Halevy | db942bb | 2009-08-14 17:19:56 +0300 | [diff] [blame] | 4265 | static int decode_verifier(struct xdr_stream *xdr, void *verifier) |
| 4266 | { |
Chuck Lever | cd93710 | 2012-03-02 17:14:31 -0500 | [diff] [blame] | 4267 | return decode_opaque_fixed(xdr, verifier, NFS4_VERIFIER_SIZE); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4268 | } |
| 4269 | |
Trond Myklebust | 2f2c63b | 2012-06-08 11:56:09 -0400 | [diff] [blame] | 4270 | static int decode_write_verifier(struct xdr_stream *xdr, struct nfs_write_verifier *verifier) |
| 4271 | { |
| 4272 | return decode_opaque_fixed(xdr, verifier->data, NFS4_VERIFIER_SIZE); |
| 4273 | } |
| 4274 | |
Fred Isaman | 0b7c015 | 2012-04-20 14:47:39 -0400 | [diff] [blame] | 4275 | static int decode_commit(struct xdr_stream *xdr, struct nfs_commitres *res) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4276 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4277 | int status; |
| 4278 | |
| 4279 | status = decode_op_hdr(xdr, OP_COMMIT); |
Benny Halevy | db942bb | 2009-08-14 17:19:56 +0300 | [diff] [blame] | 4280 | if (!status) |
Trond Myklebust | 2f2c63b | 2012-06-08 11:56:09 -0400 | [diff] [blame] | 4281 | status = decode_write_verifier(xdr, &res->verf->verifier); |
Benny Halevy | db942bb | 2009-08-14 17:19:56 +0300 | [diff] [blame] | 4282 | return status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4283 | } |
| 4284 | |
| 4285 | static int decode_create(struct xdr_stream *xdr, struct nfs4_change_info *cinfo) |
| 4286 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 4287 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4288 | uint32_t bmlen; |
| 4289 | int status; |
| 4290 | |
| 4291 | status = decode_op_hdr(xdr, OP_CREATE); |
| 4292 | if (status) |
| 4293 | return status; |
| 4294 | if ((status = decode_change_info(xdr, cinfo))) |
| 4295 | return status; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 4296 | p = xdr_inline_decode(xdr, 4); |
| 4297 | if (unlikely(!p)) |
| 4298 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 4299 | bmlen = be32_to_cpup(p); |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 4300 | p = xdr_inline_decode(xdr, bmlen << 2); |
| 4301 | if (likely(p)) |
| 4302 | return 0; |
| 4303 | out_overflow: |
| 4304 | print_overflow_msg(__func__, xdr); |
| 4305 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4306 | } |
| 4307 | |
| 4308 | static int decode_server_caps(struct xdr_stream *xdr, struct nfs4_server_caps_res *res) |
| 4309 | { |
Trond Myklebust | 256e48b | 2012-06-21 11:18:13 -0400 | [diff] [blame] | 4310 | unsigned int savep; |
Fred Isaman | dae100c | 2011-07-30 20:52:37 -0400 | [diff] [blame] | 4311 | uint32_t attrlen, bitmap[3] = {0}; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4312 | int status; |
| 4313 | |
| 4314 | if ((status = decode_op_hdr(xdr, OP_GETATTR)) != 0) |
| 4315 | goto xdr_error; |
| 4316 | if ((status = decode_attr_bitmap(xdr, bitmap)) != 0) |
| 4317 | goto xdr_error; |
| 4318 | if ((status = decode_attr_length(xdr, &attrlen, &savep)) != 0) |
| 4319 | goto xdr_error; |
| 4320 | if ((status = decode_attr_supported(xdr, bitmap, res->attr_bitmask)) != 0) |
| 4321 | goto xdr_error; |
Chuck Lever | 264e635 | 2012-03-01 17:02:05 -0500 | [diff] [blame] | 4322 | if ((status = decode_attr_fh_expire_type(xdr, bitmap, |
| 4323 | &res->fh_expire_type)) != 0) |
| 4324 | goto xdr_error; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4325 | if ((status = decode_attr_link_support(xdr, bitmap, &res->has_links)) != 0) |
| 4326 | goto xdr_error; |
| 4327 | if ((status = decode_attr_symlink_support(xdr, bitmap, &res->has_symlinks)) != 0) |
| 4328 | goto xdr_error; |
| 4329 | if ((status = decode_attr_aclsupport(xdr, bitmap, &res->acl_bitmask)) != 0) |
| 4330 | goto xdr_error; |
| 4331 | status = verify_attr_len(xdr, savep, attrlen); |
| 4332 | xdr_error: |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 4333 | dprintk("%s: xdr returned %d!\n", __func__, -status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4334 | return status; |
| 4335 | } |
Andy Adamson | 6c0195a | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 4336 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4337 | static int decode_statfs(struct xdr_stream *xdr, struct nfs_fsstat *fsstat) |
| 4338 | { |
Trond Myklebust | 256e48b | 2012-06-21 11:18:13 -0400 | [diff] [blame] | 4339 | unsigned int savep; |
Fred Isaman | dae100c | 2011-07-30 20:52:37 -0400 | [diff] [blame] | 4340 | uint32_t attrlen, bitmap[3] = {0}; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4341 | int status; |
Andy Adamson | 6c0195a | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 4342 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4343 | if ((status = decode_op_hdr(xdr, OP_GETATTR)) != 0) |
| 4344 | goto xdr_error; |
| 4345 | if ((status = decode_attr_bitmap(xdr, bitmap)) != 0) |
| 4346 | goto xdr_error; |
| 4347 | if ((status = decode_attr_length(xdr, &attrlen, &savep)) != 0) |
| 4348 | goto xdr_error; |
| 4349 | |
| 4350 | if ((status = decode_attr_files_avail(xdr, bitmap, &fsstat->afiles)) != 0) |
| 4351 | goto xdr_error; |
| 4352 | if ((status = decode_attr_files_free(xdr, bitmap, &fsstat->ffiles)) != 0) |
| 4353 | goto xdr_error; |
| 4354 | if ((status = decode_attr_files_total(xdr, bitmap, &fsstat->tfiles)) != 0) |
| 4355 | goto xdr_error; |
| 4356 | if ((status = decode_attr_space_avail(xdr, bitmap, &fsstat->abytes)) != 0) |
| 4357 | goto xdr_error; |
| 4358 | if ((status = decode_attr_space_free(xdr, bitmap, &fsstat->fbytes)) != 0) |
| 4359 | goto xdr_error; |
| 4360 | if ((status = decode_attr_space_total(xdr, bitmap, &fsstat->tbytes)) != 0) |
| 4361 | goto xdr_error; |
| 4362 | |
| 4363 | status = verify_attr_len(xdr, savep, attrlen); |
| 4364 | xdr_error: |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 4365 | dprintk("%s: xdr returned %d!\n", __func__, -status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4366 | return status; |
| 4367 | } |
| 4368 | |
| 4369 | static int decode_pathconf(struct xdr_stream *xdr, struct nfs_pathconf *pathconf) |
| 4370 | { |
Trond Myklebust | 256e48b | 2012-06-21 11:18:13 -0400 | [diff] [blame] | 4371 | unsigned int savep; |
Fred Isaman | dae100c | 2011-07-30 20:52:37 -0400 | [diff] [blame] | 4372 | uint32_t attrlen, bitmap[3] = {0}; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4373 | int status; |
Andy Adamson | 6c0195a | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 4374 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4375 | if ((status = decode_op_hdr(xdr, OP_GETATTR)) != 0) |
| 4376 | goto xdr_error; |
| 4377 | if ((status = decode_attr_bitmap(xdr, bitmap)) != 0) |
| 4378 | goto xdr_error; |
| 4379 | if ((status = decode_attr_length(xdr, &attrlen, &savep)) != 0) |
| 4380 | goto xdr_error; |
| 4381 | |
| 4382 | if ((status = decode_attr_maxlink(xdr, bitmap, &pathconf->max_link)) != 0) |
| 4383 | goto xdr_error; |
| 4384 | if ((status = decode_attr_maxname(xdr, bitmap, &pathconf->max_namelen)) != 0) |
| 4385 | goto xdr_error; |
| 4386 | |
| 4387 | status = verify_attr_len(xdr, savep, attrlen); |
| 4388 | xdr_error: |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 4389 | dprintk("%s: xdr returned %d!\n", __func__, -status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4390 | return status; |
| 4391 | } |
| 4392 | |
Andy Adamson | 88034c3 | 2012-05-23 05:02:34 -0400 | [diff] [blame] | 4393 | static int decode_threshold_hint(struct xdr_stream *xdr, |
| 4394 | uint32_t *bitmap, |
| 4395 | uint64_t *res, |
| 4396 | uint32_t hint_bit) |
| 4397 | { |
| 4398 | __be32 *p; |
| 4399 | |
| 4400 | *res = 0; |
| 4401 | if (likely(bitmap[0] & hint_bit)) { |
| 4402 | p = xdr_inline_decode(xdr, 8); |
| 4403 | if (unlikely(!p)) |
| 4404 | goto out_overflow; |
| 4405 | xdr_decode_hyper(p, res); |
| 4406 | } |
| 4407 | return 0; |
| 4408 | out_overflow: |
| 4409 | print_overflow_msg(__func__, xdr); |
| 4410 | return -EIO; |
| 4411 | } |
| 4412 | |
| 4413 | static int decode_first_threshold_item4(struct xdr_stream *xdr, |
| 4414 | struct nfs4_threshold *res) |
| 4415 | { |
Trond Myklebust | 256e48b | 2012-06-21 11:18:13 -0400 | [diff] [blame] | 4416 | __be32 *p; |
| 4417 | unsigned int savep; |
Andy Adamson | 88034c3 | 2012-05-23 05:02:34 -0400 | [diff] [blame] | 4418 | uint32_t bitmap[3] = {0,}, attrlen; |
| 4419 | int status; |
| 4420 | |
| 4421 | /* layout type */ |
| 4422 | p = xdr_inline_decode(xdr, 4); |
| 4423 | if (unlikely(!p)) { |
| 4424 | print_overflow_msg(__func__, xdr); |
| 4425 | return -EIO; |
| 4426 | } |
| 4427 | res->l_type = be32_to_cpup(p); |
| 4428 | |
| 4429 | /* thi_hintset bitmap */ |
| 4430 | status = decode_attr_bitmap(xdr, bitmap); |
| 4431 | if (status < 0) |
| 4432 | goto xdr_error; |
| 4433 | |
| 4434 | /* thi_hintlist length */ |
| 4435 | status = decode_attr_length(xdr, &attrlen, &savep); |
| 4436 | if (status < 0) |
| 4437 | goto xdr_error; |
| 4438 | /* thi_hintlist */ |
| 4439 | status = decode_threshold_hint(xdr, bitmap, &res->rd_sz, THRESHOLD_RD); |
| 4440 | if (status < 0) |
| 4441 | goto xdr_error; |
| 4442 | status = decode_threshold_hint(xdr, bitmap, &res->wr_sz, THRESHOLD_WR); |
| 4443 | if (status < 0) |
| 4444 | goto xdr_error; |
| 4445 | status = decode_threshold_hint(xdr, bitmap, &res->rd_io_sz, |
| 4446 | THRESHOLD_RD_IO); |
| 4447 | if (status < 0) |
| 4448 | goto xdr_error; |
| 4449 | status = decode_threshold_hint(xdr, bitmap, &res->wr_io_sz, |
| 4450 | THRESHOLD_WR_IO); |
| 4451 | if (status < 0) |
| 4452 | goto xdr_error; |
| 4453 | |
| 4454 | status = verify_attr_len(xdr, savep, attrlen); |
| 4455 | res->bm = bitmap[0]; |
| 4456 | |
| 4457 | dprintk("%s bm=0x%x rd_sz=%llu wr_sz=%llu rd_io=%llu wr_io=%llu\n", |
| 4458 | __func__, res->bm, res->rd_sz, res->wr_sz, res->rd_io_sz, |
| 4459 | res->wr_io_sz); |
| 4460 | xdr_error: |
| 4461 | dprintk("%s ret=%d!\n", __func__, status); |
| 4462 | return status; |
| 4463 | } |
| 4464 | |
| 4465 | /* |
| 4466 | * Thresholds on pNFS direct I/O vrs MDS I/O |
| 4467 | */ |
| 4468 | static int decode_attr_mdsthreshold(struct xdr_stream *xdr, |
| 4469 | uint32_t *bitmap, |
| 4470 | struct nfs4_threshold *res) |
| 4471 | { |
| 4472 | __be32 *p; |
| 4473 | int status = 0; |
| 4474 | uint32_t num; |
| 4475 | |
| 4476 | if (unlikely(bitmap[2] & (FATTR4_WORD2_MDSTHRESHOLD - 1U))) |
| 4477 | return -EIO; |
Trond Myklebust | 029c534 | 2012-06-05 09:35:44 -0400 | [diff] [blame] | 4478 | if (bitmap[2] & FATTR4_WORD2_MDSTHRESHOLD) { |
Trond Myklebust | 1549210f | 2012-06-05 09:16:47 -0400 | [diff] [blame] | 4479 | /* Did the server return an unrequested attribute? */ |
| 4480 | if (unlikely(res == NULL)) |
| 4481 | return -EREMOTEIO; |
Andy Adamson | 88034c3 | 2012-05-23 05:02:34 -0400 | [diff] [blame] | 4482 | p = xdr_inline_decode(xdr, 4); |
| 4483 | if (unlikely(!p)) |
| 4484 | goto out_overflow; |
| 4485 | num = be32_to_cpup(p); |
| 4486 | if (num == 0) |
| 4487 | return 0; |
| 4488 | if (num > 1) |
| 4489 | printk(KERN_INFO "%s: Warning: Multiple pNFS layout " |
| 4490 | "drivers per filesystem not supported\n", |
| 4491 | __func__); |
| 4492 | |
| 4493 | status = decode_first_threshold_item4(xdr, res); |
Trond Myklebust | 029c534 | 2012-06-05 09:35:44 -0400 | [diff] [blame] | 4494 | bitmap[2] &= ~FATTR4_WORD2_MDSTHRESHOLD; |
Andy Adamson | 88034c3 | 2012-05-23 05:02:34 -0400 | [diff] [blame] | 4495 | } |
| 4496 | return status; |
| 4497 | out_overflow: |
| 4498 | print_overflow_msg(__func__, xdr); |
| 4499 | return -EIO; |
| 4500 | } |
| 4501 | |
Bryan Schumaker | ae42c70 | 2010-10-21 16:33:17 -0400 | [diff] [blame] | 4502 | static int decode_getfattr_attrs(struct xdr_stream *xdr, uint32_t *bitmap, |
| 4503 | struct nfs_fattr *fattr, struct nfs_fh *fh, |
David Quigley | aa9c266 | 2013-05-22 12:50:44 -0400 | [diff] [blame] | 4504 | struct nfs4_fs_locations *fs_loc, struct nfs4_label *label, |
Trond Myklebust | 6926afd1 | 2012-01-07 13:22:46 -0500 | [diff] [blame] | 4505 | const struct nfs_server *server) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4506 | { |
Trond Myklebust | bca7947 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 4507 | int status; |
| 4508 | umode_t fmode = 0; |
Bryan Schumaker | ae42c70 | 2010-10-21 16:33:17 -0400 | [diff] [blame] | 4509 | uint32_t type; |
Trond Myklebust | ee7b75f | 2011-06-16 13:15:41 -0400 | [diff] [blame] | 4510 | int32_t err; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4511 | |
Trond Myklebust | f26c7a7 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 4512 | status = decode_attr_type(xdr, bitmap, &type); |
| 4513 | if (status < 0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4514 | goto xdr_error; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 4515 | fattr->mode = 0; |
| 4516 | if (status != 0) { |
| 4517 | fattr->mode |= nfs_type2fmt[type]; |
| 4518 | fattr->valid |= status; |
| 4519 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4520 | |
Trond Myklebust | f26c7a7 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 4521 | status = decode_attr_change(xdr, bitmap, &fattr->change_attr); |
| 4522 | if (status < 0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4523 | goto xdr_error; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 4524 | fattr->valid |= status; |
Trond Myklebust | f26c7a7 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 4525 | |
| 4526 | status = decode_attr_size(xdr, bitmap, &fattr->size); |
| 4527 | if (status < 0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4528 | goto xdr_error; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 4529 | fattr->valid |= status; |
Trond Myklebust | f26c7a7 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 4530 | |
| 4531 | status = decode_attr_fsid(xdr, bitmap, &fattr->fsid); |
| 4532 | if (status < 0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4533 | goto xdr_error; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 4534 | fattr->valid |= status; |
Trond Myklebust | f26c7a7 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 4535 | |
Trond Myklebust | ee7b75f | 2011-06-16 13:15:41 -0400 | [diff] [blame] | 4536 | err = 0; |
| 4537 | status = decode_attr_error(xdr, bitmap, &err); |
Bryan Schumaker | ae42c70 | 2010-10-21 16:33:17 -0400 | [diff] [blame] | 4538 | if (status < 0) |
| 4539 | goto xdr_error; |
| 4540 | |
| 4541 | status = decode_attr_filehandle(xdr, bitmap, fh); |
| 4542 | if (status < 0) |
| 4543 | goto xdr_error; |
| 4544 | |
Trond Myklebust | f26c7a7 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 4545 | status = decode_attr_fileid(xdr, bitmap, &fattr->fileid); |
| 4546 | if (status < 0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4547 | goto xdr_error; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 4548 | fattr->valid |= status; |
Trond Myklebust | f26c7a7 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 4549 | |
Trond Myklebust | 8b7e3f4 | 2012-01-30 15:43:56 -0500 | [diff] [blame] | 4550 | status = decode_attr_fs_locations(xdr, bitmap, fs_loc); |
Trond Myklebust | f26c7a7 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 4551 | if (status < 0) |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 4552 | goto xdr_error; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 4553 | fattr->valid |= status; |
Trond Myklebust | f26c7a7 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 4554 | |
| 4555 | status = decode_attr_mode(xdr, bitmap, &fmode); |
| 4556 | if (status < 0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4557 | goto xdr_error; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 4558 | if (status != 0) { |
| 4559 | fattr->mode |= fmode; |
| 4560 | fattr->valid |= status; |
| 4561 | } |
Trond Myklebust | f26c7a7 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 4562 | |
| 4563 | status = decode_attr_nlink(xdr, bitmap, &fattr->nlink); |
| 4564 | if (status < 0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4565 | goto xdr_error; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 4566 | fattr->valid |= status; |
Trond Myklebust | f26c7a7 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 4567 | |
Trond Myklebust | 6926afd1 | 2012-01-07 13:22:46 -0500 | [diff] [blame] | 4568 | status = decode_attr_owner(xdr, bitmap, server, &fattr->uid, fattr->owner_name); |
Trond Myklebust | f26c7a7 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 4569 | if (status < 0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4570 | goto xdr_error; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 4571 | fattr->valid |= status; |
Trond Myklebust | f26c7a7 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 4572 | |
Trond Myklebust | 6926afd1 | 2012-01-07 13:22:46 -0500 | [diff] [blame] | 4573 | status = decode_attr_group(xdr, bitmap, server, &fattr->gid, fattr->group_name); |
Trond Myklebust | f26c7a7 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 4574 | if (status < 0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4575 | goto xdr_error; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 4576 | fattr->valid |= status; |
Trond Myklebust | f26c7a7 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 4577 | |
| 4578 | status = decode_attr_rdev(xdr, bitmap, &fattr->rdev); |
| 4579 | if (status < 0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4580 | goto xdr_error; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 4581 | fattr->valid |= status; |
Trond Myklebust | f26c7a7 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 4582 | |
| 4583 | status = decode_attr_space_used(xdr, bitmap, &fattr->du.nfs3.used); |
| 4584 | if (status < 0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4585 | goto xdr_error; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 4586 | fattr->valid |= status; |
Trond Myklebust | f26c7a7 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 4587 | |
| 4588 | status = decode_attr_time_access(xdr, bitmap, &fattr->atime); |
| 4589 | if (status < 0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4590 | goto xdr_error; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 4591 | fattr->valid |= status; |
Trond Myklebust | f26c7a7 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 4592 | |
| 4593 | status = decode_attr_time_metadata(xdr, bitmap, &fattr->ctime); |
| 4594 | if (status < 0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4595 | goto xdr_error; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 4596 | fattr->valid |= status; |
Trond Myklebust | f26c7a7 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 4597 | |
| 4598 | status = decode_attr_time_modify(xdr, bitmap, &fattr->mtime); |
| 4599 | if (status < 0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4600 | goto xdr_error; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 4601 | fattr->valid |= status; |
Trond Myklebust | f26c7a7 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 4602 | |
Trond Myklebust | 28331a4 | 2011-04-27 13:47:52 -0400 | [diff] [blame] | 4603 | status = decode_attr_mounted_on_fileid(xdr, bitmap, &fattr->mounted_on_fileid); |
Trond Myklebust | f26c7a7 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 4604 | if (status < 0) |
Manoj Naik | 99baf62 | 2006-06-09 09:34:24 -0400 | [diff] [blame] | 4605 | goto xdr_error; |
Trond Myklebust | 28331a4 | 2011-04-27 13:47:52 -0400 | [diff] [blame] | 4606 | fattr->valid |= status; |
Trond Myklebust | f26c7a7 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 4607 | |
Andy Adamson | 88034c3 | 2012-05-23 05:02:34 -0400 | [diff] [blame] | 4608 | status = decode_attr_mdsthreshold(xdr, bitmap, fattr->mdsthreshold); |
| 4609 | if (status < 0) |
| 4610 | goto xdr_error; |
| 4611 | |
David Quigley | aa9c266 | 2013-05-22 12:50:44 -0400 | [diff] [blame] | 4612 | if (label) { |
| 4613 | status = decode_attr_security_label(xdr, bitmap, label); |
| 4614 | if (status < 0) |
| 4615 | goto xdr_error; |
| 4616 | fattr->valid |= status; |
| 4617 | } |
| 4618 | |
Bryan Schumaker | ae42c70 | 2010-10-21 16:33:17 -0400 | [diff] [blame] | 4619 | xdr_error: |
| 4620 | dprintk("%s: xdr returned %d\n", __func__, -status); |
| 4621 | return status; |
| 4622 | } |
| 4623 | |
| 4624 | 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] | 4625 | struct nfs_fh *fh, struct nfs4_fs_locations *fs_loc, |
David Quigley | aa9c266 | 2013-05-22 12:50:44 -0400 | [diff] [blame] | 4626 | struct nfs4_label *label, const struct nfs_server *server) |
Bryan Schumaker | ae42c70 | 2010-10-21 16:33:17 -0400 | [diff] [blame] | 4627 | { |
Trond Myklebust | 256e48b | 2012-06-21 11:18:13 -0400 | [diff] [blame] | 4628 | unsigned int savep; |
Bryan Schumaker | ae42c70 | 2010-10-21 16:33:17 -0400 | [diff] [blame] | 4629 | uint32_t attrlen, |
Fred Isaman | dae100c | 2011-07-30 20:52:37 -0400 | [diff] [blame] | 4630 | bitmap[3] = {0}; |
Bryan Schumaker | ae42c70 | 2010-10-21 16:33:17 -0400 | [diff] [blame] | 4631 | int status; |
| 4632 | |
| 4633 | status = decode_op_hdr(xdr, OP_GETATTR); |
| 4634 | if (status < 0) |
| 4635 | goto xdr_error; |
| 4636 | |
| 4637 | status = decode_attr_bitmap(xdr, bitmap); |
| 4638 | if (status < 0) |
| 4639 | goto xdr_error; |
| 4640 | |
| 4641 | status = decode_attr_length(xdr, &attrlen, &savep); |
| 4642 | if (status < 0) |
| 4643 | goto xdr_error; |
| 4644 | |
David Quigley | aa9c266 | 2013-05-22 12:50:44 -0400 | [diff] [blame] | 4645 | status = decode_getfattr_attrs(xdr, bitmap, fattr, fh, fs_loc, |
| 4646 | label, server); |
Bryan Schumaker | ae42c70 | 2010-10-21 16:33:17 -0400 | [diff] [blame] | 4647 | if (status < 0) |
| 4648 | goto xdr_error; |
| 4649 | |
Trond Myklebust | f26c7a7 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 4650 | status = verify_attr_len(xdr, savep, attrlen); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4651 | xdr_error: |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 4652 | dprintk("%s: xdr returned %d\n", __func__, -status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4653 | return status; |
| 4654 | } |
| 4655 | |
David Quigley | aa9c266 | 2013-05-22 12:50:44 -0400 | [diff] [blame] | 4656 | static int decode_getfattr_label(struct xdr_stream *xdr, struct nfs_fattr *fattr, |
| 4657 | struct nfs4_label *label, const struct nfs_server *server) |
| 4658 | { |
| 4659 | return decode_getfattr_generic(xdr, fattr, NULL, NULL, label, server); |
| 4660 | } |
| 4661 | |
Bryan Schumaker | ae42c70 | 2010-10-21 16:33:17 -0400 | [diff] [blame] | 4662 | static int decode_getfattr(struct xdr_stream *xdr, struct nfs_fattr *fattr, |
Trond Myklebust | 6926afd1 | 2012-01-07 13:22:46 -0500 | [diff] [blame] | 4663 | const struct nfs_server *server) |
Bryan Schumaker | ae42c70 | 2010-10-21 16:33:17 -0400 | [diff] [blame] | 4664 | { |
David Quigley | aa9c266 | 2013-05-22 12:50:44 -0400 | [diff] [blame] | 4665 | return decode_getfattr_generic(xdr, fattr, NULL, NULL, NULL, server); |
Bryan Schumaker | ae42c70 | 2010-10-21 16:33:17 -0400 | [diff] [blame] | 4666 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4667 | |
Andy Adamson | 504913f | 2010-10-20 00:17:57 -0400 | [diff] [blame] | 4668 | /* |
| 4669 | * Decode potentially multiple layout types. Currently we only support |
| 4670 | * one layout driver per file system. |
| 4671 | */ |
| 4672 | static int decode_first_pnfs_layout_type(struct xdr_stream *xdr, |
| 4673 | uint32_t *layouttype) |
| 4674 | { |
Trond Myklebust | b8a8a0d | 2013-08-20 21:08:56 -0400 | [diff] [blame] | 4675 | __be32 *p; |
Andy Adamson | 504913f | 2010-10-20 00:17:57 -0400 | [diff] [blame] | 4676 | int num; |
| 4677 | |
| 4678 | p = xdr_inline_decode(xdr, 4); |
| 4679 | if (unlikely(!p)) |
| 4680 | goto out_overflow; |
| 4681 | num = be32_to_cpup(p); |
| 4682 | |
| 4683 | /* pNFS is not supported by the underlying file system */ |
| 4684 | if (num == 0) { |
| 4685 | *layouttype = 0; |
| 4686 | return 0; |
| 4687 | } |
| 4688 | if (num > 1) |
Weston Andros Adamson | a030889 | 2012-01-26 13:32:23 -0500 | [diff] [blame] | 4689 | printk(KERN_INFO "NFS: %s: Warning: Multiple pNFS layout " |
| 4690 | "drivers per filesystem not supported\n", __func__); |
Andy Adamson | 504913f | 2010-10-20 00:17:57 -0400 | [diff] [blame] | 4691 | |
| 4692 | /* Decode and set first layout type, move xdr->p past unused types */ |
| 4693 | p = xdr_inline_decode(xdr, num * 4); |
| 4694 | if (unlikely(!p)) |
| 4695 | goto out_overflow; |
| 4696 | *layouttype = be32_to_cpup(p); |
| 4697 | return 0; |
| 4698 | out_overflow: |
| 4699 | print_overflow_msg(__func__, xdr); |
| 4700 | return -EIO; |
| 4701 | } |
| 4702 | |
| 4703 | /* |
| 4704 | * The type of file system exported. |
| 4705 | * Note we must ensure that layouttype is set in any non-error case. |
| 4706 | */ |
| 4707 | static int decode_attr_pnfstype(struct xdr_stream *xdr, uint32_t *bitmap, |
| 4708 | uint32_t *layouttype) |
| 4709 | { |
| 4710 | int status = 0; |
| 4711 | |
| 4712 | dprintk("%s: bitmap is %x\n", __func__, bitmap[1]); |
| 4713 | if (unlikely(bitmap[1] & (FATTR4_WORD1_FS_LAYOUT_TYPES - 1U))) |
| 4714 | return -EIO; |
| 4715 | if (bitmap[1] & FATTR4_WORD1_FS_LAYOUT_TYPES) { |
| 4716 | status = decode_first_pnfs_layout_type(xdr, layouttype); |
| 4717 | bitmap[1] &= ~FATTR4_WORD1_FS_LAYOUT_TYPES; |
| 4718 | } else |
| 4719 | *layouttype = 0; |
| 4720 | return status; |
| 4721 | } |
| 4722 | |
Fred Isaman | dae100c | 2011-07-30 20:52:37 -0400 | [diff] [blame] | 4723 | /* |
| 4724 | * The prefered block size for layout directed io |
| 4725 | */ |
| 4726 | static int decode_attr_layout_blksize(struct xdr_stream *xdr, uint32_t *bitmap, |
| 4727 | uint32_t *res) |
| 4728 | { |
| 4729 | __be32 *p; |
| 4730 | |
| 4731 | dprintk("%s: bitmap is %x\n", __func__, bitmap[2]); |
| 4732 | *res = 0; |
| 4733 | if (bitmap[2] & FATTR4_WORD2_LAYOUT_BLKSIZE) { |
| 4734 | p = xdr_inline_decode(xdr, 4); |
| 4735 | if (unlikely(!p)) { |
| 4736 | print_overflow_msg(__func__, xdr); |
| 4737 | return -EIO; |
| 4738 | } |
| 4739 | *res = be32_to_cpup(p); |
| 4740 | bitmap[2] &= ~FATTR4_WORD2_LAYOUT_BLKSIZE; |
| 4741 | } |
| 4742 | return 0; |
| 4743 | } |
| 4744 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4745 | static int decode_fsinfo(struct xdr_stream *xdr, struct nfs_fsinfo *fsinfo) |
| 4746 | { |
Trond Myklebust | 256e48b | 2012-06-21 11:18:13 -0400 | [diff] [blame] | 4747 | unsigned int savep; |
Fred Isaman | dae100c | 2011-07-30 20:52:37 -0400 | [diff] [blame] | 4748 | uint32_t attrlen, bitmap[3]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4749 | int status; |
| 4750 | |
| 4751 | if ((status = decode_op_hdr(xdr, OP_GETATTR)) != 0) |
| 4752 | goto xdr_error; |
| 4753 | if ((status = decode_attr_bitmap(xdr, bitmap)) != 0) |
| 4754 | goto xdr_error; |
| 4755 | if ((status = decode_attr_length(xdr, &attrlen, &savep)) != 0) |
| 4756 | goto xdr_error; |
| 4757 | |
| 4758 | fsinfo->rtmult = fsinfo->wtmult = 512; /* ??? */ |
| 4759 | |
| 4760 | if ((status = decode_attr_lease_time(xdr, bitmap, &fsinfo->lease_time)) != 0) |
| 4761 | goto xdr_error; |
| 4762 | if ((status = decode_attr_maxfilesize(xdr, bitmap, &fsinfo->maxfilesize)) != 0) |
| 4763 | goto xdr_error; |
| 4764 | if ((status = decode_attr_maxread(xdr, bitmap, &fsinfo->rtmax)) != 0) |
| 4765 | goto xdr_error; |
| 4766 | fsinfo->rtpref = fsinfo->dtpref = fsinfo->rtmax; |
| 4767 | if ((status = decode_attr_maxwrite(xdr, bitmap, &fsinfo->wtmax)) != 0) |
| 4768 | goto xdr_error; |
| 4769 | fsinfo->wtpref = fsinfo->wtmax; |
Ricardo Labiaga | 55b6e77 | 2010-10-12 16:30:06 -0700 | [diff] [blame] | 4770 | status = decode_attr_time_delta(xdr, bitmap, &fsinfo->time_delta); |
| 4771 | if (status != 0) |
| 4772 | goto xdr_error; |
Andy Adamson | 504913f | 2010-10-20 00:17:57 -0400 | [diff] [blame] | 4773 | status = decode_attr_pnfstype(xdr, bitmap, &fsinfo->layouttype); |
| 4774 | if (status != 0) |
| 4775 | goto xdr_error; |
Fred Isaman | dae100c | 2011-07-30 20:52:37 -0400 | [diff] [blame] | 4776 | status = decode_attr_layout_blksize(xdr, bitmap, &fsinfo->blksize); |
| 4777 | if (status) |
| 4778 | goto xdr_error; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4779 | |
| 4780 | status = verify_attr_len(xdr, savep, attrlen); |
| 4781 | xdr_error: |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 4782 | dprintk("%s: xdr returned %d!\n", __func__, -status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4783 | return status; |
| 4784 | } |
| 4785 | |
| 4786 | static int decode_getfh(struct xdr_stream *xdr, struct nfs_fh *fh) |
| 4787 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 4788 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4789 | uint32_t len; |
| 4790 | int status; |
| 4791 | |
Trond Myklebust | 9936781 | 2007-07-17 21:52:41 -0400 | [diff] [blame] | 4792 | /* Zero handle first to allow comparisons */ |
| 4793 | memset(fh, 0, sizeof(*fh)); |
| 4794 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4795 | status = decode_op_hdr(xdr, OP_GETFH); |
| 4796 | if (status) |
| 4797 | return status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4798 | |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 4799 | p = xdr_inline_decode(xdr, 4); |
| 4800 | if (unlikely(!p)) |
| 4801 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 4802 | len = be32_to_cpup(p); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4803 | if (len > NFS4_FHSIZE) |
| 4804 | return -EIO; |
| 4805 | fh->size = len; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 4806 | p = xdr_inline_decode(xdr, len); |
| 4807 | if (unlikely(!p)) |
| 4808 | goto out_overflow; |
Benny Halevy | 99398d0 | 2009-08-14 17:20:05 +0300 | [diff] [blame] | 4809 | memcpy(fh->data, p, len); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4810 | return 0; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 4811 | out_overflow: |
| 4812 | print_overflow_msg(__func__, xdr); |
| 4813 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4814 | } |
| 4815 | |
| 4816 | static int decode_link(struct xdr_stream *xdr, struct nfs4_change_info *cinfo) |
| 4817 | { |
| 4818 | int status; |
Andy Adamson | 6c0195a | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 4819 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4820 | status = decode_op_hdr(xdr, OP_LINK); |
| 4821 | if (status) |
| 4822 | return status; |
| 4823 | return decode_change_info(xdr, cinfo); |
| 4824 | } |
| 4825 | |
| 4826 | /* |
| 4827 | * We create the owner, so we know a proper owner.id length is 4. |
| 4828 | */ |
Trond Myklebust | 911d1aa | 2006-01-03 09:55:16 +0100 | [diff] [blame] | 4829 | 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] | 4830 | { |
Trond Myklebust | 911d1aa | 2006-01-03 09:55:16 +0100 | [diff] [blame] | 4831 | uint64_t offset, length, clientid; |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 4832 | __be32 *p; |
Trond Myklebust | 911d1aa | 2006-01-03 09:55:16 +0100 | [diff] [blame] | 4833 | uint32_t namelen, type; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4834 | |
Bryan Schumaker | babddc7 | 2010-10-20 15:44:29 -0400 | [diff] [blame] | 4835 | p = xdr_inline_decode(xdr, 32); /* read 32 bytes */ |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 4836 | if (unlikely(!p)) |
| 4837 | goto out_overflow; |
Bryan Schumaker | babddc7 | 2010-10-20 15:44:29 -0400 | [diff] [blame] | 4838 | p = xdr_decode_hyper(p, &offset); /* read 2 8-byte long words */ |
Benny Halevy | 3ceb4db | 2009-08-14 17:19:41 +0300 | [diff] [blame] | 4839 | p = xdr_decode_hyper(p, &length); |
Bryan Schumaker | babddc7 | 2010-10-20 15:44:29 -0400 | [diff] [blame] | 4840 | type = be32_to_cpup(p++); /* 4 byte read */ |
| 4841 | if (fl != NULL) { /* manipulate file lock */ |
Trond Myklebust | 911d1aa | 2006-01-03 09:55:16 +0100 | [diff] [blame] | 4842 | fl->fl_start = (loff_t)offset; |
| 4843 | fl->fl_end = fl->fl_start + (loff_t)length - 1; |
| 4844 | if (length == ~(uint64_t)0) |
| 4845 | fl->fl_end = OFFSET_MAX; |
| 4846 | fl->fl_type = F_WRLCK; |
| 4847 | if (type & 1) |
| 4848 | fl->fl_type = F_RDLCK; |
| 4849 | fl->fl_pid = 0; |
| 4850 | } |
Bryan Schumaker | babddc7 | 2010-10-20 15:44:29 -0400 | [diff] [blame] | 4851 | p = xdr_decode_hyper(p, &clientid); /* read 8 bytes */ |
| 4852 | namelen = be32_to_cpup(p); /* read 4 bytes */ /* have read all 32 bytes now */ |
| 4853 | p = xdr_inline_decode(xdr, namelen); /* variable size field */ |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 4854 | if (likely(p)) |
| 4855 | return -NFS4ERR_DENIED; |
| 4856 | out_overflow: |
| 4857 | print_overflow_msg(__func__, xdr); |
| 4858 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4859 | } |
| 4860 | |
Trond Myklebust | 911d1aa | 2006-01-03 09:55:16 +0100 | [diff] [blame] | 4861 | 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] | 4862 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4863 | int status; |
| 4864 | |
| 4865 | status = decode_op_hdr(xdr, OP_LOCK); |
Trond Myklebust | c1d5193 | 2008-04-07 13:20:54 -0400 | [diff] [blame] | 4866 | if (status == -EIO) |
| 4867 | goto out; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4868 | if (status == 0) { |
Benny Halevy | 07d3043 | 2009-08-14 17:19:52 +0300 | [diff] [blame] | 4869 | status = decode_stateid(xdr, &res->stateid); |
| 4870 | if (unlikely(status)) |
| 4871 | goto out; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4872 | } else if (status == -NFS4ERR_DENIED) |
Trond Myklebust | c1d5193 | 2008-04-07 13:20:54 -0400 | [diff] [blame] | 4873 | status = decode_lock_denied(xdr, NULL); |
| 4874 | if (res->open_seqid != NULL) |
| 4875 | nfs_increment_open_seqid(status, res->open_seqid); |
| 4876 | nfs_increment_lock_seqid(status, res->lock_seqid); |
| 4877 | out: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4878 | return status; |
| 4879 | } |
| 4880 | |
Trond Myklebust | 911d1aa | 2006-01-03 09:55:16 +0100 | [diff] [blame] | 4881 | 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] | 4882 | { |
| 4883 | int status; |
| 4884 | status = decode_op_hdr(xdr, OP_LOCKT); |
| 4885 | if (status == -NFS4ERR_DENIED) |
Trond Myklebust | 911d1aa | 2006-01-03 09:55:16 +0100 | [diff] [blame] | 4886 | return decode_lock_denied(xdr, res->denied); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4887 | return status; |
| 4888 | } |
| 4889 | |
Trond Myklebust | 911d1aa | 2006-01-03 09:55:16 +0100 | [diff] [blame] | 4890 | 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] | 4891 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4892 | int status; |
| 4893 | |
| 4894 | status = decode_op_hdr(xdr, OP_LOCKU); |
Trond Myklebust | c1d5193 | 2008-04-07 13:20:54 -0400 | [diff] [blame] | 4895 | if (status != -EIO) |
| 4896 | nfs_increment_lock_seqid(status, res->seqid); |
Benny Halevy | 07d3043 | 2009-08-14 17:19:52 +0300 | [diff] [blame] | 4897 | if (status == 0) |
| 4898 | status = decode_stateid(xdr, &res->stateid); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4899 | return status; |
| 4900 | } |
| 4901 | |
Trond Myklebust | d3c7b7c | 2010-07-01 12:49:01 -0400 | [diff] [blame] | 4902 | static int decode_release_lockowner(struct xdr_stream *xdr) |
| 4903 | { |
| 4904 | return decode_op_hdr(xdr, OP_RELEASE_LOCKOWNER); |
| 4905 | } |
| 4906 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4907 | static int decode_lookup(struct xdr_stream *xdr) |
| 4908 | { |
| 4909 | return decode_op_hdr(xdr, OP_LOOKUP); |
| 4910 | } |
| 4911 | |
| 4912 | /* This is too sick! */ |
| 4913 | static int decode_space_limit(struct xdr_stream *xdr, u64 *maxsize) |
| 4914 | { |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 4915 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4916 | uint32_t limit_type, nblocks, blocksize; |
| 4917 | |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 4918 | p = xdr_inline_decode(xdr, 12); |
| 4919 | if (unlikely(!p)) |
| 4920 | goto out_overflow; |
Benny Halevy | 6f723f7 | 2009-08-14 17:19:37 +0300 | [diff] [blame] | 4921 | limit_type = be32_to_cpup(p++); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4922 | switch (limit_type) { |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 4923 | case 1: |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 4924 | xdr_decode_hyper(p, maxsize); |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 4925 | break; |
| 4926 | case 2: |
Benny Halevy | 6f723f7 | 2009-08-14 17:19:37 +0300 | [diff] [blame] | 4927 | nblocks = be32_to_cpup(p++); |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 4928 | blocksize = be32_to_cpup(p); |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 4929 | *maxsize = (uint64_t)nblocks * (uint64_t)blocksize; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4930 | } |
| 4931 | return 0; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 4932 | out_overflow: |
| 4933 | print_overflow_msg(__func__, xdr); |
| 4934 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4935 | } |
| 4936 | |
| 4937 | static int decode_delegation(struct xdr_stream *xdr, struct nfs_openres *res) |
| 4938 | { |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 4939 | __be32 *p; |
| 4940 | uint32_t delegation_type; |
Benny Halevy | 07d3043 | 2009-08-14 17:19:52 +0300 | [diff] [blame] | 4941 | int status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4942 | |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 4943 | p = xdr_inline_decode(xdr, 4); |
| 4944 | if (unlikely(!p)) |
| 4945 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 4946 | delegation_type = be32_to_cpup(p); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4947 | if (delegation_type == NFS4_OPEN_DELEGATE_NONE) { |
| 4948 | res->delegation_type = 0; |
| 4949 | return 0; |
| 4950 | } |
Benny Halevy | 07d3043 | 2009-08-14 17:19:52 +0300 | [diff] [blame] | 4951 | status = decode_stateid(xdr, &res->delegation); |
| 4952 | if (unlikely(status)) |
| 4953 | return status; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 4954 | p = xdr_inline_decode(xdr, 4); |
| 4955 | if (unlikely(!p)) |
| 4956 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 4957 | res->do_recall = be32_to_cpup(p); |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 4958 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4959 | switch (delegation_type) { |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 4960 | case NFS4_OPEN_DELEGATE_READ: |
| 4961 | res->delegation_type = FMODE_READ; |
| 4962 | break; |
| 4963 | case NFS4_OPEN_DELEGATE_WRITE: |
| 4964 | res->delegation_type = FMODE_WRITE|FMODE_READ; |
| 4965 | if (decode_space_limit(xdr, &res->maxsize) < 0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4966 | return -EIO; |
| 4967 | } |
David Howells | 7539bba | 2006-08-22 20:06:09 -0400 | [diff] [blame] | 4968 | return decode_ace(xdr, NULL, res->server->nfs_client); |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 4969 | out_overflow: |
| 4970 | print_overflow_msg(__func__, xdr); |
| 4971 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4972 | } |
| 4973 | |
| 4974 | static int decode_open(struct xdr_stream *xdr, struct nfs_openres *res) |
| 4975 | { |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 4976 | __be32 *p; |
Jeff Layton | aa53ed5 | 2007-06-05 14:49:03 -0400 | [diff] [blame] | 4977 | uint32_t savewords, bmlen, i; |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 4978 | int status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4979 | |
Trond Myklebust | c7848f6 | 2013-12-04 17:39:23 -0500 | [diff] [blame] | 4980 | if (!__decode_op_hdr(xdr, OP_OPEN, &status)) |
| 4981 | return status; |
| 4982 | nfs_increment_open_seqid(status, res->seqid); |
| 4983 | if (status) |
| 4984 | return status; |
| 4985 | status = decode_stateid(xdr, &res->stateid); |
Benny Halevy | 07d3043 | 2009-08-14 17:19:52 +0300 | [diff] [blame] | 4986 | if (unlikely(status)) |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 4987 | return status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4988 | |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 4989 | decode_change_info(xdr, &res->cinfo); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4990 | |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 4991 | p = xdr_inline_decode(xdr, 8); |
| 4992 | if (unlikely(!p)) |
| 4993 | goto out_overflow; |
Benny Halevy | 6f723f7 | 2009-08-14 17:19:37 +0300 | [diff] [blame] | 4994 | res->rflags = be32_to_cpup(p++); |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 4995 | bmlen = be32_to_cpup(p); |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 4996 | if (bmlen > 10) |
| 4997 | goto xdr_error; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4998 | |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 4999 | p = xdr_inline_decode(xdr, bmlen << 2); |
| 5000 | if (unlikely(!p)) |
| 5001 | goto out_overflow; |
Jeff Layton | aa53ed5 | 2007-06-05 14:49:03 -0400 | [diff] [blame] | 5002 | savewords = min_t(uint32_t, bmlen, NFS4_BITMAP_SIZE); |
| 5003 | for (i = 0; i < savewords; ++i) |
Benny Halevy | 6f723f7 | 2009-08-14 17:19:37 +0300 | [diff] [blame] | 5004 | res->attrset[i] = be32_to_cpup(p++); |
Jeff Layton | aa53ed5 | 2007-06-05 14:49:03 -0400 | [diff] [blame] | 5005 | for (; i < NFS4_BITMAP_SIZE; i++) |
| 5006 | res->attrset[i] = 0; |
| 5007 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5008 | return decode_delegation(xdr, res); |
| 5009 | xdr_error: |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 5010 | dprintk("%s: Bitmap too large! Length = %u\n", __func__, bmlen); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5011 | return -EIO; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 5012 | out_overflow: |
| 5013 | print_overflow_msg(__func__, xdr); |
| 5014 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5015 | } |
| 5016 | |
| 5017 | static int decode_open_confirm(struct xdr_stream *xdr, struct nfs_open_confirmres *res) |
| 5018 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5019 | int status; |
| 5020 | |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 5021 | status = decode_op_hdr(xdr, OP_OPEN_CONFIRM); |
Trond Myklebust | c1d5193 | 2008-04-07 13:20:54 -0400 | [diff] [blame] | 5022 | if (status != -EIO) |
| 5023 | nfs_increment_open_seqid(status, res->seqid); |
Benny Halevy | 07d3043 | 2009-08-14 17:19:52 +0300 | [diff] [blame] | 5024 | if (!status) |
| 5025 | status = decode_stateid(xdr, &res->stateid); |
| 5026 | return status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5027 | } |
| 5028 | |
| 5029 | static int decode_open_downgrade(struct xdr_stream *xdr, struct nfs_closeres *res) |
| 5030 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5031 | int status; |
| 5032 | |
| 5033 | status = decode_op_hdr(xdr, OP_OPEN_DOWNGRADE); |
Trond Myklebust | c1d5193 | 2008-04-07 13:20:54 -0400 | [diff] [blame] | 5034 | if (status != -EIO) |
| 5035 | nfs_increment_open_seqid(status, res->seqid); |
Benny Halevy | 07d3043 | 2009-08-14 17:19:52 +0300 | [diff] [blame] | 5036 | if (!status) |
| 5037 | status = decode_stateid(xdr, &res->stateid); |
| 5038 | return status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5039 | } |
| 5040 | |
| 5041 | static int decode_putfh(struct xdr_stream *xdr) |
| 5042 | { |
| 5043 | return decode_op_hdr(xdr, OP_PUTFH); |
| 5044 | } |
| 5045 | |
| 5046 | static int decode_putrootfh(struct xdr_stream *xdr) |
| 5047 | { |
| 5048 | return decode_op_hdr(xdr, OP_PUTROOTFH); |
| 5049 | } |
| 5050 | |
Anna Schumaker | 9137bdf | 2014-05-06 09:12:25 -0400 | [diff] [blame] | 5051 | static int decode_read(struct xdr_stream *xdr, struct rpc_rqst *req, |
| 5052 | struct nfs_pgio_res *res) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5053 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 5054 | __be32 *p; |
Trond Myklebust | 64bd577 | 2012-06-20 22:35:05 -0400 | [diff] [blame] | 5055 | uint32_t count, eof, recvd; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5056 | int status; |
| 5057 | |
| 5058 | status = decode_op_hdr(xdr, OP_READ); |
| 5059 | if (status) |
| 5060 | return status; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 5061 | p = xdr_inline_decode(xdr, 8); |
| 5062 | if (unlikely(!p)) |
| 5063 | goto out_overflow; |
Benny Halevy | 6f723f7 | 2009-08-14 17:19:37 +0300 | [diff] [blame] | 5064 | eof = be32_to_cpup(p++); |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 5065 | count = be32_to_cpup(p); |
Trond Myklebust | 64bd577 | 2012-06-20 22:35:05 -0400 | [diff] [blame] | 5066 | recvd = xdr_read_pages(xdr, count); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5067 | if (count > recvd) { |
Chuck Lever | fe82a18 | 2007-09-11 18:01:10 -0400 | [diff] [blame] | 5068 | dprintk("NFS: server cheating in read reply: " |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5069 | "count %u > recvd %u\n", count, recvd); |
| 5070 | count = recvd; |
| 5071 | eof = 0; |
| 5072 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5073 | res->eof = eof; |
| 5074 | res->count = count; |
| 5075 | return 0; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 5076 | out_overflow: |
| 5077 | print_overflow_msg(__func__, xdr); |
| 5078 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5079 | } |
| 5080 | |
| 5081 | static int decode_readdir(struct xdr_stream *xdr, struct rpc_rqst *req, struct nfs4_readdir_res *readdir) |
| 5082 | { |
Chuck Lever | bcecff7 | 2007-10-26 13:32:03 -0400 | [diff] [blame] | 5083 | int status; |
Chuck Lever | cd93710 | 2012-03-02 17:14:31 -0500 | [diff] [blame] | 5084 | __be32 verf[2]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5085 | |
| 5086 | status = decode_op_hdr(xdr, OP_READDIR); |
Benny Halevy | db942bb | 2009-08-14 17:19:56 +0300 | [diff] [blame] | 5087 | if (!status) |
| 5088 | status = decode_verifier(xdr, readdir->verifier.data); |
| 5089 | if (unlikely(status)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5090 | return status; |
Chuck Lever | cd93710 | 2012-03-02 17:14:31 -0500 | [diff] [blame] | 5091 | memcpy(verf, readdir->verifier.data, sizeof(verf)); |
Fred Isaman | 4410924 | 2008-04-02 15:21:15 +0300 | [diff] [blame] | 5092 | dprintk("%s: verifier = %08x:%08x\n", |
Chuck Lever | cd93710 | 2012-03-02 17:14:31 -0500 | [diff] [blame] | 5093 | __func__, verf[0], verf[1]); |
Trond Myklebust | 64bd577 | 2012-06-20 22:35:05 -0400 | [diff] [blame] | 5094 | return xdr_read_pages(xdr, xdr->buf->page_len); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5095 | } |
| 5096 | |
| 5097 | static int decode_readlink(struct xdr_stream *xdr, struct rpc_rqst *req) |
| 5098 | { |
| 5099 | struct xdr_buf *rcvbuf = &req->rq_rcv_buf; |
Chuck Lever | bcecff7 | 2007-10-26 13:32:03 -0400 | [diff] [blame] | 5100 | u32 len, recvd; |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 5101 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5102 | int status; |
| 5103 | |
| 5104 | status = decode_op_hdr(xdr, OP_READLINK); |
| 5105 | if (status) |
| 5106 | return status; |
| 5107 | |
| 5108 | /* Convert length of symlink */ |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 5109 | p = xdr_inline_decode(xdr, 4); |
| 5110 | if (unlikely(!p)) |
| 5111 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 5112 | len = be32_to_cpup(p); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5113 | if (len >= rcvbuf->page_len || len <= 0) { |
Chuck Lever | fe82a18 | 2007-09-11 18:01:10 -0400 | [diff] [blame] | 5114 | dprintk("nfs: server returned giant symlink!\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5115 | return -ENAMETOOLONG; |
| 5116 | } |
Trond Myklebust | 64bd577 | 2012-06-20 22:35:05 -0400 | [diff] [blame] | 5117 | recvd = xdr_read_pages(xdr, len); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5118 | if (recvd < len) { |
Chuck Lever | fe82a18 | 2007-09-11 18:01:10 -0400 | [diff] [blame] | 5119 | dprintk("NFS: server cheating in readlink reply: " |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5120 | "count %u > recvd %u\n", len, recvd); |
| 5121 | return -EIO; |
| 5122 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5123 | /* |
| 5124 | * The XDR encode routine has set things up so that |
| 5125 | * the link text will be copied directly into the |
| 5126 | * buffer. We just have to do overflow-checking, |
| 5127 | * and and null-terminate the text (the VFS expects |
| 5128 | * null-termination). |
| 5129 | */ |
Chuck Lever | b4687da | 2010-09-21 16:55:48 -0400 | [diff] [blame] | 5130 | xdr_terminate_string(rcvbuf, len); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5131 | return 0; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 5132 | out_overflow: |
| 5133 | print_overflow_msg(__func__, xdr); |
| 5134 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5135 | } |
| 5136 | |
| 5137 | static int decode_remove(struct xdr_stream *xdr, struct nfs4_change_info *cinfo) |
| 5138 | { |
| 5139 | int status; |
| 5140 | |
| 5141 | status = decode_op_hdr(xdr, OP_REMOVE); |
| 5142 | if (status) |
| 5143 | goto out; |
| 5144 | status = decode_change_info(xdr, cinfo); |
| 5145 | out: |
| 5146 | return status; |
| 5147 | } |
| 5148 | |
| 5149 | static int decode_rename(struct xdr_stream *xdr, struct nfs4_change_info *old_cinfo, |
| 5150 | struct nfs4_change_info *new_cinfo) |
| 5151 | { |
| 5152 | int status; |
| 5153 | |
| 5154 | status = decode_op_hdr(xdr, OP_RENAME); |
| 5155 | if (status) |
| 5156 | goto out; |
| 5157 | if ((status = decode_change_info(xdr, old_cinfo))) |
| 5158 | goto out; |
| 5159 | status = decode_change_info(xdr, new_cinfo); |
| 5160 | out: |
| 5161 | return status; |
| 5162 | } |
| 5163 | |
| 5164 | static int decode_renew(struct xdr_stream *xdr) |
| 5165 | { |
| 5166 | return decode_op_hdr(xdr, OP_RENEW); |
| 5167 | } |
| 5168 | |
Trond Myklebust | 56ae19f | 2005-10-27 22:12:40 -0400 | [diff] [blame] | 5169 | static int |
| 5170 | decode_restorefh(struct xdr_stream *xdr) |
| 5171 | { |
| 5172 | return decode_op_hdr(xdr, OP_RESTOREFH); |
| 5173 | } |
| 5174 | |
J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 5175 | static int decode_getacl(struct xdr_stream *xdr, struct rpc_rqst *req, |
Andy Adamson | bf118a3 | 2011-12-07 11:55:27 -0500 | [diff] [blame] | 5176 | struct nfs_getaclres *res) |
J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 5177 | { |
Trond Myklebust | 256e48b | 2012-06-21 11:18:13 -0400 | [diff] [blame] | 5178 | unsigned int savep; |
J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 5179 | uint32_t attrlen, |
Fred Isaman | dae100c | 2011-07-30 20:52:37 -0400 | [diff] [blame] | 5180 | bitmap[3] = {0}; |
J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 5181 | int status; |
Trond Myklebust | cff298c | 2012-08-14 17:14:17 -0400 | [diff] [blame] | 5182 | unsigned int pg_offset; |
J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 5183 | |
Andy Adamson | bf118a3 | 2011-12-07 11:55:27 -0500 | [diff] [blame] | 5184 | res->acl_len = 0; |
J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 5185 | if ((status = decode_op_hdr(xdr, OP_GETATTR)) != 0) |
| 5186 | goto out; |
Sachin Prabhu | 5a00689 | 2012-04-17 14:35:39 +0100 | [diff] [blame] | 5187 | |
Trond Myklebust | 519d395 | 2012-08-14 17:30:10 -0400 | [diff] [blame] | 5188 | xdr_enter_page(xdr, xdr->buf->page_len); |
| 5189 | |
Trond Myklebust | cff298c | 2012-08-14 17:14:17 -0400 | [diff] [blame] | 5190 | /* Calculate the offset of the page data */ |
| 5191 | pg_offset = xdr->buf->head[0].iov_len; |
Sachin Prabhu | 5a00689 | 2012-04-17 14:35:39 +0100 | [diff] [blame] | 5192 | |
J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 5193 | if ((status = decode_attr_bitmap(xdr, bitmap)) != 0) |
| 5194 | goto out; |
| 5195 | if ((status = decode_attr_length(xdr, &attrlen, &savep)) != 0) |
| 5196 | goto out; |
| 5197 | |
| 5198 | if (unlikely(bitmap[0] & (FATTR4_WORD0_ACL - 1U))) |
| 5199 | return -EIO; |
| 5200 | if (likely(bitmap[0] & FATTR4_WORD0_ACL)) { |
J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 5201 | |
Andy Adamson | bf118a3 | 2011-12-07 11:55:27 -0500 | [diff] [blame] | 5202 | /* The bitmap (xdr len + bitmaps) and the attr xdr len words |
| 5203 | * are stored with the acl data to handle the problem of |
| 5204 | * variable length bitmaps.*/ |
Trond Myklebust | cff298c | 2012-08-14 17:14:17 -0400 | [diff] [blame] | 5205 | res->acl_data_offset = xdr_stream_pos(xdr) - pg_offset; |
Trond Myklebust | 519d395 | 2012-08-14 17:30:10 -0400 | [diff] [blame] | 5206 | res->acl_len = attrlen; |
Trond Myklebust | 1f1ea6c | 2012-08-26 11:44:43 -0700 | [diff] [blame] | 5207 | |
| 5208 | /* Check for receive buffer overflow */ |
| 5209 | if (res->acl_len > (xdr->nwords << 2) || |
| 5210 | res->acl_len + res->acl_data_offset > xdr->buf->page_len) { |
| 5211 | res->acl_flags |= NFS4_ACL_TRUNC; |
Trond Myklebust | 519d395 | 2012-08-14 17:30:10 -0400 | [diff] [blame] | 5212 | dprintk("NFS: acl reply: attrlen %u > page_len %u\n", |
Trond Myklebust | cff298c | 2012-08-14 17:14:17 -0400 | [diff] [blame] | 5213 | attrlen, xdr->nwords << 2); |
J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 5214 | } |
J. Bruce Fields | 8c233cf | 2005-10-13 16:54:27 -0400 | [diff] [blame] | 5215 | } else |
| 5216 | status = -EOPNOTSUPP; |
J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 5217 | |
| 5218 | out: |
| 5219 | return status; |
| 5220 | } |
| 5221 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5222 | static int |
| 5223 | decode_savefh(struct xdr_stream *xdr) |
| 5224 | { |
| 5225 | return decode_op_hdr(xdr, OP_SAVEFH); |
| 5226 | } |
| 5227 | |
Benny Halevy | 9e9ecc0 | 2009-04-01 09:22:00 -0400 | [diff] [blame] | 5228 | static int decode_setattr(struct xdr_stream *xdr) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5229 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 5230 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5231 | uint32_t bmlen; |
| 5232 | int status; |
| 5233 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5234 | status = decode_op_hdr(xdr, OP_SETATTR); |
| 5235 | if (status) |
| 5236 | return status; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 5237 | p = xdr_inline_decode(xdr, 4); |
| 5238 | if (unlikely(!p)) |
| 5239 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 5240 | bmlen = be32_to_cpup(p); |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 5241 | p = xdr_inline_decode(xdr, bmlen << 2); |
| 5242 | if (likely(p)) |
| 5243 | return 0; |
| 5244 | out_overflow: |
| 5245 | print_overflow_msg(__func__, xdr); |
| 5246 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5247 | } |
| 5248 | |
Trond Myklebust | bb8b27e | 2010-04-16 16:43:06 -0400 | [diff] [blame] | 5249 | 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] | 5250 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 5251 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5252 | uint32_t opnum; |
| 5253 | int32_t nfserr; |
| 5254 | |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 5255 | p = xdr_inline_decode(xdr, 8); |
| 5256 | if (unlikely(!p)) |
| 5257 | goto out_overflow; |
Benny Halevy | 6f723f7 | 2009-08-14 17:19:37 +0300 | [diff] [blame] | 5258 | opnum = be32_to_cpup(p++); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5259 | if (opnum != OP_SETCLIENTID) { |
Chuck Lever | fe82a18 | 2007-09-11 18:01:10 -0400 | [diff] [blame] | 5260 | dprintk("nfs: decode_setclientid: Server returned operation" |
Andy Adamson | 6c0195a | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 5261 | " %d\n", opnum); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5262 | return -EIO; |
| 5263 | } |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 5264 | nfserr = be32_to_cpup(p); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5265 | if (nfserr == NFS_OK) { |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 5266 | p = xdr_inline_decode(xdr, 8 + NFS4_VERIFIER_SIZE); |
| 5267 | if (unlikely(!p)) |
| 5268 | goto out_overflow; |
Trond Myklebust | bb8b27e | 2010-04-16 16:43:06 -0400 | [diff] [blame] | 5269 | p = xdr_decode_hyper(p, &res->clientid); |
| 5270 | memcpy(res->confirm.data, p, NFS4_VERIFIER_SIZE); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5271 | } else if (nfserr == NFSERR_CLID_INUSE) { |
| 5272 | uint32_t len; |
| 5273 | |
| 5274 | /* skip netid string */ |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 5275 | p = xdr_inline_decode(xdr, 4); |
| 5276 | if (unlikely(!p)) |
| 5277 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 5278 | len = be32_to_cpup(p); |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 5279 | p = xdr_inline_decode(xdr, len); |
| 5280 | if (unlikely(!p)) |
| 5281 | goto out_overflow; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5282 | |
| 5283 | /* skip uaddr string */ |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 5284 | p = xdr_inline_decode(xdr, 4); |
| 5285 | if (unlikely(!p)) |
| 5286 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 5287 | len = be32_to_cpup(p); |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 5288 | p = xdr_inline_decode(xdr, len); |
| 5289 | if (unlikely(!p)) |
| 5290 | goto out_overflow; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5291 | return -NFSERR_CLID_INUSE; |
| 5292 | } else |
Benny Halevy | 856dff3 | 2008-03-31 17:39:06 +0300 | [diff] [blame] | 5293 | return nfs4_stat_to_errno(nfserr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5294 | |
| 5295 | return 0; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 5296 | out_overflow: |
| 5297 | print_overflow_msg(__func__, xdr); |
| 5298 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5299 | } |
| 5300 | |
| 5301 | static int decode_setclientid_confirm(struct xdr_stream *xdr) |
| 5302 | { |
| 5303 | return decode_op_hdr(xdr, OP_SETCLIENTID_CONFIRM); |
| 5304 | } |
| 5305 | |
Anna Schumaker | 9137bdf | 2014-05-06 09:12:25 -0400 | [diff] [blame] | 5306 | 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] | 5307 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 5308 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5309 | int status; |
| 5310 | |
| 5311 | status = decode_op_hdr(xdr, OP_WRITE); |
| 5312 | if (status) |
| 5313 | return status; |
| 5314 | |
Trond Myklebust | 2f2c63b | 2012-06-08 11:56:09 -0400 | [diff] [blame] | 5315 | p = xdr_inline_decode(xdr, 8); |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 5316 | if (unlikely(!p)) |
| 5317 | goto out_overflow; |
Benny Halevy | 6f723f7 | 2009-08-14 17:19:37 +0300 | [diff] [blame] | 5318 | res->count = be32_to_cpup(p++); |
| 5319 | res->verf->committed = be32_to_cpup(p++); |
Trond Myklebust | 2f2c63b | 2012-06-08 11:56:09 -0400 | [diff] [blame] | 5320 | return decode_write_verifier(xdr, &res->verf->verifier); |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 5321 | out_overflow: |
| 5322 | print_overflow_msg(__func__, xdr); |
| 5323 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5324 | } |
| 5325 | |
| 5326 | static int decode_delegreturn(struct xdr_stream *xdr) |
| 5327 | { |
| 5328 | return decode_op_hdr(xdr, OP_DELEGRETURN); |
| 5329 | } |
| 5330 | |
Chuck Lever | fb15b26 | 2013-03-16 15:54:34 -0400 | [diff] [blame] | 5331 | static int decode_secinfo_gss(struct xdr_stream *xdr, |
| 5332 | struct nfs4_secinfo4 *flavor) |
Bryan Schumaker | 5a5ea0d | 2011-03-24 17:12:29 +0000 | [diff] [blame] | 5333 | { |
Chuck Lever | fb15b26 | 2013-03-16 15:54:34 -0400 | [diff] [blame] | 5334 | u32 oid_len; |
Bryan Schumaker | 5a5ea0d | 2011-03-24 17:12:29 +0000 | [diff] [blame] | 5335 | __be32 *p; |
| 5336 | |
| 5337 | p = xdr_inline_decode(xdr, 4); |
| 5338 | if (unlikely(!p)) |
| 5339 | goto out_overflow; |
Chuck Lever | fb15b26 | 2013-03-16 15:54:34 -0400 | [diff] [blame] | 5340 | oid_len = be32_to_cpup(p); |
| 5341 | if (oid_len > GSS_OID_MAX_LEN) |
Bryan Schumaker | 5a5ea0d | 2011-03-24 17:12:29 +0000 | [diff] [blame] | 5342 | goto out_err; |
| 5343 | |
Chuck Lever | fb15b26 | 2013-03-16 15:54:34 -0400 | [diff] [blame] | 5344 | p = xdr_inline_decode(xdr, oid_len); |
Bryan Schumaker | 5a5ea0d | 2011-03-24 17:12:29 +0000 | [diff] [blame] | 5345 | if (unlikely(!p)) |
| 5346 | goto out_overflow; |
Chuck Lever | fb15b26 | 2013-03-16 15:54:34 -0400 | [diff] [blame] | 5347 | memcpy(flavor->flavor_info.oid.data, p, oid_len); |
| 5348 | flavor->flavor_info.oid.len = oid_len; |
Bryan Schumaker | 5a5ea0d | 2011-03-24 17:12:29 +0000 | [diff] [blame] | 5349 | |
| 5350 | p = xdr_inline_decode(xdr, 8); |
| 5351 | if (unlikely(!p)) |
| 5352 | goto out_overflow; |
Chuck Lever | fb15b26 | 2013-03-16 15:54:34 -0400 | [diff] [blame] | 5353 | flavor->flavor_info.qop = be32_to_cpup(p++); |
| 5354 | flavor->flavor_info.service = be32_to_cpup(p); |
Bryan Schumaker | 5a5ea0d | 2011-03-24 17:12:29 +0000 | [diff] [blame] | 5355 | |
| 5356 | return 0; |
| 5357 | |
| 5358 | out_overflow: |
| 5359 | print_overflow_msg(__func__, xdr); |
| 5360 | return -EIO; |
| 5361 | out_err: |
| 5362 | return -EINVAL; |
| 5363 | } |
| 5364 | |
Bryan Schumaker | 31e4dda | 2012-04-27 13:27:38 -0400 | [diff] [blame] | 5365 | 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] | 5366 | { |
Chuck Lever | fb15b26 | 2013-03-16 15:54:34 -0400 | [diff] [blame] | 5367 | struct nfs4_secinfo4 *sec_flavor; |
| 5368 | unsigned int i, num_flavors; |
Bryan Schumaker | 5a5ea0d | 2011-03-24 17:12:29 +0000 | [diff] [blame] | 5369 | int status; |
| 5370 | __be32 *p; |
Bryan Schumaker | 5a5ea0d | 2011-03-24 17:12:29 +0000 | [diff] [blame] | 5371 | |
Bryan Schumaker | 5a5ea0d | 2011-03-24 17:12:29 +0000 | [diff] [blame] | 5372 | p = xdr_inline_decode(xdr, 4); |
| 5373 | if (unlikely(!p)) |
| 5374 | goto out_overflow; |
Bryan Schumaker | 5a5ea0d | 2011-03-24 17:12:29 +0000 | [diff] [blame] | 5375 | |
Bryan Schumaker | c3dfc28 | 2011-04-13 14:31:31 -0400 | [diff] [blame] | 5376 | res->flavors->num_flavors = 0; |
| 5377 | num_flavors = be32_to_cpup(p); |
| 5378 | |
| 5379 | for (i = 0; i < num_flavors; i++) { |
Bryan Schumaker | 5a5ea0d | 2011-03-24 17:12:29 +0000 | [diff] [blame] | 5380 | sec_flavor = &res->flavors->flavors[i]; |
Bryan Schumaker | c3dfc28 | 2011-04-13 14:31:31 -0400 | [diff] [blame] | 5381 | if ((char *)&sec_flavor[1] - (char *)res->flavors > PAGE_SIZE) |
Bryan Schumaker | 5a5ea0d | 2011-03-24 17:12:29 +0000 | [diff] [blame] | 5382 | break; |
| 5383 | |
| 5384 | p = xdr_inline_decode(xdr, 4); |
| 5385 | if (unlikely(!p)) |
| 5386 | goto out_overflow; |
| 5387 | sec_flavor->flavor = be32_to_cpup(p); |
| 5388 | |
| 5389 | if (sec_flavor->flavor == RPC_AUTH_GSS) { |
Bryan Schumaker | 613e901 | 2011-04-27 15:28:44 -0400 | [diff] [blame] | 5390 | status = decode_secinfo_gss(xdr, sec_flavor); |
| 5391 | if (status) |
| 5392 | goto out; |
Bryan Schumaker | 5a5ea0d | 2011-03-24 17:12:29 +0000 | [diff] [blame] | 5393 | } |
Bryan Schumaker | c3dfc28 | 2011-04-13 14:31:31 -0400 | [diff] [blame] | 5394 | res->flavors->num_flavors++; |
Bryan Schumaker | 5a5ea0d | 2011-03-24 17:12:29 +0000 | [diff] [blame] | 5395 | } |
| 5396 | |
Bryan Schumaker | 31e4dda | 2012-04-27 13:27:38 -0400 | [diff] [blame] | 5397 | status = 0; |
Bryan Schumaker | 613e901 | 2011-04-27 15:28:44 -0400 | [diff] [blame] | 5398 | out: |
| 5399 | return status; |
Bryan Schumaker | 5a5ea0d | 2011-03-24 17:12:29 +0000 | [diff] [blame] | 5400 | out_overflow: |
| 5401 | print_overflow_msg(__func__, xdr); |
| 5402 | return -EIO; |
| 5403 | } |
| 5404 | |
Bryan Schumaker | 31e4dda | 2012-04-27 13:27:38 -0400 | [diff] [blame] | 5405 | static int decode_secinfo(struct xdr_stream *xdr, struct nfs4_secinfo_res *res) |
| 5406 | { |
| 5407 | int status = decode_op_hdr(xdr, OP_SECINFO); |
| 5408 | if (status) |
| 5409 | return status; |
| 5410 | return decode_secinfo_common(xdr, res); |
| 5411 | } |
| 5412 | |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 5413 | #if defined(CONFIG_NFS_V4_1) |
Bryan Schumaker | 31e4dda | 2012-04-27 13:27:38 -0400 | [diff] [blame] | 5414 | static int decode_secinfo_no_name(struct xdr_stream *xdr, struct nfs4_secinfo_res *res) |
| 5415 | { |
| 5416 | int status = decode_op_hdr(xdr, OP_SECINFO_NO_NAME); |
| 5417 | if (status) |
| 5418 | return status; |
| 5419 | return decode_secinfo_common(xdr, res); |
| 5420 | } |
| 5421 | |
Weston Andros Adamson | 2031cd1 | 2013-08-13 16:37:32 -0400 | [diff] [blame] | 5422 | static int decode_op_map(struct xdr_stream *xdr, struct nfs4_op_map *op_map) |
| 5423 | { |
| 5424 | __be32 *p; |
| 5425 | uint32_t bitmap_words; |
| 5426 | unsigned int i; |
| 5427 | |
| 5428 | p = xdr_inline_decode(xdr, 4); |
| 5429 | bitmap_words = be32_to_cpup(p++); |
| 5430 | if (bitmap_words > NFS4_OP_MAP_NUM_WORDS) |
| 5431 | return -EIO; |
| 5432 | p = xdr_inline_decode(xdr, 4 * bitmap_words); |
| 5433 | for (i = 0; i < bitmap_words; i++) |
| 5434 | op_map->u.words[i] = be32_to_cpup(p++); |
| 5435 | |
| 5436 | return 0; |
| 5437 | } |
| 5438 | |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 5439 | static int decode_exchange_id(struct xdr_stream *xdr, |
| 5440 | struct nfs41_exchange_id_res *res) |
| 5441 | { |
| 5442 | __be32 *p; |
| 5443 | uint32_t dummy; |
Benny Halevy | 2460ba5 | 2009-08-14 17:20:10 +0300 | [diff] [blame] | 5444 | char *dummy_str; |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 5445 | int status; |
Weston Andros Adamson | 7d2ed9a | 2012-02-17 15:20:26 -0500 | [diff] [blame] | 5446 | uint32_t impl_id_count; |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 5447 | |
| 5448 | status = decode_op_hdr(xdr, OP_EXCHANGE_ID); |
| 5449 | if (status) |
| 5450 | return status; |
| 5451 | |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 5452 | p = xdr_inline_decode(xdr, 8); |
| 5453 | if (unlikely(!p)) |
| 5454 | goto out_overflow; |
Trond Myklebust | 32b0131 | 2012-05-26 13:41:04 -0400 | [diff] [blame] | 5455 | xdr_decode_hyper(p, &res->clientid); |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 5456 | p = xdr_inline_decode(xdr, 12); |
| 5457 | if (unlikely(!p)) |
| 5458 | goto out_overflow; |
Trond Myklebust | 32b0131 | 2012-05-26 13:41:04 -0400 | [diff] [blame] | 5459 | res->seqid = be32_to_cpup(p++); |
| 5460 | res->flags = be32_to_cpup(p++); |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 5461 | |
Weston Andros Adamson | 2031cd1 | 2013-08-13 16:37:32 -0400 | [diff] [blame] | 5462 | res->state_protect.how = be32_to_cpup(p); |
| 5463 | switch (res->state_protect.how) { |
| 5464 | case SP4_NONE: |
| 5465 | break; |
| 5466 | case SP4_MACH_CRED: |
| 5467 | status = decode_op_map(xdr, &res->state_protect.enforce); |
| 5468 | if (status) |
| 5469 | return status; |
| 5470 | status = decode_op_map(xdr, &res->state_protect.allow); |
| 5471 | if (status) |
| 5472 | return status; |
| 5473 | break; |
| 5474 | default: |
| 5475 | WARN_ON_ONCE(1); |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 5476 | return -EIO; |
Weston Andros Adamson | 2031cd1 | 2013-08-13 16:37:32 -0400 | [diff] [blame] | 5477 | } |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 5478 | |
Chuck Lever | acdeb69 | 2012-05-21 22:46:16 -0400 | [diff] [blame] | 5479 | /* server_owner4.so_minor_id */ |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 5480 | p = xdr_inline_decode(xdr, 8); |
| 5481 | if (unlikely(!p)) |
| 5482 | goto out_overflow; |
Chuck Lever | acdeb69 | 2012-05-21 22:46:16 -0400 | [diff] [blame] | 5483 | p = xdr_decode_hyper(p, &res->server_owner->minor_id); |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 5484 | |
Chuck Lever | acdeb69 | 2012-05-21 22:46:16 -0400 | [diff] [blame] | 5485 | /* server_owner4.so_major_id */ |
Benny Halevy | 2460ba5 | 2009-08-14 17:20:10 +0300 | [diff] [blame] | 5486 | status = decode_opaque_inline(xdr, &dummy, &dummy_str); |
| 5487 | if (unlikely(status)) |
| 5488 | return status; |
Weston Andros Adamson | 78fe0f4 | 2011-05-31 19:05:47 -0400 | [diff] [blame] | 5489 | if (unlikely(dummy > NFS4_OPAQUE_LIMIT)) |
| 5490 | return -EIO; |
Chuck Lever | acdeb69 | 2012-05-21 22:46:16 -0400 | [diff] [blame] | 5491 | memcpy(res->server_owner->major_id, dummy_str, dummy); |
| 5492 | res->server_owner->major_id_sz = dummy; |
Weston Andros Adamson | 78fe0f4 | 2011-05-31 19:05:47 -0400 | [diff] [blame] | 5493 | |
Chuck Lever | acdeb69 | 2012-05-21 22:46:16 -0400 | [diff] [blame] | 5494 | /* server_scope4 */ |
| 5495 | status = decode_opaque_inline(xdr, &dummy, &dummy_str); |
| 5496 | if (unlikely(status)) |
| 5497 | return status; |
| 5498 | if (unlikely(dummy > NFS4_OPAQUE_LIMIT)) |
| 5499 | return -EIO; |
Weston Andros Adamson | 78fe0f4 | 2011-05-31 19:05:47 -0400 | [diff] [blame] | 5500 | memcpy(res->server_scope->server_scope, dummy_str, dummy); |
| 5501 | res->server_scope->server_scope_sz = dummy; |
| 5502 | |
Weston Andros Adamson | 7d2ed9a | 2012-02-17 15:20:26 -0500 | [diff] [blame] | 5503 | /* Implementation Id */ |
| 5504 | p = xdr_inline_decode(xdr, 4); |
| 5505 | if (unlikely(!p)) |
| 5506 | goto out_overflow; |
| 5507 | impl_id_count = be32_to_cpup(p++); |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 5508 | |
Weston Andros Adamson | 7d2ed9a | 2012-02-17 15:20:26 -0500 | [diff] [blame] | 5509 | if (impl_id_count) { |
| 5510 | /* nii_domain */ |
| 5511 | status = decode_opaque_inline(xdr, &dummy, &dummy_str); |
| 5512 | if (unlikely(status)) |
| 5513 | return status; |
| 5514 | if (unlikely(dummy > NFS4_OPAQUE_LIMIT)) |
| 5515 | return -EIO; |
| 5516 | memcpy(res->impl_id->domain, dummy_str, dummy); |
| 5517 | |
| 5518 | /* nii_name */ |
| 5519 | status = decode_opaque_inline(xdr, &dummy, &dummy_str); |
| 5520 | if (unlikely(status)) |
| 5521 | return status; |
| 5522 | if (unlikely(dummy > NFS4_OPAQUE_LIMIT)) |
| 5523 | return -EIO; |
| 5524 | memcpy(res->impl_id->name, dummy_str, dummy); |
| 5525 | |
| 5526 | /* nii_date */ |
| 5527 | p = xdr_inline_decode(xdr, 12); |
| 5528 | if (unlikely(!p)) |
| 5529 | goto out_overflow; |
| 5530 | p = xdr_decode_hyper(p, &res->impl_id->date.seconds); |
| 5531 | res->impl_id->date.nseconds = be32_to_cpup(p); |
| 5532 | |
| 5533 | /* if there's more than one entry, ignore the rest */ |
| 5534 | } |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 5535 | return 0; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 5536 | out_overflow: |
| 5537 | print_overflow_msg(__func__, xdr); |
| 5538 | return -EIO; |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 5539 | } |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 5540 | |
| 5541 | static int decode_chan_attrs(struct xdr_stream *xdr, |
| 5542 | struct nfs4_channel_attrs *attrs) |
| 5543 | { |
| 5544 | __be32 *p; |
Benny Halevy | c9c30dd | 2011-06-11 17:08:39 -0400 | [diff] [blame] | 5545 | u32 nr_attrs, val; |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 5546 | |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 5547 | p = xdr_inline_decode(xdr, 28); |
| 5548 | if (unlikely(!p)) |
| 5549 | goto out_overflow; |
Benny Halevy | c9c30dd | 2011-06-11 17:08:39 -0400 | [diff] [blame] | 5550 | val = be32_to_cpup(p++); /* headerpadsz */ |
| 5551 | if (val) |
| 5552 | return -EINVAL; /* no support for header padding yet */ |
Benny Halevy | 6f723f7 | 2009-08-14 17:19:37 +0300 | [diff] [blame] | 5553 | attrs->max_rqst_sz = be32_to_cpup(p++); |
| 5554 | attrs->max_resp_sz = be32_to_cpup(p++); |
| 5555 | attrs->max_resp_sz_cached = be32_to_cpup(p++); |
| 5556 | attrs->max_ops = be32_to_cpup(p++); |
| 5557 | attrs->max_reqs = be32_to_cpup(p++); |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 5558 | nr_attrs = be32_to_cpup(p); |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 5559 | if (unlikely(nr_attrs > 1)) { |
Weston Andros Adamson | a030889 | 2012-01-26 13:32:23 -0500 | [diff] [blame] | 5560 | printk(KERN_WARNING "NFS: %s: Invalid rdma channel attrs " |
| 5561 | "count %u\n", __func__, nr_attrs); |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 5562 | return -EINVAL; |
| 5563 | } |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 5564 | if (nr_attrs == 1) { |
| 5565 | p = xdr_inline_decode(xdr, 4); /* skip rdma_attrs */ |
| 5566 | if (unlikely(!p)) |
| 5567 | goto out_overflow; |
| 5568 | } |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 5569 | return 0; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 5570 | out_overflow: |
| 5571 | print_overflow_msg(__func__, xdr); |
| 5572 | return -EIO; |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 5573 | } |
| 5574 | |
Benny Halevy | e78291e | 2009-08-14 17:20:00 +0300 | [diff] [blame] | 5575 | static int decode_sessionid(struct xdr_stream *xdr, struct nfs4_sessionid *sid) |
| 5576 | { |
| 5577 | return decode_opaque_fixed(xdr, sid->data, NFS4_MAX_SESSIONID_LEN); |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 5578 | } |
| 5579 | |
Weston Andros Adamson | 7c44f1ae | 2012-05-24 13:22:50 -0400 | [diff] [blame] | 5580 | static int decode_bind_conn_to_session(struct xdr_stream *xdr, |
| 5581 | struct nfs41_bind_conn_to_session_res *res) |
| 5582 | { |
| 5583 | __be32 *p; |
| 5584 | int status; |
| 5585 | |
| 5586 | status = decode_op_hdr(xdr, OP_BIND_CONN_TO_SESSION); |
| 5587 | if (!status) |
| 5588 | status = decode_sessionid(xdr, &res->session->sess_id); |
| 5589 | if (unlikely(status)) |
| 5590 | return status; |
| 5591 | |
| 5592 | /* dir flags, rdma mode bool */ |
| 5593 | p = xdr_inline_decode(xdr, 8); |
| 5594 | if (unlikely(!p)) |
| 5595 | goto out_overflow; |
| 5596 | |
| 5597 | res->dir = be32_to_cpup(p++); |
| 5598 | if (res->dir == 0 || res->dir > NFS4_CDFS4_BOTH) |
| 5599 | return -EIO; |
| 5600 | if (be32_to_cpup(p) == 0) |
| 5601 | res->use_conn_in_rdma_mode = false; |
| 5602 | else |
| 5603 | res->use_conn_in_rdma_mode = true; |
| 5604 | |
| 5605 | return 0; |
| 5606 | out_overflow: |
| 5607 | print_overflow_msg(__func__, xdr); |
| 5608 | return -EIO; |
| 5609 | } |
| 5610 | |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 5611 | static int decode_create_session(struct xdr_stream *xdr, |
| 5612 | struct nfs41_create_session_res *res) |
| 5613 | { |
| 5614 | __be32 *p; |
| 5615 | int status; |
| 5616 | struct nfs_client *clp = res->client; |
| 5617 | struct nfs4_session *session = clp->cl_session; |
| 5618 | |
| 5619 | status = decode_op_hdr(xdr, OP_CREATE_SESSION); |
Benny Halevy | e78291e | 2009-08-14 17:20:00 +0300 | [diff] [blame] | 5620 | if (!status) |
| 5621 | status = decode_sessionid(xdr, &session->sess_id); |
| 5622 | if (unlikely(status)) |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 5623 | return status; |
| 5624 | |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 5625 | /* seqid, flags */ |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 5626 | p = xdr_inline_decode(xdr, 8); |
| 5627 | if (unlikely(!p)) |
| 5628 | goto out_overflow; |
Benny Halevy | 6f723f7 | 2009-08-14 17:19:37 +0300 | [diff] [blame] | 5629 | clp->cl_seqid = be32_to_cpup(p++); |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 5630 | session->flags = be32_to_cpup(p); |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 5631 | |
| 5632 | /* Channel attributes */ |
| 5633 | status = decode_chan_attrs(xdr, &session->fc_attrs); |
| 5634 | if (!status) |
| 5635 | status = decode_chan_attrs(xdr, &session->bc_attrs); |
| 5636 | return status; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 5637 | out_overflow: |
| 5638 | print_overflow_msg(__func__, xdr); |
| 5639 | return -EIO; |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 5640 | } |
Andy Adamson | 0f3e66c | 2009-04-01 09:22:34 -0400 | [diff] [blame] | 5641 | |
| 5642 | static int decode_destroy_session(struct xdr_stream *xdr, void *dummy) |
| 5643 | { |
| 5644 | return decode_op_hdr(xdr, OP_DESTROY_SESSION); |
| 5645 | } |
Ricardo Labiaga | 18019753 | 2009-12-05 16:08:40 -0500 | [diff] [blame] | 5646 | |
Trond Myklebust | 6624553 | 2012-05-25 17:18:09 -0400 | [diff] [blame] | 5647 | static int decode_destroy_clientid(struct xdr_stream *xdr, void *dummy) |
| 5648 | { |
| 5649 | return decode_op_hdr(xdr, OP_DESTROY_CLIENTID); |
| 5650 | } |
| 5651 | |
Ricardo Labiaga | 18019753 | 2009-12-05 16:08:40 -0500 | [diff] [blame] | 5652 | static int decode_reclaim_complete(struct xdr_stream *xdr, void *dummy) |
| 5653 | { |
| 5654 | return decode_op_hdr(xdr, OP_RECLAIM_COMPLETE); |
| 5655 | } |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 5656 | #endif /* CONFIG_NFS_V4_1 */ |
| 5657 | |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 5658 | static int decode_sequence(struct xdr_stream *xdr, |
| 5659 | struct nfs4_sequence_res *res, |
| 5660 | struct rpc_rqst *rqstp) |
| 5661 | { |
| 5662 | #if defined(CONFIG_NFS_V4_1) |
Trond Myklebust | e3725ec | 2012-11-16 12:25:01 -0500 | [diff] [blame] | 5663 | struct nfs4_session *session; |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 5664 | struct nfs4_sessionid id; |
| 5665 | u32 dummy; |
| 5666 | int status; |
| 5667 | __be32 *p; |
| 5668 | |
Trond Myklebust | e3725ec | 2012-11-16 12:25:01 -0500 | [diff] [blame] | 5669 | if (res->sr_slot == NULL) |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 5670 | return 0; |
Chuck Lever | 3bd2384 | 2013-08-09 12:49:19 -0400 | [diff] [blame] | 5671 | if (!res->sr_slot->table->session) |
| 5672 | return 0; |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 5673 | |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 5674 | status = decode_op_hdr(xdr, OP_SEQUENCE); |
Benny Halevy | e78291e | 2009-08-14 17:20:00 +0300 | [diff] [blame] | 5675 | if (!status) |
| 5676 | status = decode_sessionid(xdr, &id); |
| 5677 | if (unlikely(status)) |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 5678 | goto out_err; |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 5679 | |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 5680 | /* |
| 5681 | * If the server returns different values for sessionID, slotID or |
| 5682 | * sequence number, the server is looney tunes. |
| 5683 | */ |
Trond Myklebust | fdcb457 | 2010-02-08 09:32:40 -0500 | [diff] [blame] | 5684 | status = -EREMOTEIO; |
Trond Myklebust | e3725ec | 2012-11-16 12:25:01 -0500 | [diff] [blame] | 5685 | session = res->sr_slot->table->session; |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 5686 | |
Trond Myklebust | e3725ec | 2012-11-16 12:25:01 -0500 | [diff] [blame] | 5687 | if (memcmp(id.data, session->sess_id.data, |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 5688 | NFS4_MAX_SESSIONID_LEN)) { |
| 5689 | dprintk("%s Invalid session id\n", __func__); |
| 5690 | goto out_err; |
| 5691 | } |
Benny Halevy | e78291e | 2009-08-14 17:20:00 +0300 | [diff] [blame] | 5692 | |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 5693 | p = xdr_inline_decode(xdr, 20); |
| 5694 | if (unlikely(!p)) |
| 5695 | goto out_overflow; |
Benny Halevy | e78291e | 2009-08-14 17:20:00 +0300 | [diff] [blame] | 5696 | |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 5697 | /* seqid */ |
Benny Halevy | 6f723f7 | 2009-08-14 17:19:37 +0300 | [diff] [blame] | 5698 | dummy = be32_to_cpup(p++); |
Benny Halevy | dfb4f309 | 2010-09-24 09:17:01 -0400 | [diff] [blame] | 5699 | if (dummy != res->sr_slot->seq_nr) { |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 5700 | dprintk("%s Invalid sequence number\n", __func__); |
| 5701 | goto out_err; |
| 5702 | } |
| 5703 | /* slot id */ |
Benny Halevy | 6f723f7 | 2009-08-14 17:19:37 +0300 | [diff] [blame] | 5704 | dummy = be32_to_cpup(p++); |
Trond Myklebust | df2fabf | 2012-11-16 12:45:06 -0500 | [diff] [blame] | 5705 | if (dummy != res->sr_slot->slot_nr) { |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 5706 | dprintk("%s Invalid slot id\n", __func__); |
| 5707 | goto out_err; |
| 5708 | } |
Trond Myklebust | da0507b | 2012-11-20 18:10:30 -0500 | [diff] [blame] | 5709 | /* highest slot id */ |
| 5710 | res->sr_highest_slotid = be32_to_cpup(p++); |
Trond Myklebust | 464ee9f | 2012-11-20 12:49:27 -0500 | [diff] [blame] | 5711 | /* target highest slot id */ |
| 5712 | res->sr_target_highest_slotid = be32_to_cpup(p++); |
Alexandros Batsakis | 0629e37 | 2009-12-05 13:46:14 -0500 | [diff] [blame] | 5713 | /* result flags */ |
| 5714 | res->sr_status_flags = be32_to_cpup(p); |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 5715 | status = 0; |
| 5716 | out_err: |
| 5717 | res->sr_status = status; |
| 5718 | return status; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 5719 | out_overflow: |
| 5720 | print_overflow_msg(__func__, xdr); |
| 5721 | status = -EIO; |
| 5722 | goto out_err; |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 5723 | #else /* CONFIG_NFS_V4_1 */ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 5724 | return 0; |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 5725 | #endif /* CONFIG_NFS_V4_1 */ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 5726 | } |
| 5727 | |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 5728 | #if defined(CONFIG_NFS_V4_1) |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 5729 | static int decode_getdeviceinfo(struct xdr_stream *xdr, |
| 5730 | struct pnfs_device *pdev) |
| 5731 | { |
| 5732 | __be32 *p; |
| 5733 | uint32_t len, type; |
| 5734 | int status; |
| 5735 | |
| 5736 | status = decode_op_hdr(xdr, OP_GETDEVICEINFO); |
| 5737 | if (status) { |
| 5738 | if (status == -ETOOSMALL) { |
| 5739 | p = xdr_inline_decode(xdr, 4); |
| 5740 | if (unlikely(!p)) |
| 5741 | goto out_overflow; |
| 5742 | pdev->mincount = be32_to_cpup(p); |
| 5743 | dprintk("%s: Min count too small. mincnt = %u\n", |
| 5744 | __func__, pdev->mincount); |
| 5745 | } |
| 5746 | return status; |
| 5747 | } |
| 5748 | |
| 5749 | p = xdr_inline_decode(xdr, 8); |
| 5750 | if (unlikely(!p)) |
| 5751 | goto out_overflow; |
| 5752 | type = be32_to_cpup(p++); |
| 5753 | if (type != pdev->layout_type) { |
| 5754 | dprintk("%s: layout mismatch req: %u pdev: %u\n", |
| 5755 | __func__, pdev->layout_type, type); |
| 5756 | return -EINVAL; |
| 5757 | } |
| 5758 | /* |
| 5759 | * Get the length of the opaque device_addr4. xdr_read_pages places |
| 5760 | * the opaque device_addr4 in the xdr_buf->pages (pnfs_device->pages) |
| 5761 | * and places the remaining xdr data in xdr_buf->tail |
| 5762 | */ |
| 5763 | pdev->mincount = be32_to_cpup(p); |
Trond Myklebust | 13fe4ba | 2012-08-01 14:21:12 -0400 | [diff] [blame] | 5764 | if (xdr_read_pages(xdr, pdev->mincount) != pdev->mincount) |
| 5765 | goto out_overflow; |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 5766 | |
| 5767 | /* Parse notification bitmap, verifying that it is zero. */ |
| 5768 | p = xdr_inline_decode(xdr, 4); |
| 5769 | if (unlikely(!p)) |
| 5770 | goto out_overflow; |
| 5771 | len = be32_to_cpup(p); |
| 5772 | if (len) { |
Chuck Lever | ead0059 | 2010-12-14 14:58:21 +0000 | [diff] [blame] | 5773 | uint32_t i; |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 5774 | |
| 5775 | p = xdr_inline_decode(xdr, 4 * len); |
| 5776 | if (unlikely(!p)) |
| 5777 | goto out_overflow; |
Christoph Hellwig | 84c9dee | 2014-09-10 17:37:28 -0700 | [diff] [blame^] | 5778 | |
| 5779 | if (be32_to_cpup(p++) & |
| 5780 | ~(NOTIFY_DEVICEID4_CHANGE | NOTIFY_DEVICEID4_DELETE)) { |
| 5781 | dprintk("%s: unsupported notification\n", |
| 5782 | __func__); |
| 5783 | } |
| 5784 | |
| 5785 | for (i = 1; i < len; i++) { |
| 5786 | if (be32_to_cpup(p++)) { |
| 5787 | dprintk("%s: unsupported notification\n", |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 5788 | __func__); |
| 5789 | return -EIO; |
| 5790 | } |
| 5791 | } |
| 5792 | } |
| 5793 | return 0; |
| 5794 | out_overflow: |
| 5795 | print_overflow_msg(__func__, xdr); |
| 5796 | return -EIO; |
| 5797 | } |
| 5798 | |
| 5799 | static int decode_layoutget(struct xdr_stream *xdr, struct rpc_rqst *req, |
| 5800 | struct nfs4_layoutget_res *res) |
| 5801 | { |
| 5802 | __be32 *p; |
| 5803 | int status; |
| 5804 | u32 layout_count; |
Trond Myklebust | 64bd577 | 2012-06-20 22:35:05 -0400 | [diff] [blame] | 5805 | u32 recvd; |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 5806 | |
| 5807 | status = decode_op_hdr(xdr, OP_LAYOUTGET); |
| 5808 | if (status) |
| 5809 | return status; |
Trond Myklebust | ea9d23f | 2012-03-04 18:13:56 -0500 | [diff] [blame] | 5810 | p = xdr_inline_decode(xdr, 4); |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 5811 | if (unlikely(!p)) |
| 5812 | goto out_overflow; |
Trond Myklebust | ea9d23f | 2012-03-04 18:13:56 -0500 | [diff] [blame] | 5813 | res->return_on_close = be32_to_cpup(p); |
| 5814 | decode_stateid(xdr, &res->stateid); |
| 5815 | p = xdr_inline_decode(xdr, 4); |
| 5816 | if (unlikely(!p)) |
| 5817 | goto out_overflow; |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 5818 | layout_count = be32_to_cpup(p); |
| 5819 | if (!layout_count) { |
| 5820 | dprintk("%s: server responded with empty layout array\n", |
| 5821 | __func__); |
| 5822 | return -EINVAL; |
| 5823 | } |
| 5824 | |
Weston Andros Adamson | 35124a0 | 2011-03-24 16:48:21 -0400 | [diff] [blame] | 5825 | p = xdr_inline_decode(xdr, 28); |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 5826 | if (unlikely(!p)) |
| 5827 | goto out_overflow; |
| 5828 | p = xdr_decode_hyper(p, &res->range.offset); |
| 5829 | p = xdr_decode_hyper(p, &res->range.length); |
| 5830 | res->range.iomode = be32_to_cpup(p++); |
| 5831 | res->type = be32_to_cpup(p++); |
Weston Andros Adamson | 35124a0 | 2011-03-24 16:48:21 -0400 | [diff] [blame] | 5832 | res->layoutp->len = be32_to_cpup(p); |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 5833 | |
| 5834 | dprintk("%s roff:%lu rlen:%lu riomode:%d, lo_type:0x%x, lo.len:%d\n", |
| 5835 | __func__, |
| 5836 | (unsigned long)res->range.offset, |
| 5837 | (unsigned long)res->range.length, |
| 5838 | res->range.iomode, |
| 5839 | res->type, |
Weston Andros Adamson | 35124a0 | 2011-03-24 16:48:21 -0400 | [diff] [blame] | 5840 | res->layoutp->len); |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 5841 | |
Trond Myklebust | 64bd577 | 2012-06-20 22:35:05 -0400 | [diff] [blame] | 5842 | recvd = xdr_read_pages(xdr, res->layoutp->len); |
Weston Andros Adamson | 35124a0 | 2011-03-24 16:48:21 -0400 | [diff] [blame] | 5843 | if (res->layoutp->len > recvd) { |
| 5844 | dprintk("NFS: server cheating in layoutget reply: " |
| 5845 | "layout len %u > recvd %u\n", |
| 5846 | res->layoutp->len, recvd); |
| 5847 | return -EINVAL; |
| 5848 | } |
| 5849 | |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 5850 | if (layout_count > 1) { |
| 5851 | /* We only handle a length one array at the moment. Any |
| 5852 | * further entries are just ignored. Note that this means |
| 5853 | * the client may see a response that is less than the |
| 5854 | * minimum it requested. |
| 5855 | */ |
| 5856 | dprintk("%s: server responded with %d layouts, dropping tail\n", |
| 5857 | __func__, layout_count); |
| 5858 | } |
| 5859 | |
| 5860 | return 0; |
| 5861 | out_overflow: |
| 5862 | print_overflow_msg(__func__, xdr); |
| 5863 | return -EIO; |
| 5864 | } |
Andy Adamson | 863a3c6 | 2011-03-23 13:27:54 +0000 | [diff] [blame] | 5865 | |
Benny Halevy | cbe8260 | 2011-05-22 19:52:37 +0300 | [diff] [blame] | 5866 | static int decode_layoutreturn(struct xdr_stream *xdr, |
| 5867 | struct nfs4_layoutreturn_res *res) |
| 5868 | { |
| 5869 | __be32 *p; |
| 5870 | int status; |
| 5871 | |
| 5872 | status = decode_op_hdr(xdr, OP_LAYOUTRETURN); |
| 5873 | if (status) |
| 5874 | return status; |
| 5875 | p = xdr_inline_decode(xdr, 4); |
| 5876 | if (unlikely(!p)) |
| 5877 | goto out_overflow; |
| 5878 | res->lrs_present = be32_to_cpup(p); |
| 5879 | if (res->lrs_present) |
| 5880 | status = decode_stateid(xdr, &res->stateid); |
| 5881 | return status; |
| 5882 | out_overflow: |
| 5883 | print_overflow_msg(__func__, xdr); |
| 5884 | return -EIO; |
| 5885 | } |
| 5886 | |
Andy Adamson | 863a3c6 | 2011-03-23 13:27:54 +0000 | [diff] [blame] | 5887 | static int decode_layoutcommit(struct xdr_stream *xdr, |
| 5888 | struct rpc_rqst *req, |
| 5889 | struct nfs4_layoutcommit_res *res) |
| 5890 | { |
| 5891 | __be32 *p; |
| 5892 | __u32 sizechanged; |
| 5893 | int status; |
| 5894 | |
| 5895 | status = decode_op_hdr(xdr, OP_LAYOUTCOMMIT); |
Andy Adamson | db29c08 | 2011-07-30 20:52:38 -0400 | [diff] [blame] | 5896 | res->status = status; |
Andy Adamson | 863a3c6 | 2011-03-23 13:27:54 +0000 | [diff] [blame] | 5897 | if (status) |
| 5898 | return status; |
| 5899 | |
| 5900 | p = xdr_inline_decode(xdr, 4); |
| 5901 | if (unlikely(!p)) |
| 5902 | goto out_overflow; |
| 5903 | sizechanged = be32_to_cpup(p); |
| 5904 | |
| 5905 | if (sizechanged) { |
| 5906 | /* throw away new size */ |
| 5907 | p = xdr_inline_decode(xdr, 8); |
| 5908 | if (unlikely(!p)) |
| 5909 | goto out_overflow; |
| 5910 | } |
| 5911 | return 0; |
| 5912 | out_overflow: |
| 5913 | print_overflow_msg(__func__, xdr); |
| 5914 | return -EIO; |
| 5915 | } |
Bryan Schumaker | 7d97479 | 2011-06-02 14:59:08 -0400 | [diff] [blame] | 5916 | |
| 5917 | static int decode_test_stateid(struct xdr_stream *xdr, |
| 5918 | struct nfs41_test_stateid_res *res) |
| 5919 | { |
| 5920 | __be32 *p; |
| 5921 | int status; |
| 5922 | int num_res; |
| 5923 | |
| 5924 | status = decode_op_hdr(xdr, OP_TEST_STATEID); |
| 5925 | if (status) |
| 5926 | return status; |
| 5927 | |
| 5928 | p = xdr_inline_decode(xdr, 4); |
| 5929 | if (unlikely(!p)) |
| 5930 | goto out_overflow; |
| 5931 | num_res = be32_to_cpup(p++); |
| 5932 | if (num_res != 1) |
| 5933 | goto out; |
| 5934 | |
| 5935 | p = xdr_inline_decode(xdr, 4); |
| 5936 | if (unlikely(!p)) |
| 5937 | goto out_overflow; |
| 5938 | res->status = be32_to_cpup(p++); |
Bryan Schumaker | 1cab065 | 2012-01-31 10:39:29 -0500 | [diff] [blame] | 5939 | |
| 5940 | return status; |
Bryan Schumaker | 7d97479 | 2011-06-02 14:59:08 -0400 | [diff] [blame] | 5941 | out_overflow: |
| 5942 | print_overflow_msg(__func__, xdr); |
| 5943 | out: |
| 5944 | return -EIO; |
| 5945 | } |
Bryan Schumaker | 9aeda35 | 2011-06-02 14:59:09 -0400 | [diff] [blame] | 5946 | |
| 5947 | static int decode_free_stateid(struct xdr_stream *xdr, |
| 5948 | struct nfs41_free_stateid_res *res) |
| 5949 | { |
Andy Adamson | 9f79fb4 | 2013-09-10 12:56:29 -0400 | [diff] [blame] | 5950 | res->status = decode_op_hdr(xdr, OP_FREE_STATEID); |
Bryan Schumaker | 9aeda35 | 2011-06-02 14:59:09 -0400 | [diff] [blame] | 5951 | return res->status; |
Bryan Schumaker | 9aeda35 | 2011-06-02 14:59:09 -0400 | [diff] [blame] | 5952 | } |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 5953 | #endif /* CONFIG_NFS_V4_1 */ |
| 5954 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5955 | /* |
Benny Halevy | 49c2559 | 2008-12-23 16:06:16 -0500 | [diff] [blame] | 5956 | * END OF "GENERIC" DECODE ROUTINES. |
| 5957 | */ |
| 5958 | |
| 5959 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5960 | * Decode OPEN_DOWNGRADE response |
| 5961 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 5962 | static int nfs4_xdr_dec_open_downgrade(struct rpc_rqst *rqstp, |
| 5963 | struct xdr_stream *xdr, |
| 5964 | struct nfs_closeres *res) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5965 | { |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 5966 | struct compound_hdr hdr; |
| 5967 | int status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5968 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 5969 | status = decode_compound_hdr(xdr, &hdr); |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 5970 | if (status) |
| 5971 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 5972 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 5973 | if (status) |
| 5974 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 5975 | status = decode_putfh(xdr); |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 5976 | if (status) |
| 5977 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 5978 | status = decode_open_downgrade(xdr, res); |
Trond Myklebust | 516a6af | 2005-10-27 22:12:41 -0400 | [diff] [blame] | 5979 | if (status != 0) |
| 5980 | goto out; |
Trond Myklebust | 6926afd1 | 2012-01-07 13:22:46 -0500 | [diff] [blame] | 5981 | decode_getfattr(xdr, res->fattr, res->server); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5982 | out: |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 5983 | return status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5984 | } |
| 5985 | |
| 5986 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5987 | * Decode ACCESS response |
| 5988 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 5989 | static int nfs4_xdr_dec_access(struct rpc_rqst *rqstp, struct xdr_stream *xdr, |
| 5990 | struct nfs4_accessres *res) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5991 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5992 | struct compound_hdr hdr; |
| 5993 | int status; |
Andy Adamson | 6c0195a | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 5994 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 5995 | status = decode_compound_hdr(xdr, &hdr); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 5996 | if (status) |
| 5997 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 5998 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 5999 | if (status) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6000 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6001 | status = decode_putfh(xdr); |
Trond Myklebust | 76b3299 | 2007-08-10 17:45:11 -0400 | [diff] [blame] | 6002 | if (status != 0) |
| 6003 | goto out; |
Weston Andros Adamson | 6168f62 | 2012-09-10 14:00:46 -0400 | [diff] [blame] | 6004 | status = decode_access(xdr, &res->supported, &res->access); |
Trond Myklebust | 76b3299 | 2007-08-10 17:45:11 -0400 | [diff] [blame] | 6005 | if (status != 0) |
| 6006 | goto out; |
Trond Myklebust | 6926afd1 | 2012-01-07 13:22:46 -0500 | [diff] [blame] | 6007 | decode_getfattr(xdr, res->fattr, res->server); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6008 | out: |
| 6009 | return status; |
| 6010 | } |
| 6011 | |
| 6012 | /* |
| 6013 | * Decode LOOKUP response |
| 6014 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6015 | static int nfs4_xdr_dec_lookup(struct rpc_rqst *rqstp, struct xdr_stream *xdr, |
| 6016 | struct nfs4_lookup_res *res) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6017 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6018 | struct compound_hdr hdr; |
| 6019 | int status; |
Andy Adamson | 6c0195a | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6020 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6021 | status = decode_compound_hdr(xdr, &hdr); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6022 | if (status) |
| 6023 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6024 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6025 | if (status) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6026 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6027 | status = decode_putfh(xdr); |
| 6028 | if (status) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6029 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6030 | status = decode_lookup(xdr); |
| 6031 | if (status) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6032 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6033 | status = decode_getfh(xdr, res->fh); |
| 6034 | if (status) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6035 | goto out; |
David Quigley | aa9c266 | 2013-05-22 12:50:44 -0400 | [diff] [blame] | 6036 | status = decode_getfattr_label(xdr, res->fattr, res->label, res->server); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6037 | out: |
| 6038 | return status; |
| 6039 | } |
| 6040 | |
| 6041 | /* |
| 6042 | * Decode LOOKUP_ROOT response |
| 6043 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6044 | static int nfs4_xdr_dec_lookup_root(struct rpc_rqst *rqstp, |
| 6045 | struct xdr_stream *xdr, |
| 6046 | struct nfs4_lookup_res *res) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6047 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6048 | struct compound_hdr hdr; |
| 6049 | int status; |
Andy Adamson | 6c0195a | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6050 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6051 | status = decode_compound_hdr(xdr, &hdr); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6052 | if (status) |
| 6053 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6054 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6055 | if (status) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6056 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6057 | status = decode_putrootfh(xdr); |
| 6058 | if (status) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6059 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6060 | status = decode_getfh(xdr, res->fh); |
| 6061 | if (status == 0) |
David Quigley | aa9c266 | 2013-05-22 12:50:44 -0400 | [diff] [blame] | 6062 | status = decode_getfattr_label(xdr, res->fattr, |
| 6063 | res->label, res->server); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6064 | out: |
| 6065 | return status; |
| 6066 | } |
| 6067 | |
| 6068 | /* |
| 6069 | * Decode REMOVE response |
| 6070 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6071 | static int nfs4_xdr_dec_remove(struct rpc_rqst *rqstp, struct xdr_stream *xdr, |
| 6072 | struct nfs_removeres *res) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6073 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6074 | struct compound_hdr hdr; |
| 6075 | int status; |
Andy Adamson | 6c0195a | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6076 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6077 | status = decode_compound_hdr(xdr, &hdr); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6078 | if (status) |
| 6079 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6080 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6081 | if (status) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6082 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6083 | status = decode_putfh(xdr); |
| 6084 | if (status) |
Trond Myklebust | 16e4295 | 2005-10-27 22:12:44 -0400 | [diff] [blame] | 6085 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6086 | status = decode_remove(xdr, &res->cinfo); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6087 | out: |
| 6088 | return status; |
| 6089 | } |
| 6090 | |
| 6091 | /* |
| 6092 | * Decode RENAME response |
| 6093 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6094 | static int nfs4_xdr_dec_rename(struct rpc_rqst *rqstp, struct xdr_stream *xdr, |
| 6095 | struct nfs_renameres *res) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6096 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6097 | struct compound_hdr hdr; |
| 6098 | int status; |
Andy Adamson | 6c0195a | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6099 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6100 | status = decode_compound_hdr(xdr, &hdr); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6101 | if (status) |
| 6102 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6103 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6104 | if (status) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6105 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6106 | status = decode_putfh(xdr); |
| 6107 | if (status) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6108 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6109 | status = decode_savefh(xdr); |
| 6110 | if (status) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6111 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6112 | status = decode_putfh(xdr); |
| 6113 | if (status) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6114 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6115 | status = decode_rename(xdr, &res->old_cinfo, &res->new_cinfo); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6116 | out: |
| 6117 | return status; |
| 6118 | } |
| 6119 | |
| 6120 | /* |
| 6121 | * Decode LINK response |
| 6122 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6123 | static int nfs4_xdr_dec_link(struct rpc_rqst *rqstp, struct xdr_stream *xdr, |
| 6124 | struct nfs4_link_res *res) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6125 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6126 | struct compound_hdr hdr; |
| 6127 | int status; |
Andy Adamson | 6c0195a | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6128 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6129 | status = decode_compound_hdr(xdr, &hdr); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6130 | if (status) |
| 6131 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6132 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6133 | if (status) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6134 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6135 | status = decode_putfh(xdr); |
| 6136 | if (status) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6137 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6138 | status = decode_savefh(xdr); |
| 6139 | if (status) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6140 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6141 | status = decode_putfh(xdr); |
| 6142 | if (status) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6143 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6144 | status = decode_link(xdr, &res->cinfo); |
| 6145 | if (status) |
Trond Myklebust | 91ba2ee | 2005-10-27 22:12:42 -0400 | [diff] [blame] | 6146 | goto out; |
| 6147 | /* |
| 6148 | * Note order: OP_LINK leaves the directory as the current |
| 6149 | * filehandle. |
| 6150 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6151 | status = decode_restorefh(xdr); |
| 6152 | if (status) |
Trond Myklebust | 91ba2ee | 2005-10-27 22:12:42 -0400 | [diff] [blame] | 6153 | goto out; |
David Quigley | aa9c266 | 2013-05-22 12:50:44 -0400 | [diff] [blame] | 6154 | decode_getfattr_label(xdr, res->fattr, res->label, res->server); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6155 | out: |
| 6156 | return status; |
| 6157 | } |
| 6158 | |
| 6159 | /* |
| 6160 | * Decode CREATE response |
| 6161 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6162 | static int nfs4_xdr_dec_create(struct rpc_rqst *rqstp, struct xdr_stream *xdr, |
| 6163 | struct nfs4_create_res *res) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6164 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6165 | struct compound_hdr hdr; |
| 6166 | int status; |
Andy Adamson | 6c0195a | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6167 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6168 | status = decode_compound_hdr(xdr, &hdr); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6169 | if (status) |
| 6170 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6171 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6172 | if (status) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6173 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6174 | status = decode_putfh(xdr); |
| 6175 | if (status) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6176 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6177 | status = decode_create(xdr, &res->dir_cinfo); |
| 6178 | if (status) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6179 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6180 | status = decode_getfh(xdr, res->fh); |
| 6181 | if (status) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6182 | goto out; |
David Quigley | aa9c266 | 2013-05-22 12:50:44 -0400 | [diff] [blame] | 6183 | decode_getfattr_label(xdr, res->fattr, res->label, res->server); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6184 | out: |
| 6185 | return status; |
| 6186 | } |
| 6187 | |
| 6188 | /* |
| 6189 | * Decode SYMLINK response |
| 6190 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6191 | static int nfs4_xdr_dec_symlink(struct rpc_rqst *rqstp, struct xdr_stream *xdr, |
| 6192 | struct nfs4_create_res *res) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6193 | { |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6194 | return nfs4_xdr_dec_create(rqstp, xdr, res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6195 | } |
| 6196 | |
| 6197 | /* |
| 6198 | * Decode GETATTR response |
| 6199 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6200 | static int nfs4_xdr_dec_getattr(struct rpc_rqst *rqstp, struct xdr_stream *xdr, |
| 6201 | struct nfs4_getattr_res *res) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6202 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6203 | struct compound_hdr hdr; |
| 6204 | int status; |
Andy Adamson | 6c0195a | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6205 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6206 | status = decode_compound_hdr(xdr, &hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6207 | if (status) |
| 6208 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6209 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6210 | if (status) |
| 6211 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6212 | status = decode_putfh(xdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6213 | if (status) |
| 6214 | goto out; |
David Quigley | aa9c266 | 2013-05-22 12:50:44 -0400 | [diff] [blame] | 6215 | status = decode_getfattr_label(xdr, res->fattr, res->label, res->server); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6216 | out: |
| 6217 | return status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6218 | } |
| 6219 | |
J. Bruce Fields | 23ec696 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 6220 | /* |
| 6221 | * Encode an SETACL request |
| 6222 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 6223 | static void nfs4_xdr_enc_setacl(struct rpc_rqst *req, struct xdr_stream *xdr, |
| 6224 | struct nfs_setaclargs *args) |
J. Bruce Fields | 23ec696 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 6225 | { |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6226 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 6227 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6228 | }; |
J. Bruce Fields | 23ec696 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 6229 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 6230 | encode_compound_hdr(xdr, req, &hdr); |
| 6231 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 6232 | encode_putfh(xdr, args->fh, &hdr); |
| 6233 | encode_setacl(xdr, args, &hdr); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 6234 | encode_nops(&hdr); |
J. Bruce Fields | 23ec696 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 6235 | } |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6236 | |
J. Bruce Fields | 23ec696 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 6237 | /* |
| 6238 | * Decode SETACL response |
| 6239 | */ |
| 6240 | static int |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6241 | nfs4_xdr_dec_setacl(struct rpc_rqst *rqstp, struct xdr_stream *xdr, |
Benny Halevy | 73c403a | 2009-04-01 09:22:01 -0400 | [diff] [blame] | 6242 | struct nfs_setaclres *res) |
J. Bruce Fields | 23ec696 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 6243 | { |
J. Bruce Fields | 23ec696 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 6244 | struct compound_hdr hdr; |
| 6245 | int status; |
| 6246 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6247 | status = decode_compound_hdr(xdr, &hdr); |
J. Bruce Fields | 23ec696 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 6248 | if (status) |
| 6249 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6250 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6251 | if (status) |
| 6252 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6253 | status = decode_putfh(xdr); |
J. Bruce Fields | 23ec696 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 6254 | if (status) |
| 6255 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6256 | status = decode_setattr(xdr); |
J. Bruce Fields | 23ec696 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 6257 | out: |
| 6258 | return status; |
| 6259 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6260 | |
| 6261 | /* |
J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 6262 | * Decode GETACL response |
| 6263 | */ |
| 6264 | static int |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6265 | nfs4_xdr_dec_getacl(struct rpc_rqst *rqstp, struct xdr_stream *xdr, |
Benny Halevy | 663c79b | 2009-04-01 09:21:59 -0400 | [diff] [blame] | 6266 | struct nfs_getaclres *res) |
J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 6267 | { |
J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 6268 | struct compound_hdr hdr; |
| 6269 | int status; |
| 6270 | |
Trond Myklebust | 331818f | 2012-02-03 18:30:53 -0500 | [diff] [blame] | 6271 | if (res->acl_scratch != NULL) { |
| 6272 | void *p = page_address(res->acl_scratch); |
| 6273 | xdr_set_scratch_buffer(xdr, p, PAGE_SIZE); |
| 6274 | } |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6275 | status = decode_compound_hdr(xdr, &hdr); |
J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 6276 | if (status) |
| 6277 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6278 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6279 | if (status) |
| 6280 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6281 | status = decode_putfh(xdr); |
J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 6282 | if (status) |
| 6283 | goto out; |
Andy Adamson | bf118a3 | 2011-12-07 11:55:27 -0500 | [diff] [blame] | 6284 | status = decode_getacl(xdr, rqstp, res); |
J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 6285 | |
| 6286 | out: |
| 6287 | return status; |
| 6288 | } |
| 6289 | |
| 6290 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6291 | * Decode CLOSE response |
| 6292 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6293 | static int nfs4_xdr_dec_close(struct rpc_rqst *rqstp, struct xdr_stream *xdr, |
| 6294 | struct nfs_closeres *res) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6295 | { |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6296 | struct compound_hdr hdr; |
| 6297 | int status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6298 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6299 | status = decode_compound_hdr(xdr, &hdr); |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6300 | if (status) |
| 6301 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6302 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6303 | if (status) |
| 6304 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6305 | status = decode_putfh(xdr); |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6306 | if (status) |
| 6307 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6308 | status = decode_close(xdr, res); |
Trond Myklebust | 516a6af | 2005-10-27 22:12:41 -0400 | [diff] [blame] | 6309 | if (status != 0) |
| 6310 | goto out; |
| 6311 | /* |
| 6312 | * Note: Server may do delete on close for this file |
| 6313 | * in which case the getattr call will fail with |
| 6314 | * an ESTALE error. Shouldn't be a problem, |
| 6315 | * though, since fattr->valid will remain unset. |
| 6316 | */ |
Trond Myklebust | 6926afd1 | 2012-01-07 13:22:46 -0500 | [diff] [blame] | 6317 | decode_getfattr(xdr, res->fattr, res->server); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6318 | out: |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6319 | return status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6320 | } |
| 6321 | |
| 6322 | /* |
| 6323 | * Decode OPEN response |
| 6324 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6325 | static int nfs4_xdr_dec_open(struct rpc_rqst *rqstp, struct xdr_stream *xdr, |
| 6326 | struct nfs_openres *res) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6327 | { |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6328 | struct compound_hdr hdr; |
| 6329 | int status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6330 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6331 | status = decode_compound_hdr(xdr, &hdr); |
Trond Myklebust | 56ae19f | 2005-10-27 22:12:40 -0400 | [diff] [blame] | 6332 | if (status) |
| 6333 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6334 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6335 | if (status) |
| 6336 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6337 | status = decode_putfh(xdr); |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6338 | if (status) |
| 6339 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6340 | status = decode_open(xdr, res); |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6341 | if (status) |
| 6342 | goto out; |
Weston Andros Adamson | 01913b4 | 2012-09-06 15:54:27 -0400 | [diff] [blame] | 6343 | status = decode_getfh(xdr, &res->fh); |
| 6344 | if (status) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6345 | goto out; |
Weston Andros Adamson | ae2bb03 | 2012-10-02 14:49:52 -0700 | [diff] [blame] | 6346 | if (res->access_request) |
| 6347 | decode_access(xdr, &res->access_supported, &res->access_result); |
David Quigley | aa9c266 | 2013-05-22 12:50:44 -0400 | [diff] [blame] | 6348 | decode_getfattr_label(xdr, res->f_attr, res->f_label, res->server); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6349 | out: |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6350 | return status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6351 | } |
| 6352 | |
| 6353 | /* |
| 6354 | * Decode OPEN_CONFIRM response |
| 6355 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6356 | static int nfs4_xdr_dec_open_confirm(struct rpc_rqst *rqstp, |
| 6357 | struct xdr_stream *xdr, |
| 6358 | struct nfs_open_confirmres *res) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6359 | { |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6360 | struct compound_hdr hdr; |
| 6361 | int status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6362 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6363 | status = decode_compound_hdr(xdr, &hdr); |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6364 | if (status) |
| 6365 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6366 | status = decode_putfh(xdr); |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6367 | if (status) |
| 6368 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6369 | status = decode_open_confirm(xdr, res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6370 | out: |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6371 | return status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6372 | } |
| 6373 | |
| 6374 | /* |
| 6375 | * Decode OPEN response |
| 6376 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6377 | static int nfs4_xdr_dec_open_noattr(struct rpc_rqst *rqstp, |
| 6378 | struct xdr_stream *xdr, |
| 6379 | struct nfs_openres *res) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6380 | { |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6381 | struct compound_hdr hdr; |
| 6382 | int status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6383 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6384 | status = decode_compound_hdr(xdr, &hdr); |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6385 | if (status) |
| 6386 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6387 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6388 | if (status) |
| 6389 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6390 | status = decode_putfh(xdr); |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6391 | if (status) |
| 6392 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6393 | status = decode_open(xdr, res); |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6394 | if (status) |
| 6395 | goto out; |
Weston Andros Adamson | ae2bb03 | 2012-10-02 14:49:52 -0700 | [diff] [blame] | 6396 | if (res->access_request) |
| 6397 | decode_access(xdr, &res->access_supported, &res->access_result); |
Trond Myklebust | 6926afd1 | 2012-01-07 13:22:46 -0500 | [diff] [blame] | 6398 | decode_getfattr(xdr, res->f_attr, res->server); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6399 | out: |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6400 | return status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6401 | } |
| 6402 | |
| 6403 | /* |
| 6404 | * Decode SETATTR response |
| 6405 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6406 | static int nfs4_xdr_dec_setattr(struct rpc_rqst *rqstp, |
| 6407 | struct xdr_stream *xdr, |
| 6408 | struct nfs_setattrres *res) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6409 | { |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6410 | struct compound_hdr hdr; |
| 6411 | int status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6412 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6413 | status = decode_compound_hdr(xdr, &hdr); |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6414 | if (status) |
| 6415 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6416 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6417 | if (status) |
| 6418 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6419 | status = decode_putfh(xdr); |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6420 | if (status) |
| 6421 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6422 | status = decode_setattr(xdr); |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6423 | if (status) |
| 6424 | goto out; |
David Quigley | aa9c266 | 2013-05-22 12:50:44 -0400 | [diff] [blame] | 6425 | decode_getfattr_label(xdr, res->fattr, res->label, res->server); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6426 | out: |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6427 | return status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6428 | } |
| 6429 | |
| 6430 | /* |
| 6431 | * Decode LOCK response |
| 6432 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6433 | static int nfs4_xdr_dec_lock(struct rpc_rqst *rqstp, struct xdr_stream *xdr, |
| 6434 | struct nfs_lock_res *res) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6435 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6436 | struct compound_hdr hdr; |
| 6437 | int status; |
| 6438 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6439 | status = decode_compound_hdr(xdr, &hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6440 | if (status) |
| 6441 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6442 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6443 | if (status) |
| 6444 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6445 | status = decode_putfh(xdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6446 | if (status) |
| 6447 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6448 | status = decode_lock(xdr, res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6449 | out: |
| 6450 | return status; |
| 6451 | } |
| 6452 | |
| 6453 | /* |
| 6454 | * Decode LOCKT response |
| 6455 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6456 | static int nfs4_xdr_dec_lockt(struct rpc_rqst *rqstp, struct xdr_stream *xdr, |
| 6457 | struct nfs_lockt_res *res) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6458 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6459 | struct compound_hdr hdr; |
| 6460 | int status; |
| 6461 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6462 | status = decode_compound_hdr(xdr, &hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6463 | if (status) |
| 6464 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6465 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6466 | if (status) |
| 6467 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6468 | status = decode_putfh(xdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6469 | if (status) |
| 6470 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6471 | status = decode_lockt(xdr, res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6472 | out: |
| 6473 | return status; |
| 6474 | } |
| 6475 | |
| 6476 | /* |
| 6477 | * Decode LOCKU response |
| 6478 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6479 | static int nfs4_xdr_dec_locku(struct rpc_rqst *rqstp, struct xdr_stream *xdr, |
| 6480 | struct nfs_locku_res *res) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6481 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6482 | struct compound_hdr hdr; |
| 6483 | int status; |
| 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; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6494 | status = decode_locku(xdr, res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6495 | out: |
| 6496 | return status; |
| 6497 | } |
| 6498 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6499 | static int nfs4_xdr_dec_release_lockowner(struct rpc_rqst *rqstp, |
| 6500 | struct xdr_stream *xdr, void *dummy) |
Trond Myklebust | d3c7b7c | 2010-07-01 12:49:01 -0400 | [diff] [blame] | 6501 | { |
Trond Myklebust | d3c7b7c | 2010-07-01 12:49:01 -0400 | [diff] [blame] | 6502 | struct compound_hdr hdr; |
| 6503 | int status; |
| 6504 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6505 | status = decode_compound_hdr(xdr, &hdr); |
Trond Myklebust | d3c7b7c | 2010-07-01 12:49:01 -0400 | [diff] [blame] | 6506 | if (!status) |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6507 | status = decode_release_lockowner(xdr); |
Trond Myklebust | d3c7b7c | 2010-07-01 12:49:01 -0400 | [diff] [blame] | 6508 | return status; |
| 6509 | } |
| 6510 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6511 | /* |
| 6512 | * Decode READLINK response |
| 6513 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6514 | static int nfs4_xdr_dec_readlink(struct rpc_rqst *rqstp, |
| 6515 | struct xdr_stream *xdr, |
Benny Halevy | f50c700 | 2009-04-01 09:21:55 -0400 | [diff] [blame] | 6516 | struct nfs4_readlink_res *res) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6517 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6518 | struct compound_hdr hdr; |
| 6519 | int status; |
| 6520 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6521 | status = decode_compound_hdr(xdr, &hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6522 | if (status) |
| 6523 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6524 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6525 | if (status) |
| 6526 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6527 | status = decode_putfh(xdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6528 | if (status) |
| 6529 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6530 | status = decode_readlink(xdr, rqstp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6531 | out: |
| 6532 | return status; |
| 6533 | } |
| 6534 | |
| 6535 | /* |
| 6536 | * Decode READDIR response |
| 6537 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6538 | static int nfs4_xdr_dec_readdir(struct rpc_rqst *rqstp, struct xdr_stream *xdr, |
| 6539 | struct nfs4_readdir_res *res) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6540 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6541 | struct compound_hdr hdr; |
| 6542 | int status; |
| 6543 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6544 | status = decode_compound_hdr(xdr, &hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6545 | if (status) |
| 6546 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6547 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6548 | if (status) |
| 6549 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6550 | status = decode_putfh(xdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6551 | if (status) |
| 6552 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6553 | status = decode_readdir(xdr, rqstp, res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6554 | out: |
| 6555 | return status; |
| 6556 | } |
| 6557 | |
| 6558 | /* |
| 6559 | * Decode Read response |
| 6560 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6561 | static int nfs4_xdr_dec_read(struct rpc_rqst *rqstp, struct xdr_stream *xdr, |
Anna Schumaker | 9137bdf | 2014-05-06 09:12:25 -0400 | [diff] [blame] | 6562 | struct nfs_pgio_res *res) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6563 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6564 | struct compound_hdr hdr; |
| 6565 | int status; |
| 6566 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6567 | status = decode_compound_hdr(xdr, &hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6568 | if (status) |
| 6569 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6570 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6571 | if (status) |
| 6572 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6573 | status = decode_putfh(xdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6574 | if (status) |
| 6575 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6576 | status = decode_read(xdr, rqstp, res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6577 | if (!status) |
| 6578 | status = res->count; |
| 6579 | out: |
| 6580 | return status; |
| 6581 | } |
| 6582 | |
| 6583 | /* |
| 6584 | * Decode WRITE response |
| 6585 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6586 | static int nfs4_xdr_dec_write(struct rpc_rqst *rqstp, struct xdr_stream *xdr, |
Anna Schumaker | 9137bdf | 2014-05-06 09:12:25 -0400 | [diff] [blame] | 6587 | struct nfs_pgio_res *res) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6588 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6589 | struct compound_hdr hdr; |
| 6590 | int status; |
| 6591 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6592 | status = decode_compound_hdr(xdr, &hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6593 | if (status) |
| 6594 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6595 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6596 | if (status) |
| 6597 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6598 | status = decode_putfh(xdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6599 | if (status) |
| 6600 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6601 | status = decode_write(xdr, res); |
Trond Myklebust | 4f9838c | 2005-10-27 22:12:44 -0400 | [diff] [blame] | 6602 | if (status) |
| 6603 | goto out; |
Fred Isaman | 7ffd106 | 2011-03-03 15:13:46 +0000 | [diff] [blame] | 6604 | if (res->fattr) |
Trond Myklebust | 6926afd1 | 2012-01-07 13:22:46 -0500 | [diff] [blame] | 6605 | decode_getfattr(xdr, res->fattr, res->server); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6606 | if (!status) |
| 6607 | status = res->count; |
| 6608 | out: |
| 6609 | return status; |
| 6610 | } |
| 6611 | |
| 6612 | /* |
| 6613 | * Decode COMMIT response |
| 6614 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6615 | static int nfs4_xdr_dec_commit(struct rpc_rqst *rqstp, struct xdr_stream *xdr, |
Fred Isaman | 0b7c015 | 2012-04-20 14:47:39 -0400 | [diff] [blame] | 6616 | struct nfs_commitres *res) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6617 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6618 | struct compound_hdr hdr; |
| 6619 | int status; |
| 6620 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6621 | status = decode_compound_hdr(xdr, &hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6622 | if (status) |
| 6623 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6624 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6625 | if (status) |
| 6626 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6627 | status = decode_putfh(xdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6628 | if (status) |
| 6629 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6630 | status = decode_commit(xdr, res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6631 | out: |
| 6632 | return status; |
| 6633 | } |
| 6634 | |
| 6635 | /* |
Ricardo Labiaga | 8b17321 | 2009-12-05 16:08:39 -0500 | [diff] [blame] | 6636 | * Decode FSINFO response |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6637 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6638 | static int nfs4_xdr_dec_fsinfo(struct rpc_rqst *req, struct xdr_stream *xdr, |
Benny Halevy | 3dda5e4 | 2009-04-01 09:21:57 -0400 | [diff] [blame] | 6639 | struct nfs4_fsinfo_res *res) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6640 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6641 | struct compound_hdr hdr; |
| 6642 | int status; |
| 6643 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6644 | status = decode_compound_hdr(xdr, &hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6645 | if (!status) |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6646 | status = decode_sequence(xdr, &res->seq_res, req); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6647 | if (!status) |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6648 | status = decode_putfh(xdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6649 | if (!status) |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6650 | status = decode_fsinfo(xdr, res->fsinfo); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6651 | return status; |
| 6652 | } |
| 6653 | |
| 6654 | /* |
Ricardo Labiaga | 8b17321 | 2009-12-05 16:08:39 -0500 | [diff] [blame] | 6655 | * Decode PATHCONF response |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6656 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6657 | static int nfs4_xdr_dec_pathconf(struct rpc_rqst *req, struct xdr_stream *xdr, |
Benny Halevy | d45b298 | 2009-04-01 09:21:58 -0400 | [diff] [blame] | 6658 | struct nfs4_pathconf_res *res) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6659 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6660 | struct compound_hdr hdr; |
| 6661 | int status; |
| 6662 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6663 | status = decode_compound_hdr(xdr, &hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6664 | if (!status) |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6665 | status = decode_sequence(xdr, &res->seq_res, req); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6666 | if (!status) |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6667 | status = decode_putfh(xdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6668 | if (!status) |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6669 | status = decode_pathconf(xdr, res->pathconf); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6670 | return status; |
| 6671 | } |
| 6672 | |
| 6673 | /* |
Ricardo Labiaga | 8b17321 | 2009-12-05 16:08:39 -0500 | [diff] [blame] | 6674 | * Decode STATFS response |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6675 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6676 | static int nfs4_xdr_dec_statfs(struct rpc_rqst *req, struct xdr_stream *xdr, |
Benny Halevy | 24ad148 | 2009-04-01 09:21:56 -0400 | [diff] [blame] | 6677 | struct nfs4_statfs_res *res) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6678 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6679 | struct compound_hdr hdr; |
| 6680 | int status; |
| 6681 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6682 | status = decode_compound_hdr(xdr, &hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6683 | if (!status) |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6684 | status = decode_sequence(xdr, &res->seq_res, req); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6685 | if (!status) |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6686 | status = decode_putfh(xdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6687 | if (!status) |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6688 | status = decode_statfs(xdr, res->fsstat); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6689 | return status; |
| 6690 | } |
| 6691 | |
| 6692 | /* |
Ricardo Labiaga | 8b17321 | 2009-12-05 16:08:39 -0500 | [diff] [blame] | 6693 | * Decode GETATTR_BITMAP response |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6694 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6695 | static int nfs4_xdr_dec_server_caps(struct rpc_rqst *req, |
| 6696 | struct xdr_stream *xdr, |
| 6697 | struct nfs4_server_caps_res *res) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6698 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6699 | struct compound_hdr hdr; |
| 6700 | int status; |
| 6701 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6702 | status = decode_compound_hdr(xdr, &hdr); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [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, req); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6706 | if (status) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6707 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6708 | status = decode_putfh(xdr); |
| 6709 | if (status) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6710 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6711 | status = decode_server_caps(xdr, res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6712 | out: |
| 6713 | return status; |
| 6714 | } |
| 6715 | |
| 6716 | /* |
| 6717 | * Decode RENEW response |
| 6718 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6719 | static int nfs4_xdr_dec_renew(struct rpc_rqst *rqstp, struct xdr_stream *xdr, |
| 6720 | void *__unused) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6721 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6722 | struct compound_hdr hdr; |
| 6723 | int status; |
| 6724 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6725 | status = decode_compound_hdr(xdr, &hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6726 | if (!status) |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6727 | status = decode_renew(xdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6728 | return status; |
| 6729 | } |
| 6730 | |
| 6731 | /* |
Ricardo Labiaga | 8b17321 | 2009-12-05 16:08:39 -0500 | [diff] [blame] | 6732 | * Decode SETCLIENTID response |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6733 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6734 | static int nfs4_xdr_dec_setclientid(struct rpc_rqst *req, |
| 6735 | struct xdr_stream *xdr, |
| 6736 | struct nfs4_setclientid_res *res) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6737 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6738 | struct compound_hdr hdr; |
| 6739 | int status; |
| 6740 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6741 | status = decode_compound_hdr(xdr, &hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6742 | if (!status) |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6743 | status = decode_setclientid(xdr, res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6744 | return status; |
| 6745 | } |
| 6746 | |
| 6747 | /* |
Ricardo Labiaga | 8b17321 | 2009-12-05 16:08:39 -0500 | [diff] [blame] | 6748 | * Decode SETCLIENTID_CONFIRM response |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6749 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6750 | static int nfs4_xdr_dec_setclientid_confirm(struct rpc_rqst *req, |
Chuck Lever | 83ca7f5 | 2013-03-16 15:55:53 -0400 | [diff] [blame] | 6751 | struct xdr_stream *xdr) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6752 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6753 | struct compound_hdr hdr; |
| 6754 | int status; |
| 6755 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6756 | status = decode_compound_hdr(xdr, &hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6757 | if (!status) |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6758 | status = decode_setclientid_confirm(xdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6759 | return status; |
| 6760 | } |
| 6761 | |
| 6762 | /* |
Ricardo Labiaga | 8b17321 | 2009-12-05 16:08:39 -0500 | [diff] [blame] | 6763 | * Decode DELEGRETURN response |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6764 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6765 | static int nfs4_xdr_dec_delegreturn(struct rpc_rqst *rqstp, |
| 6766 | struct xdr_stream *xdr, |
| 6767 | struct nfs4_delegreturnres *res) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6768 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6769 | struct compound_hdr hdr; |
| 6770 | int status; |
| 6771 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6772 | status = decode_compound_hdr(xdr, &hdr); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6773 | if (status) |
| 6774 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6775 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6776 | if (status) |
Trond Myklebust | fa178f2 | 2006-01-03 09:55:38 +0100 | [diff] [blame] | 6777 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6778 | status = decode_putfh(xdr); |
Trond Myklebust | fa178f2 | 2006-01-03 09:55:38 +0100 | [diff] [blame] | 6779 | if (status != 0) |
| 6780 | goto out; |
Trond Myklebust | e144cbc | 2012-04-28 16:05:03 -0400 | [diff] [blame] | 6781 | status = decode_getfattr(xdr, res->fattr, res->server); |
Jeff Layton | 556ae3b | 2010-03-21 12:10:36 -0400 | [diff] [blame] | 6782 | if (status != 0) |
| 6783 | goto out; |
Trond Myklebust | e144cbc | 2012-04-28 16:05:03 -0400 | [diff] [blame] | 6784 | status = decode_delegreturn(xdr); |
Trond Myklebust | fa178f2 | 2006-01-03 09:55:38 +0100 | [diff] [blame] | 6785 | out: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6786 | return status; |
| 6787 | } |
| 6788 | |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 6789 | /* |
Ricardo Labiaga | 8b17321 | 2009-12-05 16:08:39 -0500 | [diff] [blame] | 6790 | * Decode FS_LOCATIONS response |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 6791 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6792 | static int nfs4_xdr_dec_fs_locations(struct rpc_rqst *req, |
| 6793 | struct xdr_stream *xdr, |
Benny Halevy | 2295846 | 2009-04-01 09:22:02 -0400 | [diff] [blame] | 6794 | struct nfs4_fs_locations_res *res) |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 6795 | { |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 6796 | struct compound_hdr hdr; |
| 6797 | int status; |
| 6798 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6799 | status = decode_compound_hdr(xdr, &hdr); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6800 | if (status) |
| 6801 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6802 | status = decode_sequence(xdr, &res->seq_res, req); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6803 | if (status) |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 6804 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6805 | status = decode_putfh(xdr); |
| 6806 | if (status) |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 6807 | goto out; |
Chuck Lever | b03d735 | 2013-10-17 14:12:50 -0400 | [diff] [blame] | 6808 | if (res->migration) { |
| 6809 | xdr_enter_page(xdr, PAGE_SIZE); |
| 6810 | status = decode_getfattr_generic(xdr, |
| 6811 | &res->fs_locations->fattr, |
Trond Myklebust | 8b7e3f4 | 2012-01-30 15:43:56 -0500 | [diff] [blame] | 6812 | NULL, res->fs_locations, |
David Quigley | aa9c266 | 2013-05-22 12:50:44 -0400 | [diff] [blame] | 6813 | NULL, res->fs_locations->server); |
Chuck Lever | b03d735 | 2013-10-17 14:12:50 -0400 | [diff] [blame] | 6814 | if (status) |
| 6815 | goto out; |
| 6816 | if (res->renew) |
| 6817 | status = decode_renew(xdr); |
| 6818 | } else { |
| 6819 | status = decode_lookup(xdr); |
| 6820 | if (status) |
| 6821 | goto out; |
| 6822 | xdr_enter_page(xdr, PAGE_SIZE); |
| 6823 | status = decode_getfattr_generic(xdr, |
| 6824 | &res->fs_locations->fattr, |
| 6825 | NULL, res->fs_locations, |
| 6826 | NULL, res->fs_locations->server); |
| 6827 | } |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 6828 | out: |
| 6829 | return status; |
| 6830 | } |
| 6831 | |
Bryan Schumaker | 5a5ea0d | 2011-03-24 17:12:29 +0000 | [diff] [blame] | 6832 | /* |
| 6833 | * Decode SECINFO response |
| 6834 | */ |
| 6835 | static int nfs4_xdr_dec_secinfo(struct rpc_rqst *rqstp, |
| 6836 | struct xdr_stream *xdr, |
| 6837 | struct nfs4_secinfo_res *res) |
| 6838 | { |
| 6839 | struct compound_hdr hdr; |
| 6840 | int status; |
| 6841 | |
| 6842 | status = decode_compound_hdr(xdr, &hdr); |
| 6843 | if (status) |
| 6844 | goto out; |
| 6845 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
| 6846 | if (status) |
| 6847 | goto out; |
| 6848 | status = decode_putfh(xdr); |
| 6849 | if (status) |
| 6850 | goto out; |
| 6851 | status = decode_secinfo(xdr, res); |
Bryan Schumaker | 5a5ea0d | 2011-03-24 17:12:29 +0000 | [diff] [blame] | 6852 | out: |
| 6853 | return status; |
| 6854 | } |
| 6855 | |
Chuck Lever | 44c9993 | 2013-10-17 14:13:30 -0400 | [diff] [blame] | 6856 | /* |
| 6857 | * Decode FSID_PRESENT response |
| 6858 | */ |
| 6859 | static int nfs4_xdr_dec_fsid_present(struct rpc_rqst *rqstp, |
| 6860 | struct xdr_stream *xdr, |
| 6861 | struct nfs4_fsid_present_res *res) |
| 6862 | { |
| 6863 | struct compound_hdr hdr; |
| 6864 | int status; |
| 6865 | |
| 6866 | status = decode_compound_hdr(xdr, &hdr); |
| 6867 | if (status) |
| 6868 | goto out; |
| 6869 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
| 6870 | if (status) |
| 6871 | goto out; |
| 6872 | status = decode_putfh(xdr); |
| 6873 | if (status) |
| 6874 | goto out; |
| 6875 | status = decode_getfh(xdr, res->fh); |
| 6876 | if (status) |
| 6877 | goto out; |
| 6878 | if (res->renew) |
| 6879 | status = decode_renew(xdr); |
| 6880 | out: |
| 6881 | return status; |
| 6882 | } |
| 6883 | |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 6884 | #if defined(CONFIG_NFS_V4_1) |
| 6885 | /* |
Weston Andros Adamson | 7c44f1ae | 2012-05-24 13:22:50 -0400 | [diff] [blame] | 6886 | * Decode BIND_CONN_TO_SESSION response |
| 6887 | */ |
| 6888 | static int nfs4_xdr_dec_bind_conn_to_session(struct rpc_rqst *rqstp, |
| 6889 | struct xdr_stream *xdr, |
| 6890 | void *res) |
| 6891 | { |
| 6892 | struct compound_hdr hdr; |
| 6893 | int status; |
| 6894 | |
| 6895 | status = decode_compound_hdr(xdr, &hdr); |
| 6896 | if (!status) |
| 6897 | status = decode_bind_conn_to_session(xdr, res); |
| 6898 | return status; |
| 6899 | } |
| 6900 | |
| 6901 | /* |
Ricardo Labiaga | 8b17321 | 2009-12-05 16:08:39 -0500 | [diff] [blame] | 6902 | * Decode EXCHANGE_ID response |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 6903 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6904 | static int nfs4_xdr_dec_exchange_id(struct rpc_rqst *rqstp, |
| 6905 | struct xdr_stream *xdr, |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 6906 | void *res) |
| 6907 | { |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 6908 | struct compound_hdr hdr; |
| 6909 | int status; |
| 6910 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6911 | status = decode_compound_hdr(xdr, &hdr); |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 6912 | if (!status) |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6913 | status = decode_exchange_id(xdr, res); |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 6914 | return status; |
| 6915 | } |
Andy Adamson | 2050f0c | 2009-04-01 09:22:30 -0400 | [diff] [blame] | 6916 | |
| 6917 | /* |
Ricardo Labiaga | 8b17321 | 2009-12-05 16:08:39 -0500 | [diff] [blame] | 6918 | * Decode CREATE_SESSION response |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 6919 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6920 | static int nfs4_xdr_dec_create_session(struct rpc_rqst *rqstp, |
| 6921 | struct xdr_stream *xdr, |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 6922 | struct nfs41_create_session_res *res) |
| 6923 | { |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 6924 | struct compound_hdr hdr; |
| 6925 | int status; |
| 6926 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6927 | status = decode_compound_hdr(xdr, &hdr); |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 6928 | if (!status) |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6929 | status = decode_create_session(xdr, res); |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 6930 | return status; |
| 6931 | } |
| 6932 | |
| 6933 | /* |
Ricardo Labiaga | 8b17321 | 2009-12-05 16:08:39 -0500 | [diff] [blame] | 6934 | * Decode DESTROY_SESSION response |
Andy Adamson | 0f3e66c | 2009-04-01 09:22:34 -0400 | [diff] [blame] | 6935 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6936 | static int nfs4_xdr_dec_destroy_session(struct rpc_rqst *rqstp, |
| 6937 | struct xdr_stream *xdr, |
| 6938 | void *res) |
Andy Adamson | 0f3e66c | 2009-04-01 09:22:34 -0400 | [diff] [blame] | 6939 | { |
Andy Adamson | 0f3e66c | 2009-04-01 09:22:34 -0400 | [diff] [blame] | 6940 | struct compound_hdr hdr; |
| 6941 | int status; |
| 6942 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6943 | status = decode_compound_hdr(xdr, &hdr); |
Andy Adamson | 0f3e66c | 2009-04-01 09:22:34 -0400 | [diff] [blame] | 6944 | if (!status) |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6945 | status = decode_destroy_session(xdr, res); |
Andy Adamson | 0f3e66c | 2009-04-01 09:22:34 -0400 | [diff] [blame] | 6946 | return status; |
| 6947 | } |
| 6948 | |
| 6949 | /* |
Trond Myklebust | 6624553 | 2012-05-25 17:18:09 -0400 | [diff] [blame] | 6950 | * Decode DESTROY_CLIENTID response |
| 6951 | */ |
| 6952 | static int nfs4_xdr_dec_destroy_clientid(struct rpc_rqst *rqstp, |
| 6953 | struct xdr_stream *xdr, |
| 6954 | void *res) |
| 6955 | { |
| 6956 | struct compound_hdr hdr; |
| 6957 | int status; |
| 6958 | |
| 6959 | status = decode_compound_hdr(xdr, &hdr); |
| 6960 | if (!status) |
| 6961 | status = decode_destroy_clientid(xdr, res); |
| 6962 | return status; |
| 6963 | } |
| 6964 | |
| 6965 | /* |
Ricardo Labiaga | 8b17321 | 2009-12-05 16:08:39 -0500 | [diff] [blame] | 6966 | * Decode SEQUENCE response |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 6967 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6968 | static int nfs4_xdr_dec_sequence(struct rpc_rqst *rqstp, |
| 6969 | struct xdr_stream *xdr, |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 6970 | struct nfs4_sequence_res *res) |
| 6971 | { |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 6972 | struct compound_hdr hdr; |
| 6973 | int status; |
| 6974 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6975 | status = decode_compound_hdr(xdr, &hdr); |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 6976 | if (!status) |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6977 | status = decode_sequence(xdr, res, rqstp); |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 6978 | return status; |
| 6979 | } |
| 6980 | |
| 6981 | /* |
Ricardo Labiaga | 8b17321 | 2009-12-05 16:08:39 -0500 | [diff] [blame] | 6982 | * Decode GET_LEASE_TIME response |
Andy Adamson | 2050f0c | 2009-04-01 09:22:30 -0400 | [diff] [blame] | 6983 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6984 | static int nfs4_xdr_dec_get_lease_time(struct rpc_rqst *rqstp, |
| 6985 | struct xdr_stream *xdr, |
Andy Adamson | 2050f0c | 2009-04-01 09:22:30 -0400 | [diff] [blame] | 6986 | struct nfs4_get_lease_time_res *res) |
| 6987 | { |
Andy Adamson | 2050f0c | 2009-04-01 09:22:30 -0400 | [diff] [blame] | 6988 | struct compound_hdr hdr; |
| 6989 | int status; |
| 6990 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6991 | status = decode_compound_hdr(xdr, &hdr); |
Andy Adamson | 2050f0c | 2009-04-01 09:22:30 -0400 | [diff] [blame] | 6992 | if (!status) |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6993 | status = decode_sequence(xdr, &res->lr_seq_res, rqstp); |
Andy Adamson | 2050f0c | 2009-04-01 09:22:30 -0400 | [diff] [blame] | 6994 | if (!status) |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6995 | status = decode_putrootfh(xdr); |
Andy Adamson | 2050f0c | 2009-04-01 09:22:30 -0400 | [diff] [blame] | 6996 | if (!status) |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6997 | status = decode_fsinfo(xdr, res->lr_fsinfo); |
Andy Adamson | 2050f0c | 2009-04-01 09:22:30 -0400 | [diff] [blame] | 6998 | return status; |
| 6999 | } |
Ricardo Labiaga | 18019753 | 2009-12-05 16:08:40 -0500 | [diff] [blame] | 7000 | |
| 7001 | /* |
| 7002 | * Decode RECLAIM_COMPLETE response |
| 7003 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 7004 | static int nfs4_xdr_dec_reclaim_complete(struct rpc_rqst *rqstp, |
| 7005 | struct xdr_stream *xdr, |
Ricardo Labiaga | 18019753 | 2009-12-05 16:08:40 -0500 | [diff] [blame] | 7006 | struct nfs41_reclaim_complete_res *res) |
| 7007 | { |
Ricardo Labiaga | 18019753 | 2009-12-05 16:08:40 -0500 | [diff] [blame] | 7008 | struct compound_hdr hdr; |
| 7009 | int status; |
| 7010 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 7011 | status = decode_compound_hdr(xdr, &hdr); |
Ricardo Labiaga | 18019753 | 2009-12-05 16:08:40 -0500 | [diff] [blame] | 7012 | if (!status) |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 7013 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
Ricardo Labiaga | 18019753 | 2009-12-05 16:08:40 -0500 | [diff] [blame] | 7014 | if (!status) |
Himangi Saraogi | 8ee2b78 | 2014-06-27 00:09:09 +0530 | [diff] [blame] | 7015 | status = decode_reclaim_complete(xdr, NULL); |
Ricardo Labiaga | 18019753 | 2009-12-05 16:08:40 -0500 | [diff] [blame] | 7016 | return status; |
| 7017 | } |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 7018 | |
| 7019 | /* |
| 7020 | * Decode GETDEVINFO response |
| 7021 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 7022 | static int nfs4_xdr_dec_getdeviceinfo(struct rpc_rqst *rqstp, |
| 7023 | struct xdr_stream *xdr, |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 7024 | struct nfs4_getdeviceinfo_res *res) |
| 7025 | { |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [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); |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 7030 | if (status != 0) |
| 7031 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 7032 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 7033 | if (status != 0) |
| 7034 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 7035 | status = decode_getdeviceinfo(xdr, res->pdev); |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 7036 | out: |
| 7037 | return status; |
| 7038 | } |
| 7039 | |
| 7040 | /* |
| 7041 | * Decode LAYOUTGET response |
| 7042 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 7043 | static int nfs4_xdr_dec_layoutget(struct rpc_rqst *rqstp, |
| 7044 | struct xdr_stream *xdr, |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 7045 | struct nfs4_layoutget_res *res) |
| 7046 | { |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 7047 | struct compound_hdr hdr; |
| 7048 | int status; |
| 7049 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 7050 | status = decode_compound_hdr(xdr, &hdr); |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 7051 | if (status) |
| 7052 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 7053 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 7054 | if (status) |
| 7055 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 7056 | status = decode_putfh(xdr); |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 7057 | if (status) |
| 7058 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 7059 | status = decode_layoutget(xdr, rqstp, res); |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 7060 | out: |
| 7061 | return status; |
| 7062 | } |
Andy Adamson | 863a3c6 | 2011-03-23 13:27:54 +0000 | [diff] [blame] | 7063 | |
| 7064 | /* |
Benny Halevy | cbe8260 | 2011-05-22 19:52:37 +0300 | [diff] [blame] | 7065 | * Decode LAYOUTRETURN response |
| 7066 | */ |
| 7067 | static int nfs4_xdr_dec_layoutreturn(struct rpc_rqst *rqstp, |
| 7068 | struct xdr_stream *xdr, |
| 7069 | struct nfs4_layoutreturn_res *res) |
| 7070 | { |
| 7071 | struct compound_hdr hdr; |
| 7072 | int status; |
| 7073 | |
| 7074 | status = decode_compound_hdr(xdr, &hdr); |
| 7075 | if (status) |
| 7076 | goto out; |
| 7077 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
| 7078 | if (status) |
| 7079 | goto out; |
| 7080 | status = decode_putfh(xdr); |
| 7081 | if (status) |
| 7082 | goto out; |
| 7083 | status = decode_layoutreturn(xdr, res); |
| 7084 | out: |
| 7085 | return status; |
| 7086 | } |
| 7087 | |
| 7088 | /* |
Andy Adamson | 863a3c6 | 2011-03-23 13:27:54 +0000 | [diff] [blame] | 7089 | * Decode LAYOUTCOMMIT response |
| 7090 | */ |
| 7091 | static int nfs4_xdr_dec_layoutcommit(struct rpc_rqst *rqstp, |
| 7092 | struct xdr_stream *xdr, |
| 7093 | struct nfs4_layoutcommit_res *res) |
| 7094 | { |
| 7095 | struct compound_hdr hdr; |
| 7096 | int status; |
| 7097 | |
| 7098 | status = decode_compound_hdr(xdr, &hdr); |
| 7099 | if (status) |
| 7100 | goto out; |
| 7101 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
| 7102 | if (status) |
| 7103 | goto out; |
| 7104 | status = decode_putfh(xdr); |
| 7105 | if (status) |
| 7106 | goto out; |
| 7107 | status = decode_layoutcommit(xdr, rqstp, res); |
| 7108 | if (status) |
| 7109 | goto out; |
Trond Myklebust | 6926afd1 | 2012-01-07 13:22:46 -0500 | [diff] [blame] | 7110 | decode_getfattr(xdr, res->fattr, res->server); |
Andy Adamson | 863a3c6 | 2011-03-23 13:27:54 +0000 | [diff] [blame] | 7111 | out: |
| 7112 | return status; |
| 7113 | } |
Bryan Schumaker | fca78d6 | 2011-06-02 14:59:07 -0400 | [diff] [blame] | 7114 | |
| 7115 | /* |
| 7116 | * Decode SECINFO_NO_NAME response |
| 7117 | */ |
| 7118 | static int nfs4_xdr_dec_secinfo_no_name(struct rpc_rqst *rqstp, |
| 7119 | struct xdr_stream *xdr, |
| 7120 | struct nfs4_secinfo_res *res) |
| 7121 | { |
| 7122 | struct compound_hdr hdr; |
| 7123 | int status; |
| 7124 | |
| 7125 | status = decode_compound_hdr(xdr, &hdr); |
| 7126 | if (status) |
| 7127 | goto out; |
| 7128 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
| 7129 | if (status) |
| 7130 | goto out; |
| 7131 | status = decode_putrootfh(xdr); |
| 7132 | if (status) |
| 7133 | goto out; |
Bryan Schumaker | 31e4dda | 2012-04-27 13:27:38 -0400 | [diff] [blame] | 7134 | status = decode_secinfo_no_name(xdr, res); |
Bryan Schumaker | fca78d6 | 2011-06-02 14:59:07 -0400 | [diff] [blame] | 7135 | out: |
| 7136 | return status; |
| 7137 | } |
Bryan Schumaker | 7d97479 | 2011-06-02 14:59:08 -0400 | [diff] [blame] | 7138 | |
| 7139 | /* |
| 7140 | * Decode TEST_STATEID response |
| 7141 | */ |
| 7142 | static int nfs4_xdr_dec_test_stateid(struct rpc_rqst *rqstp, |
| 7143 | struct xdr_stream *xdr, |
| 7144 | struct nfs41_test_stateid_res *res) |
| 7145 | { |
| 7146 | struct compound_hdr hdr; |
| 7147 | int status; |
| 7148 | |
| 7149 | status = decode_compound_hdr(xdr, &hdr); |
| 7150 | if (status) |
| 7151 | goto out; |
| 7152 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
| 7153 | if (status) |
| 7154 | goto out; |
| 7155 | status = decode_test_stateid(xdr, res); |
| 7156 | out: |
| 7157 | return status; |
| 7158 | } |
Bryan Schumaker | 9aeda35 | 2011-06-02 14:59:09 -0400 | [diff] [blame] | 7159 | |
| 7160 | /* |
| 7161 | * Decode FREE_STATEID response |
| 7162 | */ |
| 7163 | static int nfs4_xdr_dec_free_stateid(struct rpc_rqst *rqstp, |
| 7164 | struct xdr_stream *xdr, |
| 7165 | struct nfs41_free_stateid_res *res) |
| 7166 | { |
| 7167 | struct compound_hdr hdr; |
| 7168 | int status; |
| 7169 | |
| 7170 | status = decode_compound_hdr(xdr, &hdr); |
| 7171 | if (status) |
| 7172 | goto out; |
| 7173 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
| 7174 | if (status) |
| 7175 | goto out; |
| 7176 | status = decode_free_stateid(xdr, res); |
| 7177 | out: |
| 7178 | return status; |
| 7179 | } |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 7180 | #endif /* CONFIG_NFS_V4_1 */ |
| 7181 | |
Chuck Lever | 573c4e1 | 2010-12-14 14:58:11 +0000 | [diff] [blame] | 7182 | /** |
| 7183 | * nfs4_decode_dirent - Decode a single NFSv4 directory entry stored in |
| 7184 | * the local page cache. |
| 7185 | * @xdr: XDR stream where entry resides |
| 7186 | * @entry: buffer to fill in with entry data |
| 7187 | * @plus: boolean indicating whether this should be a readdirplus entry |
| 7188 | * |
| 7189 | * Returns zero if successful, otherwise a negative errno value is |
| 7190 | * returned. |
| 7191 | * |
| 7192 | * This function is not invoked during READDIR reply decoding, but |
| 7193 | * rather whenever an application invokes the getdents(2) system call |
| 7194 | * on a directory already in our cache. |
| 7195 | */ |
| 7196 | int nfs4_decode_dirent(struct xdr_stream *xdr, struct nfs_entry *entry, |
| 7197 | int plus) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7198 | { |
Trond Myklebust | 256e48b | 2012-06-21 11:18:13 -0400 | [diff] [blame] | 7199 | unsigned int savep; |
Fred Isaman | dae100c | 2011-07-30 20:52:37 -0400 | [diff] [blame] | 7200 | uint32_t bitmap[3] = {0}; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7201 | uint32_t len; |
Bryan Schumaker | babddc7 | 2010-10-20 15:44:29 -0400 | [diff] [blame] | 7202 | __be32 *p = xdr_inline_decode(xdr, 4); |
| 7203 | if (unlikely(!p)) |
| 7204 | goto out_overflow; |
Chuck Lever | c08e76d | 2011-01-28 12:40:55 -0500 | [diff] [blame] | 7205 | if (*p == xdr_zero) { |
Bryan Schumaker | babddc7 | 2010-10-20 15:44:29 -0400 | [diff] [blame] | 7206 | p = xdr_inline_decode(xdr, 4); |
| 7207 | if (unlikely(!p)) |
| 7208 | goto out_overflow; |
Chuck Lever | c08e76d | 2011-01-28 12:40:55 -0500 | [diff] [blame] | 7209 | if (*p == xdr_zero) |
Chuck Lever | 573c4e1 | 2010-12-14 14:58:11 +0000 | [diff] [blame] | 7210 | return -EAGAIN; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7211 | entry->eof = 1; |
Chuck Lever | 573c4e1 | 2010-12-14 14:58:11 +0000 | [diff] [blame] | 7212 | return -EBADCOOKIE; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7213 | } |
| 7214 | |
Bryan Schumaker | babddc7 | 2010-10-20 15:44:29 -0400 | [diff] [blame] | 7215 | p = xdr_inline_decode(xdr, 12); |
| 7216 | if (unlikely(!p)) |
| 7217 | goto out_overflow; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7218 | entry->prev_cookie = entry->cookie; |
| 7219 | p = xdr_decode_hyper(p, &entry->cookie); |
Chuck Lever | c08e76d | 2011-01-28 12:40:55 -0500 | [diff] [blame] | 7220 | entry->len = be32_to_cpup(p); |
Bryan Schumaker | babddc7 | 2010-10-20 15:44:29 -0400 | [diff] [blame] | 7221 | |
Trond Myklebust | 9af8c22 | 2010-10-24 11:52:55 -0400 | [diff] [blame] | 7222 | p = xdr_inline_decode(xdr, entry->len); |
Bryan Schumaker | babddc7 | 2010-10-20 15:44:29 -0400 | [diff] [blame] | 7223 | if (unlikely(!p)) |
| 7224 | goto out_overflow; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7225 | entry->name = (const char *) p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7226 | |
| 7227 | /* |
| 7228 | * In case the server doesn't return an inode number, |
| 7229 | * we fake one here. (We don't use inode number 0, |
| 7230 | * since glibc seems to choke on it...) |
| 7231 | */ |
| 7232 | entry->ino = 1; |
Trond Myklebust | 4f08222 | 2010-10-24 13:14:02 -0400 | [diff] [blame] | 7233 | entry->fattr->valid = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7234 | |
Trond Myklebust | 9af8c22 | 2010-10-24 11:52:55 -0400 | [diff] [blame] | 7235 | if (decode_attr_bitmap(xdr, bitmap) < 0) |
Bryan Schumaker | babddc7 | 2010-10-20 15:44:29 -0400 | [diff] [blame] | 7236 | goto out_overflow; |
Trond Myklebust | 9af8c22 | 2010-10-24 11:52:55 -0400 | [diff] [blame] | 7237 | |
Trond Myklebust | 256e48b | 2012-06-21 11:18:13 -0400 | [diff] [blame] | 7238 | if (decode_attr_length(xdr, &len, &savep) < 0) |
Trond Myklebust | 9af8c22 | 2010-10-24 11:52:55 -0400 | [diff] [blame] | 7239 | goto out_overflow; |
| 7240 | |
Chuck Lever | 573c4e1 | 2010-12-14 14:58:11 +0000 | [diff] [blame] | 7241 | if (decode_getfattr_attrs(xdr, bitmap, entry->fattr, entry->fh, |
David Quigley | aa9c266 | 2013-05-22 12:50:44 -0400 | [diff] [blame] | 7242 | NULL, entry->label, entry->server) < 0) |
Trond Myklebust | 9af8c22 | 2010-10-24 11:52:55 -0400 | [diff] [blame] | 7243 | goto out_overflow; |
Trond Myklebust | 28331a4 | 2011-04-27 13:47:52 -0400 | [diff] [blame] | 7244 | if (entry->fattr->valid & NFS_ATTR_FATTR_MOUNTED_ON_FILEID) |
| 7245 | entry->ino = entry->fattr->mounted_on_fileid; |
| 7246 | else if (entry->fattr->valid & NFS_ATTR_FATTR_FILEID) |
Trond Myklebust | 9af8c22 | 2010-10-24 11:52:55 -0400 | [diff] [blame] | 7247 | entry->ino = entry->fattr->fileid; |
| 7248 | |
Trond Myklebust | 0b26a0b | 2010-11-20 14:26:44 -0500 | [diff] [blame] | 7249 | entry->d_type = DT_UNKNOWN; |
| 7250 | if (entry->fattr->valid & NFS_ATTR_FATTR_TYPE) |
| 7251 | entry->d_type = nfs_umode_to_dtype(entry->fattr->mode); |
| 7252 | |
Chuck Lever | 573c4e1 | 2010-12-14 14:58:11 +0000 | [diff] [blame] | 7253 | return 0; |
Bryan Schumaker | babddc7 | 2010-10-20 15:44:29 -0400 | [diff] [blame] | 7254 | |
| 7255 | out_overflow: |
| 7256 | print_overflow_msg(__func__, xdr); |
Chuck Lever | 573c4e1 | 2010-12-14 14:58:11 +0000 | [diff] [blame] | 7257 | return -EAGAIN; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7258 | } |
| 7259 | |
| 7260 | /* |
| 7261 | * We need to translate between nfs status return values and |
| 7262 | * the local errno values which may not be the same. |
| 7263 | */ |
| 7264 | static struct { |
| 7265 | int stat; |
| 7266 | int errno; |
| 7267 | } nfs_errtbl[] = { |
| 7268 | { NFS4_OK, 0 }, |
Benny Halevy | 856dff3 | 2008-03-31 17:39:06 +0300 | [diff] [blame] | 7269 | { NFS4ERR_PERM, -EPERM }, |
| 7270 | { NFS4ERR_NOENT, -ENOENT }, |
| 7271 | { NFS4ERR_IO, -errno_NFSERR_IO}, |
| 7272 | { NFS4ERR_NXIO, -ENXIO }, |
| 7273 | { NFS4ERR_ACCESS, -EACCES }, |
| 7274 | { NFS4ERR_EXIST, -EEXIST }, |
| 7275 | { NFS4ERR_XDEV, -EXDEV }, |
| 7276 | { NFS4ERR_NOTDIR, -ENOTDIR }, |
| 7277 | { NFS4ERR_ISDIR, -EISDIR }, |
| 7278 | { NFS4ERR_INVAL, -EINVAL }, |
| 7279 | { NFS4ERR_FBIG, -EFBIG }, |
| 7280 | { NFS4ERR_NOSPC, -ENOSPC }, |
| 7281 | { NFS4ERR_ROFS, -EROFS }, |
| 7282 | { NFS4ERR_MLINK, -EMLINK }, |
| 7283 | { NFS4ERR_NAMETOOLONG, -ENAMETOOLONG }, |
| 7284 | { NFS4ERR_NOTEMPTY, -ENOTEMPTY }, |
| 7285 | { NFS4ERR_DQUOT, -EDQUOT }, |
| 7286 | { NFS4ERR_STALE, -ESTALE }, |
| 7287 | { NFS4ERR_BADHANDLE, -EBADHANDLE }, |
Benny Halevy | 856dff3 | 2008-03-31 17:39:06 +0300 | [diff] [blame] | 7288 | { NFS4ERR_BAD_COOKIE, -EBADCOOKIE }, |
| 7289 | { NFS4ERR_NOTSUPP, -ENOTSUPP }, |
| 7290 | { NFS4ERR_TOOSMALL, -ETOOSMALL }, |
Trond Myklebust | fdcb457 | 2010-02-08 09:32:40 -0500 | [diff] [blame] | 7291 | { NFS4ERR_SERVERFAULT, -EREMOTEIO }, |
Benny Halevy | 856dff3 | 2008-03-31 17:39:06 +0300 | [diff] [blame] | 7292 | { NFS4ERR_BADTYPE, -EBADTYPE }, |
| 7293 | { NFS4ERR_LOCKED, -EAGAIN }, |
Benny Halevy | 856dff3 | 2008-03-31 17:39:06 +0300 | [diff] [blame] | 7294 | { NFS4ERR_SYMLINK, -ELOOP }, |
| 7295 | { NFS4ERR_OP_ILLEGAL, -EOPNOTSUPP }, |
| 7296 | { NFS4ERR_DEADLOCK, -EDEADLK }, |
Benny Halevy | 856dff3 | 2008-03-31 17:39:06 +0300 | [diff] [blame] | 7297 | { -1, -EIO } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7298 | }; |
| 7299 | |
| 7300 | /* |
| 7301 | * Convert an NFS error code to a local one. |
| 7302 | * This one is used jointly by NFSv2 and NFSv3. |
| 7303 | */ |
| 7304 | static int |
David Howells | 0a8ea43 | 2006-08-22 20:06:08 -0400 | [diff] [blame] | 7305 | nfs4_stat_to_errno(int stat) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7306 | { |
| 7307 | int i; |
| 7308 | for (i = 0; nfs_errtbl[i].stat != -1; i++) { |
| 7309 | if (nfs_errtbl[i].stat == stat) |
| 7310 | return nfs_errtbl[i].errno; |
| 7311 | } |
| 7312 | if (stat <= 10000 || stat > 10100) { |
| 7313 | /* The server is looney tunes. */ |
Trond Myklebust | fdcb457 | 2010-02-08 09:32:40 -0500 | [diff] [blame] | 7314 | return -EREMOTEIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7315 | } |
| 7316 | /* If we cannot translate the error, the recovery routines should |
| 7317 | * handle it. |
| 7318 | * Note: remaining NFSv4 error codes have values > 10000, so should |
| 7319 | * not conflict with native Linux error codes. |
| 7320 | */ |
Benny Halevy | 856dff3 | 2008-03-31 17:39:06 +0300 | [diff] [blame] | 7321 | return -stat; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7322 | } |
| 7323 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7324 | #define PROC(proc, argtype, restype) \ |
| 7325 | [NFSPROC4_CLNT_##proc] = { \ |
| 7326 | .p_proc = NFSPROC4_COMPOUND, \ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 7327 | .p_encode = (kxdreproc_t)nfs4_xdr_##argtype, \ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 7328 | .p_decode = (kxdrdproc_t)nfs4_xdr_##restype, \ |
Chuck Lever | 2bea90d | 2007-03-29 16:47:53 -0400 | [diff] [blame] | 7329 | .p_arglen = NFS4_##argtype##_sz, \ |
| 7330 | .p_replen = NFS4_##restype##_sz, \ |
Chuck Lever | cc0175c | 2006-03-20 13:44:22 -0500 | [diff] [blame] | 7331 | .p_statidx = NFSPROC4_CLNT_##proc, \ |
| 7332 | .p_name = #proc, \ |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 7333 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7334 | |
| 7335 | struct rpc_procinfo nfs4_procedures[] = { |
Chuck Lever | 7d93bd71 | 2010-12-14 14:57:42 +0000 | [diff] [blame] | 7336 | PROC(READ, enc_read, dec_read), |
| 7337 | PROC(WRITE, enc_write, dec_write), |
| 7338 | PROC(COMMIT, enc_commit, dec_commit), |
| 7339 | PROC(OPEN, enc_open, dec_open), |
| 7340 | PROC(OPEN_CONFIRM, enc_open_confirm, dec_open_confirm), |
| 7341 | PROC(OPEN_NOATTR, enc_open_noattr, dec_open_noattr), |
| 7342 | PROC(OPEN_DOWNGRADE, enc_open_downgrade, dec_open_downgrade), |
| 7343 | PROC(CLOSE, enc_close, dec_close), |
| 7344 | PROC(SETATTR, enc_setattr, dec_setattr), |
| 7345 | PROC(FSINFO, enc_fsinfo, dec_fsinfo), |
| 7346 | PROC(RENEW, enc_renew, dec_renew), |
| 7347 | PROC(SETCLIENTID, enc_setclientid, dec_setclientid), |
| 7348 | PROC(SETCLIENTID_CONFIRM, enc_setclientid_confirm, dec_setclientid_confirm), |
| 7349 | PROC(LOCK, enc_lock, dec_lock), |
| 7350 | PROC(LOCKT, enc_lockt, dec_lockt), |
| 7351 | PROC(LOCKU, enc_locku, dec_locku), |
| 7352 | PROC(ACCESS, enc_access, dec_access), |
| 7353 | PROC(GETATTR, enc_getattr, dec_getattr), |
| 7354 | PROC(LOOKUP, enc_lookup, dec_lookup), |
| 7355 | PROC(LOOKUP_ROOT, enc_lookup_root, dec_lookup_root), |
| 7356 | PROC(REMOVE, enc_remove, dec_remove), |
| 7357 | PROC(RENAME, enc_rename, dec_rename), |
| 7358 | PROC(LINK, enc_link, dec_link), |
| 7359 | PROC(SYMLINK, enc_symlink, dec_symlink), |
| 7360 | PROC(CREATE, enc_create, dec_create), |
| 7361 | PROC(PATHCONF, enc_pathconf, dec_pathconf), |
| 7362 | PROC(STATFS, enc_statfs, dec_statfs), |
| 7363 | PROC(READLINK, enc_readlink, dec_readlink), |
| 7364 | PROC(READDIR, enc_readdir, dec_readdir), |
| 7365 | PROC(SERVER_CAPS, enc_server_caps, dec_server_caps), |
| 7366 | PROC(DELEGRETURN, enc_delegreturn, dec_delegreturn), |
| 7367 | PROC(GETACL, enc_getacl, dec_getacl), |
| 7368 | PROC(SETACL, enc_setacl, dec_setacl), |
| 7369 | PROC(FS_LOCATIONS, enc_fs_locations, dec_fs_locations), |
| 7370 | PROC(RELEASE_LOCKOWNER, enc_release_lockowner, dec_release_lockowner), |
Bryan Schumaker | 5a5ea0d | 2011-03-24 17:12:29 +0000 | [diff] [blame] | 7371 | PROC(SECINFO, enc_secinfo, dec_secinfo), |
Chuck Lever | 44c9993 | 2013-10-17 14:13:30 -0400 | [diff] [blame] | 7372 | PROC(FSID_PRESENT, enc_fsid_present, dec_fsid_present), |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 7373 | #if defined(CONFIG_NFS_V4_1) |
Chuck Lever | 7d93bd71 | 2010-12-14 14:57:42 +0000 | [diff] [blame] | 7374 | PROC(EXCHANGE_ID, enc_exchange_id, dec_exchange_id), |
| 7375 | PROC(CREATE_SESSION, enc_create_session, dec_create_session), |
| 7376 | PROC(DESTROY_SESSION, enc_destroy_session, dec_destroy_session), |
| 7377 | PROC(SEQUENCE, enc_sequence, dec_sequence), |
| 7378 | PROC(GET_LEASE_TIME, enc_get_lease_time, dec_get_lease_time), |
| 7379 | PROC(RECLAIM_COMPLETE, enc_reclaim_complete, dec_reclaim_complete), |
| 7380 | PROC(GETDEVICEINFO, enc_getdeviceinfo, dec_getdeviceinfo), |
| 7381 | PROC(LAYOUTGET, enc_layoutget, dec_layoutget), |
Andy Adamson | 863a3c6 | 2011-03-23 13:27:54 +0000 | [diff] [blame] | 7382 | PROC(LAYOUTCOMMIT, enc_layoutcommit, dec_layoutcommit), |
Benny Halevy | cbe8260 | 2011-05-22 19:52:37 +0300 | [diff] [blame] | 7383 | PROC(LAYOUTRETURN, enc_layoutreturn, dec_layoutreturn), |
Bryan Schumaker | fca78d6 | 2011-06-02 14:59:07 -0400 | [diff] [blame] | 7384 | PROC(SECINFO_NO_NAME, enc_secinfo_no_name, dec_secinfo_no_name), |
Bryan Schumaker | 7d97479 | 2011-06-02 14:59:08 -0400 | [diff] [blame] | 7385 | PROC(TEST_STATEID, enc_test_stateid, dec_test_stateid), |
Bryan Schumaker | 9aeda35 | 2011-06-02 14:59:09 -0400 | [diff] [blame] | 7386 | PROC(FREE_STATEID, enc_free_stateid, dec_free_stateid), |
Trond Myklebust | ad24ecf | 2012-05-25 17:11:42 -0400 | [diff] [blame] | 7387 | PROC(BIND_CONN_TO_SESSION, |
| 7388 | enc_bind_conn_to_session, dec_bind_conn_to_session), |
Trond Myklebust | 6624553 | 2012-05-25 17:18:09 -0400 | [diff] [blame] | 7389 | PROC(DESTROY_CLIENTID, enc_destroy_clientid, dec_destroy_clientid), |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 7390 | #endif /* CONFIG_NFS_V4_1 */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7391 | }; |
| 7392 | |
Trond Myklebust | a613fa1 | 2012-01-20 13:53:56 -0500 | [diff] [blame] | 7393 | const struct rpc_version nfs_version4 = { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7394 | .number = 4, |
Tobias Klauser | e8c96f8 | 2006-03-24 03:15:34 -0800 | [diff] [blame] | 7395 | .nrprocs = ARRAY_SIZE(nfs4_procedures), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7396 | .procs = nfs4_procedures |
| 7397 | }; |
| 7398 | |
| 7399 | /* |
| 7400 | * Local variables: |
| 7401 | * c-basic-offset: 8 |
| 7402 | * End: |
| 7403 | */ |