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> |
Trond Myklebust | 4ce7971 | 2005-06-22 17:16:21 +0000 | [diff] [blame] | 56 | #include "nfs4_fs.h" |
Alexandros Batsakis | 4882ef7 | 2009-12-05 13:30:21 -0500 | [diff] [blame] | 57 | #include "internal.h" |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 58 | #include "pnfs.h" |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 59 | |
| 60 | #define NFSDBG_FACILITY NFSDBG_XDR |
| 61 | |
| 62 | /* Mapping from NFS error code to "errno" error code. */ |
| 63 | #define errno_NFSERR_IO EIO |
| 64 | |
David Howells | 0a8ea43 | 2006-08-22 20:06:08 -0400 | [diff] [blame] | 65 | static int nfs4_stat_to_errno(int); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 66 | |
| 67 | /* NFSv4 COMPOUND tags are only wanted for debugging purposes */ |
| 68 | #ifdef DEBUG |
| 69 | #define NFS4_MAXTAGLEN 20 |
| 70 | #else |
| 71 | #define NFS4_MAXTAGLEN 0 |
| 72 | #endif |
| 73 | |
Andy Adamson | 6c0195a | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 74 | /* lock,open owner id: |
Trond Myklebust | 9f958ab | 2007-07-02 13:58:33 -0400 | [diff] [blame] | 75 | * we currently use size 2 (u64) out of (NFS4_OPAQUE_LIMIT >> 2) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 76 | */ |
Trond Myklebust | d035c36 | 2010-12-21 10:45:27 -0500 | [diff] [blame] | 77 | #define open_owner_id_maxsz (1 + 1 + 4) |
| 78 | #define lock_owner_id_maxsz (1 + 1 + 4) |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 79 | #define decode_lockowner_maxsz (1 + XDR_QUADLEN(IDMAP_NAMESZ)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 80 | #define compound_encode_hdr_maxsz (3 + (NFS4_MAXTAGLEN >> 2)) |
| 81 | #define compound_decode_hdr_maxsz (3 + (NFS4_MAXTAGLEN >> 2)) |
| 82 | #define op_encode_hdr_maxsz (1) |
| 83 | #define op_decode_hdr_maxsz (2) |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 84 | #define encode_stateid_maxsz (XDR_QUADLEN(NFS4_STATEID_SIZE)) |
| 85 | #define decode_stateid_maxsz (XDR_QUADLEN(NFS4_STATEID_SIZE)) |
| 86 | #define encode_verifier_maxsz (XDR_QUADLEN(NFS4_VERIFIER_SIZE)) |
| 87 | #define decode_verifier_maxsz (XDR_QUADLEN(NFS4_VERIFIER_SIZE)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 88 | #define encode_putfh_maxsz (op_encode_hdr_maxsz + 1 + \ |
| 89 | (NFS4_FHSIZE >> 2)) |
| 90 | #define decode_putfh_maxsz (op_decode_hdr_maxsz) |
| 91 | #define encode_putrootfh_maxsz (op_encode_hdr_maxsz) |
| 92 | #define decode_putrootfh_maxsz (op_decode_hdr_maxsz) |
| 93 | #define encode_getfh_maxsz (op_encode_hdr_maxsz) |
| 94 | #define decode_getfh_maxsz (op_decode_hdr_maxsz + 1 + \ |
| 95 | ((3+NFS4_FHSIZE) >> 2)) |
Andy Adamson | e5012d1 | 2011-07-11 17:17:42 -0400 | [diff] [blame] | 96 | #define nfs4_fattr_bitmap_maxsz 4 |
J. Bruce Fields | 9692820 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 97 | #define encode_getattr_maxsz (op_encode_hdr_maxsz + nfs4_fattr_bitmap_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 98 | #define nfs4_name_maxsz (1 + ((3 + NFS4_MAXNAMLEN) >> 2)) |
| 99 | #define nfs4_path_maxsz (1 + ((3 + NFS4_MAXPATHLEN) >> 2)) |
Trond Myklebust | bd625ba | 2007-07-08 18:38:23 -0400 | [diff] [blame] | 100 | #define nfs4_owner_maxsz (1 + XDR_QUADLEN(IDMAP_NAMESZ)) |
| 101 | #define nfs4_group_maxsz (1 + XDR_QUADLEN(IDMAP_NAMESZ)) |
J. Bruce Fields | 9692820 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 102 | /* This is based on getfattr, which uses the most attributes: */ |
| 103 | #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] | 104 | 3 + 3 + 3 + nfs4_owner_maxsz + nfs4_group_maxsz)) |
J. Bruce Fields | 9692820 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 105 | #define nfs4_fattr_maxsz (nfs4_fattr_bitmap_maxsz + \ |
| 106 | nfs4_fattr_value_maxsz) |
| 107 | #define decode_getattr_maxsz (op_decode_hdr_maxsz + nfs4_fattr_maxsz) |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 108 | #define encode_attrs_maxsz (nfs4_fattr_bitmap_maxsz + \ |
| 109 | 1 + 2 + 1 + \ |
| 110 | nfs4_owner_maxsz + \ |
| 111 | nfs4_group_maxsz + \ |
| 112 | 4 + 4) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 113 | #define encode_savefh_maxsz (op_encode_hdr_maxsz) |
| 114 | #define decode_savefh_maxsz (op_decode_hdr_maxsz) |
Trond Myklebust | 56ae19f | 2005-10-27 22:12:40 -0400 | [diff] [blame] | 115 | #define encode_restorefh_maxsz (op_encode_hdr_maxsz) |
| 116 | #define decode_restorefh_maxsz (op_decode_hdr_maxsz) |
Fred Isaman | 2f42b5d | 2008-03-13 15:26:30 +0200 | [diff] [blame] | 117 | #define encode_fsinfo_maxsz (encode_getattr_maxsz) |
Fred Isaman | dae100c | 2011-07-30 20:52:37 -0400 | [diff] [blame] | 118 | /* The 5 accounts for the PNFS attributes, and assumes that at most three |
| 119 | * layout types will be returned. |
| 120 | */ |
| 121 | #define decode_fsinfo_maxsz (op_decode_hdr_maxsz + \ |
| 122 | nfs4_fattr_bitmap_maxsz + 4 + 8 + 5) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 123 | #define encode_renew_maxsz (op_encode_hdr_maxsz + 3) |
| 124 | #define decode_renew_maxsz (op_decode_hdr_maxsz) |
| 125 | #define encode_setclientid_maxsz \ |
| 126 | (op_encode_hdr_maxsz + \ |
Chuck Lever | cc38bac | 2007-12-10 14:56:54 -0500 | [diff] [blame] | 127 | XDR_QUADLEN(NFS4_VERIFIER_SIZE) + \ |
| 128 | XDR_QUADLEN(NFS4_SETCLIENTID_NAMELEN) + \ |
| 129 | 1 /* sc_prog */ + \ |
| 130 | XDR_QUADLEN(RPCBIND_MAXNETIDLEN) + \ |
| 131 | XDR_QUADLEN(RPCBIND_MAXUADDRLEN) + \ |
| 132 | 1) /* sc_cb_ident */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 133 | #define decode_setclientid_maxsz \ |
| 134 | (op_decode_hdr_maxsz + \ |
| 135 | 2 + \ |
| 136 | 1024) /* large value for CLID_INUSE */ |
| 137 | #define encode_setclientid_confirm_maxsz \ |
| 138 | (op_encode_hdr_maxsz + \ |
| 139 | 3 + (NFS4_VERIFIER_SIZE >> 2)) |
| 140 | #define decode_setclientid_confirm_maxsz \ |
| 141 | (op_decode_hdr_maxsz) |
Trond Myklebust | e688962 | 2007-07-02 13:58:30 -0400 | [diff] [blame] | 142 | #define encode_lookup_maxsz (op_encode_hdr_maxsz + nfs4_name_maxsz) |
| 143 | #define decode_lookup_maxsz (op_decode_hdr_maxsz) |
Trond Myklebust | 2cebf82 | 2007-07-02 13:57:28 -0400 | [diff] [blame] | 144 | #define encode_share_access_maxsz \ |
| 145 | (2) |
Alexandros Batsakis | 4882ef7 | 2009-12-05 13:30:21 -0500 | [diff] [blame] | 146 | #define encode_createmode_maxsz (1 + encode_attrs_maxsz + encode_verifier_maxsz) |
Trond Myklebust | 2cebf82 | 2007-07-02 13:57:28 -0400 | [diff] [blame] | 147 | #define encode_opentype_maxsz (1 + encode_createmode_maxsz) |
| 148 | #define encode_claim_null_maxsz (1 + nfs4_name_maxsz) |
| 149 | #define encode_open_maxsz (op_encode_hdr_maxsz + \ |
| 150 | 2 + encode_share_access_maxsz + 2 + \ |
| 151 | open_owner_id_maxsz + \ |
| 152 | encode_opentype_maxsz + \ |
| 153 | encode_claim_null_maxsz) |
| 154 | #define decode_ace_maxsz (3 + nfs4_owner_maxsz) |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 155 | #define decode_delegation_maxsz (1 + decode_stateid_maxsz + 1 + \ |
Trond Myklebust | 2cebf82 | 2007-07-02 13:57:28 -0400 | [diff] [blame] | 156 | decode_ace_maxsz) |
| 157 | #define decode_change_info_maxsz (5) |
| 158 | #define decode_open_maxsz (op_decode_hdr_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 159 | decode_stateid_maxsz + \ |
Trond Myklebust | 2cebf82 | 2007-07-02 13:57:28 -0400 | [diff] [blame] | 160 | decode_change_info_maxsz + 1 + \ |
| 161 | nfs4_fattr_bitmap_maxsz + \ |
| 162 | decode_delegation_maxsz) |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 163 | #define encode_open_confirm_maxsz \ |
| 164 | (op_encode_hdr_maxsz + \ |
| 165 | encode_stateid_maxsz + 1) |
| 166 | #define decode_open_confirm_maxsz \ |
| 167 | (op_decode_hdr_maxsz + \ |
| 168 | decode_stateid_maxsz) |
| 169 | #define encode_open_downgrade_maxsz \ |
| 170 | (op_encode_hdr_maxsz + \ |
| 171 | encode_stateid_maxsz + 1 + \ |
| 172 | encode_share_access_maxsz) |
| 173 | #define decode_open_downgrade_maxsz \ |
| 174 | (op_decode_hdr_maxsz + \ |
| 175 | decode_stateid_maxsz) |
| 176 | #define encode_close_maxsz (op_encode_hdr_maxsz + \ |
| 177 | 1 + encode_stateid_maxsz) |
| 178 | #define decode_close_maxsz (op_decode_hdr_maxsz + \ |
| 179 | decode_stateid_maxsz) |
| 180 | #define encode_setattr_maxsz (op_encode_hdr_maxsz + \ |
| 181 | encode_stateid_maxsz + \ |
| 182 | encode_attrs_maxsz) |
| 183 | #define decode_setattr_maxsz (op_decode_hdr_maxsz + \ |
| 184 | nfs4_fattr_bitmap_maxsz) |
| 185 | #define encode_read_maxsz (op_encode_hdr_maxsz + \ |
| 186 | encode_stateid_maxsz + 3) |
| 187 | #define decode_read_maxsz (op_decode_hdr_maxsz + 2) |
| 188 | #define encode_readdir_maxsz (op_encode_hdr_maxsz + \ |
| 189 | 2 + encode_verifier_maxsz + 5) |
| 190 | #define decode_readdir_maxsz (op_decode_hdr_maxsz + \ |
| 191 | decode_verifier_maxsz) |
| 192 | #define encode_readlink_maxsz (op_encode_hdr_maxsz) |
| 193 | #define decode_readlink_maxsz (op_decode_hdr_maxsz + 1) |
| 194 | #define encode_write_maxsz (op_encode_hdr_maxsz + \ |
| 195 | encode_stateid_maxsz + 4) |
| 196 | #define decode_write_maxsz (op_decode_hdr_maxsz + \ |
| 197 | 2 + decode_verifier_maxsz) |
| 198 | #define encode_commit_maxsz (op_encode_hdr_maxsz + 3) |
| 199 | #define decode_commit_maxsz (op_decode_hdr_maxsz + \ |
| 200 | decode_verifier_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 201 | #define encode_remove_maxsz (op_encode_hdr_maxsz + \ |
| 202 | nfs4_name_maxsz) |
Benny Halevy | 6ce1839 | 2009-04-01 09:22:06 -0400 | [diff] [blame] | 203 | #define decode_remove_maxsz (op_decode_hdr_maxsz + \ |
| 204 | decode_change_info_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 205 | #define encode_rename_maxsz (op_encode_hdr_maxsz + \ |
| 206 | 2 * nfs4_name_maxsz) |
Benny Halevy | 6ce1839 | 2009-04-01 09:22:06 -0400 | [diff] [blame] | 207 | #define decode_rename_maxsz (op_decode_hdr_maxsz + \ |
| 208 | decode_change_info_maxsz + \ |
| 209 | decode_change_info_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 210 | #define encode_link_maxsz (op_encode_hdr_maxsz + \ |
| 211 | nfs4_name_maxsz) |
Benny Halevy | 6ce1839 | 2009-04-01 09:22:06 -0400 | [diff] [blame] | 212 | #define decode_link_maxsz (op_decode_hdr_maxsz + decode_change_info_maxsz) |
Trond Myklebust | daccbde | 2010-06-25 18:11:43 -0400 | [diff] [blame] | 213 | #define encode_lockowner_maxsz (7) |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 214 | #define encode_lock_maxsz (op_encode_hdr_maxsz + \ |
| 215 | 7 + \ |
Trond Myklebust | daccbde | 2010-06-25 18:11:43 -0400 | [diff] [blame] | 216 | 1 + encode_stateid_maxsz + 1 + \ |
| 217 | encode_lockowner_maxsz) |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 218 | #define decode_lock_denied_maxsz \ |
| 219 | (8 + decode_lockowner_maxsz) |
| 220 | #define decode_lock_maxsz (op_decode_hdr_maxsz + \ |
| 221 | decode_lock_denied_maxsz) |
Trond Myklebust | daccbde | 2010-06-25 18:11:43 -0400 | [diff] [blame] | 222 | #define encode_lockt_maxsz (op_encode_hdr_maxsz + 5 + \ |
| 223 | encode_lockowner_maxsz) |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 224 | #define decode_lockt_maxsz (op_decode_hdr_maxsz + \ |
| 225 | decode_lock_denied_maxsz) |
| 226 | #define encode_locku_maxsz (op_encode_hdr_maxsz + 3 + \ |
| 227 | encode_stateid_maxsz + \ |
| 228 | 4) |
| 229 | #define decode_locku_maxsz (op_decode_hdr_maxsz + \ |
| 230 | decode_stateid_maxsz) |
Trond Myklebust | d3c7b7c | 2010-07-01 12:49:01 -0400 | [diff] [blame] | 231 | #define encode_release_lockowner_maxsz \ |
| 232 | (op_encode_hdr_maxsz + \ |
| 233 | encode_lockowner_maxsz) |
| 234 | #define decode_release_lockowner_maxsz \ |
| 235 | (op_decode_hdr_maxsz) |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 236 | #define encode_access_maxsz (op_encode_hdr_maxsz + 1) |
| 237 | #define decode_access_maxsz (op_decode_hdr_maxsz + 2) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 238 | #define encode_symlink_maxsz (op_encode_hdr_maxsz + \ |
| 239 | 1 + nfs4_name_maxsz + \ |
Chuck Lever | 94a6d75 | 2006-08-22 20:06:23 -0400 | [diff] [blame] | 240 | 1 + \ |
J. Bruce Fields | 9692820 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 241 | nfs4_fattr_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 242 | #define decode_symlink_maxsz (op_decode_hdr_maxsz + 8) |
| 243 | #define encode_create_maxsz (op_encode_hdr_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 244 | 1 + 2 + nfs4_name_maxsz + \ |
| 245 | encode_attrs_maxsz) |
Trond Myklebust | 2cebf82 | 2007-07-02 13:57:28 -0400 | [diff] [blame] | 246 | #define decode_create_maxsz (op_decode_hdr_maxsz + \ |
| 247 | decode_change_info_maxsz + \ |
| 248 | nfs4_fattr_bitmap_maxsz) |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 249 | #define encode_statfs_maxsz (encode_getattr_maxsz) |
| 250 | #define decode_statfs_maxsz (decode_getattr_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 251 | #define encode_delegreturn_maxsz (op_encode_hdr_maxsz + 4) |
| 252 | #define decode_delegreturn_maxsz (op_decode_hdr_maxsz) |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 253 | #define encode_getacl_maxsz (encode_getattr_maxsz) |
| 254 | #define decode_getacl_maxsz (op_decode_hdr_maxsz + \ |
| 255 | nfs4_fattr_bitmap_maxsz + 1) |
| 256 | #define encode_setacl_maxsz (op_encode_hdr_maxsz + \ |
| 257 | encode_stateid_maxsz + 3) |
| 258 | #define decode_setacl_maxsz (decode_setattr_maxsz) |
Trond Myklebust | e688962 | 2007-07-02 13:58:30 -0400 | [diff] [blame] | 259 | #define encode_fs_locations_maxsz \ |
| 260 | (encode_getattr_maxsz) |
| 261 | #define decode_fs_locations_maxsz \ |
| 262 | (0) |
Bryan Schumaker | 5a5ea0d | 2011-03-24 17:12:29 +0000 | [diff] [blame] | 263 | #define encode_secinfo_maxsz (op_encode_hdr_maxsz + nfs4_name_maxsz) |
Bryan Schumaker | 1650add | 2011-06-02 15:07:35 -0400 | [diff] [blame] | 264 | #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] | 265 | |
| 266 | #if defined(CONFIG_NFS_V4_1) |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 267 | #define NFS4_MAX_MACHINE_NAME_LEN (64) |
| 268 | |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 269 | #define encode_exchange_id_maxsz (op_encode_hdr_maxsz + \ |
| 270 | encode_verifier_maxsz + \ |
| 271 | 1 /* co_ownerid.len */ + \ |
| 272 | XDR_QUADLEN(NFS4_EXCHANGE_ID_LEN) + \ |
| 273 | 1 /* flags */ + \ |
| 274 | 1 /* spa_how */ + \ |
| 275 | 0 /* SP4_NONE (for now) */ + \ |
Weston Andros Adamson | db8ac8b | 2012-02-17 15:20:24 -0500 | [diff] [blame^] | 276 | 1 /* implementation id array of size 1 */ + \ |
| 277 | 1 /* nii_domain */ + \ |
| 278 | XDR_QUADLEN(NFS4_OPAQUE_LIMIT) + \ |
| 279 | 1 /* nii_name */ + \ |
| 280 | XDR_QUADLEN(NFS4_OPAQUE_LIMIT) + \ |
| 281 | 3 /* nii_date */) |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 282 | #define decode_exchange_id_maxsz (op_decode_hdr_maxsz + \ |
| 283 | 2 /* eir_clientid */ + \ |
| 284 | 1 /* eir_sequenceid */ + \ |
| 285 | 1 /* eir_flags */ + \ |
| 286 | 1 /* spr_how */ + \ |
| 287 | 0 /* SP4_NONE (for now) */ + \ |
| 288 | 2 /* eir_server_owner.so_minor_id */ + \ |
| 289 | /* eir_server_owner.so_major_id<> */ \ |
| 290 | XDR_QUADLEN(NFS4_OPAQUE_LIMIT) + 1 + \ |
| 291 | /* eir_server_scope<> */ \ |
| 292 | XDR_QUADLEN(NFS4_OPAQUE_LIMIT) + 1 + \ |
| 293 | 1 /* eir_server_impl_id array length */ + \ |
| 294 | 0 /* ignored eir_server_impl_id contents */) |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 295 | #define encode_channel_attrs_maxsz (6 + 1 /* ca_rdma_ird.len (0) */) |
| 296 | #define decode_channel_attrs_maxsz (6 + \ |
| 297 | 1 /* ca_rdma_ird.len */ + \ |
| 298 | 1 /* ca_rdma_ird */) |
| 299 | #define encode_create_session_maxsz (op_encode_hdr_maxsz + \ |
| 300 | 2 /* csa_clientid */ + \ |
| 301 | 1 /* csa_sequence */ + \ |
| 302 | 1 /* csa_flags */ + \ |
| 303 | encode_channel_attrs_maxsz + \ |
| 304 | encode_channel_attrs_maxsz + \ |
| 305 | 1 /* csa_cb_program */ + \ |
| 306 | 1 /* csa_sec_parms.len (1) */ + \ |
| 307 | 1 /* cb_secflavor (AUTH_SYS) */ + \ |
| 308 | 1 /* stamp */ + \ |
| 309 | 1 /* machinename.len */ + \ |
| 310 | XDR_QUADLEN(NFS4_MAX_MACHINE_NAME_LEN) + \ |
| 311 | 1 /* uid */ + \ |
| 312 | 1 /* gid */ + \ |
| 313 | 1 /* gids.len (0) */) |
| 314 | #define decode_create_session_maxsz (op_decode_hdr_maxsz + \ |
| 315 | XDR_QUADLEN(NFS4_MAX_SESSIONID_LEN) + \ |
| 316 | 1 /* csr_sequence */ + \ |
| 317 | 1 /* csr_flags */ + \ |
| 318 | decode_channel_attrs_maxsz + \ |
| 319 | decode_channel_attrs_maxsz) |
Andy Adamson | 0f3e66c | 2009-04-01 09:22:34 -0400 | [diff] [blame] | 320 | #define encode_destroy_session_maxsz (op_encode_hdr_maxsz + 4) |
| 321 | #define decode_destroy_session_maxsz (op_decode_hdr_maxsz) |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 322 | #define encode_sequence_maxsz (op_encode_hdr_maxsz + \ |
| 323 | XDR_QUADLEN(NFS4_MAX_SESSIONID_LEN) + 4) |
| 324 | #define decode_sequence_maxsz (op_decode_hdr_maxsz + \ |
| 325 | XDR_QUADLEN(NFS4_MAX_SESSIONID_LEN) + 5) |
Ricardo Labiaga | 1801975 | 2009-12-05 16:08:40 -0500 | [diff] [blame] | 326 | #define encode_reclaim_complete_maxsz (op_encode_hdr_maxsz + 4) |
| 327 | #define decode_reclaim_complete_maxsz (op_decode_hdr_maxsz + 4) |
Andy Adamson | 7f11d8d | 2011-07-30 20:52:35 -0400 | [diff] [blame] | 328 | #define encode_getdevicelist_maxsz (op_encode_hdr_maxsz + 4 + \ |
| 329 | encode_verifier_maxsz) |
| 330 | #define decode_getdevicelist_maxsz (op_decode_hdr_maxsz + \ |
| 331 | 2 /* nfs_cookie4 gdlr_cookie */ + \ |
| 332 | decode_verifier_maxsz \ |
| 333 | /* verifier4 gdlr_verifier */ + \ |
| 334 | 1 /* gdlr_deviceid_list count */ + \ |
| 335 | XDR_QUADLEN(NFS4_PNFS_GETDEVLIST_MAXNUM * \ |
| 336 | NFS4_DEVICEID4_SIZE) \ |
| 337 | /* gdlr_deviceid_list */ + \ |
| 338 | 1 /* bool gdlr_eof */) |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 339 | #define encode_getdeviceinfo_maxsz (op_encode_hdr_maxsz + 4 + \ |
| 340 | XDR_QUADLEN(NFS4_DEVICEID4_SIZE)) |
| 341 | #define decode_getdeviceinfo_maxsz (op_decode_hdr_maxsz + \ |
| 342 | 1 /* layout type */ + \ |
| 343 | 1 /* opaque devaddr4 length */ + \ |
| 344 | /* devaddr4 payload is read into page */ \ |
| 345 | 1 /* notification bitmap length */ + \ |
| 346 | 1 /* notification bitmap */) |
| 347 | #define encode_layoutget_maxsz (op_encode_hdr_maxsz + 10 + \ |
| 348 | encode_stateid_maxsz) |
| 349 | #define decode_layoutget_maxsz (op_decode_hdr_maxsz + 8 + \ |
| 350 | decode_stateid_maxsz + \ |
| 351 | XDR_QUADLEN(PNFS_LAYOUT_MAXSIZE)) |
Andy Adamson | 863a3c6 | 2011-03-23 13:27:54 +0000 | [diff] [blame] | 352 | #define encode_layoutcommit_maxsz (op_encode_hdr_maxsz + \ |
| 353 | 2 /* offset */ + \ |
| 354 | 2 /* length */ + \ |
| 355 | 1 /* reclaim */ + \ |
| 356 | encode_stateid_maxsz + \ |
| 357 | 1 /* new offset (true) */ + \ |
| 358 | 2 /* last byte written */ + \ |
| 359 | 1 /* nt_timechanged (false) */ + \ |
| 360 | 1 /* layoutupdate4 layout type */ + \ |
| 361 | 1 /* NULL filelayout layoutupdate4 payload */) |
| 362 | #define decode_layoutcommit_maxsz (op_decode_hdr_maxsz + 3) |
Benny Halevy | cbe8260 | 2011-05-22 19:52:37 +0300 | [diff] [blame] | 363 | #define encode_layoutreturn_maxsz (8 + op_encode_hdr_maxsz + \ |
| 364 | encode_stateid_maxsz + \ |
| 365 | 1 /* FIXME: opaque lrf_body always empty at the moment */) |
| 366 | #define decode_layoutreturn_maxsz (op_decode_hdr_maxsz + \ |
| 367 | 1 + decode_stateid_maxsz) |
Bryan Schumaker | fca78d6 | 2011-06-02 14:59:07 -0400 | [diff] [blame] | 368 | #define encode_secinfo_no_name_maxsz (op_encode_hdr_maxsz + 1) |
| 369 | #define decode_secinfo_no_name_maxsz decode_secinfo_maxsz |
Bryan Schumaker | 7d97479 | 2011-06-02 14:59:08 -0400 | [diff] [blame] | 370 | #define encode_test_stateid_maxsz (op_encode_hdr_maxsz + 2 + \ |
| 371 | XDR_QUADLEN(NFS4_STATEID_SIZE)) |
| 372 | #define decode_test_stateid_maxsz (op_decode_hdr_maxsz + 2 + 1) |
Bryan Schumaker | 9aeda35 | 2011-06-02 14:59:09 -0400 | [diff] [blame] | 373 | #define encode_free_stateid_maxsz (op_encode_hdr_maxsz + 1 + \ |
| 374 | XDR_QUADLEN(NFS4_STATEID_SIZE)) |
| 375 | #define decode_free_stateid_maxsz (op_decode_hdr_maxsz + 1) |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 376 | #else /* CONFIG_NFS_V4_1 */ |
| 377 | #define encode_sequence_maxsz 0 |
| 378 | #define decode_sequence_maxsz 0 |
| 379 | #endif /* CONFIG_NFS_V4_1 */ |
| 380 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 381 | #define NFS4_enc_compound_sz (1024) /* XXX: large enough? */ |
| 382 | #define NFS4_dec_compound_sz (1024) /* XXX: large enough? */ |
| 383 | #define NFS4_enc_read_sz (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 384 | encode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 385 | encode_putfh_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 386 | encode_read_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 387 | #define NFS4_dec_read_sz (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 388 | decode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 389 | decode_putfh_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 390 | decode_read_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 391 | #define NFS4_enc_readlink_sz (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 392 | encode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 393 | encode_putfh_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 394 | encode_readlink_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 395 | #define NFS4_dec_readlink_sz (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 396 | decode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 397 | decode_putfh_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 398 | decode_readlink_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 399 | #define NFS4_enc_readdir_sz (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 400 | encode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 401 | encode_putfh_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 402 | encode_readdir_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 403 | #define NFS4_dec_readdir_sz (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 404 | decode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 405 | decode_putfh_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 406 | decode_readdir_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 407 | #define NFS4_enc_write_sz (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 408 | encode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 409 | encode_putfh_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 410 | encode_write_maxsz + \ |
Trond Myklebust | 4f9838c | 2005-10-27 22:12:44 -0400 | [diff] [blame] | 411 | encode_getattr_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 412 | #define NFS4_dec_write_sz (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 413 | decode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 414 | decode_putfh_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 415 | decode_write_maxsz + \ |
Trond Myklebust | 4f9838c | 2005-10-27 22:12:44 -0400 | [diff] [blame] | 416 | decode_getattr_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 417 | #define NFS4_enc_commit_sz (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 418 | encode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 419 | encode_putfh_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 420 | encode_commit_maxsz + \ |
Trond Myklebust | 4f9838c | 2005-10-27 22:12:44 -0400 | [diff] [blame] | 421 | encode_getattr_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 422 | #define NFS4_dec_commit_sz (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 423 | decode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 424 | decode_putfh_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 425 | decode_commit_maxsz + \ |
Trond Myklebust | 4f9838c | 2005-10-27 22:12:44 -0400 | [diff] [blame] | 426 | decode_getattr_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 427 | #define NFS4_enc_open_sz (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 428 | encode_sequence_maxsz + \ |
Trond Myklebust | 2cebf82 | 2007-07-02 13:57:28 -0400 | [diff] [blame] | 429 | encode_putfh_maxsz + \ |
| 430 | encode_savefh_maxsz + \ |
| 431 | encode_open_maxsz + \ |
| 432 | encode_getfh_maxsz + \ |
| 433 | encode_getattr_maxsz + \ |
| 434 | encode_restorefh_maxsz + \ |
| 435 | encode_getattr_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 436 | #define NFS4_dec_open_sz (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 437 | decode_sequence_maxsz + \ |
Trond Myklebust | 2cebf82 | 2007-07-02 13:57:28 -0400 | [diff] [blame] | 438 | decode_putfh_maxsz + \ |
| 439 | decode_savefh_maxsz + \ |
| 440 | decode_open_maxsz + \ |
| 441 | decode_getfh_maxsz + \ |
| 442 | decode_getattr_maxsz + \ |
| 443 | decode_restorefh_maxsz + \ |
| 444 | decode_getattr_maxsz) |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 445 | #define NFS4_enc_open_confirm_sz \ |
| 446 | (compound_encode_hdr_maxsz + \ |
| 447 | encode_putfh_maxsz + \ |
| 448 | encode_open_confirm_maxsz) |
| 449 | #define NFS4_dec_open_confirm_sz \ |
| 450 | (compound_decode_hdr_maxsz + \ |
| 451 | decode_putfh_maxsz + \ |
| 452 | decode_open_confirm_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 453 | #define NFS4_enc_open_noattr_sz (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 454 | encode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 455 | encode_putfh_maxsz + \ |
Trond Myklebust | 2cebf82 | 2007-07-02 13:57:28 -0400 | [diff] [blame] | 456 | encode_open_maxsz + \ |
| 457 | encode_getattr_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 458 | #define NFS4_dec_open_noattr_sz (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 459 | decode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 460 | decode_putfh_maxsz + \ |
Trond Myklebust | 2cebf82 | 2007-07-02 13:57:28 -0400 | [diff] [blame] | 461 | decode_open_maxsz + \ |
| 462 | decode_getattr_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 463 | #define NFS4_enc_open_downgrade_sz \ |
| 464 | (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 465 | encode_sequence_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 466 | encode_putfh_maxsz + \ |
| 467 | encode_open_downgrade_maxsz + \ |
| 468 | encode_getattr_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 469 | #define NFS4_dec_open_downgrade_sz \ |
| 470 | (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 471 | decode_sequence_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 472 | decode_putfh_maxsz + \ |
| 473 | decode_open_downgrade_maxsz + \ |
| 474 | decode_getattr_maxsz) |
| 475 | #define NFS4_enc_close_sz (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 476 | encode_sequence_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 477 | encode_putfh_maxsz + \ |
| 478 | encode_close_maxsz + \ |
| 479 | encode_getattr_maxsz) |
| 480 | #define NFS4_dec_close_sz (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 481 | decode_sequence_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 482 | decode_putfh_maxsz + \ |
| 483 | decode_close_maxsz + \ |
| 484 | decode_getattr_maxsz) |
| 485 | #define NFS4_enc_setattr_sz (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 486 | encode_sequence_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 487 | encode_putfh_maxsz + \ |
| 488 | encode_setattr_maxsz + \ |
| 489 | encode_getattr_maxsz) |
| 490 | #define NFS4_dec_setattr_sz (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 491 | decode_sequence_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 492 | decode_putfh_maxsz + \ |
| 493 | decode_setattr_maxsz + \ |
| 494 | decode_getattr_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 495 | #define NFS4_enc_fsinfo_sz (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 496 | encode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 497 | encode_putfh_maxsz + \ |
| 498 | encode_fsinfo_maxsz) |
| 499 | #define NFS4_dec_fsinfo_sz (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 500 | decode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 501 | decode_putfh_maxsz + \ |
| 502 | decode_fsinfo_maxsz) |
| 503 | #define NFS4_enc_renew_sz (compound_encode_hdr_maxsz + \ |
| 504 | encode_renew_maxsz) |
| 505 | #define NFS4_dec_renew_sz (compound_decode_hdr_maxsz + \ |
| 506 | decode_renew_maxsz) |
| 507 | #define NFS4_enc_setclientid_sz (compound_encode_hdr_maxsz + \ |
| 508 | encode_setclientid_maxsz) |
| 509 | #define NFS4_dec_setclientid_sz (compound_decode_hdr_maxsz + \ |
| 510 | decode_setclientid_maxsz) |
| 511 | #define NFS4_enc_setclientid_confirm_sz \ |
| 512 | (compound_encode_hdr_maxsz + \ |
| 513 | encode_setclientid_confirm_maxsz + \ |
| 514 | encode_putrootfh_maxsz + \ |
| 515 | encode_fsinfo_maxsz) |
| 516 | #define NFS4_dec_setclientid_confirm_sz \ |
| 517 | (compound_decode_hdr_maxsz + \ |
| 518 | decode_setclientid_confirm_maxsz + \ |
| 519 | decode_putrootfh_maxsz + \ |
| 520 | decode_fsinfo_maxsz) |
| 521 | #define NFS4_enc_lock_sz (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 522 | encode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 523 | encode_putfh_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 524 | encode_lock_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 525 | #define NFS4_dec_lock_sz (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 526 | decode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 527 | decode_putfh_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 528 | decode_lock_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 529 | #define NFS4_enc_lockt_sz (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 530 | encode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 531 | encode_putfh_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 532 | encode_lockt_maxsz) |
| 533 | #define NFS4_dec_lockt_sz (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 534 | decode_sequence_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 535 | decode_putfh_maxsz + \ |
| 536 | decode_lockt_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 537 | #define NFS4_enc_locku_sz (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 538 | encode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 539 | encode_putfh_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 540 | encode_locku_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 541 | #define NFS4_dec_locku_sz (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 542 | decode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 543 | decode_putfh_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 544 | decode_locku_maxsz) |
Trond Myklebust | d3c7b7c | 2010-07-01 12:49:01 -0400 | [diff] [blame] | 545 | #define NFS4_enc_release_lockowner_sz \ |
| 546 | (compound_encode_hdr_maxsz + \ |
| 547 | encode_lockowner_maxsz) |
| 548 | #define NFS4_dec_release_lockowner_sz \ |
| 549 | (compound_decode_hdr_maxsz + \ |
| 550 | decode_lockowner_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 551 | #define NFS4_enc_access_sz (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 552 | encode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 553 | encode_putfh_maxsz + \ |
Trond Myklebust | 76b3299 | 2007-08-10 17:45:11 -0400 | [diff] [blame] | 554 | encode_access_maxsz + \ |
| 555 | encode_getattr_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 556 | #define NFS4_dec_access_sz (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 557 | decode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 558 | decode_putfh_maxsz + \ |
Trond Myklebust | 76b3299 | 2007-08-10 17:45:11 -0400 | [diff] [blame] | 559 | decode_access_maxsz + \ |
| 560 | decode_getattr_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 561 | #define NFS4_enc_getattr_sz (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 562 | encode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 563 | encode_putfh_maxsz + \ |
| 564 | encode_getattr_maxsz) |
| 565 | #define NFS4_dec_getattr_sz (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 566 | decode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 567 | decode_putfh_maxsz + \ |
| 568 | decode_getattr_maxsz) |
| 569 | #define NFS4_enc_lookup_sz (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 570 | encode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 571 | encode_putfh_maxsz + \ |
| 572 | encode_lookup_maxsz + \ |
| 573 | encode_getattr_maxsz + \ |
| 574 | encode_getfh_maxsz) |
| 575 | #define NFS4_dec_lookup_sz (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 576 | decode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 577 | decode_putfh_maxsz + \ |
Trond Myklebust | e688962 | 2007-07-02 13:58:30 -0400 | [diff] [blame] | 578 | decode_lookup_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 579 | decode_getattr_maxsz + \ |
| 580 | decode_getfh_maxsz) |
| 581 | #define NFS4_enc_lookup_root_sz (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 582 | encode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 583 | encode_putrootfh_maxsz + \ |
| 584 | encode_getattr_maxsz + \ |
| 585 | encode_getfh_maxsz) |
| 586 | #define NFS4_dec_lookup_root_sz (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 587 | decode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 588 | decode_putrootfh_maxsz + \ |
| 589 | decode_getattr_maxsz + \ |
| 590 | decode_getfh_maxsz) |
| 591 | #define NFS4_enc_remove_sz (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 592 | encode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 593 | encode_putfh_maxsz + \ |
Trond Myklebust | 16e4295 | 2005-10-27 22:12:44 -0400 | [diff] [blame] | 594 | encode_remove_maxsz + \ |
| 595 | encode_getattr_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 596 | #define NFS4_dec_remove_sz (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 597 | decode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 598 | decode_putfh_maxsz + \ |
Benny Halevy | 6ce1839 | 2009-04-01 09:22:06 -0400 | [diff] [blame] | 599 | decode_remove_maxsz + \ |
Trond Myklebust | 16e4295 | 2005-10-27 22:12:44 -0400 | [diff] [blame] | 600 | decode_getattr_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 601 | #define NFS4_enc_rename_sz (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 602 | encode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 603 | encode_putfh_maxsz + \ |
| 604 | encode_savefh_maxsz + \ |
| 605 | encode_putfh_maxsz + \ |
Trond Myklebust | 6caf2c8 | 2005-10-27 22:12:43 -0400 | [diff] [blame] | 606 | encode_rename_maxsz + \ |
| 607 | encode_getattr_maxsz + \ |
| 608 | encode_restorefh_maxsz + \ |
| 609 | encode_getattr_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 610 | #define NFS4_dec_rename_sz (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 611 | decode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 612 | decode_putfh_maxsz + \ |
| 613 | decode_savefh_maxsz + \ |
| 614 | decode_putfh_maxsz + \ |
Trond Myklebust | 6caf2c8 | 2005-10-27 22:12:43 -0400 | [diff] [blame] | 615 | decode_rename_maxsz + \ |
| 616 | decode_getattr_maxsz + \ |
| 617 | decode_restorefh_maxsz + \ |
| 618 | decode_getattr_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 619 | #define NFS4_enc_link_sz (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 620 | encode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 621 | encode_putfh_maxsz + \ |
| 622 | encode_savefh_maxsz + \ |
| 623 | encode_putfh_maxsz + \ |
Trond Myklebust | 91ba2ee | 2005-10-27 22:12:42 -0400 | [diff] [blame] | 624 | encode_link_maxsz + \ |
| 625 | decode_getattr_maxsz + \ |
| 626 | encode_restorefh_maxsz + \ |
| 627 | decode_getattr_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 628 | #define NFS4_dec_link_sz (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 629 | decode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 630 | decode_putfh_maxsz + \ |
| 631 | decode_savefh_maxsz + \ |
| 632 | decode_putfh_maxsz + \ |
Trond Myklebust | 91ba2ee | 2005-10-27 22:12:42 -0400 | [diff] [blame] | 633 | decode_link_maxsz + \ |
| 634 | decode_getattr_maxsz + \ |
| 635 | decode_restorefh_maxsz + \ |
| 636 | decode_getattr_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 637 | #define NFS4_enc_symlink_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_symlink_maxsz + \ |
| 641 | encode_getattr_maxsz + \ |
| 642 | encode_getfh_maxsz) |
| 643 | #define NFS4_dec_symlink_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_symlink_maxsz + \ |
| 647 | decode_getattr_maxsz + \ |
| 648 | decode_getfh_maxsz) |
| 649 | #define NFS4_enc_create_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 + \ |
Trond Myklebust | 56ae19f | 2005-10-27 22:12:40 -0400 | [diff] [blame] | 652 | encode_savefh_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 653 | encode_create_maxsz + \ |
Trond Myklebust | 56ae19f | 2005-10-27 22:12:40 -0400 | [diff] [blame] | 654 | encode_getfh_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 655 | encode_getattr_maxsz + \ |
Trond Myklebust | 56ae19f | 2005-10-27 22:12:40 -0400 | [diff] [blame] | 656 | encode_restorefh_maxsz + \ |
| 657 | encode_getattr_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 658 | #define NFS4_dec_create_sz (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 659 | decode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 660 | decode_putfh_maxsz + \ |
Trond Myklebust | 56ae19f | 2005-10-27 22:12:40 -0400 | [diff] [blame] | 661 | decode_savefh_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 662 | decode_create_maxsz + \ |
Trond Myklebust | 56ae19f | 2005-10-27 22:12:40 -0400 | [diff] [blame] | 663 | decode_getfh_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 664 | decode_getattr_maxsz + \ |
Trond Myklebust | 56ae19f | 2005-10-27 22:12:40 -0400 | [diff] [blame] | 665 | decode_restorefh_maxsz + \ |
| 666 | decode_getattr_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 667 | #define NFS4_enc_pathconf_sz (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 668 | encode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 669 | encode_putfh_maxsz + \ |
| 670 | encode_getattr_maxsz) |
| 671 | #define NFS4_dec_pathconf_sz (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 672 | decode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 673 | decode_putfh_maxsz + \ |
| 674 | decode_getattr_maxsz) |
| 675 | #define NFS4_enc_statfs_sz (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 676 | encode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 677 | encode_putfh_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 678 | encode_statfs_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 679 | #define NFS4_dec_statfs_sz (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 680 | decode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 681 | decode_putfh_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 682 | decode_statfs_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 683 | #define NFS4_enc_server_caps_sz (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 684 | encode_sequence_maxsz + \ |
Trond Myklebust | ab91f26 | 2007-02-02 14:47:17 -0800 | [diff] [blame] | 685 | encode_putfh_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 686 | encode_getattr_maxsz) |
| 687 | #define NFS4_dec_server_caps_sz (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 688 | decode_sequence_maxsz + \ |
Trond Myklebust | ab91f26 | 2007-02-02 14:47:17 -0800 | [diff] [blame] | 689 | decode_putfh_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 690 | decode_getattr_maxsz) |
| 691 | #define NFS4_enc_delegreturn_sz (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 692 | encode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 693 | encode_putfh_maxsz + \ |
Trond Myklebust | fa178f2 | 2006-01-03 09:55:38 +0100 | [diff] [blame] | 694 | encode_delegreturn_maxsz + \ |
| 695 | encode_getattr_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 696 | #define NFS4_dec_delegreturn_sz (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 697 | decode_sequence_maxsz + \ |
Trond Myklebust | fa178f2 | 2006-01-03 09:55:38 +0100 | [diff] [blame] | 698 | decode_delegreturn_maxsz + \ |
| 699 | decode_getattr_maxsz) |
J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 700 | #define NFS4_enc_getacl_sz (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 701 | encode_sequence_maxsz + \ |
J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 702 | encode_putfh_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 703 | encode_getacl_maxsz) |
J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 704 | #define NFS4_dec_getacl_sz (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 705 | decode_sequence_maxsz + \ |
J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 706 | decode_putfh_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 707 | decode_getacl_maxsz) |
J. Bruce Fields | 23ec696 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 708 | #define NFS4_enc_setacl_sz (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 709 | encode_sequence_maxsz + \ |
J. Bruce Fields | 23ec696 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 710 | encode_putfh_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 711 | encode_setacl_maxsz) |
J. Bruce Fields | 23ec696 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 712 | #define NFS4_dec_setacl_sz (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 713 | decode_sequence_maxsz + \ |
J. Bruce Fields | 23ec696 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 714 | decode_putfh_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 715 | decode_setacl_maxsz) |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 716 | #define NFS4_enc_fs_locations_sz \ |
| 717 | (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 718 | encode_sequence_maxsz + \ |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 719 | encode_putfh_maxsz + \ |
Trond Myklebust | e688962 | 2007-07-02 13:58:30 -0400 | [diff] [blame] | 720 | encode_lookup_maxsz + \ |
| 721 | encode_fs_locations_maxsz) |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 722 | #define NFS4_dec_fs_locations_sz \ |
| 723 | (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 724 | decode_sequence_maxsz + \ |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 725 | decode_putfh_maxsz + \ |
Trond Myklebust | e688962 | 2007-07-02 13:58:30 -0400 | [diff] [blame] | 726 | decode_lookup_maxsz + \ |
| 727 | decode_fs_locations_maxsz) |
Bryan Schumaker | 5a5ea0d | 2011-03-24 17:12:29 +0000 | [diff] [blame] | 728 | #define NFS4_enc_secinfo_sz (compound_encode_hdr_maxsz + \ |
| 729 | encode_sequence_maxsz + \ |
| 730 | encode_putfh_maxsz + \ |
| 731 | encode_secinfo_maxsz) |
| 732 | #define NFS4_dec_secinfo_sz (compound_decode_hdr_maxsz + \ |
| 733 | decode_sequence_maxsz + \ |
| 734 | decode_putfh_maxsz + \ |
| 735 | decode_secinfo_maxsz) |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 736 | #if defined(CONFIG_NFS_V4_1) |
| 737 | #define NFS4_enc_exchange_id_sz \ |
| 738 | (compound_encode_hdr_maxsz + \ |
| 739 | encode_exchange_id_maxsz) |
| 740 | #define NFS4_dec_exchange_id_sz \ |
| 741 | (compound_decode_hdr_maxsz + \ |
| 742 | decode_exchange_id_maxsz) |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 743 | #define NFS4_enc_create_session_sz \ |
| 744 | (compound_encode_hdr_maxsz + \ |
| 745 | encode_create_session_maxsz) |
| 746 | #define NFS4_dec_create_session_sz \ |
| 747 | (compound_decode_hdr_maxsz + \ |
| 748 | decode_create_session_maxsz) |
Andy Adamson | 0f3e66c | 2009-04-01 09:22:34 -0400 | [diff] [blame] | 749 | #define NFS4_enc_destroy_session_sz (compound_encode_hdr_maxsz + \ |
| 750 | encode_destroy_session_maxsz) |
| 751 | #define NFS4_dec_destroy_session_sz (compound_decode_hdr_maxsz + \ |
| 752 | decode_destroy_session_maxsz) |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 753 | #define NFS4_enc_sequence_sz \ |
| 754 | (compound_decode_hdr_maxsz + \ |
| 755 | encode_sequence_maxsz) |
| 756 | #define NFS4_dec_sequence_sz \ |
| 757 | (compound_decode_hdr_maxsz + \ |
| 758 | decode_sequence_maxsz) |
Andy Adamson | 2050f0c | 2009-04-01 09:22:30 -0400 | [diff] [blame] | 759 | #define NFS4_enc_get_lease_time_sz (compound_encode_hdr_maxsz + \ |
| 760 | encode_sequence_maxsz + \ |
| 761 | encode_putrootfh_maxsz + \ |
| 762 | encode_fsinfo_maxsz) |
| 763 | #define NFS4_dec_get_lease_time_sz (compound_decode_hdr_maxsz + \ |
| 764 | decode_sequence_maxsz + \ |
| 765 | decode_putrootfh_maxsz + \ |
| 766 | decode_fsinfo_maxsz) |
Ricardo Labiaga | 1801975 | 2009-12-05 16:08:40 -0500 | [diff] [blame] | 767 | #define NFS4_enc_reclaim_complete_sz (compound_encode_hdr_maxsz + \ |
| 768 | encode_sequence_maxsz + \ |
| 769 | encode_reclaim_complete_maxsz) |
| 770 | #define NFS4_dec_reclaim_complete_sz (compound_decode_hdr_maxsz + \ |
| 771 | decode_sequence_maxsz + \ |
| 772 | decode_reclaim_complete_maxsz) |
Andy Adamson | 7f11d8d | 2011-07-30 20:52:35 -0400 | [diff] [blame] | 773 | #define NFS4_enc_getdevicelist_sz (compound_encode_hdr_maxsz + \ |
| 774 | encode_sequence_maxsz + \ |
| 775 | encode_putfh_maxsz + \ |
| 776 | encode_getdevicelist_maxsz) |
| 777 | #define NFS4_dec_getdevicelist_sz (compound_decode_hdr_maxsz + \ |
| 778 | decode_sequence_maxsz + \ |
| 779 | decode_putfh_maxsz + \ |
| 780 | decode_getdevicelist_maxsz) |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 781 | #define NFS4_enc_getdeviceinfo_sz (compound_encode_hdr_maxsz + \ |
| 782 | encode_sequence_maxsz +\ |
| 783 | encode_getdeviceinfo_maxsz) |
| 784 | #define NFS4_dec_getdeviceinfo_sz (compound_decode_hdr_maxsz + \ |
| 785 | decode_sequence_maxsz + \ |
| 786 | decode_getdeviceinfo_maxsz) |
| 787 | #define NFS4_enc_layoutget_sz (compound_encode_hdr_maxsz + \ |
| 788 | encode_sequence_maxsz + \ |
| 789 | encode_putfh_maxsz + \ |
| 790 | encode_layoutget_maxsz) |
| 791 | #define NFS4_dec_layoutget_sz (compound_decode_hdr_maxsz + \ |
| 792 | decode_sequence_maxsz + \ |
| 793 | decode_putfh_maxsz + \ |
| 794 | decode_layoutget_maxsz) |
Andy Adamson | 863a3c6 | 2011-03-23 13:27:54 +0000 | [diff] [blame] | 795 | #define NFS4_enc_layoutcommit_sz (compound_encode_hdr_maxsz + \ |
| 796 | encode_sequence_maxsz +\ |
| 797 | encode_putfh_maxsz + \ |
| 798 | encode_layoutcommit_maxsz + \ |
| 799 | encode_getattr_maxsz) |
| 800 | #define NFS4_dec_layoutcommit_sz (compound_decode_hdr_maxsz + \ |
| 801 | decode_sequence_maxsz + \ |
| 802 | decode_putfh_maxsz + \ |
| 803 | decode_layoutcommit_maxsz + \ |
| 804 | decode_getattr_maxsz) |
Benny Halevy | cbe8260 | 2011-05-22 19:52:37 +0300 | [diff] [blame] | 805 | #define NFS4_enc_layoutreturn_sz (compound_encode_hdr_maxsz + \ |
| 806 | encode_sequence_maxsz + \ |
| 807 | encode_putfh_maxsz + \ |
| 808 | encode_layoutreturn_maxsz) |
| 809 | #define NFS4_dec_layoutreturn_sz (compound_decode_hdr_maxsz + \ |
| 810 | decode_sequence_maxsz + \ |
| 811 | decode_putfh_maxsz + \ |
| 812 | decode_layoutreturn_maxsz) |
Bryan Schumaker | fca78d6 | 2011-06-02 14:59:07 -0400 | [diff] [blame] | 813 | #define NFS4_enc_secinfo_no_name_sz (compound_encode_hdr_maxsz + \ |
| 814 | encode_sequence_maxsz + \ |
| 815 | encode_putrootfh_maxsz +\ |
| 816 | encode_secinfo_no_name_maxsz) |
| 817 | #define NFS4_dec_secinfo_no_name_sz (compound_decode_hdr_maxsz + \ |
| 818 | decode_sequence_maxsz + \ |
| 819 | decode_putrootfh_maxsz + \ |
| 820 | decode_secinfo_no_name_maxsz) |
Bryan Schumaker | 7d97479 | 2011-06-02 14:59:08 -0400 | [diff] [blame] | 821 | #define NFS4_enc_test_stateid_sz (compound_encode_hdr_maxsz + \ |
| 822 | encode_sequence_maxsz + \ |
| 823 | encode_test_stateid_maxsz) |
| 824 | #define NFS4_dec_test_stateid_sz (compound_decode_hdr_maxsz + \ |
| 825 | decode_sequence_maxsz + \ |
| 826 | decode_test_stateid_maxsz) |
Bryan Schumaker | 9aeda35 | 2011-06-02 14:59:09 -0400 | [diff] [blame] | 827 | #define NFS4_enc_free_stateid_sz (compound_encode_hdr_maxsz + \ |
| 828 | encode_sequence_maxsz + \ |
| 829 | encode_free_stateid_maxsz) |
| 830 | #define NFS4_dec_free_stateid_sz (compound_decode_hdr_maxsz + \ |
| 831 | decode_sequence_maxsz + \ |
| 832 | decode_free_stateid_maxsz) |
Alexandros Batsakis | 2449ea2 | 2009-12-05 13:36:55 -0500 | [diff] [blame] | 833 | |
| 834 | const u32 nfs41_maxwrite_overhead = ((RPC_MAX_HEADER_WITH_AUTH + |
| 835 | compound_encode_hdr_maxsz + |
| 836 | encode_sequence_maxsz + |
| 837 | encode_putfh_maxsz + |
| 838 | encode_getattr_maxsz) * |
| 839 | XDR_UNIT); |
| 840 | |
| 841 | const u32 nfs41_maxread_overhead = ((RPC_MAX_HEADER_WITH_AUTH + |
| 842 | compound_decode_hdr_maxsz + |
| 843 | decode_sequence_maxsz + |
| 844 | decode_putfh_maxsz) * |
| 845 | XDR_UNIT); |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 846 | #endif /* CONFIG_NFS_V4_1 */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 847 | |
Weston Andros Adamson | db8ac8b | 2012-02-17 15:20:24 -0500 | [diff] [blame^] | 848 | static unsigned short send_implementation_id = 1; |
| 849 | |
| 850 | module_param(send_implementation_id, ushort, 0644); |
| 851 | MODULE_PARM_DESC(send_implementation_id, |
| 852 | "Send implementation ID with NFSv4.1 exchange_id"); |
| 853 | |
Trond Myklebust | bca7947 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 854 | static const umode_t nfs_type2fmt[] = { |
| 855 | [NF4BAD] = 0, |
| 856 | [NF4REG] = S_IFREG, |
| 857 | [NF4DIR] = S_IFDIR, |
| 858 | [NF4BLK] = S_IFBLK, |
| 859 | [NF4CHR] = S_IFCHR, |
| 860 | [NF4LNK] = S_IFLNK, |
| 861 | [NF4SOCK] = S_IFSOCK, |
| 862 | [NF4FIFO] = S_IFIFO, |
| 863 | [NF4ATTRDIR] = 0, |
| 864 | [NF4NAMEDATTR] = 0, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 865 | }; |
| 866 | |
| 867 | struct compound_hdr { |
| 868 | int32_t status; |
| 869 | uint32_t nops; |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 870 | __be32 * nops_p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 871 | uint32_t taglen; |
| 872 | char * tag; |
Benny Halevy | 0c4e8c1 | 2009-04-01 09:22:07 -0400 | [diff] [blame] | 873 | uint32_t replen; /* expected reply words */ |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 874 | u32 minorversion; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 875 | }; |
| 876 | |
Benny Halevy | 13c65ce | 2009-08-14 17:19:25 +0300 | [diff] [blame] | 877 | static __be32 *reserve_space(struct xdr_stream *xdr, size_t nbytes) |
| 878 | { |
| 879 | __be32 *p = xdr_reserve_space(xdr, nbytes); |
| 880 | BUG_ON(!p); |
| 881 | return p; |
| 882 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 883 | |
| 884 | static void encode_string(struct xdr_stream *xdr, unsigned int len, const char *str) |
| 885 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 886 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 887 | |
| 888 | p = xdr_reserve_space(xdr, 4 + len); |
| 889 | BUG_ON(p == NULL); |
| 890 | xdr_encode_opaque(p, str, len); |
| 891 | } |
| 892 | |
Benny Halevy | 0c4e8c1 | 2009-04-01 09:22:07 -0400 | [diff] [blame] | 893 | static void encode_compound_hdr(struct xdr_stream *xdr, |
| 894 | struct rpc_rqst *req, |
| 895 | struct compound_hdr *hdr) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 896 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 897 | __be32 *p; |
Trond Myklebust | a17c215 | 2010-07-31 14:29:08 -0400 | [diff] [blame] | 898 | struct rpc_auth *auth = req->rq_cred->cr_auth; |
Benny Halevy | 0c4e8c1 | 2009-04-01 09:22:07 -0400 | [diff] [blame] | 899 | |
| 900 | /* initialize running count of expected bytes in reply. |
| 901 | * NOTE: the replied tag SHOULD be the same is the one sent, |
| 902 | * but this is not required as a MUST for the server to do so. */ |
| 903 | hdr->replen = RPC_REPHDRSIZE + auth->au_rslack + 3 + hdr->taglen; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 904 | |
| 905 | dprintk("encode_compound: tag=%.*s\n", (int)hdr->taglen, hdr->tag); |
| 906 | BUG_ON(hdr->taglen > NFS4_MAXTAGLEN); |
Benny Halevy | 811652b | 2009-08-14 17:19:34 +0300 | [diff] [blame] | 907 | p = reserve_space(xdr, 4 + hdr->taglen + 8); |
| 908 | p = xdr_encode_opaque(p, hdr->tag, hdr->taglen); |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 909 | *p++ = cpu_to_be32(hdr->minorversion); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 910 | hdr->nops_p = p; |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 911 | *p = cpu_to_be32(hdr->nops); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 912 | } |
| 913 | |
| 914 | static void encode_nops(struct compound_hdr *hdr) |
| 915 | { |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 916 | BUG_ON(hdr->nops > NFS4_MAX_OPS); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 917 | *hdr->nops_p = htonl(hdr->nops); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 918 | } |
| 919 | |
| 920 | static void encode_nfs4_verifier(struct xdr_stream *xdr, const nfs4_verifier *verf) |
| 921 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 922 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 923 | |
| 924 | p = xdr_reserve_space(xdr, NFS4_VERIFIER_SIZE); |
| 925 | BUG_ON(p == NULL); |
| 926 | xdr_encode_opaque_fixed(p, verf->data, NFS4_VERIFIER_SIZE); |
| 927 | } |
| 928 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 929 | 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] | 930 | { |
| 931 | char owner_name[IDMAP_NAMESZ]; |
| 932 | char owner_group[IDMAP_NAMESZ]; |
| 933 | int owner_namelen = 0; |
| 934 | int owner_grouplen = 0; |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 935 | __be32 *p; |
| 936 | __be32 *q; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 937 | int len; |
| 938 | uint32_t bmval0 = 0; |
| 939 | uint32_t bmval1 = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 940 | |
| 941 | /* |
| 942 | * We reserve enough space to write the entire attribute buffer at once. |
| 943 | * In the worst-case, this would be |
| 944 | * 12(bitmap) + 4(attrlen) + 8(size) + 4(mode) + 4(atime) + 4(mtime) |
| 945 | * = 36 bytes, plus any contribution from variable-length fields |
J. Bruce Fields | 23ec696 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 946 | * such as owner/group. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 947 | */ |
| 948 | len = 16; |
| 949 | |
| 950 | /* Sigh */ |
| 951 | if (iap->ia_valid & ATTR_SIZE) |
| 952 | len += 8; |
| 953 | if (iap->ia_valid & ATTR_MODE) |
| 954 | len += 4; |
| 955 | if (iap->ia_valid & ATTR_UID) { |
Trond Myklebust | e4fd72a | 2011-02-22 15:44:31 -0800 | [diff] [blame] | 956 | 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] | 957 | if (owner_namelen < 0) { |
Chuck Lever | fe82a18 | 2007-09-11 18:01:10 -0400 | [diff] [blame] | 958 | dprintk("nfs: couldn't resolve uid %d to string\n", |
| 959 | iap->ia_uid); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 960 | /* XXX */ |
| 961 | strcpy(owner_name, "nobody"); |
| 962 | owner_namelen = sizeof("nobody") - 1; |
| 963 | /* goto out; */ |
| 964 | } |
| 965 | len += 4 + (XDR_QUADLEN(owner_namelen) << 2); |
| 966 | } |
| 967 | if (iap->ia_valid & ATTR_GID) { |
Trond Myklebust | e4fd72a | 2011-02-22 15:44:31 -0800 | [diff] [blame] | 968 | 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] | 969 | if (owner_grouplen < 0) { |
Chuck Lever | fe82a18 | 2007-09-11 18:01:10 -0400 | [diff] [blame] | 970 | dprintk("nfs: couldn't resolve gid %d to string\n", |
| 971 | iap->ia_gid); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 972 | strcpy(owner_group, "nobody"); |
| 973 | owner_grouplen = sizeof("nobody") - 1; |
| 974 | /* goto out; */ |
| 975 | } |
| 976 | len += 4 + (XDR_QUADLEN(owner_grouplen) << 2); |
| 977 | } |
| 978 | if (iap->ia_valid & ATTR_ATIME_SET) |
| 979 | len += 16; |
| 980 | else if (iap->ia_valid & ATTR_ATIME) |
| 981 | len += 4; |
| 982 | if (iap->ia_valid & ATTR_MTIME_SET) |
| 983 | len += 16; |
| 984 | else if (iap->ia_valid & ATTR_MTIME) |
| 985 | len += 4; |
Benny Halevy | 13c65ce | 2009-08-14 17:19:25 +0300 | [diff] [blame] | 986 | p = reserve_space(xdr, len); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 987 | |
| 988 | /* |
| 989 | * We write the bitmap length now, but leave the bitmap and the attribute |
| 990 | * buffer length to be backfilled at the end of this routine. |
| 991 | */ |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 992 | *p++ = cpu_to_be32(2); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 993 | q = p; |
| 994 | p += 3; |
| 995 | |
| 996 | if (iap->ia_valid & ATTR_SIZE) { |
| 997 | bmval0 |= FATTR4_WORD0_SIZE; |
Benny Halevy | b95be5a | 2009-08-14 17:19:01 +0300 | [diff] [blame] | 998 | p = xdr_encode_hyper(p, iap->ia_size); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 999 | } |
| 1000 | if (iap->ia_valid & ATTR_MODE) { |
| 1001 | bmval1 |= FATTR4_WORD1_MODE; |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1002 | *p++ = cpu_to_be32(iap->ia_mode & S_IALLUGO); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1003 | } |
| 1004 | if (iap->ia_valid & ATTR_UID) { |
| 1005 | bmval1 |= FATTR4_WORD1_OWNER; |
Benny Halevy | 811652b | 2009-08-14 17:19:34 +0300 | [diff] [blame] | 1006 | p = xdr_encode_opaque(p, owner_name, owner_namelen); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1007 | } |
| 1008 | if (iap->ia_valid & ATTR_GID) { |
| 1009 | bmval1 |= FATTR4_WORD1_OWNER_GROUP; |
Benny Halevy | 811652b | 2009-08-14 17:19:34 +0300 | [diff] [blame] | 1010 | p = xdr_encode_opaque(p, owner_group, owner_grouplen); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1011 | } |
| 1012 | if (iap->ia_valid & ATTR_ATIME_SET) { |
| 1013 | bmval1 |= FATTR4_WORD1_TIME_ACCESS_SET; |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1014 | *p++ = cpu_to_be32(NFS4_SET_TO_CLIENT_TIME); |
| 1015 | *p++ = cpu_to_be32(0); |
Trond Myklebust | d3f6baa | 2010-06-22 08:52:39 -0400 | [diff] [blame] | 1016 | *p++ = cpu_to_be32(iap->ia_atime.tv_sec); |
| 1017 | *p++ = cpu_to_be32(iap->ia_atime.tv_nsec); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1018 | } |
| 1019 | else if (iap->ia_valid & ATTR_ATIME) { |
| 1020 | bmval1 |= FATTR4_WORD1_TIME_ACCESS_SET; |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1021 | *p++ = cpu_to_be32(NFS4_SET_TO_SERVER_TIME); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1022 | } |
| 1023 | if (iap->ia_valid & ATTR_MTIME_SET) { |
| 1024 | bmval1 |= FATTR4_WORD1_TIME_MODIFY_SET; |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1025 | *p++ = cpu_to_be32(NFS4_SET_TO_CLIENT_TIME); |
| 1026 | *p++ = cpu_to_be32(0); |
| 1027 | *p++ = cpu_to_be32(iap->ia_mtime.tv_sec); |
| 1028 | *p++ = cpu_to_be32(iap->ia_mtime.tv_nsec); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1029 | } |
| 1030 | else if (iap->ia_valid & ATTR_MTIME) { |
| 1031 | bmval1 |= FATTR4_WORD1_TIME_MODIFY_SET; |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1032 | *p++ = cpu_to_be32(NFS4_SET_TO_SERVER_TIME); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1033 | } |
Andy Adamson | 6c0195a | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 1034 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1035 | /* |
| 1036 | * Now we backfill the bitmap and the attribute buffer length. |
| 1037 | */ |
| 1038 | if (len != ((char *)p - (char *)q) + 4) { |
Weston Andros Adamson | f9fd2d9 | 2012-01-26 13:32:22 -0500 | [diff] [blame] | 1039 | printk(KERN_ERR "NFS: Attr length error, %u != %Zu\n", |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1040 | len, ((char *)p - (char *)q) + 4); |
| 1041 | BUG(); |
| 1042 | } |
| 1043 | len = (char *)p - (char *)q - 12; |
| 1044 | *q++ = htonl(bmval0); |
| 1045 | *q++ = htonl(bmval1); |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1046 | *q = htonl(len); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1047 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1048 | /* out: */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1049 | } |
| 1050 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1051 | 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] | 1052 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 1053 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1054 | |
Benny Halevy | 13c65ce | 2009-08-14 17:19:25 +0300 | [diff] [blame] | 1055 | p = reserve_space(xdr, 8); |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1056 | *p++ = cpu_to_be32(OP_ACCESS); |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1057 | *p = cpu_to_be32(access); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 1058 | hdr->nops++; |
Benny Halevy | dadf0c2 | 2009-04-01 09:22:08 -0400 | [diff] [blame] | 1059 | hdr->replen += decode_access_maxsz; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1060 | } |
| 1061 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1062 | 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] | 1063 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 1064 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1065 | |
Benny Halevy | 13c65ce | 2009-08-14 17:19:25 +0300 | [diff] [blame] | 1066 | p = reserve_space(xdr, 8+NFS4_STATEID_SIZE); |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1067 | *p++ = cpu_to_be32(OP_CLOSE); |
| 1068 | *p++ = cpu_to_be32(arg->seqid->sequence->counter); |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1069 | xdr_encode_opaque_fixed(p, arg->stateid->data, NFS4_STATEID_SIZE); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 1070 | hdr->nops++; |
Benny Halevy | dadf0c2 | 2009-04-01 09:22:08 -0400 | [diff] [blame] | 1071 | hdr->replen += decode_close_maxsz; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1072 | } |
| 1073 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1074 | static void encode_commit(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] | 1075 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 1076 | __be32 *p; |
Andy Adamson | 6c0195a | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 1077 | |
Benny Halevy | 13c65ce | 2009-08-14 17:19:25 +0300 | [diff] [blame] | 1078 | p = reserve_space(xdr, 16); |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1079 | *p++ = cpu_to_be32(OP_COMMIT); |
Benny Halevy | b95be5a | 2009-08-14 17:19:01 +0300 | [diff] [blame] | 1080 | p = xdr_encode_hyper(p, args->offset); |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1081 | *p = cpu_to_be32(args->count); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 1082 | hdr->nops++; |
Benny Halevy | dadf0c2 | 2009-04-01 09:22:08 -0400 | [diff] [blame] | 1083 | hdr->replen += decode_commit_maxsz; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1084 | } |
| 1085 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1086 | 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] | 1087 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 1088 | __be32 *p; |
Andy Adamson | 6c0195a | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 1089 | |
Benny Halevy | 13c65ce | 2009-08-14 17:19:25 +0300 | [diff] [blame] | 1090 | p = reserve_space(xdr, 8); |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1091 | *p++ = cpu_to_be32(OP_CREATE); |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1092 | *p = cpu_to_be32(create->ftype); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1093 | |
| 1094 | switch (create->ftype) { |
| 1095 | case NF4LNK: |
Benny Halevy | 13c65ce | 2009-08-14 17:19:25 +0300 | [diff] [blame] | 1096 | p = reserve_space(xdr, 4); |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1097 | *p = cpu_to_be32(create->u.symlink.len); |
Chuck Lever | 94a6d75 | 2006-08-22 20:06:23 -0400 | [diff] [blame] | 1098 | 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] | 1099 | break; |
| 1100 | |
| 1101 | case NF4BLK: case NF4CHR: |
Benny Halevy | 13c65ce | 2009-08-14 17:19:25 +0300 | [diff] [blame] | 1102 | p = reserve_space(xdr, 8); |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1103 | *p++ = cpu_to_be32(create->u.device.specdata1); |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1104 | *p = cpu_to_be32(create->u.device.specdata2); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1105 | break; |
| 1106 | |
| 1107 | default: |
| 1108 | break; |
| 1109 | } |
| 1110 | |
Benny Halevy | 811652b | 2009-08-14 17:19:34 +0300 | [diff] [blame] | 1111 | encode_string(xdr, create->name->len, create->name->name); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 1112 | hdr->nops++; |
Benny Halevy | dadf0c2 | 2009-04-01 09:22:08 -0400 | [diff] [blame] | 1113 | hdr->replen += decode_create_maxsz; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1114 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1115 | encode_attrs(xdr, create->attrs, create->server); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1116 | } |
| 1117 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1118 | 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] | 1119 | { |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 1120 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1121 | |
Benny Halevy | 13c65ce | 2009-08-14 17:19:25 +0300 | [diff] [blame] | 1122 | p = reserve_space(xdr, 12); |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1123 | *p++ = cpu_to_be32(OP_GETATTR); |
| 1124 | *p++ = cpu_to_be32(1); |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1125 | *p = cpu_to_be32(bitmap); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 1126 | hdr->nops++; |
Benny Halevy | dadf0c2 | 2009-04-01 09:22:08 -0400 | [diff] [blame] | 1127 | hdr->replen += decode_getattr_maxsz; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1128 | } |
| 1129 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1130 | 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] | 1131 | { |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 1132 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1133 | |
Benny Halevy | 13c65ce | 2009-08-14 17:19:25 +0300 | [diff] [blame] | 1134 | p = reserve_space(xdr, 16); |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1135 | *p++ = cpu_to_be32(OP_GETATTR); |
| 1136 | *p++ = cpu_to_be32(2); |
| 1137 | *p++ = cpu_to_be32(bm0); |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1138 | *p = cpu_to_be32(bm1); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 1139 | hdr->nops++; |
Benny Halevy | dadf0c2 | 2009-04-01 09:22:08 -0400 | [diff] [blame] | 1140 | hdr->replen += decode_getattr_maxsz; |
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 | |
| 1150 | p = reserve_space(xdr, 4); |
| 1151 | *p = cpu_to_be32(OP_GETATTR); |
| 1152 | if (bm2) { |
| 1153 | p = reserve_space(xdr, 16); |
| 1154 | *p++ = cpu_to_be32(3); |
| 1155 | *p++ = cpu_to_be32(bm0); |
| 1156 | *p++ = cpu_to_be32(bm1); |
| 1157 | *p = cpu_to_be32(bm2); |
| 1158 | } else if (bm1) { |
| 1159 | p = reserve_space(xdr, 12); |
| 1160 | *p++ = cpu_to_be32(2); |
| 1161 | *p++ = cpu_to_be32(bm0); |
| 1162 | *p = cpu_to_be32(bm1); |
| 1163 | } else { |
| 1164 | p = reserve_space(xdr, 8); |
| 1165 | *p++ = cpu_to_be32(1); |
| 1166 | *p = cpu_to_be32(bm0); |
| 1167 | } |
| 1168 | hdr->nops++; |
| 1169 | hdr->replen += decode_getattr_maxsz; |
| 1170 | } |
| 1171 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1172 | 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] | 1173 | { |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1174 | encode_getattr_two(xdr, bitmask[0] & nfs4_fattr_bitmap[0], |
| 1175 | bitmask[1] & nfs4_fattr_bitmap[1], hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1176 | } |
| 1177 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1178 | 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] | 1179 | { |
Fred Isaman | dae100c | 2011-07-30 20:52:37 -0400 | [diff] [blame] | 1180 | encode_getattr_three(xdr, |
| 1181 | bitmask[0] & nfs4_fsinfo_bitmap[0], |
| 1182 | bitmask[1] & nfs4_fsinfo_bitmap[1], |
| 1183 | bitmask[2] & nfs4_fsinfo_bitmap[2], |
| 1184 | hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1185 | } |
| 1186 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1187 | static void encode_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] | 1188 | { |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1189 | encode_getattr_two(xdr, bitmask[0] & nfs4_fs_locations_bitmap[0], |
| 1190 | bitmask[1] & nfs4_fs_locations_bitmap[1], hdr); |
Manoj Naik | 830b8e3 | 2006-06-09 09:34:25 -0400 | [diff] [blame] | 1191 | } |
| 1192 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1193 | static void encode_getfh(struct xdr_stream *xdr, struct compound_hdr *hdr) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1194 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 1195 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1196 | |
Benny Halevy | 13c65ce | 2009-08-14 17:19:25 +0300 | [diff] [blame] | 1197 | p = reserve_space(xdr, 4); |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1198 | *p = cpu_to_be32(OP_GETFH); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 1199 | hdr->nops++; |
Benny Halevy | dadf0c2 | 2009-04-01 09:22:08 -0400 | [diff] [blame] | 1200 | hdr->replen += decode_getfh_maxsz; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1201 | } |
| 1202 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1203 | static void encode_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] | 1204 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 1205 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1206 | |
Benny Halevy | 13c65ce | 2009-08-14 17:19:25 +0300 | [diff] [blame] | 1207 | p = reserve_space(xdr, 8 + name->len); |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1208 | *p++ = cpu_to_be32(OP_LINK); |
Benny Halevy | 811652b | 2009-08-14 17:19:34 +0300 | [diff] [blame] | 1209 | xdr_encode_opaque(p, name->name, name->len); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 1210 | hdr->nops++; |
Benny Halevy | dadf0c2 | 2009-04-01 09:22:08 -0400 | [diff] [blame] | 1211 | hdr->replen += decode_link_maxsz; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1212 | } |
| 1213 | |
Trond Myklebust | 911d1aa | 2006-01-03 09:55:16 +0100 | [diff] [blame] | 1214 | static inline int nfs4_lock_type(struct file_lock *fl, int block) |
| 1215 | { |
| 1216 | if ((fl->fl_type & (F_RDLCK|F_WRLCK|F_UNLCK)) == F_RDLCK) |
| 1217 | return block ? NFS4_READW_LT : NFS4_READ_LT; |
| 1218 | return block ? NFS4_WRITEW_LT : NFS4_WRITE_LT; |
| 1219 | } |
| 1220 | |
| 1221 | static inline uint64_t nfs4_lock_length(struct file_lock *fl) |
| 1222 | { |
| 1223 | if (fl->fl_end == OFFSET_MAX) |
| 1224 | return ~(uint64_t)0; |
| 1225 | return fl->fl_end - fl->fl_start + 1; |
| 1226 | } |
| 1227 | |
Trond Myklebust | daccbde | 2010-06-25 18:11:43 -0400 | [diff] [blame] | 1228 | static void encode_lockowner(struct xdr_stream *xdr, const struct nfs_lowner *lowner) |
| 1229 | { |
| 1230 | __be32 *p; |
| 1231 | |
Trond Myklebust | d035c36 | 2010-12-21 10:45:27 -0500 | [diff] [blame] | 1232 | p = reserve_space(xdr, 32); |
Trond Myklebust | daccbde | 2010-06-25 18:11:43 -0400 | [diff] [blame] | 1233 | p = xdr_encode_hyper(p, lowner->clientid); |
Trond Myklebust | d035c36 | 2010-12-21 10:45:27 -0500 | [diff] [blame] | 1234 | *p++ = cpu_to_be32(20); |
Trond Myklebust | daccbde | 2010-06-25 18:11:43 -0400 | [diff] [blame] | 1235 | p = xdr_encode_opaque_fixed(p, "lock id:", 8); |
Trond Myklebust | d035c36 | 2010-12-21 10:45:27 -0500 | [diff] [blame] | 1236 | *p++ = cpu_to_be32(lowner->s_dev); |
Trond Myklebust | daccbde | 2010-06-25 18:11:43 -0400 | [diff] [blame] | 1237 | xdr_encode_hyper(p, lowner->id); |
| 1238 | } |
| 1239 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1240 | /* |
| 1241 | * opcode,type,reclaim,offset,length,new_lock_owner = 32 |
| 1242 | * open_seqid,open_stateid,lock_seqid,lock_owner.clientid, lock_owner.id = 40 |
| 1243 | */ |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1244 | 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] | 1245 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 1246 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1247 | |
Benny Halevy | 13c65ce | 2009-08-14 17:19:25 +0300 | [diff] [blame] | 1248 | p = reserve_space(xdr, 32); |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1249 | *p++ = cpu_to_be32(OP_LOCK); |
| 1250 | *p++ = cpu_to_be32(nfs4_lock_type(args->fl, args->block)); |
| 1251 | *p++ = cpu_to_be32(args->reclaim); |
Benny Halevy | b95be5a | 2009-08-14 17:19:01 +0300 | [diff] [blame] | 1252 | p = xdr_encode_hyper(p, args->fl->fl_start); |
| 1253 | p = xdr_encode_hyper(p, nfs4_lock_length(args->fl)); |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1254 | *p = cpu_to_be32(args->new_lock_owner); |
Trond Myklebust | 911d1aa | 2006-01-03 09:55:16 +0100 | [diff] [blame] | 1255 | if (args->new_lock_owner){ |
Trond Myklebust | daccbde | 2010-06-25 18:11:43 -0400 | [diff] [blame] | 1256 | p = reserve_space(xdr, 4+NFS4_STATEID_SIZE+4); |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1257 | *p++ = cpu_to_be32(args->open_seqid->sequence->counter); |
Benny Halevy | 93f0cf2 | 2009-08-14 17:19:06 +0300 | [diff] [blame] | 1258 | p = xdr_encode_opaque_fixed(p, args->open_stateid->data, NFS4_STATEID_SIZE); |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1259 | *p++ = cpu_to_be32(args->lock_seqid->sequence->counter); |
Trond Myklebust | daccbde | 2010-06-25 18:11:43 -0400 | [diff] [blame] | 1260 | encode_lockowner(xdr, &args->lock_owner); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1261 | } |
| 1262 | else { |
Benny Halevy | 13c65ce | 2009-08-14 17:19:25 +0300 | [diff] [blame] | 1263 | p = reserve_space(xdr, NFS4_STATEID_SIZE+4); |
Benny Halevy | 93f0cf2 | 2009-08-14 17:19:06 +0300 | [diff] [blame] | 1264 | p = xdr_encode_opaque_fixed(p, args->lock_stateid->data, NFS4_STATEID_SIZE); |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1265 | *p = cpu_to_be32(args->lock_seqid->sequence->counter); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1266 | } |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 1267 | hdr->nops++; |
Benny Halevy | dadf0c2 | 2009-04-01 09:22:08 -0400 | [diff] [blame] | 1268 | hdr->replen += decode_lock_maxsz; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1269 | } |
| 1270 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1271 | 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] | 1272 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 1273 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1274 | |
Trond Myklebust | daccbde | 2010-06-25 18:11:43 -0400 | [diff] [blame] | 1275 | p = reserve_space(xdr, 24); |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1276 | *p++ = cpu_to_be32(OP_LOCKT); |
| 1277 | *p++ = cpu_to_be32(nfs4_lock_type(args->fl, 0)); |
Benny Halevy | b95be5a | 2009-08-14 17:19:01 +0300 | [diff] [blame] | 1278 | p = xdr_encode_hyper(p, args->fl->fl_start); |
| 1279 | p = xdr_encode_hyper(p, nfs4_lock_length(args->fl)); |
Trond Myklebust | daccbde | 2010-06-25 18:11:43 -0400 | [diff] [blame] | 1280 | encode_lockowner(xdr, &args->lock_owner); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 1281 | hdr->nops++; |
Benny Halevy | dadf0c2 | 2009-04-01 09:22:08 -0400 | [diff] [blame] | 1282 | hdr->replen += decode_lockt_maxsz; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1283 | } |
| 1284 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1285 | 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] | 1286 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 1287 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1288 | |
Benny Halevy | 13c65ce | 2009-08-14 17:19:25 +0300 | [diff] [blame] | 1289 | p = reserve_space(xdr, 12+NFS4_STATEID_SIZE+16); |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1290 | *p++ = cpu_to_be32(OP_LOCKU); |
| 1291 | *p++ = cpu_to_be32(nfs4_lock_type(args->fl, 0)); |
| 1292 | *p++ = cpu_to_be32(args->seqid->sequence->counter); |
Benny Halevy | 93f0cf2 | 2009-08-14 17:19:06 +0300 | [diff] [blame] | 1293 | p = xdr_encode_opaque_fixed(p, args->stateid->data, NFS4_STATEID_SIZE); |
Benny Halevy | b95be5a | 2009-08-14 17:19:01 +0300 | [diff] [blame] | 1294 | p = xdr_encode_hyper(p, args->fl->fl_start); |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1295 | xdr_encode_hyper(p, nfs4_lock_length(args->fl)); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 1296 | hdr->nops++; |
Benny Halevy | dadf0c2 | 2009-04-01 09:22:08 -0400 | [diff] [blame] | 1297 | hdr->replen += decode_locku_maxsz; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1298 | } |
| 1299 | |
Trond Myklebust | d3c7b7c | 2010-07-01 12:49:01 -0400 | [diff] [blame] | 1300 | static void encode_release_lockowner(struct xdr_stream *xdr, const struct nfs_lowner *lowner, struct compound_hdr *hdr) |
| 1301 | { |
| 1302 | __be32 *p; |
| 1303 | |
| 1304 | p = reserve_space(xdr, 4); |
| 1305 | *p = cpu_to_be32(OP_RELEASE_LOCKOWNER); |
| 1306 | encode_lockowner(xdr, lowner); |
| 1307 | hdr->nops++; |
| 1308 | hdr->replen += decode_release_lockowner_maxsz; |
| 1309 | } |
| 1310 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1311 | 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] | 1312 | { |
| 1313 | int len = name->len; |
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 | |
Benny Halevy | 13c65ce | 2009-08-14 17:19:25 +0300 | [diff] [blame] | 1316 | p = reserve_space(xdr, 8 + len); |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1317 | *p++ = cpu_to_be32(OP_LOOKUP); |
Benny Halevy | 811652b | 2009-08-14 17:19:34 +0300 | [diff] [blame] | 1318 | xdr_encode_opaque(p, name->name, len); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 1319 | hdr->nops++; |
Benny Halevy | dadf0c2 | 2009-04-01 09:22:08 -0400 | [diff] [blame] | 1320 | hdr->replen += decode_lookup_maxsz; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1321 | } |
| 1322 | |
Trond Myklebust | dc0b027 | 2008-12-23 15:21:56 -0500 | [diff] [blame] | 1323 | static void encode_share_access(struct xdr_stream *xdr, fmode_t fmode) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1324 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 1325 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1326 | |
Benny Halevy | 13c65ce | 2009-08-14 17:19:25 +0300 | [diff] [blame] | 1327 | p = reserve_space(xdr, 8); |
Trond Myklebust | dc0b027 | 2008-12-23 15:21:56 -0500 | [diff] [blame] | 1328 | switch (fmode & (FMODE_READ|FMODE_WRITE)) { |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 1329 | case FMODE_READ: |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1330 | *p++ = cpu_to_be32(NFS4_SHARE_ACCESS_READ); |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 1331 | break; |
| 1332 | case FMODE_WRITE: |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1333 | *p++ = cpu_to_be32(NFS4_SHARE_ACCESS_WRITE); |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 1334 | break; |
| 1335 | case FMODE_READ|FMODE_WRITE: |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1336 | *p++ = cpu_to_be32(NFS4_SHARE_ACCESS_BOTH); |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 1337 | break; |
| 1338 | default: |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1339 | *p++ = cpu_to_be32(0); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1340 | } |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1341 | *p = cpu_to_be32(0); /* for linux, share_deny = 0 always */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1342 | } |
| 1343 | |
| 1344 | static inline void encode_openhdr(struct xdr_stream *xdr, const struct nfs_openargs *arg) |
| 1345 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 1346 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1347 | /* |
| 1348 | * opcode 4, seqid 4, share_access 4, share_deny 4, clientid 8, ownerlen 4, |
| 1349 | * owner 4 = 32 |
| 1350 | */ |
Benny Halevy | 13c65ce | 2009-08-14 17:19:25 +0300 | [diff] [blame] | 1351 | p = reserve_space(xdr, 8); |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1352 | *p++ = cpu_to_be32(OP_OPEN); |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1353 | *p = cpu_to_be32(arg->seqid->sequence->counter); |
Trond Myklebust | dc0b027 | 2008-12-23 15:21:56 -0500 | [diff] [blame] | 1354 | encode_share_access(xdr, arg->fmode); |
Trond Myklebust | d035c36 | 2010-12-21 10:45:27 -0500 | [diff] [blame] | 1355 | p = reserve_space(xdr, 32); |
Benny Halevy | b95be5a | 2009-08-14 17:19:01 +0300 | [diff] [blame] | 1356 | p = xdr_encode_hyper(p, arg->clientid); |
Trond Myklebust | d035c36 | 2010-12-21 10:45:27 -0500 | [diff] [blame] | 1357 | *p++ = cpu_to_be32(20); |
Benny Halevy | 93f0cf2 | 2009-08-14 17:19:06 +0300 | [diff] [blame] | 1358 | p = xdr_encode_opaque_fixed(p, "open id:", 8); |
Trond Myklebust | d035c36 | 2010-12-21 10:45:27 -0500 | [diff] [blame] | 1359 | *p++ = cpu_to_be32(arg->server->s_dev); |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1360 | xdr_encode_hyper(p, arg->id); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1361 | } |
| 1362 | |
| 1363 | static inline void encode_createmode(struct xdr_stream *xdr, const struct nfs_openargs *arg) |
| 1364 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 1365 | __be32 *p; |
Alexandros Batsakis | 4882ef7 | 2009-12-05 13:30:21 -0500 | [diff] [blame] | 1366 | struct nfs_client *clp; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1367 | |
Benny Halevy | 13c65ce | 2009-08-14 17:19:25 +0300 | [diff] [blame] | 1368 | p = reserve_space(xdr, 4); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1369 | switch(arg->open_flags & O_EXCL) { |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 1370 | case 0: |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1371 | *p = cpu_to_be32(NFS4_CREATE_UNCHECKED); |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 1372 | encode_attrs(xdr, arg->u.attrs, arg->server); |
| 1373 | break; |
| 1374 | default: |
Alexandros Batsakis | 4882ef7 | 2009-12-05 13:30:21 -0500 | [diff] [blame] | 1375 | clp = arg->server->nfs_client; |
Trond Myklebust | a443234 | 2010-06-16 09:52:27 -0400 | [diff] [blame] | 1376 | if (clp->cl_mvops->minor_version > 0) { |
Alexandros Batsakis | 4882ef7 | 2009-12-05 13:30:21 -0500 | [diff] [blame] | 1377 | if (nfs4_has_persistent_session(clp)) { |
| 1378 | *p = cpu_to_be32(NFS4_CREATE_GUARDED); |
| 1379 | encode_attrs(xdr, arg->u.attrs, arg->server); |
| 1380 | } else { |
| 1381 | struct iattr dummy; |
| 1382 | |
| 1383 | *p = cpu_to_be32(NFS4_CREATE_EXCLUSIVE4_1); |
| 1384 | encode_nfs4_verifier(xdr, &arg->u.verifier); |
| 1385 | dummy.ia_valid = 0; |
| 1386 | encode_attrs(xdr, &dummy, arg->server); |
| 1387 | } |
| 1388 | } else { |
| 1389 | *p = cpu_to_be32(NFS4_CREATE_EXCLUSIVE); |
| 1390 | encode_nfs4_verifier(xdr, &arg->u.verifier); |
| 1391 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1392 | } |
| 1393 | } |
| 1394 | |
| 1395 | static void encode_opentype(struct xdr_stream *xdr, const struct nfs_openargs *arg) |
| 1396 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 1397 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1398 | |
Benny Halevy | 13c65ce | 2009-08-14 17:19:25 +0300 | [diff] [blame] | 1399 | p = reserve_space(xdr, 4); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1400 | switch (arg->open_flags & O_CREAT) { |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 1401 | case 0: |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1402 | *p = cpu_to_be32(NFS4_OPEN_NOCREATE); |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 1403 | break; |
| 1404 | default: |
| 1405 | BUG_ON(arg->claim != NFS4_OPEN_CLAIM_NULL); |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1406 | *p = cpu_to_be32(NFS4_OPEN_CREATE); |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 1407 | encode_createmode(xdr, arg); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1408 | } |
| 1409 | } |
| 1410 | |
Trond Myklebust | bd7bf9d | 2008-12-23 15:21:53 -0500 | [diff] [blame] | 1411 | 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] | 1412 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 1413 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1414 | |
Benny Halevy | 13c65ce | 2009-08-14 17:19:25 +0300 | [diff] [blame] | 1415 | p = reserve_space(xdr, 4); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1416 | switch (delegation_type) { |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 1417 | case 0: |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1418 | *p = cpu_to_be32(NFS4_OPEN_DELEGATE_NONE); |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 1419 | break; |
| 1420 | case FMODE_READ: |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1421 | *p = cpu_to_be32(NFS4_OPEN_DELEGATE_READ); |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 1422 | break; |
| 1423 | case FMODE_WRITE|FMODE_READ: |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1424 | *p = cpu_to_be32(NFS4_OPEN_DELEGATE_WRITE); |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 1425 | break; |
| 1426 | default: |
| 1427 | BUG(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1428 | } |
| 1429 | } |
| 1430 | |
| 1431 | static inline void encode_claim_null(struct xdr_stream *xdr, const struct qstr *name) |
| 1432 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 1433 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1434 | |
Benny Halevy | 13c65ce | 2009-08-14 17:19:25 +0300 | [diff] [blame] | 1435 | p = reserve_space(xdr, 4); |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1436 | *p = cpu_to_be32(NFS4_OPEN_CLAIM_NULL); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1437 | encode_string(xdr, name->len, name->name); |
| 1438 | } |
| 1439 | |
Trond Myklebust | bd7bf9d | 2008-12-23 15:21:53 -0500 | [diff] [blame] | 1440 | 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] | 1441 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 1442 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1443 | |
Benny Halevy | 13c65ce | 2009-08-14 17:19:25 +0300 | [diff] [blame] | 1444 | p = reserve_space(xdr, 4); |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1445 | *p = cpu_to_be32(NFS4_OPEN_CLAIM_PREVIOUS); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1446 | encode_delegation_type(xdr, type); |
| 1447 | } |
| 1448 | |
| 1449 | static inline void encode_claim_delegate_cur(struct xdr_stream *xdr, const struct qstr *name, const nfs4_stateid *stateid) |
| 1450 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 1451 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1452 | |
Benny Halevy | 13c65ce | 2009-08-14 17:19:25 +0300 | [diff] [blame] | 1453 | p = reserve_space(xdr, 4+NFS4_STATEID_SIZE); |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1454 | *p++ = cpu_to_be32(NFS4_OPEN_CLAIM_DELEGATE_CUR); |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1455 | xdr_encode_opaque_fixed(p, stateid->data, NFS4_STATEID_SIZE); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1456 | encode_string(xdr, name->len, name->name); |
| 1457 | } |
| 1458 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1459 | 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] | 1460 | { |
| 1461 | encode_openhdr(xdr, arg); |
| 1462 | encode_opentype(xdr, arg); |
| 1463 | switch (arg->claim) { |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 1464 | case NFS4_OPEN_CLAIM_NULL: |
| 1465 | encode_claim_null(xdr, arg->name); |
| 1466 | break; |
| 1467 | case NFS4_OPEN_CLAIM_PREVIOUS: |
| 1468 | encode_claim_previous(xdr, arg->u.delegation_type); |
| 1469 | break; |
| 1470 | case NFS4_OPEN_CLAIM_DELEGATE_CUR: |
| 1471 | encode_claim_delegate_cur(xdr, arg->name, &arg->u.delegation); |
| 1472 | break; |
| 1473 | default: |
| 1474 | BUG(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1475 | } |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 1476 | hdr->nops++; |
Benny Halevy | dadf0c2 | 2009-04-01 09:22:08 -0400 | [diff] [blame] | 1477 | hdr->replen += decode_open_maxsz; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1478 | } |
| 1479 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1480 | 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] | 1481 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 1482 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1483 | |
Benny Halevy | 13c65ce | 2009-08-14 17:19:25 +0300 | [diff] [blame] | 1484 | p = reserve_space(xdr, 4+NFS4_STATEID_SIZE+4); |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1485 | *p++ = cpu_to_be32(OP_OPEN_CONFIRM); |
Benny Halevy | 93f0cf2 | 2009-08-14 17:19:06 +0300 | [diff] [blame] | 1486 | p = xdr_encode_opaque_fixed(p, arg->stateid->data, NFS4_STATEID_SIZE); |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1487 | *p = cpu_to_be32(arg->seqid->sequence->counter); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 1488 | hdr->nops++; |
Benny Halevy | dadf0c2 | 2009-04-01 09:22:08 -0400 | [diff] [blame] | 1489 | hdr->replen += decode_open_confirm_maxsz; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1490 | } |
| 1491 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1492 | 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] | 1493 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 1494 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1495 | |
Benny Halevy | 13c65ce | 2009-08-14 17:19:25 +0300 | [diff] [blame] | 1496 | p = reserve_space(xdr, 4+NFS4_STATEID_SIZE+4); |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1497 | *p++ = cpu_to_be32(OP_OPEN_DOWNGRADE); |
Benny Halevy | 93f0cf2 | 2009-08-14 17:19:06 +0300 | [diff] [blame] | 1498 | p = xdr_encode_opaque_fixed(p, arg->stateid->data, NFS4_STATEID_SIZE); |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1499 | *p = cpu_to_be32(arg->seqid->sequence->counter); |
Trond Myklebust | dc0b027 | 2008-12-23 15:21:56 -0500 | [diff] [blame] | 1500 | encode_share_access(xdr, arg->fmode); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 1501 | hdr->nops++; |
Benny Halevy | dadf0c2 | 2009-04-01 09:22:08 -0400 | [diff] [blame] | 1502 | hdr->replen += decode_open_downgrade_maxsz; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1503 | } |
| 1504 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1505 | static void |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 1506 | 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] | 1507 | { |
| 1508 | int len = fh->size; |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 1509 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1510 | |
Benny Halevy | 13c65ce | 2009-08-14 17:19:25 +0300 | [diff] [blame] | 1511 | p = reserve_space(xdr, 8 + len); |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1512 | *p++ = cpu_to_be32(OP_PUTFH); |
Benny Halevy | 811652b | 2009-08-14 17:19:34 +0300 | [diff] [blame] | 1513 | xdr_encode_opaque(p, fh->data, len); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 1514 | hdr->nops++; |
Benny Halevy | dadf0c2 | 2009-04-01 09:22:08 -0400 | [diff] [blame] | 1515 | hdr->replen += decode_putfh_maxsz; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1516 | } |
| 1517 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1518 | static void encode_putrootfh(struct xdr_stream *xdr, struct compound_hdr *hdr) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1519 | { |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 1520 | __be32 *p; |
Andy Adamson | 6c0195a | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 1521 | |
Benny Halevy | 13c65ce | 2009-08-14 17:19:25 +0300 | [diff] [blame] | 1522 | p = reserve_space(xdr, 4); |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1523 | *p = cpu_to_be32(OP_PUTROOTFH); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 1524 | hdr->nops++; |
Benny Halevy | dadf0c2 | 2009-04-01 09:22:08 -0400 | [diff] [blame] | 1525 | hdr->replen += decode_putrootfh_maxsz; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1526 | } |
| 1527 | |
Andy Adamson | 89d1ea6 | 2011-03-01 01:34:09 +0000 | [diff] [blame] | 1528 | static void encode_stateid(struct xdr_stream *xdr, const struct nfs_open_context *ctx, const struct nfs_lock_context *l_ctx, int zero_seqid) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1529 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1530 | nfs4_stateid stateid; |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 1531 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1532 | |
Benny Halevy | 13c65ce | 2009-08-14 17:19:25 +0300 | [diff] [blame] | 1533 | p = reserve_space(xdr, NFS4_STATEID_SIZE); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1534 | if (ctx->state != NULL) { |
Trond Myklebust | 77041ed | 2010-07-01 12:49:11 -0400 | [diff] [blame] | 1535 | nfs4_copy_stateid(&stateid, ctx->state, l_ctx->lockowner, l_ctx->pid); |
Andy Adamson | 89d1ea6 | 2011-03-01 01:34:09 +0000 | [diff] [blame] | 1536 | if (zero_seqid) |
| 1537 | stateid.stateid.seqid = 0; |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1538 | xdr_encode_opaque_fixed(p, stateid.data, NFS4_STATEID_SIZE); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1539 | } else |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1540 | xdr_encode_opaque_fixed(p, zero_stateid.data, NFS4_STATEID_SIZE); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1541 | } |
| 1542 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1543 | static void encode_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] | 1544 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 1545 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1546 | |
Benny Halevy | 13c65ce | 2009-08-14 17:19:25 +0300 | [diff] [blame] | 1547 | p = reserve_space(xdr, 4); |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1548 | *p = cpu_to_be32(OP_READ); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1549 | |
Andy Adamson | 89d1ea6 | 2011-03-01 01:34:09 +0000 | [diff] [blame] | 1550 | encode_stateid(xdr, args->context, args->lock_context, |
| 1551 | hdr->minorversion); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1552 | |
Benny Halevy | 13c65ce | 2009-08-14 17:19:25 +0300 | [diff] [blame] | 1553 | p = reserve_space(xdr, 12); |
Benny Halevy | b95be5a | 2009-08-14 17:19:01 +0300 | [diff] [blame] | 1554 | p = xdr_encode_hyper(p, args->offset); |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1555 | *p = cpu_to_be32(args->count); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 1556 | hdr->nops++; |
Benny Halevy | dadf0c2 | 2009-04-01 09:22:08 -0400 | [diff] [blame] | 1557 | hdr->replen += decode_read_maxsz; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1558 | } |
| 1559 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1560 | 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] | 1561 | { |
Trond Myklebust | 28331a4 | 2011-04-27 13:47:52 -0400 | [diff] [blame] | 1562 | uint32_t attrs[2] = { |
| 1563 | FATTR4_WORD0_RDATTR_ERROR, |
| 1564 | FATTR4_WORD1_MOUNTED_ON_FILEID, |
| 1565 | }; |
Trond Myklebust | 6f7a35b | 2010-10-24 12:11:42 -0400 | [diff] [blame] | 1566 | uint32_t dircount = readdir->count >> 1; |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 1567 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1568 | |
Bryan Schumaker | 82f2e54 | 2010-10-21 16:33:18 -0400 | [diff] [blame] | 1569 | if (readdir->plus) { |
| 1570 | attrs[0] |= FATTR4_WORD0_TYPE|FATTR4_WORD0_CHANGE|FATTR4_WORD0_SIZE| |
Trond Myklebust | 28331a4 | 2011-04-27 13:47:52 -0400 | [diff] [blame] | 1571 | FATTR4_WORD0_FSID|FATTR4_WORD0_FILEHANDLE|FATTR4_WORD0_FILEID; |
Bryan Schumaker | 82f2e54 | 2010-10-21 16:33:18 -0400 | [diff] [blame] | 1572 | attrs[1] |= FATTR4_WORD1_MODE|FATTR4_WORD1_NUMLINKS|FATTR4_WORD1_OWNER| |
| 1573 | FATTR4_WORD1_OWNER_GROUP|FATTR4_WORD1_RAWDEV| |
| 1574 | FATTR4_WORD1_SPACE_USED|FATTR4_WORD1_TIME_ACCESS| |
| 1575 | FATTR4_WORD1_TIME_METADATA|FATTR4_WORD1_TIME_MODIFY; |
Trond Myklebust | 6f7a35b | 2010-10-24 12:11:42 -0400 | [diff] [blame] | 1576 | dircount >>= 1; |
Bryan Schumaker | 82f2e54 | 2010-10-21 16:33:18 -0400 | [diff] [blame] | 1577 | } |
Trond Myklebust | 28331a4 | 2011-04-27 13:47:52 -0400 | [diff] [blame] | 1578 | /* Use mounted_on_fileid only if the server supports it */ |
| 1579 | if (!(readdir->bitmask[1] & FATTR4_WORD1_MOUNTED_ON_FILEID)) |
| 1580 | attrs[0] |= FATTR4_WORD0_FILEID; |
Bryan Schumaker | 82f2e54 | 2010-10-21 16:33:18 -0400 | [diff] [blame] | 1581 | |
Benny Halevy | 13c65ce | 2009-08-14 17:19:25 +0300 | [diff] [blame] | 1582 | p = reserve_space(xdr, 12+NFS4_VERIFIER_SIZE+20); |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1583 | *p++ = cpu_to_be32(OP_READDIR); |
Benny Halevy | b95be5a | 2009-08-14 17:19:01 +0300 | [diff] [blame] | 1584 | p = xdr_encode_hyper(p, readdir->cookie); |
Benny Halevy | 93f0cf2 | 2009-08-14 17:19:06 +0300 | [diff] [blame] | 1585 | p = xdr_encode_opaque_fixed(p, readdir->verifier.data, NFS4_VERIFIER_SIZE); |
Trond Myklebust | 6f7a35b | 2010-10-24 12:11:42 -0400 | [diff] [blame] | 1586 | *p++ = cpu_to_be32(dircount); |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1587 | *p++ = cpu_to_be32(readdir->count); |
| 1588 | *p++ = cpu_to_be32(2); |
Bryan Schumaker | 82f2e54 | 2010-10-21 16:33:18 -0400 | [diff] [blame] | 1589 | |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1590 | *p++ = cpu_to_be32(attrs[0] & readdir->bitmask[0]); |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1591 | *p = cpu_to_be32(attrs[1] & readdir->bitmask[1]); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 1592 | hdr->nops++; |
Benny Halevy | dadf0c2 | 2009-04-01 09:22:08 -0400 | [diff] [blame] | 1593 | hdr->replen += decode_readdir_maxsz; |
Fred Isaman | 4410924 | 2008-04-02 15:21:15 +0300 | [diff] [blame] | 1594 | dprintk("%s: cookie = %Lu, verifier = %08x:%08x, bitmap = %08x:%08x\n", |
| 1595 | __func__, |
Trond Myklebust | eadf459 | 2005-06-22 17:16:39 +0000 | [diff] [blame] | 1596 | (unsigned long long)readdir->cookie, |
| 1597 | ((u32 *)readdir->verifier.data)[0], |
| 1598 | ((u32 *)readdir->verifier.data)[1], |
| 1599 | attrs[0] & readdir->bitmask[0], |
| 1600 | attrs[1] & readdir->bitmask[1]); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1601 | } |
| 1602 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1603 | 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] | 1604 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 1605 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1606 | |
Benny Halevy | 13c65ce | 2009-08-14 17:19:25 +0300 | [diff] [blame] | 1607 | p = reserve_space(xdr, 4); |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1608 | *p = cpu_to_be32(OP_READLINK); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 1609 | hdr->nops++; |
Benny Halevy | dadf0c2 | 2009-04-01 09:22:08 -0400 | [diff] [blame] | 1610 | hdr->replen += decode_readlink_maxsz; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1611 | } |
| 1612 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1613 | 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] | 1614 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 1615 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1616 | |
Benny Halevy | 13c65ce | 2009-08-14 17:19:25 +0300 | [diff] [blame] | 1617 | p = reserve_space(xdr, 8 + name->len); |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1618 | *p++ = cpu_to_be32(OP_REMOVE); |
Benny Halevy | 811652b | 2009-08-14 17:19:34 +0300 | [diff] [blame] | 1619 | xdr_encode_opaque(p, name->name, name->len); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 1620 | hdr->nops++; |
Benny Halevy | dadf0c2 | 2009-04-01 09:22:08 -0400 | [diff] [blame] | 1621 | hdr->replen += decode_remove_maxsz; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1622 | } |
| 1623 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1624 | 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] | 1625 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 1626 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1627 | |
Benny Halevy | 811652b | 2009-08-14 17:19:34 +0300 | [diff] [blame] | 1628 | p = reserve_space(xdr, 4); |
| 1629 | *p = cpu_to_be32(OP_RENAME); |
| 1630 | encode_string(xdr, oldname->len, oldname->name); |
| 1631 | encode_string(xdr, newname->len, newname->name); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 1632 | hdr->nops++; |
Benny Halevy | dadf0c2 | 2009-04-01 09:22:08 -0400 | [diff] [blame] | 1633 | hdr->replen += decode_rename_maxsz; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1634 | } |
| 1635 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1636 | static void encode_renew(struct xdr_stream *xdr, const struct nfs_client *client_stateid, struct compound_hdr *hdr) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1637 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 1638 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1639 | |
Benny Halevy | 13c65ce | 2009-08-14 17:19:25 +0300 | [diff] [blame] | 1640 | p = reserve_space(xdr, 12); |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1641 | *p++ = cpu_to_be32(OP_RENEW); |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1642 | xdr_encode_hyper(p, client_stateid->cl_clientid); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 1643 | hdr->nops++; |
Benny Halevy | dadf0c2 | 2009-04-01 09:22:08 -0400 | [diff] [blame] | 1644 | hdr->replen += decode_renew_maxsz; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1645 | } |
| 1646 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1647 | static void |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 1648 | encode_restorefh(struct xdr_stream *xdr, struct compound_hdr *hdr) |
Trond Myklebust | 56ae19f | 2005-10-27 22:12:40 -0400 | [diff] [blame] | 1649 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 1650 | __be32 *p; |
Trond Myklebust | 56ae19f | 2005-10-27 22:12:40 -0400 | [diff] [blame] | 1651 | |
Benny Halevy | 13c65ce | 2009-08-14 17:19:25 +0300 | [diff] [blame] | 1652 | p = reserve_space(xdr, 4); |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1653 | *p = cpu_to_be32(OP_RESTOREFH); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 1654 | hdr->nops++; |
Benny Halevy | dadf0c2 | 2009-04-01 09:22:08 -0400 | [diff] [blame] | 1655 | hdr->replen += decode_restorefh_maxsz; |
Trond Myklebust | 56ae19f | 2005-10-27 22:12:40 -0400 | [diff] [blame] | 1656 | } |
| 1657 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 1658 | static void |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 1659 | 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] | 1660 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 1661 | __be32 *p; |
J. Bruce Fields | 23ec696 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 1662 | |
Benny Halevy | 13c65ce | 2009-08-14 17:19:25 +0300 | [diff] [blame] | 1663 | p = reserve_space(xdr, 4+NFS4_STATEID_SIZE); |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1664 | *p++ = cpu_to_be32(OP_SETATTR); |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1665 | xdr_encode_opaque_fixed(p, zero_stateid.data, NFS4_STATEID_SIZE); |
Benny Halevy | 13c65ce | 2009-08-14 17:19:25 +0300 | [diff] [blame] | 1666 | p = reserve_space(xdr, 2*4); |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1667 | *p++ = cpu_to_be32(1); |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1668 | *p = cpu_to_be32(FATTR4_WORD0_ACL); |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 1669 | BUG_ON(arg->acl_len % 4); |
Benny Halevy | 13c65ce | 2009-08-14 17:19:25 +0300 | [diff] [blame] | 1670 | p = reserve_space(xdr, 4); |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1671 | *p = cpu_to_be32(arg->acl_len); |
J. Bruce Fields | 23ec696 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 1672 | xdr_write_pages(xdr, arg->acl_pages, arg->acl_pgbase, arg->acl_len); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 1673 | hdr->nops++; |
Benny Halevy | dadf0c2 | 2009-04-01 09:22:08 -0400 | [diff] [blame] | 1674 | hdr->replen += decode_setacl_maxsz; |
J. Bruce Fields | 23ec696 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 1675 | } |
| 1676 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1677 | static void |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 1678 | encode_savefh(struct xdr_stream *xdr, struct compound_hdr *hdr) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1679 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 1680 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1681 | |
Benny Halevy | 13c65ce | 2009-08-14 17:19:25 +0300 | [diff] [blame] | 1682 | p = reserve_space(xdr, 4); |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1683 | *p = cpu_to_be32(OP_SAVEFH); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 1684 | hdr->nops++; |
Benny Halevy | dadf0c2 | 2009-04-01 09:22:08 -0400 | [diff] [blame] | 1685 | hdr->replen += decode_savefh_maxsz; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1686 | } |
| 1687 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1688 | 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] | 1689 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 1690 | __be32 *p; |
Andy Adamson | 6c0195a | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 1691 | |
Benny Halevy | 13c65ce | 2009-08-14 17:19:25 +0300 | [diff] [blame] | 1692 | p = reserve_space(xdr, 4+NFS4_STATEID_SIZE); |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1693 | *p++ = cpu_to_be32(OP_SETATTR); |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1694 | xdr_encode_opaque_fixed(p, arg->stateid.data, NFS4_STATEID_SIZE); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 1695 | hdr->nops++; |
Benny Halevy | dadf0c2 | 2009-04-01 09:22:08 -0400 | [diff] [blame] | 1696 | hdr->replen += decode_setattr_maxsz; |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1697 | encode_attrs(xdr, arg->iap, server); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1698 | } |
| 1699 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1700 | 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] | 1701 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 1702 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1703 | |
Benny Halevy | 13c65ce | 2009-08-14 17:19:25 +0300 | [diff] [blame] | 1704 | p = reserve_space(xdr, 4 + NFS4_VERIFIER_SIZE); |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1705 | *p++ = cpu_to_be32(OP_SETCLIENTID); |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1706 | xdr_encode_opaque_fixed(p, setclientid->sc_verifier->data, NFS4_VERIFIER_SIZE); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1707 | |
| 1708 | encode_string(xdr, setclientid->sc_name_len, setclientid->sc_name); |
Benny Halevy | 13c65ce | 2009-08-14 17:19:25 +0300 | [diff] [blame] | 1709 | p = reserve_space(xdr, 4); |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1710 | *p = cpu_to_be32(setclientid->sc_prog); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1711 | encode_string(xdr, setclientid->sc_netid_len, setclientid->sc_netid); |
| 1712 | encode_string(xdr, setclientid->sc_uaddr_len, setclientid->sc_uaddr); |
Benny Halevy | 13c65ce | 2009-08-14 17:19:25 +0300 | [diff] [blame] | 1713 | p = reserve_space(xdr, 4); |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1714 | *p = cpu_to_be32(setclientid->sc_cb_ident); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 1715 | hdr->nops++; |
Benny Halevy | dadf0c2 | 2009-04-01 09:22:08 -0400 | [diff] [blame] | 1716 | hdr->replen += decode_setclientid_maxsz; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1717 | } |
| 1718 | |
Trond Myklebust | bb8b27e | 2010-04-16 16:43:06 -0400 | [diff] [blame] | 1719 | static void encode_setclientid_confirm(struct xdr_stream *xdr, const struct nfs4_setclientid_res *arg, struct compound_hdr *hdr) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1720 | { |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 1721 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1722 | |
Benny Halevy | 13c65ce | 2009-08-14 17:19:25 +0300 | [diff] [blame] | 1723 | p = reserve_space(xdr, 12 + NFS4_VERIFIER_SIZE); |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1724 | *p++ = cpu_to_be32(OP_SETCLIENTID_CONFIRM); |
Trond Myklebust | bb8b27e | 2010-04-16 16:43:06 -0400 | [diff] [blame] | 1725 | p = xdr_encode_hyper(p, arg->clientid); |
| 1726 | xdr_encode_opaque_fixed(p, arg->confirm.data, NFS4_VERIFIER_SIZE); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 1727 | hdr->nops++; |
Benny Halevy | dadf0c2 | 2009-04-01 09:22:08 -0400 | [diff] [blame] | 1728 | hdr->replen += decode_setclientid_confirm_maxsz; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1729 | } |
| 1730 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1731 | 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] | 1732 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 1733 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1734 | |
Benny Halevy | 13c65ce | 2009-08-14 17:19:25 +0300 | [diff] [blame] | 1735 | p = reserve_space(xdr, 4); |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1736 | *p = cpu_to_be32(OP_WRITE); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1737 | |
Andy Adamson | 89d1ea6 | 2011-03-01 01:34:09 +0000 | [diff] [blame] | 1738 | encode_stateid(xdr, args->context, args->lock_context, |
| 1739 | hdr->minorversion); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1740 | |
Benny Halevy | 13c65ce | 2009-08-14 17:19:25 +0300 | [diff] [blame] | 1741 | p = reserve_space(xdr, 16); |
Benny Halevy | b95be5a | 2009-08-14 17:19:01 +0300 | [diff] [blame] | 1742 | p = xdr_encode_hyper(p, args->offset); |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1743 | *p++ = cpu_to_be32(args->stable); |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1744 | *p = cpu_to_be32(args->count); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1745 | |
| 1746 | xdr_write_pages(xdr, args->pages, args->pgbase, args->count); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 1747 | hdr->nops++; |
Benny Halevy | dadf0c2 | 2009-04-01 09:22:08 -0400 | [diff] [blame] | 1748 | hdr->replen += decode_write_maxsz; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1749 | } |
| 1750 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1751 | 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] | 1752 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 1753 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1754 | |
Benny Halevy | 13c65ce | 2009-08-14 17:19:25 +0300 | [diff] [blame] | 1755 | p = reserve_space(xdr, 4+NFS4_STATEID_SIZE); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1756 | |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1757 | *p++ = cpu_to_be32(OP_DELEGRETURN); |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1758 | xdr_encode_opaque_fixed(p, stateid->data, NFS4_STATEID_SIZE); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 1759 | hdr->nops++; |
Benny Halevy | dadf0c2 | 2009-04-01 09:22:08 -0400 | [diff] [blame] | 1760 | hdr->replen += decode_delegreturn_maxsz; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1761 | } |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 1762 | |
Bryan Schumaker | 5a5ea0d | 2011-03-24 17:12:29 +0000 | [diff] [blame] | 1763 | static void encode_secinfo(struct xdr_stream *xdr, const struct qstr *name, struct compound_hdr *hdr) |
| 1764 | { |
| 1765 | int len = name->len; |
| 1766 | __be32 *p; |
| 1767 | |
| 1768 | p = reserve_space(xdr, 8 + len); |
| 1769 | *p++ = cpu_to_be32(OP_SECINFO); |
| 1770 | xdr_encode_opaque(p, name->name, len); |
| 1771 | hdr->nops++; |
| 1772 | hdr->replen += decode_secinfo_maxsz; |
| 1773 | } |
| 1774 | |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 1775 | #if defined(CONFIG_NFS_V4_1) |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 1776 | /* NFSv4.1 operations */ |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 1777 | static void encode_exchange_id(struct xdr_stream *xdr, |
| 1778 | struct nfs41_exchange_id_args *args, |
| 1779 | struct compound_hdr *hdr) |
| 1780 | { |
| 1781 | __be32 *p; |
Weston Andros Adamson | db8ac8b | 2012-02-17 15:20:24 -0500 | [diff] [blame^] | 1782 | char impl_name[NFS4_OPAQUE_LIMIT]; |
| 1783 | int len = 0; |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 1784 | |
Benny Halevy | 13c65ce | 2009-08-14 17:19:25 +0300 | [diff] [blame] | 1785 | p = reserve_space(xdr, 4 + sizeof(args->verifier->data)); |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1786 | *p++ = cpu_to_be32(OP_EXCHANGE_ID); |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1787 | xdr_encode_opaque_fixed(p, args->verifier->data, sizeof(args->verifier->data)); |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 1788 | |
| 1789 | encode_string(xdr, args->id_len, args->id); |
| 1790 | |
Benny Halevy | 13c65ce | 2009-08-14 17:19:25 +0300 | [diff] [blame] | 1791 | p = reserve_space(xdr, 12); |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1792 | *p++ = cpu_to_be32(args->flags); |
| 1793 | *p++ = cpu_to_be32(0); /* zero length state_protect4_a */ |
Weston Andros Adamson | db8ac8b | 2012-02-17 15:20:24 -0500 | [diff] [blame^] | 1794 | |
| 1795 | if (send_implementation_id && |
| 1796 | sizeof(CONFIG_NFS_V4_1_IMPLEMENTATION_ID_DOMAIN) > 1 && |
| 1797 | sizeof(CONFIG_NFS_V4_1_IMPLEMENTATION_ID_DOMAIN) |
| 1798 | <= NFS4_OPAQUE_LIMIT + 1) |
| 1799 | len = snprintf(impl_name, sizeof(impl_name), "%s %s %s %s", |
| 1800 | utsname()->sysname, utsname()->release, |
| 1801 | utsname()->version, utsname()->machine); |
| 1802 | |
| 1803 | if (len > 0) { |
| 1804 | *p = cpu_to_be32(1); /* implementation id array length=1 */ |
| 1805 | |
| 1806 | encode_string(xdr, |
| 1807 | sizeof(CONFIG_NFS_V4_1_IMPLEMENTATION_ID_DOMAIN) - 1, |
| 1808 | CONFIG_NFS_V4_1_IMPLEMENTATION_ID_DOMAIN); |
| 1809 | encode_string(xdr, len, impl_name); |
| 1810 | /* just send zeros for nii_date - the date is in nii_name */ |
| 1811 | p = reserve_space(xdr, 12); |
| 1812 | p = xdr_encode_hyper(p, 0); |
| 1813 | *p = cpu_to_be32(0); |
| 1814 | } else |
| 1815 | *p = cpu_to_be32(0); /* implementation id array length=0 */ |
| 1816 | |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 1817 | hdr->nops++; |
| 1818 | hdr->replen += decode_exchange_id_maxsz; |
| 1819 | } |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 1820 | |
| 1821 | static void encode_create_session(struct xdr_stream *xdr, |
| 1822 | struct nfs41_create_session_args *args, |
| 1823 | struct compound_hdr *hdr) |
| 1824 | { |
| 1825 | __be32 *p; |
| 1826 | char machine_name[NFS4_MAX_MACHINE_NAME_LEN]; |
| 1827 | uint32_t len; |
| 1828 | struct nfs_client *clp = args->client; |
Mike Sager | 8e0d46e | 2009-12-17 12:06:26 -0500 | [diff] [blame] | 1829 | u32 max_resp_sz_cached; |
| 1830 | |
| 1831 | /* |
| 1832 | * Assumes OPEN is the biggest non-idempotent compound. |
| 1833 | * 2 is the verifier. |
| 1834 | */ |
| 1835 | max_resp_sz_cached = (NFS4_dec_open_sz + RPC_REPHDRSIZE + |
| 1836 | RPC_MAX_AUTH_SIZE + 2) * XDR_UNIT; |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 1837 | |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 1838 | len = scnprintf(machine_name, sizeof(machine_name), "%s", |
| 1839 | clp->cl_ipaddr); |
Benny Halevy | 42edd69 | 2009-08-14 17:19:13 +0300 | [diff] [blame] | 1840 | |
Benny Halevy | 13c65ce | 2009-08-14 17:19:25 +0300 | [diff] [blame] | 1841 | p = reserve_space(xdr, 20 + 2*28 + 20 + len + 12); |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1842 | *p++ = cpu_to_be32(OP_CREATE_SESSION); |
Andy Adamson | 114f64b | 2011-03-09 13:13:45 -0500 | [diff] [blame] | 1843 | p = xdr_encode_hyper(p, clp->cl_clientid); |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1844 | *p++ = cpu_to_be32(clp->cl_seqid); /*Sequence id */ |
| 1845 | *p++ = cpu_to_be32(args->flags); /*flags */ |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 1846 | |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 1847 | /* Fore Channel */ |
Benny Halevy | c9c30dd | 2011-06-11 17:08:39 -0400 | [diff] [blame] | 1848 | *p++ = cpu_to_be32(0); /* header padding size */ |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1849 | *p++ = cpu_to_be32(args->fc_attrs.max_rqst_sz); /* max req size */ |
| 1850 | *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] | 1851 | *p++ = cpu_to_be32(max_resp_sz_cached); /* Max resp sz cached */ |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1852 | *p++ = cpu_to_be32(args->fc_attrs.max_ops); /* max operations */ |
| 1853 | *p++ = cpu_to_be32(args->fc_attrs.max_reqs); /* max requests */ |
| 1854 | *p++ = cpu_to_be32(0); /* rdmachannel_attrs */ |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 1855 | |
| 1856 | /* Back Channel */ |
Benny Halevy | c9c30dd | 2011-06-11 17:08:39 -0400 | [diff] [blame] | 1857 | *p++ = cpu_to_be32(0); /* header padding size */ |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1858 | *p++ = cpu_to_be32(args->bc_attrs.max_rqst_sz); /* max req size */ |
| 1859 | *p++ = cpu_to_be32(args->bc_attrs.max_resp_sz); /* max resp size */ |
| 1860 | *p++ = cpu_to_be32(args->bc_attrs.max_resp_sz_cached); /* Max resp sz cached */ |
| 1861 | *p++ = cpu_to_be32(args->bc_attrs.max_ops); /* max operations */ |
| 1862 | *p++ = cpu_to_be32(args->bc_attrs.max_reqs); /* max requests */ |
| 1863 | *p++ = cpu_to_be32(0); /* rdmachannel_attrs */ |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 1864 | |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1865 | *p++ = cpu_to_be32(args->cb_program); /* cb_program */ |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1866 | *p++ = cpu_to_be32(1); |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1867 | *p++ = cpu_to_be32(RPC_AUTH_UNIX); /* auth_sys */ |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 1868 | |
| 1869 | /* authsys_parms rfc1831 */ |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1870 | *p++ = cpu_to_be32((u32)clp->cl_boot_time.tv_nsec); /* stamp */ |
Benny Halevy | 811652b | 2009-08-14 17:19:34 +0300 | [diff] [blame] | 1871 | p = xdr_encode_opaque(p, machine_name, len); |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1872 | *p++ = cpu_to_be32(0); /* UID */ |
| 1873 | *p++ = cpu_to_be32(0); /* GID */ |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1874 | *p = cpu_to_be32(0); /* No more gids */ |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 1875 | hdr->nops++; |
| 1876 | hdr->replen += decode_create_session_maxsz; |
| 1877 | } |
Andy Adamson | 0f3e66c | 2009-04-01 09:22:34 -0400 | [diff] [blame] | 1878 | |
| 1879 | static void encode_destroy_session(struct xdr_stream *xdr, |
| 1880 | struct nfs4_session *session, |
| 1881 | struct compound_hdr *hdr) |
| 1882 | { |
| 1883 | __be32 *p; |
Benny Halevy | 13c65ce | 2009-08-14 17:19:25 +0300 | [diff] [blame] | 1884 | p = reserve_space(xdr, 4 + NFS4_MAX_SESSIONID_LEN); |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1885 | *p++ = cpu_to_be32(OP_DESTROY_SESSION); |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1886 | xdr_encode_opaque_fixed(p, session->sess_id.data, NFS4_MAX_SESSIONID_LEN); |
Andy Adamson | 0f3e66c | 2009-04-01 09:22:34 -0400 | [diff] [blame] | 1887 | hdr->nops++; |
| 1888 | hdr->replen += decode_destroy_session_maxsz; |
| 1889 | } |
Ricardo Labiaga | 1801975 | 2009-12-05 16:08:40 -0500 | [diff] [blame] | 1890 | |
| 1891 | static void encode_reclaim_complete(struct xdr_stream *xdr, |
| 1892 | struct nfs41_reclaim_complete_args *args, |
| 1893 | struct compound_hdr *hdr) |
| 1894 | { |
| 1895 | __be32 *p; |
| 1896 | |
| 1897 | p = reserve_space(xdr, 8); |
| 1898 | *p++ = cpu_to_be32(OP_RECLAIM_COMPLETE); |
| 1899 | *p++ = cpu_to_be32(args->one_fs); |
| 1900 | hdr->nops++; |
| 1901 | hdr->replen += decode_reclaim_complete_maxsz; |
| 1902 | } |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 1903 | #endif /* CONFIG_NFS_V4_1 */ |
| 1904 | |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 1905 | static void encode_sequence(struct xdr_stream *xdr, |
| 1906 | const struct nfs4_sequence_args *args, |
| 1907 | struct compound_hdr *hdr) |
| 1908 | { |
| 1909 | #if defined(CONFIG_NFS_V4_1) |
| 1910 | struct nfs4_session *session = args->sa_session; |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 1911 | struct nfs4_slot_table *tp; |
| 1912 | struct nfs4_slot *slot; |
| 1913 | __be32 *p; |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 1914 | |
| 1915 | if (!session) |
| 1916 | return; |
| 1917 | |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 1918 | tp = &session->fc_slot_table; |
| 1919 | |
| 1920 | WARN_ON(args->sa_slotid == NFS4_MAX_SLOT_TABLE); |
| 1921 | slot = tp->slots + args->sa_slotid; |
| 1922 | |
Benny Halevy | 13c65ce | 2009-08-14 17:19:25 +0300 | [diff] [blame] | 1923 | p = reserve_space(xdr, 4 + NFS4_MAX_SESSIONID_LEN + 16); |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1924 | *p++ = cpu_to_be32(OP_SEQUENCE); |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 1925 | |
| 1926 | /* |
| 1927 | * Sessionid + seqid + slotid + max slotid + cache_this |
| 1928 | */ |
| 1929 | dprintk("%s: sessionid=%u:%u:%u:%u seqid=%d slotid=%d " |
| 1930 | "max_slotid=%d cache_this=%d\n", |
| 1931 | __func__, |
| 1932 | ((u32 *)session->sess_id.data)[0], |
| 1933 | ((u32 *)session->sess_id.data)[1], |
| 1934 | ((u32 *)session->sess_id.data)[2], |
| 1935 | ((u32 *)session->sess_id.data)[3], |
| 1936 | slot->seq_nr, args->sa_slotid, |
| 1937 | tp->highest_used_slotid, args->sa_cache_this); |
Benny Halevy | 93f0cf2 | 2009-08-14 17:19:06 +0300 | [diff] [blame] | 1938 | 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] | 1939 | *p++ = cpu_to_be32(slot->seq_nr); |
| 1940 | *p++ = cpu_to_be32(args->sa_slotid); |
| 1941 | *p++ = cpu_to_be32(tp->highest_used_slotid); |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1942 | *p = cpu_to_be32(args->sa_cache_this); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 1943 | hdr->nops++; |
| 1944 | hdr->replen += decode_sequence_maxsz; |
| 1945 | #endif /* CONFIG_NFS_V4_1 */ |
| 1946 | } |
| 1947 | |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 1948 | #ifdef CONFIG_NFS_V4_1 |
| 1949 | static void |
Andy Adamson | 7f11d8d | 2011-07-30 20:52:35 -0400 | [diff] [blame] | 1950 | encode_getdevicelist(struct xdr_stream *xdr, |
| 1951 | const struct nfs4_getdevicelist_args *args, |
| 1952 | struct compound_hdr *hdr) |
| 1953 | { |
| 1954 | __be32 *p; |
| 1955 | nfs4_verifier dummy = { |
| 1956 | .data = "dummmmmy", |
| 1957 | }; |
| 1958 | |
| 1959 | p = reserve_space(xdr, 20); |
| 1960 | *p++ = cpu_to_be32(OP_GETDEVICELIST); |
| 1961 | *p++ = cpu_to_be32(args->layoutclass); |
| 1962 | *p++ = cpu_to_be32(NFS4_PNFS_GETDEVLIST_MAXNUM); |
| 1963 | xdr_encode_hyper(p, 0ULL); /* cookie */ |
| 1964 | encode_nfs4_verifier(xdr, &dummy); |
| 1965 | hdr->nops++; |
| 1966 | hdr->replen += decode_getdevicelist_maxsz; |
| 1967 | } |
| 1968 | |
| 1969 | static void |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 1970 | encode_getdeviceinfo(struct xdr_stream *xdr, |
| 1971 | const struct nfs4_getdeviceinfo_args *args, |
| 1972 | struct compound_hdr *hdr) |
| 1973 | { |
| 1974 | __be32 *p; |
| 1975 | |
| 1976 | p = reserve_space(xdr, 16 + NFS4_DEVICEID4_SIZE); |
| 1977 | *p++ = cpu_to_be32(OP_GETDEVICEINFO); |
| 1978 | p = xdr_encode_opaque_fixed(p, args->pdev->dev_id.data, |
| 1979 | NFS4_DEVICEID4_SIZE); |
| 1980 | *p++ = cpu_to_be32(args->pdev->layout_type); |
| 1981 | *p++ = cpu_to_be32(args->pdev->pglen); /* gdia_maxcount */ |
| 1982 | *p++ = cpu_to_be32(0); /* bitmap length 0 */ |
| 1983 | hdr->nops++; |
| 1984 | hdr->replen += decode_getdeviceinfo_maxsz; |
| 1985 | } |
| 1986 | |
| 1987 | static void |
| 1988 | encode_layoutget(struct xdr_stream *xdr, |
| 1989 | const struct nfs4_layoutget_args *args, |
| 1990 | struct compound_hdr *hdr) |
| 1991 | { |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 1992 | __be32 *p; |
| 1993 | |
| 1994 | p = reserve_space(xdr, 44 + NFS4_STATEID_SIZE); |
| 1995 | *p++ = cpu_to_be32(OP_LAYOUTGET); |
| 1996 | *p++ = cpu_to_be32(0); /* Signal layout available */ |
| 1997 | *p++ = cpu_to_be32(args->type); |
| 1998 | *p++ = cpu_to_be32(args->range.iomode); |
| 1999 | p = xdr_encode_hyper(p, args->range.offset); |
| 2000 | p = xdr_encode_hyper(p, args->range.length); |
| 2001 | p = xdr_encode_hyper(p, args->minlength); |
Fred Isaman | cf7d63f | 2011-01-06 11:36:25 +0000 | [diff] [blame] | 2002 | p = xdr_encode_opaque_fixed(p, &args->stateid.data, NFS4_STATEID_SIZE); |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 2003 | *p = cpu_to_be32(args->maxcount); |
| 2004 | |
| 2005 | dprintk("%s: 1st type:0x%x iomode:%d off:%lu len:%lu mc:%d\n", |
| 2006 | __func__, |
| 2007 | args->type, |
| 2008 | args->range.iomode, |
| 2009 | (unsigned long)args->range.offset, |
| 2010 | (unsigned long)args->range.length, |
| 2011 | args->maxcount); |
| 2012 | hdr->nops++; |
| 2013 | hdr->replen += decode_layoutget_maxsz; |
| 2014 | } |
Andy Adamson | 863a3c6 | 2011-03-23 13:27:54 +0000 | [diff] [blame] | 2015 | |
| 2016 | static int |
| 2017 | encode_layoutcommit(struct xdr_stream *xdr, |
Benny Halevy | ac7db72 | 2011-05-22 19:53:48 +0300 | [diff] [blame] | 2018 | struct inode *inode, |
Andy Adamson | 863a3c6 | 2011-03-23 13:27:54 +0000 | [diff] [blame] | 2019 | const struct nfs4_layoutcommit_args *args, |
| 2020 | struct compound_hdr *hdr) |
| 2021 | { |
| 2022 | __be32 *p; |
| 2023 | |
| 2024 | dprintk("%s: lbw: %llu type: %d\n", __func__, args->lastbytewritten, |
| 2025 | NFS_SERVER(args->inode)->pnfs_curr_ld->id); |
| 2026 | |
Benny Halevy | ac7db72 | 2011-05-22 19:53:48 +0300 | [diff] [blame] | 2027 | p = reserve_space(xdr, 44 + NFS4_STATEID_SIZE); |
Andy Adamson | 863a3c6 | 2011-03-23 13:27:54 +0000 | [diff] [blame] | 2028 | *p++ = cpu_to_be32(OP_LAYOUTCOMMIT); |
| 2029 | /* Only whole file layouts */ |
| 2030 | p = xdr_encode_hyper(p, 0); /* offset */ |
Peng Tao | 3557c6c | 2011-07-30 20:52:34 -0400 | [diff] [blame] | 2031 | p = xdr_encode_hyper(p, args->lastbytewritten + 1); /* length */ |
Andy Adamson | 863a3c6 | 2011-03-23 13:27:54 +0000 | [diff] [blame] | 2032 | *p++ = cpu_to_be32(0); /* reclaim */ |
| 2033 | p = xdr_encode_opaque_fixed(p, args->stateid.data, NFS4_STATEID_SIZE); |
| 2034 | *p++ = cpu_to_be32(1); /* newoffset = TRUE */ |
| 2035 | p = xdr_encode_hyper(p, args->lastbytewritten); |
| 2036 | *p++ = cpu_to_be32(0); /* Never send time_modify_changed */ |
| 2037 | *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] | 2038 | |
| 2039 | if (NFS_SERVER(inode)->pnfs_curr_ld->encode_layoutcommit) |
| 2040 | NFS_SERVER(inode)->pnfs_curr_ld->encode_layoutcommit( |
| 2041 | NFS_I(inode)->layout, xdr, args); |
| 2042 | else { |
| 2043 | p = reserve_space(xdr, 4); |
| 2044 | *p = cpu_to_be32(0); /* no layout-type payload */ |
| 2045 | } |
Andy Adamson | 863a3c6 | 2011-03-23 13:27:54 +0000 | [diff] [blame] | 2046 | |
| 2047 | hdr->nops++; |
| 2048 | hdr->replen += decode_layoutcommit_maxsz; |
| 2049 | return 0; |
| 2050 | } |
Benny Halevy | cbe8260 | 2011-05-22 19:52:37 +0300 | [diff] [blame] | 2051 | |
| 2052 | static void |
| 2053 | encode_layoutreturn(struct xdr_stream *xdr, |
| 2054 | const struct nfs4_layoutreturn_args *args, |
| 2055 | struct compound_hdr *hdr) |
| 2056 | { |
| 2057 | __be32 *p; |
| 2058 | |
| 2059 | p = reserve_space(xdr, 20); |
| 2060 | *p++ = cpu_to_be32(OP_LAYOUTRETURN); |
| 2061 | *p++ = cpu_to_be32(0); /* reclaim. always 0 for now */ |
| 2062 | *p++ = cpu_to_be32(args->layout_type); |
| 2063 | *p++ = cpu_to_be32(IOMODE_ANY); |
| 2064 | *p = cpu_to_be32(RETURN_FILE); |
| 2065 | p = reserve_space(xdr, 16 + NFS4_STATEID_SIZE); |
| 2066 | p = xdr_encode_hyper(p, 0); |
| 2067 | p = xdr_encode_hyper(p, NFS4_MAX_UINT64); |
| 2068 | spin_lock(&args->inode->i_lock); |
| 2069 | xdr_encode_opaque_fixed(p, &args->stateid.data, NFS4_STATEID_SIZE); |
| 2070 | spin_unlock(&args->inode->i_lock); |
Andy Adamson | 04a5554 | 2011-05-22 19:53:10 +0300 | [diff] [blame] | 2071 | if (NFS_SERVER(args->inode)->pnfs_curr_ld->encode_layoutreturn) { |
| 2072 | NFS_SERVER(args->inode)->pnfs_curr_ld->encode_layoutreturn( |
| 2073 | NFS_I(args->inode)->layout, xdr, args); |
| 2074 | } else { |
| 2075 | p = reserve_space(xdr, 4); |
| 2076 | *p = cpu_to_be32(0); |
| 2077 | } |
Benny Halevy | cbe8260 | 2011-05-22 19:52:37 +0300 | [diff] [blame] | 2078 | hdr->nops++; |
| 2079 | hdr->replen += decode_layoutreturn_maxsz; |
| 2080 | } |
Bryan Schumaker | fca78d6 | 2011-06-02 14:59:07 -0400 | [diff] [blame] | 2081 | |
| 2082 | static int |
| 2083 | encode_secinfo_no_name(struct xdr_stream *xdr, |
| 2084 | const struct nfs41_secinfo_no_name_args *args, |
| 2085 | struct compound_hdr *hdr) |
| 2086 | { |
| 2087 | __be32 *p; |
| 2088 | p = reserve_space(xdr, 8); |
| 2089 | *p++ = cpu_to_be32(OP_SECINFO_NO_NAME); |
| 2090 | *p++ = cpu_to_be32(args->style); |
| 2091 | hdr->nops++; |
| 2092 | hdr->replen += decode_secinfo_no_name_maxsz; |
| 2093 | return 0; |
| 2094 | } |
Bryan Schumaker | 7d97479 | 2011-06-02 14:59:08 -0400 | [diff] [blame] | 2095 | |
| 2096 | static void encode_test_stateid(struct xdr_stream *xdr, |
| 2097 | struct nfs41_test_stateid_args *args, |
| 2098 | struct compound_hdr *hdr) |
| 2099 | { |
| 2100 | __be32 *p; |
| 2101 | |
| 2102 | p = reserve_space(xdr, 8 + NFS4_STATEID_SIZE); |
| 2103 | *p++ = cpu_to_be32(OP_TEST_STATEID); |
| 2104 | *p++ = cpu_to_be32(1); |
| 2105 | xdr_encode_opaque_fixed(p, args->stateid->data, NFS4_STATEID_SIZE); |
| 2106 | hdr->nops++; |
| 2107 | hdr->replen += decode_test_stateid_maxsz; |
| 2108 | } |
Bryan Schumaker | 9aeda35 | 2011-06-02 14:59:09 -0400 | [diff] [blame] | 2109 | |
| 2110 | static void encode_free_stateid(struct xdr_stream *xdr, |
| 2111 | struct nfs41_free_stateid_args *args, |
| 2112 | struct compound_hdr *hdr) |
| 2113 | { |
| 2114 | __be32 *p; |
| 2115 | p = reserve_space(xdr, 4 + NFS4_STATEID_SIZE); |
| 2116 | *p++ = cpu_to_be32(OP_FREE_STATEID); |
| 2117 | xdr_encode_opaque_fixed(p, args->stateid->data, NFS4_STATEID_SIZE); |
| 2118 | hdr->nops++; |
| 2119 | hdr->replen += decode_free_stateid_maxsz; |
| 2120 | } |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 2121 | #endif /* CONFIG_NFS_V4_1 */ |
| 2122 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2123 | /* |
| 2124 | * END OF "GENERIC" ENCODE ROUTINES. |
| 2125 | */ |
| 2126 | |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2127 | static u32 nfs4_xdr_minorversion(const struct nfs4_sequence_args *args) |
| 2128 | { |
| 2129 | #if defined(CONFIG_NFS_V4_1) |
| 2130 | if (args->sa_session) |
Trond Myklebust | a443234 | 2010-06-16 09:52:27 -0400 | [diff] [blame] | 2131 | return args->sa_session->clp->cl_mvops->minor_version; |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2132 | #endif /* CONFIG_NFS_V4_1 */ |
| 2133 | return 0; |
| 2134 | } |
| 2135 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2136 | /* |
| 2137 | * Encode an ACCESS request |
| 2138 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2139 | static void nfs4_xdr_enc_access(struct rpc_rqst *req, struct xdr_stream *xdr, |
| 2140 | const struct nfs4_accessargs *args) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2141 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2142 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2143 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2144 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2145 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2146 | encode_compound_hdr(xdr, req, &hdr); |
| 2147 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2148 | encode_putfh(xdr, args->fh, &hdr); |
| 2149 | encode_access(xdr, args->access, &hdr); |
| 2150 | encode_getfattr(xdr, args->bitmask, &hdr); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2151 | encode_nops(&hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2152 | } |
| 2153 | |
| 2154 | /* |
| 2155 | * Encode LOOKUP request |
| 2156 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2157 | static void nfs4_xdr_enc_lookup(struct rpc_rqst *req, struct xdr_stream *xdr, |
| 2158 | const struct nfs4_lookup_arg *args) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2159 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2160 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2161 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2162 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2163 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2164 | encode_compound_hdr(xdr, req, &hdr); |
| 2165 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2166 | encode_putfh(xdr, args->dir_fh, &hdr); |
| 2167 | encode_lookup(xdr, args->name, &hdr); |
| 2168 | encode_getfh(xdr, &hdr); |
| 2169 | encode_getfattr(xdr, args->bitmask, &hdr); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2170 | encode_nops(&hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2171 | } |
| 2172 | |
| 2173 | /* |
| 2174 | * Encode LOOKUP_ROOT request |
| 2175 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2176 | static void nfs4_xdr_enc_lookup_root(struct rpc_rqst *req, |
| 2177 | struct xdr_stream *xdr, |
| 2178 | const struct nfs4_lookup_root_arg *args) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2179 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2180 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2181 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2182 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2183 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2184 | encode_compound_hdr(xdr, req, &hdr); |
| 2185 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2186 | encode_putrootfh(xdr, &hdr); |
| 2187 | encode_getfh(xdr, &hdr); |
| 2188 | encode_getfattr(xdr, args->bitmask, &hdr); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2189 | encode_nops(&hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2190 | } |
| 2191 | |
| 2192 | /* |
| 2193 | * Encode REMOVE request |
| 2194 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2195 | static void nfs4_xdr_enc_remove(struct rpc_rqst *req, struct xdr_stream *xdr, |
| 2196 | const struct nfs_removeargs *args) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2197 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2198 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2199 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2200 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2201 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2202 | encode_compound_hdr(xdr, req, &hdr); |
| 2203 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2204 | encode_putfh(xdr, args->fh, &hdr); |
| 2205 | encode_remove(xdr, &args->name, &hdr); |
| 2206 | encode_getfattr(xdr, args->bitmask, &hdr); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2207 | encode_nops(&hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2208 | } |
| 2209 | |
| 2210 | /* |
| 2211 | * Encode RENAME request |
| 2212 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2213 | static void nfs4_xdr_enc_rename(struct rpc_rqst *req, struct xdr_stream *xdr, |
| 2214 | const struct nfs_renameargs *args) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2215 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2216 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2217 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2218 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2219 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2220 | encode_compound_hdr(xdr, req, &hdr); |
| 2221 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2222 | encode_putfh(xdr, args->old_dir, &hdr); |
| 2223 | encode_savefh(xdr, &hdr); |
| 2224 | encode_putfh(xdr, args->new_dir, &hdr); |
| 2225 | encode_rename(xdr, args->old_name, args->new_name, &hdr); |
| 2226 | encode_getfattr(xdr, args->bitmask, &hdr); |
| 2227 | encode_restorefh(xdr, &hdr); |
| 2228 | encode_getfattr(xdr, args->bitmask, &hdr); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2229 | encode_nops(&hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2230 | } |
| 2231 | |
| 2232 | /* |
| 2233 | * Encode LINK request |
| 2234 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2235 | static void nfs4_xdr_enc_link(struct rpc_rqst *req, struct xdr_stream *xdr, |
| 2236 | const struct nfs4_link_arg *args) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2237 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2238 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2239 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2240 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2241 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2242 | encode_compound_hdr(xdr, req, &hdr); |
| 2243 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2244 | encode_putfh(xdr, args->fh, &hdr); |
| 2245 | encode_savefh(xdr, &hdr); |
| 2246 | encode_putfh(xdr, args->dir_fh, &hdr); |
| 2247 | encode_link(xdr, args->name, &hdr); |
| 2248 | encode_getfattr(xdr, args->bitmask, &hdr); |
| 2249 | encode_restorefh(xdr, &hdr); |
| 2250 | encode_getfattr(xdr, args->bitmask, &hdr); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2251 | encode_nops(&hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2252 | } |
| 2253 | |
| 2254 | /* |
| 2255 | * Encode CREATE request |
| 2256 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2257 | static void nfs4_xdr_enc_create(struct rpc_rqst *req, struct xdr_stream *xdr, |
| 2258 | const struct nfs4_create_arg *args) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2259 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2260 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2261 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2262 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2263 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2264 | encode_compound_hdr(xdr, req, &hdr); |
| 2265 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2266 | encode_putfh(xdr, args->dir_fh, &hdr); |
| 2267 | encode_savefh(xdr, &hdr); |
| 2268 | encode_create(xdr, args, &hdr); |
| 2269 | encode_getfh(xdr, &hdr); |
| 2270 | encode_getfattr(xdr, args->bitmask, &hdr); |
| 2271 | encode_restorefh(xdr, &hdr); |
| 2272 | encode_getfattr(xdr, args->bitmask, &hdr); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2273 | encode_nops(&hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2274 | } |
| 2275 | |
| 2276 | /* |
| 2277 | * Encode SYMLINK request |
| 2278 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2279 | static void nfs4_xdr_enc_symlink(struct rpc_rqst *req, struct xdr_stream *xdr, |
| 2280 | const struct nfs4_create_arg *args) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2281 | { |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2282 | nfs4_xdr_enc_create(req, xdr, args); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2283 | } |
| 2284 | |
| 2285 | /* |
| 2286 | * Encode GETATTR request |
| 2287 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2288 | static void nfs4_xdr_enc_getattr(struct rpc_rqst *req, struct xdr_stream *xdr, |
| 2289 | const struct nfs4_getattr_arg *args) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2290 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2291 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2292 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2293 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2294 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2295 | encode_compound_hdr(xdr, req, &hdr); |
| 2296 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2297 | encode_putfh(xdr, args->fh, &hdr); |
| 2298 | encode_getfattr(xdr, args->bitmask, &hdr); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2299 | encode_nops(&hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2300 | } |
| 2301 | |
| 2302 | /* |
| 2303 | * Encode a CLOSE request |
| 2304 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2305 | static void nfs4_xdr_enc_close(struct rpc_rqst *req, struct xdr_stream *xdr, |
| 2306 | struct nfs_closeargs *args) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2307 | { |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 2308 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2309 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 2310 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2311 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2312 | encode_compound_hdr(xdr, req, &hdr); |
| 2313 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2314 | encode_putfh(xdr, args->fh, &hdr); |
| 2315 | encode_close(xdr, args, &hdr); |
| 2316 | encode_getfattr(xdr, args->bitmask, &hdr); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2317 | encode_nops(&hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2318 | } |
| 2319 | |
| 2320 | /* |
| 2321 | * Encode an OPEN request |
| 2322 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2323 | static void nfs4_xdr_enc_open(struct rpc_rqst *req, struct xdr_stream *xdr, |
| 2324 | struct nfs_openargs *args) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2325 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2326 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2327 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2328 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2329 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2330 | encode_compound_hdr(xdr, req, &hdr); |
| 2331 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2332 | encode_putfh(xdr, args->fh, &hdr); |
| 2333 | encode_savefh(xdr, &hdr); |
| 2334 | encode_open(xdr, args, &hdr); |
| 2335 | encode_getfh(xdr, &hdr); |
| 2336 | encode_getfattr(xdr, args->bitmask, &hdr); |
| 2337 | encode_restorefh(xdr, &hdr); |
Trond Myklebust | 6926afd | 2012-01-07 13:22:46 -0500 | [diff] [blame] | 2338 | encode_getfattr(xdr, args->dir_bitmask, &hdr); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2339 | encode_nops(&hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2340 | } |
| 2341 | |
| 2342 | /* |
| 2343 | * Encode an OPEN_CONFIRM request |
| 2344 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2345 | static void nfs4_xdr_enc_open_confirm(struct rpc_rqst *req, |
| 2346 | struct xdr_stream *xdr, |
| 2347 | struct nfs_open_confirmargs *args) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2348 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2349 | struct compound_hdr hdr = { |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2350 | .nops = 0, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2351 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2352 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2353 | encode_compound_hdr(xdr, req, &hdr); |
| 2354 | encode_putfh(xdr, args->fh, &hdr); |
| 2355 | encode_open_confirm(xdr, args, &hdr); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2356 | encode_nops(&hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2357 | } |
| 2358 | |
| 2359 | /* |
| 2360 | * Encode an OPEN request with no attributes. |
| 2361 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2362 | static void nfs4_xdr_enc_open_noattr(struct rpc_rqst *req, |
| 2363 | struct xdr_stream *xdr, |
| 2364 | struct nfs_openargs *args) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2365 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2366 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2367 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2368 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2369 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2370 | encode_compound_hdr(xdr, req, &hdr); |
| 2371 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2372 | encode_putfh(xdr, args->fh, &hdr); |
| 2373 | encode_open(xdr, args, &hdr); |
| 2374 | encode_getfattr(xdr, args->bitmask, &hdr); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2375 | encode_nops(&hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2376 | } |
| 2377 | |
| 2378 | /* |
| 2379 | * Encode an OPEN_DOWNGRADE request |
| 2380 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2381 | static void nfs4_xdr_enc_open_downgrade(struct rpc_rqst *req, |
| 2382 | struct xdr_stream *xdr, |
| 2383 | struct nfs_closeargs *args) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2384 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2385 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2386 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2387 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2388 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2389 | encode_compound_hdr(xdr, req, &hdr); |
| 2390 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2391 | encode_putfh(xdr, args->fh, &hdr); |
| 2392 | encode_open_downgrade(xdr, args, &hdr); |
| 2393 | encode_getfattr(xdr, args->bitmask, &hdr); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2394 | encode_nops(&hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2395 | } |
| 2396 | |
| 2397 | /* |
| 2398 | * Encode a LOCK request |
| 2399 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2400 | static void nfs4_xdr_enc_lock(struct rpc_rqst *req, struct xdr_stream *xdr, |
| 2401 | struct nfs_lock_args *args) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2402 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2403 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2404 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2405 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2406 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2407 | encode_compound_hdr(xdr, req, &hdr); |
| 2408 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2409 | encode_putfh(xdr, args->fh, &hdr); |
| 2410 | encode_lock(xdr, args, &hdr); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2411 | encode_nops(&hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2412 | } |
| 2413 | |
| 2414 | /* |
| 2415 | * Encode a LOCKT request |
| 2416 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2417 | static void nfs4_xdr_enc_lockt(struct rpc_rqst *req, struct xdr_stream *xdr, |
| 2418 | struct nfs_lockt_args *args) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2419 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2420 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2421 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2422 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2423 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2424 | encode_compound_hdr(xdr, req, &hdr); |
| 2425 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2426 | encode_putfh(xdr, args->fh, &hdr); |
| 2427 | encode_lockt(xdr, args, &hdr); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2428 | encode_nops(&hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2429 | } |
| 2430 | |
| 2431 | /* |
| 2432 | * Encode a LOCKU request |
| 2433 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2434 | static void nfs4_xdr_enc_locku(struct rpc_rqst *req, struct xdr_stream *xdr, |
| 2435 | struct nfs_locku_args *args) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2436 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2437 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2438 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2439 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2440 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2441 | encode_compound_hdr(xdr, req, &hdr); |
| 2442 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2443 | encode_putfh(xdr, args->fh, &hdr); |
| 2444 | encode_locku(xdr, args, &hdr); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2445 | encode_nops(&hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2446 | } |
| 2447 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2448 | static void nfs4_xdr_enc_release_lockowner(struct rpc_rqst *req, |
| 2449 | struct xdr_stream *xdr, |
| 2450 | struct nfs_release_lockowner_args *args) |
Trond Myklebust | d3c7b7c | 2010-07-01 12:49:01 -0400 | [diff] [blame] | 2451 | { |
Trond Myklebust | d3c7b7c | 2010-07-01 12:49:01 -0400 | [diff] [blame] | 2452 | struct compound_hdr hdr = { |
| 2453 | .minorversion = 0, |
| 2454 | }; |
| 2455 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2456 | encode_compound_hdr(xdr, req, &hdr); |
| 2457 | encode_release_lockowner(xdr, &args->lock_owner, &hdr); |
Trond Myklebust | d3c7b7c | 2010-07-01 12:49:01 -0400 | [diff] [blame] | 2458 | encode_nops(&hdr); |
Trond Myklebust | d3c7b7c | 2010-07-01 12:49:01 -0400 | [diff] [blame] | 2459 | } |
| 2460 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2461 | /* |
| 2462 | * Encode a READLINK request |
| 2463 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2464 | static void nfs4_xdr_enc_readlink(struct rpc_rqst *req, struct xdr_stream *xdr, |
| 2465 | const struct nfs4_readlink *args) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2466 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2467 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2468 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2469 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2470 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2471 | encode_compound_hdr(xdr, req, &hdr); |
| 2472 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2473 | encode_putfh(xdr, args->fh, &hdr); |
| 2474 | encode_readlink(xdr, args, req, &hdr); |
Trond Myklebust | e3a535e | 2007-07-19 10:03:38 -0400 | [diff] [blame] | 2475 | |
Benny Halevy | 28f5669 | 2009-04-01 09:22:09 -0400 | [diff] [blame] | 2476 | xdr_inline_pages(&req->rq_rcv_buf, hdr.replen << 2, args->pages, |
Trond Myklebust | e3a535e | 2007-07-19 10:03:38 -0400 | [diff] [blame] | 2477 | args->pgbase, args->pglen); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2478 | encode_nops(&hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2479 | } |
| 2480 | |
| 2481 | /* |
| 2482 | * Encode a READDIR request |
| 2483 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2484 | static void nfs4_xdr_enc_readdir(struct rpc_rqst *req, struct xdr_stream *xdr, |
| 2485 | const struct nfs4_readdir_arg *args) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2486 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2487 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2488 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2489 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2490 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2491 | encode_compound_hdr(xdr, req, &hdr); |
| 2492 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2493 | encode_putfh(xdr, args->fh, &hdr); |
| 2494 | encode_readdir(xdr, args, req, &hdr); |
Trond Myklebust | d6ac02d | 2007-07-19 10:03:37 -0400 | [diff] [blame] | 2495 | |
Benny Halevy | 28f5669 | 2009-04-01 09:22:09 -0400 | [diff] [blame] | 2496 | xdr_inline_pages(&req->rq_rcv_buf, hdr.replen << 2, args->pages, |
Trond Myklebust | d6ac02d | 2007-07-19 10:03:37 -0400 | [diff] [blame] | 2497 | args->pgbase, args->count); |
| 2498 | dprintk("%s: inlined page args = (%u, %p, %u, %u)\n", |
Benny Halevy | 28f5669 | 2009-04-01 09:22:09 -0400 | [diff] [blame] | 2499 | __func__, hdr.replen << 2, args->pages, |
Trond Myklebust | d6ac02d | 2007-07-19 10:03:37 -0400 | [diff] [blame] | 2500 | args->pgbase, args->count); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2501 | encode_nops(&hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2502 | } |
| 2503 | |
| 2504 | /* |
| 2505 | * Encode a READ request |
| 2506 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2507 | static void nfs4_xdr_enc_read(struct rpc_rqst *req, struct xdr_stream *xdr, |
| 2508 | struct nfs_readargs *args) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2509 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2510 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2511 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
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 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2514 | encode_compound_hdr(xdr, req, &hdr); |
| 2515 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2516 | encode_putfh(xdr, args->fh, &hdr); |
| 2517 | encode_read(xdr, args, &hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2518 | |
Benny Halevy | 28f5669 | 2009-04-01 09:22:09 -0400 | [diff] [blame] | 2519 | xdr_inline_pages(&req->rq_rcv_buf, hdr.replen << 2, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2520 | args->pages, args->pgbase, args->count); |
\"Talpey, Thomas\ | 4f22ccc | 2007-09-10 13:44:58 -0400 | [diff] [blame] | 2521 | req->rq_rcv_buf.flags |= XDRBUF_READ; |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2522 | encode_nops(&hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2523 | } |
| 2524 | |
| 2525 | /* |
| 2526 | * Encode an SETATTR request |
| 2527 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2528 | static void nfs4_xdr_enc_setattr(struct rpc_rqst *req, struct xdr_stream *xdr, |
| 2529 | struct nfs_setattrargs *args) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2530 | { |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 2531 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2532 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 2533 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2534 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2535 | encode_compound_hdr(xdr, req, &hdr); |
| 2536 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2537 | encode_putfh(xdr, args->fh, &hdr); |
| 2538 | encode_setattr(xdr, args, args->server, &hdr); |
| 2539 | encode_getfattr(xdr, args->bitmask, &hdr); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2540 | encode_nops(&hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2541 | } |
| 2542 | |
| 2543 | /* |
J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 2544 | * Encode a GETACL request |
| 2545 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2546 | static void nfs4_xdr_enc_getacl(struct rpc_rqst *req, struct xdr_stream *xdr, |
| 2547 | struct nfs_getaclargs *args) |
J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 2548 | { |
J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 2549 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2550 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 2551 | }; |
Benny Halevy | 28f5669 | 2009-04-01 09:22:09 -0400 | [diff] [blame] | 2552 | uint32_t replen; |
J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 2553 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2554 | encode_compound_hdr(xdr, req, &hdr); |
| 2555 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2556 | encode_putfh(xdr, args->fh, &hdr); |
Andy Adamson | bf118a3 | 2011-12-07 11:55:27 -0500 | [diff] [blame] | 2557 | replen = hdr.replen + op_decode_hdr_maxsz + 1; |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2558 | encode_getattr_two(xdr, FATTR4_WORD0_ACL, 0, &hdr); |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 2559 | |
Benny Halevy | 28f5669 | 2009-04-01 09:22:09 -0400 | [diff] [blame] | 2560 | xdr_inline_pages(&req->rq_rcv_buf, replen << 2, |
J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 2561 | args->acl_pages, args->acl_pgbase, args->acl_len); |
Andy Adamson | bf118a3 | 2011-12-07 11:55:27 -0500 | [diff] [blame] | 2562 | xdr_set_scratch_buffer(xdr, page_address(args->acl_scratch), PAGE_SIZE); |
| 2563 | |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2564 | encode_nops(&hdr); |
J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 2565 | } |
| 2566 | |
| 2567 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2568 | * Encode a WRITE request |
| 2569 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2570 | static void nfs4_xdr_enc_write(struct rpc_rqst *req, struct xdr_stream *xdr, |
| 2571 | struct nfs_writeargs *args) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2572 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2573 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2574 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2575 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2576 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2577 | encode_compound_hdr(xdr, req, &hdr); |
| 2578 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2579 | encode_putfh(xdr, args->fh, &hdr); |
| 2580 | encode_write(xdr, args, &hdr); |
\"Talpey, Thomas\ | 4f22ccc | 2007-09-10 13:44:58 -0400 | [diff] [blame] | 2581 | req->rq_snd_buf.flags |= XDRBUF_WRITE; |
Fred Isaman | 7ffd106 | 2011-03-03 15:13:46 +0000 | [diff] [blame] | 2582 | if (args->bitmask) |
| 2583 | encode_getfattr(xdr, args->bitmask, &hdr); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2584 | encode_nops(&hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2585 | } |
| 2586 | |
| 2587 | /* |
| 2588 | * a COMMIT request |
| 2589 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2590 | static void nfs4_xdr_enc_commit(struct rpc_rqst *req, struct xdr_stream *xdr, |
| 2591 | struct nfs_writeargs *args) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2592 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2593 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2594 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2595 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2596 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2597 | encode_compound_hdr(xdr, req, &hdr); |
| 2598 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2599 | encode_putfh(xdr, args->fh, &hdr); |
| 2600 | encode_commit(xdr, args, &hdr); |
Fred Isaman | 988b6dc | 2011-03-23 13:27:52 +0000 | [diff] [blame] | 2601 | if (args->bitmask) |
| 2602 | encode_getfattr(xdr, args->bitmask, &hdr); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2603 | encode_nops(&hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2604 | } |
| 2605 | |
| 2606 | /* |
| 2607 | * FSINFO request |
| 2608 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2609 | static void nfs4_xdr_enc_fsinfo(struct rpc_rqst *req, struct xdr_stream *xdr, |
| 2610 | struct nfs4_fsinfo_arg *args) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2611 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2612 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2613 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2614 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2615 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2616 | encode_compound_hdr(xdr, req, &hdr); |
| 2617 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2618 | encode_putfh(xdr, args->fh, &hdr); |
| 2619 | encode_fsinfo(xdr, args->bitmask, &hdr); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2620 | encode_nops(&hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2621 | } |
| 2622 | |
| 2623 | /* |
| 2624 | * a PATHCONF request |
| 2625 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2626 | static void nfs4_xdr_enc_pathconf(struct rpc_rqst *req, struct xdr_stream *xdr, |
| 2627 | const struct nfs4_pathconf_arg *args) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2628 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2629 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2630 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2631 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2632 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2633 | encode_compound_hdr(xdr, req, &hdr); |
| 2634 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2635 | encode_putfh(xdr, args->fh, &hdr); |
| 2636 | encode_getattr_one(xdr, args->bitmask[0] & nfs4_pathconf_bitmap[0], |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 2637 | &hdr); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2638 | encode_nops(&hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2639 | } |
| 2640 | |
| 2641 | /* |
| 2642 | * a STATFS request |
| 2643 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2644 | static void nfs4_xdr_enc_statfs(struct rpc_rqst *req, struct xdr_stream *xdr, |
| 2645 | const struct nfs4_statfs_arg *args) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2646 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2647 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2648 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2649 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2650 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2651 | encode_compound_hdr(xdr, req, &hdr); |
| 2652 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2653 | encode_putfh(xdr, args->fh, &hdr); |
| 2654 | encode_getattr_two(xdr, args->bitmask[0] & nfs4_statfs_bitmap[0], |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 2655 | args->bitmask[1] & nfs4_statfs_bitmap[1], &hdr); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2656 | encode_nops(&hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2657 | } |
| 2658 | |
| 2659 | /* |
| 2660 | * GETATTR_BITMAP request |
| 2661 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2662 | static void nfs4_xdr_enc_server_caps(struct rpc_rqst *req, |
| 2663 | struct xdr_stream *xdr, |
| 2664 | struct nfs4_server_caps_arg *args) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2665 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2666 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2667 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2668 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2669 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2670 | encode_compound_hdr(xdr, req, &hdr); |
| 2671 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2672 | encode_putfh(xdr, args->fhandle, &hdr); |
| 2673 | encode_getattr_one(xdr, FATTR4_WORD0_SUPPORTED_ATTRS| |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 2674 | FATTR4_WORD0_LINK_SUPPORT| |
| 2675 | FATTR4_WORD0_SYMLINK_SUPPORT| |
| 2676 | FATTR4_WORD0_ACLSUPPORT, &hdr); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2677 | encode_nops(&hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2678 | } |
| 2679 | |
| 2680 | /* |
| 2681 | * a RENEW request |
| 2682 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2683 | static void nfs4_xdr_enc_renew(struct rpc_rqst *req, struct xdr_stream *xdr, |
| 2684 | struct nfs_client *clp) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2685 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2686 | struct compound_hdr hdr = { |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2687 | .nops = 0, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2688 | }; |
| 2689 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2690 | encode_compound_hdr(xdr, req, &hdr); |
| 2691 | encode_renew(xdr, clp, &hdr); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2692 | encode_nops(&hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2693 | } |
| 2694 | |
| 2695 | /* |
| 2696 | * a SETCLIENTID request |
| 2697 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2698 | static void nfs4_xdr_enc_setclientid(struct rpc_rqst *req, |
| 2699 | struct xdr_stream *xdr, |
| 2700 | struct nfs4_setclientid *sc) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2701 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2702 | struct compound_hdr hdr = { |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2703 | .nops = 0, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2704 | }; |
| 2705 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2706 | encode_compound_hdr(xdr, req, &hdr); |
| 2707 | encode_setclientid(xdr, sc, &hdr); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2708 | encode_nops(&hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2709 | } |
| 2710 | |
| 2711 | /* |
| 2712 | * a SETCLIENTID_CONFIRM request |
| 2713 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2714 | static void nfs4_xdr_enc_setclientid_confirm(struct rpc_rqst *req, |
| 2715 | struct xdr_stream *xdr, |
| 2716 | struct nfs4_setclientid_res *arg) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2717 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2718 | struct compound_hdr hdr = { |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2719 | .nops = 0, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2720 | }; |
Fred Isaman | dae100c | 2011-07-30 20:52:37 -0400 | [diff] [blame] | 2721 | const u32 lease_bitmap[3] = { FATTR4_WORD0_LEASE_TIME }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2722 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2723 | encode_compound_hdr(xdr, req, &hdr); |
| 2724 | encode_setclientid_confirm(xdr, arg, &hdr); |
| 2725 | encode_putrootfh(xdr, &hdr); |
| 2726 | encode_fsinfo(xdr, lease_bitmap, &hdr); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2727 | encode_nops(&hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2728 | } |
| 2729 | |
| 2730 | /* |
| 2731 | * DELEGRETURN request |
| 2732 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2733 | static void nfs4_xdr_enc_delegreturn(struct rpc_rqst *req, |
| 2734 | struct xdr_stream *xdr, |
| 2735 | const struct nfs4_delegreturnargs *args) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2736 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2737 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2738 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2739 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2740 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2741 | encode_compound_hdr(xdr, req, &hdr); |
| 2742 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2743 | encode_putfh(xdr, args->fhandle, &hdr); |
| 2744 | encode_delegreturn(xdr, args->stateid, &hdr); |
| 2745 | encode_getfattr(xdr, args->bitmask, &hdr); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2746 | encode_nops(&hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2747 | } |
| 2748 | |
| 2749 | /* |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 2750 | * Encode FS_LOCATIONS request |
| 2751 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2752 | static void nfs4_xdr_enc_fs_locations(struct rpc_rqst *req, |
| 2753 | struct xdr_stream *xdr, |
| 2754 | struct nfs4_fs_locations_arg *args) |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 2755 | { |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 2756 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2757 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 2758 | }; |
Benny Halevy | 28f5669 | 2009-04-01 09:22:09 -0400 | [diff] [blame] | 2759 | uint32_t replen; |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 2760 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2761 | encode_compound_hdr(xdr, req, &hdr); |
| 2762 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2763 | encode_putfh(xdr, args->dir_fh, &hdr); |
| 2764 | encode_lookup(xdr, args->name, &hdr); |
Benny Halevy | 28f5669 | 2009-04-01 09:22:09 -0400 | [diff] [blame] | 2765 | replen = hdr.replen; /* get the attribute into args->page */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2766 | encode_fs_locations(xdr, args->bitmask, &hdr); |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 2767 | |
Benny Halevy | 28f5669 | 2009-04-01 09:22:09 -0400 | [diff] [blame] | 2768 | xdr_inline_pages(&req->rq_rcv_buf, replen << 2, &args->page, |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 2769 | 0, PAGE_SIZE); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2770 | encode_nops(&hdr); |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 2771 | } |
| 2772 | |
Bryan Schumaker | 5a5ea0d | 2011-03-24 17:12:29 +0000 | [diff] [blame] | 2773 | /* |
| 2774 | * Encode SECINFO request |
| 2775 | */ |
| 2776 | static void nfs4_xdr_enc_secinfo(struct rpc_rqst *req, |
| 2777 | struct xdr_stream *xdr, |
| 2778 | struct nfs4_secinfo_arg *args) |
| 2779 | { |
| 2780 | struct compound_hdr hdr = { |
| 2781 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
| 2782 | }; |
| 2783 | |
| 2784 | encode_compound_hdr(xdr, req, &hdr); |
| 2785 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2786 | encode_putfh(xdr, args->dir_fh, &hdr); |
| 2787 | encode_secinfo(xdr, args->name, &hdr); |
| 2788 | encode_nops(&hdr); |
| 2789 | } |
| 2790 | |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 2791 | #if defined(CONFIG_NFS_V4_1) |
| 2792 | /* |
| 2793 | * EXCHANGE_ID request |
| 2794 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2795 | static void nfs4_xdr_enc_exchange_id(struct rpc_rqst *req, |
| 2796 | struct xdr_stream *xdr, |
| 2797 | struct nfs41_exchange_id_args *args) |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 2798 | { |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 2799 | struct compound_hdr hdr = { |
Trond Myklebust | a443234 | 2010-06-16 09:52:27 -0400 | [diff] [blame] | 2800 | .minorversion = args->client->cl_mvops->minor_version, |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 2801 | }; |
| 2802 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2803 | encode_compound_hdr(xdr, req, &hdr); |
| 2804 | encode_exchange_id(xdr, args, &hdr); |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 2805 | encode_nops(&hdr); |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 2806 | } |
Andy Adamson | 2050f0c | 2009-04-01 09:22:30 -0400 | [diff] [blame] | 2807 | |
| 2808 | /* |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 2809 | * a CREATE_SESSION request |
| 2810 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2811 | static void nfs4_xdr_enc_create_session(struct rpc_rqst *req, |
| 2812 | struct xdr_stream *xdr, |
| 2813 | struct nfs41_create_session_args *args) |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 2814 | { |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 2815 | struct compound_hdr hdr = { |
Trond Myklebust | a443234 | 2010-06-16 09:52:27 -0400 | [diff] [blame] | 2816 | .minorversion = args->client->cl_mvops->minor_version, |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 2817 | }; |
| 2818 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2819 | encode_compound_hdr(xdr, req, &hdr); |
| 2820 | encode_create_session(xdr, args, &hdr); |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 2821 | encode_nops(&hdr); |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 2822 | } |
| 2823 | |
| 2824 | /* |
Andy Adamson | 0f3e66c | 2009-04-01 09:22:34 -0400 | [diff] [blame] | 2825 | * a DESTROY_SESSION request |
| 2826 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2827 | static void nfs4_xdr_enc_destroy_session(struct rpc_rqst *req, |
| 2828 | struct xdr_stream *xdr, |
| 2829 | struct nfs4_session *session) |
Andy Adamson | 0f3e66c | 2009-04-01 09:22:34 -0400 | [diff] [blame] | 2830 | { |
Andy Adamson | 0f3e66c | 2009-04-01 09:22:34 -0400 | [diff] [blame] | 2831 | struct compound_hdr hdr = { |
Trond Myklebust | a443234 | 2010-06-16 09:52:27 -0400 | [diff] [blame] | 2832 | .minorversion = session->clp->cl_mvops->minor_version, |
Andy Adamson | 0f3e66c | 2009-04-01 09:22:34 -0400 | [diff] [blame] | 2833 | }; |
| 2834 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2835 | encode_compound_hdr(xdr, req, &hdr); |
| 2836 | encode_destroy_session(xdr, session, &hdr); |
Andy Adamson | 0f3e66c | 2009-04-01 09:22:34 -0400 | [diff] [blame] | 2837 | encode_nops(&hdr); |
Andy Adamson | 0f3e66c | 2009-04-01 09:22:34 -0400 | [diff] [blame] | 2838 | } |
| 2839 | |
| 2840 | /* |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 2841 | * a SEQUENCE request |
| 2842 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2843 | static void nfs4_xdr_enc_sequence(struct rpc_rqst *req, struct xdr_stream *xdr, |
| 2844 | struct nfs4_sequence_args *args) |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 2845 | { |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 2846 | struct compound_hdr hdr = { |
| 2847 | .minorversion = nfs4_xdr_minorversion(args), |
| 2848 | }; |
| 2849 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2850 | encode_compound_hdr(xdr, req, &hdr); |
| 2851 | encode_sequence(xdr, args, &hdr); |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 2852 | encode_nops(&hdr); |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 2853 | } |
| 2854 | |
| 2855 | /* |
Andy Adamson | 2050f0c | 2009-04-01 09:22:30 -0400 | [diff] [blame] | 2856 | * a GET_LEASE_TIME request |
| 2857 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2858 | static void nfs4_xdr_enc_get_lease_time(struct rpc_rqst *req, |
| 2859 | struct xdr_stream *xdr, |
| 2860 | struct nfs4_get_lease_time_args *args) |
Andy Adamson | 2050f0c | 2009-04-01 09:22:30 -0400 | [diff] [blame] | 2861 | { |
Andy Adamson | 2050f0c | 2009-04-01 09:22:30 -0400 | [diff] [blame] | 2862 | struct compound_hdr hdr = { |
| 2863 | .minorversion = nfs4_xdr_minorversion(&args->la_seq_args), |
| 2864 | }; |
Fred Isaman | dae100c | 2011-07-30 20:52:37 -0400 | [diff] [blame] | 2865 | const u32 lease_bitmap[3] = { FATTR4_WORD0_LEASE_TIME }; |
Andy Adamson | 2050f0c | 2009-04-01 09:22:30 -0400 | [diff] [blame] | 2866 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2867 | encode_compound_hdr(xdr, req, &hdr); |
| 2868 | encode_sequence(xdr, &args->la_seq_args, &hdr); |
| 2869 | encode_putrootfh(xdr, &hdr); |
| 2870 | encode_fsinfo(xdr, lease_bitmap, &hdr); |
Andy Adamson | 2050f0c | 2009-04-01 09:22:30 -0400 | [diff] [blame] | 2871 | encode_nops(&hdr); |
Andy Adamson | 2050f0c | 2009-04-01 09:22:30 -0400 | [diff] [blame] | 2872 | } |
Ricardo Labiaga | 1801975 | 2009-12-05 16:08:40 -0500 | [diff] [blame] | 2873 | |
| 2874 | /* |
| 2875 | * a RECLAIM_COMPLETE request |
| 2876 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2877 | static void nfs4_xdr_enc_reclaim_complete(struct rpc_rqst *req, |
| 2878 | struct xdr_stream *xdr, |
| 2879 | struct nfs41_reclaim_complete_args *args) |
Ricardo Labiaga | 1801975 | 2009-12-05 16:08:40 -0500 | [diff] [blame] | 2880 | { |
Ricardo Labiaga | 1801975 | 2009-12-05 16:08:40 -0500 | [diff] [blame] | 2881 | struct compound_hdr hdr = { |
| 2882 | .minorversion = nfs4_xdr_minorversion(&args->seq_args) |
| 2883 | }; |
| 2884 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2885 | encode_compound_hdr(xdr, req, &hdr); |
| 2886 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2887 | encode_reclaim_complete(xdr, args, &hdr); |
Ricardo Labiaga | 1801975 | 2009-12-05 16:08:40 -0500 | [diff] [blame] | 2888 | encode_nops(&hdr); |
Ricardo Labiaga | 1801975 | 2009-12-05 16:08:40 -0500 | [diff] [blame] | 2889 | } |
| 2890 | |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 2891 | /* |
Andy Adamson | 7f11d8d | 2011-07-30 20:52:35 -0400 | [diff] [blame] | 2892 | * Encode GETDEVICELIST request |
| 2893 | */ |
| 2894 | static void nfs4_xdr_enc_getdevicelist(struct rpc_rqst *req, |
| 2895 | struct xdr_stream *xdr, |
| 2896 | struct nfs4_getdevicelist_args *args) |
| 2897 | { |
| 2898 | struct compound_hdr hdr = { |
| 2899 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
| 2900 | }; |
| 2901 | |
| 2902 | encode_compound_hdr(xdr, req, &hdr); |
| 2903 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2904 | encode_putfh(xdr, args->fh, &hdr); |
| 2905 | encode_getdevicelist(xdr, args, &hdr); |
| 2906 | encode_nops(&hdr); |
| 2907 | } |
| 2908 | |
| 2909 | /* |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 2910 | * Encode GETDEVICEINFO request |
| 2911 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2912 | static void nfs4_xdr_enc_getdeviceinfo(struct rpc_rqst *req, |
| 2913 | struct xdr_stream *xdr, |
| 2914 | struct nfs4_getdeviceinfo_args *args) |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 2915 | { |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 2916 | struct compound_hdr hdr = { |
| 2917 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
| 2918 | }; |
| 2919 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2920 | encode_compound_hdr(xdr, req, &hdr); |
| 2921 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2922 | encode_getdeviceinfo(xdr, args, &hdr); |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 2923 | |
| 2924 | /* set up reply kvec. Subtract notification bitmap max size (2) |
| 2925 | * so that notification bitmap is put in xdr_buf tail */ |
| 2926 | xdr_inline_pages(&req->rq_rcv_buf, (hdr.replen - 2) << 2, |
| 2927 | args->pdev->pages, args->pdev->pgbase, |
| 2928 | args->pdev->pglen); |
| 2929 | |
| 2930 | encode_nops(&hdr); |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 2931 | } |
| 2932 | |
| 2933 | /* |
| 2934 | * Encode LAYOUTGET request |
| 2935 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2936 | static void nfs4_xdr_enc_layoutget(struct rpc_rqst *req, |
| 2937 | struct xdr_stream *xdr, |
| 2938 | struct nfs4_layoutget_args *args) |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 2939 | { |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 2940 | struct compound_hdr hdr = { |
| 2941 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
| 2942 | }; |
| 2943 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2944 | encode_compound_hdr(xdr, req, &hdr); |
| 2945 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2946 | encode_putfh(xdr, NFS_FH(args->inode), &hdr); |
| 2947 | encode_layoutget(xdr, args, &hdr); |
Weston Andros Adamson | 35124a0 | 2011-03-24 16:48:21 -0400 | [diff] [blame] | 2948 | |
| 2949 | xdr_inline_pages(&req->rq_rcv_buf, hdr.replen << 2, |
| 2950 | args->layout.pages, 0, args->layout.pglen); |
| 2951 | |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 2952 | encode_nops(&hdr); |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 2953 | } |
Andy Adamson | 863a3c6 | 2011-03-23 13:27:54 +0000 | [diff] [blame] | 2954 | |
| 2955 | /* |
| 2956 | * Encode LAYOUTCOMMIT request |
| 2957 | */ |
Benny Halevy | cbe8260 | 2011-05-22 19:52:37 +0300 | [diff] [blame] | 2958 | static void nfs4_xdr_enc_layoutcommit(struct rpc_rqst *req, |
| 2959 | struct xdr_stream *xdr, |
| 2960 | struct nfs4_layoutcommit_args *args) |
Andy Adamson | 863a3c6 | 2011-03-23 13:27:54 +0000 | [diff] [blame] | 2961 | { |
Benny Halevy | ac7db72 | 2011-05-22 19:53:48 +0300 | [diff] [blame] | 2962 | struct nfs4_layoutcommit_data *data = |
| 2963 | container_of(args, struct nfs4_layoutcommit_data, args); |
Andy Adamson | 863a3c6 | 2011-03-23 13:27:54 +0000 | [diff] [blame] | 2964 | struct compound_hdr hdr = { |
| 2965 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
| 2966 | }; |
| 2967 | |
| 2968 | encode_compound_hdr(xdr, req, &hdr); |
| 2969 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2970 | encode_putfh(xdr, NFS_FH(args->inode), &hdr); |
Benny Halevy | ac7db72 | 2011-05-22 19:53:48 +0300 | [diff] [blame] | 2971 | encode_layoutcommit(xdr, data->args.inode, args, &hdr); |
Andy Adamson | 863a3c6 | 2011-03-23 13:27:54 +0000 | [diff] [blame] | 2972 | encode_getfattr(xdr, args->bitmask, &hdr); |
| 2973 | encode_nops(&hdr); |
Benny Halevy | cbe8260 | 2011-05-22 19:52:37 +0300 | [diff] [blame] | 2974 | } |
| 2975 | |
| 2976 | /* |
| 2977 | * Encode LAYOUTRETURN request |
| 2978 | */ |
| 2979 | static void nfs4_xdr_enc_layoutreturn(struct rpc_rqst *req, |
| 2980 | struct xdr_stream *xdr, |
| 2981 | struct nfs4_layoutreturn_args *args) |
| 2982 | { |
| 2983 | struct compound_hdr hdr = { |
| 2984 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
| 2985 | }; |
| 2986 | |
| 2987 | encode_compound_hdr(xdr, req, &hdr); |
| 2988 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2989 | encode_putfh(xdr, NFS_FH(args->inode), &hdr); |
| 2990 | encode_layoutreturn(xdr, args, &hdr); |
| 2991 | encode_nops(&hdr); |
Andy Adamson | 863a3c6 | 2011-03-23 13:27:54 +0000 | [diff] [blame] | 2992 | } |
Bryan Schumaker | fca78d6 | 2011-06-02 14:59:07 -0400 | [diff] [blame] | 2993 | |
| 2994 | /* |
| 2995 | * Encode SECINFO_NO_NAME request |
| 2996 | */ |
| 2997 | static int nfs4_xdr_enc_secinfo_no_name(struct rpc_rqst *req, |
| 2998 | struct xdr_stream *xdr, |
| 2999 | struct nfs41_secinfo_no_name_args *args) |
| 3000 | { |
| 3001 | struct compound_hdr hdr = { |
| 3002 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
| 3003 | }; |
| 3004 | |
| 3005 | encode_compound_hdr(xdr, req, &hdr); |
| 3006 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 3007 | encode_putrootfh(xdr, &hdr); |
| 3008 | encode_secinfo_no_name(xdr, args, &hdr); |
| 3009 | encode_nops(&hdr); |
| 3010 | return 0; |
| 3011 | } |
Bryan Schumaker | 7d97479 | 2011-06-02 14:59:08 -0400 | [diff] [blame] | 3012 | |
| 3013 | /* |
| 3014 | * Encode TEST_STATEID request |
| 3015 | */ |
| 3016 | static void nfs4_xdr_enc_test_stateid(struct rpc_rqst *req, |
| 3017 | struct xdr_stream *xdr, |
| 3018 | struct nfs41_test_stateid_args *args) |
| 3019 | { |
| 3020 | struct compound_hdr hdr = { |
| 3021 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
| 3022 | }; |
| 3023 | |
| 3024 | encode_compound_hdr(xdr, req, &hdr); |
| 3025 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 3026 | encode_test_stateid(xdr, args, &hdr); |
| 3027 | encode_nops(&hdr); |
| 3028 | } |
Bryan Schumaker | 9aeda35 | 2011-06-02 14:59:09 -0400 | [diff] [blame] | 3029 | |
| 3030 | /* |
| 3031 | * Encode FREE_STATEID request |
| 3032 | */ |
| 3033 | static void nfs4_xdr_enc_free_stateid(struct rpc_rqst *req, |
| 3034 | struct xdr_stream *xdr, |
| 3035 | struct nfs41_free_stateid_args *args) |
| 3036 | { |
| 3037 | struct compound_hdr hdr = { |
| 3038 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
| 3039 | }; |
| 3040 | |
| 3041 | encode_compound_hdr(xdr, req, &hdr); |
| 3042 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 3043 | encode_free_stateid(xdr, args, &hdr); |
| 3044 | encode_nops(&hdr); |
| 3045 | } |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 3046 | #endif /* CONFIG_NFS_V4_1 */ |
| 3047 | |
Benny Halevy | 686841b | 2009-08-14 17:19:48 +0300 | [diff] [blame] | 3048 | static void print_overflow_msg(const char *func, const struct xdr_stream *xdr) |
| 3049 | { |
| 3050 | dprintk("nfs: %s: prematurely hit end of receive buffer. " |
| 3051 | "Remaining buffer length is %tu words.\n", |
| 3052 | func, xdr->end - xdr->p); |
| 3053 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3054 | |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 3055 | 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] | 3056 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3057 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3058 | |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3059 | p = xdr_inline_decode(xdr, 4); |
| 3060 | if (unlikely(!p)) |
| 3061 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3062 | *len = be32_to_cpup(p); |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3063 | p = xdr_inline_decode(xdr, *len); |
| 3064 | if (unlikely(!p)) |
| 3065 | goto out_overflow; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3066 | *string = (char *)p; |
| 3067 | return 0; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3068 | out_overflow: |
| 3069 | print_overflow_msg(__func__, xdr); |
| 3070 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3071 | } |
| 3072 | |
| 3073 | static int decode_compound_hdr(struct xdr_stream *xdr, struct compound_hdr *hdr) |
| 3074 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3075 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3076 | |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3077 | p = xdr_inline_decode(xdr, 8); |
| 3078 | if (unlikely(!p)) |
| 3079 | goto out_overflow; |
Benny Halevy | 6f723f7 | 2009-08-14 17:19:37 +0300 | [diff] [blame] | 3080 | hdr->status = be32_to_cpup(p++); |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3081 | hdr->taglen = be32_to_cpup(p); |
Andy Adamson | 6c0195a | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 3082 | |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3083 | p = xdr_inline_decode(xdr, hdr->taglen + 4); |
| 3084 | if (unlikely(!p)) |
| 3085 | goto out_overflow; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3086 | hdr->tag = (char *)p; |
| 3087 | p += XDR_QUADLEN(hdr->taglen); |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3088 | hdr->nops = be32_to_cpup(p); |
Benny Halevy | aadf615 | 2008-12-23 16:06:13 -0500 | [diff] [blame] | 3089 | if (unlikely(hdr->nops < 1)) |
| 3090 | return nfs4_stat_to_errno(hdr->status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3091 | return 0; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3092 | out_overflow: |
| 3093 | print_overflow_msg(__func__, xdr); |
| 3094 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3095 | } |
| 3096 | |
| 3097 | static int decode_op_hdr(struct xdr_stream *xdr, enum nfs_opnum4 expected) |
| 3098 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3099 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3100 | uint32_t opnum; |
| 3101 | int32_t nfserr; |
| 3102 | |
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 | 6f723f7 | 2009-08-14 17:19:37 +0300 | [diff] [blame] | 3106 | opnum = be32_to_cpup(p++); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3107 | if (opnum != expected) { |
Chuck Lever | fe82a18 | 2007-09-11 18:01:10 -0400 | [diff] [blame] | 3108 | dprintk("nfs: Server returned operation" |
| 3109 | " %d but we issued a request for %d\n", |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3110 | opnum, expected); |
| 3111 | return -EIO; |
| 3112 | } |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3113 | nfserr = be32_to_cpup(p); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3114 | if (nfserr != NFS_OK) |
Benny Halevy | 856dff3 | 2008-03-31 17:39:06 +0300 | [diff] [blame] | 3115 | return nfs4_stat_to_errno(nfserr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3116 | return 0; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3117 | out_overflow: |
| 3118 | print_overflow_msg(__func__, xdr); |
| 3119 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3120 | } |
| 3121 | |
| 3122 | /* Dummy routine */ |
David Howells | adfa6f9 | 2006-08-22 20:06:08 -0400 | [diff] [blame] | 3123 | 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] | 3124 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3125 | __be32 *p; |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 3126 | unsigned int strlen; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3127 | char *str; |
| 3128 | |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3129 | p = xdr_inline_decode(xdr, 12); |
| 3130 | if (likely(p)) |
| 3131 | return decode_opaque_inline(xdr, &strlen, &str); |
| 3132 | print_overflow_msg(__func__, xdr); |
| 3133 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3134 | } |
| 3135 | |
| 3136 | static int decode_attr_bitmap(struct xdr_stream *xdr, uint32_t *bitmap) |
| 3137 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3138 | uint32_t bmlen; |
| 3139 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3140 | |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3141 | p = xdr_inline_decode(xdr, 4); |
| 3142 | if (unlikely(!p)) |
| 3143 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3144 | bmlen = be32_to_cpup(p); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3145 | |
Fred Isaman | dae100c | 2011-07-30 20:52:37 -0400 | [diff] [blame] | 3146 | bitmap[0] = bitmap[1] = bitmap[2] = 0; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3147 | p = xdr_inline_decode(xdr, (bmlen << 2)); |
| 3148 | if (unlikely(!p)) |
| 3149 | goto out_overflow; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3150 | if (bmlen > 0) { |
Benny Halevy | 6f723f7 | 2009-08-14 17:19:37 +0300 | [diff] [blame] | 3151 | bitmap[0] = be32_to_cpup(p++); |
Fred Isaman | dae100c | 2011-07-30 20:52:37 -0400 | [diff] [blame] | 3152 | if (bmlen > 1) { |
| 3153 | bitmap[1] = be32_to_cpup(p++); |
| 3154 | if (bmlen > 2) |
| 3155 | bitmap[2] = be32_to_cpup(p); |
| 3156 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3157 | } |
| 3158 | return 0; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3159 | out_overflow: |
| 3160 | print_overflow_msg(__func__, xdr); |
| 3161 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3162 | } |
| 3163 | |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3164 | 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] | 3165 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3166 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3167 | |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3168 | p = xdr_inline_decode(xdr, 4); |
| 3169 | if (unlikely(!p)) |
| 3170 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3171 | *attrlen = be32_to_cpup(p); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3172 | *savep = xdr->p; |
| 3173 | return 0; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3174 | out_overflow: |
| 3175 | print_overflow_msg(__func__, xdr); |
| 3176 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3177 | } |
| 3178 | |
| 3179 | static int decode_attr_supported(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t *bitmask) |
| 3180 | { |
| 3181 | if (likely(bitmap[0] & FATTR4_WORD0_SUPPORTED_ATTRS)) { |
Roman Borisov | 3388bff | 2010-10-13 16:54:51 +0400 | [diff] [blame] | 3182 | int ret; |
| 3183 | ret = decode_attr_bitmap(xdr, bitmask); |
| 3184 | if (unlikely(ret < 0)) |
| 3185 | return ret; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3186 | bitmap[0] &= ~FATTR4_WORD0_SUPPORTED_ATTRS; |
| 3187 | } else |
Fred Isaman | dae100c | 2011-07-30 20:52:37 -0400 | [diff] [blame] | 3188 | bitmask[0] = bitmask[1] = bitmask[2] = 0; |
| 3189 | dprintk("%s: bitmask=%08x:%08x:%08x\n", __func__, |
| 3190 | bitmask[0], bitmask[1], bitmask[2]); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3191 | return 0; |
| 3192 | } |
| 3193 | |
| 3194 | static int decode_attr_type(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t *type) |
| 3195 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3196 | __be32 *p; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3197 | int ret = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3198 | |
| 3199 | *type = 0; |
| 3200 | if (unlikely(bitmap[0] & (FATTR4_WORD0_TYPE - 1U))) |
| 3201 | return -EIO; |
| 3202 | if (likely(bitmap[0] & FATTR4_WORD0_TYPE)) { |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3203 | p = xdr_inline_decode(xdr, 4); |
| 3204 | if (unlikely(!p)) |
| 3205 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3206 | *type = be32_to_cpup(p); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3207 | if (*type < NF4REG || *type > NF4NAMEDATTR) { |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3208 | dprintk("%s: bad type %d\n", __func__, *type); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3209 | return -EIO; |
| 3210 | } |
| 3211 | bitmap[0] &= ~FATTR4_WORD0_TYPE; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3212 | ret = NFS_ATTR_FATTR_TYPE; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3213 | } |
Trond Myklebust | bca7947 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 3214 | dprintk("%s: type=0%o\n", __func__, nfs_type2fmt[*type]); |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3215 | return ret; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3216 | out_overflow: |
| 3217 | print_overflow_msg(__func__, xdr); |
| 3218 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3219 | } |
| 3220 | |
| 3221 | static int decode_attr_change(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *change) |
| 3222 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3223 | __be32 *p; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3224 | int ret = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3225 | |
| 3226 | *change = 0; |
| 3227 | if (unlikely(bitmap[0] & (FATTR4_WORD0_CHANGE - 1U))) |
| 3228 | return -EIO; |
| 3229 | if (likely(bitmap[0] & FATTR4_WORD0_CHANGE)) { |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3230 | p = xdr_inline_decode(xdr, 8); |
| 3231 | if (unlikely(!p)) |
| 3232 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3233 | xdr_decode_hyper(p, change); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3234 | bitmap[0] &= ~FATTR4_WORD0_CHANGE; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3235 | ret = NFS_ATTR_FATTR_CHANGE; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3236 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3237 | dprintk("%s: change attribute=%Lu\n", __func__, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3238 | (unsigned long long)*change); |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3239 | return ret; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3240 | out_overflow: |
| 3241 | print_overflow_msg(__func__, xdr); |
| 3242 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3243 | } |
| 3244 | |
| 3245 | static int decode_attr_size(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *size) |
| 3246 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3247 | __be32 *p; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3248 | int ret = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3249 | |
| 3250 | *size = 0; |
| 3251 | if (unlikely(bitmap[0] & (FATTR4_WORD0_SIZE - 1U))) |
| 3252 | return -EIO; |
| 3253 | if (likely(bitmap[0] & FATTR4_WORD0_SIZE)) { |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3254 | p = xdr_inline_decode(xdr, 8); |
| 3255 | if (unlikely(!p)) |
| 3256 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3257 | xdr_decode_hyper(p, size); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3258 | bitmap[0] &= ~FATTR4_WORD0_SIZE; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3259 | ret = NFS_ATTR_FATTR_SIZE; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3260 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3261 | dprintk("%s: file size=%Lu\n", __func__, (unsigned long long)*size); |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3262 | return ret; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3263 | out_overflow: |
| 3264 | print_overflow_msg(__func__, xdr); |
| 3265 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3266 | } |
| 3267 | |
| 3268 | static int decode_attr_link_support(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t *res) |
| 3269 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3270 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3271 | |
| 3272 | *res = 0; |
| 3273 | if (unlikely(bitmap[0] & (FATTR4_WORD0_LINK_SUPPORT - 1U))) |
| 3274 | return -EIO; |
| 3275 | if (likely(bitmap[0] & FATTR4_WORD0_LINK_SUPPORT)) { |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3276 | p = xdr_inline_decode(xdr, 4); |
| 3277 | if (unlikely(!p)) |
| 3278 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3279 | *res = be32_to_cpup(p); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3280 | bitmap[0] &= ~FATTR4_WORD0_LINK_SUPPORT; |
| 3281 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3282 | dprintk("%s: link support=%s\n", __func__, *res == 0 ? "false" : "true"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3283 | return 0; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3284 | out_overflow: |
| 3285 | print_overflow_msg(__func__, xdr); |
| 3286 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3287 | } |
| 3288 | |
| 3289 | static int decode_attr_symlink_support(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t *res) |
| 3290 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3291 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3292 | |
| 3293 | *res = 0; |
| 3294 | if (unlikely(bitmap[0] & (FATTR4_WORD0_SYMLINK_SUPPORT - 1U))) |
| 3295 | return -EIO; |
| 3296 | if (likely(bitmap[0] & FATTR4_WORD0_SYMLINK_SUPPORT)) { |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3297 | p = xdr_inline_decode(xdr, 4); |
| 3298 | if (unlikely(!p)) |
| 3299 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3300 | *res = be32_to_cpup(p); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3301 | bitmap[0] &= ~FATTR4_WORD0_SYMLINK_SUPPORT; |
| 3302 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3303 | dprintk("%s: symlink support=%s\n", __func__, *res == 0 ? "false" : "true"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3304 | return 0; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3305 | out_overflow: |
| 3306 | print_overflow_msg(__func__, xdr); |
| 3307 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3308 | } |
| 3309 | |
Trond Myklebust | 8b4bdcf | 2006-06-09 09:34:19 -0400 | [diff] [blame] | 3310 | 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] | 3311 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3312 | __be32 *p; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3313 | int ret = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3314 | |
| 3315 | fsid->major = 0; |
| 3316 | fsid->minor = 0; |
| 3317 | if (unlikely(bitmap[0] & (FATTR4_WORD0_FSID - 1U))) |
| 3318 | return -EIO; |
| 3319 | if (likely(bitmap[0] & FATTR4_WORD0_FSID)) { |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3320 | p = xdr_inline_decode(xdr, 16); |
| 3321 | if (unlikely(!p)) |
| 3322 | goto out_overflow; |
Benny Halevy | 3ceb4db | 2009-08-14 17:19:41 +0300 | [diff] [blame] | 3323 | p = xdr_decode_hyper(p, &fsid->major); |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3324 | xdr_decode_hyper(p, &fsid->minor); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3325 | bitmap[0] &= ~FATTR4_WORD0_FSID; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3326 | ret = NFS_ATTR_FATTR_FSID; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3327 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3328 | dprintk("%s: fsid=(0x%Lx/0x%Lx)\n", __func__, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3329 | (unsigned long long)fsid->major, |
| 3330 | (unsigned long long)fsid->minor); |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3331 | return ret; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3332 | out_overflow: |
| 3333 | print_overflow_msg(__func__, xdr); |
| 3334 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3335 | } |
| 3336 | |
| 3337 | static int decode_attr_lease_time(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t *res) |
| 3338 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3339 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3340 | |
| 3341 | *res = 60; |
| 3342 | if (unlikely(bitmap[0] & (FATTR4_WORD0_LEASE_TIME - 1U))) |
| 3343 | return -EIO; |
| 3344 | if (likely(bitmap[0] & FATTR4_WORD0_LEASE_TIME)) { |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3345 | p = xdr_inline_decode(xdr, 4); |
| 3346 | if (unlikely(!p)) |
| 3347 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3348 | *res = be32_to_cpup(p); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3349 | bitmap[0] &= ~FATTR4_WORD0_LEASE_TIME; |
| 3350 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3351 | dprintk("%s: file size=%u\n", __func__, (unsigned int)*res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3352 | return 0; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3353 | out_overflow: |
| 3354 | print_overflow_msg(__func__, xdr); |
| 3355 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3356 | } |
| 3357 | |
Trond Myklebust | ee7b75f | 2011-06-16 13:15:41 -0400 | [diff] [blame] | 3358 | 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] | 3359 | { |
| 3360 | __be32 *p; |
| 3361 | |
| 3362 | if (unlikely(bitmap[0] & (FATTR4_WORD0_RDATTR_ERROR - 1U))) |
| 3363 | return -EIO; |
| 3364 | if (likely(bitmap[0] & FATTR4_WORD0_RDATTR_ERROR)) { |
| 3365 | p = xdr_inline_decode(xdr, 4); |
| 3366 | if (unlikely(!p)) |
| 3367 | goto out_overflow; |
| 3368 | bitmap[0] &= ~FATTR4_WORD0_RDATTR_ERROR; |
Trond Myklebust | ee7b75f | 2011-06-16 13:15:41 -0400 | [diff] [blame] | 3369 | *res = -be32_to_cpup(p); |
Bryan Schumaker | ae42c70 | 2010-10-21 16:33:17 -0400 | [diff] [blame] | 3370 | } |
| 3371 | return 0; |
| 3372 | out_overflow: |
| 3373 | print_overflow_msg(__func__, xdr); |
| 3374 | return -EIO; |
| 3375 | } |
| 3376 | |
| 3377 | static int decode_attr_filehandle(struct xdr_stream *xdr, uint32_t *bitmap, struct nfs_fh *fh) |
| 3378 | { |
| 3379 | __be32 *p; |
| 3380 | int len; |
| 3381 | |
Trond Myklebust | 7ad0735 | 2010-10-23 15:34:20 -0400 | [diff] [blame] | 3382 | if (fh != NULL) |
| 3383 | memset(fh, 0, sizeof(*fh)); |
Bryan Schumaker | ae42c70 | 2010-10-21 16:33:17 -0400 | [diff] [blame] | 3384 | |
| 3385 | if (unlikely(bitmap[0] & (FATTR4_WORD0_FILEHANDLE - 1U))) |
| 3386 | return -EIO; |
| 3387 | if (likely(bitmap[0] & FATTR4_WORD0_FILEHANDLE)) { |
| 3388 | p = xdr_inline_decode(xdr, 4); |
| 3389 | if (unlikely(!p)) |
| 3390 | goto out_overflow; |
| 3391 | len = be32_to_cpup(p); |
| 3392 | if (len > NFS4_FHSIZE) |
| 3393 | return -EIO; |
Bryan Schumaker | ae42c70 | 2010-10-21 16:33:17 -0400 | [diff] [blame] | 3394 | p = xdr_inline_decode(xdr, len); |
| 3395 | if (unlikely(!p)) |
| 3396 | goto out_overflow; |
Trond Myklebust | 7ad0735 | 2010-10-23 15:34:20 -0400 | [diff] [blame] | 3397 | if (fh != NULL) { |
| 3398 | memcpy(fh->data, p, len); |
| 3399 | fh->size = len; |
| 3400 | } |
Bryan Schumaker | ae42c70 | 2010-10-21 16:33:17 -0400 | [diff] [blame] | 3401 | bitmap[0] &= ~FATTR4_WORD0_FILEHANDLE; |
| 3402 | } |
| 3403 | return 0; |
| 3404 | out_overflow: |
| 3405 | print_overflow_msg(__func__, xdr); |
| 3406 | return -EIO; |
| 3407 | } |
| 3408 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3409 | static int decode_attr_aclsupport(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t *res) |
| 3410 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3411 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3412 | |
| 3413 | *res = ACL4_SUPPORT_ALLOW_ACL|ACL4_SUPPORT_DENY_ACL; |
| 3414 | if (unlikely(bitmap[0] & (FATTR4_WORD0_ACLSUPPORT - 1U))) |
| 3415 | return -EIO; |
| 3416 | if (likely(bitmap[0] & FATTR4_WORD0_ACLSUPPORT)) { |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3417 | p = xdr_inline_decode(xdr, 4); |
| 3418 | if (unlikely(!p)) |
| 3419 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3420 | *res = be32_to_cpup(p); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3421 | bitmap[0] &= ~FATTR4_WORD0_ACLSUPPORT; |
| 3422 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3423 | dprintk("%s: ACLs supported=%u\n", __func__, (unsigned int)*res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3424 | return 0; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3425 | out_overflow: |
| 3426 | print_overflow_msg(__func__, xdr); |
| 3427 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3428 | } |
| 3429 | |
| 3430 | static int decode_attr_fileid(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *fileid) |
| 3431 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3432 | __be32 *p; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3433 | int ret = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3434 | |
| 3435 | *fileid = 0; |
| 3436 | if (unlikely(bitmap[0] & (FATTR4_WORD0_FILEID - 1U))) |
| 3437 | return -EIO; |
| 3438 | if (likely(bitmap[0] & FATTR4_WORD0_FILEID)) { |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3439 | p = xdr_inline_decode(xdr, 8); |
| 3440 | if (unlikely(!p)) |
| 3441 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3442 | xdr_decode_hyper(p, fileid); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3443 | bitmap[0] &= ~FATTR4_WORD0_FILEID; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3444 | ret = NFS_ATTR_FATTR_FILEID; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3445 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3446 | dprintk("%s: fileid=%Lu\n", __func__, (unsigned long long)*fileid); |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3447 | return ret; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3448 | out_overflow: |
| 3449 | print_overflow_msg(__func__, xdr); |
| 3450 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3451 | } |
| 3452 | |
Manoj Naik | 99baf62 | 2006-06-09 09:34:24 -0400 | [diff] [blame] | 3453 | static int decode_attr_mounted_on_fileid(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *fileid) |
| 3454 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3455 | __be32 *p; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3456 | int ret = 0; |
Manoj Naik | 99baf62 | 2006-06-09 09:34:24 -0400 | [diff] [blame] | 3457 | |
| 3458 | *fileid = 0; |
| 3459 | if (unlikely(bitmap[1] & (FATTR4_WORD1_MOUNTED_ON_FILEID - 1U))) |
| 3460 | return -EIO; |
| 3461 | if (likely(bitmap[1] & FATTR4_WORD1_MOUNTED_ON_FILEID)) { |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3462 | p = xdr_inline_decode(xdr, 8); |
| 3463 | if (unlikely(!p)) |
| 3464 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3465 | xdr_decode_hyper(p, fileid); |
Manoj Naik | 99baf62 | 2006-06-09 09:34:24 -0400 | [diff] [blame] | 3466 | bitmap[1] &= ~FATTR4_WORD1_MOUNTED_ON_FILEID; |
Trond Myklebust | 28331a4 | 2011-04-27 13:47:52 -0400 | [diff] [blame] | 3467 | ret = NFS_ATTR_FATTR_MOUNTED_ON_FILEID; |
Manoj Naik | 99baf62 | 2006-06-09 09:34:24 -0400 | [diff] [blame] | 3468 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3469 | dprintk("%s: fileid=%Lu\n", __func__, (unsigned long long)*fileid); |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3470 | return ret; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3471 | out_overflow: |
| 3472 | print_overflow_msg(__func__, xdr); |
| 3473 | return -EIO; |
Manoj Naik | 99baf62 | 2006-06-09 09:34:24 -0400 | [diff] [blame] | 3474 | } |
| 3475 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3476 | static int decode_attr_files_avail(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *res) |
| 3477 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3478 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3479 | int status = 0; |
| 3480 | |
| 3481 | *res = 0; |
| 3482 | if (unlikely(bitmap[0] & (FATTR4_WORD0_FILES_AVAIL - 1U))) |
| 3483 | return -EIO; |
| 3484 | if (likely(bitmap[0] & FATTR4_WORD0_FILES_AVAIL)) { |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3485 | p = xdr_inline_decode(xdr, 8); |
| 3486 | if (unlikely(!p)) |
| 3487 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3488 | xdr_decode_hyper(p, res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3489 | bitmap[0] &= ~FATTR4_WORD0_FILES_AVAIL; |
| 3490 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3491 | dprintk("%s: files avail=%Lu\n", __func__, (unsigned long long)*res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3492 | return status; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3493 | out_overflow: |
| 3494 | print_overflow_msg(__func__, xdr); |
| 3495 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3496 | } |
| 3497 | |
| 3498 | static int decode_attr_files_free(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *res) |
| 3499 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3500 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3501 | int status = 0; |
| 3502 | |
| 3503 | *res = 0; |
| 3504 | if (unlikely(bitmap[0] & (FATTR4_WORD0_FILES_FREE - 1U))) |
| 3505 | return -EIO; |
| 3506 | if (likely(bitmap[0] & FATTR4_WORD0_FILES_FREE)) { |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3507 | p = xdr_inline_decode(xdr, 8); |
| 3508 | if (unlikely(!p)) |
| 3509 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3510 | xdr_decode_hyper(p, res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3511 | bitmap[0] &= ~FATTR4_WORD0_FILES_FREE; |
| 3512 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3513 | dprintk("%s: files free=%Lu\n", __func__, (unsigned long long)*res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3514 | return status; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3515 | out_overflow: |
| 3516 | print_overflow_msg(__func__, xdr); |
| 3517 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3518 | } |
| 3519 | |
| 3520 | static int decode_attr_files_total(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *res) |
| 3521 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3522 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3523 | int status = 0; |
| 3524 | |
| 3525 | *res = 0; |
| 3526 | if (unlikely(bitmap[0] & (FATTR4_WORD0_FILES_TOTAL - 1U))) |
| 3527 | return -EIO; |
| 3528 | if (likely(bitmap[0] & FATTR4_WORD0_FILES_TOTAL)) { |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3529 | p = xdr_inline_decode(xdr, 8); |
| 3530 | if (unlikely(!p)) |
| 3531 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3532 | xdr_decode_hyper(p, res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3533 | bitmap[0] &= ~FATTR4_WORD0_FILES_TOTAL; |
| 3534 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3535 | dprintk("%s: files total=%Lu\n", __func__, (unsigned long long)*res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3536 | return status; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3537 | out_overflow: |
| 3538 | print_overflow_msg(__func__, xdr); |
| 3539 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3540 | } |
| 3541 | |
Manoj Naik | 7aaa0b3 | 2006-06-09 09:34:23 -0400 | [diff] [blame] | 3542 | static int decode_pathname(struct xdr_stream *xdr, struct nfs4_pathname *path) |
| 3543 | { |
Chuck Lever | 464ad6b | 2007-10-26 13:32:08 -0400 | [diff] [blame] | 3544 | u32 n; |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3545 | __be32 *p; |
Manoj Naik | 7aaa0b3 | 2006-06-09 09:34:23 -0400 | [diff] [blame] | 3546 | int status = 0; |
| 3547 | |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3548 | p = xdr_inline_decode(xdr, 4); |
| 3549 | if (unlikely(!p)) |
| 3550 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3551 | n = be32_to_cpup(p); |
Andy Adamson | 33a43f2 | 2006-06-09 09:34:30 -0400 | [diff] [blame] | 3552 | if (n == 0) |
| 3553 | goto root_path; |
Manoj Naik | 7aaa0b3 | 2006-06-09 09:34:23 -0400 | [diff] [blame] | 3554 | dprintk("path "); |
| 3555 | path->ncomponents = 0; |
| 3556 | while (path->ncomponents < n) { |
| 3557 | struct nfs4_string *component = &path->components[path->ncomponents]; |
| 3558 | status = decode_opaque_inline(xdr, &component->len, &component->data); |
| 3559 | if (unlikely(status != 0)) |
| 3560 | goto out_eio; |
| 3561 | if (path->ncomponents != n) |
| 3562 | dprintk("/"); |
| 3563 | dprintk("%s", component->data); |
| 3564 | if (path->ncomponents < NFS4_PATHNAME_MAXCOMPONENTS) |
| 3565 | path->ncomponents++; |
| 3566 | else { |
| 3567 | dprintk("cannot parse %d components in path\n", n); |
| 3568 | goto out_eio; |
| 3569 | } |
| 3570 | } |
| 3571 | out: |
| 3572 | dprintk("\n"); |
| 3573 | return status; |
Andy Adamson | 33a43f2 | 2006-06-09 09:34:30 -0400 | [diff] [blame] | 3574 | root_path: |
| 3575 | /* a root pathname is sent as a zero component4 */ |
| 3576 | path->ncomponents = 1; |
| 3577 | path->components[0].len=0; |
| 3578 | path->components[0].data=NULL; |
| 3579 | dprintk("path /\n"); |
| 3580 | goto out; |
Manoj Naik | 7aaa0b3 | 2006-06-09 09:34:23 -0400 | [diff] [blame] | 3581 | out_eio: |
| 3582 | dprintk(" status %d", status); |
| 3583 | status = -EIO; |
| 3584 | goto out; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3585 | out_overflow: |
| 3586 | print_overflow_msg(__func__, xdr); |
| 3587 | return -EIO; |
Manoj Naik | 7aaa0b3 | 2006-06-09 09:34:23 -0400 | [diff] [blame] | 3588 | } |
| 3589 | |
| 3590 | 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] | 3591 | { |
| 3592 | int n; |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3593 | __be32 *p; |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 3594 | int status = -EIO; |
| 3595 | |
| 3596 | if (unlikely(bitmap[0] & (FATTR4_WORD0_FS_LOCATIONS -1U))) |
| 3597 | goto out; |
| 3598 | status = 0; |
| 3599 | if (unlikely(!(bitmap[0] & FATTR4_WORD0_FS_LOCATIONS))) |
| 3600 | goto out; |
Trond Myklebust | 8b7e3f4 | 2012-01-30 15:43:56 -0500 | [diff] [blame] | 3601 | status = -EIO; |
| 3602 | /* Ignore borken servers that return unrequested attrs */ |
| 3603 | if (unlikely(res == NULL)) |
| 3604 | goto out; |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3605 | dprintk("%s: fsroot ", __func__); |
Manoj Naik | 7aaa0b3 | 2006-06-09 09:34:23 -0400 | [diff] [blame] | 3606 | status = decode_pathname(xdr, &res->fs_path); |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 3607 | if (unlikely(status != 0)) |
| 3608 | goto out; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3609 | p = xdr_inline_decode(xdr, 4); |
| 3610 | if (unlikely(!p)) |
| 3611 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3612 | n = be32_to_cpup(p); |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 3613 | if (n <= 0) |
| 3614 | goto out_eio; |
| 3615 | res->nlocations = 0; |
| 3616 | while (res->nlocations < n) { |
Chuck Lever | 464ad6b | 2007-10-26 13:32:08 -0400 | [diff] [blame] | 3617 | u32 m; |
Manoj Naik | 7aaa0b3 | 2006-06-09 09:34:23 -0400 | [diff] [blame] | 3618 | struct nfs4_fs_location *loc = &res->locations[res->nlocations]; |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 3619 | |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3620 | p = xdr_inline_decode(xdr, 4); |
| 3621 | if (unlikely(!p)) |
| 3622 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3623 | m = be32_to_cpup(p); |
Manoj Naik | 7aaa0b3 | 2006-06-09 09:34:23 -0400 | [diff] [blame] | 3624 | |
| 3625 | loc->nservers = 0; |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3626 | dprintk("%s: servers ", __func__); |
Manoj Naik | 7aaa0b3 | 2006-06-09 09:34:23 -0400 | [diff] [blame] | 3627 | while (loc->nservers < m) { |
| 3628 | struct nfs4_string *server = &loc->servers[loc->nservers]; |
| 3629 | status = decode_opaque_inline(xdr, &server->len, &server->data); |
| 3630 | if (unlikely(status != 0)) |
| 3631 | goto out_eio; |
| 3632 | dprintk("%s ", server->data); |
| 3633 | if (loc->nservers < NFS4_FS_LOCATION_MAXSERVERS) |
| 3634 | loc->nservers++; |
| 3635 | else { |
Chuck Lever | 464ad6b | 2007-10-26 13:32:08 -0400 | [diff] [blame] | 3636 | unsigned int i; |
| 3637 | dprintk("%s: using first %u of %u servers " |
| 3638 | "returned for location %u\n", |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3639 | __func__, |
Chuck Lever | 464ad6b | 2007-10-26 13:32:08 -0400 | [diff] [blame] | 3640 | NFS4_FS_LOCATION_MAXSERVERS, |
| 3641 | m, res->nlocations); |
Manoj Naik | 7aaa0b3 | 2006-06-09 09:34:23 -0400 | [diff] [blame] | 3642 | for (i = loc->nservers; i < m; i++) { |
Trond Myklebust | 2e42c3e | 2007-05-14 17:20:41 -0400 | [diff] [blame] | 3643 | unsigned int len; |
Manoj Naik | 7aaa0b3 | 2006-06-09 09:34:23 -0400 | [diff] [blame] | 3644 | char *data; |
| 3645 | status = decode_opaque_inline(xdr, &len, &data); |
| 3646 | if (unlikely(status != 0)) |
| 3647 | goto out_eio; |
| 3648 | } |
| 3649 | } |
| 3650 | } |
| 3651 | status = decode_pathname(xdr, &loc->rootpath); |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 3652 | if (unlikely(status != 0)) |
| 3653 | goto out_eio; |
Manoj Naik | 7aaa0b3 | 2006-06-09 09:34:23 -0400 | [diff] [blame] | 3654 | if (res->nlocations < NFS4_FS_LOCATIONS_MAXENTRIES) |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 3655 | res->nlocations++; |
| 3656 | } |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3657 | if (res->nlocations != 0) |
| 3658 | status = NFS_ATTR_FATTR_V4_REFERRAL; |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 3659 | out: |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3660 | dprintk("%s: fs_locations done, error = %d\n", __func__, status); |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 3661 | return status; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3662 | out_overflow: |
| 3663 | print_overflow_msg(__func__, xdr); |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 3664 | out_eio: |
| 3665 | status = -EIO; |
| 3666 | goto out; |
| 3667 | } |
| 3668 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3669 | static int decode_attr_maxfilesize(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *res) |
| 3670 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3671 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3672 | int status = 0; |
| 3673 | |
| 3674 | *res = 0; |
| 3675 | if (unlikely(bitmap[0] & (FATTR4_WORD0_MAXFILESIZE - 1U))) |
| 3676 | return -EIO; |
| 3677 | if (likely(bitmap[0] & FATTR4_WORD0_MAXFILESIZE)) { |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3678 | p = xdr_inline_decode(xdr, 8); |
| 3679 | if (unlikely(!p)) |
| 3680 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3681 | xdr_decode_hyper(p, res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3682 | bitmap[0] &= ~FATTR4_WORD0_MAXFILESIZE; |
| 3683 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3684 | dprintk("%s: maxfilesize=%Lu\n", __func__, (unsigned long long)*res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3685 | return status; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3686 | out_overflow: |
| 3687 | print_overflow_msg(__func__, xdr); |
| 3688 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3689 | } |
| 3690 | |
| 3691 | static int decode_attr_maxlink(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t *maxlink) |
| 3692 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3693 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3694 | int status = 0; |
| 3695 | |
| 3696 | *maxlink = 1; |
| 3697 | if (unlikely(bitmap[0] & (FATTR4_WORD0_MAXLINK - 1U))) |
| 3698 | return -EIO; |
| 3699 | if (likely(bitmap[0] & FATTR4_WORD0_MAXLINK)) { |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3700 | p = xdr_inline_decode(xdr, 4); |
| 3701 | if (unlikely(!p)) |
| 3702 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3703 | *maxlink = be32_to_cpup(p); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3704 | bitmap[0] &= ~FATTR4_WORD0_MAXLINK; |
| 3705 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3706 | dprintk("%s: maxlink=%u\n", __func__, *maxlink); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3707 | return status; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3708 | out_overflow: |
| 3709 | print_overflow_msg(__func__, xdr); |
| 3710 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3711 | } |
| 3712 | |
| 3713 | static int decode_attr_maxname(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t *maxname) |
| 3714 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3715 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3716 | int status = 0; |
| 3717 | |
| 3718 | *maxname = 1024; |
| 3719 | if (unlikely(bitmap[0] & (FATTR4_WORD0_MAXNAME - 1U))) |
| 3720 | return -EIO; |
| 3721 | if (likely(bitmap[0] & FATTR4_WORD0_MAXNAME)) { |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3722 | p = xdr_inline_decode(xdr, 4); |
| 3723 | if (unlikely(!p)) |
| 3724 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3725 | *maxname = be32_to_cpup(p); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3726 | bitmap[0] &= ~FATTR4_WORD0_MAXNAME; |
| 3727 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3728 | dprintk("%s: maxname=%u\n", __func__, *maxname); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3729 | return status; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3730 | out_overflow: |
| 3731 | print_overflow_msg(__func__, xdr); |
| 3732 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3733 | } |
| 3734 | |
| 3735 | static int decode_attr_maxread(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t *res) |
| 3736 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3737 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3738 | int status = 0; |
| 3739 | |
| 3740 | *res = 1024; |
| 3741 | if (unlikely(bitmap[0] & (FATTR4_WORD0_MAXREAD - 1U))) |
| 3742 | return -EIO; |
| 3743 | if (likely(bitmap[0] & FATTR4_WORD0_MAXREAD)) { |
| 3744 | uint64_t maxread; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3745 | p = xdr_inline_decode(xdr, 8); |
| 3746 | if (unlikely(!p)) |
| 3747 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3748 | xdr_decode_hyper(p, &maxread); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3749 | if (maxread > 0x7FFFFFFF) |
| 3750 | maxread = 0x7FFFFFFF; |
| 3751 | *res = (uint32_t)maxread; |
| 3752 | bitmap[0] &= ~FATTR4_WORD0_MAXREAD; |
| 3753 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3754 | dprintk("%s: maxread=%lu\n", __func__, (unsigned long)*res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3755 | return status; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3756 | out_overflow: |
| 3757 | print_overflow_msg(__func__, xdr); |
| 3758 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3759 | } |
| 3760 | |
| 3761 | static int decode_attr_maxwrite(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t *res) |
| 3762 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3763 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3764 | int status = 0; |
| 3765 | |
| 3766 | *res = 1024; |
| 3767 | if (unlikely(bitmap[0] & (FATTR4_WORD0_MAXWRITE - 1U))) |
| 3768 | return -EIO; |
| 3769 | if (likely(bitmap[0] & FATTR4_WORD0_MAXWRITE)) { |
| 3770 | uint64_t maxwrite; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3771 | p = xdr_inline_decode(xdr, 8); |
| 3772 | if (unlikely(!p)) |
| 3773 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3774 | xdr_decode_hyper(p, &maxwrite); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3775 | if (maxwrite > 0x7FFFFFFF) |
| 3776 | maxwrite = 0x7FFFFFFF; |
| 3777 | *res = (uint32_t)maxwrite; |
| 3778 | bitmap[0] &= ~FATTR4_WORD0_MAXWRITE; |
| 3779 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3780 | dprintk("%s: maxwrite=%lu\n", __func__, (unsigned long)*res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3781 | return status; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3782 | out_overflow: |
| 3783 | print_overflow_msg(__func__, xdr); |
| 3784 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3785 | } |
| 3786 | |
Trond Myklebust | bca7947 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 3787 | 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] | 3788 | { |
Trond Myklebust | bca7947 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 3789 | uint32_t tmp; |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3790 | __be32 *p; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3791 | int ret = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3792 | |
| 3793 | *mode = 0; |
| 3794 | if (unlikely(bitmap[1] & (FATTR4_WORD1_MODE - 1U))) |
| 3795 | return -EIO; |
| 3796 | if (likely(bitmap[1] & FATTR4_WORD1_MODE)) { |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3797 | p = xdr_inline_decode(xdr, 4); |
| 3798 | if (unlikely(!p)) |
| 3799 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3800 | tmp = be32_to_cpup(p); |
Trond Myklebust | bca7947 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 3801 | *mode = tmp & ~S_IFMT; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3802 | bitmap[1] &= ~FATTR4_WORD1_MODE; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3803 | ret = NFS_ATTR_FATTR_MODE; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3804 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3805 | dprintk("%s: file mode=0%o\n", __func__, (unsigned int)*mode); |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3806 | return ret; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3807 | out_overflow: |
| 3808 | print_overflow_msg(__func__, xdr); |
| 3809 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3810 | } |
| 3811 | |
| 3812 | static int decode_attr_nlink(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t *nlink) |
| 3813 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3814 | __be32 *p; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3815 | int ret = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3816 | |
| 3817 | *nlink = 1; |
| 3818 | if (unlikely(bitmap[1] & (FATTR4_WORD1_NUMLINKS - 1U))) |
| 3819 | return -EIO; |
| 3820 | if (likely(bitmap[1] & FATTR4_WORD1_NUMLINKS)) { |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3821 | p = xdr_inline_decode(xdr, 4); |
| 3822 | if (unlikely(!p)) |
| 3823 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3824 | *nlink = be32_to_cpup(p); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3825 | bitmap[1] &= ~FATTR4_WORD1_NUMLINKS; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3826 | ret = NFS_ATTR_FATTR_NLINK; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3827 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3828 | dprintk("%s: nlink=%u\n", __func__, (unsigned int)*nlink); |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3829 | return ret; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3830 | out_overflow: |
| 3831 | print_overflow_msg(__func__, xdr); |
| 3832 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3833 | } |
| 3834 | |
Trond Myklebust | 80e52ac | 2009-08-09 15:06:19 -0400 | [diff] [blame] | 3835 | static int decode_attr_owner(struct xdr_stream *xdr, uint32_t *bitmap, |
Trond Myklebust | 6926afd | 2012-01-07 13:22:46 -0500 | [diff] [blame] | 3836 | const struct nfs_server *server, uint32_t *uid, |
| 3837 | struct nfs4_string *owner_name) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3838 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3839 | uint32_t len; |
| 3840 | __be32 *p; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3841 | int ret = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3842 | |
| 3843 | *uid = -2; |
| 3844 | if (unlikely(bitmap[1] & (FATTR4_WORD1_OWNER - 1U))) |
| 3845 | return -EIO; |
| 3846 | if (likely(bitmap[1] & FATTR4_WORD1_OWNER)) { |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3847 | p = xdr_inline_decode(xdr, 4); |
| 3848 | if (unlikely(!p)) |
| 3849 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3850 | len = be32_to_cpup(p); |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3851 | p = xdr_inline_decode(xdr, len); |
| 3852 | if (unlikely(!p)) |
| 3853 | goto out_overflow; |
Trond Myklebust | 6926afd | 2012-01-07 13:22:46 -0500 | [diff] [blame] | 3854 | if (owner_name != NULL) { |
| 3855 | owner_name->data = kmemdup(p, len, GFP_NOWAIT); |
| 3856 | if (owner_name->data != NULL) { |
| 3857 | owner_name->len = len; |
| 3858 | ret = NFS_ATTR_FATTR_OWNER_NAME; |
| 3859 | } |
Trond Myklebust | 80e52ac | 2009-08-09 15:06:19 -0400 | [diff] [blame] | 3860 | } else if (len < XDR_MAX_NETOBJ) { |
Trond Myklebust | e4fd72a | 2011-02-22 15:44:31 -0800 | [diff] [blame] | 3861 | if (nfs_map_name_to_uid(server, (char *)p, len, uid) == 0) |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3862 | ret = NFS_ATTR_FATTR_OWNER; |
| 3863 | else |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3864 | dprintk("%s: nfs_map_name_to_uid failed!\n", |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3865 | __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3866 | } else |
Chuck Lever | fe82a18 | 2007-09-11 18:01:10 -0400 | [diff] [blame] | 3867 | dprintk("%s: name too long (%u)!\n", |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3868 | __func__, len); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3869 | bitmap[1] &= ~FATTR4_WORD1_OWNER; |
| 3870 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3871 | dprintk("%s: uid=%d\n", __func__, (int)*uid); |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3872 | return ret; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3873 | out_overflow: |
| 3874 | print_overflow_msg(__func__, xdr); |
| 3875 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3876 | } |
| 3877 | |
Trond Myklebust | 80e52ac | 2009-08-09 15:06:19 -0400 | [diff] [blame] | 3878 | static int decode_attr_group(struct xdr_stream *xdr, uint32_t *bitmap, |
Trond Myklebust | 6926afd | 2012-01-07 13:22:46 -0500 | [diff] [blame] | 3879 | const struct nfs_server *server, uint32_t *gid, |
| 3880 | struct nfs4_string *group_name) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3881 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3882 | uint32_t len; |
| 3883 | __be32 *p; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3884 | int ret = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3885 | |
| 3886 | *gid = -2; |
| 3887 | if (unlikely(bitmap[1] & (FATTR4_WORD1_OWNER_GROUP - 1U))) |
| 3888 | return -EIO; |
| 3889 | if (likely(bitmap[1] & FATTR4_WORD1_OWNER_GROUP)) { |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3890 | p = xdr_inline_decode(xdr, 4); |
| 3891 | if (unlikely(!p)) |
| 3892 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3893 | len = be32_to_cpup(p); |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3894 | p = xdr_inline_decode(xdr, len); |
| 3895 | if (unlikely(!p)) |
| 3896 | goto out_overflow; |
Trond Myklebust | 6926afd | 2012-01-07 13:22:46 -0500 | [diff] [blame] | 3897 | if (group_name != NULL) { |
| 3898 | group_name->data = kmemdup(p, len, GFP_NOWAIT); |
| 3899 | if (group_name->data != NULL) { |
| 3900 | group_name->len = len; |
| 3901 | ret = NFS_ATTR_FATTR_GROUP_NAME; |
| 3902 | } |
Trond Myklebust | 80e52ac | 2009-08-09 15:06:19 -0400 | [diff] [blame] | 3903 | } else if (len < XDR_MAX_NETOBJ) { |
Trond Myklebust | e4fd72a | 2011-02-22 15:44:31 -0800 | [diff] [blame] | 3904 | if (nfs_map_group_to_gid(server, (char *)p, len, gid) == 0) |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3905 | ret = NFS_ATTR_FATTR_GROUP; |
| 3906 | else |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3907 | dprintk("%s: nfs_map_group_to_gid failed!\n", |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3908 | __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3909 | } else |
Chuck Lever | fe82a18 | 2007-09-11 18:01:10 -0400 | [diff] [blame] | 3910 | dprintk("%s: name too long (%u)!\n", |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3911 | __func__, len); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3912 | bitmap[1] &= ~FATTR4_WORD1_OWNER_GROUP; |
| 3913 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3914 | dprintk("%s: gid=%d\n", __func__, (int)*gid); |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3915 | return ret; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3916 | out_overflow: |
| 3917 | print_overflow_msg(__func__, xdr); |
| 3918 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3919 | } |
| 3920 | |
| 3921 | static int decode_attr_rdev(struct xdr_stream *xdr, uint32_t *bitmap, dev_t *rdev) |
| 3922 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3923 | uint32_t major = 0, minor = 0; |
| 3924 | __be32 *p; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3925 | int ret = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3926 | |
| 3927 | *rdev = MKDEV(0,0); |
| 3928 | if (unlikely(bitmap[1] & (FATTR4_WORD1_RAWDEV - 1U))) |
| 3929 | return -EIO; |
| 3930 | if (likely(bitmap[1] & FATTR4_WORD1_RAWDEV)) { |
| 3931 | dev_t tmp; |
| 3932 | |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3933 | p = xdr_inline_decode(xdr, 8); |
| 3934 | if (unlikely(!p)) |
| 3935 | goto out_overflow; |
Benny Halevy | 6f723f7 | 2009-08-14 17:19:37 +0300 | [diff] [blame] | 3936 | major = be32_to_cpup(p++); |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3937 | minor = be32_to_cpup(p); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3938 | tmp = MKDEV(major, minor); |
| 3939 | if (MAJOR(tmp) == major && MINOR(tmp) == minor) |
| 3940 | *rdev = tmp; |
| 3941 | bitmap[1] &= ~ FATTR4_WORD1_RAWDEV; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3942 | ret = NFS_ATTR_FATTR_RDEV; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3943 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3944 | dprintk("%s: rdev=(0x%x:0x%x)\n", __func__, major, minor); |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3945 | return ret; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3946 | out_overflow: |
| 3947 | print_overflow_msg(__func__, xdr); |
| 3948 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3949 | } |
| 3950 | |
| 3951 | static int decode_attr_space_avail(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *res) |
| 3952 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3953 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3954 | int status = 0; |
| 3955 | |
| 3956 | *res = 0; |
| 3957 | if (unlikely(bitmap[1] & (FATTR4_WORD1_SPACE_AVAIL - 1U))) |
| 3958 | return -EIO; |
| 3959 | if (likely(bitmap[1] & FATTR4_WORD1_SPACE_AVAIL)) { |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3960 | p = xdr_inline_decode(xdr, 8); |
| 3961 | if (unlikely(!p)) |
| 3962 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3963 | xdr_decode_hyper(p, res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3964 | bitmap[1] &= ~FATTR4_WORD1_SPACE_AVAIL; |
| 3965 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3966 | dprintk("%s: space avail=%Lu\n", __func__, (unsigned long long)*res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3967 | return status; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3968 | out_overflow: |
| 3969 | print_overflow_msg(__func__, xdr); |
| 3970 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3971 | } |
| 3972 | |
| 3973 | static int decode_attr_space_free(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *res) |
| 3974 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3975 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3976 | int status = 0; |
| 3977 | |
| 3978 | *res = 0; |
| 3979 | if (unlikely(bitmap[1] & (FATTR4_WORD1_SPACE_FREE - 1U))) |
| 3980 | return -EIO; |
| 3981 | if (likely(bitmap[1] & FATTR4_WORD1_SPACE_FREE)) { |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3982 | p = xdr_inline_decode(xdr, 8); |
| 3983 | if (unlikely(!p)) |
| 3984 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3985 | xdr_decode_hyper(p, res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3986 | bitmap[1] &= ~FATTR4_WORD1_SPACE_FREE; |
| 3987 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3988 | dprintk("%s: space free=%Lu\n", __func__, (unsigned long long)*res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3989 | return status; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3990 | out_overflow: |
| 3991 | print_overflow_msg(__func__, xdr); |
| 3992 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3993 | } |
| 3994 | |
| 3995 | static int decode_attr_space_total(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *res) |
| 3996 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3997 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3998 | int status = 0; |
| 3999 | |
| 4000 | *res = 0; |
| 4001 | if (unlikely(bitmap[1] & (FATTR4_WORD1_SPACE_TOTAL - 1U))) |
| 4002 | return -EIO; |
| 4003 | if (likely(bitmap[1] & FATTR4_WORD1_SPACE_TOTAL)) { |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 4004 | p = xdr_inline_decode(xdr, 8); |
| 4005 | if (unlikely(!p)) |
| 4006 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 4007 | xdr_decode_hyper(p, res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4008 | bitmap[1] &= ~FATTR4_WORD1_SPACE_TOTAL; |
| 4009 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 4010 | dprintk("%s: space total=%Lu\n", __func__, (unsigned long long)*res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4011 | return status; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 4012 | out_overflow: |
| 4013 | print_overflow_msg(__func__, xdr); |
| 4014 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4015 | } |
| 4016 | |
| 4017 | static int decode_attr_space_used(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *used) |
| 4018 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 4019 | __be32 *p; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 4020 | int ret = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4021 | |
| 4022 | *used = 0; |
| 4023 | if (unlikely(bitmap[1] & (FATTR4_WORD1_SPACE_USED - 1U))) |
| 4024 | return -EIO; |
| 4025 | if (likely(bitmap[1] & FATTR4_WORD1_SPACE_USED)) { |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 4026 | p = xdr_inline_decode(xdr, 8); |
| 4027 | if (unlikely(!p)) |
| 4028 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 4029 | xdr_decode_hyper(p, used); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4030 | bitmap[1] &= ~FATTR4_WORD1_SPACE_USED; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 4031 | ret = NFS_ATTR_FATTR_SPACE_USED; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4032 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 4033 | dprintk("%s: space used=%Lu\n", __func__, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4034 | (unsigned long long)*used); |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 4035 | return ret; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 4036 | out_overflow: |
| 4037 | print_overflow_msg(__func__, xdr); |
| 4038 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4039 | } |
| 4040 | |
| 4041 | static int decode_attr_time(struct xdr_stream *xdr, struct timespec *time) |
| 4042 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 4043 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4044 | uint64_t sec; |
| 4045 | uint32_t nsec; |
| 4046 | |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 4047 | p = xdr_inline_decode(xdr, 12); |
| 4048 | if (unlikely(!p)) |
| 4049 | goto out_overflow; |
Benny Halevy | 3ceb4db | 2009-08-14 17:19:41 +0300 | [diff] [blame] | 4050 | p = xdr_decode_hyper(p, &sec); |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 4051 | nsec = be32_to_cpup(p); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4052 | time->tv_sec = (time_t)sec; |
| 4053 | time->tv_nsec = (long)nsec; |
| 4054 | return 0; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 4055 | out_overflow: |
| 4056 | print_overflow_msg(__func__, xdr); |
| 4057 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4058 | } |
| 4059 | |
| 4060 | static int decode_attr_time_access(struct xdr_stream *xdr, uint32_t *bitmap, struct timespec *time) |
| 4061 | { |
| 4062 | int status = 0; |
| 4063 | |
| 4064 | time->tv_sec = 0; |
| 4065 | time->tv_nsec = 0; |
| 4066 | if (unlikely(bitmap[1] & (FATTR4_WORD1_TIME_ACCESS - 1U))) |
| 4067 | return -EIO; |
| 4068 | if (likely(bitmap[1] & FATTR4_WORD1_TIME_ACCESS)) { |
| 4069 | status = decode_attr_time(xdr, time); |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 4070 | if (status == 0) |
| 4071 | status = NFS_ATTR_FATTR_ATIME; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4072 | bitmap[1] &= ~FATTR4_WORD1_TIME_ACCESS; |
| 4073 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 4074 | dprintk("%s: atime=%ld\n", __func__, (long)time->tv_sec); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4075 | return status; |
| 4076 | } |
| 4077 | |
| 4078 | static int decode_attr_time_metadata(struct xdr_stream *xdr, uint32_t *bitmap, struct timespec *time) |
| 4079 | { |
| 4080 | int status = 0; |
| 4081 | |
| 4082 | time->tv_sec = 0; |
| 4083 | time->tv_nsec = 0; |
| 4084 | if (unlikely(bitmap[1] & (FATTR4_WORD1_TIME_METADATA - 1U))) |
| 4085 | return -EIO; |
| 4086 | if (likely(bitmap[1] & FATTR4_WORD1_TIME_METADATA)) { |
| 4087 | status = decode_attr_time(xdr, time); |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 4088 | if (status == 0) |
| 4089 | status = NFS_ATTR_FATTR_CTIME; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4090 | bitmap[1] &= ~FATTR4_WORD1_TIME_METADATA; |
| 4091 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 4092 | dprintk("%s: ctime=%ld\n", __func__, (long)time->tv_sec); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4093 | return status; |
| 4094 | } |
| 4095 | |
Ricardo Labiaga | 55b6e77 | 2010-10-12 16:30:06 -0700 | [diff] [blame] | 4096 | static int decode_attr_time_delta(struct xdr_stream *xdr, uint32_t *bitmap, |
| 4097 | struct timespec *time) |
| 4098 | { |
| 4099 | int status = 0; |
| 4100 | |
| 4101 | time->tv_sec = 0; |
| 4102 | time->tv_nsec = 0; |
| 4103 | if (unlikely(bitmap[1] & (FATTR4_WORD1_TIME_DELTA - 1U))) |
| 4104 | return -EIO; |
| 4105 | if (likely(bitmap[1] & FATTR4_WORD1_TIME_DELTA)) { |
| 4106 | status = decode_attr_time(xdr, time); |
| 4107 | bitmap[1] &= ~FATTR4_WORD1_TIME_DELTA; |
| 4108 | } |
| 4109 | dprintk("%s: time_delta=%ld %ld\n", __func__, (long)time->tv_sec, |
| 4110 | (long)time->tv_nsec); |
| 4111 | return status; |
| 4112 | } |
| 4113 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4114 | static int decode_attr_time_modify(struct xdr_stream *xdr, uint32_t *bitmap, struct timespec *time) |
| 4115 | { |
| 4116 | int status = 0; |
| 4117 | |
| 4118 | time->tv_sec = 0; |
| 4119 | time->tv_nsec = 0; |
| 4120 | if (unlikely(bitmap[1] & (FATTR4_WORD1_TIME_MODIFY - 1U))) |
| 4121 | return -EIO; |
| 4122 | if (likely(bitmap[1] & FATTR4_WORD1_TIME_MODIFY)) { |
| 4123 | status = decode_attr_time(xdr, time); |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 4124 | if (status == 0) |
| 4125 | status = NFS_ATTR_FATTR_MTIME; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4126 | bitmap[1] &= ~FATTR4_WORD1_TIME_MODIFY; |
| 4127 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 4128 | dprintk("%s: mtime=%ld\n", __func__, (long)time->tv_sec); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4129 | return status; |
| 4130 | } |
| 4131 | |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 4132 | 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] | 4133 | { |
| 4134 | unsigned int attrwords = XDR_QUADLEN(attrlen); |
| 4135 | unsigned int nwords = xdr->p - savep; |
| 4136 | |
| 4137 | if (unlikely(attrwords != nwords)) { |
Chuck Lever | fe82a18 | 2007-09-11 18:01:10 -0400 | [diff] [blame] | 4138 | dprintk("%s: server returned incorrect attribute length: " |
| 4139 | "%u %c %u\n", |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 4140 | __func__, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4141 | attrwords << 2, |
| 4142 | (attrwords < nwords) ? '<' : '>', |
| 4143 | nwords << 2); |
| 4144 | return -EIO; |
| 4145 | } |
| 4146 | return 0; |
| 4147 | } |
| 4148 | |
| 4149 | static int decode_change_info(struct xdr_stream *xdr, struct nfs4_change_info *cinfo) |
| 4150 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 4151 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4152 | |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 4153 | p = xdr_inline_decode(xdr, 20); |
| 4154 | if (unlikely(!p)) |
| 4155 | goto out_overflow; |
Benny Halevy | 6f723f7 | 2009-08-14 17:19:37 +0300 | [diff] [blame] | 4156 | cinfo->atomic = be32_to_cpup(p++); |
Benny Halevy | 3ceb4db | 2009-08-14 17:19:41 +0300 | [diff] [blame] | 4157 | p = xdr_decode_hyper(p, &cinfo->before); |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 4158 | xdr_decode_hyper(p, &cinfo->after); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4159 | return 0; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 4160 | out_overflow: |
| 4161 | print_overflow_msg(__func__, xdr); |
| 4162 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4163 | } |
| 4164 | |
| 4165 | static int decode_access(struct xdr_stream *xdr, struct nfs4_accessres *access) |
| 4166 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 4167 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4168 | uint32_t supp, acc; |
| 4169 | int status; |
| 4170 | |
| 4171 | status = decode_op_hdr(xdr, OP_ACCESS); |
| 4172 | if (status) |
| 4173 | return status; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 4174 | p = xdr_inline_decode(xdr, 8); |
| 4175 | if (unlikely(!p)) |
| 4176 | goto out_overflow; |
Benny Halevy | 6f723f7 | 2009-08-14 17:19:37 +0300 | [diff] [blame] | 4177 | supp = be32_to_cpup(p++); |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 4178 | acc = be32_to_cpup(p); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4179 | access->supported = supp; |
| 4180 | access->access = acc; |
| 4181 | return 0; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 4182 | out_overflow: |
| 4183 | print_overflow_msg(__func__, xdr); |
| 4184 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4185 | } |
| 4186 | |
Benny Halevy | 07d3043 | 2009-08-14 17:19:52 +0300 | [diff] [blame] | 4187 | 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] | 4188 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 4189 | __be32 *p; |
Benny Halevy | 07d3043 | 2009-08-14 17:19:52 +0300 | [diff] [blame] | 4190 | |
| 4191 | p = xdr_inline_decode(xdr, len); |
| 4192 | if (likely(p)) { |
| 4193 | memcpy(buf, p, len); |
| 4194 | return 0; |
| 4195 | } |
| 4196 | print_overflow_msg(__func__, xdr); |
| 4197 | return -EIO; |
| 4198 | } |
| 4199 | |
| 4200 | static int decode_stateid(struct xdr_stream *xdr, nfs4_stateid *stateid) |
| 4201 | { |
| 4202 | return decode_opaque_fixed(xdr, stateid->data, NFS4_STATEID_SIZE); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4203 | } |
| 4204 | |
| 4205 | static int decode_close(struct xdr_stream *xdr, struct nfs_closeres *res) |
| 4206 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4207 | int status; |
| 4208 | |
| 4209 | status = decode_op_hdr(xdr, OP_CLOSE); |
Trond Myklebust | c1d5193 | 2008-04-07 13:20:54 -0400 | [diff] [blame] | 4210 | if (status != -EIO) |
| 4211 | nfs_increment_open_seqid(status, res->seqid); |
Benny Halevy | 07d3043 | 2009-08-14 17:19:52 +0300 | [diff] [blame] | 4212 | if (!status) |
| 4213 | status = decode_stateid(xdr, &res->stateid); |
| 4214 | return status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4215 | } |
| 4216 | |
Benny Halevy | db942bb | 2009-08-14 17:19:56 +0300 | [diff] [blame] | 4217 | static int decode_verifier(struct xdr_stream *xdr, void *verifier) |
| 4218 | { |
| 4219 | return decode_opaque_fixed(xdr, verifier, 8); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4220 | } |
| 4221 | |
| 4222 | static int decode_commit(struct xdr_stream *xdr, struct nfs_writeres *res) |
| 4223 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4224 | int status; |
| 4225 | |
| 4226 | status = decode_op_hdr(xdr, OP_COMMIT); |
Benny Halevy | db942bb | 2009-08-14 17:19:56 +0300 | [diff] [blame] | 4227 | if (!status) |
| 4228 | status = decode_verifier(xdr, res->verf->verifier); |
| 4229 | return status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4230 | } |
| 4231 | |
| 4232 | static int decode_create(struct xdr_stream *xdr, struct nfs4_change_info *cinfo) |
| 4233 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 4234 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4235 | uint32_t bmlen; |
| 4236 | int status; |
| 4237 | |
| 4238 | status = decode_op_hdr(xdr, OP_CREATE); |
| 4239 | if (status) |
| 4240 | return status; |
| 4241 | if ((status = decode_change_info(xdr, cinfo))) |
| 4242 | return status; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 4243 | p = xdr_inline_decode(xdr, 4); |
| 4244 | if (unlikely(!p)) |
| 4245 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 4246 | bmlen = be32_to_cpup(p); |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 4247 | p = xdr_inline_decode(xdr, bmlen << 2); |
| 4248 | if (likely(p)) |
| 4249 | return 0; |
| 4250 | out_overflow: |
| 4251 | print_overflow_msg(__func__, xdr); |
| 4252 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4253 | } |
| 4254 | |
| 4255 | static int decode_server_caps(struct xdr_stream *xdr, struct nfs4_server_caps_res *res) |
| 4256 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 4257 | __be32 *savep; |
Fred Isaman | dae100c | 2011-07-30 20:52:37 -0400 | [diff] [blame] | 4258 | uint32_t attrlen, bitmap[3] = {0}; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4259 | int status; |
| 4260 | |
| 4261 | if ((status = decode_op_hdr(xdr, OP_GETATTR)) != 0) |
| 4262 | goto xdr_error; |
| 4263 | if ((status = decode_attr_bitmap(xdr, bitmap)) != 0) |
| 4264 | goto xdr_error; |
| 4265 | if ((status = decode_attr_length(xdr, &attrlen, &savep)) != 0) |
| 4266 | goto xdr_error; |
| 4267 | if ((status = decode_attr_supported(xdr, bitmap, res->attr_bitmask)) != 0) |
| 4268 | goto xdr_error; |
| 4269 | if ((status = decode_attr_link_support(xdr, bitmap, &res->has_links)) != 0) |
| 4270 | goto xdr_error; |
| 4271 | if ((status = decode_attr_symlink_support(xdr, bitmap, &res->has_symlinks)) != 0) |
| 4272 | goto xdr_error; |
| 4273 | if ((status = decode_attr_aclsupport(xdr, bitmap, &res->acl_bitmask)) != 0) |
| 4274 | goto xdr_error; |
| 4275 | status = verify_attr_len(xdr, savep, attrlen); |
| 4276 | xdr_error: |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 4277 | dprintk("%s: xdr returned %d!\n", __func__, -status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4278 | return status; |
| 4279 | } |
Andy Adamson | 6c0195a | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 4280 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4281 | static int decode_statfs(struct xdr_stream *xdr, struct nfs_fsstat *fsstat) |
| 4282 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 4283 | __be32 *savep; |
Fred Isaman | dae100c | 2011-07-30 20:52:37 -0400 | [diff] [blame] | 4284 | uint32_t attrlen, bitmap[3] = {0}; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4285 | int status; |
Andy Adamson | 6c0195a | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 4286 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4287 | if ((status = decode_op_hdr(xdr, OP_GETATTR)) != 0) |
| 4288 | goto xdr_error; |
| 4289 | if ((status = decode_attr_bitmap(xdr, bitmap)) != 0) |
| 4290 | goto xdr_error; |
| 4291 | if ((status = decode_attr_length(xdr, &attrlen, &savep)) != 0) |
| 4292 | goto xdr_error; |
| 4293 | |
| 4294 | if ((status = decode_attr_files_avail(xdr, bitmap, &fsstat->afiles)) != 0) |
| 4295 | goto xdr_error; |
| 4296 | if ((status = decode_attr_files_free(xdr, bitmap, &fsstat->ffiles)) != 0) |
| 4297 | goto xdr_error; |
| 4298 | if ((status = decode_attr_files_total(xdr, bitmap, &fsstat->tfiles)) != 0) |
| 4299 | goto xdr_error; |
| 4300 | if ((status = decode_attr_space_avail(xdr, bitmap, &fsstat->abytes)) != 0) |
| 4301 | goto xdr_error; |
| 4302 | if ((status = decode_attr_space_free(xdr, bitmap, &fsstat->fbytes)) != 0) |
| 4303 | goto xdr_error; |
| 4304 | if ((status = decode_attr_space_total(xdr, bitmap, &fsstat->tbytes)) != 0) |
| 4305 | goto xdr_error; |
| 4306 | |
| 4307 | status = verify_attr_len(xdr, savep, attrlen); |
| 4308 | xdr_error: |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 4309 | dprintk("%s: xdr returned %d!\n", __func__, -status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4310 | return status; |
| 4311 | } |
| 4312 | |
| 4313 | static int decode_pathconf(struct xdr_stream *xdr, struct nfs_pathconf *pathconf) |
| 4314 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 4315 | __be32 *savep; |
Fred Isaman | dae100c | 2011-07-30 20:52:37 -0400 | [diff] [blame] | 4316 | uint32_t attrlen, bitmap[3] = {0}; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4317 | int status; |
Andy Adamson | 6c0195a | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 4318 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4319 | if ((status = decode_op_hdr(xdr, OP_GETATTR)) != 0) |
| 4320 | goto xdr_error; |
| 4321 | if ((status = decode_attr_bitmap(xdr, bitmap)) != 0) |
| 4322 | goto xdr_error; |
| 4323 | if ((status = decode_attr_length(xdr, &attrlen, &savep)) != 0) |
| 4324 | goto xdr_error; |
| 4325 | |
| 4326 | if ((status = decode_attr_maxlink(xdr, bitmap, &pathconf->max_link)) != 0) |
| 4327 | goto xdr_error; |
| 4328 | if ((status = decode_attr_maxname(xdr, bitmap, &pathconf->max_namelen)) != 0) |
| 4329 | goto xdr_error; |
| 4330 | |
| 4331 | status = verify_attr_len(xdr, savep, attrlen); |
| 4332 | xdr_error: |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 4333 | dprintk("%s: xdr returned %d!\n", __func__, -status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4334 | return status; |
| 4335 | } |
| 4336 | |
Bryan Schumaker | ae42c70 | 2010-10-21 16:33:17 -0400 | [diff] [blame] | 4337 | static int decode_getfattr_attrs(struct xdr_stream *xdr, uint32_t *bitmap, |
| 4338 | struct nfs_fattr *fattr, struct nfs_fh *fh, |
Trond Myklebust | 8b7e3f4 | 2012-01-30 15:43:56 -0500 | [diff] [blame] | 4339 | struct nfs4_fs_locations *fs_loc, |
Trond Myklebust | 6926afd | 2012-01-07 13:22:46 -0500 | [diff] [blame] | 4340 | const struct nfs_server *server) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4341 | { |
Trond Myklebust | bca7947 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 4342 | int status; |
| 4343 | umode_t fmode = 0; |
Bryan Schumaker | ae42c70 | 2010-10-21 16:33:17 -0400 | [diff] [blame] | 4344 | uint32_t type; |
Trond Myklebust | ee7b75f | 2011-06-16 13:15:41 -0400 | [diff] [blame] | 4345 | int32_t err; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4346 | |
Trond Myklebust | f26c7a7 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 4347 | status = decode_attr_type(xdr, bitmap, &type); |
| 4348 | if (status < 0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4349 | goto xdr_error; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 4350 | fattr->mode = 0; |
| 4351 | if (status != 0) { |
| 4352 | fattr->mode |= nfs_type2fmt[type]; |
| 4353 | fattr->valid |= status; |
| 4354 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4355 | |
Trond Myklebust | f26c7a7 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 4356 | status = decode_attr_change(xdr, bitmap, &fattr->change_attr); |
| 4357 | if (status < 0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4358 | goto xdr_error; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 4359 | fattr->valid |= status; |
Trond Myklebust | f26c7a7 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 4360 | |
| 4361 | status = decode_attr_size(xdr, bitmap, &fattr->size); |
| 4362 | if (status < 0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4363 | goto xdr_error; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 4364 | fattr->valid |= status; |
Trond Myklebust | f26c7a7 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 4365 | |
| 4366 | status = decode_attr_fsid(xdr, bitmap, &fattr->fsid); |
| 4367 | if (status < 0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4368 | goto xdr_error; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 4369 | fattr->valid |= status; |
Trond Myklebust | f26c7a7 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 4370 | |
Trond Myklebust | ee7b75f | 2011-06-16 13:15:41 -0400 | [diff] [blame] | 4371 | err = 0; |
| 4372 | status = decode_attr_error(xdr, bitmap, &err); |
Bryan Schumaker | ae42c70 | 2010-10-21 16:33:17 -0400 | [diff] [blame] | 4373 | if (status < 0) |
| 4374 | goto xdr_error; |
Trond Myklebust | ee7b75f | 2011-06-16 13:15:41 -0400 | [diff] [blame] | 4375 | if (err == -NFS4ERR_WRONGSEC) |
| 4376 | nfs_fixup_secinfo_attributes(fattr, fh); |
Bryan Schumaker | ae42c70 | 2010-10-21 16:33:17 -0400 | [diff] [blame] | 4377 | |
| 4378 | status = decode_attr_filehandle(xdr, bitmap, fh); |
| 4379 | if (status < 0) |
| 4380 | goto xdr_error; |
| 4381 | |
Trond Myklebust | f26c7a7 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 4382 | status = decode_attr_fileid(xdr, bitmap, &fattr->fileid); |
| 4383 | if (status < 0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4384 | goto xdr_error; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 4385 | fattr->valid |= status; |
Trond Myklebust | f26c7a7 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 4386 | |
Trond Myklebust | 8b7e3f4 | 2012-01-30 15:43:56 -0500 | [diff] [blame] | 4387 | status = decode_attr_fs_locations(xdr, bitmap, fs_loc); |
Trond Myklebust | f26c7a7 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 4388 | if (status < 0) |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 4389 | goto xdr_error; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 4390 | fattr->valid |= status; |
Trond Myklebust | f26c7a7 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 4391 | |
| 4392 | status = decode_attr_mode(xdr, bitmap, &fmode); |
| 4393 | if (status < 0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4394 | goto xdr_error; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 4395 | if (status != 0) { |
| 4396 | fattr->mode |= fmode; |
| 4397 | fattr->valid |= status; |
| 4398 | } |
Trond Myklebust | f26c7a7 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 4399 | |
| 4400 | status = decode_attr_nlink(xdr, bitmap, &fattr->nlink); |
| 4401 | if (status < 0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4402 | goto xdr_error; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 4403 | fattr->valid |= status; |
Trond Myklebust | f26c7a7 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 4404 | |
Trond Myklebust | 6926afd | 2012-01-07 13:22:46 -0500 | [diff] [blame] | 4405 | status = decode_attr_owner(xdr, bitmap, server, &fattr->uid, fattr->owner_name); |
Trond Myklebust | f26c7a7 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 4406 | if (status < 0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4407 | goto xdr_error; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 4408 | fattr->valid |= status; |
Trond Myklebust | f26c7a7 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 4409 | |
Trond Myklebust | 6926afd | 2012-01-07 13:22:46 -0500 | [diff] [blame] | 4410 | status = decode_attr_group(xdr, bitmap, server, &fattr->gid, fattr->group_name); |
Trond Myklebust | f26c7a7 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 4411 | if (status < 0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4412 | goto xdr_error; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 4413 | fattr->valid |= status; |
Trond Myklebust | f26c7a7 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 4414 | |
| 4415 | status = decode_attr_rdev(xdr, bitmap, &fattr->rdev); |
| 4416 | if (status < 0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4417 | goto xdr_error; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 4418 | fattr->valid |= status; |
Trond Myklebust | f26c7a7 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 4419 | |
| 4420 | status = decode_attr_space_used(xdr, bitmap, &fattr->du.nfs3.used); |
| 4421 | if (status < 0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4422 | goto xdr_error; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 4423 | fattr->valid |= status; |
Trond Myklebust | f26c7a7 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 4424 | |
| 4425 | status = decode_attr_time_access(xdr, bitmap, &fattr->atime); |
| 4426 | if (status < 0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4427 | goto xdr_error; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 4428 | fattr->valid |= status; |
Trond Myklebust | f26c7a7 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 4429 | |
| 4430 | status = decode_attr_time_metadata(xdr, bitmap, &fattr->ctime); |
| 4431 | if (status < 0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4432 | goto xdr_error; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 4433 | fattr->valid |= status; |
Trond Myklebust | f26c7a7 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 4434 | |
| 4435 | status = decode_attr_time_modify(xdr, bitmap, &fattr->mtime); |
| 4436 | if (status < 0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4437 | goto xdr_error; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 4438 | fattr->valid |= status; |
Trond Myklebust | f26c7a7 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 4439 | |
Trond Myklebust | 28331a4 | 2011-04-27 13:47:52 -0400 | [diff] [blame] | 4440 | status = decode_attr_mounted_on_fileid(xdr, bitmap, &fattr->mounted_on_fileid); |
Trond Myklebust | f26c7a7 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 4441 | if (status < 0) |
Manoj Naik | 99baf62 | 2006-06-09 09:34:24 -0400 | [diff] [blame] | 4442 | goto xdr_error; |
Trond Myklebust | 28331a4 | 2011-04-27 13:47:52 -0400 | [diff] [blame] | 4443 | fattr->valid |= status; |
Trond Myklebust | f26c7a7 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 4444 | |
Bryan Schumaker | ae42c70 | 2010-10-21 16:33:17 -0400 | [diff] [blame] | 4445 | xdr_error: |
| 4446 | dprintk("%s: xdr returned %d\n", __func__, -status); |
| 4447 | return status; |
| 4448 | } |
| 4449 | |
| 4450 | 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] | 4451 | struct nfs_fh *fh, struct nfs4_fs_locations *fs_loc, |
| 4452 | const struct nfs_server *server) |
Bryan Schumaker | ae42c70 | 2010-10-21 16:33:17 -0400 | [diff] [blame] | 4453 | { |
| 4454 | __be32 *savep; |
| 4455 | uint32_t attrlen, |
Fred Isaman | dae100c | 2011-07-30 20:52:37 -0400 | [diff] [blame] | 4456 | bitmap[3] = {0}; |
Bryan Schumaker | ae42c70 | 2010-10-21 16:33:17 -0400 | [diff] [blame] | 4457 | int status; |
| 4458 | |
| 4459 | status = decode_op_hdr(xdr, OP_GETATTR); |
| 4460 | if (status < 0) |
| 4461 | goto xdr_error; |
| 4462 | |
| 4463 | status = decode_attr_bitmap(xdr, bitmap); |
| 4464 | if (status < 0) |
| 4465 | goto xdr_error; |
| 4466 | |
| 4467 | status = decode_attr_length(xdr, &attrlen, &savep); |
| 4468 | if (status < 0) |
| 4469 | goto xdr_error; |
| 4470 | |
Trond Myklebust | 8b7e3f4 | 2012-01-30 15:43:56 -0500 | [diff] [blame] | 4471 | status = decode_getfattr_attrs(xdr, bitmap, fattr, fh, fs_loc, server); |
Bryan Schumaker | ae42c70 | 2010-10-21 16:33:17 -0400 | [diff] [blame] | 4472 | if (status < 0) |
| 4473 | goto xdr_error; |
| 4474 | |
Trond Myklebust | f26c7a7 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 4475 | status = verify_attr_len(xdr, savep, attrlen); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4476 | xdr_error: |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 4477 | dprintk("%s: xdr returned %d\n", __func__, -status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4478 | return status; |
| 4479 | } |
| 4480 | |
Bryan Schumaker | ae42c70 | 2010-10-21 16:33:17 -0400 | [diff] [blame] | 4481 | static int decode_getfattr(struct xdr_stream *xdr, struct nfs_fattr *fattr, |
Trond Myklebust | 6926afd | 2012-01-07 13:22:46 -0500 | [diff] [blame] | 4482 | const struct nfs_server *server) |
Bryan Schumaker | ae42c70 | 2010-10-21 16:33:17 -0400 | [diff] [blame] | 4483 | { |
Trond Myklebust | 8b7e3f4 | 2012-01-30 15:43:56 -0500 | [diff] [blame] | 4484 | return decode_getfattr_generic(xdr, fattr, NULL, NULL, server); |
Bryan Schumaker | ae42c70 | 2010-10-21 16:33:17 -0400 | [diff] [blame] | 4485 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4486 | |
Andy Adamson | 504913f | 2010-10-20 00:17:57 -0400 | [diff] [blame] | 4487 | /* |
| 4488 | * Decode potentially multiple layout types. Currently we only support |
| 4489 | * one layout driver per file system. |
| 4490 | */ |
| 4491 | static int decode_first_pnfs_layout_type(struct xdr_stream *xdr, |
| 4492 | uint32_t *layouttype) |
| 4493 | { |
| 4494 | uint32_t *p; |
| 4495 | int num; |
| 4496 | |
| 4497 | p = xdr_inline_decode(xdr, 4); |
| 4498 | if (unlikely(!p)) |
| 4499 | goto out_overflow; |
| 4500 | num = be32_to_cpup(p); |
| 4501 | |
| 4502 | /* pNFS is not supported by the underlying file system */ |
| 4503 | if (num == 0) { |
| 4504 | *layouttype = 0; |
| 4505 | return 0; |
| 4506 | } |
| 4507 | if (num > 1) |
Weston Andros Adamson | a030889 | 2012-01-26 13:32:23 -0500 | [diff] [blame] | 4508 | printk(KERN_INFO "NFS: %s: Warning: Multiple pNFS layout " |
| 4509 | "drivers per filesystem not supported\n", __func__); |
Andy Adamson | 504913f | 2010-10-20 00:17:57 -0400 | [diff] [blame] | 4510 | |
| 4511 | /* Decode and set first layout type, move xdr->p past unused types */ |
| 4512 | p = xdr_inline_decode(xdr, num * 4); |
| 4513 | if (unlikely(!p)) |
| 4514 | goto out_overflow; |
| 4515 | *layouttype = be32_to_cpup(p); |
| 4516 | return 0; |
| 4517 | out_overflow: |
| 4518 | print_overflow_msg(__func__, xdr); |
| 4519 | return -EIO; |
| 4520 | } |
| 4521 | |
| 4522 | /* |
| 4523 | * The type of file system exported. |
| 4524 | * Note we must ensure that layouttype is set in any non-error case. |
| 4525 | */ |
| 4526 | static int decode_attr_pnfstype(struct xdr_stream *xdr, uint32_t *bitmap, |
| 4527 | uint32_t *layouttype) |
| 4528 | { |
| 4529 | int status = 0; |
| 4530 | |
| 4531 | dprintk("%s: bitmap is %x\n", __func__, bitmap[1]); |
| 4532 | if (unlikely(bitmap[1] & (FATTR4_WORD1_FS_LAYOUT_TYPES - 1U))) |
| 4533 | return -EIO; |
| 4534 | if (bitmap[1] & FATTR4_WORD1_FS_LAYOUT_TYPES) { |
| 4535 | status = decode_first_pnfs_layout_type(xdr, layouttype); |
| 4536 | bitmap[1] &= ~FATTR4_WORD1_FS_LAYOUT_TYPES; |
| 4537 | } else |
| 4538 | *layouttype = 0; |
| 4539 | return status; |
| 4540 | } |
| 4541 | |
Fred Isaman | dae100c | 2011-07-30 20:52:37 -0400 | [diff] [blame] | 4542 | /* |
| 4543 | * The prefered block size for layout directed io |
| 4544 | */ |
| 4545 | static int decode_attr_layout_blksize(struct xdr_stream *xdr, uint32_t *bitmap, |
| 4546 | uint32_t *res) |
| 4547 | { |
| 4548 | __be32 *p; |
| 4549 | |
| 4550 | dprintk("%s: bitmap is %x\n", __func__, bitmap[2]); |
| 4551 | *res = 0; |
| 4552 | if (bitmap[2] & FATTR4_WORD2_LAYOUT_BLKSIZE) { |
| 4553 | p = xdr_inline_decode(xdr, 4); |
| 4554 | if (unlikely(!p)) { |
| 4555 | print_overflow_msg(__func__, xdr); |
| 4556 | return -EIO; |
| 4557 | } |
| 4558 | *res = be32_to_cpup(p); |
| 4559 | bitmap[2] &= ~FATTR4_WORD2_LAYOUT_BLKSIZE; |
| 4560 | } |
| 4561 | return 0; |
| 4562 | } |
| 4563 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4564 | static int decode_fsinfo(struct xdr_stream *xdr, struct nfs_fsinfo *fsinfo) |
| 4565 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 4566 | __be32 *savep; |
Fred Isaman | dae100c | 2011-07-30 20:52:37 -0400 | [diff] [blame] | 4567 | uint32_t attrlen, bitmap[3]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4568 | int status; |
| 4569 | |
| 4570 | if ((status = decode_op_hdr(xdr, OP_GETATTR)) != 0) |
| 4571 | goto xdr_error; |
| 4572 | if ((status = decode_attr_bitmap(xdr, bitmap)) != 0) |
| 4573 | goto xdr_error; |
| 4574 | if ((status = decode_attr_length(xdr, &attrlen, &savep)) != 0) |
| 4575 | goto xdr_error; |
| 4576 | |
| 4577 | fsinfo->rtmult = fsinfo->wtmult = 512; /* ??? */ |
| 4578 | |
| 4579 | if ((status = decode_attr_lease_time(xdr, bitmap, &fsinfo->lease_time)) != 0) |
| 4580 | goto xdr_error; |
| 4581 | if ((status = decode_attr_maxfilesize(xdr, bitmap, &fsinfo->maxfilesize)) != 0) |
| 4582 | goto xdr_error; |
| 4583 | if ((status = decode_attr_maxread(xdr, bitmap, &fsinfo->rtmax)) != 0) |
| 4584 | goto xdr_error; |
| 4585 | fsinfo->rtpref = fsinfo->dtpref = fsinfo->rtmax; |
| 4586 | if ((status = decode_attr_maxwrite(xdr, bitmap, &fsinfo->wtmax)) != 0) |
| 4587 | goto xdr_error; |
| 4588 | fsinfo->wtpref = fsinfo->wtmax; |
Ricardo Labiaga | 55b6e77 | 2010-10-12 16:30:06 -0700 | [diff] [blame] | 4589 | status = decode_attr_time_delta(xdr, bitmap, &fsinfo->time_delta); |
| 4590 | if (status != 0) |
| 4591 | goto xdr_error; |
Andy Adamson | 504913f | 2010-10-20 00:17:57 -0400 | [diff] [blame] | 4592 | status = decode_attr_pnfstype(xdr, bitmap, &fsinfo->layouttype); |
| 4593 | if (status != 0) |
| 4594 | goto xdr_error; |
Fred Isaman | dae100c | 2011-07-30 20:52:37 -0400 | [diff] [blame] | 4595 | status = decode_attr_layout_blksize(xdr, bitmap, &fsinfo->blksize); |
| 4596 | if (status) |
| 4597 | goto xdr_error; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4598 | |
| 4599 | status = verify_attr_len(xdr, savep, attrlen); |
| 4600 | xdr_error: |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 4601 | dprintk("%s: xdr returned %d!\n", __func__, -status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4602 | return status; |
| 4603 | } |
| 4604 | |
| 4605 | static int decode_getfh(struct xdr_stream *xdr, struct nfs_fh *fh) |
| 4606 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 4607 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4608 | uint32_t len; |
| 4609 | int status; |
| 4610 | |
Trond Myklebust | 9936781 | 2007-07-17 21:52:41 -0400 | [diff] [blame] | 4611 | /* Zero handle first to allow comparisons */ |
| 4612 | memset(fh, 0, sizeof(*fh)); |
| 4613 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4614 | status = decode_op_hdr(xdr, OP_GETFH); |
| 4615 | if (status) |
| 4616 | return status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4617 | |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 4618 | p = xdr_inline_decode(xdr, 4); |
| 4619 | if (unlikely(!p)) |
| 4620 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 4621 | len = be32_to_cpup(p); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4622 | if (len > NFS4_FHSIZE) |
| 4623 | return -EIO; |
| 4624 | fh->size = len; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 4625 | p = xdr_inline_decode(xdr, len); |
| 4626 | if (unlikely(!p)) |
| 4627 | goto out_overflow; |
Benny Halevy | 99398d0 | 2009-08-14 17:20:05 +0300 | [diff] [blame] | 4628 | memcpy(fh->data, p, len); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4629 | return 0; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 4630 | out_overflow: |
| 4631 | print_overflow_msg(__func__, xdr); |
| 4632 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4633 | } |
| 4634 | |
| 4635 | static int decode_link(struct xdr_stream *xdr, struct nfs4_change_info *cinfo) |
| 4636 | { |
| 4637 | int status; |
Andy Adamson | 6c0195a | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 4638 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4639 | status = decode_op_hdr(xdr, OP_LINK); |
| 4640 | if (status) |
| 4641 | return status; |
| 4642 | return decode_change_info(xdr, cinfo); |
| 4643 | } |
| 4644 | |
| 4645 | /* |
| 4646 | * We create the owner, so we know a proper owner.id length is 4. |
| 4647 | */ |
Trond Myklebust | 911d1aa | 2006-01-03 09:55:16 +0100 | [diff] [blame] | 4648 | 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] | 4649 | { |
Trond Myklebust | 911d1aa | 2006-01-03 09:55:16 +0100 | [diff] [blame] | 4650 | uint64_t offset, length, clientid; |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 4651 | __be32 *p; |
Trond Myklebust | 911d1aa | 2006-01-03 09:55:16 +0100 | [diff] [blame] | 4652 | uint32_t namelen, type; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4653 | |
Bryan Schumaker | babddc7 | 2010-10-20 15:44:29 -0400 | [diff] [blame] | 4654 | p = xdr_inline_decode(xdr, 32); /* read 32 bytes */ |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 4655 | if (unlikely(!p)) |
| 4656 | goto out_overflow; |
Bryan Schumaker | babddc7 | 2010-10-20 15:44:29 -0400 | [diff] [blame] | 4657 | p = xdr_decode_hyper(p, &offset); /* read 2 8-byte long words */ |
Benny Halevy | 3ceb4db | 2009-08-14 17:19:41 +0300 | [diff] [blame] | 4658 | p = xdr_decode_hyper(p, &length); |
Bryan Schumaker | babddc7 | 2010-10-20 15:44:29 -0400 | [diff] [blame] | 4659 | type = be32_to_cpup(p++); /* 4 byte read */ |
| 4660 | if (fl != NULL) { /* manipulate file lock */ |
Trond Myklebust | 911d1aa | 2006-01-03 09:55:16 +0100 | [diff] [blame] | 4661 | fl->fl_start = (loff_t)offset; |
| 4662 | fl->fl_end = fl->fl_start + (loff_t)length - 1; |
| 4663 | if (length == ~(uint64_t)0) |
| 4664 | fl->fl_end = OFFSET_MAX; |
| 4665 | fl->fl_type = F_WRLCK; |
| 4666 | if (type & 1) |
| 4667 | fl->fl_type = F_RDLCK; |
| 4668 | fl->fl_pid = 0; |
| 4669 | } |
Bryan Schumaker | babddc7 | 2010-10-20 15:44:29 -0400 | [diff] [blame] | 4670 | p = xdr_decode_hyper(p, &clientid); /* read 8 bytes */ |
| 4671 | namelen = be32_to_cpup(p); /* read 4 bytes */ /* have read all 32 bytes now */ |
| 4672 | p = xdr_inline_decode(xdr, namelen); /* variable size field */ |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 4673 | if (likely(p)) |
| 4674 | return -NFS4ERR_DENIED; |
| 4675 | out_overflow: |
| 4676 | print_overflow_msg(__func__, xdr); |
| 4677 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4678 | } |
| 4679 | |
Trond Myklebust | 911d1aa | 2006-01-03 09:55:16 +0100 | [diff] [blame] | 4680 | 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] | 4681 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4682 | int status; |
| 4683 | |
| 4684 | status = decode_op_hdr(xdr, OP_LOCK); |
Trond Myklebust | c1d5193 | 2008-04-07 13:20:54 -0400 | [diff] [blame] | 4685 | if (status == -EIO) |
| 4686 | goto out; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4687 | if (status == 0) { |
Benny Halevy | 07d3043 | 2009-08-14 17:19:52 +0300 | [diff] [blame] | 4688 | status = decode_stateid(xdr, &res->stateid); |
| 4689 | if (unlikely(status)) |
| 4690 | goto out; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4691 | } else if (status == -NFS4ERR_DENIED) |
Trond Myklebust | c1d5193 | 2008-04-07 13:20:54 -0400 | [diff] [blame] | 4692 | status = decode_lock_denied(xdr, NULL); |
| 4693 | if (res->open_seqid != NULL) |
| 4694 | nfs_increment_open_seqid(status, res->open_seqid); |
| 4695 | nfs_increment_lock_seqid(status, res->lock_seqid); |
| 4696 | out: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4697 | return status; |
| 4698 | } |
| 4699 | |
Trond Myklebust | 911d1aa | 2006-01-03 09:55:16 +0100 | [diff] [blame] | 4700 | 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] | 4701 | { |
| 4702 | int status; |
| 4703 | status = decode_op_hdr(xdr, OP_LOCKT); |
| 4704 | if (status == -NFS4ERR_DENIED) |
Trond Myklebust | 911d1aa | 2006-01-03 09:55:16 +0100 | [diff] [blame] | 4705 | return decode_lock_denied(xdr, res->denied); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4706 | return status; |
| 4707 | } |
| 4708 | |
Trond Myklebust | 911d1aa | 2006-01-03 09:55:16 +0100 | [diff] [blame] | 4709 | 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] | 4710 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4711 | int status; |
| 4712 | |
| 4713 | status = decode_op_hdr(xdr, OP_LOCKU); |
Trond Myklebust | c1d5193 | 2008-04-07 13:20:54 -0400 | [diff] [blame] | 4714 | if (status != -EIO) |
| 4715 | nfs_increment_lock_seqid(status, res->seqid); |
Benny Halevy | 07d3043 | 2009-08-14 17:19:52 +0300 | [diff] [blame] | 4716 | if (status == 0) |
| 4717 | status = decode_stateid(xdr, &res->stateid); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4718 | return status; |
| 4719 | } |
| 4720 | |
Trond Myklebust | d3c7b7c | 2010-07-01 12:49:01 -0400 | [diff] [blame] | 4721 | static int decode_release_lockowner(struct xdr_stream *xdr) |
| 4722 | { |
| 4723 | return decode_op_hdr(xdr, OP_RELEASE_LOCKOWNER); |
| 4724 | } |
| 4725 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4726 | static int decode_lookup(struct xdr_stream *xdr) |
| 4727 | { |
| 4728 | return decode_op_hdr(xdr, OP_LOOKUP); |
| 4729 | } |
| 4730 | |
| 4731 | /* This is too sick! */ |
| 4732 | static int decode_space_limit(struct xdr_stream *xdr, u64 *maxsize) |
| 4733 | { |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 4734 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4735 | uint32_t limit_type, nblocks, blocksize; |
| 4736 | |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 4737 | p = xdr_inline_decode(xdr, 12); |
| 4738 | if (unlikely(!p)) |
| 4739 | goto out_overflow; |
Benny Halevy | 6f723f7 | 2009-08-14 17:19:37 +0300 | [diff] [blame] | 4740 | limit_type = be32_to_cpup(p++); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4741 | switch (limit_type) { |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 4742 | case 1: |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 4743 | xdr_decode_hyper(p, maxsize); |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 4744 | break; |
| 4745 | case 2: |
Benny Halevy | 6f723f7 | 2009-08-14 17:19:37 +0300 | [diff] [blame] | 4746 | nblocks = be32_to_cpup(p++); |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 4747 | blocksize = be32_to_cpup(p); |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 4748 | *maxsize = (uint64_t)nblocks * (uint64_t)blocksize; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4749 | } |
| 4750 | return 0; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 4751 | out_overflow: |
| 4752 | print_overflow_msg(__func__, xdr); |
| 4753 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4754 | } |
| 4755 | |
| 4756 | static int decode_delegation(struct xdr_stream *xdr, struct nfs_openres *res) |
| 4757 | { |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 4758 | __be32 *p; |
| 4759 | uint32_t delegation_type; |
Benny Halevy | 07d3043 | 2009-08-14 17:19:52 +0300 | [diff] [blame] | 4760 | int status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4761 | |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 4762 | p = xdr_inline_decode(xdr, 4); |
| 4763 | if (unlikely(!p)) |
| 4764 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 4765 | delegation_type = be32_to_cpup(p); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4766 | if (delegation_type == NFS4_OPEN_DELEGATE_NONE) { |
| 4767 | res->delegation_type = 0; |
| 4768 | return 0; |
| 4769 | } |
Benny Halevy | 07d3043 | 2009-08-14 17:19:52 +0300 | [diff] [blame] | 4770 | status = decode_stateid(xdr, &res->delegation); |
| 4771 | if (unlikely(status)) |
| 4772 | return status; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 4773 | p = xdr_inline_decode(xdr, 4); |
| 4774 | if (unlikely(!p)) |
| 4775 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 4776 | res->do_recall = be32_to_cpup(p); |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 4777 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4778 | switch (delegation_type) { |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 4779 | case NFS4_OPEN_DELEGATE_READ: |
| 4780 | res->delegation_type = FMODE_READ; |
| 4781 | break; |
| 4782 | case NFS4_OPEN_DELEGATE_WRITE: |
| 4783 | res->delegation_type = FMODE_WRITE|FMODE_READ; |
| 4784 | if (decode_space_limit(xdr, &res->maxsize) < 0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4785 | return -EIO; |
| 4786 | } |
David Howells | 7539bba | 2006-08-22 20:06:09 -0400 | [diff] [blame] | 4787 | return decode_ace(xdr, NULL, res->server->nfs_client); |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 4788 | out_overflow: |
| 4789 | print_overflow_msg(__func__, xdr); |
| 4790 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4791 | } |
| 4792 | |
| 4793 | static int decode_open(struct xdr_stream *xdr, struct nfs_openres *res) |
| 4794 | { |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 4795 | __be32 *p; |
Jeff Layton | aa53ed5 | 2007-06-05 14:49:03 -0400 | [diff] [blame] | 4796 | uint32_t savewords, bmlen, i; |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 4797 | int status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4798 | |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 4799 | status = decode_op_hdr(xdr, OP_OPEN); |
Trond Myklebust | c1d5193 | 2008-04-07 13:20:54 -0400 | [diff] [blame] | 4800 | if (status != -EIO) |
| 4801 | nfs_increment_open_seqid(status, res->seqid); |
Benny Halevy | 07d3043 | 2009-08-14 17:19:52 +0300 | [diff] [blame] | 4802 | if (!status) |
| 4803 | status = decode_stateid(xdr, &res->stateid); |
| 4804 | if (unlikely(status)) |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 4805 | return status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4806 | |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 4807 | decode_change_info(xdr, &res->cinfo); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4808 | |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 4809 | p = xdr_inline_decode(xdr, 8); |
| 4810 | if (unlikely(!p)) |
| 4811 | goto out_overflow; |
Benny Halevy | 6f723f7 | 2009-08-14 17:19:37 +0300 | [diff] [blame] | 4812 | res->rflags = be32_to_cpup(p++); |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 4813 | bmlen = be32_to_cpup(p); |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 4814 | if (bmlen > 10) |
| 4815 | goto xdr_error; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4816 | |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 4817 | p = xdr_inline_decode(xdr, bmlen << 2); |
| 4818 | if (unlikely(!p)) |
| 4819 | goto out_overflow; |
Jeff Layton | aa53ed5 | 2007-06-05 14:49:03 -0400 | [diff] [blame] | 4820 | savewords = min_t(uint32_t, bmlen, NFS4_BITMAP_SIZE); |
| 4821 | for (i = 0; i < savewords; ++i) |
Benny Halevy | 6f723f7 | 2009-08-14 17:19:37 +0300 | [diff] [blame] | 4822 | res->attrset[i] = be32_to_cpup(p++); |
Jeff Layton | aa53ed5 | 2007-06-05 14:49:03 -0400 | [diff] [blame] | 4823 | for (; i < NFS4_BITMAP_SIZE; i++) |
| 4824 | res->attrset[i] = 0; |
| 4825 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4826 | return decode_delegation(xdr, res); |
| 4827 | xdr_error: |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 4828 | dprintk("%s: Bitmap too large! Length = %u\n", __func__, bmlen); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4829 | return -EIO; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 4830 | out_overflow: |
| 4831 | print_overflow_msg(__func__, xdr); |
| 4832 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4833 | } |
| 4834 | |
| 4835 | static int decode_open_confirm(struct xdr_stream *xdr, struct nfs_open_confirmres *res) |
| 4836 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4837 | int status; |
| 4838 | |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 4839 | status = decode_op_hdr(xdr, OP_OPEN_CONFIRM); |
Trond Myklebust | c1d5193 | 2008-04-07 13:20:54 -0400 | [diff] [blame] | 4840 | if (status != -EIO) |
| 4841 | nfs_increment_open_seqid(status, res->seqid); |
Benny Halevy | 07d3043 | 2009-08-14 17:19:52 +0300 | [diff] [blame] | 4842 | if (!status) |
| 4843 | status = decode_stateid(xdr, &res->stateid); |
| 4844 | return status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4845 | } |
| 4846 | |
| 4847 | static int decode_open_downgrade(struct xdr_stream *xdr, struct nfs_closeres *res) |
| 4848 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4849 | int status; |
| 4850 | |
| 4851 | status = decode_op_hdr(xdr, OP_OPEN_DOWNGRADE); |
Trond Myklebust | c1d5193 | 2008-04-07 13:20:54 -0400 | [diff] [blame] | 4852 | if (status != -EIO) |
| 4853 | nfs_increment_open_seqid(status, res->seqid); |
Benny Halevy | 07d3043 | 2009-08-14 17:19:52 +0300 | [diff] [blame] | 4854 | if (!status) |
| 4855 | status = decode_stateid(xdr, &res->stateid); |
| 4856 | return status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4857 | } |
| 4858 | |
| 4859 | static int decode_putfh(struct xdr_stream *xdr) |
| 4860 | { |
| 4861 | return decode_op_hdr(xdr, OP_PUTFH); |
| 4862 | } |
| 4863 | |
| 4864 | static int decode_putrootfh(struct xdr_stream *xdr) |
| 4865 | { |
| 4866 | return decode_op_hdr(xdr, OP_PUTROOTFH); |
| 4867 | } |
| 4868 | |
| 4869 | static int decode_read(struct xdr_stream *xdr, struct rpc_rqst *req, struct nfs_readres *res) |
| 4870 | { |
| 4871 | struct kvec *iov = req->rq_rcv_buf.head; |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 4872 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4873 | uint32_t count, eof, recvd, hdrlen; |
| 4874 | int status; |
| 4875 | |
| 4876 | status = decode_op_hdr(xdr, OP_READ); |
| 4877 | if (status) |
| 4878 | return status; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 4879 | p = xdr_inline_decode(xdr, 8); |
| 4880 | if (unlikely(!p)) |
| 4881 | goto out_overflow; |
Benny Halevy | 6f723f7 | 2009-08-14 17:19:37 +0300 | [diff] [blame] | 4882 | eof = be32_to_cpup(p++); |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 4883 | count = be32_to_cpup(p); |
Chuck Lever | 8111f37 | 2010-12-14 14:58:01 +0000 | [diff] [blame] | 4884 | hdrlen = (u8 *) xdr->p - (u8 *) iov->iov_base; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4885 | recvd = req->rq_rcv_buf.len - hdrlen; |
| 4886 | if (count > recvd) { |
Chuck Lever | fe82a18 | 2007-09-11 18:01:10 -0400 | [diff] [blame] | 4887 | dprintk("NFS: server cheating in read reply: " |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4888 | "count %u > recvd %u\n", count, recvd); |
| 4889 | count = recvd; |
| 4890 | eof = 0; |
| 4891 | } |
| 4892 | xdr_read_pages(xdr, count); |
| 4893 | res->eof = eof; |
| 4894 | res->count = count; |
| 4895 | return 0; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 4896 | out_overflow: |
| 4897 | print_overflow_msg(__func__, xdr); |
| 4898 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4899 | } |
| 4900 | |
| 4901 | static int decode_readdir(struct xdr_stream *xdr, struct rpc_rqst *req, struct nfs4_readdir_res *readdir) |
| 4902 | { |
| 4903 | struct xdr_buf *rcvbuf = &req->rq_rcv_buf; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4904 | struct kvec *iov = rcvbuf->head; |
Chuck Lever | bcecff7 | 2007-10-26 13:32:03 -0400 | [diff] [blame] | 4905 | size_t hdrlen; |
| 4906 | u32 recvd, pglen = rcvbuf->page_len; |
Chuck Lever | bcecff7 | 2007-10-26 13:32:03 -0400 | [diff] [blame] | 4907 | int status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4908 | |
| 4909 | status = decode_op_hdr(xdr, OP_READDIR); |
Benny Halevy | db942bb | 2009-08-14 17:19:56 +0300 | [diff] [blame] | 4910 | if (!status) |
| 4911 | status = decode_verifier(xdr, readdir->verifier.data); |
| 4912 | if (unlikely(status)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4913 | return status; |
Fred Isaman | 4410924 | 2008-04-02 15:21:15 +0300 | [diff] [blame] | 4914 | dprintk("%s: verifier = %08x:%08x\n", |
| 4915 | __func__, |
Trond Myklebust | eadf459 | 2005-06-22 17:16:39 +0000 | [diff] [blame] | 4916 | ((u32 *)readdir->verifier.data)[0], |
| 4917 | ((u32 *)readdir->verifier.data)[1]); |
| 4918 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4919 | |
Benny Halevy | db942bb | 2009-08-14 17:19:56 +0300 | [diff] [blame] | 4920 | hdrlen = (char *) xdr->p - (char *) iov->iov_base; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4921 | recvd = rcvbuf->len - hdrlen; |
| 4922 | if (pglen > recvd) |
| 4923 | pglen = recvd; |
| 4924 | xdr_read_pages(xdr, pglen); |
| 4925 | |
Jeff Layton | 7bda2cd | 2008-02-22 14:50:01 -0500 | [diff] [blame] | 4926 | |
Trond Myklebust | ac39612 | 2010-11-15 20:26:22 -0500 | [diff] [blame] | 4927 | return pglen; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4928 | } |
| 4929 | |
| 4930 | static int decode_readlink(struct xdr_stream *xdr, struct rpc_rqst *req) |
| 4931 | { |
| 4932 | struct xdr_buf *rcvbuf = &req->rq_rcv_buf; |
| 4933 | struct kvec *iov = rcvbuf->head; |
Chuck Lever | bcecff7 | 2007-10-26 13:32:03 -0400 | [diff] [blame] | 4934 | size_t hdrlen; |
| 4935 | u32 len, recvd; |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 4936 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4937 | int status; |
| 4938 | |
| 4939 | status = decode_op_hdr(xdr, OP_READLINK); |
| 4940 | if (status) |
| 4941 | return status; |
| 4942 | |
| 4943 | /* Convert length of symlink */ |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 4944 | p = xdr_inline_decode(xdr, 4); |
| 4945 | if (unlikely(!p)) |
| 4946 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 4947 | len = be32_to_cpup(p); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4948 | if (len >= rcvbuf->page_len || len <= 0) { |
Chuck Lever | fe82a18 | 2007-09-11 18:01:10 -0400 | [diff] [blame] | 4949 | dprintk("nfs: server returned giant symlink!\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4950 | return -ENAMETOOLONG; |
| 4951 | } |
| 4952 | hdrlen = (char *) xdr->p - (char *) iov->iov_base; |
| 4953 | recvd = req->rq_rcv_buf.len - hdrlen; |
| 4954 | if (recvd < len) { |
Chuck Lever | fe82a18 | 2007-09-11 18:01:10 -0400 | [diff] [blame] | 4955 | dprintk("NFS: server cheating in readlink reply: " |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4956 | "count %u > recvd %u\n", len, recvd); |
| 4957 | return -EIO; |
| 4958 | } |
| 4959 | xdr_read_pages(xdr, len); |
| 4960 | /* |
| 4961 | * The XDR encode routine has set things up so that |
| 4962 | * the link text will be copied directly into the |
| 4963 | * buffer. We just have to do overflow-checking, |
| 4964 | * and and null-terminate the text (the VFS expects |
| 4965 | * null-termination). |
| 4966 | */ |
Chuck Lever | b4687da | 2010-09-21 16:55:48 -0400 | [diff] [blame] | 4967 | xdr_terminate_string(rcvbuf, len); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4968 | return 0; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 4969 | out_overflow: |
| 4970 | print_overflow_msg(__func__, xdr); |
| 4971 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4972 | } |
| 4973 | |
| 4974 | static int decode_remove(struct xdr_stream *xdr, struct nfs4_change_info *cinfo) |
| 4975 | { |
| 4976 | int status; |
| 4977 | |
| 4978 | status = decode_op_hdr(xdr, OP_REMOVE); |
| 4979 | if (status) |
| 4980 | goto out; |
| 4981 | status = decode_change_info(xdr, cinfo); |
| 4982 | out: |
| 4983 | return status; |
| 4984 | } |
| 4985 | |
| 4986 | static int decode_rename(struct xdr_stream *xdr, struct nfs4_change_info *old_cinfo, |
| 4987 | struct nfs4_change_info *new_cinfo) |
| 4988 | { |
| 4989 | int status; |
| 4990 | |
| 4991 | status = decode_op_hdr(xdr, OP_RENAME); |
| 4992 | if (status) |
| 4993 | goto out; |
| 4994 | if ((status = decode_change_info(xdr, old_cinfo))) |
| 4995 | goto out; |
| 4996 | status = decode_change_info(xdr, new_cinfo); |
| 4997 | out: |
| 4998 | return status; |
| 4999 | } |
| 5000 | |
| 5001 | static int decode_renew(struct xdr_stream *xdr) |
| 5002 | { |
| 5003 | return decode_op_hdr(xdr, OP_RENEW); |
| 5004 | } |
| 5005 | |
Trond Myklebust | 56ae19f | 2005-10-27 22:12:40 -0400 | [diff] [blame] | 5006 | static int |
| 5007 | decode_restorefh(struct xdr_stream *xdr) |
| 5008 | { |
| 5009 | return decode_op_hdr(xdr, OP_RESTOREFH); |
| 5010 | } |
| 5011 | |
J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 5012 | static int decode_getacl(struct xdr_stream *xdr, struct rpc_rqst *req, |
Andy Adamson | bf118a3 | 2011-12-07 11:55:27 -0500 | [diff] [blame] | 5013 | struct nfs_getaclres *res) |
J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 5014 | { |
Andy Adamson | bf118a3 | 2011-12-07 11:55:27 -0500 | [diff] [blame] | 5015 | __be32 *savep, *bm_p; |
J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 5016 | uint32_t attrlen, |
Fred Isaman | dae100c | 2011-07-30 20:52:37 -0400 | [diff] [blame] | 5017 | bitmap[3] = {0}; |
J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 5018 | struct kvec *iov = req->rq_rcv_buf.head; |
| 5019 | int status; |
| 5020 | |
Andy Adamson | bf118a3 | 2011-12-07 11:55:27 -0500 | [diff] [blame] | 5021 | res->acl_len = 0; |
J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 5022 | if ((status = decode_op_hdr(xdr, OP_GETATTR)) != 0) |
| 5023 | goto out; |
Andy Adamson | bf118a3 | 2011-12-07 11:55:27 -0500 | [diff] [blame] | 5024 | bm_p = xdr->p; |
J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 5025 | if ((status = decode_attr_bitmap(xdr, bitmap)) != 0) |
| 5026 | goto out; |
| 5027 | if ((status = decode_attr_length(xdr, &attrlen, &savep)) != 0) |
| 5028 | goto out; |
| 5029 | |
| 5030 | if (unlikely(bitmap[0] & (FATTR4_WORD0_ACL - 1U))) |
| 5031 | return -EIO; |
| 5032 | if (likely(bitmap[0] & FATTR4_WORD0_ACL)) { |
Chuck Lever | bcecff7 | 2007-10-26 13:32:03 -0400 | [diff] [blame] | 5033 | size_t hdrlen; |
| 5034 | u32 recvd; |
J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 5035 | |
Andy Adamson | bf118a3 | 2011-12-07 11:55:27 -0500 | [diff] [blame] | 5036 | /* The bitmap (xdr len + bitmaps) and the attr xdr len words |
| 5037 | * are stored with the acl data to handle the problem of |
| 5038 | * variable length bitmaps.*/ |
| 5039 | xdr->p = bm_p; |
| 5040 | res->acl_data_offset = be32_to_cpup(bm_p) + 2; |
| 5041 | res->acl_data_offset <<= 2; |
| 5042 | |
J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 5043 | /* We ignore &savep and don't do consistency checks on |
| 5044 | * the attr length. Let userspace figure it out.... */ |
| 5045 | hdrlen = (u8 *)xdr->p - (u8 *)iov->iov_base; |
Andy Adamson | bf118a3 | 2011-12-07 11:55:27 -0500 | [diff] [blame] | 5046 | attrlen += res->acl_data_offset; |
J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 5047 | recvd = req->rq_rcv_buf.len - hdrlen; |
| 5048 | if (attrlen > recvd) { |
Andy Adamson | bf118a3 | 2011-12-07 11:55:27 -0500 | [diff] [blame] | 5049 | if (res->acl_flags & NFS4_ACL_LEN_REQUEST) { |
| 5050 | /* getxattr interface called with a NULL buf */ |
| 5051 | res->acl_len = attrlen; |
| 5052 | goto out; |
| 5053 | } |
| 5054 | dprintk("NFS: acl reply: attrlen %u > recvd %u\n", |
J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 5055 | attrlen, recvd); |
| 5056 | return -EINVAL; |
| 5057 | } |
J. Bruce Fields | c04871e | 2006-05-30 16:28:58 -0400 | [diff] [blame] | 5058 | xdr_read_pages(xdr, attrlen); |
Andy Adamson | bf118a3 | 2011-12-07 11:55:27 -0500 | [diff] [blame] | 5059 | res->acl_len = attrlen; |
J. Bruce Fields | 8c233cf | 2005-10-13 16:54:27 -0400 | [diff] [blame] | 5060 | } else |
| 5061 | status = -EOPNOTSUPP; |
J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 5062 | |
| 5063 | out: |
| 5064 | return status; |
| 5065 | } |
| 5066 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5067 | static int |
| 5068 | decode_savefh(struct xdr_stream *xdr) |
| 5069 | { |
| 5070 | return decode_op_hdr(xdr, OP_SAVEFH); |
| 5071 | } |
| 5072 | |
Benny Halevy | 9e9ecc0 | 2009-04-01 09:22:00 -0400 | [diff] [blame] | 5073 | static int decode_setattr(struct xdr_stream *xdr) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5074 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 5075 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5076 | uint32_t bmlen; |
| 5077 | int status; |
| 5078 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5079 | status = decode_op_hdr(xdr, OP_SETATTR); |
| 5080 | if (status) |
| 5081 | return status; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 5082 | p = xdr_inline_decode(xdr, 4); |
| 5083 | if (unlikely(!p)) |
| 5084 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 5085 | bmlen = be32_to_cpup(p); |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 5086 | p = xdr_inline_decode(xdr, bmlen << 2); |
| 5087 | if (likely(p)) |
| 5088 | return 0; |
| 5089 | out_overflow: |
| 5090 | print_overflow_msg(__func__, xdr); |
| 5091 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5092 | } |
| 5093 | |
Trond Myklebust | bb8b27e | 2010-04-16 16:43:06 -0400 | [diff] [blame] | 5094 | 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] | 5095 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 5096 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5097 | uint32_t opnum; |
| 5098 | int32_t nfserr; |
| 5099 | |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 5100 | p = xdr_inline_decode(xdr, 8); |
| 5101 | if (unlikely(!p)) |
| 5102 | goto out_overflow; |
Benny Halevy | 6f723f7 | 2009-08-14 17:19:37 +0300 | [diff] [blame] | 5103 | opnum = be32_to_cpup(p++); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5104 | if (opnum != OP_SETCLIENTID) { |
Chuck Lever | fe82a18 | 2007-09-11 18:01:10 -0400 | [diff] [blame] | 5105 | dprintk("nfs: decode_setclientid: Server returned operation" |
Andy Adamson | 6c0195a | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 5106 | " %d\n", opnum); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5107 | return -EIO; |
| 5108 | } |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 5109 | nfserr = be32_to_cpup(p); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5110 | if (nfserr == NFS_OK) { |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 5111 | p = xdr_inline_decode(xdr, 8 + NFS4_VERIFIER_SIZE); |
| 5112 | if (unlikely(!p)) |
| 5113 | goto out_overflow; |
Trond Myklebust | bb8b27e | 2010-04-16 16:43:06 -0400 | [diff] [blame] | 5114 | p = xdr_decode_hyper(p, &res->clientid); |
| 5115 | memcpy(res->confirm.data, p, NFS4_VERIFIER_SIZE); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5116 | } else if (nfserr == NFSERR_CLID_INUSE) { |
| 5117 | uint32_t len; |
| 5118 | |
| 5119 | /* skip netid string */ |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 5120 | p = xdr_inline_decode(xdr, 4); |
| 5121 | if (unlikely(!p)) |
| 5122 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 5123 | len = be32_to_cpup(p); |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 5124 | p = xdr_inline_decode(xdr, len); |
| 5125 | if (unlikely(!p)) |
| 5126 | goto out_overflow; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5127 | |
| 5128 | /* skip uaddr string */ |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 5129 | p = xdr_inline_decode(xdr, 4); |
| 5130 | if (unlikely(!p)) |
| 5131 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 5132 | len = be32_to_cpup(p); |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 5133 | p = xdr_inline_decode(xdr, len); |
| 5134 | if (unlikely(!p)) |
| 5135 | goto out_overflow; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5136 | return -NFSERR_CLID_INUSE; |
| 5137 | } else |
Benny Halevy | 856dff3 | 2008-03-31 17:39:06 +0300 | [diff] [blame] | 5138 | return nfs4_stat_to_errno(nfserr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5139 | |
| 5140 | return 0; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 5141 | out_overflow: |
| 5142 | print_overflow_msg(__func__, xdr); |
| 5143 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5144 | } |
| 5145 | |
| 5146 | static int decode_setclientid_confirm(struct xdr_stream *xdr) |
| 5147 | { |
| 5148 | return decode_op_hdr(xdr, OP_SETCLIENTID_CONFIRM); |
| 5149 | } |
| 5150 | |
| 5151 | static int decode_write(struct xdr_stream *xdr, struct nfs_writeres *res) |
| 5152 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 5153 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5154 | int status; |
| 5155 | |
| 5156 | status = decode_op_hdr(xdr, OP_WRITE); |
| 5157 | if (status) |
| 5158 | return status; |
| 5159 | |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 5160 | p = xdr_inline_decode(xdr, 16); |
| 5161 | if (unlikely(!p)) |
| 5162 | goto out_overflow; |
Benny Halevy | 6f723f7 | 2009-08-14 17:19:37 +0300 | [diff] [blame] | 5163 | res->count = be32_to_cpup(p++); |
| 5164 | res->verf->committed = be32_to_cpup(p++); |
Benny Halevy | 99398d0 | 2009-08-14 17:20:05 +0300 | [diff] [blame] | 5165 | memcpy(res->verf->verifier, p, 8); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5166 | return 0; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 5167 | out_overflow: |
| 5168 | print_overflow_msg(__func__, xdr); |
| 5169 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5170 | } |
| 5171 | |
| 5172 | static int decode_delegreturn(struct xdr_stream *xdr) |
| 5173 | { |
| 5174 | return decode_op_hdr(xdr, OP_DELEGRETURN); |
| 5175 | } |
| 5176 | |
Bryan Schumaker | 5a5ea0d | 2011-03-24 17:12:29 +0000 | [diff] [blame] | 5177 | static int decode_secinfo_gss(struct xdr_stream *xdr, struct nfs4_secinfo_flavor *flavor) |
| 5178 | { |
| 5179 | __be32 *p; |
| 5180 | |
| 5181 | p = xdr_inline_decode(xdr, 4); |
| 5182 | if (unlikely(!p)) |
| 5183 | goto out_overflow; |
| 5184 | flavor->gss.sec_oid4.len = be32_to_cpup(p); |
| 5185 | if (flavor->gss.sec_oid4.len > GSS_OID_MAX_LEN) |
| 5186 | goto out_err; |
| 5187 | |
| 5188 | p = xdr_inline_decode(xdr, flavor->gss.sec_oid4.len); |
| 5189 | if (unlikely(!p)) |
| 5190 | goto out_overflow; |
| 5191 | memcpy(flavor->gss.sec_oid4.data, p, flavor->gss.sec_oid4.len); |
| 5192 | |
| 5193 | p = xdr_inline_decode(xdr, 8); |
| 5194 | if (unlikely(!p)) |
| 5195 | goto out_overflow; |
| 5196 | flavor->gss.qop4 = be32_to_cpup(p++); |
| 5197 | flavor->gss.service = be32_to_cpup(p); |
| 5198 | |
| 5199 | return 0; |
| 5200 | |
| 5201 | out_overflow: |
| 5202 | print_overflow_msg(__func__, xdr); |
| 5203 | return -EIO; |
| 5204 | out_err: |
| 5205 | return -EINVAL; |
| 5206 | } |
| 5207 | |
| 5208 | static int decode_secinfo(struct xdr_stream *xdr, struct nfs4_secinfo_res *res) |
| 5209 | { |
| 5210 | struct nfs4_secinfo_flavor *sec_flavor; |
| 5211 | int status; |
| 5212 | __be32 *p; |
Bryan Schumaker | c3dfc28 | 2011-04-13 14:31:31 -0400 | [diff] [blame] | 5213 | int i, num_flavors; |
Bryan Schumaker | 5a5ea0d | 2011-03-24 17:12:29 +0000 | [diff] [blame] | 5214 | |
| 5215 | status = decode_op_hdr(xdr, OP_SECINFO); |
Bryan Schumaker | 613e901 | 2011-04-27 15:28:44 -0400 | [diff] [blame] | 5216 | if (status) |
| 5217 | goto out; |
Bryan Schumaker | 5a5ea0d | 2011-03-24 17:12:29 +0000 | [diff] [blame] | 5218 | p = xdr_inline_decode(xdr, 4); |
| 5219 | if (unlikely(!p)) |
| 5220 | goto out_overflow; |
Bryan Schumaker | 5a5ea0d | 2011-03-24 17:12:29 +0000 | [diff] [blame] | 5221 | |
Bryan Schumaker | c3dfc28 | 2011-04-13 14:31:31 -0400 | [diff] [blame] | 5222 | res->flavors->num_flavors = 0; |
| 5223 | num_flavors = be32_to_cpup(p); |
| 5224 | |
| 5225 | for (i = 0; i < num_flavors; i++) { |
Bryan Schumaker | 5a5ea0d | 2011-03-24 17:12:29 +0000 | [diff] [blame] | 5226 | sec_flavor = &res->flavors->flavors[i]; |
Bryan Schumaker | c3dfc28 | 2011-04-13 14:31:31 -0400 | [diff] [blame] | 5227 | if ((char *)&sec_flavor[1] - (char *)res->flavors > PAGE_SIZE) |
Bryan Schumaker | 5a5ea0d | 2011-03-24 17:12:29 +0000 | [diff] [blame] | 5228 | break; |
| 5229 | |
| 5230 | p = xdr_inline_decode(xdr, 4); |
| 5231 | if (unlikely(!p)) |
| 5232 | goto out_overflow; |
| 5233 | sec_flavor->flavor = be32_to_cpup(p); |
| 5234 | |
| 5235 | if (sec_flavor->flavor == RPC_AUTH_GSS) { |
Bryan Schumaker | 613e901 | 2011-04-27 15:28:44 -0400 | [diff] [blame] | 5236 | status = decode_secinfo_gss(xdr, sec_flavor); |
| 5237 | if (status) |
| 5238 | goto out; |
Bryan Schumaker | 5a5ea0d | 2011-03-24 17:12:29 +0000 | [diff] [blame] | 5239 | } |
Bryan Schumaker | c3dfc28 | 2011-04-13 14:31:31 -0400 | [diff] [blame] | 5240 | res->flavors->num_flavors++; |
Bryan Schumaker | 5a5ea0d | 2011-03-24 17:12:29 +0000 | [diff] [blame] | 5241 | } |
| 5242 | |
Bryan Schumaker | 613e901 | 2011-04-27 15:28:44 -0400 | [diff] [blame] | 5243 | out: |
| 5244 | return status; |
Bryan Schumaker | 5a5ea0d | 2011-03-24 17:12:29 +0000 | [diff] [blame] | 5245 | out_overflow: |
| 5246 | print_overflow_msg(__func__, xdr); |
| 5247 | return -EIO; |
| 5248 | } |
| 5249 | |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 5250 | #if defined(CONFIG_NFS_V4_1) |
| 5251 | static int decode_exchange_id(struct xdr_stream *xdr, |
| 5252 | struct nfs41_exchange_id_res *res) |
| 5253 | { |
| 5254 | __be32 *p; |
| 5255 | uint32_t dummy; |
Benny Halevy | 2460ba5 | 2009-08-14 17:20:10 +0300 | [diff] [blame] | 5256 | char *dummy_str; |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 5257 | int status; |
| 5258 | struct nfs_client *clp = res->client; |
| 5259 | |
| 5260 | status = decode_op_hdr(xdr, OP_EXCHANGE_ID); |
| 5261 | if (status) |
| 5262 | return status; |
| 5263 | |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 5264 | p = xdr_inline_decode(xdr, 8); |
| 5265 | if (unlikely(!p)) |
| 5266 | goto out_overflow; |
Andy Adamson | 114f64b | 2011-03-09 13:13:45 -0500 | [diff] [blame] | 5267 | xdr_decode_hyper(p, &clp->cl_clientid); |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 5268 | p = xdr_inline_decode(xdr, 12); |
| 5269 | if (unlikely(!p)) |
| 5270 | goto out_overflow; |
Benny Halevy | 6f723f7 | 2009-08-14 17:19:37 +0300 | [diff] [blame] | 5271 | clp->cl_seqid = be32_to_cpup(p++); |
| 5272 | clp->cl_exchange_flags = be32_to_cpup(p++); |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 5273 | |
| 5274 | /* We ask for SP4_NONE */ |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 5275 | dummy = be32_to_cpup(p); |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 5276 | if (dummy != SP4_NONE) |
| 5277 | return -EIO; |
| 5278 | |
| 5279 | /* Throw away minor_id */ |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 5280 | p = xdr_inline_decode(xdr, 8); |
| 5281 | if (unlikely(!p)) |
| 5282 | goto out_overflow; |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 5283 | |
| 5284 | /* Throw away Major id */ |
Benny Halevy | 2460ba5 | 2009-08-14 17:20:10 +0300 | [diff] [blame] | 5285 | status = decode_opaque_inline(xdr, &dummy, &dummy_str); |
| 5286 | if (unlikely(status)) |
| 5287 | return status; |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 5288 | |
Weston Andros Adamson | 78fe0f4 | 2011-05-31 19:05:47 -0400 | [diff] [blame] | 5289 | /* Save server_scope */ |
Benny Halevy | 2460ba5 | 2009-08-14 17:20:10 +0300 | [diff] [blame] | 5290 | status = decode_opaque_inline(xdr, &dummy, &dummy_str); |
| 5291 | if (unlikely(status)) |
| 5292 | return status; |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 5293 | |
Weston Andros Adamson | 78fe0f4 | 2011-05-31 19:05:47 -0400 | [diff] [blame] | 5294 | if (unlikely(dummy > NFS4_OPAQUE_LIMIT)) |
| 5295 | return -EIO; |
| 5296 | |
| 5297 | memcpy(res->server_scope->server_scope, dummy_str, dummy); |
| 5298 | res->server_scope->server_scope_sz = dummy; |
| 5299 | |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 5300 | /* Throw away Implementation id array */ |
Benny Halevy | 2460ba5 | 2009-08-14 17:20:10 +0300 | [diff] [blame] | 5301 | status = decode_opaque_inline(xdr, &dummy, &dummy_str); |
| 5302 | if (unlikely(status)) |
| 5303 | return status; |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 5304 | |
| 5305 | return 0; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 5306 | out_overflow: |
| 5307 | print_overflow_msg(__func__, xdr); |
| 5308 | return -EIO; |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 5309 | } |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 5310 | |
| 5311 | static int decode_chan_attrs(struct xdr_stream *xdr, |
| 5312 | struct nfs4_channel_attrs *attrs) |
| 5313 | { |
| 5314 | __be32 *p; |
Benny Halevy | c9c30dd | 2011-06-11 17:08:39 -0400 | [diff] [blame] | 5315 | u32 nr_attrs, val; |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 5316 | |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 5317 | p = xdr_inline_decode(xdr, 28); |
| 5318 | if (unlikely(!p)) |
| 5319 | goto out_overflow; |
Benny Halevy | c9c30dd | 2011-06-11 17:08:39 -0400 | [diff] [blame] | 5320 | val = be32_to_cpup(p++); /* headerpadsz */ |
| 5321 | if (val) |
| 5322 | return -EINVAL; /* no support for header padding yet */ |
Benny Halevy | 6f723f7 | 2009-08-14 17:19:37 +0300 | [diff] [blame] | 5323 | attrs->max_rqst_sz = be32_to_cpup(p++); |
| 5324 | attrs->max_resp_sz = be32_to_cpup(p++); |
| 5325 | attrs->max_resp_sz_cached = be32_to_cpup(p++); |
| 5326 | attrs->max_ops = be32_to_cpup(p++); |
| 5327 | attrs->max_reqs = be32_to_cpup(p++); |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 5328 | nr_attrs = be32_to_cpup(p); |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 5329 | if (unlikely(nr_attrs > 1)) { |
Weston Andros Adamson | a030889 | 2012-01-26 13:32:23 -0500 | [diff] [blame] | 5330 | printk(KERN_WARNING "NFS: %s: Invalid rdma channel attrs " |
| 5331 | "count %u\n", __func__, nr_attrs); |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 5332 | return -EINVAL; |
| 5333 | } |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 5334 | if (nr_attrs == 1) { |
| 5335 | p = xdr_inline_decode(xdr, 4); /* skip rdma_attrs */ |
| 5336 | if (unlikely(!p)) |
| 5337 | goto out_overflow; |
| 5338 | } |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 5339 | return 0; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 5340 | out_overflow: |
| 5341 | print_overflow_msg(__func__, xdr); |
| 5342 | return -EIO; |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 5343 | } |
| 5344 | |
Benny Halevy | e78291e | 2009-08-14 17:20:00 +0300 | [diff] [blame] | 5345 | static int decode_sessionid(struct xdr_stream *xdr, struct nfs4_sessionid *sid) |
| 5346 | { |
| 5347 | return decode_opaque_fixed(xdr, sid->data, NFS4_MAX_SESSIONID_LEN); |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 5348 | } |
| 5349 | |
| 5350 | static int decode_create_session(struct xdr_stream *xdr, |
| 5351 | struct nfs41_create_session_res *res) |
| 5352 | { |
| 5353 | __be32 *p; |
| 5354 | int status; |
| 5355 | struct nfs_client *clp = res->client; |
| 5356 | struct nfs4_session *session = clp->cl_session; |
| 5357 | |
| 5358 | status = decode_op_hdr(xdr, OP_CREATE_SESSION); |
Benny Halevy | e78291e | 2009-08-14 17:20:00 +0300 | [diff] [blame] | 5359 | if (!status) |
| 5360 | status = decode_sessionid(xdr, &session->sess_id); |
| 5361 | if (unlikely(status)) |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 5362 | return status; |
| 5363 | |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 5364 | /* seqid, flags */ |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 5365 | p = xdr_inline_decode(xdr, 8); |
| 5366 | if (unlikely(!p)) |
| 5367 | goto out_overflow; |
Benny Halevy | 6f723f7 | 2009-08-14 17:19:37 +0300 | [diff] [blame] | 5368 | clp->cl_seqid = be32_to_cpup(p++); |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 5369 | session->flags = be32_to_cpup(p); |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 5370 | |
| 5371 | /* Channel attributes */ |
| 5372 | status = decode_chan_attrs(xdr, &session->fc_attrs); |
| 5373 | if (!status) |
| 5374 | status = decode_chan_attrs(xdr, &session->bc_attrs); |
| 5375 | return status; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 5376 | out_overflow: |
| 5377 | print_overflow_msg(__func__, xdr); |
| 5378 | return -EIO; |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 5379 | } |
Andy Adamson | 0f3e66c | 2009-04-01 09:22:34 -0400 | [diff] [blame] | 5380 | |
| 5381 | static int decode_destroy_session(struct xdr_stream *xdr, void *dummy) |
| 5382 | { |
| 5383 | return decode_op_hdr(xdr, OP_DESTROY_SESSION); |
| 5384 | } |
Ricardo Labiaga | 1801975 | 2009-12-05 16:08:40 -0500 | [diff] [blame] | 5385 | |
| 5386 | static int decode_reclaim_complete(struct xdr_stream *xdr, void *dummy) |
| 5387 | { |
| 5388 | return decode_op_hdr(xdr, OP_RECLAIM_COMPLETE); |
| 5389 | } |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 5390 | #endif /* CONFIG_NFS_V4_1 */ |
| 5391 | |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 5392 | static int decode_sequence(struct xdr_stream *xdr, |
| 5393 | struct nfs4_sequence_res *res, |
| 5394 | struct rpc_rqst *rqstp) |
| 5395 | { |
| 5396 | #if defined(CONFIG_NFS_V4_1) |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 5397 | struct nfs4_sessionid id; |
| 5398 | u32 dummy; |
| 5399 | int status; |
| 5400 | __be32 *p; |
| 5401 | |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 5402 | if (!res->sr_session) |
| 5403 | return 0; |
| 5404 | |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 5405 | status = decode_op_hdr(xdr, OP_SEQUENCE); |
Benny Halevy | e78291e | 2009-08-14 17:20:00 +0300 | [diff] [blame] | 5406 | if (!status) |
| 5407 | status = decode_sessionid(xdr, &id); |
| 5408 | if (unlikely(status)) |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 5409 | goto out_err; |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 5410 | |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 5411 | /* |
| 5412 | * If the server returns different values for sessionID, slotID or |
| 5413 | * sequence number, the server is looney tunes. |
| 5414 | */ |
Trond Myklebust | fdcb457 | 2010-02-08 09:32:40 -0500 | [diff] [blame] | 5415 | status = -EREMOTEIO; |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 5416 | |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 5417 | if (memcmp(id.data, res->sr_session->sess_id.data, |
| 5418 | NFS4_MAX_SESSIONID_LEN)) { |
| 5419 | dprintk("%s Invalid session id\n", __func__); |
| 5420 | goto out_err; |
| 5421 | } |
Benny Halevy | e78291e | 2009-08-14 17:20:00 +0300 | [diff] [blame] | 5422 | |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 5423 | p = xdr_inline_decode(xdr, 20); |
| 5424 | if (unlikely(!p)) |
| 5425 | goto out_overflow; |
Benny Halevy | e78291e | 2009-08-14 17:20:00 +0300 | [diff] [blame] | 5426 | |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 5427 | /* seqid */ |
Benny Halevy | 6f723f7 | 2009-08-14 17:19:37 +0300 | [diff] [blame] | 5428 | dummy = be32_to_cpup(p++); |
Benny Halevy | dfb4f30 | 2010-09-24 09:17:01 -0400 | [diff] [blame] | 5429 | if (dummy != res->sr_slot->seq_nr) { |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 5430 | dprintk("%s Invalid sequence number\n", __func__); |
| 5431 | goto out_err; |
| 5432 | } |
| 5433 | /* slot id */ |
Benny Halevy | 6f723f7 | 2009-08-14 17:19:37 +0300 | [diff] [blame] | 5434 | dummy = be32_to_cpup(p++); |
Benny Halevy | dfb4f30 | 2010-09-24 09:17:01 -0400 | [diff] [blame] | 5435 | if (dummy != res->sr_slot - res->sr_session->fc_slot_table.slots) { |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 5436 | dprintk("%s Invalid slot id\n", __func__); |
| 5437 | goto out_err; |
| 5438 | } |
| 5439 | /* highest slot id - currently not processed */ |
Benny Halevy | 6f723f7 | 2009-08-14 17:19:37 +0300 | [diff] [blame] | 5440 | dummy = be32_to_cpup(p++); |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 5441 | /* target highest slot id - currently not processed */ |
Benny Halevy | 6f723f7 | 2009-08-14 17:19:37 +0300 | [diff] [blame] | 5442 | dummy = be32_to_cpup(p++); |
Alexandros Batsakis | 0629e37 | 2009-12-05 13:46:14 -0500 | [diff] [blame] | 5443 | /* result flags */ |
| 5444 | res->sr_status_flags = be32_to_cpup(p); |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 5445 | status = 0; |
| 5446 | out_err: |
| 5447 | res->sr_status = status; |
| 5448 | return status; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 5449 | out_overflow: |
| 5450 | print_overflow_msg(__func__, xdr); |
| 5451 | status = -EIO; |
| 5452 | goto out_err; |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 5453 | #else /* CONFIG_NFS_V4_1 */ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 5454 | return 0; |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 5455 | #endif /* CONFIG_NFS_V4_1 */ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 5456 | } |
| 5457 | |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 5458 | #if defined(CONFIG_NFS_V4_1) |
Andy Adamson | 7f11d8d | 2011-07-30 20:52:35 -0400 | [diff] [blame] | 5459 | /* |
| 5460 | * TODO: Need to handle case when EOF != true; |
| 5461 | */ |
| 5462 | static int decode_getdevicelist(struct xdr_stream *xdr, |
| 5463 | struct pnfs_devicelist *res) |
| 5464 | { |
| 5465 | __be32 *p; |
| 5466 | int status, i; |
| 5467 | struct nfs_writeverf verftemp; |
| 5468 | |
| 5469 | status = decode_op_hdr(xdr, OP_GETDEVICELIST); |
| 5470 | if (status) |
| 5471 | return status; |
| 5472 | |
| 5473 | p = xdr_inline_decode(xdr, 8 + 8 + 4); |
| 5474 | if (unlikely(!p)) |
| 5475 | goto out_overflow; |
| 5476 | |
| 5477 | /* TODO: Skip cookie for now */ |
| 5478 | p += 2; |
| 5479 | |
| 5480 | /* Read verifier */ |
| 5481 | p = xdr_decode_opaque_fixed(p, verftemp.verifier, 8); |
| 5482 | |
| 5483 | res->num_devs = be32_to_cpup(p); |
| 5484 | |
| 5485 | dprintk("%s: num_dev %d\n", __func__, res->num_devs); |
| 5486 | |
| 5487 | if (res->num_devs > NFS4_PNFS_GETDEVLIST_MAXNUM) { |
Weston Andros Adamson | a030889 | 2012-01-26 13:32:23 -0500 | [diff] [blame] | 5488 | printk(KERN_ERR "NFS: %s too many result dev_num %u\n", |
Andy Adamson | 7f11d8d | 2011-07-30 20:52:35 -0400 | [diff] [blame] | 5489 | __func__, res->num_devs); |
| 5490 | return -EIO; |
| 5491 | } |
| 5492 | |
| 5493 | p = xdr_inline_decode(xdr, |
| 5494 | res->num_devs * NFS4_DEVICEID4_SIZE + 4); |
| 5495 | if (unlikely(!p)) |
| 5496 | goto out_overflow; |
| 5497 | for (i = 0; i < res->num_devs; i++) |
| 5498 | p = xdr_decode_opaque_fixed(p, res->dev_id[i].data, |
| 5499 | NFS4_DEVICEID4_SIZE); |
| 5500 | res->eof = be32_to_cpup(p); |
| 5501 | return 0; |
| 5502 | out_overflow: |
| 5503 | print_overflow_msg(__func__, xdr); |
| 5504 | return -EIO; |
| 5505 | } |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 5506 | |
| 5507 | static int decode_getdeviceinfo(struct xdr_stream *xdr, |
| 5508 | struct pnfs_device *pdev) |
| 5509 | { |
| 5510 | __be32 *p; |
| 5511 | uint32_t len, type; |
| 5512 | int status; |
| 5513 | |
| 5514 | status = decode_op_hdr(xdr, OP_GETDEVICEINFO); |
| 5515 | if (status) { |
| 5516 | if (status == -ETOOSMALL) { |
| 5517 | p = xdr_inline_decode(xdr, 4); |
| 5518 | if (unlikely(!p)) |
| 5519 | goto out_overflow; |
| 5520 | pdev->mincount = be32_to_cpup(p); |
| 5521 | dprintk("%s: Min count too small. mincnt = %u\n", |
| 5522 | __func__, pdev->mincount); |
| 5523 | } |
| 5524 | return status; |
| 5525 | } |
| 5526 | |
| 5527 | p = xdr_inline_decode(xdr, 8); |
| 5528 | if (unlikely(!p)) |
| 5529 | goto out_overflow; |
| 5530 | type = be32_to_cpup(p++); |
| 5531 | if (type != pdev->layout_type) { |
| 5532 | dprintk("%s: layout mismatch req: %u pdev: %u\n", |
| 5533 | __func__, pdev->layout_type, type); |
| 5534 | return -EINVAL; |
| 5535 | } |
| 5536 | /* |
| 5537 | * Get the length of the opaque device_addr4. xdr_read_pages places |
| 5538 | * the opaque device_addr4 in the xdr_buf->pages (pnfs_device->pages) |
| 5539 | * and places the remaining xdr data in xdr_buf->tail |
| 5540 | */ |
| 5541 | pdev->mincount = be32_to_cpup(p); |
| 5542 | xdr_read_pages(xdr, pdev->mincount); /* include space for the length */ |
| 5543 | |
| 5544 | /* Parse notification bitmap, verifying that it is zero. */ |
| 5545 | p = xdr_inline_decode(xdr, 4); |
| 5546 | if (unlikely(!p)) |
| 5547 | goto out_overflow; |
| 5548 | len = be32_to_cpup(p); |
| 5549 | if (len) { |
Chuck Lever | ead0059 | 2010-12-14 14:58:21 +0000 | [diff] [blame] | 5550 | uint32_t i; |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 5551 | |
| 5552 | p = xdr_inline_decode(xdr, 4 * len); |
| 5553 | if (unlikely(!p)) |
| 5554 | goto out_overflow; |
| 5555 | for (i = 0; i < len; i++, p++) { |
| 5556 | if (be32_to_cpup(p)) { |
| 5557 | dprintk("%s: notifications not supported\n", |
| 5558 | __func__); |
| 5559 | return -EIO; |
| 5560 | } |
| 5561 | } |
| 5562 | } |
| 5563 | return 0; |
| 5564 | out_overflow: |
| 5565 | print_overflow_msg(__func__, xdr); |
| 5566 | return -EIO; |
| 5567 | } |
| 5568 | |
| 5569 | static int decode_layoutget(struct xdr_stream *xdr, struct rpc_rqst *req, |
| 5570 | struct nfs4_layoutget_res *res) |
| 5571 | { |
| 5572 | __be32 *p; |
| 5573 | int status; |
| 5574 | u32 layout_count; |
Weston Andros Adamson | 35124a0 | 2011-03-24 16:48:21 -0400 | [diff] [blame] | 5575 | struct xdr_buf *rcvbuf = &req->rq_rcv_buf; |
| 5576 | struct kvec *iov = rcvbuf->head; |
| 5577 | u32 hdrlen, recvd; |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 5578 | |
| 5579 | status = decode_op_hdr(xdr, OP_LAYOUTGET); |
| 5580 | if (status) |
| 5581 | return status; |
| 5582 | p = xdr_inline_decode(xdr, 8 + NFS4_STATEID_SIZE); |
| 5583 | if (unlikely(!p)) |
| 5584 | goto out_overflow; |
| 5585 | res->return_on_close = be32_to_cpup(p++); |
| 5586 | p = xdr_decode_opaque_fixed(p, res->stateid.data, NFS4_STATEID_SIZE); |
| 5587 | layout_count = be32_to_cpup(p); |
| 5588 | if (!layout_count) { |
| 5589 | dprintk("%s: server responded with empty layout array\n", |
| 5590 | __func__); |
| 5591 | return -EINVAL; |
| 5592 | } |
| 5593 | |
Weston Andros Adamson | 35124a0 | 2011-03-24 16:48:21 -0400 | [diff] [blame] | 5594 | p = xdr_inline_decode(xdr, 28); |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 5595 | if (unlikely(!p)) |
| 5596 | goto out_overflow; |
| 5597 | p = xdr_decode_hyper(p, &res->range.offset); |
| 5598 | p = xdr_decode_hyper(p, &res->range.length); |
| 5599 | res->range.iomode = be32_to_cpup(p++); |
| 5600 | res->type = be32_to_cpup(p++); |
Weston Andros Adamson | 35124a0 | 2011-03-24 16:48:21 -0400 | [diff] [blame] | 5601 | res->layoutp->len = be32_to_cpup(p); |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 5602 | |
| 5603 | dprintk("%s roff:%lu rlen:%lu riomode:%d, lo_type:0x%x, lo.len:%d\n", |
| 5604 | __func__, |
| 5605 | (unsigned long)res->range.offset, |
| 5606 | (unsigned long)res->range.length, |
| 5607 | res->range.iomode, |
| 5608 | res->type, |
Weston Andros Adamson | 35124a0 | 2011-03-24 16:48:21 -0400 | [diff] [blame] | 5609 | res->layoutp->len); |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 5610 | |
Weston Andros Adamson | 35124a0 | 2011-03-24 16:48:21 -0400 | [diff] [blame] | 5611 | hdrlen = (u8 *) xdr->p - (u8 *) iov->iov_base; |
| 5612 | recvd = req->rq_rcv_buf.len - hdrlen; |
| 5613 | if (res->layoutp->len > recvd) { |
| 5614 | dprintk("NFS: server cheating in layoutget reply: " |
| 5615 | "layout len %u > recvd %u\n", |
| 5616 | res->layoutp->len, recvd); |
| 5617 | return -EINVAL; |
| 5618 | } |
| 5619 | |
| 5620 | xdr_read_pages(xdr, res->layoutp->len); |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 5621 | |
| 5622 | if (layout_count > 1) { |
| 5623 | /* We only handle a length one array at the moment. Any |
| 5624 | * further entries are just ignored. Note that this means |
| 5625 | * the client may see a response that is less than the |
| 5626 | * minimum it requested. |
| 5627 | */ |
| 5628 | dprintk("%s: server responded with %d layouts, dropping tail\n", |
| 5629 | __func__, layout_count); |
| 5630 | } |
| 5631 | |
| 5632 | return 0; |
| 5633 | out_overflow: |
| 5634 | print_overflow_msg(__func__, xdr); |
| 5635 | return -EIO; |
| 5636 | } |
Andy Adamson | 863a3c6 | 2011-03-23 13:27:54 +0000 | [diff] [blame] | 5637 | |
Benny Halevy | cbe8260 | 2011-05-22 19:52:37 +0300 | [diff] [blame] | 5638 | static int decode_layoutreturn(struct xdr_stream *xdr, |
| 5639 | struct nfs4_layoutreturn_res *res) |
| 5640 | { |
| 5641 | __be32 *p; |
| 5642 | int status; |
| 5643 | |
| 5644 | status = decode_op_hdr(xdr, OP_LAYOUTRETURN); |
| 5645 | if (status) |
| 5646 | return status; |
| 5647 | p = xdr_inline_decode(xdr, 4); |
| 5648 | if (unlikely(!p)) |
| 5649 | goto out_overflow; |
| 5650 | res->lrs_present = be32_to_cpup(p); |
| 5651 | if (res->lrs_present) |
| 5652 | status = decode_stateid(xdr, &res->stateid); |
| 5653 | return status; |
| 5654 | out_overflow: |
| 5655 | print_overflow_msg(__func__, xdr); |
| 5656 | return -EIO; |
| 5657 | } |
| 5658 | |
Andy Adamson | 863a3c6 | 2011-03-23 13:27:54 +0000 | [diff] [blame] | 5659 | static int decode_layoutcommit(struct xdr_stream *xdr, |
| 5660 | struct rpc_rqst *req, |
| 5661 | struct nfs4_layoutcommit_res *res) |
| 5662 | { |
| 5663 | __be32 *p; |
| 5664 | __u32 sizechanged; |
| 5665 | int status; |
| 5666 | |
| 5667 | status = decode_op_hdr(xdr, OP_LAYOUTCOMMIT); |
Andy Adamson | db29c08 | 2011-07-30 20:52:38 -0400 | [diff] [blame] | 5668 | res->status = status; |
Andy Adamson | 863a3c6 | 2011-03-23 13:27:54 +0000 | [diff] [blame] | 5669 | if (status) |
| 5670 | return status; |
| 5671 | |
| 5672 | p = xdr_inline_decode(xdr, 4); |
| 5673 | if (unlikely(!p)) |
| 5674 | goto out_overflow; |
| 5675 | sizechanged = be32_to_cpup(p); |
| 5676 | |
| 5677 | if (sizechanged) { |
| 5678 | /* throw away new size */ |
| 5679 | p = xdr_inline_decode(xdr, 8); |
| 5680 | if (unlikely(!p)) |
| 5681 | goto out_overflow; |
| 5682 | } |
| 5683 | return 0; |
| 5684 | out_overflow: |
| 5685 | print_overflow_msg(__func__, xdr); |
| 5686 | return -EIO; |
| 5687 | } |
Bryan Schumaker | 7d97479 | 2011-06-02 14:59:08 -0400 | [diff] [blame] | 5688 | |
| 5689 | static int decode_test_stateid(struct xdr_stream *xdr, |
| 5690 | struct nfs41_test_stateid_res *res) |
| 5691 | { |
| 5692 | __be32 *p; |
| 5693 | int status; |
| 5694 | int num_res; |
| 5695 | |
| 5696 | status = decode_op_hdr(xdr, OP_TEST_STATEID); |
| 5697 | if (status) |
| 5698 | return status; |
| 5699 | |
| 5700 | p = xdr_inline_decode(xdr, 4); |
| 5701 | if (unlikely(!p)) |
| 5702 | goto out_overflow; |
| 5703 | num_res = be32_to_cpup(p++); |
| 5704 | if (num_res != 1) |
| 5705 | goto out; |
| 5706 | |
| 5707 | p = xdr_inline_decode(xdr, 4); |
| 5708 | if (unlikely(!p)) |
| 5709 | goto out_overflow; |
| 5710 | res->status = be32_to_cpup(p++); |
Bryan Schumaker | 1cab065 | 2012-01-31 10:39:29 -0500 | [diff] [blame] | 5711 | |
| 5712 | return status; |
Bryan Schumaker | 7d97479 | 2011-06-02 14:59:08 -0400 | [diff] [blame] | 5713 | out_overflow: |
| 5714 | print_overflow_msg(__func__, xdr); |
| 5715 | out: |
| 5716 | return -EIO; |
| 5717 | } |
Bryan Schumaker | 9aeda35 | 2011-06-02 14:59:09 -0400 | [diff] [blame] | 5718 | |
| 5719 | static int decode_free_stateid(struct xdr_stream *xdr, |
| 5720 | struct nfs41_free_stateid_res *res) |
| 5721 | { |
| 5722 | __be32 *p; |
| 5723 | int status; |
| 5724 | |
| 5725 | status = decode_op_hdr(xdr, OP_FREE_STATEID); |
| 5726 | if (status) |
| 5727 | return status; |
| 5728 | |
| 5729 | p = xdr_inline_decode(xdr, 4); |
| 5730 | if (unlikely(!p)) |
| 5731 | goto out_overflow; |
| 5732 | res->status = be32_to_cpup(p++); |
| 5733 | return res->status; |
| 5734 | out_overflow: |
| 5735 | print_overflow_msg(__func__, xdr); |
| 5736 | return -EIO; |
| 5737 | } |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 5738 | #endif /* CONFIG_NFS_V4_1 */ |
| 5739 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5740 | /* |
Benny Halevy | 49c2559 | 2008-12-23 16:06:16 -0500 | [diff] [blame] | 5741 | * END OF "GENERIC" DECODE ROUTINES. |
| 5742 | */ |
| 5743 | |
| 5744 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5745 | * Decode OPEN_DOWNGRADE response |
| 5746 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 5747 | static int nfs4_xdr_dec_open_downgrade(struct rpc_rqst *rqstp, |
| 5748 | struct xdr_stream *xdr, |
| 5749 | struct nfs_closeres *res) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5750 | { |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 5751 | struct compound_hdr hdr; |
| 5752 | int status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5753 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 5754 | status = decode_compound_hdr(xdr, &hdr); |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 5755 | if (status) |
| 5756 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 5757 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 5758 | if (status) |
| 5759 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 5760 | status = decode_putfh(xdr); |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 5761 | if (status) |
| 5762 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 5763 | status = decode_open_downgrade(xdr, res); |
Trond Myklebust | 516a6af | 2005-10-27 22:12:41 -0400 | [diff] [blame] | 5764 | if (status != 0) |
| 5765 | goto out; |
Trond Myklebust | 6926afd | 2012-01-07 13:22:46 -0500 | [diff] [blame] | 5766 | decode_getfattr(xdr, res->fattr, res->server); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5767 | out: |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 5768 | return status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5769 | } |
| 5770 | |
| 5771 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5772 | * Decode ACCESS response |
| 5773 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 5774 | static int nfs4_xdr_dec_access(struct rpc_rqst *rqstp, struct xdr_stream *xdr, |
| 5775 | struct nfs4_accessres *res) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5776 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5777 | struct compound_hdr hdr; |
| 5778 | int status; |
Andy Adamson | 6c0195a | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 5779 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 5780 | status = decode_compound_hdr(xdr, &hdr); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 5781 | if (status) |
| 5782 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 5783 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 5784 | if (status) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5785 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 5786 | status = decode_putfh(xdr); |
Trond Myklebust | 76b3299 | 2007-08-10 17:45:11 -0400 | [diff] [blame] | 5787 | if (status != 0) |
| 5788 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 5789 | status = decode_access(xdr, res); |
Trond Myklebust | 76b3299 | 2007-08-10 17:45:11 -0400 | [diff] [blame] | 5790 | if (status != 0) |
| 5791 | goto out; |
Trond Myklebust | 6926afd | 2012-01-07 13:22:46 -0500 | [diff] [blame] | 5792 | decode_getfattr(xdr, res->fattr, res->server); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5793 | out: |
| 5794 | return status; |
| 5795 | } |
| 5796 | |
| 5797 | /* |
| 5798 | * Decode LOOKUP response |
| 5799 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 5800 | static int nfs4_xdr_dec_lookup(struct rpc_rqst *rqstp, struct xdr_stream *xdr, |
| 5801 | struct nfs4_lookup_res *res) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5802 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5803 | struct compound_hdr hdr; |
| 5804 | int status; |
Andy Adamson | 6c0195a | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 5805 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 5806 | status = decode_compound_hdr(xdr, &hdr); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 5807 | if (status) |
| 5808 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 5809 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 5810 | if (status) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5811 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 5812 | status = decode_putfh(xdr); |
| 5813 | if (status) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5814 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 5815 | status = decode_lookup(xdr); |
| 5816 | if (status) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5817 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 5818 | status = decode_getfh(xdr, res->fh); |
| 5819 | if (status) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5820 | goto out; |
Trond Myklebust | 6926afd | 2012-01-07 13:22:46 -0500 | [diff] [blame] | 5821 | status = decode_getfattr(xdr, res->fattr, res->server); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5822 | out: |
| 5823 | return status; |
| 5824 | } |
| 5825 | |
| 5826 | /* |
| 5827 | * Decode LOOKUP_ROOT response |
| 5828 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 5829 | static int nfs4_xdr_dec_lookup_root(struct rpc_rqst *rqstp, |
| 5830 | struct xdr_stream *xdr, |
| 5831 | struct nfs4_lookup_res *res) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5832 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5833 | struct compound_hdr hdr; |
| 5834 | int status; |
Andy Adamson | 6c0195a | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 5835 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 5836 | status = decode_compound_hdr(xdr, &hdr); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 5837 | if (status) |
| 5838 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 5839 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 5840 | if (status) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5841 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 5842 | status = decode_putrootfh(xdr); |
| 5843 | if (status) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5844 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 5845 | status = decode_getfh(xdr, res->fh); |
| 5846 | if (status == 0) |
Trond Myklebust | 6926afd | 2012-01-07 13:22:46 -0500 | [diff] [blame] | 5847 | status = decode_getfattr(xdr, res->fattr, res->server); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5848 | out: |
| 5849 | return status; |
| 5850 | } |
| 5851 | |
| 5852 | /* |
| 5853 | * Decode REMOVE response |
| 5854 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 5855 | static int nfs4_xdr_dec_remove(struct rpc_rqst *rqstp, struct xdr_stream *xdr, |
| 5856 | struct nfs_removeres *res) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5857 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5858 | struct compound_hdr hdr; |
| 5859 | int status; |
Andy Adamson | 6c0195a | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 5860 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 5861 | status = decode_compound_hdr(xdr, &hdr); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 5862 | if (status) |
| 5863 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 5864 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 5865 | if (status) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5866 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 5867 | status = decode_putfh(xdr); |
| 5868 | if (status) |
Trond Myklebust | 16e4295 | 2005-10-27 22:12:44 -0400 | [diff] [blame] | 5869 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 5870 | status = decode_remove(xdr, &res->cinfo); |
| 5871 | if (status) |
Trond Myklebust | 16e4295 | 2005-10-27 22:12:44 -0400 | [diff] [blame] | 5872 | goto out; |
Trond Myklebust | 6926afd | 2012-01-07 13:22:46 -0500 | [diff] [blame] | 5873 | decode_getfattr(xdr, res->dir_attr, res->server); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5874 | out: |
| 5875 | return status; |
| 5876 | } |
| 5877 | |
| 5878 | /* |
| 5879 | * Decode RENAME response |
| 5880 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 5881 | static int nfs4_xdr_dec_rename(struct rpc_rqst *rqstp, struct xdr_stream *xdr, |
| 5882 | struct nfs_renameres *res) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5883 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5884 | struct compound_hdr hdr; |
| 5885 | int status; |
Andy Adamson | 6c0195a | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 5886 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 5887 | status = decode_compound_hdr(xdr, &hdr); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 5888 | if (status) |
| 5889 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 5890 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 5891 | if (status) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5892 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 5893 | status = decode_putfh(xdr); |
| 5894 | if (status) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5895 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 5896 | status = decode_savefh(xdr); |
| 5897 | if (status) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5898 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 5899 | status = decode_putfh(xdr); |
| 5900 | if (status) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5901 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 5902 | status = decode_rename(xdr, &res->old_cinfo, &res->new_cinfo); |
| 5903 | if (status) |
Trond Myklebust | 6caf2c8 | 2005-10-27 22:12:43 -0400 | [diff] [blame] | 5904 | goto out; |
| 5905 | /* Current FH is target directory */ |
Trond Myklebust | 6926afd | 2012-01-07 13:22:46 -0500 | [diff] [blame] | 5906 | if (decode_getfattr(xdr, res->new_fattr, res->server)) |
Trond Myklebust | 6caf2c8 | 2005-10-27 22:12:43 -0400 | [diff] [blame] | 5907 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 5908 | status = decode_restorefh(xdr); |
| 5909 | if (status) |
Trond Myklebust | 6caf2c8 | 2005-10-27 22:12:43 -0400 | [diff] [blame] | 5910 | goto out; |
Trond Myklebust | 6926afd | 2012-01-07 13:22:46 -0500 | [diff] [blame] | 5911 | decode_getfattr(xdr, res->old_fattr, res->server); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5912 | out: |
| 5913 | return status; |
| 5914 | } |
| 5915 | |
| 5916 | /* |
| 5917 | * Decode LINK response |
| 5918 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 5919 | static int nfs4_xdr_dec_link(struct rpc_rqst *rqstp, struct xdr_stream *xdr, |
| 5920 | struct nfs4_link_res *res) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5921 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5922 | struct compound_hdr hdr; |
| 5923 | int status; |
Andy Adamson | 6c0195a | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 5924 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 5925 | status = decode_compound_hdr(xdr, &hdr); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 5926 | if (status) |
| 5927 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 5928 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 5929 | if (status) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5930 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 5931 | status = decode_putfh(xdr); |
| 5932 | if (status) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5933 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 5934 | status = decode_savefh(xdr); |
| 5935 | if (status) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5936 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 5937 | status = decode_putfh(xdr); |
| 5938 | if (status) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5939 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 5940 | status = decode_link(xdr, &res->cinfo); |
| 5941 | if (status) |
Trond Myklebust | 91ba2ee | 2005-10-27 22:12:42 -0400 | [diff] [blame] | 5942 | goto out; |
| 5943 | /* |
| 5944 | * Note order: OP_LINK leaves the directory as the current |
| 5945 | * filehandle. |
| 5946 | */ |
Trond Myklebust | 6926afd | 2012-01-07 13:22:46 -0500 | [diff] [blame] | 5947 | if (decode_getfattr(xdr, res->dir_attr, res->server)) |
Trond Myklebust | 91ba2ee | 2005-10-27 22:12:42 -0400 | [diff] [blame] | 5948 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 5949 | status = decode_restorefh(xdr); |
| 5950 | if (status) |
Trond Myklebust | 91ba2ee | 2005-10-27 22:12:42 -0400 | [diff] [blame] | 5951 | goto out; |
Trond Myklebust | 6926afd | 2012-01-07 13:22:46 -0500 | [diff] [blame] | 5952 | decode_getfattr(xdr, res->fattr, res->server); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5953 | out: |
| 5954 | return status; |
| 5955 | } |
| 5956 | |
| 5957 | /* |
| 5958 | * Decode CREATE response |
| 5959 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 5960 | static int nfs4_xdr_dec_create(struct rpc_rqst *rqstp, struct xdr_stream *xdr, |
| 5961 | struct nfs4_create_res *res) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5962 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5963 | struct compound_hdr hdr; |
| 5964 | int status; |
Andy Adamson | 6c0195a | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 5965 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 5966 | status = decode_compound_hdr(xdr, &hdr); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 5967 | if (status) |
| 5968 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 5969 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 5970 | if (status) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5971 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 5972 | status = decode_putfh(xdr); |
| 5973 | if (status) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5974 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 5975 | status = decode_savefh(xdr); |
| 5976 | if (status) |
Trond Myklebust | 56ae19f | 2005-10-27 22:12:40 -0400 | [diff] [blame] | 5977 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 5978 | status = decode_create(xdr, &res->dir_cinfo); |
| 5979 | if (status) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5980 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 5981 | status = decode_getfh(xdr, res->fh); |
| 5982 | if (status) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5983 | goto out; |
Trond Myklebust | 6926afd | 2012-01-07 13:22:46 -0500 | [diff] [blame] | 5984 | if (decode_getfattr(xdr, res->fattr, res->server)) |
Trond Myklebust | 56ae19f | 2005-10-27 22:12:40 -0400 | [diff] [blame] | 5985 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 5986 | status = decode_restorefh(xdr); |
| 5987 | if (status) |
Trond Myklebust | 56ae19f | 2005-10-27 22:12:40 -0400 | [diff] [blame] | 5988 | goto out; |
Trond Myklebust | 6926afd | 2012-01-07 13:22:46 -0500 | [diff] [blame] | 5989 | decode_getfattr(xdr, res->dir_fattr, res->server); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5990 | out: |
| 5991 | return status; |
| 5992 | } |
| 5993 | |
| 5994 | /* |
| 5995 | * Decode SYMLINK response |
| 5996 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 5997 | static int nfs4_xdr_dec_symlink(struct rpc_rqst *rqstp, struct xdr_stream *xdr, |
| 5998 | struct nfs4_create_res *res) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5999 | { |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6000 | return nfs4_xdr_dec_create(rqstp, xdr, res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6001 | } |
| 6002 | |
| 6003 | /* |
| 6004 | * Decode GETATTR response |
| 6005 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6006 | static int nfs4_xdr_dec_getattr(struct rpc_rqst *rqstp, struct xdr_stream *xdr, |
| 6007 | struct nfs4_getattr_res *res) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6008 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6009 | struct compound_hdr hdr; |
| 6010 | int status; |
Andy Adamson | 6c0195a | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6011 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6012 | status = decode_compound_hdr(xdr, &hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6013 | if (status) |
| 6014 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6015 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6016 | if (status) |
| 6017 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6018 | status = decode_putfh(xdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6019 | if (status) |
| 6020 | goto out; |
Trond Myklebust | 6926afd | 2012-01-07 13:22:46 -0500 | [diff] [blame] | 6021 | status = decode_getfattr(xdr, res->fattr, res->server); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6022 | out: |
| 6023 | return status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6024 | } |
| 6025 | |
J. Bruce Fields | 23ec696 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 6026 | /* |
| 6027 | * Encode an SETACL request |
| 6028 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 6029 | static void nfs4_xdr_enc_setacl(struct rpc_rqst *req, struct xdr_stream *xdr, |
| 6030 | struct nfs_setaclargs *args) |
J. Bruce Fields | 23ec696 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 6031 | { |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6032 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 6033 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6034 | }; |
J. Bruce Fields | 23ec696 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 6035 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 6036 | encode_compound_hdr(xdr, req, &hdr); |
| 6037 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 6038 | encode_putfh(xdr, args->fh, &hdr); |
| 6039 | encode_setacl(xdr, args, &hdr); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 6040 | encode_nops(&hdr); |
J. Bruce Fields | 23ec696 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 6041 | } |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6042 | |
J. Bruce Fields | 23ec696 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 6043 | /* |
| 6044 | * Decode SETACL response |
| 6045 | */ |
| 6046 | static int |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6047 | nfs4_xdr_dec_setacl(struct rpc_rqst *rqstp, struct xdr_stream *xdr, |
Benny Halevy | 73c403a | 2009-04-01 09:22:01 -0400 | [diff] [blame] | 6048 | struct nfs_setaclres *res) |
J. Bruce Fields | 23ec696 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 6049 | { |
J. Bruce Fields | 23ec696 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 6050 | struct compound_hdr hdr; |
| 6051 | int status; |
| 6052 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6053 | status = decode_compound_hdr(xdr, &hdr); |
J. Bruce Fields | 23ec696 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 6054 | if (status) |
| 6055 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6056 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6057 | if (status) |
| 6058 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6059 | status = decode_putfh(xdr); |
J. Bruce Fields | 23ec696 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 6060 | if (status) |
| 6061 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6062 | status = decode_setattr(xdr); |
J. Bruce Fields | 23ec696 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 6063 | out: |
| 6064 | return status; |
| 6065 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6066 | |
| 6067 | /* |
J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 6068 | * Decode GETACL response |
| 6069 | */ |
| 6070 | static int |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6071 | nfs4_xdr_dec_getacl(struct rpc_rqst *rqstp, struct xdr_stream *xdr, |
Benny Halevy | 663c79b | 2009-04-01 09:21:59 -0400 | [diff] [blame] | 6072 | struct nfs_getaclres *res) |
J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 6073 | { |
J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 6074 | struct compound_hdr hdr; |
| 6075 | int status; |
| 6076 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6077 | status = decode_compound_hdr(xdr, &hdr); |
J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 6078 | if (status) |
| 6079 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6080 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6081 | if (status) |
| 6082 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6083 | status = decode_putfh(xdr); |
J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 6084 | if (status) |
| 6085 | goto out; |
Andy Adamson | bf118a3 | 2011-12-07 11:55:27 -0500 | [diff] [blame] | 6086 | status = decode_getacl(xdr, rqstp, res); |
J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 6087 | |
| 6088 | out: |
| 6089 | return status; |
| 6090 | } |
| 6091 | |
| 6092 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6093 | * Decode CLOSE response |
| 6094 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6095 | static int nfs4_xdr_dec_close(struct rpc_rqst *rqstp, struct xdr_stream *xdr, |
| 6096 | struct nfs_closeres *res) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6097 | { |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6098 | struct compound_hdr hdr; |
| 6099 | int status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6100 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6101 | status = decode_compound_hdr(xdr, &hdr); |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6102 | if (status) |
| 6103 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6104 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6105 | if (status) |
| 6106 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6107 | status = decode_putfh(xdr); |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6108 | if (status) |
| 6109 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6110 | status = decode_close(xdr, res); |
Trond Myklebust | 516a6af | 2005-10-27 22:12:41 -0400 | [diff] [blame] | 6111 | if (status != 0) |
| 6112 | goto out; |
| 6113 | /* |
| 6114 | * Note: Server may do delete on close for this file |
| 6115 | * in which case the getattr call will fail with |
| 6116 | * an ESTALE error. Shouldn't be a problem, |
| 6117 | * though, since fattr->valid will remain unset. |
| 6118 | */ |
Trond Myklebust | 6926afd | 2012-01-07 13:22:46 -0500 | [diff] [blame] | 6119 | decode_getfattr(xdr, res->fattr, res->server); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6120 | out: |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6121 | return status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6122 | } |
| 6123 | |
| 6124 | /* |
| 6125 | * Decode OPEN response |
| 6126 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6127 | static int nfs4_xdr_dec_open(struct rpc_rqst *rqstp, struct xdr_stream *xdr, |
| 6128 | struct nfs_openres *res) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6129 | { |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6130 | struct compound_hdr hdr; |
| 6131 | int status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6132 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6133 | status = decode_compound_hdr(xdr, &hdr); |
Trond Myklebust | 56ae19f | 2005-10-27 22:12:40 -0400 | [diff] [blame] | 6134 | if (status) |
| 6135 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6136 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6137 | if (status) |
| 6138 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6139 | status = decode_putfh(xdr); |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6140 | if (status) |
| 6141 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6142 | status = decode_savefh(xdr); |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6143 | if (status) |
| 6144 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6145 | status = decode_open(xdr, res); |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6146 | if (status) |
| 6147 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6148 | if (decode_getfh(xdr, &res->fh) != 0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6149 | goto out; |
Trond Myklebust | 6926afd | 2012-01-07 13:22:46 -0500 | [diff] [blame] | 6150 | if (decode_getfattr(xdr, res->f_attr, res->server) != 0) |
Trond Myklebust | 56ae19f | 2005-10-27 22:12:40 -0400 | [diff] [blame] | 6151 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6152 | if (decode_restorefh(xdr) != 0) |
Trond Myklebust | 56ae19f | 2005-10-27 22:12:40 -0400 | [diff] [blame] | 6153 | goto out; |
Trond Myklebust | 6926afd | 2012-01-07 13:22:46 -0500 | [diff] [blame] | 6154 | decode_getfattr(xdr, res->dir_attr, res->server); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6155 | out: |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6156 | return status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6157 | } |
| 6158 | |
| 6159 | /* |
| 6160 | * Decode OPEN_CONFIRM response |
| 6161 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6162 | static int nfs4_xdr_dec_open_confirm(struct rpc_rqst *rqstp, |
| 6163 | struct xdr_stream *xdr, |
| 6164 | struct nfs_open_confirmres *res) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6165 | { |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6166 | struct compound_hdr hdr; |
| 6167 | int status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6168 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6169 | status = decode_compound_hdr(xdr, &hdr); |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6170 | if (status) |
| 6171 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6172 | status = decode_putfh(xdr); |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6173 | if (status) |
| 6174 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6175 | status = decode_open_confirm(xdr, res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6176 | out: |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6177 | return status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6178 | } |
| 6179 | |
| 6180 | /* |
| 6181 | * Decode OPEN response |
| 6182 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6183 | static int nfs4_xdr_dec_open_noattr(struct rpc_rqst *rqstp, |
| 6184 | struct xdr_stream *xdr, |
| 6185 | struct nfs_openres *res) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6186 | { |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6187 | struct compound_hdr hdr; |
| 6188 | int status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6189 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6190 | status = decode_compound_hdr(xdr, &hdr); |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6191 | if (status) |
| 6192 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6193 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6194 | if (status) |
| 6195 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6196 | status = decode_putfh(xdr); |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6197 | if (status) |
| 6198 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6199 | status = decode_open(xdr, res); |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6200 | if (status) |
| 6201 | goto out; |
Trond Myklebust | 6926afd | 2012-01-07 13:22:46 -0500 | [diff] [blame] | 6202 | decode_getfattr(xdr, res->f_attr, res->server); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6203 | out: |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6204 | return status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6205 | } |
| 6206 | |
| 6207 | /* |
| 6208 | * Decode SETATTR response |
| 6209 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6210 | static int nfs4_xdr_dec_setattr(struct rpc_rqst *rqstp, |
| 6211 | struct xdr_stream *xdr, |
| 6212 | struct nfs_setattrres *res) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6213 | { |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6214 | struct compound_hdr hdr; |
| 6215 | int status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6216 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6217 | status = decode_compound_hdr(xdr, &hdr); |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6218 | if (status) |
| 6219 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6220 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6221 | if (status) |
| 6222 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6223 | status = decode_putfh(xdr); |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6224 | if (status) |
| 6225 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6226 | status = decode_setattr(xdr); |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6227 | if (status) |
| 6228 | goto out; |
Trond Myklebust | 6926afd | 2012-01-07 13:22:46 -0500 | [diff] [blame] | 6229 | decode_getfattr(xdr, res->fattr, res->server); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6230 | out: |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6231 | return status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6232 | } |
| 6233 | |
| 6234 | /* |
| 6235 | * Decode LOCK response |
| 6236 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6237 | static int nfs4_xdr_dec_lock(struct rpc_rqst *rqstp, struct xdr_stream *xdr, |
| 6238 | struct nfs_lock_res *res) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6239 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6240 | struct compound_hdr hdr; |
| 6241 | int status; |
| 6242 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6243 | status = decode_compound_hdr(xdr, &hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6244 | if (status) |
| 6245 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6246 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6247 | if (status) |
| 6248 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6249 | status = decode_putfh(xdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6250 | if (status) |
| 6251 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6252 | status = decode_lock(xdr, res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6253 | out: |
| 6254 | return status; |
| 6255 | } |
| 6256 | |
| 6257 | /* |
| 6258 | * Decode LOCKT response |
| 6259 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6260 | static int nfs4_xdr_dec_lockt(struct rpc_rqst *rqstp, struct xdr_stream *xdr, |
| 6261 | struct nfs_lockt_res *res) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6262 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6263 | struct compound_hdr hdr; |
| 6264 | int status; |
| 6265 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6266 | status = decode_compound_hdr(xdr, &hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6267 | if (status) |
| 6268 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6269 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6270 | if (status) |
| 6271 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6272 | status = decode_putfh(xdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6273 | if (status) |
| 6274 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6275 | status = decode_lockt(xdr, res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6276 | out: |
| 6277 | return status; |
| 6278 | } |
| 6279 | |
| 6280 | /* |
| 6281 | * Decode LOCKU response |
| 6282 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6283 | static int nfs4_xdr_dec_locku(struct rpc_rqst *rqstp, struct xdr_stream *xdr, |
| 6284 | struct nfs_locku_res *res) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6285 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6286 | struct compound_hdr hdr; |
| 6287 | int status; |
| 6288 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6289 | status = decode_compound_hdr(xdr, &hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6290 | if (status) |
| 6291 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6292 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6293 | if (status) |
| 6294 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6295 | status = decode_putfh(xdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6296 | if (status) |
| 6297 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6298 | status = decode_locku(xdr, res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6299 | out: |
| 6300 | return status; |
| 6301 | } |
| 6302 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6303 | static int nfs4_xdr_dec_release_lockowner(struct rpc_rqst *rqstp, |
| 6304 | struct xdr_stream *xdr, void *dummy) |
Trond Myklebust | d3c7b7c | 2010-07-01 12:49:01 -0400 | [diff] [blame] | 6305 | { |
Trond Myklebust | d3c7b7c | 2010-07-01 12:49:01 -0400 | [diff] [blame] | 6306 | struct compound_hdr hdr; |
| 6307 | int status; |
| 6308 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6309 | status = decode_compound_hdr(xdr, &hdr); |
Trond Myklebust | d3c7b7c | 2010-07-01 12:49:01 -0400 | [diff] [blame] | 6310 | if (!status) |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6311 | status = decode_release_lockowner(xdr); |
Trond Myklebust | d3c7b7c | 2010-07-01 12:49:01 -0400 | [diff] [blame] | 6312 | return status; |
| 6313 | } |
| 6314 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6315 | /* |
| 6316 | * Decode READLINK response |
| 6317 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6318 | static int nfs4_xdr_dec_readlink(struct rpc_rqst *rqstp, |
| 6319 | struct xdr_stream *xdr, |
Benny Halevy | f50c700 | 2009-04-01 09:21:55 -0400 | [diff] [blame] | 6320 | struct nfs4_readlink_res *res) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6321 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6322 | struct compound_hdr hdr; |
| 6323 | int status; |
| 6324 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6325 | status = decode_compound_hdr(xdr, &hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6326 | if (status) |
| 6327 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6328 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6329 | if (status) |
| 6330 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6331 | status = decode_putfh(xdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6332 | if (status) |
| 6333 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6334 | status = decode_readlink(xdr, rqstp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6335 | out: |
| 6336 | return status; |
| 6337 | } |
| 6338 | |
| 6339 | /* |
| 6340 | * Decode READDIR response |
| 6341 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6342 | static int nfs4_xdr_dec_readdir(struct rpc_rqst *rqstp, struct xdr_stream *xdr, |
| 6343 | struct nfs4_readdir_res *res) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6344 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6345 | struct compound_hdr hdr; |
| 6346 | int status; |
| 6347 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6348 | status = decode_compound_hdr(xdr, &hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6349 | if (status) |
| 6350 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6351 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6352 | if (status) |
| 6353 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6354 | status = decode_putfh(xdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6355 | if (status) |
| 6356 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6357 | status = decode_readdir(xdr, rqstp, res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6358 | out: |
| 6359 | return status; |
| 6360 | } |
| 6361 | |
| 6362 | /* |
| 6363 | * Decode Read response |
| 6364 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6365 | static int nfs4_xdr_dec_read(struct rpc_rqst *rqstp, struct xdr_stream *xdr, |
| 6366 | struct nfs_readres *res) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6367 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6368 | struct compound_hdr hdr; |
| 6369 | int status; |
| 6370 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6371 | status = decode_compound_hdr(xdr, &hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6372 | if (status) |
| 6373 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6374 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6375 | if (status) |
| 6376 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6377 | status = decode_putfh(xdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6378 | if (status) |
| 6379 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6380 | status = decode_read(xdr, rqstp, res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6381 | if (!status) |
| 6382 | status = res->count; |
| 6383 | out: |
| 6384 | return status; |
| 6385 | } |
| 6386 | |
| 6387 | /* |
| 6388 | * Decode WRITE response |
| 6389 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6390 | static int nfs4_xdr_dec_write(struct rpc_rqst *rqstp, struct xdr_stream *xdr, |
| 6391 | struct nfs_writeres *res) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6392 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6393 | struct compound_hdr hdr; |
| 6394 | int status; |
| 6395 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6396 | status = decode_compound_hdr(xdr, &hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6397 | if (status) |
| 6398 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6399 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6400 | if (status) |
| 6401 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6402 | status = decode_putfh(xdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6403 | if (status) |
| 6404 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6405 | status = decode_write(xdr, res); |
Trond Myklebust | 4f9838c | 2005-10-27 22:12:44 -0400 | [diff] [blame] | 6406 | if (status) |
| 6407 | goto out; |
Fred Isaman | 7ffd106 | 2011-03-03 15:13:46 +0000 | [diff] [blame] | 6408 | if (res->fattr) |
Trond Myklebust | 6926afd | 2012-01-07 13:22:46 -0500 | [diff] [blame] | 6409 | decode_getfattr(xdr, res->fattr, res->server); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6410 | if (!status) |
| 6411 | status = res->count; |
| 6412 | out: |
| 6413 | return status; |
| 6414 | } |
| 6415 | |
| 6416 | /* |
| 6417 | * Decode COMMIT response |
| 6418 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6419 | static int nfs4_xdr_dec_commit(struct rpc_rqst *rqstp, struct xdr_stream *xdr, |
| 6420 | struct nfs_writeres *res) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6421 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6422 | struct compound_hdr hdr; |
| 6423 | int status; |
| 6424 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6425 | status = decode_compound_hdr(xdr, &hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6426 | if (status) |
| 6427 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6428 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6429 | if (status) |
| 6430 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6431 | status = decode_putfh(xdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6432 | if (status) |
| 6433 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6434 | status = decode_commit(xdr, res); |
Trond Myklebust | 4f9838c | 2005-10-27 22:12:44 -0400 | [diff] [blame] | 6435 | if (status) |
| 6436 | goto out; |
Fred Isaman | 988b6dc | 2011-03-23 13:27:52 +0000 | [diff] [blame] | 6437 | if (res->fattr) |
Trond Myklebust | 6926afd | 2012-01-07 13:22:46 -0500 | [diff] [blame] | 6438 | decode_getfattr(xdr, res->fattr, res->server); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6439 | out: |
| 6440 | return status; |
| 6441 | } |
| 6442 | |
| 6443 | /* |
Ricardo Labiaga | 8b17321 | 2009-12-05 16:08:39 -0500 | [diff] [blame] | 6444 | * Decode FSINFO response |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6445 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6446 | 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] | 6447 | struct nfs4_fsinfo_res *res) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6448 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6449 | struct compound_hdr hdr; |
| 6450 | int status; |
| 6451 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6452 | status = decode_compound_hdr(xdr, &hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6453 | if (!status) |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6454 | status = decode_sequence(xdr, &res->seq_res, req); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6455 | if (!status) |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6456 | status = decode_putfh(xdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6457 | if (!status) |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6458 | status = decode_fsinfo(xdr, res->fsinfo); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6459 | return status; |
| 6460 | } |
| 6461 | |
| 6462 | /* |
Ricardo Labiaga | 8b17321 | 2009-12-05 16:08:39 -0500 | [diff] [blame] | 6463 | * Decode PATHCONF response |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6464 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6465 | 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] | 6466 | struct nfs4_pathconf_res *res) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6467 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6468 | struct compound_hdr hdr; |
| 6469 | int status; |
| 6470 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6471 | status = decode_compound_hdr(xdr, &hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6472 | if (!status) |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6473 | status = decode_sequence(xdr, &res->seq_res, req); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6474 | if (!status) |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6475 | status = decode_putfh(xdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6476 | if (!status) |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6477 | status = decode_pathconf(xdr, res->pathconf); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6478 | return status; |
| 6479 | } |
| 6480 | |
| 6481 | /* |
Ricardo Labiaga | 8b17321 | 2009-12-05 16:08:39 -0500 | [diff] [blame] | 6482 | * Decode STATFS response |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6483 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6484 | 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] | 6485 | struct nfs4_statfs_res *res) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6486 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6487 | struct compound_hdr hdr; |
| 6488 | int status; |
| 6489 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6490 | status = decode_compound_hdr(xdr, &hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6491 | if (!status) |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6492 | status = decode_sequence(xdr, &res->seq_res, req); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6493 | if (!status) |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6494 | status = decode_putfh(xdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6495 | if (!status) |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6496 | status = decode_statfs(xdr, res->fsstat); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6497 | return status; |
| 6498 | } |
| 6499 | |
| 6500 | /* |
Ricardo Labiaga | 8b17321 | 2009-12-05 16:08:39 -0500 | [diff] [blame] | 6501 | * Decode GETATTR_BITMAP response |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6502 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6503 | static int nfs4_xdr_dec_server_caps(struct rpc_rqst *req, |
| 6504 | struct xdr_stream *xdr, |
| 6505 | struct nfs4_server_caps_res *res) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6506 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6507 | struct compound_hdr hdr; |
| 6508 | int status; |
| 6509 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6510 | status = decode_compound_hdr(xdr, &hdr); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6511 | if (status) |
| 6512 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6513 | status = decode_sequence(xdr, &res->seq_res, req); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6514 | if (status) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6515 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6516 | status = decode_putfh(xdr); |
| 6517 | if (status) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6518 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6519 | status = decode_server_caps(xdr, res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6520 | out: |
| 6521 | return status; |
| 6522 | } |
| 6523 | |
| 6524 | /* |
| 6525 | * Decode RENEW response |
| 6526 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6527 | static int nfs4_xdr_dec_renew(struct rpc_rqst *rqstp, struct xdr_stream *xdr, |
| 6528 | void *__unused) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6529 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6530 | struct compound_hdr hdr; |
| 6531 | int status; |
| 6532 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6533 | status = decode_compound_hdr(xdr, &hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6534 | if (!status) |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6535 | status = decode_renew(xdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6536 | return status; |
| 6537 | } |
| 6538 | |
| 6539 | /* |
Ricardo Labiaga | 8b17321 | 2009-12-05 16:08:39 -0500 | [diff] [blame] | 6540 | * Decode SETCLIENTID response |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6541 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6542 | static int nfs4_xdr_dec_setclientid(struct rpc_rqst *req, |
| 6543 | struct xdr_stream *xdr, |
| 6544 | struct nfs4_setclientid_res *res) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6545 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6546 | struct compound_hdr hdr; |
| 6547 | int status; |
| 6548 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6549 | status = decode_compound_hdr(xdr, &hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6550 | if (!status) |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6551 | status = decode_setclientid(xdr, res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6552 | return status; |
| 6553 | } |
| 6554 | |
| 6555 | /* |
Ricardo Labiaga | 8b17321 | 2009-12-05 16:08:39 -0500 | [diff] [blame] | 6556 | * Decode SETCLIENTID_CONFIRM response |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6557 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6558 | static int nfs4_xdr_dec_setclientid_confirm(struct rpc_rqst *req, |
| 6559 | struct xdr_stream *xdr, |
| 6560 | struct nfs_fsinfo *fsinfo) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6561 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6562 | struct compound_hdr hdr; |
| 6563 | int status; |
| 6564 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6565 | status = decode_compound_hdr(xdr, &hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6566 | if (!status) |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6567 | status = decode_setclientid_confirm(xdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6568 | if (!status) |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6569 | status = decode_putrootfh(xdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6570 | if (!status) |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6571 | status = decode_fsinfo(xdr, fsinfo); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6572 | return status; |
| 6573 | } |
| 6574 | |
| 6575 | /* |
Ricardo Labiaga | 8b17321 | 2009-12-05 16:08:39 -0500 | [diff] [blame] | 6576 | * Decode DELEGRETURN response |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6577 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6578 | static int nfs4_xdr_dec_delegreturn(struct rpc_rqst *rqstp, |
| 6579 | struct xdr_stream *xdr, |
| 6580 | struct nfs4_delegreturnres *res) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6581 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6582 | struct compound_hdr hdr; |
| 6583 | int status; |
| 6584 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6585 | status = decode_compound_hdr(xdr, &hdr); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6586 | if (status) |
| 6587 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6588 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6589 | if (status) |
Trond Myklebust | fa178f2 | 2006-01-03 09:55:38 +0100 | [diff] [blame] | 6590 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6591 | status = decode_putfh(xdr); |
Trond Myklebust | fa178f2 | 2006-01-03 09:55:38 +0100 | [diff] [blame] | 6592 | if (status != 0) |
| 6593 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6594 | status = decode_delegreturn(xdr); |
Jeff Layton | 556ae3b | 2010-03-21 12:10:36 -0400 | [diff] [blame] | 6595 | if (status != 0) |
| 6596 | goto out; |
Trond Myklebust | 6926afd | 2012-01-07 13:22:46 -0500 | [diff] [blame] | 6597 | decode_getfattr(xdr, res->fattr, res->server); |
Trond Myklebust | fa178f2 | 2006-01-03 09:55:38 +0100 | [diff] [blame] | 6598 | out: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6599 | return status; |
| 6600 | } |
| 6601 | |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 6602 | /* |
Ricardo Labiaga | 8b17321 | 2009-12-05 16:08:39 -0500 | [diff] [blame] | 6603 | * Decode FS_LOCATIONS response |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 6604 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6605 | static int nfs4_xdr_dec_fs_locations(struct rpc_rqst *req, |
| 6606 | struct xdr_stream *xdr, |
Benny Halevy | 2295846 | 2009-04-01 09:22:02 -0400 | [diff] [blame] | 6607 | struct nfs4_fs_locations_res *res) |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 6608 | { |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 6609 | struct compound_hdr hdr; |
| 6610 | int status; |
| 6611 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6612 | status = decode_compound_hdr(xdr, &hdr); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6613 | if (status) |
| 6614 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6615 | status = decode_sequence(xdr, &res->seq_res, req); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6616 | if (status) |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 6617 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6618 | status = decode_putfh(xdr); |
| 6619 | if (status) |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 6620 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6621 | status = decode_lookup(xdr); |
| 6622 | if (status) |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 6623 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6624 | xdr_enter_page(xdr, PAGE_SIZE); |
Trond Myklebust | 8b7e3f4 | 2012-01-30 15:43:56 -0500 | [diff] [blame] | 6625 | status = decode_getfattr_generic(xdr, &res->fs_locations->fattr, |
| 6626 | NULL, res->fs_locations, |
| 6627 | res->fs_locations->server); |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 6628 | out: |
| 6629 | return status; |
| 6630 | } |
| 6631 | |
Bryan Schumaker | 5a5ea0d | 2011-03-24 17:12:29 +0000 | [diff] [blame] | 6632 | /* |
| 6633 | * Decode SECINFO response |
| 6634 | */ |
| 6635 | static int nfs4_xdr_dec_secinfo(struct rpc_rqst *rqstp, |
| 6636 | struct xdr_stream *xdr, |
| 6637 | struct nfs4_secinfo_res *res) |
| 6638 | { |
| 6639 | struct compound_hdr hdr; |
| 6640 | int status; |
| 6641 | |
| 6642 | status = decode_compound_hdr(xdr, &hdr); |
| 6643 | if (status) |
| 6644 | goto out; |
| 6645 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
| 6646 | if (status) |
| 6647 | goto out; |
| 6648 | status = decode_putfh(xdr); |
| 6649 | if (status) |
| 6650 | goto out; |
| 6651 | status = decode_secinfo(xdr, res); |
Bryan Schumaker | 5a5ea0d | 2011-03-24 17:12:29 +0000 | [diff] [blame] | 6652 | out: |
| 6653 | return status; |
| 6654 | } |
| 6655 | |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 6656 | #if defined(CONFIG_NFS_V4_1) |
| 6657 | /* |
Ricardo Labiaga | 8b17321 | 2009-12-05 16:08:39 -0500 | [diff] [blame] | 6658 | * Decode EXCHANGE_ID response |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 6659 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6660 | static int nfs4_xdr_dec_exchange_id(struct rpc_rqst *rqstp, |
| 6661 | struct xdr_stream *xdr, |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 6662 | void *res) |
| 6663 | { |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 6664 | struct compound_hdr hdr; |
| 6665 | int status; |
| 6666 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6667 | status = decode_compound_hdr(xdr, &hdr); |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 6668 | if (!status) |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6669 | status = decode_exchange_id(xdr, res); |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 6670 | return status; |
| 6671 | } |
Andy Adamson | 2050f0c | 2009-04-01 09:22:30 -0400 | [diff] [blame] | 6672 | |
| 6673 | /* |
Ricardo Labiaga | 8b17321 | 2009-12-05 16:08:39 -0500 | [diff] [blame] | 6674 | * Decode CREATE_SESSION response |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 6675 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6676 | static int nfs4_xdr_dec_create_session(struct rpc_rqst *rqstp, |
| 6677 | struct xdr_stream *xdr, |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 6678 | struct nfs41_create_session_res *res) |
| 6679 | { |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 6680 | struct compound_hdr hdr; |
| 6681 | int status; |
| 6682 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6683 | status = decode_compound_hdr(xdr, &hdr); |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 6684 | if (!status) |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6685 | status = decode_create_session(xdr, res); |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 6686 | return status; |
| 6687 | } |
| 6688 | |
| 6689 | /* |
Ricardo Labiaga | 8b17321 | 2009-12-05 16:08:39 -0500 | [diff] [blame] | 6690 | * Decode DESTROY_SESSION response |
Andy Adamson | 0f3e66c | 2009-04-01 09:22:34 -0400 | [diff] [blame] | 6691 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6692 | static int nfs4_xdr_dec_destroy_session(struct rpc_rqst *rqstp, |
| 6693 | struct xdr_stream *xdr, |
| 6694 | void *res) |
Andy Adamson | 0f3e66c | 2009-04-01 09:22:34 -0400 | [diff] [blame] | 6695 | { |
Andy Adamson | 0f3e66c | 2009-04-01 09:22:34 -0400 | [diff] [blame] | 6696 | struct compound_hdr hdr; |
| 6697 | int status; |
| 6698 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6699 | status = decode_compound_hdr(xdr, &hdr); |
Andy Adamson | 0f3e66c | 2009-04-01 09:22:34 -0400 | [diff] [blame] | 6700 | if (!status) |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6701 | status = decode_destroy_session(xdr, res); |
Andy Adamson | 0f3e66c | 2009-04-01 09:22:34 -0400 | [diff] [blame] | 6702 | return status; |
| 6703 | } |
| 6704 | |
| 6705 | /* |
Ricardo Labiaga | 8b17321 | 2009-12-05 16:08:39 -0500 | [diff] [blame] | 6706 | * Decode SEQUENCE response |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 6707 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6708 | static int nfs4_xdr_dec_sequence(struct rpc_rqst *rqstp, |
| 6709 | struct xdr_stream *xdr, |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 6710 | struct nfs4_sequence_res *res) |
| 6711 | { |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 6712 | struct compound_hdr hdr; |
| 6713 | int status; |
| 6714 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6715 | status = decode_compound_hdr(xdr, &hdr); |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 6716 | if (!status) |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6717 | status = decode_sequence(xdr, res, rqstp); |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 6718 | return status; |
| 6719 | } |
| 6720 | |
| 6721 | /* |
Ricardo Labiaga | 8b17321 | 2009-12-05 16:08:39 -0500 | [diff] [blame] | 6722 | * Decode GET_LEASE_TIME response |
Andy Adamson | 2050f0c | 2009-04-01 09:22:30 -0400 | [diff] [blame] | 6723 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6724 | static int nfs4_xdr_dec_get_lease_time(struct rpc_rqst *rqstp, |
| 6725 | struct xdr_stream *xdr, |
Andy Adamson | 2050f0c | 2009-04-01 09:22:30 -0400 | [diff] [blame] | 6726 | struct nfs4_get_lease_time_res *res) |
| 6727 | { |
Andy Adamson | 2050f0c | 2009-04-01 09:22:30 -0400 | [diff] [blame] | 6728 | struct compound_hdr hdr; |
| 6729 | int status; |
| 6730 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6731 | status = decode_compound_hdr(xdr, &hdr); |
Andy Adamson | 2050f0c | 2009-04-01 09:22:30 -0400 | [diff] [blame] | 6732 | if (!status) |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6733 | status = decode_sequence(xdr, &res->lr_seq_res, rqstp); |
Andy Adamson | 2050f0c | 2009-04-01 09:22:30 -0400 | [diff] [blame] | 6734 | if (!status) |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6735 | status = decode_putrootfh(xdr); |
Andy Adamson | 2050f0c | 2009-04-01 09:22:30 -0400 | [diff] [blame] | 6736 | if (!status) |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6737 | status = decode_fsinfo(xdr, res->lr_fsinfo); |
Andy Adamson | 2050f0c | 2009-04-01 09:22:30 -0400 | [diff] [blame] | 6738 | return status; |
| 6739 | } |
Ricardo Labiaga | 1801975 | 2009-12-05 16:08:40 -0500 | [diff] [blame] | 6740 | |
| 6741 | /* |
| 6742 | * Decode RECLAIM_COMPLETE response |
| 6743 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6744 | static int nfs4_xdr_dec_reclaim_complete(struct rpc_rqst *rqstp, |
| 6745 | struct xdr_stream *xdr, |
Ricardo Labiaga | 1801975 | 2009-12-05 16:08:40 -0500 | [diff] [blame] | 6746 | struct nfs41_reclaim_complete_res *res) |
| 6747 | { |
Ricardo Labiaga | 1801975 | 2009-12-05 16:08:40 -0500 | [diff] [blame] | 6748 | struct compound_hdr hdr; |
| 6749 | int status; |
| 6750 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6751 | status = decode_compound_hdr(xdr, &hdr); |
Ricardo Labiaga | 1801975 | 2009-12-05 16:08:40 -0500 | [diff] [blame] | 6752 | if (!status) |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6753 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
Ricardo Labiaga | 1801975 | 2009-12-05 16:08:40 -0500 | [diff] [blame] | 6754 | if (!status) |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6755 | status = decode_reclaim_complete(xdr, (void *)NULL); |
Ricardo Labiaga | 1801975 | 2009-12-05 16:08:40 -0500 | [diff] [blame] | 6756 | return status; |
| 6757 | } |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 6758 | |
| 6759 | /* |
Andy Adamson | 7f11d8d | 2011-07-30 20:52:35 -0400 | [diff] [blame] | 6760 | * Decode GETDEVICELIST response |
| 6761 | */ |
| 6762 | static int nfs4_xdr_dec_getdevicelist(struct rpc_rqst *rqstp, |
| 6763 | struct xdr_stream *xdr, |
| 6764 | struct nfs4_getdevicelist_res *res) |
| 6765 | { |
| 6766 | struct compound_hdr hdr; |
| 6767 | int status; |
| 6768 | |
| 6769 | dprintk("encoding getdevicelist!\n"); |
| 6770 | |
| 6771 | status = decode_compound_hdr(xdr, &hdr); |
| 6772 | if (status != 0) |
| 6773 | goto out; |
| 6774 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
| 6775 | if (status != 0) |
| 6776 | goto out; |
| 6777 | status = decode_putfh(xdr); |
| 6778 | if (status != 0) |
| 6779 | goto out; |
| 6780 | status = decode_getdevicelist(xdr, res->devlist); |
| 6781 | out: |
| 6782 | return status; |
| 6783 | } |
| 6784 | |
| 6785 | /* |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 6786 | * Decode GETDEVINFO response |
| 6787 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6788 | static int nfs4_xdr_dec_getdeviceinfo(struct rpc_rqst *rqstp, |
| 6789 | struct xdr_stream *xdr, |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 6790 | struct nfs4_getdeviceinfo_res *res) |
| 6791 | { |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 6792 | struct compound_hdr hdr; |
| 6793 | int status; |
| 6794 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6795 | status = decode_compound_hdr(xdr, &hdr); |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 6796 | if (status != 0) |
| 6797 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6798 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 6799 | if (status != 0) |
| 6800 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6801 | status = decode_getdeviceinfo(xdr, res->pdev); |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 6802 | out: |
| 6803 | return status; |
| 6804 | } |
| 6805 | |
| 6806 | /* |
| 6807 | * Decode LAYOUTGET response |
| 6808 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6809 | static int nfs4_xdr_dec_layoutget(struct rpc_rqst *rqstp, |
| 6810 | struct xdr_stream *xdr, |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 6811 | struct nfs4_layoutget_res *res) |
| 6812 | { |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 6813 | struct compound_hdr hdr; |
| 6814 | int status; |
| 6815 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6816 | status = decode_compound_hdr(xdr, &hdr); |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 6817 | if (status) |
| 6818 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6819 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 6820 | if (status) |
| 6821 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6822 | status = decode_putfh(xdr); |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 6823 | if (status) |
| 6824 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6825 | status = decode_layoutget(xdr, rqstp, res); |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 6826 | out: |
| 6827 | return status; |
| 6828 | } |
Andy Adamson | 863a3c6 | 2011-03-23 13:27:54 +0000 | [diff] [blame] | 6829 | |
| 6830 | /* |
Benny Halevy | cbe8260 | 2011-05-22 19:52:37 +0300 | [diff] [blame] | 6831 | * Decode LAYOUTRETURN response |
| 6832 | */ |
| 6833 | static int nfs4_xdr_dec_layoutreturn(struct rpc_rqst *rqstp, |
| 6834 | struct xdr_stream *xdr, |
| 6835 | struct nfs4_layoutreturn_res *res) |
| 6836 | { |
| 6837 | struct compound_hdr hdr; |
| 6838 | int status; |
| 6839 | |
| 6840 | status = decode_compound_hdr(xdr, &hdr); |
| 6841 | if (status) |
| 6842 | goto out; |
| 6843 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
| 6844 | if (status) |
| 6845 | goto out; |
| 6846 | status = decode_putfh(xdr); |
| 6847 | if (status) |
| 6848 | goto out; |
| 6849 | status = decode_layoutreturn(xdr, res); |
| 6850 | out: |
| 6851 | return status; |
| 6852 | } |
| 6853 | |
| 6854 | /* |
Andy Adamson | 863a3c6 | 2011-03-23 13:27:54 +0000 | [diff] [blame] | 6855 | * Decode LAYOUTCOMMIT response |
| 6856 | */ |
| 6857 | static int nfs4_xdr_dec_layoutcommit(struct rpc_rqst *rqstp, |
| 6858 | struct xdr_stream *xdr, |
| 6859 | struct nfs4_layoutcommit_res *res) |
| 6860 | { |
| 6861 | struct compound_hdr hdr; |
| 6862 | int status; |
| 6863 | |
| 6864 | status = decode_compound_hdr(xdr, &hdr); |
| 6865 | if (status) |
| 6866 | goto out; |
| 6867 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
| 6868 | if (status) |
| 6869 | goto out; |
| 6870 | status = decode_putfh(xdr); |
| 6871 | if (status) |
| 6872 | goto out; |
| 6873 | status = decode_layoutcommit(xdr, rqstp, res); |
| 6874 | if (status) |
| 6875 | goto out; |
Trond Myklebust | 6926afd | 2012-01-07 13:22:46 -0500 | [diff] [blame] | 6876 | decode_getfattr(xdr, res->fattr, res->server); |
Andy Adamson | 863a3c6 | 2011-03-23 13:27:54 +0000 | [diff] [blame] | 6877 | out: |
| 6878 | return status; |
| 6879 | } |
Bryan Schumaker | fca78d6 | 2011-06-02 14:59:07 -0400 | [diff] [blame] | 6880 | |
| 6881 | /* |
| 6882 | * Decode SECINFO_NO_NAME response |
| 6883 | */ |
| 6884 | static int nfs4_xdr_dec_secinfo_no_name(struct rpc_rqst *rqstp, |
| 6885 | struct xdr_stream *xdr, |
| 6886 | struct nfs4_secinfo_res *res) |
| 6887 | { |
| 6888 | struct compound_hdr hdr; |
| 6889 | int status; |
| 6890 | |
| 6891 | status = decode_compound_hdr(xdr, &hdr); |
| 6892 | if (status) |
| 6893 | goto out; |
| 6894 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
| 6895 | if (status) |
| 6896 | goto out; |
| 6897 | status = decode_putrootfh(xdr); |
| 6898 | if (status) |
| 6899 | goto out; |
| 6900 | status = decode_secinfo(xdr, res); |
| 6901 | out: |
| 6902 | return status; |
| 6903 | } |
Bryan Schumaker | 7d97479 | 2011-06-02 14:59:08 -0400 | [diff] [blame] | 6904 | |
| 6905 | /* |
| 6906 | * Decode TEST_STATEID response |
| 6907 | */ |
| 6908 | static int nfs4_xdr_dec_test_stateid(struct rpc_rqst *rqstp, |
| 6909 | struct xdr_stream *xdr, |
| 6910 | struct nfs41_test_stateid_res *res) |
| 6911 | { |
| 6912 | struct compound_hdr hdr; |
| 6913 | int status; |
| 6914 | |
| 6915 | status = decode_compound_hdr(xdr, &hdr); |
| 6916 | if (status) |
| 6917 | goto out; |
| 6918 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
| 6919 | if (status) |
| 6920 | goto out; |
| 6921 | status = decode_test_stateid(xdr, res); |
| 6922 | out: |
| 6923 | return status; |
| 6924 | } |
Bryan Schumaker | 9aeda35 | 2011-06-02 14:59:09 -0400 | [diff] [blame] | 6925 | |
| 6926 | /* |
| 6927 | * Decode FREE_STATEID response |
| 6928 | */ |
| 6929 | static int nfs4_xdr_dec_free_stateid(struct rpc_rqst *rqstp, |
| 6930 | struct xdr_stream *xdr, |
| 6931 | struct nfs41_free_stateid_res *res) |
| 6932 | { |
| 6933 | struct compound_hdr hdr; |
| 6934 | int status; |
| 6935 | |
| 6936 | status = decode_compound_hdr(xdr, &hdr); |
| 6937 | if (status) |
| 6938 | goto out; |
| 6939 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
| 6940 | if (status) |
| 6941 | goto out; |
| 6942 | status = decode_free_stateid(xdr, res); |
| 6943 | out: |
| 6944 | return status; |
| 6945 | } |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 6946 | #endif /* CONFIG_NFS_V4_1 */ |
| 6947 | |
Chuck Lever | 573c4e1 | 2010-12-14 14:58:11 +0000 | [diff] [blame] | 6948 | /** |
| 6949 | * nfs4_decode_dirent - Decode a single NFSv4 directory entry stored in |
| 6950 | * the local page cache. |
| 6951 | * @xdr: XDR stream where entry resides |
| 6952 | * @entry: buffer to fill in with entry data |
| 6953 | * @plus: boolean indicating whether this should be a readdirplus entry |
| 6954 | * |
| 6955 | * Returns zero if successful, otherwise a negative errno value is |
| 6956 | * returned. |
| 6957 | * |
| 6958 | * This function is not invoked during READDIR reply decoding, but |
| 6959 | * rather whenever an application invokes the getdents(2) system call |
| 6960 | * on a directory already in our cache. |
| 6961 | */ |
| 6962 | int nfs4_decode_dirent(struct xdr_stream *xdr, struct nfs_entry *entry, |
| 6963 | int plus) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6964 | { |
Fred Isaman | dae100c | 2011-07-30 20:52:37 -0400 | [diff] [blame] | 6965 | uint32_t bitmap[3] = {0}; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6966 | uint32_t len; |
Bryan Schumaker | babddc7 | 2010-10-20 15:44:29 -0400 | [diff] [blame] | 6967 | __be32 *p = xdr_inline_decode(xdr, 4); |
| 6968 | if (unlikely(!p)) |
| 6969 | goto out_overflow; |
Chuck Lever | c08e76d | 2011-01-28 12:40:55 -0500 | [diff] [blame] | 6970 | if (*p == xdr_zero) { |
Bryan Schumaker | babddc7 | 2010-10-20 15:44:29 -0400 | [diff] [blame] | 6971 | p = xdr_inline_decode(xdr, 4); |
| 6972 | if (unlikely(!p)) |
| 6973 | goto out_overflow; |
Chuck Lever | c08e76d | 2011-01-28 12:40:55 -0500 | [diff] [blame] | 6974 | if (*p == xdr_zero) |
Chuck Lever | 573c4e1 | 2010-12-14 14:58:11 +0000 | [diff] [blame] | 6975 | return -EAGAIN; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6976 | entry->eof = 1; |
Chuck Lever | 573c4e1 | 2010-12-14 14:58:11 +0000 | [diff] [blame] | 6977 | return -EBADCOOKIE; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6978 | } |
| 6979 | |
Bryan Schumaker | babddc7 | 2010-10-20 15:44:29 -0400 | [diff] [blame] | 6980 | p = xdr_inline_decode(xdr, 12); |
| 6981 | if (unlikely(!p)) |
| 6982 | goto out_overflow; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6983 | entry->prev_cookie = entry->cookie; |
| 6984 | p = xdr_decode_hyper(p, &entry->cookie); |
Chuck Lever | c08e76d | 2011-01-28 12:40:55 -0500 | [diff] [blame] | 6985 | entry->len = be32_to_cpup(p); |
Bryan Schumaker | babddc7 | 2010-10-20 15:44:29 -0400 | [diff] [blame] | 6986 | |
Trond Myklebust | 9af8c22 | 2010-10-24 11:52:55 -0400 | [diff] [blame] | 6987 | p = xdr_inline_decode(xdr, entry->len); |
Bryan Schumaker | babddc7 | 2010-10-20 15:44:29 -0400 | [diff] [blame] | 6988 | if (unlikely(!p)) |
| 6989 | goto out_overflow; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6990 | entry->name = (const char *) p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6991 | |
| 6992 | /* |
| 6993 | * In case the server doesn't return an inode number, |
| 6994 | * we fake one here. (We don't use inode number 0, |
| 6995 | * since glibc seems to choke on it...) |
| 6996 | */ |
| 6997 | entry->ino = 1; |
Trond Myklebust | 4f08222 | 2010-10-24 13:14:02 -0400 | [diff] [blame] | 6998 | entry->fattr->valid = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6999 | |
Trond Myklebust | 9af8c22 | 2010-10-24 11:52:55 -0400 | [diff] [blame] | 7000 | if (decode_attr_bitmap(xdr, bitmap) < 0) |
Bryan Schumaker | babddc7 | 2010-10-20 15:44:29 -0400 | [diff] [blame] | 7001 | goto out_overflow; |
Trond Myklebust | 9af8c22 | 2010-10-24 11:52:55 -0400 | [diff] [blame] | 7002 | |
| 7003 | if (decode_attr_length(xdr, &len, &p) < 0) |
| 7004 | goto out_overflow; |
| 7005 | |
Chuck Lever | 573c4e1 | 2010-12-14 14:58:11 +0000 | [diff] [blame] | 7006 | if (decode_getfattr_attrs(xdr, bitmap, entry->fattr, entry->fh, |
Trond Myklebust | 8b7e3f4 | 2012-01-30 15:43:56 -0500 | [diff] [blame] | 7007 | NULL, entry->server) < 0) |
Trond Myklebust | 9af8c22 | 2010-10-24 11:52:55 -0400 | [diff] [blame] | 7008 | goto out_overflow; |
Trond Myklebust | 28331a4 | 2011-04-27 13:47:52 -0400 | [diff] [blame] | 7009 | if (entry->fattr->valid & NFS_ATTR_FATTR_MOUNTED_ON_FILEID) |
| 7010 | entry->ino = entry->fattr->mounted_on_fileid; |
| 7011 | else if (entry->fattr->valid & NFS_ATTR_FATTR_FILEID) |
Trond Myklebust | 9af8c22 | 2010-10-24 11:52:55 -0400 | [diff] [blame] | 7012 | entry->ino = entry->fattr->fileid; |
| 7013 | |
Trond Myklebust | 0b26a0b | 2010-11-20 14:26:44 -0500 | [diff] [blame] | 7014 | entry->d_type = DT_UNKNOWN; |
| 7015 | if (entry->fattr->valid & NFS_ATTR_FATTR_TYPE) |
| 7016 | entry->d_type = nfs_umode_to_dtype(entry->fattr->mode); |
| 7017 | |
Chuck Lever | 573c4e1 | 2010-12-14 14:58:11 +0000 | [diff] [blame] | 7018 | return 0; |
Bryan Schumaker | babddc7 | 2010-10-20 15:44:29 -0400 | [diff] [blame] | 7019 | |
| 7020 | out_overflow: |
| 7021 | print_overflow_msg(__func__, xdr); |
Chuck Lever | 573c4e1 | 2010-12-14 14:58:11 +0000 | [diff] [blame] | 7022 | return -EAGAIN; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7023 | } |
| 7024 | |
| 7025 | /* |
| 7026 | * We need to translate between nfs status return values and |
| 7027 | * the local errno values which may not be the same. |
| 7028 | */ |
| 7029 | static struct { |
| 7030 | int stat; |
| 7031 | int errno; |
| 7032 | } nfs_errtbl[] = { |
| 7033 | { NFS4_OK, 0 }, |
Benny Halevy | 856dff3 | 2008-03-31 17:39:06 +0300 | [diff] [blame] | 7034 | { NFS4ERR_PERM, -EPERM }, |
| 7035 | { NFS4ERR_NOENT, -ENOENT }, |
| 7036 | { NFS4ERR_IO, -errno_NFSERR_IO}, |
| 7037 | { NFS4ERR_NXIO, -ENXIO }, |
| 7038 | { NFS4ERR_ACCESS, -EACCES }, |
| 7039 | { NFS4ERR_EXIST, -EEXIST }, |
| 7040 | { NFS4ERR_XDEV, -EXDEV }, |
| 7041 | { NFS4ERR_NOTDIR, -ENOTDIR }, |
| 7042 | { NFS4ERR_ISDIR, -EISDIR }, |
| 7043 | { NFS4ERR_INVAL, -EINVAL }, |
| 7044 | { NFS4ERR_FBIG, -EFBIG }, |
| 7045 | { NFS4ERR_NOSPC, -ENOSPC }, |
| 7046 | { NFS4ERR_ROFS, -EROFS }, |
| 7047 | { NFS4ERR_MLINK, -EMLINK }, |
| 7048 | { NFS4ERR_NAMETOOLONG, -ENAMETOOLONG }, |
| 7049 | { NFS4ERR_NOTEMPTY, -ENOTEMPTY }, |
| 7050 | { NFS4ERR_DQUOT, -EDQUOT }, |
| 7051 | { NFS4ERR_STALE, -ESTALE }, |
| 7052 | { NFS4ERR_BADHANDLE, -EBADHANDLE }, |
Benny Halevy | 856dff3 | 2008-03-31 17:39:06 +0300 | [diff] [blame] | 7053 | { NFS4ERR_BAD_COOKIE, -EBADCOOKIE }, |
| 7054 | { NFS4ERR_NOTSUPP, -ENOTSUPP }, |
| 7055 | { NFS4ERR_TOOSMALL, -ETOOSMALL }, |
Trond Myklebust | fdcb457 | 2010-02-08 09:32:40 -0500 | [diff] [blame] | 7056 | { NFS4ERR_SERVERFAULT, -EREMOTEIO }, |
Benny Halevy | 856dff3 | 2008-03-31 17:39:06 +0300 | [diff] [blame] | 7057 | { NFS4ERR_BADTYPE, -EBADTYPE }, |
| 7058 | { NFS4ERR_LOCKED, -EAGAIN }, |
Benny Halevy | 856dff3 | 2008-03-31 17:39:06 +0300 | [diff] [blame] | 7059 | { NFS4ERR_SYMLINK, -ELOOP }, |
| 7060 | { NFS4ERR_OP_ILLEGAL, -EOPNOTSUPP }, |
| 7061 | { NFS4ERR_DEADLOCK, -EDEADLK }, |
Benny Halevy | 856dff3 | 2008-03-31 17:39:06 +0300 | [diff] [blame] | 7062 | { -1, -EIO } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7063 | }; |
| 7064 | |
| 7065 | /* |
| 7066 | * Convert an NFS error code to a local one. |
| 7067 | * This one is used jointly by NFSv2 and NFSv3. |
| 7068 | */ |
| 7069 | static int |
David Howells | 0a8ea43 | 2006-08-22 20:06:08 -0400 | [diff] [blame] | 7070 | nfs4_stat_to_errno(int stat) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7071 | { |
| 7072 | int i; |
| 7073 | for (i = 0; nfs_errtbl[i].stat != -1; i++) { |
| 7074 | if (nfs_errtbl[i].stat == stat) |
| 7075 | return nfs_errtbl[i].errno; |
| 7076 | } |
| 7077 | if (stat <= 10000 || stat > 10100) { |
| 7078 | /* The server is looney tunes. */ |
Trond Myklebust | fdcb457 | 2010-02-08 09:32:40 -0500 | [diff] [blame] | 7079 | return -EREMOTEIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7080 | } |
| 7081 | /* If we cannot translate the error, the recovery routines should |
| 7082 | * handle it. |
| 7083 | * Note: remaining NFSv4 error codes have values > 10000, so should |
| 7084 | * not conflict with native Linux error codes. |
| 7085 | */ |
Benny Halevy | 856dff3 | 2008-03-31 17:39:06 +0300 | [diff] [blame] | 7086 | return -stat; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7087 | } |
| 7088 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7089 | #define PROC(proc, argtype, restype) \ |
| 7090 | [NFSPROC4_CLNT_##proc] = { \ |
| 7091 | .p_proc = NFSPROC4_COMPOUND, \ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 7092 | .p_encode = (kxdreproc_t)nfs4_xdr_##argtype, \ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 7093 | .p_decode = (kxdrdproc_t)nfs4_xdr_##restype, \ |
Chuck Lever | 2bea90d | 2007-03-29 16:47:53 -0400 | [diff] [blame] | 7094 | .p_arglen = NFS4_##argtype##_sz, \ |
| 7095 | .p_replen = NFS4_##restype##_sz, \ |
Chuck Lever | cc0175c | 2006-03-20 13:44:22 -0500 | [diff] [blame] | 7096 | .p_statidx = NFSPROC4_CLNT_##proc, \ |
| 7097 | .p_name = #proc, \ |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 7098 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7099 | |
| 7100 | struct rpc_procinfo nfs4_procedures[] = { |
Chuck Lever | 7d93bd71 | 2010-12-14 14:57:42 +0000 | [diff] [blame] | 7101 | PROC(READ, enc_read, dec_read), |
| 7102 | PROC(WRITE, enc_write, dec_write), |
| 7103 | PROC(COMMIT, enc_commit, dec_commit), |
| 7104 | PROC(OPEN, enc_open, dec_open), |
| 7105 | PROC(OPEN_CONFIRM, enc_open_confirm, dec_open_confirm), |
| 7106 | PROC(OPEN_NOATTR, enc_open_noattr, dec_open_noattr), |
| 7107 | PROC(OPEN_DOWNGRADE, enc_open_downgrade, dec_open_downgrade), |
| 7108 | PROC(CLOSE, enc_close, dec_close), |
| 7109 | PROC(SETATTR, enc_setattr, dec_setattr), |
| 7110 | PROC(FSINFO, enc_fsinfo, dec_fsinfo), |
| 7111 | PROC(RENEW, enc_renew, dec_renew), |
| 7112 | PROC(SETCLIENTID, enc_setclientid, dec_setclientid), |
| 7113 | PROC(SETCLIENTID_CONFIRM, enc_setclientid_confirm, dec_setclientid_confirm), |
| 7114 | PROC(LOCK, enc_lock, dec_lock), |
| 7115 | PROC(LOCKT, enc_lockt, dec_lockt), |
| 7116 | PROC(LOCKU, enc_locku, dec_locku), |
| 7117 | PROC(ACCESS, enc_access, dec_access), |
| 7118 | PROC(GETATTR, enc_getattr, dec_getattr), |
| 7119 | PROC(LOOKUP, enc_lookup, dec_lookup), |
| 7120 | PROC(LOOKUP_ROOT, enc_lookup_root, dec_lookup_root), |
| 7121 | PROC(REMOVE, enc_remove, dec_remove), |
| 7122 | PROC(RENAME, enc_rename, dec_rename), |
| 7123 | PROC(LINK, enc_link, dec_link), |
| 7124 | PROC(SYMLINK, enc_symlink, dec_symlink), |
| 7125 | PROC(CREATE, enc_create, dec_create), |
| 7126 | PROC(PATHCONF, enc_pathconf, dec_pathconf), |
| 7127 | PROC(STATFS, enc_statfs, dec_statfs), |
| 7128 | PROC(READLINK, enc_readlink, dec_readlink), |
| 7129 | PROC(READDIR, enc_readdir, dec_readdir), |
| 7130 | PROC(SERVER_CAPS, enc_server_caps, dec_server_caps), |
| 7131 | PROC(DELEGRETURN, enc_delegreturn, dec_delegreturn), |
| 7132 | PROC(GETACL, enc_getacl, dec_getacl), |
| 7133 | PROC(SETACL, enc_setacl, dec_setacl), |
| 7134 | PROC(FS_LOCATIONS, enc_fs_locations, dec_fs_locations), |
| 7135 | PROC(RELEASE_LOCKOWNER, enc_release_lockowner, dec_release_lockowner), |
Bryan Schumaker | 5a5ea0d | 2011-03-24 17:12:29 +0000 | [diff] [blame] | 7136 | PROC(SECINFO, enc_secinfo, dec_secinfo), |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 7137 | #if defined(CONFIG_NFS_V4_1) |
Chuck Lever | 7d93bd71 | 2010-12-14 14:57:42 +0000 | [diff] [blame] | 7138 | PROC(EXCHANGE_ID, enc_exchange_id, dec_exchange_id), |
| 7139 | PROC(CREATE_SESSION, enc_create_session, dec_create_session), |
| 7140 | PROC(DESTROY_SESSION, enc_destroy_session, dec_destroy_session), |
| 7141 | PROC(SEQUENCE, enc_sequence, dec_sequence), |
| 7142 | PROC(GET_LEASE_TIME, enc_get_lease_time, dec_get_lease_time), |
| 7143 | PROC(RECLAIM_COMPLETE, enc_reclaim_complete, dec_reclaim_complete), |
| 7144 | PROC(GETDEVICEINFO, enc_getdeviceinfo, dec_getdeviceinfo), |
| 7145 | PROC(LAYOUTGET, enc_layoutget, dec_layoutget), |
Andy Adamson | 863a3c6 | 2011-03-23 13:27:54 +0000 | [diff] [blame] | 7146 | PROC(LAYOUTCOMMIT, enc_layoutcommit, dec_layoutcommit), |
Benny Halevy | cbe8260 | 2011-05-22 19:52:37 +0300 | [diff] [blame] | 7147 | PROC(LAYOUTRETURN, enc_layoutreturn, dec_layoutreturn), |
Bryan Schumaker | fca78d6 | 2011-06-02 14:59:07 -0400 | [diff] [blame] | 7148 | PROC(SECINFO_NO_NAME, enc_secinfo_no_name, dec_secinfo_no_name), |
Bryan Schumaker | 7d97479 | 2011-06-02 14:59:08 -0400 | [diff] [blame] | 7149 | PROC(TEST_STATEID, enc_test_stateid, dec_test_stateid), |
Bryan Schumaker | 9aeda35 | 2011-06-02 14:59:09 -0400 | [diff] [blame] | 7150 | PROC(FREE_STATEID, enc_free_stateid, dec_free_stateid), |
Andy Adamson | 7f11d8d | 2011-07-30 20:52:35 -0400 | [diff] [blame] | 7151 | PROC(GETDEVICELIST, enc_getdevicelist, dec_getdevicelist), |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 7152 | #endif /* CONFIG_NFS_V4_1 */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7153 | }; |
| 7154 | |
Trond Myklebust | a613fa1 | 2012-01-20 13:53:56 -0500 | [diff] [blame] | 7155 | const struct rpc_version nfs_version4 = { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7156 | .number = 4, |
Tobias Klauser | e8c96f8 | 2006-03-24 03:15:34 -0800 | [diff] [blame] | 7157 | .nrprocs = ARRAY_SIZE(nfs4_procedures), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7158 | .procs = nfs4_procedures |
| 7159 | }; |
| 7160 | |
| 7161 | /* |
| 7162 | * Local variables: |
| 7163 | * c-basic-offset: 8 |
| 7164 | * End: |
| 7165 | */ |