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" |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 59 | #include "pnfs.h" |
Chuck Lever | f092075 | 2012-05-21 22:45:41 -0400 | [diff] [blame^] | 60 | #include "netns.h" |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 61 | |
| 62 | #define NFSDBG_FACILITY NFSDBG_XDR |
| 63 | |
| 64 | /* Mapping from NFS error code to "errno" error code. */ |
| 65 | #define errno_NFSERR_IO EIO |
| 66 | |
David Howells | 0a8ea43 | 2006-08-22 20:06:08 -0400 | [diff] [blame] | 67 | static int nfs4_stat_to_errno(int); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 68 | |
| 69 | /* NFSv4 COMPOUND tags are only wanted for debugging purposes */ |
| 70 | #ifdef DEBUG |
| 71 | #define NFS4_MAXTAGLEN 20 |
| 72 | #else |
| 73 | #define NFS4_MAXTAGLEN 0 |
| 74 | #endif |
| 75 | |
Andy Adamson | 6c0195a | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 76 | /* lock,open owner id: |
Trond Myklebust | 9f958ab | 2007-07-02 13:58:33 -0400 | [diff] [blame] | 77 | * we currently use size 2 (u64) out of (NFS4_OPAQUE_LIMIT >> 2) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 78 | */ |
Trond Myklebust | 95b72eb | 2012-04-20 19:24:51 -0400 | [diff] [blame] | 79 | #define open_owner_id_maxsz (1 + 2 + 1 + 1 + 2) |
Trond Myklebust | d035c36 | 2010-12-21 10:45:27 -0500 | [diff] [blame] | 80 | #define lock_owner_id_maxsz (1 + 1 + 4) |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 81 | #define decode_lockowner_maxsz (1 + XDR_QUADLEN(IDMAP_NAMESZ)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 82 | #define compound_encode_hdr_maxsz (3 + (NFS4_MAXTAGLEN >> 2)) |
| 83 | #define compound_decode_hdr_maxsz (3 + (NFS4_MAXTAGLEN >> 2)) |
| 84 | #define op_encode_hdr_maxsz (1) |
| 85 | #define op_decode_hdr_maxsz (2) |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 86 | #define encode_stateid_maxsz (XDR_QUADLEN(NFS4_STATEID_SIZE)) |
| 87 | #define decode_stateid_maxsz (XDR_QUADLEN(NFS4_STATEID_SIZE)) |
| 88 | #define encode_verifier_maxsz (XDR_QUADLEN(NFS4_VERIFIER_SIZE)) |
| 89 | #define decode_verifier_maxsz (XDR_QUADLEN(NFS4_VERIFIER_SIZE)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 90 | #define encode_putfh_maxsz (op_encode_hdr_maxsz + 1 + \ |
| 91 | (NFS4_FHSIZE >> 2)) |
| 92 | #define decode_putfh_maxsz (op_decode_hdr_maxsz) |
| 93 | #define encode_putrootfh_maxsz (op_encode_hdr_maxsz) |
| 94 | #define decode_putrootfh_maxsz (op_decode_hdr_maxsz) |
| 95 | #define encode_getfh_maxsz (op_encode_hdr_maxsz) |
| 96 | #define decode_getfh_maxsz (op_decode_hdr_maxsz + 1 + \ |
| 97 | ((3+NFS4_FHSIZE) >> 2)) |
Andy Adamson | e5012d1 | 2011-07-11 17:17:42 -0400 | [diff] [blame] | 98 | #define nfs4_fattr_bitmap_maxsz 4 |
J. Bruce Fields | 9692820 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 99 | #define encode_getattr_maxsz (op_encode_hdr_maxsz + nfs4_fattr_bitmap_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 100 | #define nfs4_name_maxsz (1 + ((3 + NFS4_MAXNAMLEN) >> 2)) |
| 101 | #define nfs4_path_maxsz (1 + ((3 + NFS4_MAXPATHLEN) >> 2)) |
Trond Myklebust | bd625ba | 2007-07-08 18:38:23 -0400 | [diff] [blame] | 102 | #define nfs4_owner_maxsz (1 + XDR_QUADLEN(IDMAP_NAMESZ)) |
| 103 | #define nfs4_group_maxsz (1 + XDR_QUADLEN(IDMAP_NAMESZ)) |
J. Bruce Fields | 9692820 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 104 | /* This is based on getfattr, which uses the most attributes: */ |
| 105 | #define nfs4_fattr_value_maxsz (1 + (1 + 2 + 2 + 4 + 2 + 1 + 1 + 2 + 2 + \ |
Trond Myklebust | bd625ba | 2007-07-08 18:38:23 -0400 | [diff] [blame] | 106 | 3 + 3 + 3 + nfs4_owner_maxsz + nfs4_group_maxsz)) |
J. Bruce Fields | 9692820 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 107 | #define nfs4_fattr_maxsz (nfs4_fattr_bitmap_maxsz + \ |
| 108 | nfs4_fattr_value_maxsz) |
| 109 | #define decode_getattr_maxsz (op_decode_hdr_maxsz + nfs4_fattr_maxsz) |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 110 | #define encode_attrs_maxsz (nfs4_fattr_bitmap_maxsz + \ |
| 111 | 1 + 2 + 1 + \ |
| 112 | nfs4_owner_maxsz + \ |
| 113 | nfs4_group_maxsz + \ |
| 114 | 4 + 4) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 115 | #define encode_savefh_maxsz (op_encode_hdr_maxsz) |
| 116 | #define decode_savefh_maxsz (op_decode_hdr_maxsz) |
Trond Myklebust | 56ae19f | 2005-10-27 22:12:40 -0400 | [diff] [blame] | 117 | #define encode_restorefh_maxsz (op_encode_hdr_maxsz) |
| 118 | #define decode_restorefh_maxsz (op_decode_hdr_maxsz) |
Fred Isaman | 2f42b5d | 2008-03-13 15:26:30 +0200 | [diff] [blame] | 119 | #define encode_fsinfo_maxsz (encode_getattr_maxsz) |
Fred Isaman | dae100c | 2011-07-30 20:52:37 -0400 | [diff] [blame] | 120 | /* The 5 accounts for the PNFS attributes, and assumes that at most three |
| 121 | * layout types will be returned. |
| 122 | */ |
| 123 | #define decode_fsinfo_maxsz (op_decode_hdr_maxsz + \ |
| 124 | nfs4_fattr_bitmap_maxsz + 4 + 8 + 5) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 125 | #define encode_renew_maxsz (op_encode_hdr_maxsz + 3) |
| 126 | #define decode_renew_maxsz (op_decode_hdr_maxsz) |
| 127 | #define encode_setclientid_maxsz \ |
| 128 | (op_encode_hdr_maxsz + \ |
Chuck Lever | cc38bac | 2007-12-10 14:56:54 -0500 | [diff] [blame] | 129 | XDR_QUADLEN(NFS4_VERIFIER_SIZE) + \ |
| 130 | XDR_QUADLEN(NFS4_SETCLIENTID_NAMELEN) + \ |
| 131 | 1 /* sc_prog */ + \ |
| 132 | XDR_QUADLEN(RPCBIND_MAXNETIDLEN) + \ |
| 133 | XDR_QUADLEN(RPCBIND_MAXUADDRLEN) + \ |
| 134 | 1) /* sc_cb_ident */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 135 | #define decode_setclientid_maxsz \ |
| 136 | (op_decode_hdr_maxsz + \ |
| 137 | 2 + \ |
| 138 | 1024) /* large value for CLID_INUSE */ |
| 139 | #define encode_setclientid_confirm_maxsz \ |
| 140 | (op_encode_hdr_maxsz + \ |
| 141 | 3 + (NFS4_VERIFIER_SIZE >> 2)) |
| 142 | #define decode_setclientid_confirm_maxsz \ |
| 143 | (op_decode_hdr_maxsz) |
Trond Myklebust | e688962 | 2007-07-02 13:58:30 -0400 | [diff] [blame] | 144 | #define encode_lookup_maxsz (op_encode_hdr_maxsz + nfs4_name_maxsz) |
| 145 | #define decode_lookup_maxsz (op_decode_hdr_maxsz) |
Trond Myklebust | 2cebf82 | 2007-07-02 13:57:28 -0400 | [diff] [blame] | 146 | #define encode_share_access_maxsz \ |
| 147 | (2) |
Alexandros Batsakis | 4882ef7 | 2009-12-05 13:30:21 -0500 | [diff] [blame] | 148 | #define encode_createmode_maxsz (1 + encode_attrs_maxsz + encode_verifier_maxsz) |
Trond Myklebust | 2cebf82 | 2007-07-02 13:57:28 -0400 | [diff] [blame] | 149 | #define encode_opentype_maxsz (1 + encode_createmode_maxsz) |
| 150 | #define encode_claim_null_maxsz (1 + nfs4_name_maxsz) |
| 151 | #define encode_open_maxsz (op_encode_hdr_maxsz + \ |
| 152 | 2 + encode_share_access_maxsz + 2 + \ |
| 153 | open_owner_id_maxsz + \ |
| 154 | encode_opentype_maxsz + \ |
| 155 | encode_claim_null_maxsz) |
| 156 | #define decode_ace_maxsz (3 + nfs4_owner_maxsz) |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 157 | #define decode_delegation_maxsz (1 + decode_stateid_maxsz + 1 + \ |
Trond Myklebust | 2cebf82 | 2007-07-02 13:57:28 -0400 | [diff] [blame] | 158 | decode_ace_maxsz) |
| 159 | #define decode_change_info_maxsz (5) |
| 160 | #define decode_open_maxsz (op_decode_hdr_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 161 | decode_stateid_maxsz + \ |
Trond Myklebust | 2cebf82 | 2007-07-02 13:57:28 -0400 | [diff] [blame] | 162 | decode_change_info_maxsz + 1 + \ |
| 163 | nfs4_fattr_bitmap_maxsz + \ |
| 164 | decode_delegation_maxsz) |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 165 | #define encode_open_confirm_maxsz \ |
| 166 | (op_encode_hdr_maxsz + \ |
| 167 | encode_stateid_maxsz + 1) |
| 168 | #define decode_open_confirm_maxsz \ |
| 169 | (op_decode_hdr_maxsz + \ |
| 170 | decode_stateid_maxsz) |
| 171 | #define encode_open_downgrade_maxsz \ |
| 172 | (op_encode_hdr_maxsz + \ |
| 173 | encode_stateid_maxsz + 1 + \ |
| 174 | encode_share_access_maxsz) |
| 175 | #define decode_open_downgrade_maxsz \ |
| 176 | (op_decode_hdr_maxsz + \ |
| 177 | decode_stateid_maxsz) |
| 178 | #define encode_close_maxsz (op_encode_hdr_maxsz + \ |
| 179 | 1 + encode_stateid_maxsz) |
| 180 | #define decode_close_maxsz (op_decode_hdr_maxsz + \ |
| 181 | decode_stateid_maxsz) |
| 182 | #define encode_setattr_maxsz (op_encode_hdr_maxsz + \ |
| 183 | encode_stateid_maxsz + \ |
| 184 | encode_attrs_maxsz) |
| 185 | #define decode_setattr_maxsz (op_decode_hdr_maxsz + \ |
| 186 | nfs4_fattr_bitmap_maxsz) |
| 187 | #define encode_read_maxsz (op_encode_hdr_maxsz + \ |
| 188 | encode_stateid_maxsz + 3) |
| 189 | #define decode_read_maxsz (op_decode_hdr_maxsz + 2) |
| 190 | #define encode_readdir_maxsz (op_encode_hdr_maxsz + \ |
| 191 | 2 + encode_verifier_maxsz + 5) |
| 192 | #define decode_readdir_maxsz (op_decode_hdr_maxsz + \ |
| 193 | decode_verifier_maxsz) |
| 194 | #define encode_readlink_maxsz (op_encode_hdr_maxsz) |
| 195 | #define decode_readlink_maxsz (op_decode_hdr_maxsz + 1) |
| 196 | #define encode_write_maxsz (op_encode_hdr_maxsz + \ |
| 197 | encode_stateid_maxsz + 4) |
| 198 | #define decode_write_maxsz (op_decode_hdr_maxsz + \ |
| 199 | 2 + decode_verifier_maxsz) |
| 200 | #define encode_commit_maxsz (op_encode_hdr_maxsz + 3) |
| 201 | #define decode_commit_maxsz (op_decode_hdr_maxsz + \ |
| 202 | decode_verifier_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 203 | #define encode_remove_maxsz (op_encode_hdr_maxsz + \ |
| 204 | nfs4_name_maxsz) |
Benny Halevy | 6ce1839 | 2009-04-01 09:22:06 -0400 | [diff] [blame] | 205 | #define decode_remove_maxsz (op_decode_hdr_maxsz + \ |
| 206 | decode_change_info_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 207 | #define encode_rename_maxsz (op_encode_hdr_maxsz + \ |
| 208 | 2 * nfs4_name_maxsz) |
Benny Halevy | 6ce1839 | 2009-04-01 09:22:06 -0400 | [diff] [blame] | 209 | #define decode_rename_maxsz (op_decode_hdr_maxsz + \ |
| 210 | decode_change_info_maxsz + \ |
| 211 | decode_change_info_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 212 | #define encode_link_maxsz (op_encode_hdr_maxsz + \ |
| 213 | nfs4_name_maxsz) |
Benny Halevy | 6ce1839 | 2009-04-01 09:22:06 -0400 | [diff] [blame] | 214 | #define decode_link_maxsz (op_decode_hdr_maxsz + decode_change_info_maxsz) |
Trond Myklebust | daccbde | 2010-06-25 18:11:43 -0400 | [diff] [blame] | 215 | #define encode_lockowner_maxsz (7) |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 216 | #define encode_lock_maxsz (op_encode_hdr_maxsz + \ |
| 217 | 7 + \ |
Trond Myklebust | daccbde | 2010-06-25 18:11:43 -0400 | [diff] [blame] | 218 | 1 + encode_stateid_maxsz + 1 + \ |
| 219 | encode_lockowner_maxsz) |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 220 | #define decode_lock_denied_maxsz \ |
| 221 | (8 + decode_lockowner_maxsz) |
| 222 | #define decode_lock_maxsz (op_decode_hdr_maxsz + \ |
| 223 | decode_lock_denied_maxsz) |
Trond Myklebust | daccbde | 2010-06-25 18:11:43 -0400 | [diff] [blame] | 224 | #define encode_lockt_maxsz (op_encode_hdr_maxsz + 5 + \ |
| 225 | encode_lockowner_maxsz) |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 226 | #define decode_lockt_maxsz (op_decode_hdr_maxsz + \ |
| 227 | decode_lock_denied_maxsz) |
| 228 | #define encode_locku_maxsz (op_encode_hdr_maxsz + 3 + \ |
| 229 | encode_stateid_maxsz + \ |
| 230 | 4) |
| 231 | #define decode_locku_maxsz (op_decode_hdr_maxsz + \ |
| 232 | decode_stateid_maxsz) |
Trond Myklebust | d3c7b7c | 2010-07-01 12:49:01 -0400 | [diff] [blame] | 233 | #define encode_release_lockowner_maxsz \ |
| 234 | (op_encode_hdr_maxsz + \ |
| 235 | encode_lockowner_maxsz) |
| 236 | #define decode_release_lockowner_maxsz \ |
| 237 | (op_decode_hdr_maxsz) |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 238 | #define encode_access_maxsz (op_encode_hdr_maxsz + 1) |
| 239 | #define decode_access_maxsz (op_decode_hdr_maxsz + 2) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 240 | #define encode_symlink_maxsz (op_encode_hdr_maxsz + \ |
| 241 | 1 + nfs4_name_maxsz + \ |
Chuck Lever | 94a6d75 | 2006-08-22 20:06:23 -0400 | [diff] [blame] | 242 | 1 + \ |
J. Bruce Fields | 9692820 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 243 | nfs4_fattr_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 244 | #define decode_symlink_maxsz (op_decode_hdr_maxsz + 8) |
| 245 | #define encode_create_maxsz (op_encode_hdr_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 246 | 1 + 2 + nfs4_name_maxsz + \ |
| 247 | encode_attrs_maxsz) |
Trond Myklebust | 2cebf82 | 2007-07-02 13:57:28 -0400 | [diff] [blame] | 248 | #define decode_create_maxsz (op_decode_hdr_maxsz + \ |
| 249 | decode_change_info_maxsz + \ |
| 250 | nfs4_fattr_bitmap_maxsz) |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 251 | #define encode_statfs_maxsz (encode_getattr_maxsz) |
| 252 | #define decode_statfs_maxsz (decode_getattr_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 253 | #define encode_delegreturn_maxsz (op_encode_hdr_maxsz + 4) |
| 254 | #define decode_delegreturn_maxsz (op_decode_hdr_maxsz) |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 255 | #define encode_getacl_maxsz (encode_getattr_maxsz) |
| 256 | #define decode_getacl_maxsz (op_decode_hdr_maxsz + \ |
| 257 | nfs4_fattr_bitmap_maxsz + 1) |
| 258 | #define encode_setacl_maxsz (op_encode_hdr_maxsz + \ |
| 259 | encode_stateid_maxsz + 3) |
| 260 | #define decode_setacl_maxsz (decode_setattr_maxsz) |
Trond Myklebust | e688962 | 2007-07-02 13:58:30 -0400 | [diff] [blame] | 261 | #define encode_fs_locations_maxsz \ |
| 262 | (encode_getattr_maxsz) |
| 263 | #define decode_fs_locations_maxsz \ |
| 264 | (0) |
Bryan Schumaker | 5a5ea0d | 2011-03-24 17:12:29 +0000 | [diff] [blame] | 265 | #define encode_secinfo_maxsz (op_encode_hdr_maxsz + nfs4_name_maxsz) |
Bryan Schumaker | 1650add | 2011-06-02 15:07:35 -0400 | [diff] [blame] | 266 | #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] | 267 | |
| 268 | #if defined(CONFIG_NFS_V4_1) |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 269 | #define NFS4_MAX_MACHINE_NAME_LEN (64) |
| 270 | |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 271 | #define encode_exchange_id_maxsz (op_encode_hdr_maxsz + \ |
| 272 | encode_verifier_maxsz + \ |
| 273 | 1 /* co_ownerid.len */ + \ |
| 274 | XDR_QUADLEN(NFS4_EXCHANGE_ID_LEN) + \ |
| 275 | 1 /* flags */ + \ |
| 276 | 1 /* spa_how */ + \ |
| 277 | 0 /* SP4_NONE (for now) */ + \ |
Weston Andros Adamson | db8ac8b | 2012-02-17 15:20:24 -0500 | [diff] [blame] | 278 | 1 /* implementation id array of size 1 */ + \ |
| 279 | 1 /* nii_domain */ + \ |
| 280 | XDR_QUADLEN(NFS4_OPAQUE_LIMIT) + \ |
| 281 | 1 /* nii_name */ + \ |
| 282 | XDR_QUADLEN(NFS4_OPAQUE_LIMIT) + \ |
| 283 | 3 /* nii_date */) |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 284 | #define decode_exchange_id_maxsz (op_decode_hdr_maxsz + \ |
| 285 | 2 /* eir_clientid */ + \ |
| 286 | 1 /* eir_sequenceid */ + \ |
| 287 | 1 /* eir_flags */ + \ |
| 288 | 1 /* spr_how */ + \ |
| 289 | 0 /* SP4_NONE (for now) */ + \ |
| 290 | 2 /* eir_server_owner.so_minor_id */ + \ |
| 291 | /* eir_server_owner.so_major_id<> */ \ |
| 292 | XDR_QUADLEN(NFS4_OPAQUE_LIMIT) + 1 + \ |
| 293 | /* eir_server_scope<> */ \ |
| 294 | XDR_QUADLEN(NFS4_OPAQUE_LIMIT) + 1 + \ |
| 295 | 1 /* eir_server_impl_id array length */ + \ |
Weston Andros Adamson | 7d2ed9a | 2012-02-17 15:20:26 -0500 | [diff] [blame] | 296 | 1 /* nii_domain */ + \ |
| 297 | XDR_QUADLEN(NFS4_OPAQUE_LIMIT) + \ |
| 298 | 1 /* nii_name */ + \ |
| 299 | XDR_QUADLEN(NFS4_OPAQUE_LIMIT) + \ |
| 300 | 3 /* nii_date */) |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 301 | #define encode_channel_attrs_maxsz (6 + 1 /* ca_rdma_ird.len (0) */) |
| 302 | #define decode_channel_attrs_maxsz (6 + \ |
| 303 | 1 /* ca_rdma_ird.len */ + \ |
| 304 | 1 /* ca_rdma_ird */) |
| 305 | #define encode_create_session_maxsz (op_encode_hdr_maxsz + \ |
| 306 | 2 /* csa_clientid */ + \ |
| 307 | 1 /* csa_sequence */ + \ |
| 308 | 1 /* csa_flags */ + \ |
| 309 | encode_channel_attrs_maxsz + \ |
| 310 | encode_channel_attrs_maxsz + \ |
| 311 | 1 /* csa_cb_program */ + \ |
| 312 | 1 /* csa_sec_parms.len (1) */ + \ |
| 313 | 1 /* cb_secflavor (AUTH_SYS) */ + \ |
| 314 | 1 /* stamp */ + \ |
| 315 | 1 /* machinename.len */ + \ |
| 316 | XDR_QUADLEN(NFS4_MAX_MACHINE_NAME_LEN) + \ |
| 317 | 1 /* uid */ + \ |
| 318 | 1 /* gid */ + \ |
| 319 | 1 /* gids.len (0) */) |
| 320 | #define decode_create_session_maxsz (op_decode_hdr_maxsz + \ |
| 321 | XDR_QUADLEN(NFS4_MAX_SESSIONID_LEN) + \ |
| 322 | 1 /* csr_sequence */ + \ |
| 323 | 1 /* csr_flags */ + \ |
| 324 | decode_channel_attrs_maxsz + \ |
| 325 | decode_channel_attrs_maxsz) |
Andy Adamson | 0f3e66c | 2009-04-01 09:22:34 -0400 | [diff] [blame] | 326 | #define encode_destroy_session_maxsz (op_encode_hdr_maxsz + 4) |
| 327 | #define decode_destroy_session_maxsz (op_decode_hdr_maxsz) |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 328 | #define encode_sequence_maxsz (op_encode_hdr_maxsz + \ |
| 329 | XDR_QUADLEN(NFS4_MAX_SESSIONID_LEN) + 4) |
| 330 | #define decode_sequence_maxsz (op_decode_hdr_maxsz + \ |
| 331 | XDR_QUADLEN(NFS4_MAX_SESSIONID_LEN) + 5) |
Ricardo Labiaga | 18019753 | 2009-12-05 16:08:40 -0500 | [diff] [blame] | 332 | #define encode_reclaim_complete_maxsz (op_encode_hdr_maxsz + 4) |
| 333 | #define decode_reclaim_complete_maxsz (op_decode_hdr_maxsz + 4) |
Andy Adamson | 7f11d8d | 2011-07-30 20:52:35 -0400 | [diff] [blame] | 334 | #define encode_getdevicelist_maxsz (op_encode_hdr_maxsz + 4 + \ |
| 335 | encode_verifier_maxsz) |
| 336 | #define decode_getdevicelist_maxsz (op_decode_hdr_maxsz + \ |
| 337 | 2 /* nfs_cookie4 gdlr_cookie */ + \ |
| 338 | decode_verifier_maxsz \ |
| 339 | /* verifier4 gdlr_verifier */ + \ |
| 340 | 1 /* gdlr_deviceid_list count */ + \ |
| 341 | XDR_QUADLEN(NFS4_PNFS_GETDEVLIST_MAXNUM * \ |
| 342 | NFS4_DEVICEID4_SIZE) \ |
| 343 | /* gdlr_deviceid_list */ + \ |
| 344 | 1 /* bool gdlr_eof */) |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 345 | #define encode_getdeviceinfo_maxsz (op_encode_hdr_maxsz + 4 + \ |
| 346 | XDR_QUADLEN(NFS4_DEVICEID4_SIZE)) |
| 347 | #define decode_getdeviceinfo_maxsz (op_decode_hdr_maxsz + \ |
| 348 | 1 /* layout type */ + \ |
| 349 | 1 /* opaque devaddr4 length */ + \ |
| 350 | /* devaddr4 payload is read into page */ \ |
| 351 | 1 /* notification bitmap length */ + \ |
| 352 | 1 /* notification bitmap */) |
| 353 | #define encode_layoutget_maxsz (op_encode_hdr_maxsz + 10 + \ |
| 354 | encode_stateid_maxsz) |
| 355 | #define decode_layoutget_maxsz (op_decode_hdr_maxsz + 8 + \ |
| 356 | decode_stateid_maxsz + \ |
| 357 | XDR_QUADLEN(PNFS_LAYOUT_MAXSIZE)) |
Andy Adamson | 863a3c6 | 2011-03-23 13:27:54 +0000 | [diff] [blame] | 358 | #define encode_layoutcommit_maxsz (op_encode_hdr_maxsz + \ |
| 359 | 2 /* offset */ + \ |
| 360 | 2 /* length */ + \ |
| 361 | 1 /* reclaim */ + \ |
| 362 | encode_stateid_maxsz + \ |
| 363 | 1 /* new offset (true) */ + \ |
| 364 | 2 /* last byte written */ + \ |
| 365 | 1 /* nt_timechanged (false) */ + \ |
| 366 | 1 /* layoutupdate4 layout type */ + \ |
| 367 | 1 /* NULL filelayout layoutupdate4 payload */) |
| 368 | #define decode_layoutcommit_maxsz (op_decode_hdr_maxsz + 3) |
Benny Halevy | cbe8260 | 2011-05-22 19:52:37 +0300 | [diff] [blame] | 369 | #define encode_layoutreturn_maxsz (8 + op_encode_hdr_maxsz + \ |
| 370 | encode_stateid_maxsz + \ |
| 371 | 1 /* FIXME: opaque lrf_body always empty at the moment */) |
| 372 | #define decode_layoutreturn_maxsz (op_decode_hdr_maxsz + \ |
| 373 | 1 + decode_stateid_maxsz) |
Bryan Schumaker | fca78d6 | 2011-06-02 14:59:07 -0400 | [diff] [blame] | 374 | #define encode_secinfo_no_name_maxsz (op_encode_hdr_maxsz + 1) |
| 375 | #define decode_secinfo_no_name_maxsz decode_secinfo_maxsz |
Bryan Schumaker | 7d97479 | 2011-06-02 14:59:08 -0400 | [diff] [blame] | 376 | #define encode_test_stateid_maxsz (op_encode_hdr_maxsz + 2 + \ |
| 377 | XDR_QUADLEN(NFS4_STATEID_SIZE)) |
| 378 | #define decode_test_stateid_maxsz (op_decode_hdr_maxsz + 2 + 1) |
Bryan Schumaker | 9aeda35 | 2011-06-02 14:59:09 -0400 | [diff] [blame] | 379 | #define encode_free_stateid_maxsz (op_encode_hdr_maxsz + 1 + \ |
| 380 | XDR_QUADLEN(NFS4_STATEID_SIZE)) |
| 381 | #define decode_free_stateid_maxsz (op_decode_hdr_maxsz + 1) |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 382 | #else /* CONFIG_NFS_V4_1 */ |
| 383 | #define encode_sequence_maxsz 0 |
| 384 | #define decode_sequence_maxsz 0 |
| 385 | #endif /* CONFIG_NFS_V4_1 */ |
| 386 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 387 | #define NFS4_enc_compound_sz (1024) /* XXX: large enough? */ |
| 388 | #define NFS4_dec_compound_sz (1024) /* XXX: large enough? */ |
| 389 | #define NFS4_enc_read_sz (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 390 | encode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 391 | encode_putfh_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 392 | encode_read_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 393 | #define NFS4_dec_read_sz (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 394 | decode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 395 | decode_putfh_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 396 | decode_read_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 397 | #define NFS4_enc_readlink_sz (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 398 | encode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 399 | encode_putfh_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 400 | encode_readlink_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 401 | #define NFS4_dec_readlink_sz (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 402 | decode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 403 | decode_putfh_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 404 | decode_readlink_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 405 | #define NFS4_enc_readdir_sz (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 406 | encode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 407 | encode_putfh_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 408 | encode_readdir_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 409 | #define NFS4_dec_readdir_sz (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 410 | decode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 411 | decode_putfh_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 412 | decode_readdir_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 413 | #define NFS4_enc_write_sz (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 414 | encode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 415 | encode_putfh_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 416 | encode_write_maxsz + \ |
Trond Myklebust | 4f9838c | 2005-10-27 22:12:44 -0400 | [diff] [blame] | 417 | encode_getattr_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 418 | #define NFS4_dec_write_sz (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 419 | decode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 420 | decode_putfh_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 421 | decode_write_maxsz + \ |
Trond Myklebust | 4f9838c | 2005-10-27 22:12:44 -0400 | [diff] [blame] | 422 | decode_getattr_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 423 | #define NFS4_enc_commit_sz (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 424 | encode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 425 | encode_putfh_maxsz + \ |
Trond Myklebust | 8582715 | 2012-04-29 10:44:42 -0400 | [diff] [blame] | 426 | encode_commit_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 427 | #define NFS4_dec_commit_sz (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 428 | decode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 429 | decode_putfh_maxsz + \ |
Trond Myklebust | 8582715 | 2012-04-29 10:44:42 -0400 | [diff] [blame] | 430 | decode_commit_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 431 | #define NFS4_enc_open_sz (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 432 | encode_sequence_maxsz + \ |
Trond Myklebust | 2cebf82 | 2007-07-02 13:57:28 -0400 | [diff] [blame] | 433 | encode_putfh_maxsz + \ |
Trond Myklebust | 2cebf82 | 2007-07-02 13:57:28 -0400 | [diff] [blame] | 434 | encode_open_maxsz + \ |
| 435 | encode_getfh_maxsz + \ |
Trond Myklebust | 2cebf82 | 2007-07-02 13:57:28 -0400 | [diff] [blame] | 436 | encode_getattr_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 437 | #define NFS4_dec_open_sz (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 438 | decode_sequence_maxsz + \ |
Trond Myklebust | 2cebf82 | 2007-07-02 13:57:28 -0400 | [diff] [blame] | 439 | decode_putfh_maxsz + \ |
Trond Myklebust | 2cebf82 | 2007-07-02 13:57:28 -0400 | [diff] [blame] | 440 | decode_open_maxsz + \ |
| 441 | decode_getfh_maxsz + \ |
Trond Myklebust | 2cebf82 | 2007-07-02 13:57:28 -0400 | [diff] [blame] | 442 | decode_getattr_maxsz) |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 443 | #define NFS4_enc_open_confirm_sz \ |
| 444 | (compound_encode_hdr_maxsz + \ |
| 445 | encode_putfh_maxsz + \ |
| 446 | encode_open_confirm_maxsz) |
| 447 | #define NFS4_dec_open_confirm_sz \ |
| 448 | (compound_decode_hdr_maxsz + \ |
| 449 | decode_putfh_maxsz + \ |
| 450 | decode_open_confirm_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 451 | #define NFS4_enc_open_noattr_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 | 2cebf82 | 2007-07-02 13:57:28 -0400 | [diff] [blame] | 454 | encode_open_maxsz + \ |
| 455 | encode_getattr_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 456 | #define NFS4_dec_open_noattr_sz (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 457 | decode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 458 | decode_putfh_maxsz + \ |
Trond Myklebust | 2cebf82 | 2007-07-02 13:57:28 -0400 | [diff] [blame] | 459 | decode_open_maxsz + \ |
| 460 | decode_getattr_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 461 | #define NFS4_enc_open_downgrade_sz \ |
| 462 | (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 463 | encode_sequence_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 464 | encode_putfh_maxsz + \ |
| 465 | encode_open_downgrade_maxsz + \ |
| 466 | encode_getattr_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 467 | #define NFS4_dec_open_downgrade_sz \ |
| 468 | (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 469 | decode_sequence_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 470 | decode_putfh_maxsz + \ |
| 471 | decode_open_downgrade_maxsz + \ |
| 472 | decode_getattr_maxsz) |
| 473 | #define NFS4_enc_close_sz (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 474 | encode_sequence_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 475 | encode_putfh_maxsz + \ |
| 476 | encode_close_maxsz + \ |
| 477 | encode_getattr_maxsz) |
| 478 | #define NFS4_dec_close_sz (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 479 | decode_sequence_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 480 | decode_putfh_maxsz + \ |
| 481 | decode_close_maxsz + \ |
| 482 | decode_getattr_maxsz) |
| 483 | #define NFS4_enc_setattr_sz (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 484 | encode_sequence_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 485 | encode_putfh_maxsz + \ |
| 486 | encode_setattr_maxsz + \ |
| 487 | encode_getattr_maxsz) |
| 488 | #define NFS4_dec_setattr_sz (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 489 | decode_sequence_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 490 | decode_putfh_maxsz + \ |
| 491 | decode_setattr_maxsz + \ |
| 492 | decode_getattr_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 493 | #define NFS4_enc_fsinfo_sz (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 494 | encode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 495 | encode_putfh_maxsz + \ |
| 496 | encode_fsinfo_maxsz) |
| 497 | #define NFS4_dec_fsinfo_sz (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 498 | decode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 499 | decode_putfh_maxsz + \ |
| 500 | decode_fsinfo_maxsz) |
| 501 | #define NFS4_enc_renew_sz (compound_encode_hdr_maxsz + \ |
| 502 | encode_renew_maxsz) |
| 503 | #define NFS4_dec_renew_sz (compound_decode_hdr_maxsz + \ |
| 504 | decode_renew_maxsz) |
| 505 | #define NFS4_enc_setclientid_sz (compound_encode_hdr_maxsz + \ |
| 506 | encode_setclientid_maxsz) |
| 507 | #define NFS4_dec_setclientid_sz (compound_decode_hdr_maxsz + \ |
| 508 | decode_setclientid_maxsz) |
| 509 | #define NFS4_enc_setclientid_confirm_sz \ |
| 510 | (compound_encode_hdr_maxsz + \ |
| 511 | encode_setclientid_confirm_maxsz + \ |
| 512 | encode_putrootfh_maxsz + \ |
| 513 | encode_fsinfo_maxsz) |
| 514 | #define NFS4_dec_setclientid_confirm_sz \ |
| 515 | (compound_decode_hdr_maxsz + \ |
| 516 | decode_setclientid_confirm_maxsz + \ |
| 517 | decode_putrootfh_maxsz + \ |
| 518 | decode_fsinfo_maxsz) |
| 519 | #define NFS4_enc_lock_sz (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 520 | encode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 521 | encode_putfh_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 522 | encode_lock_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 523 | #define NFS4_dec_lock_sz (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 524 | decode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 525 | decode_putfh_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 526 | decode_lock_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 527 | #define NFS4_enc_lockt_sz (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 528 | encode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 529 | encode_putfh_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 530 | encode_lockt_maxsz) |
| 531 | #define NFS4_dec_lockt_sz (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 532 | decode_sequence_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 533 | decode_putfh_maxsz + \ |
| 534 | decode_lockt_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 535 | #define NFS4_enc_locku_sz (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 536 | encode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 537 | encode_putfh_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 538 | encode_locku_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 539 | #define NFS4_dec_locku_sz (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 540 | decode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 541 | decode_putfh_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 542 | decode_locku_maxsz) |
Trond Myklebust | d3c7b7c | 2010-07-01 12:49:01 -0400 | [diff] [blame] | 543 | #define NFS4_enc_release_lockowner_sz \ |
| 544 | (compound_encode_hdr_maxsz + \ |
| 545 | encode_lockowner_maxsz) |
| 546 | #define NFS4_dec_release_lockowner_sz \ |
| 547 | (compound_decode_hdr_maxsz + \ |
| 548 | decode_lockowner_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 549 | #define NFS4_enc_access_sz (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 550 | encode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 551 | encode_putfh_maxsz + \ |
Trond Myklebust | 76b3299 | 2007-08-10 17:45:11 -0400 | [diff] [blame] | 552 | encode_access_maxsz + \ |
| 553 | encode_getattr_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 554 | #define NFS4_dec_access_sz (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 555 | decode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 556 | decode_putfh_maxsz + \ |
Trond Myklebust | 76b3299 | 2007-08-10 17:45:11 -0400 | [diff] [blame] | 557 | decode_access_maxsz + \ |
| 558 | decode_getattr_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 559 | #define NFS4_enc_getattr_sz (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 560 | encode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 561 | encode_putfh_maxsz + \ |
| 562 | encode_getattr_maxsz) |
| 563 | #define NFS4_dec_getattr_sz (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 564 | decode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 565 | decode_putfh_maxsz + \ |
| 566 | decode_getattr_maxsz) |
| 567 | #define NFS4_enc_lookup_sz (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 568 | encode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 569 | encode_putfh_maxsz + \ |
| 570 | encode_lookup_maxsz + \ |
| 571 | encode_getattr_maxsz + \ |
| 572 | encode_getfh_maxsz) |
| 573 | #define NFS4_dec_lookup_sz (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 574 | decode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 575 | decode_putfh_maxsz + \ |
Trond Myklebust | e688962 | 2007-07-02 13:58:30 -0400 | [diff] [blame] | 576 | decode_lookup_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 577 | decode_getattr_maxsz + \ |
| 578 | decode_getfh_maxsz) |
| 579 | #define NFS4_enc_lookup_root_sz (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 580 | encode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 581 | encode_putrootfh_maxsz + \ |
| 582 | encode_getattr_maxsz + \ |
| 583 | encode_getfh_maxsz) |
| 584 | #define NFS4_dec_lookup_root_sz (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 585 | decode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 586 | decode_putrootfh_maxsz + \ |
| 587 | decode_getattr_maxsz + \ |
| 588 | decode_getfh_maxsz) |
| 589 | #define NFS4_enc_remove_sz (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 590 | encode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 591 | encode_putfh_maxsz + \ |
Trond Myklebust | 778d281 | 2012-04-27 13:48:19 -0400 | [diff] [blame] | 592 | encode_remove_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 593 | #define NFS4_dec_remove_sz (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 594 | decode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 595 | decode_putfh_maxsz + \ |
Trond Myklebust | 778d281 | 2012-04-27 13:48:19 -0400 | [diff] [blame] | 596 | decode_remove_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 597 | #define NFS4_enc_rename_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_savefh_maxsz + \ |
| 601 | encode_putfh_maxsz + \ |
Trond Myklebust | 778d281 | 2012-04-27 13:48:19 -0400 | [diff] [blame] | 602 | encode_rename_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 603 | #define NFS4_dec_rename_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 + \ |
| 606 | decode_savefh_maxsz + \ |
| 607 | decode_putfh_maxsz + \ |
Trond Myklebust | 778d281 | 2012-04-27 13:48:19 -0400 | [diff] [blame] | 608 | decode_rename_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 609 | #define NFS4_enc_link_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_putfh_maxsz + \ |
| 612 | encode_savefh_maxsz + \ |
| 613 | encode_putfh_maxsz + \ |
Trond Myklebust | 91ba2ee | 2005-10-27 22:12:42 -0400 | [diff] [blame] | 614 | encode_link_maxsz + \ |
Trond Myklebust | 91ba2ee | 2005-10-27 22:12:42 -0400 | [diff] [blame] | 615 | encode_restorefh_maxsz + \ |
Trond Myklebust | a9f6991 | 2012-04-27 13:48:17 -0400 | [diff] [blame] | 616 | encode_getattr_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 617 | #define NFS4_dec_link_sz (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 618 | decode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 619 | decode_putfh_maxsz + \ |
| 620 | decode_savefh_maxsz + \ |
| 621 | decode_putfh_maxsz + \ |
Trond Myklebust | 91ba2ee | 2005-10-27 22:12:42 -0400 | [diff] [blame] | 622 | decode_link_maxsz + \ |
Trond Myklebust | 91ba2ee | 2005-10-27 22:12:42 -0400 | [diff] [blame] | 623 | decode_restorefh_maxsz + \ |
| 624 | decode_getattr_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 625 | #define NFS4_enc_symlink_sz (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 626 | encode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 627 | encode_putfh_maxsz + \ |
| 628 | encode_symlink_maxsz + \ |
| 629 | encode_getattr_maxsz + \ |
| 630 | encode_getfh_maxsz) |
| 631 | #define NFS4_dec_symlink_sz (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 632 | decode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 633 | decode_putfh_maxsz + \ |
| 634 | decode_symlink_maxsz + \ |
| 635 | decode_getattr_maxsz + \ |
| 636 | decode_getfh_maxsz) |
| 637 | #define NFS4_enc_create_sz (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 638 | encode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 639 | encode_putfh_maxsz + \ |
| 640 | encode_create_maxsz + \ |
Trond Myklebust | 56ae19f | 2005-10-27 22:12:40 -0400 | [diff] [blame] | 641 | encode_getfh_maxsz + \ |
Trond Myklebust | 56ae19f | 2005-10-27 22:12:40 -0400 | [diff] [blame] | 642 | encode_getattr_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 643 | #define NFS4_dec_create_sz (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 644 | decode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 645 | decode_putfh_maxsz + \ |
| 646 | decode_create_maxsz + \ |
Trond Myklebust | 56ae19f | 2005-10-27 22:12:40 -0400 | [diff] [blame] | 647 | decode_getfh_maxsz + \ |
Trond Myklebust | 56ae19f | 2005-10-27 22:12:40 -0400 | [diff] [blame] | 648 | decode_getattr_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 649 | #define NFS4_enc_pathconf_sz (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 650 | encode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 651 | encode_putfh_maxsz + \ |
| 652 | encode_getattr_maxsz) |
| 653 | #define NFS4_dec_pathconf_sz (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 654 | decode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 655 | decode_putfh_maxsz + \ |
| 656 | decode_getattr_maxsz) |
| 657 | #define NFS4_enc_statfs_sz (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 658 | encode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 659 | encode_putfh_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 660 | encode_statfs_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 661 | #define NFS4_dec_statfs_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 + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 664 | decode_statfs_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 665 | #define NFS4_enc_server_caps_sz (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 666 | encode_sequence_maxsz + \ |
Trond Myklebust | ab91f26 | 2007-02-02 14:47:17 -0800 | [diff] [blame] | 667 | encode_putfh_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 668 | encode_getattr_maxsz) |
| 669 | #define NFS4_dec_server_caps_sz (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 670 | decode_sequence_maxsz + \ |
Trond Myklebust | ab91f26 | 2007-02-02 14:47:17 -0800 | [diff] [blame] | 671 | decode_putfh_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 672 | decode_getattr_maxsz) |
| 673 | #define NFS4_enc_delegreturn_sz (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 674 | encode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 675 | encode_putfh_maxsz + \ |
Trond Myklebust | fa178f2 | 2006-01-03 09:55:38 +0100 | [diff] [blame] | 676 | encode_delegreturn_maxsz + \ |
| 677 | encode_getattr_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 678 | #define NFS4_dec_delegreturn_sz (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 679 | decode_sequence_maxsz + \ |
Trond Myklebust | fa178f2 | 2006-01-03 09:55:38 +0100 | [diff] [blame] | 680 | decode_delegreturn_maxsz + \ |
| 681 | decode_getattr_maxsz) |
J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 682 | #define NFS4_enc_getacl_sz (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 683 | encode_sequence_maxsz + \ |
J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 684 | encode_putfh_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 685 | encode_getacl_maxsz) |
J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 686 | #define NFS4_dec_getacl_sz (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 687 | decode_sequence_maxsz + \ |
J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 688 | decode_putfh_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 689 | decode_getacl_maxsz) |
J. Bruce Fields | 23ec696 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 690 | #define NFS4_enc_setacl_sz (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 691 | encode_sequence_maxsz + \ |
J. Bruce Fields | 23ec696 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 692 | encode_putfh_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 693 | encode_setacl_maxsz) |
J. Bruce Fields | 23ec696 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 694 | #define NFS4_dec_setacl_sz (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 695 | decode_sequence_maxsz + \ |
J. Bruce Fields | 23ec696 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 696 | decode_putfh_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 697 | decode_setacl_maxsz) |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 698 | #define NFS4_enc_fs_locations_sz \ |
| 699 | (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 700 | encode_sequence_maxsz + \ |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 701 | encode_putfh_maxsz + \ |
Trond Myklebust | e688962 | 2007-07-02 13:58:30 -0400 | [diff] [blame] | 702 | encode_lookup_maxsz + \ |
| 703 | encode_fs_locations_maxsz) |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 704 | #define NFS4_dec_fs_locations_sz \ |
| 705 | (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 706 | decode_sequence_maxsz + \ |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 707 | decode_putfh_maxsz + \ |
Trond Myklebust | e688962 | 2007-07-02 13:58:30 -0400 | [diff] [blame] | 708 | decode_lookup_maxsz + \ |
| 709 | decode_fs_locations_maxsz) |
Bryan Schumaker | 5a5ea0d | 2011-03-24 17:12:29 +0000 | [diff] [blame] | 710 | #define NFS4_enc_secinfo_sz (compound_encode_hdr_maxsz + \ |
| 711 | encode_sequence_maxsz + \ |
| 712 | encode_putfh_maxsz + \ |
| 713 | encode_secinfo_maxsz) |
| 714 | #define NFS4_dec_secinfo_sz (compound_decode_hdr_maxsz + \ |
| 715 | decode_sequence_maxsz + \ |
| 716 | decode_putfh_maxsz + \ |
| 717 | decode_secinfo_maxsz) |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 718 | #if defined(CONFIG_NFS_V4_1) |
| 719 | #define NFS4_enc_exchange_id_sz \ |
| 720 | (compound_encode_hdr_maxsz + \ |
| 721 | encode_exchange_id_maxsz) |
| 722 | #define NFS4_dec_exchange_id_sz \ |
| 723 | (compound_decode_hdr_maxsz + \ |
| 724 | decode_exchange_id_maxsz) |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 725 | #define NFS4_enc_create_session_sz \ |
| 726 | (compound_encode_hdr_maxsz + \ |
| 727 | encode_create_session_maxsz) |
| 728 | #define NFS4_dec_create_session_sz \ |
| 729 | (compound_decode_hdr_maxsz + \ |
| 730 | decode_create_session_maxsz) |
Andy Adamson | 0f3e66c | 2009-04-01 09:22:34 -0400 | [diff] [blame] | 731 | #define NFS4_enc_destroy_session_sz (compound_encode_hdr_maxsz + \ |
| 732 | encode_destroy_session_maxsz) |
| 733 | #define NFS4_dec_destroy_session_sz (compound_decode_hdr_maxsz + \ |
| 734 | decode_destroy_session_maxsz) |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 735 | #define NFS4_enc_sequence_sz \ |
| 736 | (compound_decode_hdr_maxsz + \ |
| 737 | encode_sequence_maxsz) |
| 738 | #define NFS4_dec_sequence_sz \ |
| 739 | (compound_decode_hdr_maxsz + \ |
| 740 | decode_sequence_maxsz) |
Andy Adamson | 2050f0c | 2009-04-01 09:22:30 -0400 | [diff] [blame] | 741 | #define NFS4_enc_get_lease_time_sz (compound_encode_hdr_maxsz + \ |
| 742 | encode_sequence_maxsz + \ |
| 743 | encode_putrootfh_maxsz + \ |
| 744 | encode_fsinfo_maxsz) |
| 745 | #define NFS4_dec_get_lease_time_sz (compound_decode_hdr_maxsz + \ |
| 746 | decode_sequence_maxsz + \ |
| 747 | decode_putrootfh_maxsz + \ |
| 748 | decode_fsinfo_maxsz) |
Ricardo Labiaga | 18019753 | 2009-12-05 16:08:40 -0500 | [diff] [blame] | 749 | #define NFS4_enc_reclaim_complete_sz (compound_encode_hdr_maxsz + \ |
| 750 | encode_sequence_maxsz + \ |
| 751 | encode_reclaim_complete_maxsz) |
| 752 | #define NFS4_dec_reclaim_complete_sz (compound_decode_hdr_maxsz + \ |
| 753 | decode_sequence_maxsz + \ |
| 754 | decode_reclaim_complete_maxsz) |
Andy Adamson | 7f11d8d | 2011-07-30 20:52:35 -0400 | [diff] [blame] | 755 | #define NFS4_enc_getdevicelist_sz (compound_encode_hdr_maxsz + \ |
| 756 | encode_sequence_maxsz + \ |
| 757 | encode_putfh_maxsz + \ |
| 758 | encode_getdevicelist_maxsz) |
| 759 | #define NFS4_dec_getdevicelist_sz (compound_decode_hdr_maxsz + \ |
| 760 | decode_sequence_maxsz + \ |
| 761 | decode_putfh_maxsz + \ |
| 762 | decode_getdevicelist_maxsz) |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 763 | #define NFS4_enc_getdeviceinfo_sz (compound_encode_hdr_maxsz + \ |
| 764 | encode_sequence_maxsz +\ |
| 765 | encode_getdeviceinfo_maxsz) |
| 766 | #define NFS4_dec_getdeviceinfo_sz (compound_decode_hdr_maxsz + \ |
| 767 | decode_sequence_maxsz + \ |
| 768 | decode_getdeviceinfo_maxsz) |
| 769 | #define NFS4_enc_layoutget_sz (compound_encode_hdr_maxsz + \ |
| 770 | encode_sequence_maxsz + \ |
| 771 | encode_putfh_maxsz + \ |
| 772 | encode_layoutget_maxsz) |
| 773 | #define NFS4_dec_layoutget_sz (compound_decode_hdr_maxsz + \ |
| 774 | decode_sequence_maxsz + \ |
| 775 | decode_putfh_maxsz + \ |
| 776 | decode_layoutget_maxsz) |
Andy Adamson | 863a3c6 | 2011-03-23 13:27:54 +0000 | [diff] [blame] | 777 | #define NFS4_enc_layoutcommit_sz (compound_encode_hdr_maxsz + \ |
| 778 | encode_sequence_maxsz +\ |
| 779 | encode_putfh_maxsz + \ |
| 780 | encode_layoutcommit_maxsz + \ |
| 781 | encode_getattr_maxsz) |
| 782 | #define NFS4_dec_layoutcommit_sz (compound_decode_hdr_maxsz + \ |
| 783 | decode_sequence_maxsz + \ |
| 784 | decode_putfh_maxsz + \ |
| 785 | decode_layoutcommit_maxsz + \ |
| 786 | decode_getattr_maxsz) |
Benny Halevy | cbe8260 | 2011-05-22 19:52:37 +0300 | [diff] [blame] | 787 | #define NFS4_enc_layoutreturn_sz (compound_encode_hdr_maxsz + \ |
| 788 | encode_sequence_maxsz + \ |
| 789 | encode_putfh_maxsz + \ |
| 790 | encode_layoutreturn_maxsz) |
| 791 | #define NFS4_dec_layoutreturn_sz (compound_decode_hdr_maxsz + \ |
| 792 | decode_sequence_maxsz + \ |
| 793 | decode_putfh_maxsz + \ |
| 794 | decode_layoutreturn_maxsz) |
Bryan Schumaker | fca78d6 | 2011-06-02 14:59:07 -0400 | [diff] [blame] | 795 | #define NFS4_enc_secinfo_no_name_sz (compound_encode_hdr_maxsz + \ |
| 796 | encode_sequence_maxsz + \ |
| 797 | encode_putrootfh_maxsz +\ |
| 798 | encode_secinfo_no_name_maxsz) |
| 799 | #define NFS4_dec_secinfo_no_name_sz (compound_decode_hdr_maxsz + \ |
| 800 | decode_sequence_maxsz + \ |
| 801 | decode_putrootfh_maxsz + \ |
| 802 | decode_secinfo_no_name_maxsz) |
Bryan Schumaker | 7d97479 | 2011-06-02 14:59:08 -0400 | [diff] [blame] | 803 | #define NFS4_enc_test_stateid_sz (compound_encode_hdr_maxsz + \ |
| 804 | encode_sequence_maxsz + \ |
| 805 | encode_test_stateid_maxsz) |
| 806 | #define NFS4_dec_test_stateid_sz (compound_decode_hdr_maxsz + \ |
| 807 | decode_sequence_maxsz + \ |
| 808 | decode_test_stateid_maxsz) |
Bryan Schumaker | 9aeda35 | 2011-06-02 14:59:09 -0400 | [diff] [blame] | 809 | #define NFS4_enc_free_stateid_sz (compound_encode_hdr_maxsz + \ |
| 810 | encode_sequence_maxsz + \ |
| 811 | encode_free_stateid_maxsz) |
| 812 | #define NFS4_dec_free_stateid_sz (compound_decode_hdr_maxsz + \ |
| 813 | decode_sequence_maxsz + \ |
| 814 | decode_free_stateid_maxsz) |
Alexandros Batsakis | 2449ea2 | 2009-12-05 13:36:55 -0500 | [diff] [blame] | 815 | |
| 816 | const u32 nfs41_maxwrite_overhead = ((RPC_MAX_HEADER_WITH_AUTH + |
| 817 | compound_encode_hdr_maxsz + |
| 818 | encode_sequence_maxsz + |
| 819 | encode_putfh_maxsz + |
| 820 | encode_getattr_maxsz) * |
| 821 | XDR_UNIT); |
| 822 | |
| 823 | const u32 nfs41_maxread_overhead = ((RPC_MAX_HEADER_WITH_AUTH + |
| 824 | compound_decode_hdr_maxsz + |
| 825 | decode_sequence_maxsz + |
| 826 | decode_putfh_maxsz) * |
| 827 | XDR_UNIT); |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 828 | #endif /* CONFIG_NFS_V4_1 */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 829 | |
Weston Andros Adamson | db8ac8b | 2012-02-17 15:20:24 -0500 | [diff] [blame] | 830 | static unsigned short send_implementation_id = 1; |
| 831 | |
| 832 | module_param(send_implementation_id, ushort, 0644); |
| 833 | MODULE_PARM_DESC(send_implementation_id, |
| 834 | "Send implementation ID with NFSv4.1 exchange_id"); |
| 835 | |
Trond Myklebust | bca7947 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 836 | static const umode_t nfs_type2fmt[] = { |
| 837 | [NF4BAD] = 0, |
| 838 | [NF4REG] = S_IFREG, |
| 839 | [NF4DIR] = S_IFDIR, |
| 840 | [NF4BLK] = S_IFBLK, |
| 841 | [NF4CHR] = S_IFCHR, |
| 842 | [NF4LNK] = S_IFLNK, |
| 843 | [NF4SOCK] = S_IFSOCK, |
| 844 | [NF4FIFO] = S_IFIFO, |
| 845 | [NF4ATTRDIR] = 0, |
| 846 | [NF4NAMEDATTR] = 0, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 847 | }; |
| 848 | |
| 849 | struct compound_hdr { |
| 850 | int32_t status; |
| 851 | uint32_t nops; |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 852 | __be32 * nops_p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 853 | uint32_t taglen; |
| 854 | char * tag; |
Benny Halevy | 0c4e8c1 | 2009-04-01 09:22:07 -0400 | [diff] [blame] | 855 | uint32_t replen; /* expected reply words */ |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 856 | u32 minorversion; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 857 | }; |
| 858 | |
Benny Halevy | 13c65ce | 2009-08-14 17:19:25 +0300 | [diff] [blame] | 859 | static __be32 *reserve_space(struct xdr_stream *xdr, size_t nbytes) |
| 860 | { |
| 861 | __be32 *p = xdr_reserve_space(xdr, nbytes); |
| 862 | BUG_ON(!p); |
| 863 | return p; |
| 864 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 865 | |
Trond Myklebust | cb17e55 | 2012-03-04 18:13:56 -0500 | [diff] [blame] | 866 | static void encode_opaque_fixed(struct xdr_stream *xdr, const void *buf, size_t len) |
| 867 | { |
| 868 | __be32 *p; |
| 869 | |
| 870 | p = xdr_reserve_space(xdr, len); |
| 871 | xdr_encode_opaque_fixed(p, buf, len); |
| 872 | } |
| 873 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 874 | static void encode_string(struct xdr_stream *xdr, unsigned int len, const char *str) |
| 875 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 876 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 877 | |
Trond Myklebust | 6fdfb0bc | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 878 | p = reserve_space(xdr, 4 + len); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 879 | xdr_encode_opaque(p, str, len); |
| 880 | } |
| 881 | |
Trond Myklebust | 4ade982 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 882 | static void encode_uint32(struct xdr_stream *xdr, u32 n) |
| 883 | { |
| 884 | __be32 *p; |
| 885 | |
| 886 | p = reserve_space(xdr, 4); |
| 887 | *p = cpu_to_be32(n); |
| 888 | } |
| 889 | |
Trond Myklebust | ff2eb68 | 2012-03-05 11:40:12 -0500 | [diff] [blame] | 890 | static void encode_uint64(struct xdr_stream *xdr, u64 n) |
| 891 | { |
| 892 | __be32 *p; |
| 893 | |
| 894 | p = reserve_space(xdr, 8); |
| 895 | xdr_encode_hyper(p, n); |
| 896 | } |
| 897 | |
Trond Myklebust | 4ade982 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 898 | static void encode_nfs4_seqid(struct xdr_stream *xdr, |
| 899 | const struct nfs_seqid *seqid) |
| 900 | { |
| 901 | encode_uint32(xdr, seqid->sequence->counter); |
| 902 | } |
| 903 | |
Benny Halevy | 0c4e8c1 | 2009-04-01 09:22:07 -0400 | [diff] [blame] | 904 | static void encode_compound_hdr(struct xdr_stream *xdr, |
| 905 | struct rpc_rqst *req, |
| 906 | struct compound_hdr *hdr) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 907 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 908 | __be32 *p; |
Trond Myklebust | a17c215 | 2010-07-31 14:29:08 -0400 | [diff] [blame] | 909 | struct rpc_auth *auth = req->rq_cred->cr_auth; |
Benny Halevy | 0c4e8c1 | 2009-04-01 09:22:07 -0400 | [diff] [blame] | 910 | |
| 911 | /* initialize running count of expected bytes in reply. |
| 912 | * NOTE: the replied tag SHOULD be the same is the one sent, |
| 913 | * but this is not required as a MUST for the server to do so. */ |
| 914 | hdr->replen = RPC_REPHDRSIZE + auth->au_rslack + 3 + hdr->taglen; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 915 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 916 | BUG_ON(hdr->taglen > NFS4_MAXTAGLEN); |
Trond Myklebust | 6fdfb0bc | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 917 | encode_string(xdr, hdr->taglen, hdr->tag); |
| 918 | p = reserve_space(xdr, 8); |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 919 | *p++ = cpu_to_be32(hdr->minorversion); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 920 | hdr->nops_p = p; |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 921 | *p = cpu_to_be32(hdr->nops); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 922 | } |
| 923 | |
Trond Myklebust | ab19b48 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 924 | static void encode_op_hdr(struct xdr_stream *xdr, enum nfs_opnum4 op, |
| 925 | uint32_t replen, |
| 926 | struct compound_hdr *hdr) |
| 927 | { |
| 928 | encode_uint32(xdr, op); |
| 929 | hdr->nops++; |
| 930 | hdr->replen += replen; |
| 931 | } |
| 932 | |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 933 | static void encode_nops(struct compound_hdr *hdr) |
| 934 | { |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 935 | BUG_ON(hdr->nops > NFS4_MAX_OPS); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 936 | *hdr->nops_p = htonl(hdr->nops); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 937 | } |
| 938 | |
Trond Myklebust | ea9d23f | 2012-03-04 18:13:56 -0500 | [diff] [blame] | 939 | static void encode_nfs4_stateid(struct xdr_stream *xdr, const nfs4_stateid *stateid) |
| 940 | { |
Trond Myklebust | 2d2f24a | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 941 | encode_opaque_fixed(xdr, stateid, NFS4_STATEID_SIZE); |
Trond Myklebust | ea9d23f | 2012-03-04 18:13:56 -0500 | [diff] [blame] | 942 | } |
| 943 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 944 | static void encode_nfs4_verifier(struct xdr_stream *xdr, const nfs4_verifier *verf) |
| 945 | { |
Trond Myklebust | cb17e55 | 2012-03-04 18:13:56 -0500 | [diff] [blame] | 946 | encode_opaque_fixed(xdr, verf->data, NFS4_VERIFIER_SIZE); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 947 | } |
| 948 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 949 | static void encode_attrs(struct xdr_stream *xdr, const struct iattr *iap, const struct nfs_server *server) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 950 | { |
| 951 | char owner_name[IDMAP_NAMESZ]; |
| 952 | char owner_group[IDMAP_NAMESZ]; |
| 953 | int owner_namelen = 0; |
| 954 | int owner_grouplen = 0; |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 955 | __be32 *p; |
| 956 | __be32 *q; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 957 | int len; |
| 958 | uint32_t bmval0 = 0; |
| 959 | uint32_t bmval1 = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 960 | |
| 961 | /* |
| 962 | * We reserve enough space to write the entire attribute buffer at once. |
| 963 | * In the worst-case, this would be |
| 964 | * 12(bitmap) + 4(attrlen) + 8(size) + 4(mode) + 4(atime) + 4(mtime) |
| 965 | * = 36 bytes, plus any contribution from variable-length fields |
J. Bruce Fields | 23ec696 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 966 | * such as owner/group. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 967 | */ |
| 968 | len = 16; |
| 969 | |
| 970 | /* Sigh */ |
| 971 | if (iap->ia_valid & ATTR_SIZE) |
| 972 | len += 8; |
| 973 | if (iap->ia_valid & ATTR_MODE) |
| 974 | len += 4; |
| 975 | if (iap->ia_valid & ATTR_UID) { |
Trond Myklebust | e4fd72a | 2011-02-22 15:44:31 -0800 | [diff] [blame] | 976 | 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] | 977 | if (owner_namelen < 0) { |
Chuck Lever | fe82a18 | 2007-09-11 18:01:10 -0400 | [diff] [blame] | 978 | dprintk("nfs: couldn't resolve uid %d to string\n", |
| 979 | iap->ia_uid); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 980 | /* XXX */ |
| 981 | strcpy(owner_name, "nobody"); |
| 982 | owner_namelen = sizeof("nobody") - 1; |
| 983 | /* goto out; */ |
| 984 | } |
| 985 | len += 4 + (XDR_QUADLEN(owner_namelen) << 2); |
| 986 | } |
| 987 | if (iap->ia_valid & ATTR_GID) { |
Trond Myklebust | e4fd72a | 2011-02-22 15:44:31 -0800 | [diff] [blame] | 988 | 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] | 989 | if (owner_grouplen < 0) { |
Chuck Lever | fe82a18 | 2007-09-11 18:01:10 -0400 | [diff] [blame] | 990 | dprintk("nfs: couldn't resolve gid %d to string\n", |
| 991 | iap->ia_gid); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 992 | strcpy(owner_group, "nobody"); |
| 993 | owner_grouplen = sizeof("nobody") - 1; |
| 994 | /* goto out; */ |
| 995 | } |
| 996 | len += 4 + (XDR_QUADLEN(owner_grouplen) << 2); |
| 997 | } |
| 998 | if (iap->ia_valid & ATTR_ATIME_SET) |
| 999 | len += 16; |
| 1000 | else if (iap->ia_valid & ATTR_ATIME) |
| 1001 | len += 4; |
| 1002 | if (iap->ia_valid & ATTR_MTIME_SET) |
| 1003 | len += 16; |
| 1004 | else if (iap->ia_valid & ATTR_MTIME) |
| 1005 | len += 4; |
Benny Halevy | 13c65ce | 2009-08-14 17:19:25 +0300 | [diff] [blame] | 1006 | p = reserve_space(xdr, len); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1007 | |
| 1008 | /* |
| 1009 | * We write the bitmap length now, but leave the bitmap and the attribute |
| 1010 | * buffer length to be backfilled at the end of this routine. |
| 1011 | */ |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1012 | *p++ = cpu_to_be32(2); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1013 | q = p; |
| 1014 | p += 3; |
| 1015 | |
| 1016 | if (iap->ia_valid & ATTR_SIZE) { |
| 1017 | bmval0 |= FATTR4_WORD0_SIZE; |
Benny Halevy | b95be5a | 2009-08-14 17:19:01 +0300 | [diff] [blame] | 1018 | p = xdr_encode_hyper(p, iap->ia_size); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1019 | } |
| 1020 | if (iap->ia_valid & ATTR_MODE) { |
| 1021 | bmval1 |= FATTR4_WORD1_MODE; |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1022 | *p++ = cpu_to_be32(iap->ia_mode & S_IALLUGO); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1023 | } |
| 1024 | if (iap->ia_valid & ATTR_UID) { |
| 1025 | bmval1 |= FATTR4_WORD1_OWNER; |
Benny Halevy | 811652b | 2009-08-14 17:19:34 +0300 | [diff] [blame] | 1026 | p = xdr_encode_opaque(p, owner_name, owner_namelen); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1027 | } |
| 1028 | if (iap->ia_valid & ATTR_GID) { |
| 1029 | bmval1 |= FATTR4_WORD1_OWNER_GROUP; |
Benny Halevy | 811652b | 2009-08-14 17:19:34 +0300 | [diff] [blame] | 1030 | p = xdr_encode_opaque(p, owner_group, owner_grouplen); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1031 | } |
| 1032 | if (iap->ia_valid & ATTR_ATIME_SET) { |
| 1033 | bmval1 |= FATTR4_WORD1_TIME_ACCESS_SET; |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1034 | *p++ = cpu_to_be32(NFS4_SET_TO_CLIENT_TIME); |
| 1035 | *p++ = cpu_to_be32(0); |
Trond Myklebust | d3f6baa | 2010-06-22 08:52:39 -0400 | [diff] [blame] | 1036 | *p++ = cpu_to_be32(iap->ia_atime.tv_sec); |
| 1037 | *p++ = cpu_to_be32(iap->ia_atime.tv_nsec); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1038 | } |
| 1039 | else if (iap->ia_valid & ATTR_ATIME) { |
| 1040 | bmval1 |= FATTR4_WORD1_TIME_ACCESS_SET; |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1041 | *p++ = cpu_to_be32(NFS4_SET_TO_SERVER_TIME); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1042 | } |
| 1043 | if (iap->ia_valid & ATTR_MTIME_SET) { |
| 1044 | bmval1 |= FATTR4_WORD1_TIME_MODIFY_SET; |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1045 | *p++ = cpu_to_be32(NFS4_SET_TO_CLIENT_TIME); |
| 1046 | *p++ = cpu_to_be32(0); |
| 1047 | *p++ = cpu_to_be32(iap->ia_mtime.tv_sec); |
| 1048 | *p++ = cpu_to_be32(iap->ia_mtime.tv_nsec); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1049 | } |
| 1050 | else if (iap->ia_valid & ATTR_MTIME) { |
| 1051 | bmval1 |= FATTR4_WORD1_TIME_MODIFY_SET; |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1052 | *p++ = cpu_to_be32(NFS4_SET_TO_SERVER_TIME); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1053 | } |
Andy Adamson | 6c0195a | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 1054 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1055 | /* |
| 1056 | * Now we backfill the bitmap and the attribute buffer length. |
| 1057 | */ |
| 1058 | if (len != ((char *)p - (char *)q) + 4) { |
Weston Andros Adamson | f9fd2d9 | 2012-01-26 13:32:22 -0500 | [diff] [blame] | 1059 | printk(KERN_ERR "NFS: Attr length error, %u != %Zu\n", |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1060 | len, ((char *)p - (char *)q) + 4); |
| 1061 | BUG(); |
| 1062 | } |
| 1063 | len = (char *)p - (char *)q - 12; |
| 1064 | *q++ = htonl(bmval0); |
| 1065 | *q++ = htonl(bmval1); |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1066 | *q = htonl(len); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1067 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1068 | /* out: */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1069 | } |
| 1070 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1071 | 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] | 1072 | { |
Trond Myklebust | 475d4ba | 2012-03-05 11:27:16 -0500 | [diff] [blame] | 1073 | encode_op_hdr(xdr, OP_ACCESS, decode_access_maxsz, hdr); |
| 1074 | encode_uint32(xdr, access); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1075 | } |
| 1076 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1077 | 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] | 1078 | { |
Trond Myklebust | ab19b48 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1079 | encode_op_hdr(xdr, OP_CLOSE, decode_close_maxsz, hdr); |
Trond Myklebust | 4ade982 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1080 | encode_nfs4_seqid(xdr, arg->seqid); |
Trond Myklebust | ea9d23f | 2012-03-04 18:13:56 -0500 | [diff] [blame] | 1081 | encode_nfs4_stateid(xdr, arg->stateid); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1082 | } |
| 1083 | |
Fred Isaman | 0b7c015 | 2012-04-20 14:47:39 -0400 | [diff] [blame] | 1084 | 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] | 1085 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 1086 | __be32 *p; |
Andy Adamson | 6c0195a | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 1087 | |
Trond Myklebust | 475d4ba | 2012-03-05 11:27:16 -0500 | [diff] [blame] | 1088 | encode_op_hdr(xdr, OP_COMMIT, decode_commit_maxsz, hdr); |
| 1089 | p = reserve_space(xdr, 12); |
Benny Halevy | b95be5a | 2009-08-14 17:19:01 +0300 | [diff] [blame] | 1090 | p = xdr_encode_hyper(p, args->offset); |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1091 | *p = cpu_to_be32(args->count); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1092 | } |
| 1093 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1094 | 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] | 1095 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 1096 | __be32 *p; |
Andy Adamson | 6c0195a | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 1097 | |
Trond Myklebust | 475d4ba | 2012-03-05 11:27:16 -0500 | [diff] [blame] | 1098 | encode_op_hdr(xdr, OP_CREATE, decode_create_maxsz, hdr); |
| 1099 | encode_uint32(xdr, create->ftype); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1100 | |
| 1101 | switch (create->ftype) { |
| 1102 | case NF4LNK: |
Benny Halevy | 13c65ce | 2009-08-14 17:19:25 +0300 | [diff] [blame] | 1103 | p = reserve_space(xdr, 4); |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1104 | *p = cpu_to_be32(create->u.symlink.len); |
Chuck Lever | 94a6d75 | 2006-08-22 20:06:23 -0400 | [diff] [blame] | 1105 | 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] | 1106 | break; |
| 1107 | |
| 1108 | case NF4BLK: case NF4CHR: |
Benny Halevy | 13c65ce | 2009-08-14 17:19:25 +0300 | [diff] [blame] | 1109 | p = reserve_space(xdr, 8); |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1110 | *p++ = cpu_to_be32(create->u.device.specdata1); |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1111 | *p = cpu_to_be32(create->u.device.specdata2); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1112 | break; |
| 1113 | |
| 1114 | default: |
| 1115 | break; |
| 1116 | } |
| 1117 | |
Benny Halevy | 811652b | 2009-08-14 17:19:34 +0300 | [diff] [blame] | 1118 | encode_string(xdr, create->name->len, create->name->name); |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1119 | encode_attrs(xdr, create->attrs, create->server); |
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_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] | 1123 | { |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 1124 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1125 | |
Trond Myklebust | 475d4ba | 2012-03-05 11:27:16 -0500 | [diff] [blame] | 1126 | encode_op_hdr(xdr, OP_GETATTR, decode_getattr_maxsz, hdr); |
| 1127 | p = reserve_space(xdr, 8); |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1128 | *p++ = cpu_to_be32(1); |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1129 | *p = cpu_to_be32(bitmap); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1130 | } |
| 1131 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1132 | 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] | 1133 | { |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 1134 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1135 | |
Trond Myklebust | 475d4ba | 2012-03-05 11:27:16 -0500 | [diff] [blame] | 1136 | encode_op_hdr(xdr, OP_GETATTR, decode_getattr_maxsz, hdr); |
| 1137 | p = reserve_space(xdr, 12); |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1138 | *p++ = cpu_to_be32(2); |
| 1139 | *p++ = cpu_to_be32(bm0); |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1140 | *p = cpu_to_be32(bm1); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1141 | } |
| 1142 | |
Fred Isaman | dae100c | 2011-07-30 20:52:37 -0400 | [diff] [blame] | 1143 | static void |
| 1144 | encode_getattr_three(struct xdr_stream *xdr, |
| 1145 | uint32_t bm0, uint32_t bm1, uint32_t bm2, |
| 1146 | struct compound_hdr *hdr) |
| 1147 | { |
| 1148 | __be32 *p; |
| 1149 | |
Trond Myklebust | ab19b48 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1150 | encode_op_hdr(xdr, OP_GETATTR, decode_getattr_maxsz, hdr); |
Fred Isaman | dae100c | 2011-07-30 20:52:37 -0400 | [diff] [blame] | 1151 | if (bm2) { |
| 1152 | p = reserve_space(xdr, 16); |
| 1153 | *p++ = cpu_to_be32(3); |
| 1154 | *p++ = cpu_to_be32(bm0); |
| 1155 | *p++ = cpu_to_be32(bm1); |
| 1156 | *p = cpu_to_be32(bm2); |
| 1157 | } else if (bm1) { |
| 1158 | p = reserve_space(xdr, 12); |
| 1159 | *p++ = cpu_to_be32(2); |
| 1160 | *p++ = cpu_to_be32(bm0); |
| 1161 | *p = cpu_to_be32(bm1); |
| 1162 | } else { |
| 1163 | p = reserve_space(xdr, 8); |
| 1164 | *p++ = cpu_to_be32(1); |
| 1165 | *p = cpu_to_be32(bm0); |
| 1166 | } |
Fred Isaman | dae100c | 2011-07-30 20:52:37 -0400 | [diff] [blame] | 1167 | } |
| 1168 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1169 | 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] | 1170 | { |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1171 | encode_getattr_two(xdr, bitmask[0] & nfs4_fattr_bitmap[0], |
| 1172 | bitmask[1] & nfs4_fattr_bitmap[1], hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1173 | } |
| 1174 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1175 | 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] | 1176 | { |
Fred Isaman | dae100c | 2011-07-30 20:52:37 -0400 | [diff] [blame] | 1177 | encode_getattr_three(xdr, |
| 1178 | bitmask[0] & nfs4_fsinfo_bitmap[0], |
| 1179 | bitmask[1] & nfs4_fsinfo_bitmap[1], |
| 1180 | bitmask[2] & nfs4_fsinfo_bitmap[2], |
| 1181 | hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1182 | } |
| 1183 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1184 | 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] | 1185 | { |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1186 | encode_getattr_two(xdr, bitmask[0] & nfs4_fs_locations_bitmap[0], |
| 1187 | bitmask[1] & nfs4_fs_locations_bitmap[1], hdr); |
Manoj Naik | 830b8e3 | 2006-06-09 09:34:25 -0400 | [diff] [blame] | 1188 | } |
| 1189 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1190 | static void encode_getfh(struct xdr_stream *xdr, struct compound_hdr *hdr) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1191 | { |
Trond Myklebust | ab19b48 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1192 | encode_op_hdr(xdr, OP_GETFH, decode_getfh_maxsz, hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1193 | } |
| 1194 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1195 | 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] | 1196 | { |
Trond Myklebust | ab19b48 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1197 | encode_op_hdr(xdr, OP_LINK, decode_link_maxsz, hdr); |
Trond Myklebust | 6fdfb0bc | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1198 | encode_string(xdr, name->len, name->name); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1199 | } |
| 1200 | |
Trond Myklebust | 911d1aa | 2006-01-03 09:55:16 +0100 | [diff] [blame] | 1201 | static inline int nfs4_lock_type(struct file_lock *fl, int block) |
| 1202 | { |
| 1203 | if ((fl->fl_type & (F_RDLCK|F_WRLCK|F_UNLCK)) == F_RDLCK) |
| 1204 | return block ? NFS4_READW_LT : NFS4_READ_LT; |
| 1205 | return block ? NFS4_WRITEW_LT : NFS4_WRITE_LT; |
| 1206 | } |
| 1207 | |
| 1208 | static inline uint64_t nfs4_lock_length(struct file_lock *fl) |
| 1209 | { |
| 1210 | if (fl->fl_end == OFFSET_MAX) |
| 1211 | return ~(uint64_t)0; |
| 1212 | return fl->fl_end - fl->fl_start + 1; |
| 1213 | } |
| 1214 | |
Trond Myklebust | daccbde | 2010-06-25 18:11:43 -0400 | [diff] [blame] | 1215 | static void encode_lockowner(struct xdr_stream *xdr, const struct nfs_lowner *lowner) |
| 1216 | { |
| 1217 | __be32 *p; |
| 1218 | |
Trond Myklebust | d035c36 | 2010-12-21 10:45:27 -0500 | [diff] [blame] | 1219 | p = reserve_space(xdr, 32); |
Trond Myklebust | daccbde | 2010-06-25 18:11:43 -0400 | [diff] [blame] | 1220 | p = xdr_encode_hyper(p, lowner->clientid); |
Trond Myklebust | d035c36 | 2010-12-21 10:45:27 -0500 | [diff] [blame] | 1221 | *p++ = cpu_to_be32(20); |
Trond Myklebust | daccbde | 2010-06-25 18:11:43 -0400 | [diff] [blame] | 1222 | p = xdr_encode_opaque_fixed(p, "lock id:", 8); |
Trond Myklebust | d035c36 | 2010-12-21 10:45:27 -0500 | [diff] [blame] | 1223 | *p++ = cpu_to_be32(lowner->s_dev); |
Trond Myklebust | daccbde | 2010-06-25 18:11:43 -0400 | [diff] [blame] | 1224 | xdr_encode_hyper(p, lowner->id); |
| 1225 | } |
| 1226 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1227 | /* |
| 1228 | * opcode,type,reclaim,offset,length,new_lock_owner = 32 |
| 1229 | * open_seqid,open_stateid,lock_seqid,lock_owner.clientid, lock_owner.id = 40 |
| 1230 | */ |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1231 | 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] | 1232 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 1233 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1234 | |
Trond Myklebust | 475d4ba | 2012-03-05 11:27:16 -0500 | [diff] [blame] | 1235 | encode_op_hdr(xdr, OP_LOCK, decode_lock_maxsz, hdr); |
| 1236 | p = reserve_space(xdr, 28); |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1237 | *p++ = cpu_to_be32(nfs4_lock_type(args->fl, args->block)); |
| 1238 | *p++ = cpu_to_be32(args->reclaim); |
Benny Halevy | b95be5a | 2009-08-14 17:19:01 +0300 | [diff] [blame] | 1239 | p = xdr_encode_hyper(p, args->fl->fl_start); |
| 1240 | p = xdr_encode_hyper(p, nfs4_lock_length(args->fl)); |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1241 | *p = cpu_to_be32(args->new_lock_owner); |
Trond Myklebust | 911d1aa | 2006-01-03 09:55:16 +0100 | [diff] [blame] | 1242 | if (args->new_lock_owner){ |
Trond Myklebust | 4ade982 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1243 | encode_nfs4_seqid(xdr, args->open_seqid); |
Trond Myklebust | ea9d23f | 2012-03-04 18:13:56 -0500 | [diff] [blame] | 1244 | encode_nfs4_stateid(xdr, args->open_stateid); |
Trond Myklebust | 4ade982 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1245 | encode_nfs4_seqid(xdr, args->lock_seqid); |
Trond Myklebust | daccbde | 2010-06-25 18:11:43 -0400 | [diff] [blame] | 1246 | encode_lockowner(xdr, &args->lock_owner); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1247 | } |
| 1248 | else { |
Trond Myklebust | ea9d23f | 2012-03-04 18:13:56 -0500 | [diff] [blame] | 1249 | encode_nfs4_stateid(xdr, args->lock_stateid); |
Trond Myklebust | 4ade982 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1250 | encode_nfs4_seqid(xdr, args->lock_seqid); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1251 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1252 | } |
| 1253 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1254 | 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] | 1255 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 1256 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1257 | |
Trond Myklebust | 475d4ba | 2012-03-05 11:27:16 -0500 | [diff] [blame] | 1258 | encode_op_hdr(xdr, OP_LOCKT, decode_lockt_maxsz, hdr); |
| 1259 | p = reserve_space(xdr, 20); |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1260 | *p++ = cpu_to_be32(nfs4_lock_type(args->fl, 0)); |
Benny Halevy | b95be5a | 2009-08-14 17:19:01 +0300 | [diff] [blame] | 1261 | p = xdr_encode_hyper(p, args->fl->fl_start); |
| 1262 | p = xdr_encode_hyper(p, nfs4_lock_length(args->fl)); |
Trond Myklebust | daccbde | 2010-06-25 18:11:43 -0400 | [diff] [blame] | 1263 | encode_lockowner(xdr, &args->lock_owner); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1264 | } |
| 1265 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1266 | 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] | 1267 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 1268 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1269 | |
Trond Myklebust | 475d4ba | 2012-03-05 11:27:16 -0500 | [diff] [blame] | 1270 | encode_op_hdr(xdr, OP_LOCKU, decode_locku_maxsz, hdr); |
| 1271 | encode_uint32(xdr, nfs4_lock_type(args->fl, 0)); |
Trond Myklebust | 4ade982 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1272 | encode_nfs4_seqid(xdr, args->seqid); |
Trond Myklebust | ea9d23f | 2012-03-04 18:13:56 -0500 | [diff] [blame] | 1273 | encode_nfs4_stateid(xdr, args->stateid); |
| 1274 | p = reserve_space(xdr, 16); |
Benny Halevy | b95be5a | 2009-08-14 17:19:01 +0300 | [diff] [blame] | 1275 | p = xdr_encode_hyper(p, args->fl->fl_start); |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1276 | xdr_encode_hyper(p, nfs4_lock_length(args->fl)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1277 | } |
| 1278 | |
Trond Myklebust | d3c7b7c | 2010-07-01 12:49:01 -0400 | [diff] [blame] | 1279 | static void encode_release_lockowner(struct xdr_stream *xdr, const struct nfs_lowner *lowner, struct compound_hdr *hdr) |
| 1280 | { |
Trond Myklebust | ab19b48 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1281 | encode_op_hdr(xdr, OP_RELEASE_LOCKOWNER, decode_release_lockowner_maxsz, hdr); |
Trond Myklebust | d3c7b7c | 2010-07-01 12:49:01 -0400 | [diff] [blame] | 1282 | encode_lockowner(xdr, lowner); |
Trond Myklebust | d3c7b7c | 2010-07-01 12:49:01 -0400 | [diff] [blame] | 1283 | } |
| 1284 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1285 | 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] | 1286 | { |
Trond Myklebust | ab19b48 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1287 | encode_op_hdr(xdr, OP_LOOKUP, decode_lookup_maxsz, hdr); |
Trond Myklebust | 6fdfb0bc | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1288 | encode_string(xdr, name->len, name->name); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1289 | } |
| 1290 | |
Trond Myklebust | dc0b027 | 2008-12-23 15:21:56 -0500 | [diff] [blame] | 1291 | static void encode_share_access(struct xdr_stream *xdr, fmode_t fmode) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1292 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 1293 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1294 | |
Benny Halevy | 13c65ce | 2009-08-14 17:19:25 +0300 | [diff] [blame] | 1295 | p = reserve_space(xdr, 8); |
Trond Myklebust | dc0b027 | 2008-12-23 15:21:56 -0500 | [diff] [blame] | 1296 | switch (fmode & (FMODE_READ|FMODE_WRITE)) { |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 1297 | case FMODE_READ: |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1298 | *p++ = cpu_to_be32(NFS4_SHARE_ACCESS_READ); |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 1299 | break; |
| 1300 | case FMODE_WRITE: |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1301 | *p++ = cpu_to_be32(NFS4_SHARE_ACCESS_WRITE); |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 1302 | break; |
| 1303 | case FMODE_READ|FMODE_WRITE: |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1304 | *p++ = cpu_to_be32(NFS4_SHARE_ACCESS_BOTH); |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 1305 | break; |
| 1306 | default: |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1307 | *p++ = cpu_to_be32(0); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1308 | } |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1309 | *p = cpu_to_be32(0); /* for linux, share_deny = 0 always */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1310 | } |
| 1311 | |
| 1312 | static inline void encode_openhdr(struct xdr_stream *xdr, const struct nfs_openargs *arg) |
| 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 | /* |
| 1316 | * opcode 4, seqid 4, share_access 4, share_deny 4, clientid 8, ownerlen 4, |
| 1317 | * owner 4 = 32 |
| 1318 | */ |
Trond Myklebust | 4ade982 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1319 | encode_nfs4_seqid(xdr, arg->seqid); |
Trond Myklebust | dc0b027 | 2008-12-23 15:21:56 -0500 | [diff] [blame] | 1320 | encode_share_access(xdr, arg->fmode); |
Trond Myklebust | 95b72eb | 2012-04-20 19:24:51 -0400 | [diff] [blame] | 1321 | p = reserve_space(xdr, 36); |
Benny Halevy | b95be5a | 2009-08-14 17:19:01 +0300 | [diff] [blame] | 1322 | p = xdr_encode_hyper(p, arg->clientid); |
Trond Myklebust | 95b72eb | 2012-04-20 19:24:51 -0400 | [diff] [blame] | 1323 | *p++ = cpu_to_be32(24); |
Benny Halevy | 93f0cf2 | 2009-08-14 17:19:06 +0300 | [diff] [blame] | 1324 | p = xdr_encode_opaque_fixed(p, "open id:", 8); |
Trond Myklebust | d035c36 | 2010-12-21 10:45:27 -0500 | [diff] [blame] | 1325 | *p++ = cpu_to_be32(arg->server->s_dev); |
Trond Myklebust | 95b72eb | 2012-04-20 19:24:51 -0400 | [diff] [blame] | 1326 | *p++ = cpu_to_be32(arg->id.uniquifier); |
| 1327 | xdr_encode_hyper(p, arg->id.create_time); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1328 | } |
| 1329 | |
| 1330 | static inline void encode_createmode(struct xdr_stream *xdr, const struct nfs_openargs *arg) |
| 1331 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 1332 | __be32 *p; |
Alexandros Batsakis | 4882ef7 | 2009-12-05 13:30:21 -0500 | [diff] [blame] | 1333 | struct nfs_client *clp; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1334 | |
Benny Halevy | 13c65ce | 2009-08-14 17:19:25 +0300 | [diff] [blame] | 1335 | p = reserve_space(xdr, 4); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1336 | switch(arg->open_flags & O_EXCL) { |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 1337 | case 0: |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1338 | *p = cpu_to_be32(NFS4_CREATE_UNCHECKED); |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 1339 | encode_attrs(xdr, arg->u.attrs, arg->server); |
| 1340 | break; |
| 1341 | default: |
Alexandros Batsakis | 4882ef7 | 2009-12-05 13:30:21 -0500 | [diff] [blame] | 1342 | clp = arg->server->nfs_client; |
Trond Myklebust | a443234 | 2010-06-16 09:52:27 -0400 | [diff] [blame] | 1343 | if (clp->cl_mvops->minor_version > 0) { |
Alexandros Batsakis | 4882ef7 | 2009-12-05 13:30:21 -0500 | [diff] [blame] | 1344 | if (nfs4_has_persistent_session(clp)) { |
| 1345 | *p = cpu_to_be32(NFS4_CREATE_GUARDED); |
| 1346 | encode_attrs(xdr, arg->u.attrs, arg->server); |
| 1347 | } else { |
| 1348 | struct iattr dummy; |
| 1349 | |
| 1350 | *p = cpu_to_be32(NFS4_CREATE_EXCLUSIVE4_1); |
| 1351 | encode_nfs4_verifier(xdr, &arg->u.verifier); |
| 1352 | dummy.ia_valid = 0; |
| 1353 | encode_attrs(xdr, &dummy, arg->server); |
| 1354 | } |
| 1355 | } else { |
| 1356 | *p = cpu_to_be32(NFS4_CREATE_EXCLUSIVE); |
| 1357 | encode_nfs4_verifier(xdr, &arg->u.verifier); |
| 1358 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1359 | } |
| 1360 | } |
| 1361 | |
| 1362 | static void encode_opentype(struct xdr_stream *xdr, const struct nfs_openargs *arg) |
| 1363 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 1364 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1365 | |
Benny Halevy | 13c65ce | 2009-08-14 17:19:25 +0300 | [diff] [blame] | 1366 | p = reserve_space(xdr, 4); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1367 | switch (arg->open_flags & O_CREAT) { |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 1368 | case 0: |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1369 | *p = cpu_to_be32(NFS4_OPEN_NOCREATE); |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 1370 | break; |
| 1371 | default: |
| 1372 | BUG_ON(arg->claim != NFS4_OPEN_CLAIM_NULL); |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1373 | *p = cpu_to_be32(NFS4_OPEN_CREATE); |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 1374 | encode_createmode(xdr, arg); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1375 | } |
| 1376 | } |
| 1377 | |
Trond Myklebust | bd7bf9d | 2008-12-23 15:21:53 -0500 | [diff] [blame] | 1378 | 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] | 1379 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 1380 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1381 | |
Benny Halevy | 13c65ce | 2009-08-14 17:19:25 +0300 | [diff] [blame] | 1382 | p = reserve_space(xdr, 4); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1383 | switch (delegation_type) { |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 1384 | case 0: |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1385 | *p = cpu_to_be32(NFS4_OPEN_DELEGATE_NONE); |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 1386 | break; |
| 1387 | case FMODE_READ: |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1388 | *p = cpu_to_be32(NFS4_OPEN_DELEGATE_READ); |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 1389 | break; |
| 1390 | case FMODE_WRITE|FMODE_READ: |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1391 | *p = cpu_to_be32(NFS4_OPEN_DELEGATE_WRITE); |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 1392 | break; |
| 1393 | default: |
| 1394 | BUG(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1395 | } |
| 1396 | } |
| 1397 | |
| 1398 | static inline void encode_claim_null(struct xdr_stream *xdr, const struct qstr *name) |
| 1399 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 1400 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1401 | |
Benny Halevy | 13c65ce | 2009-08-14 17:19:25 +0300 | [diff] [blame] | 1402 | p = reserve_space(xdr, 4); |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1403 | *p = cpu_to_be32(NFS4_OPEN_CLAIM_NULL); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1404 | encode_string(xdr, name->len, name->name); |
| 1405 | } |
| 1406 | |
Trond Myklebust | bd7bf9d | 2008-12-23 15:21:53 -0500 | [diff] [blame] | 1407 | 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] | 1408 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 1409 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1410 | |
Benny Halevy | 13c65ce | 2009-08-14 17:19:25 +0300 | [diff] [blame] | 1411 | p = reserve_space(xdr, 4); |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1412 | *p = cpu_to_be32(NFS4_OPEN_CLAIM_PREVIOUS); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1413 | encode_delegation_type(xdr, type); |
| 1414 | } |
| 1415 | |
| 1416 | static inline void encode_claim_delegate_cur(struct xdr_stream *xdr, const struct qstr *name, const nfs4_stateid *stateid) |
| 1417 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 1418 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1419 | |
Trond Myklebust | ea9d23f | 2012-03-04 18:13:56 -0500 | [diff] [blame] | 1420 | p = reserve_space(xdr, 4); |
| 1421 | *p = cpu_to_be32(NFS4_OPEN_CLAIM_DELEGATE_CUR); |
| 1422 | encode_nfs4_stateid(xdr, stateid); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1423 | encode_string(xdr, name->len, name->name); |
| 1424 | } |
| 1425 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1426 | 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] | 1427 | { |
Trond Myklebust | ab19b48 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1428 | encode_op_hdr(xdr, OP_OPEN, decode_open_maxsz, hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1429 | encode_openhdr(xdr, arg); |
| 1430 | encode_opentype(xdr, arg); |
| 1431 | switch (arg->claim) { |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 1432 | case NFS4_OPEN_CLAIM_NULL: |
| 1433 | encode_claim_null(xdr, arg->name); |
| 1434 | break; |
| 1435 | case NFS4_OPEN_CLAIM_PREVIOUS: |
| 1436 | encode_claim_previous(xdr, arg->u.delegation_type); |
| 1437 | break; |
| 1438 | case NFS4_OPEN_CLAIM_DELEGATE_CUR: |
| 1439 | encode_claim_delegate_cur(xdr, arg->name, &arg->u.delegation); |
| 1440 | break; |
| 1441 | default: |
| 1442 | BUG(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1443 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1444 | } |
| 1445 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1446 | 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] | 1447 | { |
Trond Myklebust | ab19b48 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1448 | encode_op_hdr(xdr, OP_OPEN_CONFIRM, decode_open_confirm_maxsz, hdr); |
Trond Myklebust | ea9d23f | 2012-03-04 18:13:56 -0500 | [diff] [blame] | 1449 | encode_nfs4_stateid(xdr, arg->stateid); |
Trond Myklebust | 4ade982 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1450 | encode_nfs4_seqid(xdr, arg->seqid); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1451 | } |
| 1452 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1453 | 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] | 1454 | { |
Trond Myklebust | ab19b48 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1455 | encode_op_hdr(xdr, OP_OPEN_DOWNGRADE, decode_open_downgrade_maxsz, hdr); |
Trond Myklebust | ea9d23f | 2012-03-04 18:13:56 -0500 | [diff] [blame] | 1456 | encode_nfs4_stateid(xdr, arg->stateid); |
Trond Myklebust | 4ade982 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1457 | encode_nfs4_seqid(xdr, arg->seqid); |
Trond Myklebust | dc0b027 | 2008-12-23 15:21:56 -0500 | [diff] [blame] | 1458 | encode_share_access(xdr, arg->fmode); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1459 | } |
| 1460 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1461 | static void |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 1462 | 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] | 1463 | { |
Trond Myklebust | ab19b48 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1464 | encode_op_hdr(xdr, OP_PUTFH, decode_putfh_maxsz, hdr); |
Trond Myklebust | 6fdfb0bc | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1465 | encode_string(xdr, fh->size, fh->data); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1466 | } |
| 1467 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1468 | static void encode_putrootfh(struct xdr_stream *xdr, struct compound_hdr *hdr) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1469 | { |
Trond Myklebust | ab19b48 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1470 | encode_op_hdr(xdr, OP_PUTROOTFH, decode_putrootfh_maxsz, hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1471 | } |
| 1472 | |
Trond Myklebust | 4fc8796 | 2012-03-08 17:42:01 -0500 | [diff] [blame] | 1473 | static void encode_open_stateid(struct xdr_stream *xdr, |
| 1474 | const struct nfs_open_context *ctx, |
| 1475 | const struct nfs_lock_context *l_ctx, |
| 1476 | fmode_t fmode, |
| 1477 | int zero_seqid) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1478 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1479 | nfs4_stateid stateid; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1480 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1481 | if (ctx->state != NULL) { |
Trond Myklebust | 4fc8796 | 2012-03-08 17:42:01 -0500 | [diff] [blame] | 1482 | nfs4_select_rw_stateid(&stateid, ctx->state, |
| 1483 | fmode, l_ctx->lockowner, l_ctx->pid); |
Andy Adamson | 89d1ea6 | 2011-03-01 01:34:09 +0000 | [diff] [blame] | 1484 | if (zero_seqid) |
Trond Myklebust | 2d2f24a | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1485 | stateid.seqid = 0; |
Trond Myklebust | ea9d23f | 2012-03-04 18:13:56 -0500 | [diff] [blame] | 1486 | encode_nfs4_stateid(xdr, &stateid); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1487 | } else |
Trond Myklebust | ea9d23f | 2012-03-04 18:13:56 -0500 | [diff] [blame] | 1488 | encode_nfs4_stateid(xdr, &zero_stateid); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1489 | } |
| 1490 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1491 | static void encode_read(struct xdr_stream *xdr, const struct nfs_readargs *args, struct compound_hdr *hdr) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1492 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 1493 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1494 | |
Trond Myklebust | ab19b48 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1495 | encode_op_hdr(xdr, OP_READ, decode_read_maxsz, hdr); |
Trond Myklebust | d0b496d | 2012-03-04 18:13:56 -0500 | [diff] [blame] | 1496 | encode_open_stateid(xdr, args->context, args->lock_context, |
Trond Myklebust | 4fc8796 | 2012-03-08 17:42:01 -0500 | [diff] [blame] | 1497 | FMODE_READ, hdr->minorversion); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1498 | |
Benny Halevy | 13c65ce | 2009-08-14 17:19:25 +0300 | [diff] [blame] | 1499 | p = reserve_space(xdr, 12); |
Benny Halevy | b95be5a | 2009-08-14 17:19:01 +0300 | [diff] [blame] | 1500 | p = xdr_encode_hyper(p, args->offset); |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1501 | *p = cpu_to_be32(args->count); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1502 | } |
| 1503 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1504 | 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] | 1505 | { |
Trond Myklebust | 28331a4 | 2011-04-27 13:47:52 -0400 | [diff] [blame] | 1506 | uint32_t attrs[2] = { |
| 1507 | FATTR4_WORD0_RDATTR_ERROR, |
| 1508 | FATTR4_WORD1_MOUNTED_ON_FILEID, |
| 1509 | }; |
Trond Myklebust | 6f7a35b | 2010-10-24 12:11:42 -0400 | [diff] [blame] | 1510 | uint32_t dircount = readdir->count >> 1; |
Chuck Lever | cd93710 | 2012-03-02 17:14:31 -0500 | [diff] [blame] | 1511 | __be32 *p, verf[2]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1512 | |
Bryan Schumaker | 82f2e54 | 2010-10-21 16:33:18 -0400 | [diff] [blame] | 1513 | if (readdir->plus) { |
| 1514 | attrs[0] |= FATTR4_WORD0_TYPE|FATTR4_WORD0_CHANGE|FATTR4_WORD0_SIZE| |
Trond Myklebust | 28331a4 | 2011-04-27 13:47:52 -0400 | [diff] [blame] | 1515 | FATTR4_WORD0_FSID|FATTR4_WORD0_FILEHANDLE|FATTR4_WORD0_FILEID; |
Bryan Schumaker | 82f2e54 | 2010-10-21 16:33:18 -0400 | [diff] [blame] | 1516 | attrs[1] |= FATTR4_WORD1_MODE|FATTR4_WORD1_NUMLINKS|FATTR4_WORD1_OWNER| |
| 1517 | FATTR4_WORD1_OWNER_GROUP|FATTR4_WORD1_RAWDEV| |
| 1518 | FATTR4_WORD1_SPACE_USED|FATTR4_WORD1_TIME_ACCESS| |
| 1519 | FATTR4_WORD1_TIME_METADATA|FATTR4_WORD1_TIME_MODIFY; |
Trond Myklebust | 6f7a35b | 2010-10-24 12:11:42 -0400 | [diff] [blame] | 1520 | dircount >>= 1; |
Bryan Schumaker | 82f2e54 | 2010-10-21 16:33:18 -0400 | [diff] [blame] | 1521 | } |
Trond Myklebust | 28331a4 | 2011-04-27 13:47:52 -0400 | [diff] [blame] | 1522 | /* Use mounted_on_fileid only if the server supports it */ |
| 1523 | if (!(readdir->bitmask[1] & FATTR4_WORD1_MOUNTED_ON_FILEID)) |
| 1524 | attrs[0] |= FATTR4_WORD0_FILEID; |
Bryan Schumaker | 82f2e54 | 2010-10-21 16:33:18 -0400 | [diff] [blame] | 1525 | |
Trond Myklebust | 475d4ba | 2012-03-05 11:27:16 -0500 | [diff] [blame] | 1526 | encode_op_hdr(xdr, OP_READDIR, decode_readdir_maxsz, hdr); |
Trond Myklebust | ff2eb68 | 2012-03-05 11:40:12 -0500 | [diff] [blame] | 1527 | encode_uint64(xdr, readdir->cookie); |
Chuck Lever | cd93710 | 2012-03-02 17:14:31 -0500 | [diff] [blame] | 1528 | encode_nfs4_verifier(xdr, &readdir->verifier); |
| 1529 | p = reserve_space(xdr, 20); |
Trond Myklebust | 6f7a35b | 2010-10-24 12:11:42 -0400 | [diff] [blame] | 1530 | *p++ = cpu_to_be32(dircount); |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1531 | *p++ = cpu_to_be32(readdir->count); |
| 1532 | *p++ = cpu_to_be32(2); |
Bryan Schumaker | 82f2e54 | 2010-10-21 16:33:18 -0400 | [diff] [blame] | 1533 | |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1534 | *p++ = cpu_to_be32(attrs[0] & readdir->bitmask[0]); |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1535 | *p = cpu_to_be32(attrs[1] & readdir->bitmask[1]); |
Chuck Lever | cd93710 | 2012-03-02 17:14:31 -0500 | [diff] [blame] | 1536 | memcpy(verf, readdir->verifier.data, sizeof(verf)); |
Fred Isaman | 4410924 | 2008-04-02 15:21:15 +0300 | [diff] [blame] | 1537 | dprintk("%s: cookie = %Lu, verifier = %08x:%08x, bitmap = %08x:%08x\n", |
| 1538 | __func__, |
Trond Myklebust | eadf459 | 2005-06-22 17:16:39 +0000 | [diff] [blame] | 1539 | (unsigned long long)readdir->cookie, |
Chuck Lever | cd93710 | 2012-03-02 17:14:31 -0500 | [diff] [blame] | 1540 | verf[0], verf[1], |
Trond Myklebust | eadf459 | 2005-06-22 17:16:39 +0000 | [diff] [blame] | 1541 | attrs[0] & readdir->bitmask[0], |
| 1542 | attrs[1] & readdir->bitmask[1]); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1543 | } |
| 1544 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1545 | 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] | 1546 | { |
Trond Myklebust | ab19b48 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1547 | encode_op_hdr(xdr, OP_READLINK, decode_readlink_maxsz, hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1548 | } |
| 1549 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1550 | 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] | 1551 | { |
Trond Myklebust | ab19b48 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1552 | encode_op_hdr(xdr, OP_REMOVE, decode_remove_maxsz, hdr); |
Trond Myklebust | 6fdfb0bc | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1553 | encode_string(xdr, name->len, name->name); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1554 | } |
| 1555 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1556 | 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] | 1557 | { |
Trond Myklebust | ab19b48 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1558 | encode_op_hdr(xdr, OP_RENAME, decode_rename_maxsz, hdr); |
Benny Halevy | 811652b | 2009-08-14 17:19:34 +0300 | [diff] [blame] | 1559 | encode_string(xdr, oldname->len, oldname->name); |
| 1560 | encode_string(xdr, newname->len, newname->name); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1561 | } |
| 1562 | |
Chuck Lever | bb4dae5 | 2012-03-01 17:01:48 -0500 | [diff] [blame] | 1563 | static void encode_renew(struct xdr_stream *xdr, clientid4 clid, |
| 1564 | struct compound_hdr *hdr) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1565 | { |
Trond Myklebust | 475d4ba | 2012-03-05 11:27:16 -0500 | [diff] [blame] | 1566 | encode_op_hdr(xdr, OP_RENEW, decode_renew_maxsz, hdr); |
Trond Myklebust | ff2eb68 | 2012-03-05 11:40:12 -0500 | [diff] [blame] | 1567 | encode_uint64(xdr, clid); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1568 | } |
| 1569 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1570 | static void |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 1571 | encode_restorefh(struct xdr_stream *xdr, struct compound_hdr *hdr) |
Trond Myklebust | 56ae19f | 2005-10-27 22:12:40 -0400 | [diff] [blame] | 1572 | { |
Trond Myklebust | ab19b48 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1573 | encode_op_hdr(xdr, OP_RESTOREFH, decode_restorefh_maxsz, hdr); |
Trond Myklebust | 56ae19f | 2005-10-27 22:12:40 -0400 | [diff] [blame] | 1574 | } |
| 1575 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 1576 | static void |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 1577 | 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] | 1578 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 1579 | __be32 *p; |
J. Bruce Fields | 23ec696 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 1580 | |
Trond Myklebust | ab19b48 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1581 | encode_op_hdr(xdr, OP_SETATTR, decode_setacl_maxsz, hdr); |
Trond Myklebust | ea9d23f | 2012-03-04 18:13:56 -0500 | [diff] [blame] | 1582 | encode_nfs4_stateid(xdr, &zero_stateid); |
Benny Halevy | 13c65ce | 2009-08-14 17:19:25 +0300 | [diff] [blame] | 1583 | p = reserve_space(xdr, 2*4); |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1584 | *p++ = cpu_to_be32(1); |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1585 | *p = cpu_to_be32(FATTR4_WORD0_ACL); |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 1586 | BUG_ON(arg->acl_len % 4); |
Benny Halevy | 13c65ce | 2009-08-14 17:19:25 +0300 | [diff] [blame] | 1587 | p = reserve_space(xdr, 4); |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1588 | *p = cpu_to_be32(arg->acl_len); |
J. Bruce Fields | 23ec696 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 1589 | 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] | 1590 | } |
| 1591 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1592 | static void |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 1593 | encode_savefh(struct xdr_stream *xdr, struct compound_hdr *hdr) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1594 | { |
Trond Myklebust | ab19b48 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1595 | encode_op_hdr(xdr, OP_SAVEFH, decode_savefh_maxsz, hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1596 | } |
| 1597 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1598 | 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] | 1599 | { |
Trond Myklebust | ab19b48 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1600 | encode_op_hdr(xdr, OP_SETATTR, decode_setattr_maxsz, hdr); |
Trond Myklebust | ea9d23f | 2012-03-04 18:13:56 -0500 | [diff] [blame] | 1601 | encode_nfs4_stateid(xdr, &arg->stateid); |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1602 | encode_attrs(xdr, arg->iap, server); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1603 | } |
| 1604 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1605 | 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] | 1606 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 1607 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1608 | |
Trond Myklebust | 7001951 | 2012-03-04 20:49:32 -0500 | [diff] [blame] | 1609 | encode_op_hdr(xdr, OP_SETCLIENTID, decode_setclientid_maxsz, hdr); |
Chuck Lever | cd93710 | 2012-03-02 17:14:31 -0500 | [diff] [blame] | 1610 | encode_nfs4_verifier(xdr, setclientid->sc_verifier); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1611 | |
| 1612 | encode_string(xdr, setclientid->sc_name_len, setclientid->sc_name); |
Benny Halevy | 13c65ce | 2009-08-14 17:19:25 +0300 | [diff] [blame] | 1613 | p = reserve_space(xdr, 4); |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1614 | *p = cpu_to_be32(setclientid->sc_prog); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1615 | encode_string(xdr, setclientid->sc_netid_len, setclientid->sc_netid); |
| 1616 | encode_string(xdr, setclientid->sc_uaddr_len, setclientid->sc_uaddr); |
Benny Halevy | 13c65ce | 2009-08-14 17:19:25 +0300 | [diff] [blame] | 1617 | p = reserve_space(xdr, 4); |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1618 | *p = cpu_to_be32(setclientid->sc_cb_ident); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1619 | } |
| 1620 | |
Trond Myklebust | bb8b27e | 2010-04-16 16:43:06 -0400 | [diff] [blame] | 1621 | 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] | 1622 | { |
Trond Myklebust | 475d4ba | 2012-03-05 11:27:16 -0500 | [diff] [blame] | 1623 | encode_op_hdr(xdr, OP_SETCLIENTID_CONFIRM, |
| 1624 | decode_setclientid_confirm_maxsz, hdr); |
Trond Myklebust | ff2eb68 | 2012-03-05 11:40:12 -0500 | [diff] [blame] | 1625 | encode_uint64(xdr, arg->clientid); |
Chuck Lever | cd93710 | 2012-03-02 17:14:31 -0500 | [diff] [blame] | 1626 | encode_nfs4_verifier(xdr, &arg->confirm); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1627 | } |
| 1628 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1629 | static void encode_write(struct xdr_stream *xdr, const struct nfs_writeargs *args, struct compound_hdr *hdr) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1630 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 1631 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1632 | |
Trond Myklebust | ab19b48 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1633 | encode_op_hdr(xdr, OP_WRITE, decode_write_maxsz, hdr); |
Trond Myklebust | d0b496d | 2012-03-04 18:13:56 -0500 | [diff] [blame] | 1634 | encode_open_stateid(xdr, args->context, args->lock_context, |
Trond Myklebust | 4fc8796 | 2012-03-08 17:42:01 -0500 | [diff] [blame] | 1635 | FMODE_WRITE, hdr->minorversion); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1636 | |
Benny Halevy | 13c65ce | 2009-08-14 17:19:25 +0300 | [diff] [blame] | 1637 | p = reserve_space(xdr, 16); |
Benny Halevy | b95be5a | 2009-08-14 17:19:01 +0300 | [diff] [blame] | 1638 | p = xdr_encode_hyper(p, args->offset); |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1639 | *p++ = cpu_to_be32(args->stable); |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1640 | *p = cpu_to_be32(args->count); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1641 | |
| 1642 | xdr_write_pages(xdr, args->pages, args->pgbase, args->count); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1643 | } |
| 1644 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1645 | 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] | 1646 | { |
Trond Myklebust | ab19b48 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1647 | encode_op_hdr(xdr, OP_DELEGRETURN, decode_delegreturn_maxsz, hdr); |
Trond Myklebust | ea9d23f | 2012-03-04 18:13:56 -0500 | [diff] [blame] | 1648 | encode_nfs4_stateid(xdr, stateid); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1649 | } |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 1650 | |
Bryan Schumaker | 5a5ea0d | 2011-03-24 17:12:29 +0000 | [diff] [blame] | 1651 | static void encode_secinfo(struct xdr_stream *xdr, const struct qstr *name, struct compound_hdr *hdr) |
| 1652 | { |
Trond Myklebust | ab19b48 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1653 | encode_op_hdr(xdr, OP_SECINFO, decode_secinfo_maxsz, hdr); |
Trond Myklebust | 6fdfb0bc | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1654 | encode_string(xdr, name->len, name->name); |
Bryan Schumaker | 5a5ea0d | 2011-03-24 17:12:29 +0000 | [diff] [blame] | 1655 | } |
| 1656 | |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 1657 | #if defined(CONFIG_NFS_V4_1) |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 1658 | /* NFSv4.1 operations */ |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 1659 | static void encode_exchange_id(struct xdr_stream *xdr, |
| 1660 | struct nfs41_exchange_id_args *args, |
| 1661 | struct compound_hdr *hdr) |
| 1662 | { |
| 1663 | __be32 *p; |
Weston Andros Adamson | db8ac8b | 2012-02-17 15:20:24 -0500 | [diff] [blame] | 1664 | char impl_name[NFS4_OPAQUE_LIMIT]; |
| 1665 | int len = 0; |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 1666 | |
Trond Myklebust | 7001951 | 2012-03-04 20:49:32 -0500 | [diff] [blame] | 1667 | encode_op_hdr(xdr, OP_EXCHANGE_ID, decode_exchange_id_maxsz, hdr); |
Chuck Lever | cd93710 | 2012-03-02 17:14:31 -0500 | [diff] [blame] | 1668 | encode_nfs4_verifier(xdr, args->verifier); |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 1669 | |
| 1670 | encode_string(xdr, args->id_len, args->id); |
| 1671 | |
Benny Halevy | 13c65ce | 2009-08-14 17:19:25 +0300 | [diff] [blame] | 1672 | p = reserve_space(xdr, 12); |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1673 | *p++ = cpu_to_be32(args->flags); |
| 1674 | *p++ = cpu_to_be32(0); /* zero length state_protect4_a */ |
Weston Andros Adamson | db8ac8b | 2012-02-17 15:20:24 -0500 | [diff] [blame] | 1675 | |
| 1676 | if (send_implementation_id && |
| 1677 | sizeof(CONFIG_NFS_V4_1_IMPLEMENTATION_ID_DOMAIN) > 1 && |
| 1678 | sizeof(CONFIG_NFS_V4_1_IMPLEMENTATION_ID_DOMAIN) |
| 1679 | <= NFS4_OPAQUE_LIMIT + 1) |
| 1680 | len = snprintf(impl_name, sizeof(impl_name), "%s %s %s %s", |
| 1681 | utsname()->sysname, utsname()->release, |
| 1682 | utsname()->version, utsname()->machine); |
| 1683 | |
| 1684 | if (len > 0) { |
| 1685 | *p = cpu_to_be32(1); /* implementation id array length=1 */ |
| 1686 | |
| 1687 | encode_string(xdr, |
| 1688 | sizeof(CONFIG_NFS_V4_1_IMPLEMENTATION_ID_DOMAIN) - 1, |
| 1689 | CONFIG_NFS_V4_1_IMPLEMENTATION_ID_DOMAIN); |
| 1690 | encode_string(xdr, len, impl_name); |
| 1691 | /* just send zeros for nii_date - the date is in nii_name */ |
| 1692 | p = reserve_space(xdr, 12); |
| 1693 | p = xdr_encode_hyper(p, 0); |
| 1694 | *p = cpu_to_be32(0); |
| 1695 | } else |
| 1696 | *p = cpu_to_be32(0); /* implementation id array length=0 */ |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 1697 | } |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 1698 | |
| 1699 | static void encode_create_session(struct xdr_stream *xdr, |
| 1700 | struct nfs41_create_session_args *args, |
| 1701 | struct compound_hdr *hdr) |
| 1702 | { |
| 1703 | __be32 *p; |
| 1704 | char machine_name[NFS4_MAX_MACHINE_NAME_LEN]; |
| 1705 | uint32_t len; |
| 1706 | struct nfs_client *clp = args->client; |
Chuck Lever | f092075 | 2012-05-21 22:45:41 -0400 | [diff] [blame^] | 1707 | struct nfs_net *nn = net_generic(clp->cl_net, nfs_net_id); |
Mike Sager | 8e0d46e | 2009-12-17 12:06:26 -0500 | [diff] [blame] | 1708 | u32 max_resp_sz_cached; |
| 1709 | |
| 1710 | /* |
| 1711 | * Assumes OPEN is the biggest non-idempotent compound. |
| 1712 | * 2 is the verifier. |
| 1713 | */ |
| 1714 | max_resp_sz_cached = (NFS4_dec_open_sz + RPC_REPHDRSIZE + |
| 1715 | RPC_MAX_AUTH_SIZE + 2) * XDR_UNIT; |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 1716 | |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 1717 | len = scnprintf(machine_name, sizeof(machine_name), "%s", |
| 1718 | clp->cl_ipaddr); |
Benny Halevy | 42edd69 | 2009-08-14 17:19:13 +0300 | [diff] [blame] | 1719 | |
Trond Myklebust | 475d4ba | 2012-03-05 11:27:16 -0500 | [diff] [blame] | 1720 | encode_op_hdr(xdr, OP_CREATE_SESSION, decode_create_session_maxsz, hdr); |
| 1721 | p = reserve_space(xdr, 16 + 2*28 + 20 + len + 12); |
Andy Adamson | 114f64b | 2011-03-09 13:13:45 -0500 | [diff] [blame] | 1722 | p = xdr_encode_hyper(p, clp->cl_clientid); |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1723 | *p++ = cpu_to_be32(clp->cl_seqid); /*Sequence id */ |
| 1724 | *p++ = cpu_to_be32(args->flags); /*flags */ |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 1725 | |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 1726 | /* Fore Channel */ |
Benny Halevy | c9c30dd | 2011-06-11 17:08:39 -0400 | [diff] [blame] | 1727 | *p++ = cpu_to_be32(0); /* header padding size */ |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1728 | *p++ = cpu_to_be32(args->fc_attrs.max_rqst_sz); /* max req size */ |
| 1729 | *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] | 1730 | *p++ = cpu_to_be32(max_resp_sz_cached); /* Max resp sz cached */ |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1731 | *p++ = cpu_to_be32(args->fc_attrs.max_ops); /* max operations */ |
| 1732 | *p++ = cpu_to_be32(args->fc_attrs.max_reqs); /* max requests */ |
| 1733 | *p++ = cpu_to_be32(0); /* rdmachannel_attrs */ |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 1734 | |
| 1735 | /* Back Channel */ |
Benny Halevy | c9c30dd | 2011-06-11 17:08:39 -0400 | [diff] [blame] | 1736 | *p++ = cpu_to_be32(0); /* header padding size */ |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1737 | *p++ = cpu_to_be32(args->bc_attrs.max_rqst_sz); /* max req size */ |
| 1738 | *p++ = cpu_to_be32(args->bc_attrs.max_resp_sz); /* max resp size */ |
| 1739 | *p++ = cpu_to_be32(args->bc_attrs.max_resp_sz_cached); /* Max resp sz cached */ |
| 1740 | *p++ = cpu_to_be32(args->bc_attrs.max_ops); /* max operations */ |
| 1741 | *p++ = cpu_to_be32(args->bc_attrs.max_reqs); /* max requests */ |
| 1742 | *p++ = cpu_to_be32(0); /* rdmachannel_attrs */ |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 1743 | |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1744 | *p++ = cpu_to_be32(args->cb_program); /* cb_program */ |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1745 | *p++ = cpu_to_be32(1); |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1746 | *p++ = cpu_to_be32(RPC_AUTH_UNIX); /* auth_sys */ |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 1747 | |
| 1748 | /* authsys_parms rfc1831 */ |
Chuck Lever | f092075 | 2012-05-21 22:45:41 -0400 | [diff] [blame^] | 1749 | *p++ = (__be32)nn->boot_time.tv_nsec; /* stamp */ |
Benny Halevy | 811652b | 2009-08-14 17:19:34 +0300 | [diff] [blame] | 1750 | p = xdr_encode_opaque(p, machine_name, len); |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1751 | *p++ = cpu_to_be32(0); /* UID */ |
| 1752 | *p++ = cpu_to_be32(0); /* GID */ |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1753 | *p = cpu_to_be32(0); /* No more gids */ |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 1754 | } |
Andy Adamson | 0f3e66c | 2009-04-01 09:22:34 -0400 | [diff] [blame] | 1755 | |
| 1756 | static void encode_destroy_session(struct xdr_stream *xdr, |
| 1757 | struct nfs4_session *session, |
| 1758 | struct compound_hdr *hdr) |
| 1759 | { |
Trond Myklebust | 475d4ba | 2012-03-05 11:27:16 -0500 | [diff] [blame] | 1760 | encode_op_hdr(xdr, OP_DESTROY_SESSION, decode_destroy_session_maxsz, hdr); |
| 1761 | encode_opaque_fixed(xdr, session->sess_id.data, NFS4_MAX_SESSIONID_LEN); |
Andy Adamson | 0f3e66c | 2009-04-01 09:22:34 -0400 | [diff] [blame] | 1762 | } |
Ricardo Labiaga | 18019753 | 2009-12-05 16:08:40 -0500 | [diff] [blame] | 1763 | |
| 1764 | static void encode_reclaim_complete(struct xdr_stream *xdr, |
| 1765 | struct nfs41_reclaim_complete_args *args, |
| 1766 | struct compound_hdr *hdr) |
| 1767 | { |
Trond Myklebust | 475d4ba | 2012-03-05 11:27:16 -0500 | [diff] [blame] | 1768 | encode_op_hdr(xdr, OP_RECLAIM_COMPLETE, decode_reclaim_complete_maxsz, hdr); |
| 1769 | encode_uint32(xdr, args->one_fs); |
Ricardo Labiaga | 18019753 | 2009-12-05 16:08:40 -0500 | [diff] [blame] | 1770 | } |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 1771 | #endif /* CONFIG_NFS_V4_1 */ |
| 1772 | |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 1773 | static void encode_sequence(struct xdr_stream *xdr, |
| 1774 | const struct nfs4_sequence_args *args, |
| 1775 | struct compound_hdr *hdr) |
| 1776 | { |
| 1777 | #if defined(CONFIG_NFS_V4_1) |
| 1778 | struct nfs4_session *session = args->sa_session; |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 1779 | struct nfs4_slot_table *tp; |
| 1780 | struct nfs4_slot *slot; |
| 1781 | __be32 *p; |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 1782 | |
| 1783 | if (!session) |
| 1784 | return; |
| 1785 | |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 1786 | tp = &session->fc_slot_table; |
| 1787 | |
| 1788 | WARN_ON(args->sa_slotid == NFS4_MAX_SLOT_TABLE); |
| 1789 | slot = tp->slots + args->sa_slotid; |
| 1790 | |
Trond Myklebust | 475d4ba | 2012-03-05 11:27:16 -0500 | [diff] [blame] | 1791 | encode_op_hdr(xdr, OP_SEQUENCE, decode_sequence_maxsz, hdr); |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 1792 | |
| 1793 | /* |
| 1794 | * Sessionid + seqid + slotid + max slotid + cache_this |
| 1795 | */ |
| 1796 | dprintk("%s: sessionid=%u:%u:%u:%u seqid=%d slotid=%d " |
| 1797 | "max_slotid=%d cache_this=%d\n", |
| 1798 | __func__, |
| 1799 | ((u32 *)session->sess_id.data)[0], |
| 1800 | ((u32 *)session->sess_id.data)[1], |
| 1801 | ((u32 *)session->sess_id.data)[2], |
| 1802 | ((u32 *)session->sess_id.data)[3], |
| 1803 | slot->seq_nr, args->sa_slotid, |
| 1804 | tp->highest_used_slotid, args->sa_cache_this); |
Trond Myklebust | 475d4ba | 2012-03-05 11:27:16 -0500 | [diff] [blame] | 1805 | p = reserve_space(xdr, NFS4_MAX_SESSIONID_LEN + 16); |
Benny Halevy | 93f0cf2 | 2009-08-14 17:19:06 +0300 | [diff] [blame] | 1806 | 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] | 1807 | *p++ = cpu_to_be32(slot->seq_nr); |
| 1808 | *p++ = cpu_to_be32(args->sa_slotid); |
| 1809 | *p++ = cpu_to_be32(tp->highest_used_slotid); |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1810 | *p = cpu_to_be32(args->sa_cache_this); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 1811 | #endif /* CONFIG_NFS_V4_1 */ |
| 1812 | } |
| 1813 | |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 1814 | #ifdef CONFIG_NFS_V4_1 |
| 1815 | static void |
Andy Adamson | 7f11d8d | 2011-07-30 20:52:35 -0400 | [diff] [blame] | 1816 | encode_getdevicelist(struct xdr_stream *xdr, |
| 1817 | const struct nfs4_getdevicelist_args *args, |
| 1818 | struct compound_hdr *hdr) |
| 1819 | { |
| 1820 | __be32 *p; |
| 1821 | nfs4_verifier dummy = { |
| 1822 | .data = "dummmmmy", |
| 1823 | }; |
| 1824 | |
Trond Myklebust | 475d4ba | 2012-03-05 11:27:16 -0500 | [diff] [blame] | 1825 | encode_op_hdr(xdr, OP_GETDEVICELIST, decode_getdevicelist_maxsz, hdr); |
| 1826 | p = reserve_space(xdr, 16); |
Andy Adamson | 7f11d8d | 2011-07-30 20:52:35 -0400 | [diff] [blame] | 1827 | *p++ = cpu_to_be32(args->layoutclass); |
| 1828 | *p++ = cpu_to_be32(NFS4_PNFS_GETDEVLIST_MAXNUM); |
| 1829 | xdr_encode_hyper(p, 0ULL); /* cookie */ |
| 1830 | encode_nfs4_verifier(xdr, &dummy); |
Andy Adamson | 7f11d8d | 2011-07-30 20:52:35 -0400 | [diff] [blame] | 1831 | } |
| 1832 | |
| 1833 | static void |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 1834 | encode_getdeviceinfo(struct xdr_stream *xdr, |
| 1835 | const struct nfs4_getdeviceinfo_args *args, |
| 1836 | struct compound_hdr *hdr) |
| 1837 | { |
| 1838 | __be32 *p; |
| 1839 | |
Trond Myklebust | 475d4ba | 2012-03-05 11:27:16 -0500 | [diff] [blame] | 1840 | encode_op_hdr(xdr, OP_GETDEVICEINFO, decode_getdeviceinfo_maxsz, hdr); |
| 1841 | p = reserve_space(xdr, 12 + NFS4_DEVICEID4_SIZE); |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 1842 | p = xdr_encode_opaque_fixed(p, args->pdev->dev_id.data, |
| 1843 | NFS4_DEVICEID4_SIZE); |
| 1844 | *p++ = cpu_to_be32(args->pdev->layout_type); |
| 1845 | *p++ = cpu_to_be32(args->pdev->pglen); /* gdia_maxcount */ |
| 1846 | *p++ = cpu_to_be32(0); /* bitmap length 0 */ |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 1847 | } |
| 1848 | |
| 1849 | static void |
| 1850 | encode_layoutget(struct xdr_stream *xdr, |
| 1851 | const struct nfs4_layoutget_args *args, |
| 1852 | struct compound_hdr *hdr) |
| 1853 | { |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 1854 | __be32 *p; |
| 1855 | |
Trond Myklebust | 475d4ba | 2012-03-05 11:27:16 -0500 | [diff] [blame] | 1856 | encode_op_hdr(xdr, OP_LAYOUTGET, decode_layoutget_maxsz, hdr); |
| 1857 | p = reserve_space(xdr, 36); |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 1858 | *p++ = cpu_to_be32(0); /* Signal layout available */ |
| 1859 | *p++ = cpu_to_be32(args->type); |
| 1860 | *p++ = cpu_to_be32(args->range.iomode); |
| 1861 | p = xdr_encode_hyper(p, args->range.offset); |
| 1862 | p = xdr_encode_hyper(p, args->range.length); |
| 1863 | p = xdr_encode_hyper(p, args->minlength); |
Trond Myklebust | ea9d23f | 2012-03-04 18:13:56 -0500 | [diff] [blame] | 1864 | encode_nfs4_stateid(xdr, &args->stateid); |
Trond Myklebust | 475d4ba | 2012-03-05 11:27:16 -0500 | [diff] [blame] | 1865 | encode_uint32(xdr, args->maxcount); |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 1866 | |
| 1867 | dprintk("%s: 1st type:0x%x iomode:%d off:%lu len:%lu mc:%d\n", |
| 1868 | __func__, |
| 1869 | args->type, |
| 1870 | args->range.iomode, |
| 1871 | (unsigned long)args->range.offset, |
| 1872 | (unsigned long)args->range.length, |
| 1873 | args->maxcount); |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 1874 | } |
Andy Adamson | 863a3c6 | 2011-03-23 13:27:54 +0000 | [diff] [blame] | 1875 | |
| 1876 | static int |
| 1877 | encode_layoutcommit(struct xdr_stream *xdr, |
Benny Halevy | ac7db72 | 2011-05-22 19:53:48 +0300 | [diff] [blame] | 1878 | struct inode *inode, |
Andy Adamson | 863a3c6 | 2011-03-23 13:27:54 +0000 | [diff] [blame] | 1879 | const struct nfs4_layoutcommit_args *args, |
| 1880 | struct compound_hdr *hdr) |
| 1881 | { |
| 1882 | __be32 *p; |
| 1883 | |
| 1884 | dprintk("%s: lbw: %llu type: %d\n", __func__, args->lastbytewritten, |
| 1885 | NFS_SERVER(args->inode)->pnfs_curr_ld->id); |
| 1886 | |
Trond Myklebust | 475d4ba | 2012-03-05 11:27:16 -0500 | [diff] [blame] | 1887 | encode_op_hdr(xdr, OP_LAYOUTCOMMIT, decode_layoutcommit_maxsz, hdr); |
| 1888 | p = reserve_space(xdr, 20); |
Andy Adamson | 863a3c6 | 2011-03-23 13:27:54 +0000 | [diff] [blame] | 1889 | /* Only whole file layouts */ |
| 1890 | p = xdr_encode_hyper(p, 0); /* offset */ |
Peng Tao | 3557c6c | 2011-07-30 20:52:34 -0400 | [diff] [blame] | 1891 | p = xdr_encode_hyper(p, args->lastbytewritten + 1); /* length */ |
Trond Myklebust | ea9d23f | 2012-03-04 18:13:56 -0500 | [diff] [blame] | 1892 | *p = cpu_to_be32(0); /* reclaim */ |
| 1893 | encode_nfs4_stateid(xdr, &args->stateid); |
| 1894 | p = reserve_space(xdr, 20); |
Andy Adamson | 863a3c6 | 2011-03-23 13:27:54 +0000 | [diff] [blame] | 1895 | *p++ = cpu_to_be32(1); /* newoffset = TRUE */ |
| 1896 | p = xdr_encode_hyper(p, args->lastbytewritten); |
| 1897 | *p++ = cpu_to_be32(0); /* Never send time_modify_changed */ |
| 1898 | *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] | 1899 | |
| 1900 | if (NFS_SERVER(inode)->pnfs_curr_ld->encode_layoutcommit) |
| 1901 | NFS_SERVER(inode)->pnfs_curr_ld->encode_layoutcommit( |
| 1902 | NFS_I(inode)->layout, xdr, args); |
Trond Myklebust | 475d4ba | 2012-03-05 11:27:16 -0500 | [diff] [blame] | 1903 | else |
| 1904 | encode_uint32(xdr, 0); /* no layout-type payload */ |
Andy Adamson | 863a3c6 | 2011-03-23 13:27:54 +0000 | [diff] [blame] | 1905 | |
Andy Adamson | 863a3c6 | 2011-03-23 13:27:54 +0000 | [diff] [blame] | 1906 | return 0; |
| 1907 | } |
Benny Halevy | cbe8260 | 2011-05-22 19:52:37 +0300 | [diff] [blame] | 1908 | |
| 1909 | static void |
| 1910 | encode_layoutreturn(struct xdr_stream *xdr, |
| 1911 | const struct nfs4_layoutreturn_args *args, |
| 1912 | struct compound_hdr *hdr) |
| 1913 | { |
| 1914 | __be32 *p; |
| 1915 | |
Trond Myklebust | 475d4ba | 2012-03-05 11:27:16 -0500 | [diff] [blame] | 1916 | encode_op_hdr(xdr, OP_LAYOUTRETURN, decode_layoutreturn_maxsz, hdr); |
| 1917 | p = reserve_space(xdr, 16); |
Benny Halevy | cbe8260 | 2011-05-22 19:52:37 +0300 | [diff] [blame] | 1918 | *p++ = cpu_to_be32(0); /* reclaim. always 0 for now */ |
| 1919 | *p++ = cpu_to_be32(args->layout_type); |
| 1920 | *p++ = cpu_to_be32(IOMODE_ANY); |
| 1921 | *p = cpu_to_be32(RETURN_FILE); |
Trond Myklebust | ea9d23f | 2012-03-04 18:13:56 -0500 | [diff] [blame] | 1922 | p = reserve_space(xdr, 16); |
Benny Halevy | cbe8260 | 2011-05-22 19:52:37 +0300 | [diff] [blame] | 1923 | p = xdr_encode_hyper(p, 0); |
| 1924 | p = xdr_encode_hyper(p, NFS4_MAX_UINT64); |
| 1925 | spin_lock(&args->inode->i_lock); |
Trond Myklebust | ea9d23f | 2012-03-04 18:13:56 -0500 | [diff] [blame] | 1926 | encode_nfs4_stateid(xdr, &args->stateid); |
Benny Halevy | cbe8260 | 2011-05-22 19:52:37 +0300 | [diff] [blame] | 1927 | spin_unlock(&args->inode->i_lock); |
Andy Adamson | 04a5554 | 2011-05-22 19:53:10 +0300 | [diff] [blame] | 1928 | if (NFS_SERVER(args->inode)->pnfs_curr_ld->encode_layoutreturn) { |
| 1929 | NFS_SERVER(args->inode)->pnfs_curr_ld->encode_layoutreturn( |
| 1930 | NFS_I(args->inode)->layout, xdr, args); |
Trond Myklebust | 475d4ba | 2012-03-05 11:27:16 -0500 | [diff] [blame] | 1931 | } else |
| 1932 | encode_uint32(xdr, 0); |
Benny Halevy | cbe8260 | 2011-05-22 19:52:37 +0300 | [diff] [blame] | 1933 | } |
Bryan Schumaker | fca78d6 | 2011-06-02 14:59:07 -0400 | [diff] [blame] | 1934 | |
| 1935 | static int |
| 1936 | encode_secinfo_no_name(struct xdr_stream *xdr, |
| 1937 | const struct nfs41_secinfo_no_name_args *args, |
| 1938 | struct compound_hdr *hdr) |
| 1939 | { |
Trond Myklebust | 475d4ba | 2012-03-05 11:27:16 -0500 | [diff] [blame] | 1940 | encode_op_hdr(xdr, OP_SECINFO_NO_NAME, decode_secinfo_no_name_maxsz, hdr); |
| 1941 | encode_uint32(xdr, args->style); |
Bryan Schumaker | fca78d6 | 2011-06-02 14:59:07 -0400 | [diff] [blame] | 1942 | return 0; |
| 1943 | } |
Bryan Schumaker | 7d97479 | 2011-06-02 14:59:08 -0400 | [diff] [blame] | 1944 | |
| 1945 | static void encode_test_stateid(struct xdr_stream *xdr, |
| 1946 | struct nfs41_test_stateid_args *args, |
| 1947 | struct compound_hdr *hdr) |
| 1948 | { |
Trond Myklebust | 475d4ba | 2012-03-05 11:27:16 -0500 | [diff] [blame] | 1949 | encode_op_hdr(xdr, OP_TEST_STATEID, decode_test_stateid_maxsz, hdr); |
| 1950 | encode_uint32(xdr, 1); |
Trond Myklebust | ea9d23f | 2012-03-04 18:13:56 -0500 | [diff] [blame] | 1951 | encode_nfs4_stateid(xdr, args->stateid); |
Bryan Schumaker | 7d97479 | 2011-06-02 14:59:08 -0400 | [diff] [blame] | 1952 | } |
Bryan Schumaker | 9aeda35 | 2011-06-02 14:59:09 -0400 | [diff] [blame] | 1953 | |
| 1954 | static void encode_free_stateid(struct xdr_stream *xdr, |
| 1955 | struct nfs41_free_stateid_args *args, |
| 1956 | struct compound_hdr *hdr) |
| 1957 | { |
Trond Myklebust | ab19b48 | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 1958 | encode_op_hdr(xdr, OP_FREE_STATEID, decode_free_stateid_maxsz, hdr); |
Trond Myklebust | ea9d23f | 2012-03-04 18:13:56 -0500 | [diff] [blame] | 1959 | encode_nfs4_stateid(xdr, args->stateid); |
Bryan Schumaker | 9aeda35 | 2011-06-02 14:59:09 -0400 | [diff] [blame] | 1960 | } |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 1961 | #endif /* CONFIG_NFS_V4_1 */ |
| 1962 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1963 | /* |
| 1964 | * END OF "GENERIC" ENCODE ROUTINES. |
| 1965 | */ |
| 1966 | |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 1967 | static u32 nfs4_xdr_minorversion(const struct nfs4_sequence_args *args) |
| 1968 | { |
| 1969 | #if defined(CONFIG_NFS_V4_1) |
| 1970 | if (args->sa_session) |
Trond Myklebust | a443234 | 2010-06-16 09:52:27 -0400 | [diff] [blame] | 1971 | return args->sa_session->clp->cl_mvops->minor_version; |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 1972 | #endif /* CONFIG_NFS_V4_1 */ |
| 1973 | return 0; |
| 1974 | } |
| 1975 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1976 | /* |
| 1977 | * Encode an ACCESS request |
| 1978 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 1979 | static void nfs4_xdr_enc_access(struct rpc_rqst *req, struct xdr_stream *xdr, |
| 1980 | const struct nfs4_accessargs *args) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1981 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1982 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 1983 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1984 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1985 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 1986 | encode_compound_hdr(xdr, req, &hdr); |
| 1987 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 1988 | encode_putfh(xdr, args->fh, &hdr); |
| 1989 | encode_access(xdr, args->access, &hdr); |
| 1990 | encode_getfattr(xdr, args->bitmask, &hdr); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 1991 | encode_nops(&hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1992 | } |
| 1993 | |
| 1994 | /* |
| 1995 | * Encode LOOKUP request |
| 1996 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 1997 | static void nfs4_xdr_enc_lookup(struct rpc_rqst *req, struct xdr_stream *xdr, |
| 1998 | const struct nfs4_lookup_arg *args) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1999 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2000 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2001 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2002 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2003 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2004 | encode_compound_hdr(xdr, req, &hdr); |
| 2005 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2006 | encode_putfh(xdr, args->dir_fh, &hdr); |
| 2007 | encode_lookup(xdr, args->name, &hdr); |
| 2008 | encode_getfh(xdr, &hdr); |
| 2009 | encode_getfattr(xdr, args->bitmask, &hdr); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2010 | encode_nops(&hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2011 | } |
| 2012 | |
| 2013 | /* |
| 2014 | * Encode LOOKUP_ROOT request |
| 2015 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2016 | static void nfs4_xdr_enc_lookup_root(struct rpc_rqst *req, |
| 2017 | struct xdr_stream *xdr, |
| 2018 | const struct nfs4_lookup_root_arg *args) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2019 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2020 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2021 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2022 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2023 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2024 | encode_compound_hdr(xdr, req, &hdr); |
| 2025 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2026 | encode_putrootfh(xdr, &hdr); |
| 2027 | encode_getfh(xdr, &hdr); |
| 2028 | encode_getfattr(xdr, args->bitmask, &hdr); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2029 | encode_nops(&hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2030 | } |
| 2031 | |
| 2032 | /* |
| 2033 | * Encode REMOVE request |
| 2034 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2035 | static void nfs4_xdr_enc_remove(struct rpc_rqst *req, struct xdr_stream *xdr, |
| 2036 | const struct nfs_removeargs *args) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2037 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2038 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2039 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2040 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2041 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2042 | encode_compound_hdr(xdr, req, &hdr); |
| 2043 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2044 | encode_putfh(xdr, args->fh, &hdr); |
| 2045 | encode_remove(xdr, &args->name, &hdr); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2046 | encode_nops(&hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2047 | } |
| 2048 | |
| 2049 | /* |
| 2050 | * Encode RENAME request |
| 2051 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2052 | static void nfs4_xdr_enc_rename(struct rpc_rqst *req, struct xdr_stream *xdr, |
| 2053 | const struct nfs_renameargs *args) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2054 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2055 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2056 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2057 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2058 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2059 | encode_compound_hdr(xdr, req, &hdr); |
| 2060 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2061 | encode_putfh(xdr, args->old_dir, &hdr); |
| 2062 | encode_savefh(xdr, &hdr); |
| 2063 | encode_putfh(xdr, args->new_dir, &hdr); |
| 2064 | encode_rename(xdr, args->old_name, args->new_name, &hdr); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2065 | encode_nops(&hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2066 | } |
| 2067 | |
| 2068 | /* |
| 2069 | * Encode LINK request |
| 2070 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2071 | static void nfs4_xdr_enc_link(struct rpc_rqst *req, struct xdr_stream *xdr, |
| 2072 | const struct nfs4_link_arg *args) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2073 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2074 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2075 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2076 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2077 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2078 | encode_compound_hdr(xdr, req, &hdr); |
| 2079 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2080 | encode_putfh(xdr, args->fh, &hdr); |
| 2081 | encode_savefh(xdr, &hdr); |
| 2082 | encode_putfh(xdr, args->dir_fh, &hdr); |
| 2083 | encode_link(xdr, args->name, &hdr); |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2084 | encode_restorefh(xdr, &hdr); |
| 2085 | encode_getfattr(xdr, args->bitmask, &hdr); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2086 | encode_nops(&hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2087 | } |
| 2088 | |
| 2089 | /* |
| 2090 | * Encode CREATE request |
| 2091 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2092 | static void nfs4_xdr_enc_create(struct rpc_rqst *req, struct xdr_stream *xdr, |
| 2093 | const struct nfs4_create_arg *args) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2094 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2095 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2096 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2097 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2098 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2099 | encode_compound_hdr(xdr, req, &hdr); |
| 2100 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2101 | encode_putfh(xdr, args->dir_fh, &hdr); |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2102 | encode_create(xdr, args, &hdr); |
| 2103 | encode_getfh(xdr, &hdr); |
| 2104 | encode_getfattr(xdr, args->bitmask, &hdr); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2105 | encode_nops(&hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2106 | } |
| 2107 | |
| 2108 | /* |
| 2109 | * Encode SYMLINK request |
| 2110 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2111 | static void nfs4_xdr_enc_symlink(struct rpc_rqst *req, struct xdr_stream *xdr, |
| 2112 | const struct nfs4_create_arg *args) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2113 | { |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2114 | nfs4_xdr_enc_create(req, xdr, args); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2115 | } |
| 2116 | |
| 2117 | /* |
| 2118 | * Encode GETATTR request |
| 2119 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2120 | static void nfs4_xdr_enc_getattr(struct rpc_rqst *req, struct xdr_stream *xdr, |
| 2121 | const struct nfs4_getattr_arg *args) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2122 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2123 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2124 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2125 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2126 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2127 | encode_compound_hdr(xdr, req, &hdr); |
| 2128 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2129 | encode_putfh(xdr, args->fh, &hdr); |
| 2130 | encode_getfattr(xdr, args->bitmask, &hdr); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2131 | encode_nops(&hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2132 | } |
| 2133 | |
| 2134 | /* |
| 2135 | * Encode a CLOSE request |
| 2136 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2137 | static void nfs4_xdr_enc_close(struct rpc_rqst *req, struct xdr_stream *xdr, |
| 2138 | struct nfs_closeargs *args) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2139 | { |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 2140 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2141 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 2142 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2143 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2144 | encode_compound_hdr(xdr, req, &hdr); |
| 2145 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2146 | encode_putfh(xdr, args->fh, &hdr); |
| 2147 | encode_close(xdr, args, &hdr); |
| 2148 | encode_getfattr(xdr, args->bitmask, &hdr); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2149 | encode_nops(&hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2150 | } |
| 2151 | |
| 2152 | /* |
| 2153 | * Encode an OPEN request |
| 2154 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2155 | static void nfs4_xdr_enc_open(struct rpc_rqst *req, struct xdr_stream *xdr, |
| 2156 | struct nfs_openargs *args) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2157 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2158 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2159 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2160 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2161 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2162 | encode_compound_hdr(xdr, req, &hdr); |
| 2163 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2164 | encode_putfh(xdr, args->fh, &hdr); |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2165 | encode_open(xdr, args, &hdr); |
| 2166 | encode_getfh(xdr, &hdr); |
| 2167 | encode_getfattr(xdr, args->bitmask, &hdr); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2168 | encode_nops(&hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2169 | } |
| 2170 | |
| 2171 | /* |
| 2172 | * Encode an OPEN_CONFIRM request |
| 2173 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2174 | static void nfs4_xdr_enc_open_confirm(struct rpc_rqst *req, |
| 2175 | struct xdr_stream *xdr, |
| 2176 | struct nfs_open_confirmargs *args) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2177 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2178 | struct compound_hdr hdr = { |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2179 | .nops = 0, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2180 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2181 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2182 | encode_compound_hdr(xdr, req, &hdr); |
| 2183 | encode_putfh(xdr, args->fh, &hdr); |
| 2184 | encode_open_confirm(xdr, args, &hdr); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2185 | encode_nops(&hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2186 | } |
| 2187 | |
| 2188 | /* |
| 2189 | * Encode an OPEN request with no attributes. |
| 2190 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2191 | static void nfs4_xdr_enc_open_noattr(struct rpc_rqst *req, |
| 2192 | struct xdr_stream *xdr, |
| 2193 | struct nfs_openargs *args) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2194 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2195 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2196 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2197 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2198 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2199 | encode_compound_hdr(xdr, req, &hdr); |
| 2200 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2201 | encode_putfh(xdr, args->fh, &hdr); |
| 2202 | encode_open(xdr, args, &hdr); |
| 2203 | encode_getfattr(xdr, args->bitmask, &hdr); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2204 | encode_nops(&hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2205 | } |
| 2206 | |
| 2207 | /* |
| 2208 | * Encode an OPEN_DOWNGRADE request |
| 2209 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2210 | static void nfs4_xdr_enc_open_downgrade(struct rpc_rqst *req, |
| 2211 | struct xdr_stream *xdr, |
| 2212 | struct nfs_closeargs *args) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2213 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2214 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2215 | .minorversion = nfs4_xdr_minorversion(&args->seq_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 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2218 | encode_compound_hdr(xdr, req, &hdr); |
| 2219 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2220 | encode_putfh(xdr, args->fh, &hdr); |
| 2221 | encode_open_downgrade(xdr, args, &hdr); |
| 2222 | encode_getfattr(xdr, args->bitmask, &hdr); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2223 | encode_nops(&hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2224 | } |
| 2225 | |
| 2226 | /* |
| 2227 | * Encode a LOCK request |
| 2228 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2229 | static void nfs4_xdr_enc_lock(struct rpc_rqst *req, struct xdr_stream *xdr, |
| 2230 | struct nfs_lock_args *args) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2231 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2232 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2233 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2234 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2235 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2236 | encode_compound_hdr(xdr, req, &hdr); |
| 2237 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2238 | encode_putfh(xdr, args->fh, &hdr); |
| 2239 | encode_lock(xdr, args, &hdr); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2240 | encode_nops(&hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2241 | } |
| 2242 | |
| 2243 | /* |
| 2244 | * Encode a LOCKT request |
| 2245 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2246 | static void nfs4_xdr_enc_lockt(struct rpc_rqst *req, struct xdr_stream *xdr, |
| 2247 | struct nfs_lockt_args *args) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2248 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2249 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2250 | .minorversion = nfs4_xdr_minorversion(&args->seq_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 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2253 | encode_compound_hdr(xdr, req, &hdr); |
| 2254 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2255 | encode_putfh(xdr, args->fh, &hdr); |
| 2256 | encode_lockt(xdr, args, &hdr); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2257 | encode_nops(&hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2258 | } |
| 2259 | |
| 2260 | /* |
| 2261 | * Encode a LOCKU request |
| 2262 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2263 | static void nfs4_xdr_enc_locku(struct rpc_rqst *req, struct xdr_stream *xdr, |
| 2264 | struct nfs_locku_args *args) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2265 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2266 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2267 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2268 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2269 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2270 | encode_compound_hdr(xdr, req, &hdr); |
| 2271 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2272 | encode_putfh(xdr, args->fh, &hdr); |
| 2273 | encode_locku(xdr, args, &hdr); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2274 | encode_nops(&hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2275 | } |
| 2276 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2277 | static void nfs4_xdr_enc_release_lockowner(struct rpc_rqst *req, |
| 2278 | struct xdr_stream *xdr, |
| 2279 | struct nfs_release_lockowner_args *args) |
Trond Myklebust | d3c7b7c | 2010-07-01 12:49:01 -0400 | [diff] [blame] | 2280 | { |
Trond Myklebust | d3c7b7c | 2010-07-01 12:49:01 -0400 | [diff] [blame] | 2281 | struct compound_hdr hdr = { |
| 2282 | .minorversion = 0, |
| 2283 | }; |
| 2284 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2285 | encode_compound_hdr(xdr, req, &hdr); |
| 2286 | encode_release_lockowner(xdr, &args->lock_owner, &hdr); |
Trond Myklebust | d3c7b7c | 2010-07-01 12:49:01 -0400 | [diff] [blame] | 2287 | encode_nops(&hdr); |
Trond Myklebust | d3c7b7c | 2010-07-01 12:49:01 -0400 | [diff] [blame] | 2288 | } |
| 2289 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2290 | /* |
| 2291 | * Encode a READLINK request |
| 2292 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2293 | static void nfs4_xdr_enc_readlink(struct rpc_rqst *req, struct xdr_stream *xdr, |
| 2294 | const struct nfs4_readlink *args) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2295 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2296 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2297 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2298 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2299 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2300 | encode_compound_hdr(xdr, req, &hdr); |
| 2301 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2302 | encode_putfh(xdr, args->fh, &hdr); |
| 2303 | encode_readlink(xdr, args, req, &hdr); |
Trond Myklebust | e3a535e | 2007-07-19 10:03:38 -0400 | [diff] [blame] | 2304 | |
Benny Halevy | 28f5669 | 2009-04-01 09:22:09 -0400 | [diff] [blame] | 2305 | xdr_inline_pages(&req->rq_rcv_buf, hdr.replen << 2, args->pages, |
Trond Myklebust | e3a535e | 2007-07-19 10:03:38 -0400 | [diff] [blame] | 2306 | args->pgbase, args->pglen); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2307 | encode_nops(&hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2308 | } |
| 2309 | |
| 2310 | /* |
| 2311 | * Encode a READDIR request |
| 2312 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2313 | static void nfs4_xdr_enc_readdir(struct rpc_rqst *req, struct xdr_stream *xdr, |
| 2314 | const struct nfs4_readdir_arg *args) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2315 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2316 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2317 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2318 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2319 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2320 | encode_compound_hdr(xdr, req, &hdr); |
| 2321 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2322 | encode_putfh(xdr, args->fh, &hdr); |
| 2323 | encode_readdir(xdr, args, req, &hdr); |
Trond Myklebust | d6ac02d | 2007-07-19 10:03:37 -0400 | [diff] [blame] | 2324 | |
Benny Halevy | 28f5669 | 2009-04-01 09:22:09 -0400 | [diff] [blame] | 2325 | xdr_inline_pages(&req->rq_rcv_buf, hdr.replen << 2, args->pages, |
Trond Myklebust | d6ac02d | 2007-07-19 10:03:37 -0400 | [diff] [blame] | 2326 | args->pgbase, args->count); |
| 2327 | dprintk("%s: inlined page args = (%u, %p, %u, %u)\n", |
Benny Halevy | 28f5669 | 2009-04-01 09:22:09 -0400 | [diff] [blame] | 2328 | __func__, hdr.replen << 2, args->pages, |
Trond Myklebust | d6ac02d | 2007-07-19 10:03:37 -0400 | [diff] [blame] | 2329 | args->pgbase, args->count); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2330 | encode_nops(&hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2331 | } |
| 2332 | |
| 2333 | /* |
| 2334 | * Encode a READ request |
| 2335 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2336 | static void nfs4_xdr_enc_read(struct rpc_rqst *req, struct xdr_stream *xdr, |
| 2337 | struct nfs_readargs *args) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2338 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2339 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2340 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2341 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2342 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2343 | encode_compound_hdr(xdr, req, &hdr); |
| 2344 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2345 | encode_putfh(xdr, args->fh, &hdr); |
| 2346 | encode_read(xdr, args, &hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2347 | |
Benny Halevy | 28f5669 | 2009-04-01 09:22:09 -0400 | [diff] [blame] | 2348 | xdr_inline_pages(&req->rq_rcv_buf, hdr.replen << 2, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2349 | args->pages, args->pgbase, args->count); |
\"Talpey, Thomas\ | 4f22ccc | 2007-09-10 13:44:58 -0400 | [diff] [blame] | 2350 | req->rq_rcv_buf.flags |= XDRBUF_READ; |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2351 | encode_nops(&hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2352 | } |
| 2353 | |
| 2354 | /* |
| 2355 | * Encode an SETATTR request |
| 2356 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2357 | static void nfs4_xdr_enc_setattr(struct rpc_rqst *req, struct xdr_stream *xdr, |
| 2358 | struct nfs_setattrargs *args) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2359 | { |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 2360 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2361 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 2362 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2363 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2364 | encode_compound_hdr(xdr, req, &hdr); |
| 2365 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2366 | encode_putfh(xdr, args->fh, &hdr); |
| 2367 | encode_setattr(xdr, args, args->server, &hdr); |
| 2368 | encode_getfattr(xdr, args->bitmask, &hdr); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2369 | encode_nops(&hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2370 | } |
| 2371 | |
| 2372 | /* |
J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 2373 | * Encode a GETACL request |
| 2374 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2375 | static void nfs4_xdr_enc_getacl(struct rpc_rqst *req, struct xdr_stream *xdr, |
| 2376 | struct nfs_getaclargs *args) |
J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 2377 | { |
J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 2378 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2379 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 2380 | }; |
Benny Halevy | 28f5669 | 2009-04-01 09:22:09 -0400 | [diff] [blame] | 2381 | uint32_t replen; |
J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 2382 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2383 | encode_compound_hdr(xdr, req, &hdr); |
| 2384 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2385 | encode_putfh(xdr, args->fh, &hdr); |
Andy Adamson | bf118a3 | 2011-12-07 11:55:27 -0500 | [diff] [blame] | 2386 | replen = hdr.replen + op_decode_hdr_maxsz + 1; |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2387 | encode_getattr_two(xdr, FATTR4_WORD0_ACL, 0, &hdr); |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 2388 | |
Benny Halevy | 28f5669 | 2009-04-01 09:22:09 -0400 | [diff] [blame] | 2389 | xdr_inline_pages(&req->rq_rcv_buf, replen << 2, |
J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 2390 | args->acl_pages, args->acl_pgbase, args->acl_len); |
Andy Adamson | bf118a3 | 2011-12-07 11:55:27 -0500 | [diff] [blame] | 2391 | |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2392 | encode_nops(&hdr); |
J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 2393 | } |
| 2394 | |
| 2395 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2396 | * Encode a WRITE request |
| 2397 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2398 | static void nfs4_xdr_enc_write(struct rpc_rqst *req, struct xdr_stream *xdr, |
| 2399 | struct nfs_writeargs *args) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2400 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2401 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2402 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2403 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2404 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2405 | encode_compound_hdr(xdr, req, &hdr); |
| 2406 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2407 | encode_putfh(xdr, args->fh, &hdr); |
| 2408 | encode_write(xdr, args, &hdr); |
\"Talpey, Thomas\ | 4f22ccc | 2007-09-10 13:44:58 -0400 | [diff] [blame] | 2409 | req->rq_snd_buf.flags |= XDRBUF_WRITE; |
Fred Isaman | 7ffd106 | 2011-03-03 15:13:46 +0000 | [diff] [blame] | 2410 | if (args->bitmask) |
| 2411 | encode_getfattr(xdr, args->bitmask, &hdr); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2412 | encode_nops(&hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2413 | } |
| 2414 | |
| 2415 | /* |
| 2416 | * a COMMIT request |
| 2417 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2418 | 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] | 2419 | struct nfs_commitargs *args) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2420 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2421 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2422 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2423 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2424 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2425 | encode_compound_hdr(xdr, req, &hdr); |
| 2426 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2427 | encode_putfh(xdr, args->fh, &hdr); |
| 2428 | encode_commit(xdr, args, &hdr); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2429 | encode_nops(&hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2430 | } |
| 2431 | |
| 2432 | /* |
| 2433 | * FSINFO request |
| 2434 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2435 | static void nfs4_xdr_enc_fsinfo(struct rpc_rqst *req, struct xdr_stream *xdr, |
| 2436 | struct nfs4_fsinfo_arg *args) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2437 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2438 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2439 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2440 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2441 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2442 | encode_compound_hdr(xdr, req, &hdr); |
| 2443 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2444 | encode_putfh(xdr, args->fh, &hdr); |
| 2445 | encode_fsinfo(xdr, args->bitmask, &hdr); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2446 | encode_nops(&hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2447 | } |
| 2448 | |
| 2449 | /* |
| 2450 | * a PATHCONF request |
| 2451 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2452 | static void nfs4_xdr_enc_pathconf(struct rpc_rqst *req, struct xdr_stream *xdr, |
| 2453 | const struct nfs4_pathconf_arg *args) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2454 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2455 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2456 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2457 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2458 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2459 | encode_compound_hdr(xdr, req, &hdr); |
| 2460 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2461 | encode_putfh(xdr, args->fh, &hdr); |
| 2462 | encode_getattr_one(xdr, args->bitmask[0] & nfs4_pathconf_bitmap[0], |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 2463 | &hdr); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2464 | encode_nops(&hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2465 | } |
| 2466 | |
| 2467 | /* |
| 2468 | * a STATFS request |
| 2469 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2470 | static void nfs4_xdr_enc_statfs(struct rpc_rqst *req, struct xdr_stream *xdr, |
| 2471 | const struct nfs4_statfs_arg *args) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2472 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2473 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2474 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2475 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2476 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2477 | encode_compound_hdr(xdr, req, &hdr); |
| 2478 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2479 | encode_putfh(xdr, args->fh, &hdr); |
| 2480 | encode_getattr_two(xdr, args->bitmask[0] & nfs4_statfs_bitmap[0], |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 2481 | args->bitmask[1] & nfs4_statfs_bitmap[1], &hdr); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2482 | encode_nops(&hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2483 | } |
| 2484 | |
| 2485 | /* |
| 2486 | * GETATTR_BITMAP request |
| 2487 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2488 | static void nfs4_xdr_enc_server_caps(struct rpc_rqst *req, |
| 2489 | struct xdr_stream *xdr, |
| 2490 | struct nfs4_server_caps_arg *args) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2491 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2492 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2493 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2494 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2495 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2496 | encode_compound_hdr(xdr, req, &hdr); |
| 2497 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2498 | encode_putfh(xdr, args->fhandle, &hdr); |
| 2499 | encode_getattr_one(xdr, FATTR4_WORD0_SUPPORTED_ATTRS| |
Chuck Lever | 264e635 | 2012-03-01 17:02:05 -0500 | [diff] [blame] | 2500 | FATTR4_WORD0_FH_EXPIRE_TYPE| |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 2501 | FATTR4_WORD0_LINK_SUPPORT| |
| 2502 | FATTR4_WORD0_SYMLINK_SUPPORT| |
| 2503 | FATTR4_WORD0_ACLSUPPORT, &hdr); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2504 | encode_nops(&hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2505 | } |
| 2506 | |
| 2507 | /* |
| 2508 | * a RENEW request |
| 2509 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2510 | static void nfs4_xdr_enc_renew(struct rpc_rqst *req, struct xdr_stream *xdr, |
| 2511 | struct nfs_client *clp) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2512 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2513 | struct compound_hdr hdr = { |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2514 | .nops = 0, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2515 | }; |
| 2516 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2517 | encode_compound_hdr(xdr, req, &hdr); |
Chuck Lever | bb4dae5 | 2012-03-01 17:01:48 -0500 | [diff] [blame] | 2518 | encode_renew(xdr, clp->cl_clientid, &hdr); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2519 | encode_nops(&hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2520 | } |
| 2521 | |
| 2522 | /* |
| 2523 | * a SETCLIENTID request |
| 2524 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2525 | static void nfs4_xdr_enc_setclientid(struct rpc_rqst *req, |
| 2526 | struct xdr_stream *xdr, |
| 2527 | struct nfs4_setclientid *sc) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2528 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2529 | struct compound_hdr hdr = { |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2530 | .nops = 0, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2531 | }; |
| 2532 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2533 | encode_compound_hdr(xdr, req, &hdr); |
| 2534 | encode_setclientid(xdr, sc, &hdr); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2535 | encode_nops(&hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2536 | } |
| 2537 | |
| 2538 | /* |
| 2539 | * a SETCLIENTID_CONFIRM request |
| 2540 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2541 | static void nfs4_xdr_enc_setclientid_confirm(struct rpc_rqst *req, |
| 2542 | struct xdr_stream *xdr, |
| 2543 | struct nfs4_setclientid_res *arg) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2544 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2545 | struct compound_hdr hdr = { |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2546 | .nops = 0, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2547 | }; |
Fred Isaman | dae100c | 2011-07-30 20:52:37 -0400 | [diff] [blame] | 2548 | const u32 lease_bitmap[3] = { FATTR4_WORD0_LEASE_TIME }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2549 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2550 | encode_compound_hdr(xdr, req, &hdr); |
| 2551 | encode_setclientid_confirm(xdr, arg, &hdr); |
| 2552 | encode_putrootfh(xdr, &hdr); |
| 2553 | encode_fsinfo(xdr, lease_bitmap, &hdr); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2554 | encode_nops(&hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2555 | } |
| 2556 | |
| 2557 | /* |
| 2558 | * DELEGRETURN request |
| 2559 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2560 | static void nfs4_xdr_enc_delegreturn(struct rpc_rqst *req, |
| 2561 | struct xdr_stream *xdr, |
| 2562 | const struct nfs4_delegreturnargs *args) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2563 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2564 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2565 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2566 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2567 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2568 | encode_compound_hdr(xdr, req, &hdr); |
| 2569 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2570 | encode_putfh(xdr, args->fhandle, &hdr); |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2571 | encode_getfattr(xdr, args->bitmask, &hdr); |
Trond Myklebust | e144cbc | 2012-04-28 16:05:03 -0400 | [diff] [blame] | 2572 | encode_delegreturn(xdr, args->stateid, &hdr); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2573 | encode_nops(&hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2574 | } |
| 2575 | |
| 2576 | /* |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 2577 | * Encode FS_LOCATIONS request |
| 2578 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2579 | static void nfs4_xdr_enc_fs_locations(struct rpc_rqst *req, |
| 2580 | struct xdr_stream *xdr, |
| 2581 | struct nfs4_fs_locations_arg *args) |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 2582 | { |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 2583 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2584 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 2585 | }; |
Benny Halevy | 28f5669 | 2009-04-01 09:22:09 -0400 | [diff] [blame] | 2586 | uint32_t replen; |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 2587 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2588 | encode_compound_hdr(xdr, req, &hdr); |
| 2589 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2590 | encode_putfh(xdr, args->dir_fh, &hdr); |
| 2591 | encode_lookup(xdr, args->name, &hdr); |
Benny Halevy | 28f5669 | 2009-04-01 09:22:09 -0400 | [diff] [blame] | 2592 | replen = hdr.replen; /* get the attribute into args->page */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2593 | encode_fs_locations(xdr, args->bitmask, &hdr); |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 2594 | |
Benny Halevy | 28f5669 | 2009-04-01 09:22:09 -0400 | [diff] [blame] | 2595 | xdr_inline_pages(&req->rq_rcv_buf, replen << 2, &args->page, |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 2596 | 0, PAGE_SIZE); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2597 | encode_nops(&hdr); |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 2598 | } |
| 2599 | |
Bryan Schumaker | 5a5ea0d | 2011-03-24 17:12:29 +0000 | [diff] [blame] | 2600 | /* |
| 2601 | * Encode SECINFO request |
| 2602 | */ |
| 2603 | static void nfs4_xdr_enc_secinfo(struct rpc_rqst *req, |
| 2604 | struct xdr_stream *xdr, |
| 2605 | struct nfs4_secinfo_arg *args) |
| 2606 | { |
| 2607 | struct compound_hdr hdr = { |
| 2608 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
| 2609 | }; |
| 2610 | |
| 2611 | encode_compound_hdr(xdr, req, &hdr); |
| 2612 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2613 | encode_putfh(xdr, args->dir_fh, &hdr); |
| 2614 | encode_secinfo(xdr, args->name, &hdr); |
| 2615 | encode_nops(&hdr); |
| 2616 | } |
| 2617 | |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 2618 | #if defined(CONFIG_NFS_V4_1) |
| 2619 | /* |
| 2620 | * EXCHANGE_ID request |
| 2621 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2622 | static void nfs4_xdr_enc_exchange_id(struct rpc_rqst *req, |
| 2623 | struct xdr_stream *xdr, |
| 2624 | struct nfs41_exchange_id_args *args) |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 2625 | { |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 2626 | struct compound_hdr hdr = { |
Trond Myklebust | a443234 | 2010-06-16 09:52:27 -0400 | [diff] [blame] | 2627 | .minorversion = args->client->cl_mvops->minor_version, |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 2628 | }; |
| 2629 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2630 | encode_compound_hdr(xdr, req, &hdr); |
| 2631 | encode_exchange_id(xdr, args, &hdr); |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 2632 | encode_nops(&hdr); |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 2633 | } |
Andy Adamson | 2050f0c | 2009-04-01 09:22:30 -0400 | [diff] [blame] | 2634 | |
| 2635 | /* |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 2636 | * a CREATE_SESSION request |
| 2637 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2638 | static void nfs4_xdr_enc_create_session(struct rpc_rqst *req, |
| 2639 | struct xdr_stream *xdr, |
| 2640 | struct nfs41_create_session_args *args) |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 2641 | { |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 2642 | struct compound_hdr hdr = { |
Trond Myklebust | a443234 | 2010-06-16 09:52:27 -0400 | [diff] [blame] | 2643 | .minorversion = args->client->cl_mvops->minor_version, |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 2644 | }; |
| 2645 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2646 | encode_compound_hdr(xdr, req, &hdr); |
| 2647 | encode_create_session(xdr, args, &hdr); |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 2648 | encode_nops(&hdr); |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 2649 | } |
| 2650 | |
| 2651 | /* |
Andy Adamson | 0f3e66c | 2009-04-01 09:22:34 -0400 | [diff] [blame] | 2652 | * a DESTROY_SESSION request |
| 2653 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2654 | static void nfs4_xdr_enc_destroy_session(struct rpc_rqst *req, |
| 2655 | struct xdr_stream *xdr, |
| 2656 | struct nfs4_session *session) |
Andy Adamson | 0f3e66c | 2009-04-01 09:22:34 -0400 | [diff] [blame] | 2657 | { |
Andy Adamson | 0f3e66c | 2009-04-01 09:22:34 -0400 | [diff] [blame] | 2658 | struct compound_hdr hdr = { |
Trond Myklebust | a443234 | 2010-06-16 09:52:27 -0400 | [diff] [blame] | 2659 | .minorversion = session->clp->cl_mvops->minor_version, |
Andy Adamson | 0f3e66c | 2009-04-01 09:22:34 -0400 | [diff] [blame] | 2660 | }; |
| 2661 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2662 | encode_compound_hdr(xdr, req, &hdr); |
| 2663 | encode_destroy_session(xdr, session, &hdr); |
Andy Adamson | 0f3e66c | 2009-04-01 09:22:34 -0400 | [diff] [blame] | 2664 | encode_nops(&hdr); |
Andy Adamson | 0f3e66c | 2009-04-01 09:22:34 -0400 | [diff] [blame] | 2665 | } |
| 2666 | |
| 2667 | /* |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 2668 | * a SEQUENCE request |
| 2669 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2670 | static void nfs4_xdr_enc_sequence(struct rpc_rqst *req, struct xdr_stream *xdr, |
| 2671 | struct nfs4_sequence_args *args) |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 2672 | { |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 2673 | struct compound_hdr hdr = { |
| 2674 | .minorversion = nfs4_xdr_minorversion(args), |
| 2675 | }; |
| 2676 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2677 | encode_compound_hdr(xdr, req, &hdr); |
| 2678 | encode_sequence(xdr, args, &hdr); |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 2679 | encode_nops(&hdr); |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 2680 | } |
| 2681 | |
| 2682 | /* |
Andy Adamson | 2050f0c | 2009-04-01 09:22:30 -0400 | [diff] [blame] | 2683 | * a GET_LEASE_TIME request |
| 2684 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2685 | static void nfs4_xdr_enc_get_lease_time(struct rpc_rqst *req, |
| 2686 | struct xdr_stream *xdr, |
| 2687 | struct nfs4_get_lease_time_args *args) |
Andy Adamson | 2050f0c | 2009-04-01 09:22:30 -0400 | [diff] [blame] | 2688 | { |
Andy Adamson | 2050f0c | 2009-04-01 09:22:30 -0400 | [diff] [blame] | 2689 | struct compound_hdr hdr = { |
| 2690 | .minorversion = nfs4_xdr_minorversion(&args->la_seq_args), |
| 2691 | }; |
Fred Isaman | dae100c | 2011-07-30 20:52:37 -0400 | [diff] [blame] | 2692 | const u32 lease_bitmap[3] = { FATTR4_WORD0_LEASE_TIME }; |
Andy Adamson | 2050f0c | 2009-04-01 09:22:30 -0400 | [diff] [blame] | 2693 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2694 | encode_compound_hdr(xdr, req, &hdr); |
| 2695 | encode_sequence(xdr, &args->la_seq_args, &hdr); |
| 2696 | encode_putrootfh(xdr, &hdr); |
| 2697 | encode_fsinfo(xdr, lease_bitmap, &hdr); |
Andy Adamson | 2050f0c | 2009-04-01 09:22:30 -0400 | [diff] [blame] | 2698 | encode_nops(&hdr); |
Andy Adamson | 2050f0c | 2009-04-01 09:22:30 -0400 | [diff] [blame] | 2699 | } |
Ricardo Labiaga | 18019753 | 2009-12-05 16:08:40 -0500 | [diff] [blame] | 2700 | |
| 2701 | /* |
| 2702 | * a RECLAIM_COMPLETE request |
| 2703 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2704 | static void nfs4_xdr_enc_reclaim_complete(struct rpc_rqst *req, |
| 2705 | struct xdr_stream *xdr, |
| 2706 | struct nfs41_reclaim_complete_args *args) |
Ricardo Labiaga | 18019753 | 2009-12-05 16:08:40 -0500 | [diff] [blame] | 2707 | { |
Ricardo Labiaga | 18019753 | 2009-12-05 16:08:40 -0500 | [diff] [blame] | 2708 | struct compound_hdr hdr = { |
| 2709 | .minorversion = nfs4_xdr_minorversion(&args->seq_args) |
| 2710 | }; |
| 2711 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2712 | encode_compound_hdr(xdr, req, &hdr); |
| 2713 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2714 | encode_reclaim_complete(xdr, args, &hdr); |
Ricardo Labiaga | 18019753 | 2009-12-05 16:08:40 -0500 | [diff] [blame] | 2715 | encode_nops(&hdr); |
Ricardo Labiaga | 18019753 | 2009-12-05 16:08:40 -0500 | [diff] [blame] | 2716 | } |
| 2717 | |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 2718 | /* |
Andy Adamson | 7f11d8d | 2011-07-30 20:52:35 -0400 | [diff] [blame] | 2719 | * Encode GETDEVICELIST request |
| 2720 | */ |
| 2721 | static void nfs4_xdr_enc_getdevicelist(struct rpc_rqst *req, |
| 2722 | struct xdr_stream *xdr, |
| 2723 | struct nfs4_getdevicelist_args *args) |
| 2724 | { |
| 2725 | struct compound_hdr hdr = { |
| 2726 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
| 2727 | }; |
| 2728 | |
| 2729 | encode_compound_hdr(xdr, req, &hdr); |
| 2730 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2731 | encode_putfh(xdr, args->fh, &hdr); |
| 2732 | encode_getdevicelist(xdr, args, &hdr); |
| 2733 | encode_nops(&hdr); |
| 2734 | } |
| 2735 | |
| 2736 | /* |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 2737 | * Encode GETDEVICEINFO request |
| 2738 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2739 | static void nfs4_xdr_enc_getdeviceinfo(struct rpc_rqst *req, |
| 2740 | struct xdr_stream *xdr, |
| 2741 | struct nfs4_getdeviceinfo_args *args) |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 2742 | { |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 2743 | struct compound_hdr hdr = { |
| 2744 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
| 2745 | }; |
| 2746 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2747 | encode_compound_hdr(xdr, req, &hdr); |
| 2748 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2749 | encode_getdeviceinfo(xdr, args, &hdr); |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 2750 | |
| 2751 | /* set up reply kvec. Subtract notification bitmap max size (2) |
| 2752 | * so that notification bitmap is put in xdr_buf tail */ |
| 2753 | xdr_inline_pages(&req->rq_rcv_buf, (hdr.replen - 2) << 2, |
| 2754 | args->pdev->pages, args->pdev->pgbase, |
| 2755 | args->pdev->pglen); |
| 2756 | |
| 2757 | encode_nops(&hdr); |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 2758 | } |
| 2759 | |
| 2760 | /* |
| 2761 | * Encode LAYOUTGET request |
| 2762 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2763 | static void nfs4_xdr_enc_layoutget(struct rpc_rqst *req, |
| 2764 | struct xdr_stream *xdr, |
| 2765 | struct nfs4_layoutget_args *args) |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 2766 | { |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 2767 | struct compound_hdr hdr = { |
| 2768 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
| 2769 | }; |
| 2770 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2771 | encode_compound_hdr(xdr, req, &hdr); |
| 2772 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2773 | encode_putfh(xdr, NFS_FH(args->inode), &hdr); |
| 2774 | encode_layoutget(xdr, args, &hdr); |
Weston Andros Adamson | 35124a0 | 2011-03-24 16:48:21 -0400 | [diff] [blame] | 2775 | |
| 2776 | xdr_inline_pages(&req->rq_rcv_buf, hdr.replen << 2, |
| 2777 | args->layout.pages, 0, args->layout.pglen); |
| 2778 | |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 2779 | encode_nops(&hdr); |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 2780 | } |
Andy Adamson | 863a3c6 | 2011-03-23 13:27:54 +0000 | [diff] [blame] | 2781 | |
| 2782 | /* |
| 2783 | * Encode LAYOUTCOMMIT request |
| 2784 | */ |
Benny Halevy | cbe8260 | 2011-05-22 19:52:37 +0300 | [diff] [blame] | 2785 | static void nfs4_xdr_enc_layoutcommit(struct rpc_rqst *req, |
| 2786 | struct xdr_stream *xdr, |
| 2787 | struct nfs4_layoutcommit_args *args) |
Andy Adamson | 863a3c6 | 2011-03-23 13:27:54 +0000 | [diff] [blame] | 2788 | { |
Benny Halevy | ac7db72 | 2011-05-22 19:53:48 +0300 | [diff] [blame] | 2789 | struct nfs4_layoutcommit_data *data = |
| 2790 | container_of(args, struct nfs4_layoutcommit_data, args); |
Andy Adamson | 863a3c6 | 2011-03-23 13:27:54 +0000 | [diff] [blame] | 2791 | struct compound_hdr hdr = { |
| 2792 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
| 2793 | }; |
| 2794 | |
| 2795 | encode_compound_hdr(xdr, req, &hdr); |
| 2796 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2797 | encode_putfh(xdr, NFS_FH(args->inode), &hdr); |
Benny Halevy | ac7db72 | 2011-05-22 19:53:48 +0300 | [diff] [blame] | 2798 | encode_layoutcommit(xdr, data->args.inode, args, &hdr); |
Andy Adamson | 863a3c6 | 2011-03-23 13:27:54 +0000 | [diff] [blame] | 2799 | encode_getfattr(xdr, args->bitmask, &hdr); |
| 2800 | encode_nops(&hdr); |
Benny Halevy | cbe8260 | 2011-05-22 19:52:37 +0300 | [diff] [blame] | 2801 | } |
| 2802 | |
| 2803 | /* |
| 2804 | * Encode LAYOUTRETURN request |
| 2805 | */ |
| 2806 | static void nfs4_xdr_enc_layoutreturn(struct rpc_rqst *req, |
| 2807 | struct xdr_stream *xdr, |
| 2808 | struct nfs4_layoutreturn_args *args) |
| 2809 | { |
| 2810 | struct compound_hdr hdr = { |
| 2811 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
| 2812 | }; |
| 2813 | |
| 2814 | encode_compound_hdr(xdr, req, &hdr); |
| 2815 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2816 | encode_putfh(xdr, NFS_FH(args->inode), &hdr); |
| 2817 | encode_layoutreturn(xdr, args, &hdr); |
| 2818 | encode_nops(&hdr); |
Andy Adamson | 863a3c6 | 2011-03-23 13:27:54 +0000 | [diff] [blame] | 2819 | } |
Bryan Schumaker | fca78d6 | 2011-06-02 14:59:07 -0400 | [diff] [blame] | 2820 | |
| 2821 | /* |
| 2822 | * Encode SECINFO_NO_NAME request |
| 2823 | */ |
| 2824 | static int nfs4_xdr_enc_secinfo_no_name(struct rpc_rqst *req, |
| 2825 | struct xdr_stream *xdr, |
| 2826 | struct nfs41_secinfo_no_name_args *args) |
| 2827 | { |
| 2828 | struct compound_hdr hdr = { |
| 2829 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
| 2830 | }; |
| 2831 | |
| 2832 | encode_compound_hdr(xdr, req, &hdr); |
| 2833 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2834 | encode_putrootfh(xdr, &hdr); |
| 2835 | encode_secinfo_no_name(xdr, args, &hdr); |
| 2836 | encode_nops(&hdr); |
| 2837 | return 0; |
| 2838 | } |
Bryan Schumaker | 7d97479 | 2011-06-02 14:59:08 -0400 | [diff] [blame] | 2839 | |
| 2840 | /* |
| 2841 | * Encode TEST_STATEID request |
| 2842 | */ |
| 2843 | static void nfs4_xdr_enc_test_stateid(struct rpc_rqst *req, |
| 2844 | struct xdr_stream *xdr, |
| 2845 | struct nfs41_test_stateid_args *args) |
| 2846 | { |
| 2847 | struct compound_hdr hdr = { |
| 2848 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
| 2849 | }; |
| 2850 | |
| 2851 | encode_compound_hdr(xdr, req, &hdr); |
| 2852 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2853 | encode_test_stateid(xdr, args, &hdr); |
| 2854 | encode_nops(&hdr); |
| 2855 | } |
Bryan Schumaker | 9aeda35 | 2011-06-02 14:59:09 -0400 | [diff] [blame] | 2856 | |
| 2857 | /* |
| 2858 | * Encode FREE_STATEID request |
| 2859 | */ |
| 2860 | static void nfs4_xdr_enc_free_stateid(struct rpc_rqst *req, |
| 2861 | struct xdr_stream *xdr, |
| 2862 | struct nfs41_free_stateid_args *args) |
| 2863 | { |
| 2864 | struct compound_hdr hdr = { |
| 2865 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
| 2866 | }; |
| 2867 | |
| 2868 | encode_compound_hdr(xdr, req, &hdr); |
| 2869 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2870 | encode_free_stateid(xdr, args, &hdr); |
| 2871 | encode_nops(&hdr); |
| 2872 | } |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 2873 | #endif /* CONFIG_NFS_V4_1 */ |
| 2874 | |
Benny Halevy | 686841b | 2009-08-14 17:19:48 +0300 | [diff] [blame] | 2875 | static void print_overflow_msg(const char *func, const struct xdr_stream *xdr) |
| 2876 | { |
| 2877 | dprintk("nfs: %s: prematurely hit end of receive buffer. " |
| 2878 | "Remaining buffer length is %tu words.\n", |
| 2879 | func, xdr->end - xdr->p); |
| 2880 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2881 | |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 2882 | 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] | 2883 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 2884 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2885 | |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 2886 | p = xdr_inline_decode(xdr, 4); |
| 2887 | if (unlikely(!p)) |
| 2888 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 2889 | *len = be32_to_cpup(p); |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 2890 | p = xdr_inline_decode(xdr, *len); |
| 2891 | if (unlikely(!p)) |
| 2892 | goto out_overflow; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2893 | *string = (char *)p; |
| 2894 | return 0; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 2895 | out_overflow: |
| 2896 | print_overflow_msg(__func__, xdr); |
| 2897 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2898 | } |
| 2899 | |
| 2900 | static int decode_compound_hdr(struct xdr_stream *xdr, struct compound_hdr *hdr) |
| 2901 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 2902 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2903 | |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 2904 | p = xdr_inline_decode(xdr, 8); |
| 2905 | if (unlikely(!p)) |
| 2906 | goto out_overflow; |
Benny Halevy | 6f723f7 | 2009-08-14 17:19:37 +0300 | [diff] [blame] | 2907 | hdr->status = be32_to_cpup(p++); |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 2908 | hdr->taglen = be32_to_cpup(p); |
Andy Adamson | 6c0195a | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 2909 | |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 2910 | p = xdr_inline_decode(xdr, hdr->taglen + 4); |
| 2911 | if (unlikely(!p)) |
| 2912 | goto out_overflow; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2913 | hdr->tag = (char *)p; |
| 2914 | p += XDR_QUADLEN(hdr->taglen); |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 2915 | hdr->nops = be32_to_cpup(p); |
Benny Halevy | aadf615 | 2008-12-23 16:06:13 -0500 | [diff] [blame] | 2916 | if (unlikely(hdr->nops < 1)) |
| 2917 | return nfs4_stat_to_errno(hdr->status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2918 | return 0; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 2919 | out_overflow: |
| 2920 | print_overflow_msg(__func__, xdr); |
| 2921 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2922 | } |
| 2923 | |
| 2924 | static int decode_op_hdr(struct xdr_stream *xdr, enum nfs_opnum4 expected) |
| 2925 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 2926 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2927 | uint32_t opnum; |
| 2928 | int32_t nfserr; |
| 2929 | |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 2930 | p = xdr_inline_decode(xdr, 8); |
| 2931 | if (unlikely(!p)) |
| 2932 | goto out_overflow; |
Benny Halevy | 6f723f7 | 2009-08-14 17:19:37 +0300 | [diff] [blame] | 2933 | opnum = be32_to_cpup(p++); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2934 | if (opnum != expected) { |
Chuck Lever | fe82a18 | 2007-09-11 18:01:10 -0400 | [diff] [blame] | 2935 | dprintk("nfs: Server returned operation" |
| 2936 | " %d but we issued a request for %d\n", |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2937 | opnum, expected); |
| 2938 | return -EIO; |
| 2939 | } |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 2940 | nfserr = be32_to_cpup(p); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2941 | if (nfserr != NFS_OK) |
Benny Halevy | 856dff3 | 2008-03-31 17:39:06 +0300 | [diff] [blame] | 2942 | return nfs4_stat_to_errno(nfserr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2943 | return 0; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 2944 | out_overflow: |
| 2945 | print_overflow_msg(__func__, xdr); |
| 2946 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2947 | } |
| 2948 | |
| 2949 | /* Dummy routine */ |
David Howells | adfa6f9 | 2006-08-22 20:06:08 -0400 | [diff] [blame] | 2950 | 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] | 2951 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 2952 | __be32 *p; |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 2953 | unsigned int strlen; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2954 | char *str; |
| 2955 | |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 2956 | p = xdr_inline_decode(xdr, 12); |
| 2957 | if (likely(p)) |
| 2958 | return decode_opaque_inline(xdr, &strlen, &str); |
| 2959 | print_overflow_msg(__func__, xdr); |
| 2960 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2961 | } |
| 2962 | |
| 2963 | static int decode_attr_bitmap(struct xdr_stream *xdr, uint32_t *bitmap) |
| 2964 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 2965 | uint32_t bmlen; |
| 2966 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2967 | |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 2968 | p = xdr_inline_decode(xdr, 4); |
| 2969 | if (unlikely(!p)) |
| 2970 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 2971 | bmlen = be32_to_cpup(p); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2972 | |
Fred Isaman | dae100c | 2011-07-30 20:52:37 -0400 | [diff] [blame] | 2973 | bitmap[0] = bitmap[1] = bitmap[2] = 0; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 2974 | p = xdr_inline_decode(xdr, (bmlen << 2)); |
| 2975 | if (unlikely(!p)) |
| 2976 | goto out_overflow; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2977 | if (bmlen > 0) { |
Benny Halevy | 6f723f7 | 2009-08-14 17:19:37 +0300 | [diff] [blame] | 2978 | bitmap[0] = be32_to_cpup(p++); |
Fred Isaman | dae100c | 2011-07-30 20:52:37 -0400 | [diff] [blame] | 2979 | if (bmlen > 1) { |
| 2980 | bitmap[1] = be32_to_cpup(p++); |
| 2981 | if (bmlen > 2) |
| 2982 | bitmap[2] = be32_to_cpup(p); |
| 2983 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2984 | } |
| 2985 | return 0; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 2986 | out_overflow: |
| 2987 | print_overflow_msg(__func__, xdr); |
| 2988 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2989 | } |
| 2990 | |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 2991 | static inline int decode_attr_length(struct xdr_stream *xdr, uint32_t *attrlen, __be32 **savep) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2992 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 2993 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2994 | |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 2995 | p = xdr_inline_decode(xdr, 4); |
| 2996 | if (unlikely(!p)) |
| 2997 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 2998 | *attrlen = be32_to_cpup(p); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2999 | *savep = xdr->p; |
| 3000 | return 0; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3001 | out_overflow: |
| 3002 | print_overflow_msg(__func__, xdr); |
| 3003 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3004 | } |
| 3005 | |
| 3006 | static int decode_attr_supported(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t *bitmask) |
| 3007 | { |
| 3008 | if (likely(bitmap[0] & FATTR4_WORD0_SUPPORTED_ATTRS)) { |
Roman Borisov | 3388bff | 2010-10-13 16:54:51 +0400 | [diff] [blame] | 3009 | int ret; |
| 3010 | ret = decode_attr_bitmap(xdr, bitmask); |
| 3011 | if (unlikely(ret < 0)) |
| 3012 | return ret; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3013 | bitmap[0] &= ~FATTR4_WORD0_SUPPORTED_ATTRS; |
| 3014 | } else |
Fred Isaman | dae100c | 2011-07-30 20:52:37 -0400 | [diff] [blame] | 3015 | bitmask[0] = bitmask[1] = bitmask[2] = 0; |
| 3016 | dprintk("%s: bitmask=%08x:%08x:%08x\n", __func__, |
| 3017 | bitmask[0], bitmask[1], bitmask[2]); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3018 | return 0; |
| 3019 | } |
| 3020 | |
| 3021 | static int decode_attr_type(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t *type) |
| 3022 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3023 | __be32 *p; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3024 | int ret = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3025 | |
| 3026 | *type = 0; |
| 3027 | if (unlikely(bitmap[0] & (FATTR4_WORD0_TYPE - 1U))) |
| 3028 | return -EIO; |
| 3029 | if (likely(bitmap[0] & FATTR4_WORD0_TYPE)) { |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3030 | p = xdr_inline_decode(xdr, 4); |
| 3031 | if (unlikely(!p)) |
| 3032 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3033 | *type = be32_to_cpup(p); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3034 | if (*type < NF4REG || *type > NF4NAMEDATTR) { |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3035 | dprintk("%s: bad type %d\n", __func__, *type); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3036 | return -EIO; |
| 3037 | } |
| 3038 | bitmap[0] &= ~FATTR4_WORD0_TYPE; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3039 | ret = NFS_ATTR_FATTR_TYPE; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3040 | } |
Trond Myklebust | bca7947 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 3041 | dprintk("%s: type=0%o\n", __func__, nfs_type2fmt[*type]); |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3042 | return ret; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3043 | out_overflow: |
| 3044 | print_overflow_msg(__func__, xdr); |
| 3045 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3046 | } |
| 3047 | |
Chuck Lever | 264e635 | 2012-03-01 17:02:05 -0500 | [diff] [blame] | 3048 | static int decode_attr_fh_expire_type(struct xdr_stream *xdr, |
| 3049 | uint32_t *bitmap, uint32_t *type) |
| 3050 | { |
| 3051 | __be32 *p; |
| 3052 | |
| 3053 | *type = 0; |
| 3054 | if (unlikely(bitmap[0] & (FATTR4_WORD0_FH_EXPIRE_TYPE - 1U))) |
| 3055 | return -EIO; |
| 3056 | if (likely(bitmap[0] & FATTR4_WORD0_FH_EXPIRE_TYPE)) { |
| 3057 | p = xdr_inline_decode(xdr, 4); |
| 3058 | if (unlikely(!p)) |
| 3059 | goto out_overflow; |
| 3060 | *type = be32_to_cpup(p); |
| 3061 | bitmap[0] &= ~FATTR4_WORD0_FH_EXPIRE_TYPE; |
| 3062 | } |
| 3063 | dprintk("%s: expire type=0x%x\n", __func__, *type); |
| 3064 | return 0; |
| 3065 | out_overflow: |
| 3066 | print_overflow_msg(__func__, xdr); |
| 3067 | return -EIO; |
| 3068 | } |
| 3069 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3070 | static int decode_attr_change(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *change) |
| 3071 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3072 | __be32 *p; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3073 | int ret = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3074 | |
| 3075 | *change = 0; |
| 3076 | if (unlikely(bitmap[0] & (FATTR4_WORD0_CHANGE - 1U))) |
| 3077 | return -EIO; |
| 3078 | if (likely(bitmap[0] & FATTR4_WORD0_CHANGE)) { |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3079 | p = xdr_inline_decode(xdr, 8); |
| 3080 | if (unlikely(!p)) |
| 3081 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3082 | xdr_decode_hyper(p, change); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3083 | bitmap[0] &= ~FATTR4_WORD0_CHANGE; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3084 | ret = NFS_ATTR_FATTR_CHANGE; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3085 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3086 | dprintk("%s: change attribute=%Lu\n", __func__, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3087 | (unsigned long long)*change); |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3088 | return ret; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3089 | out_overflow: |
| 3090 | print_overflow_msg(__func__, xdr); |
| 3091 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3092 | } |
| 3093 | |
| 3094 | static int decode_attr_size(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *size) |
| 3095 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3096 | __be32 *p; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3097 | int ret = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3098 | |
| 3099 | *size = 0; |
| 3100 | if (unlikely(bitmap[0] & (FATTR4_WORD0_SIZE - 1U))) |
| 3101 | return -EIO; |
| 3102 | if (likely(bitmap[0] & FATTR4_WORD0_SIZE)) { |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3103 | p = xdr_inline_decode(xdr, 8); |
| 3104 | if (unlikely(!p)) |
| 3105 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3106 | xdr_decode_hyper(p, size); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3107 | bitmap[0] &= ~FATTR4_WORD0_SIZE; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3108 | ret = NFS_ATTR_FATTR_SIZE; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3109 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3110 | dprintk("%s: file size=%Lu\n", __func__, (unsigned long long)*size); |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3111 | return ret; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3112 | out_overflow: |
| 3113 | print_overflow_msg(__func__, xdr); |
| 3114 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3115 | } |
| 3116 | |
| 3117 | static int decode_attr_link_support(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t *res) |
| 3118 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3119 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3120 | |
| 3121 | *res = 0; |
| 3122 | if (unlikely(bitmap[0] & (FATTR4_WORD0_LINK_SUPPORT - 1U))) |
| 3123 | return -EIO; |
| 3124 | if (likely(bitmap[0] & FATTR4_WORD0_LINK_SUPPORT)) { |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3125 | p = xdr_inline_decode(xdr, 4); |
| 3126 | if (unlikely(!p)) |
| 3127 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3128 | *res = be32_to_cpup(p); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3129 | bitmap[0] &= ~FATTR4_WORD0_LINK_SUPPORT; |
| 3130 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3131 | dprintk("%s: link support=%s\n", __func__, *res == 0 ? "false" : "true"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3132 | return 0; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3133 | out_overflow: |
| 3134 | print_overflow_msg(__func__, xdr); |
| 3135 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3136 | } |
| 3137 | |
| 3138 | static int decode_attr_symlink_support(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t *res) |
| 3139 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3140 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3141 | |
| 3142 | *res = 0; |
| 3143 | if (unlikely(bitmap[0] & (FATTR4_WORD0_SYMLINK_SUPPORT - 1U))) |
| 3144 | return -EIO; |
| 3145 | if (likely(bitmap[0] & FATTR4_WORD0_SYMLINK_SUPPORT)) { |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3146 | p = xdr_inline_decode(xdr, 4); |
| 3147 | if (unlikely(!p)) |
| 3148 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3149 | *res = be32_to_cpup(p); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3150 | bitmap[0] &= ~FATTR4_WORD0_SYMLINK_SUPPORT; |
| 3151 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3152 | dprintk("%s: symlink support=%s\n", __func__, *res == 0 ? "false" : "true"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3153 | return 0; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3154 | out_overflow: |
| 3155 | print_overflow_msg(__func__, xdr); |
| 3156 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3157 | } |
| 3158 | |
Trond Myklebust | 8b4bdcf | 2006-06-09 09:34:19 -0400 | [diff] [blame] | 3159 | 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] | 3160 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3161 | __be32 *p; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3162 | int ret = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3163 | |
| 3164 | fsid->major = 0; |
| 3165 | fsid->minor = 0; |
| 3166 | if (unlikely(bitmap[0] & (FATTR4_WORD0_FSID - 1U))) |
| 3167 | return -EIO; |
| 3168 | if (likely(bitmap[0] & FATTR4_WORD0_FSID)) { |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3169 | p = xdr_inline_decode(xdr, 16); |
| 3170 | if (unlikely(!p)) |
| 3171 | goto out_overflow; |
Benny Halevy | 3ceb4db | 2009-08-14 17:19:41 +0300 | [diff] [blame] | 3172 | p = xdr_decode_hyper(p, &fsid->major); |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3173 | xdr_decode_hyper(p, &fsid->minor); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3174 | bitmap[0] &= ~FATTR4_WORD0_FSID; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3175 | ret = NFS_ATTR_FATTR_FSID; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3176 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3177 | dprintk("%s: fsid=(0x%Lx/0x%Lx)\n", __func__, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3178 | (unsigned long long)fsid->major, |
| 3179 | (unsigned long long)fsid->minor); |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3180 | return ret; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3181 | out_overflow: |
| 3182 | print_overflow_msg(__func__, xdr); |
| 3183 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3184 | } |
| 3185 | |
| 3186 | static int decode_attr_lease_time(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t *res) |
| 3187 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3188 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3189 | |
| 3190 | *res = 60; |
| 3191 | if (unlikely(bitmap[0] & (FATTR4_WORD0_LEASE_TIME - 1U))) |
| 3192 | return -EIO; |
| 3193 | if (likely(bitmap[0] & FATTR4_WORD0_LEASE_TIME)) { |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3194 | p = xdr_inline_decode(xdr, 4); |
| 3195 | if (unlikely(!p)) |
| 3196 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3197 | *res = be32_to_cpup(p); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3198 | bitmap[0] &= ~FATTR4_WORD0_LEASE_TIME; |
| 3199 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3200 | dprintk("%s: file size=%u\n", __func__, (unsigned int)*res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3201 | return 0; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3202 | out_overflow: |
| 3203 | print_overflow_msg(__func__, xdr); |
| 3204 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3205 | } |
| 3206 | |
Trond Myklebust | ee7b75f | 2011-06-16 13:15:41 -0400 | [diff] [blame] | 3207 | 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] | 3208 | { |
| 3209 | __be32 *p; |
| 3210 | |
| 3211 | if (unlikely(bitmap[0] & (FATTR4_WORD0_RDATTR_ERROR - 1U))) |
| 3212 | return -EIO; |
| 3213 | if (likely(bitmap[0] & FATTR4_WORD0_RDATTR_ERROR)) { |
| 3214 | p = xdr_inline_decode(xdr, 4); |
| 3215 | if (unlikely(!p)) |
| 3216 | goto out_overflow; |
| 3217 | bitmap[0] &= ~FATTR4_WORD0_RDATTR_ERROR; |
Trond Myklebust | ee7b75f | 2011-06-16 13:15:41 -0400 | [diff] [blame] | 3218 | *res = -be32_to_cpup(p); |
Bryan Schumaker | ae42c70 | 2010-10-21 16:33:17 -0400 | [diff] [blame] | 3219 | } |
| 3220 | return 0; |
| 3221 | out_overflow: |
| 3222 | print_overflow_msg(__func__, xdr); |
| 3223 | return -EIO; |
| 3224 | } |
| 3225 | |
| 3226 | static int decode_attr_filehandle(struct xdr_stream *xdr, uint32_t *bitmap, struct nfs_fh *fh) |
| 3227 | { |
| 3228 | __be32 *p; |
| 3229 | int len; |
| 3230 | |
Trond Myklebust | 7ad0735 | 2010-10-23 15:34:20 -0400 | [diff] [blame] | 3231 | if (fh != NULL) |
| 3232 | memset(fh, 0, sizeof(*fh)); |
Bryan Schumaker | ae42c70 | 2010-10-21 16:33:17 -0400 | [diff] [blame] | 3233 | |
| 3234 | if (unlikely(bitmap[0] & (FATTR4_WORD0_FILEHANDLE - 1U))) |
| 3235 | return -EIO; |
| 3236 | if (likely(bitmap[0] & FATTR4_WORD0_FILEHANDLE)) { |
| 3237 | p = xdr_inline_decode(xdr, 4); |
| 3238 | if (unlikely(!p)) |
| 3239 | goto out_overflow; |
| 3240 | len = be32_to_cpup(p); |
| 3241 | if (len > NFS4_FHSIZE) |
| 3242 | return -EIO; |
Bryan Schumaker | ae42c70 | 2010-10-21 16:33:17 -0400 | [diff] [blame] | 3243 | p = xdr_inline_decode(xdr, len); |
| 3244 | if (unlikely(!p)) |
| 3245 | goto out_overflow; |
Trond Myklebust | 7ad0735 | 2010-10-23 15:34:20 -0400 | [diff] [blame] | 3246 | if (fh != NULL) { |
| 3247 | memcpy(fh->data, p, len); |
| 3248 | fh->size = len; |
| 3249 | } |
Bryan Schumaker | ae42c70 | 2010-10-21 16:33:17 -0400 | [diff] [blame] | 3250 | bitmap[0] &= ~FATTR4_WORD0_FILEHANDLE; |
| 3251 | } |
| 3252 | return 0; |
| 3253 | out_overflow: |
| 3254 | print_overflow_msg(__func__, xdr); |
| 3255 | return -EIO; |
| 3256 | } |
| 3257 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3258 | static int decode_attr_aclsupport(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t *res) |
| 3259 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3260 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3261 | |
| 3262 | *res = ACL4_SUPPORT_ALLOW_ACL|ACL4_SUPPORT_DENY_ACL; |
| 3263 | if (unlikely(bitmap[0] & (FATTR4_WORD0_ACLSUPPORT - 1U))) |
| 3264 | return -EIO; |
| 3265 | if (likely(bitmap[0] & FATTR4_WORD0_ACLSUPPORT)) { |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3266 | p = xdr_inline_decode(xdr, 4); |
| 3267 | if (unlikely(!p)) |
| 3268 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3269 | *res = be32_to_cpup(p); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3270 | bitmap[0] &= ~FATTR4_WORD0_ACLSUPPORT; |
| 3271 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3272 | dprintk("%s: ACLs supported=%u\n", __func__, (unsigned int)*res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3273 | return 0; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3274 | out_overflow: |
| 3275 | print_overflow_msg(__func__, xdr); |
| 3276 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3277 | } |
| 3278 | |
| 3279 | static int decode_attr_fileid(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *fileid) |
| 3280 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3281 | __be32 *p; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3282 | int ret = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3283 | |
| 3284 | *fileid = 0; |
| 3285 | if (unlikely(bitmap[0] & (FATTR4_WORD0_FILEID - 1U))) |
| 3286 | return -EIO; |
| 3287 | if (likely(bitmap[0] & FATTR4_WORD0_FILEID)) { |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3288 | p = xdr_inline_decode(xdr, 8); |
| 3289 | if (unlikely(!p)) |
| 3290 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3291 | xdr_decode_hyper(p, fileid); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3292 | bitmap[0] &= ~FATTR4_WORD0_FILEID; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3293 | ret = NFS_ATTR_FATTR_FILEID; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3294 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3295 | dprintk("%s: fileid=%Lu\n", __func__, (unsigned long long)*fileid); |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3296 | return ret; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3297 | out_overflow: |
| 3298 | print_overflow_msg(__func__, xdr); |
| 3299 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3300 | } |
| 3301 | |
Manoj Naik | 99baf62 | 2006-06-09 09:34:24 -0400 | [diff] [blame] | 3302 | static int decode_attr_mounted_on_fileid(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *fileid) |
| 3303 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3304 | __be32 *p; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3305 | int ret = 0; |
Manoj Naik | 99baf62 | 2006-06-09 09:34:24 -0400 | [diff] [blame] | 3306 | |
| 3307 | *fileid = 0; |
| 3308 | if (unlikely(bitmap[1] & (FATTR4_WORD1_MOUNTED_ON_FILEID - 1U))) |
| 3309 | return -EIO; |
| 3310 | if (likely(bitmap[1] & FATTR4_WORD1_MOUNTED_ON_FILEID)) { |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3311 | p = xdr_inline_decode(xdr, 8); |
| 3312 | if (unlikely(!p)) |
| 3313 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3314 | xdr_decode_hyper(p, fileid); |
Manoj Naik | 99baf62 | 2006-06-09 09:34:24 -0400 | [diff] [blame] | 3315 | bitmap[1] &= ~FATTR4_WORD1_MOUNTED_ON_FILEID; |
Trond Myklebust | 28331a4 | 2011-04-27 13:47:52 -0400 | [diff] [blame] | 3316 | ret = NFS_ATTR_FATTR_MOUNTED_ON_FILEID; |
Manoj Naik | 99baf62 | 2006-06-09 09:34:24 -0400 | [diff] [blame] | 3317 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3318 | dprintk("%s: fileid=%Lu\n", __func__, (unsigned long long)*fileid); |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3319 | return ret; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3320 | out_overflow: |
| 3321 | print_overflow_msg(__func__, xdr); |
| 3322 | return -EIO; |
Manoj Naik | 99baf62 | 2006-06-09 09:34:24 -0400 | [diff] [blame] | 3323 | } |
| 3324 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3325 | static int decode_attr_files_avail(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *res) |
| 3326 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3327 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3328 | int status = 0; |
| 3329 | |
| 3330 | *res = 0; |
| 3331 | if (unlikely(bitmap[0] & (FATTR4_WORD0_FILES_AVAIL - 1U))) |
| 3332 | return -EIO; |
| 3333 | if (likely(bitmap[0] & FATTR4_WORD0_FILES_AVAIL)) { |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3334 | p = xdr_inline_decode(xdr, 8); |
| 3335 | if (unlikely(!p)) |
| 3336 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3337 | xdr_decode_hyper(p, res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3338 | bitmap[0] &= ~FATTR4_WORD0_FILES_AVAIL; |
| 3339 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3340 | dprintk("%s: files avail=%Lu\n", __func__, (unsigned long long)*res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3341 | return status; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3342 | out_overflow: |
| 3343 | print_overflow_msg(__func__, xdr); |
| 3344 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3345 | } |
| 3346 | |
| 3347 | static int decode_attr_files_free(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *res) |
| 3348 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3349 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3350 | int status = 0; |
| 3351 | |
| 3352 | *res = 0; |
| 3353 | if (unlikely(bitmap[0] & (FATTR4_WORD0_FILES_FREE - 1U))) |
| 3354 | return -EIO; |
| 3355 | if (likely(bitmap[0] & FATTR4_WORD0_FILES_FREE)) { |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3356 | p = xdr_inline_decode(xdr, 8); |
| 3357 | if (unlikely(!p)) |
| 3358 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3359 | xdr_decode_hyper(p, res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3360 | bitmap[0] &= ~FATTR4_WORD0_FILES_FREE; |
| 3361 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3362 | dprintk("%s: files free=%Lu\n", __func__, (unsigned long long)*res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3363 | return status; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3364 | out_overflow: |
| 3365 | print_overflow_msg(__func__, xdr); |
| 3366 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3367 | } |
| 3368 | |
| 3369 | static int decode_attr_files_total(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *res) |
| 3370 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3371 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3372 | int status = 0; |
| 3373 | |
| 3374 | *res = 0; |
| 3375 | if (unlikely(bitmap[0] & (FATTR4_WORD0_FILES_TOTAL - 1U))) |
| 3376 | return -EIO; |
| 3377 | if (likely(bitmap[0] & FATTR4_WORD0_FILES_TOTAL)) { |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3378 | p = xdr_inline_decode(xdr, 8); |
| 3379 | if (unlikely(!p)) |
| 3380 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3381 | xdr_decode_hyper(p, res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3382 | bitmap[0] &= ~FATTR4_WORD0_FILES_TOTAL; |
| 3383 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3384 | dprintk("%s: files total=%Lu\n", __func__, (unsigned long long)*res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3385 | return status; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3386 | out_overflow: |
| 3387 | print_overflow_msg(__func__, xdr); |
| 3388 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3389 | } |
| 3390 | |
Manoj Naik | 7aaa0b3 | 2006-06-09 09:34:23 -0400 | [diff] [blame] | 3391 | static int decode_pathname(struct xdr_stream *xdr, struct nfs4_pathname *path) |
| 3392 | { |
Chuck Lever | 464ad6b | 2007-10-26 13:32:08 -0400 | [diff] [blame] | 3393 | u32 n; |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3394 | __be32 *p; |
Manoj Naik | 7aaa0b3 | 2006-06-09 09:34:23 -0400 | [diff] [blame] | 3395 | int status = 0; |
| 3396 | |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3397 | p = xdr_inline_decode(xdr, 4); |
| 3398 | if (unlikely(!p)) |
| 3399 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3400 | n = be32_to_cpup(p); |
Andy Adamson | 33a43f2 | 2006-06-09 09:34:30 -0400 | [diff] [blame] | 3401 | if (n == 0) |
| 3402 | goto root_path; |
Chuck Lever | 02a2976 | 2012-03-01 17:00:31 -0500 | [diff] [blame] | 3403 | dprintk("pathname4: "); |
Manoj Naik | 7aaa0b3 | 2006-06-09 09:34:23 -0400 | [diff] [blame] | 3404 | path->ncomponents = 0; |
| 3405 | while (path->ncomponents < n) { |
| 3406 | struct nfs4_string *component = &path->components[path->ncomponents]; |
| 3407 | status = decode_opaque_inline(xdr, &component->len, &component->data); |
| 3408 | if (unlikely(status != 0)) |
| 3409 | goto out_eio; |
Trond Myklebust | 95a13f7 | 2012-03-14 21:55:01 -0400 | [diff] [blame] | 3410 | ifdebug (XDR) |
Chuck Lever | 02a2976 | 2012-03-01 17:00:31 -0500 | [diff] [blame] | 3411 | pr_cont("%s%.*s ", |
| 3412 | (path->ncomponents != n ? "/ " : ""), |
| 3413 | component->len, component->data); |
Manoj Naik | 7aaa0b3 | 2006-06-09 09:34:23 -0400 | [diff] [blame] | 3414 | if (path->ncomponents < NFS4_PATHNAME_MAXCOMPONENTS) |
| 3415 | path->ncomponents++; |
| 3416 | else { |
| 3417 | dprintk("cannot parse %d components in path\n", n); |
| 3418 | goto out_eio; |
| 3419 | } |
| 3420 | } |
| 3421 | out: |
Manoj Naik | 7aaa0b3 | 2006-06-09 09:34:23 -0400 | [diff] [blame] | 3422 | return status; |
Andy Adamson | 33a43f2 | 2006-06-09 09:34:30 -0400 | [diff] [blame] | 3423 | root_path: |
| 3424 | /* a root pathname is sent as a zero component4 */ |
| 3425 | path->ncomponents = 1; |
| 3426 | path->components[0].len=0; |
| 3427 | path->components[0].data=NULL; |
Chuck Lever | 02a2976 | 2012-03-01 17:00:31 -0500 | [diff] [blame] | 3428 | dprintk("pathname4: /\n"); |
Andy Adamson | 33a43f2 | 2006-06-09 09:34:30 -0400 | [diff] [blame] | 3429 | goto out; |
Manoj Naik | 7aaa0b3 | 2006-06-09 09:34:23 -0400 | [diff] [blame] | 3430 | out_eio: |
| 3431 | dprintk(" status %d", status); |
| 3432 | status = -EIO; |
| 3433 | goto out; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3434 | out_overflow: |
| 3435 | print_overflow_msg(__func__, xdr); |
| 3436 | return -EIO; |
Manoj Naik | 7aaa0b3 | 2006-06-09 09:34:23 -0400 | [diff] [blame] | 3437 | } |
| 3438 | |
| 3439 | 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] | 3440 | { |
| 3441 | int n; |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3442 | __be32 *p; |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 3443 | int status = -EIO; |
| 3444 | |
| 3445 | if (unlikely(bitmap[0] & (FATTR4_WORD0_FS_LOCATIONS -1U))) |
| 3446 | goto out; |
| 3447 | status = 0; |
| 3448 | if (unlikely(!(bitmap[0] & FATTR4_WORD0_FS_LOCATIONS))) |
| 3449 | goto out; |
Trond Myklebust | 8b7e3f4 | 2012-01-30 15:43:56 -0500 | [diff] [blame] | 3450 | status = -EIO; |
| 3451 | /* Ignore borken servers that return unrequested attrs */ |
| 3452 | if (unlikely(res == NULL)) |
| 3453 | goto out; |
Chuck Lever | 02a2976 | 2012-03-01 17:00:31 -0500 | [diff] [blame] | 3454 | dprintk("%s: fsroot:\n", __func__); |
Manoj Naik | 7aaa0b3 | 2006-06-09 09:34:23 -0400 | [diff] [blame] | 3455 | status = decode_pathname(xdr, &res->fs_path); |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 3456 | if (unlikely(status != 0)) |
| 3457 | goto out; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3458 | p = xdr_inline_decode(xdr, 4); |
| 3459 | if (unlikely(!p)) |
| 3460 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3461 | n = be32_to_cpup(p); |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 3462 | if (n <= 0) |
| 3463 | goto out_eio; |
| 3464 | res->nlocations = 0; |
| 3465 | while (res->nlocations < n) { |
Chuck Lever | 464ad6b | 2007-10-26 13:32:08 -0400 | [diff] [blame] | 3466 | u32 m; |
Manoj Naik | 7aaa0b3 | 2006-06-09 09:34:23 -0400 | [diff] [blame] | 3467 | struct nfs4_fs_location *loc = &res->locations[res->nlocations]; |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 3468 | |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3469 | p = xdr_inline_decode(xdr, 4); |
| 3470 | if (unlikely(!p)) |
| 3471 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3472 | m = be32_to_cpup(p); |
Manoj Naik | 7aaa0b3 | 2006-06-09 09:34:23 -0400 | [diff] [blame] | 3473 | |
| 3474 | loc->nservers = 0; |
Chuck Lever | 02a2976 | 2012-03-01 17:00:31 -0500 | [diff] [blame] | 3475 | dprintk("%s: servers:\n", __func__); |
Manoj Naik | 7aaa0b3 | 2006-06-09 09:34:23 -0400 | [diff] [blame] | 3476 | while (loc->nservers < m) { |
| 3477 | struct nfs4_string *server = &loc->servers[loc->nservers]; |
| 3478 | status = decode_opaque_inline(xdr, &server->len, &server->data); |
| 3479 | if (unlikely(status != 0)) |
| 3480 | goto out_eio; |
| 3481 | dprintk("%s ", server->data); |
| 3482 | if (loc->nservers < NFS4_FS_LOCATION_MAXSERVERS) |
| 3483 | loc->nservers++; |
| 3484 | else { |
Chuck Lever | 464ad6b | 2007-10-26 13:32:08 -0400 | [diff] [blame] | 3485 | unsigned int i; |
| 3486 | dprintk("%s: using first %u of %u servers " |
| 3487 | "returned for location %u\n", |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3488 | __func__, |
Chuck Lever | 464ad6b | 2007-10-26 13:32:08 -0400 | [diff] [blame] | 3489 | NFS4_FS_LOCATION_MAXSERVERS, |
| 3490 | m, res->nlocations); |
Manoj Naik | 7aaa0b3 | 2006-06-09 09:34:23 -0400 | [diff] [blame] | 3491 | for (i = loc->nservers; i < m; i++) { |
Trond Myklebust | 2e42c3e | 2007-05-14 17:20:41 -0400 | [diff] [blame] | 3492 | unsigned int len; |
Manoj Naik | 7aaa0b3 | 2006-06-09 09:34:23 -0400 | [diff] [blame] | 3493 | char *data; |
| 3494 | status = decode_opaque_inline(xdr, &len, &data); |
| 3495 | if (unlikely(status != 0)) |
| 3496 | goto out_eio; |
| 3497 | } |
| 3498 | } |
| 3499 | } |
| 3500 | status = decode_pathname(xdr, &loc->rootpath); |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 3501 | if (unlikely(status != 0)) |
| 3502 | goto out_eio; |
Manoj Naik | 7aaa0b3 | 2006-06-09 09:34:23 -0400 | [diff] [blame] | 3503 | if (res->nlocations < NFS4_FS_LOCATIONS_MAXENTRIES) |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 3504 | res->nlocations++; |
| 3505 | } |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3506 | if (res->nlocations != 0) |
Chuck Lever | 81934dd | 2012-03-01 17:01:57 -0500 | [diff] [blame] | 3507 | status = NFS_ATTR_FATTR_V4_LOCATIONS; |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 3508 | out: |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3509 | dprintk("%s: fs_locations done, error = %d\n", __func__, status); |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 3510 | return status; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3511 | out_overflow: |
| 3512 | print_overflow_msg(__func__, xdr); |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 3513 | out_eio: |
| 3514 | status = -EIO; |
| 3515 | goto out; |
| 3516 | } |
| 3517 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3518 | static int decode_attr_maxfilesize(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *res) |
| 3519 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3520 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3521 | int status = 0; |
| 3522 | |
| 3523 | *res = 0; |
| 3524 | if (unlikely(bitmap[0] & (FATTR4_WORD0_MAXFILESIZE - 1U))) |
| 3525 | return -EIO; |
| 3526 | if (likely(bitmap[0] & FATTR4_WORD0_MAXFILESIZE)) { |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3527 | p = xdr_inline_decode(xdr, 8); |
| 3528 | if (unlikely(!p)) |
| 3529 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3530 | xdr_decode_hyper(p, res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3531 | bitmap[0] &= ~FATTR4_WORD0_MAXFILESIZE; |
| 3532 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3533 | dprintk("%s: maxfilesize=%Lu\n", __func__, (unsigned long long)*res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3534 | return status; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3535 | out_overflow: |
| 3536 | print_overflow_msg(__func__, xdr); |
| 3537 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3538 | } |
| 3539 | |
| 3540 | static int decode_attr_maxlink(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t *maxlink) |
| 3541 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3542 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3543 | int status = 0; |
| 3544 | |
| 3545 | *maxlink = 1; |
| 3546 | if (unlikely(bitmap[0] & (FATTR4_WORD0_MAXLINK - 1U))) |
| 3547 | return -EIO; |
| 3548 | if (likely(bitmap[0] & FATTR4_WORD0_MAXLINK)) { |
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 | *maxlink = be32_to_cpup(p); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3553 | bitmap[0] &= ~FATTR4_WORD0_MAXLINK; |
| 3554 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3555 | dprintk("%s: maxlink=%u\n", __func__, *maxlink); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3556 | return status; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3557 | out_overflow: |
| 3558 | print_overflow_msg(__func__, xdr); |
| 3559 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3560 | } |
| 3561 | |
| 3562 | static int decode_attr_maxname(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t *maxname) |
| 3563 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3564 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3565 | int status = 0; |
| 3566 | |
| 3567 | *maxname = 1024; |
| 3568 | if (unlikely(bitmap[0] & (FATTR4_WORD0_MAXNAME - 1U))) |
| 3569 | return -EIO; |
| 3570 | if (likely(bitmap[0] & FATTR4_WORD0_MAXNAME)) { |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3571 | p = xdr_inline_decode(xdr, 4); |
| 3572 | if (unlikely(!p)) |
| 3573 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3574 | *maxname = be32_to_cpup(p); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3575 | bitmap[0] &= ~FATTR4_WORD0_MAXNAME; |
| 3576 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3577 | dprintk("%s: maxname=%u\n", __func__, *maxname); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3578 | return status; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3579 | out_overflow: |
| 3580 | print_overflow_msg(__func__, xdr); |
| 3581 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3582 | } |
| 3583 | |
| 3584 | static int decode_attr_maxread(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t *res) |
| 3585 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3586 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3587 | int status = 0; |
| 3588 | |
| 3589 | *res = 1024; |
| 3590 | if (unlikely(bitmap[0] & (FATTR4_WORD0_MAXREAD - 1U))) |
| 3591 | return -EIO; |
| 3592 | if (likely(bitmap[0] & FATTR4_WORD0_MAXREAD)) { |
| 3593 | uint64_t maxread; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3594 | p = xdr_inline_decode(xdr, 8); |
| 3595 | if (unlikely(!p)) |
| 3596 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3597 | xdr_decode_hyper(p, &maxread); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3598 | if (maxread > 0x7FFFFFFF) |
| 3599 | maxread = 0x7FFFFFFF; |
| 3600 | *res = (uint32_t)maxread; |
| 3601 | bitmap[0] &= ~FATTR4_WORD0_MAXREAD; |
| 3602 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3603 | dprintk("%s: maxread=%lu\n", __func__, (unsigned long)*res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3604 | return status; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3605 | out_overflow: |
| 3606 | print_overflow_msg(__func__, xdr); |
| 3607 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3608 | } |
| 3609 | |
| 3610 | static int decode_attr_maxwrite(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t *res) |
| 3611 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3612 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3613 | int status = 0; |
| 3614 | |
| 3615 | *res = 1024; |
| 3616 | if (unlikely(bitmap[0] & (FATTR4_WORD0_MAXWRITE - 1U))) |
| 3617 | return -EIO; |
| 3618 | if (likely(bitmap[0] & FATTR4_WORD0_MAXWRITE)) { |
| 3619 | uint64_t maxwrite; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3620 | p = xdr_inline_decode(xdr, 8); |
| 3621 | if (unlikely(!p)) |
| 3622 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3623 | xdr_decode_hyper(p, &maxwrite); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3624 | if (maxwrite > 0x7FFFFFFF) |
| 3625 | maxwrite = 0x7FFFFFFF; |
| 3626 | *res = (uint32_t)maxwrite; |
| 3627 | bitmap[0] &= ~FATTR4_WORD0_MAXWRITE; |
| 3628 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3629 | dprintk("%s: maxwrite=%lu\n", __func__, (unsigned long)*res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3630 | return status; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3631 | out_overflow: |
| 3632 | print_overflow_msg(__func__, xdr); |
| 3633 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3634 | } |
| 3635 | |
Trond Myklebust | bca7947 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 3636 | 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] | 3637 | { |
Trond Myklebust | bca7947 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 3638 | uint32_t tmp; |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3639 | __be32 *p; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3640 | int ret = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3641 | |
| 3642 | *mode = 0; |
| 3643 | if (unlikely(bitmap[1] & (FATTR4_WORD1_MODE - 1U))) |
| 3644 | return -EIO; |
| 3645 | if (likely(bitmap[1] & FATTR4_WORD1_MODE)) { |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3646 | p = xdr_inline_decode(xdr, 4); |
| 3647 | if (unlikely(!p)) |
| 3648 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3649 | tmp = be32_to_cpup(p); |
Trond Myklebust | bca7947 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 3650 | *mode = tmp & ~S_IFMT; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3651 | bitmap[1] &= ~FATTR4_WORD1_MODE; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3652 | ret = NFS_ATTR_FATTR_MODE; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3653 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3654 | dprintk("%s: file mode=0%o\n", __func__, (unsigned int)*mode); |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3655 | return ret; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3656 | out_overflow: |
| 3657 | print_overflow_msg(__func__, xdr); |
| 3658 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3659 | } |
| 3660 | |
| 3661 | static int decode_attr_nlink(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t *nlink) |
| 3662 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3663 | __be32 *p; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3664 | int ret = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3665 | |
| 3666 | *nlink = 1; |
| 3667 | if (unlikely(bitmap[1] & (FATTR4_WORD1_NUMLINKS - 1U))) |
| 3668 | return -EIO; |
| 3669 | if (likely(bitmap[1] & FATTR4_WORD1_NUMLINKS)) { |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3670 | p = xdr_inline_decode(xdr, 4); |
| 3671 | if (unlikely(!p)) |
| 3672 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3673 | *nlink = be32_to_cpup(p); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3674 | bitmap[1] &= ~FATTR4_WORD1_NUMLINKS; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3675 | ret = NFS_ATTR_FATTR_NLINK; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3676 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3677 | dprintk("%s: nlink=%u\n", __func__, (unsigned int)*nlink); |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3678 | return ret; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3679 | out_overflow: |
| 3680 | print_overflow_msg(__func__, xdr); |
| 3681 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3682 | } |
| 3683 | |
Trond Myklebust | 80e52ac | 2009-08-09 15:06:19 -0400 | [diff] [blame] | 3684 | static int decode_attr_owner(struct xdr_stream *xdr, uint32_t *bitmap, |
Trond Myklebust | 6926afd | 2012-01-07 13:22:46 -0500 | [diff] [blame] | 3685 | const struct nfs_server *server, uint32_t *uid, |
| 3686 | struct nfs4_string *owner_name) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3687 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3688 | uint32_t len; |
| 3689 | __be32 *p; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3690 | int ret = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3691 | |
| 3692 | *uid = -2; |
| 3693 | if (unlikely(bitmap[1] & (FATTR4_WORD1_OWNER - 1U))) |
| 3694 | return -EIO; |
| 3695 | if (likely(bitmap[1] & FATTR4_WORD1_OWNER)) { |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3696 | p = xdr_inline_decode(xdr, 4); |
| 3697 | if (unlikely(!p)) |
| 3698 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3699 | len = be32_to_cpup(p); |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3700 | p = xdr_inline_decode(xdr, len); |
| 3701 | if (unlikely(!p)) |
| 3702 | goto out_overflow; |
Trond Myklebust | 6926afd | 2012-01-07 13:22:46 -0500 | [diff] [blame] | 3703 | if (owner_name != NULL) { |
| 3704 | owner_name->data = kmemdup(p, len, GFP_NOWAIT); |
| 3705 | if (owner_name->data != NULL) { |
| 3706 | owner_name->len = len; |
| 3707 | ret = NFS_ATTR_FATTR_OWNER_NAME; |
| 3708 | } |
Trond Myklebust | 80e52ac | 2009-08-09 15:06:19 -0400 | [diff] [blame] | 3709 | } else if (len < XDR_MAX_NETOBJ) { |
Trond Myklebust | e4fd72a | 2011-02-22 15:44:31 -0800 | [diff] [blame] | 3710 | if (nfs_map_name_to_uid(server, (char *)p, len, uid) == 0) |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3711 | ret = NFS_ATTR_FATTR_OWNER; |
| 3712 | else |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3713 | dprintk("%s: nfs_map_name_to_uid failed!\n", |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3714 | __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3715 | } else |
Chuck Lever | fe82a18 | 2007-09-11 18:01:10 -0400 | [diff] [blame] | 3716 | dprintk("%s: name too long (%u)!\n", |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3717 | __func__, len); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3718 | bitmap[1] &= ~FATTR4_WORD1_OWNER; |
| 3719 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3720 | dprintk("%s: uid=%d\n", __func__, (int)*uid); |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3721 | return ret; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3722 | out_overflow: |
| 3723 | print_overflow_msg(__func__, xdr); |
| 3724 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3725 | } |
| 3726 | |
Trond Myklebust | 80e52ac | 2009-08-09 15:06:19 -0400 | [diff] [blame] | 3727 | static int decode_attr_group(struct xdr_stream *xdr, uint32_t *bitmap, |
Trond Myklebust | 6926afd | 2012-01-07 13:22:46 -0500 | [diff] [blame] | 3728 | const struct nfs_server *server, uint32_t *gid, |
| 3729 | struct nfs4_string *group_name) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3730 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3731 | uint32_t len; |
| 3732 | __be32 *p; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3733 | int ret = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3734 | |
| 3735 | *gid = -2; |
| 3736 | if (unlikely(bitmap[1] & (FATTR4_WORD1_OWNER_GROUP - 1U))) |
| 3737 | return -EIO; |
| 3738 | if (likely(bitmap[1] & FATTR4_WORD1_OWNER_GROUP)) { |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3739 | p = xdr_inline_decode(xdr, 4); |
| 3740 | if (unlikely(!p)) |
| 3741 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3742 | len = be32_to_cpup(p); |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3743 | p = xdr_inline_decode(xdr, len); |
| 3744 | if (unlikely(!p)) |
| 3745 | goto out_overflow; |
Trond Myklebust | 6926afd | 2012-01-07 13:22:46 -0500 | [diff] [blame] | 3746 | if (group_name != NULL) { |
| 3747 | group_name->data = kmemdup(p, len, GFP_NOWAIT); |
| 3748 | if (group_name->data != NULL) { |
| 3749 | group_name->len = len; |
| 3750 | ret = NFS_ATTR_FATTR_GROUP_NAME; |
| 3751 | } |
Trond Myklebust | 80e52ac | 2009-08-09 15:06:19 -0400 | [diff] [blame] | 3752 | } else if (len < XDR_MAX_NETOBJ) { |
Trond Myklebust | e4fd72a | 2011-02-22 15:44:31 -0800 | [diff] [blame] | 3753 | if (nfs_map_group_to_gid(server, (char *)p, len, gid) == 0) |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3754 | ret = NFS_ATTR_FATTR_GROUP; |
| 3755 | else |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3756 | dprintk("%s: nfs_map_group_to_gid failed!\n", |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3757 | __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3758 | } else |
Chuck Lever | fe82a18 | 2007-09-11 18:01:10 -0400 | [diff] [blame] | 3759 | dprintk("%s: name too long (%u)!\n", |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3760 | __func__, len); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3761 | bitmap[1] &= ~FATTR4_WORD1_OWNER_GROUP; |
| 3762 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3763 | dprintk("%s: gid=%d\n", __func__, (int)*gid); |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3764 | return ret; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3765 | out_overflow: |
| 3766 | print_overflow_msg(__func__, xdr); |
| 3767 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3768 | } |
| 3769 | |
| 3770 | static int decode_attr_rdev(struct xdr_stream *xdr, uint32_t *bitmap, dev_t *rdev) |
| 3771 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3772 | uint32_t major = 0, minor = 0; |
| 3773 | __be32 *p; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3774 | int ret = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3775 | |
| 3776 | *rdev = MKDEV(0,0); |
| 3777 | if (unlikely(bitmap[1] & (FATTR4_WORD1_RAWDEV - 1U))) |
| 3778 | return -EIO; |
| 3779 | if (likely(bitmap[1] & FATTR4_WORD1_RAWDEV)) { |
| 3780 | dev_t tmp; |
| 3781 | |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3782 | p = xdr_inline_decode(xdr, 8); |
| 3783 | if (unlikely(!p)) |
| 3784 | goto out_overflow; |
Benny Halevy | 6f723f7 | 2009-08-14 17:19:37 +0300 | [diff] [blame] | 3785 | major = be32_to_cpup(p++); |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3786 | minor = be32_to_cpup(p); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3787 | tmp = MKDEV(major, minor); |
| 3788 | if (MAJOR(tmp) == major && MINOR(tmp) == minor) |
| 3789 | *rdev = tmp; |
| 3790 | bitmap[1] &= ~ FATTR4_WORD1_RAWDEV; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3791 | ret = NFS_ATTR_FATTR_RDEV; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3792 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3793 | dprintk("%s: rdev=(0x%x:0x%x)\n", __func__, major, minor); |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3794 | return ret; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3795 | out_overflow: |
| 3796 | print_overflow_msg(__func__, xdr); |
| 3797 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3798 | } |
| 3799 | |
| 3800 | static int decode_attr_space_avail(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *res) |
| 3801 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3802 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3803 | int status = 0; |
| 3804 | |
| 3805 | *res = 0; |
| 3806 | if (unlikely(bitmap[1] & (FATTR4_WORD1_SPACE_AVAIL - 1U))) |
| 3807 | return -EIO; |
| 3808 | if (likely(bitmap[1] & FATTR4_WORD1_SPACE_AVAIL)) { |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3809 | p = xdr_inline_decode(xdr, 8); |
| 3810 | if (unlikely(!p)) |
| 3811 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3812 | xdr_decode_hyper(p, res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3813 | bitmap[1] &= ~FATTR4_WORD1_SPACE_AVAIL; |
| 3814 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3815 | dprintk("%s: space avail=%Lu\n", __func__, (unsigned long long)*res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3816 | return status; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3817 | out_overflow: |
| 3818 | print_overflow_msg(__func__, xdr); |
| 3819 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3820 | } |
| 3821 | |
| 3822 | static int decode_attr_space_free(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *res) |
| 3823 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3824 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3825 | int status = 0; |
| 3826 | |
| 3827 | *res = 0; |
| 3828 | if (unlikely(bitmap[1] & (FATTR4_WORD1_SPACE_FREE - 1U))) |
| 3829 | return -EIO; |
| 3830 | if (likely(bitmap[1] & FATTR4_WORD1_SPACE_FREE)) { |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3831 | p = xdr_inline_decode(xdr, 8); |
| 3832 | if (unlikely(!p)) |
| 3833 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3834 | xdr_decode_hyper(p, res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3835 | bitmap[1] &= ~FATTR4_WORD1_SPACE_FREE; |
| 3836 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3837 | dprintk("%s: space free=%Lu\n", __func__, (unsigned long long)*res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3838 | return status; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3839 | out_overflow: |
| 3840 | print_overflow_msg(__func__, xdr); |
| 3841 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3842 | } |
| 3843 | |
| 3844 | static int decode_attr_space_total(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *res) |
| 3845 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3846 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3847 | int status = 0; |
| 3848 | |
| 3849 | *res = 0; |
| 3850 | if (unlikely(bitmap[1] & (FATTR4_WORD1_SPACE_TOTAL - 1U))) |
| 3851 | return -EIO; |
| 3852 | if (likely(bitmap[1] & FATTR4_WORD1_SPACE_TOTAL)) { |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3853 | p = xdr_inline_decode(xdr, 8); |
| 3854 | if (unlikely(!p)) |
| 3855 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3856 | xdr_decode_hyper(p, res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3857 | bitmap[1] &= ~FATTR4_WORD1_SPACE_TOTAL; |
| 3858 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3859 | dprintk("%s: space total=%Lu\n", __func__, (unsigned long long)*res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3860 | return status; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3861 | out_overflow: |
| 3862 | print_overflow_msg(__func__, xdr); |
| 3863 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3864 | } |
| 3865 | |
| 3866 | static int decode_attr_space_used(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *used) |
| 3867 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3868 | __be32 *p; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3869 | int ret = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3870 | |
| 3871 | *used = 0; |
| 3872 | if (unlikely(bitmap[1] & (FATTR4_WORD1_SPACE_USED - 1U))) |
| 3873 | return -EIO; |
| 3874 | if (likely(bitmap[1] & FATTR4_WORD1_SPACE_USED)) { |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3875 | p = xdr_inline_decode(xdr, 8); |
| 3876 | if (unlikely(!p)) |
| 3877 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3878 | xdr_decode_hyper(p, used); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3879 | bitmap[1] &= ~FATTR4_WORD1_SPACE_USED; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3880 | ret = NFS_ATTR_FATTR_SPACE_USED; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3881 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3882 | dprintk("%s: space used=%Lu\n", __func__, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3883 | (unsigned long long)*used); |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3884 | return ret; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3885 | out_overflow: |
| 3886 | print_overflow_msg(__func__, xdr); |
| 3887 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3888 | } |
| 3889 | |
| 3890 | static int decode_attr_time(struct xdr_stream *xdr, struct timespec *time) |
| 3891 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3892 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3893 | uint64_t sec; |
| 3894 | uint32_t nsec; |
| 3895 | |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3896 | p = xdr_inline_decode(xdr, 12); |
| 3897 | if (unlikely(!p)) |
| 3898 | goto out_overflow; |
Benny Halevy | 3ceb4db | 2009-08-14 17:19:41 +0300 | [diff] [blame] | 3899 | p = xdr_decode_hyper(p, &sec); |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3900 | nsec = be32_to_cpup(p); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3901 | time->tv_sec = (time_t)sec; |
| 3902 | time->tv_nsec = (long)nsec; |
| 3903 | return 0; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3904 | out_overflow: |
| 3905 | print_overflow_msg(__func__, xdr); |
| 3906 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3907 | } |
| 3908 | |
| 3909 | static int decode_attr_time_access(struct xdr_stream *xdr, uint32_t *bitmap, struct timespec *time) |
| 3910 | { |
| 3911 | int status = 0; |
| 3912 | |
| 3913 | time->tv_sec = 0; |
| 3914 | time->tv_nsec = 0; |
| 3915 | if (unlikely(bitmap[1] & (FATTR4_WORD1_TIME_ACCESS - 1U))) |
| 3916 | return -EIO; |
| 3917 | if (likely(bitmap[1] & FATTR4_WORD1_TIME_ACCESS)) { |
| 3918 | status = decode_attr_time(xdr, time); |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3919 | if (status == 0) |
| 3920 | status = NFS_ATTR_FATTR_ATIME; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3921 | bitmap[1] &= ~FATTR4_WORD1_TIME_ACCESS; |
| 3922 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3923 | dprintk("%s: atime=%ld\n", __func__, (long)time->tv_sec); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3924 | return status; |
| 3925 | } |
| 3926 | |
| 3927 | static int decode_attr_time_metadata(struct xdr_stream *xdr, uint32_t *bitmap, struct timespec *time) |
| 3928 | { |
| 3929 | int status = 0; |
| 3930 | |
| 3931 | time->tv_sec = 0; |
| 3932 | time->tv_nsec = 0; |
| 3933 | if (unlikely(bitmap[1] & (FATTR4_WORD1_TIME_METADATA - 1U))) |
| 3934 | return -EIO; |
| 3935 | if (likely(bitmap[1] & FATTR4_WORD1_TIME_METADATA)) { |
| 3936 | status = decode_attr_time(xdr, time); |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3937 | if (status == 0) |
| 3938 | status = NFS_ATTR_FATTR_CTIME; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3939 | bitmap[1] &= ~FATTR4_WORD1_TIME_METADATA; |
| 3940 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3941 | dprintk("%s: ctime=%ld\n", __func__, (long)time->tv_sec); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3942 | return status; |
| 3943 | } |
| 3944 | |
Ricardo Labiaga | 55b6e77 | 2010-10-12 16:30:06 -0700 | [diff] [blame] | 3945 | static int decode_attr_time_delta(struct xdr_stream *xdr, uint32_t *bitmap, |
| 3946 | struct timespec *time) |
| 3947 | { |
| 3948 | int status = 0; |
| 3949 | |
| 3950 | time->tv_sec = 0; |
| 3951 | time->tv_nsec = 0; |
| 3952 | if (unlikely(bitmap[1] & (FATTR4_WORD1_TIME_DELTA - 1U))) |
| 3953 | return -EIO; |
| 3954 | if (likely(bitmap[1] & FATTR4_WORD1_TIME_DELTA)) { |
| 3955 | status = decode_attr_time(xdr, time); |
| 3956 | bitmap[1] &= ~FATTR4_WORD1_TIME_DELTA; |
| 3957 | } |
| 3958 | dprintk("%s: time_delta=%ld %ld\n", __func__, (long)time->tv_sec, |
| 3959 | (long)time->tv_nsec); |
| 3960 | return status; |
| 3961 | } |
| 3962 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3963 | static int decode_attr_time_modify(struct xdr_stream *xdr, uint32_t *bitmap, struct timespec *time) |
| 3964 | { |
| 3965 | int status = 0; |
| 3966 | |
| 3967 | time->tv_sec = 0; |
| 3968 | time->tv_nsec = 0; |
| 3969 | if (unlikely(bitmap[1] & (FATTR4_WORD1_TIME_MODIFY - 1U))) |
| 3970 | return -EIO; |
| 3971 | if (likely(bitmap[1] & FATTR4_WORD1_TIME_MODIFY)) { |
| 3972 | status = decode_attr_time(xdr, time); |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3973 | if (status == 0) |
| 3974 | status = NFS_ATTR_FATTR_MTIME; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3975 | bitmap[1] &= ~FATTR4_WORD1_TIME_MODIFY; |
| 3976 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3977 | dprintk("%s: mtime=%ld\n", __func__, (long)time->tv_sec); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3978 | return status; |
| 3979 | } |
| 3980 | |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3981 | static int verify_attr_len(struct xdr_stream *xdr, __be32 *savep, uint32_t attrlen) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3982 | { |
| 3983 | unsigned int attrwords = XDR_QUADLEN(attrlen); |
| 3984 | unsigned int nwords = xdr->p - savep; |
| 3985 | |
| 3986 | if (unlikely(attrwords != nwords)) { |
Chuck Lever | fe82a18 | 2007-09-11 18:01:10 -0400 | [diff] [blame] | 3987 | dprintk("%s: server returned incorrect attribute length: " |
| 3988 | "%u %c %u\n", |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3989 | __func__, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3990 | attrwords << 2, |
| 3991 | (attrwords < nwords) ? '<' : '>', |
| 3992 | nwords << 2); |
| 3993 | return -EIO; |
| 3994 | } |
| 3995 | return 0; |
| 3996 | } |
| 3997 | |
| 3998 | static int decode_change_info(struct xdr_stream *xdr, struct nfs4_change_info *cinfo) |
| 3999 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 4000 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4001 | |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 4002 | p = xdr_inline_decode(xdr, 20); |
| 4003 | if (unlikely(!p)) |
| 4004 | goto out_overflow; |
Benny Halevy | 6f723f7 | 2009-08-14 17:19:37 +0300 | [diff] [blame] | 4005 | cinfo->atomic = be32_to_cpup(p++); |
Benny Halevy | 3ceb4db | 2009-08-14 17:19:41 +0300 | [diff] [blame] | 4006 | p = xdr_decode_hyper(p, &cinfo->before); |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 4007 | xdr_decode_hyper(p, &cinfo->after); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4008 | return 0; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 4009 | out_overflow: |
| 4010 | print_overflow_msg(__func__, xdr); |
| 4011 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4012 | } |
| 4013 | |
| 4014 | static int decode_access(struct xdr_stream *xdr, struct nfs4_accessres *access) |
| 4015 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 4016 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4017 | uint32_t supp, acc; |
| 4018 | int status; |
| 4019 | |
| 4020 | status = decode_op_hdr(xdr, OP_ACCESS); |
| 4021 | if (status) |
| 4022 | return status; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 4023 | p = xdr_inline_decode(xdr, 8); |
| 4024 | if (unlikely(!p)) |
| 4025 | goto out_overflow; |
Benny Halevy | 6f723f7 | 2009-08-14 17:19:37 +0300 | [diff] [blame] | 4026 | supp = be32_to_cpup(p++); |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 4027 | acc = be32_to_cpup(p); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4028 | access->supported = supp; |
| 4029 | access->access = acc; |
| 4030 | return 0; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 4031 | out_overflow: |
| 4032 | print_overflow_msg(__func__, xdr); |
| 4033 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4034 | } |
| 4035 | |
Benny Halevy | 07d3043 | 2009-08-14 17:19:52 +0300 | [diff] [blame] | 4036 | 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] | 4037 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 4038 | __be32 *p; |
Benny Halevy | 07d3043 | 2009-08-14 17:19:52 +0300 | [diff] [blame] | 4039 | |
| 4040 | p = xdr_inline_decode(xdr, len); |
| 4041 | if (likely(p)) { |
| 4042 | memcpy(buf, p, len); |
| 4043 | return 0; |
| 4044 | } |
| 4045 | print_overflow_msg(__func__, xdr); |
| 4046 | return -EIO; |
| 4047 | } |
| 4048 | |
| 4049 | static int decode_stateid(struct xdr_stream *xdr, nfs4_stateid *stateid) |
| 4050 | { |
Trond Myklebust | 2d2f24a | 2012-03-04 18:13:57 -0500 | [diff] [blame] | 4051 | return decode_opaque_fixed(xdr, stateid, NFS4_STATEID_SIZE); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4052 | } |
| 4053 | |
| 4054 | static int decode_close(struct xdr_stream *xdr, struct nfs_closeres *res) |
| 4055 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4056 | int status; |
| 4057 | |
| 4058 | status = decode_op_hdr(xdr, OP_CLOSE); |
Trond Myklebust | c1d5193 | 2008-04-07 13:20:54 -0400 | [diff] [blame] | 4059 | if (status != -EIO) |
| 4060 | nfs_increment_open_seqid(status, res->seqid); |
Benny Halevy | 07d3043 | 2009-08-14 17:19:52 +0300 | [diff] [blame] | 4061 | if (!status) |
| 4062 | status = decode_stateid(xdr, &res->stateid); |
| 4063 | return status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4064 | } |
| 4065 | |
Benny Halevy | db942bb | 2009-08-14 17:19:56 +0300 | [diff] [blame] | 4066 | static int decode_verifier(struct xdr_stream *xdr, void *verifier) |
| 4067 | { |
Chuck Lever | cd93710 | 2012-03-02 17:14:31 -0500 | [diff] [blame] | 4068 | return decode_opaque_fixed(xdr, verifier, NFS4_VERIFIER_SIZE); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4069 | } |
| 4070 | |
Fred Isaman | 0b7c015 | 2012-04-20 14:47:39 -0400 | [diff] [blame] | 4071 | static int decode_commit(struct xdr_stream *xdr, struct nfs_commitres *res) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4072 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4073 | int status; |
| 4074 | |
| 4075 | status = decode_op_hdr(xdr, OP_COMMIT); |
Benny Halevy | db942bb | 2009-08-14 17:19:56 +0300 | [diff] [blame] | 4076 | if (!status) |
| 4077 | status = decode_verifier(xdr, res->verf->verifier); |
| 4078 | return status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4079 | } |
| 4080 | |
| 4081 | static int decode_create(struct xdr_stream *xdr, struct nfs4_change_info *cinfo) |
| 4082 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 4083 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4084 | uint32_t bmlen; |
| 4085 | int status; |
| 4086 | |
| 4087 | status = decode_op_hdr(xdr, OP_CREATE); |
| 4088 | if (status) |
| 4089 | return status; |
| 4090 | if ((status = decode_change_info(xdr, cinfo))) |
| 4091 | return status; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 4092 | p = xdr_inline_decode(xdr, 4); |
| 4093 | if (unlikely(!p)) |
| 4094 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 4095 | bmlen = be32_to_cpup(p); |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 4096 | p = xdr_inline_decode(xdr, bmlen << 2); |
| 4097 | if (likely(p)) |
| 4098 | return 0; |
| 4099 | out_overflow: |
| 4100 | print_overflow_msg(__func__, xdr); |
| 4101 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4102 | } |
| 4103 | |
| 4104 | static int decode_server_caps(struct xdr_stream *xdr, struct nfs4_server_caps_res *res) |
| 4105 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 4106 | __be32 *savep; |
Fred Isaman | dae100c | 2011-07-30 20:52:37 -0400 | [diff] [blame] | 4107 | uint32_t attrlen, bitmap[3] = {0}; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4108 | int status; |
| 4109 | |
| 4110 | if ((status = decode_op_hdr(xdr, OP_GETATTR)) != 0) |
| 4111 | goto xdr_error; |
| 4112 | if ((status = decode_attr_bitmap(xdr, bitmap)) != 0) |
| 4113 | goto xdr_error; |
| 4114 | if ((status = decode_attr_length(xdr, &attrlen, &savep)) != 0) |
| 4115 | goto xdr_error; |
| 4116 | if ((status = decode_attr_supported(xdr, bitmap, res->attr_bitmask)) != 0) |
| 4117 | goto xdr_error; |
Chuck Lever | 264e635 | 2012-03-01 17:02:05 -0500 | [diff] [blame] | 4118 | if ((status = decode_attr_fh_expire_type(xdr, bitmap, |
| 4119 | &res->fh_expire_type)) != 0) |
| 4120 | goto xdr_error; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4121 | if ((status = decode_attr_link_support(xdr, bitmap, &res->has_links)) != 0) |
| 4122 | goto xdr_error; |
| 4123 | if ((status = decode_attr_symlink_support(xdr, bitmap, &res->has_symlinks)) != 0) |
| 4124 | goto xdr_error; |
| 4125 | if ((status = decode_attr_aclsupport(xdr, bitmap, &res->acl_bitmask)) != 0) |
| 4126 | goto xdr_error; |
| 4127 | status = verify_attr_len(xdr, savep, attrlen); |
| 4128 | xdr_error: |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 4129 | dprintk("%s: xdr returned %d!\n", __func__, -status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4130 | return status; |
| 4131 | } |
Andy Adamson | 6c0195a | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 4132 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4133 | static int decode_statfs(struct xdr_stream *xdr, struct nfs_fsstat *fsstat) |
| 4134 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 4135 | __be32 *savep; |
Fred Isaman | dae100c | 2011-07-30 20:52:37 -0400 | [diff] [blame] | 4136 | uint32_t attrlen, bitmap[3] = {0}; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4137 | int status; |
Andy Adamson | 6c0195a | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 4138 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4139 | if ((status = decode_op_hdr(xdr, OP_GETATTR)) != 0) |
| 4140 | goto xdr_error; |
| 4141 | if ((status = decode_attr_bitmap(xdr, bitmap)) != 0) |
| 4142 | goto xdr_error; |
| 4143 | if ((status = decode_attr_length(xdr, &attrlen, &savep)) != 0) |
| 4144 | goto xdr_error; |
| 4145 | |
| 4146 | if ((status = decode_attr_files_avail(xdr, bitmap, &fsstat->afiles)) != 0) |
| 4147 | goto xdr_error; |
| 4148 | if ((status = decode_attr_files_free(xdr, bitmap, &fsstat->ffiles)) != 0) |
| 4149 | goto xdr_error; |
| 4150 | if ((status = decode_attr_files_total(xdr, bitmap, &fsstat->tfiles)) != 0) |
| 4151 | goto xdr_error; |
| 4152 | if ((status = decode_attr_space_avail(xdr, bitmap, &fsstat->abytes)) != 0) |
| 4153 | goto xdr_error; |
| 4154 | if ((status = decode_attr_space_free(xdr, bitmap, &fsstat->fbytes)) != 0) |
| 4155 | goto xdr_error; |
| 4156 | if ((status = decode_attr_space_total(xdr, bitmap, &fsstat->tbytes)) != 0) |
| 4157 | goto xdr_error; |
| 4158 | |
| 4159 | status = verify_attr_len(xdr, savep, attrlen); |
| 4160 | xdr_error: |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 4161 | dprintk("%s: xdr returned %d!\n", __func__, -status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4162 | return status; |
| 4163 | } |
| 4164 | |
| 4165 | static int decode_pathconf(struct xdr_stream *xdr, struct nfs_pathconf *pathconf) |
| 4166 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 4167 | __be32 *savep; |
Fred Isaman | dae100c | 2011-07-30 20:52:37 -0400 | [diff] [blame] | 4168 | uint32_t attrlen, bitmap[3] = {0}; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4169 | int status; |
Andy Adamson | 6c0195a | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 4170 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4171 | if ((status = decode_op_hdr(xdr, OP_GETATTR)) != 0) |
| 4172 | goto xdr_error; |
| 4173 | if ((status = decode_attr_bitmap(xdr, bitmap)) != 0) |
| 4174 | goto xdr_error; |
| 4175 | if ((status = decode_attr_length(xdr, &attrlen, &savep)) != 0) |
| 4176 | goto xdr_error; |
| 4177 | |
| 4178 | if ((status = decode_attr_maxlink(xdr, bitmap, &pathconf->max_link)) != 0) |
| 4179 | goto xdr_error; |
| 4180 | if ((status = decode_attr_maxname(xdr, bitmap, &pathconf->max_namelen)) != 0) |
| 4181 | goto xdr_error; |
| 4182 | |
| 4183 | status = verify_attr_len(xdr, savep, attrlen); |
| 4184 | xdr_error: |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 4185 | dprintk("%s: xdr returned %d!\n", __func__, -status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4186 | return status; |
| 4187 | } |
| 4188 | |
Bryan Schumaker | ae42c70 | 2010-10-21 16:33:17 -0400 | [diff] [blame] | 4189 | static int decode_getfattr_attrs(struct xdr_stream *xdr, uint32_t *bitmap, |
| 4190 | struct nfs_fattr *fattr, struct nfs_fh *fh, |
Trond Myklebust | 8b7e3f4 | 2012-01-30 15:43:56 -0500 | [diff] [blame] | 4191 | struct nfs4_fs_locations *fs_loc, |
Trond Myklebust | 6926afd | 2012-01-07 13:22:46 -0500 | [diff] [blame] | 4192 | const struct nfs_server *server) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4193 | { |
Trond Myklebust | bca7947 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 4194 | int status; |
| 4195 | umode_t fmode = 0; |
Bryan Schumaker | ae42c70 | 2010-10-21 16:33:17 -0400 | [diff] [blame] | 4196 | uint32_t type; |
Trond Myklebust | ee7b75f | 2011-06-16 13:15:41 -0400 | [diff] [blame] | 4197 | int32_t err; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4198 | |
Trond Myklebust | f26c7a7 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 4199 | status = decode_attr_type(xdr, bitmap, &type); |
| 4200 | if (status < 0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4201 | goto xdr_error; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 4202 | fattr->mode = 0; |
| 4203 | if (status != 0) { |
| 4204 | fattr->mode |= nfs_type2fmt[type]; |
| 4205 | fattr->valid |= status; |
| 4206 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4207 | |
Trond Myklebust | f26c7a7 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 4208 | status = decode_attr_change(xdr, bitmap, &fattr->change_attr); |
| 4209 | if (status < 0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4210 | goto xdr_error; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 4211 | fattr->valid |= status; |
Trond Myklebust | f26c7a7 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 4212 | |
| 4213 | status = decode_attr_size(xdr, bitmap, &fattr->size); |
| 4214 | if (status < 0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4215 | goto xdr_error; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 4216 | fattr->valid |= status; |
Trond Myklebust | f26c7a7 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 4217 | |
| 4218 | status = decode_attr_fsid(xdr, bitmap, &fattr->fsid); |
| 4219 | if (status < 0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4220 | goto xdr_error; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 4221 | fattr->valid |= status; |
Trond Myklebust | f26c7a7 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 4222 | |
Trond Myklebust | ee7b75f | 2011-06-16 13:15:41 -0400 | [diff] [blame] | 4223 | err = 0; |
| 4224 | status = decode_attr_error(xdr, bitmap, &err); |
Bryan Schumaker | ae42c70 | 2010-10-21 16:33:17 -0400 | [diff] [blame] | 4225 | if (status < 0) |
| 4226 | goto xdr_error; |
| 4227 | |
| 4228 | status = decode_attr_filehandle(xdr, bitmap, fh); |
| 4229 | if (status < 0) |
| 4230 | goto xdr_error; |
| 4231 | |
Trond Myklebust | f26c7a7 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 4232 | status = decode_attr_fileid(xdr, bitmap, &fattr->fileid); |
| 4233 | if (status < 0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4234 | goto xdr_error; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 4235 | fattr->valid |= status; |
Trond Myklebust | f26c7a7 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 4236 | |
Trond Myklebust | 8b7e3f4 | 2012-01-30 15:43:56 -0500 | [diff] [blame] | 4237 | status = decode_attr_fs_locations(xdr, bitmap, fs_loc); |
Trond Myklebust | f26c7a7 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 4238 | if (status < 0) |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 4239 | goto xdr_error; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 4240 | fattr->valid |= status; |
Trond Myklebust | f26c7a7 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 4241 | |
| 4242 | status = decode_attr_mode(xdr, bitmap, &fmode); |
| 4243 | if (status < 0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4244 | goto xdr_error; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 4245 | if (status != 0) { |
| 4246 | fattr->mode |= fmode; |
| 4247 | fattr->valid |= status; |
| 4248 | } |
Trond Myklebust | f26c7a7 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 4249 | |
| 4250 | status = decode_attr_nlink(xdr, bitmap, &fattr->nlink); |
| 4251 | if (status < 0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4252 | goto xdr_error; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 4253 | fattr->valid |= status; |
Trond Myklebust | f26c7a7 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 4254 | |
Trond Myklebust | 6926afd | 2012-01-07 13:22:46 -0500 | [diff] [blame] | 4255 | status = decode_attr_owner(xdr, bitmap, server, &fattr->uid, fattr->owner_name); |
Trond Myklebust | f26c7a7 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 4256 | if (status < 0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4257 | goto xdr_error; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 4258 | fattr->valid |= status; |
Trond Myklebust | f26c7a7 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 4259 | |
Trond Myklebust | 6926afd | 2012-01-07 13:22:46 -0500 | [diff] [blame] | 4260 | status = decode_attr_group(xdr, bitmap, server, &fattr->gid, fattr->group_name); |
Trond Myklebust | f26c7a7 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 4261 | if (status < 0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4262 | goto xdr_error; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 4263 | fattr->valid |= status; |
Trond Myklebust | f26c7a7 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 4264 | |
| 4265 | status = decode_attr_rdev(xdr, bitmap, &fattr->rdev); |
| 4266 | if (status < 0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4267 | goto xdr_error; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 4268 | fattr->valid |= status; |
Trond Myklebust | f26c7a7 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 4269 | |
| 4270 | status = decode_attr_space_used(xdr, bitmap, &fattr->du.nfs3.used); |
| 4271 | if (status < 0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4272 | goto xdr_error; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 4273 | fattr->valid |= status; |
Trond Myklebust | f26c7a7 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 4274 | |
| 4275 | status = decode_attr_time_access(xdr, bitmap, &fattr->atime); |
| 4276 | if (status < 0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4277 | goto xdr_error; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 4278 | fattr->valid |= status; |
Trond Myklebust | f26c7a7 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 4279 | |
| 4280 | status = decode_attr_time_metadata(xdr, bitmap, &fattr->ctime); |
| 4281 | if (status < 0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4282 | goto xdr_error; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 4283 | fattr->valid |= status; |
Trond Myklebust | f26c7a7 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 4284 | |
| 4285 | status = decode_attr_time_modify(xdr, bitmap, &fattr->mtime); |
| 4286 | if (status < 0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4287 | goto xdr_error; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 4288 | fattr->valid |= status; |
Trond Myklebust | f26c7a7 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 4289 | |
Trond Myklebust | 28331a4 | 2011-04-27 13:47:52 -0400 | [diff] [blame] | 4290 | status = decode_attr_mounted_on_fileid(xdr, bitmap, &fattr->mounted_on_fileid); |
Trond Myklebust | f26c7a7 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 4291 | if (status < 0) |
Manoj Naik | 99baf62 | 2006-06-09 09:34:24 -0400 | [diff] [blame] | 4292 | goto xdr_error; |
Trond Myklebust | 28331a4 | 2011-04-27 13:47:52 -0400 | [diff] [blame] | 4293 | fattr->valid |= status; |
Trond Myklebust | f26c7a7 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 4294 | |
Bryan Schumaker | ae42c70 | 2010-10-21 16:33:17 -0400 | [diff] [blame] | 4295 | xdr_error: |
| 4296 | dprintk("%s: xdr returned %d\n", __func__, -status); |
| 4297 | return status; |
| 4298 | } |
| 4299 | |
| 4300 | 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] | 4301 | struct nfs_fh *fh, struct nfs4_fs_locations *fs_loc, |
| 4302 | const struct nfs_server *server) |
Bryan Schumaker | ae42c70 | 2010-10-21 16:33:17 -0400 | [diff] [blame] | 4303 | { |
| 4304 | __be32 *savep; |
| 4305 | uint32_t attrlen, |
Fred Isaman | dae100c | 2011-07-30 20:52:37 -0400 | [diff] [blame] | 4306 | bitmap[3] = {0}; |
Bryan Schumaker | ae42c70 | 2010-10-21 16:33:17 -0400 | [diff] [blame] | 4307 | int status; |
| 4308 | |
| 4309 | status = decode_op_hdr(xdr, OP_GETATTR); |
| 4310 | if (status < 0) |
| 4311 | goto xdr_error; |
| 4312 | |
| 4313 | status = decode_attr_bitmap(xdr, bitmap); |
| 4314 | if (status < 0) |
| 4315 | goto xdr_error; |
| 4316 | |
| 4317 | status = decode_attr_length(xdr, &attrlen, &savep); |
| 4318 | if (status < 0) |
| 4319 | goto xdr_error; |
| 4320 | |
Trond Myklebust | 8b7e3f4 | 2012-01-30 15:43:56 -0500 | [diff] [blame] | 4321 | status = decode_getfattr_attrs(xdr, bitmap, fattr, fh, fs_loc, server); |
Bryan Schumaker | ae42c70 | 2010-10-21 16:33:17 -0400 | [diff] [blame] | 4322 | if (status < 0) |
| 4323 | goto xdr_error; |
| 4324 | |
Trond Myklebust | f26c7a7 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 4325 | status = verify_attr_len(xdr, savep, attrlen); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4326 | xdr_error: |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 4327 | dprintk("%s: xdr returned %d\n", __func__, -status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4328 | return status; |
| 4329 | } |
| 4330 | |
Bryan Schumaker | ae42c70 | 2010-10-21 16:33:17 -0400 | [diff] [blame] | 4331 | static int decode_getfattr(struct xdr_stream *xdr, struct nfs_fattr *fattr, |
Trond Myklebust | 6926afd | 2012-01-07 13:22:46 -0500 | [diff] [blame] | 4332 | const struct nfs_server *server) |
Bryan Schumaker | ae42c70 | 2010-10-21 16:33:17 -0400 | [diff] [blame] | 4333 | { |
Trond Myklebust | 8b7e3f4 | 2012-01-30 15:43:56 -0500 | [diff] [blame] | 4334 | return decode_getfattr_generic(xdr, fattr, NULL, NULL, server); |
Bryan Schumaker | ae42c70 | 2010-10-21 16:33:17 -0400 | [diff] [blame] | 4335 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4336 | |
Andy Adamson | 504913f | 2010-10-20 00:17:57 -0400 | [diff] [blame] | 4337 | /* |
| 4338 | * Decode potentially multiple layout types. Currently we only support |
| 4339 | * one layout driver per file system. |
| 4340 | */ |
| 4341 | static int decode_first_pnfs_layout_type(struct xdr_stream *xdr, |
| 4342 | uint32_t *layouttype) |
| 4343 | { |
| 4344 | uint32_t *p; |
| 4345 | int num; |
| 4346 | |
| 4347 | p = xdr_inline_decode(xdr, 4); |
| 4348 | if (unlikely(!p)) |
| 4349 | goto out_overflow; |
| 4350 | num = be32_to_cpup(p); |
| 4351 | |
| 4352 | /* pNFS is not supported by the underlying file system */ |
| 4353 | if (num == 0) { |
| 4354 | *layouttype = 0; |
| 4355 | return 0; |
| 4356 | } |
| 4357 | if (num > 1) |
Weston Andros Adamson | a030889 | 2012-01-26 13:32:23 -0500 | [diff] [blame] | 4358 | printk(KERN_INFO "NFS: %s: Warning: Multiple pNFS layout " |
| 4359 | "drivers per filesystem not supported\n", __func__); |
Andy Adamson | 504913f | 2010-10-20 00:17:57 -0400 | [diff] [blame] | 4360 | |
| 4361 | /* Decode and set first layout type, move xdr->p past unused types */ |
| 4362 | p = xdr_inline_decode(xdr, num * 4); |
| 4363 | if (unlikely(!p)) |
| 4364 | goto out_overflow; |
| 4365 | *layouttype = be32_to_cpup(p); |
| 4366 | return 0; |
| 4367 | out_overflow: |
| 4368 | print_overflow_msg(__func__, xdr); |
| 4369 | return -EIO; |
| 4370 | } |
| 4371 | |
| 4372 | /* |
| 4373 | * The type of file system exported. |
| 4374 | * Note we must ensure that layouttype is set in any non-error case. |
| 4375 | */ |
| 4376 | static int decode_attr_pnfstype(struct xdr_stream *xdr, uint32_t *bitmap, |
| 4377 | uint32_t *layouttype) |
| 4378 | { |
| 4379 | int status = 0; |
| 4380 | |
| 4381 | dprintk("%s: bitmap is %x\n", __func__, bitmap[1]); |
| 4382 | if (unlikely(bitmap[1] & (FATTR4_WORD1_FS_LAYOUT_TYPES - 1U))) |
| 4383 | return -EIO; |
| 4384 | if (bitmap[1] & FATTR4_WORD1_FS_LAYOUT_TYPES) { |
| 4385 | status = decode_first_pnfs_layout_type(xdr, layouttype); |
| 4386 | bitmap[1] &= ~FATTR4_WORD1_FS_LAYOUT_TYPES; |
| 4387 | } else |
| 4388 | *layouttype = 0; |
| 4389 | return status; |
| 4390 | } |
| 4391 | |
Fred Isaman | dae100c | 2011-07-30 20:52:37 -0400 | [diff] [blame] | 4392 | /* |
| 4393 | * The prefered block size for layout directed io |
| 4394 | */ |
| 4395 | static int decode_attr_layout_blksize(struct xdr_stream *xdr, uint32_t *bitmap, |
| 4396 | uint32_t *res) |
| 4397 | { |
| 4398 | __be32 *p; |
| 4399 | |
| 4400 | dprintk("%s: bitmap is %x\n", __func__, bitmap[2]); |
| 4401 | *res = 0; |
| 4402 | if (bitmap[2] & FATTR4_WORD2_LAYOUT_BLKSIZE) { |
| 4403 | p = xdr_inline_decode(xdr, 4); |
| 4404 | if (unlikely(!p)) { |
| 4405 | print_overflow_msg(__func__, xdr); |
| 4406 | return -EIO; |
| 4407 | } |
| 4408 | *res = be32_to_cpup(p); |
| 4409 | bitmap[2] &= ~FATTR4_WORD2_LAYOUT_BLKSIZE; |
| 4410 | } |
| 4411 | return 0; |
| 4412 | } |
| 4413 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4414 | static int decode_fsinfo(struct xdr_stream *xdr, struct nfs_fsinfo *fsinfo) |
| 4415 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 4416 | __be32 *savep; |
Fred Isaman | dae100c | 2011-07-30 20:52:37 -0400 | [diff] [blame] | 4417 | uint32_t attrlen, bitmap[3]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4418 | int status; |
| 4419 | |
| 4420 | if ((status = decode_op_hdr(xdr, OP_GETATTR)) != 0) |
| 4421 | goto xdr_error; |
| 4422 | if ((status = decode_attr_bitmap(xdr, bitmap)) != 0) |
| 4423 | goto xdr_error; |
| 4424 | if ((status = decode_attr_length(xdr, &attrlen, &savep)) != 0) |
| 4425 | goto xdr_error; |
| 4426 | |
| 4427 | fsinfo->rtmult = fsinfo->wtmult = 512; /* ??? */ |
| 4428 | |
| 4429 | if ((status = decode_attr_lease_time(xdr, bitmap, &fsinfo->lease_time)) != 0) |
| 4430 | goto xdr_error; |
| 4431 | if ((status = decode_attr_maxfilesize(xdr, bitmap, &fsinfo->maxfilesize)) != 0) |
| 4432 | goto xdr_error; |
| 4433 | if ((status = decode_attr_maxread(xdr, bitmap, &fsinfo->rtmax)) != 0) |
| 4434 | goto xdr_error; |
| 4435 | fsinfo->rtpref = fsinfo->dtpref = fsinfo->rtmax; |
| 4436 | if ((status = decode_attr_maxwrite(xdr, bitmap, &fsinfo->wtmax)) != 0) |
| 4437 | goto xdr_error; |
| 4438 | fsinfo->wtpref = fsinfo->wtmax; |
Ricardo Labiaga | 55b6e77 | 2010-10-12 16:30:06 -0700 | [diff] [blame] | 4439 | status = decode_attr_time_delta(xdr, bitmap, &fsinfo->time_delta); |
| 4440 | if (status != 0) |
| 4441 | goto xdr_error; |
Andy Adamson | 504913f | 2010-10-20 00:17:57 -0400 | [diff] [blame] | 4442 | status = decode_attr_pnfstype(xdr, bitmap, &fsinfo->layouttype); |
| 4443 | if (status != 0) |
| 4444 | goto xdr_error; |
Fred Isaman | dae100c | 2011-07-30 20:52:37 -0400 | [diff] [blame] | 4445 | status = decode_attr_layout_blksize(xdr, bitmap, &fsinfo->blksize); |
| 4446 | if (status) |
| 4447 | goto xdr_error; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4448 | |
| 4449 | status = verify_attr_len(xdr, savep, attrlen); |
| 4450 | xdr_error: |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 4451 | dprintk("%s: xdr returned %d!\n", __func__, -status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4452 | return status; |
| 4453 | } |
| 4454 | |
| 4455 | static int decode_getfh(struct xdr_stream *xdr, struct nfs_fh *fh) |
| 4456 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 4457 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4458 | uint32_t len; |
| 4459 | int status; |
| 4460 | |
Trond Myklebust | 9936781 | 2007-07-17 21:52:41 -0400 | [diff] [blame] | 4461 | /* Zero handle first to allow comparisons */ |
| 4462 | memset(fh, 0, sizeof(*fh)); |
| 4463 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4464 | status = decode_op_hdr(xdr, OP_GETFH); |
| 4465 | if (status) |
| 4466 | return status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4467 | |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 4468 | p = xdr_inline_decode(xdr, 4); |
| 4469 | if (unlikely(!p)) |
| 4470 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 4471 | len = be32_to_cpup(p); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4472 | if (len > NFS4_FHSIZE) |
| 4473 | return -EIO; |
| 4474 | fh->size = len; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 4475 | p = xdr_inline_decode(xdr, len); |
| 4476 | if (unlikely(!p)) |
| 4477 | goto out_overflow; |
Benny Halevy | 99398d0 | 2009-08-14 17:20:05 +0300 | [diff] [blame] | 4478 | memcpy(fh->data, p, len); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4479 | return 0; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 4480 | out_overflow: |
| 4481 | print_overflow_msg(__func__, xdr); |
| 4482 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4483 | } |
| 4484 | |
| 4485 | static int decode_link(struct xdr_stream *xdr, struct nfs4_change_info *cinfo) |
| 4486 | { |
| 4487 | int status; |
Andy Adamson | 6c0195a | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 4488 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4489 | status = decode_op_hdr(xdr, OP_LINK); |
| 4490 | if (status) |
| 4491 | return status; |
| 4492 | return decode_change_info(xdr, cinfo); |
| 4493 | } |
| 4494 | |
| 4495 | /* |
| 4496 | * We create the owner, so we know a proper owner.id length is 4. |
| 4497 | */ |
Trond Myklebust | 911d1aa | 2006-01-03 09:55:16 +0100 | [diff] [blame] | 4498 | 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] | 4499 | { |
Trond Myklebust | 911d1aa | 2006-01-03 09:55:16 +0100 | [diff] [blame] | 4500 | uint64_t offset, length, clientid; |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 4501 | __be32 *p; |
Trond Myklebust | 911d1aa | 2006-01-03 09:55:16 +0100 | [diff] [blame] | 4502 | uint32_t namelen, type; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4503 | |
Bryan Schumaker | babddc7 | 2010-10-20 15:44:29 -0400 | [diff] [blame] | 4504 | p = xdr_inline_decode(xdr, 32); /* read 32 bytes */ |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 4505 | if (unlikely(!p)) |
| 4506 | goto out_overflow; |
Bryan Schumaker | babddc7 | 2010-10-20 15:44:29 -0400 | [diff] [blame] | 4507 | p = xdr_decode_hyper(p, &offset); /* read 2 8-byte long words */ |
Benny Halevy | 3ceb4db | 2009-08-14 17:19:41 +0300 | [diff] [blame] | 4508 | p = xdr_decode_hyper(p, &length); |
Bryan Schumaker | babddc7 | 2010-10-20 15:44:29 -0400 | [diff] [blame] | 4509 | type = be32_to_cpup(p++); /* 4 byte read */ |
| 4510 | if (fl != NULL) { /* manipulate file lock */ |
Trond Myklebust | 911d1aa | 2006-01-03 09:55:16 +0100 | [diff] [blame] | 4511 | fl->fl_start = (loff_t)offset; |
| 4512 | fl->fl_end = fl->fl_start + (loff_t)length - 1; |
| 4513 | if (length == ~(uint64_t)0) |
| 4514 | fl->fl_end = OFFSET_MAX; |
| 4515 | fl->fl_type = F_WRLCK; |
| 4516 | if (type & 1) |
| 4517 | fl->fl_type = F_RDLCK; |
| 4518 | fl->fl_pid = 0; |
| 4519 | } |
Bryan Schumaker | babddc7 | 2010-10-20 15:44:29 -0400 | [diff] [blame] | 4520 | p = xdr_decode_hyper(p, &clientid); /* read 8 bytes */ |
| 4521 | namelen = be32_to_cpup(p); /* read 4 bytes */ /* have read all 32 bytes now */ |
| 4522 | p = xdr_inline_decode(xdr, namelen); /* variable size field */ |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 4523 | if (likely(p)) |
| 4524 | return -NFS4ERR_DENIED; |
| 4525 | out_overflow: |
| 4526 | print_overflow_msg(__func__, xdr); |
| 4527 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4528 | } |
| 4529 | |
Trond Myklebust | 911d1aa | 2006-01-03 09:55:16 +0100 | [diff] [blame] | 4530 | 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] | 4531 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4532 | int status; |
| 4533 | |
| 4534 | status = decode_op_hdr(xdr, OP_LOCK); |
Trond Myklebust | c1d5193 | 2008-04-07 13:20:54 -0400 | [diff] [blame] | 4535 | if (status == -EIO) |
| 4536 | goto out; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4537 | if (status == 0) { |
Benny Halevy | 07d3043 | 2009-08-14 17:19:52 +0300 | [diff] [blame] | 4538 | status = decode_stateid(xdr, &res->stateid); |
| 4539 | if (unlikely(status)) |
| 4540 | goto out; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4541 | } else if (status == -NFS4ERR_DENIED) |
Trond Myklebust | c1d5193 | 2008-04-07 13:20:54 -0400 | [diff] [blame] | 4542 | status = decode_lock_denied(xdr, NULL); |
| 4543 | if (res->open_seqid != NULL) |
| 4544 | nfs_increment_open_seqid(status, res->open_seqid); |
| 4545 | nfs_increment_lock_seqid(status, res->lock_seqid); |
| 4546 | out: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4547 | return status; |
| 4548 | } |
| 4549 | |
Trond Myklebust | 911d1aa | 2006-01-03 09:55:16 +0100 | [diff] [blame] | 4550 | 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] | 4551 | { |
| 4552 | int status; |
| 4553 | status = decode_op_hdr(xdr, OP_LOCKT); |
| 4554 | if (status == -NFS4ERR_DENIED) |
Trond Myklebust | 911d1aa | 2006-01-03 09:55:16 +0100 | [diff] [blame] | 4555 | return decode_lock_denied(xdr, res->denied); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4556 | return status; |
| 4557 | } |
| 4558 | |
Trond Myklebust | 911d1aa | 2006-01-03 09:55:16 +0100 | [diff] [blame] | 4559 | 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] | 4560 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4561 | int status; |
| 4562 | |
| 4563 | status = decode_op_hdr(xdr, OP_LOCKU); |
Trond Myklebust | c1d5193 | 2008-04-07 13:20:54 -0400 | [diff] [blame] | 4564 | if (status != -EIO) |
| 4565 | nfs_increment_lock_seqid(status, res->seqid); |
Benny Halevy | 07d3043 | 2009-08-14 17:19:52 +0300 | [diff] [blame] | 4566 | if (status == 0) |
| 4567 | status = decode_stateid(xdr, &res->stateid); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4568 | return status; |
| 4569 | } |
| 4570 | |
Trond Myklebust | d3c7b7c | 2010-07-01 12:49:01 -0400 | [diff] [blame] | 4571 | static int decode_release_lockowner(struct xdr_stream *xdr) |
| 4572 | { |
| 4573 | return decode_op_hdr(xdr, OP_RELEASE_LOCKOWNER); |
| 4574 | } |
| 4575 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4576 | static int decode_lookup(struct xdr_stream *xdr) |
| 4577 | { |
| 4578 | return decode_op_hdr(xdr, OP_LOOKUP); |
| 4579 | } |
| 4580 | |
| 4581 | /* This is too sick! */ |
| 4582 | static int decode_space_limit(struct xdr_stream *xdr, u64 *maxsize) |
| 4583 | { |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 4584 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4585 | uint32_t limit_type, nblocks, blocksize; |
| 4586 | |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 4587 | p = xdr_inline_decode(xdr, 12); |
| 4588 | if (unlikely(!p)) |
| 4589 | goto out_overflow; |
Benny Halevy | 6f723f7 | 2009-08-14 17:19:37 +0300 | [diff] [blame] | 4590 | limit_type = be32_to_cpup(p++); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4591 | switch (limit_type) { |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 4592 | case 1: |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 4593 | xdr_decode_hyper(p, maxsize); |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 4594 | break; |
| 4595 | case 2: |
Benny Halevy | 6f723f7 | 2009-08-14 17:19:37 +0300 | [diff] [blame] | 4596 | nblocks = be32_to_cpup(p++); |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 4597 | blocksize = be32_to_cpup(p); |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 4598 | *maxsize = (uint64_t)nblocks * (uint64_t)blocksize; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4599 | } |
| 4600 | return 0; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 4601 | out_overflow: |
| 4602 | print_overflow_msg(__func__, xdr); |
| 4603 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4604 | } |
| 4605 | |
| 4606 | static int decode_delegation(struct xdr_stream *xdr, struct nfs_openres *res) |
| 4607 | { |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 4608 | __be32 *p; |
| 4609 | uint32_t delegation_type; |
Benny Halevy | 07d3043 | 2009-08-14 17:19:52 +0300 | [diff] [blame] | 4610 | int status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4611 | |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 4612 | p = xdr_inline_decode(xdr, 4); |
| 4613 | if (unlikely(!p)) |
| 4614 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 4615 | delegation_type = be32_to_cpup(p); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4616 | if (delegation_type == NFS4_OPEN_DELEGATE_NONE) { |
| 4617 | res->delegation_type = 0; |
| 4618 | return 0; |
| 4619 | } |
Benny Halevy | 07d3043 | 2009-08-14 17:19:52 +0300 | [diff] [blame] | 4620 | status = decode_stateid(xdr, &res->delegation); |
| 4621 | if (unlikely(status)) |
| 4622 | return status; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 4623 | p = xdr_inline_decode(xdr, 4); |
| 4624 | if (unlikely(!p)) |
| 4625 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 4626 | res->do_recall = be32_to_cpup(p); |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 4627 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4628 | switch (delegation_type) { |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 4629 | case NFS4_OPEN_DELEGATE_READ: |
| 4630 | res->delegation_type = FMODE_READ; |
| 4631 | break; |
| 4632 | case NFS4_OPEN_DELEGATE_WRITE: |
| 4633 | res->delegation_type = FMODE_WRITE|FMODE_READ; |
| 4634 | if (decode_space_limit(xdr, &res->maxsize) < 0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4635 | return -EIO; |
| 4636 | } |
David Howells | 7539bba | 2006-08-22 20:06:09 -0400 | [diff] [blame] | 4637 | return decode_ace(xdr, NULL, res->server->nfs_client); |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 4638 | out_overflow: |
| 4639 | print_overflow_msg(__func__, xdr); |
| 4640 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4641 | } |
| 4642 | |
| 4643 | static int decode_open(struct xdr_stream *xdr, struct nfs_openres *res) |
| 4644 | { |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 4645 | __be32 *p; |
Jeff Layton | aa53ed5 | 2007-06-05 14:49:03 -0400 | [diff] [blame] | 4646 | uint32_t savewords, bmlen, i; |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 4647 | int status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4648 | |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 4649 | status = decode_op_hdr(xdr, OP_OPEN); |
Trond Myklebust | c1d5193 | 2008-04-07 13:20:54 -0400 | [diff] [blame] | 4650 | if (status != -EIO) |
| 4651 | nfs_increment_open_seqid(status, res->seqid); |
Benny Halevy | 07d3043 | 2009-08-14 17:19:52 +0300 | [diff] [blame] | 4652 | if (!status) |
| 4653 | status = decode_stateid(xdr, &res->stateid); |
| 4654 | if (unlikely(status)) |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 4655 | return status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4656 | |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 4657 | decode_change_info(xdr, &res->cinfo); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4658 | |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 4659 | p = xdr_inline_decode(xdr, 8); |
| 4660 | if (unlikely(!p)) |
| 4661 | goto out_overflow; |
Benny Halevy | 6f723f7 | 2009-08-14 17:19:37 +0300 | [diff] [blame] | 4662 | res->rflags = be32_to_cpup(p++); |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 4663 | bmlen = be32_to_cpup(p); |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 4664 | if (bmlen > 10) |
| 4665 | goto xdr_error; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4666 | |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 4667 | p = xdr_inline_decode(xdr, bmlen << 2); |
| 4668 | if (unlikely(!p)) |
| 4669 | goto out_overflow; |
Jeff Layton | aa53ed5 | 2007-06-05 14:49:03 -0400 | [diff] [blame] | 4670 | savewords = min_t(uint32_t, bmlen, NFS4_BITMAP_SIZE); |
| 4671 | for (i = 0; i < savewords; ++i) |
Benny Halevy | 6f723f7 | 2009-08-14 17:19:37 +0300 | [diff] [blame] | 4672 | res->attrset[i] = be32_to_cpup(p++); |
Jeff Layton | aa53ed5 | 2007-06-05 14:49:03 -0400 | [diff] [blame] | 4673 | for (; i < NFS4_BITMAP_SIZE; i++) |
| 4674 | res->attrset[i] = 0; |
| 4675 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4676 | return decode_delegation(xdr, res); |
| 4677 | xdr_error: |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 4678 | dprintk("%s: Bitmap too large! Length = %u\n", __func__, bmlen); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4679 | return -EIO; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 4680 | out_overflow: |
| 4681 | print_overflow_msg(__func__, xdr); |
| 4682 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4683 | } |
| 4684 | |
| 4685 | static int decode_open_confirm(struct xdr_stream *xdr, struct nfs_open_confirmres *res) |
| 4686 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4687 | int status; |
| 4688 | |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 4689 | status = decode_op_hdr(xdr, OP_OPEN_CONFIRM); |
Trond Myklebust | c1d5193 | 2008-04-07 13:20:54 -0400 | [diff] [blame] | 4690 | if (status != -EIO) |
| 4691 | nfs_increment_open_seqid(status, res->seqid); |
Benny Halevy | 07d3043 | 2009-08-14 17:19:52 +0300 | [diff] [blame] | 4692 | if (!status) |
| 4693 | status = decode_stateid(xdr, &res->stateid); |
| 4694 | return status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4695 | } |
| 4696 | |
| 4697 | static int decode_open_downgrade(struct xdr_stream *xdr, struct nfs_closeres *res) |
| 4698 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4699 | int status; |
| 4700 | |
| 4701 | status = decode_op_hdr(xdr, OP_OPEN_DOWNGRADE); |
Trond Myklebust | c1d5193 | 2008-04-07 13:20:54 -0400 | [diff] [blame] | 4702 | if (status != -EIO) |
| 4703 | nfs_increment_open_seqid(status, res->seqid); |
Benny Halevy | 07d3043 | 2009-08-14 17:19:52 +0300 | [diff] [blame] | 4704 | if (!status) |
| 4705 | status = decode_stateid(xdr, &res->stateid); |
| 4706 | return status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4707 | } |
| 4708 | |
| 4709 | static int decode_putfh(struct xdr_stream *xdr) |
| 4710 | { |
| 4711 | return decode_op_hdr(xdr, OP_PUTFH); |
| 4712 | } |
| 4713 | |
| 4714 | static int decode_putrootfh(struct xdr_stream *xdr) |
| 4715 | { |
| 4716 | return decode_op_hdr(xdr, OP_PUTROOTFH); |
| 4717 | } |
| 4718 | |
| 4719 | static int decode_read(struct xdr_stream *xdr, struct rpc_rqst *req, struct nfs_readres *res) |
| 4720 | { |
| 4721 | struct kvec *iov = req->rq_rcv_buf.head; |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 4722 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4723 | uint32_t count, eof, recvd, hdrlen; |
| 4724 | int status; |
| 4725 | |
| 4726 | status = decode_op_hdr(xdr, OP_READ); |
| 4727 | if (status) |
| 4728 | return status; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 4729 | p = xdr_inline_decode(xdr, 8); |
| 4730 | if (unlikely(!p)) |
| 4731 | goto out_overflow; |
Benny Halevy | 6f723f7 | 2009-08-14 17:19:37 +0300 | [diff] [blame] | 4732 | eof = be32_to_cpup(p++); |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 4733 | count = be32_to_cpup(p); |
Chuck Lever | 8111f37 | 2010-12-14 14:58:01 +0000 | [diff] [blame] | 4734 | hdrlen = (u8 *) xdr->p - (u8 *) iov->iov_base; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4735 | recvd = req->rq_rcv_buf.len - hdrlen; |
| 4736 | if (count > recvd) { |
Chuck Lever | fe82a18 | 2007-09-11 18:01:10 -0400 | [diff] [blame] | 4737 | dprintk("NFS: server cheating in read reply: " |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4738 | "count %u > recvd %u\n", count, recvd); |
| 4739 | count = recvd; |
| 4740 | eof = 0; |
| 4741 | } |
| 4742 | xdr_read_pages(xdr, count); |
| 4743 | res->eof = eof; |
| 4744 | res->count = count; |
| 4745 | return 0; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 4746 | out_overflow: |
| 4747 | print_overflow_msg(__func__, xdr); |
| 4748 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4749 | } |
| 4750 | |
| 4751 | static int decode_readdir(struct xdr_stream *xdr, struct rpc_rqst *req, struct nfs4_readdir_res *readdir) |
| 4752 | { |
| 4753 | struct xdr_buf *rcvbuf = &req->rq_rcv_buf; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4754 | struct kvec *iov = rcvbuf->head; |
Chuck Lever | bcecff7 | 2007-10-26 13:32:03 -0400 | [diff] [blame] | 4755 | size_t hdrlen; |
| 4756 | u32 recvd, pglen = rcvbuf->page_len; |
Chuck Lever | bcecff7 | 2007-10-26 13:32:03 -0400 | [diff] [blame] | 4757 | int status; |
Chuck Lever | cd93710 | 2012-03-02 17:14:31 -0500 | [diff] [blame] | 4758 | __be32 verf[2]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4759 | |
| 4760 | status = decode_op_hdr(xdr, OP_READDIR); |
Benny Halevy | db942bb | 2009-08-14 17:19:56 +0300 | [diff] [blame] | 4761 | if (!status) |
| 4762 | status = decode_verifier(xdr, readdir->verifier.data); |
| 4763 | if (unlikely(status)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4764 | return status; |
Chuck Lever | cd93710 | 2012-03-02 17:14:31 -0500 | [diff] [blame] | 4765 | memcpy(verf, readdir->verifier.data, sizeof(verf)); |
Fred Isaman | 4410924 | 2008-04-02 15:21:15 +0300 | [diff] [blame] | 4766 | dprintk("%s: verifier = %08x:%08x\n", |
Chuck Lever | cd93710 | 2012-03-02 17:14:31 -0500 | [diff] [blame] | 4767 | __func__, verf[0], verf[1]); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4768 | |
Benny Halevy | db942bb | 2009-08-14 17:19:56 +0300 | [diff] [blame] | 4769 | hdrlen = (char *) xdr->p - (char *) iov->iov_base; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4770 | recvd = rcvbuf->len - hdrlen; |
| 4771 | if (pglen > recvd) |
| 4772 | pglen = recvd; |
| 4773 | xdr_read_pages(xdr, pglen); |
| 4774 | |
Jeff Layton | 7bda2cd | 2008-02-22 14:50:01 -0500 | [diff] [blame] | 4775 | |
Trond Myklebust | ac39612 | 2010-11-15 20:26:22 -0500 | [diff] [blame] | 4776 | return pglen; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4777 | } |
| 4778 | |
| 4779 | static int decode_readlink(struct xdr_stream *xdr, struct rpc_rqst *req) |
| 4780 | { |
| 4781 | struct xdr_buf *rcvbuf = &req->rq_rcv_buf; |
| 4782 | struct kvec *iov = rcvbuf->head; |
Chuck Lever | bcecff7 | 2007-10-26 13:32:03 -0400 | [diff] [blame] | 4783 | size_t hdrlen; |
| 4784 | u32 len, recvd; |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 4785 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4786 | int status; |
| 4787 | |
| 4788 | status = decode_op_hdr(xdr, OP_READLINK); |
| 4789 | if (status) |
| 4790 | return status; |
| 4791 | |
| 4792 | /* Convert length of symlink */ |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 4793 | p = xdr_inline_decode(xdr, 4); |
| 4794 | if (unlikely(!p)) |
| 4795 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 4796 | len = be32_to_cpup(p); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4797 | if (len >= rcvbuf->page_len || len <= 0) { |
Chuck Lever | fe82a18 | 2007-09-11 18:01:10 -0400 | [diff] [blame] | 4798 | dprintk("nfs: server returned giant symlink!\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4799 | return -ENAMETOOLONG; |
| 4800 | } |
| 4801 | hdrlen = (char *) xdr->p - (char *) iov->iov_base; |
| 4802 | recvd = req->rq_rcv_buf.len - hdrlen; |
| 4803 | if (recvd < len) { |
Chuck Lever | fe82a18 | 2007-09-11 18:01:10 -0400 | [diff] [blame] | 4804 | dprintk("NFS: server cheating in readlink reply: " |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4805 | "count %u > recvd %u\n", len, recvd); |
| 4806 | return -EIO; |
| 4807 | } |
| 4808 | xdr_read_pages(xdr, len); |
| 4809 | /* |
| 4810 | * The XDR encode routine has set things up so that |
| 4811 | * the link text will be copied directly into the |
| 4812 | * buffer. We just have to do overflow-checking, |
| 4813 | * and and null-terminate the text (the VFS expects |
| 4814 | * null-termination). |
| 4815 | */ |
Chuck Lever | b4687da | 2010-09-21 16:55:48 -0400 | [diff] [blame] | 4816 | xdr_terminate_string(rcvbuf, len); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4817 | return 0; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 4818 | out_overflow: |
| 4819 | print_overflow_msg(__func__, xdr); |
| 4820 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4821 | } |
| 4822 | |
| 4823 | static int decode_remove(struct xdr_stream *xdr, struct nfs4_change_info *cinfo) |
| 4824 | { |
| 4825 | int status; |
| 4826 | |
| 4827 | status = decode_op_hdr(xdr, OP_REMOVE); |
| 4828 | if (status) |
| 4829 | goto out; |
| 4830 | status = decode_change_info(xdr, cinfo); |
| 4831 | out: |
| 4832 | return status; |
| 4833 | } |
| 4834 | |
| 4835 | static int decode_rename(struct xdr_stream *xdr, struct nfs4_change_info *old_cinfo, |
| 4836 | struct nfs4_change_info *new_cinfo) |
| 4837 | { |
| 4838 | int status; |
| 4839 | |
| 4840 | status = decode_op_hdr(xdr, OP_RENAME); |
| 4841 | if (status) |
| 4842 | goto out; |
| 4843 | if ((status = decode_change_info(xdr, old_cinfo))) |
| 4844 | goto out; |
| 4845 | status = decode_change_info(xdr, new_cinfo); |
| 4846 | out: |
| 4847 | return status; |
| 4848 | } |
| 4849 | |
| 4850 | static int decode_renew(struct xdr_stream *xdr) |
| 4851 | { |
| 4852 | return decode_op_hdr(xdr, OP_RENEW); |
| 4853 | } |
| 4854 | |
Trond Myklebust | 56ae19f | 2005-10-27 22:12:40 -0400 | [diff] [blame] | 4855 | static int |
| 4856 | decode_restorefh(struct xdr_stream *xdr) |
| 4857 | { |
| 4858 | return decode_op_hdr(xdr, OP_RESTOREFH); |
| 4859 | } |
| 4860 | |
J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 4861 | static int decode_getacl(struct xdr_stream *xdr, struct rpc_rqst *req, |
Andy Adamson | bf118a3 | 2011-12-07 11:55:27 -0500 | [diff] [blame] | 4862 | struct nfs_getaclres *res) |
J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 4863 | { |
Andy Adamson | bf118a3 | 2011-12-07 11:55:27 -0500 | [diff] [blame] | 4864 | __be32 *savep, *bm_p; |
J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 4865 | uint32_t attrlen, |
Fred Isaman | dae100c | 2011-07-30 20:52:37 -0400 | [diff] [blame] | 4866 | bitmap[3] = {0}; |
J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 4867 | struct kvec *iov = req->rq_rcv_buf.head; |
| 4868 | int status; |
Sachin Prabhu | 5a00689 | 2012-04-17 14:35:39 +0100 | [diff] [blame] | 4869 | size_t page_len = xdr->buf->page_len; |
J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 4870 | |
Andy Adamson | bf118a3 | 2011-12-07 11:55:27 -0500 | [diff] [blame] | 4871 | res->acl_len = 0; |
J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 4872 | if ((status = decode_op_hdr(xdr, OP_GETATTR)) != 0) |
| 4873 | goto out; |
Sachin Prabhu | 5a00689 | 2012-04-17 14:35:39 +0100 | [diff] [blame] | 4874 | |
Andy Adamson | bf118a3 | 2011-12-07 11:55:27 -0500 | [diff] [blame] | 4875 | bm_p = xdr->p; |
Sachin Prabhu | 5a00689 | 2012-04-17 14:35:39 +0100 | [diff] [blame] | 4876 | res->acl_data_offset = be32_to_cpup(bm_p) + 2; |
| 4877 | res->acl_data_offset <<= 2; |
| 4878 | /* Check if the acl data starts beyond the allocated buffer */ |
| 4879 | if (res->acl_data_offset > page_len) |
| 4880 | return -ERANGE; |
| 4881 | |
J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 4882 | if ((status = decode_attr_bitmap(xdr, bitmap)) != 0) |
| 4883 | goto out; |
| 4884 | if ((status = decode_attr_length(xdr, &attrlen, &savep)) != 0) |
| 4885 | goto out; |
| 4886 | |
| 4887 | if (unlikely(bitmap[0] & (FATTR4_WORD0_ACL - 1U))) |
| 4888 | return -EIO; |
| 4889 | if (likely(bitmap[0] & FATTR4_WORD0_ACL)) { |
Chuck Lever | bcecff7 | 2007-10-26 13:32:03 -0400 | [diff] [blame] | 4890 | size_t hdrlen; |
J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 4891 | |
Andy Adamson | bf118a3 | 2011-12-07 11:55:27 -0500 | [diff] [blame] | 4892 | /* The bitmap (xdr len + bitmaps) and the attr xdr len words |
| 4893 | * are stored with the acl data to handle the problem of |
| 4894 | * variable length bitmaps.*/ |
| 4895 | xdr->p = bm_p; |
Andy Adamson | bf118a3 | 2011-12-07 11:55:27 -0500 | [diff] [blame] | 4896 | |
J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 4897 | /* We ignore &savep and don't do consistency checks on |
| 4898 | * the attr length. Let userspace figure it out.... */ |
| 4899 | hdrlen = (u8 *)xdr->p - (u8 *)iov->iov_base; |
Andy Adamson | bf118a3 | 2011-12-07 11:55:27 -0500 | [diff] [blame] | 4900 | attrlen += res->acl_data_offset; |
Sachin Prabhu | 5a00689 | 2012-04-17 14:35:39 +0100 | [diff] [blame] | 4901 | if (attrlen > page_len) { |
Andy Adamson | bf118a3 | 2011-12-07 11:55:27 -0500 | [diff] [blame] | 4902 | if (res->acl_flags & NFS4_ACL_LEN_REQUEST) { |
| 4903 | /* getxattr interface called with a NULL buf */ |
| 4904 | res->acl_len = attrlen; |
| 4905 | goto out; |
| 4906 | } |
Sachin Prabhu | 5794d21 | 2012-04-17 14:36:40 +0100 | [diff] [blame] | 4907 | dprintk("NFS: acl reply: attrlen %u > page_len %zu\n", |
Sachin Prabhu | 5a00689 | 2012-04-17 14:35:39 +0100 | [diff] [blame] | 4908 | attrlen, page_len); |
J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 4909 | return -EINVAL; |
| 4910 | } |
J. Bruce Fields | c04871e | 2006-05-30 16:28:58 -0400 | [diff] [blame] | 4911 | xdr_read_pages(xdr, attrlen); |
Andy Adamson | bf118a3 | 2011-12-07 11:55:27 -0500 | [diff] [blame] | 4912 | res->acl_len = attrlen; |
J. Bruce Fields | 8c233cf | 2005-10-13 16:54:27 -0400 | [diff] [blame] | 4913 | } else |
| 4914 | status = -EOPNOTSUPP; |
J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 4915 | |
| 4916 | out: |
| 4917 | return status; |
| 4918 | } |
| 4919 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4920 | static int |
| 4921 | decode_savefh(struct xdr_stream *xdr) |
| 4922 | { |
| 4923 | return decode_op_hdr(xdr, OP_SAVEFH); |
| 4924 | } |
| 4925 | |
Benny Halevy | 9e9ecc0 | 2009-04-01 09:22:00 -0400 | [diff] [blame] | 4926 | static int decode_setattr(struct xdr_stream *xdr) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4927 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 4928 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4929 | uint32_t bmlen; |
| 4930 | int status; |
| 4931 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4932 | status = decode_op_hdr(xdr, OP_SETATTR); |
| 4933 | if (status) |
| 4934 | return status; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 4935 | p = xdr_inline_decode(xdr, 4); |
| 4936 | if (unlikely(!p)) |
| 4937 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 4938 | bmlen = be32_to_cpup(p); |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 4939 | p = xdr_inline_decode(xdr, bmlen << 2); |
| 4940 | if (likely(p)) |
| 4941 | return 0; |
| 4942 | out_overflow: |
| 4943 | print_overflow_msg(__func__, xdr); |
| 4944 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4945 | } |
| 4946 | |
Trond Myklebust | bb8b27e | 2010-04-16 16:43:06 -0400 | [diff] [blame] | 4947 | 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] | 4948 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 4949 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4950 | uint32_t opnum; |
| 4951 | int32_t nfserr; |
| 4952 | |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 4953 | p = xdr_inline_decode(xdr, 8); |
| 4954 | if (unlikely(!p)) |
| 4955 | goto out_overflow; |
Benny Halevy | 6f723f7 | 2009-08-14 17:19:37 +0300 | [diff] [blame] | 4956 | opnum = be32_to_cpup(p++); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4957 | if (opnum != OP_SETCLIENTID) { |
Chuck Lever | fe82a18 | 2007-09-11 18:01:10 -0400 | [diff] [blame] | 4958 | dprintk("nfs: decode_setclientid: Server returned operation" |
Andy Adamson | 6c0195a | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 4959 | " %d\n", opnum); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4960 | return -EIO; |
| 4961 | } |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 4962 | nfserr = be32_to_cpup(p); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4963 | if (nfserr == NFS_OK) { |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 4964 | p = xdr_inline_decode(xdr, 8 + NFS4_VERIFIER_SIZE); |
| 4965 | if (unlikely(!p)) |
| 4966 | goto out_overflow; |
Trond Myklebust | bb8b27e | 2010-04-16 16:43:06 -0400 | [diff] [blame] | 4967 | p = xdr_decode_hyper(p, &res->clientid); |
| 4968 | memcpy(res->confirm.data, p, NFS4_VERIFIER_SIZE); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4969 | } else if (nfserr == NFSERR_CLID_INUSE) { |
| 4970 | uint32_t len; |
| 4971 | |
| 4972 | /* skip netid string */ |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 4973 | p = xdr_inline_decode(xdr, 4); |
| 4974 | if (unlikely(!p)) |
| 4975 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 4976 | len = be32_to_cpup(p); |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 4977 | p = xdr_inline_decode(xdr, len); |
| 4978 | if (unlikely(!p)) |
| 4979 | goto out_overflow; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4980 | |
| 4981 | /* skip uaddr string */ |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 4982 | p = xdr_inline_decode(xdr, 4); |
| 4983 | if (unlikely(!p)) |
| 4984 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 4985 | len = be32_to_cpup(p); |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 4986 | p = xdr_inline_decode(xdr, len); |
| 4987 | if (unlikely(!p)) |
| 4988 | goto out_overflow; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4989 | return -NFSERR_CLID_INUSE; |
| 4990 | } else |
Benny Halevy | 856dff3 | 2008-03-31 17:39:06 +0300 | [diff] [blame] | 4991 | return nfs4_stat_to_errno(nfserr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4992 | |
| 4993 | return 0; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 4994 | out_overflow: |
| 4995 | print_overflow_msg(__func__, xdr); |
| 4996 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4997 | } |
| 4998 | |
| 4999 | static int decode_setclientid_confirm(struct xdr_stream *xdr) |
| 5000 | { |
| 5001 | return decode_op_hdr(xdr, OP_SETCLIENTID_CONFIRM); |
| 5002 | } |
| 5003 | |
| 5004 | static int decode_write(struct xdr_stream *xdr, struct nfs_writeres *res) |
| 5005 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 5006 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5007 | int status; |
| 5008 | |
| 5009 | status = decode_op_hdr(xdr, OP_WRITE); |
| 5010 | if (status) |
| 5011 | return status; |
| 5012 | |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 5013 | p = xdr_inline_decode(xdr, 16); |
| 5014 | if (unlikely(!p)) |
| 5015 | goto out_overflow; |
Benny Halevy | 6f723f7 | 2009-08-14 17:19:37 +0300 | [diff] [blame] | 5016 | res->count = be32_to_cpup(p++); |
| 5017 | res->verf->committed = be32_to_cpup(p++); |
Chuck Lever | cd93710 | 2012-03-02 17:14:31 -0500 | [diff] [blame] | 5018 | memcpy(res->verf->verifier, p, NFS4_VERIFIER_SIZE); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5019 | return 0; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 5020 | out_overflow: |
| 5021 | print_overflow_msg(__func__, xdr); |
| 5022 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5023 | } |
| 5024 | |
| 5025 | static int decode_delegreturn(struct xdr_stream *xdr) |
| 5026 | { |
| 5027 | return decode_op_hdr(xdr, OP_DELEGRETURN); |
| 5028 | } |
| 5029 | |
Bryan Schumaker | 5a5ea0d | 2011-03-24 17:12:29 +0000 | [diff] [blame] | 5030 | static int decode_secinfo_gss(struct xdr_stream *xdr, struct nfs4_secinfo_flavor *flavor) |
| 5031 | { |
| 5032 | __be32 *p; |
| 5033 | |
| 5034 | p = xdr_inline_decode(xdr, 4); |
| 5035 | if (unlikely(!p)) |
| 5036 | goto out_overflow; |
| 5037 | flavor->gss.sec_oid4.len = be32_to_cpup(p); |
| 5038 | if (flavor->gss.sec_oid4.len > GSS_OID_MAX_LEN) |
| 5039 | goto out_err; |
| 5040 | |
| 5041 | p = xdr_inline_decode(xdr, flavor->gss.sec_oid4.len); |
| 5042 | if (unlikely(!p)) |
| 5043 | goto out_overflow; |
| 5044 | memcpy(flavor->gss.sec_oid4.data, p, flavor->gss.sec_oid4.len); |
| 5045 | |
| 5046 | p = xdr_inline_decode(xdr, 8); |
| 5047 | if (unlikely(!p)) |
| 5048 | goto out_overflow; |
| 5049 | flavor->gss.qop4 = be32_to_cpup(p++); |
| 5050 | flavor->gss.service = be32_to_cpup(p); |
| 5051 | |
| 5052 | return 0; |
| 5053 | |
| 5054 | out_overflow: |
| 5055 | print_overflow_msg(__func__, xdr); |
| 5056 | return -EIO; |
| 5057 | out_err: |
| 5058 | return -EINVAL; |
| 5059 | } |
| 5060 | |
Bryan Schumaker | 31e4dda | 2012-04-27 13:27:38 -0400 | [diff] [blame] | 5061 | 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] | 5062 | { |
| 5063 | struct nfs4_secinfo_flavor *sec_flavor; |
| 5064 | int status; |
| 5065 | __be32 *p; |
Bryan Schumaker | c3dfc28 | 2011-04-13 14:31:31 -0400 | [diff] [blame] | 5066 | int i, num_flavors; |
Bryan Schumaker | 5a5ea0d | 2011-03-24 17:12:29 +0000 | [diff] [blame] | 5067 | |
Bryan Schumaker | 5a5ea0d | 2011-03-24 17:12:29 +0000 | [diff] [blame] | 5068 | p = xdr_inline_decode(xdr, 4); |
| 5069 | if (unlikely(!p)) |
| 5070 | goto out_overflow; |
Bryan Schumaker | 5a5ea0d | 2011-03-24 17:12:29 +0000 | [diff] [blame] | 5071 | |
Bryan Schumaker | c3dfc28 | 2011-04-13 14:31:31 -0400 | [diff] [blame] | 5072 | res->flavors->num_flavors = 0; |
| 5073 | num_flavors = be32_to_cpup(p); |
| 5074 | |
| 5075 | for (i = 0; i < num_flavors; i++) { |
Bryan Schumaker | 5a5ea0d | 2011-03-24 17:12:29 +0000 | [diff] [blame] | 5076 | sec_flavor = &res->flavors->flavors[i]; |
Bryan Schumaker | c3dfc28 | 2011-04-13 14:31:31 -0400 | [diff] [blame] | 5077 | if ((char *)&sec_flavor[1] - (char *)res->flavors > PAGE_SIZE) |
Bryan Schumaker | 5a5ea0d | 2011-03-24 17:12:29 +0000 | [diff] [blame] | 5078 | break; |
| 5079 | |
| 5080 | p = xdr_inline_decode(xdr, 4); |
| 5081 | if (unlikely(!p)) |
| 5082 | goto out_overflow; |
| 5083 | sec_flavor->flavor = be32_to_cpup(p); |
| 5084 | |
| 5085 | if (sec_flavor->flavor == RPC_AUTH_GSS) { |
Bryan Schumaker | 613e901 | 2011-04-27 15:28:44 -0400 | [diff] [blame] | 5086 | status = decode_secinfo_gss(xdr, sec_flavor); |
| 5087 | if (status) |
| 5088 | goto out; |
Bryan Schumaker | 5a5ea0d | 2011-03-24 17:12:29 +0000 | [diff] [blame] | 5089 | } |
Bryan Schumaker | c3dfc28 | 2011-04-13 14:31:31 -0400 | [diff] [blame] | 5090 | res->flavors->num_flavors++; |
Bryan Schumaker | 5a5ea0d | 2011-03-24 17:12:29 +0000 | [diff] [blame] | 5091 | } |
| 5092 | |
Bryan Schumaker | 31e4dda | 2012-04-27 13:27:38 -0400 | [diff] [blame] | 5093 | status = 0; |
Bryan Schumaker | 613e901 | 2011-04-27 15:28:44 -0400 | [diff] [blame] | 5094 | out: |
| 5095 | return status; |
Bryan Schumaker | 5a5ea0d | 2011-03-24 17:12:29 +0000 | [diff] [blame] | 5096 | out_overflow: |
| 5097 | print_overflow_msg(__func__, xdr); |
| 5098 | return -EIO; |
| 5099 | } |
| 5100 | |
Bryan Schumaker | 31e4dda | 2012-04-27 13:27:38 -0400 | [diff] [blame] | 5101 | static int decode_secinfo(struct xdr_stream *xdr, struct nfs4_secinfo_res *res) |
| 5102 | { |
| 5103 | int status = decode_op_hdr(xdr, OP_SECINFO); |
| 5104 | if (status) |
| 5105 | return status; |
| 5106 | return decode_secinfo_common(xdr, res); |
| 5107 | } |
| 5108 | |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 5109 | #if defined(CONFIG_NFS_V4_1) |
Bryan Schumaker | 31e4dda | 2012-04-27 13:27:38 -0400 | [diff] [blame] | 5110 | static int decode_secinfo_no_name(struct xdr_stream *xdr, struct nfs4_secinfo_res *res) |
| 5111 | { |
| 5112 | int status = decode_op_hdr(xdr, OP_SECINFO_NO_NAME); |
| 5113 | if (status) |
| 5114 | return status; |
| 5115 | return decode_secinfo_common(xdr, res); |
| 5116 | } |
| 5117 | |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 5118 | static int decode_exchange_id(struct xdr_stream *xdr, |
| 5119 | struct nfs41_exchange_id_res *res) |
| 5120 | { |
| 5121 | __be32 *p; |
| 5122 | uint32_t dummy; |
Benny Halevy | 2460ba5 | 2009-08-14 17:20:10 +0300 | [diff] [blame] | 5123 | char *dummy_str; |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 5124 | int status; |
| 5125 | struct nfs_client *clp = res->client; |
Weston Andros Adamson | 7d2ed9a | 2012-02-17 15:20:26 -0500 | [diff] [blame] | 5126 | uint32_t impl_id_count; |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 5127 | |
| 5128 | status = decode_op_hdr(xdr, OP_EXCHANGE_ID); |
| 5129 | if (status) |
| 5130 | return status; |
| 5131 | |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 5132 | p = xdr_inline_decode(xdr, 8); |
| 5133 | if (unlikely(!p)) |
| 5134 | goto out_overflow; |
Andy Adamson | 114f64b | 2011-03-09 13:13:45 -0500 | [diff] [blame] | 5135 | xdr_decode_hyper(p, &clp->cl_clientid); |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 5136 | p = xdr_inline_decode(xdr, 12); |
| 5137 | if (unlikely(!p)) |
| 5138 | goto out_overflow; |
Benny Halevy | 6f723f7 | 2009-08-14 17:19:37 +0300 | [diff] [blame] | 5139 | clp->cl_seqid = be32_to_cpup(p++); |
| 5140 | clp->cl_exchange_flags = be32_to_cpup(p++); |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 5141 | |
| 5142 | /* We ask for SP4_NONE */ |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 5143 | dummy = be32_to_cpup(p); |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 5144 | if (dummy != SP4_NONE) |
| 5145 | return -EIO; |
| 5146 | |
| 5147 | /* Throw away minor_id */ |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 5148 | p = xdr_inline_decode(xdr, 8); |
| 5149 | if (unlikely(!p)) |
| 5150 | goto out_overflow; |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 5151 | |
| 5152 | /* Throw away Major id */ |
Benny Halevy | 2460ba5 | 2009-08-14 17:20:10 +0300 | [diff] [blame] | 5153 | status = decode_opaque_inline(xdr, &dummy, &dummy_str); |
| 5154 | if (unlikely(status)) |
| 5155 | return status; |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 5156 | |
Weston Andros Adamson | 78fe0f4 | 2011-05-31 19:05:47 -0400 | [diff] [blame] | 5157 | /* Save server_scope */ |
Benny Halevy | 2460ba5 | 2009-08-14 17:20:10 +0300 | [diff] [blame] | 5158 | status = decode_opaque_inline(xdr, &dummy, &dummy_str); |
| 5159 | if (unlikely(status)) |
| 5160 | return status; |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 5161 | |
Weston Andros Adamson | 78fe0f4 | 2011-05-31 19:05:47 -0400 | [diff] [blame] | 5162 | if (unlikely(dummy > NFS4_OPAQUE_LIMIT)) |
| 5163 | return -EIO; |
| 5164 | |
| 5165 | memcpy(res->server_scope->server_scope, dummy_str, dummy); |
| 5166 | res->server_scope->server_scope_sz = dummy; |
| 5167 | |
Weston Andros Adamson | 7d2ed9a | 2012-02-17 15:20:26 -0500 | [diff] [blame] | 5168 | /* Implementation Id */ |
| 5169 | p = xdr_inline_decode(xdr, 4); |
| 5170 | if (unlikely(!p)) |
| 5171 | goto out_overflow; |
| 5172 | impl_id_count = be32_to_cpup(p++); |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 5173 | |
Weston Andros Adamson | 7d2ed9a | 2012-02-17 15:20:26 -0500 | [diff] [blame] | 5174 | if (impl_id_count) { |
| 5175 | /* nii_domain */ |
| 5176 | status = decode_opaque_inline(xdr, &dummy, &dummy_str); |
| 5177 | if (unlikely(status)) |
| 5178 | return status; |
| 5179 | if (unlikely(dummy > NFS4_OPAQUE_LIMIT)) |
| 5180 | return -EIO; |
| 5181 | memcpy(res->impl_id->domain, dummy_str, dummy); |
| 5182 | |
| 5183 | /* nii_name */ |
| 5184 | status = decode_opaque_inline(xdr, &dummy, &dummy_str); |
| 5185 | if (unlikely(status)) |
| 5186 | return status; |
| 5187 | if (unlikely(dummy > NFS4_OPAQUE_LIMIT)) |
| 5188 | return -EIO; |
| 5189 | memcpy(res->impl_id->name, dummy_str, dummy); |
| 5190 | |
| 5191 | /* nii_date */ |
| 5192 | p = xdr_inline_decode(xdr, 12); |
| 5193 | if (unlikely(!p)) |
| 5194 | goto out_overflow; |
| 5195 | p = xdr_decode_hyper(p, &res->impl_id->date.seconds); |
| 5196 | res->impl_id->date.nseconds = be32_to_cpup(p); |
| 5197 | |
| 5198 | /* if there's more than one entry, ignore the rest */ |
| 5199 | } |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 5200 | return 0; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 5201 | out_overflow: |
| 5202 | print_overflow_msg(__func__, xdr); |
| 5203 | return -EIO; |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 5204 | } |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 5205 | |
| 5206 | static int decode_chan_attrs(struct xdr_stream *xdr, |
| 5207 | struct nfs4_channel_attrs *attrs) |
| 5208 | { |
| 5209 | __be32 *p; |
Benny Halevy | c9c30dd | 2011-06-11 17:08:39 -0400 | [diff] [blame] | 5210 | u32 nr_attrs, val; |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 5211 | |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 5212 | p = xdr_inline_decode(xdr, 28); |
| 5213 | if (unlikely(!p)) |
| 5214 | goto out_overflow; |
Benny Halevy | c9c30dd | 2011-06-11 17:08:39 -0400 | [diff] [blame] | 5215 | val = be32_to_cpup(p++); /* headerpadsz */ |
| 5216 | if (val) |
| 5217 | return -EINVAL; /* no support for header padding yet */ |
Benny Halevy | 6f723f7 | 2009-08-14 17:19:37 +0300 | [diff] [blame] | 5218 | attrs->max_rqst_sz = be32_to_cpup(p++); |
| 5219 | attrs->max_resp_sz = be32_to_cpup(p++); |
| 5220 | attrs->max_resp_sz_cached = be32_to_cpup(p++); |
| 5221 | attrs->max_ops = be32_to_cpup(p++); |
| 5222 | attrs->max_reqs = be32_to_cpup(p++); |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 5223 | nr_attrs = be32_to_cpup(p); |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 5224 | if (unlikely(nr_attrs > 1)) { |
Weston Andros Adamson | a030889 | 2012-01-26 13:32:23 -0500 | [diff] [blame] | 5225 | printk(KERN_WARNING "NFS: %s: Invalid rdma channel attrs " |
| 5226 | "count %u\n", __func__, nr_attrs); |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 5227 | return -EINVAL; |
| 5228 | } |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 5229 | if (nr_attrs == 1) { |
| 5230 | p = xdr_inline_decode(xdr, 4); /* skip rdma_attrs */ |
| 5231 | if (unlikely(!p)) |
| 5232 | goto out_overflow; |
| 5233 | } |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 5234 | return 0; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 5235 | out_overflow: |
| 5236 | print_overflow_msg(__func__, xdr); |
| 5237 | return -EIO; |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 5238 | } |
| 5239 | |
Benny Halevy | e78291e | 2009-08-14 17:20:00 +0300 | [diff] [blame] | 5240 | static int decode_sessionid(struct xdr_stream *xdr, struct nfs4_sessionid *sid) |
| 5241 | { |
| 5242 | return decode_opaque_fixed(xdr, sid->data, NFS4_MAX_SESSIONID_LEN); |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 5243 | } |
| 5244 | |
| 5245 | static int decode_create_session(struct xdr_stream *xdr, |
| 5246 | struct nfs41_create_session_res *res) |
| 5247 | { |
| 5248 | __be32 *p; |
| 5249 | int status; |
| 5250 | struct nfs_client *clp = res->client; |
| 5251 | struct nfs4_session *session = clp->cl_session; |
| 5252 | |
| 5253 | status = decode_op_hdr(xdr, OP_CREATE_SESSION); |
Benny Halevy | e78291e | 2009-08-14 17:20:00 +0300 | [diff] [blame] | 5254 | if (!status) |
| 5255 | status = decode_sessionid(xdr, &session->sess_id); |
| 5256 | if (unlikely(status)) |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 5257 | return status; |
| 5258 | |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 5259 | /* seqid, flags */ |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 5260 | p = xdr_inline_decode(xdr, 8); |
| 5261 | if (unlikely(!p)) |
| 5262 | goto out_overflow; |
Benny Halevy | 6f723f7 | 2009-08-14 17:19:37 +0300 | [diff] [blame] | 5263 | clp->cl_seqid = be32_to_cpup(p++); |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 5264 | session->flags = be32_to_cpup(p); |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 5265 | |
| 5266 | /* Channel attributes */ |
| 5267 | status = decode_chan_attrs(xdr, &session->fc_attrs); |
| 5268 | if (!status) |
| 5269 | status = decode_chan_attrs(xdr, &session->bc_attrs); |
| 5270 | return status; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 5271 | out_overflow: |
| 5272 | print_overflow_msg(__func__, xdr); |
| 5273 | return -EIO; |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 5274 | } |
Andy Adamson | 0f3e66c | 2009-04-01 09:22:34 -0400 | [diff] [blame] | 5275 | |
| 5276 | static int decode_destroy_session(struct xdr_stream *xdr, void *dummy) |
| 5277 | { |
| 5278 | return decode_op_hdr(xdr, OP_DESTROY_SESSION); |
| 5279 | } |
Ricardo Labiaga | 18019753 | 2009-12-05 16:08:40 -0500 | [diff] [blame] | 5280 | |
| 5281 | static int decode_reclaim_complete(struct xdr_stream *xdr, void *dummy) |
| 5282 | { |
| 5283 | return decode_op_hdr(xdr, OP_RECLAIM_COMPLETE); |
| 5284 | } |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 5285 | #endif /* CONFIG_NFS_V4_1 */ |
| 5286 | |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 5287 | static int decode_sequence(struct xdr_stream *xdr, |
| 5288 | struct nfs4_sequence_res *res, |
| 5289 | struct rpc_rqst *rqstp) |
| 5290 | { |
| 5291 | #if defined(CONFIG_NFS_V4_1) |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 5292 | struct nfs4_sessionid id; |
| 5293 | u32 dummy; |
| 5294 | int status; |
| 5295 | __be32 *p; |
| 5296 | |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 5297 | if (!res->sr_session) |
| 5298 | return 0; |
| 5299 | |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 5300 | status = decode_op_hdr(xdr, OP_SEQUENCE); |
Benny Halevy | e78291e | 2009-08-14 17:20:00 +0300 | [diff] [blame] | 5301 | if (!status) |
| 5302 | status = decode_sessionid(xdr, &id); |
| 5303 | if (unlikely(status)) |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 5304 | goto out_err; |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 5305 | |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 5306 | /* |
| 5307 | * If the server returns different values for sessionID, slotID or |
| 5308 | * sequence number, the server is looney tunes. |
| 5309 | */ |
Trond Myklebust | fdcb457 | 2010-02-08 09:32:40 -0500 | [diff] [blame] | 5310 | status = -EREMOTEIO; |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 5311 | |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 5312 | if (memcmp(id.data, res->sr_session->sess_id.data, |
| 5313 | NFS4_MAX_SESSIONID_LEN)) { |
| 5314 | dprintk("%s Invalid session id\n", __func__); |
| 5315 | goto out_err; |
| 5316 | } |
Benny Halevy | e78291e | 2009-08-14 17:20:00 +0300 | [diff] [blame] | 5317 | |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 5318 | p = xdr_inline_decode(xdr, 20); |
| 5319 | if (unlikely(!p)) |
| 5320 | goto out_overflow; |
Benny Halevy | e78291e | 2009-08-14 17:20:00 +0300 | [diff] [blame] | 5321 | |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 5322 | /* seqid */ |
Benny Halevy | 6f723f7 | 2009-08-14 17:19:37 +0300 | [diff] [blame] | 5323 | dummy = be32_to_cpup(p++); |
Benny Halevy | dfb4f309 | 2010-09-24 09:17:01 -0400 | [diff] [blame] | 5324 | if (dummy != res->sr_slot->seq_nr) { |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 5325 | dprintk("%s Invalid sequence number\n", __func__); |
| 5326 | goto out_err; |
| 5327 | } |
| 5328 | /* slot id */ |
Benny Halevy | 6f723f7 | 2009-08-14 17:19:37 +0300 | [diff] [blame] | 5329 | dummy = be32_to_cpup(p++); |
Benny Halevy | dfb4f309 | 2010-09-24 09:17:01 -0400 | [diff] [blame] | 5330 | if (dummy != res->sr_slot - res->sr_session->fc_slot_table.slots) { |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 5331 | dprintk("%s Invalid slot id\n", __func__); |
| 5332 | goto out_err; |
| 5333 | } |
| 5334 | /* highest slot id - currently not processed */ |
Benny Halevy | 6f723f7 | 2009-08-14 17:19:37 +0300 | [diff] [blame] | 5335 | dummy = be32_to_cpup(p++); |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 5336 | /* target highest slot id - currently not processed */ |
Benny Halevy | 6f723f7 | 2009-08-14 17:19:37 +0300 | [diff] [blame] | 5337 | dummy = be32_to_cpup(p++); |
Alexandros Batsakis | 0629e37 | 2009-12-05 13:46:14 -0500 | [diff] [blame] | 5338 | /* result flags */ |
| 5339 | res->sr_status_flags = be32_to_cpup(p); |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 5340 | status = 0; |
| 5341 | out_err: |
| 5342 | res->sr_status = status; |
| 5343 | return status; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 5344 | out_overflow: |
| 5345 | print_overflow_msg(__func__, xdr); |
| 5346 | status = -EIO; |
| 5347 | goto out_err; |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 5348 | #else /* CONFIG_NFS_V4_1 */ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 5349 | return 0; |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 5350 | #endif /* CONFIG_NFS_V4_1 */ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 5351 | } |
| 5352 | |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 5353 | #if defined(CONFIG_NFS_V4_1) |
Andy Adamson | 7f11d8d | 2011-07-30 20:52:35 -0400 | [diff] [blame] | 5354 | /* |
| 5355 | * TODO: Need to handle case when EOF != true; |
| 5356 | */ |
| 5357 | static int decode_getdevicelist(struct xdr_stream *xdr, |
| 5358 | struct pnfs_devicelist *res) |
| 5359 | { |
| 5360 | __be32 *p; |
| 5361 | int status, i; |
| 5362 | struct nfs_writeverf verftemp; |
| 5363 | |
| 5364 | status = decode_op_hdr(xdr, OP_GETDEVICELIST); |
| 5365 | if (status) |
| 5366 | return status; |
| 5367 | |
| 5368 | p = xdr_inline_decode(xdr, 8 + 8 + 4); |
| 5369 | if (unlikely(!p)) |
| 5370 | goto out_overflow; |
| 5371 | |
| 5372 | /* TODO: Skip cookie for now */ |
| 5373 | p += 2; |
| 5374 | |
| 5375 | /* Read verifier */ |
Chuck Lever | cd93710 | 2012-03-02 17:14:31 -0500 | [diff] [blame] | 5376 | p = xdr_decode_opaque_fixed(p, verftemp.verifier, NFS4_VERIFIER_SIZE); |
Andy Adamson | 7f11d8d | 2011-07-30 20:52:35 -0400 | [diff] [blame] | 5377 | |
| 5378 | res->num_devs = be32_to_cpup(p); |
| 5379 | |
| 5380 | dprintk("%s: num_dev %d\n", __func__, res->num_devs); |
| 5381 | |
| 5382 | if (res->num_devs > NFS4_PNFS_GETDEVLIST_MAXNUM) { |
Weston Andros Adamson | a030889 | 2012-01-26 13:32:23 -0500 | [diff] [blame] | 5383 | printk(KERN_ERR "NFS: %s too many result dev_num %u\n", |
Andy Adamson | 7f11d8d | 2011-07-30 20:52:35 -0400 | [diff] [blame] | 5384 | __func__, res->num_devs); |
| 5385 | return -EIO; |
| 5386 | } |
| 5387 | |
| 5388 | p = xdr_inline_decode(xdr, |
| 5389 | res->num_devs * NFS4_DEVICEID4_SIZE + 4); |
| 5390 | if (unlikely(!p)) |
| 5391 | goto out_overflow; |
| 5392 | for (i = 0; i < res->num_devs; i++) |
| 5393 | p = xdr_decode_opaque_fixed(p, res->dev_id[i].data, |
| 5394 | NFS4_DEVICEID4_SIZE); |
| 5395 | res->eof = be32_to_cpup(p); |
| 5396 | return 0; |
| 5397 | out_overflow: |
| 5398 | print_overflow_msg(__func__, xdr); |
| 5399 | return -EIO; |
| 5400 | } |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 5401 | |
| 5402 | static int decode_getdeviceinfo(struct xdr_stream *xdr, |
| 5403 | struct pnfs_device *pdev) |
| 5404 | { |
| 5405 | __be32 *p; |
| 5406 | uint32_t len, type; |
| 5407 | int status; |
| 5408 | |
| 5409 | status = decode_op_hdr(xdr, OP_GETDEVICEINFO); |
| 5410 | if (status) { |
| 5411 | if (status == -ETOOSMALL) { |
| 5412 | p = xdr_inline_decode(xdr, 4); |
| 5413 | if (unlikely(!p)) |
| 5414 | goto out_overflow; |
| 5415 | pdev->mincount = be32_to_cpup(p); |
| 5416 | dprintk("%s: Min count too small. mincnt = %u\n", |
| 5417 | __func__, pdev->mincount); |
| 5418 | } |
| 5419 | return status; |
| 5420 | } |
| 5421 | |
| 5422 | p = xdr_inline_decode(xdr, 8); |
| 5423 | if (unlikely(!p)) |
| 5424 | goto out_overflow; |
| 5425 | type = be32_to_cpup(p++); |
| 5426 | if (type != pdev->layout_type) { |
| 5427 | dprintk("%s: layout mismatch req: %u pdev: %u\n", |
| 5428 | __func__, pdev->layout_type, type); |
| 5429 | return -EINVAL; |
| 5430 | } |
| 5431 | /* |
| 5432 | * Get the length of the opaque device_addr4. xdr_read_pages places |
| 5433 | * the opaque device_addr4 in the xdr_buf->pages (pnfs_device->pages) |
| 5434 | * and places the remaining xdr data in xdr_buf->tail |
| 5435 | */ |
| 5436 | pdev->mincount = be32_to_cpup(p); |
| 5437 | xdr_read_pages(xdr, pdev->mincount); /* include space for the length */ |
| 5438 | |
| 5439 | /* Parse notification bitmap, verifying that it is zero. */ |
| 5440 | p = xdr_inline_decode(xdr, 4); |
| 5441 | if (unlikely(!p)) |
| 5442 | goto out_overflow; |
| 5443 | len = be32_to_cpup(p); |
| 5444 | if (len) { |
Chuck Lever | ead0059 | 2010-12-14 14:58:21 +0000 | [diff] [blame] | 5445 | uint32_t i; |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 5446 | |
| 5447 | p = xdr_inline_decode(xdr, 4 * len); |
| 5448 | if (unlikely(!p)) |
| 5449 | goto out_overflow; |
| 5450 | for (i = 0; i < len; i++, p++) { |
| 5451 | if (be32_to_cpup(p)) { |
| 5452 | dprintk("%s: notifications not supported\n", |
| 5453 | __func__); |
| 5454 | return -EIO; |
| 5455 | } |
| 5456 | } |
| 5457 | } |
| 5458 | return 0; |
| 5459 | out_overflow: |
| 5460 | print_overflow_msg(__func__, xdr); |
| 5461 | return -EIO; |
| 5462 | } |
| 5463 | |
| 5464 | static int decode_layoutget(struct xdr_stream *xdr, struct rpc_rqst *req, |
| 5465 | struct nfs4_layoutget_res *res) |
| 5466 | { |
| 5467 | __be32 *p; |
| 5468 | int status; |
| 5469 | u32 layout_count; |
Weston Andros Adamson | 35124a0 | 2011-03-24 16:48:21 -0400 | [diff] [blame] | 5470 | struct xdr_buf *rcvbuf = &req->rq_rcv_buf; |
| 5471 | struct kvec *iov = rcvbuf->head; |
| 5472 | u32 hdrlen, recvd; |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 5473 | |
| 5474 | status = decode_op_hdr(xdr, OP_LAYOUTGET); |
| 5475 | if (status) |
| 5476 | return status; |
Trond Myklebust | ea9d23f | 2012-03-04 18:13:56 -0500 | [diff] [blame] | 5477 | p = xdr_inline_decode(xdr, 4); |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 5478 | if (unlikely(!p)) |
| 5479 | goto out_overflow; |
Trond Myklebust | ea9d23f | 2012-03-04 18:13:56 -0500 | [diff] [blame] | 5480 | res->return_on_close = be32_to_cpup(p); |
| 5481 | decode_stateid(xdr, &res->stateid); |
| 5482 | p = xdr_inline_decode(xdr, 4); |
| 5483 | if (unlikely(!p)) |
| 5484 | goto out_overflow; |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 5485 | layout_count = be32_to_cpup(p); |
| 5486 | if (!layout_count) { |
| 5487 | dprintk("%s: server responded with empty layout array\n", |
| 5488 | __func__); |
| 5489 | return -EINVAL; |
| 5490 | } |
| 5491 | |
Weston Andros Adamson | 35124a0 | 2011-03-24 16:48:21 -0400 | [diff] [blame] | 5492 | p = xdr_inline_decode(xdr, 28); |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 5493 | if (unlikely(!p)) |
| 5494 | goto out_overflow; |
| 5495 | p = xdr_decode_hyper(p, &res->range.offset); |
| 5496 | p = xdr_decode_hyper(p, &res->range.length); |
| 5497 | res->range.iomode = be32_to_cpup(p++); |
| 5498 | res->type = be32_to_cpup(p++); |
Weston Andros Adamson | 35124a0 | 2011-03-24 16:48:21 -0400 | [diff] [blame] | 5499 | res->layoutp->len = be32_to_cpup(p); |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 5500 | |
| 5501 | dprintk("%s roff:%lu rlen:%lu riomode:%d, lo_type:0x%x, lo.len:%d\n", |
| 5502 | __func__, |
| 5503 | (unsigned long)res->range.offset, |
| 5504 | (unsigned long)res->range.length, |
| 5505 | res->range.iomode, |
| 5506 | res->type, |
Weston Andros Adamson | 35124a0 | 2011-03-24 16:48:21 -0400 | [diff] [blame] | 5507 | res->layoutp->len); |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 5508 | |
Weston Andros Adamson | 35124a0 | 2011-03-24 16:48:21 -0400 | [diff] [blame] | 5509 | hdrlen = (u8 *) xdr->p - (u8 *) iov->iov_base; |
| 5510 | recvd = req->rq_rcv_buf.len - hdrlen; |
| 5511 | if (res->layoutp->len > recvd) { |
| 5512 | dprintk("NFS: server cheating in layoutget reply: " |
| 5513 | "layout len %u > recvd %u\n", |
| 5514 | res->layoutp->len, recvd); |
| 5515 | return -EINVAL; |
| 5516 | } |
| 5517 | |
| 5518 | xdr_read_pages(xdr, res->layoutp->len); |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 5519 | |
| 5520 | if (layout_count > 1) { |
| 5521 | /* We only handle a length one array at the moment. Any |
| 5522 | * further entries are just ignored. Note that this means |
| 5523 | * the client may see a response that is less than the |
| 5524 | * minimum it requested. |
| 5525 | */ |
| 5526 | dprintk("%s: server responded with %d layouts, dropping tail\n", |
| 5527 | __func__, layout_count); |
| 5528 | } |
| 5529 | |
| 5530 | return 0; |
| 5531 | out_overflow: |
| 5532 | print_overflow_msg(__func__, xdr); |
| 5533 | return -EIO; |
| 5534 | } |
Andy Adamson | 863a3c6 | 2011-03-23 13:27:54 +0000 | [diff] [blame] | 5535 | |
Benny Halevy | cbe8260 | 2011-05-22 19:52:37 +0300 | [diff] [blame] | 5536 | static int decode_layoutreturn(struct xdr_stream *xdr, |
| 5537 | struct nfs4_layoutreturn_res *res) |
| 5538 | { |
| 5539 | __be32 *p; |
| 5540 | int status; |
| 5541 | |
| 5542 | status = decode_op_hdr(xdr, OP_LAYOUTRETURN); |
| 5543 | if (status) |
| 5544 | return status; |
| 5545 | p = xdr_inline_decode(xdr, 4); |
| 5546 | if (unlikely(!p)) |
| 5547 | goto out_overflow; |
| 5548 | res->lrs_present = be32_to_cpup(p); |
| 5549 | if (res->lrs_present) |
| 5550 | status = decode_stateid(xdr, &res->stateid); |
| 5551 | return status; |
| 5552 | out_overflow: |
| 5553 | print_overflow_msg(__func__, xdr); |
| 5554 | return -EIO; |
| 5555 | } |
| 5556 | |
Andy Adamson | 863a3c6 | 2011-03-23 13:27:54 +0000 | [diff] [blame] | 5557 | static int decode_layoutcommit(struct xdr_stream *xdr, |
| 5558 | struct rpc_rqst *req, |
| 5559 | struct nfs4_layoutcommit_res *res) |
| 5560 | { |
| 5561 | __be32 *p; |
| 5562 | __u32 sizechanged; |
| 5563 | int status; |
| 5564 | |
| 5565 | status = decode_op_hdr(xdr, OP_LAYOUTCOMMIT); |
Andy Adamson | db29c08 | 2011-07-30 20:52:38 -0400 | [diff] [blame] | 5566 | res->status = status; |
Andy Adamson | 863a3c6 | 2011-03-23 13:27:54 +0000 | [diff] [blame] | 5567 | if (status) |
| 5568 | return status; |
| 5569 | |
| 5570 | p = xdr_inline_decode(xdr, 4); |
| 5571 | if (unlikely(!p)) |
| 5572 | goto out_overflow; |
| 5573 | sizechanged = be32_to_cpup(p); |
| 5574 | |
| 5575 | if (sizechanged) { |
| 5576 | /* throw away new size */ |
| 5577 | p = xdr_inline_decode(xdr, 8); |
| 5578 | if (unlikely(!p)) |
| 5579 | goto out_overflow; |
| 5580 | } |
| 5581 | return 0; |
| 5582 | out_overflow: |
| 5583 | print_overflow_msg(__func__, xdr); |
| 5584 | return -EIO; |
| 5585 | } |
Bryan Schumaker | 7d97479 | 2011-06-02 14:59:08 -0400 | [diff] [blame] | 5586 | |
| 5587 | static int decode_test_stateid(struct xdr_stream *xdr, |
| 5588 | struct nfs41_test_stateid_res *res) |
| 5589 | { |
| 5590 | __be32 *p; |
| 5591 | int status; |
| 5592 | int num_res; |
| 5593 | |
| 5594 | status = decode_op_hdr(xdr, OP_TEST_STATEID); |
| 5595 | if (status) |
| 5596 | return status; |
| 5597 | |
| 5598 | p = xdr_inline_decode(xdr, 4); |
| 5599 | if (unlikely(!p)) |
| 5600 | goto out_overflow; |
| 5601 | num_res = be32_to_cpup(p++); |
| 5602 | if (num_res != 1) |
| 5603 | goto out; |
| 5604 | |
| 5605 | p = xdr_inline_decode(xdr, 4); |
| 5606 | if (unlikely(!p)) |
| 5607 | goto out_overflow; |
| 5608 | res->status = be32_to_cpup(p++); |
Bryan Schumaker | 1cab065 | 2012-01-31 10:39:29 -0500 | [diff] [blame] | 5609 | |
| 5610 | return status; |
Bryan Schumaker | 7d97479 | 2011-06-02 14:59:08 -0400 | [diff] [blame] | 5611 | out_overflow: |
| 5612 | print_overflow_msg(__func__, xdr); |
| 5613 | out: |
| 5614 | return -EIO; |
| 5615 | } |
Bryan Schumaker | 9aeda35 | 2011-06-02 14:59:09 -0400 | [diff] [blame] | 5616 | |
| 5617 | static int decode_free_stateid(struct xdr_stream *xdr, |
| 5618 | struct nfs41_free_stateid_res *res) |
| 5619 | { |
| 5620 | __be32 *p; |
| 5621 | int status; |
| 5622 | |
| 5623 | status = decode_op_hdr(xdr, OP_FREE_STATEID); |
| 5624 | if (status) |
| 5625 | return status; |
| 5626 | |
| 5627 | p = xdr_inline_decode(xdr, 4); |
| 5628 | if (unlikely(!p)) |
| 5629 | goto out_overflow; |
| 5630 | res->status = be32_to_cpup(p++); |
| 5631 | return res->status; |
| 5632 | out_overflow: |
| 5633 | print_overflow_msg(__func__, xdr); |
| 5634 | return -EIO; |
| 5635 | } |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 5636 | #endif /* CONFIG_NFS_V4_1 */ |
| 5637 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5638 | /* |
Benny Halevy | 49c2559 | 2008-12-23 16:06:16 -0500 | [diff] [blame] | 5639 | * END OF "GENERIC" DECODE ROUTINES. |
| 5640 | */ |
| 5641 | |
| 5642 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5643 | * Decode OPEN_DOWNGRADE response |
| 5644 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 5645 | static int nfs4_xdr_dec_open_downgrade(struct rpc_rqst *rqstp, |
| 5646 | struct xdr_stream *xdr, |
| 5647 | struct nfs_closeres *res) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5648 | { |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 5649 | struct compound_hdr hdr; |
| 5650 | int status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5651 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 5652 | status = decode_compound_hdr(xdr, &hdr); |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 5653 | if (status) |
| 5654 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 5655 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 5656 | if (status) |
| 5657 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 5658 | status = decode_putfh(xdr); |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 5659 | if (status) |
| 5660 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 5661 | status = decode_open_downgrade(xdr, res); |
Trond Myklebust | 516a6af | 2005-10-27 22:12:41 -0400 | [diff] [blame] | 5662 | if (status != 0) |
| 5663 | goto out; |
Trond Myklebust | 6926afd | 2012-01-07 13:22:46 -0500 | [diff] [blame] | 5664 | decode_getfattr(xdr, res->fattr, res->server); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5665 | out: |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 5666 | return status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5667 | } |
| 5668 | |
| 5669 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5670 | * Decode ACCESS response |
| 5671 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 5672 | static int nfs4_xdr_dec_access(struct rpc_rqst *rqstp, struct xdr_stream *xdr, |
| 5673 | struct nfs4_accessres *res) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5674 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5675 | struct compound_hdr hdr; |
| 5676 | int status; |
Andy Adamson | 6c0195a | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 5677 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 5678 | status = decode_compound_hdr(xdr, &hdr); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 5679 | if (status) |
| 5680 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 5681 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 5682 | if (status) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5683 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 5684 | status = decode_putfh(xdr); |
Trond Myklebust | 76b3299 | 2007-08-10 17:45:11 -0400 | [diff] [blame] | 5685 | if (status != 0) |
| 5686 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 5687 | status = decode_access(xdr, res); |
Trond Myklebust | 76b3299 | 2007-08-10 17:45:11 -0400 | [diff] [blame] | 5688 | if (status != 0) |
| 5689 | goto out; |
Trond Myklebust | 6926afd | 2012-01-07 13:22:46 -0500 | [diff] [blame] | 5690 | decode_getfattr(xdr, res->fattr, res->server); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5691 | out: |
| 5692 | return status; |
| 5693 | } |
| 5694 | |
| 5695 | /* |
| 5696 | * Decode LOOKUP response |
| 5697 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 5698 | static int nfs4_xdr_dec_lookup(struct rpc_rqst *rqstp, struct xdr_stream *xdr, |
| 5699 | struct nfs4_lookup_res *res) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5700 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5701 | struct compound_hdr hdr; |
| 5702 | int status; |
Andy Adamson | 6c0195a | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 5703 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 5704 | status = decode_compound_hdr(xdr, &hdr); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 5705 | if (status) |
| 5706 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 5707 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 5708 | if (status) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5709 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 5710 | status = decode_putfh(xdr); |
| 5711 | if (status) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5712 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 5713 | status = decode_lookup(xdr); |
| 5714 | if (status) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5715 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 5716 | status = decode_getfh(xdr, res->fh); |
| 5717 | if (status) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5718 | goto out; |
Trond Myklebust | 6926afd | 2012-01-07 13:22:46 -0500 | [diff] [blame] | 5719 | status = decode_getfattr(xdr, res->fattr, res->server); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5720 | out: |
| 5721 | return status; |
| 5722 | } |
| 5723 | |
| 5724 | /* |
| 5725 | * Decode LOOKUP_ROOT response |
| 5726 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 5727 | static int nfs4_xdr_dec_lookup_root(struct rpc_rqst *rqstp, |
| 5728 | struct xdr_stream *xdr, |
| 5729 | struct nfs4_lookup_res *res) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5730 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5731 | struct compound_hdr hdr; |
| 5732 | int status; |
Andy Adamson | 6c0195a | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 5733 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 5734 | status = decode_compound_hdr(xdr, &hdr); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 5735 | if (status) |
| 5736 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 5737 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 5738 | if (status) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5739 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 5740 | status = decode_putrootfh(xdr); |
| 5741 | if (status) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5742 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 5743 | status = decode_getfh(xdr, res->fh); |
| 5744 | if (status == 0) |
Trond Myklebust | 6926afd | 2012-01-07 13:22:46 -0500 | [diff] [blame] | 5745 | status = decode_getfattr(xdr, res->fattr, res->server); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5746 | out: |
| 5747 | return status; |
| 5748 | } |
| 5749 | |
| 5750 | /* |
| 5751 | * Decode REMOVE response |
| 5752 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 5753 | static int nfs4_xdr_dec_remove(struct rpc_rqst *rqstp, struct xdr_stream *xdr, |
| 5754 | struct nfs_removeres *res) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5755 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5756 | struct compound_hdr hdr; |
| 5757 | int status; |
Andy Adamson | 6c0195a | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 5758 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 5759 | status = decode_compound_hdr(xdr, &hdr); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 5760 | if (status) |
| 5761 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 5762 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 5763 | if (status) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5764 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 5765 | status = decode_putfh(xdr); |
| 5766 | if (status) |
Trond Myklebust | 16e4295 | 2005-10-27 22:12:44 -0400 | [diff] [blame] | 5767 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 5768 | status = decode_remove(xdr, &res->cinfo); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5769 | out: |
| 5770 | return status; |
| 5771 | } |
| 5772 | |
| 5773 | /* |
| 5774 | * Decode RENAME response |
| 5775 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 5776 | static int nfs4_xdr_dec_rename(struct rpc_rqst *rqstp, struct xdr_stream *xdr, |
| 5777 | struct nfs_renameres *res) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5778 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5779 | struct compound_hdr hdr; |
| 5780 | int status; |
Andy Adamson | 6c0195a | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 5781 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 5782 | status = decode_compound_hdr(xdr, &hdr); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 5783 | if (status) |
| 5784 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 5785 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 5786 | if (status) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5787 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 5788 | status = decode_putfh(xdr); |
| 5789 | if (status) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5790 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 5791 | status = decode_savefh(xdr); |
| 5792 | if (status) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5793 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 5794 | status = decode_putfh(xdr); |
| 5795 | if (status) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5796 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 5797 | status = decode_rename(xdr, &res->old_cinfo, &res->new_cinfo); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5798 | out: |
| 5799 | return status; |
| 5800 | } |
| 5801 | |
| 5802 | /* |
| 5803 | * Decode LINK response |
| 5804 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 5805 | static int nfs4_xdr_dec_link(struct rpc_rqst *rqstp, struct xdr_stream *xdr, |
| 5806 | struct nfs4_link_res *res) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5807 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5808 | struct compound_hdr hdr; |
| 5809 | int status; |
Andy Adamson | 6c0195a | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 5810 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 5811 | status = decode_compound_hdr(xdr, &hdr); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 5812 | if (status) |
| 5813 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 5814 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 5815 | if (status) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5816 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 5817 | status = decode_putfh(xdr); |
| 5818 | if (status) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5819 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 5820 | status = decode_savefh(xdr); |
| 5821 | if (status) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5822 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 5823 | status = decode_putfh(xdr); |
| 5824 | if (status) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5825 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 5826 | status = decode_link(xdr, &res->cinfo); |
| 5827 | if (status) |
Trond Myklebust | 91ba2ee | 2005-10-27 22:12:42 -0400 | [diff] [blame] | 5828 | goto out; |
| 5829 | /* |
| 5830 | * Note order: OP_LINK leaves the directory as the current |
| 5831 | * filehandle. |
| 5832 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 5833 | status = decode_restorefh(xdr); |
| 5834 | if (status) |
Trond Myklebust | 91ba2ee | 2005-10-27 22:12:42 -0400 | [diff] [blame] | 5835 | goto out; |
Trond Myklebust | 6926afd | 2012-01-07 13:22:46 -0500 | [diff] [blame] | 5836 | decode_getfattr(xdr, res->fattr, res->server); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5837 | out: |
| 5838 | return status; |
| 5839 | } |
| 5840 | |
| 5841 | /* |
| 5842 | * Decode CREATE response |
| 5843 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 5844 | static int nfs4_xdr_dec_create(struct rpc_rqst *rqstp, struct xdr_stream *xdr, |
| 5845 | struct nfs4_create_res *res) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5846 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5847 | struct compound_hdr hdr; |
| 5848 | int status; |
Andy Adamson | 6c0195a | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 5849 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 5850 | status = decode_compound_hdr(xdr, &hdr); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 5851 | if (status) |
| 5852 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 5853 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 5854 | if (status) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5855 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 5856 | status = decode_putfh(xdr); |
| 5857 | if (status) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5858 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 5859 | status = decode_create(xdr, &res->dir_cinfo); |
| 5860 | if (status) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5861 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 5862 | status = decode_getfh(xdr, res->fh); |
| 5863 | if (status) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5864 | goto out; |
Trond Myklebust | 7c317fc | 2012-04-27 13:48:18 -0400 | [diff] [blame] | 5865 | decode_getfattr(xdr, res->fattr, res->server); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5866 | out: |
| 5867 | return status; |
| 5868 | } |
| 5869 | |
| 5870 | /* |
| 5871 | * Decode SYMLINK response |
| 5872 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 5873 | static int nfs4_xdr_dec_symlink(struct rpc_rqst *rqstp, struct xdr_stream *xdr, |
| 5874 | struct nfs4_create_res *res) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5875 | { |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 5876 | return nfs4_xdr_dec_create(rqstp, xdr, res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5877 | } |
| 5878 | |
| 5879 | /* |
| 5880 | * Decode GETATTR response |
| 5881 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 5882 | static int nfs4_xdr_dec_getattr(struct rpc_rqst *rqstp, struct xdr_stream *xdr, |
| 5883 | struct nfs4_getattr_res *res) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5884 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5885 | struct compound_hdr hdr; |
| 5886 | int status; |
Andy Adamson | 6c0195a | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 5887 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 5888 | status = decode_compound_hdr(xdr, &hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5889 | if (status) |
| 5890 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 5891 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 5892 | if (status) |
| 5893 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 5894 | status = decode_putfh(xdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5895 | if (status) |
| 5896 | goto out; |
Trond Myklebust | 6926afd | 2012-01-07 13:22:46 -0500 | [diff] [blame] | 5897 | status = decode_getfattr(xdr, res->fattr, res->server); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5898 | out: |
| 5899 | return status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5900 | } |
| 5901 | |
J. Bruce Fields | 23ec696 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 5902 | /* |
| 5903 | * Encode an SETACL request |
| 5904 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 5905 | static void nfs4_xdr_enc_setacl(struct rpc_rqst *req, struct xdr_stream *xdr, |
| 5906 | struct nfs_setaclargs *args) |
J. Bruce Fields | 23ec696 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 5907 | { |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 5908 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 5909 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 5910 | }; |
J. Bruce Fields | 23ec696 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 5911 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 5912 | encode_compound_hdr(xdr, req, &hdr); |
| 5913 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 5914 | encode_putfh(xdr, args->fh, &hdr); |
| 5915 | encode_setacl(xdr, args, &hdr); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 5916 | encode_nops(&hdr); |
J. Bruce Fields | 23ec696 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 5917 | } |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 5918 | |
J. Bruce Fields | 23ec696 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 5919 | /* |
| 5920 | * Decode SETACL response |
| 5921 | */ |
| 5922 | static int |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 5923 | nfs4_xdr_dec_setacl(struct rpc_rqst *rqstp, struct xdr_stream *xdr, |
Benny Halevy | 73c403a | 2009-04-01 09:22:01 -0400 | [diff] [blame] | 5924 | struct nfs_setaclres *res) |
J. Bruce Fields | 23ec696 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 5925 | { |
J. Bruce Fields | 23ec696 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 5926 | struct compound_hdr hdr; |
| 5927 | int status; |
| 5928 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 5929 | status = decode_compound_hdr(xdr, &hdr); |
J. Bruce Fields | 23ec696 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 5930 | if (status) |
| 5931 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 5932 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 5933 | if (status) |
| 5934 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 5935 | status = decode_putfh(xdr); |
J. Bruce Fields | 23ec696 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 5936 | if (status) |
| 5937 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 5938 | status = decode_setattr(xdr); |
J. Bruce Fields | 23ec696 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 5939 | out: |
| 5940 | return status; |
| 5941 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5942 | |
| 5943 | /* |
J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 5944 | * Decode GETACL response |
| 5945 | */ |
| 5946 | static int |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 5947 | nfs4_xdr_dec_getacl(struct rpc_rqst *rqstp, struct xdr_stream *xdr, |
Benny Halevy | 663c79b | 2009-04-01 09:21:59 -0400 | [diff] [blame] | 5948 | struct nfs_getaclres *res) |
J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 5949 | { |
J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 5950 | struct compound_hdr hdr; |
| 5951 | int status; |
| 5952 | |
Trond Myklebust | 331818f | 2012-02-03 18:30:53 -0500 | [diff] [blame] | 5953 | if (res->acl_scratch != NULL) { |
| 5954 | void *p = page_address(res->acl_scratch); |
| 5955 | xdr_set_scratch_buffer(xdr, p, PAGE_SIZE); |
| 5956 | } |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 5957 | status = decode_compound_hdr(xdr, &hdr); |
J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 5958 | if (status) |
| 5959 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 5960 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 5961 | if (status) |
| 5962 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 5963 | status = decode_putfh(xdr); |
J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 5964 | if (status) |
| 5965 | goto out; |
Andy Adamson | bf118a3 | 2011-12-07 11:55:27 -0500 | [diff] [blame] | 5966 | status = decode_getacl(xdr, rqstp, res); |
J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 5967 | |
| 5968 | out: |
| 5969 | return status; |
| 5970 | } |
| 5971 | |
| 5972 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5973 | * Decode CLOSE response |
| 5974 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 5975 | static int nfs4_xdr_dec_close(struct rpc_rqst *rqstp, struct xdr_stream *xdr, |
| 5976 | struct nfs_closeres *res) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5977 | { |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 5978 | struct compound_hdr hdr; |
| 5979 | int status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5980 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 5981 | status = decode_compound_hdr(xdr, &hdr); |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 5982 | if (status) |
| 5983 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 5984 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 5985 | if (status) |
| 5986 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 5987 | status = decode_putfh(xdr); |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 5988 | if (status) |
| 5989 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 5990 | status = decode_close(xdr, res); |
Trond Myklebust | 516a6af | 2005-10-27 22:12:41 -0400 | [diff] [blame] | 5991 | if (status != 0) |
| 5992 | goto out; |
| 5993 | /* |
| 5994 | * Note: Server may do delete on close for this file |
| 5995 | * in which case the getattr call will fail with |
| 5996 | * an ESTALE error. Shouldn't be a problem, |
| 5997 | * though, since fattr->valid will remain unset. |
| 5998 | */ |
Trond Myklebust | 6926afd | 2012-01-07 13:22:46 -0500 | [diff] [blame] | 5999 | decode_getfattr(xdr, res->fattr, res->server); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6000 | out: |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6001 | return status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6002 | } |
| 6003 | |
| 6004 | /* |
| 6005 | * Decode OPEN response |
| 6006 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6007 | static int nfs4_xdr_dec_open(struct rpc_rqst *rqstp, struct xdr_stream *xdr, |
| 6008 | struct nfs_openres *res) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6009 | { |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6010 | struct compound_hdr hdr; |
| 6011 | int status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6012 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6013 | status = decode_compound_hdr(xdr, &hdr); |
Trond Myklebust | 56ae19f | 2005-10-27 22:12:40 -0400 | [diff] [blame] | 6014 | if (status) |
| 6015 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6016 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6017 | if (status) |
| 6018 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6019 | status = decode_putfh(xdr); |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6020 | if (status) |
| 6021 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6022 | status = decode_open(xdr, res); |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6023 | if (status) |
| 6024 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6025 | if (decode_getfh(xdr, &res->fh) != 0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6026 | goto out; |
Trond Myklebust | 90ff0c5 | 2012-04-27 13:48:18 -0400 | [diff] [blame] | 6027 | decode_getfattr(xdr, res->f_attr, res->server); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6028 | out: |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6029 | return status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6030 | } |
| 6031 | |
| 6032 | /* |
| 6033 | * Decode OPEN_CONFIRM response |
| 6034 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6035 | static int nfs4_xdr_dec_open_confirm(struct rpc_rqst *rqstp, |
| 6036 | struct xdr_stream *xdr, |
| 6037 | struct nfs_open_confirmres *res) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6038 | { |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6039 | struct compound_hdr hdr; |
| 6040 | int status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6041 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6042 | status = decode_compound_hdr(xdr, &hdr); |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6043 | if (status) |
| 6044 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6045 | status = decode_putfh(xdr); |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6046 | if (status) |
| 6047 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6048 | status = decode_open_confirm(xdr, res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6049 | out: |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6050 | return status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6051 | } |
| 6052 | |
| 6053 | /* |
| 6054 | * Decode OPEN response |
| 6055 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6056 | static int nfs4_xdr_dec_open_noattr(struct rpc_rqst *rqstp, |
| 6057 | struct xdr_stream *xdr, |
| 6058 | struct nfs_openres *res) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6059 | { |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6060 | struct compound_hdr hdr; |
| 6061 | int status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6062 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6063 | status = decode_compound_hdr(xdr, &hdr); |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6064 | if (status) |
| 6065 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6066 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6067 | if (status) |
| 6068 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6069 | status = decode_putfh(xdr); |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6070 | if (status) |
| 6071 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6072 | status = decode_open(xdr, res); |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6073 | if (status) |
| 6074 | goto out; |
Trond Myklebust | 6926afd | 2012-01-07 13:22:46 -0500 | [diff] [blame] | 6075 | decode_getfattr(xdr, res->f_attr, res->server); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6076 | out: |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6077 | return status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6078 | } |
| 6079 | |
| 6080 | /* |
| 6081 | * Decode SETATTR response |
| 6082 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6083 | static int nfs4_xdr_dec_setattr(struct rpc_rqst *rqstp, |
| 6084 | struct xdr_stream *xdr, |
| 6085 | struct nfs_setattrres *res) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6086 | { |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6087 | struct compound_hdr hdr; |
| 6088 | int status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6089 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6090 | status = decode_compound_hdr(xdr, &hdr); |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6091 | if (status) |
| 6092 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6093 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6094 | if (status) |
| 6095 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6096 | status = decode_putfh(xdr); |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6097 | if (status) |
| 6098 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6099 | status = decode_setattr(xdr); |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6100 | if (status) |
| 6101 | goto out; |
Trond Myklebust | 6926afd | 2012-01-07 13:22:46 -0500 | [diff] [blame] | 6102 | decode_getfattr(xdr, res->fattr, res->server); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6103 | out: |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6104 | return status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6105 | } |
| 6106 | |
| 6107 | /* |
| 6108 | * Decode LOCK response |
| 6109 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6110 | static int nfs4_xdr_dec_lock(struct rpc_rqst *rqstp, struct xdr_stream *xdr, |
| 6111 | struct nfs_lock_res *res) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6112 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6113 | struct compound_hdr hdr; |
| 6114 | int status; |
| 6115 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6116 | status = decode_compound_hdr(xdr, &hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6117 | if (status) |
| 6118 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6119 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6120 | if (status) |
| 6121 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6122 | status = decode_putfh(xdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6123 | if (status) |
| 6124 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6125 | status = decode_lock(xdr, res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6126 | out: |
| 6127 | return status; |
| 6128 | } |
| 6129 | |
| 6130 | /* |
| 6131 | * Decode LOCKT response |
| 6132 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6133 | static int nfs4_xdr_dec_lockt(struct rpc_rqst *rqstp, struct xdr_stream *xdr, |
| 6134 | struct nfs_lockt_res *res) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6135 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6136 | struct compound_hdr hdr; |
| 6137 | int status; |
| 6138 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6139 | status = decode_compound_hdr(xdr, &hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6140 | if (status) |
| 6141 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6142 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6143 | if (status) |
| 6144 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6145 | status = decode_putfh(xdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6146 | if (status) |
| 6147 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6148 | status = decode_lockt(xdr, res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6149 | out: |
| 6150 | return status; |
| 6151 | } |
| 6152 | |
| 6153 | /* |
| 6154 | * Decode LOCKU response |
| 6155 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6156 | static int nfs4_xdr_dec_locku(struct rpc_rqst *rqstp, struct xdr_stream *xdr, |
| 6157 | struct nfs_locku_res *res) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6158 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6159 | struct compound_hdr hdr; |
| 6160 | int status; |
| 6161 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6162 | status = decode_compound_hdr(xdr, &hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6163 | if (status) |
| 6164 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6165 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6166 | if (status) |
| 6167 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6168 | status = decode_putfh(xdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6169 | if (status) |
| 6170 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6171 | status = decode_locku(xdr, res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6172 | out: |
| 6173 | return status; |
| 6174 | } |
| 6175 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6176 | static int nfs4_xdr_dec_release_lockowner(struct rpc_rqst *rqstp, |
| 6177 | struct xdr_stream *xdr, void *dummy) |
Trond Myklebust | d3c7b7c | 2010-07-01 12:49:01 -0400 | [diff] [blame] | 6178 | { |
Trond Myklebust | d3c7b7c | 2010-07-01 12:49:01 -0400 | [diff] [blame] | 6179 | struct compound_hdr hdr; |
| 6180 | int status; |
| 6181 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6182 | status = decode_compound_hdr(xdr, &hdr); |
Trond Myklebust | d3c7b7c | 2010-07-01 12:49:01 -0400 | [diff] [blame] | 6183 | if (!status) |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6184 | status = decode_release_lockowner(xdr); |
Trond Myklebust | d3c7b7c | 2010-07-01 12:49:01 -0400 | [diff] [blame] | 6185 | return status; |
| 6186 | } |
| 6187 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6188 | /* |
| 6189 | * Decode READLINK response |
| 6190 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6191 | static int nfs4_xdr_dec_readlink(struct rpc_rqst *rqstp, |
| 6192 | struct xdr_stream *xdr, |
Benny Halevy | f50c700 | 2009-04-01 09:21:55 -0400 | [diff] [blame] | 6193 | struct nfs4_readlink_res *res) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6194 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6195 | struct compound_hdr hdr; |
| 6196 | int status; |
| 6197 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6198 | status = decode_compound_hdr(xdr, &hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6199 | if (status) |
| 6200 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6201 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6202 | if (status) |
| 6203 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6204 | status = decode_putfh(xdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6205 | if (status) |
| 6206 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6207 | status = decode_readlink(xdr, rqstp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6208 | out: |
| 6209 | return status; |
| 6210 | } |
| 6211 | |
| 6212 | /* |
| 6213 | * Decode READDIR response |
| 6214 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6215 | static int nfs4_xdr_dec_readdir(struct rpc_rqst *rqstp, struct xdr_stream *xdr, |
| 6216 | struct nfs4_readdir_res *res) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6217 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6218 | struct compound_hdr hdr; |
| 6219 | int status; |
| 6220 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6221 | status = decode_compound_hdr(xdr, &hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6222 | if (status) |
| 6223 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6224 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6225 | if (status) |
| 6226 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6227 | status = decode_putfh(xdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6228 | if (status) |
| 6229 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6230 | status = decode_readdir(xdr, rqstp, res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6231 | out: |
| 6232 | return status; |
| 6233 | } |
| 6234 | |
| 6235 | /* |
| 6236 | * Decode Read response |
| 6237 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6238 | static int nfs4_xdr_dec_read(struct rpc_rqst *rqstp, struct xdr_stream *xdr, |
| 6239 | struct nfs_readres *res) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6240 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6241 | struct compound_hdr hdr; |
| 6242 | int status; |
| 6243 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6244 | status = decode_compound_hdr(xdr, &hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6245 | if (status) |
| 6246 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6247 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6248 | if (status) |
| 6249 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6250 | status = decode_putfh(xdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6251 | if (status) |
| 6252 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6253 | status = decode_read(xdr, rqstp, res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6254 | if (!status) |
| 6255 | status = res->count; |
| 6256 | out: |
| 6257 | return status; |
| 6258 | } |
| 6259 | |
| 6260 | /* |
| 6261 | * Decode WRITE response |
| 6262 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6263 | static int nfs4_xdr_dec_write(struct rpc_rqst *rqstp, struct xdr_stream *xdr, |
| 6264 | struct nfs_writeres *res) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6265 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6266 | struct compound_hdr hdr; |
| 6267 | int status; |
| 6268 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6269 | status = decode_compound_hdr(xdr, &hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6270 | if (status) |
| 6271 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6272 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6273 | if (status) |
| 6274 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6275 | status = decode_putfh(xdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6276 | if (status) |
| 6277 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6278 | status = decode_write(xdr, res); |
Trond Myklebust | 4f9838c | 2005-10-27 22:12:44 -0400 | [diff] [blame] | 6279 | if (status) |
| 6280 | goto out; |
Fred Isaman | 7ffd106 | 2011-03-03 15:13:46 +0000 | [diff] [blame] | 6281 | if (res->fattr) |
Trond Myklebust | 6926afd | 2012-01-07 13:22:46 -0500 | [diff] [blame] | 6282 | decode_getfattr(xdr, res->fattr, res->server); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6283 | if (!status) |
| 6284 | status = res->count; |
| 6285 | out: |
| 6286 | return status; |
| 6287 | } |
| 6288 | |
| 6289 | /* |
| 6290 | * Decode COMMIT response |
| 6291 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6292 | 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] | 6293 | struct nfs_commitres *res) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6294 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6295 | struct compound_hdr hdr; |
| 6296 | int status; |
| 6297 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6298 | status = decode_compound_hdr(xdr, &hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6299 | if (status) |
| 6300 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6301 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6302 | if (status) |
| 6303 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6304 | status = decode_putfh(xdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6305 | if (status) |
| 6306 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6307 | status = decode_commit(xdr, res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6308 | out: |
| 6309 | return status; |
| 6310 | } |
| 6311 | |
| 6312 | /* |
Ricardo Labiaga | 8b17321 | 2009-12-05 16:08:39 -0500 | [diff] [blame] | 6313 | * Decode FSINFO response |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6314 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6315 | 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] | 6316 | struct nfs4_fsinfo_res *res) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6317 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6318 | struct compound_hdr hdr; |
| 6319 | int status; |
| 6320 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6321 | status = decode_compound_hdr(xdr, &hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6322 | if (!status) |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6323 | status = decode_sequence(xdr, &res->seq_res, req); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6324 | if (!status) |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6325 | status = decode_putfh(xdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6326 | if (!status) |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6327 | status = decode_fsinfo(xdr, res->fsinfo); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6328 | return status; |
| 6329 | } |
| 6330 | |
| 6331 | /* |
Ricardo Labiaga | 8b17321 | 2009-12-05 16:08:39 -0500 | [diff] [blame] | 6332 | * Decode PATHCONF response |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6333 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6334 | 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] | 6335 | struct nfs4_pathconf_res *res) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6336 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6337 | struct compound_hdr hdr; |
| 6338 | int status; |
| 6339 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6340 | status = decode_compound_hdr(xdr, &hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6341 | if (!status) |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6342 | status = decode_sequence(xdr, &res->seq_res, req); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6343 | if (!status) |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6344 | status = decode_putfh(xdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6345 | if (!status) |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6346 | status = decode_pathconf(xdr, res->pathconf); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6347 | return status; |
| 6348 | } |
| 6349 | |
| 6350 | /* |
Ricardo Labiaga | 8b17321 | 2009-12-05 16:08:39 -0500 | [diff] [blame] | 6351 | * Decode STATFS response |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6352 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6353 | 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] | 6354 | struct nfs4_statfs_res *res) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6355 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6356 | struct compound_hdr hdr; |
| 6357 | int status; |
| 6358 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6359 | status = decode_compound_hdr(xdr, &hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6360 | if (!status) |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6361 | status = decode_sequence(xdr, &res->seq_res, req); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6362 | if (!status) |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6363 | status = decode_putfh(xdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6364 | if (!status) |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6365 | status = decode_statfs(xdr, res->fsstat); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6366 | return status; |
| 6367 | } |
| 6368 | |
| 6369 | /* |
Ricardo Labiaga | 8b17321 | 2009-12-05 16:08:39 -0500 | [diff] [blame] | 6370 | * Decode GETATTR_BITMAP response |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6371 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6372 | static int nfs4_xdr_dec_server_caps(struct rpc_rqst *req, |
| 6373 | struct xdr_stream *xdr, |
| 6374 | struct nfs4_server_caps_res *res) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6375 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6376 | struct compound_hdr hdr; |
| 6377 | int status; |
| 6378 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6379 | status = decode_compound_hdr(xdr, &hdr); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6380 | if (status) |
| 6381 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6382 | status = decode_sequence(xdr, &res->seq_res, req); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6383 | if (status) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6384 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6385 | status = decode_putfh(xdr); |
| 6386 | if (status) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6387 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6388 | status = decode_server_caps(xdr, res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6389 | out: |
| 6390 | return status; |
| 6391 | } |
| 6392 | |
| 6393 | /* |
| 6394 | * Decode RENEW response |
| 6395 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6396 | static int nfs4_xdr_dec_renew(struct rpc_rqst *rqstp, struct xdr_stream *xdr, |
| 6397 | void *__unused) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6398 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6399 | struct compound_hdr hdr; |
| 6400 | int status; |
| 6401 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6402 | status = decode_compound_hdr(xdr, &hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6403 | if (!status) |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6404 | status = decode_renew(xdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6405 | return status; |
| 6406 | } |
| 6407 | |
| 6408 | /* |
Ricardo Labiaga | 8b17321 | 2009-12-05 16:08:39 -0500 | [diff] [blame] | 6409 | * Decode SETCLIENTID response |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6410 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6411 | static int nfs4_xdr_dec_setclientid(struct rpc_rqst *req, |
| 6412 | struct xdr_stream *xdr, |
| 6413 | struct nfs4_setclientid_res *res) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6414 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6415 | struct compound_hdr hdr; |
| 6416 | int status; |
| 6417 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6418 | status = decode_compound_hdr(xdr, &hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6419 | if (!status) |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6420 | status = decode_setclientid(xdr, res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6421 | return status; |
| 6422 | } |
| 6423 | |
| 6424 | /* |
Ricardo Labiaga | 8b17321 | 2009-12-05 16:08:39 -0500 | [diff] [blame] | 6425 | * Decode SETCLIENTID_CONFIRM response |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6426 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6427 | static int nfs4_xdr_dec_setclientid_confirm(struct rpc_rqst *req, |
| 6428 | struct xdr_stream *xdr, |
| 6429 | struct nfs_fsinfo *fsinfo) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6430 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6431 | struct compound_hdr hdr; |
| 6432 | int status; |
| 6433 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6434 | status = decode_compound_hdr(xdr, &hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6435 | if (!status) |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6436 | status = decode_setclientid_confirm(xdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6437 | if (!status) |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6438 | status = decode_putrootfh(xdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6439 | if (!status) |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6440 | status = decode_fsinfo(xdr, fsinfo); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6441 | return status; |
| 6442 | } |
| 6443 | |
| 6444 | /* |
Ricardo Labiaga | 8b17321 | 2009-12-05 16:08:39 -0500 | [diff] [blame] | 6445 | * Decode DELEGRETURN response |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6446 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6447 | static int nfs4_xdr_dec_delegreturn(struct rpc_rqst *rqstp, |
| 6448 | struct xdr_stream *xdr, |
| 6449 | struct nfs4_delegreturnres *res) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6450 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6451 | struct compound_hdr hdr; |
| 6452 | int status; |
| 6453 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6454 | status = decode_compound_hdr(xdr, &hdr); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6455 | if (status) |
| 6456 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6457 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6458 | if (status) |
Trond Myklebust | fa178f2 | 2006-01-03 09:55:38 +0100 | [diff] [blame] | 6459 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6460 | status = decode_putfh(xdr); |
Trond Myklebust | fa178f2 | 2006-01-03 09:55:38 +0100 | [diff] [blame] | 6461 | if (status != 0) |
| 6462 | goto out; |
Trond Myklebust | e144cbc | 2012-04-28 16:05:03 -0400 | [diff] [blame] | 6463 | status = decode_getfattr(xdr, res->fattr, res->server); |
Jeff Layton | 556ae3b | 2010-03-21 12:10:36 -0400 | [diff] [blame] | 6464 | if (status != 0) |
| 6465 | goto out; |
Trond Myklebust | e144cbc | 2012-04-28 16:05:03 -0400 | [diff] [blame] | 6466 | status = decode_delegreturn(xdr); |
Trond Myklebust | fa178f2 | 2006-01-03 09:55:38 +0100 | [diff] [blame] | 6467 | out: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6468 | return status; |
| 6469 | } |
| 6470 | |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 6471 | /* |
Ricardo Labiaga | 8b17321 | 2009-12-05 16:08:39 -0500 | [diff] [blame] | 6472 | * Decode FS_LOCATIONS response |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 6473 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6474 | static int nfs4_xdr_dec_fs_locations(struct rpc_rqst *req, |
| 6475 | struct xdr_stream *xdr, |
Benny Halevy | 2295846 | 2009-04-01 09:22:02 -0400 | [diff] [blame] | 6476 | struct nfs4_fs_locations_res *res) |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 6477 | { |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 6478 | struct compound_hdr hdr; |
| 6479 | int status; |
| 6480 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6481 | status = decode_compound_hdr(xdr, &hdr); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6482 | if (status) |
| 6483 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6484 | status = decode_sequence(xdr, &res->seq_res, req); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6485 | if (status) |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 6486 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6487 | status = decode_putfh(xdr); |
| 6488 | if (status) |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 6489 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6490 | status = decode_lookup(xdr); |
| 6491 | if (status) |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 6492 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6493 | xdr_enter_page(xdr, PAGE_SIZE); |
Trond Myklebust | 8b7e3f4 | 2012-01-30 15:43:56 -0500 | [diff] [blame] | 6494 | status = decode_getfattr_generic(xdr, &res->fs_locations->fattr, |
| 6495 | NULL, res->fs_locations, |
| 6496 | res->fs_locations->server); |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 6497 | out: |
| 6498 | return status; |
| 6499 | } |
| 6500 | |
Bryan Schumaker | 5a5ea0d | 2011-03-24 17:12:29 +0000 | [diff] [blame] | 6501 | /* |
| 6502 | * Decode SECINFO response |
| 6503 | */ |
| 6504 | static int nfs4_xdr_dec_secinfo(struct rpc_rqst *rqstp, |
| 6505 | struct xdr_stream *xdr, |
| 6506 | struct nfs4_secinfo_res *res) |
| 6507 | { |
| 6508 | struct compound_hdr hdr; |
| 6509 | int status; |
| 6510 | |
| 6511 | status = decode_compound_hdr(xdr, &hdr); |
| 6512 | if (status) |
| 6513 | goto out; |
| 6514 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
| 6515 | if (status) |
| 6516 | goto out; |
| 6517 | status = decode_putfh(xdr); |
| 6518 | if (status) |
| 6519 | goto out; |
| 6520 | status = decode_secinfo(xdr, res); |
Bryan Schumaker | 5a5ea0d | 2011-03-24 17:12:29 +0000 | [diff] [blame] | 6521 | out: |
| 6522 | return status; |
| 6523 | } |
| 6524 | |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 6525 | #if defined(CONFIG_NFS_V4_1) |
| 6526 | /* |
Ricardo Labiaga | 8b17321 | 2009-12-05 16:08:39 -0500 | [diff] [blame] | 6527 | * Decode EXCHANGE_ID response |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 6528 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6529 | static int nfs4_xdr_dec_exchange_id(struct rpc_rqst *rqstp, |
| 6530 | struct xdr_stream *xdr, |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 6531 | void *res) |
| 6532 | { |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 6533 | struct compound_hdr hdr; |
| 6534 | int status; |
| 6535 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6536 | status = decode_compound_hdr(xdr, &hdr); |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 6537 | if (!status) |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6538 | status = decode_exchange_id(xdr, res); |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 6539 | return status; |
| 6540 | } |
Andy Adamson | 2050f0c | 2009-04-01 09:22:30 -0400 | [diff] [blame] | 6541 | |
| 6542 | /* |
Ricardo Labiaga | 8b17321 | 2009-12-05 16:08:39 -0500 | [diff] [blame] | 6543 | * Decode CREATE_SESSION response |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 6544 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6545 | static int nfs4_xdr_dec_create_session(struct rpc_rqst *rqstp, |
| 6546 | struct xdr_stream *xdr, |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 6547 | struct nfs41_create_session_res *res) |
| 6548 | { |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 6549 | struct compound_hdr hdr; |
| 6550 | int status; |
| 6551 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6552 | status = decode_compound_hdr(xdr, &hdr); |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 6553 | if (!status) |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6554 | status = decode_create_session(xdr, res); |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 6555 | return status; |
| 6556 | } |
| 6557 | |
| 6558 | /* |
Ricardo Labiaga | 8b17321 | 2009-12-05 16:08:39 -0500 | [diff] [blame] | 6559 | * Decode DESTROY_SESSION response |
Andy Adamson | 0f3e66c | 2009-04-01 09:22:34 -0400 | [diff] [blame] | 6560 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6561 | static int nfs4_xdr_dec_destroy_session(struct rpc_rqst *rqstp, |
| 6562 | struct xdr_stream *xdr, |
| 6563 | void *res) |
Andy Adamson | 0f3e66c | 2009-04-01 09:22:34 -0400 | [diff] [blame] | 6564 | { |
Andy Adamson | 0f3e66c | 2009-04-01 09:22:34 -0400 | [diff] [blame] | 6565 | struct compound_hdr hdr; |
| 6566 | int status; |
| 6567 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6568 | status = decode_compound_hdr(xdr, &hdr); |
Andy Adamson | 0f3e66c | 2009-04-01 09:22:34 -0400 | [diff] [blame] | 6569 | if (!status) |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6570 | status = decode_destroy_session(xdr, res); |
Andy Adamson | 0f3e66c | 2009-04-01 09:22:34 -0400 | [diff] [blame] | 6571 | return status; |
| 6572 | } |
| 6573 | |
| 6574 | /* |
Ricardo Labiaga | 8b17321 | 2009-12-05 16:08:39 -0500 | [diff] [blame] | 6575 | * Decode SEQUENCE response |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 6576 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6577 | static int nfs4_xdr_dec_sequence(struct rpc_rqst *rqstp, |
| 6578 | struct xdr_stream *xdr, |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 6579 | struct nfs4_sequence_res *res) |
| 6580 | { |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 6581 | struct compound_hdr hdr; |
| 6582 | int status; |
| 6583 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6584 | status = decode_compound_hdr(xdr, &hdr); |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 6585 | if (!status) |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6586 | status = decode_sequence(xdr, res, rqstp); |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 6587 | return status; |
| 6588 | } |
| 6589 | |
| 6590 | /* |
Ricardo Labiaga | 8b17321 | 2009-12-05 16:08:39 -0500 | [diff] [blame] | 6591 | * Decode GET_LEASE_TIME response |
Andy Adamson | 2050f0c | 2009-04-01 09:22:30 -0400 | [diff] [blame] | 6592 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6593 | static int nfs4_xdr_dec_get_lease_time(struct rpc_rqst *rqstp, |
| 6594 | struct xdr_stream *xdr, |
Andy Adamson | 2050f0c | 2009-04-01 09:22:30 -0400 | [diff] [blame] | 6595 | struct nfs4_get_lease_time_res *res) |
| 6596 | { |
Andy Adamson | 2050f0c | 2009-04-01 09:22:30 -0400 | [diff] [blame] | 6597 | struct compound_hdr hdr; |
| 6598 | int status; |
| 6599 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6600 | status = decode_compound_hdr(xdr, &hdr); |
Andy Adamson | 2050f0c | 2009-04-01 09:22:30 -0400 | [diff] [blame] | 6601 | if (!status) |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6602 | status = decode_sequence(xdr, &res->lr_seq_res, rqstp); |
Andy Adamson | 2050f0c | 2009-04-01 09:22:30 -0400 | [diff] [blame] | 6603 | if (!status) |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6604 | status = decode_putrootfh(xdr); |
Andy Adamson | 2050f0c | 2009-04-01 09:22:30 -0400 | [diff] [blame] | 6605 | if (!status) |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6606 | status = decode_fsinfo(xdr, res->lr_fsinfo); |
Andy Adamson | 2050f0c | 2009-04-01 09:22:30 -0400 | [diff] [blame] | 6607 | return status; |
| 6608 | } |
Ricardo Labiaga | 18019753 | 2009-12-05 16:08:40 -0500 | [diff] [blame] | 6609 | |
| 6610 | /* |
| 6611 | * Decode RECLAIM_COMPLETE response |
| 6612 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6613 | static int nfs4_xdr_dec_reclaim_complete(struct rpc_rqst *rqstp, |
| 6614 | struct xdr_stream *xdr, |
Ricardo Labiaga | 18019753 | 2009-12-05 16:08:40 -0500 | [diff] [blame] | 6615 | struct nfs41_reclaim_complete_res *res) |
| 6616 | { |
Ricardo Labiaga | 18019753 | 2009-12-05 16:08:40 -0500 | [diff] [blame] | 6617 | struct compound_hdr hdr; |
| 6618 | int status; |
| 6619 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6620 | status = decode_compound_hdr(xdr, &hdr); |
Ricardo Labiaga | 18019753 | 2009-12-05 16:08:40 -0500 | [diff] [blame] | 6621 | if (!status) |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6622 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
Ricardo Labiaga | 18019753 | 2009-12-05 16:08:40 -0500 | [diff] [blame] | 6623 | if (!status) |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6624 | status = decode_reclaim_complete(xdr, (void *)NULL); |
Ricardo Labiaga | 18019753 | 2009-12-05 16:08:40 -0500 | [diff] [blame] | 6625 | return status; |
| 6626 | } |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 6627 | |
| 6628 | /* |
Andy Adamson | 7f11d8d | 2011-07-30 20:52:35 -0400 | [diff] [blame] | 6629 | * Decode GETDEVICELIST response |
| 6630 | */ |
| 6631 | static int nfs4_xdr_dec_getdevicelist(struct rpc_rqst *rqstp, |
| 6632 | struct xdr_stream *xdr, |
| 6633 | struct nfs4_getdevicelist_res *res) |
| 6634 | { |
| 6635 | struct compound_hdr hdr; |
| 6636 | int status; |
| 6637 | |
| 6638 | dprintk("encoding getdevicelist!\n"); |
| 6639 | |
| 6640 | status = decode_compound_hdr(xdr, &hdr); |
| 6641 | if (status != 0) |
| 6642 | goto out; |
| 6643 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
| 6644 | if (status != 0) |
| 6645 | goto out; |
| 6646 | status = decode_putfh(xdr); |
| 6647 | if (status != 0) |
| 6648 | goto out; |
| 6649 | status = decode_getdevicelist(xdr, res->devlist); |
| 6650 | out: |
| 6651 | return status; |
| 6652 | } |
| 6653 | |
| 6654 | /* |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 6655 | * Decode GETDEVINFO response |
| 6656 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6657 | static int nfs4_xdr_dec_getdeviceinfo(struct rpc_rqst *rqstp, |
| 6658 | struct xdr_stream *xdr, |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 6659 | struct nfs4_getdeviceinfo_res *res) |
| 6660 | { |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 6661 | struct compound_hdr hdr; |
| 6662 | int status; |
| 6663 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6664 | status = decode_compound_hdr(xdr, &hdr); |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 6665 | if (status != 0) |
| 6666 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6667 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 6668 | if (status != 0) |
| 6669 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6670 | status = decode_getdeviceinfo(xdr, res->pdev); |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 6671 | out: |
| 6672 | return status; |
| 6673 | } |
| 6674 | |
| 6675 | /* |
| 6676 | * Decode LAYOUTGET response |
| 6677 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6678 | static int nfs4_xdr_dec_layoutget(struct rpc_rqst *rqstp, |
| 6679 | struct xdr_stream *xdr, |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 6680 | struct nfs4_layoutget_res *res) |
| 6681 | { |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 6682 | struct compound_hdr hdr; |
| 6683 | int status; |
| 6684 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6685 | status = decode_compound_hdr(xdr, &hdr); |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 6686 | if (status) |
| 6687 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6688 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 6689 | if (status) |
| 6690 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6691 | status = decode_putfh(xdr); |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 6692 | if (status) |
| 6693 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6694 | status = decode_layoutget(xdr, rqstp, res); |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 6695 | out: |
| 6696 | return status; |
| 6697 | } |
Andy Adamson | 863a3c6 | 2011-03-23 13:27:54 +0000 | [diff] [blame] | 6698 | |
| 6699 | /* |
Benny Halevy | cbe8260 | 2011-05-22 19:52:37 +0300 | [diff] [blame] | 6700 | * Decode LAYOUTRETURN response |
| 6701 | */ |
| 6702 | static int nfs4_xdr_dec_layoutreturn(struct rpc_rqst *rqstp, |
| 6703 | struct xdr_stream *xdr, |
| 6704 | struct nfs4_layoutreturn_res *res) |
| 6705 | { |
| 6706 | struct compound_hdr hdr; |
| 6707 | int status; |
| 6708 | |
| 6709 | status = decode_compound_hdr(xdr, &hdr); |
| 6710 | if (status) |
| 6711 | goto out; |
| 6712 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
| 6713 | if (status) |
| 6714 | goto out; |
| 6715 | status = decode_putfh(xdr); |
| 6716 | if (status) |
| 6717 | goto out; |
| 6718 | status = decode_layoutreturn(xdr, res); |
| 6719 | out: |
| 6720 | return status; |
| 6721 | } |
| 6722 | |
| 6723 | /* |
Andy Adamson | 863a3c6 | 2011-03-23 13:27:54 +0000 | [diff] [blame] | 6724 | * Decode LAYOUTCOMMIT response |
| 6725 | */ |
| 6726 | static int nfs4_xdr_dec_layoutcommit(struct rpc_rqst *rqstp, |
| 6727 | struct xdr_stream *xdr, |
| 6728 | struct nfs4_layoutcommit_res *res) |
| 6729 | { |
| 6730 | struct compound_hdr hdr; |
| 6731 | int status; |
| 6732 | |
| 6733 | status = decode_compound_hdr(xdr, &hdr); |
| 6734 | if (status) |
| 6735 | goto out; |
| 6736 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
| 6737 | if (status) |
| 6738 | goto out; |
| 6739 | status = decode_putfh(xdr); |
| 6740 | if (status) |
| 6741 | goto out; |
| 6742 | status = decode_layoutcommit(xdr, rqstp, res); |
| 6743 | if (status) |
| 6744 | goto out; |
Trond Myklebust | 6926afd | 2012-01-07 13:22:46 -0500 | [diff] [blame] | 6745 | decode_getfattr(xdr, res->fattr, res->server); |
Andy Adamson | 863a3c6 | 2011-03-23 13:27:54 +0000 | [diff] [blame] | 6746 | out: |
| 6747 | return status; |
| 6748 | } |
Bryan Schumaker | fca78d6 | 2011-06-02 14:59:07 -0400 | [diff] [blame] | 6749 | |
| 6750 | /* |
| 6751 | * Decode SECINFO_NO_NAME response |
| 6752 | */ |
| 6753 | static int nfs4_xdr_dec_secinfo_no_name(struct rpc_rqst *rqstp, |
| 6754 | struct xdr_stream *xdr, |
| 6755 | struct nfs4_secinfo_res *res) |
| 6756 | { |
| 6757 | struct compound_hdr hdr; |
| 6758 | int status; |
| 6759 | |
| 6760 | status = decode_compound_hdr(xdr, &hdr); |
| 6761 | if (status) |
| 6762 | goto out; |
| 6763 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
| 6764 | if (status) |
| 6765 | goto out; |
| 6766 | status = decode_putrootfh(xdr); |
| 6767 | if (status) |
| 6768 | goto out; |
Bryan Schumaker | 31e4dda | 2012-04-27 13:27:38 -0400 | [diff] [blame] | 6769 | status = decode_secinfo_no_name(xdr, res); |
Bryan Schumaker | fca78d6 | 2011-06-02 14:59:07 -0400 | [diff] [blame] | 6770 | out: |
| 6771 | return status; |
| 6772 | } |
Bryan Schumaker | 7d97479 | 2011-06-02 14:59:08 -0400 | [diff] [blame] | 6773 | |
| 6774 | /* |
| 6775 | * Decode TEST_STATEID response |
| 6776 | */ |
| 6777 | static int nfs4_xdr_dec_test_stateid(struct rpc_rqst *rqstp, |
| 6778 | struct xdr_stream *xdr, |
| 6779 | struct nfs41_test_stateid_res *res) |
| 6780 | { |
| 6781 | struct compound_hdr hdr; |
| 6782 | int status; |
| 6783 | |
| 6784 | status = decode_compound_hdr(xdr, &hdr); |
| 6785 | if (status) |
| 6786 | goto out; |
| 6787 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
| 6788 | if (status) |
| 6789 | goto out; |
| 6790 | status = decode_test_stateid(xdr, res); |
| 6791 | out: |
| 6792 | return status; |
| 6793 | } |
Bryan Schumaker | 9aeda35 | 2011-06-02 14:59:09 -0400 | [diff] [blame] | 6794 | |
| 6795 | /* |
| 6796 | * Decode FREE_STATEID response |
| 6797 | */ |
| 6798 | static int nfs4_xdr_dec_free_stateid(struct rpc_rqst *rqstp, |
| 6799 | struct xdr_stream *xdr, |
| 6800 | struct nfs41_free_stateid_res *res) |
| 6801 | { |
| 6802 | struct compound_hdr hdr; |
| 6803 | int status; |
| 6804 | |
| 6805 | status = decode_compound_hdr(xdr, &hdr); |
| 6806 | if (status) |
| 6807 | goto out; |
| 6808 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
| 6809 | if (status) |
| 6810 | goto out; |
| 6811 | status = decode_free_stateid(xdr, res); |
| 6812 | out: |
| 6813 | return status; |
| 6814 | } |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 6815 | #endif /* CONFIG_NFS_V4_1 */ |
| 6816 | |
Chuck Lever | 573c4e1 | 2010-12-14 14:58:11 +0000 | [diff] [blame] | 6817 | /** |
| 6818 | * nfs4_decode_dirent - Decode a single NFSv4 directory entry stored in |
| 6819 | * the local page cache. |
| 6820 | * @xdr: XDR stream where entry resides |
| 6821 | * @entry: buffer to fill in with entry data |
| 6822 | * @plus: boolean indicating whether this should be a readdirplus entry |
| 6823 | * |
| 6824 | * Returns zero if successful, otherwise a negative errno value is |
| 6825 | * returned. |
| 6826 | * |
| 6827 | * This function is not invoked during READDIR reply decoding, but |
| 6828 | * rather whenever an application invokes the getdents(2) system call |
| 6829 | * on a directory already in our cache. |
| 6830 | */ |
| 6831 | int nfs4_decode_dirent(struct xdr_stream *xdr, struct nfs_entry *entry, |
| 6832 | int plus) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6833 | { |
Fred Isaman | dae100c | 2011-07-30 20:52:37 -0400 | [diff] [blame] | 6834 | uint32_t bitmap[3] = {0}; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6835 | uint32_t len; |
Bryan Schumaker | babddc7 | 2010-10-20 15:44:29 -0400 | [diff] [blame] | 6836 | __be32 *p = xdr_inline_decode(xdr, 4); |
| 6837 | if (unlikely(!p)) |
| 6838 | goto out_overflow; |
Chuck Lever | c08e76d | 2011-01-28 12:40:55 -0500 | [diff] [blame] | 6839 | if (*p == xdr_zero) { |
Bryan Schumaker | babddc7 | 2010-10-20 15:44:29 -0400 | [diff] [blame] | 6840 | p = xdr_inline_decode(xdr, 4); |
| 6841 | if (unlikely(!p)) |
| 6842 | goto out_overflow; |
Chuck Lever | c08e76d | 2011-01-28 12:40:55 -0500 | [diff] [blame] | 6843 | if (*p == xdr_zero) |
Chuck Lever | 573c4e1 | 2010-12-14 14:58:11 +0000 | [diff] [blame] | 6844 | return -EAGAIN; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6845 | entry->eof = 1; |
Chuck Lever | 573c4e1 | 2010-12-14 14:58:11 +0000 | [diff] [blame] | 6846 | return -EBADCOOKIE; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6847 | } |
| 6848 | |
Bryan Schumaker | babddc7 | 2010-10-20 15:44:29 -0400 | [diff] [blame] | 6849 | p = xdr_inline_decode(xdr, 12); |
| 6850 | if (unlikely(!p)) |
| 6851 | goto out_overflow; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6852 | entry->prev_cookie = entry->cookie; |
| 6853 | p = xdr_decode_hyper(p, &entry->cookie); |
Chuck Lever | c08e76d | 2011-01-28 12:40:55 -0500 | [diff] [blame] | 6854 | entry->len = be32_to_cpup(p); |
Bryan Schumaker | babddc7 | 2010-10-20 15:44:29 -0400 | [diff] [blame] | 6855 | |
Trond Myklebust | 9af8c22 | 2010-10-24 11:52:55 -0400 | [diff] [blame] | 6856 | p = xdr_inline_decode(xdr, entry->len); |
Bryan Schumaker | babddc7 | 2010-10-20 15:44:29 -0400 | [diff] [blame] | 6857 | if (unlikely(!p)) |
| 6858 | goto out_overflow; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6859 | entry->name = (const char *) p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6860 | |
| 6861 | /* |
| 6862 | * In case the server doesn't return an inode number, |
| 6863 | * we fake one here. (We don't use inode number 0, |
| 6864 | * since glibc seems to choke on it...) |
| 6865 | */ |
| 6866 | entry->ino = 1; |
Trond Myklebust | 4f08222 | 2010-10-24 13:14:02 -0400 | [diff] [blame] | 6867 | entry->fattr->valid = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6868 | |
Trond Myklebust | 9af8c22 | 2010-10-24 11:52:55 -0400 | [diff] [blame] | 6869 | if (decode_attr_bitmap(xdr, bitmap) < 0) |
Bryan Schumaker | babddc7 | 2010-10-20 15:44:29 -0400 | [diff] [blame] | 6870 | goto out_overflow; |
Trond Myklebust | 9af8c22 | 2010-10-24 11:52:55 -0400 | [diff] [blame] | 6871 | |
| 6872 | if (decode_attr_length(xdr, &len, &p) < 0) |
| 6873 | goto out_overflow; |
| 6874 | |
Chuck Lever | 573c4e1 | 2010-12-14 14:58:11 +0000 | [diff] [blame] | 6875 | if (decode_getfattr_attrs(xdr, bitmap, entry->fattr, entry->fh, |
Trond Myklebust | 8b7e3f4 | 2012-01-30 15:43:56 -0500 | [diff] [blame] | 6876 | NULL, entry->server) < 0) |
Trond Myklebust | 9af8c22 | 2010-10-24 11:52:55 -0400 | [diff] [blame] | 6877 | goto out_overflow; |
Trond Myklebust | 28331a4 | 2011-04-27 13:47:52 -0400 | [diff] [blame] | 6878 | if (entry->fattr->valid & NFS_ATTR_FATTR_MOUNTED_ON_FILEID) |
| 6879 | entry->ino = entry->fattr->mounted_on_fileid; |
| 6880 | else if (entry->fattr->valid & NFS_ATTR_FATTR_FILEID) |
Trond Myklebust | 9af8c22 | 2010-10-24 11:52:55 -0400 | [diff] [blame] | 6881 | entry->ino = entry->fattr->fileid; |
| 6882 | |
Trond Myklebust | 0b26a0b | 2010-11-20 14:26:44 -0500 | [diff] [blame] | 6883 | entry->d_type = DT_UNKNOWN; |
| 6884 | if (entry->fattr->valid & NFS_ATTR_FATTR_TYPE) |
| 6885 | entry->d_type = nfs_umode_to_dtype(entry->fattr->mode); |
| 6886 | |
Chuck Lever | 573c4e1 | 2010-12-14 14:58:11 +0000 | [diff] [blame] | 6887 | return 0; |
Bryan Schumaker | babddc7 | 2010-10-20 15:44:29 -0400 | [diff] [blame] | 6888 | |
| 6889 | out_overflow: |
| 6890 | print_overflow_msg(__func__, xdr); |
Chuck Lever | 573c4e1 | 2010-12-14 14:58:11 +0000 | [diff] [blame] | 6891 | return -EAGAIN; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6892 | } |
| 6893 | |
| 6894 | /* |
| 6895 | * We need to translate between nfs status return values and |
| 6896 | * the local errno values which may not be the same. |
| 6897 | */ |
| 6898 | static struct { |
| 6899 | int stat; |
| 6900 | int errno; |
| 6901 | } nfs_errtbl[] = { |
| 6902 | { NFS4_OK, 0 }, |
Benny Halevy | 856dff3 | 2008-03-31 17:39:06 +0300 | [diff] [blame] | 6903 | { NFS4ERR_PERM, -EPERM }, |
| 6904 | { NFS4ERR_NOENT, -ENOENT }, |
| 6905 | { NFS4ERR_IO, -errno_NFSERR_IO}, |
| 6906 | { NFS4ERR_NXIO, -ENXIO }, |
| 6907 | { NFS4ERR_ACCESS, -EACCES }, |
| 6908 | { NFS4ERR_EXIST, -EEXIST }, |
| 6909 | { NFS4ERR_XDEV, -EXDEV }, |
| 6910 | { NFS4ERR_NOTDIR, -ENOTDIR }, |
| 6911 | { NFS4ERR_ISDIR, -EISDIR }, |
| 6912 | { NFS4ERR_INVAL, -EINVAL }, |
| 6913 | { NFS4ERR_FBIG, -EFBIG }, |
| 6914 | { NFS4ERR_NOSPC, -ENOSPC }, |
| 6915 | { NFS4ERR_ROFS, -EROFS }, |
| 6916 | { NFS4ERR_MLINK, -EMLINK }, |
| 6917 | { NFS4ERR_NAMETOOLONG, -ENAMETOOLONG }, |
| 6918 | { NFS4ERR_NOTEMPTY, -ENOTEMPTY }, |
| 6919 | { NFS4ERR_DQUOT, -EDQUOT }, |
| 6920 | { NFS4ERR_STALE, -ESTALE }, |
| 6921 | { NFS4ERR_BADHANDLE, -EBADHANDLE }, |
Benny Halevy | 856dff3 | 2008-03-31 17:39:06 +0300 | [diff] [blame] | 6922 | { NFS4ERR_BAD_COOKIE, -EBADCOOKIE }, |
| 6923 | { NFS4ERR_NOTSUPP, -ENOTSUPP }, |
| 6924 | { NFS4ERR_TOOSMALL, -ETOOSMALL }, |
Trond Myklebust | fdcb457 | 2010-02-08 09:32:40 -0500 | [diff] [blame] | 6925 | { NFS4ERR_SERVERFAULT, -EREMOTEIO }, |
Benny Halevy | 856dff3 | 2008-03-31 17:39:06 +0300 | [diff] [blame] | 6926 | { NFS4ERR_BADTYPE, -EBADTYPE }, |
| 6927 | { NFS4ERR_LOCKED, -EAGAIN }, |
Benny Halevy | 856dff3 | 2008-03-31 17:39:06 +0300 | [diff] [blame] | 6928 | { NFS4ERR_SYMLINK, -ELOOP }, |
| 6929 | { NFS4ERR_OP_ILLEGAL, -EOPNOTSUPP }, |
| 6930 | { NFS4ERR_DEADLOCK, -EDEADLK }, |
Benny Halevy | 856dff3 | 2008-03-31 17:39:06 +0300 | [diff] [blame] | 6931 | { -1, -EIO } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6932 | }; |
| 6933 | |
| 6934 | /* |
| 6935 | * Convert an NFS error code to a local one. |
| 6936 | * This one is used jointly by NFSv2 and NFSv3. |
| 6937 | */ |
| 6938 | static int |
David Howells | 0a8ea43 | 2006-08-22 20:06:08 -0400 | [diff] [blame] | 6939 | nfs4_stat_to_errno(int stat) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6940 | { |
| 6941 | int i; |
| 6942 | for (i = 0; nfs_errtbl[i].stat != -1; i++) { |
| 6943 | if (nfs_errtbl[i].stat == stat) |
| 6944 | return nfs_errtbl[i].errno; |
| 6945 | } |
| 6946 | if (stat <= 10000 || stat > 10100) { |
| 6947 | /* The server is looney tunes. */ |
Trond Myklebust | fdcb457 | 2010-02-08 09:32:40 -0500 | [diff] [blame] | 6948 | return -EREMOTEIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6949 | } |
| 6950 | /* If we cannot translate the error, the recovery routines should |
| 6951 | * handle it. |
| 6952 | * Note: remaining NFSv4 error codes have values > 10000, so should |
| 6953 | * not conflict with native Linux error codes. |
| 6954 | */ |
Benny Halevy | 856dff3 | 2008-03-31 17:39:06 +0300 | [diff] [blame] | 6955 | return -stat; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6956 | } |
| 6957 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6958 | #define PROC(proc, argtype, restype) \ |
| 6959 | [NFSPROC4_CLNT_##proc] = { \ |
| 6960 | .p_proc = NFSPROC4_COMPOUND, \ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 6961 | .p_encode = (kxdreproc_t)nfs4_xdr_##argtype, \ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6962 | .p_decode = (kxdrdproc_t)nfs4_xdr_##restype, \ |
Chuck Lever | 2bea90d | 2007-03-29 16:47:53 -0400 | [diff] [blame] | 6963 | .p_arglen = NFS4_##argtype##_sz, \ |
| 6964 | .p_replen = NFS4_##restype##_sz, \ |
Chuck Lever | cc0175c | 2006-03-20 13:44:22 -0500 | [diff] [blame] | 6965 | .p_statidx = NFSPROC4_CLNT_##proc, \ |
| 6966 | .p_name = #proc, \ |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6967 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6968 | |
| 6969 | struct rpc_procinfo nfs4_procedures[] = { |
Chuck Lever | 7d93bd71 | 2010-12-14 14:57:42 +0000 | [diff] [blame] | 6970 | PROC(READ, enc_read, dec_read), |
| 6971 | PROC(WRITE, enc_write, dec_write), |
| 6972 | PROC(COMMIT, enc_commit, dec_commit), |
| 6973 | PROC(OPEN, enc_open, dec_open), |
| 6974 | PROC(OPEN_CONFIRM, enc_open_confirm, dec_open_confirm), |
| 6975 | PROC(OPEN_NOATTR, enc_open_noattr, dec_open_noattr), |
| 6976 | PROC(OPEN_DOWNGRADE, enc_open_downgrade, dec_open_downgrade), |
| 6977 | PROC(CLOSE, enc_close, dec_close), |
| 6978 | PROC(SETATTR, enc_setattr, dec_setattr), |
| 6979 | PROC(FSINFO, enc_fsinfo, dec_fsinfo), |
| 6980 | PROC(RENEW, enc_renew, dec_renew), |
| 6981 | PROC(SETCLIENTID, enc_setclientid, dec_setclientid), |
| 6982 | PROC(SETCLIENTID_CONFIRM, enc_setclientid_confirm, dec_setclientid_confirm), |
| 6983 | PROC(LOCK, enc_lock, dec_lock), |
| 6984 | PROC(LOCKT, enc_lockt, dec_lockt), |
| 6985 | PROC(LOCKU, enc_locku, dec_locku), |
| 6986 | PROC(ACCESS, enc_access, dec_access), |
| 6987 | PROC(GETATTR, enc_getattr, dec_getattr), |
| 6988 | PROC(LOOKUP, enc_lookup, dec_lookup), |
| 6989 | PROC(LOOKUP_ROOT, enc_lookup_root, dec_lookup_root), |
| 6990 | PROC(REMOVE, enc_remove, dec_remove), |
| 6991 | PROC(RENAME, enc_rename, dec_rename), |
| 6992 | PROC(LINK, enc_link, dec_link), |
| 6993 | PROC(SYMLINK, enc_symlink, dec_symlink), |
| 6994 | PROC(CREATE, enc_create, dec_create), |
| 6995 | PROC(PATHCONF, enc_pathconf, dec_pathconf), |
| 6996 | PROC(STATFS, enc_statfs, dec_statfs), |
| 6997 | PROC(READLINK, enc_readlink, dec_readlink), |
| 6998 | PROC(READDIR, enc_readdir, dec_readdir), |
| 6999 | PROC(SERVER_CAPS, enc_server_caps, dec_server_caps), |
| 7000 | PROC(DELEGRETURN, enc_delegreturn, dec_delegreturn), |
| 7001 | PROC(GETACL, enc_getacl, dec_getacl), |
| 7002 | PROC(SETACL, enc_setacl, dec_setacl), |
| 7003 | PROC(FS_LOCATIONS, enc_fs_locations, dec_fs_locations), |
| 7004 | PROC(RELEASE_LOCKOWNER, enc_release_lockowner, dec_release_lockowner), |
Bryan Schumaker | 5a5ea0d | 2011-03-24 17:12:29 +0000 | [diff] [blame] | 7005 | PROC(SECINFO, enc_secinfo, dec_secinfo), |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 7006 | #if defined(CONFIG_NFS_V4_1) |
Chuck Lever | 7d93bd71 | 2010-12-14 14:57:42 +0000 | [diff] [blame] | 7007 | PROC(EXCHANGE_ID, enc_exchange_id, dec_exchange_id), |
| 7008 | PROC(CREATE_SESSION, enc_create_session, dec_create_session), |
| 7009 | PROC(DESTROY_SESSION, enc_destroy_session, dec_destroy_session), |
| 7010 | PROC(SEQUENCE, enc_sequence, dec_sequence), |
| 7011 | PROC(GET_LEASE_TIME, enc_get_lease_time, dec_get_lease_time), |
| 7012 | PROC(RECLAIM_COMPLETE, enc_reclaim_complete, dec_reclaim_complete), |
| 7013 | PROC(GETDEVICEINFO, enc_getdeviceinfo, dec_getdeviceinfo), |
| 7014 | PROC(LAYOUTGET, enc_layoutget, dec_layoutget), |
Andy Adamson | 863a3c6 | 2011-03-23 13:27:54 +0000 | [diff] [blame] | 7015 | PROC(LAYOUTCOMMIT, enc_layoutcommit, dec_layoutcommit), |
Benny Halevy | cbe8260 | 2011-05-22 19:52:37 +0300 | [diff] [blame] | 7016 | PROC(LAYOUTRETURN, enc_layoutreturn, dec_layoutreturn), |
Bryan Schumaker | fca78d6 | 2011-06-02 14:59:07 -0400 | [diff] [blame] | 7017 | PROC(SECINFO_NO_NAME, enc_secinfo_no_name, dec_secinfo_no_name), |
Bryan Schumaker | 7d97479 | 2011-06-02 14:59:08 -0400 | [diff] [blame] | 7018 | PROC(TEST_STATEID, enc_test_stateid, dec_test_stateid), |
Bryan Schumaker | 9aeda35 | 2011-06-02 14:59:09 -0400 | [diff] [blame] | 7019 | PROC(FREE_STATEID, enc_free_stateid, dec_free_stateid), |
Andy Adamson | 7f11d8d | 2011-07-30 20:52:35 -0400 | [diff] [blame] | 7020 | PROC(GETDEVICELIST, enc_getdevicelist, dec_getdevicelist), |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 7021 | #endif /* CONFIG_NFS_V4_1 */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7022 | }; |
| 7023 | |
Trond Myklebust | a613fa1 | 2012-01-20 13:53:56 -0500 | [diff] [blame] | 7024 | const struct rpc_version nfs_version4 = { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7025 | .number = 4, |
Tobias Klauser | e8c96f8 | 2006-03-24 03:15:34 -0800 | [diff] [blame] | 7026 | .nrprocs = ARRAY_SIZE(nfs4_procedures), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7027 | .procs = nfs4_procedures |
| 7028 | }; |
| 7029 | |
| 7030 | /* |
| 7031 | * Local variables: |
| 7032 | * c-basic-offset: 8 |
| 7033 | * End: |
| 7034 | */ |