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 */ + \ |
Weston Andros Adamson | 7d2ed9a | 2012-02-17 15:20:26 -0500 | [diff] [blame] | 294 | 1 /* nii_domain */ + \ |
| 295 | XDR_QUADLEN(NFS4_OPAQUE_LIMIT) + \ |
| 296 | 1 /* nii_name */ + \ |
| 297 | XDR_QUADLEN(NFS4_OPAQUE_LIMIT) + \ |
| 298 | 3 /* nii_date */) |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 299 | #define encode_channel_attrs_maxsz (6 + 1 /* ca_rdma_ird.len (0) */) |
| 300 | #define decode_channel_attrs_maxsz (6 + \ |
| 301 | 1 /* ca_rdma_ird.len */ + \ |
| 302 | 1 /* ca_rdma_ird */) |
| 303 | #define encode_create_session_maxsz (op_encode_hdr_maxsz + \ |
| 304 | 2 /* csa_clientid */ + \ |
| 305 | 1 /* csa_sequence */ + \ |
| 306 | 1 /* csa_flags */ + \ |
| 307 | encode_channel_attrs_maxsz + \ |
| 308 | encode_channel_attrs_maxsz + \ |
| 309 | 1 /* csa_cb_program */ + \ |
| 310 | 1 /* csa_sec_parms.len (1) */ + \ |
| 311 | 1 /* cb_secflavor (AUTH_SYS) */ + \ |
| 312 | 1 /* stamp */ + \ |
| 313 | 1 /* machinename.len */ + \ |
| 314 | XDR_QUADLEN(NFS4_MAX_MACHINE_NAME_LEN) + \ |
| 315 | 1 /* uid */ + \ |
| 316 | 1 /* gid */ + \ |
| 317 | 1 /* gids.len (0) */) |
| 318 | #define decode_create_session_maxsz (op_decode_hdr_maxsz + \ |
| 319 | XDR_QUADLEN(NFS4_MAX_SESSIONID_LEN) + \ |
| 320 | 1 /* csr_sequence */ + \ |
| 321 | 1 /* csr_flags */ + \ |
| 322 | decode_channel_attrs_maxsz + \ |
| 323 | decode_channel_attrs_maxsz) |
Andy Adamson | 0f3e66c | 2009-04-01 09:22:34 -0400 | [diff] [blame] | 324 | #define encode_destroy_session_maxsz (op_encode_hdr_maxsz + 4) |
| 325 | #define decode_destroy_session_maxsz (op_decode_hdr_maxsz) |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 326 | #define encode_sequence_maxsz (op_encode_hdr_maxsz + \ |
| 327 | XDR_QUADLEN(NFS4_MAX_SESSIONID_LEN) + 4) |
| 328 | #define decode_sequence_maxsz (op_decode_hdr_maxsz + \ |
| 329 | XDR_QUADLEN(NFS4_MAX_SESSIONID_LEN) + 5) |
Ricardo Labiaga | 18019753 | 2009-12-05 16:08:40 -0500 | [diff] [blame] | 330 | #define encode_reclaim_complete_maxsz (op_encode_hdr_maxsz + 4) |
| 331 | #define decode_reclaim_complete_maxsz (op_decode_hdr_maxsz + 4) |
Andy Adamson | 7f11d8d | 2011-07-30 20:52:35 -0400 | [diff] [blame] | 332 | #define encode_getdevicelist_maxsz (op_encode_hdr_maxsz + 4 + \ |
| 333 | encode_verifier_maxsz) |
| 334 | #define decode_getdevicelist_maxsz (op_decode_hdr_maxsz + \ |
| 335 | 2 /* nfs_cookie4 gdlr_cookie */ + \ |
| 336 | decode_verifier_maxsz \ |
| 337 | /* verifier4 gdlr_verifier */ + \ |
| 338 | 1 /* gdlr_deviceid_list count */ + \ |
| 339 | XDR_QUADLEN(NFS4_PNFS_GETDEVLIST_MAXNUM * \ |
| 340 | NFS4_DEVICEID4_SIZE) \ |
| 341 | /* gdlr_deviceid_list */ + \ |
| 342 | 1 /* bool gdlr_eof */) |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 343 | #define encode_getdeviceinfo_maxsz (op_encode_hdr_maxsz + 4 + \ |
| 344 | XDR_QUADLEN(NFS4_DEVICEID4_SIZE)) |
| 345 | #define decode_getdeviceinfo_maxsz (op_decode_hdr_maxsz + \ |
| 346 | 1 /* layout type */ + \ |
| 347 | 1 /* opaque devaddr4 length */ + \ |
| 348 | /* devaddr4 payload is read into page */ \ |
| 349 | 1 /* notification bitmap length */ + \ |
| 350 | 1 /* notification bitmap */) |
| 351 | #define encode_layoutget_maxsz (op_encode_hdr_maxsz + 10 + \ |
| 352 | encode_stateid_maxsz) |
| 353 | #define decode_layoutget_maxsz (op_decode_hdr_maxsz + 8 + \ |
| 354 | decode_stateid_maxsz + \ |
| 355 | XDR_QUADLEN(PNFS_LAYOUT_MAXSIZE)) |
Andy Adamson | 863a3c6 | 2011-03-23 13:27:54 +0000 | [diff] [blame] | 356 | #define encode_layoutcommit_maxsz (op_encode_hdr_maxsz + \ |
| 357 | 2 /* offset */ + \ |
| 358 | 2 /* length */ + \ |
| 359 | 1 /* reclaim */ + \ |
| 360 | encode_stateid_maxsz + \ |
| 361 | 1 /* new offset (true) */ + \ |
| 362 | 2 /* last byte written */ + \ |
| 363 | 1 /* nt_timechanged (false) */ + \ |
| 364 | 1 /* layoutupdate4 layout type */ + \ |
| 365 | 1 /* NULL filelayout layoutupdate4 payload */) |
| 366 | #define decode_layoutcommit_maxsz (op_decode_hdr_maxsz + 3) |
Benny Halevy | cbe8260 | 2011-05-22 19:52:37 +0300 | [diff] [blame] | 367 | #define encode_layoutreturn_maxsz (8 + op_encode_hdr_maxsz + \ |
| 368 | encode_stateid_maxsz + \ |
| 369 | 1 /* FIXME: opaque lrf_body always empty at the moment */) |
| 370 | #define decode_layoutreturn_maxsz (op_decode_hdr_maxsz + \ |
| 371 | 1 + decode_stateid_maxsz) |
Bryan Schumaker | fca78d6 | 2011-06-02 14:59:07 -0400 | [diff] [blame] | 372 | #define encode_secinfo_no_name_maxsz (op_encode_hdr_maxsz + 1) |
| 373 | #define decode_secinfo_no_name_maxsz decode_secinfo_maxsz |
Bryan Schumaker | 7d97479 | 2011-06-02 14:59:08 -0400 | [diff] [blame] | 374 | #define encode_test_stateid_maxsz (op_encode_hdr_maxsz + 2 + \ |
| 375 | XDR_QUADLEN(NFS4_STATEID_SIZE)) |
| 376 | #define decode_test_stateid_maxsz (op_decode_hdr_maxsz + 2 + 1) |
Bryan Schumaker | 9aeda35 | 2011-06-02 14:59:09 -0400 | [diff] [blame] | 377 | #define encode_free_stateid_maxsz (op_encode_hdr_maxsz + 1 + \ |
| 378 | XDR_QUADLEN(NFS4_STATEID_SIZE)) |
| 379 | #define decode_free_stateid_maxsz (op_decode_hdr_maxsz + 1) |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 380 | #else /* CONFIG_NFS_V4_1 */ |
| 381 | #define encode_sequence_maxsz 0 |
| 382 | #define decode_sequence_maxsz 0 |
| 383 | #endif /* CONFIG_NFS_V4_1 */ |
| 384 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 385 | #define NFS4_enc_compound_sz (1024) /* XXX: large enough? */ |
| 386 | #define NFS4_dec_compound_sz (1024) /* XXX: large enough? */ |
| 387 | #define NFS4_enc_read_sz (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 388 | encode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 389 | encode_putfh_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 390 | encode_read_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 391 | #define NFS4_dec_read_sz (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 392 | decode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 393 | decode_putfh_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 394 | decode_read_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 395 | #define NFS4_enc_readlink_sz (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 396 | encode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 397 | encode_putfh_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 398 | encode_readlink_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 399 | #define NFS4_dec_readlink_sz (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 400 | decode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 401 | decode_putfh_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 402 | decode_readlink_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 403 | #define NFS4_enc_readdir_sz (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 404 | encode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 405 | encode_putfh_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 406 | encode_readdir_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 407 | #define NFS4_dec_readdir_sz (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 408 | decode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 409 | decode_putfh_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 410 | decode_readdir_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 411 | #define NFS4_enc_write_sz (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 412 | encode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 413 | encode_putfh_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 414 | encode_write_maxsz + \ |
Trond Myklebust | 4f9838c | 2005-10-27 22:12:44 -0400 | [diff] [blame] | 415 | encode_getattr_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 416 | #define NFS4_dec_write_sz (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 417 | decode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 418 | decode_putfh_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 419 | decode_write_maxsz + \ |
Trond Myklebust | 4f9838c | 2005-10-27 22:12:44 -0400 | [diff] [blame] | 420 | decode_getattr_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 421 | #define NFS4_enc_commit_sz (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 422 | encode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 423 | encode_putfh_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 424 | encode_commit_maxsz + \ |
Trond Myklebust | 4f9838c | 2005-10-27 22:12:44 -0400 | [diff] [blame] | 425 | encode_getattr_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 426 | #define NFS4_dec_commit_sz (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 427 | decode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 428 | decode_putfh_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 429 | decode_commit_maxsz + \ |
Trond Myklebust | 4f9838c | 2005-10-27 22:12:44 -0400 | [diff] [blame] | 430 | decode_getattr_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 431 | #define NFS4_enc_open_sz (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 432 | encode_sequence_maxsz + \ |
Trond Myklebust | 2cebf82 | 2007-07-02 13:57:28 -0400 | [diff] [blame] | 433 | encode_putfh_maxsz + \ |
| 434 | encode_savefh_maxsz + \ |
| 435 | encode_open_maxsz + \ |
| 436 | encode_getfh_maxsz + \ |
| 437 | encode_getattr_maxsz + \ |
| 438 | encode_restorefh_maxsz + \ |
| 439 | encode_getattr_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 440 | #define NFS4_dec_open_sz (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 441 | decode_sequence_maxsz + \ |
Trond Myklebust | 2cebf82 | 2007-07-02 13:57:28 -0400 | [diff] [blame] | 442 | decode_putfh_maxsz + \ |
| 443 | decode_savefh_maxsz + \ |
| 444 | decode_open_maxsz + \ |
| 445 | decode_getfh_maxsz + \ |
| 446 | decode_getattr_maxsz + \ |
| 447 | decode_restorefh_maxsz + \ |
| 448 | decode_getattr_maxsz) |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 449 | #define NFS4_enc_open_confirm_sz \ |
| 450 | (compound_encode_hdr_maxsz + \ |
| 451 | encode_putfh_maxsz + \ |
| 452 | encode_open_confirm_maxsz) |
| 453 | #define NFS4_dec_open_confirm_sz \ |
| 454 | (compound_decode_hdr_maxsz + \ |
| 455 | decode_putfh_maxsz + \ |
| 456 | decode_open_confirm_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 457 | #define NFS4_enc_open_noattr_sz (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 458 | encode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 459 | encode_putfh_maxsz + \ |
Trond Myklebust | 2cebf82 | 2007-07-02 13:57:28 -0400 | [diff] [blame] | 460 | encode_open_maxsz + \ |
| 461 | encode_getattr_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 462 | #define NFS4_dec_open_noattr_sz (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 463 | decode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 464 | decode_putfh_maxsz + \ |
Trond Myklebust | 2cebf82 | 2007-07-02 13:57:28 -0400 | [diff] [blame] | 465 | decode_open_maxsz + \ |
| 466 | decode_getattr_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 467 | #define NFS4_enc_open_downgrade_sz \ |
| 468 | (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 469 | encode_sequence_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 470 | encode_putfh_maxsz + \ |
| 471 | encode_open_downgrade_maxsz + \ |
| 472 | encode_getattr_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 473 | #define NFS4_dec_open_downgrade_sz \ |
| 474 | (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 475 | decode_sequence_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 476 | decode_putfh_maxsz + \ |
| 477 | decode_open_downgrade_maxsz + \ |
| 478 | decode_getattr_maxsz) |
| 479 | #define NFS4_enc_close_sz (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 480 | encode_sequence_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 481 | encode_putfh_maxsz + \ |
| 482 | encode_close_maxsz + \ |
| 483 | encode_getattr_maxsz) |
| 484 | #define NFS4_dec_close_sz (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 485 | decode_sequence_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 486 | decode_putfh_maxsz + \ |
| 487 | decode_close_maxsz + \ |
| 488 | decode_getattr_maxsz) |
| 489 | #define NFS4_enc_setattr_sz (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 490 | encode_sequence_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 491 | encode_putfh_maxsz + \ |
| 492 | encode_setattr_maxsz + \ |
| 493 | encode_getattr_maxsz) |
| 494 | #define NFS4_dec_setattr_sz (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 495 | decode_sequence_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 496 | decode_putfh_maxsz + \ |
| 497 | decode_setattr_maxsz + \ |
| 498 | decode_getattr_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 499 | #define NFS4_enc_fsinfo_sz (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 500 | encode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 501 | encode_putfh_maxsz + \ |
| 502 | encode_fsinfo_maxsz) |
| 503 | #define NFS4_dec_fsinfo_sz (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 504 | decode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 505 | decode_putfh_maxsz + \ |
| 506 | decode_fsinfo_maxsz) |
| 507 | #define NFS4_enc_renew_sz (compound_encode_hdr_maxsz + \ |
| 508 | encode_renew_maxsz) |
| 509 | #define NFS4_dec_renew_sz (compound_decode_hdr_maxsz + \ |
| 510 | decode_renew_maxsz) |
| 511 | #define NFS4_enc_setclientid_sz (compound_encode_hdr_maxsz + \ |
| 512 | encode_setclientid_maxsz) |
| 513 | #define NFS4_dec_setclientid_sz (compound_decode_hdr_maxsz + \ |
| 514 | decode_setclientid_maxsz) |
| 515 | #define NFS4_enc_setclientid_confirm_sz \ |
| 516 | (compound_encode_hdr_maxsz + \ |
| 517 | encode_setclientid_confirm_maxsz + \ |
| 518 | encode_putrootfh_maxsz + \ |
| 519 | encode_fsinfo_maxsz) |
| 520 | #define NFS4_dec_setclientid_confirm_sz \ |
| 521 | (compound_decode_hdr_maxsz + \ |
| 522 | decode_setclientid_confirm_maxsz + \ |
| 523 | decode_putrootfh_maxsz + \ |
| 524 | decode_fsinfo_maxsz) |
| 525 | #define NFS4_enc_lock_sz (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 526 | encode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 527 | encode_putfh_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 528 | encode_lock_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 529 | #define NFS4_dec_lock_sz (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 530 | decode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 531 | decode_putfh_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 532 | decode_lock_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 533 | #define NFS4_enc_lockt_sz (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 534 | encode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 535 | encode_putfh_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 536 | encode_lockt_maxsz) |
| 537 | #define NFS4_dec_lockt_sz (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 538 | decode_sequence_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 539 | decode_putfh_maxsz + \ |
| 540 | decode_lockt_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 541 | #define NFS4_enc_locku_sz (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 542 | encode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 543 | encode_putfh_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 544 | encode_locku_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 545 | #define NFS4_dec_locku_sz (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 546 | decode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 547 | decode_putfh_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 548 | decode_locku_maxsz) |
Trond Myklebust | d3c7b7c | 2010-07-01 12:49:01 -0400 | [diff] [blame] | 549 | #define NFS4_enc_release_lockowner_sz \ |
| 550 | (compound_encode_hdr_maxsz + \ |
| 551 | encode_lockowner_maxsz) |
| 552 | #define NFS4_dec_release_lockowner_sz \ |
| 553 | (compound_decode_hdr_maxsz + \ |
| 554 | decode_lockowner_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 555 | #define NFS4_enc_access_sz (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 556 | encode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 557 | encode_putfh_maxsz + \ |
Trond Myklebust | 76b3299 | 2007-08-10 17:45:11 -0400 | [diff] [blame] | 558 | encode_access_maxsz + \ |
| 559 | encode_getattr_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 560 | #define NFS4_dec_access_sz (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 561 | decode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 562 | decode_putfh_maxsz + \ |
Trond Myklebust | 76b3299 | 2007-08-10 17:45:11 -0400 | [diff] [blame] | 563 | decode_access_maxsz + \ |
| 564 | decode_getattr_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 565 | #define NFS4_enc_getattr_sz (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 566 | encode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 567 | encode_putfh_maxsz + \ |
| 568 | encode_getattr_maxsz) |
| 569 | #define NFS4_dec_getattr_sz (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 570 | decode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 571 | decode_putfh_maxsz + \ |
| 572 | decode_getattr_maxsz) |
| 573 | #define NFS4_enc_lookup_sz (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 574 | encode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 575 | encode_putfh_maxsz + \ |
| 576 | encode_lookup_maxsz + \ |
| 577 | encode_getattr_maxsz + \ |
| 578 | encode_getfh_maxsz) |
| 579 | #define NFS4_dec_lookup_sz (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 580 | decode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 581 | decode_putfh_maxsz + \ |
Trond Myklebust | e688962 | 2007-07-02 13:58:30 -0400 | [diff] [blame] | 582 | decode_lookup_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 583 | decode_getattr_maxsz + \ |
| 584 | decode_getfh_maxsz) |
| 585 | #define NFS4_enc_lookup_root_sz (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 586 | encode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 587 | encode_putrootfh_maxsz + \ |
| 588 | encode_getattr_maxsz + \ |
| 589 | encode_getfh_maxsz) |
| 590 | #define NFS4_dec_lookup_root_sz (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 591 | decode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 592 | decode_putrootfh_maxsz + \ |
| 593 | decode_getattr_maxsz + \ |
| 594 | decode_getfh_maxsz) |
| 595 | #define NFS4_enc_remove_sz (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 596 | encode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 597 | encode_putfh_maxsz + \ |
Trond Myklebust | 16e4295 | 2005-10-27 22:12:44 -0400 | [diff] [blame] | 598 | encode_remove_maxsz + \ |
| 599 | encode_getattr_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 600 | #define NFS4_dec_remove_sz (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 601 | decode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 602 | decode_putfh_maxsz + \ |
Benny Halevy | 6ce1839 | 2009-04-01 09:22:06 -0400 | [diff] [blame] | 603 | decode_remove_maxsz + \ |
Trond Myklebust | 16e4295 | 2005-10-27 22:12:44 -0400 | [diff] [blame] | 604 | decode_getattr_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 605 | #define NFS4_enc_rename_sz (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 606 | encode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 607 | encode_putfh_maxsz + \ |
| 608 | encode_savefh_maxsz + \ |
| 609 | encode_putfh_maxsz + \ |
Trond Myklebust | 6caf2c8 | 2005-10-27 22:12:43 -0400 | [diff] [blame] | 610 | encode_rename_maxsz + \ |
| 611 | encode_getattr_maxsz + \ |
| 612 | encode_restorefh_maxsz + \ |
| 613 | encode_getattr_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 614 | #define NFS4_dec_rename_sz (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 615 | decode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 616 | decode_putfh_maxsz + \ |
| 617 | decode_savefh_maxsz + \ |
| 618 | decode_putfh_maxsz + \ |
Trond Myklebust | 6caf2c8 | 2005-10-27 22:12:43 -0400 | [diff] [blame] | 619 | decode_rename_maxsz + \ |
| 620 | decode_getattr_maxsz + \ |
| 621 | decode_restorefh_maxsz + \ |
| 622 | decode_getattr_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 623 | #define NFS4_enc_link_sz (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 624 | encode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 625 | encode_putfh_maxsz + \ |
| 626 | encode_savefh_maxsz + \ |
| 627 | encode_putfh_maxsz + \ |
Trond Myklebust | 91ba2ee | 2005-10-27 22:12:42 -0400 | [diff] [blame] | 628 | encode_link_maxsz + \ |
| 629 | decode_getattr_maxsz + \ |
| 630 | encode_restorefh_maxsz + \ |
| 631 | decode_getattr_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 632 | #define NFS4_dec_link_sz (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 633 | decode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 634 | decode_putfh_maxsz + \ |
| 635 | decode_savefh_maxsz + \ |
| 636 | decode_putfh_maxsz + \ |
Trond Myklebust | 91ba2ee | 2005-10-27 22:12:42 -0400 | [diff] [blame] | 637 | decode_link_maxsz + \ |
| 638 | decode_getattr_maxsz + \ |
| 639 | decode_restorefh_maxsz + \ |
| 640 | decode_getattr_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 641 | #define NFS4_enc_symlink_sz (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 642 | encode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 643 | encode_putfh_maxsz + \ |
| 644 | encode_symlink_maxsz + \ |
| 645 | encode_getattr_maxsz + \ |
| 646 | encode_getfh_maxsz) |
| 647 | #define NFS4_dec_symlink_sz (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 648 | decode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 649 | decode_putfh_maxsz + \ |
| 650 | decode_symlink_maxsz + \ |
| 651 | decode_getattr_maxsz + \ |
| 652 | decode_getfh_maxsz) |
| 653 | #define NFS4_enc_create_sz (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 654 | encode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 655 | encode_putfh_maxsz + \ |
Trond Myklebust | 56ae19f | 2005-10-27 22:12:40 -0400 | [diff] [blame] | 656 | encode_savefh_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 657 | encode_create_maxsz + \ |
Trond Myklebust | 56ae19f | 2005-10-27 22:12:40 -0400 | [diff] [blame] | 658 | encode_getfh_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 659 | encode_getattr_maxsz + \ |
Trond Myklebust | 56ae19f | 2005-10-27 22:12:40 -0400 | [diff] [blame] | 660 | encode_restorefh_maxsz + \ |
| 661 | encode_getattr_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 662 | #define NFS4_dec_create_sz (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 663 | decode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 664 | decode_putfh_maxsz + \ |
Trond Myklebust | 56ae19f | 2005-10-27 22:12:40 -0400 | [diff] [blame] | 665 | decode_savefh_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 666 | decode_create_maxsz + \ |
Trond Myklebust | 56ae19f | 2005-10-27 22:12:40 -0400 | [diff] [blame] | 667 | decode_getfh_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 668 | decode_getattr_maxsz + \ |
Trond Myklebust | 56ae19f | 2005-10-27 22:12:40 -0400 | [diff] [blame] | 669 | decode_restorefh_maxsz + \ |
| 670 | decode_getattr_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 671 | #define NFS4_enc_pathconf_sz (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 672 | encode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 673 | encode_putfh_maxsz + \ |
| 674 | encode_getattr_maxsz) |
| 675 | #define NFS4_dec_pathconf_sz (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 676 | decode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 677 | decode_putfh_maxsz + \ |
| 678 | decode_getattr_maxsz) |
| 679 | #define NFS4_enc_statfs_sz (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 680 | encode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 681 | encode_putfh_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 682 | encode_statfs_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 683 | #define NFS4_dec_statfs_sz (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 684 | decode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 685 | decode_putfh_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 686 | decode_statfs_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 687 | #define NFS4_enc_server_caps_sz (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 688 | encode_sequence_maxsz + \ |
Trond Myklebust | ab91f26 | 2007-02-02 14:47:17 -0800 | [diff] [blame] | 689 | encode_putfh_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 690 | encode_getattr_maxsz) |
| 691 | #define NFS4_dec_server_caps_sz (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 692 | decode_sequence_maxsz + \ |
Trond Myklebust | ab91f26 | 2007-02-02 14:47:17 -0800 | [diff] [blame] | 693 | decode_putfh_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 694 | decode_getattr_maxsz) |
| 695 | #define NFS4_enc_delegreturn_sz (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 696 | encode_sequence_maxsz + \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 697 | encode_putfh_maxsz + \ |
Trond Myklebust | fa178f2 | 2006-01-03 09:55:38 +0100 | [diff] [blame] | 698 | encode_delegreturn_maxsz + \ |
| 699 | encode_getattr_maxsz) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 700 | #define NFS4_dec_delegreturn_sz (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 701 | decode_sequence_maxsz + \ |
Trond Myklebust | fa178f2 | 2006-01-03 09:55:38 +0100 | [diff] [blame] | 702 | decode_delegreturn_maxsz + \ |
| 703 | decode_getattr_maxsz) |
J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 704 | #define NFS4_enc_getacl_sz (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 705 | encode_sequence_maxsz + \ |
J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 706 | encode_putfh_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 707 | encode_getacl_maxsz) |
J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 708 | #define NFS4_dec_getacl_sz (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 709 | decode_sequence_maxsz + \ |
J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 710 | decode_putfh_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 711 | decode_getacl_maxsz) |
J. Bruce Fields | 23ec696 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 712 | #define NFS4_enc_setacl_sz (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 713 | encode_sequence_maxsz + \ |
J. Bruce Fields | 23ec696 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 714 | encode_putfh_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 715 | encode_setacl_maxsz) |
J. Bruce Fields | 23ec696 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 716 | #define NFS4_dec_setacl_sz (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 717 | decode_sequence_maxsz + \ |
J. Bruce Fields | 23ec696 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 718 | decode_putfh_maxsz + \ |
Trond Myklebust | 9104a55 | 2007-07-17 21:52:42 -0400 | [diff] [blame] | 719 | decode_setacl_maxsz) |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 720 | #define NFS4_enc_fs_locations_sz \ |
| 721 | (compound_encode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 722 | encode_sequence_maxsz + \ |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 723 | encode_putfh_maxsz + \ |
Trond Myklebust | e688962 | 2007-07-02 13:58:30 -0400 | [diff] [blame] | 724 | encode_lookup_maxsz + \ |
| 725 | encode_fs_locations_maxsz) |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 726 | #define NFS4_dec_fs_locations_sz \ |
| 727 | (compound_decode_hdr_maxsz + \ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 728 | decode_sequence_maxsz + \ |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 729 | decode_putfh_maxsz + \ |
Trond Myklebust | e688962 | 2007-07-02 13:58:30 -0400 | [diff] [blame] | 730 | decode_lookup_maxsz + \ |
| 731 | decode_fs_locations_maxsz) |
Bryan Schumaker | 5a5ea0d | 2011-03-24 17:12:29 +0000 | [diff] [blame] | 732 | #define NFS4_enc_secinfo_sz (compound_encode_hdr_maxsz + \ |
| 733 | encode_sequence_maxsz + \ |
| 734 | encode_putfh_maxsz + \ |
| 735 | encode_secinfo_maxsz) |
| 736 | #define NFS4_dec_secinfo_sz (compound_decode_hdr_maxsz + \ |
| 737 | decode_sequence_maxsz + \ |
| 738 | decode_putfh_maxsz + \ |
| 739 | decode_secinfo_maxsz) |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 740 | #if defined(CONFIG_NFS_V4_1) |
| 741 | #define NFS4_enc_exchange_id_sz \ |
| 742 | (compound_encode_hdr_maxsz + \ |
| 743 | encode_exchange_id_maxsz) |
| 744 | #define NFS4_dec_exchange_id_sz \ |
| 745 | (compound_decode_hdr_maxsz + \ |
| 746 | decode_exchange_id_maxsz) |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 747 | #define NFS4_enc_create_session_sz \ |
| 748 | (compound_encode_hdr_maxsz + \ |
| 749 | encode_create_session_maxsz) |
| 750 | #define NFS4_dec_create_session_sz \ |
| 751 | (compound_decode_hdr_maxsz + \ |
| 752 | decode_create_session_maxsz) |
Andy Adamson | 0f3e66c | 2009-04-01 09:22:34 -0400 | [diff] [blame] | 753 | #define NFS4_enc_destroy_session_sz (compound_encode_hdr_maxsz + \ |
| 754 | encode_destroy_session_maxsz) |
| 755 | #define NFS4_dec_destroy_session_sz (compound_decode_hdr_maxsz + \ |
| 756 | decode_destroy_session_maxsz) |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 757 | #define NFS4_enc_sequence_sz \ |
| 758 | (compound_decode_hdr_maxsz + \ |
| 759 | encode_sequence_maxsz) |
| 760 | #define NFS4_dec_sequence_sz \ |
| 761 | (compound_decode_hdr_maxsz + \ |
| 762 | decode_sequence_maxsz) |
Andy Adamson | 2050f0c | 2009-04-01 09:22:30 -0400 | [diff] [blame] | 763 | #define NFS4_enc_get_lease_time_sz (compound_encode_hdr_maxsz + \ |
| 764 | encode_sequence_maxsz + \ |
| 765 | encode_putrootfh_maxsz + \ |
| 766 | encode_fsinfo_maxsz) |
| 767 | #define NFS4_dec_get_lease_time_sz (compound_decode_hdr_maxsz + \ |
| 768 | decode_sequence_maxsz + \ |
| 769 | decode_putrootfh_maxsz + \ |
| 770 | decode_fsinfo_maxsz) |
Ricardo Labiaga | 18019753 | 2009-12-05 16:08:40 -0500 | [diff] [blame] | 771 | #define NFS4_enc_reclaim_complete_sz (compound_encode_hdr_maxsz + \ |
| 772 | encode_sequence_maxsz + \ |
| 773 | encode_reclaim_complete_maxsz) |
| 774 | #define NFS4_dec_reclaim_complete_sz (compound_decode_hdr_maxsz + \ |
| 775 | decode_sequence_maxsz + \ |
| 776 | decode_reclaim_complete_maxsz) |
Andy Adamson | 7f11d8d | 2011-07-30 20:52:35 -0400 | [diff] [blame] | 777 | #define NFS4_enc_getdevicelist_sz (compound_encode_hdr_maxsz + \ |
| 778 | encode_sequence_maxsz + \ |
| 779 | encode_putfh_maxsz + \ |
| 780 | encode_getdevicelist_maxsz) |
| 781 | #define NFS4_dec_getdevicelist_sz (compound_decode_hdr_maxsz + \ |
| 782 | decode_sequence_maxsz + \ |
| 783 | decode_putfh_maxsz + \ |
| 784 | decode_getdevicelist_maxsz) |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 785 | #define NFS4_enc_getdeviceinfo_sz (compound_encode_hdr_maxsz + \ |
| 786 | encode_sequence_maxsz +\ |
| 787 | encode_getdeviceinfo_maxsz) |
| 788 | #define NFS4_dec_getdeviceinfo_sz (compound_decode_hdr_maxsz + \ |
| 789 | decode_sequence_maxsz + \ |
| 790 | decode_getdeviceinfo_maxsz) |
| 791 | #define NFS4_enc_layoutget_sz (compound_encode_hdr_maxsz + \ |
| 792 | encode_sequence_maxsz + \ |
| 793 | encode_putfh_maxsz + \ |
| 794 | encode_layoutget_maxsz) |
| 795 | #define NFS4_dec_layoutget_sz (compound_decode_hdr_maxsz + \ |
| 796 | decode_sequence_maxsz + \ |
| 797 | decode_putfh_maxsz + \ |
| 798 | decode_layoutget_maxsz) |
Andy Adamson | 863a3c6 | 2011-03-23 13:27:54 +0000 | [diff] [blame] | 799 | #define NFS4_enc_layoutcommit_sz (compound_encode_hdr_maxsz + \ |
| 800 | encode_sequence_maxsz +\ |
| 801 | encode_putfh_maxsz + \ |
| 802 | encode_layoutcommit_maxsz + \ |
| 803 | encode_getattr_maxsz) |
| 804 | #define NFS4_dec_layoutcommit_sz (compound_decode_hdr_maxsz + \ |
| 805 | decode_sequence_maxsz + \ |
| 806 | decode_putfh_maxsz + \ |
| 807 | decode_layoutcommit_maxsz + \ |
| 808 | decode_getattr_maxsz) |
Benny Halevy | cbe8260 | 2011-05-22 19:52:37 +0300 | [diff] [blame] | 809 | #define NFS4_enc_layoutreturn_sz (compound_encode_hdr_maxsz + \ |
| 810 | encode_sequence_maxsz + \ |
| 811 | encode_putfh_maxsz + \ |
| 812 | encode_layoutreturn_maxsz) |
| 813 | #define NFS4_dec_layoutreturn_sz (compound_decode_hdr_maxsz + \ |
| 814 | decode_sequence_maxsz + \ |
| 815 | decode_putfh_maxsz + \ |
| 816 | decode_layoutreturn_maxsz) |
Bryan Schumaker | fca78d6 | 2011-06-02 14:59:07 -0400 | [diff] [blame] | 817 | #define NFS4_enc_secinfo_no_name_sz (compound_encode_hdr_maxsz + \ |
| 818 | encode_sequence_maxsz + \ |
| 819 | encode_putrootfh_maxsz +\ |
| 820 | encode_secinfo_no_name_maxsz) |
| 821 | #define NFS4_dec_secinfo_no_name_sz (compound_decode_hdr_maxsz + \ |
| 822 | decode_sequence_maxsz + \ |
| 823 | decode_putrootfh_maxsz + \ |
| 824 | decode_secinfo_no_name_maxsz) |
Bryan Schumaker | 7d97479 | 2011-06-02 14:59:08 -0400 | [diff] [blame] | 825 | #define NFS4_enc_test_stateid_sz (compound_encode_hdr_maxsz + \ |
| 826 | encode_sequence_maxsz + \ |
| 827 | encode_test_stateid_maxsz) |
| 828 | #define NFS4_dec_test_stateid_sz (compound_decode_hdr_maxsz + \ |
| 829 | decode_sequence_maxsz + \ |
| 830 | decode_test_stateid_maxsz) |
Bryan Schumaker | 9aeda35 | 2011-06-02 14:59:09 -0400 | [diff] [blame] | 831 | #define NFS4_enc_free_stateid_sz (compound_encode_hdr_maxsz + \ |
| 832 | encode_sequence_maxsz + \ |
| 833 | encode_free_stateid_maxsz) |
| 834 | #define NFS4_dec_free_stateid_sz (compound_decode_hdr_maxsz + \ |
| 835 | decode_sequence_maxsz + \ |
| 836 | decode_free_stateid_maxsz) |
Alexandros Batsakis | 2449ea2 | 2009-12-05 13:36:55 -0500 | [diff] [blame] | 837 | |
| 838 | const u32 nfs41_maxwrite_overhead = ((RPC_MAX_HEADER_WITH_AUTH + |
| 839 | compound_encode_hdr_maxsz + |
| 840 | encode_sequence_maxsz + |
| 841 | encode_putfh_maxsz + |
| 842 | encode_getattr_maxsz) * |
| 843 | XDR_UNIT); |
| 844 | |
| 845 | const u32 nfs41_maxread_overhead = ((RPC_MAX_HEADER_WITH_AUTH + |
| 846 | compound_decode_hdr_maxsz + |
| 847 | decode_sequence_maxsz + |
| 848 | decode_putfh_maxsz) * |
| 849 | XDR_UNIT); |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 850 | #endif /* CONFIG_NFS_V4_1 */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 851 | |
Weston Andros Adamson | db8ac8b | 2012-02-17 15:20:24 -0500 | [diff] [blame] | 852 | static unsigned short send_implementation_id = 1; |
| 853 | |
| 854 | module_param(send_implementation_id, ushort, 0644); |
| 855 | MODULE_PARM_DESC(send_implementation_id, |
| 856 | "Send implementation ID with NFSv4.1 exchange_id"); |
| 857 | |
Trond Myklebust | bca7947 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 858 | static const umode_t nfs_type2fmt[] = { |
| 859 | [NF4BAD] = 0, |
| 860 | [NF4REG] = S_IFREG, |
| 861 | [NF4DIR] = S_IFDIR, |
| 862 | [NF4BLK] = S_IFBLK, |
| 863 | [NF4CHR] = S_IFCHR, |
| 864 | [NF4LNK] = S_IFLNK, |
| 865 | [NF4SOCK] = S_IFSOCK, |
| 866 | [NF4FIFO] = S_IFIFO, |
| 867 | [NF4ATTRDIR] = 0, |
| 868 | [NF4NAMEDATTR] = 0, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 869 | }; |
| 870 | |
| 871 | struct compound_hdr { |
| 872 | int32_t status; |
| 873 | uint32_t nops; |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 874 | __be32 * nops_p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 875 | uint32_t taglen; |
| 876 | char * tag; |
Benny Halevy | 0c4e8c1 | 2009-04-01 09:22:07 -0400 | [diff] [blame] | 877 | uint32_t replen; /* expected reply words */ |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 878 | u32 minorversion; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 879 | }; |
| 880 | |
Benny Halevy | 13c65ce | 2009-08-14 17:19:25 +0300 | [diff] [blame] | 881 | static __be32 *reserve_space(struct xdr_stream *xdr, size_t nbytes) |
| 882 | { |
| 883 | __be32 *p = xdr_reserve_space(xdr, nbytes); |
| 884 | BUG_ON(!p); |
| 885 | return p; |
| 886 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 887 | |
Trond Myklebust | cb17e55 | 2012-03-04 18:13:56 -0500 | [diff] [blame] | 888 | static void encode_opaque_fixed(struct xdr_stream *xdr, const void *buf, size_t len) |
| 889 | { |
| 890 | __be32 *p; |
| 891 | |
| 892 | p = xdr_reserve_space(xdr, len); |
| 893 | xdr_encode_opaque_fixed(p, buf, len); |
| 894 | } |
| 895 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 896 | static void encode_string(struct xdr_stream *xdr, unsigned int len, const char *str) |
| 897 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 898 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 899 | |
| 900 | p = xdr_reserve_space(xdr, 4 + len); |
| 901 | BUG_ON(p == NULL); |
| 902 | xdr_encode_opaque(p, str, len); |
| 903 | } |
| 904 | |
Benny Halevy | 0c4e8c1 | 2009-04-01 09:22:07 -0400 | [diff] [blame] | 905 | static void encode_compound_hdr(struct xdr_stream *xdr, |
| 906 | struct rpc_rqst *req, |
| 907 | struct compound_hdr *hdr) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 908 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 909 | __be32 *p; |
Trond Myklebust | a17c215 | 2010-07-31 14:29:08 -0400 | [diff] [blame] | 910 | struct rpc_auth *auth = req->rq_cred->cr_auth; |
Benny Halevy | 0c4e8c1 | 2009-04-01 09:22:07 -0400 | [diff] [blame] | 911 | |
| 912 | /* initialize running count of expected bytes in reply. |
| 913 | * NOTE: the replied tag SHOULD be the same is the one sent, |
| 914 | * but this is not required as a MUST for the server to do so. */ |
| 915 | hdr->replen = RPC_REPHDRSIZE + auth->au_rslack + 3 + hdr->taglen; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 916 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 917 | BUG_ON(hdr->taglen > NFS4_MAXTAGLEN); |
Benny Halevy | 811652b | 2009-08-14 17:19:34 +0300 | [diff] [blame] | 918 | p = reserve_space(xdr, 4 + hdr->taglen + 8); |
| 919 | p = xdr_encode_opaque(p, hdr->tag, hdr->taglen); |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 920 | *p++ = cpu_to_be32(hdr->minorversion); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 921 | hdr->nops_p = p; |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 922 | *p = cpu_to_be32(hdr->nops); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 923 | } |
| 924 | |
| 925 | static void encode_nops(struct compound_hdr *hdr) |
| 926 | { |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 927 | BUG_ON(hdr->nops > NFS4_MAX_OPS); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 928 | *hdr->nops_p = htonl(hdr->nops); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 929 | } |
| 930 | |
Trond Myklebust | ea9d23f | 2012-03-04 18:13:56 -0500 | [diff] [blame^] | 931 | static void encode_nfs4_stateid(struct xdr_stream *xdr, const nfs4_stateid *stateid) |
| 932 | { |
| 933 | encode_opaque_fixed(xdr, stateid->data, NFS4_STATEID_SIZE); |
| 934 | } |
| 935 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 936 | static void encode_nfs4_verifier(struct xdr_stream *xdr, const nfs4_verifier *verf) |
| 937 | { |
Trond Myklebust | cb17e55 | 2012-03-04 18:13:56 -0500 | [diff] [blame] | 938 | encode_opaque_fixed(xdr, verf->data, NFS4_VERIFIER_SIZE); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 939 | } |
| 940 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 941 | 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] | 942 | { |
| 943 | char owner_name[IDMAP_NAMESZ]; |
| 944 | char owner_group[IDMAP_NAMESZ]; |
| 945 | int owner_namelen = 0; |
| 946 | int owner_grouplen = 0; |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 947 | __be32 *p; |
| 948 | __be32 *q; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 949 | int len; |
| 950 | uint32_t bmval0 = 0; |
| 951 | uint32_t bmval1 = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 952 | |
| 953 | /* |
| 954 | * We reserve enough space to write the entire attribute buffer at once. |
| 955 | * In the worst-case, this would be |
| 956 | * 12(bitmap) + 4(attrlen) + 8(size) + 4(mode) + 4(atime) + 4(mtime) |
| 957 | * = 36 bytes, plus any contribution from variable-length fields |
J. Bruce Fields | 23ec696 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 958 | * such as owner/group. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 959 | */ |
| 960 | len = 16; |
| 961 | |
| 962 | /* Sigh */ |
| 963 | if (iap->ia_valid & ATTR_SIZE) |
| 964 | len += 8; |
| 965 | if (iap->ia_valid & ATTR_MODE) |
| 966 | len += 4; |
| 967 | if (iap->ia_valid & ATTR_UID) { |
Trond Myklebust | e4fd72a | 2011-02-22 15:44:31 -0800 | [diff] [blame] | 968 | 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] | 969 | if (owner_namelen < 0) { |
Chuck Lever | fe82a18 | 2007-09-11 18:01:10 -0400 | [diff] [blame] | 970 | dprintk("nfs: couldn't resolve uid %d to string\n", |
| 971 | iap->ia_uid); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 972 | /* XXX */ |
| 973 | strcpy(owner_name, "nobody"); |
| 974 | owner_namelen = sizeof("nobody") - 1; |
| 975 | /* goto out; */ |
| 976 | } |
| 977 | len += 4 + (XDR_QUADLEN(owner_namelen) << 2); |
| 978 | } |
| 979 | if (iap->ia_valid & ATTR_GID) { |
Trond Myklebust | e4fd72a | 2011-02-22 15:44:31 -0800 | [diff] [blame] | 980 | 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] | 981 | if (owner_grouplen < 0) { |
Chuck Lever | fe82a18 | 2007-09-11 18:01:10 -0400 | [diff] [blame] | 982 | dprintk("nfs: couldn't resolve gid %d to string\n", |
| 983 | iap->ia_gid); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 984 | strcpy(owner_group, "nobody"); |
| 985 | owner_grouplen = sizeof("nobody") - 1; |
| 986 | /* goto out; */ |
| 987 | } |
| 988 | len += 4 + (XDR_QUADLEN(owner_grouplen) << 2); |
| 989 | } |
| 990 | if (iap->ia_valid & ATTR_ATIME_SET) |
| 991 | len += 16; |
| 992 | else if (iap->ia_valid & ATTR_ATIME) |
| 993 | len += 4; |
| 994 | if (iap->ia_valid & ATTR_MTIME_SET) |
| 995 | len += 16; |
| 996 | else if (iap->ia_valid & ATTR_MTIME) |
| 997 | len += 4; |
Benny Halevy | 13c65ce | 2009-08-14 17:19:25 +0300 | [diff] [blame] | 998 | p = reserve_space(xdr, len); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 999 | |
| 1000 | /* |
| 1001 | * We write the bitmap length now, but leave the bitmap and the attribute |
| 1002 | * buffer length to be backfilled at the end of this routine. |
| 1003 | */ |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1004 | *p++ = cpu_to_be32(2); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1005 | q = p; |
| 1006 | p += 3; |
| 1007 | |
| 1008 | if (iap->ia_valid & ATTR_SIZE) { |
| 1009 | bmval0 |= FATTR4_WORD0_SIZE; |
Benny Halevy | b95be5a | 2009-08-14 17:19:01 +0300 | [diff] [blame] | 1010 | p = xdr_encode_hyper(p, iap->ia_size); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1011 | } |
| 1012 | if (iap->ia_valid & ATTR_MODE) { |
| 1013 | bmval1 |= FATTR4_WORD1_MODE; |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1014 | *p++ = cpu_to_be32(iap->ia_mode & S_IALLUGO); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1015 | } |
| 1016 | if (iap->ia_valid & ATTR_UID) { |
| 1017 | bmval1 |= FATTR4_WORD1_OWNER; |
Benny Halevy | 811652b | 2009-08-14 17:19:34 +0300 | [diff] [blame] | 1018 | p = xdr_encode_opaque(p, owner_name, owner_namelen); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1019 | } |
| 1020 | if (iap->ia_valid & ATTR_GID) { |
| 1021 | bmval1 |= FATTR4_WORD1_OWNER_GROUP; |
Benny Halevy | 811652b | 2009-08-14 17:19:34 +0300 | [diff] [blame] | 1022 | p = xdr_encode_opaque(p, owner_group, owner_grouplen); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1023 | } |
| 1024 | if (iap->ia_valid & ATTR_ATIME_SET) { |
| 1025 | bmval1 |= FATTR4_WORD1_TIME_ACCESS_SET; |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1026 | *p++ = cpu_to_be32(NFS4_SET_TO_CLIENT_TIME); |
| 1027 | *p++ = cpu_to_be32(0); |
Trond Myklebust | d3f6baa | 2010-06-22 08:52:39 -0400 | [diff] [blame] | 1028 | *p++ = cpu_to_be32(iap->ia_atime.tv_sec); |
| 1029 | *p++ = cpu_to_be32(iap->ia_atime.tv_nsec); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1030 | } |
| 1031 | else if (iap->ia_valid & ATTR_ATIME) { |
| 1032 | bmval1 |= FATTR4_WORD1_TIME_ACCESS_SET; |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1033 | *p++ = cpu_to_be32(NFS4_SET_TO_SERVER_TIME); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1034 | } |
| 1035 | if (iap->ia_valid & ATTR_MTIME_SET) { |
| 1036 | bmval1 |= FATTR4_WORD1_TIME_MODIFY_SET; |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1037 | *p++ = cpu_to_be32(NFS4_SET_TO_CLIENT_TIME); |
| 1038 | *p++ = cpu_to_be32(0); |
| 1039 | *p++ = cpu_to_be32(iap->ia_mtime.tv_sec); |
| 1040 | *p++ = cpu_to_be32(iap->ia_mtime.tv_nsec); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1041 | } |
| 1042 | else if (iap->ia_valid & ATTR_MTIME) { |
| 1043 | bmval1 |= FATTR4_WORD1_TIME_MODIFY_SET; |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1044 | *p++ = cpu_to_be32(NFS4_SET_TO_SERVER_TIME); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1045 | } |
Andy Adamson | 6c0195a | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 1046 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1047 | /* |
| 1048 | * Now we backfill the bitmap and the attribute buffer length. |
| 1049 | */ |
| 1050 | if (len != ((char *)p - (char *)q) + 4) { |
Weston Andros Adamson | f9fd2d9 | 2012-01-26 13:32:22 -0500 | [diff] [blame] | 1051 | printk(KERN_ERR "NFS: Attr length error, %u != %Zu\n", |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1052 | len, ((char *)p - (char *)q) + 4); |
| 1053 | BUG(); |
| 1054 | } |
| 1055 | len = (char *)p - (char *)q - 12; |
| 1056 | *q++ = htonl(bmval0); |
| 1057 | *q++ = htonl(bmval1); |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1058 | *q = htonl(len); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1059 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1060 | /* out: */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1061 | } |
| 1062 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1063 | 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] | 1064 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 1065 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1066 | |
Benny Halevy | 13c65ce | 2009-08-14 17:19:25 +0300 | [diff] [blame] | 1067 | p = reserve_space(xdr, 8); |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1068 | *p++ = cpu_to_be32(OP_ACCESS); |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1069 | *p = cpu_to_be32(access); |
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_access_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_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] | 1075 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 1076 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1077 | |
Trond Myklebust | ea9d23f | 2012-03-04 18:13:56 -0500 | [diff] [blame^] | 1078 | p = reserve_space(xdr, 8); |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1079 | *p++ = cpu_to_be32(OP_CLOSE); |
Trond Myklebust | ea9d23f | 2012-03-04 18:13:56 -0500 | [diff] [blame^] | 1080 | *p = cpu_to_be32(arg->seqid->sequence->counter); |
| 1081 | encode_nfs4_stateid(xdr, arg->stateid); |
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_close_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_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] | 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, 16); |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1091 | *p++ = cpu_to_be32(OP_COMMIT); |
Benny Halevy | b95be5a | 2009-08-14 17:19:01 +0300 | [diff] [blame] | 1092 | p = xdr_encode_hyper(p, args->offset); |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1093 | *p = cpu_to_be32(args->count); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 1094 | hdr->nops++; |
Benny Halevy | dadf0c2 | 2009-04-01 09:22:08 -0400 | [diff] [blame] | 1095 | hdr->replen += decode_commit_maxsz; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1096 | } |
| 1097 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1098 | 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] | 1099 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 1100 | __be32 *p; |
Andy Adamson | 6c0195a | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 1101 | |
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(OP_CREATE); |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1104 | *p = cpu_to_be32(create->ftype); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1105 | |
| 1106 | switch (create->ftype) { |
| 1107 | case NF4LNK: |
Benny Halevy | 13c65ce | 2009-08-14 17:19:25 +0300 | [diff] [blame] | 1108 | p = reserve_space(xdr, 4); |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1109 | *p = cpu_to_be32(create->u.symlink.len); |
Chuck Lever | 94a6d75 | 2006-08-22 20:06:23 -0400 | [diff] [blame] | 1110 | 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] | 1111 | break; |
| 1112 | |
| 1113 | case NF4BLK: case NF4CHR: |
Benny Halevy | 13c65ce | 2009-08-14 17:19:25 +0300 | [diff] [blame] | 1114 | p = reserve_space(xdr, 8); |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1115 | *p++ = cpu_to_be32(create->u.device.specdata1); |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1116 | *p = cpu_to_be32(create->u.device.specdata2); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1117 | break; |
| 1118 | |
| 1119 | default: |
| 1120 | break; |
| 1121 | } |
| 1122 | |
Benny Halevy | 811652b | 2009-08-14 17:19:34 +0300 | [diff] [blame] | 1123 | encode_string(xdr, create->name->len, create->name->name); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 1124 | hdr->nops++; |
Benny Halevy | dadf0c2 | 2009-04-01 09:22:08 -0400 | [diff] [blame] | 1125 | hdr->replen += decode_create_maxsz; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1126 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1127 | encode_attrs(xdr, create->attrs, create->server); |
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_one(struct xdr_stream *xdr, uint32_t bitmap, 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, 12); |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1135 | *p++ = cpu_to_be32(OP_GETATTR); |
| 1136 | *p++ = cpu_to_be32(1); |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1137 | *p = cpu_to_be32(bitmap); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 1138 | hdr->nops++; |
Benny Halevy | dadf0c2 | 2009-04-01 09:22:08 -0400 | [diff] [blame] | 1139 | hdr->replen += decode_getattr_maxsz; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1140 | } |
| 1141 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1142 | 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] | 1143 | { |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 1144 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1145 | |
Benny Halevy | 13c65ce | 2009-08-14 17:19:25 +0300 | [diff] [blame] | 1146 | p = reserve_space(xdr, 16); |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1147 | *p++ = cpu_to_be32(OP_GETATTR); |
| 1148 | *p++ = cpu_to_be32(2); |
| 1149 | *p++ = cpu_to_be32(bm0); |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1150 | *p = cpu_to_be32(bm1); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 1151 | hdr->nops++; |
Benny Halevy | dadf0c2 | 2009-04-01 09:22:08 -0400 | [diff] [blame] | 1152 | hdr->replen += decode_getattr_maxsz; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1153 | } |
| 1154 | |
Fred Isaman | dae100c | 2011-07-30 20:52:37 -0400 | [diff] [blame] | 1155 | static void |
| 1156 | encode_getattr_three(struct xdr_stream *xdr, |
| 1157 | uint32_t bm0, uint32_t bm1, uint32_t bm2, |
| 1158 | struct compound_hdr *hdr) |
| 1159 | { |
| 1160 | __be32 *p; |
| 1161 | |
| 1162 | p = reserve_space(xdr, 4); |
| 1163 | *p = cpu_to_be32(OP_GETATTR); |
| 1164 | if (bm2) { |
| 1165 | p = reserve_space(xdr, 16); |
| 1166 | *p++ = cpu_to_be32(3); |
| 1167 | *p++ = cpu_to_be32(bm0); |
| 1168 | *p++ = cpu_to_be32(bm1); |
| 1169 | *p = cpu_to_be32(bm2); |
| 1170 | } else if (bm1) { |
| 1171 | p = reserve_space(xdr, 12); |
| 1172 | *p++ = cpu_to_be32(2); |
| 1173 | *p++ = cpu_to_be32(bm0); |
| 1174 | *p = cpu_to_be32(bm1); |
| 1175 | } else { |
| 1176 | p = reserve_space(xdr, 8); |
| 1177 | *p++ = cpu_to_be32(1); |
| 1178 | *p = cpu_to_be32(bm0); |
| 1179 | } |
| 1180 | hdr->nops++; |
| 1181 | hdr->replen += decode_getattr_maxsz; |
| 1182 | } |
| 1183 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1184 | 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] | 1185 | { |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1186 | encode_getattr_two(xdr, bitmask[0] & nfs4_fattr_bitmap[0], |
| 1187 | bitmask[1] & nfs4_fattr_bitmap[1], hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1188 | } |
| 1189 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1190 | 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] | 1191 | { |
Fred Isaman | dae100c | 2011-07-30 20:52:37 -0400 | [diff] [blame] | 1192 | encode_getattr_three(xdr, |
| 1193 | bitmask[0] & nfs4_fsinfo_bitmap[0], |
| 1194 | bitmask[1] & nfs4_fsinfo_bitmap[1], |
| 1195 | bitmask[2] & nfs4_fsinfo_bitmap[2], |
| 1196 | hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1197 | } |
| 1198 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1199 | 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] | 1200 | { |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1201 | encode_getattr_two(xdr, bitmask[0] & nfs4_fs_locations_bitmap[0], |
| 1202 | bitmask[1] & nfs4_fs_locations_bitmap[1], hdr); |
Manoj Naik | 830b8e3 | 2006-06-09 09:34:25 -0400 | [diff] [blame] | 1203 | } |
| 1204 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1205 | static void encode_getfh(struct xdr_stream *xdr, struct compound_hdr *hdr) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1206 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 1207 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1208 | |
Benny Halevy | 13c65ce | 2009-08-14 17:19:25 +0300 | [diff] [blame] | 1209 | p = reserve_space(xdr, 4); |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1210 | *p = cpu_to_be32(OP_GETFH); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 1211 | hdr->nops++; |
Benny Halevy | dadf0c2 | 2009-04-01 09:22:08 -0400 | [diff] [blame] | 1212 | hdr->replen += decode_getfh_maxsz; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1213 | } |
| 1214 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1215 | 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] | 1216 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 1217 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1218 | |
Benny Halevy | 13c65ce | 2009-08-14 17:19:25 +0300 | [diff] [blame] | 1219 | p = reserve_space(xdr, 8 + name->len); |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1220 | *p++ = cpu_to_be32(OP_LINK); |
Benny Halevy | 811652b | 2009-08-14 17:19:34 +0300 | [diff] [blame] | 1221 | xdr_encode_opaque(p, name->name, name->len); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 1222 | hdr->nops++; |
Benny Halevy | dadf0c2 | 2009-04-01 09:22:08 -0400 | [diff] [blame] | 1223 | hdr->replen += decode_link_maxsz; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1224 | } |
| 1225 | |
Trond Myklebust | 911d1aa | 2006-01-03 09:55:16 +0100 | [diff] [blame] | 1226 | static inline int nfs4_lock_type(struct file_lock *fl, int block) |
| 1227 | { |
| 1228 | if ((fl->fl_type & (F_RDLCK|F_WRLCK|F_UNLCK)) == F_RDLCK) |
| 1229 | return block ? NFS4_READW_LT : NFS4_READ_LT; |
| 1230 | return block ? NFS4_WRITEW_LT : NFS4_WRITE_LT; |
| 1231 | } |
| 1232 | |
| 1233 | static inline uint64_t nfs4_lock_length(struct file_lock *fl) |
| 1234 | { |
| 1235 | if (fl->fl_end == OFFSET_MAX) |
| 1236 | return ~(uint64_t)0; |
| 1237 | return fl->fl_end - fl->fl_start + 1; |
| 1238 | } |
| 1239 | |
Trond Myklebust | daccbde | 2010-06-25 18:11:43 -0400 | [diff] [blame] | 1240 | static void encode_lockowner(struct xdr_stream *xdr, const struct nfs_lowner *lowner) |
| 1241 | { |
| 1242 | __be32 *p; |
| 1243 | |
Trond Myklebust | d035c36 | 2010-12-21 10:45:27 -0500 | [diff] [blame] | 1244 | p = reserve_space(xdr, 32); |
Trond Myklebust | daccbde | 2010-06-25 18:11:43 -0400 | [diff] [blame] | 1245 | p = xdr_encode_hyper(p, lowner->clientid); |
Trond Myklebust | d035c36 | 2010-12-21 10:45:27 -0500 | [diff] [blame] | 1246 | *p++ = cpu_to_be32(20); |
Trond Myklebust | daccbde | 2010-06-25 18:11:43 -0400 | [diff] [blame] | 1247 | p = xdr_encode_opaque_fixed(p, "lock id:", 8); |
Trond Myklebust | d035c36 | 2010-12-21 10:45:27 -0500 | [diff] [blame] | 1248 | *p++ = cpu_to_be32(lowner->s_dev); |
Trond Myklebust | daccbde | 2010-06-25 18:11:43 -0400 | [diff] [blame] | 1249 | xdr_encode_hyper(p, lowner->id); |
| 1250 | } |
| 1251 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1252 | /* |
| 1253 | * opcode,type,reclaim,offset,length,new_lock_owner = 32 |
| 1254 | * open_seqid,open_stateid,lock_seqid,lock_owner.clientid, lock_owner.id = 40 |
| 1255 | */ |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1256 | 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] | 1257 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 1258 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1259 | |
Benny Halevy | 13c65ce | 2009-08-14 17:19:25 +0300 | [diff] [blame] | 1260 | p = reserve_space(xdr, 32); |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1261 | *p++ = cpu_to_be32(OP_LOCK); |
| 1262 | *p++ = cpu_to_be32(nfs4_lock_type(args->fl, args->block)); |
| 1263 | *p++ = cpu_to_be32(args->reclaim); |
Benny Halevy | b95be5a | 2009-08-14 17:19:01 +0300 | [diff] [blame] | 1264 | p = xdr_encode_hyper(p, args->fl->fl_start); |
| 1265 | p = xdr_encode_hyper(p, nfs4_lock_length(args->fl)); |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1266 | *p = cpu_to_be32(args->new_lock_owner); |
Trond Myklebust | 911d1aa | 2006-01-03 09:55:16 +0100 | [diff] [blame] | 1267 | if (args->new_lock_owner){ |
Trond Myklebust | ea9d23f | 2012-03-04 18:13:56 -0500 | [diff] [blame^] | 1268 | p = reserve_space(xdr, 4); |
| 1269 | *p = cpu_to_be32(args->open_seqid->sequence->counter); |
| 1270 | encode_nfs4_stateid(xdr, args->open_stateid); |
| 1271 | p = reserve_space(xdr, 4); |
| 1272 | *p = cpu_to_be32(args->lock_seqid->sequence->counter); |
Trond Myklebust | daccbde | 2010-06-25 18:11:43 -0400 | [diff] [blame] | 1273 | encode_lockowner(xdr, &args->lock_owner); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1274 | } |
| 1275 | else { |
Trond Myklebust | ea9d23f | 2012-03-04 18:13:56 -0500 | [diff] [blame^] | 1276 | encode_nfs4_stateid(xdr, args->lock_stateid); |
| 1277 | p = reserve_space(xdr, 4); |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1278 | *p = cpu_to_be32(args->lock_seqid->sequence->counter); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1279 | } |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 1280 | hdr->nops++; |
Benny Halevy | dadf0c2 | 2009-04-01 09:22:08 -0400 | [diff] [blame] | 1281 | hdr->replen += decode_lock_maxsz; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1282 | } |
| 1283 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1284 | 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] | 1285 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 1286 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1287 | |
Trond Myklebust | daccbde | 2010-06-25 18:11:43 -0400 | [diff] [blame] | 1288 | p = reserve_space(xdr, 24); |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1289 | *p++ = cpu_to_be32(OP_LOCKT); |
| 1290 | *p++ = cpu_to_be32(nfs4_lock_type(args->fl, 0)); |
Benny Halevy | b95be5a | 2009-08-14 17:19:01 +0300 | [diff] [blame] | 1291 | p = xdr_encode_hyper(p, args->fl->fl_start); |
| 1292 | p = xdr_encode_hyper(p, nfs4_lock_length(args->fl)); |
Trond Myklebust | daccbde | 2010-06-25 18:11:43 -0400 | [diff] [blame] | 1293 | encode_lockowner(xdr, &args->lock_owner); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 1294 | hdr->nops++; |
Benny Halevy | dadf0c2 | 2009-04-01 09:22:08 -0400 | [diff] [blame] | 1295 | hdr->replen += decode_lockt_maxsz; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1296 | } |
| 1297 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1298 | 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] | 1299 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 1300 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1301 | |
Trond Myklebust | ea9d23f | 2012-03-04 18:13:56 -0500 | [diff] [blame^] | 1302 | p = reserve_space(xdr, 12); |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1303 | *p++ = cpu_to_be32(OP_LOCKU); |
| 1304 | *p++ = cpu_to_be32(nfs4_lock_type(args->fl, 0)); |
Trond Myklebust | ea9d23f | 2012-03-04 18:13:56 -0500 | [diff] [blame^] | 1305 | *p = cpu_to_be32(args->seqid->sequence->counter); |
| 1306 | encode_nfs4_stateid(xdr, args->stateid); |
| 1307 | p = reserve_space(xdr, 16); |
Benny Halevy | b95be5a | 2009-08-14 17:19:01 +0300 | [diff] [blame] | 1308 | p = xdr_encode_hyper(p, args->fl->fl_start); |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1309 | xdr_encode_hyper(p, nfs4_lock_length(args->fl)); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 1310 | hdr->nops++; |
Benny Halevy | dadf0c2 | 2009-04-01 09:22:08 -0400 | [diff] [blame] | 1311 | hdr->replen += decode_locku_maxsz; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1312 | } |
| 1313 | |
Trond Myklebust | d3c7b7c | 2010-07-01 12:49:01 -0400 | [diff] [blame] | 1314 | static void encode_release_lockowner(struct xdr_stream *xdr, const struct nfs_lowner *lowner, struct compound_hdr *hdr) |
| 1315 | { |
| 1316 | __be32 *p; |
| 1317 | |
| 1318 | p = reserve_space(xdr, 4); |
| 1319 | *p = cpu_to_be32(OP_RELEASE_LOCKOWNER); |
| 1320 | encode_lockowner(xdr, lowner); |
| 1321 | hdr->nops++; |
| 1322 | hdr->replen += decode_release_lockowner_maxsz; |
| 1323 | } |
| 1324 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1325 | 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] | 1326 | { |
| 1327 | int len = name->len; |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 1328 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1329 | |
Benny Halevy | 13c65ce | 2009-08-14 17:19:25 +0300 | [diff] [blame] | 1330 | p = reserve_space(xdr, 8 + len); |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1331 | *p++ = cpu_to_be32(OP_LOOKUP); |
Benny Halevy | 811652b | 2009-08-14 17:19:34 +0300 | [diff] [blame] | 1332 | xdr_encode_opaque(p, name->name, len); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 1333 | hdr->nops++; |
Benny Halevy | dadf0c2 | 2009-04-01 09:22:08 -0400 | [diff] [blame] | 1334 | hdr->replen += decode_lookup_maxsz; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1335 | } |
| 1336 | |
Trond Myklebust | dc0b027 | 2008-12-23 15:21:56 -0500 | [diff] [blame] | 1337 | static void encode_share_access(struct xdr_stream *xdr, fmode_t fmode) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1338 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 1339 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1340 | |
Benny Halevy | 13c65ce | 2009-08-14 17:19:25 +0300 | [diff] [blame] | 1341 | p = reserve_space(xdr, 8); |
Trond Myklebust | dc0b027 | 2008-12-23 15:21:56 -0500 | [diff] [blame] | 1342 | switch (fmode & (FMODE_READ|FMODE_WRITE)) { |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 1343 | case FMODE_READ: |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1344 | *p++ = cpu_to_be32(NFS4_SHARE_ACCESS_READ); |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 1345 | break; |
| 1346 | case FMODE_WRITE: |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1347 | *p++ = cpu_to_be32(NFS4_SHARE_ACCESS_WRITE); |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 1348 | break; |
| 1349 | case FMODE_READ|FMODE_WRITE: |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1350 | *p++ = cpu_to_be32(NFS4_SHARE_ACCESS_BOTH); |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 1351 | break; |
| 1352 | default: |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1353 | *p++ = cpu_to_be32(0); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1354 | } |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1355 | *p = cpu_to_be32(0); /* for linux, share_deny = 0 always */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1356 | } |
| 1357 | |
| 1358 | static inline void encode_openhdr(struct xdr_stream *xdr, const struct nfs_openargs *arg) |
| 1359 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 1360 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1361 | /* |
| 1362 | * opcode 4, seqid 4, share_access 4, share_deny 4, clientid 8, ownerlen 4, |
| 1363 | * owner 4 = 32 |
| 1364 | */ |
Benny Halevy | 13c65ce | 2009-08-14 17:19:25 +0300 | [diff] [blame] | 1365 | p = reserve_space(xdr, 8); |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1366 | *p++ = cpu_to_be32(OP_OPEN); |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1367 | *p = cpu_to_be32(arg->seqid->sequence->counter); |
Trond Myklebust | dc0b027 | 2008-12-23 15:21:56 -0500 | [diff] [blame] | 1368 | encode_share_access(xdr, arg->fmode); |
Trond Myklebust | d035c36 | 2010-12-21 10:45:27 -0500 | [diff] [blame] | 1369 | p = reserve_space(xdr, 32); |
Benny Halevy | b95be5a | 2009-08-14 17:19:01 +0300 | [diff] [blame] | 1370 | p = xdr_encode_hyper(p, arg->clientid); |
Trond Myklebust | d035c36 | 2010-12-21 10:45:27 -0500 | [diff] [blame] | 1371 | *p++ = cpu_to_be32(20); |
Benny Halevy | 93f0cf2 | 2009-08-14 17:19:06 +0300 | [diff] [blame] | 1372 | p = xdr_encode_opaque_fixed(p, "open id:", 8); |
Trond Myklebust | d035c36 | 2010-12-21 10:45:27 -0500 | [diff] [blame] | 1373 | *p++ = cpu_to_be32(arg->server->s_dev); |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1374 | xdr_encode_hyper(p, arg->id); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1375 | } |
| 1376 | |
| 1377 | static inline void encode_createmode(struct xdr_stream *xdr, const struct nfs_openargs *arg) |
| 1378 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 1379 | __be32 *p; |
Alexandros Batsakis | 4882ef7 | 2009-12-05 13:30:21 -0500 | [diff] [blame] | 1380 | struct nfs_client *clp; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1381 | |
Benny Halevy | 13c65ce | 2009-08-14 17:19:25 +0300 | [diff] [blame] | 1382 | p = reserve_space(xdr, 4); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1383 | switch(arg->open_flags & O_EXCL) { |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 1384 | case 0: |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1385 | *p = cpu_to_be32(NFS4_CREATE_UNCHECKED); |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 1386 | encode_attrs(xdr, arg->u.attrs, arg->server); |
| 1387 | break; |
| 1388 | default: |
Alexandros Batsakis | 4882ef7 | 2009-12-05 13:30:21 -0500 | [diff] [blame] | 1389 | clp = arg->server->nfs_client; |
Trond Myklebust | a443234 | 2010-06-16 09:52:27 -0400 | [diff] [blame] | 1390 | if (clp->cl_mvops->minor_version > 0) { |
Alexandros Batsakis | 4882ef7 | 2009-12-05 13:30:21 -0500 | [diff] [blame] | 1391 | if (nfs4_has_persistent_session(clp)) { |
| 1392 | *p = cpu_to_be32(NFS4_CREATE_GUARDED); |
| 1393 | encode_attrs(xdr, arg->u.attrs, arg->server); |
| 1394 | } else { |
| 1395 | struct iattr dummy; |
| 1396 | |
| 1397 | *p = cpu_to_be32(NFS4_CREATE_EXCLUSIVE4_1); |
| 1398 | encode_nfs4_verifier(xdr, &arg->u.verifier); |
| 1399 | dummy.ia_valid = 0; |
| 1400 | encode_attrs(xdr, &dummy, arg->server); |
| 1401 | } |
| 1402 | } else { |
| 1403 | *p = cpu_to_be32(NFS4_CREATE_EXCLUSIVE); |
| 1404 | encode_nfs4_verifier(xdr, &arg->u.verifier); |
| 1405 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1406 | } |
| 1407 | } |
| 1408 | |
| 1409 | static void encode_opentype(struct xdr_stream *xdr, const struct nfs_openargs *arg) |
| 1410 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 1411 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1412 | |
Benny Halevy | 13c65ce | 2009-08-14 17:19:25 +0300 | [diff] [blame] | 1413 | p = reserve_space(xdr, 4); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1414 | switch (arg->open_flags & O_CREAT) { |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 1415 | case 0: |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1416 | *p = cpu_to_be32(NFS4_OPEN_NOCREATE); |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 1417 | break; |
| 1418 | default: |
| 1419 | BUG_ON(arg->claim != NFS4_OPEN_CLAIM_NULL); |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1420 | *p = cpu_to_be32(NFS4_OPEN_CREATE); |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 1421 | encode_createmode(xdr, arg); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1422 | } |
| 1423 | } |
| 1424 | |
Trond Myklebust | bd7bf9d | 2008-12-23 15:21:53 -0500 | [diff] [blame] | 1425 | 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] | 1426 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 1427 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1428 | |
Benny Halevy | 13c65ce | 2009-08-14 17:19:25 +0300 | [diff] [blame] | 1429 | p = reserve_space(xdr, 4); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1430 | switch (delegation_type) { |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 1431 | case 0: |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1432 | *p = cpu_to_be32(NFS4_OPEN_DELEGATE_NONE); |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 1433 | break; |
| 1434 | case FMODE_READ: |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1435 | *p = cpu_to_be32(NFS4_OPEN_DELEGATE_READ); |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 1436 | break; |
| 1437 | case FMODE_WRITE|FMODE_READ: |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1438 | *p = cpu_to_be32(NFS4_OPEN_DELEGATE_WRITE); |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 1439 | break; |
| 1440 | default: |
| 1441 | BUG(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1442 | } |
| 1443 | } |
| 1444 | |
| 1445 | static inline void encode_claim_null(struct xdr_stream *xdr, const struct qstr *name) |
| 1446 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 1447 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1448 | |
Benny Halevy | 13c65ce | 2009-08-14 17:19:25 +0300 | [diff] [blame] | 1449 | p = reserve_space(xdr, 4); |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1450 | *p = cpu_to_be32(NFS4_OPEN_CLAIM_NULL); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1451 | encode_string(xdr, name->len, name->name); |
| 1452 | } |
| 1453 | |
Trond Myklebust | bd7bf9d | 2008-12-23 15:21:53 -0500 | [diff] [blame] | 1454 | 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] | 1455 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 1456 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1457 | |
Benny Halevy | 13c65ce | 2009-08-14 17:19:25 +0300 | [diff] [blame] | 1458 | p = reserve_space(xdr, 4); |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1459 | *p = cpu_to_be32(NFS4_OPEN_CLAIM_PREVIOUS); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1460 | encode_delegation_type(xdr, type); |
| 1461 | } |
| 1462 | |
| 1463 | static inline void encode_claim_delegate_cur(struct xdr_stream *xdr, const struct qstr *name, const nfs4_stateid *stateid) |
| 1464 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 1465 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1466 | |
Trond Myklebust | ea9d23f | 2012-03-04 18:13:56 -0500 | [diff] [blame^] | 1467 | p = reserve_space(xdr, 4); |
| 1468 | *p = cpu_to_be32(NFS4_OPEN_CLAIM_DELEGATE_CUR); |
| 1469 | encode_nfs4_stateid(xdr, stateid); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1470 | encode_string(xdr, name->len, name->name); |
| 1471 | } |
| 1472 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1473 | 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] | 1474 | { |
| 1475 | encode_openhdr(xdr, arg); |
| 1476 | encode_opentype(xdr, arg); |
| 1477 | switch (arg->claim) { |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 1478 | case NFS4_OPEN_CLAIM_NULL: |
| 1479 | encode_claim_null(xdr, arg->name); |
| 1480 | break; |
| 1481 | case NFS4_OPEN_CLAIM_PREVIOUS: |
| 1482 | encode_claim_previous(xdr, arg->u.delegation_type); |
| 1483 | break; |
| 1484 | case NFS4_OPEN_CLAIM_DELEGATE_CUR: |
| 1485 | encode_claim_delegate_cur(xdr, arg->name, &arg->u.delegation); |
| 1486 | break; |
| 1487 | default: |
| 1488 | BUG(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1489 | } |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 1490 | hdr->nops++; |
Benny Halevy | dadf0c2 | 2009-04-01 09:22:08 -0400 | [diff] [blame] | 1491 | hdr->replen += decode_open_maxsz; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1492 | } |
| 1493 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1494 | 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] | 1495 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 1496 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1497 | |
Trond Myklebust | ea9d23f | 2012-03-04 18:13:56 -0500 | [diff] [blame^] | 1498 | p = reserve_space(xdr, 4); |
| 1499 | *p = cpu_to_be32(OP_OPEN_CONFIRM); |
| 1500 | encode_nfs4_stateid(xdr, arg->stateid); |
| 1501 | p = reserve_space(xdr, 4); |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1502 | *p = cpu_to_be32(arg->seqid->sequence->counter); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 1503 | hdr->nops++; |
Benny Halevy | dadf0c2 | 2009-04-01 09:22:08 -0400 | [diff] [blame] | 1504 | hdr->replen += decode_open_confirm_maxsz; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1505 | } |
| 1506 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1507 | 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] | 1508 | { |
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 | |
Trond Myklebust | ea9d23f | 2012-03-04 18:13:56 -0500 | [diff] [blame^] | 1511 | p = reserve_space(xdr, 4); |
| 1512 | *p = cpu_to_be32(OP_OPEN_DOWNGRADE); |
| 1513 | encode_nfs4_stateid(xdr, arg->stateid); |
| 1514 | p = reserve_space(xdr, 4); |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1515 | *p = cpu_to_be32(arg->seqid->sequence->counter); |
Trond Myklebust | dc0b027 | 2008-12-23 15:21:56 -0500 | [diff] [blame] | 1516 | encode_share_access(xdr, arg->fmode); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 1517 | hdr->nops++; |
Benny Halevy | dadf0c2 | 2009-04-01 09:22:08 -0400 | [diff] [blame] | 1518 | hdr->replen += decode_open_downgrade_maxsz; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1519 | } |
| 1520 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1521 | static void |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 1522 | 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] | 1523 | { |
| 1524 | int len = fh->size; |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 1525 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1526 | |
Benny Halevy | 13c65ce | 2009-08-14 17:19:25 +0300 | [diff] [blame] | 1527 | p = reserve_space(xdr, 8 + len); |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1528 | *p++ = cpu_to_be32(OP_PUTFH); |
Benny Halevy | 811652b | 2009-08-14 17:19:34 +0300 | [diff] [blame] | 1529 | xdr_encode_opaque(p, fh->data, len); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 1530 | hdr->nops++; |
Benny Halevy | dadf0c2 | 2009-04-01 09:22:08 -0400 | [diff] [blame] | 1531 | hdr->replen += decode_putfh_maxsz; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1532 | } |
| 1533 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1534 | static void encode_putrootfh(struct xdr_stream *xdr, struct compound_hdr *hdr) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1535 | { |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 1536 | __be32 *p; |
Andy Adamson | 6c0195a | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 1537 | |
Benny Halevy | 13c65ce | 2009-08-14 17:19:25 +0300 | [diff] [blame] | 1538 | p = reserve_space(xdr, 4); |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1539 | *p = cpu_to_be32(OP_PUTROOTFH); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 1540 | hdr->nops++; |
Benny Halevy | dadf0c2 | 2009-04-01 09:22:08 -0400 | [diff] [blame] | 1541 | hdr->replen += decode_putrootfh_maxsz; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1542 | } |
| 1543 | |
Trond Myklebust | d0b496d | 2012-03-04 18:13:56 -0500 | [diff] [blame] | 1544 | static void encode_open_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] | 1545 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1546 | nfs4_stateid stateid; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1547 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1548 | if (ctx->state != NULL) { |
Trond Myklebust | 77041ed | 2010-07-01 12:49:11 -0400 | [diff] [blame] | 1549 | nfs4_copy_stateid(&stateid, ctx->state, l_ctx->lockowner, l_ctx->pid); |
Andy Adamson | 89d1ea6 | 2011-03-01 01:34:09 +0000 | [diff] [blame] | 1550 | if (zero_seqid) |
| 1551 | stateid.stateid.seqid = 0; |
Trond Myklebust | ea9d23f | 2012-03-04 18:13:56 -0500 | [diff] [blame^] | 1552 | encode_nfs4_stateid(xdr, &stateid); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1553 | } else |
Trond Myklebust | ea9d23f | 2012-03-04 18:13:56 -0500 | [diff] [blame^] | 1554 | encode_nfs4_stateid(xdr, &zero_stateid); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1555 | } |
| 1556 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1557 | 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] | 1558 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 1559 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1560 | |
Benny Halevy | 13c65ce | 2009-08-14 17:19:25 +0300 | [diff] [blame] | 1561 | p = reserve_space(xdr, 4); |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1562 | *p = cpu_to_be32(OP_READ); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1563 | |
Trond Myklebust | d0b496d | 2012-03-04 18:13:56 -0500 | [diff] [blame] | 1564 | encode_open_stateid(xdr, args->context, args->lock_context, |
Andy Adamson | 89d1ea6 | 2011-03-01 01:34:09 +0000 | [diff] [blame] | 1565 | hdr->minorversion); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1566 | |
Benny Halevy | 13c65ce | 2009-08-14 17:19:25 +0300 | [diff] [blame] | 1567 | p = reserve_space(xdr, 12); |
Benny Halevy | b95be5a | 2009-08-14 17:19:01 +0300 | [diff] [blame] | 1568 | p = xdr_encode_hyper(p, args->offset); |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1569 | *p = cpu_to_be32(args->count); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 1570 | hdr->nops++; |
Benny Halevy | dadf0c2 | 2009-04-01 09:22:08 -0400 | [diff] [blame] | 1571 | hdr->replen += decode_read_maxsz; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1572 | } |
| 1573 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1574 | 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] | 1575 | { |
Trond Myklebust | 28331a4 | 2011-04-27 13:47:52 -0400 | [diff] [blame] | 1576 | uint32_t attrs[2] = { |
| 1577 | FATTR4_WORD0_RDATTR_ERROR, |
| 1578 | FATTR4_WORD1_MOUNTED_ON_FILEID, |
| 1579 | }; |
Trond Myklebust | 6f7a35b | 2010-10-24 12:11:42 -0400 | [diff] [blame] | 1580 | uint32_t dircount = readdir->count >> 1; |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 1581 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1582 | |
Bryan Schumaker | 82f2e54 | 2010-10-21 16:33:18 -0400 | [diff] [blame] | 1583 | if (readdir->plus) { |
| 1584 | attrs[0] |= FATTR4_WORD0_TYPE|FATTR4_WORD0_CHANGE|FATTR4_WORD0_SIZE| |
Trond Myklebust | 28331a4 | 2011-04-27 13:47:52 -0400 | [diff] [blame] | 1585 | FATTR4_WORD0_FSID|FATTR4_WORD0_FILEHANDLE|FATTR4_WORD0_FILEID; |
Bryan Schumaker | 82f2e54 | 2010-10-21 16:33:18 -0400 | [diff] [blame] | 1586 | attrs[1] |= FATTR4_WORD1_MODE|FATTR4_WORD1_NUMLINKS|FATTR4_WORD1_OWNER| |
| 1587 | FATTR4_WORD1_OWNER_GROUP|FATTR4_WORD1_RAWDEV| |
| 1588 | FATTR4_WORD1_SPACE_USED|FATTR4_WORD1_TIME_ACCESS| |
| 1589 | FATTR4_WORD1_TIME_METADATA|FATTR4_WORD1_TIME_MODIFY; |
Trond Myklebust | 6f7a35b | 2010-10-24 12:11:42 -0400 | [diff] [blame] | 1590 | dircount >>= 1; |
Bryan Schumaker | 82f2e54 | 2010-10-21 16:33:18 -0400 | [diff] [blame] | 1591 | } |
Trond Myklebust | 28331a4 | 2011-04-27 13:47:52 -0400 | [diff] [blame] | 1592 | /* Use mounted_on_fileid only if the server supports it */ |
| 1593 | if (!(readdir->bitmask[1] & FATTR4_WORD1_MOUNTED_ON_FILEID)) |
| 1594 | attrs[0] |= FATTR4_WORD0_FILEID; |
Bryan Schumaker | 82f2e54 | 2010-10-21 16:33:18 -0400 | [diff] [blame] | 1595 | |
Benny Halevy | 13c65ce | 2009-08-14 17:19:25 +0300 | [diff] [blame] | 1596 | p = reserve_space(xdr, 12+NFS4_VERIFIER_SIZE+20); |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1597 | *p++ = cpu_to_be32(OP_READDIR); |
Benny Halevy | b95be5a | 2009-08-14 17:19:01 +0300 | [diff] [blame] | 1598 | p = xdr_encode_hyper(p, readdir->cookie); |
Benny Halevy | 93f0cf2 | 2009-08-14 17:19:06 +0300 | [diff] [blame] | 1599 | p = xdr_encode_opaque_fixed(p, readdir->verifier.data, NFS4_VERIFIER_SIZE); |
Trond Myklebust | 6f7a35b | 2010-10-24 12:11:42 -0400 | [diff] [blame] | 1600 | *p++ = cpu_to_be32(dircount); |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1601 | *p++ = cpu_to_be32(readdir->count); |
| 1602 | *p++ = cpu_to_be32(2); |
Bryan Schumaker | 82f2e54 | 2010-10-21 16:33:18 -0400 | [diff] [blame] | 1603 | |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1604 | *p++ = cpu_to_be32(attrs[0] & readdir->bitmask[0]); |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1605 | *p = cpu_to_be32(attrs[1] & readdir->bitmask[1]); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 1606 | hdr->nops++; |
Benny Halevy | dadf0c2 | 2009-04-01 09:22:08 -0400 | [diff] [blame] | 1607 | hdr->replen += decode_readdir_maxsz; |
Fred Isaman | 4410924 | 2008-04-02 15:21:15 +0300 | [diff] [blame] | 1608 | dprintk("%s: cookie = %Lu, verifier = %08x:%08x, bitmap = %08x:%08x\n", |
| 1609 | __func__, |
Trond Myklebust | eadf459 | 2005-06-22 17:16:39 +0000 | [diff] [blame] | 1610 | (unsigned long long)readdir->cookie, |
| 1611 | ((u32 *)readdir->verifier.data)[0], |
| 1612 | ((u32 *)readdir->verifier.data)[1], |
| 1613 | attrs[0] & readdir->bitmask[0], |
| 1614 | attrs[1] & readdir->bitmask[1]); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1615 | } |
| 1616 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1617 | 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] | 1618 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 1619 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1620 | |
Benny Halevy | 13c65ce | 2009-08-14 17:19:25 +0300 | [diff] [blame] | 1621 | p = reserve_space(xdr, 4); |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1622 | *p = cpu_to_be32(OP_READLINK); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 1623 | hdr->nops++; |
Benny Halevy | dadf0c2 | 2009-04-01 09:22:08 -0400 | [diff] [blame] | 1624 | hdr->replen += decode_readlink_maxsz; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1625 | } |
| 1626 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1627 | 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] | 1628 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 1629 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1630 | |
Benny Halevy | 13c65ce | 2009-08-14 17:19:25 +0300 | [diff] [blame] | 1631 | p = reserve_space(xdr, 8 + name->len); |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1632 | *p++ = cpu_to_be32(OP_REMOVE); |
Benny Halevy | 811652b | 2009-08-14 17:19:34 +0300 | [diff] [blame] | 1633 | xdr_encode_opaque(p, name->name, name->len); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 1634 | hdr->nops++; |
Benny Halevy | dadf0c2 | 2009-04-01 09:22:08 -0400 | [diff] [blame] | 1635 | hdr->replen += decode_remove_maxsz; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1636 | } |
| 1637 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1638 | 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] | 1639 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 1640 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1641 | |
Benny Halevy | 811652b | 2009-08-14 17:19:34 +0300 | [diff] [blame] | 1642 | p = reserve_space(xdr, 4); |
| 1643 | *p = cpu_to_be32(OP_RENAME); |
| 1644 | encode_string(xdr, oldname->len, oldname->name); |
| 1645 | encode_string(xdr, newname->len, newname->name); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 1646 | hdr->nops++; |
Benny Halevy | dadf0c2 | 2009-04-01 09:22:08 -0400 | [diff] [blame] | 1647 | hdr->replen += decode_rename_maxsz; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1648 | } |
| 1649 | |
Chuck Lever | bb4dae5 | 2012-03-01 17:01:48 -0500 | [diff] [blame] | 1650 | static void encode_renew(struct xdr_stream *xdr, clientid4 clid, |
| 1651 | struct compound_hdr *hdr) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1652 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 1653 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1654 | |
Benny Halevy | 13c65ce | 2009-08-14 17:19:25 +0300 | [diff] [blame] | 1655 | p = reserve_space(xdr, 12); |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1656 | *p++ = cpu_to_be32(OP_RENEW); |
Chuck Lever | bb4dae5 | 2012-03-01 17:01:48 -0500 | [diff] [blame] | 1657 | xdr_encode_hyper(p, clid); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 1658 | hdr->nops++; |
Benny Halevy | dadf0c2 | 2009-04-01 09:22:08 -0400 | [diff] [blame] | 1659 | hdr->replen += decode_renew_maxsz; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1660 | } |
| 1661 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1662 | static void |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 1663 | encode_restorefh(struct xdr_stream *xdr, struct compound_hdr *hdr) |
Trond Myklebust | 56ae19f | 2005-10-27 22:12:40 -0400 | [diff] [blame] | 1664 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 1665 | __be32 *p; |
Trond Myklebust | 56ae19f | 2005-10-27 22:12:40 -0400 | [diff] [blame] | 1666 | |
Benny Halevy | 13c65ce | 2009-08-14 17:19:25 +0300 | [diff] [blame] | 1667 | p = reserve_space(xdr, 4); |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1668 | *p = cpu_to_be32(OP_RESTOREFH); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 1669 | hdr->nops++; |
Benny Halevy | dadf0c2 | 2009-04-01 09:22:08 -0400 | [diff] [blame] | 1670 | hdr->replen += decode_restorefh_maxsz; |
Trond Myklebust | 56ae19f | 2005-10-27 22:12:40 -0400 | [diff] [blame] | 1671 | } |
| 1672 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 1673 | static void |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 1674 | 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] | 1675 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 1676 | __be32 *p; |
J. Bruce Fields | 23ec696 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 1677 | |
Trond Myklebust | ea9d23f | 2012-03-04 18:13:56 -0500 | [diff] [blame^] | 1678 | p = reserve_space(xdr, 4); |
| 1679 | *p = cpu_to_be32(OP_SETATTR); |
| 1680 | encode_nfs4_stateid(xdr, &zero_stateid); |
Benny Halevy | 13c65ce | 2009-08-14 17:19:25 +0300 | [diff] [blame] | 1681 | p = reserve_space(xdr, 2*4); |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1682 | *p++ = cpu_to_be32(1); |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1683 | *p = cpu_to_be32(FATTR4_WORD0_ACL); |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 1684 | BUG_ON(arg->acl_len % 4); |
Benny Halevy | 13c65ce | 2009-08-14 17:19:25 +0300 | [diff] [blame] | 1685 | p = reserve_space(xdr, 4); |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1686 | *p = cpu_to_be32(arg->acl_len); |
J. Bruce Fields | 23ec696 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 1687 | 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] | 1688 | hdr->nops++; |
Benny Halevy | dadf0c2 | 2009-04-01 09:22:08 -0400 | [diff] [blame] | 1689 | hdr->replen += decode_setacl_maxsz; |
J. Bruce Fields | 23ec696 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 1690 | } |
| 1691 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1692 | static void |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 1693 | encode_savefh(struct xdr_stream *xdr, struct compound_hdr *hdr) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1694 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 1695 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1696 | |
Benny Halevy | 13c65ce | 2009-08-14 17:19:25 +0300 | [diff] [blame] | 1697 | p = reserve_space(xdr, 4); |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1698 | *p = cpu_to_be32(OP_SAVEFH); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 1699 | hdr->nops++; |
Benny Halevy | dadf0c2 | 2009-04-01 09:22:08 -0400 | [diff] [blame] | 1700 | hdr->replen += decode_savefh_maxsz; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1701 | } |
| 1702 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1703 | 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] | 1704 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 1705 | __be32 *p; |
Andy Adamson | 6c0195a | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 1706 | |
Trond Myklebust | ea9d23f | 2012-03-04 18:13:56 -0500 | [diff] [blame^] | 1707 | p = reserve_space(xdr, 4); |
| 1708 | *p = cpu_to_be32(OP_SETATTR); |
| 1709 | encode_nfs4_stateid(xdr, &arg->stateid); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 1710 | hdr->nops++; |
Benny Halevy | dadf0c2 | 2009-04-01 09:22:08 -0400 | [diff] [blame] | 1711 | hdr->replen += decode_setattr_maxsz; |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1712 | encode_attrs(xdr, arg->iap, server); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1713 | } |
| 1714 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1715 | 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] | 1716 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 1717 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1718 | |
Benny Halevy | 13c65ce | 2009-08-14 17:19:25 +0300 | [diff] [blame] | 1719 | p = reserve_space(xdr, 4 + NFS4_VERIFIER_SIZE); |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1720 | *p++ = cpu_to_be32(OP_SETCLIENTID); |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1721 | xdr_encode_opaque_fixed(p, setclientid->sc_verifier->data, NFS4_VERIFIER_SIZE); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1722 | |
| 1723 | encode_string(xdr, setclientid->sc_name_len, setclientid->sc_name); |
Benny Halevy | 13c65ce | 2009-08-14 17:19:25 +0300 | [diff] [blame] | 1724 | p = reserve_space(xdr, 4); |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1725 | *p = cpu_to_be32(setclientid->sc_prog); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1726 | encode_string(xdr, setclientid->sc_netid_len, setclientid->sc_netid); |
| 1727 | encode_string(xdr, setclientid->sc_uaddr_len, setclientid->sc_uaddr); |
Benny Halevy | 13c65ce | 2009-08-14 17:19:25 +0300 | [diff] [blame] | 1728 | p = reserve_space(xdr, 4); |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1729 | *p = cpu_to_be32(setclientid->sc_cb_ident); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 1730 | hdr->nops++; |
Benny Halevy | dadf0c2 | 2009-04-01 09:22:08 -0400 | [diff] [blame] | 1731 | hdr->replen += decode_setclientid_maxsz; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1732 | } |
| 1733 | |
Trond Myklebust | bb8b27e | 2010-04-16 16:43:06 -0400 | [diff] [blame] | 1734 | 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] | 1735 | { |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 1736 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1737 | |
Benny Halevy | 13c65ce | 2009-08-14 17:19:25 +0300 | [diff] [blame] | 1738 | p = reserve_space(xdr, 12 + NFS4_VERIFIER_SIZE); |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1739 | *p++ = cpu_to_be32(OP_SETCLIENTID_CONFIRM); |
Trond Myklebust | bb8b27e | 2010-04-16 16:43:06 -0400 | [diff] [blame] | 1740 | p = xdr_encode_hyper(p, arg->clientid); |
| 1741 | xdr_encode_opaque_fixed(p, arg->confirm.data, NFS4_VERIFIER_SIZE); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 1742 | hdr->nops++; |
Benny Halevy | dadf0c2 | 2009-04-01 09:22:08 -0400 | [diff] [blame] | 1743 | hdr->replen += decode_setclientid_confirm_maxsz; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1744 | } |
| 1745 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1746 | 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] | 1747 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 1748 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1749 | |
Benny Halevy | 13c65ce | 2009-08-14 17:19:25 +0300 | [diff] [blame] | 1750 | p = reserve_space(xdr, 4); |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1751 | *p = cpu_to_be32(OP_WRITE); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1752 | |
Trond Myklebust | d0b496d | 2012-03-04 18:13:56 -0500 | [diff] [blame] | 1753 | encode_open_stateid(xdr, args->context, args->lock_context, |
Andy Adamson | 89d1ea6 | 2011-03-01 01:34:09 +0000 | [diff] [blame] | 1754 | hdr->minorversion); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1755 | |
Benny Halevy | 13c65ce | 2009-08-14 17:19:25 +0300 | [diff] [blame] | 1756 | p = reserve_space(xdr, 16); |
Benny Halevy | b95be5a | 2009-08-14 17:19:01 +0300 | [diff] [blame] | 1757 | p = xdr_encode_hyper(p, args->offset); |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1758 | *p++ = cpu_to_be32(args->stable); |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1759 | *p = cpu_to_be32(args->count); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1760 | |
| 1761 | xdr_write_pages(xdr, args->pages, args->pgbase, args->count); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 1762 | hdr->nops++; |
Benny Halevy | dadf0c2 | 2009-04-01 09:22:08 -0400 | [diff] [blame] | 1763 | hdr->replen += decode_write_maxsz; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1764 | } |
| 1765 | |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 1766 | 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] | 1767 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 1768 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1769 | |
Trond Myklebust | ea9d23f | 2012-03-04 18:13:56 -0500 | [diff] [blame^] | 1770 | p = reserve_space(xdr, 4); |
| 1771 | *p = cpu_to_be32(OP_DELEGRETURN); |
| 1772 | encode_nfs4_stateid(xdr, stateid); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 1773 | hdr->nops++; |
Benny Halevy | dadf0c2 | 2009-04-01 09:22:08 -0400 | [diff] [blame] | 1774 | hdr->replen += decode_delegreturn_maxsz; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1775 | } |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 1776 | |
Bryan Schumaker | 5a5ea0d | 2011-03-24 17:12:29 +0000 | [diff] [blame] | 1777 | static void encode_secinfo(struct xdr_stream *xdr, const struct qstr *name, struct compound_hdr *hdr) |
| 1778 | { |
| 1779 | int len = name->len; |
| 1780 | __be32 *p; |
| 1781 | |
| 1782 | p = reserve_space(xdr, 8 + len); |
| 1783 | *p++ = cpu_to_be32(OP_SECINFO); |
| 1784 | xdr_encode_opaque(p, name->name, len); |
| 1785 | hdr->nops++; |
| 1786 | hdr->replen += decode_secinfo_maxsz; |
| 1787 | } |
| 1788 | |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 1789 | #if defined(CONFIG_NFS_V4_1) |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 1790 | /* NFSv4.1 operations */ |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 1791 | static void encode_exchange_id(struct xdr_stream *xdr, |
| 1792 | struct nfs41_exchange_id_args *args, |
| 1793 | struct compound_hdr *hdr) |
| 1794 | { |
| 1795 | __be32 *p; |
Weston Andros Adamson | db8ac8b | 2012-02-17 15:20:24 -0500 | [diff] [blame] | 1796 | char impl_name[NFS4_OPAQUE_LIMIT]; |
| 1797 | int len = 0; |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 1798 | |
Benny Halevy | 13c65ce | 2009-08-14 17:19:25 +0300 | [diff] [blame] | 1799 | p = reserve_space(xdr, 4 + sizeof(args->verifier->data)); |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1800 | *p++ = cpu_to_be32(OP_EXCHANGE_ID); |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1801 | xdr_encode_opaque_fixed(p, args->verifier->data, sizeof(args->verifier->data)); |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 1802 | |
| 1803 | encode_string(xdr, args->id_len, args->id); |
| 1804 | |
Benny Halevy | 13c65ce | 2009-08-14 17:19:25 +0300 | [diff] [blame] | 1805 | p = reserve_space(xdr, 12); |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1806 | *p++ = cpu_to_be32(args->flags); |
| 1807 | *p++ = cpu_to_be32(0); /* zero length state_protect4_a */ |
Weston Andros Adamson | db8ac8b | 2012-02-17 15:20:24 -0500 | [diff] [blame] | 1808 | |
| 1809 | if (send_implementation_id && |
| 1810 | sizeof(CONFIG_NFS_V4_1_IMPLEMENTATION_ID_DOMAIN) > 1 && |
| 1811 | sizeof(CONFIG_NFS_V4_1_IMPLEMENTATION_ID_DOMAIN) |
| 1812 | <= NFS4_OPAQUE_LIMIT + 1) |
| 1813 | len = snprintf(impl_name, sizeof(impl_name), "%s %s %s %s", |
| 1814 | utsname()->sysname, utsname()->release, |
| 1815 | utsname()->version, utsname()->machine); |
| 1816 | |
| 1817 | if (len > 0) { |
| 1818 | *p = cpu_to_be32(1); /* implementation id array length=1 */ |
| 1819 | |
| 1820 | encode_string(xdr, |
| 1821 | sizeof(CONFIG_NFS_V4_1_IMPLEMENTATION_ID_DOMAIN) - 1, |
| 1822 | CONFIG_NFS_V4_1_IMPLEMENTATION_ID_DOMAIN); |
| 1823 | encode_string(xdr, len, impl_name); |
| 1824 | /* just send zeros for nii_date - the date is in nii_name */ |
| 1825 | p = reserve_space(xdr, 12); |
| 1826 | p = xdr_encode_hyper(p, 0); |
| 1827 | *p = cpu_to_be32(0); |
| 1828 | } else |
| 1829 | *p = cpu_to_be32(0); /* implementation id array length=0 */ |
| 1830 | |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 1831 | hdr->nops++; |
| 1832 | hdr->replen += decode_exchange_id_maxsz; |
| 1833 | } |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 1834 | |
| 1835 | static void encode_create_session(struct xdr_stream *xdr, |
| 1836 | struct nfs41_create_session_args *args, |
| 1837 | struct compound_hdr *hdr) |
| 1838 | { |
| 1839 | __be32 *p; |
| 1840 | char machine_name[NFS4_MAX_MACHINE_NAME_LEN]; |
| 1841 | uint32_t len; |
| 1842 | struct nfs_client *clp = args->client; |
Mike Sager | 8e0d46e | 2009-12-17 12:06:26 -0500 | [diff] [blame] | 1843 | u32 max_resp_sz_cached; |
| 1844 | |
| 1845 | /* |
| 1846 | * Assumes OPEN is the biggest non-idempotent compound. |
| 1847 | * 2 is the verifier. |
| 1848 | */ |
| 1849 | max_resp_sz_cached = (NFS4_dec_open_sz + RPC_REPHDRSIZE + |
| 1850 | RPC_MAX_AUTH_SIZE + 2) * XDR_UNIT; |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 1851 | |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 1852 | len = scnprintf(machine_name, sizeof(machine_name), "%s", |
| 1853 | clp->cl_ipaddr); |
Benny Halevy | 42edd69 | 2009-08-14 17:19:13 +0300 | [diff] [blame] | 1854 | |
Benny Halevy | 13c65ce | 2009-08-14 17:19:25 +0300 | [diff] [blame] | 1855 | p = reserve_space(xdr, 20 + 2*28 + 20 + len + 12); |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1856 | *p++ = cpu_to_be32(OP_CREATE_SESSION); |
Andy Adamson | 114f64b | 2011-03-09 13:13:45 -0500 | [diff] [blame] | 1857 | p = xdr_encode_hyper(p, clp->cl_clientid); |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1858 | *p++ = cpu_to_be32(clp->cl_seqid); /*Sequence id */ |
| 1859 | *p++ = cpu_to_be32(args->flags); /*flags */ |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 1860 | |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 1861 | /* Fore Channel */ |
Benny Halevy | c9c30dd | 2011-06-11 17:08:39 -0400 | [diff] [blame] | 1862 | *p++ = cpu_to_be32(0); /* header padding size */ |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1863 | *p++ = cpu_to_be32(args->fc_attrs.max_rqst_sz); /* max req size */ |
| 1864 | *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] | 1865 | *p++ = cpu_to_be32(max_resp_sz_cached); /* Max resp sz cached */ |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1866 | *p++ = cpu_to_be32(args->fc_attrs.max_ops); /* max operations */ |
| 1867 | *p++ = cpu_to_be32(args->fc_attrs.max_reqs); /* max requests */ |
| 1868 | *p++ = cpu_to_be32(0); /* rdmachannel_attrs */ |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 1869 | |
| 1870 | /* Back Channel */ |
Benny Halevy | c9c30dd | 2011-06-11 17:08:39 -0400 | [diff] [blame] | 1871 | *p++ = cpu_to_be32(0); /* header padding size */ |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1872 | *p++ = cpu_to_be32(args->bc_attrs.max_rqst_sz); /* max req size */ |
| 1873 | *p++ = cpu_to_be32(args->bc_attrs.max_resp_sz); /* max resp size */ |
| 1874 | *p++ = cpu_to_be32(args->bc_attrs.max_resp_sz_cached); /* Max resp sz cached */ |
| 1875 | *p++ = cpu_to_be32(args->bc_attrs.max_ops); /* max operations */ |
| 1876 | *p++ = cpu_to_be32(args->bc_attrs.max_reqs); /* max requests */ |
| 1877 | *p++ = cpu_to_be32(0); /* rdmachannel_attrs */ |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 1878 | |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1879 | *p++ = cpu_to_be32(args->cb_program); /* cb_program */ |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1880 | *p++ = cpu_to_be32(1); |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1881 | *p++ = cpu_to_be32(RPC_AUTH_UNIX); /* auth_sys */ |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 1882 | |
| 1883 | /* authsys_parms rfc1831 */ |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1884 | *p++ = cpu_to_be32((u32)clp->cl_boot_time.tv_nsec); /* stamp */ |
Benny Halevy | 811652b | 2009-08-14 17:19:34 +0300 | [diff] [blame] | 1885 | p = xdr_encode_opaque(p, machine_name, len); |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1886 | *p++ = cpu_to_be32(0); /* UID */ |
| 1887 | *p++ = cpu_to_be32(0); /* GID */ |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1888 | *p = cpu_to_be32(0); /* No more gids */ |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 1889 | hdr->nops++; |
| 1890 | hdr->replen += decode_create_session_maxsz; |
| 1891 | } |
Andy Adamson | 0f3e66c | 2009-04-01 09:22:34 -0400 | [diff] [blame] | 1892 | |
| 1893 | static void encode_destroy_session(struct xdr_stream *xdr, |
| 1894 | struct nfs4_session *session, |
| 1895 | struct compound_hdr *hdr) |
| 1896 | { |
| 1897 | __be32 *p; |
Benny Halevy | 13c65ce | 2009-08-14 17:19:25 +0300 | [diff] [blame] | 1898 | p = reserve_space(xdr, 4 + NFS4_MAX_SESSIONID_LEN); |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1899 | *p++ = cpu_to_be32(OP_DESTROY_SESSION); |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1900 | 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] | 1901 | hdr->nops++; |
| 1902 | hdr->replen += decode_destroy_session_maxsz; |
| 1903 | } |
Ricardo Labiaga | 18019753 | 2009-12-05 16:08:40 -0500 | [diff] [blame] | 1904 | |
| 1905 | static void encode_reclaim_complete(struct xdr_stream *xdr, |
| 1906 | struct nfs41_reclaim_complete_args *args, |
| 1907 | struct compound_hdr *hdr) |
| 1908 | { |
| 1909 | __be32 *p; |
| 1910 | |
| 1911 | p = reserve_space(xdr, 8); |
| 1912 | *p++ = cpu_to_be32(OP_RECLAIM_COMPLETE); |
| 1913 | *p++ = cpu_to_be32(args->one_fs); |
| 1914 | hdr->nops++; |
| 1915 | hdr->replen += decode_reclaim_complete_maxsz; |
| 1916 | } |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 1917 | #endif /* CONFIG_NFS_V4_1 */ |
| 1918 | |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 1919 | static void encode_sequence(struct xdr_stream *xdr, |
| 1920 | const struct nfs4_sequence_args *args, |
| 1921 | struct compound_hdr *hdr) |
| 1922 | { |
| 1923 | #if defined(CONFIG_NFS_V4_1) |
| 1924 | struct nfs4_session *session = args->sa_session; |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 1925 | struct nfs4_slot_table *tp; |
| 1926 | struct nfs4_slot *slot; |
| 1927 | __be32 *p; |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 1928 | |
| 1929 | if (!session) |
| 1930 | return; |
| 1931 | |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 1932 | tp = &session->fc_slot_table; |
| 1933 | |
| 1934 | WARN_ON(args->sa_slotid == NFS4_MAX_SLOT_TABLE); |
| 1935 | slot = tp->slots + args->sa_slotid; |
| 1936 | |
Benny Halevy | 13c65ce | 2009-08-14 17:19:25 +0300 | [diff] [blame] | 1937 | p = reserve_space(xdr, 4 + NFS4_MAX_SESSIONID_LEN + 16); |
Benny Halevy | e75bc1c | 2009-08-14 17:18:54 +0300 | [diff] [blame] | 1938 | *p++ = cpu_to_be32(OP_SEQUENCE); |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 1939 | |
| 1940 | /* |
| 1941 | * Sessionid + seqid + slotid + max slotid + cache_this |
| 1942 | */ |
| 1943 | dprintk("%s: sessionid=%u:%u:%u:%u seqid=%d slotid=%d " |
| 1944 | "max_slotid=%d cache_this=%d\n", |
| 1945 | __func__, |
| 1946 | ((u32 *)session->sess_id.data)[0], |
| 1947 | ((u32 *)session->sess_id.data)[1], |
| 1948 | ((u32 *)session->sess_id.data)[2], |
| 1949 | ((u32 *)session->sess_id.data)[3], |
| 1950 | slot->seq_nr, args->sa_slotid, |
| 1951 | tp->highest_used_slotid, args->sa_cache_this); |
Benny Halevy | 93f0cf2 | 2009-08-14 17:19:06 +0300 | [diff] [blame] | 1952 | 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] | 1953 | *p++ = cpu_to_be32(slot->seq_nr); |
| 1954 | *p++ = cpu_to_be32(args->sa_slotid); |
| 1955 | *p++ = cpu_to_be32(tp->highest_used_slotid); |
Benny Halevy | 3455851 | 2009-08-14 17:19:30 +0300 | [diff] [blame] | 1956 | *p = cpu_to_be32(args->sa_cache_this); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 1957 | hdr->nops++; |
| 1958 | hdr->replen += decode_sequence_maxsz; |
| 1959 | #endif /* CONFIG_NFS_V4_1 */ |
| 1960 | } |
| 1961 | |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 1962 | #ifdef CONFIG_NFS_V4_1 |
| 1963 | static void |
Andy Adamson | 7f11d8d | 2011-07-30 20:52:35 -0400 | [diff] [blame] | 1964 | encode_getdevicelist(struct xdr_stream *xdr, |
| 1965 | const struct nfs4_getdevicelist_args *args, |
| 1966 | struct compound_hdr *hdr) |
| 1967 | { |
| 1968 | __be32 *p; |
| 1969 | nfs4_verifier dummy = { |
| 1970 | .data = "dummmmmy", |
| 1971 | }; |
| 1972 | |
| 1973 | p = reserve_space(xdr, 20); |
| 1974 | *p++ = cpu_to_be32(OP_GETDEVICELIST); |
| 1975 | *p++ = cpu_to_be32(args->layoutclass); |
| 1976 | *p++ = cpu_to_be32(NFS4_PNFS_GETDEVLIST_MAXNUM); |
| 1977 | xdr_encode_hyper(p, 0ULL); /* cookie */ |
| 1978 | encode_nfs4_verifier(xdr, &dummy); |
| 1979 | hdr->nops++; |
| 1980 | hdr->replen += decode_getdevicelist_maxsz; |
| 1981 | } |
| 1982 | |
| 1983 | static void |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 1984 | encode_getdeviceinfo(struct xdr_stream *xdr, |
| 1985 | const struct nfs4_getdeviceinfo_args *args, |
| 1986 | struct compound_hdr *hdr) |
| 1987 | { |
| 1988 | __be32 *p; |
| 1989 | |
| 1990 | p = reserve_space(xdr, 16 + NFS4_DEVICEID4_SIZE); |
| 1991 | *p++ = cpu_to_be32(OP_GETDEVICEINFO); |
| 1992 | p = xdr_encode_opaque_fixed(p, args->pdev->dev_id.data, |
| 1993 | NFS4_DEVICEID4_SIZE); |
| 1994 | *p++ = cpu_to_be32(args->pdev->layout_type); |
| 1995 | *p++ = cpu_to_be32(args->pdev->pglen); /* gdia_maxcount */ |
| 1996 | *p++ = cpu_to_be32(0); /* bitmap length 0 */ |
| 1997 | hdr->nops++; |
| 1998 | hdr->replen += decode_getdeviceinfo_maxsz; |
| 1999 | } |
| 2000 | |
| 2001 | static void |
| 2002 | encode_layoutget(struct xdr_stream *xdr, |
| 2003 | const struct nfs4_layoutget_args *args, |
| 2004 | struct compound_hdr *hdr) |
| 2005 | { |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 2006 | __be32 *p; |
| 2007 | |
Trond Myklebust | ea9d23f | 2012-03-04 18:13:56 -0500 | [diff] [blame^] | 2008 | p = reserve_space(xdr, 40); |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 2009 | *p++ = cpu_to_be32(OP_LAYOUTGET); |
| 2010 | *p++ = cpu_to_be32(0); /* Signal layout available */ |
| 2011 | *p++ = cpu_to_be32(args->type); |
| 2012 | *p++ = cpu_to_be32(args->range.iomode); |
| 2013 | p = xdr_encode_hyper(p, args->range.offset); |
| 2014 | p = xdr_encode_hyper(p, args->range.length); |
| 2015 | p = xdr_encode_hyper(p, args->minlength); |
Trond Myklebust | ea9d23f | 2012-03-04 18:13:56 -0500 | [diff] [blame^] | 2016 | encode_nfs4_stateid(xdr, &args->stateid); |
| 2017 | p = reserve_space(xdr, 4); |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 2018 | *p = cpu_to_be32(args->maxcount); |
| 2019 | |
| 2020 | dprintk("%s: 1st type:0x%x iomode:%d off:%lu len:%lu mc:%d\n", |
| 2021 | __func__, |
| 2022 | args->type, |
| 2023 | args->range.iomode, |
| 2024 | (unsigned long)args->range.offset, |
| 2025 | (unsigned long)args->range.length, |
| 2026 | args->maxcount); |
| 2027 | hdr->nops++; |
| 2028 | hdr->replen += decode_layoutget_maxsz; |
| 2029 | } |
Andy Adamson | 863a3c6 | 2011-03-23 13:27:54 +0000 | [diff] [blame] | 2030 | |
| 2031 | static int |
| 2032 | encode_layoutcommit(struct xdr_stream *xdr, |
Benny Halevy | ac7db72 | 2011-05-22 19:53:48 +0300 | [diff] [blame] | 2033 | struct inode *inode, |
Andy Adamson | 863a3c6 | 2011-03-23 13:27:54 +0000 | [diff] [blame] | 2034 | const struct nfs4_layoutcommit_args *args, |
| 2035 | struct compound_hdr *hdr) |
| 2036 | { |
| 2037 | __be32 *p; |
| 2038 | |
| 2039 | dprintk("%s: lbw: %llu type: %d\n", __func__, args->lastbytewritten, |
| 2040 | NFS_SERVER(args->inode)->pnfs_curr_ld->id); |
| 2041 | |
Trond Myklebust | ea9d23f | 2012-03-04 18:13:56 -0500 | [diff] [blame^] | 2042 | p = reserve_space(xdr, 24); |
Andy Adamson | 863a3c6 | 2011-03-23 13:27:54 +0000 | [diff] [blame] | 2043 | *p++ = cpu_to_be32(OP_LAYOUTCOMMIT); |
| 2044 | /* Only whole file layouts */ |
| 2045 | p = xdr_encode_hyper(p, 0); /* offset */ |
Peng Tao | 3557c6c | 2011-07-30 20:52:34 -0400 | [diff] [blame] | 2046 | p = xdr_encode_hyper(p, args->lastbytewritten + 1); /* length */ |
Trond Myklebust | ea9d23f | 2012-03-04 18:13:56 -0500 | [diff] [blame^] | 2047 | *p = cpu_to_be32(0); /* reclaim */ |
| 2048 | encode_nfs4_stateid(xdr, &args->stateid); |
| 2049 | p = reserve_space(xdr, 20); |
Andy Adamson | 863a3c6 | 2011-03-23 13:27:54 +0000 | [diff] [blame] | 2050 | *p++ = cpu_to_be32(1); /* newoffset = TRUE */ |
| 2051 | p = xdr_encode_hyper(p, args->lastbytewritten); |
| 2052 | *p++ = cpu_to_be32(0); /* Never send time_modify_changed */ |
| 2053 | *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] | 2054 | |
| 2055 | if (NFS_SERVER(inode)->pnfs_curr_ld->encode_layoutcommit) |
| 2056 | NFS_SERVER(inode)->pnfs_curr_ld->encode_layoutcommit( |
| 2057 | NFS_I(inode)->layout, xdr, args); |
| 2058 | else { |
| 2059 | p = reserve_space(xdr, 4); |
| 2060 | *p = cpu_to_be32(0); /* no layout-type payload */ |
| 2061 | } |
Andy Adamson | 863a3c6 | 2011-03-23 13:27:54 +0000 | [diff] [blame] | 2062 | |
| 2063 | hdr->nops++; |
| 2064 | hdr->replen += decode_layoutcommit_maxsz; |
| 2065 | return 0; |
| 2066 | } |
Benny Halevy | cbe8260 | 2011-05-22 19:52:37 +0300 | [diff] [blame] | 2067 | |
| 2068 | static void |
| 2069 | encode_layoutreturn(struct xdr_stream *xdr, |
| 2070 | const struct nfs4_layoutreturn_args *args, |
| 2071 | struct compound_hdr *hdr) |
| 2072 | { |
| 2073 | __be32 *p; |
| 2074 | |
| 2075 | p = reserve_space(xdr, 20); |
| 2076 | *p++ = cpu_to_be32(OP_LAYOUTRETURN); |
| 2077 | *p++ = cpu_to_be32(0); /* reclaim. always 0 for now */ |
| 2078 | *p++ = cpu_to_be32(args->layout_type); |
| 2079 | *p++ = cpu_to_be32(IOMODE_ANY); |
| 2080 | *p = cpu_to_be32(RETURN_FILE); |
Trond Myklebust | ea9d23f | 2012-03-04 18:13:56 -0500 | [diff] [blame^] | 2081 | p = reserve_space(xdr, 16); |
Benny Halevy | cbe8260 | 2011-05-22 19:52:37 +0300 | [diff] [blame] | 2082 | p = xdr_encode_hyper(p, 0); |
| 2083 | p = xdr_encode_hyper(p, NFS4_MAX_UINT64); |
| 2084 | spin_lock(&args->inode->i_lock); |
Trond Myklebust | ea9d23f | 2012-03-04 18:13:56 -0500 | [diff] [blame^] | 2085 | encode_nfs4_stateid(xdr, &args->stateid); |
Benny Halevy | cbe8260 | 2011-05-22 19:52:37 +0300 | [diff] [blame] | 2086 | spin_unlock(&args->inode->i_lock); |
Andy Adamson | 04a5554 | 2011-05-22 19:53:10 +0300 | [diff] [blame] | 2087 | if (NFS_SERVER(args->inode)->pnfs_curr_ld->encode_layoutreturn) { |
| 2088 | NFS_SERVER(args->inode)->pnfs_curr_ld->encode_layoutreturn( |
| 2089 | NFS_I(args->inode)->layout, xdr, args); |
| 2090 | } else { |
| 2091 | p = reserve_space(xdr, 4); |
| 2092 | *p = cpu_to_be32(0); |
| 2093 | } |
Benny Halevy | cbe8260 | 2011-05-22 19:52:37 +0300 | [diff] [blame] | 2094 | hdr->nops++; |
| 2095 | hdr->replen += decode_layoutreturn_maxsz; |
| 2096 | } |
Bryan Schumaker | fca78d6 | 2011-06-02 14:59:07 -0400 | [diff] [blame] | 2097 | |
| 2098 | static int |
| 2099 | encode_secinfo_no_name(struct xdr_stream *xdr, |
| 2100 | const struct nfs41_secinfo_no_name_args *args, |
| 2101 | struct compound_hdr *hdr) |
| 2102 | { |
| 2103 | __be32 *p; |
| 2104 | p = reserve_space(xdr, 8); |
| 2105 | *p++ = cpu_to_be32(OP_SECINFO_NO_NAME); |
| 2106 | *p++ = cpu_to_be32(args->style); |
| 2107 | hdr->nops++; |
| 2108 | hdr->replen += decode_secinfo_no_name_maxsz; |
| 2109 | return 0; |
| 2110 | } |
Bryan Schumaker | 7d97479 | 2011-06-02 14:59:08 -0400 | [diff] [blame] | 2111 | |
| 2112 | static void encode_test_stateid(struct xdr_stream *xdr, |
| 2113 | struct nfs41_test_stateid_args *args, |
| 2114 | struct compound_hdr *hdr) |
| 2115 | { |
| 2116 | __be32 *p; |
| 2117 | |
Trond Myklebust | ea9d23f | 2012-03-04 18:13:56 -0500 | [diff] [blame^] | 2118 | p = reserve_space(xdr, 8); |
Bryan Schumaker | 7d97479 | 2011-06-02 14:59:08 -0400 | [diff] [blame] | 2119 | *p++ = cpu_to_be32(OP_TEST_STATEID); |
Trond Myklebust | ea9d23f | 2012-03-04 18:13:56 -0500 | [diff] [blame^] | 2120 | *p = cpu_to_be32(1); |
| 2121 | encode_nfs4_stateid(xdr, args->stateid); |
Bryan Schumaker | 7d97479 | 2011-06-02 14:59:08 -0400 | [diff] [blame] | 2122 | hdr->nops++; |
| 2123 | hdr->replen += decode_test_stateid_maxsz; |
| 2124 | } |
Bryan Schumaker | 9aeda35 | 2011-06-02 14:59:09 -0400 | [diff] [blame] | 2125 | |
| 2126 | static void encode_free_stateid(struct xdr_stream *xdr, |
| 2127 | struct nfs41_free_stateid_args *args, |
| 2128 | struct compound_hdr *hdr) |
| 2129 | { |
| 2130 | __be32 *p; |
Trond Myklebust | ea9d23f | 2012-03-04 18:13:56 -0500 | [diff] [blame^] | 2131 | p = reserve_space(xdr, 4); |
| 2132 | *p = cpu_to_be32(OP_FREE_STATEID); |
| 2133 | encode_nfs4_stateid(xdr, args->stateid); |
Bryan Schumaker | 9aeda35 | 2011-06-02 14:59:09 -0400 | [diff] [blame] | 2134 | hdr->nops++; |
| 2135 | hdr->replen += decode_free_stateid_maxsz; |
| 2136 | } |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 2137 | #endif /* CONFIG_NFS_V4_1 */ |
| 2138 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2139 | /* |
| 2140 | * END OF "GENERIC" ENCODE ROUTINES. |
| 2141 | */ |
| 2142 | |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2143 | static u32 nfs4_xdr_minorversion(const struct nfs4_sequence_args *args) |
| 2144 | { |
| 2145 | #if defined(CONFIG_NFS_V4_1) |
| 2146 | if (args->sa_session) |
Trond Myklebust | a443234 | 2010-06-16 09:52:27 -0400 | [diff] [blame] | 2147 | return args->sa_session->clp->cl_mvops->minor_version; |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2148 | #endif /* CONFIG_NFS_V4_1 */ |
| 2149 | return 0; |
| 2150 | } |
| 2151 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2152 | /* |
| 2153 | * Encode an ACCESS request |
| 2154 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2155 | static void nfs4_xdr_enc_access(struct rpc_rqst *req, struct xdr_stream *xdr, |
| 2156 | const struct nfs4_accessargs *args) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2157 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2158 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2159 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2160 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2161 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2162 | encode_compound_hdr(xdr, req, &hdr); |
| 2163 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2164 | encode_putfh(xdr, args->fh, &hdr); |
| 2165 | encode_access(xdr, args->access, &hdr); |
| 2166 | encode_getfattr(xdr, args->bitmask, &hdr); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2167 | encode_nops(&hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2168 | } |
| 2169 | |
| 2170 | /* |
| 2171 | * Encode LOOKUP request |
| 2172 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2173 | static void nfs4_xdr_enc_lookup(struct rpc_rqst *req, struct xdr_stream *xdr, |
| 2174 | const struct nfs4_lookup_arg *args) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2175 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2176 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2177 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2178 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2179 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2180 | encode_compound_hdr(xdr, req, &hdr); |
| 2181 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2182 | encode_putfh(xdr, args->dir_fh, &hdr); |
| 2183 | encode_lookup(xdr, args->name, &hdr); |
| 2184 | encode_getfh(xdr, &hdr); |
| 2185 | encode_getfattr(xdr, args->bitmask, &hdr); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2186 | encode_nops(&hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2187 | } |
| 2188 | |
| 2189 | /* |
| 2190 | * Encode LOOKUP_ROOT request |
| 2191 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2192 | static void nfs4_xdr_enc_lookup_root(struct rpc_rqst *req, |
| 2193 | struct xdr_stream *xdr, |
| 2194 | const struct nfs4_lookup_root_arg *args) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2195 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2196 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2197 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2198 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2199 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2200 | encode_compound_hdr(xdr, req, &hdr); |
| 2201 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2202 | encode_putrootfh(xdr, &hdr); |
| 2203 | encode_getfh(xdr, &hdr); |
| 2204 | encode_getfattr(xdr, args->bitmask, &hdr); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2205 | encode_nops(&hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2206 | } |
| 2207 | |
| 2208 | /* |
| 2209 | * Encode REMOVE request |
| 2210 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2211 | static void nfs4_xdr_enc_remove(struct rpc_rqst *req, struct xdr_stream *xdr, |
| 2212 | const struct nfs_removeargs *args) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2213 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2214 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2215 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2216 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2217 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2218 | encode_compound_hdr(xdr, req, &hdr); |
| 2219 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2220 | encode_putfh(xdr, args->fh, &hdr); |
| 2221 | encode_remove(xdr, &args->name, &hdr); |
| 2222 | encode_getfattr(xdr, args->bitmask, &hdr); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2223 | encode_nops(&hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2224 | } |
| 2225 | |
| 2226 | /* |
| 2227 | * Encode RENAME request |
| 2228 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2229 | static void nfs4_xdr_enc_rename(struct rpc_rqst *req, struct xdr_stream *xdr, |
| 2230 | const struct nfs_renameargs *args) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2231 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2232 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2233 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2234 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2235 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2236 | encode_compound_hdr(xdr, req, &hdr); |
| 2237 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2238 | encode_putfh(xdr, args->old_dir, &hdr); |
| 2239 | encode_savefh(xdr, &hdr); |
| 2240 | encode_putfh(xdr, args->new_dir, &hdr); |
| 2241 | encode_rename(xdr, args->old_name, args->new_name, &hdr); |
| 2242 | encode_getfattr(xdr, args->bitmask, &hdr); |
| 2243 | encode_restorefh(xdr, &hdr); |
| 2244 | encode_getfattr(xdr, args->bitmask, &hdr); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2245 | encode_nops(&hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2246 | } |
| 2247 | |
| 2248 | /* |
| 2249 | * Encode LINK request |
| 2250 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2251 | static void nfs4_xdr_enc_link(struct rpc_rqst *req, struct xdr_stream *xdr, |
| 2252 | const struct nfs4_link_arg *args) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2253 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2254 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2255 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2256 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2257 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2258 | encode_compound_hdr(xdr, req, &hdr); |
| 2259 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2260 | encode_putfh(xdr, args->fh, &hdr); |
| 2261 | encode_savefh(xdr, &hdr); |
| 2262 | encode_putfh(xdr, args->dir_fh, &hdr); |
| 2263 | encode_link(xdr, args->name, &hdr); |
| 2264 | encode_getfattr(xdr, args->bitmask, &hdr); |
| 2265 | encode_restorefh(xdr, &hdr); |
| 2266 | encode_getfattr(xdr, args->bitmask, &hdr); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2267 | encode_nops(&hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2268 | } |
| 2269 | |
| 2270 | /* |
| 2271 | * Encode CREATE request |
| 2272 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2273 | static void nfs4_xdr_enc_create(struct rpc_rqst *req, struct xdr_stream *xdr, |
| 2274 | const struct nfs4_create_arg *args) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2275 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2276 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2277 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2278 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2279 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2280 | encode_compound_hdr(xdr, req, &hdr); |
| 2281 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2282 | encode_putfh(xdr, args->dir_fh, &hdr); |
| 2283 | encode_savefh(xdr, &hdr); |
| 2284 | encode_create(xdr, args, &hdr); |
| 2285 | encode_getfh(xdr, &hdr); |
| 2286 | encode_getfattr(xdr, args->bitmask, &hdr); |
| 2287 | encode_restorefh(xdr, &hdr); |
| 2288 | encode_getfattr(xdr, args->bitmask, &hdr); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2289 | encode_nops(&hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2290 | } |
| 2291 | |
| 2292 | /* |
| 2293 | * Encode SYMLINK request |
| 2294 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2295 | static void nfs4_xdr_enc_symlink(struct rpc_rqst *req, struct xdr_stream *xdr, |
| 2296 | const struct nfs4_create_arg *args) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2297 | { |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2298 | nfs4_xdr_enc_create(req, xdr, args); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2299 | } |
| 2300 | |
| 2301 | /* |
| 2302 | * Encode GETATTR request |
| 2303 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2304 | static void nfs4_xdr_enc_getattr(struct rpc_rqst *req, struct xdr_stream *xdr, |
| 2305 | const struct nfs4_getattr_arg *args) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2306 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2307 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2308 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2309 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2310 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2311 | encode_compound_hdr(xdr, req, &hdr); |
| 2312 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2313 | encode_putfh(xdr, args->fh, &hdr); |
| 2314 | encode_getfattr(xdr, args->bitmask, &hdr); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2315 | encode_nops(&hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2316 | } |
| 2317 | |
| 2318 | /* |
| 2319 | * Encode a CLOSE request |
| 2320 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2321 | static void nfs4_xdr_enc_close(struct rpc_rqst *req, struct xdr_stream *xdr, |
| 2322 | struct nfs_closeargs *args) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2323 | { |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 2324 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2325 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 2326 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2327 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2328 | encode_compound_hdr(xdr, req, &hdr); |
| 2329 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2330 | encode_putfh(xdr, args->fh, &hdr); |
| 2331 | encode_close(xdr, args, &hdr); |
| 2332 | encode_getfattr(xdr, args->bitmask, &hdr); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2333 | encode_nops(&hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2334 | } |
| 2335 | |
| 2336 | /* |
| 2337 | * Encode an OPEN request |
| 2338 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2339 | static void nfs4_xdr_enc_open(struct rpc_rqst *req, struct xdr_stream *xdr, |
| 2340 | struct nfs_openargs *args) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2341 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2342 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2343 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2344 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2345 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2346 | encode_compound_hdr(xdr, req, &hdr); |
| 2347 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2348 | encode_putfh(xdr, args->fh, &hdr); |
| 2349 | encode_savefh(xdr, &hdr); |
| 2350 | encode_open(xdr, args, &hdr); |
| 2351 | encode_getfh(xdr, &hdr); |
| 2352 | encode_getfattr(xdr, args->bitmask, &hdr); |
| 2353 | encode_restorefh(xdr, &hdr); |
Trond Myklebust | 6926afd1 | 2012-01-07 13:22:46 -0500 | [diff] [blame] | 2354 | encode_getfattr(xdr, args->dir_bitmask, &hdr); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2355 | encode_nops(&hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2356 | } |
| 2357 | |
| 2358 | /* |
| 2359 | * Encode an OPEN_CONFIRM request |
| 2360 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2361 | static void nfs4_xdr_enc_open_confirm(struct rpc_rqst *req, |
| 2362 | struct xdr_stream *xdr, |
| 2363 | struct nfs_open_confirmargs *args) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2364 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2365 | struct compound_hdr hdr = { |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2366 | .nops = 0, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2367 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2368 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2369 | encode_compound_hdr(xdr, req, &hdr); |
| 2370 | encode_putfh(xdr, args->fh, &hdr); |
| 2371 | encode_open_confirm(xdr, args, &hdr); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2372 | encode_nops(&hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2373 | } |
| 2374 | |
| 2375 | /* |
| 2376 | * Encode an OPEN request with no attributes. |
| 2377 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2378 | static void nfs4_xdr_enc_open_noattr(struct rpc_rqst *req, |
| 2379 | struct xdr_stream *xdr, |
| 2380 | struct nfs_openargs *args) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2381 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2382 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2383 | .minorversion = nfs4_xdr_minorversion(&args->seq_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 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2386 | encode_compound_hdr(xdr, req, &hdr); |
| 2387 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2388 | encode_putfh(xdr, args->fh, &hdr); |
| 2389 | encode_open(xdr, args, &hdr); |
| 2390 | encode_getfattr(xdr, args->bitmask, &hdr); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2391 | encode_nops(&hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2392 | } |
| 2393 | |
| 2394 | /* |
| 2395 | * Encode an OPEN_DOWNGRADE request |
| 2396 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2397 | static void nfs4_xdr_enc_open_downgrade(struct rpc_rqst *req, |
| 2398 | struct xdr_stream *xdr, |
| 2399 | struct nfs_closeargs *args) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2400 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2401 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2402 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2403 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2404 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2405 | encode_compound_hdr(xdr, req, &hdr); |
| 2406 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2407 | encode_putfh(xdr, args->fh, &hdr); |
| 2408 | encode_open_downgrade(xdr, args, &hdr); |
| 2409 | encode_getfattr(xdr, args->bitmask, &hdr); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2410 | encode_nops(&hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2411 | } |
| 2412 | |
| 2413 | /* |
| 2414 | * Encode a LOCK request |
| 2415 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2416 | static void nfs4_xdr_enc_lock(struct rpc_rqst *req, struct xdr_stream *xdr, |
| 2417 | struct nfs_lock_args *args) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2418 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2419 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2420 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2421 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2422 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2423 | encode_compound_hdr(xdr, req, &hdr); |
| 2424 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2425 | encode_putfh(xdr, args->fh, &hdr); |
| 2426 | encode_lock(xdr, args, &hdr); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2427 | encode_nops(&hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2428 | } |
| 2429 | |
| 2430 | /* |
| 2431 | * Encode a LOCKT request |
| 2432 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2433 | static void nfs4_xdr_enc_lockt(struct rpc_rqst *req, struct xdr_stream *xdr, |
| 2434 | struct nfs_lockt_args *args) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2435 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2436 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2437 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2438 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2439 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2440 | encode_compound_hdr(xdr, req, &hdr); |
| 2441 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2442 | encode_putfh(xdr, args->fh, &hdr); |
| 2443 | encode_lockt(xdr, args, &hdr); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2444 | encode_nops(&hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2445 | } |
| 2446 | |
| 2447 | /* |
| 2448 | * Encode a LOCKU request |
| 2449 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2450 | static void nfs4_xdr_enc_locku(struct rpc_rqst *req, struct xdr_stream *xdr, |
| 2451 | struct nfs_locku_args *args) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2452 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2453 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2454 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2455 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2456 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2457 | encode_compound_hdr(xdr, req, &hdr); |
| 2458 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2459 | encode_putfh(xdr, args->fh, &hdr); |
| 2460 | encode_locku(xdr, args, &hdr); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2461 | encode_nops(&hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2462 | } |
| 2463 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2464 | static void nfs4_xdr_enc_release_lockowner(struct rpc_rqst *req, |
| 2465 | struct xdr_stream *xdr, |
| 2466 | struct nfs_release_lockowner_args *args) |
Trond Myklebust | d3c7b7c | 2010-07-01 12:49:01 -0400 | [diff] [blame] | 2467 | { |
Trond Myklebust | d3c7b7c | 2010-07-01 12:49:01 -0400 | [diff] [blame] | 2468 | struct compound_hdr hdr = { |
| 2469 | .minorversion = 0, |
| 2470 | }; |
| 2471 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2472 | encode_compound_hdr(xdr, req, &hdr); |
| 2473 | encode_release_lockowner(xdr, &args->lock_owner, &hdr); |
Trond Myklebust | d3c7b7c | 2010-07-01 12:49:01 -0400 | [diff] [blame] | 2474 | encode_nops(&hdr); |
Trond Myklebust | d3c7b7c | 2010-07-01 12:49:01 -0400 | [diff] [blame] | 2475 | } |
| 2476 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2477 | /* |
| 2478 | * Encode a READLINK request |
| 2479 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2480 | static void nfs4_xdr_enc_readlink(struct rpc_rqst *req, struct xdr_stream *xdr, |
| 2481 | const struct nfs4_readlink *args) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2482 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2483 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2484 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2485 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2486 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2487 | encode_compound_hdr(xdr, req, &hdr); |
| 2488 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2489 | encode_putfh(xdr, args->fh, &hdr); |
| 2490 | encode_readlink(xdr, args, req, &hdr); |
Trond Myklebust | e3a535e | 2007-07-19 10:03:38 -0400 | [diff] [blame] | 2491 | |
Benny Halevy | 28f5669 | 2009-04-01 09:22:09 -0400 | [diff] [blame] | 2492 | xdr_inline_pages(&req->rq_rcv_buf, hdr.replen << 2, args->pages, |
Trond Myklebust | e3a535e | 2007-07-19 10:03:38 -0400 | [diff] [blame] | 2493 | args->pgbase, args->pglen); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2494 | encode_nops(&hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2495 | } |
| 2496 | |
| 2497 | /* |
| 2498 | * Encode a READDIR request |
| 2499 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2500 | static void nfs4_xdr_enc_readdir(struct rpc_rqst *req, struct xdr_stream *xdr, |
| 2501 | const struct nfs4_readdir_arg *args) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2502 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2503 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2504 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2505 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2506 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2507 | encode_compound_hdr(xdr, req, &hdr); |
| 2508 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2509 | encode_putfh(xdr, args->fh, &hdr); |
| 2510 | encode_readdir(xdr, args, req, &hdr); |
Trond Myklebust | d6ac02d | 2007-07-19 10:03:37 -0400 | [diff] [blame] | 2511 | |
Benny Halevy | 28f5669 | 2009-04-01 09:22:09 -0400 | [diff] [blame] | 2512 | xdr_inline_pages(&req->rq_rcv_buf, hdr.replen << 2, args->pages, |
Trond Myklebust | d6ac02d | 2007-07-19 10:03:37 -0400 | [diff] [blame] | 2513 | args->pgbase, args->count); |
| 2514 | dprintk("%s: inlined page args = (%u, %p, %u, %u)\n", |
Benny Halevy | 28f5669 | 2009-04-01 09:22:09 -0400 | [diff] [blame] | 2515 | __func__, hdr.replen << 2, args->pages, |
Trond Myklebust | d6ac02d | 2007-07-19 10:03:37 -0400 | [diff] [blame] | 2516 | args->pgbase, args->count); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2517 | encode_nops(&hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2518 | } |
| 2519 | |
| 2520 | /* |
| 2521 | * Encode a READ request |
| 2522 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2523 | static void nfs4_xdr_enc_read(struct rpc_rqst *req, struct xdr_stream *xdr, |
| 2524 | struct nfs_readargs *args) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2525 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2526 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2527 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2528 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2529 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2530 | encode_compound_hdr(xdr, req, &hdr); |
| 2531 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2532 | encode_putfh(xdr, args->fh, &hdr); |
| 2533 | encode_read(xdr, args, &hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2534 | |
Benny Halevy | 28f5669 | 2009-04-01 09:22:09 -0400 | [diff] [blame] | 2535 | xdr_inline_pages(&req->rq_rcv_buf, hdr.replen << 2, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2536 | args->pages, args->pgbase, args->count); |
\"Talpey, Thomas\ | 4f22ccc | 2007-09-10 13:44:58 -0400 | [diff] [blame] | 2537 | req->rq_rcv_buf.flags |= XDRBUF_READ; |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2538 | encode_nops(&hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2539 | } |
| 2540 | |
| 2541 | /* |
| 2542 | * Encode an SETATTR request |
| 2543 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2544 | static void nfs4_xdr_enc_setattr(struct rpc_rqst *req, struct xdr_stream *xdr, |
| 2545 | struct nfs_setattrargs *args) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2546 | { |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 2547 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2548 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 2549 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2550 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2551 | encode_compound_hdr(xdr, req, &hdr); |
| 2552 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2553 | encode_putfh(xdr, args->fh, &hdr); |
| 2554 | encode_setattr(xdr, args, args->server, &hdr); |
| 2555 | encode_getfattr(xdr, args->bitmask, &hdr); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2556 | encode_nops(&hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2557 | } |
| 2558 | |
| 2559 | /* |
J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 2560 | * Encode a GETACL request |
| 2561 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2562 | static void nfs4_xdr_enc_getacl(struct rpc_rqst *req, struct xdr_stream *xdr, |
| 2563 | struct nfs_getaclargs *args) |
J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 2564 | { |
J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 2565 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2566 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 2567 | }; |
Benny Halevy | 28f5669 | 2009-04-01 09:22:09 -0400 | [diff] [blame] | 2568 | uint32_t replen; |
J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 2569 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2570 | encode_compound_hdr(xdr, req, &hdr); |
| 2571 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2572 | encode_putfh(xdr, args->fh, &hdr); |
Andy Adamson | bf118a3 | 2011-12-07 11:55:27 -0500 | [diff] [blame] | 2573 | replen = hdr.replen + op_decode_hdr_maxsz + 1; |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2574 | encode_getattr_two(xdr, FATTR4_WORD0_ACL, 0, &hdr); |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 2575 | |
Benny Halevy | 28f5669 | 2009-04-01 09:22:09 -0400 | [diff] [blame] | 2576 | xdr_inline_pages(&req->rq_rcv_buf, replen << 2, |
J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 2577 | args->acl_pages, args->acl_pgbase, args->acl_len); |
Andy Adamson | bf118a3 | 2011-12-07 11:55:27 -0500 | [diff] [blame] | 2578 | |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2579 | encode_nops(&hdr); |
J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 2580 | } |
| 2581 | |
| 2582 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2583 | * Encode a WRITE request |
| 2584 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2585 | static void nfs4_xdr_enc_write(struct rpc_rqst *req, struct xdr_stream *xdr, |
| 2586 | struct nfs_writeargs *args) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2587 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2588 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2589 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2590 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2591 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2592 | encode_compound_hdr(xdr, req, &hdr); |
| 2593 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2594 | encode_putfh(xdr, args->fh, &hdr); |
| 2595 | encode_write(xdr, args, &hdr); |
\"Talpey, Thomas\ | 4f22ccc | 2007-09-10 13:44:58 -0400 | [diff] [blame] | 2596 | req->rq_snd_buf.flags |= XDRBUF_WRITE; |
Fred Isaman | 7ffd106 | 2011-03-03 15:13:46 +0000 | [diff] [blame] | 2597 | if (args->bitmask) |
| 2598 | encode_getfattr(xdr, args->bitmask, &hdr); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2599 | encode_nops(&hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2600 | } |
| 2601 | |
| 2602 | /* |
| 2603 | * a COMMIT request |
| 2604 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2605 | static void nfs4_xdr_enc_commit(struct rpc_rqst *req, struct xdr_stream *xdr, |
| 2606 | struct nfs_writeargs *args) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2607 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2608 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2609 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2610 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2611 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2612 | encode_compound_hdr(xdr, req, &hdr); |
| 2613 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2614 | encode_putfh(xdr, args->fh, &hdr); |
| 2615 | encode_commit(xdr, args, &hdr); |
Fred Isaman | 988b6dc | 2011-03-23 13:27:52 +0000 | [diff] [blame] | 2616 | if (args->bitmask) |
| 2617 | encode_getfattr(xdr, args->bitmask, &hdr); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2618 | encode_nops(&hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2619 | } |
| 2620 | |
| 2621 | /* |
| 2622 | * FSINFO request |
| 2623 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2624 | static void nfs4_xdr_enc_fsinfo(struct rpc_rqst *req, struct xdr_stream *xdr, |
| 2625 | struct nfs4_fsinfo_arg *args) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2626 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2627 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2628 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2629 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2630 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2631 | encode_compound_hdr(xdr, req, &hdr); |
| 2632 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2633 | encode_putfh(xdr, args->fh, &hdr); |
| 2634 | encode_fsinfo(xdr, args->bitmask, &hdr); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2635 | encode_nops(&hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2636 | } |
| 2637 | |
| 2638 | /* |
| 2639 | * a PATHCONF request |
| 2640 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2641 | static void nfs4_xdr_enc_pathconf(struct rpc_rqst *req, struct xdr_stream *xdr, |
| 2642 | const struct nfs4_pathconf_arg *args) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2643 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2644 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2645 | .minorversion = nfs4_xdr_minorversion(&args->seq_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 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2648 | encode_compound_hdr(xdr, req, &hdr); |
| 2649 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2650 | encode_putfh(xdr, args->fh, &hdr); |
| 2651 | encode_getattr_one(xdr, args->bitmask[0] & nfs4_pathconf_bitmap[0], |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 2652 | &hdr); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2653 | encode_nops(&hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2654 | } |
| 2655 | |
| 2656 | /* |
| 2657 | * a STATFS request |
| 2658 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2659 | static void nfs4_xdr_enc_statfs(struct rpc_rqst *req, struct xdr_stream *xdr, |
| 2660 | const struct nfs4_statfs_arg *args) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2661 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2662 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2663 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2664 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2665 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2666 | encode_compound_hdr(xdr, req, &hdr); |
| 2667 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2668 | encode_putfh(xdr, args->fh, &hdr); |
| 2669 | encode_getattr_two(xdr, args->bitmask[0] & nfs4_statfs_bitmap[0], |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 2670 | args->bitmask[1] & nfs4_statfs_bitmap[1], &hdr); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2671 | encode_nops(&hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2672 | } |
| 2673 | |
| 2674 | /* |
| 2675 | * GETATTR_BITMAP request |
| 2676 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2677 | static void nfs4_xdr_enc_server_caps(struct rpc_rqst *req, |
| 2678 | struct xdr_stream *xdr, |
| 2679 | struct nfs4_server_caps_arg *args) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2680 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2681 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2682 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2683 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2684 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2685 | encode_compound_hdr(xdr, req, &hdr); |
| 2686 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2687 | encode_putfh(xdr, args->fhandle, &hdr); |
| 2688 | encode_getattr_one(xdr, FATTR4_WORD0_SUPPORTED_ATTRS| |
Chuck Lever | 264e635 | 2012-03-01 17:02:05 -0500 | [diff] [blame] | 2689 | FATTR4_WORD0_FH_EXPIRE_TYPE| |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 2690 | FATTR4_WORD0_LINK_SUPPORT| |
| 2691 | FATTR4_WORD0_SYMLINK_SUPPORT| |
| 2692 | FATTR4_WORD0_ACLSUPPORT, &hdr); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2693 | encode_nops(&hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2694 | } |
| 2695 | |
| 2696 | /* |
| 2697 | * a RENEW request |
| 2698 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2699 | static void nfs4_xdr_enc_renew(struct rpc_rqst *req, struct xdr_stream *xdr, |
| 2700 | struct nfs_client *clp) |
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); |
Chuck Lever | bb4dae5 | 2012-03-01 17:01:48 -0500 | [diff] [blame] | 2707 | encode_renew(xdr, clp->cl_clientid, &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 request |
| 2713 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2714 | static void nfs4_xdr_enc_setclientid(struct rpc_rqst *req, |
| 2715 | struct xdr_stream *xdr, |
| 2716 | struct nfs4_setclientid *sc) |
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 | }; |
| 2721 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2722 | encode_compound_hdr(xdr, req, &hdr); |
| 2723 | encode_setclientid(xdr, sc, &hdr); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2724 | encode_nops(&hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2725 | } |
| 2726 | |
| 2727 | /* |
| 2728 | * a SETCLIENTID_CONFIRM request |
| 2729 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2730 | static void nfs4_xdr_enc_setclientid_confirm(struct rpc_rqst *req, |
| 2731 | struct xdr_stream *xdr, |
| 2732 | struct nfs4_setclientid_res *arg) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2733 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2734 | struct compound_hdr hdr = { |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2735 | .nops = 0, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2736 | }; |
Fred Isaman | dae100c | 2011-07-30 20:52:37 -0400 | [diff] [blame] | 2737 | const u32 lease_bitmap[3] = { FATTR4_WORD0_LEASE_TIME }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2738 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2739 | encode_compound_hdr(xdr, req, &hdr); |
| 2740 | encode_setclientid_confirm(xdr, arg, &hdr); |
| 2741 | encode_putrootfh(xdr, &hdr); |
| 2742 | encode_fsinfo(xdr, lease_bitmap, &hdr); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2743 | encode_nops(&hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2744 | } |
| 2745 | |
| 2746 | /* |
| 2747 | * DELEGRETURN request |
| 2748 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2749 | static void nfs4_xdr_enc_delegreturn(struct rpc_rqst *req, |
| 2750 | struct xdr_stream *xdr, |
| 2751 | const struct nfs4_delegreturnargs *args) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2752 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2753 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2754 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2755 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2756 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2757 | encode_compound_hdr(xdr, req, &hdr); |
| 2758 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2759 | encode_putfh(xdr, args->fhandle, &hdr); |
| 2760 | encode_delegreturn(xdr, args->stateid, &hdr); |
| 2761 | encode_getfattr(xdr, args->bitmask, &hdr); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2762 | encode_nops(&hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2763 | } |
| 2764 | |
| 2765 | /* |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 2766 | * Encode FS_LOCATIONS request |
| 2767 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2768 | static void nfs4_xdr_enc_fs_locations(struct rpc_rqst *req, |
| 2769 | struct xdr_stream *xdr, |
| 2770 | struct nfs4_fs_locations_arg *args) |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 2771 | { |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 2772 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 2773 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 2774 | }; |
Benny Halevy | 28f5669 | 2009-04-01 09:22:09 -0400 | [diff] [blame] | 2775 | uint32_t replen; |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 2776 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2777 | encode_compound_hdr(xdr, req, &hdr); |
| 2778 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2779 | encode_putfh(xdr, args->dir_fh, &hdr); |
| 2780 | encode_lookup(xdr, args->name, &hdr); |
Benny Halevy | 28f5669 | 2009-04-01 09:22:09 -0400 | [diff] [blame] | 2781 | replen = hdr.replen; /* get the attribute into args->page */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2782 | encode_fs_locations(xdr, args->bitmask, &hdr); |
Andy Adamson | cf8cdbe | 2008-12-23 16:06:18 -0500 | [diff] [blame] | 2783 | |
Benny Halevy | 28f5669 | 2009-04-01 09:22:09 -0400 | [diff] [blame] | 2784 | xdr_inline_pages(&req->rq_rcv_buf, replen << 2, &args->page, |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 2785 | 0, PAGE_SIZE); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 2786 | encode_nops(&hdr); |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 2787 | } |
| 2788 | |
Bryan Schumaker | 5a5ea0d | 2011-03-24 17:12:29 +0000 | [diff] [blame] | 2789 | /* |
| 2790 | * Encode SECINFO request |
| 2791 | */ |
| 2792 | static void nfs4_xdr_enc_secinfo(struct rpc_rqst *req, |
| 2793 | struct xdr_stream *xdr, |
| 2794 | struct nfs4_secinfo_arg *args) |
| 2795 | { |
| 2796 | struct compound_hdr hdr = { |
| 2797 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
| 2798 | }; |
| 2799 | |
| 2800 | encode_compound_hdr(xdr, req, &hdr); |
| 2801 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2802 | encode_putfh(xdr, args->dir_fh, &hdr); |
| 2803 | encode_secinfo(xdr, args->name, &hdr); |
| 2804 | encode_nops(&hdr); |
| 2805 | } |
| 2806 | |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 2807 | #if defined(CONFIG_NFS_V4_1) |
| 2808 | /* |
| 2809 | * EXCHANGE_ID request |
| 2810 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2811 | static void nfs4_xdr_enc_exchange_id(struct rpc_rqst *req, |
| 2812 | struct xdr_stream *xdr, |
| 2813 | struct nfs41_exchange_id_args *args) |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 2814 | { |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -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, |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -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_exchange_id(xdr, args, &hdr); |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 2821 | encode_nops(&hdr); |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 2822 | } |
Andy Adamson | 2050f0c | 2009-04-01 09:22:30 -0400 | [diff] [blame] | 2823 | |
| 2824 | /* |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 2825 | * a CREATE_SESSION request |
| 2826 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2827 | static void nfs4_xdr_enc_create_session(struct rpc_rqst *req, |
| 2828 | struct xdr_stream *xdr, |
| 2829 | struct nfs41_create_session_args *args) |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 2830 | { |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 2831 | struct compound_hdr hdr = { |
Trond Myklebust | a443234 | 2010-06-16 09:52:27 -0400 | [diff] [blame] | 2832 | .minorversion = args->client->cl_mvops->minor_version, |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -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_create_session(xdr, args, &hdr); |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 2837 | encode_nops(&hdr); |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 2838 | } |
| 2839 | |
| 2840 | /* |
Andy Adamson | 0f3e66c | 2009-04-01 09:22:34 -0400 | [diff] [blame] | 2841 | * a DESTROY_SESSION request |
| 2842 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2843 | static void nfs4_xdr_enc_destroy_session(struct rpc_rqst *req, |
| 2844 | struct xdr_stream *xdr, |
| 2845 | struct nfs4_session *session) |
Andy Adamson | 0f3e66c | 2009-04-01 09:22:34 -0400 | [diff] [blame] | 2846 | { |
Andy Adamson | 0f3e66c | 2009-04-01 09:22:34 -0400 | [diff] [blame] | 2847 | struct compound_hdr hdr = { |
Trond Myklebust | a443234 | 2010-06-16 09:52:27 -0400 | [diff] [blame] | 2848 | .minorversion = session->clp->cl_mvops->minor_version, |
Andy Adamson | 0f3e66c | 2009-04-01 09:22:34 -0400 | [diff] [blame] | 2849 | }; |
| 2850 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2851 | encode_compound_hdr(xdr, req, &hdr); |
| 2852 | encode_destroy_session(xdr, session, &hdr); |
Andy Adamson | 0f3e66c | 2009-04-01 09:22:34 -0400 | [diff] [blame] | 2853 | encode_nops(&hdr); |
Andy Adamson | 0f3e66c | 2009-04-01 09:22:34 -0400 | [diff] [blame] | 2854 | } |
| 2855 | |
| 2856 | /* |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 2857 | * a SEQUENCE request |
| 2858 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2859 | static void nfs4_xdr_enc_sequence(struct rpc_rqst *req, struct xdr_stream *xdr, |
| 2860 | struct nfs4_sequence_args *args) |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 2861 | { |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 2862 | struct compound_hdr hdr = { |
| 2863 | .minorversion = nfs4_xdr_minorversion(args), |
| 2864 | }; |
| 2865 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2866 | encode_compound_hdr(xdr, req, &hdr); |
| 2867 | encode_sequence(xdr, args, &hdr); |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 2868 | encode_nops(&hdr); |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 2869 | } |
| 2870 | |
| 2871 | /* |
Andy Adamson | 2050f0c | 2009-04-01 09:22:30 -0400 | [diff] [blame] | 2872 | * a GET_LEASE_TIME request |
| 2873 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2874 | static void nfs4_xdr_enc_get_lease_time(struct rpc_rqst *req, |
| 2875 | struct xdr_stream *xdr, |
| 2876 | struct nfs4_get_lease_time_args *args) |
Andy Adamson | 2050f0c | 2009-04-01 09:22:30 -0400 | [diff] [blame] | 2877 | { |
Andy Adamson | 2050f0c | 2009-04-01 09:22:30 -0400 | [diff] [blame] | 2878 | struct compound_hdr hdr = { |
| 2879 | .minorversion = nfs4_xdr_minorversion(&args->la_seq_args), |
| 2880 | }; |
Fred Isaman | dae100c | 2011-07-30 20:52:37 -0400 | [diff] [blame] | 2881 | const u32 lease_bitmap[3] = { FATTR4_WORD0_LEASE_TIME }; |
Andy Adamson | 2050f0c | 2009-04-01 09:22:30 -0400 | [diff] [blame] | 2882 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2883 | encode_compound_hdr(xdr, req, &hdr); |
| 2884 | encode_sequence(xdr, &args->la_seq_args, &hdr); |
| 2885 | encode_putrootfh(xdr, &hdr); |
| 2886 | encode_fsinfo(xdr, lease_bitmap, &hdr); |
Andy Adamson | 2050f0c | 2009-04-01 09:22:30 -0400 | [diff] [blame] | 2887 | encode_nops(&hdr); |
Andy Adamson | 2050f0c | 2009-04-01 09:22:30 -0400 | [diff] [blame] | 2888 | } |
Ricardo Labiaga | 18019753 | 2009-12-05 16:08:40 -0500 | [diff] [blame] | 2889 | |
| 2890 | /* |
| 2891 | * a RECLAIM_COMPLETE request |
| 2892 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2893 | static void nfs4_xdr_enc_reclaim_complete(struct rpc_rqst *req, |
| 2894 | struct xdr_stream *xdr, |
| 2895 | struct nfs41_reclaim_complete_args *args) |
Ricardo Labiaga | 18019753 | 2009-12-05 16:08:40 -0500 | [diff] [blame] | 2896 | { |
Ricardo Labiaga | 18019753 | 2009-12-05 16:08:40 -0500 | [diff] [blame] | 2897 | struct compound_hdr hdr = { |
| 2898 | .minorversion = nfs4_xdr_minorversion(&args->seq_args) |
| 2899 | }; |
| 2900 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2901 | encode_compound_hdr(xdr, req, &hdr); |
| 2902 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2903 | encode_reclaim_complete(xdr, args, &hdr); |
Ricardo Labiaga | 18019753 | 2009-12-05 16:08:40 -0500 | [diff] [blame] | 2904 | encode_nops(&hdr); |
Ricardo Labiaga | 18019753 | 2009-12-05 16:08:40 -0500 | [diff] [blame] | 2905 | } |
| 2906 | |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 2907 | /* |
Andy Adamson | 7f11d8d | 2011-07-30 20:52:35 -0400 | [diff] [blame] | 2908 | * Encode GETDEVICELIST request |
| 2909 | */ |
| 2910 | static void nfs4_xdr_enc_getdevicelist(struct rpc_rqst *req, |
| 2911 | struct xdr_stream *xdr, |
| 2912 | struct nfs4_getdevicelist_args *args) |
| 2913 | { |
| 2914 | struct compound_hdr hdr = { |
| 2915 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
| 2916 | }; |
| 2917 | |
| 2918 | encode_compound_hdr(xdr, req, &hdr); |
| 2919 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2920 | encode_putfh(xdr, args->fh, &hdr); |
| 2921 | encode_getdevicelist(xdr, args, &hdr); |
| 2922 | encode_nops(&hdr); |
| 2923 | } |
| 2924 | |
| 2925 | /* |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 2926 | * Encode GETDEVICEINFO request |
| 2927 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2928 | static void nfs4_xdr_enc_getdeviceinfo(struct rpc_rqst *req, |
| 2929 | struct xdr_stream *xdr, |
| 2930 | struct nfs4_getdeviceinfo_args *args) |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 2931 | { |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 2932 | struct compound_hdr hdr = { |
| 2933 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
| 2934 | }; |
| 2935 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2936 | encode_compound_hdr(xdr, req, &hdr); |
| 2937 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2938 | encode_getdeviceinfo(xdr, args, &hdr); |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 2939 | |
| 2940 | /* set up reply kvec. Subtract notification bitmap max size (2) |
| 2941 | * so that notification bitmap is put in xdr_buf tail */ |
| 2942 | xdr_inline_pages(&req->rq_rcv_buf, (hdr.replen - 2) << 2, |
| 2943 | args->pdev->pages, args->pdev->pgbase, |
| 2944 | args->pdev->pglen); |
| 2945 | |
| 2946 | encode_nops(&hdr); |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 2947 | } |
| 2948 | |
| 2949 | /* |
| 2950 | * Encode LAYOUTGET request |
| 2951 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2952 | static void nfs4_xdr_enc_layoutget(struct rpc_rqst *req, |
| 2953 | struct xdr_stream *xdr, |
| 2954 | struct nfs4_layoutget_args *args) |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 2955 | { |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 2956 | struct compound_hdr hdr = { |
| 2957 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
| 2958 | }; |
| 2959 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 2960 | encode_compound_hdr(xdr, req, &hdr); |
| 2961 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2962 | encode_putfh(xdr, NFS_FH(args->inode), &hdr); |
| 2963 | encode_layoutget(xdr, args, &hdr); |
Weston Andros Adamson | 35124a0 | 2011-03-24 16:48:21 -0400 | [diff] [blame] | 2964 | |
| 2965 | xdr_inline_pages(&req->rq_rcv_buf, hdr.replen << 2, |
| 2966 | args->layout.pages, 0, args->layout.pglen); |
| 2967 | |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 2968 | encode_nops(&hdr); |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 2969 | } |
Andy Adamson | 863a3c6 | 2011-03-23 13:27:54 +0000 | [diff] [blame] | 2970 | |
| 2971 | /* |
| 2972 | * Encode LAYOUTCOMMIT request |
| 2973 | */ |
Benny Halevy | cbe8260 | 2011-05-22 19:52:37 +0300 | [diff] [blame] | 2974 | static void nfs4_xdr_enc_layoutcommit(struct rpc_rqst *req, |
| 2975 | struct xdr_stream *xdr, |
| 2976 | struct nfs4_layoutcommit_args *args) |
Andy Adamson | 863a3c6 | 2011-03-23 13:27:54 +0000 | [diff] [blame] | 2977 | { |
Benny Halevy | ac7db72 | 2011-05-22 19:53:48 +0300 | [diff] [blame] | 2978 | struct nfs4_layoutcommit_data *data = |
| 2979 | container_of(args, struct nfs4_layoutcommit_data, args); |
Andy Adamson | 863a3c6 | 2011-03-23 13:27:54 +0000 | [diff] [blame] | 2980 | struct compound_hdr hdr = { |
| 2981 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
| 2982 | }; |
| 2983 | |
| 2984 | encode_compound_hdr(xdr, req, &hdr); |
| 2985 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 2986 | encode_putfh(xdr, NFS_FH(args->inode), &hdr); |
Benny Halevy | ac7db72 | 2011-05-22 19:53:48 +0300 | [diff] [blame] | 2987 | encode_layoutcommit(xdr, data->args.inode, args, &hdr); |
Andy Adamson | 863a3c6 | 2011-03-23 13:27:54 +0000 | [diff] [blame] | 2988 | encode_getfattr(xdr, args->bitmask, &hdr); |
| 2989 | encode_nops(&hdr); |
Benny Halevy | cbe8260 | 2011-05-22 19:52:37 +0300 | [diff] [blame] | 2990 | } |
| 2991 | |
| 2992 | /* |
| 2993 | * Encode LAYOUTRETURN request |
| 2994 | */ |
| 2995 | static void nfs4_xdr_enc_layoutreturn(struct rpc_rqst *req, |
| 2996 | struct xdr_stream *xdr, |
| 2997 | struct nfs4_layoutreturn_args *args) |
| 2998 | { |
| 2999 | struct compound_hdr hdr = { |
| 3000 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
| 3001 | }; |
| 3002 | |
| 3003 | encode_compound_hdr(xdr, req, &hdr); |
| 3004 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 3005 | encode_putfh(xdr, NFS_FH(args->inode), &hdr); |
| 3006 | encode_layoutreturn(xdr, args, &hdr); |
| 3007 | encode_nops(&hdr); |
Andy Adamson | 863a3c6 | 2011-03-23 13:27:54 +0000 | [diff] [blame] | 3008 | } |
Bryan Schumaker | fca78d6 | 2011-06-02 14:59:07 -0400 | [diff] [blame] | 3009 | |
| 3010 | /* |
| 3011 | * Encode SECINFO_NO_NAME request |
| 3012 | */ |
| 3013 | static int nfs4_xdr_enc_secinfo_no_name(struct rpc_rqst *req, |
| 3014 | struct xdr_stream *xdr, |
| 3015 | struct nfs41_secinfo_no_name_args *args) |
| 3016 | { |
| 3017 | struct compound_hdr hdr = { |
| 3018 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
| 3019 | }; |
| 3020 | |
| 3021 | encode_compound_hdr(xdr, req, &hdr); |
| 3022 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 3023 | encode_putrootfh(xdr, &hdr); |
| 3024 | encode_secinfo_no_name(xdr, args, &hdr); |
| 3025 | encode_nops(&hdr); |
| 3026 | return 0; |
| 3027 | } |
Bryan Schumaker | 7d97479 | 2011-06-02 14:59:08 -0400 | [diff] [blame] | 3028 | |
| 3029 | /* |
| 3030 | * Encode TEST_STATEID request |
| 3031 | */ |
| 3032 | static void nfs4_xdr_enc_test_stateid(struct rpc_rqst *req, |
| 3033 | struct xdr_stream *xdr, |
| 3034 | struct nfs41_test_stateid_args *args) |
| 3035 | { |
| 3036 | struct compound_hdr hdr = { |
| 3037 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
| 3038 | }; |
| 3039 | |
| 3040 | encode_compound_hdr(xdr, req, &hdr); |
| 3041 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 3042 | encode_test_stateid(xdr, args, &hdr); |
| 3043 | encode_nops(&hdr); |
| 3044 | } |
Bryan Schumaker | 9aeda35 | 2011-06-02 14:59:09 -0400 | [diff] [blame] | 3045 | |
| 3046 | /* |
| 3047 | * Encode FREE_STATEID request |
| 3048 | */ |
| 3049 | static void nfs4_xdr_enc_free_stateid(struct rpc_rqst *req, |
| 3050 | struct xdr_stream *xdr, |
| 3051 | struct nfs41_free_stateid_args *args) |
| 3052 | { |
| 3053 | struct compound_hdr hdr = { |
| 3054 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
| 3055 | }; |
| 3056 | |
| 3057 | encode_compound_hdr(xdr, req, &hdr); |
| 3058 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 3059 | encode_free_stateid(xdr, args, &hdr); |
| 3060 | encode_nops(&hdr); |
| 3061 | } |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 3062 | #endif /* CONFIG_NFS_V4_1 */ |
| 3063 | |
Benny Halevy | 686841b | 2009-08-14 17:19:48 +0300 | [diff] [blame] | 3064 | static void print_overflow_msg(const char *func, const struct xdr_stream *xdr) |
| 3065 | { |
| 3066 | dprintk("nfs: %s: prematurely hit end of receive buffer. " |
| 3067 | "Remaining buffer length is %tu words.\n", |
| 3068 | func, xdr->end - xdr->p); |
| 3069 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3070 | |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 3071 | 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] | 3072 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3073 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3074 | |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3075 | p = xdr_inline_decode(xdr, 4); |
| 3076 | if (unlikely(!p)) |
| 3077 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3078 | *len = be32_to_cpup(p); |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3079 | p = xdr_inline_decode(xdr, *len); |
| 3080 | if (unlikely(!p)) |
| 3081 | goto out_overflow; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3082 | *string = (char *)p; |
| 3083 | return 0; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3084 | out_overflow: |
| 3085 | print_overflow_msg(__func__, xdr); |
| 3086 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3087 | } |
| 3088 | |
| 3089 | static int decode_compound_hdr(struct xdr_stream *xdr, struct compound_hdr *hdr) |
| 3090 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3091 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3092 | |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3093 | p = xdr_inline_decode(xdr, 8); |
| 3094 | if (unlikely(!p)) |
| 3095 | goto out_overflow; |
Benny Halevy | 6f723f7 | 2009-08-14 17:19:37 +0300 | [diff] [blame] | 3096 | hdr->status = be32_to_cpup(p++); |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3097 | hdr->taglen = be32_to_cpup(p); |
Andy Adamson | 6c0195a | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 3098 | |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3099 | p = xdr_inline_decode(xdr, hdr->taglen + 4); |
| 3100 | if (unlikely(!p)) |
| 3101 | goto out_overflow; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3102 | hdr->tag = (char *)p; |
| 3103 | p += XDR_QUADLEN(hdr->taglen); |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3104 | hdr->nops = be32_to_cpup(p); |
Benny Halevy | aadf615 | 2008-12-23 16:06:13 -0500 | [diff] [blame] | 3105 | if (unlikely(hdr->nops < 1)) |
| 3106 | return nfs4_stat_to_errno(hdr->status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3107 | return 0; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3108 | out_overflow: |
| 3109 | print_overflow_msg(__func__, xdr); |
| 3110 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3111 | } |
| 3112 | |
| 3113 | static int decode_op_hdr(struct xdr_stream *xdr, enum nfs_opnum4 expected) |
| 3114 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3115 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3116 | uint32_t opnum; |
| 3117 | int32_t nfserr; |
| 3118 | |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3119 | p = xdr_inline_decode(xdr, 8); |
| 3120 | if (unlikely(!p)) |
| 3121 | goto out_overflow; |
Benny Halevy | 6f723f7 | 2009-08-14 17:19:37 +0300 | [diff] [blame] | 3122 | opnum = be32_to_cpup(p++); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3123 | if (opnum != expected) { |
Chuck Lever | fe82a18 | 2007-09-11 18:01:10 -0400 | [diff] [blame] | 3124 | dprintk("nfs: Server returned operation" |
| 3125 | " %d but we issued a request for %d\n", |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3126 | opnum, expected); |
| 3127 | return -EIO; |
| 3128 | } |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3129 | nfserr = be32_to_cpup(p); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3130 | if (nfserr != NFS_OK) |
Benny Halevy | 856dff3 | 2008-03-31 17:39:06 +0300 | [diff] [blame] | 3131 | return nfs4_stat_to_errno(nfserr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3132 | return 0; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3133 | out_overflow: |
| 3134 | print_overflow_msg(__func__, xdr); |
| 3135 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3136 | } |
| 3137 | |
| 3138 | /* Dummy routine */ |
David Howells | adfa6f9 | 2006-08-22 20:06:08 -0400 | [diff] [blame] | 3139 | 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] | 3140 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3141 | __be32 *p; |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 3142 | unsigned int strlen; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3143 | char *str; |
| 3144 | |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3145 | p = xdr_inline_decode(xdr, 12); |
| 3146 | if (likely(p)) |
| 3147 | return decode_opaque_inline(xdr, &strlen, &str); |
| 3148 | print_overflow_msg(__func__, xdr); |
| 3149 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3150 | } |
| 3151 | |
| 3152 | static int decode_attr_bitmap(struct xdr_stream *xdr, uint32_t *bitmap) |
| 3153 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3154 | uint32_t bmlen; |
| 3155 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3156 | |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3157 | p = xdr_inline_decode(xdr, 4); |
| 3158 | if (unlikely(!p)) |
| 3159 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3160 | bmlen = be32_to_cpup(p); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3161 | |
Fred Isaman | dae100c | 2011-07-30 20:52:37 -0400 | [diff] [blame] | 3162 | bitmap[0] = bitmap[1] = bitmap[2] = 0; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3163 | p = xdr_inline_decode(xdr, (bmlen << 2)); |
| 3164 | if (unlikely(!p)) |
| 3165 | goto out_overflow; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3166 | if (bmlen > 0) { |
Benny Halevy | 6f723f7 | 2009-08-14 17:19:37 +0300 | [diff] [blame] | 3167 | bitmap[0] = be32_to_cpup(p++); |
Fred Isaman | dae100c | 2011-07-30 20:52:37 -0400 | [diff] [blame] | 3168 | if (bmlen > 1) { |
| 3169 | bitmap[1] = be32_to_cpup(p++); |
| 3170 | if (bmlen > 2) |
| 3171 | bitmap[2] = be32_to_cpup(p); |
| 3172 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3173 | } |
| 3174 | return 0; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3175 | out_overflow: |
| 3176 | print_overflow_msg(__func__, xdr); |
| 3177 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3178 | } |
| 3179 | |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3180 | 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] | 3181 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3182 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3183 | |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3184 | p = xdr_inline_decode(xdr, 4); |
| 3185 | if (unlikely(!p)) |
| 3186 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3187 | *attrlen = be32_to_cpup(p); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3188 | *savep = xdr->p; |
| 3189 | return 0; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3190 | out_overflow: |
| 3191 | print_overflow_msg(__func__, xdr); |
| 3192 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3193 | } |
| 3194 | |
| 3195 | static int decode_attr_supported(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t *bitmask) |
| 3196 | { |
| 3197 | if (likely(bitmap[0] & FATTR4_WORD0_SUPPORTED_ATTRS)) { |
Roman Borisov | 3388bff | 2010-10-13 16:54:51 +0400 | [diff] [blame] | 3198 | int ret; |
| 3199 | ret = decode_attr_bitmap(xdr, bitmask); |
| 3200 | if (unlikely(ret < 0)) |
| 3201 | return ret; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3202 | bitmap[0] &= ~FATTR4_WORD0_SUPPORTED_ATTRS; |
| 3203 | } else |
Fred Isaman | dae100c | 2011-07-30 20:52:37 -0400 | [diff] [blame] | 3204 | bitmask[0] = bitmask[1] = bitmask[2] = 0; |
| 3205 | dprintk("%s: bitmask=%08x:%08x:%08x\n", __func__, |
| 3206 | bitmask[0], bitmask[1], bitmask[2]); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3207 | return 0; |
| 3208 | } |
| 3209 | |
| 3210 | static int decode_attr_type(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t *type) |
| 3211 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3212 | __be32 *p; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3213 | int ret = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3214 | |
| 3215 | *type = 0; |
| 3216 | if (unlikely(bitmap[0] & (FATTR4_WORD0_TYPE - 1U))) |
| 3217 | return -EIO; |
| 3218 | if (likely(bitmap[0] & FATTR4_WORD0_TYPE)) { |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3219 | p = xdr_inline_decode(xdr, 4); |
| 3220 | if (unlikely(!p)) |
| 3221 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3222 | *type = be32_to_cpup(p); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3223 | if (*type < NF4REG || *type > NF4NAMEDATTR) { |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3224 | dprintk("%s: bad type %d\n", __func__, *type); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3225 | return -EIO; |
| 3226 | } |
| 3227 | bitmap[0] &= ~FATTR4_WORD0_TYPE; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3228 | ret = NFS_ATTR_FATTR_TYPE; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3229 | } |
Trond Myklebust | bca7947 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 3230 | dprintk("%s: type=0%o\n", __func__, nfs_type2fmt[*type]); |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3231 | return ret; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3232 | out_overflow: |
| 3233 | print_overflow_msg(__func__, xdr); |
| 3234 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3235 | } |
| 3236 | |
Chuck Lever | 264e635 | 2012-03-01 17:02:05 -0500 | [diff] [blame] | 3237 | static int decode_attr_fh_expire_type(struct xdr_stream *xdr, |
| 3238 | uint32_t *bitmap, uint32_t *type) |
| 3239 | { |
| 3240 | __be32 *p; |
| 3241 | |
| 3242 | *type = 0; |
| 3243 | if (unlikely(bitmap[0] & (FATTR4_WORD0_FH_EXPIRE_TYPE - 1U))) |
| 3244 | return -EIO; |
| 3245 | if (likely(bitmap[0] & FATTR4_WORD0_FH_EXPIRE_TYPE)) { |
| 3246 | p = xdr_inline_decode(xdr, 4); |
| 3247 | if (unlikely(!p)) |
| 3248 | goto out_overflow; |
| 3249 | *type = be32_to_cpup(p); |
| 3250 | bitmap[0] &= ~FATTR4_WORD0_FH_EXPIRE_TYPE; |
| 3251 | } |
| 3252 | dprintk("%s: expire type=0x%x\n", __func__, *type); |
| 3253 | return 0; |
| 3254 | out_overflow: |
| 3255 | print_overflow_msg(__func__, xdr); |
| 3256 | return -EIO; |
| 3257 | } |
| 3258 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3259 | static int decode_attr_change(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *change) |
| 3260 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3261 | __be32 *p; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3262 | int ret = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3263 | |
| 3264 | *change = 0; |
| 3265 | if (unlikely(bitmap[0] & (FATTR4_WORD0_CHANGE - 1U))) |
| 3266 | return -EIO; |
| 3267 | if (likely(bitmap[0] & FATTR4_WORD0_CHANGE)) { |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3268 | p = xdr_inline_decode(xdr, 8); |
| 3269 | if (unlikely(!p)) |
| 3270 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3271 | xdr_decode_hyper(p, change); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3272 | bitmap[0] &= ~FATTR4_WORD0_CHANGE; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3273 | ret = NFS_ATTR_FATTR_CHANGE; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3274 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3275 | dprintk("%s: change attribute=%Lu\n", __func__, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3276 | (unsigned long long)*change); |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3277 | return ret; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3278 | out_overflow: |
| 3279 | print_overflow_msg(__func__, xdr); |
| 3280 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3281 | } |
| 3282 | |
| 3283 | static int decode_attr_size(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *size) |
| 3284 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3285 | __be32 *p; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3286 | int ret = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3287 | |
| 3288 | *size = 0; |
| 3289 | if (unlikely(bitmap[0] & (FATTR4_WORD0_SIZE - 1U))) |
| 3290 | return -EIO; |
| 3291 | if (likely(bitmap[0] & FATTR4_WORD0_SIZE)) { |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3292 | p = xdr_inline_decode(xdr, 8); |
| 3293 | if (unlikely(!p)) |
| 3294 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3295 | xdr_decode_hyper(p, size); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3296 | bitmap[0] &= ~FATTR4_WORD0_SIZE; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3297 | ret = NFS_ATTR_FATTR_SIZE; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3298 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3299 | dprintk("%s: file size=%Lu\n", __func__, (unsigned long long)*size); |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3300 | return ret; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3301 | out_overflow: |
| 3302 | print_overflow_msg(__func__, xdr); |
| 3303 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3304 | } |
| 3305 | |
| 3306 | static int decode_attr_link_support(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t *res) |
| 3307 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3308 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3309 | |
| 3310 | *res = 0; |
| 3311 | if (unlikely(bitmap[0] & (FATTR4_WORD0_LINK_SUPPORT - 1U))) |
| 3312 | return -EIO; |
| 3313 | if (likely(bitmap[0] & FATTR4_WORD0_LINK_SUPPORT)) { |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3314 | p = xdr_inline_decode(xdr, 4); |
| 3315 | if (unlikely(!p)) |
| 3316 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3317 | *res = be32_to_cpup(p); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3318 | bitmap[0] &= ~FATTR4_WORD0_LINK_SUPPORT; |
| 3319 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3320 | dprintk("%s: link support=%s\n", __func__, *res == 0 ? "false" : "true"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3321 | return 0; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3322 | out_overflow: |
| 3323 | print_overflow_msg(__func__, xdr); |
| 3324 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3325 | } |
| 3326 | |
| 3327 | static int decode_attr_symlink_support(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t *res) |
| 3328 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3329 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3330 | |
| 3331 | *res = 0; |
| 3332 | if (unlikely(bitmap[0] & (FATTR4_WORD0_SYMLINK_SUPPORT - 1U))) |
| 3333 | return -EIO; |
| 3334 | if (likely(bitmap[0] & FATTR4_WORD0_SYMLINK_SUPPORT)) { |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3335 | p = xdr_inline_decode(xdr, 4); |
| 3336 | if (unlikely(!p)) |
| 3337 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3338 | *res = be32_to_cpup(p); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3339 | bitmap[0] &= ~FATTR4_WORD0_SYMLINK_SUPPORT; |
| 3340 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3341 | dprintk("%s: symlink support=%s\n", __func__, *res == 0 ? "false" : "true"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3342 | return 0; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3343 | out_overflow: |
| 3344 | print_overflow_msg(__func__, xdr); |
| 3345 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3346 | } |
| 3347 | |
Trond Myklebust | 8b4bdcf | 2006-06-09 09:34:19 -0400 | [diff] [blame] | 3348 | 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] | 3349 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3350 | __be32 *p; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3351 | int ret = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3352 | |
| 3353 | fsid->major = 0; |
| 3354 | fsid->minor = 0; |
| 3355 | if (unlikely(bitmap[0] & (FATTR4_WORD0_FSID - 1U))) |
| 3356 | return -EIO; |
| 3357 | if (likely(bitmap[0] & FATTR4_WORD0_FSID)) { |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3358 | p = xdr_inline_decode(xdr, 16); |
| 3359 | if (unlikely(!p)) |
| 3360 | goto out_overflow; |
Benny Halevy | 3ceb4db | 2009-08-14 17:19:41 +0300 | [diff] [blame] | 3361 | p = xdr_decode_hyper(p, &fsid->major); |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3362 | xdr_decode_hyper(p, &fsid->minor); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3363 | bitmap[0] &= ~FATTR4_WORD0_FSID; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3364 | ret = NFS_ATTR_FATTR_FSID; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3365 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3366 | dprintk("%s: fsid=(0x%Lx/0x%Lx)\n", __func__, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3367 | (unsigned long long)fsid->major, |
| 3368 | (unsigned long long)fsid->minor); |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3369 | return ret; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3370 | out_overflow: |
| 3371 | print_overflow_msg(__func__, xdr); |
| 3372 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3373 | } |
| 3374 | |
| 3375 | static int decode_attr_lease_time(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t *res) |
| 3376 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3377 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3378 | |
| 3379 | *res = 60; |
| 3380 | if (unlikely(bitmap[0] & (FATTR4_WORD0_LEASE_TIME - 1U))) |
| 3381 | return -EIO; |
| 3382 | if (likely(bitmap[0] & FATTR4_WORD0_LEASE_TIME)) { |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3383 | p = xdr_inline_decode(xdr, 4); |
| 3384 | if (unlikely(!p)) |
| 3385 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3386 | *res = be32_to_cpup(p); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3387 | bitmap[0] &= ~FATTR4_WORD0_LEASE_TIME; |
| 3388 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3389 | dprintk("%s: file size=%u\n", __func__, (unsigned int)*res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3390 | return 0; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3391 | out_overflow: |
| 3392 | print_overflow_msg(__func__, xdr); |
| 3393 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3394 | } |
| 3395 | |
Trond Myklebust | ee7b75f | 2011-06-16 13:15:41 -0400 | [diff] [blame] | 3396 | 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] | 3397 | { |
| 3398 | __be32 *p; |
| 3399 | |
| 3400 | if (unlikely(bitmap[0] & (FATTR4_WORD0_RDATTR_ERROR - 1U))) |
| 3401 | return -EIO; |
| 3402 | if (likely(bitmap[0] & FATTR4_WORD0_RDATTR_ERROR)) { |
| 3403 | p = xdr_inline_decode(xdr, 4); |
| 3404 | if (unlikely(!p)) |
| 3405 | goto out_overflow; |
| 3406 | bitmap[0] &= ~FATTR4_WORD0_RDATTR_ERROR; |
Trond Myklebust | ee7b75f | 2011-06-16 13:15:41 -0400 | [diff] [blame] | 3407 | *res = -be32_to_cpup(p); |
Bryan Schumaker | ae42c70 | 2010-10-21 16:33:17 -0400 | [diff] [blame] | 3408 | } |
| 3409 | return 0; |
| 3410 | out_overflow: |
| 3411 | print_overflow_msg(__func__, xdr); |
| 3412 | return -EIO; |
| 3413 | } |
| 3414 | |
| 3415 | static int decode_attr_filehandle(struct xdr_stream *xdr, uint32_t *bitmap, struct nfs_fh *fh) |
| 3416 | { |
| 3417 | __be32 *p; |
| 3418 | int len; |
| 3419 | |
Trond Myklebust | 7ad0735 | 2010-10-23 15:34:20 -0400 | [diff] [blame] | 3420 | if (fh != NULL) |
| 3421 | memset(fh, 0, sizeof(*fh)); |
Bryan Schumaker | ae42c70 | 2010-10-21 16:33:17 -0400 | [diff] [blame] | 3422 | |
| 3423 | if (unlikely(bitmap[0] & (FATTR4_WORD0_FILEHANDLE - 1U))) |
| 3424 | return -EIO; |
| 3425 | if (likely(bitmap[0] & FATTR4_WORD0_FILEHANDLE)) { |
| 3426 | p = xdr_inline_decode(xdr, 4); |
| 3427 | if (unlikely(!p)) |
| 3428 | goto out_overflow; |
| 3429 | len = be32_to_cpup(p); |
| 3430 | if (len > NFS4_FHSIZE) |
| 3431 | return -EIO; |
Bryan Schumaker | ae42c70 | 2010-10-21 16:33:17 -0400 | [diff] [blame] | 3432 | p = xdr_inline_decode(xdr, len); |
| 3433 | if (unlikely(!p)) |
| 3434 | goto out_overflow; |
Trond Myklebust | 7ad0735 | 2010-10-23 15:34:20 -0400 | [diff] [blame] | 3435 | if (fh != NULL) { |
| 3436 | memcpy(fh->data, p, len); |
| 3437 | fh->size = len; |
| 3438 | } |
Bryan Schumaker | ae42c70 | 2010-10-21 16:33:17 -0400 | [diff] [blame] | 3439 | bitmap[0] &= ~FATTR4_WORD0_FILEHANDLE; |
| 3440 | } |
| 3441 | return 0; |
| 3442 | out_overflow: |
| 3443 | print_overflow_msg(__func__, xdr); |
| 3444 | return -EIO; |
| 3445 | } |
| 3446 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3447 | static int decode_attr_aclsupport(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t *res) |
| 3448 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3449 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3450 | |
| 3451 | *res = ACL4_SUPPORT_ALLOW_ACL|ACL4_SUPPORT_DENY_ACL; |
| 3452 | if (unlikely(bitmap[0] & (FATTR4_WORD0_ACLSUPPORT - 1U))) |
| 3453 | return -EIO; |
| 3454 | if (likely(bitmap[0] & FATTR4_WORD0_ACLSUPPORT)) { |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3455 | p = xdr_inline_decode(xdr, 4); |
| 3456 | if (unlikely(!p)) |
| 3457 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3458 | *res = be32_to_cpup(p); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3459 | bitmap[0] &= ~FATTR4_WORD0_ACLSUPPORT; |
| 3460 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3461 | dprintk("%s: ACLs supported=%u\n", __func__, (unsigned int)*res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3462 | return 0; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3463 | out_overflow: |
| 3464 | print_overflow_msg(__func__, xdr); |
| 3465 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3466 | } |
| 3467 | |
| 3468 | static int decode_attr_fileid(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *fileid) |
| 3469 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3470 | __be32 *p; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3471 | int ret = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3472 | |
| 3473 | *fileid = 0; |
| 3474 | if (unlikely(bitmap[0] & (FATTR4_WORD0_FILEID - 1U))) |
| 3475 | return -EIO; |
| 3476 | if (likely(bitmap[0] & FATTR4_WORD0_FILEID)) { |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3477 | p = xdr_inline_decode(xdr, 8); |
| 3478 | if (unlikely(!p)) |
| 3479 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3480 | xdr_decode_hyper(p, fileid); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3481 | bitmap[0] &= ~FATTR4_WORD0_FILEID; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3482 | ret = NFS_ATTR_FATTR_FILEID; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3483 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3484 | dprintk("%s: fileid=%Lu\n", __func__, (unsigned long long)*fileid); |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3485 | return ret; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3486 | out_overflow: |
| 3487 | print_overflow_msg(__func__, xdr); |
| 3488 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3489 | } |
| 3490 | |
Manoj Naik | 99baf62 | 2006-06-09 09:34:24 -0400 | [diff] [blame] | 3491 | static int decode_attr_mounted_on_fileid(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *fileid) |
| 3492 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3493 | __be32 *p; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3494 | int ret = 0; |
Manoj Naik | 99baf62 | 2006-06-09 09:34:24 -0400 | [diff] [blame] | 3495 | |
| 3496 | *fileid = 0; |
| 3497 | if (unlikely(bitmap[1] & (FATTR4_WORD1_MOUNTED_ON_FILEID - 1U))) |
| 3498 | return -EIO; |
| 3499 | if (likely(bitmap[1] & FATTR4_WORD1_MOUNTED_ON_FILEID)) { |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3500 | p = xdr_inline_decode(xdr, 8); |
| 3501 | if (unlikely(!p)) |
| 3502 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3503 | xdr_decode_hyper(p, fileid); |
Manoj Naik | 99baf62 | 2006-06-09 09:34:24 -0400 | [diff] [blame] | 3504 | bitmap[1] &= ~FATTR4_WORD1_MOUNTED_ON_FILEID; |
Trond Myklebust | 28331a4 | 2011-04-27 13:47:52 -0400 | [diff] [blame] | 3505 | ret = NFS_ATTR_FATTR_MOUNTED_ON_FILEID; |
Manoj Naik | 99baf62 | 2006-06-09 09:34:24 -0400 | [diff] [blame] | 3506 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3507 | dprintk("%s: fileid=%Lu\n", __func__, (unsigned long long)*fileid); |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3508 | return ret; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3509 | out_overflow: |
| 3510 | print_overflow_msg(__func__, xdr); |
| 3511 | return -EIO; |
Manoj Naik | 99baf62 | 2006-06-09 09:34:24 -0400 | [diff] [blame] | 3512 | } |
| 3513 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3514 | static int decode_attr_files_avail(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *res) |
| 3515 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3516 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3517 | int status = 0; |
| 3518 | |
| 3519 | *res = 0; |
| 3520 | if (unlikely(bitmap[0] & (FATTR4_WORD0_FILES_AVAIL - 1U))) |
| 3521 | return -EIO; |
| 3522 | if (likely(bitmap[0] & FATTR4_WORD0_FILES_AVAIL)) { |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3523 | p = xdr_inline_decode(xdr, 8); |
| 3524 | if (unlikely(!p)) |
| 3525 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3526 | xdr_decode_hyper(p, res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3527 | bitmap[0] &= ~FATTR4_WORD0_FILES_AVAIL; |
| 3528 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3529 | dprintk("%s: files avail=%Lu\n", __func__, (unsigned long long)*res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3530 | return status; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3531 | out_overflow: |
| 3532 | print_overflow_msg(__func__, xdr); |
| 3533 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3534 | } |
| 3535 | |
| 3536 | static int decode_attr_files_free(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *res) |
| 3537 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3538 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3539 | int status = 0; |
| 3540 | |
| 3541 | *res = 0; |
| 3542 | if (unlikely(bitmap[0] & (FATTR4_WORD0_FILES_FREE - 1U))) |
| 3543 | return -EIO; |
| 3544 | if (likely(bitmap[0] & FATTR4_WORD0_FILES_FREE)) { |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3545 | p = xdr_inline_decode(xdr, 8); |
| 3546 | if (unlikely(!p)) |
| 3547 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3548 | xdr_decode_hyper(p, res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3549 | bitmap[0] &= ~FATTR4_WORD0_FILES_FREE; |
| 3550 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3551 | dprintk("%s: files free=%Lu\n", __func__, (unsigned long long)*res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3552 | return status; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3553 | out_overflow: |
| 3554 | print_overflow_msg(__func__, xdr); |
| 3555 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3556 | } |
| 3557 | |
| 3558 | static int decode_attr_files_total(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *res) |
| 3559 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3560 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3561 | int status = 0; |
| 3562 | |
| 3563 | *res = 0; |
| 3564 | if (unlikely(bitmap[0] & (FATTR4_WORD0_FILES_TOTAL - 1U))) |
| 3565 | return -EIO; |
| 3566 | if (likely(bitmap[0] & FATTR4_WORD0_FILES_TOTAL)) { |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3567 | p = xdr_inline_decode(xdr, 8); |
| 3568 | if (unlikely(!p)) |
| 3569 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3570 | xdr_decode_hyper(p, res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3571 | bitmap[0] &= ~FATTR4_WORD0_FILES_TOTAL; |
| 3572 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3573 | dprintk("%s: files total=%Lu\n", __func__, (unsigned long long)*res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3574 | return status; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3575 | out_overflow: |
| 3576 | print_overflow_msg(__func__, xdr); |
| 3577 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3578 | } |
| 3579 | |
Manoj Naik | 7aaa0b3 | 2006-06-09 09:34:23 -0400 | [diff] [blame] | 3580 | static int decode_pathname(struct xdr_stream *xdr, struct nfs4_pathname *path) |
| 3581 | { |
Chuck Lever | 464ad6b | 2007-10-26 13:32:08 -0400 | [diff] [blame] | 3582 | u32 n; |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3583 | __be32 *p; |
Manoj Naik | 7aaa0b3 | 2006-06-09 09:34:23 -0400 | [diff] [blame] | 3584 | int status = 0; |
| 3585 | |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3586 | p = xdr_inline_decode(xdr, 4); |
| 3587 | if (unlikely(!p)) |
| 3588 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3589 | n = be32_to_cpup(p); |
Andy Adamson | 33a43f2 | 2006-06-09 09:34:30 -0400 | [diff] [blame] | 3590 | if (n == 0) |
| 3591 | goto root_path; |
Chuck Lever | 02a2976 | 2012-03-01 17:00:31 -0500 | [diff] [blame] | 3592 | dprintk("pathname4: "); |
Manoj Naik | 7aaa0b3 | 2006-06-09 09:34:23 -0400 | [diff] [blame] | 3593 | path->ncomponents = 0; |
| 3594 | while (path->ncomponents < n) { |
| 3595 | struct nfs4_string *component = &path->components[path->ncomponents]; |
| 3596 | status = decode_opaque_inline(xdr, &component->len, &component->data); |
| 3597 | if (unlikely(status != 0)) |
| 3598 | goto out_eio; |
Chuck Lever | 02a2976 | 2012-03-01 17:00:31 -0500 | [diff] [blame] | 3599 | if (unlikely(nfs_debug & NFSDBG_XDR)) |
| 3600 | pr_cont("%s%.*s ", |
| 3601 | (path->ncomponents != n ? "/ " : ""), |
| 3602 | component->len, component->data); |
Manoj Naik | 7aaa0b3 | 2006-06-09 09:34:23 -0400 | [diff] [blame] | 3603 | if (path->ncomponents < NFS4_PATHNAME_MAXCOMPONENTS) |
| 3604 | path->ncomponents++; |
| 3605 | else { |
| 3606 | dprintk("cannot parse %d components in path\n", n); |
| 3607 | goto out_eio; |
| 3608 | } |
| 3609 | } |
| 3610 | out: |
Manoj Naik | 7aaa0b3 | 2006-06-09 09:34:23 -0400 | [diff] [blame] | 3611 | return status; |
Andy Adamson | 33a43f2 | 2006-06-09 09:34:30 -0400 | [diff] [blame] | 3612 | root_path: |
| 3613 | /* a root pathname is sent as a zero component4 */ |
| 3614 | path->ncomponents = 1; |
| 3615 | path->components[0].len=0; |
| 3616 | path->components[0].data=NULL; |
Chuck Lever | 02a2976 | 2012-03-01 17:00:31 -0500 | [diff] [blame] | 3617 | dprintk("pathname4: /\n"); |
Andy Adamson | 33a43f2 | 2006-06-09 09:34:30 -0400 | [diff] [blame] | 3618 | goto out; |
Manoj Naik | 7aaa0b3 | 2006-06-09 09:34:23 -0400 | [diff] [blame] | 3619 | out_eio: |
| 3620 | dprintk(" status %d", status); |
| 3621 | status = -EIO; |
| 3622 | goto out; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3623 | out_overflow: |
| 3624 | print_overflow_msg(__func__, xdr); |
| 3625 | return -EIO; |
Manoj Naik | 7aaa0b3 | 2006-06-09 09:34:23 -0400 | [diff] [blame] | 3626 | } |
| 3627 | |
| 3628 | 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] | 3629 | { |
| 3630 | int n; |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3631 | __be32 *p; |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 3632 | int status = -EIO; |
| 3633 | |
| 3634 | if (unlikely(bitmap[0] & (FATTR4_WORD0_FS_LOCATIONS -1U))) |
| 3635 | goto out; |
| 3636 | status = 0; |
| 3637 | if (unlikely(!(bitmap[0] & FATTR4_WORD0_FS_LOCATIONS))) |
| 3638 | goto out; |
Trond Myklebust | 8b7e3f4 | 2012-01-30 15:43:56 -0500 | [diff] [blame] | 3639 | status = -EIO; |
| 3640 | /* Ignore borken servers that return unrequested attrs */ |
| 3641 | if (unlikely(res == NULL)) |
| 3642 | goto out; |
Chuck Lever | 02a2976 | 2012-03-01 17:00:31 -0500 | [diff] [blame] | 3643 | dprintk("%s: fsroot:\n", __func__); |
Manoj Naik | 7aaa0b3 | 2006-06-09 09:34:23 -0400 | [diff] [blame] | 3644 | status = decode_pathname(xdr, &res->fs_path); |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 3645 | if (unlikely(status != 0)) |
| 3646 | goto out; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3647 | p = xdr_inline_decode(xdr, 4); |
| 3648 | if (unlikely(!p)) |
| 3649 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3650 | n = be32_to_cpup(p); |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 3651 | if (n <= 0) |
| 3652 | goto out_eio; |
| 3653 | res->nlocations = 0; |
| 3654 | while (res->nlocations < n) { |
Chuck Lever | 464ad6b | 2007-10-26 13:32:08 -0400 | [diff] [blame] | 3655 | u32 m; |
Manoj Naik | 7aaa0b3 | 2006-06-09 09:34:23 -0400 | [diff] [blame] | 3656 | struct nfs4_fs_location *loc = &res->locations[res->nlocations]; |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 3657 | |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3658 | p = xdr_inline_decode(xdr, 4); |
| 3659 | if (unlikely(!p)) |
| 3660 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3661 | m = be32_to_cpup(p); |
Manoj Naik | 7aaa0b3 | 2006-06-09 09:34:23 -0400 | [diff] [blame] | 3662 | |
| 3663 | loc->nservers = 0; |
Chuck Lever | 02a2976 | 2012-03-01 17:00:31 -0500 | [diff] [blame] | 3664 | dprintk("%s: servers:\n", __func__); |
Manoj Naik | 7aaa0b3 | 2006-06-09 09:34:23 -0400 | [diff] [blame] | 3665 | while (loc->nservers < m) { |
| 3666 | struct nfs4_string *server = &loc->servers[loc->nservers]; |
| 3667 | status = decode_opaque_inline(xdr, &server->len, &server->data); |
| 3668 | if (unlikely(status != 0)) |
| 3669 | goto out_eio; |
| 3670 | dprintk("%s ", server->data); |
| 3671 | if (loc->nservers < NFS4_FS_LOCATION_MAXSERVERS) |
| 3672 | loc->nservers++; |
| 3673 | else { |
Chuck Lever | 464ad6b | 2007-10-26 13:32:08 -0400 | [diff] [blame] | 3674 | unsigned int i; |
| 3675 | dprintk("%s: using first %u of %u servers " |
| 3676 | "returned for location %u\n", |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3677 | __func__, |
Chuck Lever | 464ad6b | 2007-10-26 13:32:08 -0400 | [diff] [blame] | 3678 | NFS4_FS_LOCATION_MAXSERVERS, |
| 3679 | m, res->nlocations); |
Manoj Naik | 7aaa0b3 | 2006-06-09 09:34:23 -0400 | [diff] [blame] | 3680 | for (i = loc->nservers; i < m; i++) { |
Trond Myklebust | 2e42c3e | 2007-05-14 17:20:41 -0400 | [diff] [blame] | 3681 | unsigned int len; |
Manoj Naik | 7aaa0b3 | 2006-06-09 09:34:23 -0400 | [diff] [blame] | 3682 | char *data; |
| 3683 | status = decode_opaque_inline(xdr, &len, &data); |
| 3684 | if (unlikely(status != 0)) |
| 3685 | goto out_eio; |
| 3686 | } |
| 3687 | } |
| 3688 | } |
| 3689 | status = decode_pathname(xdr, &loc->rootpath); |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 3690 | if (unlikely(status != 0)) |
| 3691 | goto out_eio; |
Manoj Naik | 7aaa0b3 | 2006-06-09 09:34:23 -0400 | [diff] [blame] | 3692 | if (res->nlocations < NFS4_FS_LOCATIONS_MAXENTRIES) |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 3693 | res->nlocations++; |
| 3694 | } |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3695 | if (res->nlocations != 0) |
Chuck Lever | 81934dd | 2012-03-01 17:01:57 -0500 | [diff] [blame] | 3696 | status = NFS_ATTR_FATTR_V4_LOCATIONS; |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 3697 | out: |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3698 | dprintk("%s: fs_locations done, error = %d\n", __func__, status); |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 3699 | return status; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3700 | out_overflow: |
| 3701 | print_overflow_msg(__func__, xdr); |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 3702 | out_eio: |
| 3703 | status = -EIO; |
| 3704 | goto out; |
| 3705 | } |
| 3706 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3707 | static int decode_attr_maxfilesize(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *res) |
| 3708 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3709 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3710 | int status = 0; |
| 3711 | |
| 3712 | *res = 0; |
| 3713 | if (unlikely(bitmap[0] & (FATTR4_WORD0_MAXFILESIZE - 1U))) |
| 3714 | return -EIO; |
| 3715 | if (likely(bitmap[0] & FATTR4_WORD0_MAXFILESIZE)) { |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3716 | p = xdr_inline_decode(xdr, 8); |
| 3717 | if (unlikely(!p)) |
| 3718 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3719 | xdr_decode_hyper(p, res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3720 | bitmap[0] &= ~FATTR4_WORD0_MAXFILESIZE; |
| 3721 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3722 | dprintk("%s: maxfilesize=%Lu\n", __func__, (unsigned long long)*res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3723 | return status; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3724 | out_overflow: |
| 3725 | print_overflow_msg(__func__, xdr); |
| 3726 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3727 | } |
| 3728 | |
| 3729 | static int decode_attr_maxlink(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t *maxlink) |
| 3730 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3731 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3732 | int status = 0; |
| 3733 | |
| 3734 | *maxlink = 1; |
| 3735 | if (unlikely(bitmap[0] & (FATTR4_WORD0_MAXLINK - 1U))) |
| 3736 | return -EIO; |
| 3737 | if (likely(bitmap[0] & FATTR4_WORD0_MAXLINK)) { |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3738 | p = xdr_inline_decode(xdr, 4); |
| 3739 | if (unlikely(!p)) |
| 3740 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3741 | *maxlink = be32_to_cpup(p); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3742 | bitmap[0] &= ~FATTR4_WORD0_MAXLINK; |
| 3743 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3744 | dprintk("%s: maxlink=%u\n", __func__, *maxlink); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3745 | return status; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3746 | out_overflow: |
| 3747 | print_overflow_msg(__func__, xdr); |
| 3748 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3749 | } |
| 3750 | |
| 3751 | static int decode_attr_maxname(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t *maxname) |
| 3752 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3753 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3754 | int status = 0; |
| 3755 | |
| 3756 | *maxname = 1024; |
| 3757 | if (unlikely(bitmap[0] & (FATTR4_WORD0_MAXNAME - 1U))) |
| 3758 | return -EIO; |
| 3759 | if (likely(bitmap[0] & FATTR4_WORD0_MAXNAME)) { |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3760 | p = xdr_inline_decode(xdr, 4); |
| 3761 | if (unlikely(!p)) |
| 3762 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3763 | *maxname = be32_to_cpup(p); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3764 | bitmap[0] &= ~FATTR4_WORD0_MAXNAME; |
| 3765 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3766 | dprintk("%s: maxname=%u\n", __func__, *maxname); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3767 | return status; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3768 | out_overflow: |
| 3769 | print_overflow_msg(__func__, xdr); |
| 3770 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3771 | } |
| 3772 | |
| 3773 | static int decode_attr_maxread(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t *res) |
| 3774 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3775 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3776 | int status = 0; |
| 3777 | |
| 3778 | *res = 1024; |
| 3779 | if (unlikely(bitmap[0] & (FATTR4_WORD0_MAXREAD - 1U))) |
| 3780 | return -EIO; |
| 3781 | if (likely(bitmap[0] & FATTR4_WORD0_MAXREAD)) { |
| 3782 | uint64_t maxread; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3783 | p = xdr_inline_decode(xdr, 8); |
| 3784 | if (unlikely(!p)) |
| 3785 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3786 | xdr_decode_hyper(p, &maxread); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3787 | if (maxread > 0x7FFFFFFF) |
| 3788 | maxread = 0x7FFFFFFF; |
| 3789 | *res = (uint32_t)maxread; |
| 3790 | bitmap[0] &= ~FATTR4_WORD0_MAXREAD; |
| 3791 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3792 | dprintk("%s: maxread=%lu\n", __func__, (unsigned long)*res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3793 | return status; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3794 | out_overflow: |
| 3795 | print_overflow_msg(__func__, xdr); |
| 3796 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3797 | } |
| 3798 | |
| 3799 | static int decode_attr_maxwrite(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t *res) |
| 3800 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3801 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3802 | int status = 0; |
| 3803 | |
| 3804 | *res = 1024; |
| 3805 | if (unlikely(bitmap[0] & (FATTR4_WORD0_MAXWRITE - 1U))) |
| 3806 | return -EIO; |
| 3807 | if (likely(bitmap[0] & FATTR4_WORD0_MAXWRITE)) { |
| 3808 | uint64_t maxwrite; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3809 | p = xdr_inline_decode(xdr, 8); |
| 3810 | if (unlikely(!p)) |
| 3811 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3812 | xdr_decode_hyper(p, &maxwrite); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3813 | if (maxwrite > 0x7FFFFFFF) |
| 3814 | maxwrite = 0x7FFFFFFF; |
| 3815 | *res = (uint32_t)maxwrite; |
| 3816 | bitmap[0] &= ~FATTR4_WORD0_MAXWRITE; |
| 3817 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3818 | dprintk("%s: maxwrite=%lu\n", __func__, (unsigned long)*res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3819 | return status; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3820 | out_overflow: |
| 3821 | print_overflow_msg(__func__, xdr); |
| 3822 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3823 | } |
| 3824 | |
Trond Myklebust | bca7947 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 3825 | 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] | 3826 | { |
Trond Myklebust | bca7947 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 3827 | uint32_t tmp; |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3828 | __be32 *p; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3829 | int ret = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3830 | |
| 3831 | *mode = 0; |
| 3832 | if (unlikely(bitmap[1] & (FATTR4_WORD1_MODE - 1U))) |
| 3833 | return -EIO; |
| 3834 | if (likely(bitmap[1] & FATTR4_WORD1_MODE)) { |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3835 | p = xdr_inline_decode(xdr, 4); |
| 3836 | if (unlikely(!p)) |
| 3837 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3838 | tmp = be32_to_cpup(p); |
Trond Myklebust | bca7947 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 3839 | *mode = tmp & ~S_IFMT; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3840 | bitmap[1] &= ~FATTR4_WORD1_MODE; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3841 | ret = NFS_ATTR_FATTR_MODE; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3842 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3843 | dprintk("%s: file mode=0%o\n", __func__, (unsigned int)*mode); |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3844 | return ret; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3845 | out_overflow: |
| 3846 | print_overflow_msg(__func__, xdr); |
| 3847 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3848 | } |
| 3849 | |
| 3850 | static int decode_attr_nlink(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t *nlink) |
| 3851 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3852 | __be32 *p; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3853 | int ret = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3854 | |
| 3855 | *nlink = 1; |
| 3856 | if (unlikely(bitmap[1] & (FATTR4_WORD1_NUMLINKS - 1U))) |
| 3857 | return -EIO; |
| 3858 | if (likely(bitmap[1] & FATTR4_WORD1_NUMLINKS)) { |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3859 | p = xdr_inline_decode(xdr, 4); |
| 3860 | if (unlikely(!p)) |
| 3861 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3862 | *nlink = be32_to_cpup(p); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3863 | bitmap[1] &= ~FATTR4_WORD1_NUMLINKS; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3864 | ret = NFS_ATTR_FATTR_NLINK; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3865 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3866 | dprintk("%s: nlink=%u\n", __func__, (unsigned int)*nlink); |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3867 | return ret; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3868 | out_overflow: |
| 3869 | print_overflow_msg(__func__, xdr); |
| 3870 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3871 | } |
| 3872 | |
Trond Myklebust | 80e52ac | 2009-08-09 15:06:19 -0400 | [diff] [blame] | 3873 | static int decode_attr_owner(struct xdr_stream *xdr, uint32_t *bitmap, |
Trond Myklebust | 6926afd1 | 2012-01-07 13:22:46 -0500 | [diff] [blame] | 3874 | const struct nfs_server *server, uint32_t *uid, |
| 3875 | struct nfs4_string *owner_name) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3876 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3877 | uint32_t len; |
| 3878 | __be32 *p; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3879 | int ret = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3880 | |
| 3881 | *uid = -2; |
| 3882 | if (unlikely(bitmap[1] & (FATTR4_WORD1_OWNER - 1U))) |
| 3883 | return -EIO; |
| 3884 | if (likely(bitmap[1] & FATTR4_WORD1_OWNER)) { |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3885 | p = xdr_inline_decode(xdr, 4); |
| 3886 | if (unlikely(!p)) |
| 3887 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3888 | len = be32_to_cpup(p); |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3889 | p = xdr_inline_decode(xdr, len); |
| 3890 | if (unlikely(!p)) |
| 3891 | goto out_overflow; |
Trond Myklebust | 6926afd1 | 2012-01-07 13:22:46 -0500 | [diff] [blame] | 3892 | if (owner_name != NULL) { |
| 3893 | owner_name->data = kmemdup(p, len, GFP_NOWAIT); |
| 3894 | if (owner_name->data != NULL) { |
| 3895 | owner_name->len = len; |
| 3896 | ret = NFS_ATTR_FATTR_OWNER_NAME; |
| 3897 | } |
Trond Myklebust | 80e52ac | 2009-08-09 15:06:19 -0400 | [diff] [blame] | 3898 | } else if (len < XDR_MAX_NETOBJ) { |
Trond Myklebust | e4fd72a | 2011-02-22 15:44:31 -0800 | [diff] [blame] | 3899 | if (nfs_map_name_to_uid(server, (char *)p, len, uid) == 0) |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3900 | ret = NFS_ATTR_FATTR_OWNER; |
| 3901 | else |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3902 | dprintk("%s: nfs_map_name_to_uid failed!\n", |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3903 | __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3904 | } else |
Chuck Lever | fe82a18 | 2007-09-11 18:01:10 -0400 | [diff] [blame] | 3905 | dprintk("%s: name too long (%u)!\n", |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3906 | __func__, len); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3907 | bitmap[1] &= ~FATTR4_WORD1_OWNER; |
| 3908 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3909 | dprintk("%s: uid=%d\n", __func__, (int)*uid); |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3910 | return ret; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3911 | out_overflow: |
| 3912 | print_overflow_msg(__func__, xdr); |
| 3913 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3914 | } |
| 3915 | |
Trond Myklebust | 80e52ac | 2009-08-09 15:06:19 -0400 | [diff] [blame] | 3916 | static int decode_attr_group(struct xdr_stream *xdr, uint32_t *bitmap, |
Trond Myklebust | 6926afd1 | 2012-01-07 13:22:46 -0500 | [diff] [blame] | 3917 | const struct nfs_server *server, uint32_t *gid, |
| 3918 | struct nfs4_string *group_name) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3919 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3920 | uint32_t len; |
| 3921 | __be32 *p; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3922 | int ret = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3923 | |
| 3924 | *gid = -2; |
| 3925 | if (unlikely(bitmap[1] & (FATTR4_WORD1_OWNER_GROUP - 1U))) |
| 3926 | return -EIO; |
| 3927 | if (likely(bitmap[1] & FATTR4_WORD1_OWNER_GROUP)) { |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3928 | p = xdr_inline_decode(xdr, 4); |
| 3929 | if (unlikely(!p)) |
| 3930 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3931 | len = be32_to_cpup(p); |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3932 | p = xdr_inline_decode(xdr, len); |
| 3933 | if (unlikely(!p)) |
| 3934 | goto out_overflow; |
Trond Myklebust | 6926afd1 | 2012-01-07 13:22:46 -0500 | [diff] [blame] | 3935 | if (group_name != NULL) { |
| 3936 | group_name->data = kmemdup(p, len, GFP_NOWAIT); |
| 3937 | if (group_name->data != NULL) { |
| 3938 | group_name->len = len; |
| 3939 | ret = NFS_ATTR_FATTR_GROUP_NAME; |
| 3940 | } |
Trond Myklebust | 80e52ac | 2009-08-09 15:06:19 -0400 | [diff] [blame] | 3941 | } else if (len < XDR_MAX_NETOBJ) { |
Trond Myklebust | e4fd72a | 2011-02-22 15:44:31 -0800 | [diff] [blame] | 3942 | if (nfs_map_group_to_gid(server, (char *)p, len, gid) == 0) |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3943 | ret = NFS_ATTR_FATTR_GROUP; |
| 3944 | else |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3945 | dprintk("%s: nfs_map_group_to_gid failed!\n", |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3946 | __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3947 | } else |
Chuck Lever | fe82a18 | 2007-09-11 18:01:10 -0400 | [diff] [blame] | 3948 | dprintk("%s: name too long (%u)!\n", |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3949 | __func__, len); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3950 | bitmap[1] &= ~FATTR4_WORD1_OWNER_GROUP; |
| 3951 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3952 | dprintk("%s: gid=%d\n", __func__, (int)*gid); |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3953 | return ret; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3954 | out_overflow: |
| 3955 | print_overflow_msg(__func__, xdr); |
| 3956 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3957 | } |
| 3958 | |
| 3959 | static int decode_attr_rdev(struct xdr_stream *xdr, uint32_t *bitmap, dev_t *rdev) |
| 3960 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3961 | uint32_t major = 0, minor = 0; |
| 3962 | __be32 *p; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3963 | int ret = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3964 | |
| 3965 | *rdev = MKDEV(0,0); |
| 3966 | if (unlikely(bitmap[1] & (FATTR4_WORD1_RAWDEV - 1U))) |
| 3967 | return -EIO; |
| 3968 | if (likely(bitmap[1] & FATTR4_WORD1_RAWDEV)) { |
| 3969 | dev_t tmp; |
| 3970 | |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3971 | p = xdr_inline_decode(xdr, 8); |
| 3972 | if (unlikely(!p)) |
| 3973 | goto out_overflow; |
Benny Halevy | 6f723f7 | 2009-08-14 17:19:37 +0300 | [diff] [blame] | 3974 | major = be32_to_cpup(p++); |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 3975 | minor = be32_to_cpup(p); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3976 | tmp = MKDEV(major, minor); |
| 3977 | if (MAJOR(tmp) == major && MINOR(tmp) == minor) |
| 3978 | *rdev = tmp; |
| 3979 | bitmap[1] &= ~ FATTR4_WORD1_RAWDEV; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3980 | ret = NFS_ATTR_FATTR_RDEV; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3981 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 3982 | dprintk("%s: rdev=(0x%x:0x%x)\n", __func__, major, minor); |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 3983 | return ret; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3984 | out_overflow: |
| 3985 | print_overflow_msg(__func__, xdr); |
| 3986 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3987 | } |
| 3988 | |
| 3989 | static int decode_attr_space_avail(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *res) |
| 3990 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 3991 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3992 | int status = 0; |
| 3993 | |
| 3994 | *res = 0; |
| 3995 | if (unlikely(bitmap[1] & (FATTR4_WORD1_SPACE_AVAIL - 1U))) |
| 3996 | return -EIO; |
| 3997 | if (likely(bitmap[1] & FATTR4_WORD1_SPACE_AVAIL)) { |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 3998 | p = xdr_inline_decode(xdr, 8); |
| 3999 | if (unlikely(!p)) |
| 4000 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 4001 | xdr_decode_hyper(p, res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4002 | bitmap[1] &= ~FATTR4_WORD1_SPACE_AVAIL; |
| 4003 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 4004 | dprintk("%s: space avail=%Lu\n", __func__, (unsigned long long)*res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4005 | return status; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 4006 | out_overflow: |
| 4007 | print_overflow_msg(__func__, xdr); |
| 4008 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4009 | } |
| 4010 | |
| 4011 | static int decode_attr_space_free(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *res) |
| 4012 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 4013 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4014 | int status = 0; |
| 4015 | |
| 4016 | *res = 0; |
| 4017 | if (unlikely(bitmap[1] & (FATTR4_WORD1_SPACE_FREE - 1U))) |
| 4018 | return -EIO; |
| 4019 | if (likely(bitmap[1] & FATTR4_WORD1_SPACE_FREE)) { |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 4020 | p = xdr_inline_decode(xdr, 8); |
| 4021 | if (unlikely(!p)) |
| 4022 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 4023 | xdr_decode_hyper(p, res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4024 | bitmap[1] &= ~FATTR4_WORD1_SPACE_FREE; |
| 4025 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 4026 | dprintk("%s: space free=%Lu\n", __func__, (unsigned long long)*res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4027 | return status; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 4028 | out_overflow: |
| 4029 | print_overflow_msg(__func__, xdr); |
| 4030 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4031 | } |
| 4032 | |
| 4033 | static int decode_attr_space_total(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *res) |
| 4034 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 4035 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4036 | int status = 0; |
| 4037 | |
| 4038 | *res = 0; |
| 4039 | if (unlikely(bitmap[1] & (FATTR4_WORD1_SPACE_TOTAL - 1U))) |
| 4040 | return -EIO; |
| 4041 | if (likely(bitmap[1] & FATTR4_WORD1_SPACE_TOTAL)) { |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 4042 | p = xdr_inline_decode(xdr, 8); |
| 4043 | if (unlikely(!p)) |
| 4044 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 4045 | xdr_decode_hyper(p, res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4046 | bitmap[1] &= ~FATTR4_WORD1_SPACE_TOTAL; |
| 4047 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 4048 | dprintk("%s: space total=%Lu\n", __func__, (unsigned long long)*res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4049 | return status; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 4050 | out_overflow: |
| 4051 | print_overflow_msg(__func__, xdr); |
| 4052 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4053 | } |
| 4054 | |
| 4055 | static int decode_attr_space_used(struct xdr_stream *xdr, uint32_t *bitmap, uint64_t *used) |
| 4056 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 4057 | __be32 *p; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 4058 | int ret = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4059 | |
| 4060 | *used = 0; |
| 4061 | if (unlikely(bitmap[1] & (FATTR4_WORD1_SPACE_USED - 1U))) |
| 4062 | return -EIO; |
| 4063 | if (likely(bitmap[1] & FATTR4_WORD1_SPACE_USED)) { |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 4064 | p = xdr_inline_decode(xdr, 8); |
| 4065 | if (unlikely(!p)) |
| 4066 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 4067 | xdr_decode_hyper(p, used); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4068 | bitmap[1] &= ~FATTR4_WORD1_SPACE_USED; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 4069 | ret = NFS_ATTR_FATTR_SPACE_USED; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4070 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 4071 | dprintk("%s: space used=%Lu\n", __func__, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4072 | (unsigned long long)*used); |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 4073 | return ret; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 4074 | out_overflow: |
| 4075 | print_overflow_msg(__func__, xdr); |
| 4076 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4077 | } |
| 4078 | |
| 4079 | static int decode_attr_time(struct xdr_stream *xdr, struct timespec *time) |
| 4080 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 4081 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4082 | uint64_t sec; |
| 4083 | uint32_t nsec; |
| 4084 | |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 4085 | p = xdr_inline_decode(xdr, 12); |
| 4086 | if (unlikely(!p)) |
| 4087 | goto out_overflow; |
Benny Halevy | 3ceb4db | 2009-08-14 17:19:41 +0300 | [diff] [blame] | 4088 | p = xdr_decode_hyper(p, &sec); |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 4089 | nsec = be32_to_cpup(p); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4090 | time->tv_sec = (time_t)sec; |
| 4091 | time->tv_nsec = (long)nsec; |
| 4092 | return 0; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 4093 | out_overflow: |
| 4094 | print_overflow_msg(__func__, xdr); |
| 4095 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4096 | } |
| 4097 | |
| 4098 | static int decode_attr_time_access(struct xdr_stream *xdr, uint32_t *bitmap, struct timespec *time) |
| 4099 | { |
| 4100 | int status = 0; |
| 4101 | |
| 4102 | time->tv_sec = 0; |
| 4103 | time->tv_nsec = 0; |
| 4104 | if (unlikely(bitmap[1] & (FATTR4_WORD1_TIME_ACCESS - 1U))) |
| 4105 | return -EIO; |
| 4106 | if (likely(bitmap[1] & FATTR4_WORD1_TIME_ACCESS)) { |
| 4107 | status = decode_attr_time(xdr, time); |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 4108 | if (status == 0) |
| 4109 | status = NFS_ATTR_FATTR_ATIME; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4110 | bitmap[1] &= ~FATTR4_WORD1_TIME_ACCESS; |
| 4111 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 4112 | dprintk("%s: atime=%ld\n", __func__, (long)time->tv_sec); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4113 | return status; |
| 4114 | } |
| 4115 | |
| 4116 | static int decode_attr_time_metadata(struct xdr_stream *xdr, uint32_t *bitmap, struct timespec *time) |
| 4117 | { |
| 4118 | int status = 0; |
| 4119 | |
| 4120 | time->tv_sec = 0; |
| 4121 | time->tv_nsec = 0; |
| 4122 | if (unlikely(bitmap[1] & (FATTR4_WORD1_TIME_METADATA - 1U))) |
| 4123 | return -EIO; |
| 4124 | if (likely(bitmap[1] & FATTR4_WORD1_TIME_METADATA)) { |
| 4125 | status = decode_attr_time(xdr, time); |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 4126 | if (status == 0) |
| 4127 | status = NFS_ATTR_FATTR_CTIME; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4128 | bitmap[1] &= ~FATTR4_WORD1_TIME_METADATA; |
| 4129 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 4130 | dprintk("%s: ctime=%ld\n", __func__, (long)time->tv_sec); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4131 | return status; |
| 4132 | } |
| 4133 | |
Ricardo Labiaga | 55b6e77 | 2010-10-12 16:30:06 -0700 | [diff] [blame] | 4134 | static int decode_attr_time_delta(struct xdr_stream *xdr, uint32_t *bitmap, |
| 4135 | struct timespec *time) |
| 4136 | { |
| 4137 | int status = 0; |
| 4138 | |
| 4139 | time->tv_sec = 0; |
| 4140 | time->tv_nsec = 0; |
| 4141 | if (unlikely(bitmap[1] & (FATTR4_WORD1_TIME_DELTA - 1U))) |
| 4142 | return -EIO; |
| 4143 | if (likely(bitmap[1] & FATTR4_WORD1_TIME_DELTA)) { |
| 4144 | status = decode_attr_time(xdr, time); |
| 4145 | bitmap[1] &= ~FATTR4_WORD1_TIME_DELTA; |
| 4146 | } |
| 4147 | dprintk("%s: time_delta=%ld %ld\n", __func__, (long)time->tv_sec, |
| 4148 | (long)time->tv_nsec); |
| 4149 | return status; |
| 4150 | } |
| 4151 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4152 | static int decode_attr_time_modify(struct xdr_stream *xdr, uint32_t *bitmap, struct timespec *time) |
| 4153 | { |
| 4154 | int status = 0; |
| 4155 | |
| 4156 | time->tv_sec = 0; |
| 4157 | time->tv_nsec = 0; |
| 4158 | if (unlikely(bitmap[1] & (FATTR4_WORD1_TIME_MODIFY - 1U))) |
| 4159 | return -EIO; |
| 4160 | if (likely(bitmap[1] & FATTR4_WORD1_TIME_MODIFY)) { |
| 4161 | status = decode_attr_time(xdr, time); |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 4162 | if (status == 0) |
| 4163 | status = NFS_ATTR_FATTR_MTIME; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4164 | bitmap[1] &= ~FATTR4_WORD1_TIME_MODIFY; |
| 4165 | } |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 4166 | dprintk("%s: mtime=%ld\n", __func__, (long)time->tv_sec); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4167 | return status; |
| 4168 | } |
| 4169 | |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 4170 | 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] | 4171 | { |
| 4172 | unsigned int attrwords = XDR_QUADLEN(attrlen); |
| 4173 | unsigned int nwords = xdr->p - savep; |
| 4174 | |
| 4175 | if (unlikely(attrwords != nwords)) { |
Chuck Lever | fe82a18 | 2007-09-11 18:01:10 -0400 | [diff] [blame] | 4176 | dprintk("%s: server returned incorrect attribute length: " |
| 4177 | "%u %c %u\n", |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 4178 | __func__, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4179 | attrwords << 2, |
| 4180 | (attrwords < nwords) ? '<' : '>', |
| 4181 | nwords << 2); |
| 4182 | return -EIO; |
| 4183 | } |
| 4184 | return 0; |
| 4185 | } |
| 4186 | |
| 4187 | static int decode_change_info(struct xdr_stream *xdr, struct nfs4_change_info *cinfo) |
| 4188 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 4189 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4190 | |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 4191 | p = xdr_inline_decode(xdr, 20); |
| 4192 | if (unlikely(!p)) |
| 4193 | goto out_overflow; |
Benny Halevy | 6f723f7 | 2009-08-14 17:19:37 +0300 | [diff] [blame] | 4194 | cinfo->atomic = be32_to_cpup(p++); |
Benny Halevy | 3ceb4db | 2009-08-14 17:19:41 +0300 | [diff] [blame] | 4195 | p = xdr_decode_hyper(p, &cinfo->before); |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 4196 | xdr_decode_hyper(p, &cinfo->after); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4197 | return 0; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 4198 | out_overflow: |
| 4199 | print_overflow_msg(__func__, xdr); |
| 4200 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4201 | } |
| 4202 | |
| 4203 | static int decode_access(struct xdr_stream *xdr, struct nfs4_accessres *access) |
| 4204 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 4205 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4206 | uint32_t supp, acc; |
| 4207 | int status; |
| 4208 | |
| 4209 | status = decode_op_hdr(xdr, OP_ACCESS); |
| 4210 | if (status) |
| 4211 | return status; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 4212 | p = xdr_inline_decode(xdr, 8); |
| 4213 | if (unlikely(!p)) |
| 4214 | goto out_overflow; |
Benny Halevy | 6f723f7 | 2009-08-14 17:19:37 +0300 | [diff] [blame] | 4215 | supp = be32_to_cpup(p++); |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 4216 | acc = be32_to_cpup(p); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4217 | access->supported = supp; |
| 4218 | access->access = acc; |
| 4219 | return 0; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 4220 | out_overflow: |
| 4221 | print_overflow_msg(__func__, xdr); |
| 4222 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4223 | } |
| 4224 | |
Benny Halevy | 07d3043 | 2009-08-14 17:19:52 +0300 | [diff] [blame] | 4225 | 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] | 4226 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 4227 | __be32 *p; |
Benny Halevy | 07d3043 | 2009-08-14 17:19:52 +0300 | [diff] [blame] | 4228 | |
| 4229 | p = xdr_inline_decode(xdr, len); |
| 4230 | if (likely(p)) { |
| 4231 | memcpy(buf, p, len); |
| 4232 | return 0; |
| 4233 | } |
| 4234 | print_overflow_msg(__func__, xdr); |
| 4235 | return -EIO; |
| 4236 | } |
| 4237 | |
| 4238 | static int decode_stateid(struct xdr_stream *xdr, nfs4_stateid *stateid) |
| 4239 | { |
| 4240 | return decode_opaque_fixed(xdr, stateid->data, NFS4_STATEID_SIZE); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4241 | } |
| 4242 | |
| 4243 | static int decode_close(struct xdr_stream *xdr, struct nfs_closeres *res) |
| 4244 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4245 | int status; |
| 4246 | |
| 4247 | status = decode_op_hdr(xdr, OP_CLOSE); |
Trond Myklebust | c1d5193 | 2008-04-07 13:20:54 -0400 | [diff] [blame] | 4248 | if (status != -EIO) |
| 4249 | nfs_increment_open_seqid(status, res->seqid); |
Benny Halevy | 07d3043 | 2009-08-14 17:19:52 +0300 | [diff] [blame] | 4250 | if (!status) |
| 4251 | status = decode_stateid(xdr, &res->stateid); |
| 4252 | return status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4253 | } |
| 4254 | |
Benny Halevy | db942bb | 2009-08-14 17:19:56 +0300 | [diff] [blame] | 4255 | static int decode_verifier(struct xdr_stream *xdr, void *verifier) |
| 4256 | { |
| 4257 | return decode_opaque_fixed(xdr, verifier, 8); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4258 | } |
| 4259 | |
| 4260 | static int decode_commit(struct xdr_stream *xdr, struct nfs_writeres *res) |
| 4261 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4262 | int status; |
| 4263 | |
| 4264 | status = decode_op_hdr(xdr, OP_COMMIT); |
Benny Halevy | db942bb | 2009-08-14 17:19:56 +0300 | [diff] [blame] | 4265 | if (!status) |
| 4266 | status = decode_verifier(xdr, res->verf->verifier); |
| 4267 | return status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4268 | } |
| 4269 | |
| 4270 | static int decode_create(struct xdr_stream *xdr, struct nfs4_change_info *cinfo) |
| 4271 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 4272 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4273 | uint32_t bmlen; |
| 4274 | int status; |
| 4275 | |
| 4276 | status = decode_op_hdr(xdr, OP_CREATE); |
| 4277 | if (status) |
| 4278 | return status; |
| 4279 | if ((status = decode_change_info(xdr, cinfo))) |
| 4280 | return status; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 4281 | p = xdr_inline_decode(xdr, 4); |
| 4282 | if (unlikely(!p)) |
| 4283 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 4284 | bmlen = be32_to_cpup(p); |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 4285 | p = xdr_inline_decode(xdr, bmlen << 2); |
| 4286 | if (likely(p)) |
| 4287 | return 0; |
| 4288 | out_overflow: |
| 4289 | print_overflow_msg(__func__, xdr); |
| 4290 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4291 | } |
| 4292 | |
| 4293 | static int decode_server_caps(struct xdr_stream *xdr, struct nfs4_server_caps_res *res) |
| 4294 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 4295 | __be32 *savep; |
Fred Isaman | dae100c | 2011-07-30 20:52:37 -0400 | [diff] [blame] | 4296 | uint32_t attrlen, bitmap[3] = {0}; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4297 | int status; |
| 4298 | |
| 4299 | if ((status = decode_op_hdr(xdr, OP_GETATTR)) != 0) |
| 4300 | goto xdr_error; |
| 4301 | if ((status = decode_attr_bitmap(xdr, bitmap)) != 0) |
| 4302 | goto xdr_error; |
| 4303 | if ((status = decode_attr_length(xdr, &attrlen, &savep)) != 0) |
| 4304 | goto xdr_error; |
| 4305 | if ((status = decode_attr_supported(xdr, bitmap, res->attr_bitmask)) != 0) |
| 4306 | goto xdr_error; |
Chuck Lever | 264e635 | 2012-03-01 17:02:05 -0500 | [diff] [blame] | 4307 | if ((status = decode_attr_fh_expire_type(xdr, bitmap, |
| 4308 | &res->fh_expire_type)) != 0) |
| 4309 | goto xdr_error; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4310 | if ((status = decode_attr_link_support(xdr, bitmap, &res->has_links)) != 0) |
| 4311 | goto xdr_error; |
| 4312 | if ((status = decode_attr_symlink_support(xdr, bitmap, &res->has_symlinks)) != 0) |
| 4313 | goto xdr_error; |
| 4314 | if ((status = decode_attr_aclsupport(xdr, bitmap, &res->acl_bitmask)) != 0) |
| 4315 | goto xdr_error; |
| 4316 | status = verify_attr_len(xdr, savep, attrlen); |
| 4317 | xdr_error: |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 4318 | dprintk("%s: xdr returned %d!\n", __func__, -status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4319 | return status; |
| 4320 | } |
Andy Adamson | 6c0195a | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 4321 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4322 | static int decode_statfs(struct xdr_stream *xdr, struct nfs_fsstat *fsstat) |
| 4323 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 4324 | __be32 *savep; |
Fred Isaman | dae100c | 2011-07-30 20:52:37 -0400 | [diff] [blame] | 4325 | uint32_t attrlen, bitmap[3] = {0}; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4326 | int status; |
Andy Adamson | 6c0195a | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 4327 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4328 | if ((status = decode_op_hdr(xdr, OP_GETATTR)) != 0) |
| 4329 | goto xdr_error; |
| 4330 | if ((status = decode_attr_bitmap(xdr, bitmap)) != 0) |
| 4331 | goto xdr_error; |
| 4332 | if ((status = decode_attr_length(xdr, &attrlen, &savep)) != 0) |
| 4333 | goto xdr_error; |
| 4334 | |
| 4335 | if ((status = decode_attr_files_avail(xdr, bitmap, &fsstat->afiles)) != 0) |
| 4336 | goto xdr_error; |
| 4337 | if ((status = decode_attr_files_free(xdr, bitmap, &fsstat->ffiles)) != 0) |
| 4338 | goto xdr_error; |
| 4339 | if ((status = decode_attr_files_total(xdr, bitmap, &fsstat->tfiles)) != 0) |
| 4340 | goto xdr_error; |
| 4341 | if ((status = decode_attr_space_avail(xdr, bitmap, &fsstat->abytes)) != 0) |
| 4342 | goto xdr_error; |
| 4343 | if ((status = decode_attr_space_free(xdr, bitmap, &fsstat->fbytes)) != 0) |
| 4344 | goto xdr_error; |
| 4345 | if ((status = decode_attr_space_total(xdr, bitmap, &fsstat->tbytes)) != 0) |
| 4346 | goto xdr_error; |
| 4347 | |
| 4348 | status = verify_attr_len(xdr, savep, attrlen); |
| 4349 | xdr_error: |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 4350 | dprintk("%s: xdr returned %d!\n", __func__, -status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4351 | return status; |
| 4352 | } |
| 4353 | |
| 4354 | static int decode_pathconf(struct xdr_stream *xdr, struct nfs_pathconf *pathconf) |
| 4355 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 4356 | __be32 *savep; |
Fred Isaman | dae100c | 2011-07-30 20:52:37 -0400 | [diff] [blame] | 4357 | uint32_t attrlen, bitmap[3] = {0}; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4358 | int status; |
Andy Adamson | 6c0195a | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 4359 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4360 | if ((status = decode_op_hdr(xdr, OP_GETATTR)) != 0) |
| 4361 | goto xdr_error; |
| 4362 | if ((status = decode_attr_bitmap(xdr, bitmap)) != 0) |
| 4363 | goto xdr_error; |
| 4364 | if ((status = decode_attr_length(xdr, &attrlen, &savep)) != 0) |
| 4365 | goto xdr_error; |
| 4366 | |
| 4367 | if ((status = decode_attr_maxlink(xdr, bitmap, &pathconf->max_link)) != 0) |
| 4368 | goto xdr_error; |
| 4369 | if ((status = decode_attr_maxname(xdr, bitmap, &pathconf->max_namelen)) != 0) |
| 4370 | goto xdr_error; |
| 4371 | |
| 4372 | status = verify_attr_len(xdr, savep, attrlen); |
| 4373 | xdr_error: |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 4374 | dprintk("%s: xdr returned %d!\n", __func__, -status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4375 | return status; |
| 4376 | } |
| 4377 | |
Bryan Schumaker | ae42c70 | 2010-10-21 16:33:17 -0400 | [diff] [blame] | 4378 | static int decode_getfattr_attrs(struct xdr_stream *xdr, uint32_t *bitmap, |
| 4379 | struct nfs_fattr *fattr, struct nfs_fh *fh, |
Trond Myklebust | 8b7e3f4 | 2012-01-30 15:43:56 -0500 | [diff] [blame] | 4380 | struct nfs4_fs_locations *fs_loc, |
Trond Myklebust | 6926afd1 | 2012-01-07 13:22:46 -0500 | [diff] [blame] | 4381 | const struct nfs_server *server) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4382 | { |
Trond Myklebust | bca7947 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 4383 | int status; |
| 4384 | umode_t fmode = 0; |
Bryan Schumaker | ae42c70 | 2010-10-21 16:33:17 -0400 | [diff] [blame] | 4385 | uint32_t type; |
Trond Myklebust | ee7b75f | 2011-06-16 13:15:41 -0400 | [diff] [blame] | 4386 | int32_t err; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4387 | |
Trond Myklebust | f26c7a7 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 4388 | status = decode_attr_type(xdr, bitmap, &type); |
| 4389 | if (status < 0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4390 | goto xdr_error; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 4391 | fattr->mode = 0; |
| 4392 | if (status != 0) { |
| 4393 | fattr->mode |= nfs_type2fmt[type]; |
| 4394 | fattr->valid |= status; |
| 4395 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4396 | |
Trond Myklebust | f26c7a7 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 4397 | status = decode_attr_change(xdr, bitmap, &fattr->change_attr); |
| 4398 | if (status < 0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4399 | goto xdr_error; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 4400 | fattr->valid |= status; |
Trond Myklebust | f26c7a7 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 4401 | |
| 4402 | status = decode_attr_size(xdr, bitmap, &fattr->size); |
| 4403 | if (status < 0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4404 | goto xdr_error; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 4405 | fattr->valid |= status; |
Trond Myklebust | f26c7a7 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 4406 | |
| 4407 | status = decode_attr_fsid(xdr, bitmap, &fattr->fsid); |
| 4408 | if (status < 0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4409 | goto xdr_error; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 4410 | fattr->valid |= status; |
Trond Myklebust | f26c7a7 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 4411 | |
Trond Myklebust | ee7b75f | 2011-06-16 13:15:41 -0400 | [diff] [blame] | 4412 | err = 0; |
| 4413 | status = decode_attr_error(xdr, bitmap, &err); |
Bryan Schumaker | ae42c70 | 2010-10-21 16:33:17 -0400 | [diff] [blame] | 4414 | if (status < 0) |
| 4415 | goto xdr_error; |
Trond Myklebust | ee7b75f | 2011-06-16 13:15:41 -0400 | [diff] [blame] | 4416 | if (err == -NFS4ERR_WRONGSEC) |
| 4417 | nfs_fixup_secinfo_attributes(fattr, fh); |
Bryan Schumaker | ae42c70 | 2010-10-21 16:33:17 -0400 | [diff] [blame] | 4418 | |
| 4419 | status = decode_attr_filehandle(xdr, bitmap, fh); |
| 4420 | if (status < 0) |
| 4421 | goto xdr_error; |
| 4422 | |
Trond Myklebust | f26c7a7 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 4423 | status = decode_attr_fileid(xdr, bitmap, &fattr->fileid); |
| 4424 | if (status < 0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4425 | goto xdr_error; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 4426 | fattr->valid |= status; |
Trond Myklebust | f26c7a7 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 4427 | |
Trond Myklebust | 8b7e3f4 | 2012-01-30 15:43:56 -0500 | [diff] [blame] | 4428 | status = decode_attr_fs_locations(xdr, bitmap, fs_loc); |
Trond Myklebust | f26c7a7 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 4429 | if (status < 0) |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 4430 | goto xdr_error; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 4431 | fattr->valid |= status; |
Trond Myklebust | f26c7a7 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 4432 | |
| 4433 | status = decode_attr_mode(xdr, bitmap, &fmode); |
| 4434 | if (status < 0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4435 | goto xdr_error; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 4436 | if (status != 0) { |
| 4437 | fattr->mode |= fmode; |
| 4438 | fattr->valid |= status; |
| 4439 | } |
Trond Myklebust | f26c7a7 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 4440 | |
| 4441 | status = decode_attr_nlink(xdr, bitmap, &fattr->nlink); |
| 4442 | if (status < 0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4443 | goto xdr_error; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 4444 | fattr->valid |= status; |
Trond Myklebust | f26c7a7 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 4445 | |
Trond Myklebust | 6926afd1 | 2012-01-07 13:22:46 -0500 | [diff] [blame] | 4446 | status = decode_attr_owner(xdr, bitmap, server, &fattr->uid, fattr->owner_name); |
Trond Myklebust | f26c7a7 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 4447 | if (status < 0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4448 | goto xdr_error; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 4449 | fattr->valid |= status; |
Trond Myklebust | f26c7a7 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 4450 | |
Trond Myklebust | 6926afd1 | 2012-01-07 13:22:46 -0500 | [diff] [blame] | 4451 | status = decode_attr_group(xdr, bitmap, server, &fattr->gid, fattr->group_name); |
Trond Myklebust | f26c7a7 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 4452 | if (status < 0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4453 | goto xdr_error; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 4454 | fattr->valid |= status; |
Trond Myklebust | f26c7a7 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 4455 | |
| 4456 | status = decode_attr_rdev(xdr, bitmap, &fattr->rdev); |
| 4457 | if (status < 0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4458 | goto xdr_error; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 4459 | fattr->valid |= status; |
Trond Myklebust | f26c7a7 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 4460 | |
| 4461 | status = decode_attr_space_used(xdr, bitmap, &fattr->du.nfs3.used); |
| 4462 | if (status < 0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4463 | goto xdr_error; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 4464 | fattr->valid |= status; |
Trond Myklebust | f26c7a7 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 4465 | |
| 4466 | status = decode_attr_time_access(xdr, bitmap, &fattr->atime); |
| 4467 | if (status < 0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4468 | goto xdr_error; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 4469 | fattr->valid |= status; |
Trond Myklebust | f26c7a7 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 4470 | |
| 4471 | status = decode_attr_time_metadata(xdr, bitmap, &fattr->ctime); |
| 4472 | if (status < 0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4473 | goto xdr_error; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 4474 | fattr->valid |= status; |
Trond Myklebust | f26c7a7 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 4475 | |
| 4476 | status = decode_attr_time_modify(xdr, bitmap, &fattr->mtime); |
| 4477 | if (status < 0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4478 | goto xdr_error; |
Trond Myklebust | 409924e | 2009-03-11 14:10:27 -0400 | [diff] [blame] | 4479 | fattr->valid |= status; |
Trond Myklebust | f26c7a7 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 4480 | |
Trond Myklebust | 28331a4 | 2011-04-27 13:47:52 -0400 | [diff] [blame] | 4481 | status = decode_attr_mounted_on_fileid(xdr, bitmap, &fattr->mounted_on_fileid); |
Trond Myklebust | f26c7a7 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 4482 | if (status < 0) |
Manoj Naik | 99baf62 | 2006-06-09 09:34:24 -0400 | [diff] [blame] | 4483 | goto xdr_error; |
Trond Myklebust | 28331a4 | 2011-04-27 13:47:52 -0400 | [diff] [blame] | 4484 | fattr->valid |= status; |
Trond Myklebust | f26c7a7 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 4485 | |
Bryan Schumaker | ae42c70 | 2010-10-21 16:33:17 -0400 | [diff] [blame] | 4486 | xdr_error: |
| 4487 | dprintk("%s: xdr returned %d\n", __func__, -status); |
| 4488 | return status; |
| 4489 | } |
| 4490 | |
| 4491 | 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] | 4492 | struct nfs_fh *fh, struct nfs4_fs_locations *fs_loc, |
| 4493 | const struct nfs_server *server) |
Bryan Schumaker | ae42c70 | 2010-10-21 16:33:17 -0400 | [diff] [blame] | 4494 | { |
| 4495 | __be32 *savep; |
| 4496 | uint32_t attrlen, |
Fred Isaman | dae100c | 2011-07-30 20:52:37 -0400 | [diff] [blame] | 4497 | bitmap[3] = {0}; |
Bryan Schumaker | ae42c70 | 2010-10-21 16:33:17 -0400 | [diff] [blame] | 4498 | int status; |
| 4499 | |
| 4500 | status = decode_op_hdr(xdr, OP_GETATTR); |
| 4501 | if (status < 0) |
| 4502 | goto xdr_error; |
| 4503 | |
| 4504 | status = decode_attr_bitmap(xdr, bitmap); |
| 4505 | if (status < 0) |
| 4506 | goto xdr_error; |
| 4507 | |
| 4508 | status = decode_attr_length(xdr, &attrlen, &savep); |
| 4509 | if (status < 0) |
| 4510 | goto xdr_error; |
| 4511 | |
Trond Myklebust | 8b7e3f4 | 2012-01-30 15:43:56 -0500 | [diff] [blame] | 4512 | status = decode_getfattr_attrs(xdr, bitmap, fattr, fh, fs_loc, server); |
Bryan Schumaker | ae42c70 | 2010-10-21 16:33:17 -0400 | [diff] [blame] | 4513 | if (status < 0) |
| 4514 | goto xdr_error; |
| 4515 | |
Trond Myklebust | f26c7a7 | 2009-03-11 14:10:26 -0400 | [diff] [blame] | 4516 | status = verify_attr_len(xdr, savep, attrlen); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4517 | xdr_error: |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 4518 | dprintk("%s: xdr returned %d\n", __func__, -status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4519 | return status; |
| 4520 | } |
| 4521 | |
Bryan Schumaker | ae42c70 | 2010-10-21 16:33:17 -0400 | [diff] [blame] | 4522 | static int decode_getfattr(struct xdr_stream *xdr, struct nfs_fattr *fattr, |
Trond Myklebust | 6926afd1 | 2012-01-07 13:22:46 -0500 | [diff] [blame] | 4523 | const struct nfs_server *server) |
Bryan Schumaker | ae42c70 | 2010-10-21 16:33:17 -0400 | [diff] [blame] | 4524 | { |
Trond Myklebust | 8b7e3f4 | 2012-01-30 15:43:56 -0500 | [diff] [blame] | 4525 | return decode_getfattr_generic(xdr, fattr, NULL, NULL, server); |
Bryan Schumaker | ae42c70 | 2010-10-21 16:33:17 -0400 | [diff] [blame] | 4526 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4527 | |
Andy Adamson | 504913f | 2010-10-20 00:17:57 -0400 | [diff] [blame] | 4528 | /* |
| 4529 | * Decode potentially multiple layout types. Currently we only support |
| 4530 | * one layout driver per file system. |
| 4531 | */ |
| 4532 | static int decode_first_pnfs_layout_type(struct xdr_stream *xdr, |
| 4533 | uint32_t *layouttype) |
| 4534 | { |
| 4535 | uint32_t *p; |
| 4536 | int num; |
| 4537 | |
| 4538 | p = xdr_inline_decode(xdr, 4); |
| 4539 | if (unlikely(!p)) |
| 4540 | goto out_overflow; |
| 4541 | num = be32_to_cpup(p); |
| 4542 | |
| 4543 | /* pNFS is not supported by the underlying file system */ |
| 4544 | if (num == 0) { |
| 4545 | *layouttype = 0; |
| 4546 | return 0; |
| 4547 | } |
| 4548 | if (num > 1) |
Weston Andros Adamson | a030889 | 2012-01-26 13:32:23 -0500 | [diff] [blame] | 4549 | printk(KERN_INFO "NFS: %s: Warning: Multiple pNFS layout " |
| 4550 | "drivers per filesystem not supported\n", __func__); |
Andy Adamson | 504913f | 2010-10-20 00:17:57 -0400 | [diff] [blame] | 4551 | |
| 4552 | /* Decode and set first layout type, move xdr->p past unused types */ |
| 4553 | p = xdr_inline_decode(xdr, num * 4); |
| 4554 | if (unlikely(!p)) |
| 4555 | goto out_overflow; |
| 4556 | *layouttype = be32_to_cpup(p); |
| 4557 | return 0; |
| 4558 | out_overflow: |
| 4559 | print_overflow_msg(__func__, xdr); |
| 4560 | return -EIO; |
| 4561 | } |
| 4562 | |
| 4563 | /* |
| 4564 | * The type of file system exported. |
| 4565 | * Note we must ensure that layouttype is set in any non-error case. |
| 4566 | */ |
| 4567 | static int decode_attr_pnfstype(struct xdr_stream *xdr, uint32_t *bitmap, |
| 4568 | uint32_t *layouttype) |
| 4569 | { |
| 4570 | int status = 0; |
| 4571 | |
| 4572 | dprintk("%s: bitmap is %x\n", __func__, bitmap[1]); |
| 4573 | if (unlikely(bitmap[1] & (FATTR4_WORD1_FS_LAYOUT_TYPES - 1U))) |
| 4574 | return -EIO; |
| 4575 | if (bitmap[1] & FATTR4_WORD1_FS_LAYOUT_TYPES) { |
| 4576 | status = decode_first_pnfs_layout_type(xdr, layouttype); |
| 4577 | bitmap[1] &= ~FATTR4_WORD1_FS_LAYOUT_TYPES; |
| 4578 | } else |
| 4579 | *layouttype = 0; |
| 4580 | return status; |
| 4581 | } |
| 4582 | |
Fred Isaman | dae100c | 2011-07-30 20:52:37 -0400 | [diff] [blame] | 4583 | /* |
| 4584 | * The prefered block size for layout directed io |
| 4585 | */ |
| 4586 | static int decode_attr_layout_blksize(struct xdr_stream *xdr, uint32_t *bitmap, |
| 4587 | uint32_t *res) |
| 4588 | { |
| 4589 | __be32 *p; |
| 4590 | |
| 4591 | dprintk("%s: bitmap is %x\n", __func__, bitmap[2]); |
| 4592 | *res = 0; |
| 4593 | if (bitmap[2] & FATTR4_WORD2_LAYOUT_BLKSIZE) { |
| 4594 | p = xdr_inline_decode(xdr, 4); |
| 4595 | if (unlikely(!p)) { |
| 4596 | print_overflow_msg(__func__, xdr); |
| 4597 | return -EIO; |
| 4598 | } |
| 4599 | *res = be32_to_cpup(p); |
| 4600 | bitmap[2] &= ~FATTR4_WORD2_LAYOUT_BLKSIZE; |
| 4601 | } |
| 4602 | return 0; |
| 4603 | } |
| 4604 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4605 | static int decode_fsinfo(struct xdr_stream *xdr, struct nfs_fsinfo *fsinfo) |
| 4606 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 4607 | __be32 *savep; |
Fred Isaman | dae100c | 2011-07-30 20:52:37 -0400 | [diff] [blame] | 4608 | uint32_t attrlen, bitmap[3]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4609 | int status; |
| 4610 | |
| 4611 | if ((status = decode_op_hdr(xdr, OP_GETATTR)) != 0) |
| 4612 | goto xdr_error; |
| 4613 | if ((status = decode_attr_bitmap(xdr, bitmap)) != 0) |
| 4614 | goto xdr_error; |
| 4615 | if ((status = decode_attr_length(xdr, &attrlen, &savep)) != 0) |
| 4616 | goto xdr_error; |
| 4617 | |
| 4618 | fsinfo->rtmult = fsinfo->wtmult = 512; /* ??? */ |
| 4619 | |
| 4620 | if ((status = decode_attr_lease_time(xdr, bitmap, &fsinfo->lease_time)) != 0) |
| 4621 | goto xdr_error; |
| 4622 | if ((status = decode_attr_maxfilesize(xdr, bitmap, &fsinfo->maxfilesize)) != 0) |
| 4623 | goto xdr_error; |
| 4624 | if ((status = decode_attr_maxread(xdr, bitmap, &fsinfo->rtmax)) != 0) |
| 4625 | goto xdr_error; |
| 4626 | fsinfo->rtpref = fsinfo->dtpref = fsinfo->rtmax; |
| 4627 | if ((status = decode_attr_maxwrite(xdr, bitmap, &fsinfo->wtmax)) != 0) |
| 4628 | goto xdr_error; |
| 4629 | fsinfo->wtpref = fsinfo->wtmax; |
Ricardo Labiaga | 55b6e77 | 2010-10-12 16:30:06 -0700 | [diff] [blame] | 4630 | status = decode_attr_time_delta(xdr, bitmap, &fsinfo->time_delta); |
| 4631 | if (status != 0) |
| 4632 | goto xdr_error; |
Andy Adamson | 504913f | 2010-10-20 00:17:57 -0400 | [diff] [blame] | 4633 | status = decode_attr_pnfstype(xdr, bitmap, &fsinfo->layouttype); |
| 4634 | if (status != 0) |
| 4635 | goto xdr_error; |
Fred Isaman | dae100c | 2011-07-30 20:52:37 -0400 | [diff] [blame] | 4636 | status = decode_attr_layout_blksize(xdr, bitmap, &fsinfo->blksize); |
| 4637 | if (status) |
| 4638 | goto xdr_error; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4639 | |
| 4640 | status = verify_attr_len(xdr, savep, attrlen); |
| 4641 | xdr_error: |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 4642 | dprintk("%s: xdr returned %d!\n", __func__, -status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4643 | return status; |
| 4644 | } |
| 4645 | |
| 4646 | static int decode_getfh(struct xdr_stream *xdr, struct nfs_fh *fh) |
| 4647 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 4648 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4649 | uint32_t len; |
| 4650 | int status; |
| 4651 | |
Trond Myklebust | 9936781 | 2007-07-17 21:52:41 -0400 | [diff] [blame] | 4652 | /* Zero handle first to allow comparisons */ |
| 4653 | memset(fh, 0, sizeof(*fh)); |
| 4654 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4655 | status = decode_op_hdr(xdr, OP_GETFH); |
| 4656 | if (status) |
| 4657 | return status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4658 | |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 4659 | p = xdr_inline_decode(xdr, 4); |
| 4660 | if (unlikely(!p)) |
| 4661 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 4662 | len = be32_to_cpup(p); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4663 | if (len > NFS4_FHSIZE) |
| 4664 | return -EIO; |
| 4665 | fh->size = len; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 4666 | p = xdr_inline_decode(xdr, len); |
| 4667 | if (unlikely(!p)) |
| 4668 | goto out_overflow; |
Benny Halevy | 99398d0 | 2009-08-14 17:20:05 +0300 | [diff] [blame] | 4669 | memcpy(fh->data, p, len); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4670 | return 0; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 4671 | out_overflow: |
| 4672 | print_overflow_msg(__func__, xdr); |
| 4673 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4674 | } |
| 4675 | |
| 4676 | static int decode_link(struct xdr_stream *xdr, struct nfs4_change_info *cinfo) |
| 4677 | { |
| 4678 | int status; |
Andy Adamson | 6c0195a | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 4679 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4680 | status = decode_op_hdr(xdr, OP_LINK); |
| 4681 | if (status) |
| 4682 | return status; |
| 4683 | return decode_change_info(xdr, cinfo); |
| 4684 | } |
| 4685 | |
| 4686 | /* |
| 4687 | * We create the owner, so we know a proper owner.id length is 4. |
| 4688 | */ |
Trond Myklebust | 911d1aa | 2006-01-03 09:55:16 +0100 | [diff] [blame] | 4689 | 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] | 4690 | { |
Trond Myklebust | 911d1aa | 2006-01-03 09:55:16 +0100 | [diff] [blame] | 4691 | uint64_t offset, length, clientid; |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 4692 | __be32 *p; |
Trond Myklebust | 911d1aa | 2006-01-03 09:55:16 +0100 | [diff] [blame] | 4693 | uint32_t namelen, type; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4694 | |
Bryan Schumaker | babddc7 | 2010-10-20 15:44:29 -0400 | [diff] [blame] | 4695 | p = xdr_inline_decode(xdr, 32); /* read 32 bytes */ |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 4696 | if (unlikely(!p)) |
| 4697 | goto out_overflow; |
Bryan Schumaker | babddc7 | 2010-10-20 15:44:29 -0400 | [diff] [blame] | 4698 | p = xdr_decode_hyper(p, &offset); /* read 2 8-byte long words */ |
Benny Halevy | 3ceb4db | 2009-08-14 17:19:41 +0300 | [diff] [blame] | 4699 | p = xdr_decode_hyper(p, &length); |
Bryan Schumaker | babddc7 | 2010-10-20 15:44:29 -0400 | [diff] [blame] | 4700 | type = be32_to_cpup(p++); /* 4 byte read */ |
| 4701 | if (fl != NULL) { /* manipulate file lock */ |
Trond Myklebust | 911d1aa | 2006-01-03 09:55:16 +0100 | [diff] [blame] | 4702 | fl->fl_start = (loff_t)offset; |
| 4703 | fl->fl_end = fl->fl_start + (loff_t)length - 1; |
| 4704 | if (length == ~(uint64_t)0) |
| 4705 | fl->fl_end = OFFSET_MAX; |
| 4706 | fl->fl_type = F_WRLCK; |
| 4707 | if (type & 1) |
| 4708 | fl->fl_type = F_RDLCK; |
| 4709 | fl->fl_pid = 0; |
| 4710 | } |
Bryan Schumaker | babddc7 | 2010-10-20 15:44:29 -0400 | [diff] [blame] | 4711 | p = xdr_decode_hyper(p, &clientid); /* read 8 bytes */ |
| 4712 | namelen = be32_to_cpup(p); /* read 4 bytes */ /* have read all 32 bytes now */ |
| 4713 | p = xdr_inline_decode(xdr, namelen); /* variable size field */ |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 4714 | if (likely(p)) |
| 4715 | return -NFS4ERR_DENIED; |
| 4716 | out_overflow: |
| 4717 | print_overflow_msg(__func__, xdr); |
| 4718 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4719 | } |
| 4720 | |
Trond Myklebust | 911d1aa | 2006-01-03 09:55:16 +0100 | [diff] [blame] | 4721 | 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] | 4722 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4723 | int status; |
| 4724 | |
| 4725 | status = decode_op_hdr(xdr, OP_LOCK); |
Trond Myklebust | c1d5193 | 2008-04-07 13:20:54 -0400 | [diff] [blame] | 4726 | if (status == -EIO) |
| 4727 | goto out; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4728 | if (status == 0) { |
Benny Halevy | 07d3043 | 2009-08-14 17:19:52 +0300 | [diff] [blame] | 4729 | status = decode_stateid(xdr, &res->stateid); |
| 4730 | if (unlikely(status)) |
| 4731 | goto out; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4732 | } else if (status == -NFS4ERR_DENIED) |
Trond Myklebust | c1d5193 | 2008-04-07 13:20:54 -0400 | [diff] [blame] | 4733 | status = decode_lock_denied(xdr, NULL); |
| 4734 | if (res->open_seqid != NULL) |
| 4735 | nfs_increment_open_seqid(status, res->open_seqid); |
| 4736 | nfs_increment_lock_seqid(status, res->lock_seqid); |
| 4737 | out: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4738 | return status; |
| 4739 | } |
| 4740 | |
Trond Myklebust | 911d1aa | 2006-01-03 09:55:16 +0100 | [diff] [blame] | 4741 | 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] | 4742 | { |
| 4743 | int status; |
| 4744 | status = decode_op_hdr(xdr, OP_LOCKT); |
| 4745 | if (status == -NFS4ERR_DENIED) |
Trond Myklebust | 911d1aa | 2006-01-03 09:55:16 +0100 | [diff] [blame] | 4746 | return decode_lock_denied(xdr, res->denied); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4747 | return status; |
| 4748 | } |
| 4749 | |
Trond Myklebust | 911d1aa | 2006-01-03 09:55:16 +0100 | [diff] [blame] | 4750 | 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] | 4751 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4752 | int status; |
| 4753 | |
| 4754 | status = decode_op_hdr(xdr, OP_LOCKU); |
Trond Myklebust | c1d5193 | 2008-04-07 13:20:54 -0400 | [diff] [blame] | 4755 | if (status != -EIO) |
| 4756 | nfs_increment_lock_seqid(status, res->seqid); |
Benny Halevy | 07d3043 | 2009-08-14 17:19:52 +0300 | [diff] [blame] | 4757 | if (status == 0) |
| 4758 | status = decode_stateid(xdr, &res->stateid); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4759 | return status; |
| 4760 | } |
| 4761 | |
Trond Myklebust | d3c7b7c | 2010-07-01 12:49:01 -0400 | [diff] [blame] | 4762 | static int decode_release_lockowner(struct xdr_stream *xdr) |
| 4763 | { |
| 4764 | return decode_op_hdr(xdr, OP_RELEASE_LOCKOWNER); |
| 4765 | } |
| 4766 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4767 | static int decode_lookup(struct xdr_stream *xdr) |
| 4768 | { |
| 4769 | return decode_op_hdr(xdr, OP_LOOKUP); |
| 4770 | } |
| 4771 | |
| 4772 | /* This is too sick! */ |
| 4773 | static int decode_space_limit(struct xdr_stream *xdr, u64 *maxsize) |
| 4774 | { |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 4775 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4776 | uint32_t limit_type, nblocks, blocksize; |
| 4777 | |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 4778 | p = xdr_inline_decode(xdr, 12); |
| 4779 | if (unlikely(!p)) |
| 4780 | goto out_overflow; |
Benny Halevy | 6f723f7 | 2009-08-14 17:19:37 +0300 | [diff] [blame] | 4781 | limit_type = be32_to_cpup(p++); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4782 | switch (limit_type) { |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 4783 | case 1: |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 4784 | xdr_decode_hyper(p, maxsize); |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 4785 | break; |
| 4786 | case 2: |
Benny Halevy | 6f723f7 | 2009-08-14 17:19:37 +0300 | [diff] [blame] | 4787 | nblocks = be32_to_cpup(p++); |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 4788 | blocksize = be32_to_cpup(p); |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 4789 | *maxsize = (uint64_t)nblocks * (uint64_t)blocksize; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4790 | } |
| 4791 | return 0; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 4792 | out_overflow: |
| 4793 | print_overflow_msg(__func__, xdr); |
| 4794 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4795 | } |
| 4796 | |
| 4797 | static int decode_delegation(struct xdr_stream *xdr, struct nfs_openres *res) |
| 4798 | { |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 4799 | __be32 *p; |
| 4800 | uint32_t delegation_type; |
Benny Halevy | 07d3043 | 2009-08-14 17:19:52 +0300 | [diff] [blame] | 4801 | int status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4802 | |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 4803 | p = xdr_inline_decode(xdr, 4); |
| 4804 | if (unlikely(!p)) |
| 4805 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 4806 | delegation_type = be32_to_cpup(p); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4807 | if (delegation_type == NFS4_OPEN_DELEGATE_NONE) { |
| 4808 | res->delegation_type = 0; |
| 4809 | return 0; |
| 4810 | } |
Benny Halevy | 07d3043 | 2009-08-14 17:19:52 +0300 | [diff] [blame] | 4811 | status = decode_stateid(xdr, &res->delegation); |
| 4812 | if (unlikely(status)) |
| 4813 | return status; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 4814 | p = xdr_inline_decode(xdr, 4); |
| 4815 | if (unlikely(!p)) |
| 4816 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 4817 | res->do_recall = be32_to_cpup(p); |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 4818 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4819 | switch (delegation_type) { |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 4820 | case NFS4_OPEN_DELEGATE_READ: |
| 4821 | res->delegation_type = FMODE_READ; |
| 4822 | break; |
| 4823 | case NFS4_OPEN_DELEGATE_WRITE: |
| 4824 | res->delegation_type = FMODE_WRITE|FMODE_READ; |
| 4825 | if (decode_space_limit(xdr, &res->maxsize) < 0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4826 | return -EIO; |
| 4827 | } |
David Howells | 7539bba | 2006-08-22 20:06:09 -0400 | [diff] [blame] | 4828 | return decode_ace(xdr, NULL, res->server->nfs_client); |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 4829 | out_overflow: |
| 4830 | print_overflow_msg(__func__, xdr); |
| 4831 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4832 | } |
| 4833 | |
| 4834 | static int decode_open(struct xdr_stream *xdr, struct nfs_openres *res) |
| 4835 | { |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 4836 | __be32 *p; |
Jeff Layton | aa53ed5 | 2007-06-05 14:49:03 -0400 | [diff] [blame] | 4837 | uint32_t savewords, bmlen, i; |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 4838 | int status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4839 | |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 4840 | status = decode_op_hdr(xdr, OP_OPEN); |
Trond Myklebust | c1d5193 | 2008-04-07 13:20:54 -0400 | [diff] [blame] | 4841 | if (status != -EIO) |
| 4842 | nfs_increment_open_seqid(status, res->seqid); |
Benny Halevy | 07d3043 | 2009-08-14 17:19:52 +0300 | [diff] [blame] | 4843 | if (!status) |
| 4844 | status = decode_stateid(xdr, &res->stateid); |
| 4845 | if (unlikely(status)) |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 4846 | return status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4847 | |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 4848 | decode_change_info(xdr, &res->cinfo); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4849 | |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 4850 | p = xdr_inline_decode(xdr, 8); |
| 4851 | if (unlikely(!p)) |
| 4852 | goto out_overflow; |
Benny Halevy | 6f723f7 | 2009-08-14 17:19:37 +0300 | [diff] [blame] | 4853 | res->rflags = be32_to_cpup(p++); |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 4854 | bmlen = be32_to_cpup(p); |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 4855 | if (bmlen > 10) |
| 4856 | goto xdr_error; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4857 | |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 4858 | p = xdr_inline_decode(xdr, bmlen << 2); |
| 4859 | if (unlikely(!p)) |
| 4860 | goto out_overflow; |
Jeff Layton | aa53ed5 | 2007-06-05 14:49:03 -0400 | [diff] [blame] | 4861 | savewords = min_t(uint32_t, bmlen, NFS4_BITMAP_SIZE); |
| 4862 | for (i = 0; i < savewords; ++i) |
Benny Halevy | 6f723f7 | 2009-08-14 17:19:37 +0300 | [diff] [blame] | 4863 | res->attrset[i] = be32_to_cpup(p++); |
Jeff Layton | aa53ed5 | 2007-06-05 14:49:03 -0400 | [diff] [blame] | 4864 | for (; i < NFS4_BITMAP_SIZE; i++) |
| 4865 | res->attrset[i] = 0; |
| 4866 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4867 | return decode_delegation(xdr, res); |
| 4868 | xdr_error: |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 4869 | dprintk("%s: Bitmap too large! Length = %u\n", __func__, bmlen); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4870 | return -EIO; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 4871 | out_overflow: |
| 4872 | print_overflow_msg(__func__, xdr); |
| 4873 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4874 | } |
| 4875 | |
| 4876 | static int decode_open_confirm(struct xdr_stream *xdr, struct nfs_open_confirmres *res) |
| 4877 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4878 | int status; |
| 4879 | |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 4880 | status = decode_op_hdr(xdr, OP_OPEN_CONFIRM); |
Trond Myklebust | c1d5193 | 2008-04-07 13:20:54 -0400 | [diff] [blame] | 4881 | if (status != -EIO) |
| 4882 | nfs_increment_open_seqid(status, res->seqid); |
Benny Halevy | 07d3043 | 2009-08-14 17:19:52 +0300 | [diff] [blame] | 4883 | if (!status) |
| 4884 | status = decode_stateid(xdr, &res->stateid); |
| 4885 | return status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4886 | } |
| 4887 | |
| 4888 | static int decode_open_downgrade(struct xdr_stream *xdr, struct nfs_closeres *res) |
| 4889 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4890 | int status; |
| 4891 | |
| 4892 | status = decode_op_hdr(xdr, OP_OPEN_DOWNGRADE); |
Trond Myklebust | c1d5193 | 2008-04-07 13:20:54 -0400 | [diff] [blame] | 4893 | if (status != -EIO) |
| 4894 | nfs_increment_open_seqid(status, res->seqid); |
Benny Halevy | 07d3043 | 2009-08-14 17:19:52 +0300 | [diff] [blame] | 4895 | if (!status) |
| 4896 | status = decode_stateid(xdr, &res->stateid); |
| 4897 | return status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4898 | } |
| 4899 | |
| 4900 | static int decode_putfh(struct xdr_stream *xdr) |
| 4901 | { |
| 4902 | return decode_op_hdr(xdr, OP_PUTFH); |
| 4903 | } |
| 4904 | |
| 4905 | static int decode_putrootfh(struct xdr_stream *xdr) |
| 4906 | { |
| 4907 | return decode_op_hdr(xdr, OP_PUTROOTFH); |
| 4908 | } |
| 4909 | |
| 4910 | static int decode_read(struct xdr_stream *xdr, struct rpc_rqst *req, struct nfs_readres *res) |
| 4911 | { |
| 4912 | struct kvec *iov = req->rq_rcv_buf.head; |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 4913 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4914 | uint32_t count, eof, recvd, hdrlen; |
| 4915 | int status; |
| 4916 | |
| 4917 | status = decode_op_hdr(xdr, OP_READ); |
| 4918 | if (status) |
| 4919 | return status; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 4920 | p = xdr_inline_decode(xdr, 8); |
| 4921 | if (unlikely(!p)) |
| 4922 | goto out_overflow; |
Benny Halevy | 6f723f7 | 2009-08-14 17:19:37 +0300 | [diff] [blame] | 4923 | eof = be32_to_cpup(p++); |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 4924 | count = be32_to_cpup(p); |
Chuck Lever | 8111f37 | 2010-12-14 14:58:01 +0000 | [diff] [blame] | 4925 | hdrlen = (u8 *) xdr->p - (u8 *) iov->iov_base; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4926 | recvd = req->rq_rcv_buf.len - hdrlen; |
| 4927 | if (count > recvd) { |
Chuck Lever | fe82a18 | 2007-09-11 18:01:10 -0400 | [diff] [blame] | 4928 | dprintk("NFS: server cheating in read reply: " |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4929 | "count %u > recvd %u\n", count, recvd); |
| 4930 | count = recvd; |
| 4931 | eof = 0; |
| 4932 | } |
| 4933 | xdr_read_pages(xdr, count); |
| 4934 | res->eof = eof; |
| 4935 | res->count = count; |
| 4936 | return 0; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 4937 | out_overflow: |
| 4938 | print_overflow_msg(__func__, xdr); |
| 4939 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4940 | } |
| 4941 | |
| 4942 | static int decode_readdir(struct xdr_stream *xdr, struct rpc_rqst *req, struct nfs4_readdir_res *readdir) |
| 4943 | { |
| 4944 | struct xdr_buf *rcvbuf = &req->rq_rcv_buf; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4945 | struct kvec *iov = rcvbuf->head; |
Chuck Lever | bcecff7 | 2007-10-26 13:32:03 -0400 | [diff] [blame] | 4946 | size_t hdrlen; |
| 4947 | u32 recvd, pglen = rcvbuf->page_len; |
Chuck Lever | bcecff7 | 2007-10-26 13:32:03 -0400 | [diff] [blame] | 4948 | int status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4949 | |
| 4950 | status = decode_op_hdr(xdr, OP_READDIR); |
Benny Halevy | db942bb | 2009-08-14 17:19:56 +0300 | [diff] [blame] | 4951 | if (!status) |
| 4952 | status = decode_verifier(xdr, readdir->verifier.data); |
| 4953 | if (unlikely(status)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4954 | return status; |
Fred Isaman | 4410924 | 2008-04-02 15:21:15 +0300 | [diff] [blame] | 4955 | dprintk("%s: verifier = %08x:%08x\n", |
| 4956 | __func__, |
Trond Myklebust | eadf459 | 2005-06-22 17:16:39 +0000 | [diff] [blame] | 4957 | ((u32 *)readdir->verifier.data)[0], |
| 4958 | ((u32 *)readdir->verifier.data)[1]); |
| 4959 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4960 | |
Benny Halevy | db942bb | 2009-08-14 17:19:56 +0300 | [diff] [blame] | 4961 | hdrlen = (char *) xdr->p - (char *) iov->iov_base; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4962 | recvd = rcvbuf->len - hdrlen; |
| 4963 | if (pglen > recvd) |
| 4964 | pglen = recvd; |
| 4965 | xdr_read_pages(xdr, pglen); |
| 4966 | |
Jeff Layton | 7bda2cd | 2008-02-22 14:50:01 -0500 | [diff] [blame] | 4967 | |
Trond Myklebust | ac39612 | 2010-11-15 20:26:22 -0500 | [diff] [blame] | 4968 | return pglen; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4969 | } |
| 4970 | |
| 4971 | static int decode_readlink(struct xdr_stream *xdr, struct rpc_rqst *req) |
| 4972 | { |
| 4973 | struct xdr_buf *rcvbuf = &req->rq_rcv_buf; |
| 4974 | struct kvec *iov = rcvbuf->head; |
Chuck Lever | bcecff7 | 2007-10-26 13:32:03 -0400 | [diff] [blame] | 4975 | size_t hdrlen; |
| 4976 | u32 len, recvd; |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 4977 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4978 | int status; |
| 4979 | |
| 4980 | status = decode_op_hdr(xdr, OP_READLINK); |
| 4981 | if (status) |
| 4982 | return status; |
| 4983 | |
| 4984 | /* Convert length of symlink */ |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 4985 | p = xdr_inline_decode(xdr, 4); |
| 4986 | if (unlikely(!p)) |
| 4987 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 4988 | len = be32_to_cpup(p); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4989 | if (len >= rcvbuf->page_len || len <= 0) { |
Chuck Lever | fe82a18 | 2007-09-11 18:01:10 -0400 | [diff] [blame] | 4990 | dprintk("nfs: server returned giant symlink!\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4991 | return -ENAMETOOLONG; |
| 4992 | } |
| 4993 | hdrlen = (char *) xdr->p - (char *) iov->iov_base; |
| 4994 | recvd = req->rq_rcv_buf.len - hdrlen; |
| 4995 | if (recvd < len) { |
Chuck Lever | fe82a18 | 2007-09-11 18:01:10 -0400 | [diff] [blame] | 4996 | dprintk("NFS: server cheating in readlink reply: " |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4997 | "count %u > recvd %u\n", len, recvd); |
| 4998 | return -EIO; |
| 4999 | } |
| 5000 | xdr_read_pages(xdr, len); |
| 5001 | /* |
| 5002 | * The XDR encode routine has set things up so that |
| 5003 | * the link text will be copied directly into the |
| 5004 | * buffer. We just have to do overflow-checking, |
| 5005 | * and and null-terminate the text (the VFS expects |
| 5006 | * null-termination). |
| 5007 | */ |
Chuck Lever | b4687da | 2010-09-21 16:55:48 -0400 | [diff] [blame] | 5008 | xdr_terminate_string(rcvbuf, len); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5009 | return 0; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 5010 | out_overflow: |
| 5011 | print_overflow_msg(__func__, xdr); |
| 5012 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5013 | } |
| 5014 | |
| 5015 | static int decode_remove(struct xdr_stream *xdr, struct nfs4_change_info *cinfo) |
| 5016 | { |
| 5017 | int status; |
| 5018 | |
| 5019 | status = decode_op_hdr(xdr, OP_REMOVE); |
| 5020 | if (status) |
| 5021 | goto out; |
| 5022 | status = decode_change_info(xdr, cinfo); |
| 5023 | out: |
| 5024 | return status; |
| 5025 | } |
| 5026 | |
| 5027 | static int decode_rename(struct xdr_stream *xdr, struct nfs4_change_info *old_cinfo, |
| 5028 | struct nfs4_change_info *new_cinfo) |
| 5029 | { |
| 5030 | int status; |
| 5031 | |
| 5032 | status = decode_op_hdr(xdr, OP_RENAME); |
| 5033 | if (status) |
| 5034 | goto out; |
| 5035 | if ((status = decode_change_info(xdr, old_cinfo))) |
| 5036 | goto out; |
| 5037 | status = decode_change_info(xdr, new_cinfo); |
| 5038 | out: |
| 5039 | return status; |
| 5040 | } |
| 5041 | |
| 5042 | static int decode_renew(struct xdr_stream *xdr) |
| 5043 | { |
| 5044 | return decode_op_hdr(xdr, OP_RENEW); |
| 5045 | } |
| 5046 | |
Trond Myklebust | 56ae19f | 2005-10-27 22:12:40 -0400 | [diff] [blame] | 5047 | static int |
| 5048 | decode_restorefh(struct xdr_stream *xdr) |
| 5049 | { |
| 5050 | return decode_op_hdr(xdr, OP_RESTOREFH); |
| 5051 | } |
| 5052 | |
J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 5053 | static int decode_getacl(struct xdr_stream *xdr, struct rpc_rqst *req, |
Andy Adamson | bf118a3 | 2011-12-07 11:55:27 -0500 | [diff] [blame] | 5054 | struct nfs_getaclres *res) |
J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 5055 | { |
Andy Adamson | bf118a3 | 2011-12-07 11:55:27 -0500 | [diff] [blame] | 5056 | __be32 *savep, *bm_p; |
J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 5057 | uint32_t attrlen, |
Fred Isaman | dae100c | 2011-07-30 20:52:37 -0400 | [diff] [blame] | 5058 | bitmap[3] = {0}; |
J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 5059 | struct kvec *iov = req->rq_rcv_buf.head; |
| 5060 | int status; |
| 5061 | |
Andy Adamson | bf118a3 | 2011-12-07 11:55:27 -0500 | [diff] [blame] | 5062 | res->acl_len = 0; |
J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 5063 | if ((status = decode_op_hdr(xdr, OP_GETATTR)) != 0) |
| 5064 | goto out; |
Andy Adamson | bf118a3 | 2011-12-07 11:55:27 -0500 | [diff] [blame] | 5065 | bm_p = xdr->p; |
J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 5066 | if ((status = decode_attr_bitmap(xdr, bitmap)) != 0) |
| 5067 | goto out; |
| 5068 | if ((status = decode_attr_length(xdr, &attrlen, &savep)) != 0) |
| 5069 | goto out; |
| 5070 | |
| 5071 | if (unlikely(bitmap[0] & (FATTR4_WORD0_ACL - 1U))) |
| 5072 | return -EIO; |
| 5073 | if (likely(bitmap[0] & FATTR4_WORD0_ACL)) { |
Chuck Lever | bcecff7 | 2007-10-26 13:32:03 -0400 | [diff] [blame] | 5074 | size_t hdrlen; |
| 5075 | u32 recvd; |
J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 5076 | |
Andy Adamson | bf118a3 | 2011-12-07 11:55:27 -0500 | [diff] [blame] | 5077 | /* The bitmap (xdr len + bitmaps) and the attr xdr len words |
| 5078 | * are stored with the acl data to handle the problem of |
| 5079 | * variable length bitmaps.*/ |
| 5080 | xdr->p = bm_p; |
| 5081 | res->acl_data_offset = be32_to_cpup(bm_p) + 2; |
| 5082 | res->acl_data_offset <<= 2; |
| 5083 | |
J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 5084 | /* We ignore &savep and don't do consistency checks on |
| 5085 | * the attr length. Let userspace figure it out.... */ |
| 5086 | hdrlen = (u8 *)xdr->p - (u8 *)iov->iov_base; |
Andy Adamson | bf118a3 | 2011-12-07 11:55:27 -0500 | [diff] [blame] | 5087 | attrlen += res->acl_data_offset; |
J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 5088 | recvd = req->rq_rcv_buf.len - hdrlen; |
| 5089 | if (attrlen > recvd) { |
Andy Adamson | bf118a3 | 2011-12-07 11:55:27 -0500 | [diff] [blame] | 5090 | if (res->acl_flags & NFS4_ACL_LEN_REQUEST) { |
| 5091 | /* getxattr interface called with a NULL buf */ |
| 5092 | res->acl_len = attrlen; |
| 5093 | goto out; |
| 5094 | } |
| 5095 | dprintk("NFS: acl reply: attrlen %u > recvd %u\n", |
J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 5096 | attrlen, recvd); |
| 5097 | return -EINVAL; |
| 5098 | } |
J. Bruce Fields | c04871e | 2006-05-30 16:28:58 -0400 | [diff] [blame] | 5099 | xdr_read_pages(xdr, attrlen); |
Andy Adamson | bf118a3 | 2011-12-07 11:55:27 -0500 | [diff] [blame] | 5100 | res->acl_len = attrlen; |
J. Bruce Fields | 8c233cf | 2005-10-13 16:54:27 -0400 | [diff] [blame] | 5101 | } else |
| 5102 | status = -EOPNOTSUPP; |
J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 5103 | |
| 5104 | out: |
| 5105 | return status; |
| 5106 | } |
| 5107 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5108 | static int |
| 5109 | decode_savefh(struct xdr_stream *xdr) |
| 5110 | { |
| 5111 | return decode_op_hdr(xdr, OP_SAVEFH); |
| 5112 | } |
| 5113 | |
Benny Halevy | 9e9ecc0 | 2009-04-01 09:22:00 -0400 | [diff] [blame] | 5114 | static int decode_setattr(struct xdr_stream *xdr) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5115 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 5116 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5117 | uint32_t bmlen; |
| 5118 | int status; |
| 5119 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5120 | status = decode_op_hdr(xdr, OP_SETATTR); |
| 5121 | if (status) |
| 5122 | return status; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 5123 | p = xdr_inline_decode(xdr, 4); |
| 5124 | if (unlikely(!p)) |
| 5125 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 5126 | bmlen = be32_to_cpup(p); |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 5127 | p = xdr_inline_decode(xdr, bmlen << 2); |
| 5128 | if (likely(p)) |
| 5129 | return 0; |
| 5130 | out_overflow: |
| 5131 | print_overflow_msg(__func__, xdr); |
| 5132 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5133 | } |
| 5134 | |
Trond Myklebust | bb8b27e | 2010-04-16 16:43:06 -0400 | [diff] [blame] | 5135 | 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] | 5136 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 5137 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5138 | uint32_t opnum; |
| 5139 | int32_t nfserr; |
| 5140 | |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 5141 | p = xdr_inline_decode(xdr, 8); |
| 5142 | if (unlikely(!p)) |
| 5143 | goto out_overflow; |
Benny Halevy | 6f723f7 | 2009-08-14 17:19:37 +0300 | [diff] [blame] | 5144 | opnum = be32_to_cpup(p++); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5145 | if (opnum != OP_SETCLIENTID) { |
Chuck Lever | fe82a18 | 2007-09-11 18:01:10 -0400 | [diff] [blame] | 5146 | dprintk("nfs: decode_setclientid: Server returned operation" |
Andy Adamson | 6c0195a | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 5147 | " %d\n", opnum); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5148 | return -EIO; |
| 5149 | } |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 5150 | nfserr = be32_to_cpup(p); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5151 | if (nfserr == NFS_OK) { |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 5152 | p = xdr_inline_decode(xdr, 8 + NFS4_VERIFIER_SIZE); |
| 5153 | if (unlikely(!p)) |
| 5154 | goto out_overflow; |
Trond Myklebust | bb8b27e | 2010-04-16 16:43:06 -0400 | [diff] [blame] | 5155 | p = xdr_decode_hyper(p, &res->clientid); |
| 5156 | memcpy(res->confirm.data, p, NFS4_VERIFIER_SIZE); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5157 | } else if (nfserr == NFSERR_CLID_INUSE) { |
| 5158 | uint32_t len; |
| 5159 | |
| 5160 | /* skip netid string */ |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 5161 | p = xdr_inline_decode(xdr, 4); |
| 5162 | if (unlikely(!p)) |
| 5163 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 5164 | len = be32_to_cpup(p); |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 5165 | p = xdr_inline_decode(xdr, len); |
| 5166 | if (unlikely(!p)) |
| 5167 | goto out_overflow; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5168 | |
| 5169 | /* skip uaddr string */ |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 5170 | p = xdr_inline_decode(xdr, 4); |
| 5171 | if (unlikely(!p)) |
| 5172 | goto out_overflow; |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 5173 | len = be32_to_cpup(p); |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 5174 | p = xdr_inline_decode(xdr, len); |
| 5175 | if (unlikely(!p)) |
| 5176 | goto out_overflow; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5177 | return -NFSERR_CLID_INUSE; |
| 5178 | } else |
Benny Halevy | 856dff3 | 2008-03-31 17:39:06 +0300 | [diff] [blame] | 5179 | return nfs4_stat_to_errno(nfserr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5180 | |
| 5181 | return 0; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 5182 | out_overflow: |
| 5183 | print_overflow_msg(__func__, xdr); |
| 5184 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5185 | } |
| 5186 | |
| 5187 | static int decode_setclientid_confirm(struct xdr_stream *xdr) |
| 5188 | { |
| 5189 | return decode_op_hdr(xdr, OP_SETCLIENTID_CONFIRM); |
| 5190 | } |
| 5191 | |
| 5192 | static int decode_write(struct xdr_stream *xdr, struct nfs_writeres *res) |
| 5193 | { |
Al Viro | 8687b63 | 2006-10-19 23:28:48 -0700 | [diff] [blame] | 5194 | __be32 *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5195 | int status; |
| 5196 | |
| 5197 | status = decode_op_hdr(xdr, OP_WRITE); |
| 5198 | if (status) |
| 5199 | return status; |
| 5200 | |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 5201 | p = xdr_inline_decode(xdr, 16); |
| 5202 | if (unlikely(!p)) |
| 5203 | goto out_overflow; |
Benny Halevy | 6f723f7 | 2009-08-14 17:19:37 +0300 | [diff] [blame] | 5204 | res->count = be32_to_cpup(p++); |
| 5205 | res->verf->committed = be32_to_cpup(p++); |
Benny Halevy | 99398d0 | 2009-08-14 17:20:05 +0300 | [diff] [blame] | 5206 | memcpy(res->verf->verifier, p, 8); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5207 | return 0; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 5208 | out_overflow: |
| 5209 | print_overflow_msg(__func__, xdr); |
| 5210 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5211 | } |
| 5212 | |
| 5213 | static int decode_delegreturn(struct xdr_stream *xdr) |
| 5214 | { |
| 5215 | return decode_op_hdr(xdr, OP_DELEGRETURN); |
| 5216 | } |
| 5217 | |
Bryan Schumaker | 5a5ea0d | 2011-03-24 17:12:29 +0000 | [diff] [blame] | 5218 | static int decode_secinfo_gss(struct xdr_stream *xdr, struct nfs4_secinfo_flavor *flavor) |
| 5219 | { |
| 5220 | __be32 *p; |
| 5221 | |
| 5222 | p = xdr_inline_decode(xdr, 4); |
| 5223 | if (unlikely(!p)) |
| 5224 | goto out_overflow; |
| 5225 | flavor->gss.sec_oid4.len = be32_to_cpup(p); |
| 5226 | if (flavor->gss.sec_oid4.len > GSS_OID_MAX_LEN) |
| 5227 | goto out_err; |
| 5228 | |
| 5229 | p = xdr_inline_decode(xdr, flavor->gss.sec_oid4.len); |
| 5230 | if (unlikely(!p)) |
| 5231 | goto out_overflow; |
| 5232 | memcpy(flavor->gss.sec_oid4.data, p, flavor->gss.sec_oid4.len); |
| 5233 | |
| 5234 | p = xdr_inline_decode(xdr, 8); |
| 5235 | if (unlikely(!p)) |
| 5236 | goto out_overflow; |
| 5237 | flavor->gss.qop4 = be32_to_cpup(p++); |
| 5238 | flavor->gss.service = be32_to_cpup(p); |
| 5239 | |
| 5240 | return 0; |
| 5241 | |
| 5242 | out_overflow: |
| 5243 | print_overflow_msg(__func__, xdr); |
| 5244 | return -EIO; |
| 5245 | out_err: |
| 5246 | return -EINVAL; |
| 5247 | } |
| 5248 | |
| 5249 | static int decode_secinfo(struct xdr_stream *xdr, struct nfs4_secinfo_res *res) |
| 5250 | { |
| 5251 | struct nfs4_secinfo_flavor *sec_flavor; |
| 5252 | int status; |
| 5253 | __be32 *p; |
Bryan Schumaker | c3dfc28 | 2011-04-13 14:31:31 -0400 | [diff] [blame] | 5254 | int i, num_flavors; |
Bryan Schumaker | 5a5ea0d | 2011-03-24 17:12:29 +0000 | [diff] [blame] | 5255 | |
| 5256 | status = decode_op_hdr(xdr, OP_SECINFO); |
Bryan Schumaker | 613e901 | 2011-04-27 15:28:44 -0400 | [diff] [blame] | 5257 | if (status) |
| 5258 | goto out; |
Bryan Schumaker | 5a5ea0d | 2011-03-24 17:12:29 +0000 | [diff] [blame] | 5259 | p = xdr_inline_decode(xdr, 4); |
| 5260 | if (unlikely(!p)) |
| 5261 | goto out_overflow; |
Bryan Schumaker | 5a5ea0d | 2011-03-24 17:12:29 +0000 | [diff] [blame] | 5262 | |
Bryan Schumaker | c3dfc28 | 2011-04-13 14:31:31 -0400 | [diff] [blame] | 5263 | res->flavors->num_flavors = 0; |
| 5264 | num_flavors = be32_to_cpup(p); |
| 5265 | |
| 5266 | for (i = 0; i < num_flavors; i++) { |
Bryan Schumaker | 5a5ea0d | 2011-03-24 17:12:29 +0000 | [diff] [blame] | 5267 | sec_flavor = &res->flavors->flavors[i]; |
Bryan Schumaker | c3dfc28 | 2011-04-13 14:31:31 -0400 | [diff] [blame] | 5268 | if ((char *)&sec_flavor[1] - (char *)res->flavors > PAGE_SIZE) |
Bryan Schumaker | 5a5ea0d | 2011-03-24 17:12:29 +0000 | [diff] [blame] | 5269 | break; |
| 5270 | |
| 5271 | p = xdr_inline_decode(xdr, 4); |
| 5272 | if (unlikely(!p)) |
| 5273 | goto out_overflow; |
| 5274 | sec_flavor->flavor = be32_to_cpup(p); |
| 5275 | |
| 5276 | if (sec_flavor->flavor == RPC_AUTH_GSS) { |
Bryan Schumaker | 613e901 | 2011-04-27 15:28:44 -0400 | [diff] [blame] | 5277 | status = decode_secinfo_gss(xdr, sec_flavor); |
| 5278 | if (status) |
| 5279 | goto out; |
Bryan Schumaker | 5a5ea0d | 2011-03-24 17:12:29 +0000 | [diff] [blame] | 5280 | } |
Bryan Schumaker | c3dfc28 | 2011-04-13 14:31:31 -0400 | [diff] [blame] | 5281 | res->flavors->num_flavors++; |
Bryan Schumaker | 5a5ea0d | 2011-03-24 17:12:29 +0000 | [diff] [blame] | 5282 | } |
| 5283 | |
Bryan Schumaker | 613e901 | 2011-04-27 15:28:44 -0400 | [diff] [blame] | 5284 | out: |
| 5285 | return status; |
Bryan Schumaker | 5a5ea0d | 2011-03-24 17:12:29 +0000 | [diff] [blame] | 5286 | out_overflow: |
| 5287 | print_overflow_msg(__func__, xdr); |
| 5288 | return -EIO; |
| 5289 | } |
| 5290 | |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 5291 | #if defined(CONFIG_NFS_V4_1) |
| 5292 | static int decode_exchange_id(struct xdr_stream *xdr, |
| 5293 | struct nfs41_exchange_id_res *res) |
| 5294 | { |
| 5295 | __be32 *p; |
| 5296 | uint32_t dummy; |
Benny Halevy | 2460ba5 | 2009-08-14 17:20:10 +0300 | [diff] [blame] | 5297 | char *dummy_str; |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 5298 | int status; |
| 5299 | struct nfs_client *clp = res->client; |
Weston Andros Adamson | 7d2ed9a | 2012-02-17 15:20:26 -0500 | [diff] [blame] | 5300 | uint32_t impl_id_count; |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 5301 | |
| 5302 | status = decode_op_hdr(xdr, OP_EXCHANGE_ID); |
| 5303 | if (status) |
| 5304 | return status; |
| 5305 | |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 5306 | p = xdr_inline_decode(xdr, 8); |
| 5307 | if (unlikely(!p)) |
| 5308 | goto out_overflow; |
Andy Adamson | 114f64b | 2011-03-09 13:13:45 -0500 | [diff] [blame] | 5309 | xdr_decode_hyper(p, &clp->cl_clientid); |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 5310 | p = xdr_inline_decode(xdr, 12); |
| 5311 | if (unlikely(!p)) |
| 5312 | goto out_overflow; |
Benny Halevy | 6f723f7 | 2009-08-14 17:19:37 +0300 | [diff] [blame] | 5313 | clp->cl_seqid = be32_to_cpup(p++); |
| 5314 | clp->cl_exchange_flags = be32_to_cpup(p++); |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 5315 | |
| 5316 | /* We ask for SP4_NONE */ |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 5317 | dummy = be32_to_cpup(p); |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 5318 | if (dummy != SP4_NONE) |
| 5319 | return -EIO; |
| 5320 | |
| 5321 | /* Throw away minor_id */ |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 5322 | p = xdr_inline_decode(xdr, 8); |
| 5323 | if (unlikely(!p)) |
| 5324 | goto out_overflow; |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 5325 | |
| 5326 | /* Throw away Major id */ |
Benny Halevy | 2460ba5 | 2009-08-14 17:20:10 +0300 | [diff] [blame] | 5327 | status = decode_opaque_inline(xdr, &dummy, &dummy_str); |
| 5328 | if (unlikely(status)) |
| 5329 | return status; |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 5330 | |
Weston Andros Adamson | 78fe0f4 | 2011-05-31 19:05:47 -0400 | [diff] [blame] | 5331 | /* Save server_scope */ |
Benny Halevy | 2460ba5 | 2009-08-14 17:20:10 +0300 | [diff] [blame] | 5332 | status = decode_opaque_inline(xdr, &dummy, &dummy_str); |
| 5333 | if (unlikely(status)) |
| 5334 | return status; |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 5335 | |
Weston Andros Adamson | 78fe0f4 | 2011-05-31 19:05:47 -0400 | [diff] [blame] | 5336 | if (unlikely(dummy > NFS4_OPAQUE_LIMIT)) |
| 5337 | return -EIO; |
| 5338 | |
| 5339 | memcpy(res->server_scope->server_scope, dummy_str, dummy); |
| 5340 | res->server_scope->server_scope_sz = dummy; |
| 5341 | |
Weston Andros Adamson | 7d2ed9a | 2012-02-17 15:20:26 -0500 | [diff] [blame] | 5342 | /* Implementation Id */ |
| 5343 | p = xdr_inline_decode(xdr, 4); |
| 5344 | if (unlikely(!p)) |
| 5345 | goto out_overflow; |
| 5346 | impl_id_count = be32_to_cpup(p++); |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 5347 | |
Weston Andros Adamson | 7d2ed9a | 2012-02-17 15:20:26 -0500 | [diff] [blame] | 5348 | if (impl_id_count) { |
| 5349 | /* nii_domain */ |
| 5350 | status = decode_opaque_inline(xdr, &dummy, &dummy_str); |
| 5351 | if (unlikely(status)) |
| 5352 | return status; |
| 5353 | if (unlikely(dummy > NFS4_OPAQUE_LIMIT)) |
| 5354 | return -EIO; |
| 5355 | memcpy(res->impl_id->domain, dummy_str, dummy); |
| 5356 | |
| 5357 | /* nii_name */ |
| 5358 | status = decode_opaque_inline(xdr, &dummy, &dummy_str); |
| 5359 | if (unlikely(status)) |
| 5360 | return status; |
| 5361 | if (unlikely(dummy > NFS4_OPAQUE_LIMIT)) |
| 5362 | return -EIO; |
| 5363 | memcpy(res->impl_id->name, dummy_str, dummy); |
| 5364 | |
| 5365 | /* nii_date */ |
| 5366 | p = xdr_inline_decode(xdr, 12); |
| 5367 | if (unlikely(!p)) |
| 5368 | goto out_overflow; |
| 5369 | p = xdr_decode_hyper(p, &res->impl_id->date.seconds); |
| 5370 | res->impl_id->date.nseconds = be32_to_cpup(p); |
| 5371 | |
| 5372 | /* if there's more than one entry, ignore the rest */ |
| 5373 | } |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 5374 | return 0; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 5375 | out_overflow: |
| 5376 | print_overflow_msg(__func__, xdr); |
| 5377 | return -EIO; |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 5378 | } |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 5379 | |
| 5380 | static int decode_chan_attrs(struct xdr_stream *xdr, |
| 5381 | struct nfs4_channel_attrs *attrs) |
| 5382 | { |
| 5383 | __be32 *p; |
Benny Halevy | c9c30dd | 2011-06-11 17:08:39 -0400 | [diff] [blame] | 5384 | u32 nr_attrs, val; |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 5385 | |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 5386 | p = xdr_inline_decode(xdr, 28); |
| 5387 | if (unlikely(!p)) |
| 5388 | goto out_overflow; |
Benny Halevy | c9c30dd | 2011-06-11 17:08:39 -0400 | [diff] [blame] | 5389 | val = be32_to_cpup(p++); /* headerpadsz */ |
| 5390 | if (val) |
| 5391 | return -EINVAL; /* no support for header padding yet */ |
Benny Halevy | 6f723f7 | 2009-08-14 17:19:37 +0300 | [diff] [blame] | 5392 | attrs->max_rqst_sz = be32_to_cpup(p++); |
| 5393 | attrs->max_resp_sz = be32_to_cpup(p++); |
| 5394 | attrs->max_resp_sz_cached = be32_to_cpup(p++); |
| 5395 | attrs->max_ops = be32_to_cpup(p++); |
| 5396 | attrs->max_reqs = be32_to_cpup(p++); |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 5397 | nr_attrs = be32_to_cpup(p); |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 5398 | if (unlikely(nr_attrs > 1)) { |
Weston Andros Adamson | a030889 | 2012-01-26 13:32:23 -0500 | [diff] [blame] | 5399 | printk(KERN_WARNING "NFS: %s: Invalid rdma channel attrs " |
| 5400 | "count %u\n", __func__, nr_attrs); |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 5401 | return -EINVAL; |
| 5402 | } |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 5403 | if (nr_attrs == 1) { |
| 5404 | p = xdr_inline_decode(xdr, 4); /* skip rdma_attrs */ |
| 5405 | if (unlikely(!p)) |
| 5406 | goto out_overflow; |
| 5407 | } |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 5408 | return 0; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 5409 | out_overflow: |
| 5410 | print_overflow_msg(__func__, xdr); |
| 5411 | return -EIO; |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 5412 | } |
| 5413 | |
Benny Halevy | e78291e | 2009-08-14 17:20:00 +0300 | [diff] [blame] | 5414 | static int decode_sessionid(struct xdr_stream *xdr, struct nfs4_sessionid *sid) |
| 5415 | { |
| 5416 | return decode_opaque_fixed(xdr, sid->data, NFS4_MAX_SESSIONID_LEN); |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 5417 | } |
| 5418 | |
| 5419 | static int decode_create_session(struct xdr_stream *xdr, |
| 5420 | struct nfs41_create_session_res *res) |
| 5421 | { |
| 5422 | __be32 *p; |
| 5423 | int status; |
| 5424 | struct nfs_client *clp = res->client; |
| 5425 | struct nfs4_session *session = clp->cl_session; |
| 5426 | |
| 5427 | status = decode_op_hdr(xdr, OP_CREATE_SESSION); |
Benny Halevy | e78291e | 2009-08-14 17:20:00 +0300 | [diff] [blame] | 5428 | if (!status) |
| 5429 | status = decode_sessionid(xdr, &session->sess_id); |
| 5430 | if (unlikely(status)) |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 5431 | return status; |
| 5432 | |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 5433 | /* seqid, flags */ |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 5434 | p = xdr_inline_decode(xdr, 8); |
| 5435 | if (unlikely(!p)) |
| 5436 | goto out_overflow; |
Benny Halevy | 6f723f7 | 2009-08-14 17:19:37 +0300 | [diff] [blame] | 5437 | clp->cl_seqid = be32_to_cpup(p++); |
Benny Halevy | cccddf4 | 2009-08-14 17:20:19 +0300 | [diff] [blame] | 5438 | session->flags = be32_to_cpup(p); |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 5439 | |
| 5440 | /* Channel attributes */ |
| 5441 | status = decode_chan_attrs(xdr, &session->fc_attrs); |
| 5442 | if (!status) |
| 5443 | status = decode_chan_attrs(xdr, &session->bc_attrs); |
| 5444 | return status; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 5445 | out_overflow: |
| 5446 | print_overflow_msg(__func__, xdr); |
| 5447 | return -EIO; |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 5448 | } |
Andy Adamson | 0f3e66c | 2009-04-01 09:22:34 -0400 | [diff] [blame] | 5449 | |
| 5450 | static int decode_destroy_session(struct xdr_stream *xdr, void *dummy) |
| 5451 | { |
| 5452 | return decode_op_hdr(xdr, OP_DESTROY_SESSION); |
| 5453 | } |
Ricardo Labiaga | 18019753 | 2009-12-05 16:08:40 -0500 | [diff] [blame] | 5454 | |
| 5455 | static int decode_reclaim_complete(struct xdr_stream *xdr, void *dummy) |
| 5456 | { |
| 5457 | return decode_op_hdr(xdr, OP_RECLAIM_COMPLETE); |
| 5458 | } |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 5459 | #endif /* CONFIG_NFS_V4_1 */ |
| 5460 | |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 5461 | static int decode_sequence(struct xdr_stream *xdr, |
| 5462 | struct nfs4_sequence_res *res, |
| 5463 | struct rpc_rqst *rqstp) |
| 5464 | { |
| 5465 | #if defined(CONFIG_NFS_V4_1) |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 5466 | struct nfs4_sessionid id; |
| 5467 | u32 dummy; |
| 5468 | int status; |
| 5469 | __be32 *p; |
| 5470 | |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 5471 | if (!res->sr_session) |
| 5472 | return 0; |
| 5473 | |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 5474 | status = decode_op_hdr(xdr, OP_SEQUENCE); |
Benny Halevy | e78291e | 2009-08-14 17:20:00 +0300 | [diff] [blame] | 5475 | if (!status) |
| 5476 | status = decode_sessionid(xdr, &id); |
| 5477 | if (unlikely(status)) |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 5478 | goto out_err; |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 5479 | |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 5480 | /* |
| 5481 | * If the server returns different values for sessionID, slotID or |
| 5482 | * sequence number, the server is looney tunes. |
| 5483 | */ |
Trond Myklebust | fdcb457 | 2010-02-08 09:32:40 -0500 | [diff] [blame] | 5484 | status = -EREMOTEIO; |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 5485 | |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 5486 | if (memcmp(id.data, res->sr_session->sess_id.data, |
| 5487 | NFS4_MAX_SESSIONID_LEN)) { |
| 5488 | dprintk("%s Invalid session id\n", __func__); |
| 5489 | goto out_err; |
| 5490 | } |
Benny Halevy | e78291e | 2009-08-14 17:20:00 +0300 | [diff] [blame] | 5491 | |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 5492 | p = xdr_inline_decode(xdr, 20); |
| 5493 | if (unlikely(!p)) |
| 5494 | goto out_overflow; |
Benny Halevy | e78291e | 2009-08-14 17:20:00 +0300 | [diff] [blame] | 5495 | |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 5496 | /* seqid */ |
Benny Halevy | 6f723f7 | 2009-08-14 17:19:37 +0300 | [diff] [blame] | 5497 | dummy = be32_to_cpup(p++); |
Benny Halevy | dfb4f309 | 2010-09-24 09:17:01 -0400 | [diff] [blame] | 5498 | if (dummy != res->sr_slot->seq_nr) { |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 5499 | dprintk("%s Invalid sequence number\n", __func__); |
| 5500 | goto out_err; |
| 5501 | } |
| 5502 | /* slot id */ |
Benny Halevy | 6f723f7 | 2009-08-14 17:19:37 +0300 | [diff] [blame] | 5503 | dummy = be32_to_cpup(p++); |
Benny Halevy | dfb4f309 | 2010-09-24 09:17:01 -0400 | [diff] [blame] | 5504 | if (dummy != res->sr_slot - res->sr_session->fc_slot_table.slots) { |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 5505 | dprintk("%s Invalid slot id\n", __func__); |
| 5506 | goto out_err; |
| 5507 | } |
| 5508 | /* highest slot id - currently not processed */ |
Benny Halevy | 6f723f7 | 2009-08-14 17:19:37 +0300 | [diff] [blame] | 5509 | dummy = be32_to_cpup(p++); |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 5510 | /* target highest slot id - currently not processed */ |
Benny Halevy | 6f723f7 | 2009-08-14 17:19:37 +0300 | [diff] [blame] | 5511 | dummy = be32_to_cpup(p++); |
Alexandros Batsakis | 0629e37 | 2009-12-05 13:46:14 -0500 | [diff] [blame] | 5512 | /* result flags */ |
| 5513 | res->sr_status_flags = be32_to_cpup(p); |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 5514 | status = 0; |
| 5515 | out_err: |
| 5516 | res->sr_status = status; |
| 5517 | return status; |
Benny Halevy | c0eae66 | 2009-08-14 17:20:14 +0300 | [diff] [blame] | 5518 | out_overflow: |
| 5519 | print_overflow_msg(__func__, xdr); |
| 5520 | status = -EIO; |
| 5521 | goto out_err; |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 5522 | #else /* CONFIG_NFS_V4_1 */ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 5523 | return 0; |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 5524 | #endif /* CONFIG_NFS_V4_1 */ |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 5525 | } |
| 5526 | |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 5527 | #if defined(CONFIG_NFS_V4_1) |
Andy Adamson | 7f11d8d | 2011-07-30 20:52:35 -0400 | [diff] [blame] | 5528 | /* |
| 5529 | * TODO: Need to handle case when EOF != true; |
| 5530 | */ |
| 5531 | static int decode_getdevicelist(struct xdr_stream *xdr, |
| 5532 | struct pnfs_devicelist *res) |
| 5533 | { |
| 5534 | __be32 *p; |
| 5535 | int status, i; |
| 5536 | struct nfs_writeverf verftemp; |
| 5537 | |
| 5538 | status = decode_op_hdr(xdr, OP_GETDEVICELIST); |
| 5539 | if (status) |
| 5540 | return status; |
| 5541 | |
| 5542 | p = xdr_inline_decode(xdr, 8 + 8 + 4); |
| 5543 | if (unlikely(!p)) |
| 5544 | goto out_overflow; |
| 5545 | |
| 5546 | /* TODO: Skip cookie for now */ |
| 5547 | p += 2; |
| 5548 | |
| 5549 | /* Read verifier */ |
| 5550 | p = xdr_decode_opaque_fixed(p, verftemp.verifier, 8); |
| 5551 | |
| 5552 | res->num_devs = be32_to_cpup(p); |
| 5553 | |
| 5554 | dprintk("%s: num_dev %d\n", __func__, res->num_devs); |
| 5555 | |
| 5556 | if (res->num_devs > NFS4_PNFS_GETDEVLIST_MAXNUM) { |
Weston Andros Adamson | a030889 | 2012-01-26 13:32:23 -0500 | [diff] [blame] | 5557 | printk(KERN_ERR "NFS: %s too many result dev_num %u\n", |
Andy Adamson | 7f11d8d | 2011-07-30 20:52:35 -0400 | [diff] [blame] | 5558 | __func__, res->num_devs); |
| 5559 | return -EIO; |
| 5560 | } |
| 5561 | |
| 5562 | p = xdr_inline_decode(xdr, |
| 5563 | res->num_devs * NFS4_DEVICEID4_SIZE + 4); |
| 5564 | if (unlikely(!p)) |
| 5565 | goto out_overflow; |
| 5566 | for (i = 0; i < res->num_devs; i++) |
| 5567 | p = xdr_decode_opaque_fixed(p, res->dev_id[i].data, |
| 5568 | NFS4_DEVICEID4_SIZE); |
| 5569 | res->eof = be32_to_cpup(p); |
| 5570 | return 0; |
| 5571 | out_overflow: |
| 5572 | print_overflow_msg(__func__, xdr); |
| 5573 | return -EIO; |
| 5574 | } |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 5575 | |
| 5576 | static int decode_getdeviceinfo(struct xdr_stream *xdr, |
| 5577 | struct pnfs_device *pdev) |
| 5578 | { |
| 5579 | __be32 *p; |
| 5580 | uint32_t len, type; |
| 5581 | int status; |
| 5582 | |
| 5583 | status = decode_op_hdr(xdr, OP_GETDEVICEINFO); |
| 5584 | if (status) { |
| 5585 | if (status == -ETOOSMALL) { |
| 5586 | p = xdr_inline_decode(xdr, 4); |
| 5587 | if (unlikely(!p)) |
| 5588 | goto out_overflow; |
| 5589 | pdev->mincount = be32_to_cpup(p); |
| 5590 | dprintk("%s: Min count too small. mincnt = %u\n", |
| 5591 | __func__, pdev->mincount); |
| 5592 | } |
| 5593 | return status; |
| 5594 | } |
| 5595 | |
| 5596 | p = xdr_inline_decode(xdr, 8); |
| 5597 | if (unlikely(!p)) |
| 5598 | goto out_overflow; |
| 5599 | type = be32_to_cpup(p++); |
| 5600 | if (type != pdev->layout_type) { |
| 5601 | dprintk("%s: layout mismatch req: %u pdev: %u\n", |
| 5602 | __func__, pdev->layout_type, type); |
| 5603 | return -EINVAL; |
| 5604 | } |
| 5605 | /* |
| 5606 | * Get the length of the opaque device_addr4. xdr_read_pages places |
| 5607 | * the opaque device_addr4 in the xdr_buf->pages (pnfs_device->pages) |
| 5608 | * and places the remaining xdr data in xdr_buf->tail |
| 5609 | */ |
| 5610 | pdev->mincount = be32_to_cpup(p); |
| 5611 | xdr_read_pages(xdr, pdev->mincount); /* include space for the length */ |
| 5612 | |
| 5613 | /* Parse notification bitmap, verifying that it is zero. */ |
| 5614 | p = xdr_inline_decode(xdr, 4); |
| 5615 | if (unlikely(!p)) |
| 5616 | goto out_overflow; |
| 5617 | len = be32_to_cpup(p); |
| 5618 | if (len) { |
Chuck Lever | ead0059 | 2010-12-14 14:58:21 +0000 | [diff] [blame] | 5619 | uint32_t i; |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 5620 | |
| 5621 | p = xdr_inline_decode(xdr, 4 * len); |
| 5622 | if (unlikely(!p)) |
| 5623 | goto out_overflow; |
| 5624 | for (i = 0; i < len; i++, p++) { |
| 5625 | if (be32_to_cpup(p)) { |
| 5626 | dprintk("%s: notifications not supported\n", |
| 5627 | __func__); |
| 5628 | return -EIO; |
| 5629 | } |
| 5630 | } |
| 5631 | } |
| 5632 | return 0; |
| 5633 | out_overflow: |
| 5634 | print_overflow_msg(__func__, xdr); |
| 5635 | return -EIO; |
| 5636 | } |
| 5637 | |
| 5638 | static int decode_layoutget(struct xdr_stream *xdr, struct rpc_rqst *req, |
| 5639 | struct nfs4_layoutget_res *res) |
| 5640 | { |
| 5641 | __be32 *p; |
| 5642 | int status; |
| 5643 | u32 layout_count; |
Weston Andros Adamson | 35124a0 | 2011-03-24 16:48:21 -0400 | [diff] [blame] | 5644 | struct xdr_buf *rcvbuf = &req->rq_rcv_buf; |
| 5645 | struct kvec *iov = rcvbuf->head; |
| 5646 | u32 hdrlen, recvd; |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 5647 | |
| 5648 | status = decode_op_hdr(xdr, OP_LAYOUTGET); |
| 5649 | if (status) |
| 5650 | return status; |
Trond Myklebust | ea9d23f | 2012-03-04 18:13:56 -0500 | [diff] [blame^] | 5651 | p = xdr_inline_decode(xdr, 4); |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 5652 | if (unlikely(!p)) |
| 5653 | goto out_overflow; |
Trond Myklebust | ea9d23f | 2012-03-04 18:13:56 -0500 | [diff] [blame^] | 5654 | res->return_on_close = be32_to_cpup(p); |
| 5655 | decode_stateid(xdr, &res->stateid); |
| 5656 | p = xdr_inline_decode(xdr, 4); |
| 5657 | if (unlikely(!p)) |
| 5658 | goto out_overflow; |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 5659 | layout_count = be32_to_cpup(p); |
| 5660 | if (!layout_count) { |
| 5661 | dprintk("%s: server responded with empty layout array\n", |
| 5662 | __func__); |
| 5663 | return -EINVAL; |
| 5664 | } |
| 5665 | |
Weston Andros Adamson | 35124a0 | 2011-03-24 16:48:21 -0400 | [diff] [blame] | 5666 | p = xdr_inline_decode(xdr, 28); |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 5667 | if (unlikely(!p)) |
| 5668 | goto out_overflow; |
| 5669 | p = xdr_decode_hyper(p, &res->range.offset); |
| 5670 | p = xdr_decode_hyper(p, &res->range.length); |
| 5671 | res->range.iomode = be32_to_cpup(p++); |
| 5672 | res->type = be32_to_cpup(p++); |
Weston Andros Adamson | 35124a0 | 2011-03-24 16:48:21 -0400 | [diff] [blame] | 5673 | res->layoutp->len = be32_to_cpup(p); |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 5674 | |
| 5675 | dprintk("%s roff:%lu rlen:%lu riomode:%d, lo_type:0x%x, lo.len:%d\n", |
| 5676 | __func__, |
| 5677 | (unsigned long)res->range.offset, |
| 5678 | (unsigned long)res->range.length, |
| 5679 | res->range.iomode, |
| 5680 | res->type, |
Weston Andros Adamson | 35124a0 | 2011-03-24 16:48:21 -0400 | [diff] [blame] | 5681 | res->layoutp->len); |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 5682 | |
Weston Andros Adamson | 35124a0 | 2011-03-24 16:48:21 -0400 | [diff] [blame] | 5683 | hdrlen = (u8 *) xdr->p - (u8 *) iov->iov_base; |
| 5684 | recvd = req->rq_rcv_buf.len - hdrlen; |
| 5685 | if (res->layoutp->len > recvd) { |
| 5686 | dprintk("NFS: server cheating in layoutget reply: " |
| 5687 | "layout len %u > recvd %u\n", |
| 5688 | res->layoutp->len, recvd); |
| 5689 | return -EINVAL; |
| 5690 | } |
| 5691 | |
| 5692 | xdr_read_pages(xdr, res->layoutp->len); |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 5693 | |
| 5694 | if (layout_count > 1) { |
| 5695 | /* We only handle a length one array at the moment. Any |
| 5696 | * further entries are just ignored. Note that this means |
| 5697 | * the client may see a response that is less than the |
| 5698 | * minimum it requested. |
| 5699 | */ |
| 5700 | dprintk("%s: server responded with %d layouts, dropping tail\n", |
| 5701 | __func__, layout_count); |
| 5702 | } |
| 5703 | |
| 5704 | return 0; |
| 5705 | out_overflow: |
| 5706 | print_overflow_msg(__func__, xdr); |
| 5707 | return -EIO; |
| 5708 | } |
Andy Adamson | 863a3c6 | 2011-03-23 13:27:54 +0000 | [diff] [blame] | 5709 | |
Benny Halevy | cbe8260 | 2011-05-22 19:52:37 +0300 | [diff] [blame] | 5710 | static int decode_layoutreturn(struct xdr_stream *xdr, |
| 5711 | struct nfs4_layoutreturn_res *res) |
| 5712 | { |
| 5713 | __be32 *p; |
| 5714 | int status; |
| 5715 | |
| 5716 | status = decode_op_hdr(xdr, OP_LAYOUTRETURN); |
| 5717 | if (status) |
| 5718 | return status; |
| 5719 | p = xdr_inline_decode(xdr, 4); |
| 5720 | if (unlikely(!p)) |
| 5721 | goto out_overflow; |
| 5722 | res->lrs_present = be32_to_cpup(p); |
| 5723 | if (res->lrs_present) |
| 5724 | status = decode_stateid(xdr, &res->stateid); |
| 5725 | return status; |
| 5726 | out_overflow: |
| 5727 | print_overflow_msg(__func__, xdr); |
| 5728 | return -EIO; |
| 5729 | } |
| 5730 | |
Andy Adamson | 863a3c6 | 2011-03-23 13:27:54 +0000 | [diff] [blame] | 5731 | static int decode_layoutcommit(struct xdr_stream *xdr, |
| 5732 | struct rpc_rqst *req, |
| 5733 | struct nfs4_layoutcommit_res *res) |
| 5734 | { |
| 5735 | __be32 *p; |
| 5736 | __u32 sizechanged; |
| 5737 | int status; |
| 5738 | |
| 5739 | status = decode_op_hdr(xdr, OP_LAYOUTCOMMIT); |
Andy Adamson | db29c08 | 2011-07-30 20:52:38 -0400 | [diff] [blame] | 5740 | res->status = status; |
Andy Adamson | 863a3c6 | 2011-03-23 13:27:54 +0000 | [diff] [blame] | 5741 | if (status) |
| 5742 | return status; |
| 5743 | |
| 5744 | p = xdr_inline_decode(xdr, 4); |
| 5745 | if (unlikely(!p)) |
| 5746 | goto out_overflow; |
| 5747 | sizechanged = be32_to_cpup(p); |
| 5748 | |
| 5749 | if (sizechanged) { |
| 5750 | /* throw away new size */ |
| 5751 | p = xdr_inline_decode(xdr, 8); |
| 5752 | if (unlikely(!p)) |
| 5753 | goto out_overflow; |
| 5754 | } |
| 5755 | return 0; |
| 5756 | out_overflow: |
| 5757 | print_overflow_msg(__func__, xdr); |
| 5758 | return -EIO; |
| 5759 | } |
Bryan Schumaker | 7d97479 | 2011-06-02 14:59:08 -0400 | [diff] [blame] | 5760 | |
| 5761 | static int decode_test_stateid(struct xdr_stream *xdr, |
| 5762 | struct nfs41_test_stateid_res *res) |
| 5763 | { |
| 5764 | __be32 *p; |
| 5765 | int status; |
| 5766 | int num_res; |
| 5767 | |
| 5768 | status = decode_op_hdr(xdr, OP_TEST_STATEID); |
| 5769 | if (status) |
| 5770 | return status; |
| 5771 | |
| 5772 | p = xdr_inline_decode(xdr, 4); |
| 5773 | if (unlikely(!p)) |
| 5774 | goto out_overflow; |
| 5775 | num_res = be32_to_cpup(p++); |
| 5776 | if (num_res != 1) |
| 5777 | goto out; |
| 5778 | |
| 5779 | p = xdr_inline_decode(xdr, 4); |
| 5780 | if (unlikely(!p)) |
| 5781 | goto out_overflow; |
| 5782 | res->status = be32_to_cpup(p++); |
Bryan Schumaker | 1cab065 | 2012-01-31 10:39:29 -0500 | [diff] [blame] | 5783 | |
| 5784 | return status; |
Bryan Schumaker | 7d97479 | 2011-06-02 14:59:08 -0400 | [diff] [blame] | 5785 | out_overflow: |
| 5786 | print_overflow_msg(__func__, xdr); |
| 5787 | out: |
| 5788 | return -EIO; |
| 5789 | } |
Bryan Schumaker | 9aeda35 | 2011-06-02 14:59:09 -0400 | [diff] [blame] | 5790 | |
| 5791 | static int decode_free_stateid(struct xdr_stream *xdr, |
| 5792 | struct nfs41_free_stateid_res *res) |
| 5793 | { |
| 5794 | __be32 *p; |
| 5795 | int status; |
| 5796 | |
| 5797 | status = decode_op_hdr(xdr, OP_FREE_STATEID); |
| 5798 | if (status) |
| 5799 | return status; |
| 5800 | |
| 5801 | p = xdr_inline_decode(xdr, 4); |
| 5802 | if (unlikely(!p)) |
| 5803 | goto out_overflow; |
| 5804 | res->status = be32_to_cpup(p++); |
| 5805 | return res->status; |
| 5806 | out_overflow: |
| 5807 | print_overflow_msg(__func__, xdr); |
| 5808 | return -EIO; |
| 5809 | } |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 5810 | #endif /* CONFIG_NFS_V4_1 */ |
| 5811 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5812 | /* |
Benny Halevy | 49c2559 | 2008-12-23 16:06:16 -0500 | [diff] [blame] | 5813 | * END OF "GENERIC" DECODE ROUTINES. |
| 5814 | */ |
| 5815 | |
| 5816 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5817 | * Decode OPEN_DOWNGRADE response |
| 5818 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 5819 | static int nfs4_xdr_dec_open_downgrade(struct rpc_rqst *rqstp, |
| 5820 | struct xdr_stream *xdr, |
| 5821 | struct nfs_closeres *res) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5822 | { |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 5823 | struct compound_hdr hdr; |
| 5824 | int status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5825 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 5826 | status = decode_compound_hdr(xdr, &hdr); |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 5827 | if (status) |
| 5828 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 5829 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 5830 | if (status) |
| 5831 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 5832 | status = decode_putfh(xdr); |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 5833 | if (status) |
| 5834 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 5835 | status = decode_open_downgrade(xdr, res); |
Trond Myklebust | 516a6af | 2005-10-27 22:12:41 -0400 | [diff] [blame] | 5836 | if (status != 0) |
| 5837 | goto out; |
Trond Myklebust | 6926afd1 | 2012-01-07 13:22:46 -0500 | [diff] [blame] | 5838 | decode_getfattr(xdr, res->fattr, res->server); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5839 | out: |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 5840 | return status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5841 | } |
| 5842 | |
| 5843 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5844 | * Decode ACCESS response |
| 5845 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 5846 | static int nfs4_xdr_dec_access(struct rpc_rqst *rqstp, struct xdr_stream *xdr, |
| 5847 | struct nfs4_accessres *res) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5848 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5849 | struct compound_hdr hdr; |
| 5850 | int status; |
Andy Adamson | 6c0195a | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 5851 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 5852 | status = decode_compound_hdr(xdr, &hdr); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 5853 | if (status) |
| 5854 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 5855 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 5856 | if (status) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5857 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 5858 | status = decode_putfh(xdr); |
Trond Myklebust | 76b3299 | 2007-08-10 17:45:11 -0400 | [diff] [blame] | 5859 | if (status != 0) |
| 5860 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 5861 | status = decode_access(xdr, res); |
Trond Myklebust | 76b3299 | 2007-08-10 17:45:11 -0400 | [diff] [blame] | 5862 | if (status != 0) |
| 5863 | goto out; |
Trond Myklebust | 6926afd1 | 2012-01-07 13:22:46 -0500 | [diff] [blame] | 5864 | decode_getfattr(xdr, res->fattr, res->server); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5865 | out: |
| 5866 | return status; |
| 5867 | } |
| 5868 | |
| 5869 | /* |
| 5870 | * Decode LOOKUP response |
| 5871 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 5872 | static int nfs4_xdr_dec_lookup(struct rpc_rqst *rqstp, struct xdr_stream *xdr, |
| 5873 | struct nfs4_lookup_res *res) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5874 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5875 | struct compound_hdr hdr; |
| 5876 | int status; |
Andy Adamson | 6c0195a | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 5877 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 5878 | status = decode_compound_hdr(xdr, &hdr); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 5879 | if (status) |
| 5880 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 5881 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 5882 | if (status) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5883 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 5884 | status = decode_putfh(xdr); |
| 5885 | if (status) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5886 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 5887 | status = decode_lookup(xdr); |
| 5888 | if (status) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5889 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 5890 | status = decode_getfh(xdr, res->fh); |
| 5891 | if (status) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5892 | goto out; |
Trond Myklebust | 6926afd1 | 2012-01-07 13:22:46 -0500 | [diff] [blame] | 5893 | status = decode_getfattr(xdr, res->fattr, res->server); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5894 | out: |
| 5895 | return status; |
| 5896 | } |
| 5897 | |
| 5898 | /* |
| 5899 | * Decode LOOKUP_ROOT response |
| 5900 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 5901 | static int nfs4_xdr_dec_lookup_root(struct rpc_rqst *rqstp, |
| 5902 | struct xdr_stream *xdr, |
| 5903 | struct nfs4_lookup_res *res) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5904 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5905 | struct compound_hdr hdr; |
| 5906 | int status; |
Andy Adamson | 6c0195a | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 5907 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 5908 | status = decode_compound_hdr(xdr, &hdr); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 5909 | if (status) |
| 5910 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 5911 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 5912 | if (status) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5913 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 5914 | status = decode_putrootfh(xdr); |
| 5915 | if (status) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5916 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 5917 | status = decode_getfh(xdr, res->fh); |
| 5918 | if (status == 0) |
Trond Myklebust | 6926afd1 | 2012-01-07 13:22:46 -0500 | [diff] [blame] | 5919 | status = decode_getfattr(xdr, res->fattr, res->server); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5920 | out: |
| 5921 | return status; |
| 5922 | } |
| 5923 | |
| 5924 | /* |
| 5925 | * Decode REMOVE response |
| 5926 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 5927 | static int nfs4_xdr_dec_remove(struct rpc_rqst *rqstp, struct xdr_stream *xdr, |
| 5928 | struct nfs_removeres *res) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5929 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5930 | struct compound_hdr hdr; |
| 5931 | int status; |
Andy Adamson | 6c0195a | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 5932 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 5933 | status = decode_compound_hdr(xdr, &hdr); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 5934 | if (status) |
| 5935 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 5936 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 5937 | if (status) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5938 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 5939 | status = decode_putfh(xdr); |
| 5940 | if (status) |
Trond Myklebust | 16e4295 | 2005-10-27 22:12:44 -0400 | [diff] [blame] | 5941 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 5942 | status = decode_remove(xdr, &res->cinfo); |
| 5943 | if (status) |
Trond Myklebust | 16e4295 | 2005-10-27 22:12:44 -0400 | [diff] [blame] | 5944 | goto out; |
Trond Myklebust | 6926afd1 | 2012-01-07 13:22:46 -0500 | [diff] [blame] | 5945 | decode_getfattr(xdr, res->dir_attr, res->server); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5946 | out: |
| 5947 | return status; |
| 5948 | } |
| 5949 | |
| 5950 | /* |
| 5951 | * Decode RENAME response |
| 5952 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 5953 | static int nfs4_xdr_dec_rename(struct rpc_rqst *rqstp, struct xdr_stream *xdr, |
| 5954 | struct nfs_renameres *res) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5955 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5956 | struct compound_hdr hdr; |
| 5957 | int status; |
Andy Adamson | 6c0195a | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 5958 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 5959 | status = decode_compound_hdr(xdr, &hdr); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 5960 | if (status) |
| 5961 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 5962 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 5963 | if (status) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5964 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 5965 | status = decode_putfh(xdr); |
| 5966 | if (status) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5967 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 5968 | status = decode_savefh(xdr); |
| 5969 | if (status) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5970 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 5971 | status = decode_putfh(xdr); |
| 5972 | if (status) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5973 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 5974 | status = decode_rename(xdr, &res->old_cinfo, &res->new_cinfo); |
| 5975 | if (status) |
Trond Myklebust | 6caf2c8 | 2005-10-27 22:12:43 -0400 | [diff] [blame] | 5976 | goto out; |
| 5977 | /* Current FH is target directory */ |
Trond Myklebust | 6926afd1 | 2012-01-07 13:22:46 -0500 | [diff] [blame] | 5978 | if (decode_getfattr(xdr, res->new_fattr, res->server)) |
Trond Myklebust | 6caf2c8 | 2005-10-27 22:12:43 -0400 | [diff] [blame] | 5979 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 5980 | status = decode_restorefh(xdr); |
| 5981 | if (status) |
Trond Myklebust | 6caf2c8 | 2005-10-27 22:12:43 -0400 | [diff] [blame] | 5982 | goto out; |
Trond Myklebust | 6926afd1 | 2012-01-07 13:22:46 -0500 | [diff] [blame] | 5983 | decode_getfattr(xdr, res->old_fattr, res->server); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5984 | out: |
| 5985 | return status; |
| 5986 | } |
| 5987 | |
| 5988 | /* |
| 5989 | * Decode LINK response |
| 5990 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 5991 | static int nfs4_xdr_dec_link(struct rpc_rqst *rqstp, struct xdr_stream *xdr, |
| 5992 | struct nfs4_link_res *res) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5993 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5994 | struct compound_hdr hdr; |
| 5995 | int status; |
Andy Adamson | 6c0195a | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 5996 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 5997 | status = decode_compound_hdr(xdr, &hdr); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 5998 | if (status) |
| 5999 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6000 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6001 | if (status) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6002 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6003 | status = decode_putfh(xdr); |
| 6004 | if (status) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6005 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6006 | status = decode_savefh(xdr); |
| 6007 | if (status) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6008 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6009 | status = decode_putfh(xdr); |
| 6010 | if (status) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6011 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6012 | status = decode_link(xdr, &res->cinfo); |
| 6013 | if (status) |
Trond Myklebust | 91ba2ee | 2005-10-27 22:12:42 -0400 | [diff] [blame] | 6014 | goto out; |
| 6015 | /* |
| 6016 | * Note order: OP_LINK leaves the directory as the current |
| 6017 | * filehandle. |
| 6018 | */ |
Trond Myklebust | 6926afd1 | 2012-01-07 13:22:46 -0500 | [diff] [blame] | 6019 | if (decode_getfattr(xdr, res->dir_attr, res->server)) |
Trond Myklebust | 91ba2ee | 2005-10-27 22:12:42 -0400 | [diff] [blame] | 6020 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6021 | status = decode_restorefh(xdr); |
| 6022 | if (status) |
Trond Myklebust | 91ba2ee | 2005-10-27 22:12:42 -0400 | [diff] [blame] | 6023 | goto out; |
Trond Myklebust | 6926afd1 | 2012-01-07 13:22:46 -0500 | [diff] [blame] | 6024 | decode_getfattr(xdr, res->fattr, res->server); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6025 | out: |
| 6026 | return status; |
| 6027 | } |
| 6028 | |
| 6029 | /* |
| 6030 | * Decode CREATE response |
| 6031 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6032 | static int nfs4_xdr_dec_create(struct rpc_rqst *rqstp, struct xdr_stream *xdr, |
| 6033 | struct nfs4_create_res *res) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6034 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6035 | struct compound_hdr hdr; |
| 6036 | int status; |
Andy Adamson | 6c0195a | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6037 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6038 | status = decode_compound_hdr(xdr, &hdr); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6039 | if (status) |
| 6040 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6041 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6042 | if (status) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6043 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6044 | status = decode_putfh(xdr); |
| 6045 | if (status) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6046 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6047 | status = decode_savefh(xdr); |
| 6048 | if (status) |
Trond Myklebust | 56ae19f | 2005-10-27 22:12:40 -0400 | [diff] [blame] | 6049 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6050 | status = decode_create(xdr, &res->dir_cinfo); |
| 6051 | if (status) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6052 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6053 | status = decode_getfh(xdr, res->fh); |
| 6054 | if (status) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6055 | goto out; |
Trond Myklebust | 6926afd1 | 2012-01-07 13:22:46 -0500 | [diff] [blame] | 6056 | if (decode_getfattr(xdr, res->fattr, res->server)) |
Trond Myklebust | 56ae19f | 2005-10-27 22:12:40 -0400 | [diff] [blame] | 6057 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6058 | status = decode_restorefh(xdr); |
| 6059 | if (status) |
Trond Myklebust | 56ae19f | 2005-10-27 22:12:40 -0400 | [diff] [blame] | 6060 | goto out; |
Trond Myklebust | 6926afd1 | 2012-01-07 13:22:46 -0500 | [diff] [blame] | 6061 | decode_getfattr(xdr, res->dir_fattr, res->server); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6062 | out: |
| 6063 | return status; |
| 6064 | } |
| 6065 | |
| 6066 | /* |
| 6067 | * Decode SYMLINK response |
| 6068 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6069 | static int nfs4_xdr_dec_symlink(struct rpc_rqst *rqstp, struct xdr_stream *xdr, |
| 6070 | struct nfs4_create_res *res) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6071 | { |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6072 | return nfs4_xdr_dec_create(rqstp, xdr, res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6073 | } |
| 6074 | |
| 6075 | /* |
| 6076 | * Decode GETATTR response |
| 6077 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6078 | static int nfs4_xdr_dec_getattr(struct rpc_rqst *rqstp, struct xdr_stream *xdr, |
| 6079 | struct nfs4_getattr_res *res) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6080 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6081 | struct compound_hdr hdr; |
| 6082 | int status; |
Andy Adamson | 6c0195a | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6083 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6084 | status = decode_compound_hdr(xdr, &hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6085 | if (status) |
| 6086 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6087 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6088 | if (status) |
| 6089 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6090 | status = decode_putfh(xdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6091 | if (status) |
| 6092 | goto out; |
Trond Myklebust | 6926afd1 | 2012-01-07 13:22:46 -0500 | [diff] [blame] | 6093 | status = decode_getfattr(xdr, res->fattr, res->server); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6094 | out: |
| 6095 | return status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6096 | } |
| 6097 | |
J. Bruce Fields | 23ec696 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 6098 | /* |
| 6099 | * Encode an SETACL request |
| 6100 | */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 6101 | static void nfs4_xdr_enc_setacl(struct rpc_rqst *req, struct xdr_stream *xdr, |
| 6102 | struct nfs_setaclargs *args) |
J. Bruce Fields | 23ec696 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 6103 | { |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6104 | struct compound_hdr hdr = { |
Benny Halevy | 66cc042 | 2009-04-01 09:22:10 -0400 | [diff] [blame] | 6105 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6106 | }; |
J. Bruce Fields | 23ec696 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 6107 | |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 6108 | encode_compound_hdr(xdr, req, &hdr); |
| 6109 | encode_sequence(xdr, &args->seq_args, &hdr); |
| 6110 | encode_putfh(xdr, args->fh, &hdr); |
| 6111 | encode_setacl(xdr, args, &hdr); |
Andy Adamson | d017931 | 2008-12-23 16:06:17 -0500 | [diff] [blame] | 6112 | encode_nops(&hdr); |
J. Bruce Fields | 23ec696 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 6113 | } |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6114 | |
J. Bruce Fields | 23ec696 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 6115 | /* |
| 6116 | * Decode SETACL response |
| 6117 | */ |
| 6118 | static int |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6119 | nfs4_xdr_dec_setacl(struct rpc_rqst *rqstp, struct xdr_stream *xdr, |
Benny Halevy | 73c403a | 2009-04-01 09:22:01 -0400 | [diff] [blame] | 6120 | struct nfs_setaclres *res) |
J. Bruce Fields | 23ec696 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 6121 | { |
J. Bruce Fields | 23ec696 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 6122 | struct compound_hdr hdr; |
| 6123 | int status; |
| 6124 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6125 | status = decode_compound_hdr(xdr, &hdr); |
J. Bruce Fields | 23ec696 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 6126 | if (status) |
| 6127 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6128 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6129 | if (status) |
| 6130 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6131 | status = decode_putfh(xdr); |
J. Bruce Fields | 23ec696 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 6132 | if (status) |
| 6133 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6134 | status = decode_setattr(xdr); |
J. Bruce Fields | 23ec696 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 6135 | out: |
| 6136 | return status; |
| 6137 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6138 | |
| 6139 | /* |
J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 6140 | * Decode GETACL response |
| 6141 | */ |
| 6142 | static int |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6143 | nfs4_xdr_dec_getacl(struct rpc_rqst *rqstp, struct xdr_stream *xdr, |
Benny Halevy | 663c79b | 2009-04-01 09:21:59 -0400 | [diff] [blame] | 6144 | struct nfs_getaclres *res) |
J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 6145 | { |
J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 6146 | struct compound_hdr hdr; |
| 6147 | int status; |
| 6148 | |
Trond Myklebust | 331818f | 2012-02-03 18:30:53 -0500 | [diff] [blame] | 6149 | if (res->acl_scratch != NULL) { |
| 6150 | void *p = page_address(res->acl_scratch); |
| 6151 | xdr_set_scratch_buffer(xdr, p, PAGE_SIZE); |
| 6152 | } |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6153 | status = decode_compound_hdr(xdr, &hdr); |
J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 6154 | if (status) |
| 6155 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6156 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6157 | if (status) |
| 6158 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6159 | status = decode_putfh(xdr); |
J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 6160 | if (status) |
| 6161 | goto out; |
Andy Adamson | bf118a3 | 2011-12-07 11:55:27 -0500 | [diff] [blame] | 6162 | status = decode_getacl(xdr, rqstp, res); |
J. Bruce Fields | 029d105 | 2005-06-22 17:16:22 +0000 | [diff] [blame] | 6163 | |
| 6164 | out: |
| 6165 | return status; |
| 6166 | } |
| 6167 | |
| 6168 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6169 | * Decode CLOSE response |
| 6170 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6171 | static int nfs4_xdr_dec_close(struct rpc_rqst *rqstp, struct xdr_stream *xdr, |
| 6172 | struct nfs_closeres *res) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6173 | { |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6174 | struct compound_hdr hdr; |
| 6175 | int status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6176 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6177 | status = decode_compound_hdr(xdr, &hdr); |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6178 | if (status) |
| 6179 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6180 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6181 | if (status) |
| 6182 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6183 | status = decode_putfh(xdr); |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6184 | if (status) |
| 6185 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6186 | status = decode_close(xdr, res); |
Trond Myklebust | 516a6af | 2005-10-27 22:12:41 -0400 | [diff] [blame] | 6187 | if (status != 0) |
| 6188 | goto out; |
| 6189 | /* |
| 6190 | * Note: Server may do delete on close for this file |
| 6191 | * in which case the getattr call will fail with |
| 6192 | * an ESTALE error. Shouldn't be a problem, |
| 6193 | * though, since fattr->valid will remain unset. |
| 6194 | */ |
Trond Myklebust | 6926afd1 | 2012-01-07 13:22:46 -0500 | [diff] [blame] | 6195 | decode_getfattr(xdr, res->fattr, res->server); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6196 | out: |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6197 | return status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6198 | } |
| 6199 | |
| 6200 | /* |
| 6201 | * Decode OPEN response |
| 6202 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6203 | static int nfs4_xdr_dec_open(struct rpc_rqst *rqstp, struct xdr_stream *xdr, |
| 6204 | struct nfs_openres *res) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6205 | { |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6206 | struct compound_hdr hdr; |
| 6207 | int status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6208 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6209 | status = decode_compound_hdr(xdr, &hdr); |
Trond Myklebust | 56ae19f | 2005-10-27 22:12:40 -0400 | [diff] [blame] | 6210 | if (status) |
| 6211 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6212 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6213 | if (status) |
| 6214 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6215 | status = decode_putfh(xdr); |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6216 | if (status) |
| 6217 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6218 | status = decode_savefh(xdr); |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6219 | if (status) |
| 6220 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6221 | status = decode_open(xdr, res); |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6222 | if (status) |
| 6223 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6224 | if (decode_getfh(xdr, &res->fh) != 0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6225 | goto out; |
Trond Myklebust | 6926afd1 | 2012-01-07 13:22:46 -0500 | [diff] [blame] | 6226 | if (decode_getfattr(xdr, res->f_attr, res->server) != 0) |
Trond Myklebust | 56ae19f | 2005-10-27 22:12:40 -0400 | [diff] [blame] | 6227 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6228 | if (decode_restorefh(xdr) != 0) |
Trond Myklebust | 56ae19f | 2005-10-27 22:12:40 -0400 | [diff] [blame] | 6229 | goto out; |
Trond Myklebust | 6926afd1 | 2012-01-07 13:22:46 -0500 | [diff] [blame] | 6230 | decode_getfattr(xdr, res->dir_attr, res->server); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6231 | out: |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6232 | return status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6233 | } |
| 6234 | |
| 6235 | /* |
| 6236 | * Decode OPEN_CONFIRM response |
| 6237 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6238 | static int nfs4_xdr_dec_open_confirm(struct rpc_rqst *rqstp, |
| 6239 | struct xdr_stream *xdr, |
| 6240 | struct nfs_open_confirmres *res) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6241 | { |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6242 | struct compound_hdr hdr; |
| 6243 | int status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6244 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6245 | status = decode_compound_hdr(xdr, &hdr); |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6246 | if (status) |
| 6247 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6248 | status = decode_putfh(xdr); |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6249 | if (status) |
| 6250 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6251 | status = decode_open_confirm(xdr, res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6252 | out: |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6253 | return status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6254 | } |
| 6255 | |
| 6256 | /* |
| 6257 | * Decode OPEN response |
| 6258 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6259 | static int nfs4_xdr_dec_open_noattr(struct rpc_rqst *rqstp, |
| 6260 | struct xdr_stream *xdr, |
| 6261 | struct nfs_openres *res) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6262 | { |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6263 | struct compound_hdr hdr; |
| 6264 | int status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6265 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6266 | status = decode_compound_hdr(xdr, &hdr); |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [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); |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6273 | if (status) |
| 6274 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6275 | status = decode_open(xdr, res); |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6276 | if (status) |
| 6277 | goto out; |
Trond Myklebust | 6926afd1 | 2012-01-07 13:22:46 -0500 | [diff] [blame] | 6278 | decode_getfattr(xdr, res->f_attr, res->server); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6279 | out: |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6280 | return status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6281 | } |
| 6282 | |
| 6283 | /* |
| 6284 | * Decode SETATTR response |
| 6285 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6286 | static int nfs4_xdr_dec_setattr(struct rpc_rqst *rqstp, |
| 6287 | struct xdr_stream *xdr, |
| 6288 | struct nfs_setattrres *res) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6289 | { |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6290 | struct compound_hdr hdr; |
| 6291 | int status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6292 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6293 | status = decode_compound_hdr(xdr, &hdr); |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6294 | if (status) |
| 6295 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6296 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6297 | if (status) |
| 6298 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6299 | status = decode_putfh(xdr); |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6300 | if (status) |
| 6301 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6302 | status = decode_setattr(xdr); |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6303 | if (status) |
| 6304 | goto out; |
Trond Myklebust | 6926afd1 | 2012-01-07 13:22:46 -0500 | [diff] [blame] | 6305 | decode_getfattr(xdr, res->fattr, res->server); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6306 | out: |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 6307 | return status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6308 | } |
| 6309 | |
| 6310 | /* |
| 6311 | * Decode LOCK response |
| 6312 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6313 | static int nfs4_xdr_dec_lock(struct rpc_rqst *rqstp, struct xdr_stream *xdr, |
| 6314 | struct nfs_lock_res *res) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6315 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6316 | struct compound_hdr hdr; |
| 6317 | int status; |
| 6318 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6319 | status = decode_compound_hdr(xdr, &hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6320 | if (status) |
| 6321 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6322 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6323 | if (status) |
| 6324 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6325 | status = decode_putfh(xdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6326 | if (status) |
| 6327 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6328 | status = decode_lock(xdr, res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6329 | out: |
| 6330 | return status; |
| 6331 | } |
| 6332 | |
| 6333 | /* |
| 6334 | * Decode LOCKT response |
| 6335 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6336 | static int nfs4_xdr_dec_lockt(struct rpc_rqst *rqstp, struct xdr_stream *xdr, |
| 6337 | struct nfs_lockt_res *res) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6338 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6339 | struct compound_hdr hdr; |
| 6340 | int status; |
| 6341 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6342 | status = decode_compound_hdr(xdr, &hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6343 | if (status) |
| 6344 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6345 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6346 | if (status) |
| 6347 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6348 | status = decode_putfh(xdr); |
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_lockt(xdr, res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6352 | out: |
| 6353 | return status; |
| 6354 | } |
| 6355 | |
| 6356 | /* |
| 6357 | * Decode LOCKU response |
| 6358 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6359 | static int nfs4_xdr_dec_locku(struct rpc_rqst *rqstp, struct xdr_stream *xdr, |
| 6360 | struct nfs_locku_res *res) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6361 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6362 | struct compound_hdr hdr; |
| 6363 | int status; |
| 6364 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6365 | status = decode_compound_hdr(xdr, &hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6366 | if (status) |
| 6367 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6368 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6369 | if (status) |
| 6370 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6371 | status = decode_putfh(xdr); |
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_locku(xdr, res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6375 | out: |
| 6376 | return status; |
| 6377 | } |
| 6378 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6379 | static int nfs4_xdr_dec_release_lockowner(struct rpc_rqst *rqstp, |
| 6380 | struct xdr_stream *xdr, void *dummy) |
Trond Myklebust | d3c7b7c | 2010-07-01 12:49:01 -0400 | [diff] [blame] | 6381 | { |
Trond Myklebust | d3c7b7c | 2010-07-01 12:49:01 -0400 | [diff] [blame] | 6382 | struct compound_hdr hdr; |
| 6383 | int status; |
| 6384 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6385 | status = decode_compound_hdr(xdr, &hdr); |
Trond Myklebust | d3c7b7c | 2010-07-01 12:49:01 -0400 | [diff] [blame] | 6386 | if (!status) |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6387 | status = decode_release_lockowner(xdr); |
Trond Myklebust | d3c7b7c | 2010-07-01 12:49:01 -0400 | [diff] [blame] | 6388 | return status; |
| 6389 | } |
| 6390 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6391 | /* |
| 6392 | * Decode READLINK response |
| 6393 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6394 | static int nfs4_xdr_dec_readlink(struct rpc_rqst *rqstp, |
| 6395 | struct xdr_stream *xdr, |
Benny Halevy | f50c700 | 2009-04-01 09:21:55 -0400 | [diff] [blame] | 6396 | struct nfs4_readlink_res *res) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6397 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6398 | struct compound_hdr hdr; |
| 6399 | int status; |
| 6400 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6401 | status = decode_compound_hdr(xdr, &hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6402 | if (status) |
| 6403 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6404 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6405 | if (status) |
| 6406 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6407 | status = decode_putfh(xdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6408 | if (status) |
| 6409 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6410 | status = decode_readlink(xdr, rqstp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6411 | out: |
| 6412 | return status; |
| 6413 | } |
| 6414 | |
| 6415 | /* |
| 6416 | * Decode READDIR response |
| 6417 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6418 | static int nfs4_xdr_dec_readdir(struct rpc_rqst *rqstp, struct xdr_stream *xdr, |
| 6419 | struct nfs4_readdir_res *res) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6420 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6421 | struct compound_hdr hdr; |
| 6422 | int status; |
| 6423 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6424 | status = decode_compound_hdr(xdr, &hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6425 | if (status) |
| 6426 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6427 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6428 | if (status) |
| 6429 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6430 | status = decode_putfh(xdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6431 | if (status) |
| 6432 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6433 | status = decode_readdir(xdr, rqstp, res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6434 | out: |
| 6435 | return status; |
| 6436 | } |
| 6437 | |
| 6438 | /* |
| 6439 | * Decode Read response |
| 6440 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6441 | static int nfs4_xdr_dec_read(struct rpc_rqst *rqstp, struct xdr_stream *xdr, |
| 6442 | struct nfs_readres *res) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6443 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6444 | struct compound_hdr hdr; |
| 6445 | int status; |
| 6446 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6447 | status = decode_compound_hdr(xdr, &hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6448 | if (status) |
| 6449 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6450 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6451 | if (status) |
| 6452 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6453 | status = decode_putfh(xdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6454 | if (status) |
| 6455 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6456 | status = decode_read(xdr, rqstp, res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6457 | if (!status) |
| 6458 | status = res->count; |
| 6459 | out: |
| 6460 | return status; |
| 6461 | } |
| 6462 | |
| 6463 | /* |
| 6464 | * Decode WRITE response |
| 6465 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6466 | static int nfs4_xdr_dec_write(struct rpc_rqst *rqstp, struct xdr_stream *xdr, |
| 6467 | struct nfs_writeres *res) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6468 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6469 | struct compound_hdr hdr; |
| 6470 | int status; |
| 6471 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6472 | status = decode_compound_hdr(xdr, &hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6473 | if (status) |
| 6474 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6475 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6476 | if (status) |
| 6477 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6478 | status = decode_putfh(xdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6479 | if (status) |
| 6480 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6481 | status = decode_write(xdr, res); |
Trond Myklebust | 4f9838c | 2005-10-27 22:12:44 -0400 | [diff] [blame] | 6482 | if (status) |
| 6483 | goto out; |
Fred Isaman | 7ffd106 | 2011-03-03 15:13:46 +0000 | [diff] [blame] | 6484 | if (res->fattr) |
Trond Myklebust | 6926afd1 | 2012-01-07 13:22:46 -0500 | [diff] [blame] | 6485 | decode_getfattr(xdr, res->fattr, res->server); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6486 | if (!status) |
| 6487 | status = res->count; |
| 6488 | out: |
| 6489 | return status; |
| 6490 | } |
| 6491 | |
| 6492 | /* |
| 6493 | * Decode COMMIT response |
| 6494 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6495 | static int nfs4_xdr_dec_commit(struct rpc_rqst *rqstp, struct xdr_stream *xdr, |
| 6496 | struct nfs_writeres *res) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6497 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6498 | struct compound_hdr hdr; |
| 6499 | int status; |
| 6500 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6501 | status = decode_compound_hdr(xdr, &hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6502 | if (status) |
| 6503 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6504 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6505 | if (status) |
| 6506 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6507 | status = decode_putfh(xdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6508 | if (status) |
| 6509 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6510 | status = decode_commit(xdr, res); |
Trond Myklebust | 4f9838c | 2005-10-27 22:12:44 -0400 | [diff] [blame] | 6511 | if (status) |
| 6512 | goto out; |
Fred Isaman | 988b6dc | 2011-03-23 13:27:52 +0000 | [diff] [blame] | 6513 | if (res->fattr) |
Trond Myklebust | 6926afd1 | 2012-01-07 13:22:46 -0500 | [diff] [blame] | 6514 | decode_getfattr(xdr, res->fattr, res->server); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6515 | out: |
| 6516 | return status; |
| 6517 | } |
| 6518 | |
| 6519 | /* |
Ricardo Labiaga | 8b17321 | 2009-12-05 16:08:39 -0500 | [diff] [blame] | 6520 | * Decode FSINFO response |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6521 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6522 | 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] | 6523 | struct nfs4_fsinfo_res *res) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6524 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6525 | struct compound_hdr hdr; |
| 6526 | int status; |
| 6527 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6528 | status = decode_compound_hdr(xdr, &hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6529 | if (!status) |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6530 | status = decode_sequence(xdr, &res->seq_res, req); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6531 | if (!status) |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6532 | status = decode_putfh(xdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6533 | if (!status) |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6534 | status = decode_fsinfo(xdr, res->fsinfo); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6535 | return status; |
| 6536 | } |
| 6537 | |
| 6538 | /* |
Ricardo Labiaga | 8b17321 | 2009-12-05 16:08:39 -0500 | [diff] [blame] | 6539 | * Decode PATHCONF response |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6540 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6541 | 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] | 6542 | struct nfs4_pathconf_res *res) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6543 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6544 | struct compound_hdr hdr; |
| 6545 | int status; |
| 6546 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6547 | status = decode_compound_hdr(xdr, &hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6548 | if (!status) |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6549 | status = decode_sequence(xdr, &res->seq_res, req); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6550 | if (!status) |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6551 | status = decode_putfh(xdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6552 | if (!status) |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6553 | status = decode_pathconf(xdr, res->pathconf); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6554 | return status; |
| 6555 | } |
| 6556 | |
| 6557 | /* |
Ricardo Labiaga | 8b17321 | 2009-12-05 16:08:39 -0500 | [diff] [blame] | 6558 | * Decode STATFS response |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6559 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6560 | 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] | 6561 | struct nfs4_statfs_res *res) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6562 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6563 | struct compound_hdr hdr; |
| 6564 | int status; |
| 6565 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6566 | status = decode_compound_hdr(xdr, &hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6567 | if (!status) |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6568 | status = decode_sequence(xdr, &res->seq_res, req); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6569 | if (!status) |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6570 | status = decode_putfh(xdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6571 | if (!status) |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6572 | status = decode_statfs(xdr, res->fsstat); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6573 | return status; |
| 6574 | } |
| 6575 | |
| 6576 | /* |
Ricardo Labiaga | 8b17321 | 2009-12-05 16:08:39 -0500 | [diff] [blame] | 6577 | * Decode GETATTR_BITMAP response |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6578 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6579 | static int nfs4_xdr_dec_server_caps(struct rpc_rqst *req, |
| 6580 | struct xdr_stream *xdr, |
| 6581 | struct nfs4_server_caps_res *res) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6582 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6583 | struct compound_hdr hdr; |
| 6584 | int status; |
| 6585 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6586 | status = decode_compound_hdr(xdr, &hdr); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6587 | if (status) |
| 6588 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6589 | status = decode_sequence(xdr, &res->seq_res, req); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6590 | if (status) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6591 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6592 | status = decode_putfh(xdr); |
| 6593 | if (status) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6594 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6595 | status = decode_server_caps(xdr, res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6596 | out: |
| 6597 | return status; |
| 6598 | } |
| 6599 | |
| 6600 | /* |
| 6601 | * Decode RENEW response |
| 6602 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6603 | static int nfs4_xdr_dec_renew(struct rpc_rqst *rqstp, struct xdr_stream *xdr, |
| 6604 | void *__unused) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6605 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6606 | struct compound_hdr hdr; |
| 6607 | int status; |
| 6608 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6609 | status = decode_compound_hdr(xdr, &hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6610 | if (!status) |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6611 | status = decode_renew(xdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6612 | return status; |
| 6613 | } |
| 6614 | |
| 6615 | /* |
Ricardo Labiaga | 8b17321 | 2009-12-05 16:08:39 -0500 | [diff] [blame] | 6616 | * Decode SETCLIENTID response |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6617 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6618 | static int nfs4_xdr_dec_setclientid(struct rpc_rqst *req, |
| 6619 | struct xdr_stream *xdr, |
| 6620 | struct nfs4_setclientid_res *res) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6621 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6622 | struct compound_hdr hdr; |
| 6623 | int status; |
| 6624 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6625 | status = decode_compound_hdr(xdr, &hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6626 | if (!status) |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6627 | status = decode_setclientid(xdr, res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6628 | return status; |
| 6629 | } |
| 6630 | |
| 6631 | /* |
Ricardo Labiaga | 8b17321 | 2009-12-05 16:08:39 -0500 | [diff] [blame] | 6632 | * Decode SETCLIENTID_CONFIRM response |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6633 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6634 | static int nfs4_xdr_dec_setclientid_confirm(struct rpc_rqst *req, |
| 6635 | struct xdr_stream *xdr, |
| 6636 | struct nfs_fsinfo *fsinfo) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6637 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6638 | struct compound_hdr hdr; |
| 6639 | int status; |
| 6640 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6641 | status = decode_compound_hdr(xdr, &hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6642 | if (!status) |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6643 | status = decode_setclientid_confirm(xdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6644 | if (!status) |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6645 | status = decode_putrootfh(xdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6646 | if (!status) |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6647 | status = decode_fsinfo(xdr, fsinfo); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6648 | return status; |
| 6649 | } |
| 6650 | |
| 6651 | /* |
Ricardo Labiaga | 8b17321 | 2009-12-05 16:08:39 -0500 | [diff] [blame] | 6652 | * Decode DELEGRETURN response |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6653 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6654 | static int nfs4_xdr_dec_delegreturn(struct rpc_rqst *rqstp, |
| 6655 | struct xdr_stream *xdr, |
| 6656 | struct nfs4_delegreturnres *res) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6657 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6658 | struct compound_hdr hdr; |
| 6659 | int status; |
| 6660 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6661 | status = decode_compound_hdr(xdr, &hdr); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6662 | if (status) |
| 6663 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6664 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6665 | if (status) |
Trond Myklebust | fa178f2 | 2006-01-03 09:55:38 +0100 | [diff] [blame] | 6666 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6667 | status = decode_putfh(xdr); |
Trond Myklebust | fa178f2 | 2006-01-03 09:55:38 +0100 | [diff] [blame] | 6668 | if (status != 0) |
| 6669 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6670 | status = decode_delegreturn(xdr); |
Jeff Layton | 556ae3b | 2010-03-21 12:10:36 -0400 | [diff] [blame] | 6671 | if (status != 0) |
| 6672 | goto out; |
Trond Myklebust | 6926afd1 | 2012-01-07 13:22:46 -0500 | [diff] [blame] | 6673 | decode_getfattr(xdr, res->fattr, res->server); |
Trond Myklebust | fa178f2 | 2006-01-03 09:55:38 +0100 | [diff] [blame] | 6674 | out: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6675 | return status; |
| 6676 | } |
| 6677 | |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 6678 | /* |
Ricardo Labiaga | 8b17321 | 2009-12-05 16:08:39 -0500 | [diff] [blame] | 6679 | * Decode FS_LOCATIONS response |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 6680 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6681 | static int nfs4_xdr_dec_fs_locations(struct rpc_rqst *req, |
| 6682 | struct xdr_stream *xdr, |
Benny Halevy | 2295846 | 2009-04-01 09:22:02 -0400 | [diff] [blame] | 6683 | struct nfs4_fs_locations_res *res) |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 6684 | { |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 6685 | struct compound_hdr hdr; |
| 6686 | int status; |
| 6687 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6688 | status = decode_compound_hdr(xdr, &hdr); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6689 | if (status) |
| 6690 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6691 | status = decode_sequence(xdr, &res->seq_res, req); |
Andy Adamson | 9b7b9fc | 2009-04-01 09:22:11 -0400 | [diff] [blame] | 6692 | if (status) |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 6693 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6694 | status = decode_putfh(xdr); |
| 6695 | if (status) |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 6696 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6697 | status = decode_lookup(xdr); |
| 6698 | if (status) |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 6699 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6700 | xdr_enter_page(xdr, PAGE_SIZE); |
Trond Myklebust | 8b7e3f4 | 2012-01-30 15:43:56 -0500 | [diff] [blame] | 6701 | status = decode_getfattr_generic(xdr, &res->fs_locations->fattr, |
| 6702 | NULL, res->fs_locations, |
| 6703 | res->fs_locations->server); |
Trond Myklebust | 683b57b | 2006-06-09 09:34:22 -0400 | [diff] [blame] | 6704 | out: |
| 6705 | return status; |
| 6706 | } |
| 6707 | |
Bryan Schumaker | 5a5ea0d | 2011-03-24 17:12:29 +0000 | [diff] [blame] | 6708 | /* |
| 6709 | * Decode SECINFO response |
| 6710 | */ |
| 6711 | static int nfs4_xdr_dec_secinfo(struct rpc_rqst *rqstp, |
| 6712 | struct xdr_stream *xdr, |
| 6713 | struct nfs4_secinfo_res *res) |
| 6714 | { |
| 6715 | struct compound_hdr hdr; |
| 6716 | int status; |
| 6717 | |
| 6718 | status = decode_compound_hdr(xdr, &hdr); |
| 6719 | if (status) |
| 6720 | goto out; |
| 6721 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
| 6722 | if (status) |
| 6723 | goto out; |
| 6724 | status = decode_putfh(xdr); |
| 6725 | if (status) |
| 6726 | goto out; |
| 6727 | status = decode_secinfo(xdr, res); |
Bryan Schumaker | 5a5ea0d | 2011-03-24 17:12:29 +0000 | [diff] [blame] | 6728 | out: |
| 6729 | return status; |
| 6730 | } |
| 6731 | |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 6732 | #if defined(CONFIG_NFS_V4_1) |
| 6733 | /* |
Ricardo Labiaga | 8b17321 | 2009-12-05 16:08:39 -0500 | [diff] [blame] | 6734 | * Decode EXCHANGE_ID response |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 6735 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6736 | static int nfs4_xdr_dec_exchange_id(struct rpc_rqst *rqstp, |
| 6737 | struct xdr_stream *xdr, |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 6738 | void *res) |
| 6739 | { |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 6740 | struct compound_hdr hdr; |
| 6741 | int status; |
| 6742 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6743 | status = decode_compound_hdr(xdr, &hdr); |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 6744 | if (!status) |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6745 | status = decode_exchange_id(xdr, res); |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 6746 | return status; |
| 6747 | } |
Andy Adamson | 2050f0c | 2009-04-01 09:22:30 -0400 | [diff] [blame] | 6748 | |
| 6749 | /* |
Ricardo Labiaga | 8b17321 | 2009-12-05 16:08:39 -0500 | [diff] [blame] | 6750 | * Decode CREATE_SESSION response |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 6751 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6752 | static int nfs4_xdr_dec_create_session(struct rpc_rqst *rqstp, |
| 6753 | struct xdr_stream *xdr, |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 6754 | struct nfs41_create_session_res *res) |
| 6755 | { |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 6756 | struct compound_hdr hdr; |
| 6757 | int status; |
| 6758 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6759 | status = decode_compound_hdr(xdr, &hdr); |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 6760 | if (!status) |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6761 | status = decode_create_session(xdr, res); |
Andy Adamson | fc93158 | 2009-04-01 09:22:31 -0400 | [diff] [blame] | 6762 | return status; |
| 6763 | } |
| 6764 | |
| 6765 | /* |
Ricardo Labiaga | 8b17321 | 2009-12-05 16:08:39 -0500 | [diff] [blame] | 6766 | * Decode DESTROY_SESSION response |
Andy Adamson | 0f3e66c | 2009-04-01 09:22:34 -0400 | [diff] [blame] | 6767 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6768 | static int nfs4_xdr_dec_destroy_session(struct rpc_rqst *rqstp, |
| 6769 | struct xdr_stream *xdr, |
| 6770 | void *res) |
Andy Adamson | 0f3e66c | 2009-04-01 09:22:34 -0400 | [diff] [blame] | 6771 | { |
Andy Adamson | 0f3e66c | 2009-04-01 09:22:34 -0400 | [diff] [blame] | 6772 | struct compound_hdr hdr; |
| 6773 | int status; |
| 6774 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6775 | status = decode_compound_hdr(xdr, &hdr); |
Andy Adamson | 0f3e66c | 2009-04-01 09:22:34 -0400 | [diff] [blame] | 6776 | if (!status) |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6777 | status = decode_destroy_session(xdr, res); |
Andy Adamson | 0f3e66c | 2009-04-01 09:22:34 -0400 | [diff] [blame] | 6778 | return status; |
| 6779 | } |
| 6780 | |
| 6781 | /* |
Ricardo Labiaga | 8b17321 | 2009-12-05 16:08:39 -0500 | [diff] [blame] | 6782 | * Decode SEQUENCE response |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 6783 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6784 | static int nfs4_xdr_dec_sequence(struct rpc_rqst *rqstp, |
| 6785 | struct xdr_stream *xdr, |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 6786 | struct nfs4_sequence_res *res) |
| 6787 | { |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 6788 | struct compound_hdr hdr; |
| 6789 | int status; |
| 6790 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6791 | status = decode_compound_hdr(xdr, &hdr); |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 6792 | if (!status) |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6793 | status = decode_sequence(xdr, res, rqstp); |
Andy Adamson | fc01cea | 2009-04-01 09:22:36 -0400 | [diff] [blame] | 6794 | return status; |
| 6795 | } |
| 6796 | |
| 6797 | /* |
Ricardo Labiaga | 8b17321 | 2009-12-05 16:08:39 -0500 | [diff] [blame] | 6798 | * Decode GET_LEASE_TIME response |
Andy Adamson | 2050f0c | 2009-04-01 09:22:30 -0400 | [diff] [blame] | 6799 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6800 | static int nfs4_xdr_dec_get_lease_time(struct rpc_rqst *rqstp, |
| 6801 | struct xdr_stream *xdr, |
Andy Adamson | 2050f0c | 2009-04-01 09:22:30 -0400 | [diff] [blame] | 6802 | struct nfs4_get_lease_time_res *res) |
| 6803 | { |
Andy Adamson | 2050f0c | 2009-04-01 09:22:30 -0400 | [diff] [blame] | 6804 | struct compound_hdr hdr; |
| 6805 | int status; |
| 6806 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6807 | status = decode_compound_hdr(xdr, &hdr); |
Andy Adamson | 2050f0c | 2009-04-01 09:22:30 -0400 | [diff] [blame] | 6808 | if (!status) |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6809 | status = decode_sequence(xdr, &res->lr_seq_res, rqstp); |
Andy Adamson | 2050f0c | 2009-04-01 09:22:30 -0400 | [diff] [blame] | 6810 | if (!status) |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6811 | status = decode_putrootfh(xdr); |
Andy Adamson | 2050f0c | 2009-04-01 09:22:30 -0400 | [diff] [blame] | 6812 | if (!status) |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6813 | status = decode_fsinfo(xdr, res->lr_fsinfo); |
Andy Adamson | 2050f0c | 2009-04-01 09:22:30 -0400 | [diff] [blame] | 6814 | return status; |
| 6815 | } |
Ricardo Labiaga | 18019753 | 2009-12-05 16:08:40 -0500 | [diff] [blame] | 6816 | |
| 6817 | /* |
| 6818 | * Decode RECLAIM_COMPLETE response |
| 6819 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6820 | static int nfs4_xdr_dec_reclaim_complete(struct rpc_rqst *rqstp, |
| 6821 | struct xdr_stream *xdr, |
Ricardo Labiaga | 18019753 | 2009-12-05 16:08:40 -0500 | [diff] [blame] | 6822 | struct nfs41_reclaim_complete_res *res) |
| 6823 | { |
Ricardo Labiaga | 18019753 | 2009-12-05 16:08:40 -0500 | [diff] [blame] | 6824 | struct compound_hdr hdr; |
| 6825 | int status; |
| 6826 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6827 | status = decode_compound_hdr(xdr, &hdr); |
Ricardo Labiaga | 18019753 | 2009-12-05 16:08:40 -0500 | [diff] [blame] | 6828 | if (!status) |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6829 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
Ricardo Labiaga | 18019753 | 2009-12-05 16:08:40 -0500 | [diff] [blame] | 6830 | if (!status) |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6831 | status = decode_reclaim_complete(xdr, (void *)NULL); |
Ricardo Labiaga | 18019753 | 2009-12-05 16:08:40 -0500 | [diff] [blame] | 6832 | return status; |
| 6833 | } |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 6834 | |
| 6835 | /* |
Andy Adamson | 7f11d8d | 2011-07-30 20:52:35 -0400 | [diff] [blame] | 6836 | * Decode GETDEVICELIST response |
| 6837 | */ |
| 6838 | static int nfs4_xdr_dec_getdevicelist(struct rpc_rqst *rqstp, |
| 6839 | struct xdr_stream *xdr, |
| 6840 | struct nfs4_getdevicelist_res *res) |
| 6841 | { |
| 6842 | struct compound_hdr hdr; |
| 6843 | int status; |
| 6844 | |
| 6845 | dprintk("encoding getdevicelist!\n"); |
| 6846 | |
| 6847 | status = decode_compound_hdr(xdr, &hdr); |
| 6848 | if (status != 0) |
| 6849 | goto out; |
| 6850 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
| 6851 | if (status != 0) |
| 6852 | goto out; |
| 6853 | status = decode_putfh(xdr); |
| 6854 | if (status != 0) |
| 6855 | goto out; |
| 6856 | status = decode_getdevicelist(xdr, res->devlist); |
| 6857 | out: |
| 6858 | return status; |
| 6859 | } |
| 6860 | |
| 6861 | /* |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 6862 | * Decode GETDEVINFO response |
| 6863 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6864 | static int nfs4_xdr_dec_getdeviceinfo(struct rpc_rqst *rqstp, |
| 6865 | struct xdr_stream *xdr, |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 6866 | struct nfs4_getdeviceinfo_res *res) |
| 6867 | { |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 6868 | struct compound_hdr hdr; |
| 6869 | int status; |
| 6870 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6871 | status = decode_compound_hdr(xdr, &hdr); |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 6872 | if (status != 0) |
| 6873 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6874 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 6875 | if (status != 0) |
| 6876 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6877 | status = decode_getdeviceinfo(xdr, res->pdev); |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 6878 | out: |
| 6879 | return status; |
| 6880 | } |
| 6881 | |
| 6882 | /* |
| 6883 | * Decode LAYOUTGET response |
| 6884 | */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6885 | static int nfs4_xdr_dec_layoutget(struct rpc_rqst *rqstp, |
| 6886 | struct xdr_stream *xdr, |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 6887 | struct nfs4_layoutget_res *res) |
| 6888 | { |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 6889 | struct compound_hdr hdr; |
| 6890 | int status; |
| 6891 | |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6892 | status = decode_compound_hdr(xdr, &hdr); |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 6893 | if (status) |
| 6894 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6895 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 6896 | if (status) |
| 6897 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6898 | status = decode_putfh(xdr); |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 6899 | if (status) |
| 6900 | goto out; |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 6901 | status = decode_layoutget(xdr, rqstp, res); |
Andy Adamson | b1f69b7 | 2010-10-20 00:18:03 -0400 | [diff] [blame] | 6902 | out: |
| 6903 | return status; |
| 6904 | } |
Andy Adamson | 863a3c6 | 2011-03-23 13:27:54 +0000 | [diff] [blame] | 6905 | |
| 6906 | /* |
Benny Halevy | cbe8260 | 2011-05-22 19:52:37 +0300 | [diff] [blame] | 6907 | * Decode LAYOUTRETURN response |
| 6908 | */ |
| 6909 | static int nfs4_xdr_dec_layoutreturn(struct rpc_rqst *rqstp, |
| 6910 | struct xdr_stream *xdr, |
| 6911 | struct nfs4_layoutreturn_res *res) |
| 6912 | { |
| 6913 | struct compound_hdr hdr; |
| 6914 | int status; |
| 6915 | |
| 6916 | status = decode_compound_hdr(xdr, &hdr); |
| 6917 | if (status) |
| 6918 | goto out; |
| 6919 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
| 6920 | if (status) |
| 6921 | goto out; |
| 6922 | status = decode_putfh(xdr); |
| 6923 | if (status) |
| 6924 | goto out; |
| 6925 | status = decode_layoutreturn(xdr, res); |
| 6926 | out: |
| 6927 | return status; |
| 6928 | } |
| 6929 | |
| 6930 | /* |
Andy Adamson | 863a3c6 | 2011-03-23 13:27:54 +0000 | [diff] [blame] | 6931 | * Decode LAYOUTCOMMIT response |
| 6932 | */ |
| 6933 | static int nfs4_xdr_dec_layoutcommit(struct rpc_rqst *rqstp, |
| 6934 | struct xdr_stream *xdr, |
| 6935 | struct nfs4_layoutcommit_res *res) |
| 6936 | { |
| 6937 | struct compound_hdr hdr; |
| 6938 | int status; |
| 6939 | |
| 6940 | status = decode_compound_hdr(xdr, &hdr); |
| 6941 | if (status) |
| 6942 | goto out; |
| 6943 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
| 6944 | if (status) |
| 6945 | goto out; |
| 6946 | status = decode_putfh(xdr); |
| 6947 | if (status) |
| 6948 | goto out; |
| 6949 | status = decode_layoutcommit(xdr, rqstp, res); |
| 6950 | if (status) |
| 6951 | goto out; |
Trond Myklebust | 6926afd1 | 2012-01-07 13:22:46 -0500 | [diff] [blame] | 6952 | decode_getfattr(xdr, res->fattr, res->server); |
Andy Adamson | 863a3c6 | 2011-03-23 13:27:54 +0000 | [diff] [blame] | 6953 | out: |
| 6954 | return status; |
| 6955 | } |
Bryan Schumaker | fca78d6 | 2011-06-02 14:59:07 -0400 | [diff] [blame] | 6956 | |
| 6957 | /* |
| 6958 | * Decode SECINFO_NO_NAME response |
| 6959 | */ |
| 6960 | static int nfs4_xdr_dec_secinfo_no_name(struct rpc_rqst *rqstp, |
| 6961 | struct xdr_stream *xdr, |
| 6962 | struct nfs4_secinfo_res *res) |
| 6963 | { |
| 6964 | struct compound_hdr hdr; |
| 6965 | int status; |
| 6966 | |
| 6967 | status = decode_compound_hdr(xdr, &hdr); |
| 6968 | if (status) |
| 6969 | goto out; |
| 6970 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
| 6971 | if (status) |
| 6972 | goto out; |
| 6973 | status = decode_putrootfh(xdr); |
| 6974 | if (status) |
| 6975 | goto out; |
| 6976 | status = decode_secinfo(xdr, res); |
| 6977 | out: |
| 6978 | return status; |
| 6979 | } |
Bryan Schumaker | 7d97479 | 2011-06-02 14:59:08 -0400 | [diff] [blame] | 6980 | |
| 6981 | /* |
| 6982 | * Decode TEST_STATEID response |
| 6983 | */ |
| 6984 | static int nfs4_xdr_dec_test_stateid(struct rpc_rqst *rqstp, |
| 6985 | struct xdr_stream *xdr, |
| 6986 | struct nfs41_test_stateid_res *res) |
| 6987 | { |
| 6988 | struct compound_hdr hdr; |
| 6989 | int status; |
| 6990 | |
| 6991 | status = decode_compound_hdr(xdr, &hdr); |
| 6992 | if (status) |
| 6993 | goto out; |
| 6994 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
| 6995 | if (status) |
| 6996 | goto out; |
| 6997 | status = decode_test_stateid(xdr, res); |
| 6998 | out: |
| 6999 | return status; |
| 7000 | } |
Bryan Schumaker | 9aeda35 | 2011-06-02 14:59:09 -0400 | [diff] [blame] | 7001 | |
| 7002 | /* |
| 7003 | * Decode FREE_STATEID response |
| 7004 | */ |
| 7005 | static int nfs4_xdr_dec_free_stateid(struct rpc_rqst *rqstp, |
| 7006 | struct xdr_stream *xdr, |
| 7007 | struct nfs41_free_stateid_res *res) |
| 7008 | { |
| 7009 | struct compound_hdr hdr; |
| 7010 | int status; |
| 7011 | |
| 7012 | status = decode_compound_hdr(xdr, &hdr); |
| 7013 | if (status) |
| 7014 | goto out; |
| 7015 | status = decode_sequence(xdr, &res->seq_res, rqstp); |
| 7016 | if (status) |
| 7017 | goto out; |
| 7018 | status = decode_free_stateid(xdr, res); |
| 7019 | out: |
| 7020 | return status; |
| 7021 | } |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 7022 | #endif /* CONFIG_NFS_V4_1 */ |
| 7023 | |
Chuck Lever | 573c4e1 | 2010-12-14 14:58:11 +0000 | [diff] [blame] | 7024 | /** |
| 7025 | * nfs4_decode_dirent - Decode a single NFSv4 directory entry stored in |
| 7026 | * the local page cache. |
| 7027 | * @xdr: XDR stream where entry resides |
| 7028 | * @entry: buffer to fill in with entry data |
| 7029 | * @plus: boolean indicating whether this should be a readdirplus entry |
| 7030 | * |
| 7031 | * Returns zero if successful, otherwise a negative errno value is |
| 7032 | * returned. |
| 7033 | * |
| 7034 | * This function is not invoked during READDIR reply decoding, but |
| 7035 | * rather whenever an application invokes the getdents(2) system call |
| 7036 | * on a directory already in our cache. |
| 7037 | */ |
| 7038 | int nfs4_decode_dirent(struct xdr_stream *xdr, struct nfs_entry *entry, |
| 7039 | int plus) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7040 | { |
Fred Isaman | dae100c | 2011-07-30 20:52:37 -0400 | [diff] [blame] | 7041 | uint32_t bitmap[3] = {0}; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7042 | uint32_t len; |
Bryan Schumaker | babddc7 | 2010-10-20 15:44:29 -0400 | [diff] [blame] | 7043 | __be32 *p = xdr_inline_decode(xdr, 4); |
| 7044 | if (unlikely(!p)) |
| 7045 | goto out_overflow; |
Chuck Lever | c08e76d | 2011-01-28 12:40:55 -0500 | [diff] [blame] | 7046 | if (*p == xdr_zero) { |
Bryan Schumaker | babddc7 | 2010-10-20 15:44:29 -0400 | [diff] [blame] | 7047 | p = xdr_inline_decode(xdr, 4); |
| 7048 | if (unlikely(!p)) |
| 7049 | goto out_overflow; |
Chuck Lever | c08e76d | 2011-01-28 12:40:55 -0500 | [diff] [blame] | 7050 | if (*p == xdr_zero) |
Chuck Lever | 573c4e1 | 2010-12-14 14:58:11 +0000 | [diff] [blame] | 7051 | return -EAGAIN; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7052 | entry->eof = 1; |
Chuck Lever | 573c4e1 | 2010-12-14 14:58:11 +0000 | [diff] [blame] | 7053 | return -EBADCOOKIE; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7054 | } |
| 7055 | |
Bryan Schumaker | babddc7 | 2010-10-20 15:44:29 -0400 | [diff] [blame] | 7056 | p = xdr_inline_decode(xdr, 12); |
| 7057 | if (unlikely(!p)) |
| 7058 | goto out_overflow; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7059 | entry->prev_cookie = entry->cookie; |
| 7060 | p = xdr_decode_hyper(p, &entry->cookie); |
Chuck Lever | c08e76d | 2011-01-28 12:40:55 -0500 | [diff] [blame] | 7061 | entry->len = be32_to_cpup(p); |
Bryan Schumaker | babddc7 | 2010-10-20 15:44:29 -0400 | [diff] [blame] | 7062 | |
Trond Myklebust | 9af8c22 | 2010-10-24 11:52:55 -0400 | [diff] [blame] | 7063 | p = xdr_inline_decode(xdr, entry->len); |
Bryan Schumaker | babddc7 | 2010-10-20 15:44:29 -0400 | [diff] [blame] | 7064 | if (unlikely(!p)) |
| 7065 | goto out_overflow; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7066 | entry->name = (const char *) p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7067 | |
| 7068 | /* |
| 7069 | * In case the server doesn't return an inode number, |
| 7070 | * we fake one here. (We don't use inode number 0, |
| 7071 | * since glibc seems to choke on it...) |
| 7072 | */ |
| 7073 | entry->ino = 1; |
Trond Myklebust | 4f08222 | 2010-10-24 13:14:02 -0400 | [diff] [blame] | 7074 | entry->fattr->valid = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7075 | |
Trond Myklebust | 9af8c22 | 2010-10-24 11:52:55 -0400 | [diff] [blame] | 7076 | if (decode_attr_bitmap(xdr, bitmap) < 0) |
Bryan Schumaker | babddc7 | 2010-10-20 15:44:29 -0400 | [diff] [blame] | 7077 | goto out_overflow; |
Trond Myklebust | 9af8c22 | 2010-10-24 11:52:55 -0400 | [diff] [blame] | 7078 | |
| 7079 | if (decode_attr_length(xdr, &len, &p) < 0) |
| 7080 | goto out_overflow; |
| 7081 | |
Chuck Lever | 573c4e1 | 2010-12-14 14:58:11 +0000 | [diff] [blame] | 7082 | if (decode_getfattr_attrs(xdr, bitmap, entry->fattr, entry->fh, |
Trond Myklebust | 8b7e3f4 | 2012-01-30 15:43:56 -0500 | [diff] [blame] | 7083 | NULL, entry->server) < 0) |
Trond Myklebust | 9af8c22 | 2010-10-24 11:52:55 -0400 | [diff] [blame] | 7084 | goto out_overflow; |
Trond Myklebust | 28331a4 | 2011-04-27 13:47:52 -0400 | [diff] [blame] | 7085 | if (entry->fattr->valid & NFS_ATTR_FATTR_MOUNTED_ON_FILEID) |
| 7086 | entry->ino = entry->fattr->mounted_on_fileid; |
| 7087 | else if (entry->fattr->valid & NFS_ATTR_FATTR_FILEID) |
Trond Myklebust | 9af8c22 | 2010-10-24 11:52:55 -0400 | [diff] [blame] | 7088 | entry->ino = entry->fattr->fileid; |
| 7089 | |
Trond Myklebust | 0b26a0b | 2010-11-20 14:26:44 -0500 | [diff] [blame] | 7090 | entry->d_type = DT_UNKNOWN; |
| 7091 | if (entry->fattr->valid & NFS_ATTR_FATTR_TYPE) |
| 7092 | entry->d_type = nfs_umode_to_dtype(entry->fattr->mode); |
| 7093 | |
Chuck Lever | 573c4e1 | 2010-12-14 14:58:11 +0000 | [diff] [blame] | 7094 | return 0; |
Bryan Schumaker | babddc7 | 2010-10-20 15:44:29 -0400 | [diff] [blame] | 7095 | |
| 7096 | out_overflow: |
| 7097 | print_overflow_msg(__func__, xdr); |
Chuck Lever | 573c4e1 | 2010-12-14 14:58:11 +0000 | [diff] [blame] | 7098 | return -EAGAIN; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7099 | } |
| 7100 | |
| 7101 | /* |
| 7102 | * We need to translate between nfs status return values and |
| 7103 | * the local errno values which may not be the same. |
| 7104 | */ |
| 7105 | static struct { |
| 7106 | int stat; |
| 7107 | int errno; |
| 7108 | } nfs_errtbl[] = { |
| 7109 | { NFS4_OK, 0 }, |
Benny Halevy | 856dff3 | 2008-03-31 17:39:06 +0300 | [diff] [blame] | 7110 | { NFS4ERR_PERM, -EPERM }, |
| 7111 | { NFS4ERR_NOENT, -ENOENT }, |
| 7112 | { NFS4ERR_IO, -errno_NFSERR_IO}, |
| 7113 | { NFS4ERR_NXIO, -ENXIO }, |
| 7114 | { NFS4ERR_ACCESS, -EACCES }, |
| 7115 | { NFS4ERR_EXIST, -EEXIST }, |
| 7116 | { NFS4ERR_XDEV, -EXDEV }, |
| 7117 | { NFS4ERR_NOTDIR, -ENOTDIR }, |
| 7118 | { NFS4ERR_ISDIR, -EISDIR }, |
| 7119 | { NFS4ERR_INVAL, -EINVAL }, |
| 7120 | { NFS4ERR_FBIG, -EFBIG }, |
| 7121 | { NFS4ERR_NOSPC, -ENOSPC }, |
| 7122 | { NFS4ERR_ROFS, -EROFS }, |
| 7123 | { NFS4ERR_MLINK, -EMLINK }, |
| 7124 | { NFS4ERR_NAMETOOLONG, -ENAMETOOLONG }, |
| 7125 | { NFS4ERR_NOTEMPTY, -ENOTEMPTY }, |
| 7126 | { NFS4ERR_DQUOT, -EDQUOT }, |
| 7127 | { NFS4ERR_STALE, -ESTALE }, |
| 7128 | { NFS4ERR_BADHANDLE, -EBADHANDLE }, |
Benny Halevy | 856dff3 | 2008-03-31 17:39:06 +0300 | [diff] [blame] | 7129 | { NFS4ERR_BAD_COOKIE, -EBADCOOKIE }, |
| 7130 | { NFS4ERR_NOTSUPP, -ENOTSUPP }, |
| 7131 | { NFS4ERR_TOOSMALL, -ETOOSMALL }, |
Trond Myklebust | fdcb457 | 2010-02-08 09:32:40 -0500 | [diff] [blame] | 7132 | { NFS4ERR_SERVERFAULT, -EREMOTEIO }, |
Benny Halevy | 856dff3 | 2008-03-31 17:39:06 +0300 | [diff] [blame] | 7133 | { NFS4ERR_BADTYPE, -EBADTYPE }, |
| 7134 | { NFS4ERR_LOCKED, -EAGAIN }, |
Benny Halevy | 856dff3 | 2008-03-31 17:39:06 +0300 | [diff] [blame] | 7135 | { NFS4ERR_SYMLINK, -ELOOP }, |
| 7136 | { NFS4ERR_OP_ILLEGAL, -EOPNOTSUPP }, |
| 7137 | { NFS4ERR_DEADLOCK, -EDEADLK }, |
Benny Halevy | 856dff3 | 2008-03-31 17:39:06 +0300 | [diff] [blame] | 7138 | { -1, -EIO } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7139 | }; |
| 7140 | |
| 7141 | /* |
| 7142 | * Convert an NFS error code to a local one. |
| 7143 | * This one is used jointly by NFSv2 and NFSv3. |
| 7144 | */ |
| 7145 | static int |
David Howells | 0a8ea43 | 2006-08-22 20:06:08 -0400 | [diff] [blame] | 7146 | nfs4_stat_to_errno(int stat) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7147 | { |
| 7148 | int i; |
| 7149 | for (i = 0; nfs_errtbl[i].stat != -1; i++) { |
| 7150 | if (nfs_errtbl[i].stat == stat) |
| 7151 | return nfs_errtbl[i].errno; |
| 7152 | } |
| 7153 | if (stat <= 10000 || stat > 10100) { |
| 7154 | /* The server is looney tunes. */ |
Trond Myklebust | fdcb457 | 2010-02-08 09:32:40 -0500 | [diff] [blame] | 7155 | return -EREMOTEIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7156 | } |
| 7157 | /* If we cannot translate the error, the recovery routines should |
| 7158 | * handle it. |
| 7159 | * Note: remaining NFSv4 error codes have values > 10000, so should |
| 7160 | * not conflict with native Linux error codes. |
| 7161 | */ |
Benny Halevy | 856dff3 | 2008-03-31 17:39:06 +0300 | [diff] [blame] | 7162 | return -stat; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7163 | } |
| 7164 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7165 | #define PROC(proc, argtype, restype) \ |
| 7166 | [NFSPROC4_CLNT_##proc] = { \ |
| 7167 | .p_proc = NFSPROC4_COMPOUND, \ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 7168 | .p_encode = (kxdreproc_t)nfs4_xdr_##argtype, \ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 7169 | .p_decode = (kxdrdproc_t)nfs4_xdr_##restype, \ |
Chuck Lever | 2bea90d | 2007-03-29 16:47:53 -0400 | [diff] [blame] | 7170 | .p_arglen = NFS4_##argtype##_sz, \ |
| 7171 | .p_replen = NFS4_##restype##_sz, \ |
Chuck Lever | cc0175c | 2006-03-20 13:44:22 -0500 | [diff] [blame] | 7172 | .p_statidx = NFSPROC4_CLNT_##proc, \ |
| 7173 | .p_name = #proc, \ |
Andy Adamson | 05d564f | 2008-12-23 16:06:15 -0500 | [diff] [blame] | 7174 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7175 | |
| 7176 | struct rpc_procinfo nfs4_procedures[] = { |
Chuck Lever | 7d93bd71 | 2010-12-14 14:57:42 +0000 | [diff] [blame] | 7177 | PROC(READ, enc_read, dec_read), |
| 7178 | PROC(WRITE, enc_write, dec_write), |
| 7179 | PROC(COMMIT, enc_commit, dec_commit), |
| 7180 | PROC(OPEN, enc_open, dec_open), |
| 7181 | PROC(OPEN_CONFIRM, enc_open_confirm, dec_open_confirm), |
| 7182 | PROC(OPEN_NOATTR, enc_open_noattr, dec_open_noattr), |
| 7183 | PROC(OPEN_DOWNGRADE, enc_open_downgrade, dec_open_downgrade), |
| 7184 | PROC(CLOSE, enc_close, dec_close), |
| 7185 | PROC(SETATTR, enc_setattr, dec_setattr), |
| 7186 | PROC(FSINFO, enc_fsinfo, dec_fsinfo), |
| 7187 | PROC(RENEW, enc_renew, dec_renew), |
| 7188 | PROC(SETCLIENTID, enc_setclientid, dec_setclientid), |
| 7189 | PROC(SETCLIENTID_CONFIRM, enc_setclientid_confirm, dec_setclientid_confirm), |
| 7190 | PROC(LOCK, enc_lock, dec_lock), |
| 7191 | PROC(LOCKT, enc_lockt, dec_lockt), |
| 7192 | PROC(LOCKU, enc_locku, dec_locku), |
| 7193 | PROC(ACCESS, enc_access, dec_access), |
| 7194 | PROC(GETATTR, enc_getattr, dec_getattr), |
| 7195 | PROC(LOOKUP, enc_lookup, dec_lookup), |
| 7196 | PROC(LOOKUP_ROOT, enc_lookup_root, dec_lookup_root), |
| 7197 | PROC(REMOVE, enc_remove, dec_remove), |
| 7198 | PROC(RENAME, enc_rename, dec_rename), |
| 7199 | PROC(LINK, enc_link, dec_link), |
| 7200 | PROC(SYMLINK, enc_symlink, dec_symlink), |
| 7201 | PROC(CREATE, enc_create, dec_create), |
| 7202 | PROC(PATHCONF, enc_pathconf, dec_pathconf), |
| 7203 | PROC(STATFS, enc_statfs, dec_statfs), |
| 7204 | PROC(READLINK, enc_readlink, dec_readlink), |
| 7205 | PROC(READDIR, enc_readdir, dec_readdir), |
| 7206 | PROC(SERVER_CAPS, enc_server_caps, dec_server_caps), |
| 7207 | PROC(DELEGRETURN, enc_delegreturn, dec_delegreturn), |
| 7208 | PROC(GETACL, enc_getacl, dec_getacl), |
| 7209 | PROC(SETACL, enc_setacl, dec_setacl), |
| 7210 | PROC(FS_LOCATIONS, enc_fs_locations, dec_fs_locations), |
| 7211 | PROC(RELEASE_LOCKOWNER, enc_release_lockowner, dec_release_lockowner), |
Bryan Schumaker | 5a5ea0d | 2011-03-24 17:12:29 +0000 | [diff] [blame] | 7212 | PROC(SECINFO, enc_secinfo, dec_secinfo), |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 7213 | #if defined(CONFIG_NFS_V4_1) |
Chuck Lever | 7d93bd71 | 2010-12-14 14:57:42 +0000 | [diff] [blame] | 7214 | PROC(EXCHANGE_ID, enc_exchange_id, dec_exchange_id), |
| 7215 | PROC(CREATE_SESSION, enc_create_session, dec_create_session), |
| 7216 | PROC(DESTROY_SESSION, enc_destroy_session, dec_destroy_session), |
| 7217 | PROC(SEQUENCE, enc_sequence, dec_sequence), |
| 7218 | PROC(GET_LEASE_TIME, enc_get_lease_time, dec_get_lease_time), |
| 7219 | PROC(RECLAIM_COMPLETE, enc_reclaim_complete, dec_reclaim_complete), |
| 7220 | PROC(GETDEVICEINFO, enc_getdeviceinfo, dec_getdeviceinfo), |
| 7221 | PROC(LAYOUTGET, enc_layoutget, dec_layoutget), |
Andy Adamson | 863a3c6 | 2011-03-23 13:27:54 +0000 | [diff] [blame] | 7222 | PROC(LAYOUTCOMMIT, enc_layoutcommit, dec_layoutcommit), |
Benny Halevy | cbe8260 | 2011-05-22 19:52:37 +0300 | [diff] [blame] | 7223 | PROC(LAYOUTRETURN, enc_layoutreturn, dec_layoutreturn), |
Bryan Schumaker | fca78d6 | 2011-06-02 14:59:07 -0400 | [diff] [blame] | 7224 | PROC(SECINFO_NO_NAME, enc_secinfo_no_name, dec_secinfo_no_name), |
Bryan Schumaker | 7d97479 | 2011-06-02 14:59:08 -0400 | [diff] [blame] | 7225 | PROC(TEST_STATEID, enc_test_stateid, dec_test_stateid), |
Bryan Schumaker | 9aeda35 | 2011-06-02 14:59:09 -0400 | [diff] [blame] | 7226 | PROC(FREE_STATEID, enc_free_stateid, dec_free_stateid), |
Andy Adamson | 7f11d8d | 2011-07-30 20:52:35 -0400 | [diff] [blame] | 7227 | PROC(GETDEVICELIST, enc_getdevicelist, dec_getdevicelist), |
Benny Halevy | 99fe60d | 2009-04-01 09:22:29 -0400 | [diff] [blame] | 7228 | #endif /* CONFIG_NFS_V4_1 */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7229 | }; |
| 7230 | |
Trond Myklebust | a613fa1 | 2012-01-20 13:53:56 -0500 | [diff] [blame] | 7231 | const struct rpc_version nfs_version4 = { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7232 | .number = 4, |
Tobias Klauser | e8c96f8 | 2006-03-24 03:15:34 -0800 | [diff] [blame] | 7233 | .nrprocs = ARRAY_SIZE(nfs4_procedures), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7234 | .procs = nfs4_procedures |
| 7235 | }; |
| 7236 | |
| 7237 | /* |
| 7238 | * Local variables: |
| 7239 | * c-basic-offset: 8 |
| 7240 | * End: |
| 7241 | */ |